# HG changeset patch
# User Jim Fehlig <jfehlig(a)novell.com>
# Date 1250021734 21600
# Node ID 9bb1d8852a07160ab0d4572d55a4ea21db830e12
# Parent 2de7d9bdb9af3414ddc01f28d7a007d6c3d19bbc
(#2) Add LibvirtVersion to VSMS
I've had users ask for libvirt version available through libvirt-cim.
This patch add LibvirtVersion property to VSMS, which is a proxy for
libvirt and seems the most appropriate place to add the property.
I consider VSMSC, but that class describes what the associated service
is capable of as opposed to version information about the service.
#2:
If unable to determine libvirt version, set property to
"Unknown libvirt version" instead of "Unknown libvirt".
Signed-off-by: Jim Fehlig <jfehlig novell com>
diff -r 2de7d9bdb9af -r 9bb1d8852a07 schema/VirtualSystemManagementService.mof
--- a/schema/VirtualSystemManagementService.mof Fri Aug 07 15:53:57 2009 -0700
+++ b/schema/VirtualSystemManagementService.mof Tue Aug 11 14:15:34 2009 -0600
@@ -11,6 +11,9 @@
[Description("Package Version")]
string Release;
+
+ [Description("libvirt Version")]
+ string LibvirtVersion;
};
[Provider("cmpi::Virt_VirtualSystemManagementService")]
@@ -24,6 +27,9 @@
[Description("Package Version")]
string Release;
+
+ [Description("libvirt Version")]
+ string LibvirtVersion;
};
[Provider("cmpi::Virt_VirtualSystemManagementService")]
@@ -37,4 +43,7 @@
[Description("Package Version")]
string Release;
+
+ [Description("libvirt Version")]
+ string LibvirtVersion;
};
diff -r 2de7d9bdb9af -r 9bb1d8852a07 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Fri Aug 07 15:53:57 2009 -0700
+++ b/src/Virt_VirtualSystemManagementService.c Tue Aug 11 14:15:34 2009 -0600
@@ -2418,8 +2418,10 @@
const char *ccname = NULL;
virConnectPtr conn = NULL;
unsigned long hv_version = 0;
+ unsigned long lv_version = 0;
const char * hv_type = NULL;
char *caption = NULL;
+ char *lv_version_string = NULL;
CMPIArray *array;
uint16_t op_status;
@@ -2483,6 +2485,26 @@
CMSetProperty(inst, "Caption",
(CMPIValue *)"Unknown Hypervisor", CMPI_chars);
+ if (virGetVersion(&lv_version, hv_type, &hv_version) < 0) {
+ CU_DEBUG("Unable to get libvirt version");
+ lv_version= 0;
+ hv_version= 0;
+ }
+
+ if (asprintf(&lv_version_string, "%lu.%lu.%lu",
+ lv_version / 1000000,
+ (lv_version % 1000000) / 1000,
+ (lv_version % 1000000) % 1000) == -1)
+ lv_version_string = NULL;
+
+ if (lv_version_string != NULL)
+ CMSetProperty(inst, "LibvirtVersion",
+ (CMPIValue *)lv_version_string, CMPI_chars);
+ else
+ CMSetProperty(inst, "LibvirtVersion",
+ (CMPIValue *)"Unknown libvirt version",
+ CMPI_chars);
+
CMSetProperty(inst, "Name",
(CMPIValue *)"Management Service", CMPI_chars);
@@ -2522,6 +2544,7 @@
"");
out:
free(caption);
+ free(lv_version_string);
virConnectClose(conn);
*_inst = inst;