[PATCH 0 of 3] #2 - Device: fix getInstance issues

- getInstance with wrong hypervisor segfaults - getInstance returns with FAILED instead of NOT_FOUND - SystemCreationClassName not set in key properties diff to patch set 1: - close connection to libvirt in 3rd patch now

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1201773643 -3600 # Node ID 277d2b8395e2460a355973309ed14c06e1ef9038 # Parent 2920e184226248f7885dd87a28e30eb1a90005c9 Device: getInstance with wrong hypervisor segfaults wbemgi 'http://localhost:5988/root/virt:Xen_LogicalDisk.DeviceID="qemu1/hda",CreationClassName="KVM_LogicalDisk",SystemName="qemu1",SystemCreationClassName=""' on a KVM system segfaults. Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 2920e1842262 -r 277d2b8395e2 src/Virt_Device.c --- a/src/Virt_Device.c Wed Jan 30 10:52:58 2008 -0800 +++ b/src/Virt_Device.c Thu Jan 31 11:00:43 2008 +0100 @@ -464,8 +464,12 @@ static CMPIStatus get_device(const CMPIO cn = CLASSNAME(reference); conn = connect_by_classname(_BROKER, cn, &s); - if (!conn) - return s; + if (conn == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } inst = instance_from_devid(_BROKER, conn, @@ -481,6 +485,7 @@ static CMPIStatus get_device(const CMPIO "Unable to get device instance"); } + out: virConnectClose(conn); return s;

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1201773653 -3600 # Node ID aeff601277c84629df5ab6d61174409134692215 # Parent 277d2b8395e2460a355973309ed14c06e1ef9038 Device: getInstance returns with FAILED instead of NOT_FOUND Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 277d2b8395e2 -r aeff601277c8 src/Virt_Device.c --- a/src/Virt_Device.c Thu Jan 31 11:00:43 2008 +0100 +++ b/src/Virt_Device.c Thu Jan 31 11:00:53 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);

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1201773719 -3600 # Node ID 6cd2c98c9dc6cac1b1fe88a4f486a59952051bdc # Parent aeff601277c84629df5ab6d61174409134692215 Device: SystemCreationClassName not set in key properties Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r aeff601277c8 -r 6cd2c98c9dc6 src/Virt_Device.c --- a/src/Virt_Device.c Thu Jan 31 11:00:53 2008 +0100 +++ b/src/Virt_Device.c Thu Jan 31 11:01:59 2008 +0100 @@ -84,15 +84,6 @@ static int net_set_hwaddr(CMPIInstance * return 1; } -static int net_set_systemname(CMPIInstance *instance, - const char *domain) -{ - CMSetProperty(instance, "SystemName", - (CMPIValue *)domain, CMPI_chars); - - return 1; -} - static CMPIInstance *net_instance(const CMPIBroker *broker, struct net_device *dev, const virDomainPtr dom, @@ -111,9 +102,6 @@ static CMPIInstance *net_instance(const return NULL; if (!net_set_hwaddr(inst, dev, broker)) - return NULL; - - if (!net_set_systemname(inst, virDomainGetName(dom))) return NULL; return inst; @@ -224,8 +212,20 @@ static int device_set_systemname(CMPIIns static int device_set_systemname(CMPIInstance *instance, const virDomainPtr dom) { + virConnectPtr conn = NULL; + CMSetProperty(instance, "SystemName", (CMPIValue *)virDomainGetName(dom), CMPI_chars); + + conn = virDomainGetConnect(dom); + if (conn) { + char *sccn = NULL; + sccn = get_typed_class(pfx_from_conn(conn), "ComputerSystem"); + CMSetProperty(instance, "SystemCreationClassName", + (CMPIValue *)sccn, CMPI_chars); + free(sccn); + virConnectClose(conn); + } return 1; }
participants (2)
-
Heidi Eckhart
-
Jay Gagnon