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

Re: [Xen-devel] Upstream QEMU not working with Xen unstable, lacks optio

On Fri, 2011-05-06 at 09:20 +0100, Wei Liu wrote:
> On Fri, May 6, 2011 at 3:54 PM, Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx> 
> wrote:
> >
> > Can you post your actual config file?
> >
> > I use both vnclisten = '0.0.0.0' and serial = 'pty' in my config files
> > and xl behaves as expected for me.
> >
> > Ian.
> >
> >
> 
> My first vnc config used with xm, which is taken from xen examples:
> 
> vfb = [ 'vnc=1,vnclisten=0.0.0.0,vncunused=1']
> 
> Later I found out this is not for HVM. So I change to:
> 
> vnc=1
> vnclisten='0.0.0.0'
> 
> It solves the vnc problem.

Great.

> 
> As for serial, I use serial='pty', too. It works fine with qemu-dm
> from xen-tools. However, it is not working when I use upstream QEMU.
> The upstream QEMU doesn't write anything in
> /local/domain/DOMID/serial/0/tty . If I manually write this entry, xl
> console will work as expected.

Oh, yes, I use the following local patch and had forgotten about it, not
sure how upstreamable it is, perhaps we might need to get libxl to query
this via QMP and write the result itself or something.

Ian.

diff --git a/hw/xen.h b/hw/xen.h
index adc32f7..b46a02c 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -9,6 +9,7 @@
 #include <inttypes.h>
 
 #include "qemu-common.h"
+#include "qemu-option.h"
 
 /* xen-machine.c */
 enum xen_mode {
@@ -57,4 +58,6 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size);
 #  define HVM_MAX_VCPUS 32
 #endif
 
+void xenstore_store_serial_port_info(CharDriverState *chr, QemuOpts *opts);
+
 #endif /* QEMU_HW_XEN_H */
diff --git a/qemu-char.c b/qemu-char.c
index 03858d4..0870cc8 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -31,6 +31,7 @@
 #include "hw/usb.h"
 #include "hw/baum.h"
 #include "hw/msmouse.h"
+#include "hw/xen.h"
 #include "qemu-objects.h"
 
 #include <unistd.h>
@@ -1007,6 +1008,8 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)
 
     s->timer = qemu_new_timer_ms(rt_clock, pty_chr_timer, chr);
 
+    xenstore_store_serial_port_info(chr, opts);
+
     return chr;
 }
 
diff --git a/xen-all.c b/xen-all.c
index 12258ef..a84b725 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -579,3 +579,85 @@ void destroy_hvm_domain(void)
         xc_interface_close(xc_handle);
     }
 }
+
+/*
+ * Create a store entry for a device (e.g., monitor, serial/parallel lines).
+ * The entry is <domain-path><storeString>/tty and the value is the name
+ * of the pty associated with the device.
+ */
+static int store_dev_info(const char *id,
+                         CharDriverState *chr,
+                         const char *storeString,
+                         const char *storeVal)
+{
+#ifdef CONFIG_STUBDOM
+    fprintf(stderr, "can't store dev %s name for domid %d in %s from a stub 
domain\n", devName, xen_domid, storeString);
+    return ENOSYS;
+#else
+    xc_interface *xc_handle;
+    struct xs_handle *xs;
+    char *path, *newpath;
+
+    xs = xs_daemon_open();
+    if (xs == NULL) {
+        fprintf(stderr, "Could not contact XenStore\n");
+        return -1;
+    }
+
+    xc_handle = xc_interface_open(0,0,0);
+    if (xc_handle == NULL) {
+        fprintf(stderr, "xc_interface_open() error\n");
+        return -1;
+    }
+
+    path = xs_get_domain_path(xs, xen_domid);
+    if (path == NULL) {
+        fprintf(stderr, "xs_get_domain_path() error\n");
+        return -1;
+    }
+    newpath = realloc(path, (strlen(path) + strlen(storeString) +
+                             strlen("/tty") + 1));
+    if (newpath == NULL) {
+        free(path); /* realloc errors leave old block */
+        fprintf(stderr, "realloc error\n");
+        return -1;
+    }
+    path = newpath;
+
+    strcat(path, storeString);
+    strcat(path, "/tty");
+    if (!xs_write(xs, XBT_NULL, path, storeVal, strlen(storeVal))) {
+        fprintf(stderr, "xs_write for '%s' fail", storeString);
+        return -1;
+    }
+
+    free(path);
+    xs_daemon_close(xs);
+    xc_interface_close(xc_handle);
+
+    return 0;
+#endif
+}
+
+void xenstore_store_serial_port_info(CharDriverState *chr, QemuOpts *opts) {
+    char path[16];
+    const char *id;
+    const char *backend;
+    const char *pty;
+    int i;
+
+    backend = qemu_opt_get(opts, "backend");
+    if (!backend || strcmp(backend, "pty") != 0) return;
+
+    id = qemu_opts_id(opts);
+    if (!id) return;
+
+    if (sscanf(id, "serial%d", &i) != 1)
+           return;
+
+    pty = qemu_opt_get(opts, "path");
+    if (!pty) return;
+
+    snprintf(path, sizeof(path), "/serial/%d", i);
+    store_dev_info(id, chr, path, pty);
+}




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel