[PATCH V3] Fix kvm support check logic
by Xu Wang
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..d4bc65d 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 parse_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 (parse_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..00932d7 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 parse_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..bf61f43 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 (parse_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
11 years, 5 months
[PATCH V2] Fix kvm support check logic
by Xu Wang
Kvm support check function should return domain type of guest which
arch name same with host. This patch add arch name comparation and
return the domain type of right guest.
Signed-off-by: Xu Wang <cngesaint(a)gmail.com>
---
libxkutil/device_parsing.c | 51 +++++++++++++++++++++++++++++++++----------
1 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 16195da..2f39af3 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -396,31 +396,58 @@ err:
return 0;
}
+static xmlNodePtr seek_subNode(xmlNodePtr node, char *tag)
+{
+ xmlNodePtr child = node->children;
+ xmlNodePtr ret = NULL;
+
+ if (child == NULL) {
+ return NULL;
+ }
+
+ while (child) {
+ if (XSTREQ(child->name, tag)) {
+ return child;
+ }
+
+ ret = seek_subNode(child, tag);
+ if (ret) {
+ return ret;
+ }
+
+ child = child->next;
+ }
+
+ return NULL;
+}
+
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;
}
}
-
- if (parse_domain_type(child, value) == 1) {
- goto out;
- }
-
child = child->next;
}
return 0;
-out:
- return 1;
}
static int parse_net_device(xmlNode *inode, struct virt_device **vdevs)
--
1.7.1
11 years, 6 months
[PATCH] Fix kvm support check logic
by Xu Wang
Kvm support check function should return domain type of guest which
arch name same with host. This patch add arch name comparation and
return the domain type of right guest.
Signed-off-by: Xu Wang <cngesaint(a)gmail.com>
---
libxkutil/device_parsing.c | 49 +++++++++++++++++++++++++++++++++----------
1 files changed, 37 insertions(+), 12 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 16195da..184627f 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -396,31 +396,56 @@ err:
return 0;
}
+static xmlNodePtr seek_subNode(xmlNodePtr node, char *tag)
+{
+ xmlNodePtr child = node->children;
+ xmlNodePtr ret = NULL;
+
+ if (child == NULL) {
+ return NULL;
+ }
+
+ while (child) {
+ if (XSTREQ(child->name, tag)) {
+ return child;
+ }
+
+ ret = seek_subNode(child, tag);
+ if (ret) {
+ return ret;
+ }
+
+ child = child->next;
+ }
+}
+
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;
}
}
-
- if (parse_domain_type(child, value) == 1) {
- goto out;
- }
-
child = child->next;
}
return 0;
-out:
- return 1;
}
static int parse_net_device(xmlNode *inode, struct virt_device **vdevs)
--
1.7.1
11 years, 6 months
[PATCH V2] Improve support of nested KVM
by Xu Wang
From: Xu Wang <cngesaint(a)outlook.com>
Under nested KVM environment libvirt-cim could recognize kvm support
correctly now.
Signed-off-by: Xu Wang <cngesaint(a)outlook.com>
---
libxkutil/device_parsing.c | 27 ++++++++++++++++++++
libxkutil/device_parsing.h | 2 +
src/Virt_VirtualSystemManagementService.c | 38 +++++++++++++++++++++++++----
3 files changed, 62 insertions(+), 5 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 436415a..16195da 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -396,6 +396,33 @@ err:
return 0;
}
+int parse_domain_type(xmlNodePtr node, char **value)
+{
+ xmlNodePtr child = NULL;
+ char *type = NULL;
+
+ child = node->children;
+ while (child != NULL) {
+ if (XSTREQ(child->name, "domain")) {
+ type = get_attr_value(child, "type");
+ if (type != NULL) {
+ *value = strdup(type);
+ goto out;
+ }
+ }
+
+ if (parse_domain_type(child, value) == 1) {
+ goto out;
+ }
+
+ child = child->next;
+ }
+
+ return 0;
+out:
+ return 1;
+}
+
static int parse_net_device(xmlNode *inode, struct virt_device **vdevs)
{
struct virt_device *vdev = NULL;
diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h
index 6f6b0b4..733324f 100644
--- a/libxkutil/device_parsing.h
+++ b/libxkutil/device_parsing.h
@@ -221,6 +221,8 @@ 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);
+
#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 7b7261a..8e1e6b1 100644
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -393,25 +393,53 @@ static bool system_has_kvm(const char *pfx)
CMPIStatus s;
virConnectPtr conn;
char *caps = NULL;
- bool kvm = false;
bool disable_kvm = get_disable_kvm();
+ char *val = NULL;
+ xmlDocPtr doc = NULL;
+ xmlNodePtr node = NULL;
+ int len;
+ bool kvm = false;
/* sometimes disable KVM to avoid problem in nested KVM */
if (disable_kvm) {
CU_DEBUG("Enter disable kvm mode!");
- return false;
+ goto out;
}
conn = connect_by_classname(_BROKER, pfx, &s);
if ((conn == NULL) || (s.rc != CMPI_RC_OK)) {
- return false;
+ goto out;
}
caps = virConnectGetCapabilities(conn);
- if (caps != NULL)
- kvm = (strstr(caps, "kvm") != NULL);
+ if (caps != NULL) {
+ len = strlen(caps) + 1;
+
+ doc = xmlParseMemory(caps, len);
+ if (doc == NULL) {
+ CU_DEBUG("xmlParseMemory() call failed!");
+ goto out;
+ }
+
+ node = xmlDocGetRootElement(doc);
+ if (node == NULL) {
+ CU_DEBUG("xmlDocGetRootElement() call failed!");
+ goto out;
+ }
+
+ if (parse_domain_type(node, &val) &&
+ STREQC(val, "kvm")) {
+ 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
11 years, 6 months
[PATCH] Update GPL
by John Ferlan
Following the lead of changes made to libvirt upstream to update the FSF
address based on the following recommended text:
http://www.gnu.org/licenses/gpl-howto.html
I have pushed this as trival
Essentially the difference is as follows:
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
John Ferlan (1):
Update GPL
libxkutil/acl_parsing.c | 4 ++--
libxkutil/acl_parsing.h | 4 ++--
libxkutil/cs_util.h | 4 ++--
libxkutil/cs_util_instance.c | 4 ++--
libxkutil/device_parsing.c | 4 ++--
libxkutil/device_parsing.h | 4 ++--
libxkutil/infostore.c | 4 ++--
libxkutil/infostore.h | 4 ++--
libxkutil/list_util.c | 4 ++--
libxkutil/list_util.h | 4 ++--
libxkutil/misc_util.c | 4 ++--
libxkutil/misc_util.h | 4 ++--
libxkutil/pool_parsing.c | 4 ++--
libxkutil/pool_parsing.h | 4 ++--
libxkutil/xmlgen.c | 4 ++--
libxkutil/xmlgen.h | 4 ++--
src/Virt_AllocationCapabilities.c | 4 ++--
src/Virt_AllocationCapabilities.h | 4 ++--
src/Virt_AppliedFilterList.c | 4 ++--
src/Virt_ComputerSystem.c | 4 ++--
src/Virt_ComputerSystem.h | 4 ++--
src/Virt_ComputerSystemIndication.c | 4 ++--
src/Virt_ComputerSystemIndication.h | 4 ++--
src/Virt_ComputerSystemMigrationIndication.c | 4 ++--
src/Virt_ConcreteComponent.c | 4 ++--
src/Virt_ConsoleRedirectionService.c | 4 ++--
src/Virt_ConsoleRedirectionService.h | 4 ++--
src/Virt_ConsoleRedirectionServiceCapabilities.c | 4 ++--
src/Virt_ConsoleRedirectionServiceCapabilities.h | 4 ++--
src/Virt_Device.c | 4 ++--
src/Virt_Device.h | 4 ++--
src/Virt_DevicePool.c | 4 ++--
src/Virt_DevicePool.h | 4 ++--
src/Virt_ElementAllocatedFromPool.c | 4 ++--
src/Virt_ElementCapabilities.c | 4 ++--
src/Virt_ElementConformsToProfile.c | 4 ++--
src/Virt_ElementSettingData.c | 4 ++--
src/Virt_EnabledLogicalElementCapabilities.c | 4 ++--
src/Virt_EnabledLogicalElementCapabilities.h | 4 ++--
src/Virt_EntriesInFilterList.c | 4 ++--
src/Virt_FilterEntry.c | 4 ++--
src/Virt_FilterEntry.h | 4 ++--
src/Virt_FilterList.c | 4 ++--
src/Virt_FilterList.h | 4 ++--
src/Virt_HostSystem.c | 4 ++--
src/Virt_HostSystem.h | 4 ++--
src/Virt_HostedAccessPoint.c | 4 ++--
src/Virt_HostedDependency.c | 4 ++--
src/Virt_HostedFilterList.c | 4 ++--
src/Virt_HostedResourcePool.c | 4 ++--
src/Virt_HostedService.c | 4 ++--
src/Virt_KVMRedirectionSAP.c | 4 ++--
src/Virt_KVMRedirectionSAP.h | 4 ++--
src/Virt_NestedFilterList.c | 4 ++--
src/Virt_RASD.c | 4 ++--
src/Virt_RASD.h | 4 ++--
src/Virt_ReferencedProfile.c | 4 ++--
src/Virt_RegisteredProfile.c | 4 ++--
src/Virt_RegisteredProfile.h | 4 ++--
src/Virt_ResourceAllocationFromPool.c | 4 ++--
src/Virt_ResourceAllocationSettingDataIndication.c | 4 ++--
src/Virt_ResourcePoolConfigurationCapabilities.c | 4 ++--
src/Virt_ResourcePoolConfigurationService.c | 4 ++--
src/Virt_ResourcePoolConfigurationService.h | 4 ++--
src/Virt_SAPAvailableForElement.c | 4 ++--
src/Virt_ServiceAccessBySAP.c | 4 ++--
src/Virt_ServiceAffectsElement.c | 4 ++--
src/Virt_SettingsDefineCapabilities.c | 4 ++--
src/Virt_SettingsDefineCapabilities.h | 4 ++--
src/Virt_SettingsDefineState.c | 4 ++--
src/Virt_SwitchService.c | 4 ++--
src/Virt_SystemDevice.c | 4 ++--
src/Virt_VSMigrationCapabilities.c | 4 ++--
src/Virt_VSMigrationCapabilities.h | 4 ++--
src/Virt_VSMigrationService.c | 4 ++--
src/Virt_VSMigrationService.h | 4 ++--
src/Virt_VSMigrationSettingData.c | 4 ++--
src/Virt_VSMigrationSettingData.h | 4 ++--
src/Virt_VSSD.c | 4 ++--
src/Virt_VSSD.h | 4 ++--
src/Virt_VSSDComponent.c | 4 ++--
src/Virt_VirtualSystemManagementCapabilities.c | 4 ++--
src/Virt_VirtualSystemManagementCapabilities.h | 4 ++--
src/Virt_VirtualSystemManagementService.c | 4 ++--
src/Virt_VirtualSystemManagementService.h | 4 ++--
src/Virt_VirtualSystemSnapshotService.c | 4 ++--
src/Virt_VirtualSystemSnapshotService.h | 4 ++--
src/Virt_VirtualSystemSnapshotServiceCapabilities.c | 4 ++--
src/Virt_VirtualSystemSnapshotServiceCapabilities.h | 4 ++--
src/profiles.h | 4 ++--
src/svpc_types.h | 4 ++--
tools/migration_tester.py | 4 ++--
92 files changed, 184 insertions(+), 184 deletions(-)
--
1.8.1.4
11 years, 6 months
[PATCH 00/19] Resolve Coverity warnings
by John Ferlan
The following set of patches resolve a number of Coverity errors/warnings
that have crept into the code. After these changes there will be zero
warnings
John Ferlan (19):
Coverity: Resolve BAD_COMPARE - ActivateFilter()
Coverity: Resolve CHECKED_RETURN - _generic_infostore_open()
Coverity: Resolve CHECKED_RETURN - filter_by_pool()
Coverity: Resolve CHECKED_RETURN - get_dev_from_pool
Coverity: Resolve CHECKED_RETURN - get_pools()
Coverity: Resolve CHECKED_RETURN - mem_rasd_to_vdev()
Coverity: Resolve CHECKED_RETURN - return_enum_rasds()
Coverity: Resolve DEADCODE - do_parse()
Coverity: Resolve DEADCODE - get_hypervisor_enabled()
Coverity: Resolve DEADCODE - octets_from_ip()
Coverity: Resolve NO_EFFECT - set_proc_rasd_params()
Coverity: Resolve NO_EFFECT - _set_fv_prop()
Coverity: Resolve RESOURCE_LEAK - parse_os()
Coverity: Resolve REVERSE_INULL - doms_to_xml()
Coverity: Resolve REVERSE_INULL - lifecycle_thread_native()
Coverity: Resolve UNINIT - vsss_delete_snapshot()
Coverity: Resolve UNUSED_VALUE - system_xml() && mem_xml()
Coverity: Resolve USE_AFTER_FREE - lifecycle_thread_native()
Coverity: Resolve ARRAY_VS_SINGLETON - get_dev_paths() and callers
libxkutil/device_parsing.c | 8 +++++++-
libxkutil/infostore.c | 5 ++++-
libxkutil/misc_util.c | 4 ++--
libxkutil/xmlgen.c | 16 ++++++++++++++++
src/Virt_ComputerSystemIndication.c | 19 +++++++++++++------
src/Virt_ElementAllocatedFromPool.c | 12 +++++++-----
src/Virt_FilterEntry.c | 3 ---
src/Virt_RASD.c | 20 ++++++++++++++------
src/Virt_ResourceAllocationFromPool.c | 4 +++-
src/Virt_ResourcePoolConfigurationService.c | 20 +++++++-------------
src/Virt_VSSD.c | 2 +-
src/Virt_VirtualSystemManagementService.c | 4 +++-
src/Virt_VirtualSystemSnapshotService.c | 2 +-
13 files changed, 78 insertions(+), 41 deletions(-)
--
1.8.1.4
11 years, 6 months
[PATCH] Improve support of nested KVM
by cngesaint@outlook.com
From: Xu Wang <cngesaint(a)outlook.com>
Under nested KVM environment libvirt-cim could recognize kvm support
correctly now.
Signed-off-by: Xu Wang <cngesaint(a)outlook.com>
---
libxkutil/device_parsing.c | 19 +++++++++++++++++++
libxkutil/device_parsing.h | 2 ++
src/Virt_VirtualSystemManagementService.c | 22 +++++++++++++++++++---
3 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 436415a..58d9094 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -396,6 +396,25 @@ err:
return 0;
}
+int parse_domain_type(xmlNodePtr node, char **value)
+{
+ xmlNodePtr child = NULL;
+
+ child = node->children;
+ while (child != NULL) {
+ if (XSTREQ(child->name, "domain")) {
+ *value = get_attr_value(child, "type");
+ }
+ if (parse_domain_type(child, value) != 1)
+ goto err;
+ child = child->next;
+ }
+
+ return 1;
+err:
+ return 0;
+}
+
static int parse_net_device(xmlNode *inode, struct virt_device **vdevs)
{
struct virt_device *vdev = NULL;
diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h
index 6f6b0b4..733324f 100644
--- a/libxkutil/device_parsing.h
+++ b/libxkutil/device_parsing.h
@@ -221,6 +221,8 @@ 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);
+
#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 7b7261a..5210fdf 100644
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -393,8 +393,13 @@ static bool system_has_kvm(const char *pfx)
CMPIStatus s;
virConnectPtr conn;
char *caps = NULL;
- bool kvm = false;
bool disable_kvm = get_disable_kvm();
+ char *val = NULL;
+ int ret;
+ xmlDocPtr doc;
+ xmlNodePtr node;
+ int len;
+ bool kvm = false;
/* sometimes disable KVM to avoid problem in nested KVM */
if (disable_kvm) {
@@ -408,10 +413,21 @@ static bool system_has_kvm(const char *pfx)
}
caps = virConnectGetCapabilities(conn);
- if (caps != NULL)
- kvm = (strstr(caps, "kvm") != NULL);
+ if (caps != NULL) {
+ len = strlen(caps) + 1;
+ doc = xmlParseMemory(caps, len);
+ node = xmlDocGetRootElement(doc);
+ ret = parse_domain_type(node, &val);
+ CU_DEBUG("domain type is %s.", val);
+ if (ret == CMPI_RC_OK) {
+ if(STREQC(val, "kvm"))
+ kvm = true;
+ }
+ }
free(caps);
+ free(doc);
+ free(val);
virConnectClose(conn);
--
1.7.1
11 years, 6 months