[PATCH 0 of 6] Take two of huge SettingsDefineCapabilities set

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

# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1194970453 18000 # Node ID 00626d8731495a89a93055be42ac52951f6fbcc7 # Parent 146a93bf2b929232c41bf7ed157c0343481d01a3 Turns out that the sdc_rasd_prop functions might need to report status or see the passed in reference. This updates the typedef and the memory functions, since those are already in the tree. Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r 146a93bf2b92 -r 00626d873149 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Mon Nov 12 17:53:00 2007 -0800 +++ b/src/Virt_ElementCapabilities.c Tue Nov 13 11:14:13 2007 -0500 @@ -94,14 +94,16 @@ static CMPIStatus cap_to_sys(const CMPIO inst_id = cu_get_str_path(ref, "InstanceID"); if (inst_id == NULL) { - CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Could not get InstanceID."); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Could not get InstanceID."); goto out; } if (!parse_fq_devid(inst_id, &host, &device)) { - CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Could not get system name."); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Could not get system name."); goto out; } @@ -152,14 +154,16 @@ static CMPIStatus cap_to_cs(const CMPIOb inst_id = cu_get_str_path(ref, "InstanceID"); if (inst_id == NULL) { - CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Could not get InstanceID."); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Could not get InstanceID."); goto error1; } if (!parse_fq_devid(inst_id, &host, &device)) { - CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Could not get system name."); + cu_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Could not get system name."); goto error1; } diff -r 146a93bf2b92 -r 00626d873149 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Nov 12 17:53:00 2007 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Nov 13 11:14:13 2007 -0500 @@ -96,84 +96,100 @@ static bool free_rasd_prop_list(struct s return true; } -static struct sdc_rasd_prop *mem_max(void) -{ - bool ret; - struct sdc_rasd_prop *rasd; +static struct sdc_rasd_prop *mem_max(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + struct sdc_rasd_prop *rasd = NULL; uint64_t max_vq = MAX_MEM; - struct sdc_rasd_prop max[] = { + struct sdc_rasd_prop tmp[] = { {"InstanceID", (CMPIValue *)"Maximum", CMPI_chars}, {"AllocationUnits", (CMPIValue *)"MegaBytes", CMPI_chars}, {"VirtualQuantity", (CMPIValue *)&max_vq, CMPI_uint64}, PROP_END }; - ret = dup_rasd_prop_list(max, &rasd); - if (ret) - return rasd; - else - return NULL; -} - -static struct sdc_rasd_prop *mem_min(void) -{ - bool ret; - struct sdc_rasd_prop *rasd; + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static struct sdc_rasd_prop *mem_min(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + struct sdc_rasd_prop *rasd = NULL; uint64_t min_vq = 64; - struct sdc_rasd_prop min[] = { + struct sdc_rasd_prop tmp[] = { {"InstanceID", (CMPIValue *)"Minimum", CMPI_chars}, {"AllocationUnits", (CMPIValue *)"MegaBytes", CMPI_chars}, {"VirtualQuantity", (CMPIValue *)&min_vq, CMPI_uint64}, PROP_END }; - ret = dup_rasd_prop_list(min, &rasd); - if (ret) - return rasd; - else - return NULL; -} - -static struct sdc_rasd_prop *mem_def(void) -{ - bool ret; - struct sdc_rasd_prop *rasd; + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static struct sdc_rasd_prop *mem_def(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + struct sdc_rasd_prop *rasd = NULL; uint64_t def_vq = 256; - struct sdc_rasd_prop def[] = { + struct sdc_rasd_prop tmp[] = { {"InstanceID", (CMPIValue *)"Default", CMPI_chars}, {"AllocationUnits", (CMPIValue *)"MegaBytes", CMPI_chars}, {"VirtualQuantity", (CMPIValue *)&def_vq, CMPI_uint64}, PROP_END }; - ret = dup_rasd_prop_list(def, &rasd); - if (ret) - return rasd; - else - return NULL; -} - -static struct sdc_rasd_prop *mem_inc(void) -{ - bool ret; - struct sdc_rasd_prop *rasd; + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static struct sdc_rasd_prop *mem_inc(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + struct sdc_rasd_prop *rasd = NULL; uint64_t inc_vq = 1; - struct sdc_rasd_prop inc[] = { + struct sdc_rasd_prop tmp[] = { {"InstanceID", (CMPIValue *)"Increment", CMPI_chars}, {"AllocationUnits", (CMPIValue *)"MegaBytes", CMPI_chars}, {"VirtualQuantity", (CMPIValue *)&inc_vq, CMPI_uint64}, PROP_END }; - ret = dup_rasd_prop_list(inc, &rasd); - if (ret) - return rasd; - else - return NULL; + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; } static struct sdc_rasd mem = { @@ -190,17 +206,17 @@ static struct sdc_rasd *sdc_rasd_list[] }; static CMPIInstance *sdc_rasd_inst(const CMPIBroker *broker, + CMPIStatus *s, const CMPIObjectPath *ref, struct sdc_rasd *rasd, sdc_rasd_type type) { - CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; struct sdc_rasd_prop *prop_list; int i; char *inst_id; uint16_t resource_type; - /* Defaults for the following three values are from + /* Defaults for the following are from CIM_SettingsDefineCapabilities.mof. */ uint16_t policy = SDC_POLICY_INDEPENDENT; uint16_t role = SDC_ROLE_SUPPORTED; @@ -209,43 +225,40 @@ static CMPIInstance *sdc_rasd_inst(const case SDC_RASD_MIN: if (rasd->min == NULL) goto out; - prop_list = rasd->min(); + prop_list = rasd->min(ref, s); inst_id = "Minimum"; range = SDC_RANGE_MIN; break; case SDC_RASD_MAX: if (rasd->max == NULL) goto out; - prop_list = rasd->max(); + prop_list = rasd->max(ref, s); inst_id = "Maximum"; range = SDC_RANGE_MAX; break; case SDC_RASD_INC: if (rasd->inc == NULL) goto out; - prop_list = rasd->inc(); + prop_list = rasd->inc(ref, s); inst_id = "Increment"; range = SDC_RANGE_INC; break; case SDC_RASD_DEF: if (rasd->def == NULL) goto out; - prop_list = rasd->def(); + prop_list = rasd->def(ref, s); inst_id = "Default"; role = SDC_ROLE_DEFAULT; range = SDC_RANGE_POINT; break; default: - CMSetStatusWithChars(broker, &s, CMPI_RC_ERR_FAILED, + CMSetStatusWithChars(broker, s, CMPI_RC_ERR_FAILED, "Unsupported sdc_rasd type."); goto out; } - if (prop_list == NULL) { - CMSetStatusWithChars(broker, &s, CMPI_RC_ERR_FAILED, - "Failed to get prop_list."); + if (s->rc != CMPI_RC_OK) goto out; - } inst = get_typed_instance(broker, "ResourceAllocationSettingData", @@ -291,7 +304,11 @@ static CMPIStatus sdc_rasds_for_type(con if (rasd) { for (i = SDC_RASD_MIN; i <= SDC_RASD_INC; i++) { - inst = sdc_rasd_inst(_BROKER, ref, rasd, i); + inst = sdc_rasd_inst(_BROKER, &s, ref, rasd, i); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Problem getting inst."); + goto out; + } CU_DEBUG("Got inst.\n"); if (inst != NULL) { inst_list_add(list, inst); @@ -307,6 +324,7 @@ static CMPIStatus sdc_rasds_for_type(con "Unsupported device type."); } + out: return s; } diff -r 146a93bf2b92 -r 00626d873149 src/Virt_SettingsDefineCapabilities.h --- a/src/Virt_SettingsDefineCapabilities.h Mon Nov 12 17:53:00 2007 -0800 +++ b/src/Virt_SettingsDefineCapabilities.h Tue Nov 13 11:14:13 2007 -0500 @@ -50,7 +50,8 @@ struct sdc_rasd_prop { CMPIType type; }; -typedef struct sdc_rasd_prop *(*rasd_prop_func_t)(void); +typedef struct sdc_rasd_prop *(*rasd_prop_func_t)(const CMPIObjectPath *ref, + CMPIStatus *s); struct sdc_rasd { uint16_t resource_type;

JG> # HG changeset patch JG> # User Jay Gagnon <grendel@linux.vnet.ibm.com> JG> # Date 1194970453 18000 JG> # Node ID 00626d8731495a89a93055be42ac52951f6fbcc7 JG> # Parent 146a93bf2b929232c41bf7ed157c0343481d01a3 JG> Turns out that the sdc_rasd_prop functions might need to report status or see the passed in reference. This updates the typedef and the memory functions, since those are already in the tree. Thanks, applied. I do think that the minimum and default memory values need to be #defines but they were already in the tree and I didn't catch them the first time. I think we should plan to pull those out at some point though. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1194970453 18000 # Node ID bd43a8aca68d8b40186bd3ba51fd966fc02d9560 # Parent 00626d8731495a89a93055be42ac52951f6fbcc7 Need to reorder the .la lines in makefile since SettingsDefineCapabilities now depends on DevicePool. Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r 00626d873149 -r bd43a8aca68d src/Makefile.am --- a/src/Makefile.am Tue Nov 13 11:14:13 2007 -0500 +++ b/src/Makefile.am Tue Nov 13 11:14:13 2007 -0500 @@ -35,12 +35,12 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_VirtualSystemManagementCapabilities.la \ libVirt_EnabledLogicalElementCapabilities.la \ libVirt_AllocationCapabilities.la \ - libVirt_SettingsDefineCapabilities.la \ libVirt_VSSD.la \ libVirt_HostedDependency.la \ libVirt_RegisteredProfile.la \ libVirt_ElementConformsToProfile.la \ libVirt_DevicePool.la \ + libVirt_SettingsDefineCapabilities.la \ libVirt_HostedResourcePool.la \ libVirt_ElementCapabilities.la \ libVirt_ResourcePoolConfigurationService.la \

