[PATCH 1/5] qemu: command: Inline qemuBuildDiskFrontendAttributeErrorPolicy

Peter Krempa pkrempa at redhat.com
Mon Feb 14 14:22:53 UTC 2022


Commit dc481f11a61 which converted the function generating properties
for disk '-device' argument to JSON removed the only other use of
qemuBuildDiskFrontendAttributeErrorPolicy, so we can now inline it into
qemuBuildDriveStr.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_command.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1abff4fcaa..2c963a7297 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2002,22 +2002,6 @@ qemuBuildDiskGetErrorPolicy(virDomainDiskDef *disk,
 }


-static void
-qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDef *disk,
-                                          virBuffer *buf)
-{
-    const char *wpolicy = NULL;
-    const char *rpolicy = NULL;
-
-    qemuBuildDiskGetErrorPolicy(disk, &wpolicy, &rpolicy);
-
-    if (wpolicy)
-        virBufferAsprintf(buf, ",werror=%s", wpolicy);
-    if (rpolicy)
-        virBufferAsprintf(buf, ",rerror=%s", rpolicy);
-}
-
-
 static char *
 qemuBuildDriveStr(virDomainDiskDef *disk,
                   virQEMUCaps *qemuCaps)
@@ -2043,8 +2027,17 @@ qemuBuildDriveStr(virDomainDiskDef *disk,

     /* werror/rerror are really frontend attributes, but older
      * qemu requires them on -drive instead of -device */
-    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_STORAGE_WERROR))
-        qemuBuildDiskFrontendAttributeErrorPolicy(disk, &opt);
+    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_STORAGE_WERROR)) {
+        const char *wpolicy = NULL;
+        const char *rpolicy = NULL;
+
+        qemuBuildDiskGetErrorPolicy(disk, &wpolicy, &rpolicy);
+
+        if (wpolicy)
+            virBufferAsprintf(&opt, ",werror=%s", wpolicy);
+        if (rpolicy)
+            virBufferAsprintf(&opt, ",rerror=%s", rpolicy);
+    }

     if (disk->src->readonly)
         virBufferAddLit(&opt, ",readonly=on");
-- 
2.34.1




More information about the libvir-list mailing list