Results of quick test run now, patch review to follow. Test uses a simple program to try ioctl CDROM_DRIVE_STATUS (attached).
Test run in the host: [start with tray closed & empty] $ ./drive-status CDS_NO_DISC $ eject /dev/sr0 [tray opens] $ ./drive-status CDS_TRAY_OPEN $ eject -t /dev/sr0 [tray closes] $ ./drive-status CDS_NO_DISC [open tray, insert media, close tray] $ ./drive-status CDS_DISC_OK $ eject /dev/sr0 [tray opens] $ ./drive-status CDS_TRAY_OPEN $ eject -t /dev/sr0 [tray closes] $ ./drive-status CDS_DRIVE_NOT_READY [ok, too impatient] $ ./drive-status CDS_DISC_OK Test in guest without your patches: [start with empty drive] # ./drive-status CDS_NO_DISC # eject /dev/sr0 # ./drive-status CDS_NO_DISC [incorrect, should be CDS_TRAY_OPEN] # eject -t /dev/sr0 # ./drive-status CDS_NO_DISC [insert media with monitor command change] # ./drive-status CDS_DISC_OK # eject /dev/sr0 # ./drive-status CDS_NO_DISC [incorrect, should be CDS_TRAY_OPEN] # eject -t /dev/sr0 # ./drive-status CDS_DISC_OK With the patches, it behaves as expected. Except something (guest kernel?) closes the tray right after eject if there's a medium in the open tray. Anaconda is *much* happier with the patches. Before, it could get into a confused state where it can't find install medium because the tray is stuck open. Now, it recovers from "can't find" on first retry, by closing the tray.
#include <errno.h> #include <error.h> #include <fcntl.h> #include <limits.h> #include <stdio.h> #include <linux/cdrom.h> #include <sys/ioctl.h> char * cdsstr(int cds) { static char *ststr[5] = { "CDS_NO_INFO", "CDS_NO_DISC", "CDS_TRAY_OPEN", "CDS_DRIVE_NOT_READY", "CDS_DISC_OK", }; if ((unsigned)cds >= 5) return NULL; return ststr[cds]; } int main(void) { int fd, cds; char *s; fd = open("/dev/sr0", O_RDONLY | O_NONBLOCK); if (fd < 0) error(1, errno, "open"); cds = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT); if (cds < 0) error(1, errno, "ioctl"); s = cdsstr(cds); if (s) printf("%s\n", s); else printf("%d\n", cds); return 0; }