From nobody Tue Nov 26 18:16:59 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1570482737; cv=none; d=zoho.com; s=zohoarc; b=OfUBd9NqPCGqqHSzetMa/Zp1vJFLvgT0GICYJo8DEm/dh0LP370G3yN/jZYkObduT0qIInXgmd7UzPPy8xe++K74Es7bPs0q1wYnSjRMfi2Lgm46KYvVYEWLSCtJ+59n+LSdu86/6Cxua1bIi2M6xENAEDvIecetR+FxOb/2wtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570482737; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2AKQty3+WF1HKxcIQBWJ6eADLV4VpU5+LUBlo91BCUQ=; b=UfRv3wbkVWX7U8Rw1AM1/uMDAfcR17nqtOZ2dVFvELvEm8CEZemXDHJaxPYhSGgDOQGI+rELRzRb3+5x9J4aJAs7O4ae6Bc0SKbcgDeTLSLtnJp7tgccLZJ6ihTz5qLkQIVxUv1cwhEvGtaRwBAu4YHwaFohdsKzUOE80/csRew= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15704827370591.744835018533763; Mon, 7 Oct 2019 14:12:17 -0700 (PDT) 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 34DF5302C08A; Mon, 7 Oct 2019 21:12:15 +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 0E718600C1; Mon, 7 Oct 2019 21:12: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 BCF694EE68; Mon, 7 Oct 2019 21:12:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LBv3Z012229 for ; Mon, 7 Oct 2019 17:11:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 61A2719C68; Mon, 7 Oct 2019 21:11:57 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5BD6E19C69 for ; Mon, 7 Oct 2019 21:11:55 +0000 (UTC) Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 12D10308FC22 for ; Mon, 7 Oct 2019 21:11:53 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id w2so14126278qkf.2 for ; Mon, 07 Oct 2019 14:11:53 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:e8e7:3739:3e28:be31:8030]) by smtp.gmail.com with ESMTPSA id i30sm11333409qte.27.2019.10.07.14.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 14:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dB+xYqo1vLOuT1r4246Whp741oXEbUAXavZdTetyOHk=; b=Kj9d8jNxjzypCY1Boahikx8zPXgisdwEwElKwccMCVb5B0m8HvcbCbJY5skQ17MQt4 54BgQ2rmuUJkgabAR2eHu1fXJ2/kjCVrK/AdCvEVEPUv/BSFKnj5fRYWXq9AWpS9xFRi d5j3b6Xh1IjjkSW1/KLAhIp2BiKwKcfytSwnc0iOgVE6E9BCXJhf7d+wrLOmIqV240Fj z/sUPvo+BXuL/uwJby+6r8wHRkTmf2XnckPJSgS+Y9yltQ8xXlh77fK66S+OrksmyMPJ FfNcARiQ0EvbowMbtr0rQmhr1TLfcfgyZWGyIZA//IsnuC9fgM7iaCK23bHbJQQeDo7q BNOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dB+xYqo1vLOuT1r4246Whp741oXEbUAXavZdTetyOHk=; b=QHw70rBssvNUgmXDQffvUgd0Oz9IBuxyJKbCGvzyDJbgmbAg3HdeTivPOFWuqc4/vV CYgTW5Ns3sIOoGN8SVHXjwcpMd4O4jY5CQUm1YcH4UOCh6wddTcTf741/Eafs7jPv8wA K8FC6iHn3g6nyGEzjW3JUjmk0G/p5+5/gC7JHqnvyIGmtYhxQN5TtYuLXZ67l8GOWzWh Ax0TiOqRlzIlgdwp/J721pzV+ewahSlBxmhvjXIsuNSk6mMbGaCsQeiTFycNYe1r3U2F vqdrrpEZgwTHgCb0wmzffLnfERJ7VhfO25qYz0PgAQ4F1BuD3SfSL9qgBgySpYO90HfT ovHg== X-Gm-Message-State: APjAAAVhUTNvXewuvzYD8g/N46aPBouRmZp3DRp5N9Bp6f1XNY7u31WD NlCrw23V417z+AKehypDpCws5ked X-Google-Smtp-Source: APXvYqzg2mOqWPji+4Zr48659G4cWFZdNMB8FoDcwddlsrZjyfLRw4K5B8gfsqvIy2iHLNaelIqNAA== X-Received: by 2002:a37:7fc7:: with SMTP id a190mr25717456qkd.351.1570482711984; Mon, 07 Oct 2019 14:11:51 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 18:11:35 -0300 Message-Id: <20191007211136.16730-4-danielhb413@gmail.com> In-Reply-To: <20191007211136.16730-1-danielhb413@gmail.com> References: <20191007211136.16730-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 07 Oct 2019 21:11:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 07 Oct 2019 21:11:53 +0000 (UTC) for IP:'209.85.222.193' DOMAIN:'mail-qk1-f193.google.com' HELO:'mail-qk1-f193.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.15 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.222.193 mail-qk1-f193.google.com 209.85.222.193 mail-qk1-f193.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH 3/4] qemu_command: ignore non-assigned PCI multifunction hostdevs 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.46]); Mon, 07 Oct 2019 21:12:15 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Bulding up in the new attribute introduced by the previous patch, let's not assign a hostdev to a QEMU domain by avoiding the '-device' line to be created at all inside qemu_command.c. Since the device isn't going to be guest visible, makes little sense to assign alias and address to it, so let's also prevent that. Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_alias.c | 8 +++ src/qemu/qemu_command.c | 5 ++ src/qemu/qemu_domain_address.c | 7 +++ .../hostdev-pci-multifunction-partial.args | 31 ++++++++++ .../hostdev-pci-multifunction-partial.xml | 41 +++++++++++++ tests/qemuxml2argvtest.c | 4 ++ .../hostdev-pci-multifunction-partial.xml | 57 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 8 files changed, 154 insertions(+) create mode 100644 tests/qemuxml2argvdata/hostdev-pci-multifunction-partia= l.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-multifunction-partia= l.xml create mode 100644 tests/qemuxml2xmloutdata/hostdev-pci-multifunction-part= ial.xml diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index d294963d35..f1705a9a47 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -602,6 +602,14 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCa= psPtr qemuCaps) return -1; } for (i =3D 0; i < def->nhostdevs; i++) { + /* do not assign alias for PCI multifunction hostdevs that + * will not be assigned to the guest. + */ + + if (virHostdevIsPCIMultifunctionDevice(def->hostdevs[i]) && + !def->hostdevs[i]->assigned) + continue; + /* we can't start assigning at 0, since netdevs may have used * up some hostdevN entries already. Also if the HostdevDef is * linked to a NetDef, they will share an info and the alias diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index cbf25d5f07..1e12550e9b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5490,6 +5490,11 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, } } =20 + /* Ignore 'noAssign' devices + */ + if (!hostdev->assigned) + continue; + unsigned int bootIndex =3D hostdev->info->bootIndex; =20 /* bootNet will be non-0 if boot order was set and no other diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 4f5671f458..71711e22d2 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -2319,6 +2319,13 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, continue; } =20 + /* Do not assign an address to a hostdev that will not + * be assigned to the guest. + */ + if (virHostdevIsPCIMultifunctionDevice(def->hostdevs[i]) && + !def->hostdevs[i]->assigned) + continue; + if (qemuDomainPCIAddressReserveNextAddr(addrs, def->hostdevs[i]->info) < = 0) goto error; diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.args = b/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.args new file mode 100644 index 0000000000..4074968c84 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.args @@ -0,0 +1,31 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-delete \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-delete/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-delete/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-delete/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name delete \ +-S \ +-machine pc,accel=3Dkvm,usb=3Doff,dump-guest-core=3Doff \ +-m 256 \ +-realtime mlock=3Doff \ +-smp 4,sockets=3D4,cores=3D1,threads=3D1 \ +-uuid 583a8e8e-f0ce-4f53-89ab-092862148b25 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-delete/monitor.= sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-usb \ +-device vfio-pci,host=3D0005:90:01.0,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D0005:90:01.1,id=3Dhostdev1,bus=3Dpci.0,addr=3D0x4 \ +-device vfio-pci,host=3D0005:90:01.3,id=3Dhostdev2,bus=3Dpci.0,addr=3D0x5 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x6 diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.xml b= /tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.xml new file mode 100644 index 0000000000..e87dfcdcff --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.xml @@ -0,0 +1,41 @@ + + delete + 583a8e8e-f0ce-4f53-89ab-092862148b25 + 262144 + 4 + + hvm + + + /usr/bin/qemu-system-x86_64 + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index db79301f0e..434e01308c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1357,6 +1357,10 @@ mymain(void) QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_VFIO_PCI); =20 + DO_TEST("hostdev-pci-multifunction-partial", + QEMU_CAPS_KVM, + QEMU_CAPS_DEVICE_VFIO_PCI); + DO_TEST("serial-file-log", QEMU_CAPS_CHARDEV_FILE_APPEND, QEMU_CAPS_DEVICE_ISA_SERIAL, diff --git a/tests/qemuxml2xmloutdata/hostdev-pci-multifunction-partial.xml= b/tests/qemuxml2xmloutdata/hostdev-pci-multifunction-partial.xml new file mode 100644 index 0000000000..aa8da25ccd --- /dev/null +++ b/tests/qemuxml2xmloutdata/hostdev-pci-multifunction-partial.xml @@ -0,0 +1,57 @@ + + delete + 583a8e8e-f0ce-4f53-89ab-092862148b25 + 262144 + 262144 + 4 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + + + +
+ +
+ + + + +
+ +
+ + + + +
+ + + + + +
+ +
+ + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index d5c66d8791..5e0fa6af86 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -441,6 +441,7 @@ mymain(void) DO_TEST("hostdev-usb-address", NONE); DO_TEST("hostdev-pci-address", NONE); DO_TEST("hostdev-pci-multifunction", NONE); + DO_TEST("hostdev-pci-multifunction-partial", NONE); DO_TEST("hostdev-vfio", NONE); DO_TEST("hostdev-vfio-zpci", QEMU_CAPS_DEVICE_ZPCI, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list