conf: domain: Introduce virDomainDiskDefParseSource

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>
This commit is contained in:
Peter Krempa 2021-04-14 16:35:52 +02:00
parent 5c56538937
commit fb0238414e
3 changed files with 34 additions and 0 deletions

View 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)

View 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,

View File

@ -371,6 +371,7 @@ virDomainDiskDefCheckDuplicateInfo;
virDomainDiskDefFree;
virDomainDiskDefNew;
virDomainDiskDefParse;
virDomainDiskDefParseSource;
virDomainDiskDetectZeroesTypeFromString;
virDomainDiskDetectZeroesTypeToString;
virDomainDiskDeviceTypeToString;