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

[Xen-devel] [PATCH] libxl: enabling upstream qemu as pure pv backend.



commit 02cf9f9cfdf720c636c6ba08f795e49b5eb1f03e
Author: Wei Liu <liuw@xxxxxxxxx>
Date:   Wed Jun 8 11:13:25 2011 +0800

    libxl: enabling upstream qemu as pure pv backend.
    
    This patch makes device_model_{version,override} work for pure pv
    guest, so that users can specify upstream qemu as pure pv backend
    other than traditional qemu-xen.
    
    Signed-off-by: Wei Liu <liuw@xxxxxxxxx>

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 62294b2..4ff3c7d 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -507,7 +507,8 @@ static int do_domain_create(libxl__gc *gc, 
libxl_domain_config *d_config,
         libxl_device_console_destroy(&console);
 
         if (need_qemu)
-            libxl__create_xenpv_qemu(gc, domid, d_config->vfbs, &dm_starting);
+            libxl__create_xenpv_qemu(gc, domid, &d_config->dm_info,
+                                     d_config->vfbs, &dm_starting);
     }
 
     if (dm_starting) {
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 47a51c8..0505c84 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -702,7 +702,7 @@ retry_transaction:
         if (ret)
             goto out_free;
     }
-    if (libxl__create_xenpv_qemu(gc, domid, vfb, &dm_starting) < 0) {
+    if (libxl__create_xenpv_qemu(gc, domid, info, vfb, &dm_starting) < 0) {
         ret = ERROR_FAIL;
         goto out_free;
     }
@@ -909,8 +909,8 @@ static int libxl__build_xenpv_qemu_args(libxl__gc *gc,
                                         libxl_device_model_info *info)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
-    memset(info, 0x00, sizeof(libxl_device_model_info));
 
+    info->vnc = 0;
     if (vfb != NULL) {
         info->vnc = vfb->vnc;
         if (vfb->vnclisten)
@@ -927,9 +927,12 @@ static int libxl__build_xenpv_qemu_args(libxl__gc *gc,
         info->nographic = 1;
     info->domid = domid;
     info->dom_name = libxl_domid_to_name(ctx, domid);
-    info->device_model_version = 
LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
-    info->device_model = NULL;
-    info->type = LIBXL_DOMAIN_TYPE_PV;
+    info->target_ram = 0;
+    info->videoram = 0;
+    info->acpi = 0;
+    info->vcpus = 0;
+    info->vcpu_avail = 0;
+    info->xen_platform_pci = 0;
     return 0;
 }
 
@@ -985,12 +988,12 @@ out:
     return ret;
 }
 
-int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, libxl_device_vfb 
*vfb,
+int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
+                             libxl_device_model_info *dm_info,
+                             libxl_device_vfb *vfb,
                              libxl__device_model_starting **starting_r)
 {
-    libxl_device_model_info info;
-
-    libxl__build_xenpv_qemu_args(gc, domid, vfb, &info);
-    libxl__create_device_model(gc, &info, NULL, 0, NULL, 0, starting_r);
+    libxl__build_xenpv_qemu_args(gc, domid, vfb, dm_info);
+    libxl__create_device_model(gc, dm_info, NULL, 0, NULL, 0, starting_r);
     return 0;
 }
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 64e1d56..55e9f7f 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -256,7 +256,9 @@ _hidden int libxl__create_device_model(libxl__gc *gc,
                               libxl_device_disk *disk, int num_disks,
                               libxl_device_nic *vifs, int num_vifs,
                               libxl__device_model_starting **starting_r);
-_hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, 
libxl_device_vfb *vfb,
+_hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid,
+                            libxl_device_model_info *dm_info,
+                            libxl_device_vfb *vfb,
                             libxl__device_model_starting **starting_r);
 _hidden int libxl__need_xenpv_qemu(libxl__gc *gc,
         int nr_consoles, libxl_device_console *consoles,
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 5415bc5..74a77a7 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -626,6 +626,8 @@ static void parse_config_data(const char 
*configfile_filename_report,
     int pci_power_mgmt = 0;
     int pci_msitranslate = 1;
     int e;
+    XLU_ConfigList *dmargs;
+    int nr_dmargs = 0;
 
     libxl_domain_create_info *c_info = &d_config->c_info;
     libxl_domain_build_info *b_info = &d_config->b_info;
@@ -1075,14 +1077,10 @@ skip_vfb:
         break;
     }
 
-    if (c_info->hvm == 1) {
-        XLU_ConfigList *dmargs;
-        int nr_dmargs = 0;
-
-        /* init dm from c and b */
-        libxl_init_dm_info(dm_info, c_info, b_info);
+    /* init dm from c and b */
+    libxl_init_dm_info(dm_info, c_info, b_info);
 
-        /* then process config related to dm */
+    if (c_info->hvm == 1) {
         if (!xlu_cfg_get_string (config, "device_model", &buf)) {
             fprintf(stderr,
                     "WARNING: ignoring device_model directive.\n"
@@ -1147,6 +1145,42 @@ skip_vfb:
                 dm_info->extra[i] = a ? strdup(a) : NULL;
             }
         }
+    } else {
+        if (!xlu_cfg_get_string (config, "device_model", &buf)) {
+            fprintf(stderr,
+                    "WARNING: ignoring device_model directive.\n"
+                    "WARNING: Use \"device_model_override\" instead if you 
really want a non-default device_model\n");
+        }
+
+        xlu_cfg_replace_string (config, "device_model_override",
+                                &dm_info->device_model);
+        if (!xlu_cfg_get_string (config, "device_model_version", &buf)) {
+            if (!strcmp(buf, "qemu-xen-traditional")) {
+                dm_info->device_model_version
+                    = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+            } else if (!strcmp(buf, "qemu-xen")) {
+                dm_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)
+            fprintf(stderr, "WARNING: device model override given without 
specific DM version\n");
+        if (!xlu_cfg_get_long (config, "device_model_stubdomain_override", &l))
+            fprintf(stderr, "WARNING: ignoring 
device_model_stubdomain_override for PV guest\n");
+
+        if (!xlu_cfg_get_list(config, "device_model_args", &dmargs, 
&nr_dmargs, 0))
+        {
+            int i;
+            dm_info->extra = xmalloc(sizeof(char *) * (nr_dmargs + 1));
+            dm_info->extra[nr_dmargs] = NULL;
+            for (i=0; i<nr_dmargs; i++) {
+                const char *a = xlu_cfg_get_listitem(dmargs, i);
+                dm_info->extra[i] = a ? strdup(a) : NULL;
+            }
+        }
     }
 
     dm_info->type = c_info->hvm ?



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