]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virsh-domain: Remove unused vshCompleteXMLFromDomain
authorPeter Krempa <pkrempa@redhat.com>
Fri, 8 Mar 2013 09:08:26 +0000 (10:08 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Sun, 10 Mar 2013 09:18:23 +0000 (10:18 +0100)
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

index 96dd4fabd8c1dcee36e073ebe2fa2c3dacf69fec..7caa36481a73b7f5292a49a3deb54fcab2e40c80 100644 (file)
@@ -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