]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: command: Call qemuGetDriveSourceProps only if necessary
authorPeter Krempa <pkrempa@redhat.com>
Fri, 7 Jul 2017 12:41:25 +0000 (14:41 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 14 Jul 2017 14:05:46 +0000 (16:05 +0200)
Add logic which will call qemuGetDriveSourceProps only in cases where we
need the JSON representation. This will allow qemuGetDriveSourceProps to
generate the JSON representation for all possible disk sources.

src/qemu/qemu_command.c

index 8d73934d00b8bcf50a7c77b9c76d094dbcc5b5a4..b69ff4ae5dc7dc772fa8543f48bfd6909a94dbb1 100644 (file)
@@ -1436,6 +1436,28 @@ qemuDiskBusNeedsDeviceArg(int bus)
 }
 
 
+/**
+ * qemuDiskSourceNeedsProps:
+ * @src: disk source
+ *
+ * Returns true, if the disk source needs to be generated from the JSON
+ * representation. Otherwise, the disk source should be represented using
+ * the legacy representation.
+ */
+static bool
+qemuDiskSourceNeedsProps(virStorageSourcePtr src)
+{
+    int actualType = virStorageSourceGetActualType(src);
+
+    if (actualType == VIR_STORAGE_TYPE_NETWORK &&
+        src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER &&
+        src->nhosts > 1)
+        return true;
+
+    return false;
+}
+
+
 static int
 qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
                         virQEMUDriverConfigPtr cfg,
@@ -1450,7 +1472,8 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
     char *source = NULL;
     int ret = -1;
 
-    if (qemuGetDriveSourceProps(disk->src, &srcprops) < 0)
+    if (qemuDiskSourceNeedsProps(disk->src) &&
+        qemuGetDriveSourceProps(disk->src, &srcprops) < 0)
         goto cleanup;
 
     if (!srcprops &&