From fiuczy at linux.vnet.ibm.com Tue Feb 4 12:31:10 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Tue, 04 Feb 2014 13:31:10 +0100 Subject: [Libvirt-cim] [PATCH 2/6] libxkutil:pool_parsing: Coverity cleanups In-Reply-To: <1390419037-10777-3-git-send-email-jferlan@redhat.com> References: <1390419037-10777-1-git-send-email-jferlan@redhat.com> <1390419037-10777-3-git-send-email-jferlan@redhat.com> Message-ID: <52F0DD8E.4070905@linux.vnet.ibm.com> On 01/22/2014 08:30 PM, John Ferlan wrote: > A new version of Coverity found a number of issues: > > get_pool_from_xml(): FORWARD_NULL > parse_disk_pool(): RESOURCE_LEAK > - If parse_disk_pool() returned name == NULL, then the strdup() of > name into pool->id would dereference the NULL pointer leading to > a segfault. > > Furthermore parse_disk_pool() had a few issues. First the 'type_str' > could be NULL, so that needs to be checked. Second, 'type_str' was > never free()'d (the get_attr_value returns a strdup()'d value). > > Realizing all that resulted in a few extra changes to not strdup() > a value that we strdup()'d > > Eventually get_pool_from_xml() will return to get_disk_pool() which > returns to diskpool_set_capacity() or _new_volume_template() which > both error out when return value != 0 (although, I did change the > latter to be more explicit and match the former). > > Finally, even though the parsing of the element will only ever have > one "name" value - Coverity doesn't know that, so as a benign fix be > sure to not overwrite 'name' if "name" isn't already set. > > Signed-off-by: John Ferlan > --- > libxkutil/pool_parsing.c | 39 ++++++++++++++++++----------------- > src/Virt_SettingsDefineCapabilities.c | 2 +- > 2 files changed, 21 insertions(+), 20 deletions(-) > > diff --git a/libxkutil/pool_parsing.c b/libxkutil/pool_parsing.c > index 922ff32..80bd4ca 100644 > --- a/libxkutil/pool_parsing.c > +++ b/libxkutil/pool_parsing.c > @@ -194,15 +194,17 @@ char *get_disk_pool_type(uint16_t type) > > } > > -static const char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) > +static char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) > { > xmlNode **nodes = nsv->nodeTab; > xmlNode *child; > - const char *type_str = NULL; > - const char *name = NULL; > + char *type_str = NULL; > + char *name = NULL; > int type = 0; > > type_str = get_attr_value(nodes[0], "type"); > + if (type_str == NULL) > + return NULL; > > if (STREQC(type_str, "dir")) > type = DISK_POOL_DIR; > @@ -220,12 +222,15 @@ static const char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) > type = DISK_POOL_SCSI; > else > type = DISK_POOL_UNKNOWN; > + free(type_str); > > pool->pool_type = type; > - > + > for (child = nodes[0]->children; child != NULL; child = child->next) { > - if (XSTREQ(child->name, "name")) { > + if (XSTREQ(child->name, "name") && name == NULL) { > name = get_node_content(child); > + if (name == NULL) > + return NULL; > } else if (XSTREQ(child->name, "target")) > parse_disk_target(child, pool); > else if (XSTREQ(child->name, "source")) > @@ -238,14 +243,18 @@ static const char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) > int get_pool_from_xml(const char *xml, struct virt_pool *pool, int type) > { > int len; > - int ret = 0; > + int ret = 1; Isn't this a bug fix... beside a cleanup? Before the return value was always 0! It also changes the method get_disk_pool in Virt_DevicePool.c in its return value behavior in the same way. The usage of get_disk_pool in the method diskpool_set_capacity checks for the return value and being !=0 it is considered an error (Virt_DevicePool.c line 324). Doesn't that need to get changed in this patch? Even so you mention above in your description the two chained exploitation code pieces it seems that you fixed just one ... or did I miss something? > xmlDoc *xmldoc; > xmlXPathContext *xpathctx; > xmlXPathObject *xpathobj; > const xmlChar *xpathstr = (xmlChar *)"/pool"; > - const char *name; > > CU_DEBUG("Pool XML : %s", xml); > + > + /* FIXME: Add support for parsing network pools */ > + if (type == CIM_RES_TYPE_NET) > + return 0; > + > len = strlen(xml) + 1; > > if ((xmldoc = xmlParseMemory(xml, len)) == NULL) > @@ -257,22 +266,14 @@ int get_pool_from_xml(const char *xml, struct virt_pool *pool, int type) > if ((xpathobj = xmlXPathEvalExpression(xpathstr, xpathctx)) == NULL) > goto err3; > > - /* FIXME: Add support for parsing network pools */ > - if (type == CIM_RES_TYPE_NET) { > - ret = 0; > - goto err1; > - } > - > memset(pool, 0, sizeof(*pool)); > > - pool->type = CIM_RES_TYPE_DISK; > - name = parse_disk_pool(xpathobj->nodesetval, > - &(pool)->pool_info.disk); > - if (name == NULL) > + pool->type = CIM_RES_TYPE_DISK; > + pool->id = parse_disk_pool(xpathobj->nodesetval, > + &(pool)->pool_info.disk); > + if (pool->id != NULL) > ret = 0; > > - pool->id = strdup(name); > - > xmlXPathFreeObject(xpathobj); > err3: > xmlXPathFreeContext(xpathctx); > diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c > index fe16e3f..756e46b 100644 > --- a/src/Virt_SettingsDefineCapabilities.c > +++ b/src/Virt_SettingsDefineCapabilities.c > @@ -1376,7 +1376,7 @@ static CMPIStatus _new_volume_template(const CMPIObjectPath *ref, > } > > ret = get_disk_pool(poolptr, &pool); > - if (ret == 1) { > + if (ret != 0) { > virt_set_status(_BROKER, &s, > CMPI_RC_ERR_FAILED, > virStoragePoolGetConnect(poolptr), > src/Virt_DevicePool.c line 324 =! change seems to be missing. -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From fiuczy at linux.vnet.ibm.com Tue Feb 4 15:24:11 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Tue, 04 Feb 2014 16:24:11 +0100 Subject: [Libvirt-cim] [PATCH 1/6] VSMS: Coverity cleanups In-Reply-To: <1390419037-10777-2-git-send-email-jferlan@redhat.com> References: <1390419037-10777-1-git-send-email-jferlan@redhat.com> <1390419037-10777-2-git-send-email-jferlan@redhat.com> Message-ID: <52F1061B.60205@linux.vnet.ibm.com> On 01/22/2014 08:30 PM, John Ferlan wrote: > A new version of Coverity found a number of issues: > > parse_ip_address(): FORWARD_NULL > - Benign issue regarding how 'tmp_ip' was compared against NULL for > the IPv6 processing and then used blindly later when strdup()'ing > into *ip. Rather than use NULL check, compare against return of 1 > or more which indicates that something is there > > update_system_settings(): RESOURCE_LEAK > - The 'uuid' value was being leaked if strdup()'d. Also rather than > strdup()'g and strdup()'d value and risking failure, just assign the > initially strdup()'d value and reinitialize uuid to NULL > > fv_vssd_to_domain(): USE_AFTER_FREE > - The domain->os_info.fv.arch is free()'d only to be potentially > strdup()'d after processing the 'cu_get_str_prop()' for "Arch". > The complaint was that it was possible to not strdup() a new value > and thus possible to pass a free()'d value to get_default_machine(). > Passing a NULL is not an issue as that is checked. > > Additionally found by inspection, 'val' was not initialized to NULL, > so the setting of os_info.fv.arch may not be what was expected. Also, > after processing "Arch" it was not reinitialized to NULL so its > contents could potentially have been saved in os_info.fv.machine. > > Signed-off-by: John Ferlan > --- > src/Virt_VirtualSystemManagementService.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index 5c7238f..b624d8c 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -464,7 +464,7 @@ static int fv_vssd_to_domain(CMPIInstance *inst, > { > int ret = 1; > int retr; > - const char *val; > + const char *val = NULL; > const char *domtype = NULL; > const char *ostype = "hvm"; > struct capabilities *capsinfo = NULL; > @@ -494,6 +494,7 @@ static int fv_vssd_to_domain(CMPIInstance *inst, > } > > free(domain->os_info.fv.arch); > + domain->os_info.fv.arch = NULL; > retr = cu_get_str_prop(inst, "Arch", &val); > if (retr != CMPI_RC_OK) { > if (capsinfo != NULL) { /* set default */ > @@ -506,6 +507,8 @@ static int fv_vssd_to_domain(CMPIInstance *inst, > domain->os_info.fv.arch = strdup(val); > > free(domain->os_info.fv.machine); > + domain->os_info.fv.machine = NULL; > + val = NULL; > retr = cu_get_str_prop(inst, "Machine", &val); > if (retr != CMPI_RC_OK) { > if (capsinfo != NULL && domtype != NULL) { /* set default */ > @@ -1415,7 +1418,7 @@ static int parse_ip_address(const char *id, > if (strstr(id, "[") != NULL) { > /* its an ipv6 address */ > ret = sscanf(id, "%a[^]]]:%as", &tmp_ip, &tmp_port); > - if (tmp_ip != NULL) { > + if (ret >= 1) { > tmp_ip = realloc(tmp_ip, strlen(tmp_ip) + 2); > if (tmp_ip == NULL) { > ret = 0; > @@ -2798,7 +2801,8 @@ static CMPIStatus update_system_settings(const CMPIContext *context, > } > > if ((dominfo->uuid == NULL) || (STREQ(dominfo->uuid, ""))) { > - dominfo->uuid = strdup(uuid); > + dominfo->uuid = uuid; > + uuid = NULL; I am getting a compile error here and below for the free of uuid. error: assignment discards 'const' qualifier from pointer target type [-Werror] error: passing argument 1 of 'free' discards 'const' qualifier from pointer target type [-Werror] Removing the const in the declaration works... for me. > } else if (!STREQ(uuid, dominfo->uuid)) { > cu_statusf(_BROKER, &s, > CMPI_RC_ERR_FAILED, > @@ -2829,6 +2833,7 @@ static CMPIStatus update_system_settings(const CMPIContext *context, > } > > out: > + free(uuid); > free(xml); > virDomainFree(dom); > virConnectClose(conn); > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Wed Feb 5 13:14:19 2014 From: jferlan at redhat.com (John Ferlan) Date: Wed, 05 Feb 2014 08:14:19 -0500 Subject: [Libvirt-cim] [PATCH 1/6] VSMS: Coverity cleanups In-Reply-To: <52F1061B.60205@linux.vnet.ibm.com> References: <1390419037-10777-1-git-send-email-jferlan@redhat.com> <1390419037-10777-2-git-send-email-jferlan@redhat.com> <52F1061B.60205@linux.vnet.ibm.com> Message-ID: <52F2392B.8040201@redhat.com> On 02/04/2014 10:24 AM, Boris Fiuczynski wrote: > On 01/22/2014 08:30 PM, John Ferlan wrote: <...snip...> >> @@ -2798,7 +2801,8 @@ static CMPIStatus update_system_settings(const CMPIContext *context, >> } >> >> if ((dominfo->uuid == NULL) || (STREQ(dominfo->uuid, ""))) { >> - dominfo->uuid = strdup(uuid); >> + dominfo->uuid = uuid; >> + uuid = NULL; > I am getting a compile error here and below for the free of uuid. > error: assignment discards 'const' qualifier from pointer target type > [-Werror] > error: passing argument 1 of 'free' discards 'const' qualifier from > pointer target type [-Werror] > > Removing the const in the declaration works... for me. > Strange - mine didn't complain, but one would also think that the prior code doing a uuid = strdup(dominfo->uuid); would elicit the same issue! Anyway, adjusted the definition from "const char *uuid" to just "char *uuid". In actually reading and thinking about the code, do you think a "free(dominfo->uuid);" prior to the setting should be added too? In the event it was the empty string? Not sure how it gets set that way, but since cleanup_dominfo() would free() it if it was "" or whatever real value is, then I suppose better safe than sorry. Tks, John >> } else if (!STREQ(uuid, dominfo->uuid)) { >> cu_statusf(_BROKER, &s, >> CMPI_RC_ERR_FAILED, >> @@ -2829,6 +2833,7 @@ static CMPIStatus update_system_settings(const CMPIContext *context, >> } >> >> out: >> + free(uuid); >> free(xml); >> virDomainFree(dom); >> virConnectClose(conn); >> > > From jferlan at redhat.com Wed Feb 5 14:08:26 2014 From: jferlan at redhat.com (John Ferlan) Date: Wed, 05 Feb 2014 09:08:26 -0500 Subject: [Libvirt-cim] [PATCH 2/6] libxkutil:pool_parsing: Coverity cleanups In-Reply-To: <52F0DD8E.4070905@linux.vnet.ibm.com> References: <1390419037-10777-1-git-send-email-jferlan@redhat.com> <1390419037-10777-3-git-send-email-jferlan@redhat.com> <52F0DD8E.4070905@linux.vnet.ibm.com> Message-ID: <52F245DA.2030806@redhat.com> On 02/04/2014 07:31 AM, Boris Fiuczynski wrote: > On 01/22/2014 08:30 PM, John Ferlan wrote: >> A new version of Coverity found a number of issues: >> >> get_pool_from_xml(): FORWARD_NULL >> parse_disk_pool(): RESOURCE_LEAK >> - If parse_disk_pool() returned name == NULL, then the strdup() of >> name into pool->id would dereference the NULL pointer leading to >> a segfault. >> >> Furthermore parse_disk_pool() had a few issues. First the 'type_str' >> could be NULL, so that needs to be checked. Second, 'type_str' was >> never free()'d (the get_attr_value returns a strdup()'d value). >> >> Realizing all that resulted in a few extra changes to not strdup() >> a value that we strdup()'d >> >> Eventually get_pool_from_xml() will return to get_disk_pool() which >> returns to diskpool_set_capacity() or _new_volume_template() which >> both error out when return value != 0 (although, I did change the >> latter to be more explicit and match the former). >> >> Finally, even though the parsing of the element will only ever have >> one "name" value - Coverity doesn't know that, so as a benign fix be >> sure to not overwrite 'name' if "name" isn't already set. >> >> Signed-off-by: John Ferlan >> --- >> libxkutil/pool_parsing.c | 39 ++++++++++++++++++----------------- >> src/Virt_SettingsDefineCapabilities.c | 2 +- >> 2 files changed, 21 insertions(+), 20 deletions(-) >> >> diff --git a/libxkutil/pool_parsing.c b/libxkutil/pool_parsing.c >> index 922ff32..80bd4ca 100644 >> --- a/libxkutil/pool_parsing.c >> +++ b/libxkutil/pool_parsing.c >> @@ -194,15 +194,17 @@ char *get_disk_pool_type(uint16_t type) >> >> } >> >> -static const char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) >> +static char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) >> { >> xmlNode **nodes = nsv->nodeTab; >> xmlNode *child; >> - const char *type_str = NULL; >> - const char *name = NULL; >> + char *type_str = NULL; >> + char *name = NULL; >> int type = 0; >> >> type_str = get_attr_value(nodes[0], "type"); >> + if (type_str == NULL) >> + return NULL; >> >> if (STREQC(type_str, "dir")) >> type = DISK_POOL_DIR; >> @@ -220,12 +222,15 @@ static const char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) >> type = DISK_POOL_SCSI; >> else >> type = DISK_POOL_UNKNOWN; >> + free(type_str); >> >> pool->pool_type = type; >> - >> + >> for (child = nodes[0]->children; child != NULL; child = child->next) { >> - if (XSTREQ(child->name, "name")) { >> + if (XSTREQ(child->name, "name") && name == NULL) { >> name = get_node_content(child); >> + if (name == NULL) >> + return NULL; >> } else if (XSTREQ(child->name, "target")) >> parse_disk_target(child, pool); >> else if (XSTREQ(child->name, "source")) >> @@ -238,14 +243,18 @@ static const char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) >> int get_pool_from_xml(const char *xml, struct virt_pool *pool, int type) >> { >> int len; >> - int ret = 0; >> + int ret = 1; > Isn't this a bug fix... beside a cleanup? Before the return value was > always 0! It also changes the method get_disk_pool in Virt_DevicePool.c > in its return value behavior in the same way. True - a bug fix insomuch as either caller is concerned, but yet still found by Coverity as a RESOURCE_LEAK initially and then me as I was reading the code... I think the primary way to hit the bug would have been through a *alloc()/strdup() failure though. > The usage of get_disk_pool in the method diskpool_set_capacity checks > for the return value and being !=0 it is considered an error > (Virt_DevicePool.c line 324). Doesn't that need to get changed in this > patch? I don't think so. Prior to my change/cleanup if anything failed in get_pool_from_xml(), then diskpool_set_capacity() could wrongly or even partially set the properties for "Path", "Host", "SourceDirectory", and "OtherResourceType". Although perhaps only the type would be wrong, since all others actually check for non NULL fields before strdup() and CMSetProperty() calls. Thus perhaps "path" could be set, but host and source directory not due to memory constraints, or some combination of the 3. Probably not a good thing to be happening. Of course there are those that contend that if you're that memory constrained, the code isn't going much further anyway... In any case, all my change does is acknowledge and return the failure which the caller already handled properly. FWIW: For context Line 324 in diskpool_set_capacity(): if (get_disk_pool(pool, &pool_vals) != 0) { CU_DEBUG("Error getting pool path for: %s", _pool->tag); } else { if (pool_vals->pool_info.disk.path != NULL) { pool_str = strdup(pool_vals->pool_info.disk.path); CMSetProperty(inst, "Path", (CMPIValue *)pool_str, CMPI_chars); } ... > Even so you mention above in your description the two chained > exploitation code pieces it seems that you fixed just one ... or did I > miss something? > The reason for the change in _new_volume_template() was to match the return comparison from diskpool_set_capacity()... It's unnecessary technically. One used to fail on "ret == 1" and the other when "ret != 0". Now both fail in the ret != 0 case. It's the "Type A personality" in me that does that. John >> xmlDoc *xmldoc; >> xmlXPathContext *xpathctx; >> xmlXPathObject *xpathobj; >> const xmlChar *xpathstr = (xmlChar *)"/pool"; >> - const char *name; >> >> CU_DEBUG("Pool XML : %s", xml); >> + >> + /* FIXME: Add support for parsing network pools */ >> + if (type == CIM_RES_TYPE_NET) >> + return 0; >> + >> len = strlen(xml) + 1; >> >> if ((xmldoc = xmlParseMemory(xml, len)) == NULL) >> @@ -257,22 +266,14 @@ int get_pool_from_xml(const char *xml, struct virt_pool *pool, int type) >> if ((xpathobj = xmlXPathEvalExpression(xpathstr, xpathctx)) == NULL) >> goto err3; >> >> - /* FIXME: Add support for parsing network pools */ >> - if (type == CIM_RES_TYPE_NET) { >> - ret = 0; >> - goto err1; >> - } >> - >> memset(pool, 0, sizeof(*pool)); >> >> - pool->type = CIM_RES_TYPE_DISK; >> - name = parse_disk_pool(xpathobj->nodesetval, >> - &(pool)->pool_info.disk); >> - if (name == NULL) >> + pool->type = CIM_RES_TYPE_DISK; >> + pool->id = parse_disk_pool(xpathobj->nodesetval, >> + &(pool)->pool_info.disk); >> + if (pool->id != NULL) >> ret = 0; >> >> - pool->id = strdup(name); >> - >> xmlXPathFreeObject(xpathobj); >> err3: >> xmlXPathFreeContext(xpathctx); >> diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c >> index fe16e3f..756e46b 100644 >> --- a/src/Virt_SettingsDefineCapabilities.c >> +++ b/src/Virt_SettingsDefineCapabilities.c >> @@ -1376,7 +1376,7 @@ static CMPIStatus _new_volume_template(const CMPIObjectPath *ref, >> } >> >> ret = get_disk_pool(poolptr, &pool); >> - if (ret == 1) { >> + if (ret != 0) { >> virt_set_status(_BROKER, &s, >> CMPI_RC_ERR_FAILED, >> virStoragePoolGetConnect(poolptr), >> > src/Virt_DevicePool.c line 324 =! change seems to be missing. > > From fiuczy at linux.vnet.ibm.com Wed Feb 5 15:43:59 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Wed, 05 Feb 2014 16:43:59 +0100 Subject: [Libvirt-cim] [PATCH 1/6] VSMS: Coverity cleanups In-Reply-To: <52F2392B.8040201@redhat.com> References: <1390419037-10777-1-git-send-email-jferlan@redhat.com> <1390419037-10777-2-git-send-email-jferlan@redhat.com> <52F1061B.60205@linux.vnet.ibm.com> <52F2392B.8040201@redhat.com> Message-ID: <52F25C3F.5000301@linux.vnet.ibm.com> On 02/05/2014 02:14 PM, John Ferlan wrote: > > > On 02/04/2014 10:24 AM, Boris Fiuczynski wrote: >> On 01/22/2014 08:30 PM, John Ferlan wrote: > > <...snip...> > >>> @@ -2798,7 +2801,8 @@ static CMPIStatus update_system_settings(const CMPIContext *context, >>> } >>> >>> if ((dominfo->uuid == NULL) || (STREQ(dominfo->uuid, ""))) { >>> - dominfo->uuid = strdup(uuid); >>> + dominfo->uuid = uuid; >>> + uuid = NULL; >> I am getting a compile error here and below for the free of uuid. >> error: assignment discards 'const' qualifier from pointer target type >> [-Werror] >> error: passing argument 1 of 'free' discards 'const' qualifier from >> pointer target type [-Werror] >> >> Removing the const in the declaration works... for me. >> > > Strange - mine didn't complain, but one would also think that the prior > code doing a uuid = strdup(dominfo->uuid); would elicit the same issue! > > Anyway, adjusted the definition from "const char *uuid" to just "char > *uuid". > > In actually reading and thinking about the code, do you think a > "free(dominfo->uuid);" prior to the setting should be added too? In the > event it was the empty string? Not sure how it gets set that way, but > since cleanup_dominfo() would free() it if it was "" or whatever real > value is, then I suppose better safe than sorry. Yeah, to be 100% sure I guess just freeing it is ok... :-) > > Tks, > > John >>> } else if (!STREQ(uuid, dominfo->uuid)) { >>> cu_statusf(_BROKER, &s, >>> CMPI_RC_ERR_FAILED, >>> @@ -2829,6 +2833,7 @@ static CMPIStatus update_system_settings(const CMPIContext *context, >>> } >>> >>> out: >>> + free(uuid); >>> free(xml); >>> virDomainFree(dom); >>> virConnectClose(conn); >>> >> >> > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From fiuczy at linux.vnet.ibm.com Wed Feb 5 16:04:34 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Wed, 05 Feb 2014 17:04:34 +0100 Subject: [Libvirt-cim] [PATCH 2/6] libxkutil:pool_parsing: Coverity cleanups In-Reply-To: <52F245DA.2030806@redhat.com> References: <1390419037-10777-1-git-send-email-jferlan@redhat.com> <1390419037-10777-3-git-send-email-jferlan@redhat.com> <52F0DD8E.4070905@linux.vnet.ibm.com> <52F245DA.2030806@redhat.com> Message-ID: <52F26112.2040404@linux.vnet.ibm.com> On 02/05/2014 03:08 PM, John Ferlan wrote: > > > On 02/04/2014 07:31 AM, Boris Fiuczynski wrote: >> On 01/22/2014 08:30 PM, John Ferlan wrote: >>> A new version of Coverity found a number of issues: >>> >>> get_pool_from_xml(): FORWARD_NULL >>> parse_disk_pool(): RESOURCE_LEAK >>> - If parse_disk_pool() returned name == NULL, then the strdup() of >>> name into pool->id would dereference the NULL pointer leading to >>> a segfault. >>> >>> Furthermore parse_disk_pool() had a few issues. First the 'type_str' >>> could be NULL, so that needs to be checked. Second, 'type_str' was >>> never free()'d (the get_attr_value returns a strdup()'d value). >>> >>> Realizing all that resulted in a few extra changes to not strdup() >>> a value that we strdup()'d >>> >>> Eventually get_pool_from_xml() will return to get_disk_pool() which >>> returns to diskpool_set_capacity() or _new_volume_template() which >>> both error out when return value != 0 (although, I did change the >>> latter to be more explicit and match the former). >>> >>> Finally, even though the parsing of the element will only ever have >>> one "name" value - Coverity doesn't know that, so as a benign fix be >>> sure to not overwrite 'name' if "name" isn't already set. >>> >>> Signed-off-by: John Ferlan >>> --- >>> libxkutil/pool_parsing.c | 39 ++++++++++++++++++----------------- >>> src/Virt_SettingsDefineCapabilities.c | 2 +- >>> 2 files changed, 21 insertions(+), 20 deletions(-) >>> >>> diff --git a/libxkutil/pool_parsing.c b/libxkutil/pool_parsing.c >>> index 922ff32..80bd4ca 100644 >>> --- a/libxkutil/pool_parsing.c >>> +++ b/libxkutil/pool_parsing.c >>> @@ -194,15 +194,17 @@ char *get_disk_pool_type(uint16_t type) >>> >>> } >>> >>> -static const char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) >>> +static char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) >>> { >>> xmlNode **nodes = nsv->nodeTab; >>> xmlNode *child; >>> - const char *type_str = NULL; >>> - const char *name = NULL; >>> + char *type_str = NULL; >>> + char *name = NULL; >>> int type = 0; >>> >>> type_str = get_attr_value(nodes[0], "type"); >>> + if (type_str == NULL) >>> + return NULL; >>> >>> if (STREQC(type_str, "dir")) >>> type = DISK_POOL_DIR; >>> @@ -220,12 +222,15 @@ static const char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) >>> type = DISK_POOL_SCSI; >>> else >>> type = DISK_POOL_UNKNOWN; >>> + free(type_str); >>> >>> pool->pool_type = type; >>> - >>> + >>> for (child = nodes[0]->children; child != NULL; child = child->next) { >>> - if (XSTREQ(child->name, "name")) { >>> + if (XSTREQ(child->name, "name") && name == NULL) { >>> name = get_node_content(child); >>> + if (name == NULL) >>> + return NULL; >>> } else if (XSTREQ(child->name, "target")) >>> parse_disk_target(child, pool); >>> else if (XSTREQ(child->name, "source")) >>> @@ -238,14 +243,18 @@ static const char *parse_disk_pool(xmlNodeSet *nsv, struct disk_pool *pool) >>> int get_pool_from_xml(const char *xml, struct virt_pool *pool, int type) >>> { >>> int len; >>> - int ret = 0; >>> + int ret = 1; >> Isn't this a bug fix... beside a cleanup? Before the return value was >> always 0! It also changes the method get_disk_pool in Virt_DevicePool.c >> in its return value behavior in the same way. > > True - a bug fix insomuch as either caller is concerned, but yet still > found by Coverity as a RESOURCE_LEAK initially and then me as I was > reading the code... I think the primary way to hit the bug would have > been through a *alloc()/strdup() failure though. > >> The usage of get_disk_pool in the method diskpool_set_capacity checks >> for the return value and being !=0 it is considered an error >> (Virt_DevicePool.c line 324). Doesn't that need to get changed in this >> patch? > > I don't think so. Prior to my change/cleanup if anything failed in > get_pool_from_xml(), then diskpool_set_capacity() could wrongly or even > partially set the properties for "Path", "Host", "SourceDirectory", and > "OtherResourceType". Although perhaps only the type would be wrong, > since all others actually check for non NULL fields before strdup() and > CMSetProperty() calls. Thus perhaps "path" could be set, but host and > source directory not due to memory constraints, or some combination of > the 3. Probably not a good thing to be happening. Of course there are > those that contend that if you're that memory constrained, the code > isn't going much further anyway... > > In any case, all my change does is acknowledge and return the failure > which the caller already handled properly. > > FWIW: For context > > Line 324 in diskpool_set_capacity(): > > if (get_disk_pool(pool, &pool_vals) != 0) { > CU_DEBUG("Error getting pool path for: %s", _pool->tag); > } else { > if (pool_vals->pool_info.disk.path != NULL) { > pool_str = strdup(pool_vals->pool_info.disk.path); > CMSetProperty(inst, "Path", > (CMPIValue *)pool_str, CMPI_chars); > } > ... > Sorry, but you are right. I missed one line in get_pool_from_xml that screwed up my logic. Works fine. I also did run cimtest on my system and it remained the same. > >> Even so you mention above in your description the two chained >> exploitation code pieces it seems that you fixed just one ... or did I >> miss something? >> > > The reason for the change in _new_volume_template() was to match the > return comparison from diskpool_set_capacity()... It's unnecessary > technically. One used to fail on "ret == 1" and the other when "ret != > 0". Now both fail in the ret != 0 case. It's the "Type A personality" > in me that does that. > > John > > > >>> xmlDoc *xmldoc; >>> xmlXPathContext *xpathctx; >>> xmlXPathObject *xpathobj; >>> const xmlChar *xpathstr = (xmlChar *)"/pool"; >>> - const char *name; >>> >>> CU_DEBUG("Pool XML : %s", xml); >>> + >>> + /* FIXME: Add support for parsing network pools */ >>> + if (type == CIM_RES_TYPE_NET) >>> + return 0; >>> + >>> len = strlen(xml) + 1; >>> >>> if ((xmldoc = xmlParseMemory(xml, len)) == NULL) >>> @@ -257,22 +266,14 @@ int get_pool_from_xml(const char *xml, struct virt_pool *pool, int type) >>> if ((xpathobj = xmlXPathEvalExpression(xpathstr, xpathctx)) == NULL) >>> goto err3; >>> >>> - /* FIXME: Add support for parsing network pools */ >>> - if (type == CIM_RES_TYPE_NET) { >>> - ret = 0; >>> - goto err1; >>> - } >>> - >>> memset(pool, 0, sizeof(*pool)); >>> >>> - pool->type = CIM_RES_TYPE_DISK; >>> - name = parse_disk_pool(xpathobj->nodesetval, >>> - &(pool)->pool_info.disk); >>> - if (name == NULL) >>> + pool->type = CIM_RES_TYPE_DISK; >>> + pool->id = parse_disk_pool(xpathobj->nodesetval, >>> + &(pool)->pool_info.disk); >>> + if (pool->id != NULL) >>> ret = 0; >>> >>> - pool->id = strdup(name); >>> - >>> xmlXPathFreeObject(xpathobj); >>> err3: >>> xmlXPathFreeContext(xpathctx); >>> diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c >>> index fe16e3f..756e46b 100644 >>> --- a/src/Virt_SettingsDefineCapabilities.c >>> +++ b/src/Virt_SettingsDefineCapabilities.c >>> @@ -1376,7 +1376,7 @@ static CMPIStatus _new_volume_template(const CMPIObjectPath *ref, >>> } >>> >>> ret = get_disk_pool(poolptr, &pool); >>> - if (ret == 1) { >>> + if (ret != 0) { >>> virt_set_status(_BROKER, &s, >>> CMPI_RC_ERR_FAILED, >>> virStoragePoolGetConnect(poolptr), >>> >> src/Virt_DevicePool.c line 324 =! change seems to be missing. >> >> > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Wed Feb 5 18:20:58 2014 From: jferlan at redhat.com (John Ferlan) Date: Wed, 05 Feb 2014 13:20:58 -0500 Subject: [Libvirt-cim] [PATCH 0/6] Coverity cleanups In-Reply-To: <1390419037-10777-1-git-send-email-jferlan@redhat.com> References: <1390419037-10777-1-git-send-email-jferlan@redhat.com> Message-ID: <52F2810A.7050509@redhat.com> On 01/22/2014 02:30 PM, John Ferlan wrote: > A recent Coverity version update discovered some existing issues (and some > benign cases). This patch set cleans them all up. > > John Ferlan (6): > VSMS: Coverity cleanups > libxkutil:pool_parsing: Coverity cleanups > libxkutil:device_parsing: Coverity cleanups > libxkutil/xml_parse_test: Coverity cleanup > RAFP: Coverity cleanup > EAFP: Coverity cleanup > > libxkutil/device_parsing.c | 41 +++++++++++++++++-------------- > libxkutil/pool_parsing.c | 39 +++++++++++++++-------------- > libxkutil/xml_parse_test.c | 1 + > src/Virt_ElementAllocatedFromPool.c | 6 ++++- > src/Virt_ResourceAllocationFromPool.c | 7 ++++-- > src/Virt_SettingsDefineCapabilities.c | 2 +- > src/Virt_VirtualSystemManagementService.c | 11 ++++++--- > 7 files changed, 63 insertions(+), 44 deletions(-) > Patch 1 & 2 are now pushed. Tks, John From jmiao at redhat.com Wed Feb 12 09:15:20 2014 From: jmiao at redhat.com (Jincheng Miao) Date: Wed, 12 Feb 2014 04:15:20 -0500 (EST) Subject: [Libvirt-cim] About provProcs value problem for sblim-sfcb cim server In-Reply-To: <1699985203.2559729.1392195779054.JavaMail.zimbra@redhat.com> Message-ID: <846872987.2567004.1392196520908.JavaMail.zimbra@redhat.com> Hi all, I met a problem for sblim-sfcb cim server. In the configuration file, the default value of 'provProcs' is 32. While running cimtest, there are many failed cases with error "Provider not found or not loadable", eg: HostedAccessPoint - 01_forward.py: FAIL ERROR - No kvmrsap instance returned Provider not found or not loadable -------------------------------------------------------------------- HostedAccessPoint - 02_reverse.py: FAIL ERROR - No kvmrsap instance returned Provider not found or not loadable -------------------------------------------------------------------- After I change the value of 'provProcs' to 64, these cases pass. The provProcs is 'Max number of provider processes', and http://doc.opensuse.org/products/draft/SLES/SLES-admin_sd_draft/cha.wbem.html#sec.wbem.config.confile.9 said 'if a new incoming request requires loading a new provider, then one of the existing providers will first be automatically unloaded' So I am wondering that why does sblim-sfcb not automatically unload the existing providers, and load the specified provider for case 'HostedAccessPoint - 01_forward.py'. Is it a real problem? From mihajlov at linux.vnet.ibm.com Fri Feb 14 09:26:33 2014 From: mihajlov at linux.vnet.ibm.com (Viktor Mihajlovski) Date: Fri, 14 Feb 2014 10:26:33 +0100 Subject: [Libvirt-cim] About provProcs value problem for sblim-sfcb cim server In-Reply-To: <846872987.2567004.1392196520908.JavaMail.zimbra@redhat.com> References: <846872987.2567004.1392196520908.JavaMail.zimbra@redhat.com> Message-ID: <52FDE149.5020406@linux.vnet.ibm.com> On 02/12/2014 10:15 AM, Jincheng Miao wrote: > Hi all, > > I met a problem for sblim-sfcb cim server. > In the configuration file, the default value of 'provProcs' is 32. While running cimtest, > there are many failed cases with error "Provider not found or not loadable", eg: > > HostedAccessPoint - 01_forward.py: FAIL > ERROR - No kvmrsap instance returned > Provider not found or not loadable > -------------------------------------------------------------------- > HostedAccessPoint - 02_reverse.py: FAIL > ERROR - No kvmrsap instance returned > Provider not found or not loadable > -------------------------------------------------------------------- > > After I change the value of 'provProcs' to 64, these cases pass. > > The provProcs is 'Max number of provider processes', and > http://doc.opensuse.org/products/draft/SLES/SLES-admin_sd_draft/cha.wbem.html#sec.wbem.config.confile.9 > said 'if a new incoming request requires loading a new provider, > then one of the existing providers will first be automatically unloaded' > > So I am wondering that why does sblim-sfcb not automatically unload the existing providers, > and load the specified provider for case 'HostedAccessPoint - 01_forward.py'. > > Is it a real problem? the crux lies in the usage of the libcmpiutil DEFAULT_INST_CLEANUP macro which prevents the provider from being unloaded. sfcb doesn't unload providers forcibly by design, so it is not bug. In the long run, it would probably be desirable to allow the unloading of the libvirt-cim providers. For now, the number of processes would need to be increased. -- Mit freundlichen Gr??en/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Mon Feb 17 19:40:50 2014 From: jferlan at redhat.com (John Ferlan) Date: Mon, 17 Feb 2014 14:40:50 -0500 Subject: [Libvirt-cim] [PATCH 0/6] Coverity cleanups In-Reply-To: <1390419037-10777-1-git-send-email-jferlan@redhat.com> References: <1390419037-10777-1-git-send-email-jferlan@redhat.com> Message-ID: <530265C2.3000304@redhat.com> On 01/22/2014 02:30 PM, John Ferlan wrote: > A recent Coverity version update discovered some existing issues (and some > benign cases). This patch set cleans them all up. > > John Ferlan (6): > VSMS: Coverity cleanups > libxkutil:pool_parsing: Coverity cleanups > libxkutil:device_parsing: Coverity cleanups > libxkutil/xml_parse_test: Coverity cleanup > RAFP: Coverity cleanup > EAFP: Coverity cleanup > > libxkutil/device_parsing.c | 41 +++++++++++++++++-------------- > libxkutil/pool_parsing.c | 39 +++++++++++++++-------------- > libxkutil/xml_parse_test.c | 1 + > src/Virt_ElementAllocatedFromPool.c | 6 ++++- > src/Virt_ResourceAllocationFromPool.c | 7 ++++-- > src/Virt_SettingsDefineCapabilities.c | 2 +- > src/Virt_VirtualSystemManagementService.c | 11 ++++++--- > 7 files changed, 63 insertions(+), 44 deletions(-) > Ping? Any thoughts/comments on patches 3 -> 7? Tks, John From fiuczy at linux.vnet.ibm.com Tue Feb 18 13:56:54 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Tue, 18 Feb 2014 14:56:54 +0100 Subject: [Libvirt-cim] [PATCH 0/6] Coverity cleanups In-Reply-To: <530265C2.3000304@redhat.com> References: <1390419037-10777-1-git-send-email-jferlan@redhat.com> <530265C2.3000304@redhat.com> Message-ID: <530366A6.30504@linux.vnet.ibm.com> On 02/17/2014 08:40 PM, John Ferlan wrote: > > > On 01/22/2014 02:30 PM, John Ferlan wrote: >> A recent Coverity version update discovered some existing issues (and some >> benign cases). This patch set cleans them all up. >> >> John Ferlan (6): >> VSMS: Coverity cleanups >> libxkutil:pool_parsing: Coverity cleanups >> libxkutil:device_parsing: Coverity cleanups >> libxkutil/xml_parse_test: Coverity cleanup >> RAFP: Coverity cleanup >> EAFP: Coverity cleanup >> >> libxkutil/device_parsing.c | 41 +++++++++++++++++-------------- >> libxkutil/pool_parsing.c | 39 +++++++++++++++-------------- >> libxkutil/xml_parse_test.c | 1 + >> src/Virt_ElementAllocatedFromPool.c | 6 ++++- >> src/Virt_ResourceAllocationFromPool.c | 7 ++++-- >> src/Virt_SettingsDefineCapabilities.c | 2 +- >> src/Virt_VirtualSystemManagementService.c | 11 ++++++--- >> 7 files changed, 63 insertions(+), 44 deletions(-) >> > > Ping? Any thoughts/comments on patches 3 -> 7? Look OK to me. Sorry, for the late answer. Distraction made me forget to send you a response on these. -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Tue Feb 18 18:16:47 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 18 Feb 2014 13:16:47 -0500 Subject: [Libvirt-cim] [PATCH 0/6] Coverity cleanups In-Reply-To: <530366A6.30504@linux.vnet.ibm.com> References: <1390419037-10777-1-git-send-email-jferlan@redhat.com> <530265C2.3000304@redhat.com> <530366A6.30504@linux.vnet.ibm.com> Message-ID: <5303A38F.8050702@redhat.com> On 02/18/2014 08:56 AM, Boris Fiuczynski wrote: > On 02/17/2014 08:40 PM, John Ferlan wrote: >> >> >> On 01/22/2014 02:30 PM, John Ferlan wrote: >>> A recent Coverity version update discovered some existing issues (and some >>> benign cases). This patch set cleans them all up. >>> >>> John Ferlan (6): >>> VSMS: Coverity cleanups >>> libxkutil:pool_parsing: Coverity cleanups >>> libxkutil:device_parsing: Coverity cleanups >>> libxkutil/xml_parse_test: Coverity cleanup >>> RAFP: Coverity cleanup >>> EAFP: Coverity cleanup >>> >>> libxkutil/device_parsing.c | 41 +++++++++++++++++-------------- >>> libxkutil/pool_parsing.c | 39 +++++++++++++++-------------- >>> libxkutil/xml_parse_test.c | 1 + >>> src/Virt_ElementAllocatedFromPool.c | 6 ++++- >>> src/Virt_ResourceAllocationFromPool.c | 7 ++++-- >>> src/Virt_SettingsDefineCapabilities.c | 2 +- >>> src/Virt_VirtualSystemManagementService.c | 11 ++++++--- >>> 7 files changed, 63 insertions(+), 44 deletions(-) >>> >> >> Ping? Any thoughts/comments on patches 3 -> 7? > Look OK to me. Sorry, for the late answer. Distraction made me forget to > send you a response on these. > > Great - thanks. These are now pushed. John From jferlan at redhat.com Tue Feb 18 22:41:43 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 18 Feb 2014 17:41:43 -0500 Subject: [Libvirt-cim] [PATCH] Use of root/interop instead of root/PG_InterOp Message-ID: <1392763303-21091-1-git-send-email-jferlan@redhat.com> As of tog-pegasus 2.12.1-5 we can no longer use "root/PG_InterOp" namespace for the CIM provider instead the use of "root/interop" is the preferred mechanism. This patch will adjust where libvirt-cim installs its classes to use the "root/interop" namespace. For more context, see: http://www.redhat.com/archives/libvirt-cim/2013-November/msg00083.html and http://www.redhat.com/archives/libvirt-cim/2013-November/msg00008.html This patch will be required for RHEL7 which fails to install with the base 0.6.3 release. Signed-off-by: John Ferlan --- Makefile.am | 29 ++++++++++++++++++++++++----- libvirt-cim.spec.in | 27 ++++++++++++++++++++++----- provider-register.sh | 18 +++++++++++++++++- 3 files changed, 63 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9e8e96b..69b65cf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -78,6 +78,9 @@ INTEROP_MOFS = \ $(top_srcdir)/schema/ReferencedProfile.mof \ $(top_srcdir)/schema/AllocationCapabilities.mof +# The PGINTEROP_MOFS are used by tog-pegasus up through version 2.12.1 +# If support for versions prior to 2.12.1 is removed, then these defs +# can go away PGINTEROP_MOFS = \ $(top_srcdir)/schema/RegisteredProfile.mof \ $(top_srcdir)/schema/ElementConformsToProfile.mof \ @@ -157,6 +160,9 @@ INTEROP_REGS = \ $(top_srcdir)/schema/ElementConformsToProfile.registration \ $(top_srcdir)/schema/ReferencedProfile.registration +# The PGINTEROP_REGS are used by tog-pegasus up through version 2.12.1 +# If support for versions prior to 2.12.1 is removed, then these defs +# can go away PGINTEROP_REGS = \ $(top_srcdir)/schema/RegisteredProfile.registration \ $(top_srcdir)/schema/ElementConformsToProfile.registration \ @@ -181,7 +187,8 @@ EXTRA_DIST = schema $(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS) \ .changeset .revision \ examples/diskpool.conf -# If Pegasus isn't the CIMOM target, then remove the PG_InterOp namespace from the appropriate files +# If Pegasus isn't the CIMOM target, then remove the PG_InterOp namespace +# from the appropriate files install-data-local: $(mkinstalldirs) "$(DESTDIR)$(pkgdatadir)" $(install_sh_DATA) -t "$(DESTDIR)$(pkgdatadir)" $(MOFS) @@ -189,11 +196,12 @@ install-data-local: $(install_sh_DATA) -t "$(DESTDIR)$(pkgdatadir)" $(INTEROP_MOFS) $(install_sh_DATA) -t "$(DESTDIR)$(pkgdatadir)" $(INTEROP_REGS) if [[ @CIMSERVER@ != pegasus ]]; then \ - sed -i '/^# --/,/^# --!/d' $(subst $(top_srcdir)/schema,$(DESTDIR)$(pkgdatadir), $(PGINTEROP_REGS)); \ + sed -i '/^# --/,/^# --!/d' $(subst $(top_srcdir)/schema,$(DESTDIR)$(pkgdatadir), $(PGINTEROP_REGS)); \ + sed -i '/^# --/,/^# --!/d' $(subst $(top_srcdir)/schema,$(DESTDIR)$(pkgdatadir), $(PGINTEROP_MOFS)); \ fi uninstall-local: - @list='$(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS)'; \ + @list='$(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS) $(PGINTEROP_REGS) $(PGINTEROP_MOFS)'; \ for p in $$list; do \ f=`echo "$$p" | sed 's|^.*/||;'`; \ echo " rm -f '$(DESTDIR)$(pkgdatadir)/$$f'"; \ @@ -209,8 +217,19 @@ postinstall: $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n @CIM_VIRT_NS@ -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(MOFS)) $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/interop -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_MOFS)) $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/cimv2 -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_MOFS)) + # + # We need to check the version - if we're not yet at 2.12.1, then + # we'll register at root/PG_InterOp; otherwise, using just the above + # registration should be sufficient. The actual cutoff root/PG_InterOp + # not being valid was 2.12.1-5; however, --version doesn't give us that + # level of detail. The Pegasus docs imply that usage of root/interop was + # valid as of 2.12.0. + # if [[ @CIMSERVER@ = pegasus ]]; then \ - $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ + CIMVER=`@CIMSERVER@ --version | awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'` \ + if [[ $CIMVER -lt 021201 ]]; then \ + $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ + fi \ fi virsh -v | grep -q '^0.3' && cp examples/diskpool.conf $(DISK_POOL_CONFIG) || true mkdir -p $(INFO_STORE) @@ -220,7 +239,7 @@ preuninstall: $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/interop -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_MOFS)) $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/cimv2 -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_MOFS)) if [[ @CIMSERVER@ = pegasus ]]; then \ - $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ + $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ fi rpm: clean diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in index 24ef280..01ee329 100644 --- a/libvirt-cim.spec.in +++ b/libvirt-cim.spec.in @@ -200,6 +200,10 @@ rm -fr $RPM_BUILD_ROOT %{_datadir}/%{name}/ReferencedProfile.mof \\\ %{_datadir}/%{name}/AllocationCapabilities.mof +# NOTE: As of Pegasus 2.12.1-5, using root/PG_InterOp will no longer be +# valid. All mofs can just compile into root/interop. However, we +# need to keep these here for 'historical purposes'. +# %define PGINTEROP_REG %{_datadir}/%{name}/RegisteredProfile.registration \\\ %{_datadir}/%{name}/ElementConformsToProfile.registration \\\ %{_datadir}/%{name}/ReferencedProfile.registration @@ -268,12 +272,12 @@ fi %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 if [ "`systemctl is-active tog-pegasus.service 2> /dev/null`" = "active" ] then - systemctl restart tog-pegasus.service + systemctl restart tog-pegasus.service > /dev/null 2>&1 fi if [ "`systemctl is-active sblim-sfcb.service 2> /dev/null`" = "active" ] then - systemctl restart sblim-sfcb.service + systemctl restart sblim-sfcb.service > /dev/null 2>&1 fi %else /etc/init.d/tog-pegasus condrestart @@ -287,9 +291,22 @@ then %{_datadir}/%{name}/provider-register.sh -t pegasus \ -n root/interop \ -r %{INTEROP_REG} -m %{INTEROP_MOF} -v >/dev/null 2>&1 || true - %{_datadir}/%{name}/provider-register.sh -t pegasus \ - -n root/PG_InterOp \ - -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} -v >/dev/null 2>&1 || true + # + # We need to check the version - if we're not yet at 2.12.1, then + # we'll register at root/PG_InterOp; otherwise, using just the above + # registration should be sufficient. The actual cutoff root/PG_InterOp + # not being valid was 2.12.1-5; however, --version doesn't give us that + # level of detail. The Pegasus docs imply that usage of root/interop was + # valid as of 2.12.0. + # + CIMVER=`/usr/sbin/cimserver --version | \ + awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'` + if [ $CIMVER -lt 021201 ] + then + %{_datadir}/%{name}/provider-register.sh -t pegasus \ + -n root/PG_InterOp \ + -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} -v >/dev/null 2>&1 || true + fi %{_datadir}/%{name}/provider-register.sh -t pegasus \ -n root/cimv2\ -r %{CIMV2_REG} -m %{CIMV2_MOF} -v >/dev/null 2>&1 || true diff --git a/provider-register.sh b/provider-register.sh index abe8e95..f66fe54 100755 --- a/provider-register.sh +++ b/provider-register.sh @@ -274,7 +274,23 @@ pegasus_install() chatter Registering providers with $state cimserver '('$version')' chatter Installing mofs into namespace $namespace from path $mofpath $CIMMOF -uc -I $mofpath -n $namespace $mymofs && - $CIMMOF -uc -n root/PG_Interop $_REGFILENAME + # + # If compare_version returns false here (e.g. $version is less than + # "2.12.1", then we will compile into root/PG_InterOp; otherwise, + # compile into root/interop. As of 2.12.1-5 using the PG_InterOp + # will fail. Since we cannot get that level of detail out of the + # --version output, "assume" that 2.12.1 -> 2.12.1-4 will be able + # to use the new namespace. The Pegasus docs imply as of 2.12.0 using + # root/interop was preferred. + # + if compare_version "$version" "2.12.1" + then + chatter Installing $_REGFILENAME into root/PG_InterOp + $CIMMOF -uc -n root/PG_Interop $_REGFILENAME + else + chatter Installing $_REGFILENAME into root/interop + $CIMMOF -uc -n root/interop $_REGFILENAME + fi else echo "Failed to build pegasus registration MOF." >&2 return 1 -- 1.8.4.2 From jferlan at redhat.com Wed Feb 26 15:56:06 2014 From: jferlan at redhat.com (John Ferlan) Date: Wed, 26 Feb 2014 10:56:06 -0500 Subject: [Libvirt-cim] [PATCH] Use of root/interop instead of root/PG_InterOp In-Reply-To: <1392763303-21091-1-git-send-email-jferlan@redhat.com> References: <1392763303-21091-1-git-send-email-jferlan@redhat.com> Message-ID: <530E0E96.5030306@redhat.com> Ping? Since this affects RHEL7 - I really need to get this reviewed and committed upstream in order to include into RHEL7. Tks, John On 02/18/2014 05:41 PM, John Ferlan wrote: > As of tog-pegasus 2.12.1-5 we can no longer use "root/PG_InterOp" namespace > for the CIM provider instead the use of "root/interop" is the preferred > mechanism. > > This patch will adjust where libvirt-cim installs its classes to use the > "root/interop" namespace. > > For more context, see: > > http://www.redhat.com/archives/libvirt-cim/2013-November/msg00083.html > > and > > http://www.redhat.com/archives/libvirt-cim/2013-November/msg00008.html > > This patch will be required for RHEL7 which fails to install with the > base 0.6.3 release. > > Signed-off-by: John Ferlan > --- > Makefile.am | 29 ++++++++++++++++++++++++----- > libvirt-cim.spec.in | 27 ++++++++++++++++++++++----- > provider-register.sh | 18 +++++++++++++++++- > 3 files changed, 63 insertions(+), 11 deletions(-) > > diff --git a/Makefile.am b/Makefile.am > index 9e8e96b..69b65cf 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -78,6 +78,9 @@ INTEROP_MOFS = \ > $(top_srcdir)/schema/ReferencedProfile.mof \ > $(top_srcdir)/schema/AllocationCapabilities.mof > > +# The PGINTEROP_MOFS are used by tog-pegasus up through version 2.12.1 > +# If support for versions prior to 2.12.1 is removed, then these defs > +# can go away > PGINTEROP_MOFS = \ > $(top_srcdir)/schema/RegisteredProfile.mof \ > $(top_srcdir)/schema/ElementConformsToProfile.mof \ > @@ -157,6 +160,9 @@ INTEROP_REGS = \ > $(top_srcdir)/schema/ElementConformsToProfile.registration \ > $(top_srcdir)/schema/ReferencedProfile.registration > > +# The PGINTEROP_REGS are used by tog-pegasus up through version 2.12.1 > +# If support for versions prior to 2.12.1 is removed, then these defs > +# can go away > PGINTEROP_REGS = \ > $(top_srcdir)/schema/RegisteredProfile.registration \ > $(top_srcdir)/schema/ElementConformsToProfile.registration \ > @@ -181,7 +187,8 @@ EXTRA_DIST = schema $(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS) \ > .changeset .revision \ > examples/diskpool.conf > > -# If Pegasus isn't the CIMOM target, then remove the PG_InterOp namespace from the appropriate files > +# If Pegasus isn't the CIMOM target, then remove the PG_InterOp namespace > +# from the appropriate files > install-data-local: > $(mkinstalldirs) "$(DESTDIR)$(pkgdatadir)" > $(install_sh_DATA) -t "$(DESTDIR)$(pkgdatadir)" $(MOFS) > @@ -189,11 +196,12 @@ install-data-local: > $(install_sh_DATA) -t "$(DESTDIR)$(pkgdatadir)" $(INTEROP_MOFS) > $(install_sh_DATA) -t "$(DESTDIR)$(pkgdatadir)" $(INTEROP_REGS) > if [[ @CIMSERVER@ != pegasus ]]; then \ > - sed -i '/^# --/,/^# --!/d' $(subst $(top_srcdir)/schema,$(DESTDIR)$(pkgdatadir), $(PGINTEROP_REGS)); \ > + sed -i '/^# --/,/^# --!/d' $(subst $(top_srcdir)/schema,$(DESTDIR)$(pkgdatadir), $(PGINTEROP_REGS)); \ > + sed -i '/^# --/,/^# --!/d' $(subst $(top_srcdir)/schema,$(DESTDIR)$(pkgdatadir), $(PGINTEROP_MOFS)); \ > fi > > uninstall-local: > - @list='$(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS)'; \ > + @list='$(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS) $(PGINTEROP_REGS) $(PGINTEROP_MOFS)'; \ > for p in $$list; do \ > f=`echo "$$p" | sed 's|^.*/||;'`; \ > echo " rm -f '$(DESTDIR)$(pkgdatadir)/$$f'"; \ > @@ -209,8 +217,19 @@ postinstall: > $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n @CIM_VIRT_NS@ -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(MOFS)) > $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/interop -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_MOFS)) > $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/cimv2 -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_MOFS)) > + # > + # We need to check the version - if we're not yet at 2.12.1, then > + # we'll register at root/PG_InterOp; otherwise, using just the above > + # registration should be sufficient. The actual cutoff root/PG_InterOp > + # not being valid was 2.12.1-5; however, --version doesn't give us that > + # level of detail. The Pegasus docs imply that usage of root/interop was > + # valid as of 2.12.0. > + # > if [[ @CIMSERVER@ = pegasus ]]; then \ > - $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ > + CIMVER=`@CIMSERVER@ --version | awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'` \ > + if [[ $CIMVER -lt 021201 ]]; then \ > + $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ > + fi \ > fi > virsh -v | grep -q '^0.3' && cp examples/diskpool.conf $(DISK_POOL_CONFIG) || true > mkdir -p $(INFO_STORE) > @@ -220,7 +239,7 @@ preuninstall: > $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/interop -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_MOFS)) > $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/cimv2 -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_MOFS)) > if [[ @CIMSERVER@ = pegasus ]]; then \ > - $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ > + $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ > fi > > rpm: clean > diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in > index 24ef280..01ee329 100644 > --- a/libvirt-cim.spec.in > +++ b/libvirt-cim.spec.in > @@ -200,6 +200,10 @@ rm -fr $RPM_BUILD_ROOT > %{_datadir}/%{name}/ReferencedProfile.mof \\\ > %{_datadir}/%{name}/AllocationCapabilities.mof > > +# NOTE: As of Pegasus 2.12.1-5, using root/PG_InterOp will no longer be > +# valid. All mofs can just compile into root/interop. However, we > +# need to keep these here for 'historical purposes'. > +# > %define PGINTEROP_REG %{_datadir}/%{name}/RegisteredProfile.registration \\\ > %{_datadir}/%{name}/ElementConformsToProfile.registration \\\ > %{_datadir}/%{name}/ReferencedProfile.registration > @@ -268,12 +272,12 @@ fi > %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 > if [ "`systemctl is-active tog-pegasus.service 2> /dev/null`" = "active" ] > then > - systemctl restart tog-pegasus.service > + systemctl restart tog-pegasus.service > /dev/null 2>&1 > fi > > if [ "`systemctl is-active sblim-sfcb.service 2> /dev/null`" = "active" ] > then > - systemctl restart sblim-sfcb.service > + systemctl restart sblim-sfcb.service > /dev/null 2>&1 > fi > %else > /etc/init.d/tog-pegasus condrestart > @@ -287,9 +291,22 @@ then > %{_datadir}/%{name}/provider-register.sh -t pegasus \ > -n root/interop \ > -r %{INTEROP_REG} -m %{INTEROP_MOF} -v >/dev/null 2>&1 || true > - %{_datadir}/%{name}/provider-register.sh -t pegasus \ > - -n root/PG_InterOp \ > - -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} -v >/dev/null 2>&1 || true > + # > + # We need to check the version - if we're not yet at 2.12.1, then > + # we'll register at root/PG_InterOp; otherwise, using just the above > + # registration should be sufficient. The actual cutoff root/PG_InterOp > + # not being valid was 2.12.1-5; however, --version doesn't give us that > + # level of detail. The Pegasus docs imply that usage of root/interop was > + # valid as of 2.12.0. > + # > + CIMVER=`/usr/sbin/cimserver --version | \ > + awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'` > + if [ $CIMVER -lt 021201 ] > + then > + %{_datadir}/%{name}/provider-register.sh -t pegasus \ > + -n root/PG_InterOp \ > + -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} -v >/dev/null 2>&1 || true > + fi > %{_datadir}/%{name}/provider-register.sh -t pegasus \ > -n root/cimv2\ > -r %{CIMV2_REG} -m %{CIMV2_MOF} -v >/dev/null 2>&1 || true > diff --git a/provider-register.sh b/provider-register.sh > index abe8e95..f66fe54 100755 > --- a/provider-register.sh > +++ b/provider-register.sh > @@ -274,7 +274,23 @@ pegasus_install() > chatter Registering providers with $state cimserver '('$version')' > chatter Installing mofs into namespace $namespace from path $mofpath > $CIMMOF -uc -I $mofpath -n $namespace $mymofs && > - $CIMMOF -uc -n root/PG_Interop $_REGFILENAME > + # > + # If compare_version returns false here (e.g. $version is less than > + # "2.12.1", then we will compile into root/PG_InterOp; otherwise, > + # compile into root/interop. As of 2.12.1-5 using the PG_InterOp > + # will fail. Since we cannot get that level of detail out of the > + # --version output, "assume" that 2.12.1 -> 2.12.1-4 will be able > + # to use the new namespace. The Pegasus docs imply as of 2.12.0 using > + # root/interop was preferred. > + # > + if compare_version "$version" "2.12.1" > + then > + chatter Installing $_REGFILENAME into root/PG_InterOp > + $CIMMOF -uc -n root/PG_Interop $_REGFILENAME > + else > + chatter Installing $_REGFILENAME into root/interop > + $CIMMOF -uc -n root/interop $_REGFILENAME > + fi > else > echo "Failed to build pegasus registration MOF." >&2 > return 1 > From mprivozn at redhat.com Thu Feb 27 14:00:18 2014 From: mprivozn at redhat.com (Michal Privoznik) Date: Thu, 27 Feb 2014 15:00:18 +0100 Subject: [Libvirt-cim] [PATCH] Use of root/interop instead of root/PG_InterOp In-Reply-To: <1392763303-21091-1-git-send-email-jferlan@redhat.com> References: <1392763303-21091-1-git-send-email-jferlan@redhat.com> Message-ID: <530F44F2.5000607@redhat.com> On 18.02.2014 23:41, John Ferlan wrote: > As of tog-pegasus 2.12.1-5 we can no longer use "root/PG_InterOp" namespace > for the CIM provider instead the use of "root/interop" is the preferred > mechanism. > > This patch will adjust where libvirt-cim installs its classes to use the > "root/interop" namespace. > > For more context, see: > > http://www.redhat.com/archives/libvirt-cim/2013-November/msg00083.html > > and > > http://www.redhat.com/archives/libvirt-cim/2013-November/msg00008.html > > This patch will be required for RHEL7 which fails to install with the > base 0.6.3 release. > > Signed-off-by: John Ferlan > --- > Makefile.am | 29 ++++++++++++++++++++++++----- > libvirt-cim.spec.in | 27 ++++++++++++++++++++++----- > provider-register.sh | 18 +++++++++++++++++- > 3 files changed, 63 insertions(+), 11 deletions(-) ACK Michal From daniel.hansel at linux.vnet.ibm.com Thu Feb 27 16:01:03 2014 From: daniel.hansel at linux.vnet.ibm.com (Daniel Hansel) Date: Thu, 27 Feb 2014 17:01:03 +0100 Subject: [Libvirt-cim] [PATCH] Use of root/interop instead of root/PG_InterOp In-Reply-To: <1392763303-21091-1-git-send-email-jferlan@redhat.com> References: <1392763303-21091-1-git-send-email-jferlan@redhat.com> Message-ID: <530F613F.3010802@linux.vnet.ibm.com> Hi John, I have tested your change on s390x platform. Installed cimserver: tog-pegasus-2.12.0-2.fc18.s390x The comparison of the test results of both runs (with and without your changes) did not show up any difference. ACKed. -- Mit freundlichen Gr??en / Kind regards Daniel Hansel IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 On 18.02.2014 23:41, John Ferlan wrote: > As of tog-pegasus 2.12.1-5 we can no longer use "root/PG_InterOp" namespace for the CIM provider instead the use of "root/interop" is the preferred mechanism. > > This patch will adjust where libvirt-cim installs its classes to use the "root/interop" namespace. > > For more context, see: > > http://www.redhat.com/archives/libvirt-cim/2013-November/msg00083.html > > and > > http://www.redhat.com/archives/libvirt-cim/2013-November/msg00008.html > > This patch will be required for RHEL7 which fails to install with the base 0.6.3 release. > > Signed-off-by: John Ferlan --- Makefile.am | 29 ++++++++++++++++++++++++----- libvirt-cim.spec.in | 27 ++++++++++++++++++++++----- provider-register.sh | 18 > +++++++++++++++++- 3 files changed, 63 insertions(+), 11 deletions(-) > > diff --git a/Makefile.am b/Makefile.am index 9e8e96b..69b65cf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -78,6 +78,9 @@ INTEROP_MOFS = \ $(top_srcdir)/schema/ReferencedProfile.mof \ > $(top_srcdir)/schema/AllocationCapabilities.mof > > +# The PGINTEROP_MOFS are used by tog-pegasus up through version 2.12.1 +# If support for versions prior to 2.12.1 is removed, then these defs +# can go away PGINTEROP_MOFS = \ > $(top_srcdir)/schema/RegisteredProfile.mof \ $(top_srcdir)/schema/ElementConformsToProfile.mof \ @@ -157,6 +160,9 @@ INTEROP_REGS = \ $(top_srcdir)/schema/ElementConformsToProfile.registration \ > $(top_srcdir)/schema/ReferencedProfile.registration > > +# The PGINTEROP_REGS are used by tog-pegasus up through version 2.12.1 +# If support for versions prior to 2.12.1 is removed, then these defs +# can go away PGINTEROP_REGS = \ > $(top_srcdir)/schema/RegisteredProfile.registration \ $(top_srcdir)/schema/ElementConformsToProfile.registration \ @@ -181,7 +187,8 @@ EXTRA_DIST = schema $(MOFS) $(REGS) $(INTEROP_MOFS) > $(INTEROP_REGS) \ .changeset .revision \ examples/diskpool.conf > > -# If Pegasus isn't the CIMOM target, then remove the PG_InterOp namespace from the appropriate files +# If Pegasus isn't the CIMOM target, then remove the PG_InterOp namespace +# from the > appropriate files install-data-local: $(mkinstalldirs) "$(DESTDIR)$(pkgdatadir)" $(install_sh_DATA) -t "$(DESTDIR)$(pkgdatadir)" $(MOFS) @@ -189,11 +196,12 @@ install-data-local: > $(install_sh_DATA) -t "$(DESTDIR)$(pkgdatadir)" $(INTEROP_MOFS) $(install_sh_DATA) -t "$(DESTDIR)$(pkgdatadir)" $(INTEROP_REGS) if [[ @CIMSERVER@ != pegasus ]]; then \ - sed -i '/^# --/,/^# > --!/d' $(subst $(top_srcdir)/schema,$(DESTDIR)$(pkgdatadir), $(PGINTEROP_REGS)); \ + sed -i '/^# --/,/^# --!/d' $(subst $(top_srcdir)/schema,$(DESTDIR)$(pkgdatadir), $(PGINTEROP_REGS)); \ + > sed -i '/^# --/,/^# --!/d' $(subst $(top_srcdir)/schema,$(DESTDIR)$(pkgdatadir), $(PGINTEROP_MOFS)); \ fi > > uninstall-local: - @list='$(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS)'; \ + @list='$(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS) $(PGINTEROP_REGS) $(PGINTEROP_MOFS)'; \ for p in $$list; do > \ f=`echo "$$p" | sed 's|^.*/||;'`; \ echo " rm -f '$(DESTDIR)$(pkgdatadir)/$$f'"; \ @@ -209,8 +217,19 @@ postinstall: $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n @CIM_VIRT_NS@ -r $(subst > $(top_srcdir)/schema,$(pkgdatadir), $(REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(MOFS)) $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/interop -r $(subst > $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_MOFS)) $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/cimv2 -r $(subst > $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_MOFS)) + # + # We need to check the version - if we're not yet at 2.12.1, > then + # we'll register at root/PG_InterOp; otherwise, using just the above + # registration should be sufficient. The actual cutoff root/PG_InterOp + # not being valid was > 2.12.1-5; however, --version doesn't give us that + # level of detail. The Pegasus docs imply that usage of root/interop was + # valid as of 2.12.0. + # if [[ @CIMSERVER@ = > pegasus ]]; then \ - $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst > $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ + CIMVER=`@CIMSERVER@ --version | awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'` \ + if [[ $CIMVER -lt 021201 ]]; then \ + > $(SHELL) provider-register.sh -v -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), > $(PGINTEROP_MOFS)); \ + fi \ fi virsh -v | grep -q '^0.3' && cp examples/diskpool.conf $(DISK_POOL_CONFIG) || true mkdir -p $(INFO_STORE) @@ -220,7 +239,7 @@ preuninstall: $(SHELL) > provider-register.sh -v -d -t @CIMSERVER@ -n root/interop -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(INTEROP_MOFS)) $(SHELL) > provider-register.sh -v -d -t @CIMSERVER@ -n root/cimv2 -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(CIMV2_MOFS)) if [[ > @CIMSERVER@ = pegasus ]]; then \ - $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_REGS)) -m $(subst > $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ + $(SHELL) provider-register.sh -v -d -t @CIMSERVER@ -n root/PG_InterOp -r $(subst $(top_srcdir)/schema,$(pkgdatadir), > $(PGINTEROP_REGS)) -m $(subst $(top_srcdir)/schema,$(pkgdatadir), $(PGINTEROP_MOFS)); \ fi > > rpm: clean diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in index 24ef280..01ee329 100644 --- a/libvirt-cim.spec.in +++ b/libvirt-cim.spec.in @@ -200,6 +200,10 @@ rm -fr $RPM_BUILD_ROOT > %{_datadir}/%{name}/ReferencedProfile.mof \\\ %{_datadir}/%{name}/AllocationCapabilities.mof > > +# NOTE: As of Pegasus 2.12.1-5, using root/PG_InterOp will no longer be +# valid. All mofs can just compile into root/interop. However, we +# need to keep these here for 'historical > purposes'. +# %define PGINTEROP_REG %{_datadir}/%{name}/RegisteredProfile.registration \\\ %{_datadir}/%{name}/ElementConformsToProfile.registration \\\ > %{_datadir}/%{name}/ReferencedProfile.registration @@ -268,12 +272,12 @@ fi %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 if [ "`systemctl is-active tog-pegasus.service 2> /dev/null`" = "active" ] > then - systemctl restart tog-pegasus.service + systemctl restart tog-pegasus.service > /dev/null 2>&1 fi > > if [ "`systemctl is-active sblim-sfcb.service 2> /dev/null`" = "active" ] then - systemctl restart sblim-sfcb.service + systemctl restart sblim-sfcb.service > /dev/null 2>&1 fi > %else /etc/init.d/tog-pegasus condrestart @@ -287,9 +291,22 @@ then %{_datadir}/%{name}/provider-register.sh -t pegasus \ -n root/interop \ -r %{INTEROP_REG} -m %{INTEROP_MOF} -v >/dev/null 2>&1 > || true - %{_datadir}/%{name}/provider-register.sh -t pegasus \ - -n root/PG_InterOp \ - -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} -v >/dev/null 2>&1 || true + # + # We need > to check the version - if we're not yet at 2.12.1, then + # we'll register at root/PG_InterOp; otherwise, using just the above + # registration should be sufficient. The actual cutoff > root/PG_InterOp + # not being valid was 2.12.1-5; however, --version doesn't give us that + # level of detail. The Pegasus docs imply that usage of root/interop was + # valid as of > 2.12.0. + # + CIMVER=`/usr/sbin/cimserver --version | \ + awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'` + if [ $CIMVER -lt 021201 ] + then + > %{_datadir}/%{name}/provider-register.sh -t pegasus \ + -n root/PG_InterOp \ + -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} -v >/dev/null 2>&1 || true + fi > %{_datadir}/%{name}/provider-register.sh -t pegasus \ -n root/cimv2\ -r %{CIMV2_REG} -m %{CIMV2_MOF} -v >/dev/null 2>&1 || true diff --git a/provider-register.sh b/provider-register.sh index > abe8e95..f66fe54 100755 --- a/provider-register.sh +++ b/provider-register.sh @@ -274,7 +274,23 @@ pegasus_install() chatter Registering providers with $state cimserver '('$version')' chatter > Installing mofs into namespace $namespace from path $mofpath $CIMMOF -uc -I $mofpath -n $namespace $mymofs && - $CIMMOF -uc -n root/PG_Interop $_REGFILENAME + # + # If > compare_version returns false here (e.g. $version is less than + # "2.12.1", then we will compile into root/PG_InterOp; otherwise, + # compile into root/interop. As of 2.12.1-5 > using the PG_InterOp + # will fail. Since we cannot get that level of detail out of the + # --version output, "assume" that 2.12.1 -> 2.12.1-4 will be able + # to use the > new namespace. The Pegasus docs imply as of 2.12.0 using + # root/interop was preferred. + # + if compare_version "$version" "2.12.1" + then + chatter > Installing $_REGFILENAME into root/PG_InterOp + $CIMMOF -uc -n root/PG_Interop $_REGFILENAME + else + chatter Installing $_REGFILENAME into root/interop + $CIMMOF -uc -n > root/interop $_REGFILENAME + fi else echo "Failed to build pegasus registration MOF." >&2 return 1 >