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

[Xen-devel] [PATCH 18 of 32 RFC] libxl: move device model selection variables to b_info



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1326383828 0
# Node ID ff41e5fc0f12450cd836ce1466c0c51ab685e04b
# Parent  20f5a6a37f6aac5eb314262c16e3548e6ab7a2a9
libxl: move device model selection variables to b_info.

Currently we have one set of device model version (and associated) variables.
However we can actually have two device models (stub device model + non-stub PV
device model) which need not necessarily be the same version. Perhaps this
needs more thought.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl.c       Thu Jan 12 15:57:08 2012 +0000
@@ -2389,7 +2389,7 @@ int libxl_domain_need_memory(libxl_ctx *
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         *need_memkb += b_info->shadow_memkb + LIBXL_HVM_EXTRA_MEMORY;
-        if (dm_info->device_model_stubdomain)
+        if (b_info->device_model_stubdomain)
             *need_memkb += 32 * 1024;
         break;
     case LIBXL_DOMAIN_TYPE_PV:
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c        Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl_create.c        Thu Jan 12 15:57:08 2012 +0000
@@ -84,6 +84,12 @@ int libxl_init_build_info(libxl_ctx *ctx
     b_info->cpuid = NULL;
     b_info->shadow_memkb = 0;
     b_info->type = c_info->type;
+
+    b_info->device_model_version =
+        LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+    b_info->device_model_stubdomain = false;
+    b_info->device_model = NULL;
+
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         b_info->video_memkb = 8 * 1024;
@@ -134,9 +140,6 @@ int libxl_init_dm_info(libxl_ctx *ctx,
 {
     memset(dm_info, '\0', sizeof(*dm_info));
 
-    dm_info->device_model_version = 
LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
-    dm_info->device_model_stubdomain = false;
-    dm_info->device_model = NULL;
 
     return 0;
 }
@@ -446,14 +449,14 @@ retry_transaction:
 }
 
 static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
-                             libxl_device_model_info *dm_info)
+                             libxl_domain_build_info *b_info)
 {
     char *path = NULL;
 
     path = libxl__xs_libxl_path(gc, domid);
     path = libxl__sprintf(gc, "%s/dm-version", path);
     return libxl__xs_write(gc, XBT_NULL, path, "%s",
-        libxl_device_model_version_to_string(dm_info->device_model_version));
+        libxl_device_model_version_to_string(b_info->device_model_version));
 }
 
 static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
@@ -512,7 +515,7 @@ static int do_domain_create(libxl__gc *g
         goto error_out;
     }
 
-    store_libxl_entry(gc, domid, dm_info);
+    store_libxl_entry(gc, domid, &d_config->b_info);
 
     for (i = 0; i < d_config->num_disks; i++) {
         ret = libxl_device_disk_add(ctx, domid, &d_config->disks[i]);
@@ -588,12 +591,6 @@ static int do_domain_create(libxl__gc *g
         if (need_qemu) {
             /* only copy those useful configs */
             memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info));
-            xenpv_dm_info.device_model_version =
-                d_config->dm_info.device_model_version;
-            xenpv_dm_info.device_model = d_config->dm_info.device_model;
-            xenpv_dm_info.extra = d_config->dm_info.extra;
-            xenpv_dm_info.extra_pv = d_config->dm_info.extra_pv;
-            xenpv_dm_info.extra_hvm = d_config->dm_info.extra_hvm;
 
             libxl__create_xenpv_qemu(gc, domid,
                                      d_config, &xenpv_dm_info, &dm_starting);
@@ -606,7 +603,7 @@ static int do_domain_create(libxl__gc *g
     }
 
     if (dm_starting) {
-        if (dm_info->device_model_version
+        if (d_config->b_info.device_model_version
             == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
             libxl__qmp_initializations(ctx, domid);
         }
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl_dm.c    Thu Jan 12 15:57:08 2012 +0000
@@ -42,7 +42,7 @@ const char *libxl__device_model_savefile
 }
 
 const char *libxl__domain_device_model(libxl__gc *gc,
-                                       libxl_device_model_info *info)
+                                       const libxl_domain_build_info *info)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     const char *dm;
@@ -72,7 +72,7 @@ const char *libxl__domain_device_model(l
 }
 
 static const char *libxl__domain_bios(libxl__gc *gc,
-                                libxl_device_model_info *info)
+                                const libxl_domain_build_info *info)
 {
     switch (info->device_model_version) {
     case 1: return "rombios";
@@ -259,19 +259,19 @@ static char ** libxl__build_device_model
     if (info->saved_state) {
         flexarray_vappend(dm_args, "-loadvm", info->saved_state, NULL);
     }
-    for (i = 0; info->extra && info->extra[i] != NULL; i++)
-        flexarray_append(dm_args, info->extra[i]);
+    for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++)
+        flexarray_append(dm_args, b_info->extra[i]);
     flexarray_append(dm_args, "-M");
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_PV:
         flexarray_append(dm_args, "xenpv");
-        for (i = 0; info->extra_pv && info->extra_pv[i] != NULL; i++)
-            flexarray_append(dm_args, info->extra_pv[i]);
+        for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++)
+            flexarray_append(dm_args, b_info->extra_pv[i]);
         break;
     case LIBXL_DOMAIN_TYPE_HVM:
         flexarray_append(dm_args, "xenfv");
