From nobody Sat May 4 11:15:24 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533900288232501.7414909794858; Fri, 10 Aug 2018 04:24:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA3003086262; Fri, 10 Aug 2018 11:24:45 +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 3EE6970A02; Fri, 10 Aug 2018 11:24:45 +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 CC63C18037F0; Fri, 10 Aug 2018 11:24:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7ABOgGC014972 for ; Fri, 10 Aug 2018 07:24:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id F39319CDEA; Fri, 10 Aug 2018 11:24:41 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA9DA9CDF0 for ; Fri, 10 Aug 2018 11:24:38 +0000 (UTC) Received: from mx.conquex.com (mx.conquex.com [87.120.9.15]) (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 141D885362 for ; Fri, 10 Aug 2018 11:24:36 +0000 (UTC) Received: from [94.156.238.70] (helo=fbsd.conquex.local) by mx.conquex.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1fo5X1-00064Q-I7; Fri, 10 Aug 2018 14:24:37 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=conquex.com; s=rsa1; h=Subject:To:From; bh=7S7Pn99FnTkUn51JKHmuvNYgnrdWlQUJ0F2HsQwmIz8=; b=X+qFf8DNWNmN5rBuNlxo7D1pkH31S8U8iuF7lOBqRjqcBzAdwKALZH+UZLRMiUZ1GHkMqAGayDHeZTpamBhDTUYgYY7/hQL3idDriZy+MOcQTEY2P8edFImhT26vIScukSTI/20mR82EA6H4iWRgqtgFnk/FGTDOJvRs3yOwzyU=; From: Ivan Mishonov To: libvir-list@redhat.com Date: Fri, 10 Aug 2018 14:22:33 +0300 Message-Id: <20180810112233.44540-2-ivan@conquex.com> In-Reply-To: <20180810112233.44540-1-ivan@conquex.com> References: <20180810112233.44540-1-ivan@conquex.com> X-Sender-cnX: ivan@conquex.com X-Spam-Score-Int: -9 X-Greylist: Sender passed SPF test, ACL 232 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 10 Aug 2018 11:24:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 10 Aug 2018 11:24:36 +0000 (UTC) for IP:'87.120.9.15' DOMAIN:'mx.conquex.com' HELO:'mx.conquex.com' FROM:'ivan@conquex.com' RCPT:'' X-RedHat-Spam-Score: -0.101 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_PASS) 87.120.9.15 mx.conquex.com 87.120.9.15 mx.conquex.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: Ivan Mishonov Subject: [libvirt] [PATCH 1/1] bhyve: Make LPC slot number configurable 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: , MIME-Version: 1.0 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 10 Aug 2018 11:24:46 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Ivan Mishonov --- docs/schemas/domaincommon.rng | 15 ++++++ src/bhyve/bhyve_command.c | 7 ++- src/bhyve/bhyve_conf.c | 12 +++++ src/bhyve/bhyve_conf.h | 9 ++++ src/bhyve/bhyve_device.c | 16 ++++--- src/bhyve/bhyve_domain.c | 86 ++++++++++++++++++++++++++++++++++- src/bhyve/bhyve_domain.h | 1 + 7 files changed, 138 insertions(+), 8 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 1a786968cc..102bfbda87 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -75,6 +75,9 @@ + + + @@ -6015,6 +6018,18 @@ =20 + + + + + + + + + diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 802997bd2d..14e5635011 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -27,6 +27,7 @@ =20 #include "bhyve_capabilities.h" #include "bhyve_command.h" +#include "bhyve_conf.h" #include "bhyve_domain.h" #include "bhyve_driver.h" #include "datatypes.h" @@ -329,7 +330,11 @@ static int bhyveBuildLPCArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, virCommandPtr cmd) { - virCommandAddArgList(cmd, "-s", "1,lpc", NULL); + unsigned int lpcslotnumber =3D virBhyveGetLPCSlotNumber(def); + + virCommandAddArg(cmd, "-s"); + virCommandAddArgFormat(cmd, "%d,lpc", lpcslotnumber); + return 0; } =20 diff --git a/src/bhyve/bhyve_conf.c b/src/bhyve/bhyve_conf.c index 153de7b391..ce234e4546 100644 --- a/src/bhyve/bhyve_conf.c +++ b/src/bhyve/bhyve_conf.c @@ -44,6 +44,18 @@ static int virBhyveConfigOnceInit(void) =20 VIR_ONCE_GLOBAL_INIT(virBhyveConfig) =20 +void bhyveDomainDefFree(bhyveDomainDefPtr def) +{ + VIR_FREE(def); +} + +int virBhyveGetLPCSlotNumber(const virDomainDef *def) { + bhyveDomainDefPtr bhyveopts; + + bhyveopts =3D def->namespaceData; + return bhyveopts ? bhyveopts->lpc_slot_number : 1; +} + virBhyveDriverConfigPtr virBhyveDriverConfigNew(void) { diff --git a/src/bhyve/bhyve_conf.h b/src/bhyve/bhyve_conf.h index 3f105ace1c..441b7ef2b9 100644 --- a/src/bhyve/bhyve_conf.h +++ b/src/bhyve/bhyve_conf.h @@ -29,4 +29,13 @@ virBhyveDriverConfigPtr virBhyveDriverGetConfig(bhyveCon= nPtr driver); int virBhyveLoadDriverConfig(virBhyveDriverConfigPtr cfg, const char *filename); =20 +typedef struct _bhyveDomainDef bhyveDomainDef; +typedef bhyveDomainDef *bhyveDomainDefPtr; +struct _bhyveDomainDef { + unsigned int lpc_slot_number; +}; + +void bhyveDomainDefFree(bhyveDomainDefPtr def); +int virBhyveGetLPCSlotNumber(const virDomainDef *def); + #endif /* BHYVE_CONF_H */ diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c index 03aa6c93bd..651b8f02f1 100644 --- a/src/bhyve/bhyve_device.c +++ b/src/bhyve/bhyve_device.c @@ -22,6 +22,7 @@ =20 #include =20 +#include "bhyve_conf.h" #include "bhyve_device.h" #include "domain_addr.h" #include "viralloc.h" @@ -44,14 +45,16 @@ bhyveCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UN= USED, =20 virDomainPCIAddressSetPtr addrs =3D opaque; virPCIDeviceAddressPtr addr =3D &info->addr.pci; + unsigned int lpcslotnumber =3D virBhyveGetLPCSlotNumber(def); =20 if (addr->domain =3D=3D 0 && addr->bus =3D=3D 0) { if (addr->slot =3D=3D 0) { return 0; - } else if (addr->slot =3D=3D 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("PCI bus 0 slot 1 is reserved for the implici= t " - "LPC PCI-ISA bridge")); + } else if (addr->slot =3D=3D lpcslotnumber) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("PCI bus 0 slot %d is reserved for the implicit " + "LPC PCI-ISA bridge"), + lpcslotnumber); return -1; } } @@ -95,9 +98,10 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def, size_t i; virPCIDeviceAddress lpc_addr; =20 - /* explicitly reserve slot 1 for LPC-ISA bridge */ + /* explicitly reserve slot for LPC-ISA bridge */ + unsigned int lpcslotnumber =3D virBhyveGetLPCSlotNumber(def); memset(&lpc_addr, 0, sizeof(lpc_addr)); - lpc_addr.slot =3D 0x1; + lpc_addr.slot =3D lpcslotnumber; =20 if (virDomainPCIAddressReserveAddr(addrs, &lpc_addr, VIR_PCI_CONNECT_TYPE_PCI_DEVICE, 0)= < 0) { diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index 3c23441969..09715f3dd5 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -20,18 +20,23 @@ * Author: Roman Bogorodskiy */ =20 +#include #include =20 +#include "bhyve_conf.h" #include "bhyve_device.h" #include "bhyve_domain.h" #include "bhyve_capabilities.h" #include "viralloc.h" #include "virlog.h" +#include "virstring.h" =20 #define VIR_FROM_THIS VIR_FROM_BHYVE =20 VIR_LOG_INIT("bhyve.bhyve_domain"); =20 +#define BHYVE_NAMESPACE_HREF "http://libvirt.org/schemas/domain/bhyve/1.0" + static void * bhyveDomainObjPrivateAlloc(void *opaque ATTRIBUTE_UNUSED) { @@ -58,6 +63,84 @@ virDomainXMLPrivateDataCallbacks virBhyveDriverPrivateDa= taCallbacks =3D { .free =3D bhyveDomainObjPrivateFree, }; =20 +static void +bhyveDomainDefNamespaceFree(void *nsdata) +{ + bhyveDomainDefPtr def =3D nsdata; + =20 + bhyveDomainDefFree(def); +} + +static int +bhyveDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED, + xmlNodePtr root ATTRIBUTE_UNUSED, + xmlXPathContextPtr ctxt, + void **data) +{ + bhyveDomainDefPtr domainDef =3D NULL; + char *lpcslotnumberstring =3D NULL; + + if (xmlXPathRegisterNs(ctxt, BAD_CAST "bhyve", BAD_CAST BHYVE_NAMESPAC= E_HREF) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to register xml namespace '%s'"), + BHYVE_NAMESPACE_HREF); + return -1; + } + + xmlNodePtr lpcnode =3D virXPathNode("./bhyve:lpcslotnumber", ctxt); + if (lpcnode =3D=3D NULL)=20 + return 0; + + if (VIR_ALLOC(domainDef) < 0) + return -1; + + lpcslotnumberstring =3D virXMLPropString(lpcnode, "value"); + if (lpcslotnumberstring =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Bhyve lpcslotnumber value property not found")); + goto error; + } else if (virStrToLong_ui(lpcslotnumberstring, NULL, 10, &domainDef->= lpc_slot_number) !=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s got %s", _("Bhyve lpcslotnumber value property must be int= eger"), lpcslotnumberstring); + VIR_FREE(lpcslotnumberstring); + goto error; + } + VIR_FREE(lpcslotnumberstring); + + *data =3D domainDef; + return 0; + error: + bhyveDomainDefFree(domainDef); + return -1; +} + +static int +bhyveDomainDefNamespaceFormatXML(virBufferPtr buf, + void *nsdata) +{ + bhyveDomainDefPtr domainDef =3D nsdata; + + if (domainDef) { + virBufferAsprintf(buf, "\n", + domainDef->lpc_slot_number); + } + + return 0; +} + +static const char * +bhyveDomainDefNamespaceHref(void) +{ + return "xmlns:bhyve=3D'" BHYVE_NAMESPACE_HREF "'"; +} + +virDomainXMLNamespace virBhyveDriverDomainXMLNamespace =3D { + .parse =3D bhyveDomainDefNamespaceParse, + .free =3D bhyveDomainDefNamespaceFree, + .format =3D bhyveDomainDefNamespaceFormatXML, + .href =3D bhyveDomainDefNamespaceHref, +}; + static int bhyveDomainDefPostParse(virDomainDefPtr def, virCapsPtr caps ATTRIBUTE_UNUSED, @@ -159,7 +242,8 @@ virBhyveDriverCreateXMLConf(bhyveConnPtr driver) virBhyveDriverDomainDefParserConfig.priv =3D driver; return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig, &virBhyveDriverPrivateDataCallbacks, - NULL, NULL, NULL); + &virBhyveDriverDomainXMLNamespace,=20 + NULL, NULL); } =20 virDomainDefParserConfig virBhyveDriverDomainDefParserConfig =3D { diff --git a/src/bhyve/bhyve_domain.h b/src/bhyve/bhyve_domain.h index bbc8ecd8cf..ce4b4bf7b8 100644 --- a/src/bhyve/bhyve_domain.h +++ b/src/bhyve/bhyve_domain.h @@ -39,6 +39,7 @@ struct _bhyveDomainObjPrivate { =20 virDomainXMLOptionPtr virBhyveDriverCreateXMLConf(bhyveConnPtr); =20 +extern virDomainXMLNamespace virBhyveDriverDomainXMLNamespace; extern virDomainXMLPrivateDataCallbacks virBhyveDriverPrivateDataCallbacks; extern virDomainDefParserConfig virBhyveDriverDomainDefParserConfig; =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list