Skip to contentSkip to conversation

Fix xc_domain_config usage

PATCH In review Roger Pau Monne 4 participants 19 messages Nov 13, 2015 – Dec 3, 2015 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

cover Fix xc_domain_config usage

Hello,

Due to the HVMlite patches now x86 always requires a valid arch domain config. This is currently causing problems to out-of-tree toolstacks that are based on the Ocaml or the python bindings, since those bindings have lost the ability to create HVM guests because a zeroed arch domain config is always used regardless of the guest type.

In order to fix this add a new parameter to xc_domain_create that's a pointer to a arch domain config that can be null (the function itself will set a sensible default based on the guest type). Since xc_domain_create_config is meaningless now just remove it.

The in-tree callers are fixed in the first patch, while Qemu is fixed in the second patch. I'm not sure how this is going to work with the push gate, since both patches should be applied and tested together, or else Qemu build is going to fail.

Thanks, Roger.

#1 lore raw

PATCH 1/2 x86/libxc: add an arch domain config parameter to xc_domain_create

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.

---
 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(-)
tools/libxc/include/xenctrl.h +3 -11
index 2fec1fb..01a6dda 100644
@@ -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
tools/libxc/xc_domain.c +21 -30

67 lines not on this page · raw message

tools/libxl/libxl_create.c +2 -3
index f0fee00..4fbe7ac 100644
@@ -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;
tools/ocaml/libs/xc/xenctrl_stubs.c +1 -1
index b7de615..393156c 100644
@@ -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)
tools/python/xen/lowlevel/xc/xc.c +1 -1
index 26290a3..5a0ea33 100644
@@ -136,7 +136,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 )
tools/xenstore/init-xenstore-domain.c +1 -1
index 0d12169..297afe5 100644
@@ -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;
Signature · 7 lines
1.9.5 (Apple Git-50.3)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH XEN 1/2] x86/libxc: add an arch domain config parameter to xc_domain_create

Quoted 11 lines · Roger Pau Monne

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.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by
#3 lore raw

Re: [PATCH XEN 1/2] x86/libxc: add an arch domain config parameter to xc_domain_create

Quoted 11 lines · Andrew Cooper
Quoted 10 lines · Roger Pau Monne

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.

Quoted 7 lines
Quoted 5 lines

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

I went to apply but of course it broke without the corresponding qemu change already being in the qemu-xen.git tree.

According to <[email protected]> S tefano has applied to his tree, but I think it hasn't been sent upstream.

Please someone let me know when this change is in our qemu-xen.git#master (i.e. applied to staging and passed through the push gate) and I'll pick up this one then.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

Re: [PATCH XEN 1/2] x86/libxc: add an arch domain config parameter to xc_domain_create

Quoted 26 lines · Ian Campbell
Quoted 12 lines · Andrew Cooper
Quoted 11 lines · Roger Pau Monne

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.

Quoted 7 lines
Quoted 5 lines

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

I went to apply but of course it broke without the corresponding qemu change already being in the qemu-xen.git tree.

Quoted 6 lines

According to <[email protected]> S tefano has applied to his tree, but I think it hasn't been sent upstream.

Please someone let me know when this change is in our qemu-xen.git#master (i.e. applied to staging and passed through the push gate) and I'll pick up this one then.

I spotted the qemu fix coming through this afternoon => applied.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw

PATCH 2/2 xen: fix usage of xc_domain_create in domain builder

In reply to Roger Pau Monne

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

---
Cc: Stefano Stabellini <[email protected]>
Cc: [email protected]

---
 hw/xenpv/xen_domainbuild.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/xenpv/xen_domainbuild.c +1 -1
index c0ab753..a737908 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid, NULL);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
Signature · 1 line
1.9.5 (Apple Git-50.3)
#6 lore raw

Re: [PATCH QEMU 2/2] xen: fix usage of xc_domain_create in domain builder

Quoted 5 lines · Roger Pau Monne

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

Give a look at include/hw/xen/xen_common.h and add a compatibility shim there. Keep in mind that QEMU needs to build against any version of Xen from 4.0 onward.

Quoted 20 lines
Cc Stefano Stabellini <[email protected]>
---
 hw/xenpv/xen_domainbuild.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/xenpv/xen_domainbuild.c +1 -2
index c0ab753..a737908 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid, NULL);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
--
Quoted 2 lines

1.9.5 (Apple Git-50.3)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw

Re: [Qemu-devel] [PATCH QEMU 2/2] xen: fix usage of xc_domain_create in domain builder

