Skip to contentSkip to conversation

libxl: use qemu-xen (upstream QEMU) as device model by default

PATCH In review Stefano Stabellini 3 participants 17 messages Dec 4, 2012 – Mar 13, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libxl: use qemu-xen (upstream QEMU) as device model by default

Changes in v2:
- update the xl man page;
- write a small helper function in libxl_{linux,netbsd}.c to set the default device_model, so that NetBSD can keep using the old version.

docs/man/xl.cfg.pod.5 +6 -6
index fe4fac9..69a38b9 100644
@@ -1132,15 +1132,15 @@ guest. Valid values are:
 
 =over 4
 
-=item B<qemu-xen-traditional>
+=item B<qemu-xen>
 
-Use the device-model based upon the historical Xen fork of Qemu.  This
-device-model is currently the default.
+use the device-model merged into the upstream QEMU project.
+This device-model is the default for Linux dom0.
 
-=item B<qemu-xen>
+=item B<qemu-xen-traditional>
 
-use the device-model merged into the upstream QEMU project.  This
-device-model will become the default in a future version of Xen.
+Use the device-model based upon the historical Xen fork of Qemu.
+This device-model is still the default for NetBSD dom0.
 
 =back
 
tools/libxl/libxl_create.c +1 -2
index 9d20086..6ec543a 100644
@@ -143,8 +143,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
 
     if (!b_info->device_model_version) {
         if (b_info->type == LIBXL_DOMAIN_TYPE_HVM)
-            b_info->device_model_version =
-                LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+            b_info->device_model_version = libxl__default_device_model(gc);
         else {
             const char *dm;
             int rc;
tools/libxl/libxl_internal.h +4 -0
index cba3616..0ea11d1 100644
@@ -1557,6 +1557,10 @@ _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s);
   /* Based on /local/domain/$domid/dm-version xenstore key
    * default is qemu xen traditional */
 _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);
+  /* Return the system-wide default device model:
+   * qemu-xen for Linux, qemu-xen-traditional for NetBSD.
+   */
+_hidden libxl_device_model_version libxl__default_device_model(libxl__gc *gc);
 
 /* Check how executes hotplug script currently */
 int libxl__hotplug_settings(libxl__gc *gc, xs_transaction_t t);
tools/libxl/libxl_linux.c +5 -0
index 1fed3cd..409e9f2 100644
@@ -266,3 +266,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
 out:
     return rc;
 }
+
+libxl_device_model_version libxl__default_device_model(libxl__gc *gc)
+{
+    return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
+}
tools/libxl/libxl_netbsd.c +5 -0
index 9587833..aa04969 100644
@@ -94,3 +94,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
 out:
     return rc;
 }
+
+libxl_device_model_version libxl__default_device_model(libxl__gc *gc)
+{
+    return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+}
#1 lore raw
Quoted 5 lines · Stefano Stabellini
docs/man/xl.cfg.pod.5 +0 -0
index fe4fac9..69a38b9 100644

docs/man/xl.cfg.pod.5 guest. Valid values are: · line 1137

Quoted 9 lines
docs/man/xl.cfg.pod.5 +2 -3
@@ -1132,15 +1132,15 @@ guest. Valid values are:
 
 =over 4
 
-=item B<qemu-xen-traditional>
+=item B<qemu-xen>
 
-Use the device-model based upon the historical Xen fork of Qemu.  This
-device-model is currently the default.
+use the device-model merged into the upstream QEMU project.

Can you correct to "Use" as you move it please.

docs/man/xl.cfg.pod.5 guest. Valid values are: · line 1143

Quoted 9 lines
docs/man/xl.cfg.pod.5 +4 -3
+This device-model is the default for Linux dom0.
 
-=item B<qemu-xen>
+=item B<qemu-xen-traditional>
 
-use the device-model merged into the upstream QEMU project.  This
-device-model will become the default in a future version of Xen.
+Use the device-model based upon the historical Xen fork of Qemu.
+This device-model is still the default for NetBSD dom0.

