]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: virDomainHostdevSubsysMediatedDevDefParseXML refactor
authorKirill Shchetiniuk <kshcheti@redhat.com>
Mon, 7 Jul 2025 16:03:47 +0000 (18:03 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 14 Jul 2025 16:42:20 +0000 (18:42 +0200)
Refactored the virDomainHostdevSubsysMediatedDevDefParseXML function
to use virXMLPropUUID fuction instead of getting a string and parsing
it later.

Due to parsing function change the missing uuid error reporter and
message were changed and changed error message was also reflected in
tests' outputs.

Signed-off-by: Kirill Shchetiniuk <kshcheti@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c
tests/qemuxmlconfdata/hostdev-mdev-src-address-invalid.x86_64-latest.err

index 1e24e41a48ec464ed8e76444cfb99d214f061098..bfc62b62705f5466b7d8e71858be29b3ea01242d 100644 (file)
@@ -6348,7 +6348,6 @@ virDomainHostdevSubsysMediatedDevDefParseXML(virDomainHostdevDef *def,
     unsigned char uuid[VIR_UUID_BUFLEN] = {0};
     xmlNodePtr node = NULL;
     virDomainHostdevSubsysMediatedDev *mdevsrc = &def->source.subsys.u.mdev;
-    g_autofree char *uuidxml = NULL;
 
     if (!(node = virXPathNode("./source/address", ctxt))) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -6356,18 +6355,8 @@ virDomainHostdevSubsysMediatedDevDefParseXML(virDomainHostdevDef *def,
         return -1;
     }
 
-    if (!(uuidxml = virXMLPropString(node, "uuid"))) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Missing 'uuid' attribute for element <address>"));
-        return -1;
-    }
-
-    if (virUUIDParse(uuidxml, uuid) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s",
-                       _("Cannot parse uuid attribute of element <address>"));
+    if (virXMLPropUUID(node, "uuid", VIR_XML_PROP_REQUIRED, uuid) < 0)
         return -1;
-    }
 
     virUUIDFormat(uuid, mdevsrc->uuidstr);
     return 0;
index 20a91e7fa6413dc14e601a7e4fc4de697dc6a5ba..29dfbfb1ce5762acfe83e8a3b9953271c22b3e32 100644 (file)
@@ -1 +1 @@
-unsupported configuration: Missing 'uuid' attribute for element <address>
+XML error: Missing required attribute 'uuid' in element 'address'