JG> # HG changeset patch JG> # User Jay Gagnon <grendel@linux.vnet.ibm.com> JG> # Date 1194970453 18000 JG> # Node ID bd43a8aca68d8b40186bd3ba51fd966fc02d9560 JG> # Parent 00626d8731495a89a93055be42ac52951f6fbcc7 JG> Need to reorder the .la lines in makefile since SettingsDefineCapabilities now depends on DevicePool. Applied. I meant to go ahead and commit this one last time :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1194970453 18000 # Node ID fa1ace488da3c6b98e8b77290860e7ab15e2e8f5 # Parent bd43a8aca68d8b40186bd3ba51fd966fc02d9560 Add Disk support to SettingsDefineCapabilities. Still lacks a bit of polish (i.e. lack of warning when minimum or default is higher than maximum), but is functional. Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r bd43a8aca68d -r fa1ace488da3 src/Makefile.am --- a/src/Makefile.am Tue Nov 13 11:14:13 2007 -0500 +++ b/src/Makefile.am Tue Nov 13 11:14:13 2007 -0500 @@ -88,7 +88,7 @@ libVirt_AllocationCapabilities_la_LIBADD libVirt_AllocationCapabilities_la_LIBADD = -lVirt_RASD libVirt_SettingsDefineCapabilities_la_SOURCES = Virt_SettingsDefineCapabilities.c -libVirt_SettingsDefineCapabilities_la_LIBADD = -lVirt_RASD +libVirt_SettingsDefineCapabilities_la_LIBADD = -lVirt_RASD -lVirt_DevicePool libVirt_RegisteredProfile_la_SOURCES = Virt_RegisteredProfile.c diff -r bd43a8aca68d -r fa1ace488da3 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Tue Nov 13 11:14:13 2007 -0500 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Nov 13 11:14:13 2007 -0500 @@ -23,6 +23,8 @@ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> +#include <sys/vfs.h> +#include <errno.h> #include "config.h" @@ -37,8 +39,14 @@ #include "svpc_types.h" #include "Virt_SettingsDefineCapabilities.h" +#include "Virt_DevicePool.h" const static CMPIBroker *_BROKER; + +/* These are used in more than one place so they are defined here. */ +#define SDC_DISK_MIN 2000 +#define SDC_DISK_DEF 5000 +#define SDC_DISK_INC 250 static bool rasd_prop_copy_value(struct sdc_rasd_prop src, struct sdc_rasd_prop *dest) @@ -192,6 +200,145 @@ static struct sdc_rasd_prop *mem_inc(con return rasd; } +static struct sdc_rasd_prop *disk_min(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + uint16_t disk_size = SDC_DISK_MIN; + struct sdc_rasd_prop *rasd = NULL; + + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Minimum", CMPI_chars}, + {"AllocationQuantity", (CMPIValue *)"MegaBytes", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&disk_size, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static struct sdc_rasd_prop *disk_max(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + char *inst_id; + CMPIrc prop_ret; + uint16_t free_space; + uint64_t free_64; + virConnectPtr conn; + CMPIInstance *pool_inst; + struct sdc_rasd_prop *rasd = NULL; + + inst_id = cu_get_str_path(ref, "InstanceID"); + if (inst_id == NULL) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not get InstanceID."); + goto out; + } + + conn = lv_connect(_BROKER, s); + if (s->rc != CMPI_RC_OK) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not get connection."); + goto out; + } + + /* Getting the relevant resource pool directly finds the free space + for us. It is in the Capacity field. */ + pool_inst = get_pool_by_id(_BROKER, conn, inst_id, NAMESPACE(ref)); + if (pool_inst == NULL) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not get pool instance."); + goto out; + } + + prop_ret = cu_get_u64_prop(pool_inst, "Capacity", &free_64); + if (prop_ret != CMPI_RC_OK) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not get capacity from instance."); + goto out; + } + CU_DEBUG("Got capacity from pool_inst: %lld", free_64); + + free_space = (uint16_t)free_64; + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Maximum", CMPI_chars}, + {"AllocationQuantity", (CMPIValue *)"MegaBytes", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&free_space, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + out: + free(inst_id); + return rasd; +} + +static struct sdc_rasd_prop *disk_def(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + uint16_t disk_size = SDC_DISK_DEF; + struct sdc_rasd_prop *rasd = NULL; + + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Default", CMPI_chars}, + {"AllocationQuantity", (CMPIValue *)"MegaBytes", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&disk_size, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static struct sdc_rasd_prop *disk_inc(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + uint16_t disk_size = SDC_DISK_INC; + struct sdc_rasd_prop *rasd = NULL; + + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Increment", CMPI_chars}, + {"AllocationQuantity", (CMPIValue *)"MegaBytes", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&disk_size, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + static struct sdc_rasd mem = { .resource_type = CIM_RASD_TYPE_MEM, .min = mem_min, @@ -200,8 +347,17 @@ static struct sdc_rasd mem = { .inc = mem_inc }; +static struct sdc_rasd disk = { + .resource_type = CIM_RASD_TYPE_DISK, + .min = disk_min, + .max = disk_max, + .def = disk_def, + .inc = disk_inc +}; + static struct sdc_rasd *sdc_rasd_list[] = { &mem, + &disk, NULL };

