]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: domain: Introduce virDomainDiskDefParseSource
authorPeter Krempa <pkrempa@redhat.com>
Wed, 14 Apr 2021 14:35:52 +0000 (16:35 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 19 Apr 2021 12:43:58 +0000 (14:43 +0200)
Add a helper function which will parse the source portion of a <disk>.

The idea is to replace *virDomainDiskDefParse with
VIR_DOMAIN_DEF_PARSE_DISK_SOURCE with the new helper in the future.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms

index 6795f0b3be4f8087d6d18ce3dd2d42bd0a85b567..57cad6ffdeba897ddf99f7adf010dafedbc4536d 100644 (file)
@@ -9704,6 +9704,21 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
 }
 
 
+static virStorageSource *
+virDomainDiskDefParseSourceXML(virDomainXMLOption *xmlopt,
+                               xmlNodePtr node,
+                               xmlXPathContextPtr ctxt,
+                               unsigned int flags)
+{
+    g_autoptr(virDomainDiskDef) diskdef = NULL;
+
+    if (!(diskdef = virDomainDiskDefParseXML(xmlopt, node, ctxt,
+                                             flags | VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)))
+        return NULL;
+
+    return g_steal_pointer(&diskdef->src);
+}
+
 
 /**
  * virDomainParseMemory:
@@ -16445,6 +16460,21 @@ virDomainDiskDefParse(const char *xmlStr,
 }
 
 
+virStorageSource *
+virDomainDiskDefParseSource(const char *xmlStr,
+                            virDomainXMLOption *xmlopt,
+                            unsigned int flags)
+{
+    g_autoptr(xmlDoc) xml = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
+
+    if (!(xml = virXMLParseStringCtxtRoot(xmlStr, _("(disk_definition)"), "disk", &ctxt)))
+        return NULL;
+
+    return virDomainDiskDefParseSourceXML(xmlopt, ctxt->node, ctxt, flags);
+}
+
+
 static const char *
 virDomainChrTargetTypeToString(int deviceType,
                                int targetType)
index 99ab2a96d9415d955a22439d3c60a42bf48ba1ba..83b92889410d77926408fc58576721e8e41c9482 100644 (file)
@@ -3406,6 +3406,9 @@ virDomainDeviceDef *virDomainDeviceDefParse(const char *xmlStr,
 virDomainDiskDef *virDomainDiskDefParse(const char *xmlStr,
                                         virDomainXMLOption *xmlopt,
                                         unsigned int flags);
+virStorageSource *virDomainDiskDefParseSource(const char *xmlStr,
+                                              virDomainXMLOption *xmlopt,
+                                              unsigned int flags);
 virDomainDef *virDomainDefParseString(const char *xmlStr,
                                       virDomainXMLOption *xmlopt,
                                       void *parseOpaque,
index 0fcbf546a6205cf515657fc3768602ae82910e44..fe3b4431711f15142b98ca6d56cc597a9a5467c6 100644 (file)
@@ -371,6 +371,7 @@ virDomainDiskDefCheckDuplicateInfo;
 virDomainDiskDefFree;
 virDomainDiskDefNew;
 virDomainDiskDefParse;
+virDomainDiskDefParseSource;
 virDomainDiskDetectZeroesTypeFromString;
 virDomainDiskDetectZeroesTypeToString;
 virDomainDiskDeviceTypeToString;