Bug 1077302

Summary: Disable host_cdrom detection logic, fall back to plain file: protocol
Product: Red Hat Enterprise Linux 7 Reporter: Cole Robinson <crobinso>
Component: qemu-kvmAssignee: Markus Armbruster <armbru>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, dyuan, gscrivan, juzhang, knoel, kwolf, lcui, marcandre.lureau, michen, mzhan, sluo, tzheng, virt-maint, zeenix
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-16 13:22:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Cole Robinson 2014-03-17 16:38:52 UTC
host_cdrom support is compiled out of qemu, for good reasons, as mentioned here:

https://bugzilla.redhat.com/show_bug.cgi?id=760885

Though the implementation means that any attempt to use /dev/sr0 through libvirt will fail. /dev/sr0 is detected as host_cdrom, qemu reports host_cdrom isn't available, and fails.

This breaks some prominent bits of virt-manager and boxes UI that expect to be able to attach a host cdrom device to a guest. There are bugs for that:

https://bugzilla.redhat.com/show_bug.cgi?id=1072611
https://bugzilla.redhat.com/show_bug.cgi?id=1072610

However it seems like less work and friendly for our users to just have qemu fall back to treating /dev/sr0 like it would any other block device, and not use the special host_cdrom integration.

This patch works for me, but may not be suitable as is:

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 1688e16..7802724 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -2028,28 +2028,7 @@ static int cdrom_open(BlockDriverState *bs, QDict *option
 
 static int cdrom_probe_device(const char *filename)
 {
-    int fd, ret;
-    int prio = 0;
-    struct stat st;
-
-    fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);
-    if (fd < 0) {
-        goto out;
-    }
-    ret = fstat(fd, &st);
-    if (ret == -1 || !S_ISBLK(st.st_mode)) {
-        goto outc;
-    }
-
-    /* Attempt to detect via a CDROM specific ioctl */
-    ret = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
-    if (ret >= 0)
-        prio = 100;
-
-outc:
-    qemu_close(fd);
-out:
-    return prio;
+    return 0;
 }


This may not solve the libvirt + /dev/sr0 + udev + selinux relabelling issues as linked in the host_cdrom bug report, I'm not sure (but they may have been due to a side effect of host_cdrom behavior, so perhaps they will be avoided). There may well be other reasons, but I think something along the above idea should be considered.

Comment 1 Markus Armbruster 2014-06-24 13:31:29 UTC
The patch makes qemu-kvm use backend "host_device" instead of
"host_cdrom".

I have two problems with this idea:

1. It turns "Attempt to use host CD-ROM is rejected out of hand with a
reasonably clear error message" into "Host CD-ROM is accepted, but
doesn't fully work".  In particular, guest commands to eject and load
media succeed without doing anything.  I doubt that's an improvement.

2. The boat has sailed: we shipped 7.0.  I'm rather reluctant to
change how we treat host CD-ROM now.  Feedback from customers could
overcome my reluctance.

Any objections to WONTFIX?

Comment 2 Markus Armbruster 2014-07-16 13:22:13 UTC
Closing WONTFIX.  If you disagree, please reopen stating your arguments.