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

Re: [Xen-devel] [RFC 5/7] libxl: Handle Linux stubdomain specific QEMU options.



On Tue, 3 Feb 2015, Eric Shelton wrote:
> 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@xxxxxxxxx>
> ---
>  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 */
>              }

I don't think that this works if you specify more than one disk or one
cdrom for the guest.


> @@ -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)

I don't see the corresponding change to the call sites.


>  {
>      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"))) {

You are always passing all the args to QEMU, without filters. Why?
Is that because you have filtered the arguments previously?
If so, could not just do the same for qemu-xen-tradition case and unify
the code paths?


>              strcat(dmargs, " ");
>              strcat(dmargs, args[i]);
>          }
> -- 
> 1.8.5.5
> 

_______________________________________________
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®.