All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Shelton <eshelton@pobox.com>
To: xen-devel@lists.xensource.com
Cc: anthony.perard@citrix.com, Eric Shelton <eshelton@pobox.com>,
	Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com
Subject: [RFC 5/7] libxl: Handle Linux stubdomain specific QEMU options.
Date: Tue,  3 Feb 2015 23:06:13 -0500	[thread overview]
Message-ID: <1423022775-7132-6-git-send-email-eshelton@pobox.com> (raw)
In-Reply-To: <1423022775-7132-1-git-send-email-eshelton@pobox.com>

This patch creates an appropriate command line for the QEMU instance
running in a Linux-based stubdomain.

NOTE: a number of items are not currently implemented for Linux-based
stubdomains, such as:
- save/restore
- QMP socket
- graphics output (e.g., VNC)

Signed-off-by: Eric Shelton <eshelton@pobox.com>
---
 tools/libxl/libxl_dm.c | 86 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 58 insertions(+), 28 deletions(-)

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 8599a6a..68d5886 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -20,9 +20,12 @@
 #include "libxl_internal.h"
 #include <xen/hvm/e820.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)
 {
 #if defined(__linux__) || defined(__FreeBSD__)
+    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());
@@ -307,8 +310,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++;
             }
@@ -430,6 +433,7 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
     int i, connection, devid;
     uint64_t ram_size;
     const char *path, *chardev;
+    bool is_stubdom = libxl_defbool_val(b_info->device_model_stubdomain);
 
     dm_args = flexarray_make(gc, 16, 1);
 
@@ -437,15 +441,18 @@ 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));
-
-    flexarray_append(dm_args, "-no-shutdown");
-    flexarray_append(dm_args, "-mon");
-    flexarray_append(dm_args, "chardev=libxl-cmd,mode=control");
+    /* There is currently no way to access the QMP socket in the stubdom */
+    if (!is_stubdom) {
+        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, "-no-shutdown");
+        flexarray_append(dm_args, "-mon");
+        flexarray_append(dm_args, "chardev=libxl-cmd,mode=control");
+    }
 
     for (i = 0; i < guest_config->num_channels; i++) {
         connection = guest_config->channels[i].connection;
@@ -483,7 +490,7 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
         flexarray_vappend(dm_args, "-name", c_info->name, NULL);
     }
 
-    if (vnc) {
+    if (vnc && !is_stubdom) {
         char *vncarg = NULL;
 
         flexarray_append(dm_args, "-vnc");
@@ -524,7 +531,7 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
         flexarray_append(dm_args, vncarg);
     }
 
-    if (sdl) {
+    if (sdl && !is_stubdom) {
         flexarray_append(dm_args, "-sdl");
         /* XXX sdl->{display,xauthority} into $DISPLAY/$XAUTHORITY */
     }
@@ -552,10 +559,19 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                 return NULL;
             }
             if (b_info->u.hvm.serial) {
-                flexarray_vappend(dm_args,
-                                  "-serial", b_info->u.hvm.serial, NULL);
+                if (is_stubdom) {
+                    flexarray_vappend(dm_args,
+                                      "-serial", "/dev/hvc1", NULL);
+                } else {
+                    flexarray_vappend(dm_args,
+                                      "-serial", b_info->u.hvm.serial, NULL);
+                }
             } else if (b_info->u.hvm.serial_list) {
                 char **p;
+                if (is_stubdom) {
+                    flexarray_vappend(dm_args,
+                                      "-serial", "/dev/hvc1", NULL);
+                }
                 for (p = b_info->u.hvm.serial_list;
                      *p;
                      p++) {
@@ -570,7 +586,7 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
             flexarray_append(dm_args, "-nographic");
         }
 
-        if (libxl_defbool_val(b_info->u.hvm.spice.enable)) {
+        if (libxl_defbool_val(b_info->u.hvm.spice.enable) && !is_stubdom) {
             const libxl_spice_info *spice = &b_info->u.hvm.spice;
             char *spiceoptions = dm_spice_options(gc, spice);
             if (!spiceoptions)
@@ -700,8 +716,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++;
             }
         }
@@ -789,6 +805,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",
@@ -824,10 +844,16 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                     drive = libxl__sprintf
                         (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=writeback",
                          pdev_path, disk, format);
-                else if (disk < 4)
-                    drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",
-                         pdev_path, disk, format);
+                else if (disk < 4) {
+                    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,format=%s,cache=writeback",
+                                 pdev_path, disk, format);
+                }
                 else
                     continue; /* Do not emulate this disk */
             }
