[PATCH 12/35] qemu: domain: Store whether a virStorageSource is a host CDROM drive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c    | 8 ++++++++
 src/util/virstoragefile.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9f94809fd1..86e40e13e0 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7545,6 +7545,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;
     }
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 57d39f98c2..c8a4a288b1 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -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 */
 };


-- 
2.16.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux