From nobody Mon Feb 9 08:29:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1597441472; cv=none; d=zohomail.com; s=zohoarc; b=XWpz6/GBDj7fIUyEhrwUKEBiwAFZe/FIedr1/ElNn7OWYiAtX8hov/VmMYSCxRBWENxS7JX/fwfF2ASbn7kO+zEPt9lRwl1nXMaMq6Vz5gZm9eq4CNDkCcvZgFm0MjjeslSFkctxyDPQKeD5yj7HgiSX5r1NrMDazdTtbmVeprs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597441472; h=Content-Type:Content-Transfer-Encoding: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; bh=+6kcHN1A5iu5Y0DK3u+9du4xzY7YCI+iw3HVo+p+u7Y=; b=WNLIoiU/9XQ298yKXUX8OsM1XMkWkh0dorprmlXsSNnHI4LyYyXkxJXTnw7rluZgQTQ0BkgqrwDq35jENJ8pIVbT1mdBJaZ1yML+ScZZeoBW7cZnbzudSWWctRVrQOyNxHpsc+sZwwOcLRt8fhBKd4yK1nSs6qZxa7y15o10kjE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1597441472034338.5265670692779; Fri, 14 Aug 2020 14:44:32 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-536-x6hSyM-7NbGG8yDib8aAoA-1; Fri, 14 Aug 2020 17:44:29 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 140FC801A9D; Fri, 14 Aug 2020 21:44:24 +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 E863E702DC; Fri, 14 Aug 2020 21:44:23 +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 B04F6181A050; Fri, 14 Aug 2020 21:44:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07ELi3H3002243 for ; Fri, 14 Aug 2020 17:44:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 070202166BB3; Fri, 14 Aug 2020 21:44:03 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00C852166BA3 for ; Fri, 14 Aug 2020 21:43:57 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7EF4A85A5A7 for ; Fri, 14 Aug 2020 21:43:57 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [62.140.7.102]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-Bby1RSnKPAO77fzqYwkbYw-1; Fri, 14 Aug 2020 17:43:55 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2169.outbound.protection.outlook.com [104.47.17.169]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-14-kinJVV51PSy0FQcRDH3qvQ-1; Fri, 14 Aug 2020 23:43:53 +0200 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com (2603:10a6:800:2c::13) by VI1PR0402MB3456.eurprd04.prod.outlook.com (2603:10a6:803:7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.18; Fri, 14 Aug 2020 21:43:52 +0000 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::c13d:6e8a:85f9:1bf5]) by VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::c13d:6e8a:85f9:1bf5%6]) with mapi id 15.20.3283.015; Fri, 14 Aug 2020 21:43:52 +0000 Received: from linux-tbji.devlab.prv.suse.com (192.150.153.236) by AM0PR01CA0137.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Fri, 14 Aug 2020 21:43:50 +0000 X-MC-Unique: x6hSyM-7NbGG8yDib8aAoA-1 X-MC-Unique: Bby1RSnKPAO77fzqYwkbYw-1 X-MC-Unique: kinJVV51PSy0FQcRDH3qvQ-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH V3 2/3] Xen: Add support for writeFiltering in config converter Date: Fri, 14 Aug 2020 15:43:28 -0600 Message-ID: <20200814214329.32535-3-jfehlig@suse.com> In-Reply-To: <20200814214329.32535-1-jfehlig@suse.com> References: <20200814214329.32535-1-jfehlig@suse.com> X-ClientProxiedBy: AM0PR01CA0137.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::42) To VI1PR0401MB2429.eurprd04.prod.outlook.com (2603:10a6:800:2c::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Originating-IP: [192.150.153.236] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4299c7d4-f2f9-4a94-7146-08d8409b226a X-MS-TrafficTypeDiagnostic: VI1PR0402MB3456: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:220; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: getHQWOFeTwh5nd+siOX2NEvT282ViCPiBhFrBSevnEqofIR9cObxRLeAL8lkhKc27T2EMKeop10uRG+bgbK9LJEp6whUKZpt4OvoxXFbDSCO25F1E7FhRfRqynnp+JwSNl1bY8VdeNoMUDfKYm+/Quo8ZYbl40DuGWSb45dlqVDKdwJhYcKg7glUm7IDtKDZdOSYWKOA2qN7Ig+pQm8ipnM4piuny2ollJKJGqUEUtWaiM++YZ0nExk4BdfzKaC6Z3Dt3XUQsxJpfO/YNCh0eHBv3eh2nyruU2e66mCxfCNGTvC6a5qqrRRnwCyM+wNswtLRz8JqH0lxd/NRcrZog== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0401MB2429.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(396003)(136003)(376002)(39860400002)(366004)(2616005)(4326008)(478600001)(83380400001)(186003)(956004)(1076003)(8676002)(6486002)(52116002)(7696005)(36756003)(66574015)(66476007)(66556008)(6666004)(86362001)(26005)(66946007)(316002)(16526019)(2906002)(5660300002)(54906003)(8936002)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: AdractqLdgzfVBKs6rJ/CPvZEDjSVd4yWKl7posfPR/nxAmjzfz7Zzya/Ub0RUXCBQ4xsVJfsO4bwwtR7/YNBd6FY29cUjWKtXM7dHk0/uoCQ2SzMf986f/HcKdMMARFo4AWKPxcLsikQ6Hlvfc+oh9FnmGDsRyh0yK5FOiuJGNHquCMIa/V1OLDc/3Wm9gbwQ8PbGSczGY9pr2ZiXbdu9QaEdtbBZBiPiMGg9tkafKvGu3hiKjQEGtEmLzDtAzXLhfnsXX5eFCG5RO/FF+eY9RSpuUA8b4v1N6kFFa2rjDZNsdymBFNtt3p2fPKaVNT/B1B5frpDYjbOpc+6HuobZeSlbJXnLtMqVHVGZ2fYFPukkryhh4hcj5CD8BEgWeU22Kugiija3JIvOdQTVd93UU6SuQux6m4hVnqEzvzgbtPEaNGvEbznSxEZonc0TyYaGUY31n5UhyYi0um13D46gANcSlDHQMhLHAbhE+S75MSV3E5/QOxRymPlwv9CokjQ1/wMvrCFaL3rSibDLiJKLEVUmTMdWC4qzSOOxx5lIQ61k2Ylyizy9S9TtVgojbMN/VwqSmzh43wIi4yREmP0pdZzMIaQv8BsoJ2Nd4biYU8HIBaHKg+5lZNUnDCv4IzM9Xfe8Ih9SXmnKhuHlAcsg== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4299c7d4-f2f9-4a94-7146-08d8409b226a X-MS-Exchange-CrossTenant-AuthSource: VI1PR0401MB2429.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2020 21:43:52.1191 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: v81WK0/ULDZLjtXTrlfqXBeND3sEWO4MFwvZNWqps6vSHbYFsjuEKwbqc1xnbBvMXTOpIxWlyMjb45On82ctvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3456 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 07ELi3H3002243 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add support for the writeFiltering attribute in the domXML to native config converter. Also include a test. Signed-off-by: Jim Fehlig Signed-off-by: Marek Marczykowski-G=C3=B3recki --- src/libxl/xen_common.c | 52 ++++++++++++++++++++--- tests/xlconfigdata/test-fullvirt-pci.cfg | 25 +++++++++++ tests/xlconfigdata/test-fullvirt-pci.xml | 53 ++++++++++++++++++++++++ tests/xlconfigtest.c | 1 + 4 files changed, 126 insertions(+), 5 deletions(-) diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 75fe7e0644..a15a3c6007 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -381,10 +381,11 @@ xenParsePCI(char *entry) int busID; int slotID; int funcID; + virTristateBool filtered =3D VIR_TRISTATE_BOOL_ABSENT; =20 domain[0] =3D bus[0] =3D slot[0] =3D func[0] =3D '\0'; =20 - /* pci=3D['0000:00:1b.0','0000:00:13.0'] */ + /* pci=3D['0000:00:1b.0','0000:00:13.0,permissive=3D1'] */ if (!(key =3D entry)) return NULL; if (!(nextkey =3D strchr(key, ':'))) @@ -414,14 +415,38 @@ xenParsePCI(char *entry) } =20 key =3D nextkey + 1; - if (strlen(key) !=3D 1) + if (!(nextkey =3D strchrnul(key, ','))) return NULL; - if (virStrncpy(func, key, 1, sizeof(func)) < 0) { + if (virStrncpy(func, key, (nextkey - key), sizeof(func)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Function %s too big for destination"), key); return NULL; } =20 + /* options */ + while (*nextkey !=3D '\0') { + char *data; + key =3D nextkey + 1; + if (!(data =3D strchr(key, '=3D'))) + return NULL; + data++; + if (!(nextkey =3D strchrnul(key, ','))) + return NULL; + if (STRPREFIX(key, "permissive=3D")) { + char valuestr[5]; + int valueint; + if (virStrncpy(valuestr, data, (nextkey - data), sizeof(values= tr)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Permissive %s too big for destination"), data); + return NULL; + } + /* xl.cfg(5) specifies false as 0 and true as any other numeri= c value */ + if (virStrToLong_i(valuestr, NULL, 10, &valueint) < 0) + return NULL; + filtered =3D valueint ? VIR_TRISTATE_BOOL_NO : VIR_TRISTATE_BO= OL_YES; + } + } + if (virStrToLong_i(domain, NULL, 16, &domainID) < 0) return NULL; if (virStrToLong_i(bus, NULL, 16, &busID) < 0) @@ -435,6 +460,7 @@ xenParsePCI(char *entry) return NULL; =20 hostdev->managed =3D false; + hostdev->writeFiltering =3D filtered; hostdev->source.subsys.type =3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI; hostdev->source.subsys.u.pci.addr.domain =3D domainID; hostdev->source.subsys.u.pci.addr.bus =3D busID; @@ -1849,12 +1875,28 @@ xenFormatPCI(virConfPtr conf, virDomainDefPtr def) def->hostdevs[i]->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV= _SUBSYS_TYPE_PCI) { virConfValuePtr val, tmp; char *buf; + const char *permissive_str =3D NULL; =20 - buf =3D g_strdup_printf("%04x:%02x:%02x.%x", + switch (def->hostdevs[i]->writeFiltering) { + case VIR_TRISTATE_BOOL_YES: + permissive_str =3D ",permissive=3D0"; + break; + case VIR_TRISTATE_BOOL_NO: + permissive_str =3D ",permissive=3D1"; + break; + case VIR_TRISTATE_BOOL_ABSENT: + case VIR_TRISTATE_BOOL_LAST: + permissive_str =3D ""; + break; + } + + buf =3D g_strdup_printf("%04x:%02x:%02x.%x%s", def->hostdevs[i]->source.subsys.u.pci.ad= dr.domain, def->hostdevs[i]->source.subsys.u.pci.ad= dr.bus, def->hostdevs[i]->source.subsys.u.pci.ad= dr.slot, - def->hostdevs[i]->source.subsys.u.pci.ad= dr.function); + def->hostdevs[i]->source.subsys.u.pci.ad= dr.function, + permissive_str); + =20 if (VIR_ALLOC(val) < 0) { VIR_FREE(buf); diff --git a/tests/xlconfigdata/test-fullvirt-pci.cfg b/tests/xlconfigdata/= test-fullvirt-pci.cfg new file mode 100644 index 0000000000..5a3f572e25 --- /dev/null +++ b/tests/xlconfigdata/test-fullvirt-pci.cfg @@ -0,0 +1,25 @@ +name =3D "XenGuest2" +uuid =3D "c7a5fdb2-cdaf-9455-926a-d65c16db1809" +maxmem =3D 579 +memory =3D 394 +vcpus =3D 1 +pae =3D 1 +acpi =3D 1 +apic =3D 1 +viridian =3D 0 +rtc_timeoffset =3D 0 +localtime =3D 0 +on_poweroff =3D "destroy" +on_reboot =3D "restart" +on_crash =3D "restart" +device_model =3D "/usr/lib/xen/bin/qemu-system-i386" +sdl =3D 0 +vnc =3D 1 +vncunused =3D 1 +vnclisten =3D "127.0.0.1" +pci =3D [ "0000:01:1a.1", "0000:02:00.0,permissive=3D1" ] +parallel =3D "none" +serial =3D "none" +builder =3D "hvm" +boot =3D "d" +disk =3D [ "format=3Draw,vdev=3Dhda,access=3Drw,backendtype=3Dphy,target= =3D/dev/HostVG/XenGuest2" ] diff --git a/tests/xlconfigdata/test-fullvirt-pci.xml b/tests/xlconfigdata/= test-fullvirt-pci.xml new file mode 100644 index 0000000000..75aa6ac25b --- /dev/null +++ b/tests/xlconfigdata/test-fullvirt-pci.xml @@ -0,0 +1,53 @@ + + XenGuest2 + c7a5fdb2-cdaf-9455-926a-d65c16db1809 + 592896 + 403456 + 1 + + hvm + /usr/lib/xen/boot/hvmloader + + + + + + + + + destroy + restart + restart + + /usr/lib/xen/bin/qemu-system-i386 + + + + +
+ + + + + + + + + + + + +
+ + + + + +
+ + + + + diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index b2e045dfa5..35f437bde1 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -260,6 +260,7 @@ mymain(void) DO_TEST("fullvirt-nestedhvm-disabled"); DO_TEST("fullvirt-cpuid"); DO_TEST("fullvirt-acpi-slic"); + DO_TEST("fullvirt-pci"); #ifdef LIBXL_HAVE_VNUMA DO_TEST("fullvirt-vnuma"); DO_TEST_PARSE("fullvirt-vnuma-autocomplete", false); --=20 2.28.0