[PATCH 0 of 3] Initial image creation support

Right now, the CreateResourceInPool() doesn't do anything other than check the parameters that are parsed in. Subsequent patches will add additional functionality.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1245187550 25200 # Node ID 274a3daaed7a8f64d7e070ef77a59bd42951922b # Parent 7f946266983b4b0a7e0aa86d5a1b21b794b46a76 Method definition to RPCS mof for image creation Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 7f946266983b -r 274a3daaed7a schema/ResourcePoolConfigurationService.mof --- a/schema/ResourcePoolConfigurationService.mof Tue Jun 16 14:25:50 2009 -0700 +++ b/schema/ResourcePoolConfigurationService.mof Tue Jun 16 14:25:50 2009 -0700 @@ -3,14 +3,71 @@ [Provider("cmpi::Virt_ResourcePoolConfigurationService")] class Xen_ResourcePoolConfigurationService : CIM_ResourcePoolConfigurationService { + + [Description ( "Create a resource within a specified pool using the " + "specified allocation settings. If 0 is returned, the " + "function completed successfully." )] + uint32 CreateResourceInPool( + [IN, Description ( "String containing a representation of a " + "CIM_SettingData instance that is used to specify " + "the settings for the resource." ), + EmbeddedInstance ( "CIM_ResourceAllocationSettingData" )] + string Settings, + + [IN, Description ( "Reference to the pool to create the resources in." )] + CIM_ResourcePool REF Pool, + + [IN ( false ), OUT, Description ( "Reference to the job (may be null " + "if job completed)." )] + CIM_ResourceAllocationSettingData REF Resource + ); + }; [Provider("cmpi::Virt_ResourcePoolConfigurationService")] class KVM_ResourcePoolConfigurationService : CIM_ResourcePoolConfigurationService { + + [Description ( "Create a resource within a specified pool using the " + "specified allocation settings. If 0 is returned, the " + "function completed successfully." )] + uint32 CreateResourceInPool( + [IN, Description ( "String containing a representation of a " + "CIM_SettingData instance that is used to specify " + "the settings for the resource." ), + EmbeddedInstance ( "CIM_ResourceAllocationSettingData" )] + string Settings, + + [IN, Description ( "Reference to the pool to create the resources in." )] + CIM_ResourcePool REF Pool, + + [IN ( false ), OUT, Description ( "Reference to the job (may be null " + "if job completed)." )] + CIM_ResourceAllocationSettingData REF Resource + ); + }; [Provider("cmpi::Virt_ResourcePoolConfigurationService")] class LXC_ResourcePoolConfigurationService : CIM_ResourcePoolConfigurationService { + + [Description ( "Create a resource within a specified pool using the " + "specified allocation settings. If 0 is returned, the " + "function completed successfully." )] + uint32 CreateResourceInPool( + [IN, Description ( "String containing a representation of a " + "CIM_SettingData instance that is used to specify " + "the settings for the resource." ), + EmbeddedInstance ( "CIM_ResourceAllocationSettingData" )] + string Settings, + + [IN, Description ( "Reference to the pool to create the resources in." )] + CIM_ResourcePool REF Pool, + + [IN ( false ), OUT, Description ( "Reference to the job (may be null " + "if job completed)." )] + CIM_ResourceAllocationSettingData REF Resource + ); + };

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1249595936 25200 # Node ID fc589363fb55e780942d8431f9c3559d766dcb69 # Parent 274a3daaed7a8f64d7e070ef77a59bd42951922b Add initial support for CreateResourceInPool() method This is just the stub. Additional support to follow. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 274a3daaed7a -r fc589363fb55 src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Tue Jun 16 14:25:50 2009 -0700 +++ b/src/Virt_ResourcePoolConfigurationService.c Thu Aug 06 14:58:56 2009 -0700 @@ -664,6 +664,25 @@ return s; } +static CMPIStatus create_resource_in_pool(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + uint32_t rc = CIM_SVPC_RETURN_FAILED; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + CU_DEBUG("CreateResourceInPool"); + + if (s.rc == CMPI_RC_OK) + rc = CIM_SVPC_RETURN_COMPLETED; + CMReturnData(results, &rc, CMPI_uint32); + + return s; +} + static CMPIStatus dummy_handler(CMPIMethodMI *self, const CMPIContext *context, const CMPIResult *results, @@ -710,12 +729,22 @@ } }; +static struct method_handler CreateResourceInPool = { + .name = "CreateResourceInPool", + .handler = create_resource_in_pool, + .args = {{"Settings", CMPI_instance, true}, + {"Pool", CMPI_ref, true}, + ARG_END + } +}; + static struct method_handler *my_handlers[] = { &CreateResourcePool, &CreateChildResourcePool, &AddResourcesToResourcePool, &RemoveResourcesFromResourcePool, &DeleteResourcePool, + &CreateResourceInPool, NULL, };

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1249595963 25200 # Node ID af509ca0e7f25db4e7ce96dff8bc77df6289e9b3 # Parent fc589363fb55e780942d8431f9c3559d766dcb69 Parse parameters passed in to CreateResourceInPool Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r fc589363fb55 -r af509ca0e7f2 src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Thu Aug 06 14:58:56 2009 -0700 +++ b/src/Virt_ResourcePoolConfigurationService.c Thu Aug 06 14:59:23 2009 -0700 @@ -664,6 +664,32 @@ return s; } +static CMPIStatus create_resource_parse_args(const CMPIArgs *argsin, + CMPIInstance **settings, + CMPIObjectPath **pool) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + if (cu_get_inst_arg(argsin, "Settings", settings) != CMPI_RC_OK) { + CU_DEBUG("Failed to get Settings arg"); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing argument `Settings'"); + goto out; + } + + if (cu_get_ref_arg(argsin, "Pool", pool) != CMPI_RC_OK) { + CU_DEBUG("Failed to get Pool reference arg"); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing argument `Pool'"); + goto out; + } + + out: + return s; +} + static CMPIStatus create_resource_in_pool(CMPIMethodMI *self, const CMPIContext *context, const CMPIResult *results, @@ -673,13 +699,21 @@ { uint32_t rc = CIM_SVPC_RETURN_FAILED; CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *settings; + CMPIObjectPath *pool; CU_DEBUG("CreateResourceInPool"); + s = create_resource_parse_args(argsin, &settings, &pool); + if (s.rc != CMPI_RC_OK) + goto out; + if (s.rc == CMPI_RC_OK) rc = CIM_SVPC_RETURN_COMPLETED; CMReturnData(results, &rc, CMPI_uint32); + out: + return s; }

