qemu: support multiple pv consoles for hvm guests too
This patch allows qemu to provide pv console backends for hvm guests too:
- initialize the pv console backends when emulating a "xen_fv" machine;
- separate the pv consoles and emulated serials on xenstore: pv
consoles use the console prefix and emulated serials use the serial
prefix;
- read the "output" node on xenstore to know where the output of a pv
console has to go.
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
diff --git a/hw/xen_console.c b/hw/xen_console.c
index a4e97ca..73b8bc8 100644
--- a/hw/xen_console.c
+++ b/hw/xen_console.c
@@ -181,7 +181,7 @@ static void xencons_send(struct XenConsole *con)
static int con_init(struct XenDevice *xendev)
{
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
- char *type, *dom;
+ char *type, *dom, *output, label[32];
/* setup */
dom = xs_get_domain_path(xenstore, con->xendev.dom);
@@ -200,11 +200,13 @@ static int con_init(struct XenDevice *xendev)
}
qemu_free(type);
- if (!serial_hds[con->xendev.dev])
- xen_be_printf(xendev, 1, "WARNING: serial line %d not configured\n",
- con->xendev.dev);
- else
- con->chr = serial_hds[con->xendev.dev];
+ output = xenstore_read_str(con->console, "output");
+ /* output is a pty by default */
+ if (output == NULL)
+ output = "pty";
+ snprintf(label, sizeof(label), "xencons%d", con->xendev.dev);
+ con->chr = qemu_chr_open(label, output, NULL);
+ xenstore_store_pv_console_info(con->xendev.dev, con->chr, output);
return 0;
}
diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
index d02e23f..79880a8 100644
--- a/hw/xen_machine_fv.c
+++ b/hw/xen_machine_fv.c
@@ -29,6 +29,7 @@
#include "exec-all.h"
#include "qemu-xen.h"
#include "qemu-aio.h"
+#include "xen_backend.h"
#include <xen/hvm/params.h>
#include <sys/mman.h>
@@ -361,6 +362,12 @@ static void xen_init_fv(ram_addr_t ram_size, int
vga_ram_size,
timeoffset_get();
+ /* Initialize backend core & drivers */
+ if (xen_be_init() != 0) {
+ fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
+ exit(1);
+ }
+ xen_be_register("console", &xen_console_ops);
pc_machine.init(ram_size, vga_ram_size, boot_device,
kernel_filename, kernel_cmdline, initrd_filename,
diff --git a/xen-config-host.h b/xen-config-host.h
index 9526bb9..f50c3aa 100644
--- a/xen-config-host.h
+++ b/xen-config-host.h
@@ -39,6 +39,8 @@ extern uint32_t vcpu_avail[];
struct CharDriverState;
void xenstore_store_serial_port_info(int i, struct CharDriverState *chr,
const char *devname);
+void xenstore_store_pv_console_info(int i, struct CharDriverState *chr,
+ const char *devname);
extern unsigned int xen_logdirty_enable;
diff --git a/xenstore.c b/xenstore.c
index 4a35f55..6d24613 100644
--- a/xenstore.c
+++ b/xenstore.c
@@ -1567,8 +1567,19 @@ void xenstore_store_serial_port_info(int i,
CharDriverState *chr,
snprintf(buf, sizeof(buf), "/serial/%d", i);
store_dev_info(devname, domid, chr, buf);
- if (i == 0) /* serial 0 is also called the console */
- store_dev_info(devname, domid, chr, "/console");
+}
+
+void xenstore_store_pv_console_info(int i, CharDriverState *chr,
+ const char *devname) {
+ char buf[32];
+
+ if (i == 0) {
+ snprintf(buf, sizeof(buf), "/console", i);
+ store_dev_info(devname, domid, chr, buf);
+ } else {
+ snprintf(buf, sizeof(buf), "/device/console/%d", i);
+ store_dev_info(devname, domid, chr, buf);
+ }
}
char *xenstore_dom_read(int domid, const char *key, unsigned int *len)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|