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

[libvirt] [PATCH 6/6] qemu: command: Properly format disk 'debug' attribute



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 | 21 +++++++--------------
 src/qemu/qemu_command.h |  1 -
 src/qemu/qemu_domain.c  |  7 +++++++
 src/qemu/qemu_hotplug.c |  2 +-
 4 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 667ac746e1..26f86c74b5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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)) {
@@ -2209,7 +2203,6 @@ qemuBuildDriveDevStr(const virDomainDef *def,

 static int
 qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
-                              virQEMUDriverConfigPtr cfg,
                               const virDomainDef *def,
                               virQEMUCapsPtr qemuCaps)
 {
@@ -2289,7 +2282,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);
@@ -10147,7 +10140,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)
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 2bcfc6c707..18e0894581 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -101,7 +101,6 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk);

 /* Both legacy & current support */
 char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
-                        virQEMUDriverConfigPtr cfg,
                         bool bootable,
                         virQEMUCapsPtr qemuCaps);

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a5bfcfb48a..75482ac5e6 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -10439,5 +10439,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;
 }
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 44d48ca95a..a1a088af4b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -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)))
-- 
2.14.3


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