In reply to Roger Pau Monne
Quoted 5 lines · Roger Pau Monne

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

Give a look at include/hw/xen/xen_common.h and add a compatibility shim there. Keep in mind that QEMU needs to build against any version of Xen from 4.0 onward.

Quoted 22 lines
Cc Stefano Stabellini <[email protected]>
---
 hw/xenpv/xen_domainbuild.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/xenpv/xen_domainbuild.c +1 -1
index c0ab753..a737908 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid, NULL);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
Signature · 1 line
1.9.5 (Apple Git-50.3)
#8 lore raw

PATCH v2 2/2 xen: fix usage of xc_domain_create in domain builder

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

Add a small stub called xen_domain_create that encapsulates the correct call to xc_domain_create depending on the libxc version detected.

---
Cc: Stefano Stabellini <[email protected]>
Cc: [email protected]
---
Changes since v1:
- Add a compat layer to support previous libxc versions.
- Add machinery to detect current Xen unstable (4.7).

---
 configure                   | 17 +++++++++++++++++
 hw/xenpv/xen_domainbuild.c  |  2 +-
 include/hw/xen/xen_common.h | 12 ++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
configure +17 -0
index 779623a..001982f 100755
@@ -1863,6 +1863,23 @@ EOF
   elif
       cat > $TMPC <<EOF &&
 #include <xenctrl.h>
+#include <stdint.h>
+int main(void) {
+  xc_interface *xc = NULL;
+  xen_domain_handle_t handle;
+  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
+  return 0;
+}
+EOF
+      compile_prog "" "$xen_libs"
+    then
+    xen_ctrl_version=470
+    xen=yes
+
+  # Xen 4.6
+  elif
+      cat > $TMPC <<EOF &&
+#include <xenctrl.h>
 #include <xenstore.h>
 #include <stdint.h>
 #include <xen/hvm/hvm_info_table.h>
hw/xenpv/xen_domainbuild.c +1 -1
index c0ab753..07814f6 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xen_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid, NULL);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
include/hw/xen/xen_common.h +12 -0
index 5923290..e5ba732 100644
@@ -417,4 +417,16 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom,
 
 #endif
 
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid,
+                                    xc_domain_configuration_t *config)
+{
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 470
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid);
+#else
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid, config);
+#endif
+}
+
 #endif /* QEMU_HW_XEN_COMMON_H */
Signature · 1 line
1.9.5 (Apple Git-50.3)
#9 lore raw

Re: [PATCH QEMU v2 2/2] xen: fix usage of xc_domain_create in domain builder

Quoted 8 lines · Roger Pau Monne

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

Add a small stub called xen_domain_create that encapsulates the correct call to xc_domain_create depending on the libxc version detected.

FYI this is going to conflict with Ian's series:

[email protected]

Is the corresponding libxc change already in Xen?

Quoted 64 lines
Cc Stefano Stabellini <[email protected]>

---
Changes since v1:
- Add a compat layer to support previous libxc versions.
- Add machinery to detect current Xen unstable (4.7).

---
 configure                   | 17 +++++++++++++++++
 hw/xenpv/xen_domainbuild.c  |  2 +-
 include/hw/xen/xen_common.h | 12 ++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
configure +17 -0
index 779623a..001982f 100755
@@ -1863,6 +1863,23 @@ EOF
   elif
       cat > $TMPC <<EOF &&
 #include <xenctrl.h>
+#include <stdint.h>
+int main(void) {
+  xc_interface *xc = NULL;
+  xen_domain_handle_t handle;
+  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
+  return 0;
+}
+EOF
+      compile_prog "" "$xen_libs"
+    then
+    xen_ctrl_version=470
+    xen=yes
+
+  # Xen 4.6
+  elif
+      cat > $TMPC <<EOF &&
+#include <xenctrl.h>
 #include <xenstore.h>
 #include <stdint.h>
 #include <xen/hvm/hvm_info_table.h>
hw/xenpv/xen_domainbuild.c +1 -1
index c0ab753..07814f6 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xen_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid, NULL);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
include/hw/xen/xen_common.h +3 -0
index 5923290..e5ba732 100644
@@ -417,4 +417,16 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom,
 
 #endif
 
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid,

include/hw/xen/xen_common.h static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom, · line 432

Quoted 10 lines
include/hw/xen/xen_common.h +9 -0
+                                    xc_domain_configuration_t *config)
+{
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 470
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid);
+#else
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid, config);
+#endif
+}
+
 #endif /* QEMU_HW_XEN_COMMON_H */

Please follow the existing scheme by introducing two xen_domain_create functions.

In addition, the patch causes a build failure against most Xen versions:

In file included from /local/scratch/sstabellini/qemu/include/hw/xen/xen_backend.h:4:0,

                 from hw/block/xen_disk.c:38:

/local/scratch/sstabellini/qemu/include/hw/xen/xen_common.h:445:37: error: unknown type name ‘xc_domain_configuration_t’
CC hw/bt/hci-csr.o
make: *** [hw/block/xen_disk.o] Error 1

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#10 lore raw

Re: [Qemu-devel] [PATCH QEMU v2 2/2] xen: fix usage of xc_domain_create in domain builder

In reply to Roger Pau Monne
Quoted 8 lines · Roger Pau Monne

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

Add a small stub called xen_domain_create that encapsulates the correct call to xc_domain_create depending on the libxc version detected.

FYI this is going to conflict with Ian's series:

[email protected]

Is the corresponding libxc change already in Xen?

Quoted 64 lines
Cc Stefano Stabellini <[email protected]>

---
Changes since v1:
- Add a compat layer to support previous libxc versions.
- Add machinery to detect current Xen unstable (4.7).

---
 configure                   | 17 +++++++++++++++++
 hw/xenpv/xen_domainbuild.c  |  2 +-
 include/hw/xen/xen_common.h | 12 ++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
configure +17 -0
index 779623a..001982f 100755
@@ -1863,6 +1863,23 @@ EOF
   elif
       cat > $TMPC <<EOF &&
 #include <xenctrl.h>
+#include <stdint.h>
+int main(void) {
+  xc_interface *xc = NULL;
+  xen_domain_handle_t handle;
+  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
+  return 0;
+}
+EOF
+      compile_prog "" "$xen_libs"
+    then
+    xen_ctrl_version=470
+    xen=yes
+
+  # Xen 4.6
+  elif
+      cat > $TMPC <<EOF &&
+#include <xenctrl.h>
 #include <xenstore.h>
 #include <stdint.h>
 #include <xen/hvm/hvm_info_table.h>
hw/xenpv/xen_domainbuild.c +1 -1
index c0ab753..07814f6 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xen_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid, NULL);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
include/hw/xen/xen_common.h +3 -0
index 5923290..e5ba732 100644
@@ -417,4 +417,16 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom,
 
 #endif
 
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid,

include/hw/xen/xen_common.h static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom, · line 432

Quoted 10 lines
include/hw/xen/xen_common.h +9 -0
+                                    xc_domain_configuration_t *config)
+{
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 470
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid);
+#else
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid, config);
+#endif
+}
+
 #endif /* QEMU_HW_XEN_COMMON_H */

Please follow the existing scheme by introducing two xen_domain_create functions.

In addition, the patch causes a build failure against most Xen versions:

In file included from /local/scratch/sstabellini/qemu/include/hw/xen/xen_backend.h:4:0,

                 from hw/block/xen_disk.c:38:

/local/scratch/sstabellini/qemu/include/hw/xen/xen_common.h:445:37: error: unknown type name ‘xc_domain_configuration_t’
CC hw/bt/hci-csr.o
make: *** [hw/block/xen_disk.o] Error 1

#11 lore raw

Re: [PATCH QEMU v2 2/2] xen: fix usage of xc_domain_create in domain builder

Quoted 11 lines · Stefano Stabellini
Quoted 10 lines · Roger Pau Monne

Due to the addition of HVMlite and the requirement to always provide a valid
xc_domain_configuration_t, xc_domain_create now always takes an arch domain
config, which can be NULL in order to mimic previous behaviour.

Add a small stub called xen_domain_create that encapsulates the correct call
to xc_domain_create depending on the libxc version detected.

Quoted 5 lines
Quoted 1 line

FYI this is going to conflict with Ian's series:

[email protected]

The bit being patched here is disabled by
"xen: make it possible to build without the Xen PV domain builder" in that series.

In any case I think Roger's stuff would be better off going in first and I can easily rebase over it.

Quoted 9 lines

In addition, the patch causes a build failure against most Xen versions:

In file included from /local/scratch/sstabellini/qemu/include/hw/xen/xen_backend.h:4:0, from hw/block/xen_disk.c:38:
/local/scratch/sstabellini/qemu/include/hw/xen/xen_common.h:445:37:
error: unknown type name ‘xc_domain_configuration_t’
  CC    hw/bt/hci-csr.o
make: *** [hw/block/xen_disk.o] Error 1

Given the only caller today passes NULL I'd suggest moving the NULL down into the wrapper, i.e. dropping the argument from xen_domain_create.

If someone wants to resurrect the domain build in QEMU _and_ teach it to do pvh, then they will surely be able to refactor this to suit their needs.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#12 lore raw

Re: [Qemu-devel] [PATCH QEMU v2 2/2] xen: fix usage of xc_domain_create in domain builder

In reply to Stefano Stabellini
Quoted 11 lines · Stefano Stabellini
Quoted 10 lines · Roger Pau Monne

Due to the addition of HVMlite and the requirement to always provide a valid
xc_domain_configuration_t, xc_domain_create now always takes an arch domain
config, which can be NULL in order to mimic previous behaviour.

Add a small stub called xen_domain_create that encapsulates the correct call
to xc_domain_create depending on the libxc version detected.

Quoted 5 lines
Quoted 1 line

FYI this is going to conflict with Ian's series:

[email protected]

The bit being patched here is disabled by
"xen: make it possible to build without the Xen PV domain builder" in that series.

In any case I think Roger's stuff would be better off going in first and I can easily rebase over it.

Quoted 9 lines

In addition, the patch causes a build failure against most Xen versions:

In file included from /local/scratch/sstabellini/qemu/include/hw/xen/xen_backend.h:4:0, from hw/block/xen_disk.c:38:
/local/scratch/sstabellini/qemu/include/hw/xen/xen_common.h:445:37:
error: unknown type name ‘xc_domain_configuration_t’
  CC    hw/bt/hci-csr.o
make: *** [hw/block/xen_disk.o] Error 1

Given the only caller today passes NULL I'd suggest moving the NULL down into the wrapper, i.e. dropping the argument from xen_domain_create.

If someone wants to resurrect the domain build in QEMU _and_ teach it to do pvh, then they will surely be able to refactor this to suit their needs.

Ian.

#13 lore raw

PATCH v3 2/2 xen: fix usage of xc_domain_create in domain builder

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

Add a small stub called xen_domain_create that encapsulates the correct call to xc_domain_create depending on the libxc version detected.

---
Cc: Stefano Stabellini <[email protected]>
Cc: [email protected]
---
Changes since v2:
- Drop the last parameter to xen_create_domain since it's always NULL ATM and was causing build problems with older Xen versions.
- Create two different inline functions instead of putting ifdefs inside of a single one.

Changes since v1:
- Add a compat layer to support previous libxc versions.
- Add machinery to detect current Xen unstable (4.7).

---
 configure                   | 17 +++++++++++++++++
 hw/xenpv/xen_domainbuild.c  |  2 +-
 include/hw/xen/xen_common.h | 16 ++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)
configure +17 -0
index 779623a..001982f 100755
@@ -1863,6 +1863,23 @@ EOF
   elif
       cat > $TMPC <<EOF &&
 #include <xenctrl.h>
+#include <stdint.h>
+int main(void) {
+  xc_interface *xc = NULL;
+  xen_domain_handle_t handle;
+  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
+  return 0;
+}
+EOF
+      compile_prog "" "$xen_libs"
+    then
+    xen_ctrl_version=470
+    xen=yes
+
+  # Xen 4.6
+  elif
+      cat > $TMPC <<EOF &&
+#include <xenctrl.h>
 #include <xenstore.h>
 #include <stdint.h>
 #include <xen/hvm/hvm_info_table.h>
hw/xenpv/xen_domainbuild.c +1 -1
index c0ab753..ac0e5ac 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xen_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
include/hw/xen/xen_common.h +16 -0
index 5923290..04bf6da 100644
@@ -417,4 +417,20 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom,
 
 #endif
 
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 470
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid)
+{
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid);
+}
+#else
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid)
+{
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid, NULL);
+}
+#endif
+
 #endif /* QEMU_HW_XEN_COMMON_H */
Signature · 7 lines
1.9.5 (Apple Git-50.3)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#14 lore raw

PATCH v3 2/2 xen: fix usage of xc_domain_create in domain builder

In reply to Ian Campbell

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

Add a small stub called xen_domain_create that encapsulates the correct call to xc_domain_create depending on the libxc version detected.

---
Cc: Stefano Stabellini <[email protected]>
Cc: [email protected]
---
Changes since v2:
- Drop the last parameter to xen_create_domain since it's always NULL ATM and was causing build problems with older Xen versions.
- Create two different inline functions instead of putting ifdefs inside of a single one.

