Dear John, If you feel it is OK please insert it into upstream. Thank you:-)
Sincerely yours, Xu Wang ---------------------------------------- > From: [email protected] > To: [email protected] > Date: Wed, 3 Jul 2013 10:03:12 +0800 > Subject: [Libvirt-cim] [PATCH V5] Fix kvm support check logic > > Now system_has_kvm() would check all type value of domain label in > caps. If any of them type is "kvm", system_has_kvm() return 1 as > true result. > > Signed-off-by: Xu Wang <[email protected]> > --- > libxkutil/device_parsing.c | 16 +++++++++------- > libxkutil/device_parsing.h | 2 +- > src/Virt_VirtualSystemManagementService.c | 7 +------ > 3 files changed, 11 insertions(+), 14 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index 16195da..9d7ddb4 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -396,31 +396,33 @@ err: > return 0; > } > > -int parse_domain_type(xmlNodePtr node, char **value) > +bool has_kvm_domain_type(xmlNodePtr node) > { > xmlNodePtr child = NULL; > char *type = NULL; > + bool ret = false; > > child = node->children; > while (child != NULL) { > if (XSTREQ(child->name, "domain")) { > type = get_attr_value(child, "type"); > - if (type != NULL) { > - *value = strdup(type); > + if (XSTREQ(type, "kvm")) { > + ret = true; > goto out; > } > } > > - if (parse_domain_type(child, value) == 1) { > + if (has_kvm_domain_type(child) == 1) { > + ret = true; > goto out; > } > > child = child->next; > } > > - return 0; > -out: > - return 1; > + out: > + free(type); > + return ret; > } > > static int parse_net_device(xmlNode *inode, struct virt_device **vdevs) > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index 733324f..2a4c911 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -221,7 +221,7 @@ int attach_device(virDomainPtr dom, struct virt_device > *dev); > int detach_device(virDomainPtr dom, struct virt_device *dev); > int change_device(virDomainPtr dom, struct virt_device *dev); > > -int parse_domain_type(xmlNodePtr node, char **value); > +bool has_kvm_domain_type(xmlNodePtr node); > > #define XSTREQ(x, y) (STREQ((char *)x, y)) > #define STRPROP(d, p, n) (d->p = get_node_content(n)) > diff --git a/src/Virt_VirtualSystemManagementService.c > b/src/Virt_VirtualSystemManagementService.c > index 8e1e6b1..199ab2d 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -394,7 +394,6 @@ static bool system_has_kvm(const char *pfx) > virConnectPtr conn = NULL; > char *caps = NULL; > bool disable_kvm = get_disable_kvm(); > - char *val = NULL; > xmlDocPtr doc = NULL; > xmlNodePtr node = NULL; > int len; > @@ -427,19 +426,15 @@ static bool system_has_kvm(const char *pfx) > goto out; > } > > - if (parse_domain_type(node, &val) && > - STREQC(val, "kvm")) { > + if (has_kvm_domain_type(node)) { > CU_DEBUG("The system support kvm!"); > kvm = true; > - } else { > - CU_DEBUG("Domain type is %s.", val); > } > } > > out: > free(caps); > free(doc); > - free(val); > > virConnectClose(conn); > > -- > 1.7.1 > > _______________________________________________ > Libvirt-cim mailing list > [email protected] > https://www.redhat.com/mailman/listinfo/libvirt-cim > _______________________________________________ Libvirt-cim mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvirt-cim
