[PATCH] Fix VSMS instance code to refuse to return an instance if ref is invalid
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1193689589 25200
# Node ID a9008606ede19590b358580f3bc2732f9c92c23c
# Parent bf5ad6924b99903d68d019a7c5faaa2f5a5d1ef9
Fix VSMS instance code to refuse to return an instance if ref is invalid
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r bf5ad6924b99 -r a9008606ede1 src/Makefile.am
--- a/src/Makefile.am Mon Oct 29 15:39:52 2007 -0400
+++ b/src/Makefile.am Mon Oct 29 13:26:29 2007 -0700
@@ -56,7 +56,7 @@ libVirt_ComputerSystemIndication_la_LIBA
libVirt_ComputerSystemIndication_la_LIBADD = -lVirt_ComputerSystem -lpthread -lrt
libVirt_VirtualSystemManagementService_la_SOURCES = Virt_VirtualSystemManagementService.c
-libVirt_VirtualSystemManagementService_la_LIBADD = -lVirt_ComputerSystem -lVirt_ComputerSystemIndication -lVirt_RASD
+libVirt_VirtualSystemManagementService_la_LIBADD = -lVirt_ComputerSystem -lVirt_ComputerSystemIndication -lVirt_RASD -lVirt_HostSystem
libVirt_VirtualSystemManagementCapabilities_la_SOURCES = Virt_VirtualSystemManagementCapabilities.c
diff -r bf5ad6924b99 -r a9008606ede1 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Mon Oct 29 15:39:52 2007 -0400
+++ b/src/Virt_VirtualSystemManagementService.c Mon Oct 29 13:26:29 2007 -0700
@@ -44,6 +44,7 @@
#include "Virt_ComputerSystem.h"
#include "Virt_ComputerSystemIndication.h"
#include "Virt_RASD.h"
+#include "Virt_HostSystem.h"
#include "svpc_types.h"
const static CMPIBroker *_BROKER;
@@ -896,18 +897,24 @@ STDIM_MethodMIStub(, Virt_VirtualSystemM
STDIM_MethodMIStub(, Virt_VirtualSystemManagementService,
_BROKER, CMNoHook, my_handlers);
-
-static CMPIStatus return_vsms(const CMPIObjectPath *reference,
- const CMPIResult *results,
- int name_only)
+static CMPIStatus _get_vsms(const CMPIObjectPath *reference,
+ CMPIInstance **_inst,
+ int name_only)
{
CMPIStatus s;
CMPIInstance *inst;
+ CMPIInstance *host;
+ char *val = NULL;
+
+ s = get_host_cs(_BROKER, reference, &host);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
inst = get_typed_instance(_BROKER,
"VirtualSystemManagementService",
NAMESPACE(reference));
if (inst == NULL) {
+ CU_DEBUG("Failed to get typed instance");
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Failed to create instance");
@@ -916,6 +923,46 @@ static CMPIStatus return_vsms(const CMPI
CMSetProperty(inst, "Name",
(CMPIValue *)"Management Service", CMPI_chars);
+
+ if (cu_get_str_prop(host, "Name", &val) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get name of System");
+ goto out;
+ }
+
+ CMSetProperty(inst, "SystemName",
+ (CMPIValue *)val, CMPI_chars);
+ free(val);
+
+ if (cu_get_str_prop(host, "CreationClassName", &val) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get creation class of system");
+ goto out;
+ }
+
+ CMSetProperty(inst, "SystemCreationClassName",
+ (CMPIValue *)val, CMPI_chars);
+ free(val);
+
+ CMSetStatus(&s, CMPI_RC_OK);
+
+ *_inst = inst;
+ out:
+ return s;
+}
+
+static CMPIStatus return_vsms(const CMPIObjectPath *reference,
+ const CMPIResult *results,
+ int name_only)
+{
+ CMPIInstance *inst;
+ CMPIStatus s;
+
+ s = _get_vsms(reference, &inst, name_only);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
if (name_only)
cu_return_instance_name(results, inst);
@@ -923,7 +970,6 @@ static CMPIStatus return_vsms(const CMPI
CMReturnInstance(results, inst);
CMSetStatus(&s, CMPI_RC_OK);
-
out:
return s;
}
@@ -946,13 +992,58 @@ static CMPIStatus EnumInstances(CMPIInst
return return_vsms(reference, results, 0);
}
+static int compare_prop(const CMPIObjectPath *ref,
+ const CMPIInstance *inst,
+ const char *name,
+ int mandatory)
+{
+ char *prop = NULL;
+ char *key = NULL;
+ int rc = 0;
+
+ key = cu_get_str_path(ref, name);
+ if (key == NULL) {
+ rc = !mandatory;
+ goto out;
+ }
+
+ if (cu_get_str_prop(inst, name, &prop) != CMPI_RC_OK)
+ goto out;
+
+ rc = STREQ(key, prop);
+ out:
+ free(prop);
+ free(key);
+
+ return rc;
+}
+
static CMPIStatus GetInstance(CMPIInstanceMI *self,
const CMPIContext *context,
const CMPIResult *results,
- const CMPIObjectPath *reference,
+ const CMPIObjectPath *ref,
const char **properties)
{
- return return_vsms(reference, results, 0);
+ CMPIInstance *inst;
+ CMPIStatus s;
+
+ s = _get_vsms(ref, &inst, 0);
+ if (s.rc != CMPI_RC_OK)
+ return s;
+
+ if (!compare_prop(ref, inst, "CreationClassName", 0) ||
+ !compare_prop(ref, inst, "SystemName", 0) ||
+ !compare_prop(ref, inst, "Name", 1) ||
+ !compare_prop(ref, inst, "SystemCreationClassName", 0))
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "No such instance");
+ else {
+ CMSetStatus(&s, CMPI_RC_OK);
+ CMReturnInstance(results, inst);
+ }
+
+ return s;
}
DEFAULT_CI();
17 years, 1 month
Automatic reply to list not working?
by Zhengang Li
It seems that the email from the list only adds the
"libvirt-cim(a)redhat.com" in the CC field.
Replying to an email sending from the list automatically goes to the
original author instead of
the list itself.
Is this an intended configuration in the mailing-list setup?
--
- Zhengang
17 years, 1 month
[PATCH] Make the location of the disk pool config file a compile-time option. No checks are done at the moment, mostly due to my lack of m4 skills. Suggestions are welcome or we can do the check in the provider itself
by Jay Gagnon
# HG changeset patch
# User Jay Gagnon <grendel(a)linux.vnet.ibm.com>
# Date 1193686792 14400
# Node ID 4667bc86331dbde59f7ddbde9766d7025385eaec
# Parent f2966180a03a8604d32159b12e44db18ca429a91
Make the location of the disk pool config file a compile-time option. No checks are done at the moment, mostly due to my lack of m4 skills. Suggestions are welcome or we can do the check in the provider itself.
Signed-off-by: Jay Gagnon <grendel(a)linux.vnet.ibm.com>
diff -r f2966180a03a -r 4667bc86331d acinclude.m4
--- a/acinclude.m4 Sat Oct 27 10:16:03 2007 -0700
+++ b/acinclude.m4 Mon Oct 29 15:39:52 2007 -0400
@@ -463,3 +463,12 @@ AC_DEFUN([DEFINE_MAXMEM],
AC_DEFINE_UNQUOTED([MAX_MEM], $1, [Max memory for a guest.])
]
)
+
+#
+# Define disk pool config.
+#
+AC_DEFUN([DEFINE_DISK_CONFIG],
+ [
+ AC_DEFINE_UNQUOTED([DISK_POOL_CONFIG], "$1", [Disk pool config filepath.])
+ ]
+)
\ No newline at end of file
diff -r f2966180a03a -r 4667bc86331d configure.ac
--- a/configure.ac Sat Oct 27 10:16:03 2007 -0700
+++ b/configure.ac Mon Oct 29 15:39:52 2007 -0400
@@ -35,6 +35,11 @@ AC_ARG_VAR([TESTSUITEDIR],[the directory
AC_ARG_VAR([TESTSUITEDIR],[the directory where the SBLIM testsuite is installed.
])
+AC_ARG_WITH([diskconfig],
+ [ --with-diskconfig=PATH Set config file for disk pool. (default=/tmp/diskpool.conf)],
+ [DEFINE_DISK_CONFIG($with_diskconfig)],
+ [DEFINE_DISK_CONFIG(/tmp/diskpool.conf)]
+)
AC_ARG_WITH([maxmem],
[ --with-maxmem=FOO Set max memory (MB) for a guest.],
[DEFINE_MAXMEM($with_maxmem)],
diff -r f2966180a03a -r 4667bc86331d src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Sat Oct 27 10:16:03 2007 -0700
+++ b/src/Virt_DevicePool.c Mon Oct 29 15:39:52 2007 -0400
@@ -32,6 +32,8 @@
#include <cmpift.h>
#include <cmpimacs.h>
+#include "config.h"
+
#include "misc_util.h"
#include "hostres.h"
#include "device_parsing.h"
@@ -42,8 +44,6 @@
#include "svpc_types.h"
static const CMPIBroker *_BROKER;
-
-#define DISK_POOL_CONFIG "/tmp/diskpool.conf"
char *device_pool_names[] = {"ProcessorPool", "MemoryPool", NULL};
17 years, 1 month
[PATCH] Add some useful debug messages to VSMS to assist in debugging DefineSystem
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1193683554 25200
# Node ID 4a1d173152a3c4ceffe3cde01424a6576ea0ae20
# Parent 000f480e2956d631525f5151f611b3e8b41bbe8e
Add some useful debug messages to VSMS to assist in debugging DefineSystem
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 000f480e2956 -r 4a1d173152a3 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Mon Oct 29 09:13:57 2007 -0700
+++ b/src/Virt_VirtualSystemManagementService.c Mon Oct 29 11:45:54 2007 -0700
@@ -85,11 +85,14 @@ static CMPIStatus define_system_parse_ar
int ret;
sys_str = cu_get_str_arg(argsin, "SystemSettings");
- if (sys_str == NULL)
- goto out;
+ if (sys_str == NULL) {
+ CU_DEBUG("No SystemSettings string argument");
+ goto out;
+ }
ret = cu_parse_embedded_instance(sys_str, _BROKER, sys);
if (ret) {
+ CU_DEBUG("Unable to parse SystemSettings instance");
CMSetStatusWithChars(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"SystemSettings parse error");
@@ -98,7 +101,7 @@ static CMPIStatus define_system_parse_ar
res_arr = cu_get_array_arg(argsin, "ResourceSettings");
if (res_arr == NULL) {
- printf("Failed to get array arg\n");
+ CU_DEBUG("Failed to get array arg");
goto out;
}
@@ -227,12 +230,16 @@ static int classify_resources(struct ins
CMPIObjectPath *op;
op = CMGetObjectPath(all->list[i], NULL);
- if (op == NULL)
+ if (op == NULL) {
+ CU_DEBUG("No path for RASD");
return 0;
+ }
if (rasd_type_from_classname(CLASSNAME(op), &type) !=
- CMPI_RC_OK)
+ CMPI_RC_OK) {
+ CU_DEBUG("No type for class %s", CLASSNAME(op))
return 0;
+ }
if (type == CIM_RASD_TYPE_PROC)
rasd_to_vdev(all->list[i],
@@ -261,11 +268,14 @@ static CMPIInstance *connect_and_create(
CMPIInstance *inst;
conn = connect_by_classname(_BROKER, CLASSNAME(ref), s);
- if (conn == NULL)
+ if (conn == NULL) {
+ CU_DEBUG("libvirt connection failed");
return NULL;
+ }
dom = virDomainDefineXML(conn, xml);
if (dom == NULL) {
+ CU_DEBUG("Failed to define domain from XML");
CMSetStatusWithChars(_BROKER, s,
CMPI_RC_ERR_FAILED,
"Failed to create domain");
@@ -274,10 +284,12 @@ static CMPIInstance *connect_and_create(
name = virDomainGetName(dom);
inst = instance_from_name(_BROKER, conn, (char *)name, ref);
- if (inst == NULL)
+ if (inst == NULL) {
+ CU_DEBUG("Failed to get new instance");
CMSetStatusWithChars(_BROKER, s,
CMPI_RC_ERR_FAILED,
"Failed to lookup resulting system");
+ }
virConnectClose(conn);
@@ -301,6 +313,7 @@ static CMPIInstance *create_system(CMPII
}
if (!classify_resources(resources, domain)) {
+ CU_DEBUG("Failed to classify resources");
cu_statusf(_BROKER, s,
CMPI_RC_ERR_FAILED,
"ResourceSettings Error");
@@ -308,6 +321,7 @@ static CMPIInstance *create_system(CMPII
}
if (!vssd_to_domain(vssd, domain)) {
+ CU_DEBUG("Failed to create domain from VSSD");
cu_statusf(_BROKER, s,
CMPI_RC_ERR_FAILED,
"SystemSettings Error");
@@ -315,7 +329,7 @@ static CMPIInstance *create_system(CMPII
}
xml = system_to_xml(domain);
- printf("\nSystem XML:\n%s\n", xml);
+ CU_DEBUG("System XML:\n%s", xml);
inst = connect_and_create(xml, ref, s);
@@ -357,7 +371,7 @@ static CMPIStatus define_system(CMPIMeth
inst_list_init(&res);
- printf("Parsing args\n");
+ CU_DEBUG("DefineSystem");
s = define_system_parse_args(argsin, &vssd, &res);
if (s.rc != CMPI_RC_OK)
17 years, 1 month
[PATCH] Add disk resource pools
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1193505363 25200
# Node ID 06e694e6367634fab4ebc1c1a9927cee790d31c4
# Parent f9d3ced9a8b4eb54d46997ba8f96f8105998d625
Add disk resource pools
This patch parses a disk pool config file, which allows you to specify a pool
name and path. The path is assumed to be a directory of image files. The
Capacity and Reserved properties are reported with statvfs (although the
free/reserved calculation isn't working yet). The config is hard-coded to
/tmp/diskpool.conf currently, but needs to be a compile-time option. This
should be a good start though.
Updated to fix a similar compile warning on Fedora 7
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r f9d3ced9a8b4 -r 06e694e63676 Makefile.am
--- a/Makefile.am Sat Oct 27 10:07:46 2007 -0700
+++ b/Makefile.am Sat Oct 27 10:16:03 2007 -0700
@@ -19,6 +19,7 @@ MOFS = \
schema/MemoryPool.mof \
schema/ElementCapabilities.mof \
schema/ProcessorPool.mof \
+ schema/DiskPool.mof \
schema/HostedResourcePool.mof \
schema/ElementConformsToProfile.mof \
schema/ComputerSystemIndication.mof \
@@ -54,6 +55,7 @@ REGS = \
schema/MemoryPool.registration \
schema/ElementCapabilities.registration \
schema/ProcessorPool.registration \
+ schema/DiskPool.registration \
schema/HostedResourcePool.registration \
schema/ComputerSystemIndication.registration \
schema/ResourceAllocationSettingData.registration \
diff -r f9d3ced9a8b4 -r 06e694e63676 schema/DiskPool.mof
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/schema/DiskPool.mof Sat Oct 27 10:16:03 2007 -0700
@@ -0,0 +1,7 @@
+class Xen_DiskPool : CIM_ResourcePool
+{
+};
+class KVM_DiskPool : CIM_ResourcePool
+{
+};
+
diff -r f9d3ced9a8b4 -r 06e694e63676 schema/DiskPool.registration
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/schema/DiskPool.registration Sat Oct 27 10:16:03 2007 -0700
@@ -0,0 +1,2 @@
+Xen_DiskPool root/ibmsd Virt_DevicePoolProvider Virt_DevicePool instance
+KVM_DiskPool root/ibmsd Virt_DevicePoolProvider Virt_DevicePool instance
diff -r f9d3ced9a8b4 -r 06e694e63676 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Sat Oct 27 10:07:46 2007 -0700
+++ b/src/Virt_DevicePool.c Sat Oct 27 10:16:03 2007 -0700
@@ -19,10 +19,14 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#define __USE_FILE_OFFSET64
+
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/statvfs.h>
+#include <inttypes.h>
#include <cmpidt.h>
#include <cmpift.h>
@@ -39,7 +43,151 @@
static const CMPIBroker *_BROKER;
+#define DISK_POOL_CONFIG "/tmp/diskpool.conf"
+
char *device_pool_names[] = {"ProcessorPool", "MemoryPool", NULL};
+
+struct disk_pool {
+ char *tag;
+ char *path;
+};
+
+static int parse_diskpool_line(struct disk_pool *pool,
+ const char *line)
+{
+ int ret;
+
+ ret = sscanf(line, "%as %as", &pool->tag, &pool->path);
+ if (ret != 2) {
+ free(pool->tag);
+ free(pool->path);
+ }
+
+ return (ret == 2);
+}
+
+static int get_diskpool_config(struct disk_pool **_pools)
+{
+ const char *path = DISK_POOL_CONFIG;
+ FILE *config;
+ char *line = NULL;
+ size_t len = 0;
+ int count = 0;
+ struct disk_pool *pools = NULL;
+
+ config = fopen(path, "r");
+ if (config == NULL) {
+ CU_DEBUG("Failed to open %s: %m", path);
+ return 0;
+ }
+
+ while (getline(&line, &len, config) > 0) {
+ pools = realloc(pools,
+ (count + 1) * (sizeof(*pools)));
+ if (pools == NULL) {
+ CU_DEBUG("Failed to alloc new pool");
+ goto out;
+ }
+
+ if (parse_diskpool_line(&pools[count], line))
+ count++;
+ }
+
+ out:
+ free(line);
+ *_pools = pools;
+ fclose(config);
+
+ return count;
+}
+
+static void free_diskpool(struct disk_pool *pools, int count)
+{
+ int i;
+
+ if (pools == NULL)
+ return;
+
+ for (i = 0; i < count; i++) {
+ free(pools[i].tag);
+ free(pools[i].path);
+ }
+
+ free(pools);
+}
+
+static char *_diskpool_member_of(const char *file)
+{
+ struct disk_pool *pools = NULL;
+ int count;
+ int i;
+ char *pool = NULL;
+
+ count = get_diskpool_config(&pools);
+ if (count == 0)
+ return NULL;
+
+ for (i = 0; i < count; i++) {
+ if (STARTS_WITH(file, pools[i].path)) {
+ int ret;
+
+ ret = asprintf(&pool, "DiskPool/%s", pools[i].tag);
+ if (ret == -1)
+ pool = NULL;
+ break;
+ }
+ }
+
+ free_diskpool(pools, count);
+
+ return pool;
+}
+
+static char *diskpool_member_of(const CMPIBroker *broker, char *rasd_id)
+{
+ char *host = NULL;
+ char *dev = NULL;
+ int ret;
+ virConnectPtr conn = NULL;
+ virDomainPtr dom = NULL;
+ int count = 0;
+ struct virt_device *devs = NULL;
+ int i;
+ char *pool = NULL;
+ CMPIStatus s;
+
+ ret = parse_fq_devid(rasd_id, &host, &dev);
+ if (!ret)
+ goto out;
+
+ conn = lv_connect(broker, &s);
+ if (conn == NULL)
+ goto out;
+
+ dom = virDomainLookupByName(conn, host);
+ if (dom == NULL)
+ goto out;
+
+ count = get_disk_devices(dom, &devs);
+
+ for (i = 0; i < count; i++) {
+ if (STREQ((devs[i].dev.disk.virtual_dev), dev)) {
+ pool = _diskpool_member_of(devs[i].dev.disk.source);
+ break;
+ }
+ }
+
+ out:
+ if (count > 0)
+ cleanup_virt_devices(&devs, count);
+
+ free(host);
+ free(dev);
+ virConnectClose(conn);
+ virDomainFree(dom);
+
+ return pool;
+}
static char *netpool_member_of(const CMPIBroker *broker, char *rasd_id)
{
@@ -100,6 +248,8 @@ char *pool_member_of(const CMPIBroker *b
poolid = strdup("MemoryPool/0");
else if (type == CIM_RASD_TYPE_NET)
poolid = netpool_member_of(broker, id);
+ else if (type == CIM_RASD_TYPE_DISK)
+ poolid = diskpool_member_of(broker, id);
else
return NULL;
@@ -296,6 +446,96 @@ static CMPIStatus netpool_instance(virCo
return s;
}
+static CMPIInstance *diskpool_from_path(const char *path,
+ const char *id,
+ const char *ns,
+ const CMPIBroker *broker)
+{
+ CMPIInstance *inst;
+ char *poolid = NULL;
+ const uint16_t type = CIM_RASD_TYPE_DISK;
+ struct statvfs vfs;
+ uint64_t cap;
+ uint64_t res;
+
+ inst = get_typed_instance(broker, "DiskPool", ns);
+
+ if (asprintf(&poolid, "DiskPool/%s", id) == -1)
+ return NULL;
+
+ CMSetProperty(inst, "InstanceID",
+ (CMPIValue *)poolid, CMPI_chars);
+
+ CMSetProperty(inst, "ResourceType",
+ (CMPIValue *)&type, CMPI_uint16);
+
+ CMSetProperty(inst, "AllocationUnits",
+ (CMPIValue *)"Megabytes", CMPI_chars);
+
+ if (statvfs(path, &vfs) != 0) {
+ CU_DEBUG("Failed to statvfs(%s): %m", path);
+ goto out;
+ }
+
+ cap = (uint64_t) vfs.f_frsize * vfs.f_blocks;
+ res = cap - (uint64_t)(vfs.f_frsize * vfs.f_bfree);
+
+ cap >>= 20;
+ res >>= 20;
+
+ CMSetProperty(inst, "Capacity",
+ (CMPIValue *)&cap, CMPI_uint64);
+
+ CMSetProperty(inst, "Reserved",
+ (CMPIValue *)&res, CMPI_uint64);
+
+ out:
+ free(poolid);
+
+ return inst;
+}
+
+static CMPIStatus diskpool_instance(virConnectPtr conn,
+ struct inst_list *list,
+ const char *ns,
+ const char *id,
+ const CMPIBroker *broker)
+{
+ CMPIStatus s;
+ struct disk_pool *pools = NULL;
+ int count = 0;
+ int i;
+
+ count = get_diskpool_config(&pools);
+ if ((id == NULL) && (count == 0)) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "No such pool `%s'", id);
+ goto out;
+ }
+
+ for (i = 0; i < count; i++) {
+ CMPIInstance *pool;
+
+ if ((id != NULL) && (!STREQ(id, pools[i].tag)))
+ continue;
+ /* Either this matches id, or we're matching all */
+
+ pool = diskpool_from_path(pools[i].path,
+ pools[i].tag,
+ ns,
+ broker);
+ if (pool != NULL)
+ inst_list_add(list, pool);
+ }
+
+ CMSetStatus(&s, CMPI_RC_OK);
+ out:
+ free_diskpool(pools, count);
+
+ return s;
+}
+
static CMPIStatus _get_pool(const CMPIBroker *broker,
virConnectPtr conn,
const char *type,
@@ -309,6 +549,8 @@ static CMPIStatus _get_pool(const CMPIBr
return procpool_instance(conn, list, ns, id, broker);
else if (STARTS_WITH(type, "NetworkPool"))
return netpool_instance(conn, list, ns, id, broker);
+ else if (STARTS_WITH(type, "DiskPool"))
+ return diskpool_instance(conn, list, ns, id, broker);
return (CMPIStatus){CMPI_RC_ERR_NOT_FOUND, NULL};
}
17 years, 1 month
cu_parse_embedded_instance() different results on sfcb & pegasus
by Zhengang Li
The VSMS.defineSystem method on pegasus currently blocks on the this
difference:
After cu_parse_embedded_instance(), I can get a correct value on those
integer type
property (e.g. ResourceType) with a sfcb CIMOM. But I failed to get any
value from
a pegasus CIMOM. Try the following patch:
diff -r 0868c5ff8fd7 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Thu Oct 25 09:39:46 2007
-0700
+++ b/src/Virt_VirtualSystemManagementService.c Mon Oct 29 17:42:52 2007
+0800
@@ -56,8 +56,21 @@ static int parse_str_inst_array(CMPIArra
_BROKER,
&inst);
- if (ret == 0)
+ if (ret == 0) {
+ int tret = 0;
+ char * mystr = NULL;
+ uint16_t myint = 0;
+ tret = cu_get_str_prop(inst, "InstanceID", &mystr);
+ if (tret == 0) {
+ printf("InstanceID = %s\n", mystr);
+ free(mystr);
+ }
+ tret = cu_get_u16_prop(inst, "ResourceType",
&myint);
+ if (tret == 0) {
+ printf("ResourceType = %d\n", myint);
+ }
inst_list_add(list, inst);
+ }
}
return 1;
The actual code that breaks lives in the function classify_resources(),
I added the patch
above to the function parse_str_inst_array(), right after a successful
cu_parse_embedded_instance().
On sfcb, you'll see both lines (InstanceID & ResourceType). But on
pegasus, only the InstanceID lines.
I turned on the EODEBUG macro. Messages from libcmpiutil told me that
the integer types are set
as SINT64 type. The lexer & parser also take all the integer types as
sint64 type. Is that the cause?
--
- Zhengang
17 years, 1 month
[PATCH] Fix asprintf warning in DevicePool
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1193504300 25200
# Node ID b00e3353ccec10cdd9c3e6882067b2b73a5bd448
# Parent aaad430ea766d9a3bc0be035e595d8da17ee2122
Fix asprintf warning in DevicePool
This fixes the compile warning (error) that was preventing a compile on
Fedora 7.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r aaad430ea766 -r b00e3353ccec src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Fri Oct 26 13:34:26 2007 -0700
+++ b/src/Virt_DevicePool.c Sat Oct 27 09:58:20 2007 -0700
@@ -70,9 +70,11 @@ static char *netpool_member_of(const CMP
for (i = 0; i < count; i++) {
if (STREQ((devs[i].id), dev)) {
- asprintf(&result,
- "NetworkPool/%s",
- devs[i].dev.net.bridge);
+ ret = asprintf(&result,
+ "NetworkPool/%s",
+ devs[i].dev.net.bridge);
+ if (ret == -1)
+ result = NULL;
break;
}
}
17 years, 1 month
[PATCH] Build changes for new libcmpiutil header placement
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1193430866 25200
# Node ID aaad430ea766d9a3bc0be035e595d8da17ee2122
# Parent 239f76be94c5fbf730a315408af156c3b0b0d092
Build changes for new libcmpiutil header placement
This attempts to find libcmpiutil by pkg-config, but falls back on
looking in some of the normal locations.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 239f76be94c5 -r aaad430ea766 acinclude.m4
--- a/acinclude.m4 Fri Oct 26 09:15:15 2007 -0700
+++ b/acinclude.m4 Fri Oct 26 13:34:26 2007 -0700
@@ -258,7 +258,45 @@ AC_DEFUN([CHECK_LIBXML2],
fi
]
)
-
+
+AC_DEFUN([_CHECK_LIBCU_PC],
+ [
+ if pkg-config --exists libcmpiutil; then
+ CPPFLAGS="$CPPFLAGS `pkg-config --cflags libcmpiutil`"
+ LDFLAGS="$LDFLAGS `pkg-config --libs libcmpiutil`"
+ found_libcu=yes
+ fi
+ ]
+)
+
+AC_DEFUN([_CHECK_LIBCU_NOPC],
+ [
+ DIRS="/usr /usr/local"
+ for dir in $DIRS; do
+ if test -f "${dir}/include/libcmpiutil/libcmpiutil.h"; then
+ CPPFLAGS="$CPPFLAGS -I${dir}/include/libcmpiutil"
+ LDFLAGS="$LDFLAGS -lcmpiutil -L${dir}/lib"
+ found_libcu=yes
+ fi
+ done
+ ]
+)
+
+AC_DEFUN([CHECK_LIBCU],
+ [
+ _CHECK_LIBCU_PC
+ if test "x$found_libcu" != "xyes"; then
+ _CHECK_LIBCU_NOPC
+ fi
+ AC_CHECK_LIB(cmpiutil, cu_check_args, [], [
+ AC_MSG_ERROR(libcmpiutil not found)
+ ])
+ AC_CHECK_HEADER([libcmpiutil.h], [], [
+ AC_MSG_ERROR([libcmpiutil.h not found])
+ ])
+ ]
+)
+
dnl
dnl The check for the libvirt library
dnl Sets the LIBVIRTDIR variable
diff -r 239f76be94c5 -r aaad430ea766 configure.ac
--- a/configure.ac Fri Oct 26 09:15:15 2007 -0700
+++ b/configure.ac Fri Oct 26 13:34:26 2007 -0700
@@ -133,10 +133,7 @@ fi
CFLAGS_STRICT="-Werror"
-AC_CHECK_LIB(cmpiutil, cu_check_args, [], [
- echo "libcmpiutil not found"
- exit 1
- ])
+CHECK_LIBCU
AC_ARG_ENABLE([werror],
[ --enable-werror enable werror on builds [[default=yes]]],
17 years, 2 months
[PATCH] Add a basic README file to libcmpiutil (without libxml2 as a requirement)
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1193423426 25200
# Node ID 6cb1126452eb354573b95acd7c9077038cc24111
# Parent c771f49faf36a1d0dffc5b5ee0b053ed171fb500
Add a basic README file to libcmpiutil (without libxml2 as a requirement)
Also updated the Makefile.am and spec file to include the readme.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r c771f49faf36 -r 6cb1126452eb Makefile.am
--- a/Makefile.am Fri Oct 26 19:12:06 2007 +0200
+++ b/Makefile.am Fri Oct 26 11:30:26 2007 -0700
@@ -3,7 +3,7 @@ SUBDIRS = tools
EXTRA_DIST = libcmpiutil.spec.in libcmpiutil.spec COPYING \
libcmpiutil.pc.in libcmpiutil.pc \
- doc/doxygen.conf doc/mainpage doc/SubmittingPatches
+ doc/doxygen.conf doc/mainpage doc/SubmittingPatches README
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libcmpiutil.pc
diff -r c771f49faf36 -r 6cb1126452eb README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README Fri Oct 26 11:30:26 2007 -0700
@@ -0,0 +1,36 @@
+ libcmpiutil : A CMPI toolkit library for writing providers
+
+Libcmpiutil is a library of utility functions for CMPI providers. It
+is free software available under the GNU Lesser General Public
+License. The goal is to reduce the amount of repetitive work done in
+most CMPI providers by encapsulating common procedures with more
+"normal" APIs. This extends from operations like getting typed
+instance properties to standardizing method dispatch and argument
+checking.
+
+The latest version of the library can be found here:
+
+ http://libvirt.org/hg/libcmpiutil
+
+ Development discussion currently takes place on the libvirt-cim
+ mailing list:
+
+ https://www.redhat.com/mailman/listinfo/libvirt-cim
+
+Building
+--------
+
+Requirements:
+
+ - Pegasus or SFCB development headers
+ - Lex (if enabling the EO parser)
+ - Yacc (if enabling the EO parser)
+ - doxygen
+
+Procedure:
+
+ $ ./autogen.sh
+ $ # You probably want the EO parser enabled
+ $ ./configure --enable-eoparser
+ $ make
+ $ sudo make install
diff -r c771f49faf36 -r 6cb1126452eb libcmpiutil.spec.in
--- a/libcmpiutil.spec.in Fri Oct 26 19:12:06 2007 +0200
+++ b/libcmpiutil.spec.in Fri Oct 26 11:30:26 2007 -0700
@@ -59,7 +59,7 @@ rm -fr %{buildroot}
%files
%defattr(-, root, root)
-%doc doc/doxygen.conf doc/mainpage doc/SubmittingPatches
+%doc doc/doxygen.conf doc/mainpage doc/SubmittingPatches README
%{_libdir}/lib*.so.*
%files devel
@@ -70,7 +70,7 @@ rm -fr %{buildroot}
%{_includedir}/libcmpiutil/*.h
%{_libdir}/pkgconfig/libcmpiutil.pc
-%doc doc/doxygen.conf doc/mainpage doc/SubmittingPatches
+%doc doc/doxygen.conf doc/mainpage doc/SubmittingPatches README
%changelog
* Fri Oct 26 2007 Daniel Veillard <veillard(a)redhat.com> - 0.1-1
17 years, 2 months
[PATCH] add packaging for libcmpiutil
by Daniel Veillard
# HG changeset patch
# User Daniel Veillard <veillard(a)redhat.com>
# Date 1193418726 -7200
# Node ID d08da2d71ea4fbc8302758688de452bf125dd924
# Parent cdd77491efaac8f60428cbf0ef92ec8b566f5b60
- libcmpiutil.spec.in template file for libcmpiutil allowing to build RPMs
- libcmpiutil.pc.in template file for libcmpiutil for a pkgconfig file
- modifications to configure.ac to generate the spec and pkgconfig files
- modifications to Makefile.am to include the current docs (README will
have to be added)
- modifications to Makefile.am to move the includes to a safer place
/usr/include/libcmpiutil
- modification to Makefile.am to add a 'make rpm' command which can be
quite convenient at times.
Daniel
diff -r cdd77491efaa -r d08da2d71ea4 Makefile.am
--- a/Makefile.am Thu Oct 25 13:44:11 2007 -0700
+++ b/Makefile.am Fri Oct 26 19:12:06 2007 +0200
@@ -1,7 +1,16 @@
# Copyright IBM Corp. 2007
SUBDIRS = tools
-include_HEADERS = libcmpiutil.h \
+EXTRA_DIST = libcmpiutil.spec.in libcmpiutil.spec COPYING \
+ libcmpiutil.pc.in libcmpiutil.pc \
+ doc/doxygen.conf doc/mainpage doc/SubmittingPatches
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libcmpiutil.pc
+
+libcmpiutilincdir = $(includedir)/libcmpiutil
+
+libcmpiutilinc_HEADERS = libcmpiutil.h \
std_invokemethod.h \
std_association.h \
std_indication.h
@@ -33,4 +42,8 @@ endif
endif
clean-local:
- rm -f $(BUILT_SOURCES) *~
\ No newline at end of file
+ rm -f $(BUILT_SOURCES) *~
+
+rpm: clean
+ @(unset CDPATH ; $(MAKE) dist && rpmbuild -ta $(distdir).tar.gz)
+
diff -r cdd77491efaa -r d08da2d71ea4 configure.ac
--- a/configure.ac Thu Oct 25 13:44:11 2007 -0700
+++ b/configure.ac Fri Oct 26 19:12:06 2007 +0200
@@ -61,4 +61,5 @@ echo "Build Embedded Object parser:
echo "Build Embedded Object parser: $eoparser"
echo ""
-AC_OUTPUT
\ No newline at end of file
+AC_OUTPUT(libcmpiutil.spec libcmpiutil.pc)
+
diff -r cdd77491efaa -r d08da2d71ea4 libcmpiutil.pc.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libcmpiutil.pc.in Fri Oct 26 19:12:06 2007 +0200
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@/libcmpiutil
+
+Name: libcmpiutil
+Version: @VERSION@
+Description: CMPI Utility Library
+Requires:
+Libs: -L${libdir} -lcmpiutil
+Cflags: -I${includedir}
diff -r cdd77491efaa -r d08da2d71ea4 libcmpiutil.spec.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libcmpiutil.spec.in Fri Oct 26 19:12:06 2007 +0200
@@ -0,0 +1,77 @@
+# -*- rpm-spec -*-
+
+Summary: CMPI Utility Library
+Name: libcmpiutil
+Version: @PACKAGE_VERSION@
+Release: 1%{?dist}%{?extra_release}
+License: LGPL
+Group: Development/Libraries
+Source: libcmpiutil-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+URL: http://libvirt.org/CIM/
+BuildRequires: sblim-cmpi-devel
+BuildRequires: flex
+BuildRequires: bison
+
+%description
+Libcmpiutil is a library of utility functions for CMPI providers.
+The goal is to reduce the amount of repetitive work done in
+most CMPI providers by encapsulating common procedures with more
+"normal" APIs. This extends from operations like getting typed
+instance properties to standardizing method dispatch and argument checking.
+
+%package devel
+Summary: Libraries, includes, etc. to use the CMPI utility library
+Group: Development/Libraries
+Requires: sblim-cmpi-devel
+Requires: pkgconfig
+
+%description devel
+Includes and documentations for the CMPI utility library
+The goal is to reduce the amount of repetitive work done in
+most CMPI providers by encapsulating common procedures with more
+"normal" APIs. This extends from operations like getting typed
+instance properties to standardizing method dispatch and argument checking.
+
+%prep
+%setup -q
+
+%build
+%configure
+make
+
+%install
+rm -fr %{buildroot}
+
+%makeinstall
+rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
+rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
+
+%clean
+rm -fr %{buildroot}
+
+%post
+/sbin/ldconfig
+
+%postun
+/sbin/ldconfig
+
+%files
+%defattr(-, root, root)
+
+%doc doc/doxygen.conf doc/mainpage doc/SubmittingPatches
+%{_libdir}/lib*.so.*
+
+%files devel
+%defattr(-, root, root)
+
+%{_libdir}/lib*.so
+%dir %{_includedir}/
+%{_includedir}/libcmpiutil/*.h
+%{_libdir}/pkgconfig/libcmpiutil.pc
+
+%doc doc/doxygen.conf doc/mainpage doc/SubmittingPatches
+
+%changelog
+* Fri Oct 26 2007 Daniel Veillard <veillard(a)redhat.com> - 0.1-1
+- created
17 years, 2 months