diff options
author | Peter Krempa <pkrempa@redhat.com> | 2022-09-22 18:02:50 +0200 |
---|---|---|
committer | Peter Krempa <pkrempa@redhat.com> | 2022-10-06 10:54:25 +0200 |
commit | 573f764ee4f8dca852b0d04d86b9bf5e66d7fa54 (patch) | |
tree | 36fcd3a924b5ce8378d03ca022a4ca7258652b7d /src | |
parent | a84a2d8e1c3bbbb7f21fcec13ae778fd280c9784 (diff) | |
download | libvirt-573f764ee4f8dca852b0d04d86b9bf5e66d7fa54.tar.gz |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/conf/backup_conf.c | 41 | ||||
-rw-r--r-- | src/conf/backup_conf.h | 10 | ||||
-rw-r--r-- | src/libvirt_private.syms | 2 | ||||
-rw-r--r-- | src/qemu/qemu_domain.c | 9 |
4 files changed, 22 insertions, 40 deletions
diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 7dfc8ee635..ad5633388d 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -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); - } - xmlKeepBlanksDefault(keepBlanksDefault); - - return ret; -} - + xml = virXMLParse(NULL, xmlStr, _("(domain_backup)"), + "domainbackup", &ctxt, "domainbackup.rng", validate); -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; - } + xmlKeepBlanksDefault(keepBlanksDefault); - if (!(ctxt = virXMLXPathContextNew(xml))) + if (!xml) return NULL; - ctxt->node = root; - return virDomainBackupDefParse(ctxt, xmlopt, flags); + return virDomainBackupDefParseXML(ctxt, xmlopt, flags); } diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h index dc66b75892..9c3532a546 100644 --- a/src/conf/backup_conf.h +++ b/src/conf/backup_conf.h @@ -106,15 +106,15 @@ typedef enum { } 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); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6334cbb448..0adcf20f0c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -46,8 +46,8 @@ virAccessPermStorageVolTypeToString; virDomainBackupAlignDisks; virDomainBackupDefFormat; virDomainBackupDefFree; -virDomainBackupDefParseNode; virDomainBackupDefParseString; +virDomainBackupDefParseXML; # conf/capabilities.h diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 858d14af6a..4c14fc2aef 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -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; |