render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From f7162a7c681e0dda365f1883736979d64ae7d2a5 Mon Sep 17 00:00:00 2001
Message-Id: <f7162a7c681e0dda365f1883736979d64ae7d2a5@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 25 Jul 2016 12:42:56 -0400
Subject: [PATCH] qemu: Move and rename qemuBufferEscapeComma

https://bugzilla.redhat.com/show_bug.cgi?id=1301021

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

(cherry picked from commit 8215aab0036e65da47a2646f85749e9f5ea5d252)
Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 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 62c9dc5..c205fd8 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 b87d9c3..0ee1d34 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;
@@ -1233,7 +1218,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
             break;
         }
 
-        qemuBufferEscapeComma(&opt, source);
+        virQEMUBuildBufferEscapeComma(&opt, source);
         virBufferAddLit(&opt, ",");
 
         if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
@@ -3776,7 +3761,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;
@@ -4778,7 +4763,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;
@@ -6157,7 +6142,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);
     }
 
@@ -6764,7 +6749,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))
@@ -7313,7 +7298,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:
@@ -8890,10 +8875,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.9.2