mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 06:25:19 +00:00
qemu: Use qemuBuildChrChardevCommand for vhost-user disk backend
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 <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5f2cc74257
commit
fd4aca6cf5
@ -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);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,6 @@ struct qemuBlockStorageSourceAttachData {
|
||||
|
||||
virDomainChrSourceDef *chardevDef;
|
||||
char *chardevAlias;
|
||||
char *chardevCmd;
|
||||
bool chardevAdded;
|
||||
|
||||
virJSONValue *authsecretProps;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user