On 08/06/2009 06:59 PM, Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert<karupert@us.ibm.com> # Date 1249595963 25200 # Node ID af509ca0e7f25db4e7ce96dff8bc77df6289e9b3 # Parent fc589363fb55e780942d8431f9c3559d766dcb69 Parse parameters passed in to CreateResourceInPool
Signed-off-by: Kaitlin Rupert<karupert@us.ibm.com>
diff -r fc589363fb55 -r af509ca0e7f2 src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Thu Aug 06 14:58:56 2009 -0700 +++ b/src/Virt_ResourcePoolConfigurationService.c Thu Aug 06 14:59:23 2009 -0700 @@ -664,6 +664,32 @@ return s; }
+static CMPIStatus create_resource_parse_args(const CMPIArgs *argsin, + CMPIInstance **settings, + CMPIObjectPath **pool) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + if (cu_get_inst_arg(argsin, "Settings", settings) != CMPI_RC_OK) { + CU_DEBUG("Failed to get Settings arg"); + cu_statusf(_BROKER,&s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing argument `Settings'"); + goto out; + } + + if (cu_get_ref_arg(argsin, "Pool", pool) != CMPI_RC_OK) { + CU_DEBUG("Failed to get Pool reference arg"); + cu_statusf(_BROKER,&s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing argument `Pool'"); + goto out; + } + + out: + return s; +} + static CMPIStatus create_resource_in_pool(CMPIMethodMI *self, const CMPIContext *context, const CMPIResult *results, @@ -673,13 +699,21 @@ { uint32_t rc = CIM_SVPC_RETURN_FAILED; CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *settings; + CMPIObjectPath *pool;
CU_DEBUG("CreateResourceInPool");
+ s = create_resource_parse_args(argsin,&settings,&pool); + if (s.rc != CMPI_RC_OK) + goto out; + if (s.rc == CMPI_RC_OK) rc = CIM_SVPC_RETURN_COMPLETED; CMReturnData(results,&rc, CMPI_uint32);
+ out: + return s; }
According to the patchset header, this should check the parameters passed, but this code always call create_resource_parse_args with a both settings and pool parameters NULL. This will always generate an error!
_______________________________________________ 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

@@ -673,13 +699,21 @@ { uint32_t rc = CIM_SVPC_RETURN_FAILED; CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *settings; + CMPIObjectPath *pool;
CU_DEBUG("CreateResourceInPool");
+ s = create_resource_parse_args(argsin,&settings,&pool); + if (s.rc != CMPI_RC_OK) + goto out; + if (s.rc == CMPI_RC_OK) rc = CIM_SVPC_RETURN_COMPLETED; CMReturnData(results,&rc, CMPI_uint32);
+ out: + return s; }
According to the patchset header, this should check the parameters passed, but this code always call create_resource_parse_args with a both settings and pool parameters NULL. This will always generate an error!
Settings and Pool are NULL because the create_resource_parse_args() assigns those parameters. Once create_resource_parse_args() returns, those params shouldn't be NULL unless create_resource_parse_args() encounters an error. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

+1 On 08/06/2009 06:59 PM, Kaitlin Rupert wrote:
Right now, the CreateResourceInPool() doesn't do anything other than check the parameters that are parsed in. Subsequent patches will add additional functionality.
_______________________________________________ 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