libxl: Stubdom cd-rom changing support
PATCH v2 1/3 libxl: Create empty file for Phy cdrom
In reply to Jason AndryukWith a device model stubdom, dom0 exports a PV disk to the stubdom. Inside the stubdom, QEMU emulates a cdrom to the guest with a host_device pointing at the PV frontend (/dev/xvdc)
An empty cdrom drive causes problems booting the stubdom. The PV disk protocol isn't designed to support no media. That can be partially hacked around, but the stubdom kernel waits for all block devices to transition to Connected. Since the backend never connects empty media, stubdom launch times out and it is destroyed.
Empty media and the PV disks not connecting is fine at runtime since the stubdom keeps running irrespective of the disk state.
Empty media can be worked around my providing an empty file to the stubdom for the PV disk source. This works as the disk is exposed as a zero-size disk. Dynamically create the empty file as needed and remove in the stubdom cleanup.
libxl__device_disk_set_backend() needs to allow through these "empty" disks with a pdev_path.
Fixup the params writing since scripts have trouble with an empty params field.
This works for non-stubdom HVMs as well.
---
v2:
New to support "empty" cdroms
--- tools/libs/light/libxl_device.c | 5 ++++- tools/libs/light/libxl_disk.c | 36 +++++++++++++++++++++++++++---- tools/libs/light/libxl_domain.c | 4 ++++ tools/libs/light/libxl_internal.h | 1 + 4 files changed, 41 insertions(+), 5 deletions(-)
tools/libs/light/libxl_device.c +4 -1
@@ -421,7 +421,10 @@ int libxl__device_disk_set_backend(libxl__gc *gc, libxl_device_disk *disk) {LOG (ERROR ,"Disk vdev=%s is empty but not cdrom" , disk->vdev);return ERROR_INVAL ; } -if (disk->pdev_path !=NULL &&strcmp (disk->pdev_path,"" )) { +if (disk->pdev_path !=NULL && + (strcmp (disk->pdev_path,"" ) && +strncmp (disk->pdev_path,LIBXL_STUBDOM_EMPTY_CDROM , +strlen (LIBXL_STUBDOM_EMPTY_CDROM )))) {LOG (ERROR ,"Disk vdev=%s is empty but an image has been provided: %s" , disk->vdev, disk->pdev_path);
tools/libs/light/libxl_disk.c +32 -4
@@ -199,6 +199,32 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid, disk->backend =LIBXL_DISK_BACKEND_QDISK ; } +if (disk->is_cdrom && + disk->format ==LIBXL_DISK_FORMAT_EMPTY && + disk->backend ==LIBXL_DISK_BACKEND_PHY && + disk->backend_domid ==LIBXL_TOOLSTACK_DOMID ) { +uint32_t target_domid; +int fd; + +if (libxl_is_stubdom (CTX , domid, &target_domid)) { +LOGED (DEBUG , domid,"Using target_domid %u" , target_domid); + }else { + target_domid = domid; + } +free (disk->pdev_path); + disk->pdev_path = +libxl__sprintf (NOGC ,LIBXL_STUBDOM_EMPTY_CDROM ".%u" , + target_domid); + fd =creat (disk->pdev_path,0400 ); +if (fd <0 ) { +LOGED (ERROR , domid,"Failed to create empty cdrom \"%s\"" , + disk->pdev_path); +return ERROR_FAIL ; + } + +close (fd); + } + rc =libxl__device_disk_set_backend (gc, disk);return rc; }
@@ -988,7 +1014,7 @@ static void cdrom_insert_ejected(libxl__egc *egc, empty =flexarray_make (gc,4 ,1 );flexarray_append_pair (empty,"type" ,libxl__device_disk_string_of_backend (disk->backend)); -flexarray_append_pair (empty,"params" ,"" ); +flexarray_append_pair (empty,"params" , disk->pdev_path ?:"" );for (;;) { rc =libxl__xs_transaction_start (gc, &t);
@@ -1164,13 +1190,15 @@ static void cdrom_insert_inserted(libxl__egc *egc, insert =flexarray_make (gc,4 ,1 );flexarray_append_pair (insert,"type" ,libxl__device_disk_string_of_backend (disk->backend)); -if (disk->format !=LIBXL_DISK_FORMAT_EMPTY ) +if (disk->backend ==LIBXL_DISK_BACKEND_QDISK && + disk->format !=LIBXL_DISK_FORMAT_EMPTY ) {flexarray_append_pair (insert,"params" ,GCSPRINTF ("%s:%s" ,libxl__device_disk_string_of_format (disk->format), disk->pdev_path)); -else -flexarray_append_pair (insert,"params" ,"" ); + }else { +flexarray_append_pair (insert,"params" , disk->pdev_path ?:"" ); + }for (;;) { rc =libxl__xs_transaction_start (gc, &t);
tools/libs/light/libxl_domain.c +4 -0
@@ -1525,6 +1525,10 @@ static void devices_destroy_cb(libxl__egc *egc,if (rc <0 )LOGD (ERROR , domid,"libxl__devices_destroy failed" ); +/* Remove the file after the hotplug scripts have run. The scripts won't +* run if the file doesn't exist when they are run. */ +libxl__remove_file (gc,GCSPRINTF (LIBXL_STUBDOM_EMPTY_CDROM ".%u" , domid)); + vm_path =libxl__xs_read (gc,XBT_NULL ,GCSPRINTF ("%s/vm" , dom_path));if (vm_path)if (!xs_rm (ctx->xsh,XBT_NULL , vm_path))
tools/libs/light/libxl_internal.h +1 -0
@@ -120,6 +120,7 @@#define STUBDOM_CONSOLE_SERIAL 3#define STUBDOM_SPECIAL_CONSOLES 3#define LIBXL_LINUX_STUBDOM_MEM 128 +#define LIBXL_STUBDOM_EMPTY_CDROM XEN_RUN_DIR "/empty-cdrom"/* .$domid */ #define TAP_DEVICE_SUFFIX "-emu"#define DOMID_XS_PATH "domid"#define PVSHIM_BASENAME "xen-shim"
Signature · 1 line
2.43.0
v2 cover libxl: Stubdom cd-rom changing support
These patches enable cd-rom media changing for an HVM with a linux stubdom.
v1 didn't support these empty drives. The code came out of OpenXT which has a hack - null.iso. null.iso is an ISO with no contents. OpenXT doesn't actually eject the cd-rom, it just inserts null.iso. This patch set has QEMU present empty media.
The first patch creates an empty file, /run/xen/empty-cdrom.%u, for Phy drives that are "empty". The place holder simplifies things because the block scripts don't work for an empty params. Even if the scripts were modified for that, a stubdom will timeout on startup when the empty disk/blkback never connects. The empty file works around these issues.
The second patch allows use of Phy backend drives for a cd-rom. This works for non-stubdom HVMs. Actually special casing stubdoms didn't work.
The third patch 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
xl cd-eject follows the above through connecting the new PV disk, empty-cdrom.%u. It skips the QMP media change. This keeps the xenstore entries which are needed to identify that a cd-rom drive is present. If the xenstore entries were removed on eject, libxl wouldn't find the device (hdc) for a subsequent cd-insert.
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
(OpenXT mdev as the hotplug helper works, but with a ~Qubes stubdom, I had to run mdev as a daemon, mdev -d.)
Linux locks the cd-rom by default? That means the QMP eject commands fail, but then Linux unlocks. Re-running a second time works. Windows doesn't do that.
There are spurious messages sometimes like:
libxl: error: libxl_qmp.c:1837:qmp_ev_parse_error_messages: Domain 5:Could not dup FD for /dev/fdset/8002 flags 0: No such file or directory
libxl doesn't know when the stubdom has setup the fdset. Since it gets those errors, it'll retry adding to the fdset.
Jason Andryuk (3):
libxl: Create empty cdrom file for stubdom
libxl: Allow Phy backend for CDROM devices
libxl: Enable stubdom cdrom changing
docs/misc/stubdom.txt | 16 ++ tools/libs/light/libxl_device.c | 17 +- tools/libs/light/libxl_disk.c | 345 +++++++++++++++++++++++++++--- tools/libs/light/libxl_domain.c | 4 + tools/libs/light/libxl_internal.h | 1 + 5 files changed, 344 insertions(+), 39 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 2/3 libxl: Allow Phy backend for CDROM devices
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. Phy support has been enhanced to provide a placeholder file forempty disks, so it is usable as a CDROM backend as well. Allow Phy to pass the check as well.
(Bypassing just for a linux-based stubdom doesn't work because libxl__device_disk_setdefault() gets called early in domain creation before xenstore is populated with relevant information for the stubdom type. The build information isn't readily available and won't exist in some call trees, so it isn't usable either.)
Let disk_try_backend() allow format empty for Phy cdrom drives.
---
v2:
Different approach to pass QDISK requirement check.
--- tools/libs/light/libxl_device.c | 12 ++++++++---- tools/libs/light/libxl_disk.c | 11 +++++++---- 2 files changed, 15 insertions(+), 8 deletions(-)
tools/libs/light/libxl_device.c +8 -4
@@ -301,13 +301,17 @@ static int disk_try_backend(disk_try_backend_args *a,switch (backend) {case LIBXL_DISK_BACKEND_PHY : -if (a->disk->format !=LIBXL_DISK_FORMAT_RAW ) { - goto bad_format; - } -if (libxl_defbool_val (a->disk->colo_enable)) goto bad_colo; +if (a->disk->is_cdrom && a->disk->format ==LIBXL_DISK_FORMAT_EMPTY ) { +LOG (DEBUG ,"Disk vdev=%s is an empty cdrom" , a->disk->vdev); +return backend; + } + +if (a->disk->format !=LIBXL_DISK_FORMAT_RAW ) + goto bad_format; +if (a->disk->backend_domid !=LIBXL_TOOLSTACK_DOMID ) {LOG (DEBUG ,"Disk vdev=%s, is using a storage driver domain, " "skipping physical device check" , a->disk->vdev);
tools/libs/light/libxl_disk.c +7 -4
@@ -188,15 +188,18 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid,return ERROR_FAIL ; } -/* Force Qdisk backend for CDROM devices of guests with a device model. */ +/* Only allow Qdisk or Phy for CDROM devices. */ if (disk->is_cdrom !=0 &&libxl__domain_type (gc, domid) ==LIBXL_DOMAIN_TYPE_HVM ) { +if (disk->backend ==LIBXL_DISK_BACKEND_UNKNOWN ) + disk->backend =LIBXL_DISK_BACKEND_QDISK ; +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" ); + disk->backend ==LIBXL_DISK_BACKEND_PHY )) { +LOGD (ERROR , domid, +"Backend for CD devices on HVM guests must be Qdisk or Phy" );return ERROR_FAIL ; } - disk->backend =LIBXL_DISK_BACKEND_QDISK ; } if (disk->is_cdrom &&
Signature · 1 line
2.43.0
PATCH v2 3/3 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().
For cd-eject, we still need to attach the empty vbd. This is necessary since xenstore is used to determine that hdc exists. Otherwise after eject, hdc would be gone and the cd-insert would fail to find the drive to insert new media.
The ERROR_JSON_CONFIG_EMPTY check in cdrom_insert_inserted() is because a stubdom don't have a json config.
---
v2:
Only allow for Linux stubdoms (Marek)
Fix cd-eject
Fix errant hard tabs
Move the debug print and into the special case.
--- docs/misc/stubdom.txt | 16 ++ tools/libs/light/libxl_disk.c | 298 +++++++++++++++++++++++++++++++--- 2 files changed, 288 insertions(+), 26 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 +272 -26
467 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v2 3/3] libxl: Enable stubdom cdrom changing
Quoted 6 lines · Jason Andryuk
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
Quoted 6 lines
The QMP code is reused, and remove and attach are implemented here.
The stubdom must internally handle adding
/dev/xvdcto 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 callingcdrom_insert_addfd_cb().
Why do you use "fdset" in linux stubdom, can't QEMU open /dev/xvdc directly? And so why don't libxl tell QEMU to open /dev/xvdc?
I think the only reason I've implemented cd-insert via fdset in libxl was because that was the only way to have libxl open a file on behalf of QEMU when it's deprivileged and don't have access to any file. But that doesn't mean we need to use an fdset with the stubdom.
And BTW, there's a "query-fdsets" command that could be used to findout when and fdset is available, there's even an "opaque" field that could be used to communicate which fdset to use instead of needing to rely on a static fdset-id.
Quoted 15 lines
For cd-eject, we still need to attach the empty vbd. This is necessary since xenstore is used to determine that hdc exists. Otherwise after eject, hdc would be gone and the cd-insert would fail to find the drive to insert new media.
The
ERROR_JSON_CONFIG_EMPTYcheck incdrom_insert_inserted()is because a stubdom don't have a json config.Signed-off-by Jason Andryuk <[email protected]>---
tools/libs/light/libxl_disk.c +0
-0
tools/libs/light/libxl_disk.c int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk, · line 945
Quoted 8 lines
tools/libs/light/libxl_disk.c +5
-0@@ -905,6 +938,18 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk, disk->format =LIBXL_DISK_FORMAT_EMPTY ; } +#define STUBDOM_FDSET_CD 8000 +if (strncmp (disk->vdev,"hd" ,2 ) ==0 ) { + cis->stubdom_fdset =STUBDOM_FDSET_CD + disk->vdev[2 ] -'a' ; + }else if (strncmp (disk->vdev,"xvd" ,3 ) ==0 ) { + cis->stubdom_fdset =STUBDOM_FDSET_CD + disk->vdev[3 ] -'a' ;
Currently, cd-rom eject/insert also works if one use "sdc", so we probably want to check for "sd".
Also, you could use device_virtdisk_matches() like libxl__device_disk_dev_number(). I'm not sure if having vdev been something like "xvdaa" is going to work well, and that case isn't going to produce the expected fdset. (Without the patch, "xvdaa" produce a warning when trying to generate QEMU's command line, so maybe it's fine to not handle this case.)
Quoted 11 lines
tools/libs/light/libxl_disk.c +7
-0+ }else { +LOGD (ERROR , cis->domid,"disk->vdev \"%s\" isn't hdX or xvdY" , + disk->vdev); + rc =ERROR_FAIL ; + goto out; + } + out:libxl__device_list_free (&libxl__disk_devtype, disks, num);if (rc) {
tools/libs/light/libxl_disk.c static void cdrom_insert_lock_acquired(libxl__egc *egc, · line 971
Quoted 4 lines
tools/libs/light/libxl_disk.c +1
-0@@ -923,6 +968,7 @@ static void cdrom_insert_lock_acquired(libxl__egc *egc,libxl__cdrom_insert_state *cis =CONTAINER_OF (lock, *cis, qmp_lock);STATE_AO_GC (cis->ao); +LOGD (DEBUG , cis->domid,"rc=%d" , rc);
Left over debug logging? The new one in cdrom_insert_done() might be enough? Also, I think libxl__ao_complete() does log this rc value as well.
tools/libs/light/libxl_disk.c out: · line 1066
Quoted 13 lines
tools/libs/light/libxl_disk.c +8
-0if (rc) goto out; rc = libxl__ev_time_register_rel(ao, &cis->time, +static void cdrom_insert_stubdom_ejected(libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) +{ + libxl__cdrom_insert_state *cis = CONTAINER_OF(qmp, *cis, qmp); + libxl__device *device; + STATE_AO_GC(cis->ao); + domid_t stubdomid = libxl_get_stubdom_id(CTX, cis->domid);
cis->disk_domid?
tools/libs/light/libxl_disk.c out: · line 1078
Quoted 12 lines
tools/libs/light/libxl_disk.c +12
-0+ +LOGD (DEBUG , cis->domid,"rc=%d" , rc); +/* cis->stubdom_fdset is initially empty, so remove-fd fails the first +* call with: +* {"error": {"class": "GenericError", +* "desc": "File descriptor named 'fdset-id:8675' not found"}} +* Carry on in that case. */ +if (rc && rc !=ERROR_QMP_GENERIC_ERROR ) goto out; + +GCNEW (device); + rc =libxl__device_from_disk (gc, stubdomid, cis->disk, device); +if (rc !=0 ) goto out;
If (rc) is more common without "!= 0".
tools/libs/light/libxl_disk.c out: · line 1082
Quoted 4 lines
tools/libs/light/libxl_disk.c +4
-0+ +/* block dev eject */ +/* Below is basically an open coding of: +* libxl_device_disk__remove(CTX, cis->domid, cis->disk, 0);
One too many '_'?
Quoted 1 line
+ * ...since we can't call it from within libxl.
Well, not exactly, we also need to set our own callback and own struct here.
tools/libs/light/libxl_disk.c out: · line 1090
Quoted 7 lines
tools/libs/light/libxl_disk.c +7
-0+*/ +libxl__prepare_ao_device (ao, &cis->aodev_del); + cis->aodev_del.action =LIBXL__DEVICE_ACTION_REMOVE ; + cis->aodev_del.dev = device; + cis->aodev_del.callback = cdrom_insert_stubdom_disk_ejected_aocomplete; + cis->aodev_del.force.flag =LIBXL__FORCE_OFF ; +libxl__initiate_device_generic_remove (egc, &cis->aodev_del);
It doesn't looks like you need an extra aodev_del field, and you can probably reuse the same aodev field twice.
Quoted 5 lines
tools/libs/light/libxl_disk.c +5
-0+return ; + + out: +cdrom_insert_done (egc, cis, rc);/* must be last */ +}
tools/libs/light/libxl_disk.c out: · line 1105
Quoted 10 lines
tools/libs/light/libxl_disk.c +10
-0+ +static void cdrom_insert_stubdom_disk_ejected_aocomplete (libxl__egc *egc, +libxl__ao_device *aodev) +{ +STATE_AO_GC (aodev->ao); +libxl__cdrom_insert_state *cis =CONTAINER_OF (aodev, *cis, aodev_del); + +LOGD (DEBUG , cis->domid,"rc=%d" , aodev->rc); +if (aodev->rc) { +if (aodev->dev) {
I'm pretty sure "aodev->dev" should be set, so this if doesn't seems needed.
tools/libs/light/libxl_disk.c
Quoted 2 lines
tools/libs/light/libxl_disk.c +2
-0+ LOGD(ERROR, aodev->dev->domid, "Unable to %s %s with id %u", + libxl__device_action_to_string(aodev->action),
We already know the action is "remove".
tools/libs/light/libxl_disk.c
Quoted 2 lines
tools/libs/light/libxl_disk.c +2
-0+libxl__device_kind_to_string (aodev->dev->kind), + aodev->dev->devid);
This whole message could be personalised to what we are trying to achieve, that is, remove the cd-rom from the stubdomain.
Quoted 8 lines
tools/libs/light/libxl_disk.c +8
-0+ }else { +LOG (ERROR ,"unable to %s device" , +libxl__device_action_to_string (aodev->action)); + } + goto out; + } + +cdrom_insert_stubdom_disk_ejected (egc, &cis->qmp,NULL , aodev->rc);
tools/libs/light/libxl_disk.c out: · line 1127
Quoted 10 lines
tools/libs/light/libxl_disk.c +10
-0+return ; + + out: +cdrom_insert_done (egc, cis, aodev->rc); +} + +static void cdrom_insert_stubdom_disk_ejected (libxl__egc *egc, +libxl__ev_qmp *qmp, +const libxl__json_object *response, +int rc)
This functions prototype looks like a ev_qmp callback but it's never used like that. Also, it could be merged into the previous function.
tools/libs/light/libxl_disk.c out: · line 1389
Quoted 8 lines
static void cdrom_insert_inserted(libxl__egc *egc,
libxl__ev_qmp*qmp, constlibxl__json_object*response, int rc)
{tools/libs/light/libxl_disk.c +1
-1-EGC_GC ;libxl__cdrom_insert_state *cis =CONTAINER_OF (qmp, *cis, qmp); +STATE_AO_GC (cis->ao);
Why do you replace EGC_GC by AO_GC ? Is there an allocation that need to last longer in the current function? If it's just to have "ao" in the current scope, you can use "cis->ao" below.
Quoted 29 lines
libxl__flock *data_lock = NULL; libxl_domain_config d_config; flexarray_t *insert = NULL;tools/libs/light/libxl_disk.c +15
-2@@ -1171,9 +1401,22 @@ static void cdrom_insert_inserted(libxl__egc *egc,libxl_domain_config_init (&d_config); -if (rc) goto out; +LOGD (DEBUG , cis->domid,"rc=%d" , rc); + +if (rc) { +if (cis->retries++ <10 ) { +LOGD (DEBUG , qmp->domid,"Retrying QMP cdrom change\n" ); + rc =libxl__ev_time_register_rel (ao, &cis->timeout_retry, + cdrom_insert_addfd_retry,100 ); +if (rc) goto out; - rc =libxl__device_from_disk (gc, domid, disk, &device); +return ; + }else { + goto out; + } + } + + rc =libxl__device_from_disk (gc, cis->disk_domid, disk, &device);if (rc) goto out; be_path =libxl__device_backend_path (gc, &device); libxl_path =libxl__device_libxl_path (gc, &device);
tools/libs/light/libxl_disk.c static void cdrom_insert_done(libxl__egc *egc, · line 1503
Quoted 4 lines
tools/libs/light/libxl_disk.c +1
-0@@ -1257,7 +1500,10 @@ static void cdrom_insert_done(libxl__egc *egc, {EGC_GC ; +LOGD (DEBUG , cis->domid,"rc=%d" , rc);
I don't think this is useful because libxl__ao_complete() will print rc as well.
Quoted 5 lines
tools/libs/light/libxl_disk.c +1
-0libxl__ev_time_deregister (gc, &cis->time); +libxl__ev_time_deregister (gc, &cis->timeout_retry);libxl__ev_qmp_dispose (gc, &cis->qmp);if (cis->qmp.payload_fd >=0 )close (cis->qmp.payload_fd);libxl__ev_slowlock_unlock (gc, &cis->qmp_lock);
Signature · 1 line
Anthony PERARD
Quoted 3 lines · Jason Andryuk
Linux locks the cd-rom by default? That means the QMP eject commands fail, but then Linux unlocks. Re-running a second time works. Windows doesn't do that.
Yes, looks like it. It would be possible to have libxl retry automatically since Linux eject and unlock the cd-rom tray, then QEMU does send an event via QMP about this, so libxl could retry after receiving the event. Waiting for events is just not implemented in libxl, but that something that could be done.
The event is, for example:
'event': 'DEVICE_TRAY_MOVED', 'data': {'device': 'ide-5632', 'tray-open': True, 'id': 'ide-5632'}Cheers,
Signature · 1 line
Anthony PERARD
Re: [PATCH v2 1/3] libxl: Create empty file for Phy cdrom
In reply to Jason AndryukQuoted 21 lines · Jason Andryuk
With a device model stubdom, dom0 exports a PV disk to the stubdom. Inside the stubdom, QEMU emulates a cdrom to the guest with a
host_devicepointing at the PV frontend (/dev/xvdc)An empty cdrom drive causes problems booting the stubdom. The PV disk protocol isn't designed to support no media. That can be partially hacked around, but the stubdom kernel waits for all block devices to transition to Connected. Since the backend never connects empty media, stubdom launch times out and it is destroyed.
Empty media and the PV disks not connecting is fine at runtime since the stubdom keeps running irrespective of the disk state.
Empty media can be worked around my providing an empty file to the stubdom for the PV disk source. This works as the disk is exposed as a zero-size disk. Dynamically create the empty file as needed and remove in the stubdom cleanup.
libxl__device_disk_set_backend()needs to allow through these "empty" disks with apdev_path.
Quoted 6 lines
Fixup the params writing since scripts have trouble with an empty params field.
This works for non-stubdom HVMs as well.
Signed-off-by Jason Andryuk <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
Re: [PATCH v2 2/3] libxl: Allow Phy backend for CDROM devices
In reply to Jason AndryukQuoted 17 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. Phy support has been enhanced to provide a placeholder file forempty disks, so it is usable as a CDROM backend as well. Allow Phy to pass the check as well.
(Bypassing just for a linux-based stubdom doesn't work because
libxl__device_disk_setdefault()gets called early in domain creation before xenstore is populated with relevant information for the stubdom type. The build information isn't readily available and won't exist in some call trees, so it isn't usable either.)
Quoted 3 lines
Let
disk_try_backend()allow format empty for Phy cdrom drives.Signed-off-by Jason Andryuk <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD