From de325472cc27f57c56d0a4049fc3c58f59e8c8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 27 Jan 2017 15:26:13 +0100 Subject: [PATCH] qemu: assign USB addresses on redirdev hotplug too https://bugzilla.redhat.com/show_bug.cgi?id=1375410 --- src/qemu/qemu_hotplug.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index a6de254071..57ecc02e43 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1587,6 +1587,7 @@ int qemuDomainAttachRedirdevDevice(virConnectPtr conn, virJSONValuePtr secProps = NULL; char *tlsAlias = NULL; char *secAlias = NULL; + bool need_release = false; virErrorPtr orig_err; qemuDomainPrepareChardevSourceTLS(redirdev->source, cfg); @@ -1597,6 +1598,11 @@ int qemuDomainAttachRedirdevDevice(virConnectPtr conn, if (!(charAlias = qemuAliasChardevFromDevAlias(redirdev->info.alias))) goto cleanup; + if ((rc = virDomainUSBAddressEnsure(priv->usbaddrs, &redirdev->info)) < 0) + goto cleanup; + if (rc == 1) + need_release = true; + if (!(devstr = qemuBuildRedirdevDevStr(def, redirdev, priv->qemuCaps))) goto cleanup; @@ -1649,6 +1655,8 @@ int qemuDomainAttachRedirdevDevice(virConnectPtr conn, audit: virDomainAuditRedirdev(vm, redirdev, "attach", ret == 0); cleanup: + if (ret < 0 && need_release) + qemuDomainReleaseDeviceAddress(vm, &redirdev->info, NULL); VIR_FREE(tlsAlias); virJSONValueFree(tlsProps); VIR_FREE(secAlias); -- GitLab