mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
conf: backup: Remove virDomainBackupDefParseNode
Rename virDomainBackupDefParse to virDomainBackupDefParseXML and use it in place of virDomainBackupDefParseNode. This is possible as virXMLParse can be used to replace XPath context allocation and root node checking. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
a84a2d8e1c
commit
573f764ee4
@ -190,10 +190,10 @@ virDomainBackupDefParsePrivate(virDomainBackupDef *def,
|
||||
}
|
||||
|
||||
|
||||
static virDomainBackupDef *
|
||||
virDomainBackupDefParse(xmlXPathContextPtr ctxt,
|
||||
virDomainXMLOption *xmlopt,
|
||||
unsigned int flags)
|
||||
virDomainBackupDef *
|
||||
virDomainBackupDefParseXML(xmlXPathContextPtr ctxt,
|
||||
virDomainXMLOption *xmlopt,
|
||||
unsigned int flags)
|
||||
{
|
||||
g_autoptr(virDomainBackupDef) def = NULL;
|
||||
g_autofree xmlNodePtr *nodes = NULL;
|
||||
@ -274,41 +274,20 @@ virDomainBackupDefParseString(const char *xmlStr,
|
||||
virDomainXMLOption *xmlopt,
|
||||
unsigned int flags)
|
||||
{
|
||||
virDomainBackupDef *ret = NULL;
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
||||
bool validate = !(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL);
|
||||
|
||||
if ((xml = virXMLParse(NULL, xmlStr, _("(domain_backup)"),
|
||||
NULL, NULL, "domainbackup.rng", validate))) {
|
||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
||||
ret = virDomainBackupDefParseNode(xml, xmlDocGetRootElement(xml),
|
||||
xmlopt, flags);
|
||||
}
|
||||
xml = virXMLParse(NULL, xmlStr, _("(domain_backup)"),
|
||||
"domainbackup", &ctxt, "domainbackup.rng", validate);
|
||||
|
||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
virDomainBackupDef *
|
||||
virDomainBackupDefParseNode(xmlDocPtr xml,
|
||||
xmlNodePtr root,
|
||||
virDomainXMLOption *xmlopt,
|
||||
unsigned int flags)
|
||||
{
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
|
||||
if (!virXMLNodeNameEqual(root, "domainbackup")) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s", _("domainbackup"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(ctxt = virXMLXPathContextNew(xml)))
|
||||
if (!xml)
|
||||
return NULL;
|
||||
|
||||
ctxt->node = root;
|
||||
return virDomainBackupDefParse(ctxt, xmlopt, flags);
|
||||
return virDomainBackupDefParseXML(ctxt, xmlopt, flags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,16 +105,16 @@ typedef enum {
|
||||
VIR_DOMAIN_BACKUP_PARSE_INTERNAL = 1 << 0,
|
||||
} virDomainBackupParseFlags;
|
||||
|
||||
virDomainBackupDef *
|
||||
virDomainBackupDefParseXML(xmlXPathContextPtr ctxt,
|
||||
virDomainXMLOption *xmlopt,
|
||||
unsigned int flags);
|
||||
|
||||
virDomainBackupDef *
|
||||
virDomainBackupDefParseString(const char *xmlStr,
|
||||
virDomainXMLOption *xmlopt,
|
||||
unsigned int flags);
|
||||
|
||||
virDomainBackupDef *
|
||||
virDomainBackupDefParseNode(xmlDocPtr xml,
|
||||
xmlNodePtr root,
|
||||
virDomainXMLOption *xmlopt,
|
||||
unsigned int flags);
|
||||
void
|
||||
virDomainBackupDefFree(virDomainBackupDef *def);
|
||||
|
||||
|
@ -46,8 +46,8 @@ virAccessPermStorageVolTypeToString;
|
||||
virDomainBackupAlignDisks;
|
||||
virDomainBackupDefFormat;
|
||||
virDomainBackupDefFree;
|
||||
virDomainBackupDefParseNode;
|
||||
virDomainBackupDefParseString;
|
||||
virDomainBackupDefParseXML;
|
||||
|
||||
|
||||
# conf/capabilities.h
|
||||
|
@ -2860,6 +2860,7 @@ static int
|
||||
qemuDomainObjPrivateXMLParseBackups(qemuDomainObjPrivate *priv,
|
||||
xmlXPathContextPtr ctxt)
|
||||
{
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
g_autofree xmlNodePtr *nodes = NULL;
|
||||
ssize_t nnodes = 0;
|
||||
|
||||
@ -2875,9 +2876,11 @@ qemuDomainObjPrivateXMLParseBackups(qemuDomainObjPrivate *priv,
|
||||
if (nnodes == 0)
|
||||
return 0;
|
||||
|
||||
if (!(priv->backup = virDomainBackupDefParseNode(ctxt->doc, nodes[0],
|
||||
priv->driver->xmlopt,
|
||||
VIR_DOMAIN_BACKUP_PARSE_INTERNAL)))
|
||||
ctxt->node = nodes[0];
|
||||
|
||||
if (!(priv->backup = virDomainBackupDefParseXML(ctxt,
|
||||
priv->driver->xmlopt,
|
||||
VIR_DOMAIN_BACKUP_PARSE_INTERNAL)))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user