util: virqemu: introduce virQEMUBuildBufferEscape

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@redhat.com>
This commit is contained in:
Pavel Hrdina 2017-02-22 20:20:42 +01:00
parent 726403461b
commit 22b02f4492
3 changed files with 19 additions and 0 deletions

View File

@ -2298,6 +2298,7 @@ virProcessWait;
# util/virqemu.h
virQEMUBuildBufferEscape;
virQEMUBuildBufferEscapeComma;
virQEMUBuildCommandLineJSON;
virQEMUBuildCommandLineJSONArrayBitmap;

View File

@ -299,6 +299,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

View File

@ -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)