[Libvirt-cim] [PATCH 2 of 5] GetInstance() in DevicePool returns an instance for invalid refs

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Dec 21 19:00:21 UTC 2007


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1198261308 28800
# Node ID 40de750e13d37994bee0f7031e82f612d02ebe4d
# Parent  97c1cab36073319f7cf78cbec70eec9eaee01a4d
GetInstance() in DevicePool returns an instance for invalid refs.

If a ref with a correct InstanceID but non-matching classname is passed, GetInstance() returns an instance that matches the InstanceID.  This should return an error.

Add cu_compare_ref() after retrieving the instance to make sure ref is valid.

Failing query:
wbemcli gi 'http://localhost:5988/root/virt:Xen_ProcessorPool.InstanceID="MemoryPool/0"'

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 97c1cab36073 -r 40de750e13d3 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c	Fri Dec 21 09:54:11 2007 -0800
+++ b/src/Virt_DevicePool.c	Fri Dec 21 10:21:48 2007 -0800
@@ -739,6 +739,7 @@ static CMPIStatus GetInstance(CMPIInstan
         CMPIInstance *inst;
         virConnectPtr conn = NULL;
         const char *id = NULL;
+        const char *prop;
 
         if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) {
                 cu_statusf(_BROKER, &s,
@@ -753,6 +754,12 @@ static CMPIStatus GetInstance(CMPIInstan
 
         inst = get_pool_by_id(_BROKER, conn, id, NAMESPACE(reference));
         if (inst) {
+                prop = cu_compare_ref(reference, inst);
+                if (prop != NULL) {
+                        cu_statusf(broker, &s,
+                                   CMPI_RC_ERR_NOT_FOUND,
+                                   "No such ResourcePool instance (%s)", prop);
+                }
                 CMReturnInstance(results, inst);
                 CMSetStatus(&s, CMPI_RC_OK);
         } else {




More information about the Libvirt-cim mailing list