From nobody Mon Feb 9 20:34:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1486384122616561.1485283741536; Mon, 6 Feb 2017 04:28:42 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v16CLWla014289; Mon, 6 Feb 2017 07:21:32 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v16CLBD7017450 for ; Mon, 6 Feb 2017 07:21:11 -0500 Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16CL6x8013739; Mon, 6 Feb 2017 07:21:11 -0500 From: Erik Skultety To: libvir-list@redhat.com Date: Mon, 6 Feb 2017 13:19:46 +0100 Message-Id: <7c97727dbbb8d65add1d0fd38fc16205861c15d5.1486383339.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 04/16] conf: Adjust the domain parser to work with mdevs 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" As for the parser, the uuid element is optional and a UUID will be generated automatically if missing unless the device is unmanaged (default) in which case the element is mandatory, otherwise libvirt wouldn't have means to identify the device uniquely. Signed-off-by: Erik Skultety --- src/conf/domain_conf.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 38ffc95..f7bdd7a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6326,6 +6326,49 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePt= r sourcenode, return ret; } =20 +static int +virDomainHostdevSubsysMediatedDevDefParseXML(virDomainHostdevDefPtr def, + xmlXPathContextPtr ctxt) +{ + int ret =3D -1; + unsigned char uuid[VIR_UUID_BUFLEN] =3D {0}; + char *uuidxml =3D NULL; + xmlNodePtr node =3D NULL; + + virDomainHostdevSubsysMediatedDevPtr mdevsrc =3D &def->source.subsys.u= .mdev; + virPCIDeviceAddressPtr addr =3D &mdevsrc->addr; + + node =3D virXPathNode("./source/address", ctxt); + if (virPCIDeviceAddressParseXML(node, addr) < 0) + return -1; + + uuidxml =3D virXPathString("string(./source/uuid)", ctxt); + if (!uuidxml && !def->managed) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("uuid element is mandatory for unmanaged devices"= )); + goto cleanup; + } + + if (uuidxml) { + if (virUUIDParse(uuidxml, uuid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed uuid element")); + goto cleanup; + } + } else { + if (virUUIDGenerate(uuid)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Failed to generate UUID")); + goto cleanup; + } + } + + virUUIDFormat(uuid, mdevsrc->uuidstr); + ret =3D 0; + cleanup: + VIR_FREE(uuidxml); + return ret; +} =20 static int virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, @@ -6455,6 +6498,8 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, goto error; break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: + if (virDomainHostdevSubsysMediatedDevDefParseXML(def, ctxt) < 0) + goto error; break; =20 default: --=20 2.10.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list