JG> # HG changeset patch JG> # User Jay Gagnon <grendel@linux.vnet.ibm.com> JG> # Date 1194970453 18000 JG> # Node ID fa1ace488da3c6b98e8b77290860e7ab15e2e8f5 JG> # Parent bd43a8aca68d8b40186bd3ba51fd966fc02d9560 JG> Add Disk support to SettingsDefineCapabilities. Still lacks a bit of polish (i.e. lack of warning when minimum or default is higher than maximum), but is functional. Applied. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1194970453 18000 # Node ID 5d8e959f6b81f08015e32866a9d2de2506c51762 # Parent fa1ace488da3c6b98e8b77290860e7ab15e2e8f5 Add NetworkPort functionality to SettingsDefineCapabilities. All static, max may become dynamic. Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r fa1ace488da3 -r 5d8e959f6b81 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Tue Nov 13 11:14:13 2007 -0500 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Nov 13 11:14:13 2007 -0500 @@ -200,6 +200,114 @@ static struct sdc_rasd_prop *mem_inc(con return rasd; } +static struct sdc_rasd_prop *net_min(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + uint16_t num_nics = 0; + struct sdc_rasd_prop *rasd = NULL; + + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Minimum", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&num_nics, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static int net_max_xen(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + /* No dynamic lookup for now. */ + return 6; +} + +static struct sdc_rasd_prop *net_max(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + uint16_t num_nics; + struct sdc_rasd_prop *rasd = NULL; + + /* TODO: relevant functions for KVM etc. and dispatch code. */ + num_nics = net_max_xen(ref, s); + if (s->rc != CMPI_RC_OK) { + goto out; + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not get max nic count"); + } + + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Maximum", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&num_nics, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + out: + return rasd; +} + +static struct sdc_rasd_prop *net_def(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + uint16_t num_nics = 1; + struct sdc_rasd_prop *rasd = NULL; + + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Default", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&num_nics, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static struct sdc_rasd_prop *net_inc(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + uint16_t num_nics = 1; + struct sdc_rasd_prop *rasd = NULL; + + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Increment", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&num_nics, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + static struct sdc_rasd_prop *disk_min(const CMPIObjectPath *ref, CMPIStatus *s) { @@ -347,6 +455,14 @@ static struct sdc_rasd mem = { .inc = mem_inc }; +static struct sdc_rasd network = { + .resource_type = CIM_RASD_TYPE_NET, + .min = net_min, + .max = net_max, + .def = net_def, + .inc = net_inc +}; + static struct sdc_rasd disk = { .resource_type = CIM_RASD_TYPE_DISK, .min = disk_min, @@ -357,6 +473,7 @@ static struct sdc_rasd disk = { static struct sdc_rasd *sdc_rasd_list[] = { &mem, + &network, &disk, NULL };

JG> # HG changeset patch JG> # User Jay Gagnon <grendel@linux.vnet.ibm.com> JG> # Date 1194970453 18000 JG> # Node ID 5d8e959f6b81f08015e32866a9d2de2506c51762 JG> # Parent fa1ace488da3c6b98e8b77290860e7ab15e2e8f5 JG> Add NetworkPort functionality to SettingsDefineCapabilities. All static, max may become dynamic. Applied. Per our discussion on #virt, we'll augment this with a version that exposes the correct max value for each of xen-3.0.x, xen-3.1.x, and qemu. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1194970453 18000 # Node ID 1cee1dbf1fc9c270ca007f5ebc36138713ffd97f # Parent 5d8e959f6b81f08015e32866a9d2de2506c51762 Add processor support to SettingsDefineCapabilities. Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r 5d8e959f6b81 -r 1cee1dbf1fc9 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Tue Nov 13 11:14:13 2007 -0500 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Nov 13 11:14:13 2007 -0500 @@ -26,6 +26,8 @@ #include <sys/vfs.h> #include <errno.h> +#include <libvirt.h> + #include "config.h" #include "cmpidt.h" @@ -200,6 +202,117 @@ static struct sdc_rasd_prop *mem_inc(con return rasd; } +static struct sdc_rasd_prop *proc_min(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + uint16_t num_procs = 1; + struct sdc_rasd_prop *rasd = NULL; + + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Minimum", CMPI_chars}, + {"AllocationUnits", (CMPIValue *)"Processors", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&num_procs, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static struct sdc_rasd_prop *proc_max(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + virConnectPtr conn; + uint16_t num_procs = 0; + struct sdc_rasd_prop *rasd = NULL; + + CU_DEBUG("In proc_max()"); + + conn = lv_connect(_BROKER, s); + if (conn == NULL) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not connect to hypervisor."); + goto out; + } + + num_procs = virConnectGetMaxVcpus(conn, NULL); + CU_DEBUG("libvirt says %d max vcpus", num_procs); + + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Maximum", CMPI_chars}, + {"AllocationUnits", (CMPIValue *)"Processors", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&num_procs, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + out: + return rasd; +} + +static struct sdc_rasd_prop *proc_def(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + uint16_t num_procs = 1; + struct sdc_rasd_prop *rasd = NULL; + + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Default", CMPI_chars}, + {"AllocationUnits", (CMPIValue *)"Processors", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&num_procs, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + +static struct sdc_rasd_prop *proc_inc(const CMPIObjectPath *ref, + CMPIStatus *s) +{ + bool ret; + uint16_t num_procs = 1; + struct sdc_rasd_prop *rasd = NULL; + + struct sdc_rasd_prop tmp[] = { + {"InstanceID", (CMPIValue *)"Increment", CMPI_chars}, + {"AllocationUnits", (CMPIValue *)"Processors", CMPI_chars}, + {"VirtualQuantity", (CMPIValue *)&num_procs, CMPI_uint16}, + PROP_END + }; + + ret = dup_rasd_prop_list(tmp, &rasd); + if (!ret) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Could not copy RASD."); + } + + return rasd; +} + static struct sdc_rasd_prop *net_min(const CMPIObjectPath *ref, CMPIStatus *s) { @@ -455,6 +568,14 @@ static struct sdc_rasd mem = { .inc = mem_inc }; +static struct sdc_rasd processor = { + .resource_type = CIM_RASD_TYPE_PROC, + .min = proc_min, + .max = proc_max, + .def = proc_def, + .inc = proc_inc +}; + static struct sdc_rasd network = { .resource_type = CIM_RASD_TYPE_NET, .min = net_min, @@ -473,6 +594,7 @@ static struct sdc_rasd disk = { static struct sdc_rasd *sdc_rasd_list[] = { &mem, + &processor, &network, &disk, NULL

