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

[Xen-devel] [PATCH XEN v6 01/32] x86/libxc: add an arch domain config parameter to xc_domain_create



From: Roger Pau Monne <roger.pau@xxxxxxxxxx>

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@xxxxxxxxxx>
---
XXX picked up in this series so I can work against qemu-mainline.
---
 tools/libxc/include/xenctrl.h         | 14 +++-------
 tools/libxc/xc_domain.c               | 51 +++++++++++++++--------------------
 tools/libxl/libxl_create.c            |  5 ++--
 tools/ocaml/libs/xc/xenctrl_stubs.c   |  2 +-
 tools/python/xen/lowlevel/xc/xc.c     |  2 +-
 tools/xenstore/init-xenstore-domain.c |  2 +-
 6 files changed, 29 insertions(+), 47 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 2fec1fb..01a6dda 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -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
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 83afc75..96506d5 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -26,16 +26,31 @@
 #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)
 {
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 673e537..a1ccf23 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -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;
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c 
b/tools/ocaml/libs/xc/xenctrl_stubs.c
index b7de615..393156c 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -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)
diff --git a/tools/python/xen/lowlevel/xc/xc.c 
b/tools/python/xen/lowlevel/xc/xc.c
index d75f98c..6dd79e0 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -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 )
diff --git a/tools/xenstore/init-xenstore-domain.c 
b/tools/xenstore/init-xenstore-domain.c
index 0d12169..297afe5 100644
--- a/tools/xenstore/init-xenstore-domain.c
+++ b/tools/xenstore/init-xenstore-domain.c
@@ -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;
-- 
2.1.4


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