-        for (i = 0; info->extra_hvm && info->extra_hvm[i] != NULL; i++)
-            flexarray_append(dm_args, info->extra_hvm[i]);
+        for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++)
+            flexarray_append(dm_args, b_info->extra_hvm[i]);
         break;
     }
     flexarray_append(dm_args, NULL);
@@ -503,19 +503,19 @@ static char ** libxl__build_device_model
         flexarray_append(dm_args, "-incoming");
         flexarray_append(dm_args, libxl__sprintf(gc, "fd:%d", migration_fd));
     }
-    for (i = 0; info->extra && info->extra[i] != NULL; i++)
-        flexarray_append(dm_args, info->extra[i]);
+    for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++)
+        flexarray_append(dm_args, b_info->extra[i]);
     flexarray_append(dm_args, "-M");
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_PV:
         flexarray_append(dm_args, "xenpv");
-        for (i = 0; info->extra_pv && info->extra_pv[i] != NULL; i++)
-            flexarray_append(dm_args, info->extra_pv[i]);
+        for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++)
+            flexarray_append(dm_args, b_info->extra_pv[i]);
         break;
     case LIBXL_DOMAIN_TYPE_HVM:
         flexarray_append(dm_args, "xenfv");
-        for (i = 0; info->extra_hvm && info->extra_hvm[i] != NULL; i++)
-            flexarray_append(dm_args, info->extra_hvm[i]);
+        for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++)
+            flexarray_append(dm_args, b_info->extra_hvm[i]);
         break;
     }
 
@@ -593,14 +593,14 @@ static char ** libxl__build_device_model
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
 
-    switch (info->device_model_version) {
+    switch (guest_config->b_info.device_model_version) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
         return libxl__build_device_model_args_old(gc, dm, guest_config, info);
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
         return libxl__build_device_model_args_new(gc, dm, guest_config, info);
     default:
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version 
%d",
-                         info->device_model_version);
+                         guest_config->b_info.device_model_version);
         return NULL;
     }
 }
