]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: command: Properly format disk 'debug' attribute
authorPeter Krempa <pkrempa@redhat.com>
Thu, 23 Nov 2017 16:15:17 +0000 (17:15 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 23 Nov 2017 17:50:04 +0000 (18:50 +0100)
Move the setup of the disk attribute to the disk source prepare function
which will allow proper usage with JSON props and move the fallback
(legacy) generating code into the block which is executed with legacy
options.

As a side-effect of this change we can clean up propagation of 'cfg'
into the command generator.

Also it's nice to see that the test output is the same even when the
value is generated in a different place.

src/qemu/qemu_command.c
src/qemu/qemu_command.h
src/qemu/qemu_domain.c
src/qemu/qemu_hotplug.c

index 5ef98d38cca63d6e7dbbc7f11a9bc7b9b8ed7c07..b8d8a5182828db4fe9ade5a6c09bc25b219fade5 100644 (file)
@@ -1509,9 +1509,7 @@ qemuDiskSourceGetProps(virStorageSourcePtr src)
 
 static int
 qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
-                        virQEMUDriverConfigPtr cfg,
-                        virBufferPtr buf,
-                        virQEMUCapsPtr qemuCaps)
+                        virBufferPtr buf)
 {
     int actualType = virStorageSourceGetActualType(disk->src);
     qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
@@ -1581,6 +1579,9 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
 
         if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES)
             virBufferAsprintf(buf, ",file.password-secret=%s", secinfo->s.aes.alias);
+
+        if (disk->src->debug)
+            virBufferAsprintf(buf, ",file.debug=%d", disk->src->debugLevel);
     } else {
         if (!(source = virQEMUBuildDriveCommandlineFromJSON(srcprops)))
             goto cleanup;
@@ -1589,12 +1590,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
     }
     virBufferAddLit(buf, ",");
 
-    if (disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
-        disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER) {
-        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL))
-            virBufferAsprintf(buf, "file.debug=%d,", cfg->glusterDebugLevel);
-    }
-
     if (encinfo)
         virQEMUBuildLuksOpts(buf, &disk->src->encryption->encinfo,
                              encinfo->s.aes.alias);
@@ -1722,13 +1717,12 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
 
 char *
 qemuBuildDriveStr(virDomainDiskDefPtr disk,
-                  virQEMUDriverConfigPtr cfg,
                   bool bootable,
                   virQEMUCapsPtr qemuCaps)
 {
     virBuffer opt = VIR_BUFFER_INITIALIZER;
 
-    if (qemuBuildDriveSourceStr(disk, cfg, &opt, qemuCaps) < 0)
+    if (qemuBuildDriveSourceStr(disk, &opt) < 0)
         goto error;
 
     if (qemuDiskBusNeedsDeviceArg(disk->bus)) {
@@ -2213,7 +2207,6 @@ qemuBuildDriveDevStr(const virDomainDef *def,
 
 static int
 qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
-                              virQEMUDriverConfigPtr cfg,
                               const virDomainDef *def,
                               virQEMUCapsPtr qemuCaps)
 {
@@ -2293,7 +2286,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
 
         virCommandAddArg(cmd, "-drive");
 
-        if (!(optstr = qemuBuildDriveStr(disk, cfg, driveBoot, qemuCaps)))
+        if (!(optstr = qemuBuildDriveStr(disk, driveBoot, qemuCaps)))
             return -1;
 
         virCommandAddArg(cmd, optstr);
@@ -10188,7 +10181,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
     if (qemuBuildHubCommandLine(cmd, def, qemuCaps) < 0)
         goto error;
 
-    if (qemuBuildDiskDriveCommandLine(cmd, cfg, def, qemuCaps) < 0)
+    if (qemuBuildDiskDriveCommandLine(cmd, def, qemuCaps) < 0)
         goto error;
 
     if (qemuBuildFSDevCommandLine(cmd, def, qemuCaps) < 0)
index 2bcfc6c707a1946eea911a5ea7c708fccd61b8b1..18e0894581dbb7ebee9b1e40a8ccf995304bddff 100644 (file)
@@ -101,7 +101,6 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk);
 
 /* Both legacy & current support */
 char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
-                        virQEMUDriverConfigPtr cfg,
                         bool bootable,
                         virQEMUCapsPtr qemuCaps);
 
index f9bc19078937a154f0d2f382917898878684a5b6..2bda4a726be96fa4019fba87e815655aea3a45a0 100644 (file)
@@ -10520,5 +10520,12 @@ qemuDomainPrepareDiskSource(virConnectPtr conn,
     if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
         return -1;
 
+    if (disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
+        disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER &&
+        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) {
+        disk->src->debug = true;
+        disk->src->debugLevel = cfg->glusterDebugLevel;
+    }
+
     return 0;
 }
index 44d48ca95adb9e2c6ab966cb376d4f811d881442..a1a088af4bea21f7845024a3c5e1a04584100bda 100644 (file)
@@ -406,7 +406,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
                                       disk->info.alias) < 0)
         goto error;
 
-    if (!(drivestr = qemuBuildDriveStr(disk, cfg, false, priv->qemuCaps)))
+    if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps)))
         goto error;
 
     if (!(drivealias = qemuAliasFromDisk(disk)))