]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: domain: Store whether a virStorageSource is a host CDROM drive
authorPeter Krempa <pkrempa@redhat.com>
Tue, 24 Apr 2018 14:59:00 +0000 (16:59 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 7 May 2018 13:22:30 +0000 (15:22 +0200)
Use virFileIsCDROM to detect whether a block device is a cdrom drive and
store it in virStorageSource. This will be necessary to correctly create
the 'host_cdrom' backend in qemu when using -blockdev.

We assume that host_cdrom makes only sense when used directly as a raw
image, but if a backing chain would be put in front of it, libvirt will
use 'host_device' in that case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_domain.c
src/util/virstoragefile.h

index 890facf1b7c39c2592fe5a0a6d27d876fd59148c..8a9c958c5ccc12f9844f22dcce8a1d332f76e9d2 100644 (file)
@@ -7530,6 +7530,14 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
             VIR_ALLOC(src->backingStore) < 0)
             goto cleanup;
 
+        /* host cdrom requires special treatment in qemu, so we need to check
+         * whether a block device is a cdrom */
+        if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
+            src->format == VIR_STORAGE_FILE_RAW &&
+            virStorageSourceIsBlockLocal(src) &&
+            virFileIsCDROM(src->path) == 1)
+            src->hostcdrom = true;
+
         ret = 0;
         goto cleanup;
     }
index 92864368275031fbb0811912144b532f0daa2a32..01f89bf182d5823b46dc2b2fa47edc8a8750f005 100644 (file)
@@ -316,6 +316,8 @@ struct _virStorageSource {
 
     bool floppyimg; /* set to true if the storage source is going to be used
                        as a source for floppy drive */
+
+    bool hostcdrom; /* backing device is a cdrom */
 };