WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 4 of 4] qemu: support multiple pv consoles for hvm gu

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 4 of 4] qemu: support multiple pv consoles for hvm guests too
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Fri, 13 Aug 2010 19:53:10 +0100
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Delivery-date: Fri, 13 Aug 2010 11:56:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
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

<Prev in Thread] Current Thread [Next in Thread>