libxl: Stubdom cd-rom changing support
cover libxl: Stubdom cd-rom changing support
These two patches enable cd-rom media changing for an HVM with a linux stubdom.
The first patch allows use of non-QDISK drives with a stubdom. The second expands the cd-rom changing code to support the stubdom case.
To change the cd-rom medium, libxl will:
- QMP eject the medium from QEMU
- block-detach the old PV disk
- block-attach the new PV disk
- QMP change the medium to the new PV disk by fdset-id
The QMP change insert uses fdset-id STUBDOM_FDSET_CD + $disk - 'a'. That is, hda -> 'a', soSTUBDOM_FDSET_CD + 'a' - 'a' = STUBDOM_FDSET_CD.
For hdc:STUBDOM_FDSET_CD + 'c' - 'a' = STUBDOM_FDSET_CD + 2.
The stubdom must internally handle adding /dev/xvdc to the appropriate fdset inside QEMU.
A script like this:
https://github.com/OpenXT/xenclient-oe/blob/master/recipes-core/initrdscripts/initramfs-stubdomain/qemu-xvdc-add-fd.sh
Can be called by busybox mdev configured like this:
https://github.com/OpenXT/xenclient-oe/blob/master/recipes-core/busybox/files/mdev.conf
Jason Andryuk (2):
libxl: Remove cdrom forced QDISK w/ stubdom
libxl: Enable stubdom cdrom changing
docs/misc/stubdom.txt | 16 ++ tools/libs/light/libxl_disk.c | 302 ++++++++++++++++++++++++++++++---- 2 files changed, 287 insertions(+), 31 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 libxl: Remove cdrom forced QDISK w/ stubdom
A Linux HVM domain ignores PV block devices with type cdrom. The Windows PV drivers also ignore device-type != "disk". Therefore QEMU's emulated CD-ROM support is used. This allows ejection and other CD-ROM features to work.
With a stubdom, QEMU is running in the stubdom. A PV disk is still connected into the stubdom, and then QEMU can emulate the CD-ROM into the guest. This removes the need for forcing to a QDISK. Relax the checks to support this.
--- tools/libs/light/libxl_disk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libs/light/libxl_disk.c +2 -1
@@ -192,7 +192,8 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid,/* Force Qdisk backend for CDROM devices of guests with a device model. */ if (disk->is_cdrom !=0 && -libxl__domain_type (gc, domid) ==LIBXL_DOMAIN_TYPE_HVM ) { +libxl__domain_type (gc, domid) ==LIBXL_DOMAIN_TYPE_HVM && + !libxl_get_stubdom_id (CTX , domid)) {if (!(disk->backend ==LIBXL_DISK_BACKEND_QDISK || disk->backend ==LIBXL_DISK_BACKEND_UNKNOWN )) {LOGD (ERROR , domid,"Backend for CD devices on HVM guests must be Qdisk" );
Signature · 1 line
2.43.0
Re: [PATCH 1/2] libxl: Remove cdrom forced QDISK w/ stubdom
Quoted 20 lines · Jason Andryuk
A Linux HVM domain ignores PV block devices with type cdrom. The Windows PV drivers also ignore device-type != "disk". Therefore QEMU's emulated CD-ROM support is used. This allows ejection and other CD-ROM features to work.
With a stubdom, QEMU is running in the stubdom. A PV disk is still connected into the stubdom, and then QEMU can emulate the CD-ROM into the guest. This removes the need for forcing to a QDISK. Relax the checks to support this.
Signed-off-by Jason Andryuk <[email protected]>--- tools/libs/light/libxl_disk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tools/libs/light/libxl_disk.c +0
-0
tools/libs/light/libxl_disk.c static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid, · line 196
Quoted 6 lines
tools/libs/light/libxl_disk.c +2
-1@@ -192,7 +192,8 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid,/* Force Qdisk backend for CDROM devices of guests with a device model. */ if (disk->is_cdrom !=0 && -libxl__domain_type (gc, domid) ==LIBXL_DOMAIN_TYPE_HVM ) { +libxl__domain_type (gc, domid) ==LIBXL_DOMAIN_TYPE_HVM && + !libxl_get_stubdom_id (CTX , domid)) {
Should this check for stubdomain flavor too? I guess it won't really work with qemu-traditional.
Similar check also wants to be in the next patch, instead of completely dropping stubdomain check.
Quoted 6 lines
tools/libs/light/libxl_disk.c +0
-0if (!(disk->backend ==LIBXL_DISK_BACKEND_QDISK || disk->backend ==LIBXL_DISK_BACKEND_UNKNOWN )) {LOGD (ERROR , domid,"Backend for CD devices on HVM guests must be Qdisk" );Signature · 1 line
2.43.0
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
PATCH 2/2 libxl: Enable stubdom cdrom changing
In reply to Jason AndryukTo change the cd-rom medium, libxl will:
- QMP eject the medium from QEMU
- block-detach the old PV disk
- block-attach the new PV disk
- QMP change the medium to the new PV disk by fdset-id
The QMP code is reused, and remove and attach are implemented here.
The stubdom must internally handle adding /dev/xvdc to the appropriate fdset. libxl in dom0 doesn't see the result of adding to the fdset as that is internal to the stubdom, so a delay and retries are added to around calling cdrom_insert_addfd_cb().
--- docs/misc/stubdom.txt | 16 ++ tools/libs/light/libxl_disk.c | 299 ++++++++++++++++++++++++++++++---- 2 files changed, 285 insertions(+), 30 deletions(-)
docs/misc/stubdom.txt +16 -0
@@ -127,6 +127,22 @@ Limitations: - at most 26 emulated disks are supported (more are still available as PV disks) - graphics output (VNC/SDL/Spice) not supported +CD-ROM changing: + +To change the CD-ROM medium, libxl will: + - QMP eject the medium from QEMU + - block-detach the old PV disk + - block-attach the new PV disk + - QMP change the medium to the new PV disk by fdset-id + +The QMP change insert uses fdset-id STUBDOM_FDSET_CD + $disk - 'a'. +That is, hda -> 'a', so +STUBDOM_FDSET_CD + 'a' - 'a' = STUBDOM_FDSET_CD. +For hdc: +STUBDOM_FDSET_CD + 'c' - 'a' = STUBDOM_FDSET_CD + 2. + +The stubdom must internally handle adding /dev/xvdc to the appropriate +fdset. PV-GRUB =======
tools/libs/light/libxl_disk.c +269 -30
474 lines not on this page · raw message
Signature · 1 line
2.43.0