[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC 5/6] libxl: Handle Linux stubdomain specifique QEMU option.



There is few things that are not possible for now in the stubdomain, the
QMP socket and graphique output, and few other things that are handled
in an other way. This patch try to fix the command line passed to the
QEMU in the Linux stubdomain.

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 tools/libxl/libxl_dm.c | 71 ++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 52 insertions(+), 19 deletions(-)

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index d10a58f..6180a01 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -19,9 +19,12 @@
 
 #include "libxl_internal.h"
 
-static const char *libxl_tapif_script(libxl__gc *gc)
+static const char *libxl_tapif_script(libxl__gc *gc,
+                                      const libxl_domain_build_info *info)
 {
 #ifdef __linux__
+    if (info->stubdomain_version == LIBXL_STUBDOMAIN_VERSION_LINUX)
+        return libxl__sprintf(gc, "/etc/qemu-ifup");
     return libxl__strdup(gc, "no");
 #else
     return libxl__sprintf(gc, "%s/qemu-ifup", libxl__xen_script_dir_path());
@@ -257,8 +260,8 @@ static char ** libxl__build_device_model_args_old(libxl__gc 
*gc,
                                       "tap,vlan=%d,ifname=%s,bridge=%s,"
                                       "script=%s,downscript=%s",
                                       nics[i].devid, ifname, nics[i].bridge,
-                                      libxl_tapif_script(gc),
-                                      libxl_tapif_script(gc)),
+                                      libxl_tapif_script(gc, b_info),
+                                      libxl_tapif_script(gc, b_info)),
                                   NULL);
                 ioemu_nics++;
             }
@@ -372,14 +375,17 @@ static char ** 
libxl__build_device_model_args_new(libxl__gc *gc,
                       "-xen-domid",
                       libxl__sprintf(gc, "%d", guest_domid), NULL);
 
-    flexarray_append(dm_args, "-chardev");
-    flexarray_append(dm_args,
-                     libxl__sprintf(gc, "socket,id=libxl-cmd,"
-                                    "path=%s/qmp-libxl-%d,server,nowait",
-                                    libxl__run_dir_path(), guest_domid));
+    /* There is currently no way to access the QMP socket in the stubdom */
+    if (!libxl_defbool_val(b_info->device_model_stubdomain)) {
+        flexarray_append(dm_args, "-chardev");
+        flexarray_append(dm_args,
+                         libxl__sprintf(gc, "socket,id=libxl-cmd,"
+                                        "path=%s/qmp-libxl-%d,server,nowait",
+                                        libxl__run_dir_path(), guest_domid));
 
-    flexarray_append(dm_args, "-mon");
-    flexarray_append(dm_args, "chardev=libxl-cmd,mode=control");
+        flexarray_append(dm_args, "-mon");
+        flexarray_append(dm_args, "chardev=libxl-cmd,mode=control");
+    }
 
     if (b_info->type == LIBXL_DOMAIN_TYPE_PV) {
         flexarray_append(dm_args, "-xen-attach");
@@ -556,8 +562,8 @@ static char ** libxl__build_device_model_args_new(libxl__gc 
*gc,
                                           "type=tap,id=net%d,ifname=%s,"
                                           "script=%s,downscript=%s",
                                           nics[i].devid, ifname,
-                                          libxl_tapif_script(gc),
-                                          libxl_tapif_script(gc)));
+                                          libxl_tapif_script(gc, b_info),
+                                          libxl_tapif_script(gc, b_info)));
                 ioemu_nics++;
             }
         }
@@ -622,6 +628,10 @@ static char ** 
libxl__build_device_model_args_new(libxl__gc *gc,
                     drive = libxl__sprintf
                         (gc, 
"if=ide,index=%d,media=cdrom,cache=writeback,id=ide-%i",
                          disk, dev_number);
+                else if (b_info->stubdomain_version == 
LIBXL_STUBDOMAIN_VERSION_LINUX)
+                    drive = libxl__sprintf
+                        (gc, 
"file=%s,if=ide,index=%d,media=cdrom,cache=writeback,format=%s,id=ide-%i",
+                                "/dev/xvdc", disk, "host_cdrom", dev_number);
                 else
                     drive = libxl__sprintf
                         (gc, 
"file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback,id=ide-%i",
@@ -650,9 +660,14 @@ static char ** 
libxl__build_device_model_args_new(libxl__gc *gc,
                         (gc, 
"file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=writeback",
                          disks[i].pdev_path, disk, format);
                 else if (disk < 4)
-                    drive = libxl__sprintf
-                        (gc, 
"file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",
-                         disks[i].pdev_path, disk, format);
+                    if (b_info->stubdomain_version == 
LIBXL_STUBDOMAIN_VERSION_LINUX)
+                        drive = libxl__sprintf
+                                (gc, 
"file=%s,if=ide,index=%d,media=disk,cache=writeback,format=%s",
+                                "/dev/xvda", disk, "host_device");
+                    else
+                        drive = libxl__sprintf
+                                (gc, 
"file=%s,if=ide,index=%d,media=disk,cache=writeback,format=%s",
+                                disks[i].pdev_path, disk, format);
                 else
                     continue; /* Do not emulate this disk */
             }
@@ -733,7 +748,7 @@ static int 
libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,
 
 static int libxl__write_stub_dmargs(libxl__gc *gc,
                                     int dm_domid, int guest_domid,
-                                    char **args)
+                                    char **args, bool linux_stubdom)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int i;
@@ -761,10 +776,28 @@ static int libxl__write_stub_dmargs(libxl__gc *gc,
     i = 1;
     dmargs[0] = '\0';
     while (args[i] != NULL) {
-        if (strcmp(args[i], "-sdl") && strcmp(args[i], "-M") && 
strcmp(args[i], "xenfv")) {
-            strcat(dmargs, " ");
-            strcat(dmargs, args[i]);
+        if (!linux_stubdom) {
+            if (!(strcmp(args[i], "-sdl") && strcmp(args[i], "-M") && 
strcmp(args[i], "xenfv"))) {
+                i++;
+                continue;
+            }
+        } else {
+            if (!strcmp(args[i], "-sdl")) {
+                i++;
+                continue;
+            }
+            if (!strcmp(args[i], "-incoming")
+                || !strcmp(args[i], "-vnc")
+                || !strcmp(args[i], "-vga")) {
+                i += 2;
+                continue;
+            }
+            if (!strcmp(args[i], "-serial")) {
+                args[i+1] = "/dev/hvc1";
+            }
         }
+        strcat(dmargs, " ");
+        strcat(dmargs, args[i]);
         i++;
     }
     path = libxl__sprintf(gc, "%s/image/dmargs", vm_path);
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.