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

[libvirt] [PATCH 6/9] qemu: always assume QEMU_CAPS_DRIVE_READONLY



We have been always setting the capability on if qemu has
QEMU_CAPS_DEVICE.
---
 src/qemu/qemu_capabilities.c | 19 +++++++------------
 src/qemu/qemu_command.c      | 39 +++++++--------------------------------
 src/qemu/qemu_command.h      |  3 +--
 src/qemu/qemu_hotplug.c      |  2 +-
 4 files changed, 16 insertions(+), 47 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 13427ed..1e8450d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4079,8 +4079,7 @@ virQEMUCapsGetDefaultMachine(virQEMUCapsPtr qemuCaps)
 
 
 static int
-virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps,
-                                virDomainCapsLoaderPtr capsLoader,
+virQEMUCapsFillDomainLoaderCaps(virDomainCapsLoaderPtr capsLoader,
                                 char **loader,
                                 size_t nloader)
 {
@@ -4112,25 +4111,22 @@ virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps,
                              VIR_DOMAIN_LOADER_TYPE_PFLASH);
 
 
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY))
-        VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->readonly,
-                                 VIR_TRISTATE_BOOL_YES,
-                                 VIR_TRISTATE_BOOL_NO);
+    VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->readonly,
+                             VIR_TRISTATE_BOOL_YES,
+                             VIR_TRISTATE_BOOL_NO);
     return 0;
 }
 
 
 static int
-virQEMUCapsFillDomainOSCaps(virQEMUCapsPtr qemuCaps,
-                            virDomainCapsOSPtr os,
+virQEMUCapsFillDomainOSCaps(virDomainCapsOSPtr os,
                             char **loader,
                             size_t nloader)
 {
     virDomainCapsLoaderPtr capsLoader = &os->loader;
 
     os->supported = true;
-    if (virQEMUCapsFillDomainLoaderCaps(qemuCaps, capsLoader,
-                                        loader, nloader) < 0)
+    if (virQEMUCapsFillDomainLoaderCaps(capsLoader, loader, nloader) < 0)
         return -1;
     return 0;
 }
@@ -4358,8 +4354,7 @@ virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
 
     domCaps->maxvcpus = maxvcpus;
 
-    if (virQEMUCapsFillDomainOSCaps(qemuCaps, os,
-                                    loader, nloader) < 0 ||
+    if (virQEMUCapsFillDomainOSCaps(os, loader, nloader) < 0 ||
         virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps,
                                             domCaps->machine, disk) < 0 ||
         virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics) < 0 ||
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index acee310..48a6658 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1283,8 +1283,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
          disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) &&
         disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
         virBufferAddLit(&opt, ",boot=on");
-    if (disk->src->readonly &&
-        virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY)) {
+    if (disk->src->readonly) {
         if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
             if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -2064,16 +2063,8 @@ qemuBuildFSStr(virDomainFSDefPtr fs,
     virBufferAsprintf(&opt, ",id=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
     virBufferAsprintf(&opt, ",path=%s", fs->src);
 
-    if (fs->readonly) {
-        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_FSDEV_READONLY)) {
-            virBufferAddLit(&opt, ",readonly");
-        } else {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("readonly filesystem is not supported by this "
-                             "QEMU binary"));
-            goto error;
-        }
-    }
+    if (fs->readonly)
+        virBufferAddLit(&opt, ",readonly");
 
     if (virBufferCheckError(&opt) < 0)
         goto error;
@@ -4493,8 +4484,7 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
 }
 
 char *
-qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
-                           virQEMUCapsPtr qemuCaps)
+qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     char *source = NULL;
@@ -4513,16 +4503,8 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
                       virDomainDeviceAddressTypeToString(dev->info->type),
                       dev->info->alias);
 
-    if (dev->readonly) {
-        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY)) {
-            virBufferAddLit(&buf, ",readonly=on");
-        } else {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("this qemu doesn't support 'readonly' "
-                             "for -drive"));
-            goto error;
-        }
-    }
+    if (dev->readonly)
+        virBufferAddLit(&buf, ",readonly=on");
 
     if (virBufferCheckError(&buf) < 0)
         goto error;
@@ -4925,7 +4907,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
                 char *drvstr;
 
                 virCommandAddArg(cmd, "-drive");
-                if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, qemuCaps)))
+                if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev)))
                     return -1;
                 virCommandAddArg(cmd, drvstr);
                 VIR_FREE(drvstr);
@@ -8660,13 +8642,6 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
         unit++;
 
         if (loader->readonly) {
-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("this qemu doesn't support passing "
-                                 "readonly attribute"));
-                goto cleanup;
-            }
-
             virBufferAsprintf(&buf, ",readonly=%s",
                               virTristateSwitchTypeToString(loader->readonly));
         }
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index c777701..1c22705 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -161,8 +161,7 @@ char *qemuBuildUSBHostdevDevStr(const virDomainDef *def,
                                 virDomainHostdevDefPtr dev,
                                 virQEMUCapsPtr qemuCaps);
 
-char *qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
-                                 virQEMUCapsPtr qemuCaps);
+char *qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev);
 
 char *qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
                                  virDomainHostdevDefPtr dev,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index fc1bf6e..5f34a76 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1928,7 +1928,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
     if (qemuDomainSecretHostdevPrepare(conn, priv, hostdev) < 0)
         goto cleanup;
 
-    if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, priv->qemuCaps)))
+    if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev)))
         goto cleanup;
 
     if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, priv->qemuCaps)))
-- 
2.7.3


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