Changes since v1:
- Add a compat layer to support previous libxc versions.
- Add machinery to detect current Xen unstable (4.7).

---
 configure                   | 17 +++++++++++++++++
 hw/xenpv/xen_domainbuild.c  |  2 +-
 include/hw/xen/xen_common.h | 16 ++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)
configure +17 -0
index 779623a..001982f 100755
@@ -1863,6 +1863,23 @@ EOF
   elif
       cat > $TMPC <<EOF &&
 #include <xenctrl.h>
+#include <stdint.h>
+int main(void) {
+  xc_interface *xc = NULL;
+  xen_domain_handle_t handle;
+  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
+  return 0;
+}
+EOF
+      compile_prog "" "$xen_libs"
+    then
+    xen_ctrl_version=470
+    xen=yes
+
+  # Xen 4.6
+  elif
+      cat > $TMPC <<EOF &&
+#include <xenctrl.h>
 #include <xenstore.h>
 #include <stdint.h>
 #include <xen/hvm/hvm_info_table.h>
hw/xenpv/xen_domainbuild.c +1 -1
index c0ab753..ac0e5ac 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xen_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
include/hw/xen/xen_common.h +16 -0
index 5923290..04bf6da 100644
@@ -417,4 +417,20 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom,
 
 #endif
 
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 470
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid)
+{
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid);
+}
+#else
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid)
+{
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid, NULL);
+}
+#endif
+
 #endif /* QEMU_HW_XEN_COMMON_H */
Signature · 1 line
1.9.5 (Apple Git-50.3)
Acked-by on v3 2/2
#15 lore raw

Re: [PATCH QEMU v3 2/2] xen: fix usage of xc_domain_create in domain builder

Quoted 8 lines · Roger Pau Monne

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

Add a small stub called xen_domain_create that encapsulates the correct call to xc_domain_create depending on the libxc version detected.

I'll apply it to my tree

Quoted 85 lines
Cc Stefano Stabellini <[email protected]>

---
Changes since v2:
- Drop the last parameter to xen_create_domain since it's always NULL ATM and was causing build problems with older Xen versions.
- Create two different inline functions instead of putting ifdefs inside of a single one.

Changes since v1:
- Add a compat layer to support previous libxc versions.
- Add machinery to detect current Xen unstable (4.7).

---
 configure                   | 17 +++++++++++++++++
 hw/xenpv/xen_domainbuild.c  |  2 +-
 include/hw/xen/xen_common.h | 16 ++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)
configure +17 -0
index 779623a..001982f 100755
@@ -1863,6 +1863,23 @@ EOF
   elif
       cat > $TMPC <<EOF &&
 #include <xenctrl.h>
+#include <stdint.h>
+int main(void) {
+  xc_interface *xc = NULL;
+  xen_domain_handle_t handle;
+  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
+  return 0;
+}
+EOF
+      compile_prog "" "$xen_libs"
+    then
+    xen_ctrl_version=470
+    xen=yes
+
+  # Xen 4.6
+  elif
+      cat > $TMPC <<EOF &&
+#include <xenctrl.h>
 #include <xenstore.h>
 #include <stdint.h>
 #include <xen/hvm/hvm_info_table.h>
hw/xenpv/xen_domainbuild.c +1 -1
index c0ab753..ac0e5ac 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xen_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
include/hw/xen/xen_common.h +16 -1
index 5923290..04bf6da 100644
@@ -417,4 +417,20 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom,
 
 #endif
 
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 470
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid)
+{
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid);
+}
+#else
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid)
+{
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid, NULL);
+}
+#endif
+
 #endif /* QEMU_HW_XEN_COMMON_H */
--
Quoted 2 lines

1.9.5 (Apple Git-50.3)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v3 2/2
#16 lore raw

Re: [Qemu-devel] [PATCH QEMU v3 2/2] xen: fix usage of xc_domain_create in domain builder

In reply to Roger Pau Monne
Quoted 8 lines · Roger Pau Monne

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

Add a small stub called xen_domain_create that encapsulates the correct call to xc_domain_create depending on the libxc version detected.

I'll apply it to my tree

Quoted 87 lines
Cc Stefano Stabellini <[email protected]>

---
Changes since v2:
- Drop the last parameter to xen_create_domain since it's always NULL ATM and was causing build problems with older Xen versions.
- Create two different inline functions instead of putting ifdefs inside of a single one.

Changes since v1:
- Add a compat layer to support previous libxc versions.
- Add machinery to detect current Xen unstable (4.7).

