[PATCH 7/7] qemu: Move and rename qemuBufferEscapeComma

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

 



Move to virqemu and rename to virQEMUBuildBufferEscapeComma. This can then
be shared by the storage driver when it builds the command line for qemuimg

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_command.c  | 33 +++++++++------------------------
 src/util/virqemu.c       | 15 +++++++++++++++
 src/util/virqemu.h       |  2 ++
 4 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ba718b8..dcbff06 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2192,6 +2192,7 @@ virProcessWait;
 
 
 # util/virqemu.h
+virQEMUBuildBufferEscapeComma;
 virQEMUBuildObjectCommandlineFromJSON;
 
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fe4bb88..ba50987 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -152,21 +152,6 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_DOMAIN_NUMATUNE_MEM_LAST,
 
 
 /**
- * qemuBufferEscapeComma:
- * @buf: buffer to append the escaped string
- * @str: the string to escape
- *
- * qemu requires that any values passed on the command line which contain
- * a ',' must escape it using an extra ',' as the escape character
- */
-static void
-qemuBufferEscapeComma(virBufferPtr buf, const char *str)
-{
-    virBufferEscape(buf, ',', ",", "%s", str);
-}
-
-
-/**
  * qemuBuildHasMasterKey:
  * @qemuCaps: QEMU binary capabilities
  *
@@ -221,7 +206,7 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
 
     virCommandAddArg(cmd, "-object");
     virBufferAsprintf(&buf, "secret,id=%s,format=raw,file=", alias);
-    qemuBufferEscapeComma(&buf, path);
+    virQEMUBuildBufferEscapeComma(&buf, path);
     virCommandAddArgBuffer(cmd, &buf);
 
     ret = 0;
@@ -1229,7 +1214,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
             break;
         }
 
-        qemuBufferEscapeComma(&opt, source);
+        virQEMUBuildBufferEscapeComma(&opt, source);
         virBufferAddLit(&opt, ",");
 
         if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
@@ -3773,7 +3758,7 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
             goto error;
         }
         virBufferAsprintf(&buf, "virtio-input-host%s,id=%s,evdev=", suffix, dev->info.alias);
-        qemuBufferEscapeComma(&buf, dev->source.evdev);
+        virQEMUBuildBufferEscapeComma(&buf, dev->source.evdev);
         break;
     case VIR_DOMAIN_INPUT_TYPE_LAST:
         break;
@@ -4775,7 +4760,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
 
     case VIR_DOMAIN_CHR_TYPE_UNIX:
         virBufferAsprintf(&buf, "socket,id=char%s,path=", alias);
-        qemuBufferEscapeComma(&buf, dev->data.nix.path);
+        virQEMUBuildBufferEscapeComma(&buf, dev->data.nix.path);
         if (dev->data.nix.listen)
             virBufferAddLit(&buf, ",server,nowait");
         break;
@@ -6147,7 +6132,7 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
         virBuffer buf = VIR_BUFFER_INITIALIZER;
         virCommandAddArg(cmd, "-acpitable");
         virBufferAddLit(&buf, "sig=SLIC,file=");
-        qemuBufferEscapeComma(&buf, def->os.slic_table);
+        virQEMUBuildBufferEscapeComma(&buf, def->os.slic_table);
         virCommandAddArgBuffer(cmd, &buf);
     }
 
@@ -6734,7 +6719,7 @@ qemuBuildNameCommandLine(virCommandPtr cmd,
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NAME_GUEST))
         virBufferAddLit(&buf, "guest=");
 
-    qemuBufferEscapeComma(&buf, def->name);
+    virQEMUBuildBufferEscapeComma(&buf, def->name);
 
     if (cfg->setProcessName &&
         virQEMUCapsGet(qemuCaps, QEMU_CAPS_NAME_PROCESS))
@@ -7271,7 +7256,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
     switch (glisten->type) {
     case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
         virBufferAddLit(&opt, "unix:");
-        qemuBufferEscapeComma(&opt, glisten->socket);
+        virQEMUBuildBufferEscapeComma(&opt, glisten->socket);
         break;
 
     case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
@@ -8847,10 +8832,10 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
                 goto error;
         }
         virBufferAddLit(&buf, ",path=");
-        qemuBufferEscapeComma(&buf, devset ? devset : tpmdev);
+        virQEMUBuildBufferEscapeComma(&buf, devset ? devset : tpmdev);
 
         virBufferAddLit(&buf, ",cancel-path=");
-        qemuBufferEscapeComma(&buf, cancel_path);
+        virQEMUBuildBufferEscapeComma(&buf, cancel_path);
 
         VIR_FREE(devset);
         VIR_FREE(cancel_path);
diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index 895168e..79a4292 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -140,3 +140,18 @@ virQEMUBuildObjectCommandlineFromJSON(const char *type,
     virBufferFreeAndReset(&buf);
     return ret;
 }
+
+
+/**
+ * virQEMUBuildBufferEscapeComma:
+ * @buf: buffer to append the escaped string
+ * @str: the string to escape
+ *
+ * qemu requires that any values passed on the command line which contain
+ * a ',' must escape it using an extra ',' as the escape character
+ */
+void
+virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str)
+{
+    virBufferEscape(buf, ',', ",", "%s", str);
+}
diff --git a/src/util/virqemu.h b/src/util/virqemu.h
index af4ec1d..1033412 100644
--- a/src/util/virqemu.h
+++ b/src/util/virqemu.h
@@ -25,10 +25,12 @@
 # define __VIR_QEMU_H_
 
 # include "internal.h"
+# include "virbuffer.h"
 # include "virjson.h"
 
 char *virQEMUBuildObjectCommandlineFromJSON(const char *type,
                                             const char *alias,
                                             virJSONValuePtr props);
 
+void virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str);
 #endif /* __VIR_QEMU_H_ */
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]