[PATCH] (#3) Make the ProcRASD show CPU pinning information
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1202320669 28800
# Node ID c82b7296a2cfcdc6cec7c42412326aca9cfa8421
# Parent da31d60724565fb6da4bed307bcc69d710680306
(#3) Make the ProcRASD show CPU pinning information
This is done by embedding instances of the physical processor objects into
the HostResource[] field of the ProcRASD (per the MOF).
In order for the linkage to be present, you need sblim-cmpi-base.
Changes:
- Remove silly double-semicolons from proc_set_cpu()
- Actually report the correct pinning information
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r da31d6072456 -r c82b7296a2cf src/Virt_RASD.c
--- a/src/Virt_RASD.c Wed Feb 06 09:18:23 2008 -0800
+++ b/src/Virt_RASD.c Wed Feb 06 09:57:49 2008 -0800
@@ -23,6 +23,7 @@
#include <string.h>
#include <inttypes.h>
#include <sys/stat.h>
+#include <unistd.h>
#include <cmpidt.h>
#include <cmpift.h>
@@ -91,6 +92,195 @@ char *rasd_to_xml(CMPIInstance *rasd)
{
/* FIXME: Remove this */
return NULL;
+}
+
+static bool proc_get_physical_ref(const CMPIBroker *broker,
+ uint32_t physnum,
+ struct inst_list *list)
+{
+ CMPIObjectPath *op = NULL;
+ CMPIStatus s;
+ char hostname[255];
+ char *devid = NULL;
+ CMPIInstance *inst;
+ bool result = false;
+
+ if (asprintf(&devid, "%i", physnum) == -1) {
+ CU_DEBUG("Failed to create DeviceID string");
+ goto out;
+ }
+
+ if (gethostname(hostname, sizeof(hostname)) == -1) {
+ CU_DEBUG("Hostname overflow");
+ goto out;
+ }
+
+ op = CMNewObjectPath(broker, "root/cimv2", "Linux_Processor", &s);
+ if ((op == NULL) || (s.rc != CMPI_RC_OK)) {
+ CU_DEBUG("Failed to get ObjectPath for processor");
+ goto out;
+ }
+
+ CMAddKey(op, "CreationClassName",
+ (CMPIValue *)"Linux_Processor",
+ CMPI_chars);
+ CMAddKey(op, "SystemName",
+ (CMPIValue *)hostname,
+ CMPI_chars);
+ CMAddKey(op, "SystemCreationClassName",
+ (CMPIValue *)"Linux_ComputerSystem",
+ CMPI_chars);
+ CMAddKey(op, "DeviceID",
+ (CMPIValue *)devid,
+ CMPI_chars);
+
+ inst = CMNewInstance(broker, op, &s);
+ if ((inst == NULL) || (s.rc != CMPI_RC_OK)) {
+ CU_DEBUG("Failed to make instance");
+ goto out;
+ }
+
+ inst_list_add(list, inst);
+
+ result = true;
+ out:
+ free(devid);
+
+ return result;
+}
+
+static uint32_t proc_set_cpu(const CMPIBroker *broker,
+ virNodeInfoPtr node,
+ virDomainPtr dom,
+ struct virt_device *dev,
+ struct inst_list *list)
+{
+ virVcpuInfoPtr vinfo = NULL;
+ virDomainInfo info;
+ uint8_t *cpumaps = NULL;
+ int ret;
+ int i;
+ int vcpu = dev->dev.vcpu.number;
+ int maplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(*node));
+
+ ret = virDomainGetInfo(dom, &info);
+ if (ret == -1) {
+ CU_DEBUG("Failed to get info for domain `%s'",
+ virDomainGetName(dom));
+ goto out;
+ }
+
+ if (dev->dev.vcpu.number >= info.nrVirtCpu) {
+ CU_DEBUG("VCPU %i higher than max of %i for %s",
+ dev->dev.vcpu.number,
+ info.nrVirtCpu,
+ virDomainGetName(dom));
+ goto out;
+ }
+
+ vinfo = calloc(info.nrVirtCpu, sizeof(*vinfo));
+ if (vinfo == NULL) {
+ CU_DEBUG("Failed to allocate memory for %i virVcpuInfo",
+ info.nrVirtCpu);
+ goto out;
+ }
+
+ cpumaps = calloc(info.nrVirtCpu, maplen);
+ if (cpumaps == NULL) {
+ CU_DEBUG("Failed to allocate memory for %ix%i maps",
+ info.nrVirtCpu, maplen);
+ goto out;
+ }
+
+ ret = virDomainGetVcpus(dom, vinfo, info.nrVirtCpu, cpumaps, maplen);
+ if (ret < info.nrVirtCpu) {
+ CU_DEBUG("Failed to get VCPU info for %s",
+ virDomainGetName(dom));
+ goto out;
+ }
+
+ for (i = 0; i < VIR_NODEINFO_MAXCPUS(*node); i++) {
+ if (VIR_CPU_USABLE(cpumaps, maplen, vcpu, i)) {
+ CU_DEBUG("VCPU %i pinned to physical %i",
+ vcpu, i);
+ proc_get_physical_ref(broker, i, list);
+ } else {
+ CU_DEBUG("VCPU %i not pinned to physical %i",
+ vcpu, i);
+ }
+ }
+ out:
+ free(vinfo);
+ free(cpumaps);
+
+ return 0;
+}
+
+static CMPIStatus proc_rasd_from_vdev(const CMPIBroker *broker,
+ struct virt_device *dev,
+ const char *host,
+ const CMPIObjectPath *ref,
+ CMPIInstance *inst)
+{
+ virConnectPtr conn = NULL;
+ virDomainPtr dom = NULL;
+ virNodeInfo node;
+ CMPIStatus s;
+ CMPIArray *array;
+ struct inst_list list;
+
+ inst_list_init(&list);
+
+ conn = connect_by_classname(broker, CLASSNAME(ref), &s);
+ if (conn == NULL) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to connect for ProcRASD (%s)",
+ CLASSNAME(ref));
+ goto out;
+ }
+
+ dom = virDomainLookupByName(conn, host);
+ if (dom == NULL) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Unable to get domain for ProcRASD: %s", host);
+ goto out;
+ }
+
+ if (virNodeGetInfo(virDomainGetConnect(dom), &node) == -1) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get node info");
+ goto out;
+ }
+
+ proc_set_cpu(broker, &node, dom, dev, &list);
+
+ if (list.cur > 0) {
+ int i;
+
+ array = CMNewArray(broker,
+ list.cur,
+ CMPI_instance,
+ &s);
+ for (i = 0; i < list.cur; i++) {
+ CMSetArrayElementAt(array,
+ i,
+ (CMPIValue *)&list.list[i],
+ CMPI_instance);
+ }
+
+ CMSetProperty(inst, "HostResource",
+ (CMPIValue *)&array, CMPI_instanceA);
+ }
+
+ out:
+ inst_list_free(&list);
+ virDomainFree(dom);
+ virConnectClose(conn);
+
+ return s;
}
static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker,
@@ -159,6 +349,8 @@ static CMPIInstance *rasd_from_vdev(cons
(CMPIValue *)&dev->dev.mem.size, CMPI_uint64);
CMSetProperty(inst, "Limit",
(CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64);
+ } else if (dev->type == VIRT_DEV_VCPU) {
+ proc_rasd_from_vdev(broker, dev, host, ref, inst);
}
/* FIXME: Put the HostResource in place */
16 years, 8 months
[PATCH] (#2) Make the ProcRASD show CPU pinning information
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1202316457 28800
# Node ID 1f9cfddac518f134de81cae833e20120b38b673d
# Parent c7dd4a8358a187a3469c3d8a177950625898a227
(#2) Make the ProcRASD show CPU pinning information
This is done by embedding instances of the physical processor objects into
the HostResource[] field of the ProcRASD (per the MOF).
In order for the linkage to be present, you need sblim-cmpi-base.
Changes:
- Actually report the correct pinning information
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r c7dd4a8358a1 -r 1f9cfddac518 src/Virt_RASD.c
--- a/src/Virt_RASD.c Wed Feb 06 07:00:00 2008 -0800
+++ b/src/Virt_RASD.c Wed Feb 06 08:47:37 2008 -0800
@@ -23,6 +23,7 @@
#include <string.h>
#include <inttypes.h>
#include <sys/stat.h>
+#include <unistd.h>
#include <cmpidt.h>
#include <cmpift.h>
@@ -91,6 +92,195 @@ char *rasd_to_xml(CMPIInstance *rasd)
{
/* FIXME: Remove this */
return NULL;
+}
+
+static bool proc_get_physical_ref(const CMPIBroker *broker,
+ uint32_t physnum,
+ struct inst_list *list)
+{
+ CMPIObjectPath *op = NULL;
+ CMPIStatus s;
+ char hostname[255];
+ char *devid = NULL;
+ CMPIInstance *inst;
+ bool result = false;
+
+ if (asprintf(&devid, "%i", physnum) == -1) {
+ CU_DEBUG("Failed to create DeviceID string");
+ goto out;
+ }
+
+ if (gethostname(hostname, sizeof(hostname)) == -1) {
+ CU_DEBUG("Hostname overflow");
+ goto out;
+ }
+
+ op = CMNewObjectPath(broker, "root/cimv2", "Linux_Processor", &s);
+ if ((op == NULL) || (s.rc != CMPI_RC_OK)) {
+ CU_DEBUG("Failed to get ObjectPath for processor");
+ goto out;
+ }
+
+ CMAddKey(op, "CreationClassName",
+ (CMPIValue *)"Linux_Processor",
+ CMPI_chars);
+ CMAddKey(op, "SystemName",
+ (CMPIValue *)hostname,
+ CMPI_chars);
+ CMAddKey(op, "SystemCreationClassName",
+ (CMPIValue *)"Linux_ComputerSystem",
+ CMPI_chars);
+ CMAddKey(op, "DeviceID",
+ (CMPIValue *)devid,
+ CMPI_chars);
+
+ inst = CMNewInstance(broker, op, &s);
+ if ((inst == NULL) || (s.rc != CMPI_RC_OK)) {
+ CU_DEBUG("Failed to make instance");
+ goto out;
+ }
+
+ inst_list_add(list, inst);
+
+ result = true;
+ out:
+ free(devid);
+
+ return result;
+}
+
+static uint32_t proc_set_cpu(const CMPIBroker *broker,
+ virNodeInfoPtr node,
+ virDomainPtr dom,
+ struct virt_device *dev,
+ struct inst_list *list)
+{
+ virVcpuInfoPtr vinfo = NULL;
+ virDomainInfo info;
+ uint8_t *cpumaps = NULL;
+ int ret;
+ int i;
+ int vcpu = dev->dev.vcpu.number;;
+ int maplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(*node));;
+
+ ret = virDomainGetInfo(dom, &info);
+ if (ret == -1) {
+ CU_DEBUG("Failed to get info for domain `%s'",
+ virDomainGetName(dom));
+ goto out;
+ }
+
+ if (dev->dev.vcpu.number >= info.nrVirtCpu) {
+ CU_DEBUG("VCPU %i higher than max of %i for %s",
+ dev->dev.vcpu.number,
+ info.nrVirtCpu,
+ virDomainGetName(dom));
+ goto out;
+ }
+
+ vinfo = calloc(info.nrVirtCpu, sizeof(*vinfo));
+ if (vinfo == NULL) {
+ CU_DEBUG("Failed to allocate memory for %i virVcpuInfo",
+ info.nrVirtCpu);
+ goto out;
+ }
+
+ cpumaps = calloc(info.nrVirtCpu, maplen);
+ if (cpumaps == NULL) {
+ CU_DEBUG("Failed to allocate memory for %ix%i maps",
+ info.nrVirtCpu, maplen);
+ goto out;
+ }
+
+ ret = virDomainGetVcpus(dom, vinfo, info.nrVirtCpu, cpumaps, maplen);
+ if (ret < info.nrVirtCpu) {
+ CU_DEBUG("Failed to get VCPU info for %s",
+ virDomainGetName(dom));
+ goto out;
+ }
+
+ for (i = 0; i < VIR_NODEINFO_MAXCPUS(*node); i++) {
+ if (VIR_CPU_USABLE(cpumaps, maplen, vcpu, i)) {
+ CU_DEBUG("VCPU %i pinned to physical %i",
+ vcpu, i);
+ proc_get_physical_ref(broker, i, list);
+ } else {
+ CU_DEBUG("VCPU %i not pinned to physical %i",
+ vcpu, i);
+ }
+ }
+ out:
+ free(vinfo);
+ free(cpumaps);
+
+ return 0;
+}
+
+static CMPIStatus proc_rasd_from_vdev(const CMPIBroker *broker,
+ struct virt_device *dev,
+ const char *host,
+ const CMPIObjectPath *ref,
+ CMPIInstance *inst)
+{
+ virConnectPtr conn = NULL;
+ virDomainPtr dom = NULL;
+ virNodeInfo node;
+ CMPIStatus s;
+ CMPIArray *array;
+ struct inst_list list;
+
+ inst_list_init(&list);
+
+ conn = connect_by_classname(broker, CLASSNAME(ref), &s);
+ if (conn == NULL) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to connect for ProcRASD (%s)",
+ CLASSNAME(ref));
+ goto out;
+ }
+
+ dom = virDomainLookupByName(conn, host);
+ if (dom == NULL) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "Unable to get domain for ProcRASD: %s", host);
+ goto out;
+ }
+
+ if (virNodeGetInfo(virDomainGetConnect(dom), &node) == -1) {
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get node info");
+ goto out;
+ }
+
+ proc_set_cpu(broker, &node, dom, dev, &list);
+
+ if (list.cur > 0) {
+ int i;
+
+ array = CMNewArray(broker,
+ list.cur,
+ CMPI_instance,
+ &s);
+ for (i = 0; i < list.cur; i++) {
+ CMSetArrayElementAt(array,
+ i,
+ (CMPIValue *)&list.list[i],
+ CMPI_instance);
+ }
+
+ CMSetProperty(inst, "HostResource",
+ (CMPIValue *)&array, CMPI_instanceA);
+ }
+
+ out:
+ inst_list_free(&list);
+ virDomainFree(dom);
+ virConnectClose(conn);
+
+ return s;
}
static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker,
@@ -159,6 +349,8 @@ static CMPIInstance *rasd_from_vdev(cons
(CMPIValue *)&dev->dev.mem.size, CMPI_uint64);
CMSetProperty(inst, "Limit",
(CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64);
+ } else if (dev->type == VIRT_DEV_VCPU) {
+ proc_rasd_from_vdev(broker, dev, host, ref, inst);
}
/* FIXME: Put the HostResource in place */
16 years, 8 months
[PATCH] [CU] #2 Add more meaningful return messages to EO parsing functions
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1202315232 28800
# Node ID 2760beb95b59fde75f3323f2cc699f9a8f52964e
# Parent 1e5195053c3280f2185b98da10c595835eee6233
[CU] #2 Add more meaningful return messages to EO parsing functions.
Updates from patch 1 to patch 2:
-Return CMPI_RC_ERR_INVALID_PARAMETER instead of CMPI_RC_ERR_FAILED in the case of an invalid param.
Add error messages so that something more descriptive than the generic error message is used.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 1e5195053c32 -r 2760beb95b59 std_invokemethod.c
--- a/std_invokemethod.c Tue Jan 29 11:43:44 2008 -0800
+++ b/std_invokemethod.c Wed Feb 06 08:27:12 2008 -0800
@@ -55,8 +55,9 @@ static int parse_eo_inst_arg(CMPIString
str = CMGetCharPtr(string_in);
if (str == NULL) {
- CMSetStatus(s, CMPI_RC_ERR_INVALID_PARAMETER);
- CU_DEBUG("Method parameter value is NULL");
+ cu_statusf(broker, s,
+ CMPI_RC_ERR_INVALID_PARAMETER,
+ "Method parameter value is NULL");
return 0;
}
@@ -67,8 +68,9 @@ static int parse_eo_inst_arg(CMPIString
/* cu_parse_embedded_instance() returns 0 on success */
if ((ret != 0) || CMIsNullObject(instance_out)) {
- CMSetStatus(s, CMPI_RC_ERR_FAILED);
- CU_DEBUG("Unable to parse embedded object");
+ cu_statusf(broker, s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to parse embedded object");
return 0;
}
@@ -86,8 +88,9 @@ static int parse_eo_array(CMPIArray *str
int count;
if (CMIsNullObject(strings_in)) {
- CMSetStatus(s, CMPI_RC_ERR_INVALID_PARAMETER);
- CU_DEBUG("Method parameter is NULL");
+ cu_statusf(broker, s,
+ CMPI_RC_ERR_INVALID_PARAMETER,
+ "Method parameter is NULL");
return 0;
}
@@ -146,10 +149,11 @@ static int parse_eo_param(CMPIArgs *args
broker,
ns,
s);
- } else {
- CMSetStatus(s, CMPI_RC_ERR_FAILED);
- CU_DEBUG("Unable to parse argument type %d", type);
- }
+ } else
+ cu_statusf(broker, s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to parse argument type %d",
+ type);
if (ret != 1)
return 0;
16 years, 8 months
[PATCH] [CU] Add more meaningful return messages to EO parsing functions
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1202251455 28800
# Node ID 7cdea1fba87f7aea14d9b4d4543eb3b70d61fe36
# Parent 1e5195053c3280f2185b98da10c595835eee6233
[CU] Add more meaningful return messages to EO parsing functions.
Add error messages so that something more descriptive than the generic error message is used.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 1e5195053c32 -r 7cdea1fba87f std_invokemethod.c
--- a/std_invokemethod.c Tue Jan 29 11:43:44 2008 -0800
+++ b/std_invokemethod.c Tue Feb 05 14:44:15 2008 -0800
@@ -55,8 +55,9 @@ static int parse_eo_inst_arg(CMPIString
str = CMGetCharPtr(string_in);
if (str == NULL) {
- CMSetStatus(s, CMPI_RC_ERR_INVALID_PARAMETER);
- CU_DEBUG("Method parameter value is NULL");
+ cu_statusf(broker, s,
+ CMPI_RC_ERR_FAILED,
+ "Method parameter value is NULL");
return 0;
}
@@ -67,8 +68,9 @@ static int parse_eo_inst_arg(CMPIString
/* cu_parse_embedded_instance() returns 0 on success */
if ((ret != 0) || CMIsNullObject(instance_out)) {
- CMSetStatus(s, CMPI_RC_ERR_FAILED);
- CU_DEBUG("Unable to parse embedded object");
+ cu_statusf(broker, s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to parse embedded object");
return 0;
}
@@ -86,8 +88,9 @@ static int parse_eo_array(CMPIArray *str
int count;
if (CMIsNullObject(strings_in)) {
- CMSetStatus(s, CMPI_RC_ERR_INVALID_PARAMETER);
- CU_DEBUG("Method parameter is NULL");
+ cu_statusf(broker, s,
+ CMPI_RC_ERR_FAILED,
+ "Method parameter is NULL");
return 0;
}
@@ -146,10 +149,11 @@ static int parse_eo_param(CMPIArgs *args
broker,
ns,
s);
- } else {
- CMSetStatus(s, CMPI_RC_ERR_FAILED);
- CU_DEBUG("Unable to parse argument type %d", type);
- }
+ } else
+ cu_statusf(broker, s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to parse argument type %d",
+ type);
if (ret != 1)
return 0;
16 years, 8 months
[PATCH 0 of 2] (#2) MigrationIndications
by Jay Gagnon
Fixes from last set, with the exception of the hardcoded "Xen" issue. That will be fixed as part of the larger effort eliminate all hardcoded prefixes.
Fixes are detailed per patch.
16 years, 8 months