[PATCH 00 of 27] Fix uses of get_typed_*()

This is a huge set that changes the semantics of get_typed_class() and get_typed_instance() to take a reference class name for proper typing. I have only smoke-tested it, but it fixes several issues with returning incorrectly-typed instances that I know of. A healthy amount of testing would be appreciated :)

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195496688 28800 # Node ID b1d53e304e5dc88a3f57b303838926d31c8f0a7e # Parent e1423289fc1dfd4b326c2d79c715ad1246be1cfa Change the behavior of get_typed_{instance,class}() so that they take a proper prefix. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r e1423289fc1d -r b1d53e304e5d libxkutil/misc_util.c --- a/libxkutil/misc_util.c Mon Nov 19 09:38:22 2007 -0800 +++ b/libxkutil/misc_util.c Mon Nov 19 10:24:48 2007 -0800 @@ -178,43 +178,6 @@ int parse_instance_id(char *_iid, char * return ret; } -static const char *prefix_from_uri(const char *uri) -{ - if (strstr(uri, "xen")) - return "Xen"; - else if (strstr(uri, "qemu")) - return "KVM"; - else - return NULL; -} - -static bool is_xen(void) -{ - return access("/proc/xen/privcmd", R_OK) == 0; -} - -static bool is_kvm(void) -{ - return access("/sys/module/kvm", R_OK) == 0; -} - -static bool is_user(void) -{ - return getenv(URI_ENV) != NULL; -} - -static const char *default_prefix(void) -{ - if (is_user()) - return prefix_from_uri(getenv(URI_ENV)); - else if (is_xen()) - return "Xen"; - else if (is_kvm()) - return "KVM"; - else - return NULL; -} - uint64_t allocated_memory(virConnectPtr conn) { virDomainPtr *list; @@ -241,24 +204,61 @@ uint64_t allocated_memory(virConnectPtr return memory; } +const char *pfx_from_conn(virConnectPtr conn) +{ + char *uri; + const char *pfx = "Xen"; + + uri = virConnectGetURI(conn); + if (uri == NULL) + return pfx; /* Default/Error case */ + + CU_DEBUG("URI of connection is: %s", uri); + + if (STARTS_WITH(uri, "xen")) + pfx = "Xen"; + else if (STARTS_WITH(uri, "qemu")) + pfx = "KVM"; + + free(uri); + + return pfx; +} + +char *get_typed_class(const char *refcn, const char *new_base) +{ + char *class = NULL; + char *pfx; + + if (strchr(refcn, '_')) + pfx = class_prefix_name(refcn); + else + pfx = strdup(refcn); + + if (pfx == NULL) + return NULL; + + if (asprintf(&class, "%s_%s", pfx, new_base) == -1) + class = NULL; + + free(pfx); + + return class; +} + CMPIInstance *get_typed_instance(const CMPIBroker *broker, + const char *refcn, const char *base, const char *namespace) { - const char *prefix; char *new_cn; CMPIObjectPath *op; CMPIInstance *inst = NULL; CMPIStatus s; - prefix = default_prefix(); - if (prefix == NULL) - goto out; - - if (asprintf(&new_cn, "%s_%s", prefix, base) == -1) { - new_cn = NULL; - goto out; - } + new_cn = get_typed_class(refcn, base); + if (new_cn == NULL) + goto out; op = CMNewObjectPath(broker, namespace, new_cn, &s); if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) @@ -275,21 +275,6 @@ CMPIInstance *get_typed_instance(const C free(new_cn); return inst; -} - -char *get_typed_class(const char *new_base) -{ - const char *pfx; - char *class = NULL; - - pfx = default_prefix(); - if (pfx == NULL) - return NULL; - - if (asprintf(&class, "%s_%s", pfx, new_base) == -1) - class = NULL; - - return class; } char *class_base_name(const char *classname) @@ -305,27 +290,15 @@ char *class_base_name(const char *classn virConnectPtr lv_connect(const CMPIBroker *broker, CMPIStatus *s) { - const char *uri = NULL; virConnectPtr conn; - if (is_user()) - uri = getenv(URI_ENV); - else if (is_xen()) - uri = "xen"; - else if (is_kvm()) - uri = "qemu:///system"; - else { - cu_statusf(broker, s, - CMPI_RC_ERR_FAILED, - "Unable to determine hypervisor type"); - return NULL; - } - - conn = virConnectOpen(uri); + /* This is going away, so just assume Xen for right now */ + + conn = virConnectOpen("xen"); if (conn == NULL) cu_statusf(broker, s, CMPI_RC_ERR_FAILED, - "Unable to connect to %s", uri); + "Unable to connect to xen"); else CMSetStatus(s, CMPI_RC_OK); diff -r e1423289fc1d -r b1d53e304e5d libxkutil/misc_util.h --- a/libxkutil/misc_util.h Mon Nov 19 09:38:22 2007 -0800 +++ b/libxkutil/misc_util.h Mon Nov 19 10:24:48 2007 -0800 @@ -70,9 +70,13 @@ char *class_prefix_name(const char *clas char *class_prefix_name(const char *classname); char *class_base_name(const char *classname); -/* Returns "%s_%s" % (prefix($classname), new_base) */ -char *get_typed_class(const char *new_base); +/* Returns a class prefix based on the URI reported by conn */ +const char *pfx_from_conn(virConnectPtr conn); + +/* Returns "%s_%s" % (prefix($refcn), new_base) */ +char *get_typed_class(const char *refcn, const char *new_base); CMPIInstance *get_typed_instance(const CMPIBroker *broker, + const char *refcn, const char *base, const char *namespace);

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195496766 28800 # Node ID aca1440f3971d2f4068fa0c957a7729428af8b1d # Parent b1d53e304e5dc88a3f57b303838926d31c8f0a7e Fix uses of get_typed_*() in ComputerSystem Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r b1d53e304e5d -r aca1440f3971 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Mon Nov 19 10:24:48 2007 -0800 +++ b/src/Virt_ComputerSystem.c Mon Nov 19 10:26:06 2007 -0800 @@ -288,6 +288,7 @@ CMPIInstance *instance_from_name(const C return 0; instance = get_typed_instance(broker, + pfx_from_conn(conn), "ComputerSystem", NAMESPACE(op)); if (instance == NULL) @@ -319,7 +320,10 @@ int enum_domains(const CMPIBroker *broke for (i = 0; i < count; i++) { CMPIInstance *inst; - inst = get_typed_instance(broker, "ComputerSystem", ns); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "ComputerSystem", + ns); if (inst == NULL) goto end;

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195497230 28800 # Node ID 430b7fab22f00f2d86ba9587e4e98af4b47881a3 # Parent aca1440f3971d2f4068fa0c957a7729428af8b1d Fix uses of get_typed_*() in Device Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r aca1440f3971 -r 430b7fab22f0 src/Virt_Device.c --- a/src/Virt_Device.c Mon Nov 19 10:26:06 2007 -0800 +++ b/src/Virt_Device.c Mon Nov 19 10:33:50 2007 -0800 @@ -95,12 +95,17 @@ static int net_set_systemname(CMPIInstan static CMPIInstance *net_instance(const CMPIBroker *broker, struct net_device *dev, - const char *domain, + const virDomainPtr dom, const char *ns) { CMPIInstance *inst; - - inst = get_typed_instance(broker, "NetworkPort", ns); + virConnectPtr conn; + + conn = virDomainGetConnect(dom); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "NetworkPort", + ns); if (!net_set_type(inst, dev)) return NULL; @@ -108,7 +113,7 @@ static CMPIInstance *net_instance(const if (!net_set_hwaddr(inst, dev, broker)) return NULL; - if (!net_set_systemname(inst, domain)) + if (!net_set_systemname(inst, virDomainGetName(dom))) return NULL; return inst; @@ -125,12 +130,17 @@ static int disk_set_name(CMPIInstance *i static CMPIInstance *disk_instance(const CMPIBroker *broker, struct disk_device *dev, - const char *domain, + const virDomainPtr dom, const char *ns) { CMPIInstance *inst; - - inst = get_typed_instance(broker, "LogicalDisk", ns); + virConnectPtr conn; + + conn = virDomainGetConnect(dom); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "LogicalDisk", + ns); if (!disk_set_name(inst, dev)) return NULL; @@ -158,12 +168,17 @@ static int mem_set_size(CMPIInstance *in static CMPIInstance *mem_instance(const CMPIBroker *broker, struct mem_device *dev, - const char *domain, + const virDomainPtr dom, const char *ns) { CMPIInstance *inst; - - inst = get_typed_instance(broker, "Memory", ns); + virConnectPtr conn; + + conn = virDomainGetConnect(dom); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "Memory", + ns); if (!mem_set_size(inst, dev)) return NULL; @@ -173,23 +188,28 @@ static CMPIInstance *mem_instance(const static CMPIInstance *vcpu_instance(const CMPIBroker *broker, struct _virVcpuInfo *dev, - const char *domain, + const virDomainPtr dom, const char *ns) { CMPIInstance *inst; - - inst = get_typed_instance(broker, "Processor", ns); + virConnectPtr conn; + + conn = virDomainGetConnect(dom); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "Processor", + ns); return inst; } static int device_set_devid(CMPIInstance *instance, struct virt_device *dev, - const char *domain) + const virDomainPtr dom) { char *id; - id = get_fq_devid((char *)domain, dev->id); + id = get_fq_devid((char *)virDomainGetName(dom), dev->id); if (id == NULL) return 0; @@ -202,17 +222,17 @@ static int device_set_devid(CMPIInstance } static int device_set_systemname(CMPIInstance *instance, - const char *domain) + const virDomainPtr dom) { CMSetProperty(instance, "SystemName", - (CMPIValue *)domain, CMPI_chars); + (CMPIValue *)virDomainGetName(dom), CMPI_chars); return 1; } static CMPIInstance *device_instance(const CMPIBroker *broker, struct virt_device *dev, - const char *domain, + const virDomainPtr dom, const char *ns) { CMPIInstance *instance; @@ -220,22 +240,22 @@ static CMPIInstance *device_instance(con if (dev->type == VIRT_DEV_NET) instance = net_instance(broker, &dev->dev.net, - domain, + dom, ns); else if (dev->type == VIRT_DEV_DISK) instance = disk_instance(broker, &dev->dev.disk, - domain, + dom, ns); else if (dev->type == VIRT_DEV_MEM) instance = mem_instance(broker, &dev->dev.mem, - domain, + dom, ns); else if (dev->type == VIRT_DEV_VCPU) instance = vcpu_instance(broker, &dev->dev.vcpu, - domain, + dom, ns); else return NULL; @@ -243,8 +263,8 @@ static CMPIInstance *device_instance(con if (!instance) return NULL; - device_set_devid(instance, dev, domain); - device_set_systemname(instance, domain); + device_set_devid(instance, dev, dom); + device_set_systemname(instance, dom); return instance; } @@ -288,11 +308,6 @@ int dom_devices(const CMPIBroker *broker int count; int i; struct virt_device *devs = NULL; - const char *domain; - - domain = virDomainGetName(dom); - if (!domain) - return 0; count = get_devices(dom, &devs, type); if (count <= 0) @@ -301,7 +316,7 @@ int dom_devices(const CMPIBroker *broker for (i = 0; i < count; i++) { CMPIInstance *dev = NULL; - dev = device_instance(broker, &devs[i], domain, ns); + dev = device_instance(broker, &devs[i], dom, ns); if (dev) inst_list_add(list, dev); @@ -442,7 +457,7 @@ CMPIInstance *instance_from_devid(const if (!dev) goto out; - instance = device_instance(broker, dev, domain, ns); + instance = device_instance(broker, dev, dom, ns); cleanup_virt_device(dev); out:

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195497544 28800 # Node ID 2baab0636245ee278bcddd63dfdd4dffbb8698ba # Parent 430b7fab22f00f2d86ba9587e4e98af4b47881a3 Fix uses of get_typed_*() in SystemDevice Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 430b7fab22f0 -r 2baab0636245 src/Virt_SystemDevice.c --- a/src/Virt_SystemDevice.c Mon Nov 19 10:33:50 2007 -0800 +++ b/src/Virt_SystemDevice.c Mon Nov 19 10:39:04 2007 -0800 @@ -100,8 +100,7 @@ static int get_all_devices(const char *n } static CMPIInstance *host_instance(char *name, - const char *host_cn, - const char *ns) + const CMPIObjectPath *ref) { CMPIInstance *inst = NULL; virConnectPtr conn = NULL; @@ -109,15 +108,16 @@ static CMPIInstance *host_instance(char CMPIObjectPath *op; char *host_class; - host_class = get_typed_class("ComputerSystem"); + host_class = get_typed_class(CLASSNAME(ref), + "ComputerSystem"); if (host_class == NULL) goto out; - op = CMNewObjectPath(_BROKER, ns, host_class, &s); + op = CMNewObjectPath(_BROKER, NAMESPACE(ref), host_class, &s); if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) goto out; - conn = connect_by_classname(_BROKER, host_cn, &s); + conn = connect_by_classname(_BROKER, host_class, &s); if (conn == NULL) goto out; @@ -139,6 +139,7 @@ static CMPIInstance *make_ref(const CMPI CMPIInstance *refinst = NULL; refinst = get_typed_instance(_BROKER, + CLASSNAME(ref), "SystemDevice", NAMESPACE(ref)); @@ -227,9 +228,7 @@ static CMPIStatus dev_to_sys(const CMPIO goto out; } - sys = host_instance(host, - CLASSNAME(ref), - NAMESPACE(ref)); + sys = host_instance(host, ref); if (sys == NULL) cu_statusf(_BROKER, &s,

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195497844 28800 # Node ID 2f6d7ab90c35f7a7be3555c945e412f098ad51e6 # Parent 2baab0636245ee278bcddd63dfdd4dffbb8698ba Hack up ComputerSystemIndication to work with the new prototype ...I'll fix it later when I figure out how we're going to do all of the per-class stuff in indications. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 2baab0636245 -r 2f6d7ab90c35 src/Virt_ComputerSystemIndication.c --- a/src/Virt_ComputerSystemIndication.c Mon Nov 19 10:39:04 2007 -0800 +++ b/src/Virt_ComputerSystemIndication.c Mon Nov 19 10:44:04 2007 -0800 @@ -71,7 +71,10 @@ static bool _lifecycle_indication(const CMPIInstance *ind; CMPIStatus s; - ind = get_typed_instance(broker, type, NAMESPACE(newsystem)); + ind = get_typed_instance(broker, + "Xen", /* Temporary hack */ + type, + NAMESPACE(newsystem)); if (ind == NULL) { printf("Failed to create ind\n"); return false; @@ -148,12 +151,12 @@ static bool async_ind(CMPIContext *conte if (type == CS_CREATED) { type_name = "ComputerSystemCreatedIndication"; - type_cn = get_typed_class(type_name); + type_cn = get_typed_class(pfx_from_conn(conn), type_name); op = CMNewObjectPath(_BROKER, ns, type_cn, &s); } else if (type == CS_DELETED) { type_name = "ComputerSystemDeletedIndication"; - type_cn = get_typed_class(type_name); + type_cn = get_typed_class(pfx_from_conn(conn), type_name); op = CMNewObjectPath(_BROKER, ns, type_cn, &s); } else {

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195498008 28800 # Node ID 5de7d5dad0a016a8bcd1ae6ad443726d880ecda3 # Parent 2f6d7ab90c35f7a7be3555c945e412f098ad51e6 Fix uses of get_typed_*() in RASD Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 2f6d7ab90c35 -r 5de7d5dad0a0 src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Nov 19 10:44:04 2007 -0800 +++ b/src/Virt_RASD.c Mon Nov 19 10:46:48 2007 -0800 @@ -105,7 +105,7 @@ static CMPIInstance *rasd_from_vdev(cons static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, - const char *ns) + const CMPIObjectPath *ref) { CMPIInstance *inst; uint16_t type; @@ -128,7 +128,10 @@ static CMPIInstance *rasd_from_vdev(cons return NULL; } - inst = get_typed_instance(broker, base, ns); + inst = get_typed_instance(broker, + CLASSNAME(ref), + base, + NAMESPACE(ref)); if (inst == NULL) return inst; @@ -197,7 +200,7 @@ static CMPIInstance *get_rasd_instance(c dev = find_dev(conn, type, host, devid); if (dev) - inst = rasd_from_vdev(_BROKER, dev, host, NAMESPACE(ref)); + inst = rasd_from_vdev(_BROKER, dev, host, ref); out: virConnectClose(conn); @@ -284,10 +287,8 @@ int rasds_for_domain(const CMPIBroker *b int i; virConnectPtr conn; CMPIStatus s; - const char *ns = NAMESPACE(ref); - const char *cn = CLASSNAME(ref); - - conn = connect_by_classname(broker, cn, &s); + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); if (conn == NULL) return 0; @@ -296,7 +297,7 @@ int rasds_for_domain(const CMPIBroker *b for (i = 0; i < count; i++) { CMPIInstance *inst; - inst = rasd_from_vdev(broker, &list[i], name, ns); + inst = rasd_from_vdev(broker, &list[i], name, ref); if (inst != NULL) inst_list_add(_list, inst); }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195498359 28800 # Node ID 4304ba0c1cedd5401ae3fb24e4edc1a2291f770f # Parent 5de7d5dad0a016a8bcd1ae6ad443726d880ecda3 Fix uses of get_typed_*() in HostSystem Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 5de7d5dad0a0 -r 4304ba0c1ced src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Mon Nov 19 10:46:48 2007 -0800 +++ b/src/Virt_HostSystem.c Mon Nov 19 10:52:39 2007 -0800 @@ -65,7 +65,7 @@ CMPIStatus get_host_cs(const CMPIBroker ns = NAMESPACE(reference); - classname = get_typed_class("HostSystem"); + classname = get_typed_class(CLASSNAME(reference), "HostSystem"); if (classname == NULL) { CMSetStatusWithChars(broker, &s, CMPI_RC_ERR_FAILED,

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195498598 28800 # Node ID 989ee919bdc85b26f9a454b4ed89e3e42211266d # Parent 4304ba0c1cedd5401ae3fb24e4edc1a2291f770f Fix uses of get_typed_*() in VSMS Also short-cut to triggering Xen_Foo indications for now. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 4304ba0c1ced -r 989ee919bdc8 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon Nov 19 10:52:39 2007 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Mon Nov 19 10:56:38 2007 -0800 @@ -358,7 +358,7 @@ static bool trigger_indication(const CMP char *type; CMPIStatus s; - type = get_typed_class(base_type); + type = get_typed_class("Xen", base_type); s = stdi_trigger_indication(_BROKER, context, type, ns); @@ -1059,6 +1059,7 @@ CMPIStatus get_vsms(const CMPIObjectPath goto out; inst = get_typed_instance(broker, + CLASSNAME(reference), "VirtualSystemManagementService", NAMESPACE(reference)); if (inst == NULL) {

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195498788 28800 # Node ID eac989ba68973546f17e21be499e9b0de64baf92 # Parent 989ee919bdc85b26f9a454b4ed89e3e42211266d Fix uses of get_typed_*() in VirtualSystemManagementCapabilities Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 989ee919bdc8 -r eac989ba6897 src/Virt_VirtualSystemManagementCapabilities.c --- a/src/Virt_VirtualSystemManagementCapabilities.c Mon Nov 19 10:56:38 2007 -0800 +++ b/src/Virt_VirtualSystemManagementCapabilities.c Mon Nov 19 10:59:48 2007 -0800 @@ -105,7 +105,8 @@ CMPIStatus get_vsm_cap(const CMPIBroker goto out; } - classname = get_typed_class("VirtualSystemManagementCapabilities"); + classname = get_typed_class(CLASSNAME(ref), + "VirtualSystemManagementCapabilities"); if (classname == NULL) { CMSetStatusWithChars(broker, &s, CMPI_RC_ERR_FAILED,

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195498843 28800 # Node ID 463508334518aaa57a72e5f0b5adc691da009301 # Parent eac989ba68973546f17e21be499e9b0de64baf92 Fix uses of get_typed_*() in EnabledLogicalElementCapabilities Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r eac989ba6897 -r 463508334518 src/Virt_EnabledLogicalElementCapabilities.c --- a/src/Virt_EnabledLogicalElementCapabilities.c Mon Nov 19 10:59:48 2007 -0800 +++ b/src/Virt_EnabledLogicalElementCapabilities.c Mon Nov 19 11:00:43 2007 -0800 @@ -118,7 +118,8 @@ CMPIStatus get_ele_cap(const CMPIBroker goto out; } - classname = get_typed_class("EnabledLogicalElementCapabilities"); + classname = get_typed_class(CLASSNAME(ref), + "EnabledLogicalElementCapabilities"); if (classname == NULL) { CMSetStatusWithChars(broker, &s, CMPI_RC_ERR_FAILED,

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195498882 28800 # Node ID 1b453297885197a4b629dca9d03ec7377e5cfc09 # Parent 463508334518aaa57a72e5f0b5adc691da009301 Fix uses of get_typed_*() in AllocationCapabilities Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 463508334518 -r 1b4532978851 src/Virt_AllocationCapabilities.c --- a/src/Virt_AllocationCapabilities.c Mon Nov 19 11:00:43 2007 -0800 +++ b/src/Virt_AllocationCapabilities.c Mon Nov 19 11:01:22 2007 -0800 @@ -44,7 +44,9 @@ CMPIStatus get_alloc_cap(const CMPIBroke uint16_t type; int ret; - *inst = get_typed_instance(broker, "AllocationCapabilities", + *inst = get_typed_instance(broker, + CLASSNAME(ref), + "AllocationCapabilities", NAMESPACE(ref)); if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195498911 28800 # Node ID 30e1598a81c47ec7794f232cfff1cfbdaa5a5387 # Parent 1b453297885197a4b629dca9d03ec7377e5cfc09 Fix uses of get_typed_*() in VSSD Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 1b4532978851 -r 30e1598a81c4 src/Virt_VSSD.c --- a/src/Virt_VSSD.c Mon Nov 19 11:01:22 2007 -0800 +++ b/src/Virt_VSSD.c Mon Nov 19 11:01:51 2007 -0800 @@ -108,6 +108,7 @@ CMPIInstance *get_vssd_instance(virDomai CMPIInstance *inst; inst = get_typed_instance(broker, + CLASSNAME(ref), "VirtualSystemSettingData", NAMESPACE(ref));

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195498949 28800 # Node ID f328924600e90f76f360e19c40b30cd63bc40801 # Parent 30e1598a81c47ec7794f232cfff1cfbdaa5a5387 Fix uses of get_typed_*() in HostedDependency Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 30e1598a81c4 -r f328924600e9 src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Mon Nov 19 11:01:51 2007 -0800 +++ b/src/Virt_HostedDependency.c Mon Nov 19 11:02:29 2007 -0800 @@ -84,6 +84,7 @@ static CMPIInstance *make_ref(const CMPI CMPIInstance *refinst = NULL; refinst = get_typed_instance(_BROKER, + CLASSNAME(ref), "HostedDependency", NAMESPACE(ref));

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499075 28800 # Node ID efeaecd744af8a062b02b5b6614fd80bc7a7cc48 # Parent f328924600e90f76f360e19c40b30cd63bc40801 Hack up RegisteredProfile to work with the new prototype ...I'll fix it later when I figure out how we're going to do all of the per-class stuff in profiles. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r f328924600e9 -r efeaecd744af src/Virt_RegisteredProfile.c --- a/src/Virt_RegisteredProfile.c Mon Nov 19 11:02:29 2007 -0800 +++ b/src/Virt_RegisteredProfile.c Mon Nov 19 11:04:35 2007 -0800 @@ -50,7 +50,7 @@ CMPIInstance *reg_prof_instance(const CM CMPIInstance *instance = NULL; char *classname; - classname = get_typed_class("RegisteredProfile"); + classname = get_typed_class("Xen", "RegisteredProfile"); if (classname == NULL) { goto out; }

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499129 28800 # Node ID b58e0f79b99e8c9eaedb7a9c2b4dbd194afc2a8d # Parent efeaecd744af8a062b02b5b6614fd80bc7a7cc48 Hack up ElementConformsToProfile to work with the new prototype ...I'll fix it later when I figure out how we're going to do all of the per-class stuff in profiles. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r efeaecd744af -r b58e0f79b99e src/Virt_ElementConformsToProfile.c --- a/src/Virt_ElementConformsToProfile.c Mon Nov 19 11:04:35 2007 -0800 +++ b/src/Virt_ElementConformsToProfile.c Mon Nov 19 11:05:29 2007 -0800 @@ -58,7 +58,7 @@ static CMPIStatus elem_instances(const C CMPIData data ; char *classname; - classname = get_typed_class(profile->provider_name); + classname = get_typed_class("Xen", profile->provider_name); if (classname == NULL) { CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -176,6 +176,7 @@ static CMPIInstance *make_ref(const CMPI CMPIInstance *assoc_inst; assoc_inst = get_typed_instance(_BROKER, + "Xen", "ElementConformsToProfile", NAMESPACE(source_op));

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499376 28800 # Node ID 0912b735d6a65db09f6f9e671bc7cccd5122532c # Parent b58e0f79b99e8c9eaedb7a9c2b4dbd194afc2a8d Fix uses of get_typed_*() in DevicePool Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r b58e0f79b99e -r 0912b735d6a6 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Mon Nov 19 11:05:29 2007 -0800 +++ b/src/Virt_DevicePool.c Mon Nov 19 11:09:36 2007 -0800 @@ -345,7 +345,10 @@ static CMPIStatus mempool_instance(virCo return s; } - inst = get_typed_instance(broker, "MemoryPool", ns); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "MemoryPool", + ns); mempool_set_total(inst, conn); mempool_set_reserved(inst, conn); @@ -380,7 +383,10 @@ static CMPIStatus procpool_instance(virC return s; } - inst = get_typed_instance(broker, "ProcessorPool", ns); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "ProcessorPool", + ns); procpool_set_total(inst, conn); set_units(inst, "Processors"); @@ -399,13 +405,17 @@ static CMPIStatus _netpool_for_bridge(st static CMPIStatus _netpool_for_bridge(struct inst_list *list, const char *ns, const char *bridge, + const char *refcn, const CMPIBroker *broker) { char *id = NULL; uint16_t type = CIM_RASD_TYPE_NET; CMPIInstance *inst; - inst = get_typed_instance(broker, "NetworkPool", ns); + inst = get_typed_instance(broker, + refcn, + "NetworkPool", + ns); if (asprintf(&id, "NetworkPool/%s", bridge) == -1) return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL}; @@ -440,7 +450,11 @@ static CMPIStatus netpool_instance(virCo "No such network pool `%s'", id); goto out; } - return _netpool_for_bridge(list, ns, id, broker); + return _netpool_for_bridge(list, + ns, + id, + pfx_from_conn(conn), + broker); } bridges = list_bridges(); @@ -448,7 +462,11 @@ static CMPIStatus netpool_instance(virCo return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL}; for (i = 0; bridges[i]; i++) { - _netpool_for_bridge(list, ns, bridges[i], broker); + _netpool_for_bridge(list, + ns, + bridges[i], + pfx_from_conn(conn), + broker); free(bridges[i]); } @@ -461,6 +479,7 @@ static CMPIInstance *diskpool_from_path( static CMPIInstance *diskpool_from_path(const char *path, const char *id, const char *ns, + const char *refcn, const CMPIBroker *broker) { CMPIInstance *inst; @@ -470,7 +489,7 @@ static CMPIInstance *diskpool_from_path( uint64_t cap; uint64_t res; - inst = get_typed_instance(broker, "DiskPool", ns); + inst = get_typed_instance(broker, refcn, "DiskPool", ns); if (asprintf(&poolid, "DiskPool/%s", id) == -1) return NULL; @@ -536,6 +555,7 @@ static CMPIStatus diskpool_instance(virC pool = diskpool_from_path(pools[i].path, pools[i].tag, ns, + pfx_from_conn(conn), broker); if (pool != NULL) inst_list_add(list, pool);

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499432 28800 # Node ID 3b7ec9c6323372f82fcad5be76faec50de401b6e # Parent 0912b735d6a65db09f6f9e671bc7cccd5122532c Fix uses of get_typed_*() in SettingsDefineCapabilities Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 0912b735d6a6 -r 3b7ec9c63233 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Nov 19 11:09:36 2007 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Mon Nov 19 11:10:32 2007 -0800 @@ -706,6 +706,7 @@ static CMPIInstance *sdc_rasd_inst(const goto out; inst = get_typed_instance(broker, + CLASSNAME(ref), "ResourceAllocationSettingData", NAMESPACE(ref)); @@ -820,6 +821,7 @@ static CMPIInstance *make_ref(const CMPI return NULL; refinst = get_typed_instance(_BROKER, + CLASSNAME(ref), base, NAMESPACE(ref));

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499464 28800 # Node ID aee029ef5abcbfff7fd730698c145f742de4e218 # Parent 3b7ec9c6323372f82fcad5be76faec50de401b6e Fix uses of get_typed_*() in HostedResourcePool Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 3b7ec9c63233 -r aee029ef5abc src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Mon Nov 19 11:10:32 2007 -0800 +++ b/src/Virt_HostedResourcePool.c Mon Nov 19 11:11:04 2007 -0800 @@ -103,6 +103,7 @@ static CMPIInstance *make_ref(const CMPI base = class_base_name(info->assoc_class); refinst = get_typed_instance(_BROKER, + CLASSNAME(ref), base, NAMESPACE(ref)); if (refinst != NULL) {

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499513 28800 # Node ID b717a04e455cd5de99c549482339eb4e56c062d8 # Parent aee029ef5abcbfff7fd730698c145f742de4e218 Fix uses of get_typed_*() in ElementCapabilities Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r aee029ef5abc -r b717a04e455c src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Mon Nov 19 11:11:04 2007 -0800 +++ b/src/Virt_ElementCapabilities.c Mon Nov 19 11:11:53 2007 -0800 @@ -208,7 +208,9 @@ static CMPIStatus pool_to_alloc(const CM goto out; } - inst = get_typed_instance(_BROKER, "AllocationCapabilities", + inst = get_typed_instance(_BROKER, + CLASSNAME(ref), + "AllocationCapabilities", NAMESPACE(ref)); CMSetProperty(inst, "InstanceID", inst_id, CMPI_chars); @@ -240,6 +242,7 @@ static CMPIInstance *make_ref(const CMPI return NULL; refinst = get_typed_instance(_BROKER, + CLASSNAME(ref), base, NAMESPACE(ref));

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499568 28800 # Node ID c247a785f91edfe2b8a9f2467a44eaddaf2a43d3 # Parent b717a04e455cd5de99c549482339eb4e56c062d8 Fix uses of get_typed_*() in ResourcePoolConfigurationService Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r b717a04e455c -r c247a785f91e src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Mon Nov 19 11:11:53 2007 -0800 +++ b/src/Virt_ResourcePoolConfigurationService.c Mon Nov 19 11:12:48 2007 -0800 @@ -105,6 +105,7 @@ CMPIStatus rpcs_instance(const CMPIObjec goto out; inst = get_typed_instance(broker, + CLASSNAME(reference), "ResourcePoolConfigurationService", NAMESPACE(reference)); if (inst == NULL) {

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499623 28800 # Node ID ec6c39eba07cdfad02b87e66e6b82afb2e5de479 # Parent c247a785f91edfe2b8a9f2467a44eaddaf2a43d3 Fix uses of get_typed_*() in ResourcePoolConfigurationCapabilities Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r c247a785f91e -r ec6c39eba07c src/Virt_ResourcePoolConfigurationCapabilities.c --- a/src/Virt_ResourcePoolConfigurationCapabilities.c Mon Nov 19 11:12:48 2007 -0800 +++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Mon Nov 19 11:13:43 2007 -0800 @@ -54,6 +54,7 @@ static CMPIStatus get_rpc_cap(const CMPI CMPIInstance *inst; inst = get_typed_instance(broker, + CLASSNAME(reference), "ResourcePoolConfigurationCapabilities", NAMESPACE(reference)); if (inst == NULL)

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499659 28800 # Node ID 906da584d07d8b15e324222de57beeff241aca38 # Parent ec6c39eba07cdfad02b87e66e6b82afb2e5de479 Fix uses of get_typed_*() in VSSDComponent Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r ec6c39eba07c -r 906da584d07d src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Mon Nov 19 11:13:43 2007 -0800 +++ b/src/Virt_VSSDComponent.c Mon Nov 19 11:14:19 2007 -0800 @@ -160,6 +160,7 @@ static CMPIInstance *make_ref(const CMPI CMPIInstance *refinst = NULL; refinst = get_typed_instance(_BROKER, + CLASSNAME(ref), "VirtualSystemSettingDataComponent", NAMESPACE(ref));

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499692 28800 # Node ID ec285ccf09c150d0f7a374a650043cc46401fcc2 # Parent 906da584d07d8b15e324222de57beeff241aca38 Fix uses of get_typed_*() in SettingsDefineState Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 906da584d07d -r ec285ccf09c1 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Mon Nov 19 11:14:19 2007 -0800 +++ b/src/Virt_SettingsDefineState.c Mon Nov 19 11:14:52 2007 -0800 @@ -299,6 +299,7 @@ static CMPIInstance *make_ref(const CMPI CMPIInstance *refinst = NULL; refinst = get_typed_instance(_BROKER, + CLASSNAME(ref), "SettingsDefineState", NAMESPACE(ref));

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499722 28800 # Node ID 2669d79e2d2959da0de8d7709d66bad9fb36a2ec # Parent ec285ccf09c150d0f7a374a650043cc46401fcc2 Fix uses of get_typed_*() in ResourceAllocationFromPool Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r ec285ccf09c1 -r 2669d79e2d29 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Mon Nov 19 11:14:52 2007 -0800 +++ b/src/Virt_ResourceAllocationFromPool.c Mon Nov 19 11:15:22 2007 -0800 @@ -235,6 +235,7 @@ static CMPIInstance *make_ref(const CMPI CMPIInstance *refinst = NULL; refinst = get_typed_instance(_BROKER, + CLASSNAME(ref), "ResourceAllocationFromPool", NAMESPACE(ref));

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499766 28800 # Node ID 13dd8a2a47e9227b8cf34852914d6f1ca0d61db0 # Parent 2669d79e2d2959da0de8d7709d66bad9fb36a2ec Fix uses of get_typed_*() in ElementAllocatedFromPool Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 2669d79e2d29 -r 13dd8a2a47e9 src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Mon Nov 19 11:15:22 2007 -0800 +++ b/src/Virt_ElementAllocatedFromPool.c Mon Nov 19 11:16:06 2007 -0800 @@ -257,6 +257,7 @@ static CMPIInstance *make_ref(const CMPI CMPIInstance *refinst = NULL; refinst = get_typed_instance(_BROKER, + CLASSNAME(ref), "ElementAllocatedFromPool", NAMESPACE(ref));

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499818 28800 # Node ID 1911ceb455c3a0ed249e4d0eaad750ef8a46aaf8 # Parent 13dd8a2a47e9227b8cf34852914d6f1ca0d61db0 Fix uses of get_typed_*() in HostedService Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 13dd8a2a47e9 -r 1911ceb455c3 src/Virt_HostedService.c --- a/src/Virt_HostedService.c Mon Nov 19 11:16:06 2007 -0800 +++ b/src/Virt_HostedService.c Mon Nov 19 11:16:58 2007 -0800 @@ -89,6 +89,7 @@ static CMPIInstance *make_ref(const CMPI goto out; refinst = get_typed_instance(_BROKER, + CLASSNAME(ref), base, NAMESPACE(ref));

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195499849 28800 # Node ID 5cba4b046c9c91c502c93ce1042872f1eaeecb3b # Parent 1911ceb455c3a0ed249e4d0eaad750ef8a46aaf8 Fix uses of get_typed_*() in ElementSettingData Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 1911ceb455c3 -r 5cba4b046c9c src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Mon Nov 19 11:16:58 2007 -0800 +++ b/src/Virt_ElementSettingData.c Mon Nov 19 11:17:29 2007 -0800 @@ -97,6 +97,7 @@ static CMPIInstance *make_ref(const CMPI goto out; refinst = get_typed_instance(_BROKER, + CLASSNAME(ref), base, NAMESPACE(ref));

Dan Smith wrote:
This is a huge set that changes the semantics of get_typed_class() and get_typed_instance() to take a reference class name for proper typing. I have only smoke-tested it, but it fixes several issues with returning incorrectly-typed instances that I know of.
A healthy amount of testing would be appreciated :)
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
Once again tried to test every provider touched. Nice changes. =) +1 -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com

Dan Smith wrote:
This is a huge set that changes the semantics of get_typed_class() and get_typed_instance() to take a reference class name for proper typing. I have only smoke-tested it, but it fixes several issues with returning incorrectly-typed instances that I know of.
A healthy amount of testing would be appreciated :)
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
Applied and tested fine - nothing got broken. +1 Only patch #1 had some problems to apply, but nothing was rejected. The issues encountered before got not fixed. I'm even not sure, if they have already been there before this huge amount of patches. So I will investigate further into them ... try to send patches as soon as possible. -- 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