[PATCH 00 of 12] Finish out the conversion to classname connections

This fixes the remaining uses of lv_connect() (except for ComputerSystemIndication, which I'll deal with later). A quick poke seems to indicate that things still work, but testing would be good. Next, I will work on get_typed_instance(), which also needs a per-classname change so that we don't return Xen_foo instances for non-xen cases. There are also a lot of fixes needed to prevent classes from returning instances for the incorrect platform. These would be any that don't depend on a valid libvirt connection for their work.

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195491599 28800 # Node ID 7a114401c8ede2268fb291d713c0b1e4715b0b8d # Parent 66f0dde5f3fd81a495a1597033e180e251817054 Make parse_fq_devid() take a const char * ...like it should have from the beginning Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 66f0dde5f3fd -r 7a114401c8ed libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Mon Nov 19 08:00:03 2007 -0800 +++ b/libxkutil/device_parsing.c Mon Nov 19 08:59:59 2007 -0800 @@ -447,7 +447,7 @@ char *get_fq_devid(char *host, char *_de return devid; } -int parse_fq_devid(char *devid, char **host, char **device) +int parse_fq_devid(const char *devid, char **host, char **device) { int ret; diff -r 66f0dde5f3fd -r 7a114401c8ed libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Mon Nov 19 08:00:03 2007 -0800 +++ b/libxkutil/device_parsing.h Mon Nov 19 08:59:59 2007 -0800 @@ -109,7 +109,7 @@ void cleanup_virt_devices(struct virt_de void cleanup_virt_devices(struct virt_device **devs, int count); char *get_fq_devid(char *host, char *_devid); -int parse_fq_devid(char *devid, char **host, char **device); +int parse_fq_devid(const char *devid, char **host, char **device); int attach_device(virDomainPtr dom, struct virt_device *dev); int detach_device(virDomainPtr dom, struct virt_device *dev);

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195491890 28800 # Node ID 59abf0e63644d8c306492645f9291718c35e40d5 # Parent 7a114401c8ede2268fb291d713c0b1e4715b0b8d Make DevicePool use connect_by_classname() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 7a114401c8ed -r 59abf0e63644 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Mon Nov 19 08:59:59 2007 -0800 +++ b/src/Virt_DevicePool.c Mon Nov 19 09:04:50 2007 -0800 @@ -148,7 +148,9 @@ static char *_diskpool_member_of(const c return pool; } -static char *diskpool_member_of(const CMPIBroker *broker, char *rasd_id) +static char *diskpool_member_of(const CMPIBroker *broker, + const char *rasd_id, + const char *refcn) { char *host = NULL; char *dev = NULL; @@ -165,7 +167,7 @@ static char *diskpool_member_of(const CM if (!ret) goto out; - conn = lv_connect(broker, &s); + conn = connect_by_classname(broker, refcn, &s); if (conn == NULL) goto out; @@ -194,7 +196,9 @@ static char *diskpool_member_of(const CM return pool; } -static char *netpool_member_of(const CMPIBroker *broker, char *rasd_id) +static char *netpool_member_of(const CMPIBroker *broker, + const char *rasd_id, + const char *refcn) { char *host = NULL; char *dev = NULL; @@ -211,7 +215,7 @@ static char *netpool_member_of(const CMP if (!ret) goto out; - conn = lv_connect(broker, &s); + conn = connect_by_classname(broker, refcn, &s); if (conn == NULL) goto out; @@ -243,7 +247,10 @@ static char *netpool_member_of(const CMP return result; } -char *pool_member_of(const CMPIBroker *broker, uint16_t type, char *id) +char *pool_member_of(const CMPIBroker *broker, + const char *refcn, + uint16_t type, + const char *id) { char *poolid = NULL; @@ -252,9 +259,9 @@ char *pool_member_of(const CMPIBroker *b else if (type == CIM_RASD_TYPE_MEM) poolid = strdup("MemoryPool/0"); else if (type == CIM_RASD_TYPE_NET) - poolid = netpool_member_of(broker, id); + poolid = netpool_member_of(broker, id, refcn); else if (type == CIM_RASD_TYPE_DISK) - poolid = diskpool_member_of(broker, id); + poolid = diskpool_member_of(broker, id, refcn); else return NULL; @@ -630,7 +637,7 @@ static CMPIStatus return_pool(const CMPI inst_list_init(&list); - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) goto out; @@ -691,7 +698,7 @@ static CMPIStatus GetInstance(CMPIInstan goto out; } - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); if (conn == NULL) goto out; diff -r 7a114401c8ed -r 59abf0e63644 src/Virt_DevicePool.h --- a/src/Virt_DevicePool.h Mon Nov 19 08:59:59 2007 -0800 +++ b/src/Virt_DevicePool.h Mon Nov 19 09:04:50 2007 -0800 @@ -39,7 +39,21 @@ CMPIInstance *get_pool_by_id(const CMPIB const char *id, const char *ns); -char *pool_member_of(const CMPIBroker *broker, uint16_t type, char *id); + +/** + * Get the InstanceID of a pool that a given RASD id (for type) is in + * + * @param broker The current Broker + * @param refcn A reference classname to be used for libvirt + * connections. This can be anything as long as the + * prefix is correct. + * @param type The ResourceType of the RASD + * @param id The InstanceID of the RASD + */ +char *pool_member_of(const CMPIBroker *broker, + const char *refcn, + uint16_t type, + const char *id); #endif diff -r 7a114401c8ed -r 59abf0e63644 src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Mon Nov 19 08:59:59 2007 -0800 +++ b/src/Virt_ElementAllocatedFromPool.c Mon Nov 19 09:04:50 2007 -0800 @@ -84,7 +84,7 @@ static CMPIStatus vdev_to_pool(const CMP goto out; } - poolid = pool_member_of(_BROKER, type, id); + poolid = pool_member_of(_BROKER, CLASSNAME(ref), type, id); if (poolid == NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -120,21 +120,27 @@ static int filter_by_pool(struct inst_li const char *_poolid) { int i; - char *dev_id = NULL; char *poolid = NULL; for (i = 0; i < src->cur; i++) { CMPIInstance *inst = src->list[i]; - + char *cn = NULL; + char *dev_id = NULL; + + cu_get_str_prop(inst, "CreationClassName", &cn); cu_get_str_prop(inst, "DeviceID", &dev_id); + if ((dev_id == NULL) || (cn == NULL)) + goto end; + printf("Device %hhi:%s", type, dev_id); - poolid = pool_member_of(_BROKER, type, dev_id); + poolid = pool_member_of(_BROKER, cn, type, dev_id); if (poolid && STREQ(poolid, _poolid)) inst_list_add(dest, inst); - + end: free(dev_id); + free(cn); } return dest->cur; diff -r 7a114401c8ed -r 59abf0e63644 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Mon Nov 19 08:59:59 2007 -0800 +++ b/src/Virt_ResourceAllocationFromPool.c Mon Nov 19 09:04:50 2007 -0800 @@ -66,7 +66,7 @@ static CMPIStatus rasd_to_pool(const CMP goto out; } - poolid = pool_member_of(_BROKER, type, id); + poolid = pool_member_of(_BROKER, CLASSNAME(ref), type, id); if (poolid == NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -123,7 +123,7 @@ static int filter_by_pool(struct inst_li cu_get_str_prop(inst, "InstanceID", &rasd_id); - poolid = pool_member_of(_BROKER, type, rasd_id); + poolid = pool_member_of(_BROKER, CLASSNAME(op), type, rasd_id); if (STREQ(poolid, _poolid)) inst_list_add(dest, inst);

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195492220 28800 # Node ID 63881b803abfa7a291082191fb245f26731c7d7c # Parent 59abf0e63644d8c306492645f9291718c35e40d5 Make ElementAllocatedFromPool use connect_by_classname() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 59abf0e63644 -r 63881b803abf src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Mon Nov 19 09:04:50 2007 -0800 +++ b/src/Virt_ElementAllocatedFromPool.c Mon Nov 19 09:10:20 2007 -0800 @@ -92,7 +92,7 @@ static CMPIStatus vdev_to_pool(const CMP goto out; } - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) goto out; @@ -147,7 +147,7 @@ static int filter_by_pool(struct inst_li } static int devs_from_pool(uint16_t type, - const char *ns, + const CMPIObjectPath *ref, const char *poolid, struct inst_list *list) { @@ -156,8 +156,10 @@ static int devs_from_pool(uint16_t type, virDomainPtr *doms = NULL; int count; int i; - - conn = lv_connect(_BROKER, &s); + const char *ns = NAMESPACE(ref); + const char *cn = CLASSNAME(ref); + + conn = connect_by_classname(_BROKER, cn, &s); if (conn == NULL) return 0; @@ -200,7 +202,6 @@ static CMPIStatus pool_to_vdev(const CMP { char *poolid; CMPIStatus s; - const char *ns = NAMESPACE(ref); poolid = cu_get_str_path(ref, "InstanceID"); if (poolid == NULL) { @@ -215,22 +216,22 @@ static CMPIStatus pool_to_vdev(const CMP /* FIXME, make this shared with the RAFP version */ if (STARTS_WITH(poolid, "ProcessorPool")) devs_from_pool(CIM_RASD_TYPE_PROC, - ns, + ref, poolid, list); else if (STARTS_WITH(poolid, "MemoryPool")) devs_from_pool(CIM_RASD_TYPE_MEM, - ns, + ref, poolid, list); else if (STARTS_WITH(poolid, "NetworkPool")) devs_from_pool(CIM_RASD_TYPE_NET, - ns, + ref, poolid, list); else if (STARTS_WITH(poolid, "DiskPool")) devs_from_pool(CIM_RASD_TYPE_DISK, - ns, + ref, poolid, list); else {

Dan Smith wrote:
{ @@ -156,8 +156,10 @@ static int devs_from_pool(uint16_t type, virDomainPtr *doms = NULL; int count; int i; - - conn = lv_connect(_BROKER, &s); + const char *ns = NAMESPACE(ref); + const char *cn = CLASSNAME(ref); + + conn = connect_by_classname(_BROKER, cn, &s); if (conn == NULL) return 0;
This is terribly nit-picky.. but why use variables for ns and cn? They only get used once in this function, right? I suppose it does look cleaner though. -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com

KR> This is terribly nit-picky.. but why use variables for ns and cn? KR> They only get used once in this function, right? I suppose it KR> does look cleaner though. It is just to clean up the function calls. Also, in lots of these functions, there are already lines that depend on something like 'ns' being passed in, so just setting ns to what it was before reduces the likelihood of breaking something that depends on such semantics. Given how fast I'm going through these, breaking fewer things is a good thing, I think. We do the "const char *ns = NAMESPACE(ref)" thing in lots of other places and it just "feels right" for some reason, but if people disagree and want to set a policy about it, that's fine with me. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> This is terribly nit-picky.. but why use variables for ns and cn? KR> They only get used once in this function, right? I suppose it KR> does look cleaner though.
It is just to clean up the function calls. Also, in lots of these functions, there are already lines that depend on something like 'ns' being passed in, so just setting ns to what it was before reduces the likelihood of breaking something that depends on such semantics. Given how fast I'm going through these, breaking fewer things is a good thing, I think.
We do the "const char *ns = NAMESPACE(ref)" thing in lots of other places and it just "feels right" for some reason, but if people disagree and want to set a policy about it, that's fine with me.
Sure - this makes sense. I also wasn't sure if it's a style thing. I see it in some places and other places I don't. But either way is fine with me. -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195492278 28800 # Node ID 0257746b9ab4cdda63bd9a793b87d240dc6ca17d # Parent 63881b803abfa7a291082191fb245f26731c7d7c Make ElementCapabilities use connect_by_classname() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 63881b803abf -r 0257746b9ab4 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Mon Nov 19 09:10:20 2007 -0800 +++ b/src/Virt_ElementCapabilities.c Mon Nov 19 09:11:18 2007 -0800 @@ -167,7 +167,7 @@ static CMPIStatus cap_to_cs(const CMPIOb goto error1; } - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (s.rc != CMPI_RC_OK) goto error1;

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195492322 28800 # Node ID ca9fa1774a7bf967dd12da8e2d57f1b467db354c # Parent 0257746b9ab4cdda63bd9a793b87d240dc6ca17d Make ElementSettingData use connect_by_classname() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 0257746b9ab4 -r ca9fa1774a7b src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Mon Nov 19 09:11:18 2007 -0800 +++ b/src/Virt_ElementSettingData.c Mon Nov 19 09:12:02 2007 -0800 @@ -53,7 +53,7 @@ static CMPIStatus vssd_to_sd(const CMPIO goto out; } - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) goto out;

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195492369 28800 # Node ID cfc79d123d0a9760c8c6c1e3d81ef4683e93b988 # Parent ca9fa1774a7bf967dd12da8e2d57f1b467db354c Make HostedResourcePool use connect_by_classname() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r ca9fa1774a7b -r cfc79d123d0a src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Mon Nov 19 09:12:02 2007 -0800 +++ b/src/Virt_HostedResourcePool.c Mon Nov 19 09:12:49 2007 -0800 @@ -76,7 +76,7 @@ static CMPIStatus sys_to_pool(const CMPI return s; } - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) return s;

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195493224 28800 # Node ID 00deec21b241f4f29207138456f3623b7867d04f # Parent cfc79d123d0a9760c8c6c1e3d81ef4683e93b988 Make RASD use connect_by_classname() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r cfc79d123d0a -r 00deec21b241 src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Nov 19 09:12:49 2007 -0800 +++ b/src/Virt_RASD.c Mon Nov 19 09:27:04 2007 -0800 @@ -175,7 +175,7 @@ static CMPIInstance *rasd_from_vdev(cons } static CMPIInstance *get_rasd_instance(const CMPIContext *context, - const CMPIObjectPath *ns, + const CMPIObjectPath *ref, const char *id, const uint16_t type) { @@ -191,13 +191,13 @@ static CMPIInstance *get_rasd_instance(c if (!ret) return NULL; - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) goto out; dev = find_dev(conn, type, host, devid); if (dev) - inst = rasd_from_vdev(_BROKER, dev, host, NAMESPACE(ns)); + inst = rasd_from_vdev(_BROKER, dev, host, NAMESPACE(ref)); out: virConnectClose(conn); @@ -276,7 +276,7 @@ int rasds_for_domain(const CMPIBroker *b int rasds_for_domain(const CMPIBroker *broker, const char *name, const uint16_t type, - const char *ns, + const CMPIObjectPath *ref, struct inst_list *_list) { struct virt_device *list; @@ -284,8 +284,10 @@ int rasds_for_domain(const CMPIBroker *b int i; virConnectPtr conn; CMPIStatus s; - - conn = lv_connect(_BROKER, &s); + const char *ns = NAMESPACE(ref); + const char *cn = CLASSNAME(ref); + + conn = connect_by_classname(broker, cn, &s); if (conn == NULL) return 0; diff -r cfc79d123d0a -r 00deec21b241 src/Virt_RASD.h --- a/src/Virt_RASD.h Mon Nov 19 09:12:49 2007 -0800 +++ b/src/Virt_RASD.h Mon Nov 19 09:27:04 2007 -0800 @@ -22,11 +22,23 @@ #define __VIRT_RASD_H char *rasd_to_xml(CMPIInstance *rasd); + +/** + * Get a list of RASDs for a given domain + * + * @param broker The current broker + * @param name The name of the domain in question + * @param type The ResourceType of the desired RASDs + * @param ref A reference used for hypervisor connection and namespace + * setting of the resulting instances + * @param _list The list of instances to populate + */ int rasds_for_domain(const CMPIBroker *broker, const char *name, const uint16_t type, - const char *ns, + const CMPIObjectPath *ref, struct inst_list *_list); + CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type); #endif diff -r cfc79d123d0a -r 00deec21b241 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Mon Nov 19 09:12:49 2007 -0800 +++ b/src/Virt_ResourceAllocationFromPool.c Mon Nov 19 09:27:04 2007 -0800 @@ -134,7 +134,7 @@ static int filter_by_pool(struct inst_li } static int rasds_from_pool(uint16_t type, - const char *ns, + const CMPIObjectPath *ref, const char *poolid, struct inst_list *list) { @@ -161,7 +161,7 @@ static int rasds_from_pool(uint16_t type rasds_for_domain(_BROKER, name, type, - ns, + ref, &tmp); filter_by_pool(list, &tmp, poolid); @@ -194,22 +194,22 @@ static CMPIStatus pool_to_rasd(const CMP if (STARTS_WITH(poolid, "ProcessorPool")) rasds_from_pool(CIM_RASD_TYPE_PROC, - NAMESPACE(ref), + ref, poolid, list); else if (STARTS_WITH(poolid, "MemoryPool")) rasds_from_pool(CIM_RASD_TYPE_MEM, - NAMESPACE(ref), + ref, poolid, list); else if (STARTS_WITH(poolid, "NetworkPool")) rasds_from_pool(CIM_RASD_TYPE_NET, - NAMESPACE(ref), + ref, poolid, list); else if (STARTS_WITH(poolid, "DiskPool")) rasds_from_pool(CIM_RASD_TYPE_DISK, - NAMESPACE(ref), + ref, poolid, list); else { diff -r cfc79d123d0a -r 00deec21b241 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Mon Nov 19 09:12:49 2007 -0800 +++ b/src/Virt_SettingsDefineState.c Mon Nov 19 09:27:04 2007 -0800 @@ -99,7 +99,7 @@ static CMPIStatus dev_to_rasd(const CMPI ret = rasds_for_domain(_BROKER, name, device_type_from_classname(CLASSNAME(ref)), - NAMESPACE(ref), + ref, &rasds); rasd = find_rasd(&rasds, id); diff -r cfc79d123d0a -r 00deec21b241 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Mon Nov 19 09:12:49 2007 -0800 +++ b/src/Virt_VSSDComponent.c Mon Nov 19 09:27:04 2007 -0800 @@ -64,7 +64,7 @@ static CMPIStatus vssd_to_rasd(const CMP rasds_for_domain(_BROKER, name, types[i], - NAMESPACE(ref), + ref, list); }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195493301 28800 # Node ID c5a2fc3f7a6c13f19c06c528026d1dca2becba00 # Parent 00deec21b241f4f29207138456f3623b7867d04f Make ResourceAllocationFromPool use connect_by_classname() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 00deec21b241 -r c5a2fc3f7a6c src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Mon Nov 19 09:27:04 2007 -0800 +++ b/src/Virt_ResourceAllocationFromPool.c Mon Nov 19 09:28:21 2007 -0800 @@ -74,7 +74,7 @@ static CMPIStatus rasd_to_pool(const CMP goto out; } - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) goto out; @@ -144,7 +144,7 @@ static int rasds_from_pool(uint16_t type int count; int i; - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) return 0;

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195493466 28800 # Node ID ca32e4299b0944be44ec5bf9821a087857ca37a9 # Parent c5a2fc3f7a6c13f19c06c528026d1dca2becba00 Make SettingsDefineState use connect_by_classname() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r c5a2fc3f7a6c -r ca32e4299b09 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Mon Nov 19 09:28:21 2007 -0800 +++ b/src/Virt_SettingsDefineState.c Mon Nov 19 09:31:06 2007 -0800 @@ -118,14 +118,14 @@ static CMPIStatus dev_to_rasd(const CMPI static CMPIInstance *_get_typed_device(char *id, int type, - const char *ns, + const CMPIObjectPath *ref, CMPIStatus *s) { virConnectPtr conn = NULL; CMPIInstance *dev = NULL; const char *typestr; - conn = lv_connect(_BROKER, s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), s); if (conn == NULL) goto out; @@ -147,7 +147,7 @@ static CMPIInstance *_get_typed_device(c dev = instance_from_devid(_BROKER, conn, id, - ns, + NAMESPACE(ref), device_type_from_classname(typestr)); out: virConnectClose(conn); @@ -181,7 +181,7 @@ static CMPIStatus rasd_to_dev(const CMPI goto out; } - dev = _get_typed_device(id, type, NAMESPACE(ref), &s); + dev = _get_typed_device(id, type, ref, &s); if (dev == NULL) goto out; @@ -205,7 +205,7 @@ static CMPIStatus vs_to_vssd(const CMPIO CMPIInstance *vssd; CMPIStatus s; - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) return s; @@ -268,7 +268,7 @@ static CMPIStatus vssd_to_vs(const CMPIO goto out; } - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) goto out;

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195493553 28800 # Node ID ea31aaa60fb3f4164ee296c349d45e73a36149a5 # Parent ca32e4299b0944be44ec5bf9821a087857ca37a9 Make SettingsDefineCapabilities use connect_by_classname() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r ca32e4299b09 -r ea31aaa60fb3 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Nov 19 09:31:06 2007 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Mon Nov 19 09:32:33 2007 -0800 @@ -232,7 +232,7 @@ static struct sdc_rasd_prop *proc_max(co CU_DEBUG("In proc_max()"); - conn = lv_connect(_BROKER, s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), s); if (conn == NULL) { cu_statusf(_BROKER, s, CMPI_RC_ERR_FAILED, @@ -346,7 +346,7 @@ static uint16_t net_max_xen(const CMPIOb unsigned long version; uint16_t num_nics = -1; - conn = lv_connect(_BROKER, s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), s); if (s->rc != CMPI_RC_OK) { cu_statusf(_BROKER, s, CMPI_RC_ERR_FAILED, @@ -515,7 +515,7 @@ static struct sdc_rasd_prop *disk_max(co goto out; } - conn = lv_connect(_BROKER, s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), s); if (s->rc != CMPI_RC_OK) { cu_statusf(_BROKER, s, CMPI_RC_ERR_FAILED,

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195493851 28800 # Node ID 3957678edbd4b7ed01011ac08a0771529a8c335b # Parent ea31aaa60fb3f4164ee296c349d45e73a36149a5 Make VSMS use connect_by_classname() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r ea31aaa60fb3 -r 3957678edbd4 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon Nov 19 09:32:33 2007 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Mon Nov 19 09:37:31 2007 -0800 @@ -482,7 +482,7 @@ static CMPIStatus update_system_settings goto out; } - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) goto out; @@ -587,7 +587,8 @@ static struct virt_device **find_list(st static CMPIStatus _resource_dynamic(struct domain *dominfo, struct virt_device *dev, - enum ResourceAction action) + enum ResourceAction action, + const char *refcn) { CMPIStatus s; virConnectPtr conn; @@ -608,7 +609,7 @@ static CMPIStatus _resource_dynamic(stru return s; } - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, refcn, &s); if (conn == NULL) { CU_DEBUG("Failed to connect"); return s; @@ -653,11 +654,16 @@ static CMPIStatus resource_del(struct do const char *devid) { CMPIStatus s; + CMPIObjectPath *op; struct virt_device **_list; struct virt_device *list; int *count; int i; + op = CMGetObjectPath(rasd, &s); + if ((op == NULL) || (s.rc != CMPI_RC_OK)) + goto out; + _list = find_list(dominfo, type, &count); if ((type == CIM_RASD_TYPE_MEM) || (_list != NULL)) list = *_list; @@ -677,7 +683,10 @@ static CMPIStatus resource_del(struct do struct virt_device *dev = &list[i]; if (STREQ(dev->id, devid)) { - s = _resource_dynamic(dominfo, dev, RESOURCE_DEL); + s = _resource_dynamic(dominfo, + dev, + RESOURCE_DEL, + CLASSNAME(op)); dev->type = VIRT_DEV_UNKNOWN; break; } @@ -693,11 +702,16 @@ static CMPIStatus resource_add(struct do const char *devid) { CMPIStatus s; + CMPIObjectPath *op; struct virt_device **_list; struct virt_device *list; struct virt_device *dev; int *count; + op = CMGetObjectPath(rasd, &s); + if ((op == NULL) || (s.rc != CMPI_RC_OK)) + goto out; + _list = find_list(dominfo, type, &count); if ((type == CIM_RASD_TYPE_MEM) || (_list == NULL)) { cu_statusf(_BROKER, &s, @@ -734,7 +748,7 @@ static CMPIStatus resource_add(struct do dev->id = strdup(devid); rasd_to_vdev(rasd, dev); - s = _resource_dynamic(dominfo, dev, RESOURCE_ADD); + s = _resource_dynamic(dominfo, dev, RESOURCE_ADD, CLASSNAME(op)); if (s.rc != CMPI_RC_OK) goto out; @@ -751,11 +765,16 @@ static CMPIStatus resource_mod(struct do const char *devid) { CMPIStatus s; + CMPIObjectPath *op; struct virt_device **_list; struct virt_device *list; int *count; int i; + op = CMGetObjectPath(rasd, &s); + if ((op == NULL) || (s.rc != CMPI_RC_OK)) + goto out; + _list = find_list(dominfo, type, &count); if (_list != NULL) list = *_list; @@ -776,7 +795,10 @@ static CMPIStatus resource_mod(struct do if (STREQ(dev->id, devid)) { rasd_to_vdev(rasd, dev); - s = _resource_dynamic(dominfo, dev, RESOURCE_MOD); + s = _resource_dynamic(dominfo, + dev, + RESOURCE_MOD, + CLASSNAME(op)); break; } } @@ -850,7 +872,7 @@ static CMPIStatus _update_resource_setti virConnectPtr conn = NULL; CMPIStatus s; - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) goto out;

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195493902 28800 # Node ID e1423289fc1dfd4b326c2d79c715ad1246be1cfa # Parent 3957678edbd4b7ed01011ac08a0771529a8c335b Make VSSDComponent use connect_by_classname() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 3957678edbd4 -r e1423289fc1d src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Mon Nov 19 09:37:31 2007 -0800 +++ b/src/Virt_VSSDComponent.c Mon Nov 19 09:38:22 2007 -0800 @@ -84,7 +84,7 @@ static CMPIStatus vssd_for_name(const ch virDomainPtr dom = NULL; CMPIStatus s; - conn = lv_connect(_BROKER, &s); + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) goto out;

Dan Smith wrote:
This fixes the remaining uses of lv_connect() (except for ComputerSystemIndication, which I'll deal with later). A quick poke seems to indicate that things still work, but testing would be good.
Next, I will work on get_typed_instance(), which also needs a per-classname change so that we don't return Xen_foo instances for non-xen cases. There are also a lot of fixes needed to prevent classes from returning instances for the incorrect platform. These would be any that don't depend on a valid libvirt connection for their work.
I tried to test every provider that you touched. Things looked good by my testing. +1 -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com

Dan Smith wrote:
This fixes the remaining uses of lv_connect() (except for ComputerSystemIndication, which I'll deal with later). A quick poke seems to indicate that things still work, but testing would be good.
Next, I will work on get_typed_instance(), which also needs a per-classname change so that we don't return Xen_foo instances for non-xen cases. There are also a lot of fixes needed to prevent classes from returning instances for the incorrect platform. These would be any that don't depend on a valid libvirt connection for their work. All patches applied and compiled fine (FC6, sfcb). +1 While testing I found some minor issues ... with duplicated instances and some other interesting behavior. Will test further with the get_typed_instance() stuff. But this should not prevent you from checking these patches in ;).
-- Regards Heidi Eckhart Software Engineer Linux Technology Center - Open Hypervisor heidieck@linux.vnet.ibm.com ************************************************** IBM Deutschland Entwicklung GmbH Vorsitzender des Aufsichtsrats: Martin Jetter Geschaeftsfuehrung: Herbert Kircher Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
participants (3)
-
Dan Smith
-
Heidi Eckhart
-
Kaitlin Rupert