JG> # HG changeset patch JG> # User Jay Gagnon <grendel@linux.vnet.ibm.com> JG> # Date 1194970453 18000 JG> # Node ID 1cee1dbf1fc9c270ca007f5ebc36138713ffd97f JG> # Parent 5d8e959f6b81f08015e32866a9d2de2506c51762 JG> Add processor support to SettingsDefineCapabilities. Applied. JG> + num_procs = virConnectGetMaxVcpus(conn, NULL); Ah, even better :) Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1194970454 18000 # Node ID 6a57bca4ac97fb503e1d32713a3b0155bd4ff322 # Parent 1cee1dbf1fc9c270ca007f5ebc36138713ffd97f Add another relationship to ElementCapabilities, the ResourcePool-AllocationCapabilities connection. Only supports the pool_to_alloc direction, because it is the only one that's terribly interesting, but the other direction will need to be added at some point. Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r 1cee1dbf1fc9 -r 6a57bca4ac97 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Tue Nov 13 11:14:13 2007 -0500 +++ b/src/Virt_ElementCapabilities.c Tue Nov 13 11:14:14 2007 -0500 @@ -183,6 +183,50 @@ static CMPIStatus cap_to_cs(const CMPIOb return s; } +static CMPIStatus alloc_to_pool(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + /* Pool to alloc is more important. That will be done first. */ + RETURN_UNSUPPORTED(); +} + +static CMPIStatus pool_to_alloc(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + int ret; + char *inst_id; + uint16_t type; + CMPIInstance *inst = NULL; + CMPIStatus s = {CMPI_RC_OK}; + + inst_id = cu_get_str_path(ref, "InstanceID"); + if (inst_id == NULL) { + CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, + "Could not get InstanceID."); + goto out; + } + + inst = get_typed_instance(_BROKER, "AllocationCapabilities", + NAMESPACE(ref)); + CMSetProperty(inst, "InstanceID", inst_id, CMPI_chars); + + ret = cu_get_u16_path(ref, "ResourceType", &type); + if (ret != 1) { + CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, + "Could not get ResourceType."); + goto out; + } + CMSetProperty(inst, "ResourceType", &type, CMPI_uint16); + + inst_list_add(list, inst); + + out: + free(inst_id); + + return s; +} static CMPIInstance *make_ref(const CMPIObjectPath *ref, const CMPIInstance *inst, struct std_assoc_info *info, @@ -277,6 +321,28 @@ struct std_assoc ele_cap_to_computer_sys .assoc_class = "CIM_ElementCapabilities", .handler = cap_to_cs, + .make_ref = make_ref +}; + +struct std_assoc alloc_cap_to_resource_pool = { + .source_class = "CIM_AllocationCapabilities", + .source_prop = "Capabilities", + + .target_class = "CIM_ResourcePool", + .target_prop = "ManagedElement", + + .handler = alloc_to_pool, + .make_ref = make_ref +}; + +struct std_assoc resource_pool_to_alloc_cap = { + .source_class = "CIM_ResourcePool", + .source_prop = "ManagedElement", + + .target_class = "CIM_AllocationCapabilities", + .target_prop = "Capabilities", + + .handler = pool_to_alloc, .make_ref = make_ref }; @@ -286,6 +352,8 @@ struct std_assoc *assoc_handlers[] = { &system_to_vsm_cap, &vsm_cap_to_system, &ele_cap_to_computer_system, + &alloc_cap_to_resource_pool, + &resource_pool_to_alloc_cap, NULL };

JG> # HG changeset patch JG> # User Jay Gagnon <grendel@linux.vnet.ibm.com> JG> # Date 1194970454 18000 JG> # Node ID 6a57bca4ac97fb503e1d32713a3b0155bd4ff322 JG> # Parent 1cee1dbf1fc9c270ca007f5ebc36138713ffd97f JG> Add another relationship to ElementCapabilities, the ResourcePool-AllocationCapabilities connection. Only supports the pool_to_alloc direction, because it is the only one that's terribly interesting, but the other direction will need to be added at some point. Applied. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (2)
-
Dan Smith
-
Jay Gagnon