From nobody Tue Mar 3 04:52:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1771245683; cv=none; d=zohomail.com; s=zohoarc; b=Oh9+zmmO0w/6p420Y98BkG9vH+k5jrgBP9N0mQOVj+3mnxhP6MrTrg+MGAEkBUSoyOaczS3clC3sfXDJCJtdO6mtZ+I215bbJG1URl+NfrPtSQNpbW2fhGhOKnI/Dhg9BXhWUBbCckP9tUfCyics2STQV0VKmv+yaBpNyHeSbJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771245683; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=sCh5GscqLeMnqwzIahG4JKqXHkCtGLw6k3ctwinFjzk=; b=lIcRSBVaOlTtREPrPm/P3V6F1LEnhI26kw46otDJUgVygIu+XT3RzSevTo53XIY0MCF/gEp/QRB5ijP350Uq8naPHeXFKQjH7m3JpRQdhs/aMUFzeJtA0C+MrAIRKr5bIoQW7jm3o3PzvbeptzhomP+IaONNEzJCCTy8CIBxMTA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1771245683297974.9506302107769; Mon, 16 Feb 2026 04:41:23 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 7D8F83F9A4; Mon, 16 Feb 2026 07:41:22 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id A42D441BE2; Mon, 16 Feb 2026 07:33:01 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 09A613FCA9; Mon, 16 Feb 2026 07:32:58 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7C10D41945 for ; Mon, 16 Feb 2026 07:28:35 -0500 (EST) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-83-hhllvNeMOCaPvunziGxvpQ-1; Mon, 16 Feb 2026 07:28:33 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 135A21956048 for ; Mon, 16 Feb 2026 12:28:33 +0000 (UTC) Received: from antique-laptop.rosnicka.net (unknown [10.45.242.10]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 66D6C30001A5 for ; Mon, 16 Feb 2026 12:28:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771244915; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sCh5GscqLeMnqwzIahG4JKqXHkCtGLw6k3ctwinFjzk=; b=b1wZE9qlgzEn5Um2fNC1purIVBTJpbwkcn9Pt/MsSp8Ta0ZE8Dx0WruPhLm4d+bUXXopWW h43yzxq/73+u+Khjr52kvXfLNWstLr//Oss8dg0LNCXSsQhFtTj/1CYyNCr3TGgN3C/Exj LeBOB9wgxShRN6/Q21kCRR5wQ65k7WA= X-MC-Unique: hhllvNeMOCaPvunziGxvpQ-1 X-Mimecast-MFC-AGG-ID: hhllvNeMOCaPvunziGxvpQ_1771244913 To: devel@lists.libvirt.org Subject: [libvirt PATCH 13/24] qemuxmlconftest: Refactor host device preparation Date: Mon, 16 Feb 2026 13:28:05 +0100 Message-ID: <1aafb7b6819d67016b5326009ea70c7e4d7fa954.1771244723.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: RNQtX5i8CG1UC0kXh20CCL6LaPGBzJErDmQJANwZVS4_1771244913 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: AEKSIQH4LIEHLH5SKOQQMNFK7G2IT6DF X-Message-ID-Hash: AEKSIQH4LIEHLH5SKOQQMNFK7G2IT6DF X-MailFrom: phrdina@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pavel Hrdina via Devel Reply-To: Pavel Hrdina X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1771245684925158500 Content-Type: text/plain; charset="utf-8"; x-default="true" Create a single place for host device preparation code. Signed-off-by: Pavel Hrdina --- tests/qemuxmlconftest.c | 71 ++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 5fddf3a523..321c444d77 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -378,6 +378,54 @@ testSetupHostdevPrivateData(virDomainDef *def) } =20 =20 +static void +testQemuPrepareHostdevUSB(virDomainHostdevDef *hostdev) +{ + virDomainHostdevSubsysUSB *usb =3D &hostdev->source.subsys.u.usb; + + if (!usb->device && !usb->bus) { + if (usb->vendor =3D=3D 0x1234 && usb->product =3D=3D 0x4321) { + usb->bus =3D 42; + usb->device =3D 0x1234; + } else { + g_assert_not_reached(); + } + } else if (!usb->device && !usb->vendor && !usb->product) { + if (usb->bus =3D=3D 2 && STREQ(usb->port, "3")) { + usb->device =3D 4; + } else { + g_assert_not_reached(); + } + } +} + + +static void +testQemuPrepareHostdev(virDomainObj *vm) +{ + size_t i; + + for (i =3D 0; i < vm->def->nhostdevs; i++) { + virDomainHostdevDef *hostdev =3D vm->def->hostdevs[i]; + + if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) + continue; + + switch (hostdev->source.subsys.type) { + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: + testQemuPrepareHostdevUSB(hostdev); + break; + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: + break; + } + } +} + + static virNetworkDriver fakeNetworkDriver =3D { .networkLookupByName =3D fakeNetworkLookupByName, .networkGetXMLDesc =3D fakeNetworkGetXMLDesc, @@ -524,28 +572,7 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, } } =20 - for (i =3D 0; i < vm->def->nhostdevs; i++) { - virDomainHostdevDef *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) { - virDomainHostdevSubsysUSB *usb =3D &hostdev->source.subsys.u.u= sb; - if (!usb->device && !usb->bus) { - if (usb->vendor =3D=3D 0x1234 && usb->product =3D=3D 0x432= 1) { - usb->bus =3D 42; - usb->device =3D 0x1234; - } else { - g_assert_not_reached(); - } - } else if (!usb->device && !usb->vendor && !usb->product) { - if (usb->bus =3D=3D 2 && STREQ(usb->port, "3")) { - usb->device =3D 4; - } else { - g_assert_not_reached(); - } - } - } - } + testQemuPrepareHostdev(vm); =20 if (flags & FLAG_SLIRP_HELPER) { for (i =3D 0; i < vm->def->nnets; i++) { --=20 2.53.0