@@ -854,7 +880,7 @@ static char ** libxl__build_device_model_args(libxl__gc *gc,
                                         const libxl_domain_config *guest_config,
                                         const libxl__domain_build_state *state,
                                         int *dm_state_fd)
-/* dm_state_fd may be NULL iff caller knows we are using old stubdom
+/* dm_state_fd may be NULL iff caller knows we are using stubdom
  * and therefore will be passing a filename rather than a fd. */
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -865,8 +891,10 @@ static char ** libxl__build_device_model_args(libxl__gc *gc,
                                                   guest_domid, guest_config,
                                                   state);
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
-        assert(dm_state_fd != NULL);
-        assert(*dm_state_fd < 0);
+        if (!libxl_defbool_val(guest_config->b_info.device_model_stubdomain)) {
+            assert(dm_state_fd != NULL);
+            assert(*dm_state_fd < 0);
+	}
         return libxl__build_device_model_args_new(gc, dm,
                                                   guest_domid, guest_config,
                                                   state, dm_state_fd);
@@ -922,7 +950,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;
@@ -950,7 +978,9 @@ 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")) {
+        if (linux_stubdom ||
+            (strcmp(args[i], "-sdl") &&
+             strcmp(args[i], "-M") && strcmp(args[i], "xenfv"))) {
             strcat(dmargs, " ");
             strcat(dmargs, args[i]);
         }
-- 
1.8.5.5

  parent reply	other threads:[~2015-02-04  4:06 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-04  4:06 [RFC 0/7] RFC Linux-based QEMU-upstream stub domain Eric Shelton
2015-02-04  4:06 ` [RFC 1/7] linux-stubdomain: Compile QEMU Eric Shelton
2015-02-06 15:46   ` Stefano Stabellini
2015-02-06 17:25     ` Eric Shelton
2015-02-06 17:27       ` Stefano Stabellini
2015-02-06 18:57       ` Wei Liu
2015-02-04  4:06 ` [RFC 2/7] linux-stubdomain: Compile Linux Eric Shelton
2015-02-06 15:51   ` Stefano Stabellini
2015-02-06 17:42     ` Eric Shelton
2015-02-06 17:45       ` Stefano Stabellini
2015-02-09  9:09         ` Ian Campbell
2015-05-14  9:08         ` George Dunlap
2015-05-14  9:28           ` Ian Campbell
2015-05-18 10:37             ` George Dunlap
2015-05-18 10:45               ` Ian Campbell
2015-05-18 10:55                 ` George Dunlap
2015-02-04  4:06 ` [RFC 3/7] linux-stubdomain: Build a disk image Eric Shelton
2015-02-06 15:57   ` Stefano Stabellini
2015-02-06 17:45     ` Eric Shelton
2015-02-04  4:06 ` [RFC 4/7] libxl: Add "stubdomain_version" to domain_build_info Eric Shelton
2015-02-06 16:06   ` Stefano Stabellini
2015-02-06 17:50     ` Eric Shelton
2015-02-06 17:54       ` Stefano Stabellini
2015-02-09  9:11   ` Ian Campbell
2015-02-09 14:11     ` Eric Shelton
2015-02-04  4:06 ` Eric Shelton [this message]
2015-02-06 16:17   ` [RFC 5/7] libxl: Handle Linux stubdomain specific QEMU options Stefano Stabellini
2015-02-04  4:06 ` [RFC 6/7] libxl: Build the domain with a Linux based stubdomain Eric Shelton
2015-02-06 16:33   ` Stefano Stabellini
2015-02-04  4:06 ` [RFC 7/7] libxl: Wait for QEMU startup in stubdomain Eric Shelton
2015-02-06 11:16   ` Wei Liu
2015-02-06 13:56     ` Eric Shelton
2015-02-06 14:59       ` Wei Liu
2015-02-06 15:36         ` Stefano Stabellini
2015-02-06 17:10           ` Eric Shelton
2015-02-06 17:23             ` Stefano Stabellini
2015-02-09  9:07               ` Ian Campbell
2015-02-09  9:14                 ` Stefano Stabellini
2015-02-09 12:08                 ` Anthony PERARD
2015-02-09 13:57                   ` Eric Shelton
2015-02-06 15:46         ` Eric Shelton
2015-02-06 16:12           ` Wei Liu
2015-02-06 15:42 ` [RFC 0/7] RFC Linux-based QEMU-upstream stub domain Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423022775-7132-6-git-send-email-eshelton@pobox.com \
    --to=eshelton@pobox.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.