diff mbox

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

Message ID 1447417100-24921-1-git-send-email-roger.pau@citrix.com
State New
Headers show

Commit Message

Roger Pau Monné Nov. 13, 2015, 12:18 p.m. UTC
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.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: qemu-devel@nongnu.org
---
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(-)

Comments

Stefano Stabellini Nov. 13, 2015, 1:46 p.m. UTC | #1
On Fri, 13 Nov 2015, Roger Pau Monne wrote:
> 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.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

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

1447070487-31229-1-git-send-email-ian.campbell@citrix.com

Is the corresponding libxc change already in Xen?


> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Cc: qemu-devel@nongnu.org
> ---
> 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(-)
> 
> diff --git a/configure b/configure
> index 779623a..001982f 100755
> --- a/configure
> +++ b/configure
> @@ -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>
> diff --git a/hw/xenpv/xen_domainbuild.c b/hw/xenpv/xen_domainbuild.c
> index c0ab753..07814f6 100644
> --- a/hw/xenpv/xen_domainbuild.c
> +++ b/hw/xenpv/xen_domainbuild.c
> @@ -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;
> diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
> index 5923290..e5ba732 100644
> --- a/include/hw/xen/xen_common.h
> +++ b/include/hw/xen/xen_common.h
> @@ -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 */

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
Ian Campbell Nov. 13, 2015, 1:54 p.m. UTC | #2
On Fri, 2015-11-13 at 13:46 +0000, Stefano Stabellini wrote:
> On Fri, 13 Nov 2015, Roger Pau Monne wrote:
> > 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.
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> FYI this is going to conflict with Ian's series:
> 
> 1447070487-31229-1-git-send-email-ian.campbell@citrix.com

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.

> 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.
diff mbox

Patch

diff --git a/configure b/configure
index 779623a..001982f 100755
--- a/configure
+++ b/configure
@@ -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>
diff --git a/hw/xenpv/xen_domainbuild.c b/hw/xenpv/xen_domainbuild.c
index c0ab753..07814f6 100644
--- a/hw/xenpv/xen_domainbuild.c
+++ b/hw/xenpv/xen_domainbuild.c
@@ -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;
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index 5923290..e5ba732 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -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 */