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(a)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