]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virQEMUBuildDriveCommandlineFromJSON: Open-code in callers
authorPeter Krempa <pkrempa@redhat.com>
Wed, 24 Mar 2021 13:00:07 +0000 (14:00 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 Oct 2021 08:26:00 +0000 (10:26 +0200)
Optimize the number of string copies by using the virBuffers in the
callers directly. Simplest way to achieve this is to just open code the
one function call 'virQEMUBuildDriveCommandlineFromJSON' was wrapping
in the two callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libvirt_private.syms
src/qemu/qemu_command.c
src/util/virqemu.c
src/util/virqemu.h

index cffd3d638c590ffc7971f4c0d297a081808ec5ad..516b3692b24f152908dba7e320229e7bddb87175 100644 (file)
@@ -3119,7 +3119,6 @@ virQEMUBuildCommandLineJSON;
 virQEMUBuildCommandLineJSONArrayBitmap;
 virQEMUBuildCommandLineJSONArrayNumbered;
 virQEMUBuildCommandLineJSONArrayObjectsStr;
-virQEMUBuildDriveCommandlineFromJSON;
 
 
 # util/virrandom.h
index b6a8a391a8f67b5b9be1e9beca7a0216b7642c6c..22b0f85fe3b78f8761cef8fc2463ffe55ee0882d 100644 (file)
@@ -1252,10 +1252,9 @@ qemuBuildDriveSourceStr(virDomainDiskDef *disk,
         if (qemuBuildDriveSourcePR(buf, disk) < 0)
             return -1;
     } else {
-        if (!(source = virQEMUBuildDriveCommandlineFromJSON(srcprops)))
+        if (virQEMUBuildCommandLineJSON(srcprops, buf, NULL,
+                                        virQEMUBuildCommandLineJSONArrayNumbered) < 0)
             return -1;
-
-        virBufferAdd(buf, source, -1);
     }
     virBufferAddLit(buf, ",");
 
@@ -4533,16 +4532,18 @@ static char *
 qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDef *dev)
 {
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-    g_autofree char *netsource = NULL;
     g_autoptr(virJSONValue) srcprops = NULL;
     virDomainHostdevSubsysSCSI *scsisrc = &dev->source.subsys.u.scsi;
     virDomainHostdevSubsysSCSIiSCSI *iscsisrc = &scsisrc->u.iscsi;
 
     if (!(srcprops = qemuDiskSourceGetProps(iscsisrc->src)))
         return NULL;
-    if (!(netsource = virQEMUBuildDriveCommandlineFromJSON(srcprops)))
+
+    if (virQEMUBuildCommandLineJSON(srcprops, &buf, NULL,
+                                    virQEMUBuildCommandLineJSONArrayNumbered) < 0)
         return NULL;
-    virBufferAsprintf(&buf, "%s,if=none,format=raw", netsource);
+
+    virBufferAddLit(&buf, ",if=none,format=raw");
 
     return virBufferContentAndReset(&buf);
 }
index 8119643431f49b255dd0356096f0f510a00f34a9..e31451dff4f28e796c3b78eb8d6dcd4a9f803c42 100644 (file)
@@ -283,19 +283,6 @@ virQEMUBuildCommandLineJSON(virJSONValue *value,
 }
 
 
-char *
-virQEMUBuildDriveCommandlineFromJSON(virJSONValue *srcdef)
-{
-    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-
-    if (virQEMUBuildCommandLineJSON(srcdef, &buf, NULL,
-                                    virQEMUBuildCommandLineJSONArrayNumbered) < 0)
-        return NULL;
-
-    return virBufferContentAndReset(&buf);
-}
-
-
 /**
  * virQEMUBuildBufferEscapeComma:
  * @buf: buffer to append the escaped string
index 5098ed7653224c74f89429eed288546f5f93c6e6..472f24de53c1f6cabdfb7af47e4e0da07ea3d7ae 100644 (file)
@@ -48,6 +48,4 @@ int virQEMUBuildCommandLineJSON(virJSONValue *value,
                                 const char *skipKey,
                                 virQEMUBuildCommandLineJSONArrayFormatFunc array);
 
-char *virQEMUBuildDriveCommandlineFromJSON(virJSONValue *src);
-
 void virQEMUBuildBufferEscapeComma(virBuffer *buf, const char *str);