[Libvirt-cim] [PATCH 5 of 6] Make VSMS record scheduler parameters when changed

Dan Smith danms at us.ibm.com
Wed Jun 18 16:05:58 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1213805105 25200
# Node ID cbbf8d96967525ab4dcb5bb67b2458a02c27e772
# Parent  5a98830e047c3b61be88c763325ecb9c9bc70370
Make VSMS record scheduler parameters when changed

This includes a new function to synchronize information to the infostore
for use during a ModifyResource() or DefineSystem() call.

Also, delete the infostore for a domain on DestroySystem()

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

diff -r 5a98830e047c -r cbbf8d969675 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c	Wed Jun 18 09:04:19 2008 -0700
+++ b/src/Virt_VirtualSystemManagementService.c	Wed Jun 18 09:05:05 2008 -0700
@@ -42,6 +42,7 @@
 #include <libcmpiutil/std_instance.h>
 
 #include "misc_util.h"
+#include "infostore.h"
 
 #include "Virt_VirtualSystemManagementService.h"
 #include "Virt_ComputerSystem.h"
@@ -471,6 +472,8 @@
                                      struct virt_device *dev)
 {
         cu_get_u64_prop(inst, "VirtualQuantity", &dev->dev.vcpu.quantity);
+        cu_get_u64_prop(inst, "Limit", &dev->dev.vcpu.limit);
+        cu_get_u32_prop(inst, "Weight", &dev->dev.vcpu.weight);
 
         return NULL;
 }
@@ -650,6 +653,54 @@
         return inst;
 }
 
+static CMPIStatus update_dominfo(const struct domain *dominfo,
+                                 const char *refcn)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        struct infostore_ctx *ctx = NULL;
+        struct virt_device *dev = dominfo->dev_vcpu;
+        virConnectPtr conn = NULL;
+        virDomainPtr dom = NULL;
+
+        if (dominfo->dev_vcpu_ct != 1) {
+                /* Right now, we only have extra info for processors */
+                CU_DEBUG("Domain has no vcpu devices!");
+                return s;
+        }
+
+        conn = connect_by_classname(_BROKER, refcn, &s);
+        if (conn == NULL) {
+                CU_DEBUG("Failed to connnect by %s", refcn);
+                return s;
+        }
+
+        dom = virDomainLookupByName(conn, dominfo->name);
+        if (dom == NULL) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_NOT_FOUND,
+                           "Unable to lookup domain `%s'", dominfo->name);
+                goto out;
+        }
+
+        ctx = infostore_open(dom);
+        if (ctx == NULL) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Unable to open infostore");
+                goto out;
+        }
+
+        infostore_set_u64(ctx, "weight", dev->dev.vcpu.weight);
+        infostore_set_u64(ctx, "limit", dev->dev.vcpu.limit);
+ out:
+        infostore_close(ctx);
+
+        virDomainFree(dom);
+        virConnectClose(conn);
+
+        return s;
+}
+
 static CMPIInstance *create_system(CMPIInstance *vssd,
                                    CMPIArray *resources,
                                    const CMPIObjectPath *ref,
@@ -690,6 +741,8 @@
         CU_DEBUG("System XML:\n%s", xml);
 
         inst = connect_and_create(xml, ref, s);
+        if (inst != NULL)
+                update_dominfo(domain, CLASSNAME(ref));
 
  out:
         cleanup_dominfo(&domain);
@@ -780,6 +833,8 @@
                 rc = IM_RC_SYS_NOT_FOUND;
                 goto error;
         }
+
+        infostore_delete(virConnectGetType(conn), dom_name);
 
         virDomainDestroy(dom); /* Okay for this to fail */
         if (virDomainUndefine(dom) == 0) {
@@ -961,6 +1016,8 @@
                            "Virtual System `%s' not found", dominfo->name);
                 goto out;
         }
+
+        update_dominfo(dominfo, refcn);
 
         if (!domain_online(dom)) {
                 CU_DEBUG("VS `%s' not online; skipping dynamic update",




More information about the Libvirt-cim mailing list