[Libvirt-cim] [PATCH 2 of 3] Device: getInstance returns with FAILED instead of NOT_FOUND

Heidi Eckhart heidieck at linux.vnet.ibm.com
Wed Jan 30 11:30:33 UTC 2008


# HG changeset patch
# User Heidi Eckhart <heidieck at linux.vnet.ibm.com>
# Date 1201694304 -3600
# Node ID 0a2eafae729edda6f4cd12171fd28d7fbf5b1c16
# Parent  d7a8461a61dcf13ff9d0ab2220b78d9748818cb4
Device: getInstance returns with FAILED instead of NOT_FOUND
Signed-off-by: Heidi Eckhart <heidieck at linux.vnet.ibm.com>

diff -r d7a8461a61dc -r 0a2eafae729e src/Virt_Device.c
--- a/src/Virt_Device.c	Wed Jan 30 12:52:09 2008 +0100
+++ b/src/Virt_Device.c	Wed Jan 30 12:58:24 2008 +0100
@@ -456,7 +456,7 @@ static CMPIStatus get_device(const CMPIO
                              const CMPIResult *results,
                              const char *devid)
 {
-        CMPIStatus s;
+        CMPIStatus s = {CMPI_RC_OK, NULL};
         virConnectPtr conn;
         CMPIInstance *inst;
         const char *cn;
@@ -476,14 +476,18 @@ static CMPIStatus get_device(const CMPIO
                                    devid,
                                    NAMESPACE(reference),
                                    device_type_from_classname(cn));
-        if (inst) {
-                CMReturnInstance(results, inst);
-                CMSetStatus(&s, CMPI_RC_OK);
-        } else {
+        if (inst == NULL) {
                 cu_statusf(_BROKER, &s,
-                           CMPI_RC_ERR_FAILED,
-                           "Unable to get device instance");
-        }
+                           CMPI_RC_ERR_NOT_FOUND,
+                           "No such instance (%s)", devid);
+                goto out;
+        }
+
+        s = cu_validate_ref(_BROKER, reference, inst);
+        if (s.rc != CMPI_RC_OK)
+                goto out;
+
+        CMReturnInstance(results, inst);
 
  out:
         virConnectClose(conn);




More information about the Libvirt-cim mailing list