Skip to contentSkip to conversation

libxl: fix assertion failure in stub domain creation

PATCH In review Paul Durrant 4 participants 5 messages Feb 5, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libxl: fix assertion failure in stub domain creation

An assertion in libxl__domain_make():

'soft_reset || *domid == INVALID_DOMID'

does not hold true for stub domain creation, where soft_reset is false but the passed in domid == 0. This is easily fixed by changing the initializer in libxl__spawn_stub_dm().

NOTE: The comment for XEN_DOMCTL_createdomain in domctl.h is changed to
reflect reality.

Fixes 75259239d85d ("libxl_create: make 'soft reset' explicit")

---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Roger Pau Monné <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>

An example of the assertion failure can be seen at:

http://logs.test-lab.xenproject.org/osstest/logs/146726/test-amd64-amd64-xl-qemut-stubdom-debianhvm-amd64-xsm/10.ts-debian-hvm-install.log

---
 tools/libxl/libxl_dm.c      | 2 +-
 xen/include/public/domctl.h | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
tools/libxl/libxl_dm.c +1 -1
index f758daf3b6..3b1da90167 100644
@@ -2127,7 +2127,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
         goto out;
     }
 
-    sdss->pvqemu.guest_domid = 0;
+    sdss->pvqemu.guest_domid = INVALID_DOMID;
 
     libxl_domain_create_info_init(&dm_config->c_info);
     dm_config->c_info.type = LIBXL_DOMAIN_TYPE_PV;
xen/include/public/domctl.h +2 -1
index 2bb7397923..fec6f6fdd1 100644
@@ -42,7 +42,8 @@
 
 /*
  * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
- * If it is specified as zero, an id is auto-allocated and returned.
+ * If it is specified as an invalid value (0 or >= DOMID_FIRST_RESERVED),
+ * an id is auto-allocated and returned.
  */
 /* XEN_DOMCTL_createdomain */
 struct xen_domctl_createdomain {
Signature · 7 lines
2.20.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v2 1/1
#1 lore raw
Quoted 8 lines · Paul Durrant

An assertion in libxl__domain_make():

'soft_reset || *domid == INVALID_DOMID'

does not hold true for stub domain creation, where soft_reset is false but the passed in domid == 0. This is easily fixed by changing the initializer in libxl__spawn_stub_dm().

Quoted 5 lines

NOTE: The comment for XEN_DOMCTL_createdomain in domctl.h is changed to
reflect reality.

Fixes 75259239d85d ("libxl_create: make 'soft reset' explicit")

I will wait until end of today in case others want to comment on the domctl.h change.

I will also carry over Anthony's ack from v1 while committing.

Wei.

Quoted 50 lines

---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Roger Pau Monné <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>

An example of the assertion failure can be seen at:

http://logs.test-lab.xenproject.org/osstest/logs/146726/test-amd64-amd64-xl-qemut-stubdom-debianhvm-amd64-xsm/10.ts-debian-hvm-install.log

---
 tools/libxl/libxl_dm.c      | 2 +-
 xen/include/public/domctl.h | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
tools/libxl/libxl_dm.c +1 -1
index f758daf3b6..3b1da90167 100644
@@ -2127,7 +2127,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
         goto out;
     }
 
-    sdss->pvqemu.guest_domid = 0;
+    sdss->pvqemu.guest_domid = INVALID_DOMID;
 
     libxl_domain_create_info_init(&dm_config->c_info);
     dm_config->c_info.type = LIBXL_DOMAIN_TYPE_PV;
xen/include/public/domctl.h +2 -1
index 2bb7397923..fec6f6fdd1 100644
@@ -42,7 +42,8 @@
 
 /*
  * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
- * If it is specified as zero, an id is auto-allocated and returned.
+ * If it is specified as an invalid value (0 or >= DOMID_FIRST_RESERVED),
+ * an id is auto-allocated and returned.
  */
 /* XEN_DOMCTL_createdomain */
 struct xen_domctl_createdomain {
Signature · 1 line
2.20.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v2 1/1
#2 lore raw
In reply to Paul Durrant

xen/include/public/domctl.h line 49

Quoted 12 lines · Paul Durrant
xen/include/public/domctl.h +2 -1
@@ -42,7 +42,8 @@
 
 /*
  * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
- * If it is specified as zero, an id is auto-allocated and returned.
+ * If it is specified as an invalid value (0 or >= DOMID_FIRST_RESERVED),
+ * an id is auto-allocated and returned.
  */
 /* XEN_DOMCTL_createdomain */
 struct xen_domctl_createdomain {

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to Paul Durrant
Quoted 2 lines · Paul Durrant

NOTE: The comment for XEN_DOMCTL_createdomain in domctl.h is changed to
reflect reality.

Surely, this change deserve to be in its own patch, isn't it?

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#4 lore raw
Quoted 5 lines · Anthony PERARD
Quoted 2 lines · Paul Durrant

NOTE: The comment for XEN_DOMCTL_createdomain in domctl.h is changed to
reflect reality.

Surely, this change deserve to be in its own patch, isn't it?

Ideally I would want that too. But this patch is trivial so I'm not too fussed either way.

Wei.

Quoted 3 lines
Signature · 2 lines
-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel