[PATCH] Remove extra newline characters at end of CU_DEBUG calls
by Jay Gagnon
# HG changeset patch
# User Jay Gagnon <grendel(a)linux.vnet.ibm.com>
# Date 1194980442 18000
# Node ID cd4498fc44de514aed4232f5ee1a9a4828d8e3b1
# Parent 5f84fd6c5cdefb2dfe41e4d8ec6ca750d3e69faa
Remove extra newline characters at end of CU_DEBUG calls.
Signed-off-by: Jay Gagnon <grendel(a)linux.vnet.ibm.com>
diff -r 5f84fd6c5cde -r cd4498fc44de std_association.c
--- a/std_association.c Thu Nov 08 11:21:50 2007 -0800
+++ b/std_association.c Tue Nov 13 14:00:42 2007 -0500
@@ -139,22 +139,22 @@ static CMPIStatus do_assoc(struct std_as
inst_list_init(&list);
- CU_DEBUG("Getting handler...\n");
+ CU_DEBUG("Getting handler...");
handler = std_assoc_get_handler(ctx, ref);
if (handler == NULL) {
- CU_DEBUG("No handler found.\n");
+ CU_DEBUG("No handler found.");
cu_statusf(ctx->brkr, &s,
CMPI_RC_ERR_FAILED,
"Unable to handle this association");
goto out;
}
- CU_DEBUG("OK.\n\tsource: '%s'\n\ttarget: '%s'\n\tassoc_class: '%s'\n",
+ CU_DEBUG("OK.\n\tsource: '%s'\n\ttarget: '%s'\n\tassoc_class: '%s'",
handler->source_class,
handler->target_class,
handler->assoc_class);
- CU_DEBUG("Calling match_class: \n\tinfo->result_class: '%s'\n",
+ CU_DEBUG("Calling match_class: \tinfo->result_class: '%s'",
info->result_class);
rc = match_class(ctx->brkr,
@@ -162,35 +162,35 @@ static CMPIStatus do_assoc(struct std_as
info->result_class,
handler->target_class);
if (!rc) {
- CU_DEBUG("Match_class failed.\n");
- goto out;
- }
- CU_DEBUG("Match_class succeeded.\n");
-
- CU_DEBUG("Calling match_class: \n\tinfo->assoc_class: '%s'\n",
+ CU_DEBUG("Match_class failed.");
+ goto out;
+ }
+ CU_DEBUG("Match_class succeeded.");
+
+ CU_DEBUG("Calling match_class: \tinfo->assoc_class: '%s'",
info->result_class);
rc = match_class(ctx->brkr,
NAMESPACE(ref),
info->assoc_class,
handler->assoc_class);
if (!rc) {
- CU_DEBUG("Match_class failed.\n");
- goto out;
- }
- CU_DEBUG("Match_class succeeded.\n");
- CU_DEBUG("Calling handler->handler...\n");
+ CU_DEBUG("Match_class failed.");
+ goto out;
+ }
+ CU_DEBUG("Match_class succeeded.");
+ CU_DEBUG("Calling handler->handler...");
s = handler->handler(ref, info, &list);
if (s.rc != CMPI_RC_OK) {
- CU_DEBUG("\thandler did not return CMPI_RC_OK.\n");
+ CU_DEBUG("Handler did not return CMPI_RC_OK.");
goto out;
} else {
- CU_DEBUG("\thandler returned CMPI_RC_OK.\n");
+ CU_DEBUG("Handler returned CMPI_RC_OK.");
}
if (list.list == NULL) {
- CU_DEBUG("\tlist is empty.\n");
+ CU_DEBUG("List is empty.");
goto out;
}
@@ -199,15 +199,15 @@ static CMPIStatus do_assoc(struct std_as
info->result_class,
ctx->brkr);
if (s.rc != CMPI_RC_OK) {
- CU_DEBUG("\tfilter_results did not return CMPI_RC_OK.\n");
+ CU_DEBUG("filter_results did not return CMPI_RC_OK.");
goto out;
}
if (list.list == NULL) {
- CU_DEBUG("\tlist is empty.\n");
+ CU_DEBUG("list is empty.");
goto out;
} else {
- CU_DEBUG("\treturned %u instance(s).\n", list.cur);
+ CU_DEBUG("returned %u instance(s).", list.cur);
}
if (names_only)
@@ -218,7 +218,6 @@ static CMPIStatus do_assoc(struct std_as
out:
inst_list_free(&list);
- CU_DEBUG("Returning.\n");
return s;
}
17 years, 1 month
[PATCH] Remove newline characters from CU_DEBUG calls now that the newline is automatic. Also remove a few debug messages that are no longer necessary and clutter output
by Jay Gagnon
# HG changeset patch
# User Jay Gagnon <grendel(a)linux.vnet.ibm.com>
# Date 1194979853 18000
# Node ID 49c65d339cc56abfc9dc3e09c6f894ea88fc169e
# Parent aad2a74321d54e26b5b2c89dc8df0e95bd1860f8
Remove newline characters from CU_DEBUG calls now that the newline is automatic. Also remove a few debug messages that are no longer necessary and clutter output.
Signed-off-by: Jay Gagnon <grendel(a)linux.vnet.ibm.com>
diff -r aad2a74321d5 -r 49c65d339cc5 src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Tue Nov 13 11:14:14 2007 -0500
+++ b/src/Virt_SettingsDefineCapabilities.c Tue Nov 13 13:50:53 2007 -0500
@@ -55,12 +55,10 @@ static bool rasd_prop_copy_value(struct
{
bool rc = true;
- CU_DEBUG("Copying '%s'.\n", src.field);
+ CU_DEBUG("Copying '%s'.", src.field);
if (src.type & CMPI_string) {
- CU_DEBUG("String type.\n");
dest->value = (CMPIValue *)strdup((char *)src.value);
} else if (src.type & CMPI_INTEGER) {
- CU_DEBUG("Integer type.\n");
dest->value = malloc(sizeof(CMPIValue));
memcpy(dest->value, src.value, sizeof(CMPIValue));
} else {
@@ -78,7 +76,6 @@ static bool dup_rasd_prop_list(struct sd
*dest = NULL;
for (i = 0, count = 1; src[i].field != NULL; i++, count++) {
- CU_DEBUG("count: %d, i: %d. reallocing.\n", count, i);
*dest = realloc(*dest, count * sizeof(struct sdc_rasd_prop));
(*dest)[i].field = strdup(src[i].field);
ret = rasd_prop_copy_value(src[i], &(*dest)[i]);
@@ -86,7 +83,6 @@ static bool dup_rasd_prop_list(struct sd
}
/* Make sure to terminate the list. */
- CU_DEBUG("Terminating list. count: %d, i: %d\n", count, i);
*dest = realloc(*dest, count * sizeof(struct sdc_rasd_prop));
(*dest)[i] = (struct sdc_rasd_prop)PROP_END;
@@ -668,16 +664,15 @@ static CMPIInstance *sdc_rasd_inst(const
CMSetProperty(inst, "ResourceType", &resource_type, CMPI_uint16);
for (i = 0; prop_list[i].field != NULL; i++) {
- CU_DEBUG("Setting property '%s'.\n", prop_list[i].field);
+ CU_DEBUG("Setting property '%s'.", prop_list[i].field);
CMSetProperty(inst, prop_list[i].field,
prop_list[i].value, prop_list[i].type);
- CU_DEBUG("Set.\n");
- }
-
- CU_DEBUG("freeing prop_list.\n");
+ }
+
+ CU_DEBUG("freeing prop_list.");
free_rasd_prop_list(prop_list);
out:
- CU_DEBUG("Returning inst.\n");
+ CU_DEBUG("Returning inst.");
return inst;
}
@@ -704,17 +699,17 @@ static CMPIStatus sdc_rasds_for_type(con
CU_DEBUG("Problem getting inst.");
goto out;
}
- CU_DEBUG("Got inst.\n");
+ CU_DEBUG("Got inst.");
if (inst != NULL) {
inst_list_add(list, inst);
- CU_DEBUG("Added inst.\n");
+ CU_DEBUG("Added inst.");
} else {
- CU_DEBUG("Inst is null, not added.\n");
+ CU_DEBUG("Inst is null, not added.");
}
}
} else {
- CU_DEBUG("Unsupported type.\n");
+ CU_DEBUG("Unsupported type.");
CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED,
"Unsupported device type.");
}
@@ -731,7 +726,7 @@ static CMPIStatus alloc_cap_to_rasd(cons
int ret;
uint16_t type;
- CU_DEBUG("Getting ResourceType.\n");
+ CU_DEBUG("Getting ResourceType.");
ret = cu_get_u16_path(ref, "ResourceType", &type);
if (ret != 1) {
@@ -740,7 +735,7 @@ static CMPIStatus alloc_cap_to_rasd(cons
goto out;
}
- CU_DEBUG("ResourceType: %hi.\n", type);
+ CU_DEBUG("ResourceType: %hi.", type);
s = sdc_rasds_for_type(ref, list, type);
17 years, 1 month
[PATCH 0 of 6] Take two of huge SettingsDefineCapabilities set
by Jay Gagnon
Changes from the last set are:
reformatted cu_statusf calls
SDC_DISK_INC as a define
use of libvirt call for proc_max
breakout for net_max so each hypervisor can have its own function call
alloc_to_pool returning unsupported instead of nothing
17 years, 1 month
[PATCH] Change cu_compare_ref() to be a little lighter-weight
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1194453648 28800
# Node ID 926009fc62a0080bcf93aaddf098b074ce71a096
# Parent 404c4803b1b542676c4d283226a7cc3b7f3ab58d
Change cu_compare_ref() to be a little lighter-weight
Now, we just check the keys that were provided by the client (or the CIMOM
if that ever starts to happen). We will have already checked the required
keys to actually do the lookup in the provider, which serves the "required"
key purpose. Changes to libvirt-cim to follow shortly...
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 404c4803b1b5 -r 926009fc62a0 instance_util.c
--- a/instance_util.c Fri Nov 02 15:29:38 2007 -0700
+++ b/instance_util.c Wed Nov 07 08:40:48 2007 -0800
@@ -88,38 +88,48 @@ static bool _compare_data(const CMPIData
return false;
}
-const struct cu_property *cu_compare_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- const struct cu_property *props)
+const char *cu_compare_ref(const CMPIObjectPath *ref,
+ const CMPIInstance *inst)
{
- const struct cu_property *p = NULL;
int i;
CMPIStatus s;
+ int count;
+ const char *prop = NULL;
- for (i = 0; props[i].name != NULL; i++) {
+ count = CMGetKeyCount(ref, &s);
+ if (s.rc != CMPI_RC_OK) {
+ CU_DEBUG("Unable to get key count");
+ return NULL;
+ }
+
+ for (i = 0; i < count; i++) {
CMPIData kd, pd;
+ CMPIString *str;
- p = &props[i];
-
- kd = CMGetKey(ref, p->name, &s);
+ kd = CMGetKeyAt(ref, i, &str, &s);
if (s.rc != CMPI_RC_OK) {
- if (p->required)
- goto out;
- else
- continue;
+ CU_DEBUG("Failed to get key %i", i);
+ goto out;
}
- pd = CMGetProperty(inst, p->name, &s);
- if (s.rc != CMPI_RC_OK)
+ prop = CMGetCharPtr(str);
+ CU_DEBUG("Comparing key `%s'", prop);
+
+ pd = CMGetProperty(inst, prop, &s);
+ if (s.rc != CMPI_RC_OK) {
+ CU_DEBUG("Failed to get property `%s'", prop);
goto out;
+ }
- if (!_compare_data(&kd, &pd))
+ if (!_compare_data(&kd, &pd)) {
+ CU_DEBUG("No data match for `%s'", prop);
goto out;
+ }
}
- p = NULL;
+ prop = NULL;
out:
- return p;
+ return prop;
}
/*
diff -r 404c4803b1b5 -r 926009fc62a0 libcmpiutil.h
--- a/libcmpiutil.h Fri Nov 02 15:29:38 2007 -0700
+++ b/libcmpiutil.h Wed Nov 07 08:40:48 2007 -0800
@@ -337,26 +337,17 @@ void inst_list_free(struct inst_list *li
*/
int inst_list_add(struct inst_list *list, CMPIInstance *inst);
-struct cu_property {
- const char *name;
- bool required;
-};
-
/**
* Compare key values in a reference to properties in an instance,
- * making sure they are identical. If props identifies a particular
- * key as not required, then absence in the object path will not
- * result in failure of this test.
+ * making sure they are identical.
*
* @param ref The ObjectPath to examine
* @param inst The Instance to compare
- * @param props A NULL-terminated list of properties to compare
- * @returns A pointer to the property structure of the first
- * non-matching property, or NULL if all match
- */
-const struct cu_property *cu_compare_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- const struct cu_property *props);
+ * @returns A pointer to the name of the first non-matching property,
+ * or NULL if all match
+ */
+const char *cu_compare_ref(const CMPIObjectPath *ref,
+ const CMPIInstance *inst);
#define DEFAULT_EIN(pn) \
static CMPIStatus pn##EnumInstanceNames(CMPIInstanceMI *self, \
17 years, 1 month
[PATCH] GetInstance does not return NOT_FOUND in case of Xen classname on KVM system (and reverse)
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1194957414 -3600
# Node ID a561761306d40f4394cb519784c5b474a268db7d
# Parent b201578d4ade863822cb06c1e52d839f51250d87
GetInstance does not return NOT_FOUND in case of Xen classname on KVM system (and reverse)
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r b201578d4ade -r a561761306d4 src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c Tue Nov 13 09:37:25 2007 +0100
+++ b/src/Virt_ComputerSystem.c Tue Nov 13 13:36:54 2007 +0100
@@ -381,6 +381,11 @@ static CMPIStatus get_domain(const CMPIO
virConnectPtr conn = NULL;
const char *prop = NULL;
+ if (!provider_is_responsible(_BROKER, reference, &s)) {
+ CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND);
+ return s;
+ }
+
conn = lv_connect(_BROKER, &s);
if (conn == NULL)
return s;
17 years, 1 month
[PATCH] Make cu_compare_ref() also compare the actual classname of the ref and inst
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1194548973 28800
# Node ID a55a0f630c034ac5ed76211b8459ae1e4fdc56ae
# Parent 41c761dba6a6268da6fdb9a89c1cc6f959870aac
Make cu_compare_ref() also compare the actual classname of the ref and inst
...and change STREQ to STREQC, per Heidi's suggestion.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 41c761dba6a6 -r a55a0f630c03 instance_util.c
--- a/instance_util.c Thu Nov 08 10:28:41 2007 -0800
+++ b/instance_util.c Thu Nov 08 11:09:33 2007 -0800
@@ -78,7 +78,7 @@ static bool _compare_data(const CMPIData
const char *as = CMGetCharPtr(a->value.string);
const char *bs = CMGetCharPtr(b->value.string);
- return STREQ(as, bs);
+ return STREQC(as, bs);
} else if (a->type & CMPI_INTEGER) {
return memcmp(&a->value, &b->value, sizeof(a->value)) == 0;
}
@@ -86,6 +86,29 @@ static bool _compare_data(const CMPIData
CU_DEBUG("Unhandled CMPI type: `%i'", a->type);
return false;
+}
+
+static bool _compare_classname(const CMPIObjectPath *ref,
+ const CMPIInstance *inst)
+{
+ const char *ref_cn;
+ const char *inst_cn;
+ CMPIObjectPath *op;
+ CMPIStatus s;
+
+ op = CMGetObjectPath(inst, &s);
+ if ((op == NULL) || (s.rc != CMPI_RC_OK))
+ return false;
+
+ ref_cn = CLASSNAME(ref);
+ if (ref_cn == NULL)
+ return false;
+
+ inst_cn = CLASSNAME(op);
+ if (inst_cn == NULL)
+ return false;
+
+ return STREQC(inst_cn, ref_cn);
}
const char *cu_compare_ref(const CMPIObjectPath *ref,
@@ -101,6 +124,9 @@ const char *cu_compare_ref(const CMPIObj
CU_DEBUG("Unable to get key count");
return NULL;
}
+
+ if (!_compare_classname(ref, inst))
+ return "CreationClassName";
for (i = 0; i < count; i++) {
CMPIData kd, pd;
17 years, 1 month
[PATCH] This fixes a potential crash if _get_domain() is unable to properly parse the dom XML
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1194918780 28800
# Node ID 8b6965d9e9479dab28337480e1f84812d2c880f2
# Parent 4ceb57b4430b0455ef7cb68f57a8ec6ad01abeca
This fixes a potential crash if _get_domain() is unable to properly parse the dom XML.
Also fixes an issue in VSSD - if get_domaininfo() returns 0 (an error), then instance_from_dom() needs to set ret properly so that an empty instance won't be created.
Previous patch had a memory leak - fixed this issue.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 4ceb57b4430b -r 8b6965d9e947 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Mon Nov 12 13:54:53 2007 -0800
+++ b/libxkutil/device_parsing.c Mon Nov 12 17:53:00 2007 -0800
@@ -575,16 +575,24 @@ int get_dominfo(virDomainPtr dom, struct
xml = virDomainGetXMLDesc(dom, 0);
if (!xml) {
free(*dominfo);
+ *dominfo = NULL;
return 0;
}
ret = _get_dominfo(xml, *dominfo);
- free(xml);
+ if (!ret) {
+ free(*dominfo);
+ *dominfo = NULL;
+ goto out;
+ }
(*dominfo)->dev_mem_ct = get_mem_devices(dom, &(*dominfo)->dev_mem);
(*dominfo)->dev_net_ct = get_net_devices(dom, &(*dominfo)->dev_net);
(*dominfo)->dev_disk_ct = get_disk_devices(dom, &(*dominfo)->dev_disk);
(*dominfo)->dev_vcpu_ct = get_vcpu_devices(dom, &(*dominfo)->dev_vcpu);
+
+out:
+ free(xml);
return ret;
}
diff -r 4ceb57b4430b -r 8b6965d9e947 src/Virt_VSSD.c
--- a/src/Virt_VSSD.c Mon Nov 12 13:54:53 2007 -0800
+++ b/src/Virt_VSSD.c Mon Nov 12 17:53:00 2007 -0800
@@ -45,7 +45,8 @@ static int instance_from_dom(virDomainPt
CMPIObjectPath *op;
struct domain *dominfo = NULL;
- if (!get_dominfo(dom, &dominfo))
+ ret = get_dominfo(dom, &dominfo);
+ if (!ret)
goto out;
op = CMGetObjectPath(inst, NULL);
17 years, 1 month
[PATCH] This fixes a potential crash if _get_domain() is unable to properly parse the dom XML
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1194912941 28800
# Node ID f2966070990024afbad3ee79dd5f276b0310aa2e
# Parent 4ceb57b4430b0455ef7cb68f57a8ec6ad01abeca
This fixes a potential crash if _get_domain() is unable to properly parse the dom XML.
Also fixes an issue in VSSD - if get_domaininfo() returns 0 (an error), then instance_from_dom() needs to set ret properly so that an empty instance won't be created.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 4ceb57b4430b -r f29660709900 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Mon Nov 12 13:54:53 2007 -0800
+++ b/libxkutil/device_parsing.c Mon Nov 12 16:15:41 2007 -0800
@@ -575,10 +575,17 @@ int get_dominfo(virDomainPtr dom, struct
xml = virDomainGetXMLDesc(dom, 0);
if (!xml) {
free(*dominfo);
+ *dominfo = NULL;
return 0;
}
ret = _get_dominfo(xml, *dominfo);
+ if (!ret) {
+ free(*dominfo);
+ *dominfo = NULL;
+ return 0;
+ }
+
free(xml);
(*dominfo)->dev_mem_ct = get_mem_devices(dom, &(*dominfo)->dev_mem);
diff -r 4ceb57b4430b -r f29660709900 src/Virt_VSSD.c
--- a/src/Virt_VSSD.c Mon Nov 12 13:54:53 2007 -0800
+++ b/src/Virt_VSSD.c Mon Nov 12 16:15:41 2007 -0800
@@ -45,7 +45,8 @@ static int instance_from_dom(virDomainPt
CMPIObjectPath *op;
struct domain *dominfo = NULL;
- if (!get_dominfo(dom, &dominfo))
+ ret = get_dominfo(dom, &dominfo);
+ if (!ret)
goto out;
op = CMGetObjectPath(inst, NULL);
17 years, 1 month
[PATCH] Fix crash if create_system() returns a NULL instance
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1194905315 28800
# Node ID c3aebc961483f72f6a60795b5902499cd4422a9e
# Parent 44fb749aa036b3ccaeed3862a302a3848cea3822
Fix crash if create_system() returns a NULL instance
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 44fb749aa036 -r c3aebc961483 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Mon Nov 12 14:06:19 2007 -0800
+++ b/src/Virt_VirtualSystemManagementService.c Mon Nov 12 14:08:35 2007 -0800
@@ -388,6 +388,8 @@ static CMPIStatus define_system(CMPIMeth
goto out;
sys = create_system(vssd, &res, reference, &s);
+ if (sys == NULL)
+ goto out;
inst_list_free(&res);
17 years, 1 month
[PATCH] Handle the case where bootloader (and _args) is not specified
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1194905179 28800
# Node ID 44fb749aa036b3ccaeed3862a302a3848cea3822
# Parent 4ceb57b4430b0455ef7cb68f57a8ec6ad01abeca
Handle the case where bootloader (and _args) is not specified
Otherwise, there is an error starting the domain because the bootloader
is not executable.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 4ceb57b4430b -r 44fb749aa036 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Mon Nov 12 13:54:53 2007 -0800
+++ b/libxkutil/xmlgen.c Mon Nov 12 14:06:19 2007 -0800
@@ -244,21 +244,29 @@ static char *system_xml(struct domain *d
static char *system_xml(struct domain *domain)
{
int ret;
- char *xml;
+ char *bl = NULL;
+ char *bl_args = NULL;
+ char *xml;
+
+ bl = tagify("bootloader", domain->bootloader, NULL, 0);
+ bl_args = tagify("bootloader_args", domain->bootloader_args, NULL, 0);
ret = asprintf(&xml,
"<name>%s</name>\n"
- "<bootloader>%s</bootloader>\n"
- "<bootloader_args>%s</bootloader_args>\n"
+ "%s\n"
+ "%s\n"
"<on_poweroff>%s</on_poweroff>\n"
"<on_crash>%s</on_crash>\n",
domain->name,
- domain->bootloader,
- domain->bootloader_args,
+ bl,
+ bl_args,
vssd_recovery_action_str(domain->on_poweroff),
vssd_recovery_action_str(domain->on_crash));
if (ret == -1)
xml = NULL;
+
+ free(bl);
+ free(bl_args);
return xml;
}
17 years, 1 month