Remove backend xen store entry on domain destroy
v2 cover Remove backend xen store entry on domain destroy
From: Oleksandr Grytsov <[email protected]>
Changes since v1:
* add commit to rename VKB backend type "linux" to "pv";
* add default case to handle adding/removing PV devices in add_device, remove_device functions (libxl_device.c);
* add comment about removing num_vifs, num_vbds into commit message.
Oleksandr Grytsov (3):
libxl: introduce new backend type VINPUT
libxl: rename VKB backend type "linux" to "pv"
libxl: make default path to add/remove all PV devices
docs/man/xl.cfg.5.pod.in | 4 +- tools/libxl/libxl_device.c | 63 +++++++++++----------------- tools/libxl/libxl_types.idl | 2 +- tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vkb.c | 29 ++++++++----- 5 files changed, 47 insertions(+), 52 deletions(-)
Signature · 7 lines
2.17.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 1/3 libxl: introduce new backend type VINPUT
From: Oleksandr Grytsov <[email protected]>
There are two kind of VKBD devices: with QEMU backend and user space PV backend. In current implementation they can't be distinguished as both use VKBD backend type. As result, user space PV KBD backend is started and stopped as QEMU backend. This commit adds new device kind VINPUT to be used as backend type for user space PV KBD backend.
--- tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vkb.c | 29 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-)
tools/libxl/libxl_types_internal.idl +1 -0
@@ -31,6 +31,7 @@ libxl__device_kind = Enumeration("device_kind", [ (13, "VUART"), (14, "PVCALLS"), (15, "VSND"), + (16, "VINPUT"), ]) libxl__console_backend = Enumeration("console_backend", [
tools/libxl/libxl_vkb.c +19 -10
@@ -38,9 +38,6 @@ static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t domid, flexarray_t *back, flexarray_t *front, flexarray_t *ro_front) { -flexarray_append_pair (back,"backend-type" , - (char *)libxl_vkb_backend_to_string (vkb->backend_type)); -if (vkb->unique_id) {flexarray_append_pair (back,XENKBD_FIELD_UNIQUE_ID , vkb->unique_id); }
@@ -93,7 +90,8 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char *libxl_path,libxl_devid devid, libxl_device_vkb *vkb) { - const char *be_path, *be_type, *fe_path, *tmp; + const char *be_path, *fe_path, *tmp; +libxl__device dev;int rc; vkb->devid = devid;
@@ -111,13 +109,11 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char *libxl_path, rc =libxl__backendpath_parse_domid (gc, be_path, &vkb->backend_domid);if (rc) goto out; - rc =libxl__xs_read_mandatory (gc,XBT_NULL , -GCSPRINTF ("%s/backend-type" , be_path), - &be_type); + rc =libxl__parse_backend_path (gc, be_path, &dev);if (rc) goto out; - rc =libxl_vkb_backend_from_string (be_type, &vkb->backend_type); -if (rc) goto out; + vkb->backend_type = dev.backend_kind ==LIBXL__DEVICE_KIND_VINPUT ? +LIBXL_VKB_BACKEND_LINUX :LIBXL_VKB_BACKEND_QEMU ; vkb->unique_id =xs_read (CTX ->xsh,XBT_NULL ,GCSPRINTF ("%s/" XENKBD_FIELD_UNIQUE_ID , be_path),NULL );
@@ -218,6 +214,20 @@ out:return rc; } +static int libxl__device_from_vkb (libxl__gc *gc,uint32_t domid, +libxl_device_vkb *type,libxl__device *device) +{ + device->backend_devid = type->devid; + device->backend_domid = type->backend_domid; + device->backend_kind = type->backend_type ==LIBXL_VKB_BACKEND_LINUX ? +LIBXL__DEVICE_KIND_VINPUT :LIBXL__DEVICE_KIND_VKBD ; + device->devid = type->devid; + device->domid = domid; + device->kind =LIBXL__DEVICE_KIND_VKBD ; + +return 0 ; +} +int libxl_device_vkb_add (libxl_ctx *ctx,uint32_t domid,libxl_device_vkb *vkb,const libxl_asyncop_how *ao_how) {
@@ -318,7 +328,6 @@ out:return rc; } -static LIBXL_DEFINE_DEVICE_FROM_TYPE(vkb) static LIBXL_DEFINE_UPDATE_DEVID(vkb)#define libxl__add_vkbs NULL
Signature · 7 lines
2.17.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 1/3] libxl: introduce new backend type VINPUT
Quoted 10 lines · Oleksandr Grytsov
From: Oleksandr Grytsov <[email protected]>
There are two kind of VKBD devices: with QEMU backend and user space PV backend. In current implementation they can't be distinguished as both use VKBD backend type. As result, user space PV KBD backend is started and stopped as QEMU backend. This commit adds new device kind VINPUT to be used as backend type for user space PV KBD backend.
Signed-off-by Oleksandr Grytsov <[email protected]>Acked-by Ian Jackson <[email protected]>
That patch removes the "backend-type" node from xenstore but it wasn't part of the api (kbdif.h) and qemu doesn't read, it so I guess that's fine:
Thanks,
Signature · 6 lines
Anthony PERARD _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 1/3] libxl: introduce new backend type VINPUT
Quoted 9 lines · Anthony PERARD
Quoted 8 lines · Oleksandr Grytsov
From: Oleksandr Grytsov <[email protected]>
There are two kind of VKBD devices: with QEMU backend and user space PV backend. In current implementation they can't be distinguished as both use VKBD backend type. As result, user space PV KBD backend is started and stopped as QEMU backend. This commit adds new device kind VINPUT to be used as backend type for user space PV KBD backend.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Oleksandr Grytsov <[email protected]>Acked-by Ian Jackson <[email protected]>That patch removes the "backend-type" node from xenstore but it wasn't part of the api (
kbdif.h) and qemu doesn't read, it so I guess that's fine:Acked-by Anthony PERARD <[email protected]>
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 1/3] libxl: introduce new backend type VINPUT
Quoted 13 lines · Jürgen Groß
Quoted 12 lines · Anthony PERARD
Quoted 10 lines · Oleksandr Grytsov
From: Oleksandr Grytsov <[email protected]>
There are two kind of VKBD devices: with QEMU backend and user space PV backend. In current implementation they can't be distinguished as both use VKBD backend type. As result, user space PV KBD backend is started and stopped as QEMU backend. This commit adds new device kind VINPUT to be used as backend type for user space PV KBD backend.
Signed-off-by Oleksandr Grytsov <[email protected]>Acked-by Ian Jackson <[email protected]>
Quoted 7 lines
Quoted 5 lines
That patch removes the "backend-type" node from xenstore but it wasn't part of the api (
kbdif.h) and qemu doesn't read, it so I guess that's fine:Acked-by Anthony PERARD <[email protected]>Release-acked-by Juergen Gross <[email protected]>
I take it this applies to both patch 1 and 3?
Wei.
Quoted 3 lines
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 1/3] libxl: introduce new backend type VINPUT
Wei Liu writes ("Re: [Xen-devel] [PATCH v2 1/3] libxl: introduce new backend type VINPUT"):
Quoted 4 lines · Jürgen Groß
Quoted 1 line
Release-acked-by Juergen Gross <[email protected]>I take it this applies to both patch 1 and 3?
In the absence of a reply to the contrary by 21:00 UTC today, I will assume this to be the case and push this to staging. I hope that meets with everyone's approval.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 1/3] libxl: introduce new backend type VINPUT
Quoted 9 lines · Ian Jackson
Wei Liu writes ("Re: [Xen-devel] [PATCH v2 1/3] libxl: introduce new backend type VINPUT"):
Quoted 4 lines · Jürgen Groß
Quoted 1 line
Release-acked-by Juergen Gross <[email protected]>I take it this applies to both patch 1 and 3?
In the absence of a reply to the contrary by 21:00 UTC today, I will assume this to be the case and push this to staging. I hope that meets with everyone's approval.
Got confirmation from Juergen on IRC, so I have just pushed patch 1 and 3.
Wei.
Quoted 2 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/3 libxl: rename VKB backend type "linux" to "pv"
In reply to Oleksandr GrytsovFrom: Oleksandr Grytsov <[email protected]>
There are two kind of VKB backends: QEMU and user space PV backend. For PV backend "linux" enum is used but this name is confused. Rename "linux" enum to "pv" as it better matches user space PV backend.
--- docs/man/xl.cfg.5.pod.in | 4 ++-- tools/libxl/libxl_types.idl | 2 +- tools/libxl/libxl_vkb.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
docs/man/xl.cfg.5.pod.in +2 -2
@@ -1562,8 +1562,8 @@ Specifies the backend domain name or id. =item B<backend-type=type> -Specifies the backend type: qemu - for QEMU backend or linux - for Linux PV -domain. +Specifies the backend type: qemu - for QEMU backend or pv - for PV +backend. =item B<feature-disable-keyboard=BOOLEAN>
tools/libxl/libxl_types.idl +1 -1
@@ -260,7 +260,7 @@ libxl_vuart_type = Enumeration("vuart_type", [ libxl_vkb_backend = Enumeration("vkb_backend", [ (0, "UNKNOWN"), (1, "QEMU"), - (2, "LINUX") + (2, "PV") ]) libxl_passthrough = Enumeration("passthrough", [
tools/libxl/libxl_vkb.c +2 -2
@@ -113,7 +113,7 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char *libxl_path,if (rc) goto out; vkb->backend_type = dev.backend_kind ==LIBXL__DEVICE_KIND_VINPUT ? -LIBXL_VKB_BACKEND_LINUX :LIBXL_VKB_BACKEND_QEMU ; +LIBXL_VKB_BACKEND_PV :LIBXL_VKB_BACKEND_QEMU ; vkb->unique_id =xs_read (CTX ->xsh,XBT_NULL ,GCSPRINTF ("%s/" XENKBD_FIELD_UNIQUE_ID , be_path),NULL );
@@ -219,7 +219,7 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid, { device->backend_devid = type->devid; device->backend_domid = type->backend_domid; - device->backend_kind = type->backend_type ==LIBXL_VKB_BACKEND_LINUX ? + device->backend_kind = type->backend_type ==LIBXL_VKB_BACKEND_PV ?LIBXL__DEVICE_KIND_VINPUT :LIBXL__DEVICE_KIND_VKBD ; device->devid = type->devid; device->domid = domid;
Signature · 7 lines
2.17.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 2/3] libxl: rename VKB backend type "linux" to "pv"
Oleksandr Grytsov writes ("[PATCH v2 2/3] libxl: rename VKB backend type "linux" to "pv""):
Quoted 7 lines
From: Oleksandr Grytsov <[email protected]>
There are two kind of VKB backends: QEMU and user space PV backend. For PV backend "linux" enum is used but this name is confused. Rename "linux" enum to "pv" as it better matches user space PV backend.
Signed-off-by Oleksandr Grytsov <[email protected]>
Thanks.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 2/3] libxl: rename VKB backend type "linux" to "pv"
Quoted 11 lines · Ian Jackson
Oleksandr Grytsov writes ("[PATCH v2 2/3] libxl: rename VKB backend type "linux" to "pv""):
Quoted 7 lines
From: Oleksandr Grytsov <[email protected]>
There are two kind of VKB backends: QEMU and user space PV backend. For PV backend "linux" enum is used but this name is confused. Rename "linux" enum to "pv" as it better matches user space PV backend.
Signed-off-by Oleksandr Grytsov <[email protected]>Requested-by Ian Jackson <[email protected]>Acked-by Ian Jackson <[email protected]>
The LINUX type was introduced back in 2018.
This patch should have provided at least a
#define ...LINUX ...PV
in libxl.h for backward compatibility purpose.
Wei.
Quoted 4 lines
Thanks.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 2/3] libxl: rename VKB backend type "linux" to "pv"
Wei Liu writes ("Re: [PATCH v2 2/3] libxl: rename VKB backend type "linux" to "pv""):
Quoted 1 line
The LINUX type was introduced back in 2018.
Oh. Yes. I used a wrong git-describe rune to try to find out where it had been introduced. The answer in fact is that it was in 4.12.0-rc1. Thanks for pointing this out.
Thanks also for the 2nd pair of eyes on
[PATCH v2 3/3] libxl: make default path to add/remove all PV devices
Quoted 3 lines
This patch should have provided at least a
#define ...LINUX ...PV
inlibxl.hfor backward compatibility purpose.
Under the circumstances, given that I suggested the rename during the 4.13 freeze, and the (IMO wrong) name was shipped in 4.12, it seems that we should drop this patch for 4.13. This is something that perhaps we should think about for the future but if it's been released already the cost of messing about with the name is sharply larger, and it may not be worth it at all. Sorry for messing you about more, Oleksandr.
The other two patches 1/ and 3/ apply and work just fine without this middle one, so I don't think we need a resend.
I'm still hoping for a 2nd pair of eyes on
[PATCH v2 1/3] libxl: introduce new backend type VINPUT
and a release ack for both 1/3 and 3/3.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 3/3 libxl: make default path to add/remove all PV devices
In reply to Oleksandr GrytsovFrom: Oleksandr Grytsov <[email protected]>
Adding/removing device is handled for specific devices only: VBD, VIF, QDISK. This commit adds default case to handle adding/removing for all PV devices by default, except QDISK device, which requires special handling. If any other device is required a special handling it should be done by implementing separate case (similar to QDISK device). The default behaviour for adding device is to wait when the backend goes to XenbusStateInitWait and the default behaviour on removing device is to start generic device remove procedure.
Also this commit fixes removing guest function: before the guest was removed when all VIF and VBD devices are removed. The fix removes guest when all created devices are removed. This is done by checking the guest device list instead of checking num_vifs and num_vbds. num_vifs and num_vbds variables are removed as redundant in this case.
--- tools/libxl/libxl_device.c | 63 +++++++++++++++----------------------- 1 file changed, 24 insertions(+), 39 deletions(-)
tools/libxl/libxl_device.c +24 -39
@@ -1477,7 +1477,7 @@ typedef struct libxl__ddomain_device {*/ typedef struct libxl__ddomain_guest {uint32_t domid; -int num_vifs, num_vbds, num_qdisks; +int num_qdisks; LIBXL_SLIST_HEAD(, struct libxl__ddomain_device) devices;LIBXL_SLIST_ENTRY (struct libxl__ddomain_guest ) next; }libxl__ddomain_guest ;
@@ -1530,8 +1530,7 @@ static void check_and_maybe_remove_guest(libxl__gc *gc, {assert (ddomain); -if (dguest !=NULL && - dguest->num_vifs + dguest->num_vbds + dguest->num_qdisks ==0 ) { +if (dguest !=NULL &&LIBXL_SLIST_FIRST (&dguest->devices) ==NULL ) {LIBXL_SLIST_REMOVE (&ddomain->guests, dguest, libxl__ddomain_guest, next);LOGD (DEBUG , dguest->domid,"Removed domain from the list of active guests" );
@@ -1571,24 +1570,6 @@ static int add_device(libxl__egc *egc, libxl__ao *ao, libxl__device_backend_path(gc, dev));switch (dev->backend_kind) { -case LIBXL__DEVICE_KIND_VBD : -case LIBXL__DEVICE_KIND_VIF : -if (dev->backend_kind ==LIBXL__DEVICE_KIND_VBD ) dguest->num_vbds++; -if (dev->backend_kind ==LIBXL__DEVICE_KIND_VIF ) dguest->num_vifs++; - -GCNEW (aodev); -libxl__prepare_ao_device (ao, aodev); -/* -* Clone the libxl__device to avoid races if remove_device is called -* before the device addition has finished. -*/ -GCNEW (aodev->dev); - *aodev->dev = *dev; - aodev->action =LIBXL__DEVICE_ACTION_ADD ; - aodev->callback = device_complete; -libxl__wait_device_connection (egc, aodev); - -break ;case LIBXL__DEVICE_KIND_QDISK :if (dguest->num_qdisks ==0 ) {GCNEW (dmss);
@@ -1599,10 +1580,19 @@ static int add_device(libxl__egc *egc, libxl__ao *ao,libxl__spawn_qdisk_backend (egc, dmss); } dguest->num_qdisks++; -break ;default : - rc =1 ; +GCNEW (aodev); +libxl__prepare_ao_device (ao, aodev); +/* +* Clone the libxl__device to avoid races if remove_device is called +* before the device addition has finished. +*/ +GCNEW (aodev->dev); + *aodev->dev = *dev; + aodev->action =LIBXL__DEVICE_ACTION_ADD ; + aodev->callback = device_complete; +libxl__wait_device_connection (egc, aodev);break ; }
@@ -1619,11 +1609,17 @@ static int remove_device(libxl__egc *egc, libxl__ao *ao,int rc =0 ;switch (ddev->dev->backend_kind) { -case LIBXL__DEVICE_KIND_VBD : -case LIBXL__DEVICE_KIND_VIF : -if (dev->backend_kind ==LIBXL__DEVICE_KIND_VBD ) dguest->num_vbds--; -if (dev->backend_kind ==LIBXL__DEVICE_KIND_VIF ) dguest->num_vifs--; - +case LIBXL__DEVICE_KIND_QDISK : +if (--dguest->num_qdisks ==0 ) { + rc =libxl__destroy_qdisk_backend (gc, dev->domid); +if (rc) + goto out; + } +libxl__device_destroy (gc, dev); +/* Return > 0, no ao has been dispatched */ + rc =1 ; +break ; +default :GCNEW (aodev);libxl__prepare_ao_device (ao, aodev);/*
@@ -1636,17 +1632,6 @@ static int remove_device(libxl__egc *egc, libxl__ao *ao, aodev->callback = device_complete;libxl__initiate_device_generic_remove (egc, aodev);break ; -case LIBXL__DEVICE_KIND_QDISK : -if (--dguest->num_qdisks ==0 ) { - rc =libxl__destroy_qdisk_backend (gc, dev->domid); -if (rc) - goto out; - } -libxl__device_destroy (gc, dev); -/* Fall through to return > 0, no ao has been dispatched */ -default : - rc =1 ; -break ; }/*
Signature · 7 lines
2.17.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 3/3] libxl: make default path to add/remove all PV devices
Oleksandr Grytsov writes ("[PATCH v2 3/3] libxl: make default path to add/remove all PV devices"):
Quoted 11 lines
From: Oleksandr Grytsov <[email protected]>
Adding/removing device is handled for specific devices only: VBD, VIF, QDISK. This commit adds default case to handle adding/removing for all PV devices by default, except QDISK device, which requires special handling. If any other device is required a special handling it should be done by implementing separate case (similar to QDISK device). The default behaviour for adding device is to wait when the backend goes to XenbusStateInitWait and the default behaviour on removing device is to start generic device remove procedure.
Quoted 5 lines
Also this commit fixes removing guest function: before the guest was removed when all VIF and VBD devices are removed. The fix removes guest when all created devices are removed. This is done by checking the guest device list instead of checking
num_vifsandnum_vbds.num_vifsandnum_vbdsvariables are removed as redundant in this case.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 3/3] libxl: make default path to add/remove all PV devices
In reply to Oleksandr GrytsovQuoted 11 lines · Oleksandr Grytsov
From: Oleksandr Grytsov <[email protected]>
Adding/removing device is handled for specific devices only: VBD, VIF, QDISK. This commit adds default case to handle adding/removing for all PV devices by default, except QDISK device, which requires special handling. If any other device is required a special handling it should be done by implementing separate case (similar to QDISK device). The default behaviour for adding device is to wait when the backend goes to XenbusStateInitWait and the default behaviour on removing device is to start generic device remove procedure.
Quoted 7 lines
Also this commit fixes removing guest function: before the guest was removed when all VIF and VBD devices are removed. The fix removes guest when all created devices are removed. This is done by checking the guest device list instead of checking
num_vifsandnum_vbds.num_vifsandnum_vbdsvariables are removed as redundant in this case.Signed-off-by Oleksandr Grytsov <[email protected]>
I agree with this approach in general, but I haven't looked closely into the implementation. FWIW:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Oleksandr Grytsov writes ("[PATCH v2 0/3] Remove backend xen store entry on domain destroy"):
Quoted 8 lines
From: Oleksandr Grytsov <[email protected]>
Changes since v1:
* add commit to rename VKB backend type "linux" to "pv";
* add default case to handle adding/removing PV devices inadd_device,remove_devicefunctions (libxl_device.c);
* add comment about removingnum_vifs,num_vbdsinto commit message.
Thank you for this. As you see, I approve. We need an ack from the Release Manager, so I have addresed Juergen (and also added the missing `for-4.13' tag to the subject).
Given where we are in the release cycle with this (which I stress is not really Oleksandr's fault) I think I would like to get a 2nd review from another libxl maintainer. Anthony, or Wei, would you like to take a look ?
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel