[PATCH 0 of 3] Expose Path attribute in DiskPool instances

The first two patches are some minor tweaks and reshuffling of code in order to prevent name collisions and redundant code across providers.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1251155681 25200 # Node ID cb562e877b51e5a5811080f47c657ec64b9b7918 # Parent 5a1871168fd4d9b906646bc4b036a950bcc339df Rename disk_pool struct in Virt_DevicePool to tmp_disk_pool This is an internal struct - make this name more unique so it doesn't collide with the struct in pool_parsing.h Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 5a1871168fd4 -r cb562e877b51 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Mon Aug 24 14:45:22 2009 -0700 +++ b/src/Virt_DevicePool.c Mon Aug 24 16:14:41 2009 -0700 @@ -45,7 +45,7 @@ static const CMPIBroker *_BROKER; -struct disk_pool { +struct tmp_disk_pool { char *tag; char *path; bool primordial; @@ -61,10 +61,10 @@ # define VIR_USE_LIBVIRT_STORAGE 0 #endif -static bool get_disk_parent(struct disk_pool **_pools, +static bool get_disk_parent(struct tmp_disk_pool **_pools, int *_count) { - struct disk_pool *pools = NULL; + struct tmp_disk_pool *pools = NULL; int ret = false; int count; @@ -93,12 +93,12 @@ #if VIR_USE_LIBVIRT_STORAGE static int get_diskpool_config(virConnectPtr conn, - struct disk_pool **_pools) + struct tmp_disk_pool **_pools) { int count = 0; int i; char ** names = NULL; - struct disk_pool *pools = NULL; + struct tmp_disk_pool *pools = NULL; count = virConnectNumOfStoragePools(conn); if (count <= 0) @@ -139,7 +139,7 @@ static bool diskpool_set_capacity(virConnectPtr conn, CMPIInstance *inst, - struct disk_pool *_pool) + struct tmp_disk_pool *_pool) { bool result = false; virStoragePoolPtr pool; @@ -175,7 +175,7 @@ } static bool _diskpool_is_member(virConnectPtr conn, - const struct disk_pool *pool, + const struct tmp_disk_pool *pool, const char *file) { virStorageVolPtr vol = NULL; @@ -206,7 +206,7 @@ return result; } #else -static int parse_diskpool_line(struct disk_pool *pool, +static int parse_diskpool_line(struct tmp_disk_pool *pool, const char *line) { int ret; @@ -222,14 +222,14 @@ } static int get_diskpool_config(virConnectPtr conn, - struct disk_pool **_pools) + struct tmp_disk_pool **_pools) { const char *path = DISK_POOL_CONFIG; FILE *config; char *line = NULL; size_t len = 0; int count = 0; - struct disk_pool *pools = NULL; + struct tmp_disk_pool *pools = NULL; config = fopen(path, "r"); if (config == NULL) { @@ -261,7 +261,7 @@ static bool diskpool_set_capacity(virConnectPtr conn, CMPIInstance *inst, - struct disk_pool *pool) + struct tmp_disk_pool *pool) { bool result = false; struct statvfs vfs; @@ -298,7 +298,7 @@ } #endif -static void free_diskpool(struct disk_pool *pools, int count) +static void free_diskpool(struct tmp_disk_pool *pools, int count) { int i; @@ -316,7 +316,7 @@ static char *_diskpool_member_of(virConnectPtr conn, const char *file) { - struct disk_pool *pools = NULL; + struct tmp_disk_pool *pools = NULL; int count; int i; char *pool = NULL; @@ -910,7 +910,7 @@ return s; } -static CMPIInstance *diskpool_from_path(struct disk_pool *pool, +static CMPIInstance *diskpool_from_path(struct tmp_disk_pool *pool, virConnectPtr conn, const char *ns, const char *refcn, @@ -947,7 +947,7 @@ const CMPIBroker *broker) { CMPIStatus s = {CMPI_RC_OK, NULL}; - struct disk_pool *pools = NULL; + struct tmp_disk_pool *pools = NULL; int count = 0; int i;

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1251215156 25200 # Node ID 5253dd03a6588d6856aa30fdbb385c3325d0fed1 # Parent cb562e877b51e5a5811080f47c657ec64b9b7918 Move get_disk_pool() to Virt_DevicePool.h from SDC Also, fix the #ifndef in pool_parsing.h - otherwise, there are redeclaration conflicts during build. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r cb562e877b51 -r 5253dd03a658 libxkutil/pool_parsing.h --- a/libxkutil/pool_parsing.h Mon Aug 24 16:14:41 2009 -0700 +++ b/libxkutil/pool_parsing.h Tue Aug 25 08:45:56 2009 -0700 @@ -18,7 +18,7 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __RES_POOLS_H_ +#ifndef __RES_POOLS_H #define __RES_POOLS_H #include <stdint.h> diff -r cb562e877b51 -r 5253dd03a658 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Mon Aug 24 16:14:41 2009 -0700 +++ b/src/Virt_DevicePool.c Tue Aug 25 08:45:56 2009 -0700 @@ -92,6 +92,26 @@ #if VIR_USE_LIBVIRT_STORAGE +int get_disk_pool(virStoragePoolPtr poolptr, struct virt_pool **pool) +{ + char *xml; + int ret; + + xml = virStoragePoolGetXMLDesc(poolptr, 0); + if (xml == NULL) + return 0; + + *pool = malloc(sizeof(**pool)); + if (*pool == NULL) + return 0; + + ret = get_pool_from_xml(xml, *pool, CIM_RES_TYPE_DISK); + + free(xml); + + return ret; +} + static int get_diskpool_config(virConnectPtr conn, struct tmp_disk_pool **_pools) { diff -r cb562e877b51 -r 5253dd03a658 src/Virt_DevicePool.h --- a/src/Virt_DevicePool.h Mon Aug 24 16:14:41 2009 -0700 +++ b/src/Virt_DevicePool.h Tue Aug 25 08:45:56 2009 -0700 @@ -26,6 +26,8 @@ #include <libcmpiutil/libcmpiutil.h> #include <stdint.h> +#include "pool_parsing.h" + /** * Get the InstanceID of a pool that a given RASD id (for type) is in * @@ -133,6 +135,15 @@ uint16_t type, CMPIStatus *status); +/** + * Get the configuration settings of a given storage pool + * + * @param poolptr A pointer to the given storage pool + * @param pool A struct to hold the configuration settings of the storage pool + * @returns An int that indicates whether the function was successful + */ +int get_disk_pool(virStoragePoolPtr poolptr, struct virt_pool **pool); + #endif /* diff -r cb562e877b51 -r 5253dd03a658 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Aug 24 16:14:41 2009 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Aug 25 08:45:56 2009 -0700 @@ -1027,26 +1027,6 @@ } #if VIR_USE_LIBVIRT_STORAGE -static int get_disk_pool(virStoragePoolPtr poolptr, struct virt_pool **pool) -{ - char *xml; - int ret; - - xml = virStoragePoolGetXMLDesc(poolptr, 0); - if (xml == NULL) - return 0; - - *pool = malloc(sizeof(**pool)); - if (*pool == NULL) - return 0; - - ret = get_pool_from_xml(xml, *pool, CIM_RES_TYPE_DISK); - - free(xml); - - return ret; -} - static CMPIStatus new_volume_template(const CMPIObjectPath *ref, int template_type, virStoragePoolPtr poolptr,

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1251155681 25200 # Node ID 9af5eef7ea76c7e9d1657d2e8cd4df9ed126b596 # Parent 5253dd03a6588d6856aa30fdbb385c3325d0fed1 Expose Path attribute for DiskPools Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 5253dd03a658 -r 9af5eef7ea76 schema/DiskPool.mof --- a/schema/DiskPool.mof Tue Aug 25 08:45:56 2009 -0700 +++ b/schema/DiskPool.mof Mon Aug 24 16:14:41 2009 -0700 @@ -3,15 +3,24 @@ [Provider("cmpi::Virt_DevicePool")] class Xen_DiskPool : CIM_ResourcePool { + [Description("Path this storage pool represents")] + string Path; + }; [Provider("cmpi::Virt_DevicePool")] class KVM_DiskPool : CIM_ResourcePool { + [Description("Path this storage pool represents")] + string Path; + }; [Provider("cmpi::Virt_DevicePool")] class LXC_DiskPool : CIM_ResourcePool { + [Description("Path this storage pool represents")] + string Path; + }; diff -r 5253dd03a658 -r 9af5eef7ea76 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Tue Aug 25 08:45:56 2009 -0700 +++ b/src/Virt_DevicePool.c Mon Aug 24 16:14:41 2009 -0700 @@ -166,6 +166,8 @@ virStoragePoolInfo info; uint64_t cap; uint64_t res; + struct virt_pool *pool_vals = NULL; + const char *pool_str = NULL; pool = virStoragePoolLookupByName(conn, _pool->tag); if (pool == NULL) { @@ -187,9 +189,21 @@ CMSetProperty(inst, "Reserved", (CMPIValue *)&res, CMPI_uint64); + if (get_disk_pool(pool, &pool_vals) != 0) { + CU_DEBUG("Error getting pool path for: %s", _pool->tag); + } else { + if (pool_vals->pool_info.disk.path != NULL) { + pool_str = strdup(pool_vals->pool_info.disk.path); + + CMSetProperty(inst, "Path", + (CMPIValue *)pool_str, CMPI_chars); + } + } + result = true; out: virStoragePoolFree(pool); + cleanup_virt_pool(&pool_vals); return result; } @@ -305,6 +319,9 @@ CMSetProperty(inst, "Reserved", (CMPIValue *)&res, CMPI_uint64); + CMSetProperty(inst, "Path", + (CMPIValue *)pool->path, CMPI_chars); + result = true; out: return result;

+1 On 08/25/2009 12:47 PM, Kaitlin Rupert wrote:
The first two patches are some minor tweaks and reshuffling of code in order to prevent name collisions and redundant code across providers.
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Richard Maciel, MSc IBM Linux Technology Center rmaciel@linux.vnet.ibm.com
participants (2)
-
Kaitlin Rupert
-
Richard Maciel