From nobody Sat Apr 27 20:18:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541995305438998.0877423979961; Sun, 11 Nov 2018 20:01:45 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BC1E308624E; Mon, 12 Nov 2018 04:01:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23FC15C207; Mon, 12 Nov 2018 04:01:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A5D7A181A968; Mon, 12 Nov 2018 04:01:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAC3xdAc026602 for ; Sun, 11 Nov 2018 22:59:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id AE9AE5D739; Mon, 12 Nov 2018 03:59:39 +0000 (UTC) Received: from hansolo.nay.redhat.com (unknown [10.66.4.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93BD45D756; Mon, 12 Nov 2018 03:59:38 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Mon, 12 Nov 2018 11:59:16 +0800 Message-Id: <20181112035925.22376-2-hhan@redhat.com> In-Reply-To: <20181112035925.22376-1-hhan@redhat.com> References: <20181112035925.22376-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v3 01/10] qemu: Allow coldplugging of hub device X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 12 Nov 2018 04:01:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1375423 Signed-off-by: Han Han --- src/qemu/qemu_driver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9f71641dfa..1e5a69358b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8133,6 +8133,11 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, return -1; break; =20 + case VIR_DOMAIN_DEVICE_HUB: + if (VIR_APPEND_ELEMENT(vmdef->hubs, vmdef->nhubs, dev->data.hub) <= 0) + return -1; + break; + case VIR_DOMAIN_DEVICE_VSOCK: if (vmdef->vsock) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -8145,7 +8150,6 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: - case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 20:18:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541995316448211.82855751479485; Sun, 11 Nov 2018 20:01:56 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D314308624F; Mon, 12 Nov 2018 04:01:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23753600D6; Mon, 12 Nov 2018 04:01:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CF2E0181A132; Mon, 12 Nov 2018 04:01:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAC3xfVO026612 for ; Sun, 11 Nov 2018 22:59:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5B8F95D739; Mon, 12 Nov 2018 03:59:41 +0000 (UTC) Received: from hansolo.nay.redhat.com (unknown [10.66.4.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FA945D738; Mon, 12 Nov 2018 03:59:39 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Mon, 12 Nov 2018 11:59:17 +0800 Message-Id: <20181112035925.22376-3-hhan@redhat.com> In-Reply-To: <20181112035925.22376-1-hhan@redhat.com> References: <20181112035925.22376-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v3 02/10] qemu: Allow coldunplugging of hub device X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 12 Nov 2018 04:01:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1375423 Signed-off-by: Han Han --- src/conf/domain_conf.c | 30 ++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 10 +++++++++- 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 237540bccc..a2655bc29b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17652,6 +17652,36 @@ virDomainVsockDefEquals(const virDomainVsockDef *a, } =20 =20 +static bool +virDomainHubDefEquals(const virDomainHubDef *a, + const virDomainHubDef *b) +{ + if (a->type !=3D b->type) + return false; + + if (a->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + !virDomainDeviceInfoAddressIsEqual(&a->info, &b->info)) + return false; + + return true; +} + + +ssize_t +virDomainHubDefFind(const virDomainDef *def, + const virDomainHubDef *hub) +{ + size_t i; + + for (i =3D 0; i < def->nhubs; i++) { + if (virDomainHubDefEquals(hub, def->hubs[i])) + return i; + } + + return -1; +} + + char * virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e30a4b2fe7..c2d0877170 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3365,6 +3365,9 @@ virDomainShmemDefPtr virDomainShmemDefRemove(virDomai= nDefPtr def, size_t idx) ssize_t virDomainInputDefFind(const virDomainDef *def, const virDomainInputDef *input) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; +ssize_t virDomainHubDefFind(const virDomainDef *def, + const virDomainHubDef *hub) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; bool virDomainVsockDefEquals(const virDomainVsockDef *a, const virDomainVsockDef *b) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 335210c31d..6245927673 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -399,6 +399,7 @@ virDomainHostdevRemove; virDomainHostdevSubsysPCIBackendTypeToString; virDomainHostdevSubsysTypeToString; virDomainHPTResizingTypeToString; +virDomainHubDefFind; virDomainHubTypeFromString; virDomainHubTypeToString; virDomainHypervTypeFromString; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1e5a69358b..4209f017c7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8338,10 +8338,18 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, vmdef->vsock =3D NULL; break; =20 + case VIR_DOMAIN_DEVICE_HUB: + if ((idx =3D virDomainHubDefFind(vmdef, dev->data.hub)) < 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("matching hub device not found")); + return -1; + } + VIR_DELETE_ELEMENT(vmdef->hubs, idx, vmdef->nhubs); + break; + case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: - case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 20:18:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541995303310382.42115067083637; Sun, 11 Nov 2018 20:01:43 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE9713082125; Mon, 12 Nov 2018 04:01:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E1495C207; Mon, 12 Nov 2018 04:01:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F25AE181A968; Mon, 12 Nov 2018 04:01:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAC3xhaa026618 for ; Sun, 11 Nov 2018 22:59:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0922F5D757; Mon, 12 Nov 2018 03:59:43 +0000 (UTC) Received: from hansolo.nay.redhat.com (unknown [10.66.4.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1F355D756; Mon, 12 Nov 2018 03:59:41 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Mon, 12 Nov 2018 11:59:18 +0800 Message-Id: <20181112035925.22376-4-hhan@redhat.com> In-Reply-To: <20181112035925.22376-1-hhan@redhat.com> References: <20181112035925.22376-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v3 03/10] qemu: Refactor hub alias assignment for hotplug X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 12 Nov 2018 04:01:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Make qemuAssignDeviceHubAlias global and allow alias generating for reuse on hotplug. Signed-off-by: Han Han --- src/qemu/qemu_alias.c | 22 ++++++++++++++++++---- src/qemu/qemu_alias.h | 4 ++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 815caec465..116480eaee 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -364,14 +364,28 @@ qemuAssignDeviceVideoAlias(virDomainVideoDefPtr video, } =20 =20 -static int -qemuAssignDeviceHubAlias(virDomainHubDefPtr hub, +int +qemuAssignDeviceHubAlias(virDomainDefPtr def, + virDomainHubDefPtr hub, int idx) { if (hub->info.alias) return 0; =20 - return virAsprintf(&hub->info.alias, "hub%d", idx); + if (idx =3D=3D -1) { + int thisidx; + size_t i; + + for (i =3D 0; i < def->nhubs; i++) { + if ((thisidx =3D qemuDomainDeviceAliasIndex(&def->hubs[i]->inf= o, "hub")) >=3D idx) + idx =3D thisidx + 1; + } + } + + if (virAsprintf(&hub->info.alias, "hub%d", idx) < 0) + return -1; + + return 0; } =20 =20 @@ -647,7 +661,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCap= sPtr qemuCaps) return -1; } for (i =3D 0; i < def->nhubs; i++) { - if (qemuAssignDeviceHubAlias(def->hubs[i], i) < 0) + if (qemuAssignDeviceHubAlias(def, def->hubs[i], i) < 0) return -1; } for (i =3D 0; i < def->nshmems; i++) { diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h index 33b9937ea4..ea30c1c8a3 100644 --- a/src/qemu/qemu_alias.h +++ b/src/qemu/qemu_alias.h @@ -71,6 +71,10 @@ int qemuAssignDeviceInputAlias(virDomainDefPtr def, virDomainInputDefPtr input, int idx); =20 +int qemuAssignDeviceHubAlias(virDomainDefPtr def, + virDomainHubDefPtr hub, + int idx); + int qemuAssignDeviceVsockAlias(virDomainVsockDefPtr vsock); =20 int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps); --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 20:18:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541995327898453.6568493860789; Sun, 11 Nov 2018 20:02:07 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E64F3637E5; Mon, 12 Nov 2018 04:02:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A147608FA; Mon, 12 Nov 2018 04:02:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 04720181B9E3; Mon, 12 Nov 2018 04:02:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAC3xiO4026628 for ; Sun, 11 Nov 2018 22:59:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id A93F05D757; Mon, 12 Nov 2018 03:59:44 +0000 (UTC) Received: from hansolo.nay.redhat.com (unknown [10.66.4.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D4E75D756; Mon, 12 Nov 2018 03:59:43 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Mon, 12 Nov 2018 11:59:19 +0800 Message-Id: <20181112035925.22376-5-hhan@redhat.com> In-Reply-To: <20181112035925.22376-1-hhan@redhat.com> References: <20181112035925.22376-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v3 04/10] qemu: Make qemuBuildHubDevStr global X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 12 Nov 2018 04:02:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Make function qemuBuildHubDevStr global for reuse on hub hotplug. Signed-off-by: Han Han --- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_command.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f59cbf559e..508f1b4477 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4675,7 +4675,7 @@ qemuBuildUSBHostdevDevStr(const virDomainDef *def, } =20 =20 -static char * +char * qemuBuildHubDevStr(const virDomainDef *def, virDomainHubDefPtr dev, virQEMUCapsPtr qemuCaps) diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 98d4ac90b5..e1e4e56bc3 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -174,6 +174,10 @@ char *qemuBuildRedirdevDevStr(const virDomainDef *def, virDomainRedirdevDefPtr dev, virQEMUCapsPtr qemuCaps); =20 +char *qemuBuildHubDevStr(const virDomainDef *def, + virDomainHubDefPtr dev, + virQEMUCapsPtr qemuCaps); + int qemuNetworkPrepareDevices(virDomainDefPtr def); =20 int qemuGetDriveSourceString(virStorageSourcePtr src, --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 20:18:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 154199527071217.88179529678996; Sun, 11 Nov 2018 20:01:10 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E075D308FB8C; Mon, 12 Nov 2018 04:01:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB3885D757; Mon, 12 Nov 2018 04:01:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 454941808841; Mon, 12 Nov 2018 04:01:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAC3xkV8026638 for ; Sun, 11 Nov 2018 22:59:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 538955D757; Mon, 12 Nov 2018 03:59:46 +0000 (UTC) Received: from hansolo.nay.redhat.com (unknown [10.66.4.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3879C5D756; Mon, 12 Nov 2018 03:59:44 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Mon, 12 Nov 2018 11:59:20 +0800 Message-Id: <20181112035925.22376-6-hhan@redhat.com> In-Reply-To: <20181112035925.22376-1-hhan@redhat.com> References: <20181112035925.22376-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v3 05/10] conf: Add virDomainHubDefFree to libvirt_private.syms X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 12 Nov 2018 04:01:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add virDomainHubDefFree to for the preparation of usb hub hotplug. Signed-off-by: Han Han --- src/libvirt_private.syms | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6245927673..b29c2bf62b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -400,6 +400,7 @@ virDomainHostdevSubsysPCIBackendTypeToString; virDomainHostdevSubsysTypeToString; virDomainHPTResizingTypeToString; virDomainHubDefFind; +virDomainHubDefFree; virDomainHubTypeFromString; virDomainHubTypeToString; virDomainHypervTypeFromString; --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 20:18:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541995298562726.3098382134726; Sun, 11 Nov 2018 20:01:38 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67E67308A947; Mon, 12 Nov 2018 04:01:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA4336091C; Mon, 12 Nov 2018 04:01:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8E3D6181A133; Mon, 12 Nov 2018 04:01:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAC3xmta026643 for ; Sun, 11 Nov 2018 22:59:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id F2EEF5D759; Mon, 12 Nov 2018 03:59:47 +0000 (UTC) Received: from hansolo.nay.redhat.com (unknown [10.66.4.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7B525D756; Mon, 12 Nov 2018 03:59:46 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Mon, 12 Nov 2018 11:59:21 +0800 Message-Id: <20181112035925.22376-7-hhan@redhat.com> In-Reply-To: <20181112035925.22376-1-hhan@redhat.com> References: <20181112035925.22376-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v3 06/10] qemu: Implement usb hub device hotplug X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 12 Nov 2018 04:01:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1375423 Signed-off-by: Han Han --- src/qemu/qemu_driver.c | 9 ++++++- src/qemu/qemu_hotplug.c | 58 +++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_hotplug.h | 4 +++ 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4209f017c7..774f6ac8b9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7710,12 +7710,19 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, } break; =20 + case VIR_DOMAIN_DEVICE_HUB: + ret =3D qemuDomainAttachHubDevice(driver, vm, dev->data.hub); + if (ret =3D=3D 0) { + alias =3D dev->data.hub->info.alias; + dev->data.hub =3D NULL; + } + break; + case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: - case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 0a63741b9e..1b6cc36bc8 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3303,6 +3303,64 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver, } =20 =20 +int +qemuDomainAttachHubDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainHubDefPtr hub) +{ + int ret =3D -1; + char *devstr =3D NULL; + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virErrorPtr originalError =3D NULL; + bool releaseaddr =3D false; + + if (priv->usbaddrs) { + if (virDomainUSBAddressEnsure(priv->usbaddrs, &hub->info) < 0) + goto cleanup; + releaseaddr =3D true; + } + + if (qemuAssignDeviceHubAlias(vm->def, hub, -1) < 0) + goto cleanup; + + if (!(devstr =3D qemuBuildHubDevStr(vm->def, hub, priv->qemuCaps))) + goto cleanup; + + if (VIR_REALLOC_N(vm->def->hubs, vm->def->nhubs + 1) < 0) + goto cleanup; + + qemuDomainObjEnterMonitor(driver, vm); + if (qemuMonitorAddDevice(priv->mon, devstr) < 0) + goto exit_monitor; + + if (qemuDomainObjExitMonitor(driver, vm) < 0) { + releaseaddr =3D false; + goto cleanup; + } + + VIR_APPEND_ELEMENT_COPY_INPLACE(vm->def->hubs, vm->def->nhubs, hub); + + ret =3D 0; + releaseaddr =3D false; + + cleanup: + if (ret < 0) { + virErrorPreserveLast(&originalError); + if (releaseaddr) + qemuDomainReleaseDeviceAddress(vm, &hub->info, NULL); + virErrorRestore(&originalError); + } + + VIR_FREE(devstr); + return ret; + + exit_monitor: + if (qemuDomainObjExitMonitor(driver, vm) < 0) + releaseaddr =3D false; + goto cleanup; +} + + int qemuDomainAttachVsockDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 0297e42a98..19b8950254 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -135,6 +135,10 @@ int qemuDomainAttachInputDevice(virQEMUDriverPtr drive= r, virDomainObjPtr vm, virDomainInputDefPtr input); =20 +int qemuDomainAttachHubDevice(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainHubDefPtr hub); + int qemuDomainAttachVsockDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainVsockDefPtr vsock); --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 20:18:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541995311153908.1302321033317; Sun, 11 Nov 2018 20:01:51 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEB8258E26; Mon, 12 Nov 2018 04:01:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9CB1D5D738; Mon, 12 Nov 2018 04:01:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 50A8B4CA95; Mon, 12 Nov 2018 04:01:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAC3xnvO026656 for ; Sun, 11 Nov 2018 22:59:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id A0BBA5D757; Mon, 12 Nov 2018 03:59:49 +0000 (UTC) Received: from hansolo.nay.redhat.com (unknown [10.66.4.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 855A25D739; Mon, 12 Nov 2018 03:59:48 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Mon, 12 Nov 2018 11:59:22 +0800 Message-Id: <20181112035925.22376-8-hhan@redhat.com> In-Reply-To: <20181112035925.22376-1-hhan@redhat.com> References: <20181112035925.22376-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v3 07/10] conf: Add function virDomainUSBAddressIsAttachedToHub X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 12 Nov 2018 04:01:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add this function to check if the a usb address is attached to a hub device. Signed-off-by: Han Han --- src/conf/domain_addr.c | 22 ++++++++++++++++++++++ src/conf/domain_addr.h | 5 +++++ src/libvirt_private.syms | 1 + 3 files changed, 28 insertions(+) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index e4ed143b76..722bd2c9fe 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -2155,6 +2155,28 @@ virDomainUSBAddressEnsure(virDomainUSBAddressSetPtr = addrs, } =20 =20 +bool +virDomainUSBAddressIsAttachedToHub(virDomainDeviceInfoPtr info, + virDomainHubDefPtr hub) +{ + unsigned int *hub_port =3D hub->info.addr.usb.port; + unsigned int *device_port =3D info->addr.usb.port; + size_t i; + if (hub->info.addr.usb.bus =3D=3D info->addr.usb.bus) { + for (i =3D 0; i < VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH; ++i) { + if (hub_port[i] =3D=3D device_port[i]) + continue; + else if (hub_port[i] =3D=3D 0 && device_port[i] !=3D 0) + return true; + else + return false; + } + } + + return false; +} + + int virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs, virDomainDeviceInfoPtr info) diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index 2a9af9c00b..b1e0714923 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -285,6 +285,11 @@ virDomainUSBAddressEnsure(virDomainUSBAddressSetPtr ad= drs, virDomainDeviceInfoPtr info) ATTRIBUTE_NONNULL(2); =20 +bool +virDomainUSBAddressIsAttachedToHub(virDomainDeviceInfoPtr info, + virDomainHubDefPtr hub) + ATTRIBUTE_NONNULL(2); + int virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs, virDomainDeviceInfoPtr info) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b29c2bf62b..b45a7b92b4 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -131,6 +131,7 @@ virDomainPCIControllerModelToConnectType; virDomainUSBAddressAssign; virDomainUSBAddressCountAllPorts; virDomainUSBAddressEnsure; +virDomainUSBAddressIsAttachedToHub; virDomainUSBAddressPortFormatBuf; virDomainUSBAddressPortIsValid; virDomainUSBAddressPresent; --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 20:18:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541995314828128.21835259314355; Sun, 11 Nov 2018 20:01:54 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1DA8658E36; Mon, 12 Nov 2018 04:01:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3BFD5D968; Mon, 12 Nov 2018 04:01:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7F1274CAA7; Mon, 12 Nov 2018 04:01:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAC3xpai026671 for ; Sun, 11 Nov 2018 22:59:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4D7E55D739; Mon, 12 Nov 2018 03:59:51 +0000 (UTC) Received: from hansolo.nay.redhat.com (unknown [10.66.4.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31C895D756; Mon, 12 Nov 2018 03:59:49 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Mon, 12 Nov 2018 11:59:23 +0800 Message-Id: <20181112035925.22376-9-hhan@redhat.com> In-Reply-To: <20181112035925.22376-1-hhan@redhat.com> References: <20181112035925.22376-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v3 08/10] qemu: Check whether hub device is busy X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 12 Nov 2018 04:01:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" qemuDomainHubIsBusy is to check whether a usb device are attached to the hub device. It will be used for hotunplugging and live device update of hub device. Signed-off-by: Han Han --- src/qemu/qemu_hotplug.c | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1b6cc36bc8..ca73456260 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5332,6 +5332,70 @@ static bool qemuDomainControllerIsBusy(virDomainObjP= tr vm, } } =20 +static bool qemuDomainHubIsBusy(virDomainObjPtr vm, + virDomainHubDefPtr detach) +{ + size_t i; + virDomainDiskDefPtr disk; + virDomainHubDefPtr hub; + virDomainInputDefPtr input; + virDomainSoundDefPtr sound; + virDomainHostdevDefPtr hostdev; + virDomainRedirdevDefPtr redirdev; + virDomainControllerDefPtr controller; + + for (i =3D 0; i < vm->def->ndisks; i++) { + disk =3D vm->def->disks[i]; + if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_USB && + virDomainUSBAddressIsAttachedToHub(&(disk->info), detach)) + return true; + } + + for (i =3D 0; i < vm->def->nhubs; i++) { + hub =3D vm->def->hubs[i]; + if (virDomainUSBAddressIsAttachedToHub(&(hub->info), detach)) + return true; + } + + for (i =3D 0; i < vm->def->ninputs; i++) { + input =3D vm->def->inputs[i]; + if (input->bus =3D=3D VIR_DOMAIN_INPUT_BUS_USB && + virDomainUSBAddressIsAttachedToHub(&(input->info), detach)) + return true; + } + + for (i =3D 0; i < vm->def->nsounds; i++) { + sound =3D vm->def->sounds[i]; + if (sound->model =3D=3D VIR_DOMAIN_SOUND_MODEL_USB && + virDomainUSBAddressIsAttachedToHub(&(sound->info), detach)) + return true; + } + + for (i =3D 0; i < vm->def->nhostdevs; i++) { + hostdev =3D vm->def->hostdevs[i]; + if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && + hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_USB && + virDomainUSBAddressIsAttachedToHub(hostdev->info, detach)) + return true; + } + + for (i =3D 0; i < vm->def->nredirdevs; i++) { + redirdev =3D vm->def->redirdevs[i]; + if (redirdev->bus =3D=3D VIR_DOMAIN_REDIRDEV_BUS_USB && + virDomainUSBAddressIsAttachedToHub(&(redirdev->info), detach)) + return true; + } + + for (i =3D 0; i < vm->def->ncontrollers; i++) { + controller =3D vm->def->controllers[i]; + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_CCID && + virDomainUSBAddressIsAttachedToHub(&(controller->info), detach= )) + return false; + } + + return false; +} + int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 20:18:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541995326208666.7795419680745; Sun, 11 Nov 2018 20:02:06 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E660E308A974; Mon, 12 Nov 2018 04:02:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9EB43101962C; Mon, 12 Nov 2018 04:02:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3A783181A133; Mon, 12 Nov 2018 04:02:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAC3xq9V026684 for ; Sun, 11 Nov 2018 22:59:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id EFCBF5D756; Mon, 12 Nov 2018 03:59:52 +0000 (UTC) Received: from hansolo.nay.redhat.com (unknown [10.66.4.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id D247B5D738; Mon, 12 Nov 2018 03:59:51 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Mon, 12 Nov 2018 11:59:24 +0800 Message-Id: <20181112035925.22376-10-hhan@redhat.com> In-Reply-To: <20181112035925.22376-1-hhan@redhat.com> References: <20181112035925.22376-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v3 09/10] qemu: Implement usb hub device hotunplug X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 12 Nov 2018 04:02:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1375423 Signed-off-by: Han Han --- src/qemu/qemu_driver.c | 5 ++- src/qemu/qemu_hotplug.c | 81 ++++++++++++++++++++++++++++++++++++++++- src/qemu/qemu_hotplug.h | 4 ++ 3 files changed, 88 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 774f6ac8b9..2813a00050 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7822,11 +7822,14 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, ret =3D qemuDomainDetachVsockDevice(vm, dev->data.vsock, async); break; =20 + case VIR_DOMAIN_DEVICE_HUB: + ret =3D qemuDomainDetachHubDevice(vm, dev->data.hub, async); + break; + case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: - case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ca73456260..124703b7b2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4965,6 +4965,32 @@ qemuDomainRemoveRedirdevDevice(virQEMUDriverPtr driv= er, } =20 =20 +static int +qemuDomainRemoveHubDevice(virDomainObjPtr vm, + virDomainHubDefPtr dev) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virQEMUDriverPtr driver =3D priv->driver; + virObjectEventPtr event =3D NULL; + size_t i; + + VIR_DEBUG("Removing hub device %s from domain %p %s", + dev->info.alias, vm, vm->def->name); + + event =3D virDomainEventDeviceRemovedNewFromObj(vm, dev->info.alias); + virObjectEventStateQueue(driver->domainEventState, event); + for (i =3D 0; i < vm->def->nhubs; i++) { + if (vm->def->hubs[i] =3D=3D dev) + break; + } + qemuDomainReleaseDeviceAddress(vm, &dev->info, NULL); + + virDomainHubDefFree(vm->def->hubs[i]); + VIR_DELETE_ELEMENT(vm->def->hubs, i, vm->def->nhubs); + return 0; +} + + int qemuDomainRemoveDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -5016,13 +5042,16 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, ret =3D qemuDomainRemoveVsockDevice(vm, dev->data.vsock); break; =20 + case VIR_DOMAIN_DEVICE_HUB: + ret =3D qemuDomainRemoveHubDevice(vm, dev->data.hub); + break; + case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: - case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: @@ -7019,3 +7048,53 @@ qemuDomainDetachVsockDevice(virDomainObjPtr vm, qemuDomainResetDeviceRemoval(vm); return ret; } + + +int +qemuDomainDetachHubDevice(virDomainObjPtr vm, + virDomainHubDefPtr def, + bool async) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virQEMUDriverPtr driver =3D priv->driver; + virDomainHubDefPtr detach; + int ret =3D -1; + int idx; + + if ((idx =3D virDomainHubDefFind(vm->def, def)) < 0) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("matching hub device not found")); + return -1; + } + + detach =3D vm->def->hubs[idx]; + if (qemuDomainHubIsBusy(vm, detach)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached: device is busy")); + goto cleanup; + } + + if (!async) + qemuDomainMarkDeviceForRemoval(vm, &detach->info); + + qemuDomainObjEnterMonitor(driver, vm); + if (qemuMonitorDelDevice(priv->mon, detach->info.alias)) { + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + goto cleanup; + } + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + goto cleanup; + + if (async) { + ret =3D 0; + } else { + if ((ret =3D qemuDomainWaitForDeviceRemoval(vm)) =3D=3D 1) + ret =3D qemuDomainRemoveHubDevice(vm, detach); + } + + cleanup: + if (!async) + qemuDomainResetDeviceRemoval(vm); + return ret; +} diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 19b8950254..5c860c26ac 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -204,4 +204,8 @@ int qemuDomainDetachInputDevice(virDomainObjPtr vm, int qemuDomainDetachVsockDevice(virDomainObjPtr vm, virDomainVsockDefPtr dev, bool async); + +int qemuDomainDetachHubDevice(virDomainObjPtr vm, + virDomainHubDefPtr def, + bool async); #endif /* __QEMU_HOTPLUG_H__ */ --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 20:18:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541995337998596.196828405579; Sun, 11 Nov 2018 20:02:17 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 00C023082E23; Mon, 12 Nov 2018 04:02:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B783C18500; Mon, 12 Nov 2018 04:02:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 505374CA94; Mon, 12 Nov 2018 04:02:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAC3xu7q026694 for ; Sun, 11 Nov 2018 22:59:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 873795D738; Mon, 12 Nov 2018 03:59:56 +0000 (UTC) Received: from hansolo.nay.redhat.com (unknown [10.66.4.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B87C5D757; Mon, 12 Nov 2018 03:59:53 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Mon, 12 Nov 2018 11:59:25 +0800 Message-Id: <20181112035925.22376-11-hhan@redhat.com> In-Reply-To: <20181112035925.22376-1-hhan@redhat.com> References: <20181112035925.22376-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v3 10/10] news: Cold(un)plug and hot(un)plug support for usb hub X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 12 Nov 2018 04:02:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Han Han --- docs/news.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 88774c55ae..b677f52efc 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -35,6 +35,16 @@
+ + + Qemu: Add active and inactive device add or remove for QEMU + USB Hub devices + + + Add the ability to attach or detach a USB Hub device either + for active or inactive guests. + +
--=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list