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@xxxxxxxxxx> --- src/conf/domain_conf.c | 30 ++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 34 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6795f0b3be..57cad6ffde 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 99ab2a96d9..83b9288941 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -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, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0fcbf546a6..fe3b443171 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -371,6 +371,7 @@ virDomainDiskDefCheckDuplicateInfo; virDomainDiskDefFree; virDomainDiskDefNew; virDomainDiskDefParse; +virDomainDiskDefParseSource; virDomainDiskDetectZeroesTypeFromString; virDomainDiskDetectZeroesTypeToString; virDomainDiskDeviceTypeToString; -- 2.30.2