[libvirt] [PATCH 0/2] Proper fix for xmlSaveToBuffer missing on RHEL4

The original fix for one of the issues was done by defining a missing symbol from libxml2. The fix is not needed as the code using the function is never used. Revert the fix and remove the unused offending function instead. Peter Krempa (2): Revert "Ensure xmlSaveToBuffer is always defined" virsh-domain: Remove unused vshCompleteXMLFromDomain tools/virsh-domain.c | 139 --------------------------------------------------- 1 file changed, 139 deletions(-) -- 1.8.1.1

The commit originally fixed code that isn't being used. Revert it and remove the unused code as a real fix. This reverts commit a66b32d9295ed87698ffd98d82e9e5818ff799e5. --- tools/virsh-domain.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index c272688..96dd4fa 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -56,17 +56,6 @@ #include "virtypedparam.h" #include "virxml.h" -/* libxml2 in RHEL4 has this symbol in the binary but it - * is commented out in the header, despite apparently - * working fine. This hacks around that header problem - */ -#ifndef xmlSaveToBuffer -XMLPUBFUN xmlSaveCtxtPtr XMLCALL -xmlSaveToBuffer (xmlBufferPtr buffer, - const char *encoding, - int options); -#endif - /* Gnulib doesn't guarantee SA_SIGINFO support. */ #ifndef SA_SIGINFO # define SA_SIGINFO 0 -- 1.8.1.1

The function is marked as unused and breaks compilation on RHEL4. Remove it from the tree until a new use case can be found. --- tools/virsh-domain.c | 128 --------------------------------------------------- 1 file changed, 128 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 96dd4fa..7caa364 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9374,134 +9374,6 @@ cleanup: return ret; } -/** - * vshCompleteXMLFromDomain: - * @ctl vshControl for error messages printing - * @dom domain - * @oldXML device XML before - * @newXML and after completion - * - * For given domain and (probably incomplete) device XML specification try to - * find such device in domain and complete missing parts. This is however - * possible only when given device XML is sufficiently precise so it addresses - * only one device. - * - * Returns -2 when no such device exists in domain, -3 when given XML selects many - * (is too ambiguous), 0 in case of success. Otherwise returns -1. @newXML - * is touched only in case of success. - */ -ATTRIBUTE_UNUSED -static int -vshCompleteXMLFromDomain(vshControl *ctl, virDomainPtr dom, char *oldXML, - char **newXML) -{ - int funcRet = -1; - char *domXML = NULL; - xmlDocPtr domDoc = NULL, devDoc = NULL; - xmlNodePtr node = NULL; - xmlXPathContextPtr domCtxt = NULL, devCtxt = NULL; - xmlNodePtr *devices = NULL; - xmlSaveCtxtPtr sctxt = NULL; - int devices_size; - char *xpath = NULL; - xmlBufferPtr buf = NULL; - int i = 0; - int indx = -1; - - if (!(domXML = virDomainGetXMLDesc(dom, 0))) { - vshError(ctl, _("couldn't get XML description of domain %s"), - virDomainGetName(dom)); - goto cleanup; - } - - domDoc = virXMLParseStringCtxt(domXML, _("(domain_definition)"), &domCtxt); - if (!domDoc) { - vshError(ctl, _("Failed to parse domain definition xml")); - goto cleanup; - } - - devDoc = virXMLParseStringCtxt(oldXML, _("(device_definition)"), &devCtxt); - if (!devDoc) { - vshError(ctl, _("Failed to parse device definition xml")); - goto cleanup; - } - - node = xmlDocGetRootElement(devDoc); - - buf = xmlBufferCreate(); - if (!buf) { - vshError(ctl, "%s", _("out of memory")); - goto cleanup; - } - - /* Get all possible devices */ - if (virAsprintf(&xpath, "/domain/devices/%s", node->name) < 0) { - virReportOOMError(); - goto cleanup; - } - devices_size = virXPathNodeSet(xpath, domCtxt, &devices); - - if (devices_size < 0) { - /* error */ - vshError(ctl, "%s", _("error when selecting nodes")); - goto cleanup; - } else if (devices_size == 0) { - /* no such device */ - funcRet = -2; - goto cleanup; - } - - /* and refine */ - for (i = 0; i < devices_size; i++) { - if (vshNodeIsSuperset(devices[i], node)) { - if (indx >= 0) { - funcRet = -3; /* ambiguous */ - goto cleanup; - } - indx = i; - } - } - - if (indx < 0) { - funcRet = -2; /* no such device */ - goto cleanup; - } - - vshDebug(ctl, VSH_ERR_DEBUG, "Found device at pos %d\n", indx); - - if (newXML) { - sctxt = xmlSaveToBuffer(buf, NULL, 0); - if (!sctxt) { - vshError(ctl, "%s", _("failed to create document saving context")); - goto cleanup; - } - - xmlSaveTree(sctxt, devices[indx]); - xmlSaveClose(sctxt); - *newXML = (char *) xmlBufferContent(buf); - if (!*newXML) { - virReportOOMError(); - goto cleanup; - } - buf->content = NULL; - } - - vshDebug(ctl, VSH_ERR_DEBUG, "Old xml:\n%s\nNew xml:\n%s\n", oldXML, - newXML ? NULLSTR(*newXML) : "(null)"); - - funcRet = 0; - -cleanup: - xmlBufferFree(buf); - VIR_FREE(devices); - xmlXPathFreeContext(devCtxt); - xmlXPathFreeContext(domCtxt); - xmlFreeDoc(devDoc); - xmlFreeDoc(domDoc); - VIR_FREE(domXML); - VIR_FREE(xpath); - return funcRet; -} /* * "detach-device" command -- 1.8.1.1

On 03/08/2013 02:15 AM, Peter Krempa wrote:
The original fix for one of the issues was done by defining a missing symbol from libxml2. The fix is not needed as the code using the function is never used.
Revert the fix and remove the unused offending function instead.
ACK series.
Peter Krempa (2): Revert "Ensure xmlSaveToBuffer is always defined" virsh-domain: Remove unused vshCompleteXMLFromDomain
tools/virsh-domain.c | 139 --------------------------------------------------- 1 file changed, 139 deletions(-)
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 03/08/13 18:33, Eric Blake wrote:
On 03/08/2013 02:15 AM, Peter Krempa wrote:
The original fix for one of the issues was done by defining a missing symbol from libxml2. The fix is not needed as the code using the function is never used.
Revert the fix and remove the unused offending function instead.
ACK series.
Pushed. Thanks. Peter
participants (2)
-
Eric Blake
-
Peter Krempa