
On 06/27/2013 09:22 AM, Xu Wang wrote:
int parse_domain_type(xmlNodePtr node, char **value) { xmlNodePtr child = NULL; + xmlNodePtr seek_node = NULL; char *type = NULL; + char *host_arch = NULL; + char *guest_arch = NULL;
child = node->children; - while (child != NULL) { - if (XSTREQ(child->name, "domain")) { - type = get_attr_value(child, "type"); - if (type != NULL) { + while (child) { + if (XSTREQ(child->name, "host")) { + seek_node = seek_subNode(child, "arch"); + host_arch = get_node_content(seek_node); + } else if (XSTREQ(child->name, "guest")) { + seek_node = seek_subNode(child, "arch"); + guest_arch = get_attr_value(seek_node, "name"); + if (XSTREQ(host_arch, guest_arch)) { + seek_node = seek_subNode(child, "domain"); + type = get_attr_value(seek_node, "type"); *value = strdup(type); - goto out; + return 1; unfortunately this logic is still returns the first guest domain type in the capabilities XML which is "qemu". It would be necessary to iterate all guest domains to find out whether one of them is of type "kvm".
BTW: this function is leaking type, host_arch and guest_arch...
} } -
-- Mit freundlichen Grüßen/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294