[Libvirt-cim] [PATCH] Add hypervisor version information to the Caption field of the VSMS

Dan Smith danms at us.ibm.com
Wed Jul 23 15:21:27 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1216826114 25200
# Node ID 8d236493f5d67a952bfab94a3fc19a34b3fdf394
# Parent  caa024a3a0938bcb709df190a02fcce0d738c165
Add hypervisor version information to the Caption field of the VSMS.

I don't really see anywhere else this fits into the model, so setting
the caption as such seems reasonable to me.

Comments and arguments are welcome :)

Signed-off-by: Dan Smith <danms at us.ibm.com>

diff -r caa024a3a093 -r 8d236493f5d6 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c	Wed Jul 23 07:53:08 2008 -0700
+++ b/src/Virt_VirtualSystemManagementService.c	Wed Jul 23 08:15:14 2008 -0700
@@ -1706,6 +1706,9 @@
         const char *name = NULL;
         const char *ccname = NULL;
         virConnectPtr conn = NULL;
+        unsigned long hv_version = 0;
+        const char * hv_type = NULL;
+        char *caption = NULL;
 
         *_inst = NULL;
         conn = connect_by_classname(broker, CLASSNAME(reference), &s);
@@ -1742,6 +1745,30 @@
                 goto out;
         }
 
+        hv_type = virConnectGetType(conn);
+        if (hv_type == NULL)
+                hv_type = "Unkown";
+
+        if (virConnectGetVersion(conn, &hv_version) < 0) {
+                CU_DEBUG("Unable to get hypervisor version");
+                hv_version = 0;
+        }
+
+        if (asprintf(&caption,
+                     "%s %lu.%lu.%lu",
+                     hv_type,
+                     hv_version / 1000000,
+                     (hv_version % 1000000) / 1000,
+                     (hv_version % 1000000) % 1000) == -1)
+                caption = NULL;
+
+        if (caption != NULL)
+                CMSetProperty(inst, "Caption",
+                              (CMPIValue *)caption, CMPI_chars);
+        else
+                CMSetProperty(inst, "Caption",
+                              (CMPIValue *)"Unknown Hypervisor", CMPI_chars);
+
         CMSetProperty(inst, "Name",
                       (CMPIValue *)"Management Service", CMPI_chars);
 
@@ -1767,6 +1794,7 @@
                    CMPI_RC_OK,
                    "");
  out:
+        free(caption);
         virConnectClose(conn);
         *_inst = inst;
 




More information about the Libvirt-cim mailing list