提交 8215aab0 编写于 作者: J John Ferlan

qemu: Move and rename qemuBufferEscapeComma

Move to virqemu and rename to virQEMUBuildBufferEscapeComma. This can then
be shared by the storage driver when it builds the command line for qemuimg
上级 99026fd0
...@@ -2196,6 +2196,7 @@ virProcessWait; ...@@ -2196,6 +2196,7 @@ virProcessWait;
# util/virqemu.h # util/virqemu.h
virQEMUBuildBufferEscapeComma;
virQEMUBuildObjectCommandlineFromJSON; virQEMUBuildObjectCommandlineFromJSON;
......
...@@ -151,21 +151,6 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_DOMAIN_NUMATUNE_MEM_LAST, ...@@ -151,21 +151,6 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_DOMAIN_NUMATUNE_MEM_LAST,
"interleave"); "interleave");
/**
* 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: * qemuBuildHasMasterKey:
* @qemuCaps: QEMU binary capabilities * @qemuCaps: QEMU binary capabilities
...@@ -221,7 +206,7 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd, ...@@ -221,7 +206,7 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
virCommandAddArg(cmd, "-object"); virCommandAddArg(cmd, "-object");
virBufferAsprintf(&buf, "secret,id=%s,format=raw,file=", alias); virBufferAsprintf(&buf, "secret,id=%s,format=raw,file=", alias);
qemuBufferEscapeComma(&buf, path); virQEMUBuildBufferEscapeComma(&buf, path);
virCommandAddArgBuffer(cmd, &buf); virCommandAddArgBuffer(cmd, &buf);
ret = 0; ret = 0;
...@@ -1233,7 +1218,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, ...@@ -1233,7 +1218,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
break; break;
} }
qemuBufferEscapeComma(&opt, source); virQEMUBuildBufferEscapeComma(&opt, source);
virBufferAddLit(&opt, ","); virBufferAddLit(&opt, ",");
if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) { if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
...@@ -3777,7 +3762,7 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def, ...@@ -3777,7 +3762,7 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
goto error; goto error;
} }
virBufferAsprintf(&buf, "virtio-input-host%s,id=%s,evdev=", suffix, dev->info.alias); virBufferAsprintf(&buf, "virtio-input-host%s,id=%s,evdev=", suffix, dev->info.alias);
qemuBufferEscapeComma(&buf, dev->source.evdev); virQEMUBuildBufferEscapeComma(&buf, dev->source.evdev);
break; break;
case VIR_DOMAIN_INPUT_TYPE_LAST: case VIR_DOMAIN_INPUT_TYPE_LAST:
break; break;
...@@ -4779,7 +4764,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, ...@@ -4779,7 +4764,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
case VIR_DOMAIN_CHR_TYPE_UNIX: case VIR_DOMAIN_CHR_TYPE_UNIX:
virBufferAsprintf(&buf, "socket,id=char%s,path=", alias); 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) if (dev->data.nix.listen)
virBufferAddLit(&buf, ",server,nowait"); virBufferAddLit(&buf, ",server,nowait");
break; break;
...@@ -6151,7 +6136,7 @@ qemuBuildBootCommandLine(virCommandPtr cmd, ...@@ -6151,7 +6136,7 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
virCommandAddArg(cmd, "-acpitable"); virCommandAddArg(cmd, "-acpitable");
virBufferAddLit(&buf, "sig=SLIC,file="); virBufferAddLit(&buf, "sig=SLIC,file=");
qemuBufferEscapeComma(&buf, def->os.slic_table); virQEMUBuildBufferEscapeComma(&buf, def->os.slic_table);
virCommandAddArgBuffer(cmd, &buf); virCommandAddArgBuffer(cmd, &buf);
} }
...@@ -6738,7 +6723,7 @@ qemuBuildNameCommandLine(virCommandPtr cmd, ...@@ -6738,7 +6723,7 @@ qemuBuildNameCommandLine(virCommandPtr cmd,
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NAME_GUEST)) if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NAME_GUEST))
virBufferAddLit(&buf, "guest="); virBufferAddLit(&buf, "guest=");
qemuBufferEscapeComma(&buf, def->name); virQEMUBuildBufferEscapeComma(&buf, def->name);
if (cfg->setProcessName && if (cfg->setProcessName &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_NAME_PROCESS)) virQEMUCapsGet(qemuCaps, QEMU_CAPS_NAME_PROCESS))
...@@ -7275,7 +7260,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, ...@@ -7275,7 +7260,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
switch (glisten->type) { switch (glisten->type) {
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
virBufferAddLit(&opt, "unix:"); virBufferAddLit(&opt, "unix:");
qemuBufferEscapeComma(&opt, glisten->socket); virQEMUBuildBufferEscapeComma(&opt, glisten->socket);
break; break;
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
...@@ -8851,10 +8836,10 @@ qemuBuildTPMBackendStr(const virDomainDef *def, ...@@ -8851,10 +8836,10 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
goto error; goto error;
} }
virBufferAddLit(&buf, ",path="); virBufferAddLit(&buf, ",path=");
qemuBufferEscapeComma(&buf, devset ? devset : tpmdev); virQEMUBuildBufferEscapeComma(&buf, devset ? devset : tpmdev);
virBufferAddLit(&buf, ",cancel-path="); virBufferAddLit(&buf, ",cancel-path=");
qemuBufferEscapeComma(&buf, cancel_path); virQEMUBuildBufferEscapeComma(&buf, cancel_path);
VIR_FREE(devset); VIR_FREE(devset);
VIR_FREE(cancel_path); VIR_FREE(cancel_path);
......
...@@ -140,3 +140,18 @@ virQEMUBuildObjectCommandlineFromJSON(const char *type, ...@@ -140,3 +140,18 @@ virQEMUBuildObjectCommandlineFromJSON(const char *type,
virBufferFreeAndReset(&buf); virBufferFreeAndReset(&buf);
return ret; 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);
}
...@@ -25,10 +25,12 @@ ...@@ -25,10 +25,12 @@
# define __VIR_QEMU_H_ # define __VIR_QEMU_H_
# include "internal.h" # include "internal.h"
# include "virbuffer.h"
# include "virjson.h" # include "virjson.h"
char *virQEMUBuildObjectCommandlineFromJSON(const char *type, char *virQEMUBuildObjectCommandlineFromJSON(const char *type,
const char *alias, const char *alias,
virJSONValuePtr props); virJSONValuePtr props);
void virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str);
#endif /* __VIR_QEMU_H_ */ #endif /* __VIR_QEMU_H_ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册