@@ -696,7 +696,8 @@ static int libxl__create_stubdom(libxl__
     libxl__spawner_starting *dm_starting = 0;
     libxl_device_model_info xenpv_dm_info;
 
-    if (info->device_model_version != 
LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) {
+    if (guest_config->b_info.device_model_version !=
+        LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) {
         ret = ERROR_INVAL;
         goto out;
     }
@@ -720,6 +721,14 @@ static int libxl__create_stubdom(libxl__
     dm_config.b_info.u.pv.ramdisk.path = "";
     dm_config.b_info.u.pv.features = "";
 
+    dm_config.b_info.device_model_version =
+        guest_config->b_info.device_model_version;
+    dm_config.b_info.device_model =
+        guest_config->b_info.device_model;
+    dm_config.b_info.extra = guest_config->b_info.extra;
+    dm_config.b_info.extra_pv = guest_config->b_info.extra_pv;
+    dm_config.b_info.extra_hvm = guest_config->b_info.extra_hvm;
+
     dm_config.disks = guest_config->disks;
     dm_config.num_disks = guest_config->num_disks;
 
@@ -838,11 +847,6 @@ retry_transaction:
     }
 
     memset((void*)&xenpv_dm_info, 0, sizeof(libxl_device_model_info));
-    xenpv_dm_info.device_model_version = info->device_model_version;
-    xenpv_dm_info.device_model = info->device_model;
-    xenpv_dm_info.extra = info->extra;
-    xenpv_dm_info.extra_pv = info->extra_pv;
-    xenpv_dm_info.extra_hvm = info->extra_hvm;
 
     if (libxl__create_xenpv_qemu(gc, domid,
                                  &dm_config,
@@ -881,6 +885,7 @@ int libxl__create_device_model(libxl__gc
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     const libxl_domain_create_info *c_info = &guest_config->c_info;
+    const libxl_domain_build_info *b_info = &guest_config->b_info;
     const libxl_vnc_info *vnc = dm_vnc(guest_config, info);
     char *path, *logfile;
     int logfile_w, null;
@@ -892,12 +897,12 @@ int libxl__create_device_model(libxl__gc
     char **pass_stuff;
     const char *dm;
 
-    if (info->device_model_stubdomain) {
+    if (b_info->device_model_stubdomain) {
         rc = libxl__create_stubdom(gc, guest_config, info, starting_r);
         goto out;
     }
 
-    dm = libxl__domain_device_model(gc, info);
+    dm = libxl__domain_device_model(gc, b_info);
     if (!dm) {
         rc = ERROR_FAIL;
         goto out;
@@ -917,12 +922,12 @@ int libxl__create_device_model(libxl__gc
     path = libxl__sprintf(gc, "/local/domain/%d/hvmloader", info->domid);
     xs_mkdir(ctx->xsh, XBT_NULL, path);
     libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/bios", path),
-                    "%s", libxl__domain_bios(gc, info));
+                    "%s", libxl__domain_bios(gc, b_info));
 
     path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", info->domid);
     xs_mkdir(ctx->xsh, XBT_NULL, path);
     libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path),
-                    "%d", !guest_config->b_info.u.hvm.xen_platform_pci);
+                    "%d", !b_info->u.hvm.xen_platform_pci);
 
     libxl_create_logfile(ctx,
                          libxl__sprintf(gc, "qemu-dm-%s", c_info->name),
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl_dom.c   Thu Jan 12 15:57:08 2012 +0000
@@ -297,7 +297,7 @@ static const char *libxl__domain_firmwar
     if (info->u.hvm.firmware)
         firmware = info->u.hvm.firmware;
     else {
-        switch (dm_info->device_model_version)
+        switch (info->device_model_version)
         {
         case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
             firmware = "hvmloader";
@@ -307,7 +307,7 @@ static const char *libxl__domain_firmwar
             break;
         default:
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "invalid device model version 
%d",
-                       dm_info->device_model_version);
+                       info->device_model_version);
             return NULL;
             break;
         }
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl_internal.h      Thu Jan 12 15:57:08 2012 +0000
@@ -463,7 +463,7 @@ _hidden int libxl__domain_build(libxl__g
 
 /* for device model creation */
 _hidden const char *libxl__domain_device_model(libxl__gc *gc,
-                                               libxl_device_model_info *info);
+                                        const libxl_domain_build_info *info);
 _hidden int libxl__create_device_model(libxl__gc *gc,
                               libxl_domain_config *guest_config,
                               libxl_device_model_info *info,
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl       Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/libxl_types.idl       Thu Jan 12 15:57:08 2012 +0000
@@ -205,6 +205,19 @@ libxl_domain_build_info = Struct("domain
     ("disable_migrate", bool),
     ("cpuid",           libxl_cpuid_policy_list),
     ("type",            libxl_domain_type),
+    
+    ("device_model_version", libxl_device_model_version),
+    ("device_model_stubdomain", bool),
+    # you set device_model you must set device_model_version too
+    ("device_model",     string),
+
+    # extra parameters pass directly to qemu, NULL terminated
+    ("extra",            libxl_string_list),
+    # extra parameters pass directly to qemu for PV guest, NULL terminated
+    ("extra_pv",         libxl_string_list),
+    # extra parameters pass directly to qemu for HVM guest, NULL terminated
+    ("extra_hvm",        libxl_string_list),
+
     ("u", KeyedUnion(None, libxl_domain_type, "type",
                 [("hvm", Struct(None, [("firmware", string),
                                        ("pae", bool),
@@ -257,17 +270,7 @@ libxl_domain_build_info = Struct("domain
 libxl_device_model_info = Struct("device_model_info",[
     ("domid",            libxl_domid),
     
-    ("device_model_version", libxl_device_model_version),
-    ("device_model_stubdomain", bool),
-    # you set device_model you must set device_model_version too
-    ("device_model",     string),
     ("saved_state",      string),
-    # extra parameters pass directly to qemu, NULL terminated
-    ("extra",            libxl_string_list),
-    # extra parameters pass directly to qemu for PV guest, NULL terminated
-    ("extra_pv",         libxl_string_list),
-    # extra parameters pass directly to qemu for HVM guest, NULL terminated
-    ("extra_hvm",        libxl_string_list),
     ],
 )
 
diff -r 20f5a6a37f6a -r ff41e5fc0f12 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Jan 12 15:50:25 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Thu Jan 12 15:57:08 2012 +0000
@@ -378,7 +378,7 @@ static void printf_info(int domid,
                     b_info->u.hvm.spice.disable_ticketing);
         printf("\t\t\t(spiceagent_mouse %d)\n", 
b_info->u.hvm.spice.agent_mouse);
 
-        printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : 
"default");
+        printf("\t\t\t(device_model %s)\n", b_info->device_model ? : 
"default");
         printf("\t\t\t(gfx_passthru %d)\n", b_info->u.hvm.gfx_passthru);
         printf("\t\t\t(serial %s)\n", b_info->u.hvm.serial);
         printf("\t\t\t(boot %s)\n", b_info->u.hvm.boot);
@@ -1133,27 +1133,27 @@ skip_vfb:
 
 
     xlu_cfg_replace_string (config, "device_model_override",
-                            &dm_info->device_model, 0);
+                            &b_info->device_model, 0);
     if (!xlu_cfg_get_string (config, "device_model_version", &buf, 0)) {
         if (!strcmp(buf, "qemu-xen-traditional")) {
-            dm_info->device_model_version
+            b_info->device_model_version
                 = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
         } else if (!strcmp(buf, "qemu-xen")) {
-            dm_info->device_model_version
+            b_info->device_model_version
                 = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
         } else {
             fprintf(stderr,
                     "Unknown device_model_version \"%s\" specified\n", buf);
             exit(1);
         }
-    } else if (dm_info->device_model)
+    } else if (b_info->device_model)
         fprintf(stderr, "WARNING: device model override given without specific 
DM version\n");
     if (!xlu_cfg_get_long (config, "device_model_stubdomain_override", &l, 0))
-        dm_info->device_model_stubdomain = l;
+        b_info->device_model_stubdomain = l;
 
 #define parse_extra_args(type)                                            \
     e = xlu_cfg_get_list_as_string_list(config, "device_model_args"#type, \
-                                    &dm_info->extra##type, 0);            \
+                                    &b_info->extra##type, 0);            \
     if (e && e != ESRCH) {                                                \
         fprintf(stderr,"xl: Unable to parse device_model_args"#type".\n");\
         exit(-ERROR_FAIL);                                                \

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


 


Rackspace

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