[PATCH V4] 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 <cngesaint@gmail.com> --- libxkutil/device_parsing.c | 13 +++++-------- libxkutil/device_parsing.h | 2 +- src/Virt_VirtualSystemManagementService.c | 7 +------ 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 16195da..98c6c54 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -396,7 +396,7 @@ err: return 0; } -int parse_domain_type(xmlNodePtr node, char **value) +int has_kvm_domain_type(xmlNodePtr node) { xmlNodePtr child = NULL; char *type = NULL; @@ -405,22 +405,19 @@ int parse_domain_type(xmlNodePtr node, char **value) while (child != NULL) { if (XSTREQ(child->name, "domain")) { type = get_attr_value(child, "type"); - if (type != NULL) { - *value = strdup(type); - goto out; + if (XSTREQ(type, "kvm")) { + return 1; } } - if (parse_domain_type(child, value) == 1) { - goto out; + if (has_kvm_domain_type(child) == 1) { + return 1; } child = child->next; } return 0; -out: - return 1; } 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..6abcf14 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); +int 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; 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

On 07/01/2013 03:00 AM, Xu Wang wrote:
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 <cngesaint@gmail.com> --- libxkutil/device_parsing.c | 13 +++++-------- libxkutil/device_parsing.h | 2 +- src/Virt_VirtualSystemManagementService.c | 7 +------ 3 files changed, 7 insertions(+), 15 deletions(-)
Looks good to me. John, could you review the patch? Thx! -- 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

On 07/01/2013 08:42 AM, Viktor Mihajlovski wrote:
On 07/01/2013 03:00 AM, Xu Wang wrote:
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 <cngesaint@gmail.com> --- libxkutil/device_parsing.c | 13 +++++-------- libxkutil/device_parsing.h | 2 +- src/Virt_VirtualSystemManagementService.c | 7 +------ 3 files changed, 7 insertions(+), 15 deletions(-)
Looks good to me. John, could you review the patch? Thx!
I'm OK with the patch - I suppose the desire though is to have me push it right :-)? Curious - are there other patches coming shortly or is this it for a while? Reason I'm asking deals with Red Hat releases - specifically the need to have something for the 7.0 release. I'm thinking the desire is to perhaps generate a release with everything up to date. That could then be pushed into the RHEL 7.0. John

On 07/01/2013 05:01 PM, John Ferlan wrote:
I'm OK with the patch - I suppose the desire though is to have me push it right :-)?
well, I am not yet acquainted with the libvirt-cim who-is-who (or who-can-push) but I would appreciate this patch to go upstream.
Curious - are there other patches coming shortly or is this it for a while? Reason I'm asking deals with Red Hat releases - specifically the need to have something for the 7.0 release. I'm thinking the desire is to perhaps generate a release with everything up to date. That could then be pushed into the RHEL 7.0.
Hm, it happens that I am currently looking at portability aspects of libvirt-cim. And although some patches could well result from this exercise I am not yet able to tell whether this would be in time for a specific distribution release level. Sorry for not being able to offer more at this point in time. -- 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

On 07/01/2013 11:54 AM, Viktor Mihajlovski wrote:
On 07/01/2013 05:01 PM, John Ferlan wrote:
I'm OK with the patch - I suppose the desire though is to have me push it right :-)?
well, I am not yet acquainted with the libvirt-cim who-is-who (or who-can-push) but I would appreciate this patch to go upstream.
It was more a question for the author since I've pushed the last couple of patches I wasn't sure who would do this one. In any case, I had to make one small adjustment to the patch output, but I was able to 'git am', run a test build, but I'm having some issues during testing. I think those are a self inflicted environment though. The adjustment involved the difference line: virConnectPtr conn; which did not have the prior update to add the "NULL" to the def: virConnectPtr conn = NULL; because the following can go to out before conn was defined: if (disable_kvm) { CU_DEBUG("Enter disable kvm mode!"); goto out; } Before pushing I'd like to get verification from the author that the cimtest works.
Curious - are there other patches coming shortly or is this it for a while? Reason I'm asking deals with Red Hat releases - specifically the need to have something for the 7.0 release. I'm thinking the desire is to perhaps generate a release with everything up to date. That could then be pushed into the RHEL 7.0.
Hm, it happens that I am currently looking at portability aspects of libvirt-cim. And although some patches could well result from this exercise I am not yet able to tell whether this would be in time for a specific distribution release level. Sorry for not being able to offer more at this point in time.
Fair enough - it's probably a "this month" type timeframe. John

On 07/01/2013 11:54 AM, Viktor Mihajlovski wrote:
On 07/01/2013 05:01 PM, John Ferlan wrote:
I'm OK with the patch - I suppose the desire though is to have me push it right :-)?
well, I am not yet acquainted with the libvirt-cim who-is-who (or who-can-push) but I would appreciate this patch to go upstream.
It was more a question for the author since I've pushed the last couple of patches I wasn't sure who would do this one. In any case, I had to make one small adjustment to the patch output, but I was able to 'git am', run a test build, but I'm having some issues during testing. I think those are a self inflicted environment though.
The adjustment involved the difference line:
virConnectPtr conn;
which did not have the prior update to add the "NULL" to the def:
virConnectPtr conn = NULL;
because the following can go to out before conn was defined:
if (disable_kvm) { CU_DEBUG("Enter disable kvm mode!"); goto out; }
Before pushing I'd like to get verification from the author that the cimtest works. Sorry for it. I think I didn't update my local git on time. Now the
于 2013-07-03 00:44, John Ferlan 写道: patch V5 should solved this issue and another memory leak. I just rerun cimtest and it works well. If no problem, please push it into upstream. Thank you:-) Sincerely yours, Xu Wang
Curious - are there other patches coming shortly or is this it for a while? Reason I'm asking deals with Red Hat releases - specifically the need to have something for the 7.0 release. I'm thinking the desire is to perhaps generate a release with everything up to date. That could then be pushed into the RHEL 7.0.
Hm, it happens that I am currently looking at portability aspects of libvirt-cim. And although some patches could well result from this exercise I am not yet able to tell whether this would be in time for a specific distribution release level. Sorry for not being able to offer more at this point in time.
Fair enough - it's probably a "this month" type timeframe.
John
participants (3)
-
John Ferlan
-
Viktor Mihajlovski
-
Xu Wang