[PATCH] Fix the XML we generate for an incoming system to include the <os> block
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1423944550 28800
# Node ID 5789eadba6e6f71822493043214c3a8749ebb2f6
# Parent babb2ffdc4c2c3f11a3281af4fb33cc3257127f8
Fix the XML we generate for an incoming system to include the <os> block
which seems to be required. Without it, libvirt-0.2.0 seems to break.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r babb2ffdc4c2 -r 5789eadba6e6 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Tue Oct 30 11:11:32 2007 -0700
+++ b/libxkutil/xmlgen.c Sat Feb 14 12:09:10 2015 -0800
@@ -33,7 +33,6 @@
#include "cmpimacs.h"
#endif
-#if 0
static char *__tag_attr(struct kv *attrs, int count)
{
char *result = strdup("");
@@ -94,7 +93,6 @@ static char *tagify(char *tagname, char
return result;
}
-#endif
static char *disk_block_xml(const char *path, const char *vdev)
{
@@ -265,11 +263,55 @@ static char *system_xml(struct domain *d
return xml;
}
+static char *os_xml(struct domain *domain)
+{
+ struct os_info *os = &domain->os_info;
+ int ret;
+ char *xml;
+ char *type = NULL;
+ char *kernel = NULL;
+ char *initrd = NULL;
+ char *cmdline = NULL;
+
+ if (os->type == NULL)
+ os->type = strdup("linux");
+
+ if (os->kernel == NULL)
+ os->kernel = strdup("/dev/null");
+
+ type = tagify("type", os->type, NULL, 0);
+ kernel = tagify("kernel", os->kernel, NULL, 0);
+ initrd = tagify("initrd", os->initrd, NULL, 0);
+ cmdline = tagify("cmdline", os->cmdline, NULL, 0);
+
+ ret = asprintf(&xml,
+ "<os>\n"
+ " %s\n"
+ " %s\n"
+ " %s\n"
+ " %s\n"
+ "</os>\n",
+ type,
+ kernel,
+ initrd,
+ cmdline);
+ if (ret == -1)
+ xml = NULL;
+
+ free(type);
+ free(kernel);
+ free(initrd);
+ free(cmdline);
+
+ return xml;
+}
+
char *system_to_xml(struct domain *dominfo)
{
char *devxml = strdup("");
char *sysdevxml = strdup("");
char *sysxml = NULL;
+ char *osxml = NULL;
char *xml = NULL;
int ret;
uint8_t uuid[16];
@@ -285,18 +327,21 @@ char *system_to_xml(struct domain *domin
concat_devxml(&sysdevxml, dominfo->dev_vcpu, dominfo->dev_vcpu_ct);
sysxml = system_xml(dominfo);
+ osxml = os_xml(dominfo);
ret = asprintf(&xml,
"<domain type='xen'>\n"
"<uuid>%s</uuid>\n"
- "%s\n"
- "%s\n"
+ "%s"
+ "%s"
+ "%s"
"<devices>\n"
- "%s\n"
+ "%s"
"</devices>\n"
"</domain>\n",
uuidstr,
sysxml,
+ osxml,
sysdevxml,
devxml);
if (ret == -1)
@@ -304,6 +349,7 @@ char *system_to_xml(struct domain *domin
free(devxml);
free(sysdevxml);
+ free(osxml);
free(sysxml);
return xml;
16 years, 11 months
[PATCH] Make RASD not dependent on ResourceType key
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1193673965 25200
# Node ID 07b9be7502efdeead8b1ab83df2d13bcb5398548
# Parent 82ff2daf1ddb72c0bd8a83588a03bd7a37ea110b
Make RASD not dependent on ResourceType key
I have tested DefineSystem() and some of the ResourcePool associations.
It would be good to get a quick smoke test of the AllocationCapabilities
stuff as well, just to make sure I didn't break anything.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 82ff2daf1ddb -r 07b9be7502ef schema/KVM_ResourceAllocationSettingData.mof
--- a/schema/KVM_ResourceAllocationSettingData.mof Mon Oct 29 12:20:44 2007 +0100
+++ b/schema/KVM_ResourceAllocationSettingData.mof Mon Oct 29 09:06:05 2007 -0700
@@ -1,9 +1,4 @@
// Copyright IBM Corp. 2007
class KVM_ResourceAllocationSettingData : CIM_ResourceAllocationSettingData {
- [Key,
- Description ("The type of allocated resource"),
- Override ("ResourceType")]
- uint16 ResourceType;
-
};
diff -r 82ff2daf1ddb -r 07b9be7502ef schema/Xen_ResourceAllocationSettingData.mof
--- a/schema/Xen_ResourceAllocationSettingData.mof Mon Oct 29 12:20:44 2007 +0100
+++ b/schema/Xen_ResourceAllocationSettingData.mof Mon Oct 29 09:06:05 2007 -0700
@@ -1,9 +1,4 @@
// Copyright IBM Corp. 2007
class Xen_ResourceAllocationSettingData : CIM_ResourceAllocationSettingData {
- [Key,
- Description ("The type of allocated resource"),
- Override ("ResourceType")]
- uint16 ResourceType;
-
};
diff -r 82ff2daf1ddb -r 07b9be7502ef src/Makefile.am
--- a/src/Makefile.am Mon Oct 29 12:20:44 2007 +0100
+++ b/src/Makefile.am Mon Oct 29 09:06:05 2007 -0700
@@ -83,8 +83,10 @@ libVirt_ElementCapabilities_la_LIBADD =
-lVirt_HostSystem
libVirt_AllocationCapabilities_la_SOURCES = Virt_AllocationCapabilities.c
+libVirt_AllocationCapabilities_la_SOURCES = -lVirt_RASD
libVirt_SettingsDefineCapabilities_la_SOURCES = Virt_SettingsDefineCapabilities.c
+libVirt_SettingsDefineCapabilities_la_SOURCES = -lVirt_RASD
libVirt_RegisteredProfile_la_SOURCES = Virt_RegisteredProfile.c
diff -r 82ff2daf1ddb -r 07b9be7502ef src/Virt_AllocationCapabilities.c
--- a/src/Virt_AllocationCapabilities.c Mon Oct 29 12:20:44 2007 +0100
+++ b/src/Virt_AllocationCapabilities.c Mon Oct 29 09:06:05 2007 -0700
@@ -29,6 +29,7 @@
#include "misc_util.h"
#include "Virt_AllocationCapabilities.h"
+#include "Virt_RASD.h"
const static CMPIBroker *_BROKER;
@@ -44,8 +45,7 @@ CMPIStatus get_alloc_cap(const CMPIBroke
*inst = get_typed_instance(broker, "AllocationCapabilities",
NAMESPACE(ref));
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (ret != 1) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
CMSetStatusWithChars(broker, &s, CMPI_RC_ERR_FAILED,
"Could not get ResourceType.");
goto out;
diff -r 82ff2daf1ddb -r 07b9be7502ef src/Virt_RASD.c
--- a/src/Virt_RASD.c Mon Oct 29 12:20:44 2007 +0100
+++ b/src/Virt_RASD.c Mon Oct 29 09:06:05 2007 -0700
@@ -205,10 +205,38 @@ static CMPIInstance *get_rasd_instance(c
return inst;
}
+CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type)
+{
+ char *base = NULL;
+ CMPIrc rc = CMPI_RC_ERR_FAILED;
+
+ base = class_base_name(cn);
+ if (base == NULL)
+ goto out;
+
+ if (STREQ(base, "DiskResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_DISK;
+ else if (STREQ(base, "NetResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_NET;
+ else if (STREQ(base, "ProcResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_PROC;
+ else if (STREQ(base, "MemResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_MEM;
+ else
+ goto out;
+
+ rc = CMPI_RC_OK;
+
+ out:
+ free(base);
+
+ return rc;
+}
+
static CMPIStatus GetInstance(CMPIInstanceMI *self,
const CMPIContext *context,
const CMPIResult *results,
- const CMPIObjectPath *reference,
+ const CMPIObjectPath *ref,
const char **properties)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
@@ -216,7 +244,7 @@ static CMPIStatus GetInstance(CMPIInstan
char *id = NULL;
uint16_t type;
- id = cu_get_str_path(reference, "InstanceID");
+ id = cu_get_str_path(ref, "InstanceID");
if (id == NULL) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -224,14 +252,14 @@ static CMPIStatus GetInstance(CMPIInstan
goto out;
}
- if (!cu_get_u16_path(reference, "ResourceType", &type)) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Missing or invalid ResourceType");
- goto out;
- }
-
- inst = get_rasd_instance(context, reference, id, type);
+ "Unable to determine RASD type");
+ goto out;
+ }
+
+ inst = get_rasd_instance(context, ref, id, type);
if (inst != NULL)
CMReturnInstance(results, inst);
diff -r 82ff2daf1ddb -r 07b9be7502ef src/Virt_RASD.h
--- a/src/Virt_RASD.h Mon Oct 29 12:20:44 2007 +0100
+++ b/src/Virt_RASD.h Mon Oct 29 09:06:05 2007 -0700
@@ -27,6 +27,7 @@ int rasds_for_domain(const CMPIBroker *b
const uint16_t type,
const char *ns,
struct inst_list *_list);
+CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type);
#endif
diff -r 82ff2daf1ddb -r 07b9be7502ef src/Virt_ResourceAllocationFromPool.c
--- a/src/Virt_ResourceAllocationFromPool.c Mon Oct 29 12:20:44 2007 +0100
+++ b/src/Virt_ResourceAllocationFromPool.c Mon Oct 29 09:06:05 2007 -0700
@@ -42,7 +42,6 @@ static CMPIStatus rasd_to_pool(const CMP
struct inst_list *list)
{
CMPIStatus s;
- int ret;
uint16_t type;
char *id = NULL;
char *poolid = NULL;
@@ -52,11 +51,10 @@ static CMPIStatus rasd_to_pool(const CMP
inst_list_init(&_list);
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (!ret) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing ResourceType");
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to determine RASD type");
goto out;
}
@@ -113,8 +111,16 @@ static int filter_by_pool(struct inst_li
for (i = 0; i < src->cur; i++) {
CMPIInstance *inst = src->list[i];
-
- cu_get_u16_prop(inst, "ResourceType", &type);
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(inst, NULL);
+ if (op == NULL)
+ continue;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) !=
+ CMPI_RC_OK)
+ continue;
+
cu_get_str_prop(inst, "InstanceID", &rasd_id);
poolid = pool_member_of(_BROKER, type, rasd_id);
diff -r 82ff2daf1ddb -r 07b9be7502ef src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Mon Oct 29 12:20:44 2007 +0100
+++ b/src/Virt_SettingsDefineCapabilities.c Mon Oct 29 09:06:05 2007 -0700
@@ -37,6 +37,7 @@
#include "svpc_types.h"
#include "Virt_SettingsDefineCapabilities.h"
+#include "Virt_RASD.h"
const static CMPIBroker *_BROKER;
@@ -315,13 +316,11 @@ static CMPIStatus alloc_cap_to_rasd(cons
struct inst_list *list)
{
CMPIStatus s = {CMPI_RC_OK};
- int ret;
uint16_t type;
CU_DEBUG("Getting ResourceType.\n");
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (ret != 1) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED,
"Could not get ResourceType.");
goto out;
diff -r 82ff2daf1ddb -r 07b9be7502ef src/Virt_SettingsDefineState.c
--- a/src/Virt_SettingsDefineState.c Mon Oct 29 12:20:44 2007 +0100
+++ b/src/Virt_SettingsDefineState.c Mon Oct 29 09:06:05 2007 -0700
@@ -162,7 +162,6 @@ static CMPIStatus rasd_to_dev(const CMPI
CMPIStatus s;
CMPIInstance *dev = NULL;
char *id = NULL;
- int ret;
uint16_t type;
ASSOC_MATCH(info->provider_name, CLASSNAME(ref));
@@ -175,8 +174,7 @@ static CMPIStatus rasd_to_dev(const CMPI
goto out;
}
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (!ret) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Missing ResourceType");
diff -r 82ff2daf1ddb -r 07b9be7502ef src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Mon Oct 29 12:20:44 2007 +0100
+++ b/src/Virt_VirtualSystemManagementService.c Mon Oct 29 09:06:05 2007 -0700
@@ -157,9 +157,15 @@ static int rasd_to_vdev(CMPIInstance *in
char *id = NULL;
char *name = NULL;
char *devid = NULL;
-
- if (cu_get_u16_prop(inst, "ResourceType", &type) != CMPI_RC_OK)
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(inst, NULL);
+ if (op == NULL)
goto err;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) != CMPI_RC_OK)
+ goto err;
+
dev->type = (int)type;
if (cu_get_str_prop(inst, "InstanceID", &id) != CMPI_RC_OK)
@@ -206,7 +212,6 @@ static int classify_resources(struct ins
static int classify_resources(struct inst_list *all,
struct domain *domain)
{
- int ret;
int i;
uint16_t type;
@@ -219,8 +224,14 @@ static int classify_resources(struct ins
domain->dev_net = calloc(all->cur, sizeof(struct virt_device));
for (i = 0; i < all->cur; i++) {
- ret = cu_get_u16_prop(all->list[i], "ResourceType", &type);
- if (ret != CMPI_RC_OK)
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(all->list[i], NULL);
+ if (op == NULL)
+ return 0;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) !=
+ CMPI_RC_OK)
return 0;
if (type == CIM_RASD_TYPE_PROC)
@@ -681,6 +692,7 @@ static CMPIStatus _update_resources_for(
struct domain *dominfo = NULL;
uint16_t type;
char *xml = NULL;
+ CMPIObjectPath *op;
if (!get_dominfo(dom, &dominfo)) {
cu_statusf(_BROKER, &s,
@@ -689,10 +701,18 @@ static CMPIStatus _update_resources_for(
goto out;
}
- if (cu_get_u16_prop(rasd, "ResourceType", &type) != CMPI_RC_OK) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing ResourceType");
+ op = CMGetObjectPath(rasd, NULL);
+ if (op == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get RASD path");
+ goto out;
+ }
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to determine RASD type");
goto out;
}
16 years, 11 months
[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 1193849716 25200
# Node ID dde11a85b5c04cfe4c3028fe48dc5e383a80f946
# Parent bf5ad6924b99903d68d019a7c5faaa2f5a5d1ef9
Fix VSMS instance code to refuse to return an instance if ref is invalid
Tweaked to include the proper NOT_FOUND error code and fix the build order.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r bf5ad6924b99 -r dde11a85b5c0 src/Makefile.am
--- a/src/Makefile.am Mon Oct 29 15:39:52 2007 -0400
+++ b/src/Makefile.am Wed Oct 31 09:55:16 2007 -0700
@@ -29,13 +29,13 @@ provider_LTLIBRARIES = libVirt_ComputerS
libVirt_SystemDevice.la \
libVirt_ComputerSystemIndication.la \
libVirt_RASD.la \
+ libVirt_HostSystem.la \
libVirt_VirtualSystemManagementService.la \
libVirt_VirtualSystemManagementCapabilities.la \
libVirt_EnabledLogicalElementCapabilities.la \
libVirt_AllocationCapabilities.la \
libVirt_SettingsDefineCapabilities.la \
libVirt_VSSD.la \
- libVirt_HostSystem.la \
libVirt_HostedDependency.la \
libVirt_RegisteredProfile.la \
libVirt_ElementConformsToProfile.la \
@@ -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 dde11a85b5c0 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Mon Oct 29 15:39:52 2007 -0400
+++ b/src/Virt_VirtualSystemManagementService.c Wed Oct 31 09:55:16 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_NOT_FOUND,
+ "No such instance");
+ else {
+ CMSetStatus(&s, CMPI_RC_OK);
+ CMReturnInstance(results, inst);
+ }
+
+ return s;
}
DEFAULT_CI();
16 years, 11 months
[PATCH] Fix a crash when std_invokemethod handlers return nonzero
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1424066513 28800
# Node ID 05b01d03f0b801afe266d8d012bc464be6a2d165
# Parent 8d634949f520faafd42c3d59add7c20fac39bb88
Fix a crash when std_invokemethod handlers return nonzero
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 8d634949f520 -r 05b01d03f0b8 std_invokemethod.c
--- a/std_invokemethod.c Fri Oct 26 08:58:03 2007 -0700
+++ b/std_invokemethod.c Sun Feb 15 22:01:53 2015 -0800
@@ -112,7 +112,7 @@ CMPIStatus _std_invokemethod(CMPIMethodM
CU_DEBUG("Executing handler for method `%s'", methodname);
s = h->handler(self, context, results, reference, argsin, argsout);
- CU_DEBUG("Method `%s' returned %i", s.rc);
+ CU_DEBUG("Method `%s' returned %i", methodname, s.rc);
exit:
CMReturnDone(results);
16 years, 11 months
[PATCH] Add some starter web content
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1193852665 25200
# Node ID fb92838e55651ca80d2de49344db81312a5ebe8b
# Parent 5789eadba6e6f71822493043214c3a8749ebb2f6
Add some starter web content
Right now, this is just the flat content (un-transformed), but it should get
us started. Comments welcome :)
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 5789eadba6e6 -r fb92838e5565 Makefile.am
--- a/Makefile.am Sat Feb 14 12:09:10 2015 -0800
+++ b/Makefile.am Wed Oct 31 10:44:25 2007 -0700
@@ -1,5 +1,5 @@
# Copyright IBM Corp. 2007
-SUBDIRS = libxkutil src
+SUBDIRS = libxkutil src doc
MOFS = \
schema/ComputerSystem.mof \
diff -r 5789eadba6e6 -r fb92838e5565 configure.ac
--- a/configure.ac Sat Feb 14 12:09:10 2015 -0800
+++ b/configure.ac Wed Oct 31 10:44:25 2007 -0700
@@ -67,6 +67,7 @@ AC_CONFIG_FILES([
libxkutil/tests/Makefile
src/Makefile
src/tests/Makefile
+ doc/Makefile
Makefile
])
diff -r 5789eadba6e6 -r fb92838e5565 doc/Makefile.am
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/Makefile.am Wed Oct 31 10:44:25 2007 -0700
@@ -0,0 +1,9 @@
+XSLTPROC = /usr/bin/xsltproc
+
+WEB_PAGES = index.html
+
+$(WEB_PAGES): libvirt-cim.html site.xsl
+ $(XSLTPROC) --nonet --html $(top_srcdir)/doc/site.xsl $(top_srcdir)/doc/libvirt-cim.html > index.html
+
+all: $(WEB_PAGES)
+
diff -r 5789eadba6e6 -r fb92838e5565 doc/libvirt-cim.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/libvirt-cim.html Wed Oct 31 10:44:25 2007 -0700
@@ -0,0 +1,147 @@
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="">
+ <title>Libvirt-CIM: The CIM provider for libvirt</title>
+</head>
+
+<body bgcolor="#ffffff">
+<h1 align="center">Libvirt-CIM: The CIM provider for libvirt</h1>
+
+<h1>Note: this is the flat content of the <a href="index.html">web site</a></h1>
+
+<h1 style="text-align: center">libvirt-cim</h1>
+
+<h3>What is <span class="style1">libvirt-cim?</span></h3>
+
+<p>Libvirt-CIM is a CIM provider for managing linux virtualization
+ platforms using libvirt. It is written in C and should work in any
+ CIMOM that supports CMPI 2.0 providers. The intent is to implement
+ the SVPC virtualization class model currently available in the DMTF
+ Experimental 2.16 schema.
+</p>
+
+<h2><a name="News">Releases</a></h2>
+
+<p>There have been no releases to date</p>
+
+<h2><a name="Introducti">Introduction</a></h2>
+
+<p>Libvirt-CIM is a CIM provider for managing linux virtualization
+ platforms using libvirt. It is written in C and should work in any
+ CIMOM that supports CMPI 2.0 providers. The intent is to implement
+ the SVPC virtualization class model currently available in the DMTF
+ Experimental 2.16 schema.
+</p>
+
+<p>The providers are currently under heavy development. Focus is on
+ Xen support right now, which means some of the providers have some
+ "shortcuts" hard-coded to Xen right now. The long-term goal is to
+ support all of the platforms that libvirt supports with minimal
+ differences.
+</p>
+
+<h2><a name="Downloads">Downloads</a></h2>
+
+<p>The libvirt-cim development tree can be found in the
+ <a href="http://libvirt.org/hg">libvirt.org/hg</a> repository.
+</p>
+
+<p>To get a copy of the development tree, use
+ <a href="http://www.selenic.com/mercurial/wiki/">mercurial</a>'s
+ clone feature:
+</p>
+
+<p><code>$ hg clone http://libvirt.org/hg/libvirt-cim</code></p>
+
+<p>Alternatively, you can grab a
+ <a href="http://libvirt.org/hg/libvirt-cim/archive/tip.tar.gz">tarball</a> or
+ <a href="http://libvirt.org/hg/libvirt-cim/archive/tip.zip">zip</a>
+ file snapshot of the repository.
+</p>
+
+<h2><a name="Schema">Schema Requirements and Installation</a></h2>
+
+<p>The libvirt-cim provider depends on an installed
+ <a href="http://www.dmtf.org/standards/cim/cim_schema_v216/">DMTF
+ CIM v2.16</a> Experimental schema. The package can be obtained
+<a href="http://www.dmtf.org/standards/cim/cim_schema_v216/cimv216Experimental-MOF...">here</a>.</p>
+
+<h4>To install the schema in Pegasus:</h4>
+
+<p><code>
+ $ PEGASUS_REPO=/var/lib/Pegasus # adjust this as needed<br/>
+ $ mkdir cim216<br/>
+ $ cd cim216<br/>
+ $ unzip $PATH_TO_ZIPFILE<br/>
+ $ sudo cimmofl -uc -aEV -R$PEGASUS_REPO -n /root/ibmsd cimv216.mof<br/>
+</code></p>
+
+<h4>To install the schema in SFCB:</h4>
+
+<p><code>
+ $ SFCB_CIM=/usr/local/share/sfcb/CIM # adjust this as needed<br/>
+ $ mkdir cim216<br/>
+ $ cd cim216<br/>
+ $ unzip $PATH_TO_ZIPFILE<br/>
+ $ mv cimv216.mof CIM_Schema.mof<br/>
+ $ sudo cp * $SFCB_CIM<br/>
+ $ sudo sfcbrepos<br/>
+</code></p>
+
+<p><strong>Note:</strong> in both cases, the CIM v2.16 schema seems to have a
+ few classes that don't register correctly. You may need to
+ disable installation of classes with something like the
+ following:
+</p>
+
+<p><code>
+--- CIM_Schema.mof 2007-10-15 00:15:44.000000000 -0700<br/>
++++ cimv216.mof 2007-10-22 10:11:19.000000000 -0700<br/>
+@@ -507,3 +507,3 @@<br/>
+ #pragma include ("Policy/CIM_SharedSecretAuthentication.mof")<br/>
+-#pragma include ("Security/CIM_SecurityIndication.mof")<br/>
++//#pragma include ("Security/CIM_SecurityIndication.mof")<br/>
+ #pragma include ("Support/PRS_Activity.mof")<br/>
+@@ -728,4 +728,4 @@<br/>
+ #pragma include ("Policy/CIM_PolicyConditionInPolicyRule.mof")<br/>
+-#pragma include ("Security/CIM_IPNetworkSecurityIndication.mof")<br/>
+-#pragma include ("Security/CIM_IPPacketFilterIndication.mof")<br/>
++//#pragma include ("Security/CIM_IPNetworkSecurityIndication.mof")<br/>
++//#pragma include ("Security/CIM_IPPacketFilterIndication.mof")<br/>
+ #pragma include ("Support/PRS_ActivityContact.mof")<br/>
+</code></p>
+
+<h2><a name="Platforms">Platform Support</a></h2>
+
+<p>Currently, libvirt-cim is targetting Xen as its primary support
+ platform because is has the largest installed user base. The
+ long-term plan is to support many others (hopefully any that libvirt
+ supports). This includes KVM and containers.
+</p>
+
+<p>The code base currently has many Xen-specific "shortcuts" that need
+ to be resolved and generalized in order to support other platforms.
+ A short list of these may include:</p>
+<ul>
+ <li>The XML generation and parsing code and the related device
+ modeling code.</li>
+ <li>The libvirt connection logic. Right now, (in most places) we
+ detect the current hypervisor in use and connect to libvirt
+ appropriately. This may or may not be the correct behavior in a
+ situation where you could need to support containers and QEMU
+ virtual machines.</li>
+ <li>Some lingering hard-coded "Xen_Foo" class names.</li>
+</ul>
+
+<p>Further, supporting new platforms have some registration and
+ modeling implications:</p>
+<ul>
+ <li>Additions to the MOF and registration files for "branded"
+ classes (Xen_Foo, KVM_Foo, etc)</li>
+ <li>Modifications to some of the association providers that register
+ separate CMPI provider structures for each class type they handle
+ (to avoid duplicate results in the general case)</li>
+</ul>
+
+</body>
+</html>
16 years, 11 months
[PATCH] Registration of ElementConformsToProfile for two namespaces causes errors with Pegasus
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1193744530 -3600
# Node ID c94a9d6b36d9bd39e85c16805cdc8e525dd585cd
# Parent bf5ad6924b99903d68d019a7c5faaa2f5a5d1ef9
Registration of ElementConformsToProfile for two namespaces causes errors with Pegasus
diff -r bf5ad6924b99 -r c94a9d6b36d9 schema/ElementConformsToProfile.registration
--- a/schema/ElementConformsToProfile.registration Mon Oct 29 15:39:52 2007 -0400
+++ b/schema/ElementConformsToProfile.registration Tue Oct 30 12:42:10 2007 +0100
@@ -1,7 +1,7 @@
# Copyright IBM Corp. 2007
# Classname Namespace ProviderName ProviderModule ProviderTypes ...
-Xen_ElementConformsToProfile root/ibmsd Virt_ElementConformsToProfileProvider Virt_ElementConformsToProfile association
+#Xen_ElementConformsToProfile root/ibmsd Virt_ElementConformsToProfileProvider Virt_ElementConformsToProfile association
Xen_ElementConformsToProfile root/interop Virt_ElementConformsToProfileProvider Virt_ElementConformsToProfile association
# Classname Namespace ProviderName ProviderModule ProviderTypes ...
-KVM_ElementConformsToProfile root/ibmsd Virt_ElementConformsToProfileProvider Virt_ElementConformsToProfile association
+#KVM_ElementConformsToProfile root/ibmsd Virt_ElementConformsToProfileProvider Virt_ElementConformsToProfile association
KVM_ElementConformsToProfile root/interop Virt_ElementConformsToProfileProvider Virt_ElementConformsToProfile association
16 years, 11 months
[PATCH] Make RASD not dependent on ResourceType key
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1193767892 25200
# Node ID babb2ffdc4c2c3f11a3281af4fb33cc3257127f8
# Parent e385d591fa6f8bbe135434117a16039d5693f5b4
Make RASD not dependent on ResourceType key
I have tested DefineSystem() and some of the ResourcePool associations.
(replaced the AllocationCapabilities changes)
(removed the SettingsDefineCapabilities changes)
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r e385d591fa6f -r babb2ffdc4c2 schema/KVM_ResourceAllocationSettingData.mof
--- a/schema/KVM_ResourceAllocationSettingData.mof Tue Oct 30 09:39:29 2007 -0700
+++ b/schema/KVM_ResourceAllocationSettingData.mof Tue Oct 30 11:11:32 2007 -0700
@@ -1,9 +1,4 @@
// Copyright IBM Corp. 2007
class KVM_ResourceAllocationSettingData : CIM_ResourceAllocationSettingData {
- [Key,
- Description ("The type of allocated resource"),
- Override ("ResourceType")]
- uint16 ResourceType;
-
};
diff -r e385d591fa6f -r babb2ffdc4c2 schema/Xen_ResourceAllocationSettingData.mof
--- a/schema/Xen_ResourceAllocationSettingData.mof Tue Oct 30 09:39:29 2007 -0700
+++ b/schema/Xen_ResourceAllocationSettingData.mof Tue Oct 30 11:11:32 2007 -0700
@@ -1,9 +1,4 @@
// Copyright IBM Corp. 2007
class Xen_ResourceAllocationSettingData : CIM_ResourceAllocationSettingData {
- [Key,
- Description ("The type of allocated resource"),
- Override ("ResourceType")]
- uint16 ResourceType;
-
};
diff -r e385d591fa6f -r babb2ffdc4c2 src/Makefile.am
--- a/src/Makefile.am Tue Oct 30 09:39:29 2007 -0700
+++ b/src/Makefile.am Tue Oct 30 11:11:32 2007 -0700
@@ -83,8 +83,10 @@ libVirt_ElementCapabilities_la_LIBADD =
-lVirt_HostSystem
libVirt_AllocationCapabilities_la_SOURCES = Virt_AllocationCapabilities.c
+libVirt_AllocationCapabilities_la_LIBADD = -lVirt_RASD
libVirt_SettingsDefineCapabilities_la_SOURCES = Virt_SettingsDefineCapabilities.c
+libVirt_SettingsDefineCapabilities_la_LIBADD = -lVirt_RASD
libVirt_RegisteredProfile_la_SOURCES = Virt_RegisteredProfile.c
diff -r e385d591fa6f -r babb2ffdc4c2 src/Virt_AllocationCapabilities.c
--- a/src/Virt_AllocationCapabilities.c Tue Oct 30 09:39:29 2007 -0700
+++ b/src/Virt_AllocationCapabilities.c Tue Oct 30 11:11:32 2007 -0700
@@ -29,6 +29,7 @@
#include "misc_util.h"
#include "Virt_AllocationCapabilities.h"
+#include "Virt_RASD.h"
const static CMPIBroker *_BROKER;
@@ -44,8 +45,7 @@ CMPIStatus get_alloc_cap(const CMPIBroke
*inst = get_typed_instance(broker, "AllocationCapabilities",
NAMESPACE(ref));
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (ret != 1) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
CMSetStatusWithChars(broker, &s, CMPI_RC_ERR_FAILED,
"Could not get ResourceType.");
goto out;
diff -r e385d591fa6f -r babb2ffdc4c2 src/Virt_RASD.c
--- a/src/Virt_RASD.c Tue Oct 30 09:39:29 2007 -0700
+++ b/src/Virt_RASD.c Tue Oct 30 11:11:32 2007 -0700
@@ -205,10 +205,38 @@ static CMPIInstance *get_rasd_instance(c
return inst;
}
+CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type)
+{
+ char *base = NULL;
+ CMPIrc rc = CMPI_RC_ERR_FAILED;
+
+ base = class_base_name(cn);
+ if (base == NULL)
+ goto out;
+
+ if (STREQ(base, "DiskResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_DISK;
+ else if (STREQ(base, "NetResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_NET;
+ else if (STREQ(base, "ProcResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_PROC;
+ else if (STREQ(base, "MemResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_MEM;
+ else
+ goto out;
+
+ rc = CMPI_RC_OK;
+
+ out:
+ free(base);
+
+ return rc;
+}
+
static CMPIStatus GetInstance(CMPIInstanceMI *self,
const CMPIContext *context,
const CMPIResult *results,
- const CMPIObjectPath *reference,
+ const CMPIObjectPath *ref,
const char **properties)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
@@ -216,7 +244,7 @@ static CMPIStatus GetInstance(CMPIInstan
char *id = NULL;
uint16_t type;
- id = cu_get_str_path(reference, "InstanceID");
+ id = cu_get_str_path(ref, "InstanceID");
if (id == NULL) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -224,14 +252,14 @@ static CMPIStatus GetInstance(CMPIInstan
goto out;
}
- if (!cu_get_u16_path(reference, "ResourceType", &type)) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Missing or invalid ResourceType");
- goto out;
- }
-
- inst = get_rasd_instance(context, reference, id, type);
+ "Unable to determine RASD type");
+ goto out;
+ }
+
+ inst = get_rasd_instance(context, ref, id, type);
if (inst != NULL)
CMReturnInstance(results, inst);
diff -r e385d591fa6f -r babb2ffdc4c2 src/Virt_RASD.h
--- a/src/Virt_RASD.h Tue Oct 30 09:39:29 2007 -0700
+++ b/src/Virt_RASD.h Tue Oct 30 11:11:32 2007 -0700
@@ -27,6 +27,7 @@ int rasds_for_domain(const CMPIBroker *b
const uint16_t type,
const char *ns,
struct inst_list *_list);
+CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type);
#endif
diff -r e385d591fa6f -r babb2ffdc4c2 src/Virt_ResourceAllocationFromPool.c
--- a/src/Virt_ResourceAllocationFromPool.c Tue Oct 30 09:39:29 2007 -0700
+++ b/src/Virt_ResourceAllocationFromPool.c Tue Oct 30 11:11:32 2007 -0700
@@ -42,7 +42,6 @@ static CMPIStatus rasd_to_pool(const CMP
struct inst_list *list)
{
CMPIStatus s;
- int ret;
uint16_t type;
char *id = NULL;
char *poolid = NULL;
@@ -52,11 +51,10 @@ static CMPIStatus rasd_to_pool(const CMP
inst_list_init(&_list);
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (!ret) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing ResourceType");
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to determine RASD type");
goto out;
}
@@ -113,8 +111,16 @@ static int filter_by_pool(struct inst_li
for (i = 0; i < src->cur; i++) {
CMPIInstance *inst = src->list[i];
-
- cu_get_u16_prop(inst, "ResourceType", &type);
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(inst, NULL);
+ if (op == NULL)
+ continue;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) !=
+ CMPI_RC_OK)
+ continue;
+
cu_get_str_prop(inst, "InstanceID", &rasd_id);
poolid = pool_member_of(_BROKER, type, rasd_id);
diff -r e385d591fa6f -r babb2ffdc4c2 src/Virt_SettingsDefineState.c
--- a/src/Virt_SettingsDefineState.c Tue Oct 30 09:39:29 2007 -0700
+++ b/src/Virt_SettingsDefineState.c Tue Oct 30 11:11:32 2007 -0700
@@ -162,7 +162,6 @@ static CMPIStatus rasd_to_dev(const CMPI
CMPIStatus s;
CMPIInstance *dev = NULL;
char *id = NULL;
- int ret;
uint16_t type;
ASSOC_MATCH(info->provider_name, CLASSNAME(ref));
@@ -175,8 +174,7 @@ static CMPIStatus rasd_to_dev(const CMPI
goto out;
}
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (!ret) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Missing ResourceType");
diff -r e385d591fa6f -r babb2ffdc4c2 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Tue Oct 30 09:39:29 2007 -0700
+++ b/src/Virt_VirtualSystemManagementService.c Tue Oct 30 11:11:32 2007 -0700
@@ -161,9 +161,15 @@ static int rasd_to_vdev(CMPIInstance *in
char *id = NULL;
char *name = NULL;
char *devid = NULL;
-
- if (cu_get_u16_prop(inst, "ResourceType", &type) != CMPI_RC_OK)
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(inst, NULL);
+ if (op == NULL)
goto err;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) != CMPI_RC_OK)
+ goto err;
+
dev->type = (int)type;
if (cu_get_str_prop(inst, "InstanceID", &id) != CMPI_RC_OK)
@@ -210,7 +216,6 @@ static int classify_resources(struct ins
static int classify_resources(struct inst_list *all,
struct domain *domain)
{
- int ret;
int i;
uint16_t type;
@@ -223,8 +228,14 @@ static int classify_resources(struct ins
domain->dev_net = calloc(all->cur, sizeof(struct virt_device));
for (i = 0; i < all->cur; i++) {
- ret = cu_get_u16_prop(all->list[i], "ResourceType", &type);
- if (ret != CMPI_RC_OK)
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(all->list[i], NULL);
+ if (op == NULL)
+ return 0;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) !=
+ CMPI_RC_OK)
return 0;
if (type == CIM_RASD_TYPE_PROC)
@@ -692,6 +703,7 @@ static CMPIStatus _update_resources_for(
struct domain *dominfo = NULL;
uint16_t type;
char *xml = NULL;
+ CMPIObjectPath *op;
if (!get_dominfo(dom, &dominfo)) {
cu_statusf(_BROKER, &s,
@@ -700,10 +712,18 @@ static CMPIStatus _update_resources_for(
goto out;
}
- if (cu_get_u16_prop(rasd, "ResourceType", &type) != CMPI_RC_OK) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing ResourceType");
+ op = CMGetObjectPath(rasd, NULL);
+ if (op == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get RASD path");
+ goto out;
+ }
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to determine RASD type");
goto out;
}
16 years, 11 months
[PATCH] Make RASD not dependent on ResourceType key
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1193761666 25200
# Node ID 02556a928bf33c5f796009ae4ad2fb1cd37d6283
# Parent 6f68b7da0f6bfa6f1c709f56b2879c62e8831639
Make RASD not dependent on ResourceType key
I have tested DefineSystem() and some of the ResourcePool associations.
(removed the AllocationCapabilities changes)
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 6f68b7da0f6b -r 02556a928bf3 schema/KVM_ResourceAllocationSettingData.mof
--- a/schema/KVM_ResourceAllocationSettingData.mof Tue Oct 30 09:25:06 2007 -0700
+++ b/schema/KVM_ResourceAllocationSettingData.mof Tue Oct 30 09:27:46 2007 -0700
@@ -1,9 +1,4 @@
// Copyright IBM Corp. 2007
class KVM_ResourceAllocationSettingData : CIM_ResourceAllocationSettingData {
- [Key,
- Description ("The type of allocated resource"),
- Override ("ResourceType")]
- uint16 ResourceType;
-
};
diff -r 6f68b7da0f6b -r 02556a928bf3 schema/Xen_ResourceAllocationSettingData.mof
--- a/schema/Xen_ResourceAllocationSettingData.mof Tue Oct 30 09:25:06 2007 -0700
+++ b/schema/Xen_ResourceAllocationSettingData.mof Tue Oct 30 09:27:46 2007 -0700
@@ -1,9 +1,4 @@
// Copyright IBM Corp. 2007
class Xen_ResourceAllocationSettingData : CIM_ResourceAllocationSettingData {
- [Key,
- Description ("The type of allocated resource"),
- Override ("ResourceType")]
- uint16 ResourceType;
-
};
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Makefile.am
--- a/src/Makefile.am Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Makefile.am Tue Oct 30 09:27:46 2007 -0700
@@ -83,8 +83,10 @@ libVirt_ElementCapabilities_la_LIBADD =
-lVirt_HostSystem
libVirt_AllocationCapabilities_la_SOURCES = Virt_AllocationCapabilities.c
+libVirt_AllocationCapabilities_la_LIBADD = -lVirt_RASD
libVirt_SettingsDefineCapabilities_la_SOURCES = Virt_SettingsDefineCapabilities.c
+libVirt_SettingsDefineCapabilities_la_LIBADD = -lVirt_RASD
libVirt_RegisteredProfile_la_SOURCES = Virt_RegisteredProfile.c
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_RASD.c
--- a/src/Virt_RASD.c Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_RASD.c Tue Oct 30 09:27:46 2007 -0700
@@ -205,10 +205,38 @@ static CMPIInstance *get_rasd_instance(c
return inst;
}
+CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type)
+{
+ char *base = NULL;
+ CMPIrc rc = CMPI_RC_ERR_FAILED;
+
+ base = class_base_name(cn);
+ if (base == NULL)
+ goto out;
+
+ if (STREQ(base, "DiskResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_DISK;
+ else if (STREQ(base, "NetResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_NET;
+ else if (STREQ(base, "ProcResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_PROC;
+ else if (STREQ(base, "MemResourceAllocationSettingData"))
+ *type = CIM_RASD_TYPE_MEM;
+ else
+ goto out;
+
+ rc = CMPI_RC_OK;
+
+ out:
+ free(base);
+
+ return rc;
+}
+
static CMPIStatus GetInstance(CMPIInstanceMI *self,
const CMPIContext *context,
const CMPIResult *results,
- const CMPIObjectPath *reference,
+ const CMPIObjectPath *ref,
const char **properties)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
@@ -216,7 +244,7 @@ static CMPIStatus GetInstance(CMPIInstan
char *id = NULL;
uint16_t type;
- id = cu_get_str_path(reference, "InstanceID");
+ id = cu_get_str_path(ref, "InstanceID");
if (id == NULL) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -224,14 +252,14 @@ static CMPIStatus GetInstance(CMPIInstan
goto out;
}
- if (!cu_get_u16_path(reference, "ResourceType", &type)) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
- "Missing or invalid ResourceType");
- goto out;
- }
-
- inst = get_rasd_instance(context, reference, id, type);
+ "Unable to determine RASD type");
+ goto out;
+ }
+
+ inst = get_rasd_instance(context, ref, id, type);
if (inst != NULL)
CMReturnInstance(results, inst);
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_RASD.h
--- a/src/Virt_RASD.h Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_RASD.h Tue Oct 30 09:27:46 2007 -0700
@@ -27,6 +27,7 @@ int rasds_for_domain(const CMPIBroker *b
const uint16_t type,
const char *ns,
struct inst_list *_list);
+CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type);
#endif
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_ResourceAllocationFromPool.c
--- a/src/Virt_ResourceAllocationFromPool.c Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_ResourceAllocationFromPool.c Tue Oct 30 09:27:46 2007 -0700
@@ -42,7 +42,6 @@ static CMPIStatus rasd_to_pool(const CMP
struct inst_list *list)
{
CMPIStatus s;
- int ret;
uint16_t type;
char *id = NULL;
char *poolid = NULL;
@@ -52,11 +51,10 @@ static CMPIStatus rasd_to_pool(const CMP
inst_list_init(&_list);
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (!ret) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing ResourceType");
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to determine RASD type");
goto out;
}
@@ -113,8 +111,16 @@ static int filter_by_pool(struct inst_li
for (i = 0; i < src->cur; i++) {
CMPIInstance *inst = src->list[i];
-
- cu_get_u16_prop(inst, "ResourceType", &type);
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(inst, NULL);
+ if (op == NULL)
+ continue;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) !=
+ CMPI_RC_OK)
+ continue;
+
cu_get_str_prop(inst, "InstanceID", &rasd_id);
poolid = pool_member_of(_BROKER, type, rasd_id);
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_SettingsDefineCapabilities.c Tue Oct 30 09:27:46 2007 -0700
@@ -37,6 +37,7 @@
#include "svpc_types.h"
#include "Virt_SettingsDefineCapabilities.h"
+#include "Virt_RASD.h"
const static CMPIBroker *_BROKER;
@@ -315,13 +316,11 @@ static CMPIStatus alloc_cap_to_rasd(cons
struct inst_list *list)
{
CMPIStatus s = {CMPI_RC_OK};
- int ret;
uint16_t type;
CU_DEBUG("Getting ResourceType.\n");
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (ret != 1) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED,
"Could not get ResourceType.");
goto out;
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_SettingsDefineState.c
--- a/src/Virt_SettingsDefineState.c Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_SettingsDefineState.c Tue Oct 30 09:27:46 2007 -0700
@@ -162,7 +162,6 @@ static CMPIStatus rasd_to_dev(const CMPI
CMPIStatus s;
CMPIInstance *dev = NULL;
char *id = NULL;
- int ret;
uint16_t type;
ASSOC_MATCH(info->provider_name, CLASSNAME(ref));
@@ -175,8 +174,7 @@ static CMPIStatus rasd_to_dev(const CMPI
goto out;
}
- ret = cu_get_u16_path(ref, "ResourceType", &type);
- if (!ret) {
+ if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Missing ResourceType");
diff -r 6f68b7da0f6b -r 02556a928bf3 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Tue Oct 30 09:25:06 2007 -0700
+++ b/src/Virt_VirtualSystemManagementService.c Tue Oct 30 09:27:46 2007 -0700
@@ -158,9 +158,15 @@ static int rasd_to_vdev(CMPIInstance *in
char *id = NULL;
char *name = NULL;
char *devid = NULL;
-
- if (cu_get_u16_prop(inst, "ResourceType", &type) != CMPI_RC_OK)
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(inst, NULL);
+ if (op == NULL)
goto err;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) != CMPI_RC_OK)
+ goto err;
+
dev->type = (int)type;
if (cu_get_str_prop(inst, "InstanceID", &id) != CMPI_RC_OK)
@@ -207,7 +213,6 @@ static int classify_resources(struct ins
static int classify_resources(struct inst_list *all,
struct domain *domain)
{
- int ret;
int i;
uint16_t type;
@@ -220,8 +225,14 @@ static int classify_resources(struct ins
domain->dev_net = calloc(all->cur, sizeof(struct virt_device));
for (i = 0; i < all->cur; i++) {
- ret = cu_get_u16_prop(all->list[i], "ResourceType", &type);
- if (ret != CMPI_RC_OK)
+ CMPIObjectPath *op;
+
+ op = CMGetObjectPath(all->list[i], NULL);
+ if (op == NULL)
+ return 0;
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) !=
+ CMPI_RC_OK)
return 0;
if (type == CIM_RASD_TYPE_PROC)
@@ -682,6 +693,7 @@ static CMPIStatus _update_resources_for(
struct domain *dominfo = NULL;
uint16_t type;
char *xml = NULL;
+ CMPIObjectPath *op;
if (!get_dominfo(dom, &dominfo)) {
cu_statusf(_BROKER, &s,
@@ -690,10 +702,18 @@ static CMPIStatus _update_resources_for(
goto out;
}
- if (cu_get_u16_prop(rasd, "ResourceType", &type) != CMPI_RC_OK) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Missing ResourceType");
+ op = CMGetObjectPath(rasd, NULL);
+ if (op == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get RASD path");
+ goto out;
+ }
+
+ if (rasd_type_from_classname(CLASSNAME(op), &type) != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to determine RASD type");
goto out;
}
16 years, 11 months
[PATCH] add RPM packaging for libvirt-cim, and cleanups
by Daniel Veillard
# HG changeset patch
# User Daniel Veillard <veillard(a)redhat.com>
# Date 1193656844 -3600
# Node ID 5b601a0035127544c54feaf086fb7065f873e9f9
# Parent aaad430ea766d9a3bc0be035e595d8da17ee2122
RPM Packaging changes and associated cleanups:
- Augment some Makefiles variables with missing files
- add a spec file template
- extend the configure script to generate the spec file
- add a 'make rpm' target
- fix src/Makefile.am to use late binding of providerdir variable
Signed-off-by: Daniel Veillard <veillard(a)redhat.com>
There is still one thing missing I guess in the spec file: the registration
step, which I think should be run as a post-install script. The spec file
saves the provider-register.sh and register_base.sh scripts in
/usr/share/libvirt-cim/ so they are available at that point, but I don't
understand how to best call them, so it will need some attention by someone
who knows how that process should work.
Daniel
diff -r aaad430ea766 -r 5b601a003512 Makefile.am
--- a/Makefile.am Fri Oct 26 13:34:26 2007 -0700
+++ b/Makefile.am Mon Oct 29 12:20:44 2007 +0100
@@ -74,9 +74,11 @@ EXTRA_BASE_MOFS = \
schema/KVM_ResourceAllocationSettingData.mof
pkgdata_DATA = $(MOFS) $(REGS)
-pkgdata_SCRIPTS = provider-register.sh
+pkgdata_SCRIPTS = provider-register.sh register_base.sh
-EXTRA_DIST = schema $(pkgdata_DATA) $(pkgdata_SCRIPTS)
+EXTRA_DIST = schema $(pkgdata_DATA) $(pkgdata_SCRIPTS) \
+ libvirt-cim.spec.in libvirt-cim.spec \
+ doc/CodingStyle doc/SubmittingPatches
# Un/Register the providers and class definitions from/to the current CIMOM.
# @CIMSERVER@ is set by the configure script
@@ -88,3 +90,6 @@ preuninstall:
preuninstall:
sh provider-register.sh -d -t @CIMSERVER@ -n /root/ibmsd -r $(REGS) -m $(MOFS)
sh provider-register.sh -d -t @CIMSERVER@ -n /root/interop -r $(INTEROP_REGS) -m $(INTEROP_MOFS)
+
+rpm: clean
+ @(unset CDPATH ; $(MAKE) dist && rpmbuild -ta $(distdir).tar.gz)
diff -r aaad430ea766 -r 5b601a003512 configure.ac
--- a/configure.ac Fri Oct 26 13:34:26 2007 -0700
+++ b/configure.ac Mon Oct 29 12:20:44 2007 +0100
@@ -180,7 +180,7 @@ echo "----------------------------------
echo "----------------------------------------------------------"
# Generate configure scripts for the Makefile
-AC_OUTPUT
+AC_OUTPUT(libvirt-cim.spec)
echo "You may now run make"
diff -r aaad430ea766 -r 5b601a003512 libvirt-cim.spec.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libvirt-cim.spec.in Mon Oct 29 12:20:44 2007 +0100
@@ -0,0 +1,65 @@
+# -*- rpm-spec -*-
+
+Summary: A CIM provider for libvirt
+Name: libvirt-cim
+Version: @PACKAGE_VERSION@
+Release: 1%{?dist}%{?extra_release}
+License: LGPL
+Group: Development/Libraries
+Source: libvirt-cim-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+URL: http://libvirt.org/CIM/
+Requires: libxml2
+Requires: libvirt >= 0.2.3
+BuildRequires: sblim-cmpi-devel
+BuildRequires: libvirt-devel >= 0.2.3
+BuildRequires: e2fsprogs-devel
+BuildRequires: libxml2-devel
+BuildRequires: libcmpiutil-devel
+
+%description
+Libvirt-cim is a CMPI CIM provider that implements the DMTF SVPC
+virtualization model. The goal is to support most of the features
+exported by libvirt itself, enabling management of multiple
+platforms with a single provider.
+
+%prep
+%setup -q
+
+%build
+%configure --disable-werror
+make
+
+%install
+rm -fr %{buildroot}
+
+%makeinstall PROVIDERDIR=%{buildroot}%{_libdir}/cmpi
+cp provider-register.sh register_base.sh %{buildroot}%{_datadir}/libvirt-cim/
+rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
+rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
+rm -f $RPM_BUILD_ROOT%{_libdir}/cmpi/*.la
+rm -f $RPM_BUILD_ROOT%{_libdir}/cmpi/*.a
+
+%clean
+rm -fr %{buildroot}
+
+%post
+/sbin/ldconfig
+
+%postun
+/sbin/ldconfig
+
+%files
+%defattr(-, root, root)
+
+%doc README doc/CodingStyle doc/SubmittingPatches
+%doc provider-register.sh register_base.sh
+%{_libdir}/lib*.so*
+%{_libdir}/cmpi/lib*.so*
+%{_datadir}/libvirt-cim/*.sh
+%{_datadir}/libvirt-cim/*.mof
+%{_datadir}/libvirt-cim/*.registration
+
+%changelog
+* Fri Oct 26 2007 Daniel Veillard <veillard(a)redhat.com> - 0.1-1
+- created
diff -r aaad430ea766 -r 5b601a003512 libxkutil/Makefile.am
--- a/libxkutil/Makefile.am Fri Oct 26 13:34:26 2007 -0700
+++ b/libxkutil/Makefile.am Mon Oct 29 12:20:44 2007 +0100
@@ -4,7 +4,7 @@ SUBDIRS = tests
CFLAGS += $(CFLAGS_STRICT)
-noinst_HEADERS = cs_util.h misc_util.h device_parsing.h hostres.h
+noinst_HEADERS = cs_util.h misc_util.h device_parsing.h hostres.h xmlgen.h
lib_LTLIBRARIES = libxkutil.la
diff -r aaad430ea766 -r 5b601a003512 src/Makefile.am
--- a/src/Makefile.am Fri Oct 26 13:34:26 2007 -0700
+++ b/src/Makefile.am Mon Oct 29 12:20:44 2007 +0100
@@ -1,7 +1,20 @@
# Copyright IBM Corp. 2007
SUBDIRS = tests
-noinst_HEADERS = Virt_ElementConformsToProfile.h profiles.h
+noinst_HEADERS = profiles.h svpc_types.h \
+ Virt_AllocationCapabilities.h \
+ Virt_ComputerSystem.h \
+ Virt_ComputerSystemIndication.h \
+ Virt_Device.h \
+ Virt_DevicePool.h \
+ Virt_ElementConformsToProfile.h \
+ Virt_EnabledLogicalElementCapabilities.h \
+ Virt_HostSystem.h \
+ Virt_RASD.h \
+ Virt_RegisteredProfile.h \
+ Virt_SettingsDefineCapabilities.h \
+ Virt_VirtualSystemManagementCapabilities.h \
+ Virt_VSSD.h
XKUADD = $(top_builddir)/libxkutil/libxkutil.la
@@ -9,7 +22,7 @@ CFLAGS += -I$(top_builddir)/libxkutil $(
AM_LDFLAGS = $(XKUADD)
-providerdir = @PROVIDERDIR@
+providerdir = $(PROVIDERDIR)
provider_LTLIBRARIES = libVirt_ComputerSystem.la \
libVirt_Device.la \
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
16 years, 11 months