]> xenbits.xensource.com Git - people/julieng/xen-unstable.git/commitdiff
x86/libxc: add an arch domain config parameter to xc_domain_create
authorRoger Pau Monne <roger.pau@citrix.com>
Fri, 13 Nov 2015 11:05:51 +0000 (12:05 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 3 Dec 2015 15:00:53 +0000 (15:00 +0000)
With the addition of HVMlite the hypervisor now always requires a non-null
arch domain config, which is different between HVM and PV guests.

Add a new parameter to xc_domain_create that contains a pointer to an arch
domain config. If the pointer is null, create a default arch domain config
based on guest type.

Fix all the in-tree callers to provide a null arch domain config in order to
mimic previous behaviour.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxc/include/xenctrl.h
tools/libxc/xc_domain.c
tools/libxl/libxl_create.c
tools/ocaml/libs/xc/xenctrl_stubs.c
tools/python/xen/lowlevel/xc/xc.c
tools/xenstore/init-xenstore-domain.c

index 2fec1fb91e0401833b204155a3115d4e0024d46f..01a6dda42c3666c79d61ddceb0050a86e3fe7620 100644 (file)
@@ -502,17 +502,9 @@ typedef union
 
 
 typedef struct xen_arch_domainconfig xc_domain_configuration_t;
-int xc_domain_create_config(xc_interface *xch,
-                            uint32_t ssidref,
-                            xen_domain_handle_t handle,
-                            uint32_t flags,
-                            uint32_t *pdomid,
-                            xc_domain_configuration_t *config);
-int xc_domain_create(xc_interface *xch,
-                     uint32_t ssidref,
-                     xen_domain_handle_t handle,
-                     uint32_t flags,
-                     uint32_t *pdomid);
+int xc_domain_create(xc_interface *xch, uint32_t ssidref,
+                     xen_domain_handle_t handle, uint32_t flags,
+                     uint32_t *pdomid, xc_domain_configuration_t *config);
 
 
 /* Functions to produce a dump of a given domain
index 83afc7545973a509d95252196fe80d3b159f28d1..96506d5bf8cdfadfff89a8c9f1afd03d615ccded 100644 (file)
 #include <xen/memory.h>
 #include <xen/hvm/hvm_op.h>
 
-int xc_domain_create_config(xc_interface *xch,
-                            uint32_t ssidref,
-                            xen_domain_handle_t handle,
-                            uint32_t flags,
-                            uint32_t *pdomid,
-                            xc_domain_configuration_t *config)
+int xc_domain_create(xc_interface *xch, uint32_t ssidref,
+                     xen_domain_handle_t handle, uint32_t flags,
+                     uint32_t *pdomid, xc_domain_configuration_t *config)
 {
+    xc_domain_configuration_t lconfig;
     int err;
     DECLARE_DOMCTL;
 
+    if ( config == NULL )
+    {
+        memset(&lconfig, 0, sizeof(lconfig));
+
+#if defined (__i386) || defined(__x86_64__)
+        if ( flags & XEN_DOMCTL_CDF_hvm_guest )
+            lconfig.emulation_flags = XEN_X86_EMU_ALL;
+#elif defined (__arm__) || defined(__aarch64__)
+        lconfig.gic_version = XEN_DOMCTL_CONFIG_GIC_NATIVE;
+        lconfig.nr_spis = 0;
+#else
+#error Architecture not supported
+#endif
+
+        config = &lconfig;
+    }
+
     domctl.cmd = XEN_DOMCTL_createdomain;
     domctl.domain = (domid_t)*pdomid;
     domctl.u.createdomain.ssidref = ssidref;
@@ -52,30 +67,6 @@ int xc_domain_create_config(xc_interface *xch,
     return 0;
 }
 
-int xc_domain_create(xc_interface *xch,
-                     uint32_t ssidref,
-                     xen_domain_handle_t handle,
-                     uint32_t flags,
-                     uint32_t *pdomid)
-{
-    xc_domain_configuration_t config;
-
-    memset(&config, 0, sizeof(config));
-
-#if defined (__i386) || defined(__x86_64__)
-    /* No arch-specific configuration for now */
-#elif defined (__arm__) || defined(__aarch64__)
-    config.gic_version = XEN_DOMCTL_CONFIG_GIC_NATIVE;
-    config.nr_spis = 0;
-#else
-    errno = ENOSYS;
-    return -1;
-#endif
-
-    return xc_domain_create_config(xch, ssidref, handle,
-                                   flags, pdomid, &config);
-}
-
 int xc_domain_cacheflush(xc_interface *xch, uint32_t domid,
                          xen_pfn_t start_pfn, xen_pfn_t nr_pfns)
 {
index 673e5379ac6bd14bfce018164692e1ffcef9857c..a1ccf237daba4a574883604a8caa4b8269cb9cc3 100644 (file)
@@ -528,9 +528,8 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
 
     /* Valid domid here means we're soft resetting. */
     if (!libxl_domid_valid_guest(*domid)) {
-        ret = xc_domain_create_config(ctx->xch, info->ssidref,
-                                      handle, flags, domid,
-                                      xc_config);
+        ret = xc_domain_create(ctx->xch, info->ssidref, handle, flags, domid,
+                               xc_config);
         if (ret < 0) {
             LOGE(ERROR, "domain creation fail");
             rc = ERROR_FAIL;
index b7de6157f3ece4ff6384e06473e9447c41c1cf0e..393156cec3c76c4aa2726c9b2d4793d3ae52da39 100644 (file)
@@ -175,7 +175,7 @@ CAMLprim value stub_xc_domain_create(value xch, value ssidref,
        }
 
        caml_enter_blocking_section();
-       result = xc_domain_create(_H(xch), c_ssidref, h, c_flags, &domid);
+       result = xc_domain_create(_H(xch), c_ssidref, h, c_flags, &domid, NULL);
        caml_leave_blocking_section();
 
        if (result < 0)
index d75f98c0ff870578165d1042da8e63f697ef8be0..6dd79e0d1767deeb084bfc0b4643be1776e85023 100644 (file)
@@ -132,7 +132,7 @@ static PyObject *pyxc_domain_create(XcObject *self,
     }
 
     if ( (ret = xc_domain_create(self->xc_handle, ssidref,
-                                 handle, flags, &dom)) < 0 )
+                                 handle, flags, &dom, NULL)) < 0 )
         return pyxc_error_to_exception(self->xc_handle);
 
     if ( target )
index 0d12169ca405bcf8608e16a4e919bf30d283cfcb..297afe518734da9be717fcde5a8ad7f254063c50 100644 (file)
@@ -28,7 +28,7 @@ static int build(xc_interface *xch, int argc, char** argv)
 
        rv = xc_flask_context_to_sid(xch, argv[3], strlen(argv[3]), &ssid);
        if (rv) goto err;
-       rv = xc_domain_create(xch, ssid, handle, 0, &domid);
+       rv = xc_domain_create(xch, ssid, handle, 0, &domid, NULL);
        if (rv) goto err;
        rv = xc_domain_max_vcpus(xch, domid, 1);
        if (rv) goto err;