]> xenbits.xensource.com Git - qemu-xen-unstable.git/commitdiff
support multiple pv consoles for hvm guests too
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 16 Aug 2010 12:29:36 +0000 (13:29 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 16 Aug 2010 12:29:36 +0000 (13:29 +0100)
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@eu.citrix.com>
hw/xen_console.c
hw/xen_machine_fv.c
xen-config-host.h
xenstore.c

index a4e97caeb9294589d4be5c0cc35cc71a30bab53f..545caa7cf1e395c6250d329a16c25d125a929d4f 100644 (file)
@@ -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;
 }
index d02e23f4a6f22e63e7e3b69fcfa651be48ddb587..79880a858ae986eea719d808d90b96a7318a38ca 100644 (file)
@@ -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,
index 9526bb9f65333d3aa73d329e5debe85d1f468870..f50c3aa56d98f13f19e559d9981ad1f634a78bb3 100644 (file)
@@ -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;
 
index 4a35f55ffabaf2d65cbb7923e23f1c6095e30b1f..6d246132a1411ebe50c8522afb92ecad59e045e2 100644 (file)
@@ -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)