mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-05 12:35:20 +00:00
qemuBuildHubCommandLine: Generate via JSON
The 'usb-hub' device doesn't have any special properties. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
39f181dacc
commit
173b990a82
@ -4875,19 +4875,27 @@ qemuBuildUSBHostdevDevProps(const virDomainDef *def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *
|
static int
|
||||||
qemuBuildHubDevStr(const virDomainDef *def,
|
qemuBuildHubDevCmd(virCommand *cmd,
|
||||||
|
const virDomainDef *def,
|
||||||
virDomainHubDef *dev,
|
virDomainHubDef *dev,
|
||||||
virQEMUCaps *qemuCaps G_GNUC_UNUSED)
|
virQEMUCaps *qemuCaps)
|
||||||
{
|
{
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_autoptr(virJSONValue) props = NULL;
|
||||||
|
|
||||||
virBufferAddLit(&buf, "usb-hub");
|
if (virJSONValueObjectCreate(&props,
|
||||||
virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
|
"s:driver", "usb-hub",
|
||||||
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0)
|
"s:id", dev->info.alias,
|
||||||
return NULL;
|
NULL) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return virBufferContentAndReset(&buf);
|
if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4899,13 +4907,8 @@ qemuBuildHubCommandLine(virCommand *cmd,
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < def->nhubs; i++) {
|
for (i = 0; i < def->nhubs; i++) {
|
||||||
virDomainHubDef *hub = def->hubs[i];
|
if (qemuBuildHubDevCmd(cmd, def, def->hubs[i], qemuCaps) < 0)
|
||||||
g_autofree char *optstr = NULL;
|
|
||||||
|
|
||||||
virCommandAddArg(cmd, "-device");
|
|
||||||
if (!(optstr = qemuBuildHubDevStr(def, hub, qemuCaps)))
|
|
||||||
return -1;
|
return -1;
|
||||||
virCommandAddArg(cmd, optstr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user