The 'vhost-user-fs-pci' has following properties we control:
chardev=<str> - ID of a chardev to use as a backend
queue-size=<uint16> - (default: 128)
tag=<str>
bootindex=<int32>
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 43 ++++++++++++++++++++---------------------
src/qemu/qemu_command.h | 10 +++++-----
2 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c566ab7bd5..f47d77548d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2571,31 +2571,30 @@ qemuBuildVHostUserFsChardevStr(const virDomainFSDef *fs,
}
-char *
-qemuBuildVHostUserFsDevStr(virDomainFSDef *fs,
- const virDomainDef *def,
- const char *chardev_alias,
- qemuDomainObjPrivate *priv)
+virJSONValue *
+qemuBuildVHostUserFsDevProps(virDomainFSDef *fs,
+ const virDomainDef *def,
+ const char *chardev_alias,
+ qemuDomainObjPrivate *priv)
{
- g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+ g_autoptr(virJSONValue) props = NULL;
- if (qemuBuildVirtioDevStr(&buf, priv->qemuCaps, VIR_DOMAIN_DEVICE_FS, fs) <
0)
+ if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_FS, fs, priv->qemuCaps)))
return NULL;
- virBufferAsprintf(&buf, ",id=%s", fs->info.alias);
- virBufferAsprintf(&buf, ",chardev=%s", chardev_alias);
- if (fs->queue_size)
- virBufferAsprintf(&buf, ",queue-size=%llu", fs->queue_size);
- virBufferAddLit(&buf, ",tag=");
- virQEMUBuildBufferEscapeComma(&buf, fs->dst);
-
- if (fs->info.bootIndex)
- virBufferAsprintf(&buf, ",bootindex=%u", fs->info.bootIndex);
+ if (virJSONValueObjectAdd(props,
+ "s:id", fs->info.alias,
+ "s:chardev", chardev_alias,
+ "P:queue-size", fs->queue_size,
+ "s:tag", fs->dst,
+ "p:bootindex", fs->info.bootIndex,
+ NULL) < 0)
+ return NULL;
- if (qemuBuildDeviceAddressStr(&buf, def, &fs->info) < 0)
+ if (qemuBuildDeviceAddressProps(props, def, &fs->info) < 0)
return NULL;
- return virBufferContentAndReset(&buf);
+ return g_steal_pointer(&props);
}
@@ -2607,7 +2606,7 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd,
{
g_autofree char *chardev_alias = NULL;
g_autofree char *chrdevstr = NULL;
- g_autofree char *devstr = NULL;
+ g_autoptr(virJSONValue) devprops = NULL;
chardev_alias = qemuDomainGetVhostUserChrAlias(fs->info.alias);
chrdevstr = qemuBuildVHostUserFsChardevStr(fs, chardev_alias, priv);
@@ -2618,11 +2617,11 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd,
if (qemuCommandAddExtDevice(cmd, &fs->info, priv->qemuCaps) < 0)
return -1;
- if (!(devstr = qemuBuildVHostUserFsDevStr(fs, def, chardev_alias, priv)))
+ if (!(devprops = qemuBuildVHostUserFsDevProps(fs, def, chardev_alias, priv)))
return -1;
- virCommandAddArg(cmd, "-device");
- virCommandAddArg(cmd, devstr);
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, priv->qemuCaps) < 0)
+ return -1;
return 0;
}
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 56999b7424..81fd24406d 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -138,11 +138,11 @@ qemuBuildDiskDeviceProps(const virDomainDef *def,
virDomainDiskDef *disk,
virQEMUCaps *qemuCaps);
-char *
-qemuBuildVHostUserFsDevStr(virDomainFSDef *fs,
- const virDomainDef *def,
- const char *chardev_alias,
- qemuDomainObjPrivate *priv);
+virJSONValue *
+qemuBuildVHostUserFsDevProps(virDomainFSDef *fs,
+ const virDomainDef *def,
+ const char *chardev_alias,
+ qemuDomainObjPrivate *priv);
/* Current, best practice */
int
--
2.31.1