This will eventually replace virQEMUBuildBufferEscapeComma, however
it's not possible right now. Some parts of the code that uses the
old function needs to be refactored.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/libvirt_private.syms | 1 +
src/util/virqemu.c | 17 +++++++++++++++++
src/util/virqemu.h | 1 +
3 files changed, 19 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 28e595fe58..dffc1f2a24 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2298,6 +2298,7 @@ virProcessWait;
# util/virqemu.h
+virQEMUBuildBufferEscape;
virQEMUBuildBufferEscapeComma;
virQEMUBuildCommandLineJSON;
virQEMUBuildCommandLineJSONArrayBitmap;
diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index 2e9e65f9ef..f10b356781 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -300,6 +300,23 @@ virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str)
/**
+ * virQEMUBuildBufferEscape:
+ * @buf: buffer to append the escaped string
+ * @str: the string to escape
+ *
+ * Some characters passed as values on the QEMU command line must be escaped.
+ *
+ * - ',' must by escaped by ','
+ * - '=' must by escaped by '\'
+ */
+void
+virQEMUBuildBufferEscape(virBufferPtr buf, const char *str)
+{
+ virBufferEscapeN(buf, "%s", str, ',', ",", '\\',
"=", NULL);
+}
+
+
+/**
* virQEMUBuildLuksOpts:
* @buf: buffer to build the string into
* @enc: pointer to encryption info
diff --git a/src/util/virqemu.h b/src/util/virqemu.h
index 539d62ab14..10aeb67f4e 100644
--- a/src/util/virqemu.h
+++ b/src/util/virqemu.h
@@ -50,6 +50,7 @@ char *virQEMUBuildObjectCommandlineFromJSON(const char *type,
char *virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr src);
void virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str);
+void virQEMUBuildBufferEscape(virBufferPtr buf, const char *str);
void virQEMUBuildLuksOpts(virBufferPtr buf,
virStorageEncryptionInfoDefPtr enc,
const char *alias)
--
2.11.1