Does that look like changing for 4.3?

tools/libxl/libxl_create.c int libxl__domain_build_info_setdefault(libxl__gc *gc, · line 146

Quoted 11 lines
tools/libxl/libxl_create.c +1 -2
index 9d20086..6ec543a 100644
@@ -143,8 +143,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
 
     if (!b_info->device_model_version) {
         if (b_info->type == LIBXL_DOMAIN_TYPE_HVM)
-            b_info->device_model_version =
-                LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+            b_info->device_model_version = libxl__default_device_model(gc);

For PV we stat() the executable before using it -- I don't remember why but should we be doing the same here?

Also, will this not break things for people with "device_model_stubdomain_override = 1" (but nothing else) in their configuration?

I think the logic needs to be (perhaps in Linux's
libxl__default_device_model(gc) only)

	if (libxl_defbool_val(b_info->device_model_stubdomain)
		LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
	else
		LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;

? At least until we have upstream stubdoms in some form.

tools/libxl/libxl_internal.h _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s); · line 1561

Quoted 13 lines
tools/libxl/libxl_create.c +0 -0
         else {
             const char *dm;
             int rc;
tools/libxl/libxl_internal.h +2 -0
index cba3616..0ea11d1 100644
@@ -1557,6 +1557,10 @@ _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s);
   /* Based on /local/domain/$domid/dm-version xenstore key
    * default is qemu xen traditional */
 _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);
+  /* Return the system-wide default device model:
+   * qemu-xen for Linux, qemu-xen-traditional for NetBSD.

I bet you someone forgets to update this when NetBSD changes ;-)

Quoted 5 lines
tools/libxl/libxl_internal.h +2 -0
+   */
+_hidden libxl_device_model_version libxl__default_device_model(libxl__gc *gc);
 
 /* Check how executes hotplug script currently */
 int libxl__hotplug_settings(libxl__gc *gc, xs_transaction_t t);
#2 lore raw

v3 cover libxl: change to qemu-xen (upstream) by default

Ian Campbell writes ("Re: [Xen-devel] [PATCH v2] libxl: use qemu-xen (upstream QEMU) as device model by default"):

Quoted 6 lines · Stefano Stabellini

docs/man/xl.cfg.pod.5 guest. Valid values are: · line 1137

Quoted 3 lines
docs/man/xl.cfg.pod.5 +1 -2
-Use the device-model based upon the historical Xen fork of Qemu.  This
-device-model is currently the default.
+use the device-model merged into the upstream QEMU project.

Can you correct to "Use" as you move it please.

Fixed.

Quoted 6 lines

docs/man/xl.cfg.pod.5 guest. Valid values are: · line 1143

Quoted 4 lines
docs/man/xl.cfg.pod.5 +2 -2
-use the device-model merged into the upstream QEMU project.  This
-device-model will become the default in a future version of Xen.
+Use the device-model based upon the historical Xen fork of Qemu.
+This device-model is still the default for NetBSD dom0.

Does that look like changing for 4.3?

I guess not but I don't think that should block this change.

Quoted 6 lines

tools/libxl/libxl_create.c int libxl__domain_build_info_setdefault(libxl__gc *gc, · line 146

Quoted 3 lines
tools/libxl/libxl_create.c +1 -2
-            b_info->device_model_version =
-                LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+            b_info->device_model_version = libxl__default_device_model(gc);

For PV we stat() the executable before using it -- I don't remember why but should we be doing the same here?

Presumably in case the upstream build was disabled. I think the same logic applies so I have arranged to do the same.

Quoted 6 lines

I think the logic needs to be (perhaps in Linux's
libxl__default_device_model(gc) only)

	if (libxl_defbool_val(b_info->device_model_stubdomain)
		LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
	else
		LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;

Yes, done.

Quoted 4 lines

tools/libxl/libxl_internal.h _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s); · line 1561

Quoted 2 lines
tools/libxl/libxl_internal.h +2 -0
+  /* Return the system-wide default device model:
+   * qemu-xen for Linux, qemu-xen-traditional for NetBSD.

I bet you someone forgets to update this when NetBSD changes ;-)

That remark just needs to go IMO.

So we now have:
[PATCH 1/2] libxl: move check for existence of qemuu device model [PATCH 2/2] libxl: use qemu-xen (upstream QEMU) as device model by default

#3 lore raw

PATCH v3 1/2 libxl: move check for existence of qemuu device model

In reply to Ian Campbell

The stat in libxl__domain_build_info_setdefault's default device model logic works to fall back to qemu-xen-traditional whenever the executable for qemu-xen is not found.

We are going to use qemu-xen-traditional in more cases, so break this check out into its own if statement.

Also add a pair of braces to make the if() statement symmetrical.

--
New in v3 of series.

---
 tools/libxl/libxl_create.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
tools/libxl/libxl_create.c +8 -5
index efeebf2..04bf4a5 100644
@@ -105,22 +105,25 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
     libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
 
     if (!b_info->device_model_version) {
-        if (b_info->type == LIBXL_DOMAIN_TYPE_HVM)
+        if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
             b_info->device_model_version =
                 LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
-        else {
+        } else {
+            b_info->device_model_version =
+                LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
+        }
+        if (b_info->device_model_version
+                == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
             const char *dm;
             int rc;
 
-            b_info->device_model_version =
-                LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
             dm = libxl__domain_device_model(gc, b_info);
             rc = access(dm, X_OK);
             if (rc < 0) {
                 /* qemu-xen unavailable, use qemu-xen-traditional */
                 if (errno == ENOENT) {
                     LIBXL__LOG_ERRNO(CTX, XTL_VERBOSE, "qemu-xen is unavailable"
-                            ", use qemu-xen-traditional instead");
+                                     ", use qemu-xen-traditional instead");
                     b_info->device_model_version =
                         LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
                 } else {
Signature · 1 line
1.7.2.5
#4 lore raw

Re: [PATCH 1/2] libxl: move check for existence of qemuu device model

Quoted 7 lines · Ian Jackson
tools/libxl/libxl_create.c +2 -2
+        if (b_info->device_model_version
+                == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
             const char *dm;
             int rc;
 
-            b_info->device_model_version =
-                LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;

tools/libxl/libxl_create.c int libxl__domain_build_info_setdefault(libxl__gc *gc, · line 128

Quoted 10 lines
tools/libxl/libxl_create.c +1 -1
             dm = libxl__domain_device_model(gc, b_info);
             rc = access(dm, X_OK);
             if (rc < 0) {
                 /* qemu-xen unavailable, use qemu-xen-traditional */
                 if (errno == ENOENT) {
                     LIBXL__LOG_ERRNO(CTX, XTL_VERBOSE, "qemu-xen is unavailable"
-                            ", use qemu-xen-traditional instead");
+                                     ", use qemu-xen-traditional instead");
                     b_info->device_model_version =
                         LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;

After the following change (in 2/2) won't this stat potentially be checking for the qemu-xen-trad binaries, which makes the error message somewhat confusing and also makes the fallback unhelpful.

On a related note we could do with stating the device model even in the case where the user has specified device_model_version explicitly, to give better error reporting in that case too.

Ian.

#5 lore raw

Re: [PATCH 1/2] libxl: move check for existence of qemuu device model

Ian Campbell writes ("Re: [Xen-devel] [PATCH 1/2] libxl: move check for existence of qemuu device model"):

Quoted 5 lines · Ian Jackson
Quoted 4 lines
tools/libxl/libxl_create.c +2 -0
+        if (b_info->device_model_version
+                == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
             const char *dm;
             int rc;

...

Quoted 3 lines
Quoted 3 lines
             rc = access(dm, X_OK);
             if (rc < 0) {
                 /* qemu-xen unavailable, use qemu-xen-traditional */

...

Quoted 3 lines

After the following change (in 2/2) won't this stat potentially be checking for the qemu-xen-trad binaries, which makes the error message somewhat confusing and also makes the fallback unhelpful.

No, because the whole thing is in an if which applies only if we're trying to use ..._QEMU_XEN.

Quoted 3 lines

On a related note we could do with stating the device model even in the case where the user has specified device_model_version explicitly, to give better error reporting in that case too.

You mean logging it ?

Ian.

#6 lore raw

Re: [PATCH 1/2] libxl: move check for existence of qemuu device model

Quoted 10 lines · Ian Jackson

Ian Campbell writes ("Re: [Xen-devel] [PATCH 1/2] libxl: move check for existence of qemuu device model"):

Quoted 5 lines · Ian Jackson
Quoted 4 lines
tools/libxl/libxl_create.c +2 -0
+        if (b_info->device_model_version
+                == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
             const char *dm;
             int rc;

...

Quoted 3 lines
Quoted 3 lines
             rc = access(dm, X_OK);
             if (rc < 0) {
                 /* qemu-xen unavailable, use qemu-xen-traditional */
Quoted 7 lines

...

Quoted 3 lines

After the following change (in 2/2) won't this stat potentially be checking for the qemu-xen-trad binaries, which makes the error message somewhat confusing and also makes the fallback unhelpful.

No, because the whole thing is in an if which applies only if we're trying to use ..._QEMU_XEN.

Oh, right. I combined the tow patches wrongly in my head.

Don't we also want to check for the presence of the trad binary though?

Quoted 5 lines
Quoted 3 lines

On a related note we could do with stating the device model even in the case where the user has specified device_model_version explicitly, to give better error reporting in that case too.

You mean logging it ?

Actually I meant "not trying to start the guest regardless and returning success", which AIUI is what happens... Logging would be nice too though.

Quoted 2 lines

Ian.

#7 lore raw

Re: [PATCH 1/2] libxl: move check for existence of qemuu device model

Ian Campbell writes ("Re: [Xen-devel] [PATCH 1/2] libxl: move check for existence of qemuu device model"):

Quoted 7 lines · Ian Jackson
Quoted 2 lines

No, because the whole thing is in an if which applies only if we're trying to use ..._QEMU_XEN.

Oh, right. I combined the tow patches wrongly in my head.

Don't we also want to check for the presence of the trad binary though?

AIUI the trad binary is always built ? AIUI there is a possibility that the new one isn't ? And that was the rationale for this check ?

CCing Stefano.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

On a related note we could do with stating the device model even in the case where the user has specified device_model_version explicitly, to give better error reporting in that case too.

You mean logging it ?

Actually I meant "not trying to start the guest regardless and returning success", which AIUI is what happens... Logging would be nice too though.

Oh I see. TBH once we start to think about these kinds of installation problems it's difficult to see where we'll stop.

Ian.

#8 lore raw

Re: [PATCH 1/2] libxl: move check for existence of qemuu device model

Quoted 10 lines · Ian Jackson

Ian Campbell writes ("Re: [Xen-devel] [PATCH 1/2] libxl: move check for existence of qemuu device model"):

Quoted 7 lines · Ian Jackson
Quoted 2 lines

No, because the whole thing is in an if which applies only if we're trying to use ..._QEMU_XEN.

Oh, right. I combined the tow patches wrongly in my head.

Don't we also want to check for the presence of the trad binary though?

AIUI the trad binary is always built ?

By us it is, but e.g. Debian's packaging has been known to omit it, or the user may have overridden the path but made a typo.

Quoted 9 lines

AIUI there is a possibility
that the new one isn't ? And that was the rationale for this check ?

CCing Stefano.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

On a related note we could do with stating the device model even in the case where the user has specified device_model_version explicitly, to give better error reporting in that case too.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

You mean logging it ?

Actually I meant "not trying to start the guest regardless and returning success", which AIUI is what happens... Logging would be nice too though.

Oh I see. TBH once we start to think about these kinds of installation problems it's difficult to see where we'll stop.

This is one which has been tripping people up in practice.

#9 lore raw

Re: [PATCH 1/2] libxl: move check for existence of qemuu device model

Ian Campbell writes ("Re: [Xen-devel] [PATCH 1/2] libxl: move check for existence of qemuu device model"):

Quoted 5 lines · Ian Jackson
Quoted 2 lines

Oh I see. TBH once we start to think about these kinds of installation problems it's difficult to see where we'll stop.

This is one which has been tripping people up in practice.

OK then.

Should we stat whichever one we intend to use and fall back to the other with a warning, then ?

Ian.

#10 lore raw

Re: [PATCH 1/2] libxl: move check for existence of qemuu device model

Quoted 5 lines · Ian Jackson

Ian Campbell writes ("Re: [Xen-devel] [PATCH 1/2] libxl: move check for existence of qemuu device model"):

Quoted 4 lines · Ian Jackson
Quoted 2 lines

Oh I see. TBH once we start to think about these kinds of installation problems it's difficult to see where we'll stop.

Quoted 7 lines
Quoted 1 line

This is one which has been tripping people up in practice.

OK then.

Should we stat whichever one we intend to use and fall back to the other with a warning, then ?

Could do that if libxl is the one doing the choosing, I suppose. I'd also be happy with failing explicitly with an appropriate message.

In the case where the user gave an explicit path or version we should obviously use it or fail.

Ian.

#11 lore raw

Re: [PATCH 1/2] libxl: move check for existence of qemuu device model

Ian Campbell writes ("Re: [Xen-devel] [PATCH 1/2] libxl: move check for existence of qemuu device model"):

Quoted 2 lines

Could do that if libxl is the one doing the choosing, I suppose. I'd also be happy with failing explicitly with an appropriate message.

Right.

Quoted 2 lines

In the case where the user gave an explicit path or version we should obviously use it or fail.

Indeed.

Ian.

Acked-by
#12 lore raw

Re: [PATCH 1/2] libxl: move check for existence of qemuu device model

In reply to Ian Campbell
Quoted 12 lines · Ian Campbell
Quoted 11 lines · Ian Jackson

Ian Campbell writes ("Re: [Xen-devel] [PATCH 1/2] libxl: move check for existence of qemuu device model"):

Quoted 5 lines · Ian Jackson
Quoted 4 lines
tools/libxl/libxl_create.c +2 -0
+        if (b_info->device_model_version
+                == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
             const char *dm;
             int rc;

...

Quoted 3 lines
Quoted 3 lines
             rc = access(dm, X_OK);
             if (rc < 0) {
                 /* qemu-xen unavailable, use qemu-xen-traditional */

...

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

After the following change (in 2/2) won't this stat potentially be checking for the qemu-xen-trad binaries, which makes the error message somewhat confusing and also makes the fallback unhelpful.

No, because the whole thing is in an if which applies only if we're trying to use ..._QEMU_XEN.

Oh, right. I combined the tow patches wrongly in my head.

So I think this patch is good as far as it goes and the rest of this thread is really followup material.
So:

Quoted 22 lines

Don't we also want to check for the presence of the trad binary though?

Quoted 5 lines
Quoted 3 lines

On a related note we could do with stating the device model even in the case where the user has specified device_model_version explicitly, to give better error reporting in that case too.

You mean logging it ?

Actually I meant "not trying to start the guest regardless and returning success", which AIUI is what happens... Logging would be nice too though.

Quoted 2 lines

Ian.

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

#13 lore raw

PATCH v3 2/2 libxl: use qemu-xen (upstream QEMU) as device model by default

In reply to Ian Campbell

From: Stefano Stabellini <[email protected]>

--
Changes in v3:
- Fix "use" to "Use" in documentation part
- Do not try to use qemu-xen (upstream) for stubdoms
- Remove a hostage-to-fortune remark in a comment about OS defaults

Changes in v2:
- update the xl man page;
- write a small helper function in libxl_{linux,netbsd}.c to set the default device_model, so that NetBSD can keep using the old version.

---
 docs/man/xl.cfg.pod.5        |   12 ++++++------
 tools/libxl/libxl_create.c   |   10 +++++++---
 tools/libxl/libxl_internal.h |    2 ++
 tools/libxl/libxl_linux.c    |    5 +++++
 tools/libxl/libxl_netbsd.c   |    5 +++++
 5 files changed, 25 insertions(+), 9 deletions(-)
docs/man/xl.cfg.pod.5 +6 -6
index 25523c9..8db24d7 100644
@@ -1176,15 +1176,15 @@ guest. Valid values are:
 
 =over 4
 
-=item B<qemu-xen-traditional>
+=item B<qemu-xen>
 
-Use the device-model based upon the historical Xen fork of Qemu.  This
-device-model is currently the default.
+Use the device-model merged into the upstream QEMU project.
+This device-model is the default for Linux dom0.
 
-=item B<qemu-xen>
+=item B<qemu-xen-traditional>
 
-use the device-model merged into the upstream QEMU project.  This
-device-model will become the default in a future version of Xen.
+Use the device-model based upon the historical Xen fork of Qemu.
+This device-model is still the default for NetBSD dom0.
 
 =back
 
tools/libxl/libxl_create.c +7 -3
index 04bf4a5..7ec8c2b 100644
@@ -105,9 +105,13 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
     libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
 
     if (!b_info->device_model_version) {
-        if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
-            b_info->device_model_version =
-                LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+        if (b_info->type == LIBXL_DOMAIN_TYPE_HVM)
+            if (libxl_defbool_val(info->device_model_stubdomain)) {
+                b_info->device_model_version =
+                    LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+            } else {
+                b_info->device_model_version = libxl__default_device_model(gc);
+            }
         } else {
             b_info->device_model_version =
                 LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
tools/libxl/libxl_internal.h +2 -0
index 1567b4b..25172f0 100644
@@ -1561,6 +1561,8 @@ _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s);
   /* Based on /local/domain/$domid/dm-version xenstore key
    * default is qemu xen traditional */
 _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);
+  /* Return the system-wide default device model */
+_hidden libxl_device_model_version libxl__default_device_model(libxl__gc *gc);
 
 /* Check how executes hotplug script currently */
 int libxl__hotplug_settings(libxl__gc *gc, xs_transaction_t t);
tools/libxl/libxl_linux.c +5 -0
index 1fed3cd..409e9f2 100644
@@ -266,3 +266,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
 out:
     return rc;
 }
+
+libxl_device_model_version libxl__default_device_model(libxl__gc *gc)
+{
+    return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
+}
tools/libxl/libxl_netbsd.c +5 -0
index 9587833..aa04969 100644
@@ -94,3 +94,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
 out:
     return rc;
 }
+
+libxl_device_model_version libxl__default_device_model(libxl__gc *gc)
+{
+    return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+}
Signature · 1 line
1.7.2.5
#14 lore raw
Quoted 11 lines · Ian Jackson

From: Stefano Stabellini <[email protected]>

--
Changes in v3:
- Fix "use" to "Use" in documentation part
- Do not try to use qemu-xen (upstream) for stubdoms
- Remove a hostage-to-fortune remark in a comment about OS defaults

Quoted 4 lines

Changes in v2:
- update the xl man page;
- write a small helper function in libxl_{linux,netbsd}.c to set the default device_model, so that NetBSD can keep using the old version.

it looks OK to me, thanks for picking it up

Quoted 96 lines
 docs/man/xl.cfg.pod.5        |   12 ++++++------
 tools/libxl/libxl_create.c   |   10 +++++++---
 tools/libxl/libxl_internal.h |    2 ++
 tools/libxl/libxl_linux.c    |    5 +++++
 tools/libxl/libxl_netbsd.c   |    5 +++++
 5 files changed, 25 insertions(+), 9 deletions(-)
docs/man/xl.cfg.pod.5 +6 -6
index 25523c9..8db24d7 100644
@@ -1176,15 +1176,15 @@ guest. Valid values are:
 
 =over 4
 
-=item B<qemu-xen-traditional>
+=item B<qemu-xen>
 
-Use the device-model based upon the historical Xen fork of Qemu.  This
-device-model is currently the default.
+Use the device-model merged into the upstream QEMU project.
+This device-model is the default for Linux dom0.
 
-=item B<qemu-xen>
+=item B<qemu-xen-traditional>
 
-use the device-model merged into the upstream QEMU project.  This
-device-model will become the default in a future version of Xen.
+Use the device-model based upon the historical Xen fork of Qemu.
+This device-model is still the default for NetBSD dom0.
 
 =back
 
tools/libxl/libxl_create.c +7 -3
index 04bf4a5..7ec8c2b 100644
@@ -105,9 +105,13 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
     libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
 
     if (!b_info->device_model_version) {
-        if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
-            b_info->device_model_version =
-                LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+        if (b_info->type == LIBXL_DOMAIN_TYPE_HVM)
+            if (libxl_defbool_val(info->device_model_stubdomain)) {
+                b_info->device_model_version =
+                    LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+            } else {
+                b_info->device_model_version = libxl__default_device_model(gc);
+            }
         } else {
             b_info->device_model_version =
                 LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
tools/libxl/libxl_internal.h +2 -0
index 1567b4b..25172f0 100644
@@ -1561,6 +1561,8 @@ _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s);
   /* Based on /local/domain/$domid/dm-version xenstore key
    * default is qemu xen traditional */
 _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);
+  /* Return the system-wide default device model */
+_hidden libxl_device_model_version libxl__default_device_model(libxl__gc *gc);
 
 /* Check how executes hotplug script currently */
 int libxl__hotplug_settings(libxl__gc *gc, xs_transaction_t t);
tools/libxl/libxl_linux.c +5 -0
index 1fed3cd..409e9f2 100644
@@ -266,3 +266,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
 out:
     return rc;
 }
+
+libxl_device_model_version libxl__default_device_model(libxl__gc *gc)
+{
+    return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
+}
tools/libxl/libxl_netbsd.c +5 -0
index 9587833..aa04969 100644
@@ -94,3 +94,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
 out:
     return rc;
 }
+
+libxl_device_model_version libxl__default_device_model(libxl__gc *gc)
+{
+    return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+}
Signature · 1 line
1.7.2.5
Acked-by
#15 lore raw
Quoted 12 lines · Stefano Stabellini
Quoted 11 lines · Ian Jackson

From: Stefano Stabellini <[email protected]>

--
Changes in v3:
- Fix "use" to "Use" in documentation part
- Do not try to use qemu-xen (upstream) for stubdoms
- Remove a hostage-to-fortune remark in a comment about OS defaults

Quoted 6 lines
Quoted 4 lines

Changes in v2:
- update the xl man page;
- write a small helper function in libxl_{linux,netbsd}.c to set the default device_model, so that NetBSD can keep using the old version.

it looks OK to me, thanks for picking it up

#16 lore raw

Ian Campbell writes ("Re: [Xen-devel] [PATCH 2/2] libxl: use qemu-xen (upstream QEMU) as device model by default"):

Quoted 4 lines · Stefano Stabellini
Quoted 1 line

it looks OK to me, thanks for picking it up

Thanks, pushed both to staging.

Ian.