From snmishra at us.ibm.com Wed Mar 2 16:24:24 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 02 Mar 2011 08:24:24 -0800 Subject: [Libvirt-cim] [PATCH] Query switch to find its vsi capabilities Message-ID: <134137bc4f2505fc3576.1299083064@elm3a148.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1299082247 28800 # Node ID 134137bc4f2505fc3576b312b8ef2c63a510fa68 # Parent 432922275bea75a769cf058209bdb81198f3b360 Query switch to find its vsi capabilities. This patch adds a new 'SwitchService' provider that will query the switch to check if it supports VSI. Signed-off-by: Sharad Mishra diff -r 432922275bea -r 134137bc4f25 Makefile.am --- a/Makefile.am Fri Jan 21 15:59:27 2011 -0500 +++ b/Makefile.am Wed Mar 02 08:10:47 2011 -0800 @@ -28,6 +28,7 @@ schema/ElementConformsToProfile.mof \ schema/ComputerSystemIndication.mof \ schema/ResourceAllocationSettingDataIndication.mof \ + schema/SwitchService.mof \ schema/ComputerSystemMigrationIndication.mof \ schema/Virt_ResourceAllocationSettingData.mof \ schema/ResourceAllocationSettingData.mof \ @@ -108,6 +109,7 @@ schema/HostedResourcePool.registration \ schema/ComputerSystemIndication.registration \ schema/ResourceAllocationSettingDataIndication.registration \ + schema/SwitchService.registration \ schema/ComputerSystemMigrationIndication.registration \ schema/ResourceAllocationSettingData.registration \ schema/ResourcePoolConfigurationService.registration \ diff -r 432922275bea -r 134137bc4f25 schema/SwitchService.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/SwitchService.mof Wed Mar 02 08:10:47 2011 -0800 @@ -0,0 +1,27 @@ +// Copyright IBM Corp. 2011 + +[Provider("cmpi::Virt_SwitchService")] +class Xen_SwitchService : CIM_SwitchService +{ + [Description("Flag to determine if VSI is supported on the switch")] + boolean IsVSISupported; + +}; + +[Provider("cmpi::Virt_SwitchService")] +class KVM_SwitchService : CIM_SwitchService +{ + [Description("Flag to determine if VSI is supported on the switch")] + boolean IsVSISupported; + +}; + +[Provider("cmpi::Virt_SwitchService")] +class LXC_SwitchService : CIM_SwitchService +{ + [Description("Flag to determine if VSI is supported on the switch")] + boolean IsVSISupported; + +}; + + diff -r 432922275bea -r 134137bc4f25 schema/SwitchService.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/SwitchService.registration Wed Mar 02 08:10:47 2011 -0800 @@ -0,0 +1,6 @@ +# Copyright IBM Corp. 2011 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance +KVM_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance +LXC_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance + diff -r 432922275bea -r 134137bc4f25 src/Makefile.am --- a/src/Makefile.am Fri Jan 21 15:59:27 2011 -0500 +++ b/src/Makefile.am Wed Mar 02 08:10:47 2011 -0800 @@ -49,6 +49,7 @@ libVirt_SystemDevice.la \ libVirt_ComputerSystemIndication.la \ libVirt_ResourceAllocationSettingDataIndication.la \ + libVirt_SwitchService.la \ libVirt_ComputerSystemMigrationIndication.la \ libVirt_VirtualSystemManagementCapabilities.la \ libVirt_AllocationCapabilities.la \ @@ -91,6 +92,10 @@ libVirt_ResourceAllocationSettingDataIndication_la_SOURCES = Virt_ResourceAllocationSettingDataIndication.c libVirt_ResourceAllocationSettingDataIndication_la_LIBADD = -lVirt_ComputerSystem +libVirt_SwitchService_la_DEPENDENCIES = libVirt_ComputerSystem.la +libVirt_SwitchService_la_SOURCES = Virt_SwitchService.c +libVirt_SwitchService_la_LIBADD = -lVirt_ComputerSystem + libVirt_ComputerSystemMigrationIndication_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_ComputerSystemMigrationIndication_la_SOURCES = Virt_ComputerSystemMigrationIndication.c libVirt_ComputerSystemMigrationIndication_la_LIBADD = -lVirt_ComputerSystem diff -r 432922275bea -r 134137bc4f25 src/Virt_SwitchService.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_SwitchService.c Wed Mar 02 08:10:47 2011 -0800 @@ -0,0 +1,297 @@ +/* + * Copyright IBM Corp. 2011 + * + * Authors: + * Sharad Mishra + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "misc_util.h" +#include "config.h" + +#define MAX_LEN 512 +#define CMD "/sbin/ifconfig -a | /bin/grep eth | /bin/awk '{print$1}'" + +const static CMPIBroker *_BROKER; + +static CMPIStatus check_vsi_support(char *command) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + char buff[MAX_LEN]; + FILE *stream = NULL; + const char *searchStr[] = {" supported forwarding mode: " + "(0x40) reflective relay", + " supported capabilities: " + "(0x07) RTE ECP VDP"}; + int matched = 0; + + // Run lldptool command to find vsi support. + stream = popen(command, "r"); + if (stream == NULL) { + CU_DEBUG("Failed to open pipe to read vsi support"); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "Failed to open pipe"); + goto out; + } + + // Read the output of the command. + while (fgets(buff, MAX_LEN, stream) != NULL) { + int i = 0; + while (searchStr[i] != NULL) { + int len = strlen(searchStr[i]); + /* Read value which is stored in 'buff' has newline + at the end, we remove it for comparison. */ + if (strncmp(buff, searchStr[i], (len - 1)) == 0) { + /* 'matched' flag is incremented each time + we find that read string (output of lldptool + command) and searchStrings are same. */ + matched++; + break; + } + i++; + } + /* All the search strings were found in the output of this + command. */ + if (matched == 2) { + cu_statusf(_BROKER, &s, CMPI_RC_OK, "VSI supported"); + goto out;; + } + } + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "No VSI Support found"); + + out: + pclose(stream); + return s; +} + +static char **run_command(char *func, int *len, CMPIStatus *s) { + + char buff[MAX_LEN]; + FILE *stream = NULL; + char **arr = NULL; + char *string = NULL; + int i = 0; + + // run the command. + stream = popen(func, "r"); + if (stream == NULL) { + CU_DEBUG("Failed to open pipe to run command"); + cu_statusf(_BROKER, s, + CMPI_RC_ERR_NOT_FOUND, + "Failed to open pipe"); + return NULL; + } + + // read output of command. + while (fgets(buff, MAX_LEN, stream) != NULL) { + int len = strlen(buff) - 1; + char **tmp_list = NULL; + + // dynamically increase size as more interfaces are found. + tmp_list = (char **)realloc(arr, + (i + 1) * + sizeof(char *)); + if (tmp_list == NULL) { + CU_DEBUG("Failed to allocate memory"); + cu_statusf(_BROKER, s, + CMPI_RC_ERR_NOT_FOUND, + "Failed to realloc"); + return NULL; + } + + arr = tmp_list; + + string = calloc(len, sizeof(char)); + if (string == NULL) { + CU_DEBUG("Failed to allocate memory"); + cu_statusf(_BROKER, s, + CMPI_RC_ERR_NOT_FOUND, + "Failed to calloc"); + return NULL; + } + strncpy(string, buff, len); + arr[i] = string; + i++; + } + + pclose(stream); + *len = i; + return arr; +} + +static CMPIStatus get_switchservice(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker, + const CMPIContext *context, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn = NULL; + bool vsi = false; + int count = 0; + int i; + char **if_list; + char cmd[MAX_LEN]; + + *_inst = NULL; + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + + return s; + } + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "SwitchService", + NAMESPACE(reference)); + + if (inst == NULL) { + CU_DEBUG("Failed to get typed instance"); + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Failed to create instance"); + goto out; + } + + CMSetProperty(inst, "Name", + (CMPIValue *)"Switch Virtualization Capabilities", + CMPI_chars); + + if_list = run_command(CMD, &count, &s); + if (if_list == 0) { + CU_DEBUG("Failed to get network interfaces"); + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Failed to get network interfaces"); + goto out; + } + + CU_DEBUG("Found %d interfaces", count); + + + for (i=0; i # HG changeset patch # User Sharad Mishra # Date 1299089374 28800 # Node ID 1a894e2ab420ffb16d21d8ffa8c9850bea58b31c # Parent 7a2ce3106321ac1729aeff2b9e42fb2e75da9295 Auto refresh StoragePools This patch refreshes storage pool after volumes have been created or deleted from this pool. This patch also refreshes the pool before enumerating them. Signed-off-by: Sharad Mishra diff -r 7a2ce3106321 -r 1a894e2ab420 libxkutil/pool_parsing.c --- a/libxkutil/pool_parsing.c Mon Feb 28 05:57:22 2011 -0800 +++ b/libxkutil/pool_parsing.c Wed Mar 02 10:09:34 2011 -0800 @@ -400,6 +400,9 @@ goto out; } + if ((virStoragePoolRefresh(ptr, 0)) == -1) + CU_DEBUG("Unable to refresh storage pool"); + path = virStorageVolGetPath(vptr); if (path == NULL) { CU_DEBUG("Unable to get storage volume path"); @@ -420,9 +423,11 @@ int res_type) { int ret = 0; + virStorageVolPtr ptr; + virStoragePoolPtr pool_ptr; if (res_type == CIM_RES_TYPE_IMAGE) { - virStorageVolPtr ptr = virStorageVolLookupByPath(conn, rname); + ptr = virStorageVolLookupByPath(conn, rname); if (ptr == NULL) { CU_DEBUG("Storage volume %s is not defined", rname); goto out; @@ -432,6 +437,16 @@ if (ret != 0) { CU_DEBUG("Unable to delete storage volume %s", rname); } else { + pool_ptr = virStoragePoolLookupByVolume(ptr); + if (pool_ptr == NULL) { + CU_DEBUG("Unable to get storage pool " + "from volume"); + } else { + ret = virStoragePoolRefresh(pool_ptr, 0); + if (ret != 0) + CU_DEBUG("Unable to refresh storage " + "pool"); + } ret = 1; } diff -r 7a2ce3106321 -r 1a894e2ab420 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Mon Feb 28 05:57:22 2011 -0800 +++ b/src/Virt_DevicePool.c Wed Mar 02 10:09:34 2011 -0800 @@ -182,6 +182,10 @@ goto out; } + if ((virStoragePoolRefresh(pool, 0)) == -1) + CU_DEBUG("Unable to refresh storage pool"); + + if (virStoragePoolGetInfo(pool, &info) == -1) { CU_DEBUG("Failed to get info for pool `%s'", _pool->tag); goto out; From cvincent at linux.vnet.ibm.com Sat Mar 5 00:48:46 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Fri, 04 Mar 2011 19:48:46 -0500 Subject: [Libvirt-cim] [PATCH] Query switch to find its vsi capabilities In-Reply-To: <134137bc4f2505fc3576.1299083064@elm3a148.beaverton.ibm.com> References: <134137bc4f2505fc3576.1299083064@elm3a148.beaverton.ibm.com> Message-ID: <4D71886E.9020702@linux.vnet.ibm.com> +1. I have not tested since I don't have the hardware. BTW, is there a cimtest update coming for this function? On 03/02/2011 11:24 AM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1299082247 28800 > # Node ID 134137bc4f2505fc3576b312b8ef2c63a510fa68 > # Parent 432922275bea75a769cf058209bdb81198f3b360 > Query switch to find its vsi capabilities. > > This patch adds a new 'SwitchService' provider that will query the switch to check if it supports VSI. > > Signed-off-by: Sharad Mishra > > diff -r 432922275bea -r 134137bc4f25 Makefile.am > --- a/Makefile.am Fri Jan 21 15:59:27 2011 -0500 > +++ b/Makefile.am Wed Mar 02 08:10:47 2011 -0800 > @@ -28,6 +28,7 @@ > schema/ElementConformsToProfile.mof \ > schema/ComputerSystemIndication.mof \ > schema/ResourceAllocationSettingDataIndication.mof \ > + schema/SwitchService.mof \ > schema/ComputerSystemMigrationIndication.mof \ > schema/Virt_ResourceAllocationSettingData.mof \ > schema/ResourceAllocationSettingData.mof \ > @@ -108,6 +109,7 @@ > schema/HostedResourcePool.registration \ > schema/ComputerSystemIndication.registration \ > schema/ResourceAllocationSettingDataIndication.registration \ > + schema/SwitchService.registration \ > schema/ComputerSystemMigrationIndication.registration \ > schema/ResourceAllocationSettingData.registration \ > schema/ResourcePoolConfigurationService.registration \ > diff -r 432922275bea -r 134137bc4f25 schema/SwitchService.mof > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/schema/SwitchService.mof Wed Mar 02 08:10:47 2011 -0800 > @@ -0,0 +1,27 @@ > +// Copyright IBM Corp. 2011 > + > +[Provider("cmpi::Virt_SwitchService")] > +class Xen_SwitchService : CIM_SwitchService > +{ > + [Description("Flag to determine if VSI is supported on the switch")] > + boolean IsVSISupported; > + > +}; > + > +[Provider("cmpi::Virt_SwitchService")] > +class KVM_SwitchService : CIM_SwitchService > +{ > + [Description("Flag to determine if VSI is supported on the switch")] > + boolean IsVSISupported; > + > +}; > + > +[Provider("cmpi::Virt_SwitchService")] > +class LXC_SwitchService : CIM_SwitchService > +{ > + [Description("Flag to determine if VSI is supported on the switch")] > + boolean IsVSISupported; > + > +}; > + > + > diff -r 432922275bea -r 134137bc4f25 schema/SwitchService.registration > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/schema/SwitchService.registration Wed Mar 02 08:10:47 2011 -0800 > @@ -0,0 +1,6 @@ > +# Copyright IBM Corp. 2011 > +# Classname Namespace ProviderName ProviderModule ProviderTypes > +Xen_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance > +KVM_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance > +LXC_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance > + > diff -r 432922275bea -r 134137bc4f25 src/Makefile.am > --- a/src/Makefile.am Fri Jan 21 15:59:27 2011 -0500 > +++ b/src/Makefile.am Wed Mar 02 08:10:47 2011 -0800 > @@ -49,6 +49,7 @@ > libVirt_SystemDevice.la \ > libVirt_ComputerSystemIndication.la \ > libVirt_ResourceAllocationSettingDataIndication.la \ > + libVirt_SwitchService.la \ > libVirt_ComputerSystemMigrationIndication.la \ > libVirt_VirtualSystemManagementCapabilities.la \ > libVirt_AllocationCapabilities.la \ > @@ -91,6 +92,10 @@ > libVirt_ResourceAllocationSettingDataIndication_la_SOURCES = Virt_ResourceAllocationSettingDataIndication.c > libVirt_ResourceAllocationSettingDataIndication_la_LIBADD = -lVirt_ComputerSystem > > +libVirt_SwitchService_la_DEPENDENCIES = libVirt_ComputerSystem.la > +libVirt_SwitchService_la_SOURCES = Virt_SwitchService.c > +libVirt_SwitchService_la_LIBADD = -lVirt_ComputerSystem > + > libVirt_ComputerSystemMigrationIndication_la_DEPENDENCIES = libVirt_ComputerSystem.la > libVirt_ComputerSystemMigrationIndication_la_SOURCES = Virt_ComputerSystemMigrationIndication.c > libVirt_ComputerSystemMigrationIndication_la_LIBADD = -lVirt_ComputerSystem > diff -r 432922275bea -r 134137bc4f25 src/Virt_SwitchService.c > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/src/Virt_SwitchService.c Wed Mar 02 08:10:47 2011 -0800 > @@ -0,0 +1,297 @@ > +/* > + * Copyright IBM Corp. 2011 > + * > + * Authors: > + * Sharad Mishra > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > + */ > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > + > +#include > +#include > + > +#include "misc_util.h" > +#include "config.h" > + > +#define MAX_LEN 512 > +#define CMD "/sbin/ifconfig -a | /bin/grep eth | /bin/awk '{print$1}'" > + > +const static CMPIBroker *_BROKER; > + > +static CMPIStatus check_vsi_support(char *command) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + char buff[MAX_LEN]; > + FILE *stream = NULL; > + const char *searchStr[] = {" supported forwarding mode: " > + "(0x40) reflective relay", > + " supported capabilities: " > + "(0x07) RTE ECP VDP"}; > + int matched = 0; > + > + // Run lldptool command to find vsi support. > + stream = popen(command, "r"); > + if (stream == NULL) { > + CU_DEBUG("Failed to open pipe to read vsi support"); > + cu_statusf(_BROKER,&s, > + CMPI_RC_ERR_NOT_FOUND, > + "Failed to open pipe"); > + goto out; > + } > + > + // Read the output of the command. > + while (fgets(buff, MAX_LEN, stream) != NULL) { > + int i = 0; > + while (searchStr[i] != NULL) { > + int len = strlen(searchStr[i]); > + /* Read value which is stored in 'buff' has newline > + at the end, we remove it for comparison. */ > + if (strncmp(buff, searchStr[i], (len - 1)) == 0) { > + /* 'matched' flag is incremented each time > + we find that read string (output of lldptool > + command) and searchStrings are same. */ > + matched++; > + break; > + } > + i++; > + } > + /* All the search strings were found in the output of this > + command. */ > + if (matched == 2) { > + cu_statusf(_BROKER,&s, CMPI_RC_OK, "VSI supported"); > + goto out;; > + } > + } > + cu_statusf(_BROKER,&s, > + CMPI_RC_ERR_NOT_FOUND, > + "No VSI Support found"); > + > + out: > + pclose(stream); > + return s; > +} > + > +static char **run_command(char *func, int *len, CMPIStatus *s) { > + > + char buff[MAX_LEN]; > + FILE *stream = NULL; > + char **arr = NULL; > + char *string = NULL; > + int i = 0; > + > + // run the command. > + stream = popen(func, "r"); > + if (stream == NULL) { > + CU_DEBUG("Failed to open pipe to run command"); > + cu_statusf(_BROKER, s, > + CMPI_RC_ERR_NOT_FOUND, > + "Failed to open pipe"); > + return NULL; > + } > + > + // read output of command. > + while (fgets(buff, MAX_LEN, stream) != NULL) { > + int len = strlen(buff) - 1; > + char **tmp_list = NULL; > + > + // dynamically increase size as more interfaces are found. > + tmp_list = (char **)realloc(arr, > + (i + 1) * > + sizeof(char *)); > + if (tmp_list == NULL) { > + CU_DEBUG("Failed to allocate memory"); > + cu_statusf(_BROKER, s, > + CMPI_RC_ERR_NOT_FOUND, > + "Failed to realloc"); > + return NULL; > + } > + > + arr = tmp_list; > + > + string = calloc(len, sizeof(char)); > + if (string == NULL) { > + CU_DEBUG("Failed to allocate memory"); > + cu_statusf(_BROKER, s, > + CMPI_RC_ERR_NOT_FOUND, > + "Failed to calloc"); > + return NULL; > + } > + strncpy(string, buff, len); > + arr[i] = string; > + i++; > + } > + > + pclose(stream); > + *len = i; > + return arr; > +} > + > +static CMPIStatus get_switchservice(const CMPIObjectPath *reference, > + CMPIInstance **_inst, > + const CMPIBroker *broker, > + const CMPIContext *context, > + bool is_get_inst) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + CMPIInstance *inst = NULL; > + virConnectPtr conn = NULL; > + bool vsi = false; > + int count = 0; > + int i; > + char **if_list; > + char cmd[MAX_LEN]; > + > + *_inst = NULL; > + conn = connect_by_classname(broker, CLASSNAME(reference),&s); > + if (conn == NULL) { > + if (is_get_inst) > + cu_statusf(broker,&s, > + CMPI_RC_ERR_NOT_FOUND, > + "No such instance"); > + > + return s; > + } > + > + inst = get_typed_instance(broker, > + pfx_from_conn(conn), > + "SwitchService", > + NAMESPACE(reference)); > + > + if (inst == NULL) { > + CU_DEBUG("Failed to get typed instance"); > + cu_statusf(broker,&s, > + CMPI_RC_ERR_FAILED, > + "Failed to create instance"); > + goto out; > + } > + > + CMSetProperty(inst, "Name", > + (CMPIValue *)"Switch Virtualization Capabilities", > + CMPI_chars); > + > + if_list = run_command(CMD,&count,&s); > + if (if_list == 0) { > + CU_DEBUG("Failed to get network interfaces"); > + cu_statusf(broker,&s, > + CMPI_RC_ERR_FAILED, > + "Failed to get network interfaces"); > + goto out; > + } > + > + CU_DEBUG("Found %d interfaces", count); > + > + > + for (i=0; i + sprintf(cmd, "lldptool -i %s -t -V evbcfg", if_list[i]); > + CU_DEBUG("running command %s ...", cmd); > + s = check_vsi_support(cmd); > + if (s.rc == CMPI_RC_OK) { > + vsi = true; > + break; > + } > + else > + vsi = false; > + } > + > + CMSetProperty(inst, "IsVSISupported", (CMPIValue *)&vsi, CMPI_boolean); > + s.rc = CMPI_RC_OK; > + > + out: > + virConnectClose(conn); > + *_inst = inst; > + > + return s; > + > +} > + > +static CMPIStatus return_switchservice(const CMPIContext *context, > + const CMPIObjectPath *reference, > + const CMPIResult *results, > + bool name_only, > + bool is_get_inst) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + CMPIInstance *inst; > + > + s = get_switchservice(reference,&inst, _BROKER, context, is_get_inst); > + if (s.rc != CMPI_RC_OK || inst == NULL) > + goto out; > + > + if (name_only) > + cu_return_instance_name(results, inst); > + else > + CMReturnInstance(results, inst); > + out: > + return s; > +} > + > +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, > + const CMPIContext *context, > + const CMPIResult *results, > + const CMPIObjectPath *ref) > +{ > + return return_switchservice(context, ref, results, true, false); > +} > + > +static CMPIStatus EnumInstances(CMPIInstanceMI *self, > + const CMPIContext *context, > + const CMPIResult *results, > + const CMPIObjectPath *ref, > + const char **properties) > +{ > + > + return return_switchservice(context, ref, results, false, false); > +} > + > +static CMPIStatus GetInstance(CMPIInstanceMI *self, > + const CMPIContext *context, > + const CMPIResult *results, > + const CMPIObjectPath *ref, > + const char **properties) > +{ > + return return_switchservice(context, ref, results, false, true); > +} > + > +DEFAULT_CI(); > +DEFAULT_MI(); > +DEFAULT_DI(); > +DEFAULT_EQ(); > +DEFAULT_INST_CLEANUP(); > + > +STD_InstanceMIStub(, > + Virt_SwitchService, > + _BROKER, > + libvirt_cim_init()); > + > +/* > + * Local Variables: > + * mode: C > + * c-set-style: "K&R" > + * tab-width: 8 > + * c-basic-offset: 8 > + * indent-tabs-mode: nil > + * End: > + */ > + > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Sat Mar 5 00:53:33 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Fri, 04 Mar 2011 19:53:33 -0500 Subject: [Libvirt-cim] [PATCH] Auto refresh StoragePools In-Reply-To: <1a894e2ab420ffb16d21.1299180350@elm3a148.beaverton.ibm.com> References: <1a894e2ab420ffb16d21.1299180350@elm3a148.beaverton.ibm.com> Message-ID: <4D71898D.1040100@linux.vnet.ibm.com> +1. I like the approach. I wonder if this sort of thing goes on under the covers in libvirt, or if not, if there might be an advantage to moving this lower? Something to think about. On 03/03/2011 02:25 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1299089374 28800 > # Node ID 1a894e2ab420ffb16d21d8ffa8c9850bea58b31c > # Parent 7a2ce3106321ac1729aeff2b9e42fb2e75da9295 > Auto refresh StoragePools > > This patch refreshes storage pool after volumes have been created or deleted from this pool. This patch also refreshes the pool before enumerating them. > > Signed-off-by: Sharad Mishra > > diff -r 7a2ce3106321 -r 1a894e2ab420 libxkutil/pool_parsing.c > --- a/libxkutil/pool_parsing.c Mon Feb 28 05:57:22 2011 -0800 > +++ b/libxkutil/pool_parsing.c Wed Mar 02 10:09:34 2011 -0800 > @@ -400,6 +400,9 @@ > goto out; > } > > + if ((virStoragePoolRefresh(ptr, 0)) == -1) > + CU_DEBUG("Unable to refresh storage pool"); > + > path = virStorageVolGetPath(vptr); > if (path == NULL) { > CU_DEBUG("Unable to get storage volume path"); > @@ -420,9 +423,11 @@ > int res_type) > { > int ret = 0; > + virStorageVolPtr ptr; > + virStoragePoolPtr pool_ptr; > > if (res_type == CIM_RES_TYPE_IMAGE) { > - virStorageVolPtr ptr = virStorageVolLookupByPath(conn, rname); > + ptr = virStorageVolLookupByPath(conn, rname); > if (ptr == NULL) { > CU_DEBUG("Storage volume %s is not defined", rname); > goto out; > @@ -432,6 +437,16 @@ > if (ret != 0) { > CU_DEBUG("Unable to delete storage volume %s", rname); > } else { > + pool_ptr = virStoragePoolLookupByVolume(ptr); > + if (pool_ptr == NULL) { > + CU_DEBUG("Unable to get storage pool " > + "from volume"); > + } else { > + ret = virStoragePoolRefresh(pool_ptr, 0); > + if (ret != 0) > + CU_DEBUG("Unable to refresh storage " > + "pool"); > + } > ret = 1; > } > > diff -r 7a2ce3106321 -r 1a894e2ab420 src/Virt_DevicePool.c > --- a/src/Virt_DevicePool.c Mon Feb 28 05:57:22 2011 -0800 > +++ b/src/Virt_DevicePool.c Wed Mar 02 10:09:34 2011 -0800 > @@ -182,6 +182,10 @@ > goto out; > } > > + if ((virStoragePoolRefresh(pool, 0)) == -1) > + CU_DEBUG("Unable to refresh storage pool"); > + > + > if (virStoragePoolGetInfo(pool,&info) == -1) { > CU_DEBUG("Failed to get info for pool `%s'", _pool->tag); > goto out; > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From snmishra at us.ibm.com Mon Mar 7 03:44:56 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Sun, 6 Mar 2011 19:44:56 -0800 Subject: [Libvirt-cim] [PATCH] Query switch to find its vsi capabilities In-Reply-To: <4D71886E.9020702@linux.vnet.ibm.com> References: <134137bc4f2505fc3576.1299083064@elm3a148.beaverton.ibm.com> <4D71886E.9020702@linux.vnet.ibm.com> Message-ID: I have tested it. There is no cimtest coming as this can be tested by wbemcli or any cim browser. I am still exploring and may decide to write a cimtest. For now, it is just wbemcli. -Sharad Chip Vincent wrote on 03/04/2011 04:48:46 PM: > Chip Vincent > 03/04/11 04:48 PM > > Please respond to > cvincent at linux.vnet.ibm.com > > To > > List for discussion and development of libvirt CIM > > cc > > Sharad Mishra/Beaverton/IBM at IBMUS > > Subject > > Re: [Libvirt-cim] [PATCH] Query switch to find its vsi capabilities > > +1. I have not tested since I don't have the hardware. BTW, is there a > cimtest update coming for this function? > > On 03/02/2011 11:24 AM, Sharad Mishra wrote: > > # HG changeset patch > > # User Sharad Mishra > > # Date 1299082247 28800 > > # Node ID 134137bc4f2505fc3576b312b8ef2c63a510fa68 > > # Parent 432922275bea75a769cf058209bdb81198f3b360 > > Query switch to find its vsi capabilities. > > > > This patch adds a new 'SwitchService' provider that will query the > switch to check if it supports VSI. > > > > Signed-off-by: Sharad Mishra > > > > diff -r 432922275bea -r 134137bc4f25 Makefile.am > > --- a/Makefile.am Fri Jan 21 15:59:27 2011 -0500 > > +++ b/Makefile.am Wed Mar 02 08:10:47 2011 -0800 > > @@ -28,6 +28,7 @@ > > schema/ElementConformsToProfile.mof \ > > schema/ComputerSystemIndication.mof \ > > schema/ResourceAllocationSettingDataIndication.mof \ > > + schema/SwitchService.mof \ > > schema/ComputerSystemMigrationIndication.mof \ > > schema/Virt_ResourceAllocationSettingData.mof \ > > schema/ResourceAllocationSettingData.mof \ > > @@ -108,6 +109,7 @@ > > schema/HostedResourcePool.registration \ > > schema/ComputerSystemIndication.registration \ > > schema/ResourceAllocationSettingDataIndication.registration \ > > + schema/SwitchService.registration \ > > schema/ComputerSystemMigrationIndication.registration \ > > schema/ResourceAllocationSettingData.registration \ > > schema/ResourcePoolConfigurationService.registration \ > > diff -r 432922275bea -r 134137bc4f25 schema/SwitchService.mof > > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > > +++ b/schema/SwitchService.mof Wed Mar 02 08:10:47 2011 -0800 > > @@ -0,0 +1,27 @@ > > +// Copyright IBM Corp. 2011 > > + > > +[Provider("cmpi::Virt_SwitchService")] > > +class Xen_SwitchService : CIM_SwitchService > > +{ > > + [Description("Flag to determine if VSI is supported on the switch")] > > + boolean IsVSISupported; > > + > > +}; > > + > > +[Provider("cmpi::Virt_SwitchService")] > > +class KVM_SwitchService : CIM_SwitchService > > +{ > > + [Description("Flag to determine if VSI is supported on the switch")] > > + boolean IsVSISupported; > > + > > +}; > > + > > +[Provider("cmpi::Virt_SwitchService")] > > +class LXC_SwitchService : CIM_SwitchService > > +{ > > + [Description("Flag to determine if VSI is supported on the switch")] > > + boolean IsVSISupported; > > + > > +}; > > + > > + > > diff -r 432922275bea -r 134137bc4f25 schema/SwitchService.registration > > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > > +++ b/schema/SwitchService.registration Wed Mar 02 08:10:47 2011 -0800 > > @@ -0,0 +1,6 @@ > > +# Copyright IBM Corp. 2011 > > +# Classname Namespace ProviderName ProviderModule ProviderTypes > > +Xen_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance > > +KVM_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance > > +LXC_SwitchService root/virt Virt_SwitchService Virt_SwitchService instance > > + > > diff -r 432922275bea -r 134137bc4f25 src/Makefile.am > > --- a/src/Makefile.am Fri Jan 21 15:59:27 2011 -0500 > > +++ b/src/Makefile.am Wed Mar 02 08:10:47 2011 -0800 > > @@ -49,6 +49,7 @@ > > libVirt_SystemDevice.la \ > > libVirt_ComputerSystemIndication.la \ > > > libVirt_ResourceAllocationSettingDataIndication.la \ > > + libVirt_SwitchService.la \ > > libVirt_ComputerSystemMigrationIndication.la \ > > libVirt_VirtualSystemManagementCapabilities.la \ > > libVirt_AllocationCapabilities.la \ > > @@ -91,6 +92,10 @@ > > libVirt_ResourceAllocationSettingDataIndication_la_SOURCES = > Virt_ResourceAllocationSettingDataIndication.c > > libVirt_ResourceAllocationSettingDataIndication_la_LIBADD = - > lVirt_ComputerSystem > > > > +libVirt_SwitchService_la_DEPENDENCIES = libVirt_ComputerSystem.la > > +libVirt_SwitchService_la_SOURCES = Virt_SwitchService.c > > +libVirt_SwitchService_la_LIBADD = -lVirt_ComputerSystem > > + > > libVirt_ComputerSystemMigrationIndication_la_DEPENDENCIES = > libVirt_ComputerSystem.la > > libVirt_ComputerSystemMigrationIndication_la_SOURCES = > Virt_ComputerSystemMigrationIndication.c > > libVirt_ComputerSystemMigrationIndication_la_LIBADD = - > lVirt_ComputerSystem > > diff -r 432922275bea -r 134137bc4f25 src/Virt_SwitchService.c > > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > > +++ b/src/Virt_SwitchService.c Wed Mar 02 08:10:47 2011 -0800 > > @@ -0,0 +1,297 @@ > > +/* > > + * Copyright IBM Corp. 2011 > > + * > > + * Authors: > > + * Sharad Mishra > > + * > > + * This library is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU Lesser General Public > > + * License as published by the Free Software Foundation; either > > + * version 2.1 of the License, or (at your option) any later version. > > + * > > + * This library is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > + * Lesser General Public License for more details. > > + * > > + * You should have received a copy of the GNU Lesser General Public > > + * License along with this library; if not, write to the Free Software > > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > > + */ > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > + > > +#include "misc_util.h" > > +#include "config.h" > > + > > +#define MAX_LEN 512 > > +#define CMD "/sbin/ifconfig -a | /bin/grep eth | /bin/awk '{print$1}'" > > + > > +const static CMPIBroker *_BROKER; > > + > > +static CMPIStatus check_vsi_support(char *command) > > +{ > > + CMPIStatus s = {CMPI_RC_OK, NULL}; > > + char buff[MAX_LEN]; > > + FILE *stream = NULL; > > + const char *searchStr[] = {" supported forwarding mode: " > > + "(0x40) reflective relay", > > + " supported capabilities: " > > + "(0x07) RTE ECP VDP"}; > > + int matched = 0; > > + > > + // Run lldptool command to find vsi support. > > + stream = popen(command, "r"); > > + if (stream == NULL) { > > + CU_DEBUG("Failed to open pipe to read vsi support"); > > + cu_statusf(_BROKER,&s, > > + CMPI_RC_ERR_NOT_FOUND, > > + "Failed to open pipe"); > > + goto out; > > + } > > + > > + // Read the output of the command. > > + while (fgets(buff, MAX_LEN, stream) != NULL) { > > + int i = 0; > > + while (searchStr[i] != NULL) { > > + int len = strlen(searchStr[i]); > > + /* Read value which is stored in 'buff' has newline > > + at the end, we remove it for comparison. */ > > + if (strncmp(buff, searchStr[i], (len - 1)) == 0) { > > + /* 'matched' flag is incremented each time > > + we find that read string > (output of lldptool > > + command) and searchStrings are same. */ > > + matched++; > > + break; > > + } > > + i++; > > + } > > + /* All the search strings were found in the output of this > > + command. */ > > + if (matched == 2) { > > + cu_statusf(_BROKER,&s, CMPI_RC_OK, "VSI > supported"); > > + goto out;; > > + } > > + } > > + cu_statusf(_BROKER,&s, > > + CMPI_RC_ERR_NOT_FOUND, > > + "No VSI Support found"); > > + > > + out: > > + pclose(stream); > > + return s; > > +} > > + > > +static char **run_command(char *func, int *len, CMPIStatus *s) { > > + > > + char buff[MAX_LEN]; > > + FILE *stream = NULL; > > + char **arr = NULL; > > + char *string = NULL; > > + int i = 0; > > + > > + // run the command. > > + stream = popen(func, "r"); > > + if (stream == NULL) { > > + CU_DEBUG("Failed to open pipe to run command"); > > + cu_statusf(_BROKER, s, > > + CMPI_RC_ERR_NOT_FOUND, > > + "Failed to open pipe"); > > + return NULL; > > + } > > + > > + // read output of command. > > + while (fgets(buff, MAX_LEN, stream) != NULL) { > > + int len = strlen(buff) - 1; > > + char **tmp_list = NULL; > > + > > + // dynamically increase size as more interfaces are found. > > + tmp_list = (char **)realloc(arr, > > + (i + 1) * > > + sizeof(char *)); > > + if (tmp_list == NULL) { > > + CU_DEBUG("Failed to allocate memory"); > > + cu_statusf(_BROKER, s, > > + CMPI_RC_ERR_NOT_FOUND, > > + "Failed to realloc"); > > + return NULL; > > + } > > + > > + arr = tmp_list; > > + > > + string = calloc(len, sizeof(char)); > > + if (string == NULL) { > > + CU_DEBUG("Failed to allocate memory"); > > + cu_statusf(_BROKER, s, > > + CMPI_RC_ERR_NOT_FOUND, > > + "Failed to calloc"); > > + return NULL; > > + } > > + strncpy(string, buff, len); > > + arr[i] = string; > > + i++; > > + } > > + > > + pclose(stream); > > + *len = i; > > + return arr; > > +} > > + > > +static CMPIStatus get_switchservice(const CMPIObjectPath *reference, > > + CMPIInstance **_inst, > > + const CMPIBroker *broker, > > + const CMPIContext *context, > > + bool is_get_inst) > > +{ > > + CMPIStatus s = {CMPI_RC_OK, NULL}; > > + CMPIInstance *inst = NULL; > > + virConnectPtr conn = NULL; > > + bool vsi = false; > > + int count = 0; > > + int i; > > + char **if_list; > > + char cmd[MAX_LEN]; > > + > > + *_inst = NULL; > > + conn = connect_by_classname(broker, CLASSNAME(reference),&s); > > + if (conn == NULL) { > > + if (is_get_inst) > > + cu_statusf(broker,&s, > > + CMPI_RC_ERR_NOT_FOUND, > > + "No such instance"); > > + > > + return s; > > + } > > + > > + inst = get_typed_instance(broker, > > + pfx_from_conn(conn), > > + "SwitchService", > > + NAMESPACE(reference)); > > + > > + if (inst == NULL) { > > + CU_DEBUG("Failed to get typed instance"); > > + cu_statusf(broker,&s, > > + CMPI_RC_ERR_FAILED, > > + "Failed to create instance"); > > + goto out; > > + } > > + > > + CMSetProperty(inst, "Name", > > + (CMPIValue *)"Switch Virtualization Capabilities", > > + CMPI_chars); > > + > > + if_list = run_command(CMD,&count,&s); > > + if (if_list == 0) { > > + CU_DEBUG("Failed to get network interfaces"); > > + cu_statusf(broker,&s, > > + CMPI_RC_ERR_FAILED, > > + "Failed to get network interfaces"); > > + goto out; > > + } > > + > > + CU_DEBUG("Found %d interfaces", count); > > + > > + > > + for (i=0; i > + sprintf(cmd, "lldptool -i %s -t -V evbcfg", if_list [i]); > > + CU_DEBUG("running command %s ...", cmd); > > + s = check_vsi_support(cmd); > > + if (s.rc == CMPI_RC_OK) { > > + vsi = true; > > + break; > > + } > > + else > > + vsi = false; > > + } > > + > > + CMSetProperty(inst, "IsVSISupported", (CMPIValue *)&vsi, > CMPI_boolean); > > + s.rc = CMPI_RC_OK; > > + > > + out: > > + virConnectClose(conn); > > + *_inst = inst; > > + > > + return s; > > + > > +} > > + > > +static CMPIStatus return_switchservice(const CMPIContext *context, > > + const CMPIObjectPath *reference, > > + const CMPIResult *results, > > + bool name_only, > > + bool is_get_inst) > > +{ > > + CMPIStatus s = {CMPI_RC_OK, NULL}; > > + CMPIInstance *inst; > > + > > + s = get_switchservice(reference,&inst, _BROKER, context, > is_get_inst); > > + if (s.rc != CMPI_RC_OK || inst == NULL) > > + goto out; > > + > > + if (name_only) > > + cu_return_instance_name(results, inst); > > + else > > + CMReturnInstance(results, inst); > > + out: > > + return s; > > +} > > + > > +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, > > + const CMPIContext *context, > > + const CMPIResult *results, > > + const CMPIObjectPath *ref) > > +{ > > + return return_switchservice(context, ref, results, true, false); > > +} > > + > > +static CMPIStatus EnumInstances(CMPIInstanceMI *self, > > + const CMPIContext *context, > > + const CMPIResult *results, > > + const CMPIObjectPath *ref, > > + const char **properties) > > +{ > > + > > + return return_switchservice(context, ref, results, false, false); > > +} > > + > > +static CMPIStatus GetInstance(CMPIInstanceMI *self, > > + const CMPIContext *context, > > + const CMPIResult *results, > > + const CMPIObjectPath *ref, > > + const char **properties) > > +{ > > + return return_switchservice(context, ref, results, false, true); > > +} > > + > > +DEFAULT_CI(); > > +DEFAULT_MI(); > > +DEFAULT_DI(); > > +DEFAULT_EQ(); > > +DEFAULT_INST_CLEANUP(); > > + > > +STD_InstanceMIStub(, > > + Virt_SwitchService, > > + _BROKER, > > + libvirt_cim_init()); > > + > > +/* > > + * Local Variables: > > + * mode: C > > + * c-set-style: "K&R" > > + * tab-width: 8 > > + * c-basic-offset: 8 > > + * indent-tabs-mode: nil > > + * End: > > + */ > > + > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > -- > Chip Vincent > Open Virtualization > IBM Linux Technology Center > cvincent at linux.vnet.ibm.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From snmishra at us.ibm.com Tue Mar 8 11:50:34 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Tue, 08 Mar 2011 03:50:34 -0800 Subject: [Libvirt-cim] [PATCH] [TEST] New test to check SwitchService provider Message-ID: # HG changeset patch # User Sharad Mishra # Date 1299548429 28800 # Node ID f5bc7977f2d5813474b2c56981bd93e2cf9d96b7 # Parent 4f2bf0006818d2ca4903a0b550dde65e4d581d7c [TEST] New test to check SwitchService provider This test enumerates SwitchService and checks to see if VSI is supported or not. Signed-off-by: Sharad Mishra diff -r 4f2bf0006818 -r f5bc7977f2d5 suites/libvirt-cim/cimtest/SwitchService/01_enum.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/SwitchService/01_enum.py Mon Mar 07 17:40:29 2011 -0800 @@ -0,0 +1,51 @@ +#!/usr/bin/python +# +# Copyright 2011 IBM Corp. +# +# Authors: +# Sharad Mishra +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import sys +from XenKvmLib.const import do_main +from XenKvmLib import enumclass +from XenKvmLib.classes import get_typed_class +from CimTest.Globals import logger +from CimTest.ReturnCodes import XFAIL + +SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV'] + + at do_main(SUPPORTED_TYPES) +def main(): + options = main.options + + cs_class = get_typed_class(options.virt, 'SwitchService') + try: + cs = enumclass.EnumInstances(options.ip, cs_class) + print "Please check if this is the expected result ---" + for name in cs: + if name.IsVSISupported: + print "*** VSI supported ***" + else: + print "*** VSI NOT supported ***" + except Exception, detail: + logger.error("Exception: %s", detail) + + return XFAIL + +if __name__ == "__main__": + sys.exit(main()) From snmishra at us.ibm.com Tue Mar 8 11:51:01 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Tue, 08 Mar 2011 03:51:01 -0800 Subject: [Libvirt-cim] [PATCH] Fixing NullPointerException Message-ID: # HG changeset patch # User Sharad Mishra # Date 1299548081 28800 # Node ID eea958fbf1d965bc1053850f59df4005e64093ac # Parent 32ec4dfd813c449501f70e2419cd6f17eee5c673 Fixing NullPointerException While reading the output of lldptool command the read buffer was going beyond the allocated size and was reading garbage. Added a check to make sure it doesn't go beyond the allocated size. Signed-off-by: Sharad Mishra diff -r 32ec4dfd813c -r eea958fbf1d9 src/Virt_SwitchService.c --- a/src/Virt_SwitchService.c Wed Mar 02 10:09:34 2011 -0800 +++ b/src/Virt_SwitchService.c Mon Mar 07 17:34:41 2011 -0800 @@ -48,7 +48,8 @@ const char *searchStr[] = {" supported forwarding mode: " "(0x40) reflective relay", " supported capabilities: " - "(0x07) RTE ECP VDP"}; + "(0x07) RTE ECP VDP", + NULL}; int matched = 0; // Run lldptool command to find vsi support. From cvincent at linux.vnet.ibm.com Tue Mar 8 16:43:06 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 08 Mar 2011 11:43:06 -0500 Subject: [Libvirt-cim] [PATCH] Fixing NullPointerException In-Reply-To: References: Message-ID: <4D765C9A.7060901@linux.vnet.ibm.com> +1 On 03/08/2011 06:51 AM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1299548081 28800 > # Node ID eea958fbf1d965bc1053850f59df4005e64093ac > # Parent 32ec4dfd813c449501f70e2419cd6f17eee5c673 > Fixing NullPointerException > > While reading the output of lldptool command the read buffer was going beyond the allocated size and was reading garbage. Added a check to make sure it doesn't go beyond the allocated size. > > Signed-off-by: Sharad Mishra > > diff -r 32ec4dfd813c -r eea958fbf1d9 src/Virt_SwitchService.c > --- a/src/Virt_SwitchService.c Wed Mar 02 10:09:34 2011 -0800 > +++ b/src/Virt_SwitchService.c Mon Mar 07 17:34:41 2011 -0800 > @@ -48,7 +48,8 @@ > const char *searchStr[] = {" supported forwarding mode: " > "(0x40) reflective relay", > " supported capabilities: " > - "(0x07) RTE ECP VDP"}; > + "(0x07) RTE ECP VDP", > + NULL}; > int matched = 0; > > // Run lldptool command to find vsi support. > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From snmishra at us.ibm.com Tue Mar 15 17:20:26 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Tue, 15 Mar 2011 10:20:26 -0700 Subject: [Libvirt-cim] [PATCH] Add SystemCreationClassName and CreationClassName for SwitchService Message-ID: <5e06c520e09e7bada9b8.1300209626@elm3a148.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1300209608 25200 # Node ID 5e06c520e09e7bada9b851a46c78bb96b947614c # Parent c5239e6e1fef9bfd74e0adca2da5f15e9fe2e734 Add SystemCreationClassName and CreationClassName for SwitchService Added above two properties to SwitchService provider. Signed-off-by: Sharad Mishra diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_Device.c --- a/src/Virt_Device.c Mon Mar 14 08:04:37 2011 -0700 +++ b/src/Virt_Device.c Tue Mar 15 10:20:08 2011 -0700 @@ -77,7 +77,7 @@ return 0; str = CMNewString(broker, dev->mac, &s); - if ((s.rc = CMPI_RC_OK) || (CMIsNullObject(str))) + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(str))) return 0; CMSetArrayElementAt(array, 0, &str, CMPI_string); diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Mon Mar 14 08:04:37 2011 -0700 +++ b/src/Virt_HostSystem.c Tue Mar 15 10:20:08 2011 -0700 @@ -101,7 +101,7 @@ char hostname[256] = {0}; op = CMGetObjectPath(instance, &s); - if ((s.rc == CMPI_RC_OK) || !CMIsNullObject(op)) { + if ((s.rc == CMPI_RC_OK) && !CMIsNullObject(op)) { CMSetProperty(instance, "CreationClassName", (CMPIValue *)CLASSNAME(op), CMPI_chars); } @@ -109,6 +109,7 @@ if (get_fqdn(hostname, sizeof(hostname)) != 0) strcpy(hostname, "unknown"); + CU_DEBUG("hostname is %s", hostname); CMSetProperty(instance, "Name", (CMPIValue *)hostname, CMPI_chars); diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Mar 14 08:04:37 2011 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Mar 15 10:20:08 2011 -0700 @@ -1598,7 +1598,7 @@ } str = CMNewString(_BROKER, dev_path, &s); - if ((s.rc = CMPI_RC_OK) || (CMIsNullObject(str))) { + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(str))) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Unable to create new string"); diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_SwitchService.c --- a/src/Virt_SwitchService.c Mon Mar 14 08:04:37 2011 -0700 +++ b/src/Virt_SwitchService.c Tue Mar 15 10:20:08 2011 -0700 @@ -34,6 +34,7 @@ #include "misc_util.h" #include "config.h" +#include "Virt_HostSystem.h" #define MAX_LEN 512 #define CMD "/sbin/ifconfig -a | /bin/grep eth | /bin/awk '{print$1}'" @@ -149,6 +150,41 @@ return arr; } +static CMPIStatus set_inst_properties(const CMPIBroker *broker, + const CMPIContext *context, + const CMPIObjectPath *reference, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + const char *name = NULL; + const char *ccname = NULL; + + s = get_host_system_properties(&name, + &ccname, + reference, + broker, + context); + if (s.rc != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get host attributes"); + goto out; + } + + CMSetProperty(inst, "Name", + (CMPIValue *)"Switch Virtualization Capabilities", + CMPI_chars); + + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); + + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)ccname, CMPI_chars); + + out: + return s; +} + static CMPIStatus get_switchservice(const CMPIObjectPath *reference, CMPIInstance **_inst, const CMPIBroker *broker, @@ -188,10 +224,12 @@ goto out; } - CMSetProperty(inst, "Name", - (CMPIValue *)"Switch Virtualization Capabilities", - CMPI_chars); - + s = set_inst_properties(broker, context, reference, inst); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Failed to set instance properties"); + goto out; + } + if_list = run_command(CMD, &count, &s); if (if_list == 0) { CU_DEBUG("Failed to get network interfaces"); From cvincent at linux.vnet.ibm.com Wed Mar 16 00:33:20 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 15 Mar 2011 20:33:20 -0400 Subject: [Libvirt-cim] [PATCH] Add support for Pegasus OOP grouping Message-ID: <6cdfba0135e08b8b5878.1300235600@oc0840652111.ibm.com> # HG changeset patch # User Chip Vincent # Date 1300235494 14400 # Node ID 6cdfba0135e08b8b5878075dff77b5e03107c614 # Parent eea958fbf1d965bc1053850f59df4005e64093ac Add support for Pegasus OOP grouping Update Pegasus ProviderModule registration to include support for ModuleGroupProperty. This will allow all libvirt-cim provider to load into a single process when the CIMOM is configured to run providers outside the CIMOM process. Signed-off-by: Chip Vincent diff --git a/provider-register.sh b/provider-register.sh --- a/provider-register.sh +++ b/provider-register.sh @@ -32,6 +32,43 @@ return 1 } +pegasus_version() +{ + CIMSERVER=`pegasus_path cimserver` + if test $? != 0 + then + echo "Error: cimserver not found" >&2 + return 1 + fi + + VERSION=`$CIMSERVER --version` + if test $? != 0 + then + echo "Error: could not determine cimserver version" >&2 + return 1 + fi + + echo $VERSION + return 0 +} + +compare_version() +{ + source=`echo "$1" | awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'` + target=`echo "$2" | awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'` + + if test $source \< $target + then + chatter $source " < " $target + echo "true" + return 0 + else + chatter $source " >= " $target + echo "false" + return 1 + fi +} + pegasus_transform() { OUTFILE=$1 @@ -49,10 +86,15 @@ # produce ProviderModules echo > $OUTFILE - chatter "Processing provider modules:" $PROVIDERMODULES - for pm in $PROVIDERMODULES - do - cat >> $OUTFILE <> $OUTFILE <> $OUTFILE < References: <5e06c520e09e7bada9b8.1300209626@elm3a148.beaverton.ibm.com> Message-ID: <4D80080D.3030706@linux.vnet.ibm.com> +1. Was not able to test due to lack of HW. Can you retest on VSI HW with upstream code? Thanks. On 03/15/2011 01:20 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1300209608 25200 > # Node ID 5e06c520e09e7bada9b851a46c78bb96b947614c > # Parent c5239e6e1fef9bfd74e0adca2da5f15e9fe2e734 > Add SystemCreationClassName and CreationClassName for SwitchService > > Added above two properties to SwitchService provider. > > Signed-off-by: Sharad Mishra > > diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_Device.c > --- a/src/Virt_Device.c Mon Mar 14 08:04:37 2011 -0700 > +++ b/src/Virt_Device.c Tue Mar 15 10:20:08 2011 -0700 > @@ -77,7 +77,7 @@ > return 0; > > str = CMNewString(broker, dev->mac,&s); > - if ((s.rc = CMPI_RC_OK) || (CMIsNullObject(str))) > + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(str))) > return 0; > > CMSetArrayElementAt(array, 0,&str, CMPI_string); > diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_HostSystem.c > --- a/src/Virt_HostSystem.c Mon Mar 14 08:04:37 2011 -0700 > +++ b/src/Virt_HostSystem.c Tue Mar 15 10:20:08 2011 -0700 > @@ -101,7 +101,7 @@ > char hostname[256] = {0}; > > op = CMGetObjectPath(instance,&s); > - if ((s.rc == CMPI_RC_OK) || !CMIsNullObject(op)) { > + if ((s.rc == CMPI_RC_OK)&& !CMIsNullObject(op)) { > CMSetProperty(instance, "CreationClassName", > (CMPIValue *)CLASSNAME(op), CMPI_chars); > } > @@ -109,6 +109,7 @@ > if (get_fqdn(hostname, sizeof(hostname)) != 0) > strcpy(hostname, "unknown"); > > + CU_DEBUG("hostname is %s", hostname); > CMSetProperty(instance, "Name", > (CMPIValue *)hostname, CMPI_chars); > > diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_SettingsDefineCapabilities.c > --- a/src/Virt_SettingsDefineCapabilities.c Mon Mar 14 08:04:37 2011 -0700 > +++ b/src/Virt_SettingsDefineCapabilities.c Tue Mar 15 10:20:08 2011 -0700 > @@ -1598,7 +1598,7 @@ > } > > str = CMNewString(_BROKER, dev_path,&s); > - if ((s.rc = CMPI_RC_OK) || (CMIsNullObject(str))) { > + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(str))) { > cu_statusf(_BROKER,&s, > CMPI_RC_ERR_FAILED, > "Unable to create new string"); > diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_SwitchService.c > --- a/src/Virt_SwitchService.c Mon Mar 14 08:04:37 2011 -0700 > +++ b/src/Virt_SwitchService.c Tue Mar 15 10:20:08 2011 -0700 > @@ -34,6 +34,7 @@ > > #include "misc_util.h" > #include "config.h" > +#include "Virt_HostSystem.h" > > #define MAX_LEN 512 > #define CMD "/sbin/ifconfig -a | /bin/grep eth | /bin/awk '{print$1}'" > @@ -149,6 +150,41 @@ > return arr; > } > > +static CMPIStatus set_inst_properties(const CMPIBroker *broker, > + const CMPIContext *context, > + const CMPIObjectPath *reference, > + CMPIInstance *inst) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + const char *name = NULL; > + const char *ccname = NULL; > + > + s = get_host_system_properties(&name, > +&ccname, > + reference, > + broker, > + context); > + if (s.rc != CMPI_RC_OK) { > + cu_statusf(broker,&s, > + CMPI_RC_ERR_FAILED, > + "Unable to get host attributes"); > + goto out; > + } > + > + CMSetProperty(inst, "Name", > + (CMPIValue *)"Switch Virtualization Capabilities", > + CMPI_chars); > + > + CMSetProperty(inst, "SystemName", > + (CMPIValue *)name, CMPI_chars); > + > + CMSetProperty(inst, "SystemCreationClassName", > + (CMPIValue *)ccname, CMPI_chars); > + > + out: > + return s; > +} > + > static CMPIStatus get_switchservice(const CMPIObjectPath *reference, > CMPIInstance **_inst, > const CMPIBroker *broker, > @@ -188,10 +224,12 @@ > goto out; > } > > - CMSetProperty(inst, "Name", > - (CMPIValue *)"Switch Virtualization Capabilities", > - CMPI_chars); > - > + s = set_inst_properties(broker, context, reference, inst); > + if (s.rc != CMPI_RC_OK) { > + CU_DEBUG("Failed to set instance properties"); > + goto out; > + } > + > if_list = run_command(CMD,&count,&s); > if (if_list == 0) { > CU_DEBUG("Failed to get network interfaces"); > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From snmishra at us.ibm.com Wed Mar 16 14:53:15 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 16 Mar 2011 07:53:15 -0700 Subject: [Libvirt-cim] [PATCH] Add SystemCreationClassName and CreationClassName for SwitchService In-Reply-To: <4D80080D.3030706@linux.vnet.ibm.com> References: <5e06c520e09e7bada9b8.1300209626@elm3a148.beaverton.ibm.com> <4D80080D.3030706@linux.vnet.ibm.com> Message-ID: Chip, I have tested it on VSI hardware. Sharad Mishra Open Virtualization Linux Technology Center IBM Chip Vincent wrote on 03/15/2011 05:45:01 PM: > Chip Vincent > 03/15/2011 05:45 PM > > Please respond to > cvincent at linux.vnet.ibm.com > > To > > List for discussion and development of libvirt CIM > > cc > > Sharad Mishra/Beaverton/IBM at IBMUS > > Subject > > Re: [Libvirt-cim] [PATCH] Add SystemCreationClassName and > CreationClassName for SwitchService > > +1. Was not able to test due to lack of HW. Can you retest on VSI HW > with upstream code? Thanks. > > On 03/15/2011 01:20 PM, Sharad Mishra wrote: > > # HG changeset patch > > # User Sharad Mishra > > # Date 1300209608 25200 > > # Node ID 5e06c520e09e7bada9b851a46c78bb96b947614c > > # Parent c5239e6e1fef9bfd74e0adca2da5f15e9fe2e734 > > Add SystemCreationClassName and CreationClassName for SwitchService > > > > Added above two properties to SwitchService provider. > > > > Signed-off-by: Sharad Mishra > > > > diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_Device.c > > --- a/src/Virt_Device.c Mon Mar 14 08:04:37 2011 -0700 > > +++ b/src/Virt_Device.c Tue Mar 15 10:20:08 2011 -0700 > > @@ -77,7 +77,7 @@ > > return 0; > > > > str = CMNewString(broker, dev->mac,&s); > > - if ((s.rc = CMPI_RC_OK) || (CMIsNullObject(str))) > > + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(str))) > > return 0; > > > > CMSetArrayElementAt(array, 0,&str, CMPI_string); > > diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_HostSystem.c > > --- a/src/Virt_HostSystem.c Mon Mar 14 08:04:37 2011 -0700 > > +++ b/src/Virt_HostSystem.c Tue Mar 15 10:20:08 2011 -0700 > > @@ -101,7 +101,7 @@ > > char hostname[256] = {0}; > > > > op = CMGetObjectPath(instance,&s); > > - if ((s.rc == CMPI_RC_OK) || !CMIsNullObject(op)) { > > + if ((s.rc == CMPI_RC_OK)&& !CMIsNullObject(op)) { > > CMSetProperty(instance, "CreationClassName", > > (CMPIValue *)CLASSNAME(op), CMPI_chars); > > } > > @@ -109,6 +109,7 @@ > > if (get_fqdn(hostname, sizeof(hostname)) != 0) > > strcpy(hostname, "unknown"); > > > > + CU_DEBUG("hostname is %s", hostname); > > CMSetProperty(instance, "Name", > > (CMPIValue *)hostname, CMPI_chars); > > > > diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_SettingsDefineCapabilities.c > > --- a/src/Virt_SettingsDefineCapabilities.c Mon Mar 14 08:04:37 2011 -0700 > > +++ b/src/Virt_SettingsDefineCapabilities.c Tue Mar 15 10:20:08 2011 -0700 > > @@ -1598,7 +1598,7 @@ > > } > > > > str = CMNewString(_BROKER, dev_path,&s); > > - if ((s.rc = CMPI_RC_OK) || (CMIsNullObject (str))) { > > + if ((s.rc != CMPI_RC_OK) || > (CMIsNullObject(str))) { > > cu_statusf(_BROKER,&s, > > CMPI_RC_ERR_FAILED, > > "Unable to create newstring"); > > diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_SwitchService.c > > --- a/src/Virt_SwitchService.c Mon Mar 14 08:04:37 2011 -0700 > > +++ b/src/Virt_SwitchService.c Tue Mar 15 10:20:08 2011 -0700 > > @@ -34,6 +34,7 @@ > > > > #include "misc_util.h" > > #include "config.h" > > +#include "Virt_HostSystem.h" > > > > #define MAX_LEN 512 > > #define CMD "/sbin/ifconfig -a | /bin/grep eth | /bin/awk '{print $1}'" > > @@ -149,6 +150,41 @@ > > return arr; > > } > > > > +static CMPIStatus set_inst_properties(const CMPIBroker *broker, > > + const CMPIContext *context, > > + const CMPIObjectPath *reference, > > + CMPIInstance *inst) > > +{ > > + CMPIStatus s = {CMPI_RC_OK, NULL}; > > + const char *name = NULL; > > + const char *ccname = NULL; > > + > > + s = get_host_system_properties(&name, > > +&ccname, > > + reference, > > + broker, > > + context); > > + if (s.rc != CMPI_RC_OK) { > > + cu_statusf(broker,&s, > > + CMPI_RC_ERR_FAILED, > > + "Unable to get host attributes"); > > + goto out; > > + } > > + > > + CMSetProperty(inst, "Name", > > + (CMPIValue *)"Switch Virtualization Capabilities", > > + CMPI_chars); > > + > > + CMSetProperty(inst, "SystemName", > > + (CMPIValue *)name, CMPI_chars); > > + > > + CMSetProperty(inst, "SystemCreationClassName", > > + (CMPIValue *)ccname, CMPI_chars); > > + > > + out: > > + return s; > > +} > > + > > static CMPIStatus get_switchservice(const CMPIObjectPath *reference, > > CMPIInstance **_inst, > > const CMPIBroker *broker, > > @@ -188,10 +224,12 @@ > > goto out; > > } > > > > - CMSetProperty(inst, "Name", > > - (CMPIValue *)"Switch Virtualization Capabilities", > > - CMPI_chars); > > - > > + s = set_inst_properties(broker, context, reference, inst); > > + if (s.rc != CMPI_RC_OK) { > > + CU_DEBUG("Failed to set instance properties"); > > + goto out; > > + } > > + > > if_list = run_command(CMD,&count,&s); > > if (if_list == 0) { > > CU_DEBUG("Failed to get network interfaces"); > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > -- > Chip Vincent > Open Virtualization > IBM Linux Technology Center > cvincent at linux.vnet.ibm.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From snmishra at us.ibm.com Wed Mar 16 17:01:07 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 16 Mar 2011 10:01:07 -0700 Subject: [Libvirt-cim] [PATCH] Add support for Pegasus OOP grouping In-Reply-To: <6cdfba0135e08b8b5878.1300235600@oc0840652111.ibm.com> References: <6cdfba0135e08b8b5878.1300235600@oc0840652111.ibm.com> Message-ID: +1 test was successful. Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 03/15/2011 05:33:20 PM: > Chip Vincent > Sent by: libvirt-cim-bounces at redhat.com > > 03/15/2011 05:33 PM > > Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > [Libvirt-cim] [PATCH] Add support for Pegasus OOP grouping > > # HG changeset patch > # User Chip Vincent > # Date 1300235494 14400 > # Node ID 6cdfba0135e08b8b5878075dff77b5e03107c614 > # Parent eea958fbf1d965bc1053850f59df4005e64093ac > Add support for Pegasus OOP grouping > > Update Pegasus ProviderModule registration to include support for > ModuleGroupProperty. This will allow all libvirt-cim provider to > load into a single process when the CIMOM is configured to run > providers outside the CIMOM process. > > Signed-off-by: Chip Vincent > > diff --git a/provider-register.sh b/provider-register.sh > --- a/provider-register.sh > +++ b/provider-register.sh > @@ -32,6 +32,43 @@ > return 1 > } > > +pegasus_version() > +{ > + CIMSERVER=`pegasus_path cimserver` > + if test $? != 0 > + then > + echo "Error: cimserver not found" >&2 > + return 1 > + fi > + > + VERSION=`$CIMSERVER --version` > + if test $? != 0 > + then > + echo "Error: could not determine cimserver version" >&2 > + return 1 > + fi > + > + echo $VERSION > + return 0 > +} > + > +compare_version() > +{ > + source=`echo "$1" | awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'` > + target=`echo "$2" | awk -F. '{printf("%02d%02d%02d\n", $1,$2,$3); }'` > + > + if test $source \< $target > + then > + chatter $source " < " $target > + echo "true" > + return 0 > + else > + chatter $source " >= " $target > + echo "false" > + return 1 > + fi > +} > + > pegasus_transform() > { > OUTFILE=$1 > @@ -49,10 +86,15 @@ > > # produce ProviderModules > echo > $OUTFILE > - chatter "Processing provider modules:" $PROVIDERMODULES > - for pm in $PROVIDERMODULES > - do > - cat >> $OUTFILE < + version=`pegasus_version` > + chatter "cimserver version is " $version > + if compare_version "$version" "2.11.0" > + then > + chatter "Processing provider modules (w/o ModuleGroupName):" \ > + $PROVIDERMODULES > + for pm in $PROVIDERMODULES > + do > + cat >> $OUTFILE < instance of PG_ProviderModule > { > Name = "$pm"; > @@ -65,7 +107,29 @@ > > EOFPM > done > + > + else > + chatter "Processing provider modules (w/ ModuleGroupName):" \ > + $PROVIDERMODULES > + for pm in $PROVIDERMODULES > + do > + cat >> $OUTFILE < +instance of PG_ProviderModule > +{ > + Name = "$pm"; > + Location = "$pm"; > + Vendor = "SBLIM"; > + Version = "2.0.0"; > + InterfaceType = "CMPI"; > + InterfaceVersion = "2.0.0"; > + ModuleGroupName = "libvirt-cim"; > +}; > + > +EOFPM > + done > > + fi > + > # produce Providers > set -- $PROVIDERS > while test x$1 != x > @@ -170,6 +234,7 @@ > myregs= > mofmode=1 > namespace=$1 > + version=`pegasus_version` > shift > > while test x$1 != x > @@ -206,7 +271,7 @@ > > if pegasus_transform $_REGFILENAME $namespace $myregs > then > - chatter Registering providers with $state cimserver > + chatter Registering providers with $state cimserver '('$version')' > $CIMMOF -uc -I $mofpath -n $namespace $mymofs && > $CIMMOF -uc -n root/PG_Interop $_REGFILENAME > else > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From cvincent at linux.vnet.ibm.com Mon Mar 21 19:07:21 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Mon, 21 Mar 2011 15:07:21 -0400 Subject: [Libvirt-cim] [PATCH] Add VNC autoport support Message-ID: <505a9e36438d02c8b580.1300734441@oc0840652111.ibm.com> # HG changeset patch # User Chip Vincent # Date 1300734383 14400 # Node ID 505a9e36438d02c8b580a0ac103e6b8ab0b5cda4 # Parent 1ac08805bf69fd5e09db234f61860f986f29e0b9 Add VNC autoport support Signed-off-by: Chip Vincent diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -406,6 +406,12 @@ goto out; xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); + + if(dev->port == "-1") + xmlNewProp(tmp, BAD_CAST "autoport" BAD_CAST "yes") + else + xmlNewProp(tmp, BAD_CAST "autoport" BAD_CAST "no") + xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap); From snmishra at us.ibm.com Mon Mar 21 21:17:48 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Mon, 21 Mar 2011 14:17:48 -0700 Subject: [Libvirt-cim] [PATCH] Add VNC autoport support In-Reply-To: <505a9e36438d02c8b580.1300734441@oc0840652111.ibm.com> References: <505a9e36438d02c8b580.1300734441@oc0840652111.ibm.com> Message-ID: This patch fails to compile. Please correct and resend. Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 03/21/2011 12:07:21 PM: > Chip Vincent > Sent by: libvirt-cim-bounces at redhat.com > > 03/21/11 12:07 PM > > Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > [Libvirt-cim] [PATCH] Add VNC autoport support > > # HG changeset patch > # User Chip Vincent > # Date 1300734383 14400 > # Node ID 505a9e36438d02c8b580a0ac103e6b8ab0b5cda4 > # Parent 1ac08805bf69fd5e09db234f61860f986f29e0b9 > Add VNC autoport support > > Signed-off-by: Chip Vincent > > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -406,6 +406,12 @@ > goto out; > > xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); > + > + if(dev->port == "-1") > + xmlNewProp(tmp, BAD_CAST "autoport" BAD_CAST "yes") > + else > + xmlNewProp(tmp, BAD_CAST "autoport" BAD_CAST "no") > + > xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); > xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev-> keymap); > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From cvincent at linux.vnet.ibm.com Tue Mar 22 01:08:00 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Mon, 21 Mar 2011 21:08:00 -0400 Subject: [Libvirt-cim] [PATCH #2] Add VNC autoport support. Updated patch to resolve compilation issues, and omit the port property if =1 and only set autoport=yes Message-ID: # HG changeset patch # User Chip Vincent # Date 1300756004 14400 # Node ID ee92bc70899ca4dd6f169c89edc4d374163f3b4f # Parent 1ac08805bf69fd5e09db234f61860f986f29e0b9 Add VNC autoport support. Updated patch to resolve compilation issues, and omit the port property if =1 and only set autoport=yes. Signed-off-by: Chip Vincent diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -405,7 +405,11 @@ if (STREQC(dev->type, "sdl")) goto out; - xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); + if (STREQC(dev->port, "-1")) + xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); + else + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); + xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap); From snmishra at us.ibm.com Tue Mar 22 01:45:22 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Mon, 21 Mar 2011 18:45:22 -0700 Subject: [Libvirt-cim] [PATCH #2] Add VNC autoport support. Updated patch to resolve compilation issues, and omit the port property if =1 and only set autoport=yes In-Reply-To: References: Message-ID: +1 code follows coding guidelines, compiles and cimtest "VirtualSystemManagementService - 20_verify_vnc_password.py" passes. Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 03/21/2011 06:08:00 PM: > Chip Vincent > Sent by: libvirt-cim-bounces at redhat.com > > 03/21/11 06:08 PM > > Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > [Libvirt-cim] [PATCH #2] Add VNC autoport support. Updated patch to > resolve compilation issues, and omit the port property if =1 and > only set autoport=yes > > # HG changeset patch > # User Chip Vincent > # Date 1300756004 14400 > # Node ID ee92bc70899ca4dd6f169c89edc4d374163f3b4f > # Parent 1ac08805bf69fd5e09db234f61860f986f29e0b9 > Add VNC autoport support. Updated patch to resolve compilation > issues, and omit the port property if =1 and only set autoport=yes. > > Signed-off-by: Chip Vincent > > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -405,7 +405,11 @@ > if (STREQC(dev->type, "sdl")) > goto out; > > - xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); > + if (STREQC(dev->port, "-1")) > + xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); > + else > + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev-> port); > + > xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); > xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev-> keymap); > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From snmishra at us.ibm.com Wed Mar 23 16:36:50 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 23 Mar 2011 09:36:50 -0700 Subject: [Libvirt-cim] [PATCH] Add check to verify that sysname is not null Message-ID: <6e35991ef06d5f568bdf.1300898210@elm3a148.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1300897966 25200 # Node ID 6e35991ef06d5f568bdfb199921e8591b1cf6452 # Parent 62c565a5f71453b02cfcd1317e4a186f2ac1c519 Add check to verify that sysname is not null. All string values like SystemCreationClass name and SystemName etc are not being checked for null before setting these properties. Signed-off-by: Sharad Mishra diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_ConcreteComponent.c --- a/src/Virt_ConcreteComponent.c Mon Mar 21 21:35:54 2011 -0400 +++ b/src/Virt_ConcreteComponent.c Wed Mar 23 09:32:46 2011 -0700 @@ -85,9 +85,16 @@ goto out; CMAddKey(path, "CreationClassName", cn, CMPI_chars); - CMAddKey(path, "SystemName", sys, CMPI_chars); - CMAddKey(path, "SystemCreationClassName", syscc, CMPI_chars); - CMAddKey(path, "DeviceID", bridge, CMPI_chars); + + if (sys != NULL) + CMAddKey(path, "SystemName", sys, CMPI_chars); + + if (syscc != NULL) + CMAddKey(path, "SystemCreationClassName", + syscc, CMPI_chars); + + if (bridge != NULL) + CMAddKey(path, "DeviceID", bridge, CMPI_chars); inst = CBGetInstance(_BROKER, context, path, NULL, s); out: diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_ConsoleRedirectionService.c --- a/src/Virt_ConsoleRedirectionService.c Mon Mar 21 21:35:54 2011 -0400 +++ b/src/Virt_ConsoleRedirectionService.c Wed Mar 23 09:32:46 2011 -0700 @@ -67,11 +67,13 @@ CMSetProperty(inst, "Name", (CMPIValue *)"ConsoleRedirectionService", CMPI_chars); - CMSetProperty(inst, "SystemName", - (CMPIValue *)name, CMPI_chars); + if (name != NULL) + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); - CMSetProperty(inst, "SystemCreationClassName", - (CMPIValue *)ccname, CMPI_chars); + if (ccname != NULL) + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)ccname, CMPI_chars); array = CMNewArray(broker, 1, CMPI_uint16, &s); if ((s.rc != CMPI_RC_OK) || CMIsNullObject(array)) diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_Device.c --- a/src/Virt_Device.c Mon Mar 21 21:35:54 2011 -0400 +++ b/src/Virt_Device.c Wed Mar 23 09:32:46 2011 -0700 @@ -344,8 +344,9 @@ if (conn) { char *sccn = NULL; sccn = get_typed_class(pfx_from_conn(conn), "ComputerSystem"); - CMSetProperty(instance, "SystemCreationClassName", - (CMPIValue *)sccn, CMPI_chars); + if (sccn != NULL) + CMSetProperty(instance, "SystemCreationClassName", + (CMPIValue *)sccn, CMPI_chars); free(sccn); } diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_KVMRedirectionSAP.c --- a/src/Virt_KVMRedirectionSAP.c Mon Mar 21 21:35:54 2011 -0400 +++ b/src/Virt_KVMRedirectionSAP.c Wed Mar 23 09:32:46 2011 -0700 @@ -76,17 +76,21 @@ pfx = class_prefix_name(CLASSNAME(ref)); sccn = get_typed_class(pfx, "ComputerSystem"); - CMSetProperty(inst, "Name", - (CMPIValue *)id, CMPI_chars); + if (id != NULL) + CMSetProperty(inst, "Name", + (CMPIValue *)id, CMPI_chars); - CMSetProperty(inst, "SystemName", - (CMPIValue *)port->name, CMPI_chars); + if (port->name != NULL) + CMSetProperty(inst, "SystemName", + (CMPIValue *)port->name, CMPI_chars); - CMSetProperty(inst, "SystemCreationClassName", - (CMPIValue *)sccn, CMPI_chars); + if (sccn != NULL) + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)sccn, CMPI_chars); - CMSetProperty(inst, "ElementName", - (CMPIValue *)id, CMPI_chars); + if (id != NULL) + CMSetProperty(inst, "ElementName", + (CMPIValue *)id, CMPI_chars); prop_val = (uint16_t)CIM_CRS_VNC; CMSetProperty(inst, "KVMProtocol", diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Mon Mar 21 21:35:54 2011 -0400 +++ b/src/Virt_ResourcePoolConfigurationService.c Wed Mar 23 09:32:46 2011 -0700 @@ -1200,11 +1200,13 @@ CMSetProperty(inst, "Name", (CMPIValue *)"RPCS", CMPI_chars); - CMSetProperty(inst, "SystemName", - (CMPIValue *)name, CMPI_chars); + if (name != NULL) + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); - CMSetProperty(inst, "SystemCreationClassName", - (CMPIValue *)ccname, CMPI_chars); + if (ccname != NULL) + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)ccname, CMPI_chars); if (is_get_inst) { s = cu_validate_ref(broker, reference, inst); diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_SwitchService.c --- a/src/Virt_SwitchService.c Mon Mar 21 21:35:54 2011 -0400 +++ b/src/Virt_SwitchService.c Wed Mar 23 09:32:46 2011 -0700 @@ -175,11 +175,13 @@ (CMPIValue *)"Switch Virtualization Capabilities", CMPI_chars); - CMSetProperty(inst, "SystemName", - (CMPIValue *)name, CMPI_chars); + if (name != NULL) + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); - CMSetProperty(inst, "SystemCreationClassName", - (CMPIValue *)ccname, CMPI_chars); + if (ccname != NULL) + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)ccname, CMPI_chars); out: return s; diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Mon Mar 21 21:35:54 2011 -0400 +++ b/src/Virt_VSMigrationService.c Wed Mar 23 09:32:46 2011 -0700 @@ -1698,11 +1698,13 @@ CMSetProperty(inst, "Name", (CMPIValue *)"MigrationService", CMPI_chars); - CMSetProperty(inst, "SystemName", - (CMPIValue *)name, CMPI_chars); + if (name != NULL) + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); - CMSetProperty(inst, "SystemCreationClassName", - (CMPIValue *)ccname, CMPI_chars); + if (ccname != NULL) + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)ccname, CMPI_chars); if (is_get_inst) { s = cu_validate_ref(broker, ref, inst); diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon Mar 21 21:35:54 2011 -0400 +++ b/src/Virt_VirtualSystemManagementService.c Wed Mar 23 09:32:46 2011 -0700 @@ -3057,11 +3057,13 @@ CMSetProperty(inst, "Name", (CMPIValue *)"Management Service", CMPI_chars); - CMSetProperty(inst, "SystemName", - (CMPIValue *)name, CMPI_chars); - - CMSetProperty(inst, "SystemCreationClassName", - (CMPIValue *)ccname, CMPI_chars); + if (name != NULL) + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); + + if (ccname != NULL) + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)ccname, CMPI_chars); CMSetProperty(inst, "Changeset", (CMPIValue *)LIBVIRT_CIM_CS, CMPI_chars); diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_VirtualSystemSnapshotService.c --- a/src/Virt_VirtualSystemSnapshotService.c Mon Mar 21 21:35:54 2011 -0400 +++ b/src/Virt_VirtualSystemSnapshotService.c Wed Mar 23 09:32:46 2011 -0700 @@ -626,8 +626,8 @@ CMPIInstance *inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; - const char *name; - const char *ccname; + const char *name = NULL; + const char *ccname = NULL; s = get_host_system_properties(&name, &ccname, @@ -644,11 +644,13 @@ CMSetProperty(inst, "Name", (CMPIValue *)"SnapshotService", CMPI_chars); - CMSetProperty(inst, "SystemName", - (CMPIValue *)name, CMPI_chars); + if (name != NULL) + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); - CMSetProperty(inst, "SystemCreationClassName", - (CMPIValue *)ccname, CMPI_chars); + if (ccname != NULL) + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)ccname, CMPI_chars); out: return s; From snmishra at us.ibm.com Wed Mar 23 17:43:59 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 23 Mar 2011 17:43:59 -0000 Subject: [Libvirt-cim] [PATCH] Added support for disk driver Message-ID: <1818f2324144b0a0fa21.1300902239@elm3b193.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1300902032 25200 # Node ID 1818f2324144b0a0fa21b1eea1a7dabac1a5eb7f # Parent 62c565a5f71453b02cfcd1317e4a186f2ac1c519 Added support for disk driver. With this patch libvirt-cim allows a user to pass disk driver information. Currently a libvirt-cim XML looks like - with this patch a user can optionally add driver properties to look like - Signed-off-by: Sharad Mishra diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -53,6 +53,7 @@ free(dev->type); free(dev->device); free(dev->driver); + free(dev->driver_type); free(dev->cache); free(dev->source); free(dev->virtual_dev); @@ -242,6 +243,7 @@ ddev->driver = get_attr_value(child, "name"); if (ddev->driver == NULL) goto err; + ddev->driver_type = get_attr_value(child, "type"); ddev->cache = get_attr_value(child, "cache"); } else if (XSTREQ(child->name, "source")) { ddev->source = get_attr_value(child, "file"); @@ -741,6 +743,7 @@ DUP_FIELD(dev, _dev, dev.disk.type); DUP_FIELD(dev, _dev, dev.disk.device); DUP_FIELD(dev, _dev, dev.disk.driver); + DUP_FIELD(dev, _dev, dev.disk.driver_type); DUP_FIELD(dev, _dev, dev.disk.cache); DUP_FIELD(dev, _dev, dev.disk.source); DUP_FIELD(dev, _dev, dev.disk.virtual_dev); diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -47,6 +47,7 @@ char *type; char *device; char *driver; + char *driver_type; char *source; char *virtual_dev; enum {DISK_UNKNOWN, DISK_PHY, DISK_FILE, DISK_FS} disk_type; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -50,7 +50,20 @@ if (disk == NULL) return XML_ERROR; xmlNewProp(disk, BAD_CAST "type", BAD_CAST "block"); - xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device); + if (dev->device) + xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device); + + if (dev->driver) { + tmp = xmlNewChild(disk, NULL, BAD_CAST "driver", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "name", BAD_CAST dev->driver); + if (dev->driver_type) + xmlNewProp(tmp, BAD_CAST "type", + BAD_CAST dev->driver_type); + if (dev->cache) + xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST dev->cache); + } tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); if (tmp == NULL) @@ -82,14 +95,18 @@ if (disk == NULL) return XML_ERROR; xmlNewProp(disk, BAD_CAST "type", BAD_CAST "file"); - xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device); + if (dev->device) + xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device); - tmp = xmlNewChild(disk, NULL, BAD_CAST "driver", NULL); - if (tmp == NULL) - return XML_ERROR; - if(dev->driver != NULL) { + if (dev->driver) { + tmp = xmlNewChild(disk, NULL, BAD_CAST "driver", NULL); + if (tmp == NULL) + return XML_ERROR; xmlNewProp(tmp, BAD_CAST "name", BAD_CAST dev->driver); - if(dev->cache != NULL) + if (dev->driver_type) + xmlNewProp(tmp, BAD_CAST "type", + BAD_CAST dev->driver_type); + if (dev->cache) xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST dev->cache); } @@ -411,7 +428,6 @@ xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); } - xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap); diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -20,9 +20,14 @@ [Description ("readonly mode for disk")] boolean readonly; + [Description ("Primary backend driver name")] + string DriverName; + + [Description ("Optional subtype backend driver")] + string DriverType; + [Description ("cache setting for device")] - string cache; - + string DriverCache; }; [Description ("KVM virtual disk configuration"), @@ -45,8 +50,14 @@ [Description ("readonly mode for disk")] boolean readonly; + [Description ("Primary backend driver name")] + string DriverName; + + [Description ("Optional subtype backend driver")] + string DriverType; + [Description ("cache setting for device")] - string cache; + string DriverCache; }; [Description ("LXC virtual disk configuration"), diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -281,9 +281,21 @@ (CMPIValue *)&(dev->dev.disk.readonly), CMPI_boolean); + if(dev->dev.disk.driver) + CMSetProperty(inst, + "DriverName", + (CMPIValue *)dev->dev.disk.driver, + CMPI_chars); + + if(dev->dev.disk.driver_type) + CMSetProperty(inst, + "DriverType", + (CMPIValue *)dev->dev.disk.driver_type, + CMPI_chars); + if(dev->dev.disk.cache) CMSetProperty(inst, - "cache", + "DriverCache", (CMPIValue *)dev->dev.disk.cache, CMPI_chars); diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -882,8 +882,20 @@ else dev->dev.disk.bus_type = strdup(val); + free(dev->dev.disk.driver); + if (cu_get_str_prop(inst, "DriverName", &val) != CMPI_RC_OK) + dev->dev.disk.driver = NULL; + else + dev->dev.disk.driver = strdup(val); + + free(dev->dev.disk.driver_type); + if (cu_get_str_prop(inst, "DriverType", &val) != CMPI_RC_OK) + dev->dev.disk.driver_type = NULL; + else + dev->dev.disk.driver_type = strdup(val); + free(dev->dev.disk.cache); - if (cu_get_str_prop(inst, "cache", &val) != CMPI_RC_OK) + if (cu_get_str_prop(inst, "DriverCache", &val) != CMPI_RC_OK) dev->dev.disk.cache = NULL; else dev->dev.disk.cache = strdup(val); From cvincent at linux.vnet.ibm.com Fri Mar 25 01:11:55 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 24 Mar 2011 21:11:55 -0400 Subject: [Libvirt-cim] [PATCH] Add check to verify that sysname is not null In-Reply-To: <6e35991ef06d5f568bdf.1300898210@elm3a148.beaverton.ibm.com> References: <6e35991ef06d5f568bdf.1300898210@elm3a148.beaverton.ibm.com> Message-ID: <4D8BEBDB.1020604@linux.vnet.ibm.com> +1 on these changes. I think some additional error checkign might be a good idea. First, we should add some error checking to the lib function that initially gathers theses values and check that return code in providers. Second, setting a property to NULL and not setting a property are essentially the same thing in CIM. The property assumes a default value, which in most cases is NULL. I'll open a BZ for this and we can resolve that way. Thanks! On 03/23/2011 12:36 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1300897966 25200 > # Node ID 6e35991ef06d5f568bdfb199921e8591b1cf6452 > # Parent 62c565a5f71453b02cfcd1317e4a186f2ac1c519 > Add check to verify that sysname is not null. > > All string values like SystemCreationClass name and SystemName etc are not being checked for null before setting these properties. > > Signed-off-by: Sharad Mishra > > diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_ConcreteComponent.c > --- a/src/Virt_ConcreteComponent.c Mon Mar 21 21:35:54 2011 -0400 > +++ b/src/Virt_ConcreteComponent.c Wed Mar 23 09:32:46 2011 -0700 > @@ -85,9 +85,16 @@ > goto out; > > CMAddKey(path, "CreationClassName", cn, CMPI_chars); > - CMAddKey(path, "SystemName", sys, CMPI_chars); > - CMAddKey(path, "SystemCreationClassName", syscc, CMPI_chars); > - CMAddKey(path, "DeviceID", bridge, CMPI_chars); > + > + if (sys != NULL) > + CMAddKey(path, "SystemName", sys, CMPI_chars); > + > + if (syscc != NULL) > + CMAddKey(path, "SystemCreationClassName", > + syscc, CMPI_chars); > + > + if (bridge != NULL) > + CMAddKey(path, "DeviceID", bridge, CMPI_chars); > > inst = CBGetInstance(_BROKER, context, path, NULL, s); > out: > diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_ConsoleRedirectionService.c > --- a/src/Virt_ConsoleRedirectionService.c Mon Mar 21 21:35:54 2011 -0400 > +++ b/src/Virt_ConsoleRedirectionService.c Wed Mar 23 09:32:46 2011 -0700 > @@ -67,11 +67,13 @@ > CMSetProperty(inst, "Name", > (CMPIValue *)"ConsoleRedirectionService", CMPI_chars); > > - CMSetProperty(inst, "SystemName", > - (CMPIValue *)name, CMPI_chars); > + if (name != NULL) > + CMSetProperty(inst, "SystemName", > + (CMPIValue *)name, CMPI_chars); > > - CMSetProperty(inst, "SystemCreationClassName", > - (CMPIValue *)ccname, CMPI_chars); > + if (ccname != NULL) > + CMSetProperty(inst, "SystemCreationClassName", > + (CMPIValue *)ccname, CMPI_chars); > > array = CMNewArray(broker, 1, CMPI_uint16,&s); > if ((s.rc != CMPI_RC_OK) || CMIsNullObject(array)) > diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_Device.c > --- a/src/Virt_Device.c Mon Mar 21 21:35:54 2011 -0400 > +++ b/src/Virt_Device.c Wed Mar 23 09:32:46 2011 -0700 > @@ -344,8 +344,9 @@ > if (conn) { > char *sccn = NULL; > sccn = get_typed_class(pfx_from_conn(conn), "ComputerSystem"); > - CMSetProperty(instance, "SystemCreationClassName", > - (CMPIValue *)sccn, CMPI_chars); > + if (sccn != NULL) > + CMSetProperty(instance, "SystemCreationClassName", > + (CMPIValue *)sccn, CMPI_chars); > free(sccn); > } > > diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_KVMRedirectionSAP.c > --- a/src/Virt_KVMRedirectionSAP.c Mon Mar 21 21:35:54 2011 -0400 > +++ b/src/Virt_KVMRedirectionSAP.c Wed Mar 23 09:32:46 2011 -0700 > @@ -76,17 +76,21 @@ > pfx = class_prefix_name(CLASSNAME(ref)); > sccn = get_typed_class(pfx, "ComputerSystem"); > > - CMSetProperty(inst, "Name", > - (CMPIValue *)id, CMPI_chars); > + if (id != NULL) > + CMSetProperty(inst, "Name", > + (CMPIValue *)id, CMPI_chars); > > - CMSetProperty(inst, "SystemName", > - (CMPIValue *)port->name, CMPI_chars); > + if (port->name != NULL) > + CMSetProperty(inst, "SystemName", > + (CMPIValue *)port->name, CMPI_chars); > > - CMSetProperty(inst, "SystemCreationClassName", > - (CMPIValue *)sccn, CMPI_chars); > + if (sccn != NULL) > + CMSetProperty(inst, "SystemCreationClassName", > + (CMPIValue *)sccn, CMPI_chars); > > - CMSetProperty(inst, "ElementName", > - (CMPIValue *)id, CMPI_chars); > + if (id != NULL) > + CMSetProperty(inst, "ElementName", > + (CMPIValue *)id, CMPI_chars); > > prop_val = (uint16_t)CIM_CRS_VNC; > CMSetProperty(inst, "KVMProtocol", > diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_ResourcePoolConfigurationService.c > --- a/src/Virt_ResourcePoolConfigurationService.c Mon Mar 21 21:35:54 2011 -0400 > +++ b/src/Virt_ResourcePoolConfigurationService.c Wed Mar 23 09:32:46 2011 -0700 > @@ -1200,11 +1200,13 @@ > CMSetProperty(inst, "Name", > (CMPIValue *)"RPCS", CMPI_chars); > > - CMSetProperty(inst, "SystemName", > - (CMPIValue *)name, CMPI_chars); > + if (name != NULL) > + CMSetProperty(inst, "SystemName", > + (CMPIValue *)name, CMPI_chars); > > - CMSetProperty(inst, "SystemCreationClassName", > - (CMPIValue *)ccname, CMPI_chars); > + if (ccname != NULL) > + CMSetProperty(inst, "SystemCreationClassName", > + (CMPIValue *)ccname, CMPI_chars); > > if (is_get_inst) { > s = cu_validate_ref(broker, reference, inst); > diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_SwitchService.c > --- a/src/Virt_SwitchService.c Mon Mar 21 21:35:54 2011 -0400 > +++ b/src/Virt_SwitchService.c Wed Mar 23 09:32:46 2011 -0700 > @@ -175,11 +175,13 @@ > (CMPIValue *)"Switch Virtualization Capabilities", > CMPI_chars); > > - CMSetProperty(inst, "SystemName", > - (CMPIValue *)name, CMPI_chars); > + if (name != NULL) > + CMSetProperty(inst, "SystemName", > + (CMPIValue *)name, CMPI_chars); > > - CMSetProperty(inst, "SystemCreationClassName", > - (CMPIValue *)ccname, CMPI_chars); > + if (ccname != NULL) > + CMSetProperty(inst, "SystemCreationClassName", > + (CMPIValue *)ccname, CMPI_chars); > > out: > return s; > diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_VSMigrationService.c > --- a/src/Virt_VSMigrationService.c Mon Mar 21 21:35:54 2011 -0400 > +++ b/src/Virt_VSMigrationService.c Wed Mar 23 09:32:46 2011 -0700 > @@ -1698,11 +1698,13 @@ > CMSetProperty(inst, "Name", > (CMPIValue *)"MigrationService", CMPI_chars); > > - CMSetProperty(inst, "SystemName", > - (CMPIValue *)name, CMPI_chars); > + if (name != NULL) > + CMSetProperty(inst, "SystemName", > + (CMPIValue *)name, CMPI_chars); > > - CMSetProperty(inst, "SystemCreationClassName", > - (CMPIValue *)ccname, CMPI_chars); > + if (ccname != NULL) > + CMSetProperty(inst, "SystemCreationClassName", > + (CMPIValue *)ccname, CMPI_chars); > > if (is_get_inst) { > s = cu_validate_ref(broker, ref, inst); > diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c Mon Mar 21 21:35:54 2011 -0400 > +++ b/src/Virt_VirtualSystemManagementService.c Wed Mar 23 09:32:46 2011 -0700 > @@ -3057,11 +3057,13 @@ > CMSetProperty(inst, "Name", > (CMPIValue *)"Management Service", CMPI_chars); > > - CMSetProperty(inst, "SystemName", > - (CMPIValue *)name, CMPI_chars); > - > - CMSetProperty(inst, "SystemCreationClassName", > - (CMPIValue *)ccname, CMPI_chars); > + if (name != NULL) > + CMSetProperty(inst, "SystemName", > + (CMPIValue *)name, CMPI_chars); > + > + if (ccname != NULL) > + CMSetProperty(inst, "SystemCreationClassName", > + (CMPIValue *)ccname, CMPI_chars); > > CMSetProperty(inst, "Changeset", > (CMPIValue *)LIBVIRT_CIM_CS, CMPI_chars); > diff -r 62c565a5f714 -r 6e35991ef06d src/Virt_VirtualSystemSnapshotService.c > --- a/src/Virt_VirtualSystemSnapshotService.c Mon Mar 21 21:35:54 2011 -0400 > +++ b/src/Virt_VirtualSystemSnapshotService.c Wed Mar 23 09:32:46 2011 -0700 > @@ -626,8 +626,8 @@ > CMPIInstance *inst) > { > CMPIStatus s = {CMPI_RC_OK, NULL}; > - const char *name; > - const char *ccname; > + const char *name = NULL; > + const char *ccname = NULL; > > s = get_host_system_properties(&name, > &ccname, > @@ -644,11 +644,13 @@ > CMSetProperty(inst, "Name", > (CMPIValue *)"SnapshotService", CMPI_chars); > > - CMSetProperty(inst, "SystemName", > - (CMPIValue *)name, CMPI_chars); > + if (name != NULL) > + CMSetProperty(inst, "SystemName", > + (CMPIValue *)name, CMPI_chars); > > - CMSetProperty(inst, "SystemCreationClassName", > - (CMPIValue *)ccname, CMPI_chars); > + if (ccname != NULL) > + CMSetProperty(inst, "SystemCreationClassName", > + (CMPIValue *)ccname, CMPI_chars); > > out: > return s; > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From snmishra at us.ibm.com Tue Mar 29 17:49:11 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Tue, 29 Mar 2011 10:49:11 -0700 Subject: [Libvirt-cim] [PATCH] [TEST] Look for SNIA profile while gathering SLP profiles Message-ID: <4f37c9bb6b41d678f0cd.1301420951@elm3a148.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1301420804 25200 # Node ID 4f37c9bb6b41d678f0cd019dded1c35cd617e339 # Parent 73e89596e15d229befd24a80f84806153b924a17 [TEST] Look for SNIA profile while gathering SLP profiles. This cimtest was only looking at DMTF profiles and was not parsing SNIA profiles correctly. This patch fixes that issue. Signed-off-by: Sharad Mishra diff -r 73e89596e15d -r 4f37c9bb6b41 suites/libvirt-cim/cimtest/Profile/04_verify_libvirt_cim_slp_profiles.py --- a/suites/libvirt-cim/cimtest/Profile/04_verify_libvirt_cim_slp_profiles.py Tue Mar 29 10:23:32 2011 -0700 +++ b/suites/libvirt-cim/cimtest/Profile/04_verify_libvirt_cim_slp_profiles.py Tue Mar 29 10:46:44 2011 -0700 @@ -89,6 +89,16 @@ lines = line.split("RegisteredProfilesSupported") dmtf_profiles = lines[1].split("DMTF") for profile in dmtf_profiles: + snia = profile.split(",SNIA") + for sprofile in snia: + tmp_prof = sprofile.rsplit(":", 1) + if len(tmp_prof) < 2: + return [] + + temp_reg_ele = tmp_prof[1].rstrip(",") + reg_prof_name = temp_reg_ele.rstrip(")") + slp_profile_list.append(reg_prof_name) + tmp_prof = profile.rsplit(":", 1) if len(tmp_prof) < 2: return [] @@ -163,6 +173,8 @@ # Make sure all the Libvirt-CIM profiles are advertised via slp if (libvirt_cim_reg_list) <= (slp_profile_list): logger.info("Successfully verified the Libvirt-CIM profiles") + logger.info("Slp returned profile --> %s,\n Libvirt-CIM expected " + "profiles %s", slp_profile_list, libvirt_cim_reg_list) return PASS logger.error("Mismatch in the profiles registered") From cvincent at linux.vnet.ibm.com Wed Mar 30 14:53:51 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 30 Mar 2011 10:53:51 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Look for SNIA profile while gathering SLP profiles In-Reply-To: <4f37c9bb6b41d678f0cd.1301420951@elm3a148.beaverton.ibm.com> References: <4f37c9bb6b41d678f0cd.1301420951@elm3a148.beaverton.ibm.com> Message-ID: <4D9343FF.9030004@linux.vnet.ibm.com> +1. Thanks. On 03/29/2011 01:49 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1301420804 25200 > # Node ID 4f37c9bb6b41d678f0cd019dded1c35cd617e339 > # Parent 73e89596e15d229befd24a80f84806153b924a17 > [TEST] Look for SNIA profile while gathering SLP profiles. > > This cimtest was only looking at DMTF profiles and was not parsing SNIA profiles correctly. This patch fixes that issue. > > Signed-off-by: Sharad Mishra > > diff -r 73e89596e15d -r 4f37c9bb6b41 suites/libvirt-cim/cimtest/Profile/04_verify_libvirt_cim_slp_profiles.py > --- a/suites/libvirt-cim/cimtest/Profile/04_verify_libvirt_cim_slp_profiles.py Tue Mar 29 10:23:32 2011 -0700 > +++ b/suites/libvirt-cim/cimtest/Profile/04_verify_libvirt_cim_slp_profiles.py Tue Mar 29 10:46:44 2011 -0700 > @@ -89,6 +89,16 @@ > lines = line.split("RegisteredProfilesSupported") > dmtf_profiles = lines[1].split("DMTF") > for profile in dmtf_profiles: > + snia = profile.split(",SNIA") > + for sprofile in snia: > + tmp_prof = sprofile.rsplit(":", 1) > + if len(tmp_prof)< 2: > + return [] > + > + temp_reg_ele = tmp_prof[1].rstrip(",") > + reg_prof_name = temp_reg_ele.rstrip(")") > + slp_profile_list.append(reg_prof_name) > + > tmp_prof = profile.rsplit(":", 1) > if len(tmp_prof)< 2: > return [] > @@ -163,6 +173,8 @@ > # Make sure all the Libvirt-CIM profiles are advertised via slp > if (libvirt_cim_reg_list)<= (slp_profile_list): > logger.info("Successfully verified the Libvirt-CIM profiles") > + logger.info("Slp returned profile --> %s,\n Libvirt-CIM expected " > + "profiles %s", slp_profile_list, libvirt_cim_reg_list) > return PASS > > logger.error("Mismatch in the profiles registered") > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Wed Mar 30 15:11:47 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 30 Mar 2011 11:11:47 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Test VM's AutoStart feature In-Reply-To: <53f2cfb2a6ea2940b4de.1298473321@elm3a148.beaverton.ibm.com> References: <53f2cfb2a6ea2940b4de.1298473321@elm3a148.beaverton.ibm.com> Message-ID: <4D934833.9090603@linux.vnet.ibm.com> Testing KVM hypervisor -------------------------------------------------------------------- VSSD - 07_autostart.py: PASS -------------------------------------------------------------------- +1 On 02/23/2011 10:02 AM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1298473315 28800 > # Node ID 53f2cfb2a6ea2940b4de62fff16e3413419cb511 > # Parent 4f2bf0006818d2ca4903a0b550dde65e4d581d7c > [TEST] Test VM's AutoStart feature. > > This testcase will create VM, get its AutoStart setting and compare against expected value. Then it changes AutoStart, modifies the VM and reads the AutoStart back to verify that it was changed. > > Signed-off-by: Sharad Mishra > > diff -r 4f2bf0006818 -r 53f2cfb2a6ea suites/libvirt-cim/cimtest/VSSD/07_autostart.py > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/suites/libvirt-cim/cimtest/VSSD/07_autostart.py Wed Feb 23 07:01:55 2011 -0800 > @@ -0,0 +1,118 @@ > +#!/usr/bin/python > +# > +# Copyright 2009 IBM Corp. > +# > +# Authors: > +# Sharad Mishra > +# > +# This library is free software; you can redistribute it and/or > +# modify it under the terms of the GNU General Public > +# License as published by the Free Software Foundation; either > +# version 2.1 of the License, or (at your option) any later version. > +# > +# This library is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > +# General Public License for more details. > +# > +# You should have received a copy of the GNU General Public > +# License along with this library; if not, write to the Free Software > +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > +# > +# This test will create a VM, get its autostart setting and compare against > +# the expected value. Then it sets the autostart to '1', and Modifies the VM. > +# Updated VM's autostart is read and compared. Then once more autostart is reset > +# and VM updated. Updated VM's autostart is again compared. > +# > + > +import sys > +import time > +import pywbem > +from XenKvmLib import vsms > +from XenKvmLib import vxml > +from CimTest.Globals import logger > +from CimTest.ReturnCodes import PASS, FAIL, SKIP > +from XenKvmLib.const import do_main > +from XenKvmLib.classes import get_typed_class, inst_to_mof > +from XenKvmLib.enumclass import GetInstance > +from XenKvmLib.const import get_provider_version > +from pywbem.cim_types import Uint16 > + > +sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] > +default_dom = 'uuid_domain' > +autostart_support = 1076 > + > +def get_vssd(ip, virt, dom): > + cn = get_typed_class(virt, "VirtualSystemSettingData") > + inst = None > + > + try: > + if virt == "XenFV": > + virt = "Xen" > + > + key_list = {"InstanceID" : "%s:%s" % (virt, dom) } > + > + inst = GetInstance(ip, cn, key_list, True) > + > + except Exception, details: > + logger.error(details) > + return FAIL, inst > + > + if inst is None: > + return FAIL, inst > + > + return PASS, inst > + > + at do_main(sup_types) > +def main(): > + options = main.options > + virt = options.virt > + server = options.ip > + > + curr_cim_rev, changeset = get_provider_version(virt, server) > + if curr_cim_rev< autostart_support: > + logger.info("Need provider version %d or greater to run testcase", > + autostart_support) > + return SKIP > + > + service = vsms.get_vsms_class(options.virt)(options.ip) > + > + sxml = None > + cxml = vxml.get_class(options.virt)(default_dom) > + ret = cxml.cim_define(options.ip) > + if not ret: > + logger.error("Failed to define the dom: %s", default_dom) > + return FAIL > + > + status, inst = get_vssd(options.ip, options.virt, default_dom) > + if status != PASS: > + raise Exception("Failed to get the VSSD instance for %s" % > + default_dom) > + inst['AutoStart'] = Uint16(1) > + vssd = inst_to_mof(inst) > + service.ModifySystemSettings(SystemSettings=vssd) > + > + status, inst = get_vssd(options.ip, options.virt, default_dom) > + if status != PASS: > + raise Exception("Failed to get the VSSD instance for %s" % > + default_dom) > + if inst['AutoStart'] != Uint16(1): > + raise Exception("Test failed, Autostart settings mismatch") > + > + inst['AutoStart'] = Uint16(0) > + vssd = inst_to_mof(inst) > + service.ModifySystemSettings(SystemSettings=vssd) > + > + status, inst = get_vssd(options.ip, options.virt, default_dom) > + if status != PASS: > + raise Exception("Failed to get the VSSD instance for %s" % > + default_dom) > + if inst['AutoStart'] != Uint16(0): > + raise Exception("Test failed, Autostart settings mismatch") > + > + cxml.undefine(options.ip) > + return status > + > +if __name__ == "__main__": > + sys.exit(main()) > + > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Wed Mar 30 15:13:42 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 30 Mar 2011 11:13:42 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] New test to check SwitchService provider In-Reply-To: References: Message-ID: <4D9348A6.9050504@linux.vnet.ibm.com> Testing KVM hypervisor -------------------------------------------------------------------- VSSD - 07_autostart.py: PASS -------------------------------------------------------------------- +1 I don't have the proper HW so this is the expected result. On 03/08/2011 06:50 AM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1299548429 28800 > # Node ID f5bc7977f2d5813474b2c56981bd93e2cf9d96b7 > # Parent 4f2bf0006818d2ca4903a0b550dde65e4d581d7c > [TEST] New test to check SwitchService provider > > This test enumerates SwitchService and checks to see if VSI is supported or not. > > Signed-off-by: Sharad Mishra > > diff -r 4f2bf0006818 -r f5bc7977f2d5 suites/libvirt-cim/cimtest/SwitchService/01_enum.py > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/suites/libvirt-cim/cimtest/SwitchService/01_enum.py Mon Mar 07 17:40:29 2011 -0800 > @@ -0,0 +1,51 @@ > +#!/usr/bin/python > +# > +# Copyright 2011 IBM Corp. > +# > +# Authors: > +# Sharad Mishra > +# > +# This library is free software; you can redistribute it and/or > +# modify it under the terms of the GNU General Public > +# License as published by the Free Software Foundation; either > +# version 2.1 of the License, or (at your option) any later version. > +# > +# This library is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > +# General Public License for more details. > +# > +# You should have received a copy of the GNU General Public > +# License along with this library; if not, write to the Free Software > +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > +# > + > +import sys > +from XenKvmLib.const import do_main > +from XenKvmLib import enumclass > +from XenKvmLib.classes import get_typed_class > +from CimTest.Globals import logger > +from CimTest.ReturnCodes import XFAIL > + > +SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV'] > + > + at do_main(SUPPORTED_TYPES) > +def main(): > + options = main.options > + > + cs_class = get_typed_class(options.virt, 'SwitchService') > + try: > + cs = enumclass.EnumInstances(options.ip, cs_class) > + print "Please check if this is the expected result ---" > + for name in cs: > + if name.IsVSISupported: > + print "*** VSI supported ***" > + else: > + print "*** VSI NOT supported ***" > + except Exception, detail: > + logger.error("Exception: %s", detail) > + > + return XFAIL > + > +if __name__ == "__main__": > + sys.exit(main()) > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Wed Mar 30 15:23:00 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 30 Mar 2011 11:23:00 -0400 Subject: [Libvirt-cim] Fwd: Re: [PATCH] [TEST] New test to check SwitchService provider Message-ID: <4D934AD4.50803@linux.vnet.ibm.com> Meant to paste this: Testing KVM hypervisor -------------------------------------------------------------------- SwitchService - 01_enum.py: XFAIL Please check if this is the expected result --- *** VSI NOT supported *** -------------------------------------------------------------------- -------- Original Message -------- Subject: Re: [Libvirt-cim] [PATCH] [TEST] New test to check SwitchService provider Date: Wed, 30 Mar 2011 11:13:42 -0400 From: Chip Vincent Reply-To: cvincent at linux.vnet.ibm.com To: libvirt-cim at redhat.com Testing KVM hypervisor -------------------------------------------------------------------- VSSD - 07_autostart.py: PASS -------------------------------------------------------------------- +1 I don't have the proper HW so this is the expected result. On 03/08/2011 06:50 AM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1299548429 28800 > # Node ID f5bc7977f2d5813474b2c56981bd93e2cf9d96b7 > # Parent 4f2bf0006818d2ca4903a0b550dde65e4d581d7c > [TEST] New test to check SwitchService provider > > This test enumerates SwitchService and checks to see if VSI is supported or not. > > Signed-off-by: Sharad Mishra > > diff -r 4f2bf0006818 -r f5bc7977f2d5 suites/libvirt-cim/cimtest/SwitchService/01_enum.py > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/suites/libvirt-cim/cimtest/SwitchService/01_enum.py Mon Mar 07 17:40:29 2011 -0800 > @@ -0,0 +1,51 @@ > +#!/usr/bin/python > +# > +# Copyright 2011 IBM Corp. > +# > +# Authors: > +# Sharad Mishra > +# > +# This library is free software; you can redistribute it and/or > +# modify it under the terms of the GNU General Public > +# License as published by the Free Software Foundation; either > +# version 2.1 of the License, or (at your option) any later version. > +# > +# This library is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > +# General Public License for more details. > +# > +# You should have received a copy of the GNU General Public > +# License along with this library; if not, write to the Free Software > +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > +# > + > +import sys > +from XenKvmLib.const import do_main > +from XenKvmLib import enumclass > +from XenKvmLib.classes import get_typed_class > +from CimTest.Globals import logger > +from CimTest.ReturnCodes import XFAIL > + > +SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV'] > + > + at do_main(SUPPORTED_TYPES) > +def main(): > + options = main.options > + > + cs_class = get_typed_class(options.virt, 'SwitchService') > + try: > + cs = enumclass.EnumInstances(options.ip, cs_class) > + print "Please check if this is the expected result ---" > + for name in cs: > + if name.IsVSISupported: > + print "*** VSI supported ***" > + else: > + print "*** VSI NOT supported ***" > + except Exception, detail: > + logger.error("Exception: %s", detail) > + > + return XFAIL > + > +if __name__ == "__main__": > + sys.exit(main()) > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Wed Mar 30 21:41:25 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 30 Mar 2011 17:41:25 -0400 Subject: [Libvirt-cim] [PATCH] Add support for console/serial grahpics devices Message-ID: # HG changeset patch # User Chip Vincent # Date 1301520765 14400 # Node ID c241ce1cae4e8c55f84667896beb0683fdb3f42c # Parent a521a11eeec4b41399ca954ab17b874a708eb4b3 Add support for console/serial grahpics devices Add support for Graphics RASD ResourceSubType = console | serial. This includes support for allowing more than a single graphics RASD instance. Instances can be created externally or during DefineSystem. No changes to current level of hotswapping. Signed-off-by: Chip Vincent diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -40,7 +40,8 @@ #define NET_XPATH (xmlChar *)"/domain/devices/interface" #define EMU_XPATH (xmlChar *)"/domain/devices/emulator" #define MEM_XPATH (xmlChar *)"/domain/memory | /domain/currentMemory" -#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics" +#define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ + "/domain/devices/console | /domain/devices/serial" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" #define DEFAULT_BRIDGE "xenbr0" @@ -501,6 +502,7 @@ { struct virt_device *vdev = NULL; struct graphics_device *gdev = NULL; + xmlNode *child = NULL; vdev = calloc(1, sizeof(*vdev)); if (vdev == NULL) @@ -509,24 +511,46 @@ gdev = &(vdev->dev.graphics); gdev->type = get_attr_value(node, "type"); - gdev->port = get_attr_value(node, "port"); - gdev->host = get_attr_value(node, "listen"); - gdev->keymap = get_attr_value(node, "keymap"); - if (gdev->type == NULL) goto err; + CU_DEBUG("graphics device type = %s", gdev->type); + if (STREQC(gdev->type, "vnc")) { - if (gdev->port == NULL) - goto err; + gdev->port = get_attr_value(node, "port"); + gdev->host = get_attr_value(node, "listen"); + gdev->keymap = get_attr_value(node, "keymap"); + } + else if (STREQC(gdev->type, "pty")) { + free(gdev->type); + gdev->type = strdup((char *)node->name); - if (gdev->host == NULL) - goto err; + for (child = node->children; child != NULL; + child = child->next) { + if (XSTREQ(child->name, "source")) + gdev->host = get_attr_value(child, "path"); + else if (XSTREQ(child->name, "target")) + gdev->port = get_attr_value(child, "port"); + } } + else { + CU_DEBUG("Unknown graphics type %s", gdev->type); + goto err; + } + + if (gdev->port == NULL || gdev->host == NULL) + goto err; vdev->type = CIM_RES_TYPE_GRAPHICS; vdev->id = strdup("graphics"); + /* FIXME: IDs should be unique, but that breaks existing tests. + ret = asprintf(&vdev->id, "graphics:%s", gdev->type); + if(ret == -1) { + CU_DEBUG("Failed to create graphics is string"); + goto err; + } */ + *vdevs = vdev; return 1; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -401,43 +401,87 @@ return NULL; } +static const char *graphics_vnc_xml(xmlNodePtr root, + struct graphics_device *dev) +{ + xmlNodePtr tmp = NULL; + + tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + + if (STREQC(dev->type, "sdl")) + return NULL; + + xmlNewProp(root, BAD_CAST "port", BAD_CAST dev->port); + + if (STREQC(dev->port, "-1")) + xmlNewProp(root, BAD_CAST "autoport", BAD_CAST "yes"); + else + xmlNewProp(root, BAD_CAST "autoport", BAD_CAST "no"); + + xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); + + if (dev->passwd != NULL) + xmlNewProp(tmp, BAD_CAST "passwd", BAD_CAST dev->passwd); + + xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap); + + return NULL; +} + +static const char *graphics_pty_xml(xmlNodePtr root, + struct graphics_device *dev) +{ + xmlNodePtr pty = NULL; + xmlNodePtr tmp = NULL; + + pty = xmlNewChild(root, NULL, BAD_CAST dev->type, NULL); + if (pty == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST "pty"); + + tmp = xmlNewChild(pty, NULL, BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->host); + + tmp = xmlNewChild(pty, NULL, BAD_CAST "target", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); + + return NULL; +} + static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo) { + const char *msg = NULL; int i; for (i = 0; i < dominfo->dev_graphics_ct; i++) { - xmlNodePtr tmp; struct virt_device *_dev = &dominfo->dev_graphics[i]; if (_dev->type == CIM_RES_TYPE_UNKNOWN) continue; struct graphics_device *dev = &_dev->dev.graphics; - tmp = xmlNewChild(root, NULL, BAD_CAST "graphics", NULL); - if (tmp == NULL) - return XML_ERROR; - - xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); - - if (STREQC(dev->type, "sdl")) - goto out; - - if (STREQC(dev->port, "-1")) - xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "yes"); - else { - xmlNewProp(tmp, BAD_CAST "autoport", BAD_CAST "no"); - xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->port); - } - xmlNewProp(tmp, BAD_CAST "listen", BAD_CAST dev->host); - xmlNewProp(tmp, BAD_CAST "keymap", BAD_CAST dev->keymap); - - if (dev->passwd != NULL) - xmlNewProp(tmp, - BAD_CAST "passwd", - BAD_CAST dev->passwd); + if (STREQC(dev->type, "vnc") || STREQC(dev->type, "sdl")) + msg = graphics_vnc_xml(root, dev); + else if (STREQC(dev->type, "console") || STREQC(dev->type, "serial")) + msg = graphics_pty_xml(root, dev); + else + continue; + + if(msg != NULL) + return msg; } - out: return NULL; } diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -216,8 +216,10 @@ ] class Xen_GraphicsResourceAllocationSettingData : Xen_ResourceAllocationSettingData { - [Description ("VNC Address. IPv4 in a.b.c.d:port or" - "IPv6 in [ip]:port format")] + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType " + "is 'console', this is a character device path in " + "path:port format (e.g., '/dev/pts/3:0'\)")] string Address; [Description ("Keyboard keymapping")] @@ -235,8 +237,10 @@ ] class KVM_GraphicsResourceAllocationSettingData : KVM_ResourceAllocationSettingData { - [Description ("VNC Address. IPv4 in a.b.c.d:port or" - "IPv6 in [ip]:port format")] + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType " + "is 'console', this is a character device path in " + "path:port format (e.g., '/dev/pts/3:0'\)")] string Address; [Description ("Keyboard keymapping")] @@ -254,8 +258,10 @@ ] class LXC_GraphicsResourceAllocationSettingData : LXC_ResourceAllocationSettingData { - [Description ("VNC Address. IPv4 in a.b.c.d:port or" - "IPv6 in [ip]:port format")] + [Description ("If ResourceSubType is 'vnc', this is a VNC Address. " + "IPv4 in a.b.c.d:port or IPv6 in [ip]:port format. If ResourceSubType " + "is 'console', this is a character device path in " + "path:port format (e.g., '/dev/pts/3:0'\)")] string Address; [Description ("Keyboard keymapping")] diff --git a/src/Virt_Device.c b/src/Virt_Device.c --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -189,14 +189,13 @@ int rc; char *vp_str = NULL; - if (STREQC(dev->type, "vnc")) + if (STREQC(dev->type, "sdl")) + rc = asprintf(&vp_str, "%s", dev->type); + else rc = asprintf(&vp_str, "%s/%s:%s", dev->type, dev->host, dev->port); - else - rc = asprintf(&vp_str, "%s", dev->type); - if (rc == -1) return 0; diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -421,44 +421,57 @@ CMSetProperty(inst, "ResourceSubType", (CMPIValue *)dev->dev.graphics.type, CMPI_chars); - if (STREQC(dev->dev.graphics.type, "vnc")) { + if (STREQC(dev->dev.graphics.type, "sdl")) + rc = asprintf(&addr_str, "%s", dev->dev.graphics.type); + else { rc = asprintf(&addr_str, - "%s:%s", + "%s:%s:%s", + dev->dev.graphics.type, dev->dev.graphics.host, dev->dev.graphics.port); - if (rc == -1) + } + + CU_DEBUG("graphics Address = %s", addr_str); + + if (rc == -1) + goto out; + + CMSetProperty(inst, "Address", + (CMPIValue *)addr_str, CMPI_chars); + + if (STREQC(dev->dev.graphics.type, "vnc")) { + CMSetProperty(inst, "KeyMap", + (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars); + + conn = connect_by_classname(_BROKER, classname, &s); + if (conn == NULL) goto out; - CMSetProperty(inst, "Address", - (CMPIValue *)addr_str, CMPI_chars); + dom = virDomainLookupByName(conn, name); + if (dom == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "Domain %s not found", + name); + goto out; + } - CMSetProperty(inst, "KeyMap", - (CMPIValue *)dev->dev.graphics.keymap, CMPI_chars); + infostore = infostore_open(dom); + if (infostore != NULL) + has_passwd = infostore_get_bool(infostore, + "has_vnc_passwd"); + + if (has_passwd) { + CU_DEBUG("has password"); + CMSetProperty(inst, "Password", + (CMPIValue *)"********", CMPI_chars); + } + + infostore_close(infostore); + + /* FIXME: Populate the IsIPv6Only */ } - conn = connect_by_classname(_BROKER, classname, &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, name); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "Domain %s not found", - name); - goto out; - } - - infostore = infostore_open(dom); - if (infostore != NULL) - has_passwd = infostore_get_bool(infostore, "has_vnc_passwd"); - - if (has_passwd) - CMSetProperty(inst, "Password", - (CMPIValue *)"********", CMPI_chars); - - infostore_close(infostore); - out: free(addr_str); virDomainFree(dom); diff --git a/src/Virt_SettingsDefineCapabilities.c b/src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c +++ b/src/Virt_SettingsDefineCapabilities.c @@ -1694,10 +1694,9 @@ inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_GRAPHICS, DEVICE_RASD); CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); - + CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); + if (STREQC(type, "vnc")) { - CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); - CMSetProperty(inst, "KeyMap", (CMPIValue *)"en-us", CMPI_chars); } diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -405,7 +405,7 @@ static bool add_default_devs(struct domain *domain) { - if (domain->dev_graphics_ct != 1) { + if (domain->dev_graphics_ct < 1) { if (!default_graphics_device(domain)) return false; } @@ -1027,6 +1027,41 @@ return NULL; } +static int parse_console_address(const char *id, + char **path, + char **port) +{ + int ret; + char *tmp_path = NULL; + char *tmp_port = NULL; + + CU_DEBUG("Entering parse_console_address, address is %s", id); + + ret = sscanf(id, "%a[^:]:%as", &tmp_path, &tmp_port); + + if (ret != 2) { + ret = 0; + goto out; + } + + if (path) + *path = strdup(tmp_path); + + if (port) + *port = strdup(tmp_port); + + ret = 1; + + out: + CU_DEBUG("Exiting parse_console_address, ip is %s, port is %s", + *path, *port); + + free(tmp_path); + free(tmp_port); + + return ret; +} + static int parse_vnc_address(const char *id, char **ip, char **port) @@ -1068,9 +1103,8 @@ static const char *graphics_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev) { - const char *val; + const char *val = NULL; const char *msg = NULL; - const char *keymap; bool ipv6 = false; int ret; @@ -1080,36 +1114,67 @@ } dev->dev.graphics.type = strdup(val); + CU_DEBUG("graphics type = %s", dev->dev.graphics.type); + /* FIXME: Add logic to prevent address:port collisions */ - if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { - CU_DEBUG("no graphics port defined, giving default"); - if (cu_get_bool_prop(inst, "IsIPv6Only", &ipv6) != CMPI_RC_OK) - ipv6 = false; - if (ipv6) - dev->dev.graphics.host = strdup("[::1]"); - else - dev->dev.graphics.host = strdup("127.0.0.1"); - dev->dev.graphics.port = strdup("-1"); - } else { - ret = parse_vnc_address(val, - &dev->dev.graphics.host, - &dev->dev.graphics.port); + if (STREQC(dev->dev.graphics.type, "vnc")) { + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { + CU_DEBUG("graphics Address empty, using default"); + + if (cu_get_bool_prop(inst, "IsIPV6Only", &ipv6) != CMPI_RC_OK) + ipv6 = false; + + if(ipv6) + val = "[::1]:-1"; + else + val = "127.0.0.1:-1"; + } + + ret = parse_vnc_address(val, + &dev->dev.graphics.host, + &dev->dev.graphics.port); if (ret != 1) { msg = "GraphicsRASD field Address not valid"; goto out; } + + if (cu_get_str_prop(inst, "KeyMap", &val) != CMPI_RC_OK) + dev->dev.graphics.keymap = strdup("en-us"); + else + dev->dev.graphics.keymap = strdup(val); + + if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { + CU_DEBUG("vnc password is not set"); + dev->dev.graphics.passwd = NULL; + } else { + CU_DEBUG("vnc password is set"); + dev->dev.graphics.passwd = strdup(val); + } } - - if (cu_get_str_prop(inst, "KeyMap", &keymap) != CMPI_RC_OK) - keymap = "en-us"; - - dev->dev.graphics.keymap = strdup(keymap); - - if (cu_get_str_prop(inst, "Password", &val) != CMPI_RC_OK) { - dev->dev.graphics.passwd = NULL; - } else { - dev->dev.graphics.passwd = strdup(val); - } + else if (STREQC(dev->dev.graphics.type, "console") || + STREQC(dev->dev.graphics.type, "serial")) { + if (cu_get_str_prop(inst, "Address", &val) != CMPI_RC_OK) { + CU_DEBUG("graphics Address empty, using default"); + val = "/dev/pts/0:0"; + } + + ret = parse_console_address(val, + &dev->dev.graphics.host, + &dev->dev.graphics.port); + if (ret != 1) { + msg = "GraphicsRASD field Address not valid"; + goto out; + } + } else { + CU_DEBUG("Unsupported graphics type %s", dev->dev.graphics.type); + msg = "Unsupported graphics type"; + goto out; + } + + CU_DEBUG("graphics = %s:%s:%s", + dev->dev.graphics.type, + dev->dev.graphics.host, + dev->dev.graphics.port); out: return msg; @@ -1358,11 +1423,19 @@ ncount, &domain->dev_net_ct); } else if (type == CIM_RES_TYPE_GRAPHICS) { - domain->dev_graphics_ct = 1; + struct virt_device dev; + int ncount = count + domain->dev_graphics_ct; + + memset(&dev, 0, sizeof(dev)); msg = rasd_to_vdev(inst, domain, - &domain->dev_graphics[0], + &dev, ns); + if (msg == NULL) + msg = add_device_nodup(&dev, + domain->dev_graphics, + ncount, + &domain->dev_graphics_ct); } else if (type == CIM_RES_TYPE_INPUT) { domain->dev_input_ct = 1; msg = rasd_to_vdev(inst, From snmishra at us.ibm.com Thu Mar 31 19:25:31 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 31 Mar 2011 12:25:31 -0700 Subject: [Libvirt-cim] [PATCH] [TEST] Fix HostSystem/01_enum.py test Message-ID: <434ee28b0c8000175c81.1301599531@elm3a148.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1301597899 25200 # Node ID 434ee28b0c8000175c81ea7291d7bcf01756cfdd # Parent e71cf5aa81f77498c18ad7d870a41ed9760d3c06 [TEST] Fix HostSystem/01_enum.py test This test was not taking into account the localhost discovered by sblim providers. Signed-off-by: Sharad Mishra diff -r e71cf5aa81f7 -r 434ee28b0c80 suites/libvirt-cim/cimtest/HostSystem/01_enum.py --- a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Mon Mar 07 17:40:29 2011 -0800 +++ b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Thu Mar 31 11:58:19 2011 -0700 @@ -55,8 +55,12 @@ if ret == PASS: if len(hs) != 0: - logger.error("Unexpected instance returned") - return FAIL + if hs[0].CreationClassName != name or hs[0].Name != host: + logger.error("Exp %s, got %s", name, hs[0].CreationClassName) + logger.error("Exp %s, got %s", host, hs[0].Name) + return FAIL + else: + return PASS else: if linux_cs.CreationClassName != 'Linux_ComputerSystem'\ or linux_cs.Name != host: From snmishra at us.ibm.com Thu Mar 31 20:42:35 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 31 Mar 2011 13:42:35 -0700 Subject: [Libvirt-cim] [PATCH] [TEST] Fixing testcase to account for different libvirt error string Message-ID: <6d7dab79f4e8806aea65.1301604155@elm3a148.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1301604051 25200 # Node ID 6d7dab79f4e8806aea65cb413c4f193cdbfc4f40 # Parent f0a7eee4cbe06cc4f618770ac149218a1bddb171 [TEST] Fixing testcase to account for different libvirt error string. Noticed that this test was failing on some libvirt versions between 0.7.0 and 0.8.7 because libvirt was returning new error message. Latest libvirt (0.8.7-5) is back to using error string from libvirt versions prior to 0.7.0. Signed-off-by: Sharad Mishra diff -r f0a7eee4cbe0 -r 6d7dab79f4e8 suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py Thu Mar 31 12:32:11 2011 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py Thu Mar 31 13:40:51 2011 -0700 @@ -125,10 +125,17 @@ if not ret: status = verify_error(exp_rc, exp_desc, cxml) if status != PASS: - raise Exception('Defing domain with invalid %s name %s' - ' gave unexpected rc code %s and ' - 'description:\n %s'% (nettype, field, - cxml.err_rc, cxml.err_desc)) + # There are few libvirt version between 0.7.0 + # and 0.8.7 which give following error. + status = verify_error(exp_rc, + 'No Network bridge name specified', + cxml) + if status != PASS: + raise Exception('Defining domain with invalid %s' + ' name %s gave unexpected rc code' + ' %s and description:\n' + ' %s'% (nettype, field, + cxml.err_rc, cxml.err_desc)) continue ret = cxml.cim_start(options.ip) if ret: From snmishra at us.ibm.com Thu Mar 31 20:51:40 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 31 Mar 2011 13:51:40 -0700 Subject: [Libvirt-cim] [PATCH] [TEST] Conditionally fail if VSI hardware not available Message-ID: # HG changeset patch # User Sharad Mishra # Date 1301604632 25200 # Node ID c1d9565fff50d8aaa7990088b16a8364f563187a # Parent 6d7dab79f4e8806aea65cb413c4f193cdbfc4f40 [TEST] Conditionally fail if VSI hardware not available. This test requires VSI capable hardware to run successfully. On non-vsi hosts, the test was failing, changed it to fail conditionally now giving detailed cause of failure. Signed-off-by: Sharad Mishra diff -r 6d7dab79f4e8 -r c1d9565fff50 suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py Thu Mar 31 13:40:51 2011 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py Thu Mar 31 13:50:32 2011 -0700 @@ -179,29 +179,34 @@ try: rasd_list = get_rasd_list(server, virt, vsi_defaults, nrasd_cn) if len(rasd_list) < 1: + status = FAIL raise Exception("Unable to get template RASDs for %s" % test_dom) cxml = get_class(virt)(test_dom) cxml.set_res_settings(rasd_list) ret = cxml.cim_define(server) if not ret: + status = FAIL raise Exception("Unable to define guest %s" % test_dom) status = cxml.cim_start(server) if status != PASS: - raise Exception("Unable to start %s" % test_dom) + status = XFAIL + raise Exception("Unable to start VM " + "*** Is VSI support available on this host? ***") status, inst = get_net_inst(server, nrasd_cn, test_dom) if status != PASS: + status = FAIL raise Exception("Failed to get net interface for %s" % test_dom) status = verify_net_rasd(server, virt, vsi_defaults, inst) if status != PASS: + status = FAIL logger.error("Failed to verify net interface for %s", test_dom) except Exception, details: logger.error(details) - status = FAIL cxml.cim_destroy(server) cxml.undefine(server) From snmishra at us.ibm.com Thu Mar 31 21:08:28 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 31 Mar 2011 14:08:28 -0700 Subject: [Libvirt-cim] [PATCH] [TEST] Removing redundant test Message-ID: <4bcde13186e6c9985efc.1301605708@elm3a148.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1301605604 25200 # Node ID 4bcde13186e6c9985efc3a11f050c76cf3daf3fa # Parent c1d9565fff50d8aaa7990088b16a8364f563187a [TEST] Removing redundant test. This test is no longer needed as libvirt-cim does not check for duplicate mac addresses. This check is now done by libvirt. Signed-off-by: Sharad Mishra diff -r c1d9565fff50 -r 4bcde13186e6 suites/libvirt-cim/cimtest/VirtualSystemManagementService/23_verify_duplicate_mac_err.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/23_verify_duplicate_mac_err.py Thu Mar 31 13:50:32 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,156 +0,0 @@ -#!/usr/bin/python -# -# Copyright 2009 IBM Corp. -# -# Authors: -# Yogananth subramanian -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# This testcase verifies definig network interface with conflicting MAC -# - -from sys import exit -from random import randint -from pywbem import CIM_ERR_FAILED -from XenKvmLib.vsms_util import add_net_res -from XenKvmLib.vsms import get_vsms_class, get_nasd_class -from XenKvmLib.vxml import get_class -from CimTest.Globals import logger -from CimTest.ReturnCodes import FAIL, PASS, SKIP -from XenKvmLib.const import default_network_name, do_main -from XenKvmLib.common_util import create_netpool_conf, destroy_netpool -from XenKvmLib.classes import get_typed_class -from XenKvmLib.enumclass import GetInstance, EnumNames -from XenKvmLib.const import get_provider_version - -sup_types = ['Xen', 'KVM', 'XenFV'] -default_dom = 'net_domain1' -test_dom = 'brgtest_domain2' -nmac = '99:aa:bb:cc:ee:ff' -ntype = 'network' -npool_name = default_network_name + str(randint(1, 100)) -exp_rc = CIM_ERR_FAILED -exp_desc = "Conflicting MAC Addresses" - -dup_mac_rev = 929 - -def cleanup_env(ip, virt, npool_name, cxml): - cxml.cim_destroy(ip) - cxml.undefine(ip) - destroy_netpool(ip, virt, npool_name) - -def start_dom(cxml,ip,dom): - ret = cxml.cim_define(ip) - if not ret: - status = cxml.verify_error_msg(exp_rc, exp_desc) - if status != PASS: - raise Exception("Got unexpected rc code %s and description %s" - % (cxml.err_rc, cxml.err_desc)) - return FAIL - ret = cxml.cim_start(ip) - if ret: - status = cxml.verify_error_msg(exp_rc, exp_desc) - cxml.undefine(ip) - if status != PASS: - raise Exception("Got unexpected rc code %s and description %s" - % (cxml.err_rc, cxml.err_desc)) - return FAIL - return PASS - - at do_main(sup_types) -def main(): - options = main.options - - rev, changeset = get_provider_version(options.virt, options.ip) - if rev < dup_mac_rev: - logger.error("Test only valid with provider version > %d", dup_mac_rev) - return SKIP - - status, net_name = create_netpool_conf(options.ip, options.virt, - use_existing=False, - net_name=npool_name) - if status != PASS: - logger.error('Unable to create network pool') - return FAIL - cxml = get_class(options.virt)(default_dom, mac=nmac, - ntype=ntype, net_name=npool_name) - try: - status = start_dom(cxml, options.ip, default_dom) - if status == FAIL: - raise Exception("Starting %s domain failed, got unexpeceted rc" - "code %s and description %s" % (default_dom, - cxml.err_rc, cxml.err_desc)) - - except Exception, details: - logger.error(details) - destroy_netpool(options.ip, options.virt, net_name) - return FAIL - - sxml = get_class(options.virt)(test_dom, mac=nmac, - ntype=ntype, net_name=npool_name) - try: - status = start_dom(sxml, options.ip, test_dom) - - if status == PASS: - sxml.cim_destroy(options.ip) - sxml.undefine(options.ip) - raise Exception("Was able to create two domains with" - "Conflicting MAC Addresses") - - service = get_vsms_class(options.virt)(options.ip) - classname = get_typed_class(options.virt, 'VirtualSystemSettingData') - netpool = EnumNames(options.ip, classname) - - if options.virt == "XenFV": - prefix = "Xen" - else: - prefix = options.virt - - inst_id = '%s:%s' % (prefix, default_dom) - vssd_ref = None - for i in range(0, len(netpool)): - ret_pool = netpool[i].keybindings['InstanceID'] - if ret_pool == inst_id: - vssd_ref = netpool[i] - break - if vssd_ref == None: - raise Exception("Failed to get vssd_ref for '%s'"% default_dom) - - nasd = get_nasd_class(options.virt)(type=ntype, mac=nmac, - name=default_dom, - virt_net=npool_name) - net_attr = { 'ntype' : ntype, - 'net_name' : npool_name, - 'nmac' : nmac - } - - ret = add_net_res(options.ip, service, options.virt, cxml, - vssd_ref, nasd, net_attr) - if ret == PASS: - raise Exception("AddRS should NOT return OK with duplicate MAC") - else: - status = PASS - - except Exception, details: - logger.error(details) - status = FAIL - - cleanup_env(options.ip, options.virt, npool_name, cxml) - return status - -if __name__ == "__main__": - exit(main()) -