From nobody Mon Feb 9 12:09:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598279270; cv=none; d=zohomail.com; s=zohoarc; b=OIAQJn7KlV7TJ9TChkgipkj7QdYI2rcr6bFUa0A8tT6RhkMtoATPjMIUTpiESvOdI0hPVYNxDoiFrsOWDNni26SqJWKgIhZsthiTDyVVv2jj5hD2RBZDUmrhtvG++vXnuVx5AjsH2jXN+Qf2OcB9hiBfJ22ev7DtxLdmoPknls0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598279270; 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=1P/dcbQo693cQssRnDbSKgZXkgmqMxNGaJjJLh4FyDw=; b=HWYWX6/AX7Fq6+JiosjsHf6ai+3Dpds2kgi27NRjJjfh2PSohzaRm/D/0QBzA+QuxTeSirgy95Emw/ZGtJ5HWsC9hzNcqZqCjnVGRLwd6RNQm681Gh/riOI3R5Tw0zDPbEfX4nGFH+pVYnnYMH6pQjjXfG+pRCHBHQpv7JeowuY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1598279270311843.5899773179302; Mon, 24 Aug 2020 07:27:50 -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-330-2sNsXsr6MOKwQ4-Er82B0g-1; Mon, 24 Aug 2020 10:27:46 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3169281F020; Mon, 24 Aug 2020 14:27:39 +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 05F145D9E4; Mon, 24 Aug 2020 14:27:39 +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 CEFA8668F7; Mon, 24 Aug 2020 14:27:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07OERZeq018147 for ; Mon, 24 Aug 2020 10:27:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 88A52203B864; Mon, 24 Aug 2020 14:27:35 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8361B203B867 for ; Mon, 24 Aug 2020 14:27:35 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 658FF800296 for ; Mon, 24 Aug 2020 14:27:35 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [51.163.158.102]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-195-B-KSbaP3Mvmvy0zepgg6vQ-1; Mon, 24 Aug 2020 10:27:33 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2108.outbound.protection.outlook.com [104.47.18.108]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-27-Nuh52FXsMiGx17xNiA0N5w-1; Mon, 24 Aug 2020 16:27:30 +0200 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com (2603:10a6:800:2c::13) by VI1PR0402MB3662.eurprd04.prod.outlook.com (2603:10a6:803:1c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Mon, 24 Aug 2020 14:27:30 +0000 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::a0ba:4965:e484:d014]) by VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::a0ba:4965:e484:d014%9]) with mapi id 15.20.3305.026; Mon, 24 Aug 2020 14:27:30 +0000 Received: from linux-tbji.devlab.prv.suse.com (192.150.153.236) by AM0PR06CA0144.eurprd06.prod.outlook.com (2603:10a6:208:ab::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.25 via Frontend Transport; Mon, 24 Aug 2020 14:27:28 +0000 X-MC-Unique: 2sNsXsr6MOKwQ4-Er82B0g-1 X-MC-Unique: B-KSbaP3Mvmvy0zepgg6vQ-1 X-MC-Unique: Nuh52FXsMiGx17xNiA0N5w-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH V4 2/3] Xen: Add support for writeFiltering in config converter Date: Mon, 24 Aug 2020 08:26:56 -0600 Message-ID: <20200824142657.16682-3-jfehlig@suse.com> In-Reply-To: <20200824142657.16682-1-jfehlig@suse.com> References: <20200824142657.16682-1-jfehlig@suse.com> X-ClientProxiedBy: AM0PR06CA0144.eurprd06.prod.outlook.com (2603:10a6:208:ab::49) 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: 82249616-db71-4f07-36c9-08d84839d4b1 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3662: 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: CJZ8WMMfnksXKBMkvSYSgREmOcYePqKbGl5qOkorWKZfE3t8ScdVeHfoVWtzQ0aIhpELxI9eVF1u9shtr4Py2fwH/2UZUojTot3K+4u1P14XCPQ37982TfIGs6hSp6M4b+Vox2424cyOg9MQgdyO3083pwVrftA4qw/ib/nHxsXlrTjJa7y8miyn6eRDG4mudIvTAsOMOmzQ6pe6OSPO7COErRIJqIzc7b5GK0YznGDEAasbhjcgQDLpROqI/xU+lT7j+1LKcPQ7qB7qWl80ubcP92s5D0XjDc2Knyy2qPGM+37TEOCkoWZv9pHNmcTwRl9yWMkRq+F7Ja7sRMenfQ== 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:(39860400002)(376002)(366004)(346002)(396003)(136003)(36756003)(66574015)(5660300002)(86362001)(83380400001)(4326008)(52116002)(7696005)(8676002)(6916009)(2616005)(26005)(186003)(956004)(66946007)(66476007)(66556008)(1076003)(8936002)(6666004)(54906003)(6486002)(478600001)(2906002)(316002)(16526019); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: aEe5bU7oi+fQSnQd2Yr+6aId0pWr4F9zzcIpKJwza9wDIUxwA5s+4MoeiZpIf9cSMB3D/0uwXE3/JbnXg7+vBw1GGwycUxgofX2JnutziyKISiy3sYQRwZoMm+qsZK7ZFKvfIf1Np3RvoxAdhrx3hLODi3ahSXF0OqFEoFtyHYQ8WgDbZcauGHB8R6mF8mJcICP899jssd1bch4DecAzUZ2uVF4bVtKc0Cc+vCuJwB1bGy+LRO323KUVhmT4I/NtI9r31yd9af0n189RCKgRNcHChsOtjZj+//s8+xI4TcRjXmhlKLkdhFPKxxdjqQA76QslqSsiLDFoOIv4Q+TL+xt0PsxV6H6d53SomxebQ5LB0CiwHNn/WRGWVK2HI0+z/XyMZu94DswDBXd/1cwwzgpGbJXIY+rPUPQ4xN9Dj1HrqL3gJpFckwGuq9QArm5xHHvUsAMXveC4XA6apfhhJzgPoJJHki9EfK1Px0OPCf5fYbQ2/yJMtmpRxmcYnTL1SFhMjUqp8byj8np4biCjZMq9iVguEP67uJJrHYSfI1AxjVek9Exo/2WDI+4tH7Kl+XiJCkO+xqlmQLu64csORO1/nRBlgXC2cr8/0kmEjPrnjima9DzGxlJP6N1DgUcJ3+qsM7UFM08Xczn1co3svA== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82249616-db71-4f07-36c9-08d84839d4b1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0401MB2429.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2020 14:27:30.0080 (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: 0XMiKHf3ohQyARvZw1JGYnijNghWD4xleo/8CQq8AVSf5fS/EJ0Xzjr3xosUnTLNUVVxhfi2XUWzvpCLaQePyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3662 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.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 07OERZeq018147 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.14 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libxl/xen_common.c | 77 ++++++++++++++++++++---- tests/xlconfigdata/test-fullvirt-pci.cfg | 25 ++++++++ tests/xlconfigdata/test-fullvirt-pci.xml | 53 ++++++++++++++++ tests/xlconfigtest.c | 1 + 4 files changed, 143 insertions(+), 13 deletions(-) diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 73ce412fe7..56702a2a76 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -373,16 +373,18 @@ xenParsePCI(char *entry) { virDomainHostdevDefPtr hostdev =3D NULL; VIR_AUTOSTRINGLIST tokens =3D NULL; + VIR_AUTOSTRINGLIST options =3D NULL; size_t ntokens =3D 0; size_t nexttoken =3D 0; - char *slotstr; - char *funcstr; + char *str; + char *nextstr; int domain =3D 0x0; int bus; int slot; int func; + virTristateBool filtered =3D VIR_TRISTATE_BOOL_ABSENT; =20 - /* pci=3D['00:1b.0','0000:00:13.0'] */ + /* pci=3D['00:1b.0','0000:00:13.0,permissive=3D1'] */ if (!(tokens =3D virStringSplitCount(entry, ":", 3, &ntokens))) return NULL; =20 @@ -398,24 +400,57 @@ xenParsePCI(char *entry) return NULL; nexttoken++; =20 - /* slot and function */ - slotstr =3D tokens[nexttoken]; - if (!(funcstr =3D strchr(slotstr, '.'))) { + /* slot, function, and options */ + str =3D tokens[nexttoken]; + if (!(nextstr =3D strchr(str, '.'))) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Malformed PCI address %s"), slotstr); + _("Malformed PCI address %s"), str); return NULL; } - *funcstr =3D '\0'; - funcstr++; - if (virStrToLong_i(slotstr, NULL, 16, &slot) < 0) + *nextstr =3D '\0'; + nextstr++; + if (virStrToLong_i(str, NULL, 16, &slot) < 0) return NULL; - if (virStrToLong_i(funcstr, NULL, 16, &func) < 0) + str =3D nextstr++; + + nextstr =3D strchr(str, ','); + if (nextstr) { + *nextstr =3D '\0'; + nextstr++; + } + if (virStrToLong_i(str, NULL, 16, &func) < 0) return NULL; =20 + str =3D nextstr; + if (str && (options =3D virStringSplit(str, ",", 0))) { + size_t i; + + for (i =3D 0; options[i] !=3D NULL; i++) { + char *val; + + if (!(val =3D strchr(options[i], '=3D'))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Malformed PCI options %s"), str); + return NULL; + } + *val =3D '\0'; + val++; + if (STREQ(options[i], "permissive")) { + int intval; + + /* xl.cfg(5) specifies false as 0 and true as any other nu= meric value */ + if (virStrToLong_i(val, NULL, 10, &intval) < 0) + return NULL; + filtered =3D intval ? VIR_TRISTATE_BOOL_NO : VIR_TRISTATE_= BOOL_YES; + } + } + } + if (!(hostdev =3D virDomainHostdevDefNew())) 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 domain; hostdev->source.subsys.u.pci.addr.bus =3D bus; @@ -1830,12 +1865,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