mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh-domain: Remove unused virshNodeIsSuperset
The function is marked as unused. Remove it from the tree
until a new use case can be found.
Unused since: 38cc07b7bc
Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
f035f53baa
commit
ed3cc76b48
@ -11933,121 +11933,6 @@ cmdDomHostname(vshControl *ctl, const vshCmd *cmd)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if n1 is superset of n2, meaning n1 contains all elements and
|
|
||||||
* attributes as n2 at least. Including children.
|
|
||||||
* @n1 first node
|
|
||||||
* @n2 second node
|
|
||||||
* returns true in case n1 covers n2, false otherwise.
|
|
||||||
*/
|
|
||||||
G_GNUC_UNUSED
|
|
||||||
static bool
|
|
||||||
virshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2)
|
|
||||||
{
|
|
||||||
xmlNodePtr child1, child2;
|
|
||||||
xmlAttrPtr attr;
|
|
||||||
char *prop1, *prop2;
|
|
||||||
bool found;
|
|
||||||
bool visited;
|
|
||||||
bool ret = false;
|
|
||||||
long n1_child_size, n2_child_size, n1_iter;
|
|
||||||
virBitmapPtr bitmap;
|
|
||||||
|
|
||||||
if (!n1 && !n2)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!n1 || !n2)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!xmlStrEqual(n1->name, n2->name))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* Iterate over n2 attributes and check if n1 contains them */
|
|
||||||
attr = n2->properties;
|
|
||||||
while (attr) {
|
|
||||||
if (attr->type == XML_ATTRIBUTE_NODE) {
|
|
||||||
prop1 = virXMLPropString(n1, (const char *) attr->name);
|
|
||||||
prop2 = virXMLPropString(n2, (const char *) attr->name);
|
|
||||||
if (STRNEQ_NULLABLE(prop1, prop2)) {
|
|
||||||
xmlFree(prop1);
|
|
||||||
xmlFree(prop2);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
xmlFree(prop1);
|
|
||||||
xmlFree(prop2);
|
|
||||||
}
|
|
||||||
attr = attr->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
n1_child_size = virXMLChildElementCount(n1);
|
|
||||||
n2_child_size = virXMLChildElementCount(n2);
|
|
||||||
if (n1_child_size < 0 || n2_child_size < 0 ||
|
|
||||||
n1_child_size < n2_child_size)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (n1_child_size == 0 && n2_child_size == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
bitmap = virBitmapNew(n1_child_size);
|
|
||||||
|
|
||||||
child2 = n2->children;
|
|
||||||
while (child2) {
|
|
||||||
if (child2->type != XML_ELEMENT_NODE) {
|
|
||||||
child2 = child2->next;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
child1 = n1->children;
|
|
||||||
n1_iter = 0;
|
|
||||||
found = false;
|
|
||||||
while (child1) {
|
|
||||||
if (child1->type != XML_ELEMENT_NODE) {
|
|
||||||
child1 = child1->next;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virBitmapGetBit(bitmap, n1_iter, &visited) < 0) {
|
|
||||||
vshError(NULL, "%s", _("Bad child elements counting."));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (visited) {
|
|
||||||
child1 = child1->next;
|
|
||||||
n1_iter++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xmlStrEqual(child1->name, child2->name)) {
|
|
||||||
found = true;
|
|
||||||
if (virBitmapSetBit(bitmap, n1_iter) < 0) {
|
|
||||||
vshError(NULL, "%s", _("Bad child elements counting."));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!virshNodeIsSuperset(child1, child2))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
child1 = child1->next;
|
|
||||||
n1_iter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
child2 = child2->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = true;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virBitmapFree(bitmap);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "detach-device" command
|
* "detach-device" command
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user