libxl: Improve `xl cd-eject`
Description:
Linux tend to lock the cd-rom tray, so usually, when someone try to eject a cd-rom from a Linux VM, they will first get an error, but a retry a few second later works. Linux would have unlock the cd-rom tray and QEMU would happily eject the cd-rom on the second try.
Instead of having to try again, libxl
could do the retry automatically.
When trying to to execute xl cd-eject $vm hdc
, we have the GenericError
error messsage:
libxl_qmp.c:1837:qmp_ev_parse_error_messages: Domain 15:Device 'ide-5632' is locked and force was not specified, wait for tray to open and try again
When this happen, libxl
could wait for an event to be send by QEMU to tell that the tray is now open, then try again or timeout. The QMP message is something like
{'timestamp': {'seconds': 1707843081, 'microseconds': 865458}, 'event': 'DEVICE_TRAY_MOVED', 'data': {'device': 'ide-5632', 'tray-open': True, 'id': 'ide-5632'}}
There's no support in libxl
to wait for QMP events, so that would need to be added.
Edited by Anthony PERARD