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

[libvirt] [PATCH 05/11] qemu: Prohibit setting tray status as open for block type disk



--
Created this as a seperate patch, as I'm not quite sure if it's
good to do this in libvirt, it's more like a protection for
qemu problem, i.e. closing the physical drive tray won't close
the guest tray. Paolo persist in doing this in libvirt, but IMHO
QEMU is the better place to prevent that. Anyway, let's evaluate.
---
 src/qemu/qemu_command.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ba6edce..29cc4bd 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1963,6 +1963,13 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
                 break;
             }
         } else {
+            if ((disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK) &&
+                (disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN)) {
+                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                _("tray status 'open' is invalid for "
+                                  "block type disk"));
+                goto error;
+            }
             virBufferEscape(&opt, ',', ",", "file=%s,", disk->src);
         }
     }
@@ -4625,6 +4632,14 @@ qemuBuildCommandLine(virConnectPtr conn,
             const char *fmt;
             virDomainDiskDefPtr disk = def->disks[i];
 
+            if ((disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK) &&
+                (disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN)) {
+                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                _("tray status 'open' is invalid for "
+                                  "block type disk"));
+                goto error;
+            }
+
             if (disk->bus == VIR_DOMAIN_DISK_BUS_USB) {
                 if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
                     virCommandAddArg(cmd, "-usbdevice");
-- 
1.7.1


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