From nobody Mon Feb 9 13:57:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1596211891; cv=none; d=zohomail.com; s=zohoarc; b=EXXqdxiWepnlQA0i6fvRiA9h/HQAwlOWnxWpmU6811QEZuYMMVyMe/+m/9vSw3XfastCI0ArbwDx97cgz0LwB/t6Z5ZfcTEYJVU8O8LyLf7lBL10tBJDMUKcW4/99fIekQnRsklLbcECs0vTufHJPHkgpaJnrB7LdT2alurHnZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596211891; 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=e7/XeZD2MktSMgzw5dwZD+qBusZR6bKOYJQRuaapO9c=; b=JE9fF85wBmCruILQpBd2m7tx4CLmb9WaCuS6bIDU7gKGThuLrc6SVZ03nRa9msrM56tV7ePkxco2NI26+OkXOiwsZ2W2KVMP7VCwV1FE/YwaONh7DLXmGlhMrl+nuZH39mp9/zdXKveY4zzsy44ngSTVTiQRmkLIrFtiU0xLorY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1596211891672814.8107119418613; Fri, 31 Jul 2020 09:11:31 -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-249-po9IBXGEMZmFFXmDNSm-rQ-1; Fri, 31 Jul 2020 12:11:27 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 34BDE59; Fri, 31 Jul 2020 16:11:22 +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 137E45F7D8; Fri, 31 Jul 2020 16:11:22 +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 D46E095A7B; Fri, 31 Jul 2020 16:11:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06VGBI9X002580 for ; Fri, 31 Jul 2020 12:11:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id A4C8AFA73E; Fri, 31 Jul 2020 16:11:18 +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 5B6A6F7FCA for ; Fri, 31 Jul 2020 16:11:15 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 F015C805C21 for ; Fri, 31 Jul 2020 16:11:14 +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-164-tmu4OCJFMWCdTmfGQSEkJg-1; Fri, 31 Jul 2020 12:11:12 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01lp2055.outbound.protection.outlook.com [104.47.2.55]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-16-KihaxIMzOq2c1RaQJ5ooxA-3; Fri, 31 Jul 2020 18:11:09 +0200 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com (2603:10a6:800:2c::13) by VI1PR04MB6830.eurprd04.prod.outlook.com (2603:10a6:803:132::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.17; Fri, 31 Jul 2020 16:11:08 +0000 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::7cc0:b0a4:b951:90e2]) by VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::7cc0:b0a4:b951:90e2%11]) with mapi id 15.20.3216.034; Fri, 31 Jul 2020 16:11:08 +0000 Received: from linux-tbji.devlab.prv.suse.com (192.150.153.236) by FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.9 via Frontend Transport; Fri, 31 Jul 2020 16:11:06 +0000 X-MC-Unique: po9IBXGEMZmFFXmDNSm-rQ-1 X-MC-Unique: tmu4OCJFMWCdTmfGQSEkJg-1 X-MC-Unique: KihaxIMzOq2c1RaQJ5ooxA-3 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH 2/4] Xen: Add support for qemu command-line passthrough Date: Fri, 31 Jul 2020 10:10:41 -0600 Message-ID: <20200731161043.8858-3-jfehlig@suse.com> In-Reply-To: <20200731161043.8858-1-jfehlig@suse.com> References: <20200731161043.8858-1-jfehlig@suse.com> X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) 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: 85bb3c14-fd20-4677-7504-08d8356c5546 X-MS-TrafficTypeDiagnostic: VI1PR04MB6830: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:765; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pW90ooLcteh/IkAvQc+hR3kW1SB9CfbdtUx19gVHVPfja4WkreYK82uKbE5VWRUVhwfYtTs6hUtMxcp2yCBZcq9LeEhv0ZdYOp+ooWr27DdlXuvAZRFT6+12pi8BAgJB5U0wEg+stH46ETOWsCKr32Dn78+huuSRujkz2IV/9+DDaOwPHsPYt92BXK9Gds2mLzVJCnwD2PSawSitdrKoWT1tZO+p9/Vo1PpAdisV/41dPve9lWoqlCK2QylHlaVC8QVYoGPfl8A1zqa9wlvxC4TmjVNQ0VizDK8S95WebPAqtfeZRaEvMoYFEOZLiK5dFTsl2fHCZKND4VjFwWoVzoJtThgJX7+8BOAQZxQess5K0qWNGlbdT55Nwcd8MP3cQ3LerUtsgz0Q0VcpoS/GqA== 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; SFTY:; SFS:(136003)(376002)(39860400002)(346002)(396003)(366004)(4326008)(6666004)(16526019)(186003)(26005)(1076003)(5660300002)(86362001)(316002)(8676002)(66556008)(2906002)(478600001)(956004)(7696005)(83380400001)(6916009)(52116002)(66476007)(107886003)(6486002)(8936002)(36756003)(2616005)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 7zCj/NgKHUquLbbVUZK9oiPrwoV2TKOTgHRYt7Y+HNs0ClSt+F0nVVBNvyrqvWW93jz90TIO9wNwXGcZ4uzOwK2hFtTZixDiEwPyHwH81c5VieYuRRv9lAl+LCYXFI1FJYx/LSicrJoOuRdgrS9PJHirpvhLNbBTk82w5PxW+ZrllfxSwzfA4vRVLYlRhig6I38cmt+r1up4I6Or2mm0JMnLUR0IqJ6cSi3KtmJ3sLqckjZRBIjAP+Gu4ZL1D2UFC3azdvikYd3tabq1LLWDD2oLbYd9z5jqBXJOwy+65NmHuDIohUHrGIymxXuNnPpBnl19CbVG2joL/ff7pxTxkPUbjgz1Xjo7H4IVHW/aQWj9gkeEttwhd2rLq/sGZchcvLD5aQ/EZONl2I6JYgorwRTrM5DNVAOUVaVxnDLQIPJ/MPPqNuQifHNlQxhLCHmMUyjFT00TqaC+YldIiMD2KNuiFGbC/AvPgSRgyMYOtfIO9eMDC0Aqw+sOSgS7t/ZzZu6M83BaX1qxFBYWU+XuKBv5YQm/1Iu5EiRQBbAAAu2yh/zDRHnwgP/yhtymZblUREpCKqyv584iNxz8UkUMPMJVBt0nfYJe43PUtmf6Y0Zj0sXxqtZAmjb9pxywutWtQa5/Z0ro302NJsVczVV30g== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85bb3c14-fd20-4677-7504-08d8356c5546 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0401MB2429.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2020 16:11:08.2063 (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: hBbkOppT6n0dfCXiHu/20DnodDYf78VZMCM/T8UBfobz0wPvaqhMRbak30/uGUOUd+PuMXjFp4VmrJFEgAy6Tg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6830 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.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 06VGBI9X002580 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.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Xen supports passing arbitrary arguments to the QEMU device model via the 'extra' member of the public libxl_domain_build_info structure. This patch uses QEMU namespace extensions already in place for the QEMU driver to map arbitrary arguments to the 'extra' member. Only passthrough of arguments is supported. Trying to pass environment variables or capabilities adjustments is not supported and will result in an error. Signed-off-by: Jim Fehlig --- docs/drvxen.html.in | 35 ++++++++++++++ src/libxl/libxl_conf.c | 11 ++++- src/libxl/libxl_conf.h | 8 ++++ src/libxl/libxl_domain.c | 99 ++++++++++++++++++++++++++++++++++++++++ src/libxl/libxl_domain.h | 1 + 5 files changed, 153 insertions(+), 1 deletion(-) diff --git a/docs/drvxen.html.in b/docs/drvxen.html.in index b2f41c1763..ffaf01fedb 100644 --- a/docs/drvxen.html.in +++ b/docs/drvxen.html.in @@ -141,6 +141,41 @@ vnclisten =3D "0.0.0.0" disk =3D [ "tap:aio:/var/lib/xen/images/rhel5pv.img,xvda,w", "tap:qcow:/ro= ot/qcow1-xen.img,xvdd,w" ] vif =3D [ "mac=3D00:16:3e:60:36:ba,bridge=3Dvirbr0,script=3Dvif-bridge,vif= name=3Dvif5.0" ] =20 +

Pass-through of arbitrary command-line argume= nts + to the qemu device model

+ +

Since 6.7.0, the Xen driver supports p= assing + arbitrary command-line arguments to the qemu device model used by Xe= n with + the <qemu:commandline> element under domain= . + In order to use command-line pass-through, an XML namespace request = must be + issued that pulls in http://libvirt.org/schemas/domain/qemu/1.= 0. + With the namespace in place, it is then possible to add + <qemu:arg>sub-elements to + <qemu:commandline> describing each argument passe= d to + the device model when starting the domain. +

+

+ Note that although the schema is shared with the QEMU driver, only + command-line arguments are supported. Passing environment variables = or + capabilities adjustments are not supported and will result in an err= or when + defining or creating the domain. +

+

The following example illustrates passing agruments to the QEMU dev= ice + model that define a floppy drive, which Xen does not support through= its + public APIs: +

+
+<domain type=3D"xen" xmlns:qemu=3D"http://libvirt.org/schemas/domain/qe=
mu/1.0">
+  ...
+  <qemu:commandline>
+    <qemu:arg value=3D'-drive'/>
+    <qemu:arg value=3D'file=3D/path/to/image,format=3Draw,if=3Dnone,id=
=3Ddrive-fdc0-0-0'/>
+    <qemu:arg value=3D'-global'/>
+    <qemu:arg value=3D'isa-fdc.driveA=3Ddrive-fdc0-0-0'/>
+  </qemu:commandline>
+</domain>
+    
+

Example domain XML config

=20

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 8e63d40376..b163e39712 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -760,6 +760,14 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_get_required_shadow_memory(b_info->max_memkb, b_info->max_vcpus); =20 + if (def->namespaceData) { + libxlDomainXmlNsDefPtr nsdata =3D def->namespaceData; + + if (nsdata->num_args > 0) + if (virStringListCopy(&b_info->extra, (const char **)nsdata->a= rgs) < 0) + return -1; + } + return 0; } =20 @@ -2513,5 +2521,6 @@ libxlCreateXMLConf(libxlDriverPrivatePtr driver) libxlDomainDefParserConfig.priv =3D driver; return virDomainXMLOptionNew(&libxlDomainDefParserConfig, &libxlDomainXMLPrivateDataCallbacks, - NULL, NULL, NULL); + &libxlDriverDomainXMLNamespace, + NULL, NULL); } diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h index b057a9e4ba..fc652df61e 100644 --- a/src/libxl/libxl_conf.h +++ b/src/libxl/libxl_conf.h @@ -168,6 +168,14 @@ struct _libxlSavefileHeader { uint32_t unused[10]; }; =20 + +typedef struct _libxlDomainXmlNsDef libxlDomainXmlNsDef; +typedef libxlDomainXmlNsDef *libxlDomainXmlNsDefPtr; +struct _libxlDomainXmlNsDef { + size_t num_args; + char **args; +}; + libxlDriverConfigPtr libxlDriverConfigNew(void); int diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index d9fcde4364..b67738061f 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1573,3 +1573,102 @@ libxlDomainDefCheckABIStability(libxlDriverPrivateP= tr driver, virDomainDefFree(migratableDefDst); return ret; } + + +static void +libxlDomainDefNamespaceFree(void *nsdata) +{ + libxlDomainXmlNsDefPtr def =3D nsdata; + + if (!def) + return; + + virStringListFreeCount(def->args, def->num_args); + VIR_FREE(def); +} + + +static int +libxlDomainDefNamespaceParse(xmlXPathContextPtr ctxt, + void **data) +{ + libxlDomainXmlNsDefPtr nsdata =3D NULL; + g_autofree xmlNodePtr *nodes =3D NULL; + ssize_t nnodes; + size_t i; + int ret =3D -1; + + /* Only qemu args are supported in the libxl driver */ + if ((nnodes =3D virXPathNodeSet("./qemu:commandline/qemu:env", ctxt, &= nodes)) > 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("libxl does not support setting qemu environment = variables")); + return -1; + } + if ((nnodes =3D virXPathNodeSet("./qemu:capabilities", ctxt, &nodes)) = > 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("libxl does not support setting qemu capabilities= ")); + return -1; + } + + if ((nnodes =3D virXPathNodeSet("./qemu:commandline/qemu:arg", ctxt, &= nodes)) < 0) + return -1; + + if (nnodes =3D=3D 0) + return 0; + + if (VIR_ALLOC(nsdata) < 0) + return -1; + + if (VIR_ALLOC_N(nsdata->args, nnodes) < 0) + goto cleanup; + + for (i =3D 0; i < nnodes; i++) { + if (!(nsdata->args[nsdata->num_args++] =3D virXMLPropString(nodes[= i], "value"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No qemu command-line argument specified")); + goto cleanup; + } + } + + if (nsdata->num_args > 0) + *data =3D g_steal_pointer(&nsdata); + + ret =3D 0; + + cleanup: + libxlDomainDefNamespaceFree(nsdata); + return ret; +} + + +static int +libxlDomainDefNamespaceFormatXML(virBufferPtr buf, + void *nsdata) +{ + libxlDomainXmlNsDefPtr cmd =3D nsdata; + size_t i; + + if (!cmd->num_args) + return 0; + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + + for (i =3D 0; i < cmd->num_args; i++) + virBufferEscapeString(buf, "\n", + cmd->args[i]); + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + + return 0; +} + + +virXMLNamespace libxlDriverDomainXMLNamespace =3D { + .parse =3D libxlDomainDefNamespaceParse, + .free =3D libxlDomainDefNamespaceFree, + .format =3D libxlDomainDefNamespaceFormatXML, + .prefix =3D "qemu", + .uri =3D "http://libvirt.org/schemas/domain/qemu/1.0", +}; diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h index 7e28093722..00682546e0 100644 --- a/src/libxl/libxl_domain.h +++ b/src/libxl/libxl_domain.h @@ -77,6 +77,7 @@ struct _libxlDomainObjPrivate { =20 extern virDomainXMLPrivateDataCallbacks libxlDomainXMLPrivateDataCallbacks; extern virDomainDefParserConfig libxlDomainDefParserConfig; +extern virXMLNamespace libxlDriverDomainXMLNamespace; extern const struct libxl_event_hooks ev_hooks; =20 int --=20 2.26.2