---
 configure                   | 17 +++++++++++++++++
 hw/xenpv/xen_domainbuild.c  |  2 +-
 include/hw/xen/xen_common.h | 16 ++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)
configure +17 -0
index 779623a..001982f 100755
@@ -1863,6 +1863,23 @@ EOF
   elif
       cat > $TMPC <<EOF &&
 #include <xenctrl.h>
+#include <stdint.h>
+int main(void) {
+  xc_interface *xc = NULL;
+  xen_domain_handle_t handle;
+  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
+  return 0;
+}
+EOF
+      compile_prog "" "$xen_libs"
+    then
+    xen_ctrl_version=470
+    xen=yes
+
+  # Xen 4.6
+  elif
+      cat > $TMPC <<EOF &&
+#include <xenctrl.h>
 #include <xenstore.h>
 #include <stdint.h>
 #include <xen/hvm/hvm_info_table.h>
hw/xenpv/xen_domainbuild.c +1 -1
index c0ab753..ac0e5ac 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xen_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
include/hw/xen/xen_common.h +16 -0
index 5923290..04bf6da 100644
@@ -417,4 +417,20 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom,
 
 #endif
 
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 470
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid)
+{
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid);
+}
+#else
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid)
+{
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid, NULL);
+}
+#endif
+
 #endif /* QEMU_HW_XEN_COMMON_H */
Signature · 1 line
1.9.5 (Apple Git-50.3)
#17 lore raw

PATCH v2 2/2 xen: fix usage of xc_domain_create in domain builder

In reply to Stefano Stabellini

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

Add a small stub called xen_domain_create that encapsulates the correct call to xc_domain_create depending on the libxc version detected.

---
Cc: Stefano Stabellini <[email protected]>
Cc: [email protected]
---
Changes since v1:
- Add a compat layer to support previous libxc versions.
- Add machinery to detect current Xen unstable (4.7).

---
 configure                   | 17 +++++++++++++++++
 hw/xenpv/xen_domainbuild.c  |  2 +-
 include/hw/xen/xen_common.h | 12 ++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
configure +17 -0
index 779623a..001982f 100755
@@ -1863,6 +1863,23 @@ EOF
   elif
       cat > $TMPC <<EOF &&
 #include <xenctrl.h>
+#include <stdint.h>
+int main(void) {
+  xc_interface *xc = NULL;
+  xen_domain_handle_t handle;
+  xc_domain_create(xc, 0, handle, 0, NULL, NULL);
+  return 0;
+}
+EOF
+      compile_prog "" "$xen_libs"
+    then
+    xen_ctrl_version=470
+    xen=yes
+
+  # Xen 4.6
+  elif
+      cat > $TMPC <<EOF &&
+#include <xenctrl.h>
 #include <xenstore.h>
 #include <stdint.h>
 #include <xen/hvm/hvm_info_table.h>
hw/xenpv/xen_domainbuild.c +1 -1
index c0ab753..07814f6 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xen_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid, NULL);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
include/hw/xen/xen_common.h +12 -0
index 5923290..e5ba732 100644
@@ -417,4 +417,16 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom,
 
 #endif
 
+static inline int xen_domain_create(XenXC xc, uint32_t ssidref,
+                                    xen_domain_handle_t handle, uint32_t flags,
+                                    uint32_t *pdomid,
+                                    xc_domain_configuration_t *config)
+{
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 470
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid);
+#else
+    return xc_domain_create(xc, ssidref, handle, flags, pdomid, config);
+#endif
+}
+
 #endif /* QEMU_HW_XEN_COMMON_H */
Signature · 7 lines
1.9.5 (Apple Git-50.3)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#18 lore raw

PATCH 2/2 xen: fix usage of xc_domain_create in domain builder

In reply to Roger Pau Monne

Due to the addition of HVMlite and the requirement to always provide a valid xc_domain_configuration_t, xc_domain_create now always takes an arch domain config, which can be NULL in order to mimic previous behaviour.

---
Cc: Stefano Stabellini <[email protected]>
Cc: [email protected]

---
 hw/xenpv/xen_domainbuild.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/xenpv/xen_domainbuild.c +1 -1
index c0ab753..a737908 100644
@@ -234,7 +234,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     int rc;
 
     memcpy(uuid, qemu_uuid, sizeof(uuid));
-    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
+    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid, NULL);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_create() failed\n");
         goto err;
Signature · 7 lines
1.9.5 (Apple Git-50.3)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel