Now that the API for qemuBuildChrChardevCommand is sane enough, we can use it to centralize formatting of '-chardev' generally.
For virtiofs we don't have a centrally stored chardev source so we allocate one inline for temporary use. Signed-off-by: Peter Krempa <pkre...@redhat.com> --- src/qemu/qemu_block.c | 1 - src/qemu/qemu_block.h | 1 - src/qemu/qemu_command.c | 18 ++++-------------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index f6a7f2b750..87dca40179 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1655,7 +1655,6 @@ qemuBlockStorageSourceAttachDataFree(qemuBlockStorageSourceAttachData *data) g_free(data->driveCmd); g_free(data->driveAlias); g_free(data->chardevAlias); - g_free(data->chardevCmd); g_free(data); } diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 54601a48a9..184a549d5c 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -99,7 +99,6 @@ struct qemuBlockStorageSourceAttachData { virDomainChrSourceDef *chardevDef; char *chardevAlias; - char *chardevCmd; bool chardevAdded; virJSONValue *authsecretProps; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0fb7b83d3f..0bfe76c29c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2591,8 +2591,10 @@ qemuBuildBlockStorageSourceAttachDataCommandline(virCommand *cmd, if (data->driveCmd) virCommandAddArgList(cmd, "-drive", data->driveCmd, NULL); - if (data->chardevCmd) - virCommandAddArgList(cmd, "-chardev", data->chardevCmd, NULL); + if (data->chardevDef) { + if (qemuBuildChardevCommand(cmd, data->chardevDef, data->chardevAlias, qemuCaps) < 0) + return -1; + } if (data->storageProps) { if (!(tmp = virJSONValueToString(data->storageProps, false))) @@ -10959,24 +10961,12 @@ static qemuBlockStorageSourceAttachData * qemuBuildStorageSourceAttachPrepareChardev(virDomainDiskDef *disk) { g_autoptr(qemuBlockStorageSourceAttachData) data = NULL; - g_auto(virBuffer) chardev = VIR_BUFFER_INITIALIZER; data = g_new0(qemuBlockStorageSourceAttachData, 1); data->chardevDef = disk->src->vhostuser; data->chardevAlias = qemuDomainGetVhostUserChrAlias(disk->info.alias); - virBufferAddLit(&chardev, "socket"); - virBufferAsprintf(&chardev, ",id=%s", data->chardevAlias); - virBufferAddLit(&chardev, ",path="); - virQEMUBuildBufferEscapeComma(&chardev, disk->src->vhostuser->data.nix.path); - - qemuBuildChrChardevReconnectStr(&chardev, - &disk->src->vhostuser->data.nix.reconnect); - - if (!(data->chardevCmd = virBufferContentAndReset(&chardev))) - return NULL; - return g_steal_pointer(&data); } -- 2.31.1