From yunguol at cn.ibm.com Fri Feb 1 00:57:57 2008 From: yunguol at cn.ibm.com (Guo Lian Yun) Date: Fri, 1 Feb 2008 08:57:57 +0800 Subject: [Libvirt-cim] lowercase of instanceid in Virt_MigrationJob instance In-Reply-To: <47A1A922.4040400@linux.vnet.ibm.com> Message-ID: libvirt-cim-bounces at redhat.com wrote on 2008-01-31 18:55:30: > Guo Lian Yun wrote: > > > > libvirt-cim-bounces at redhat.com wrote on 2008-01-30 21:48:16: > > > > > Guo Lian Yun wrote: > > > > > > > > Hi, > > > > > > > > The key name of instanceid is not case sensitive in ein or gi > > operation. > > > > Generally, it's written by "InstanceID" in querying result, but > > > > Virt_MigrationJob > > > > instance is different, the ein output as following: > > > > ... > > > > localhost:5988/root/virt:Virt_MigrationJob.instanceid="48814722- > > > f6d7-4ba5-b2db-6bf3242bd281" > > > > localhost:5988/root/virt:Virt_MigrationJob. > > > instanceid="36529c45-8aed-425e-ad57-7f411b79d898" > > > > ... > > > > > > > > I know it's a small problem, do you think we need to make it identify > > > > with other instances? > > > > > > > > > > > > Best, > > > > Regards > > > > > > > > Daisy Guo Lian Yun > > > > E-mail: yunguol at cn.ibm.com > > > > IBM China Development Lab, Shanghai, China > > > > TEL: (86)-21-61008057 > > > > > > > > > > > Looking through the code I can't find anywhere where we set InstanceID > > > using all lowercase like that. Could you provide the exact steps you > > > did to get this so I can reproduce it? > > > > > > > > > > I get it by migration test. The steps are as followings: > > > > 1) Create and start a domain > > 2) Call MigrateVirtualSystemToHost > > > > ret = service.MigrateVirtualSystemToHost(ComputerSystem=cs_ref, > > DestinationHost=options.ip) > > > > 3) Once the migration started, you can get Virt_MigrationJob instance. > > Get the Job ID from the result of MigrateVirtualSystemToHost, > > and then monitor the Xen_MigrationJob instance to see when it > > finishes, > > which can be got on the other console by ein and gi. > > > > > > wbemcli ein http://root:password at localhost/root/virt:Virt_MigrationJob > > localhost:5988/root/virt:Virt_MigrationJob. > instanceid="2eb7e2ca-6197-4e50-9590-7cd05064d242" > > > > wbemcli gi > > http://root:password at localhost/root/virt:Virt_MigrationJob.instanceid= > "2eb7e2ca-6197-4e50-9590-7cd05064d242" > > localhost:5988/root/virt:Virt_MigrationJob. > instanceid="2eb7e2ca-6197-4e50-9590-7cd05064d242" > > > > OtherRecoveryAction,RecoveryAction,ErrorDescription,ErrorCode, > DeleteOnCompletion=TRUE,PercentComplete,Priority,Owner,Notify, > UntilTime,LocalOrUtcTime,RunStartInterval,RunDayOfWeek,RunDay, > RunMonth,JobRunTimes=1,ElapsedTime,StartTime=20080131123445. > 522288+480,ScheduledStartTime,TimeSubmitted,JobStatus, > CommunicationStatus,OperatingStatus,DetailedStatus,PrimaryStatus, > HealthState,Status="Migration > > Failed",StatusDescriptions,OperationalStatus,InstallDate,Caption, > Description,ElementName, > InstanceID="2eb7e2ca-6197-4e50-9590-7cd05064d242",Name="Migration", > JobState=7,TimeOfLastStateChange,TimeBeforeRemoval=00000000000500.000000:000 > > > > > Well, the background is that the instance provider for Virt_MigrationJob > is none of our providers. I found no implementation nor a registration > of one provider for Virt_MigrationJob (as Jay already mentioned). But > within the code you can find calls back to the CIMOM, that do > createInstance(), modifyInstance() and deleteInstance() on the > Virt_MigrationJob instances. This can only mean, that the instance(s) of > Virt_MigrationJob are stored in the CIMOM's repository (where also the > schema is located) and are handled by Pegasus' internal provider. And > this internal provider is responsible for setting the "instanceid". So > now I can only suppose ... the provider is setting "instanceid" instead > of "InstanceID" for ein calls. One interesting test case would be doing > the gi with the uppercase notation. Please can you provide me this > result ? Thanks. > > wbemcli gi > http://root:password at localhost/root/virt:Virt_MigrationJob.InstanceID= > >"2eb7e2ca-6197-4e50-9590-7cd05064d242" > Below are the outputs of ein and gi with the uppercase notation. wbemcli ein http://root:password at localhost/root/virt:Virt_MigrationJob localhost:5988/root/virt:Virt_MigrationJob.instanceid ="066259d5-4c5a-4b1f-991f-0d839f105a68" wbemcli gi http://root:password at localhost/root/virt:Virt_MigrationJob. InstanceID="066259d5-4c5a-4b1f-991f-0d839f105a68" localhost:5988/root/virt:Virt_MigrationJob.InstanceID ="066259d5-4c5a-4b1f-991f-0d839f105a68" OtherRecoveryAction,RecoveryAction,ErrorDescription,ErrorCode,DeleteOnCompletion=TRUE,PercentComplete,Priority,Owner,Notify,UntilTime,LocalOrUtcTime,RunStartInterval,RunDayOfWeek,RunDay,RunMonth,JobRunTimes=1,ElapsedTime,StartTime=20080201081420.535009+480,ScheduledStartTime,TimeSubmitted,JobStatus,CommunicationStatus,OperatingStatus,DetailedStatus,PrimaryStatus,HealthState,Status="Running",StatusDescriptions,OperationalStatus,InstallDate,Caption,Description,ElementName,InstanceID="066259d5-4c5a-4b1f-991f-0d839f105a68",Name="Migration",JobState=4,TimeOfLastStateChange,TimeBeforeRemoval=00000000000500.000000:000 Also, the output of gi with the lowercase notation as follows: wbemcli gi http://root:password at localhost/root/virt:Virt_MigrationJob. instanceid="066259d5-4c5a-4b1f-991f-0d839f105a68" localhost:5988/root/virt:Virt_MigrationJob.instanceid ="066259d5-4c5a-4b1f-991f-0d839f105a68" OtherRecoveryAction,RecoveryAction,ErrorDescription,ErrorCode,DeleteOnCompletion=TRUE,PercentComplete,Priority,Owner,Notify,UntilTime,LocalOrUtcTime,RunStartInterval,RunDayOfWeek,RunDay,RunMonth,JobRunTimes=1,ElapsedTime,StartTime=20080201081420.535009+480,ScheduledStartTime,TimeSubmitted,JobStatus,CommunicationStatus,OperatingStatus,DetailedStatus,PrimaryStatus,HealthState,Status="Running",StatusDescriptions,OperationalStatus,InstallDate,Caption,Description,ElementName,InstanceID="066259d5-4c5a-4b1f-991f-0d839f105a68",Name="Migration",JobState=4,TimeOfLastStateChange,TimeBeforeRemoval=00000000000500.000000:000 > -- > Regards > > Heidi Eckhart > Software Engineer > IBM Linux Technology Center - Open Hypervisor > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From heidieck at linux.vnet.ibm.com Fri Feb 1 09:32:44 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 01 Feb 2008 10:32:44 +0100 Subject: [Libvirt-cim] [PATCH] (2) Remove the embedded object parsing pieces from VirtualSystemManagmentService In-Reply-To: References: Message-ID: <47A2E73C.3030201@linux.vnet.ibm.com> Kaitlin Rupert wrote: > # HG changeset patch > # User Kaitlin Rupert > # Date 1201801531 28800 > # Node ID e27208a0ac3f69df3f704ecd32fdfdc78b79dc7c > # Parent b8d69e734306e618b4efb53e23c17ffdd8bab128 > (2) Remove the embedded object parsing pieces from VirtualSystemManagmentService. > > Updates from set 1 to set 2: > Removed unsused sys_op from define_system() > Removed unused list from update_resource_setting() > Changed CMPIArray **out_arr to **ret_arr in rasd_refs_to_insts() > > Opps, sorry, I'm sure I was not very clear on what I meant with the out_arr. I thought something like this might look better in the code ... instead of submitting *out_arr submitting a ret_arr (which itself becomes the content of *out_arr at the end). > static CMPIStatus rasd_refs_to_insts(const CMPIContext *ctx, > const CMPIObjectPath *reference, > CMPIArray *arr, > - struct inst_list *list) > + CMPIArray **ret_arr) > { > CMPIStatus s; > int i; > > CMPIArray *ret_arr; > @@ -1049,6 +994,11 @@ static CMPIStatus rasd_refs_to_insts(con > c = CMGetArrayCount(arr, &s); > if (s.rc != CMPI_RC_OK) > return s; > + > + *ret_arr = CMNewArray(_BROKER, > ret_arr = CMNewArray(_BROKER, > + c, > + CMPI_instance, > + &s); > > for (i = 0; i < c; i++) { > CMPIData d; > @@ -1079,7 +1029,9 @@ static CMPIStatus rasd_refs_to_insts(con > > inst = get_rasd_instance(ctx, reference, _BROKER, id, type); > if (inst != NULL) > - inst_list_add(list, inst); > + CMSetArrayElementAt(*ret_arr, i, > CMSetArrayElementAt(ret_arr, i, > + &inst, > + CMPI_instance); > else > CU_DEBUG("Failed to get instance for `%s'", > REF2STR(ref)); > > ret_arr = *out_arr; -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 1 09:41:23 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 01 Feb 2008 10:41:23 +0100 Subject: [Libvirt-cim] lowercase of instanceid in Virt_MigrationJob instance In-Reply-To: References: Message-ID: <47A2E943.2060403@linux.vnet.ibm.com> Guo Lian Yun wrote: > > libvirt-cim-bounces at redhat.com wrote on 2008-01-31 18:55:30: > > > Guo Lian Yun wrote: > > > > > > libvirt-cim-bounces at redhat.com wrote on 2008-01-30 21:48:16: > > > > > > > Guo Lian Yun wrote: > > > > > > > > > > Hi, > > > > > > > > > > The key name of instanceid is not case sensitive in ein or gi > > > operation. > > > > > Generally, it's written by "InstanceID" in querying result, but > > > > > Virt_MigrationJob > > > > > instance is different, the ein output as following: > > > > > ... > > > > > localhost:5988/root/virt:Virt_MigrationJob.instanceid="48814722- > > > > f6d7-4ba5-b2db-6bf3242bd281" > > > > > localhost:5988/root/virt:Virt_MigrationJob. > > > > instanceid="36529c45-8aed-425e-ad57-7f411b79d898" > > > > > ... > > > > > > > > > > I know it's a small problem, do you think we need to make it > identify > > > > > with other instances? > > > > > > > > > > > > > > > Best, > > > > > Regards > > > > > > > > > > Daisy Guo Lian Yun > > > > > E-mail: yunguol at cn.ibm.com > > > > > IBM China Development Lab, Shanghai, China > > > > > TEL: (86)-21-61008057 > > > > > > > > > > > > > > Looking through the code I can't find anywhere where we set > InstanceID > > > > using all lowercase like that. Could you provide the exact > steps you > > > > did to get this so I can reproduce it? > > > > > > > > > > > > > > I get it by migration test. The steps are as followings: > > > > > > 1) Create and start a domain > > > 2) Call MigrateVirtualSystemToHost > > > > > > ret = service.MigrateVirtualSystemToHost(ComputerSystem=cs_ref, > > > DestinationHost=options.ip) > > > > > > 3) Once the migration started, you can get Virt_MigrationJob instance. > > > Get the Job ID from the result of MigrateVirtualSystemToHost, > > > and then monitor the Xen_MigrationJob instance to see when it > > > finishes, > > > which can be got on the other console by ein and gi. > > > > > > > > > wbemcli ein http://root:password at localhost/root/virt:Virt_MigrationJob > > > localhost:5988/root/virt:Virt_MigrationJob. > > instanceid="2eb7e2ca-6197-4e50-9590-7cd05064d242" > > > > > > wbemcli gi > > > http://root:password at localhost/root/virt:Virt_MigrationJob.instanceid= > > "2eb7e2ca-6197-4e50-9590-7cd05064d242" > > > localhost:5988/root/virt:Virt_MigrationJob. > > instanceid="2eb7e2ca-6197-4e50-9590-7cd05064d242" > > > > > > OtherRecoveryAction,RecoveryAction,ErrorDescription,ErrorCode, > > DeleteOnCompletion=TRUE,PercentComplete,Priority,Owner,Notify, > > UntilTime,LocalOrUtcTime,RunStartInterval,RunDayOfWeek,RunDay, > > RunMonth,JobRunTimes=1,ElapsedTime,StartTime=20080131123445. > > 522288+480,ScheduledStartTime,TimeSubmitted,JobStatus, > > CommunicationStatus,OperatingStatus,DetailedStatus,PrimaryStatus, > > HealthState,Status="Migration > > > Failed",StatusDescriptions,OperationalStatus,InstallDate,Caption, > > Description,ElementName, > > InstanceID="2eb7e2ca-6197-4e50-9590-7cd05064d242",Name="Migration", > > > JobState=7,TimeOfLastStateChange,TimeBeforeRemoval=00000000000500.000000:000 > > > > > > > > Well, the background is that the instance provider for > Virt_MigrationJob > > is none of our providers. I found no implementation nor a registration > > of one provider for Virt_MigrationJob (as Jay already mentioned). But > > within the code you can find calls back to the CIMOM, that do > > createInstance(), modifyInstance() and deleteInstance() on the > > Virt_MigrationJob instances. This can only mean, that the > instance(s) of > > Virt_MigrationJob are stored in the CIMOM's repository (where also the > > schema is located) and are handled by Pegasus' internal provider. And > > this internal provider is responsible for setting the "instanceid". So > > now I can only suppose ... the provider is setting "instanceid" instead > > of "InstanceID" for ein calls. One interesting test case would be doing > > the gi with the uppercase notation. Please can you provide me this > > result ? Thanks. > > > > wbemcli gi > > http://root:password at localhost/root/virt:Virt_MigrationJob.InstanceID= > > > >"2eb7e2ca-6197-4e50-9590-7cd05064d242" > > > > Below are the outputs of ein and gi with the uppercase notation. > > wbemcli ein http://root:password at localhost/root/virt:Virt_MigrationJob > localhost:5988/root/virt:Virt_MigrationJob.instanceid="066259d5-4c5a-4b1f-991f-0d839f105a68" > > wbemcli gi > http://root:password at localhost/root/virt:Virt_MigrationJob.InstanceID="066259d5-4c5a-4b1f-991f-0d839f105a68" > localhost:5988/root/virt:Virt_MigrationJob.InstanceID="066259d5-4c5a-4b1f-991f-0d839f105a68" > OtherRecoveryAction,RecoveryAction,ErrorDescription,ErrorCode,DeleteOnCompletion=TRUE,PercentComplete,Priority,Owner,Notify,UntilTime,LocalOrUtcTime,RunStartInterval,RunDayOfWeek,RunDay,RunMonth,JobRunTimes=1,ElapsedTime,StartTime=20080201081420.535009+480,ScheduledStartTime,TimeSubmitted,JobStatus,CommunicationStatus,OperatingStatus,DetailedStatus,PrimaryStatus,HealthState,Status="Running",StatusDescriptions,OperationalStatus,InstallDate,Caption,Description,ElementName,InstanceID="066259d5-4c5a-4b1f-991f-0d839f105a68",Name="Migration",JobState=4,TimeOfLastStateChange,TimeBeforeRemoval=00000000000500.000000:000 > > Also, the output of gi with the lowercase notation as follows: > wbemcli gi > http://root:password at localhost/root/virt:Virt_MigrationJob.instanceid="066259d5-4c5a-4b1f-991f-0d839f105a68" > localhost:5988/root/virt:Virt_MigrationJob.instanceid="066259d5-4c5a-4b1f-991f-0d839f105a68" > OtherRecoveryAction,RecoveryAction,ErrorDescription,ErrorCode,DeleteOnCompletion=TRUE,PercentComplete,Priority,Owner,Notify,UntilTime,LocalOrUtcTime,RunStartInterval,RunDayOfWeek,RunDay,RunMonth,JobRunTimes=1,ElapsedTime,StartTime=20080201081420.535009+480,ScheduledStartTime,TimeSubmitted,JobStatus,CommunicationStatus,OperatingStatus,DetailedStatus,PrimaryStatus,HealthState,Status="Running",StatusDescriptions,OperationalStatus,InstallDate,Caption,Description,ElementName,InstanceID="066259d5-4c5a-4b1f-991f-0d839f105a68",Name="Migration",JobState=4,TimeOfLastStateChange,TimeBeforeRemoval=00000000000500.000000:000 > Ok, now I have cleared up my mind. Pegasus' internal provider sets "instanceid" lowercase for ein (please don't ask me why) and short term we have no possibility to change this. Long term we can go back into the Pegasus community and ask them to use the DMTF given uppercase notation. But that would take a while. For the different object pathes on the gi call wbemcli itself is responsible. Only for informational purpose wbemcli is - in addition to the providers instance - printing the request's object path again. This object path was not generated by the provider. That's all I can tell to this issue. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 1 10:16:37 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 01 Feb 2008 12:16:37 +0200 Subject: [Libvirt-cim] [PATCH] RegisteredProfile: getInstance with wrong hypervisor segfaults Message-ID: <405c0a9cdc3f8a2e3fce.1201864597@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1201860600 -3600 # Node ID 405c0a9cdc3f8a2e3fce2a5245f23a1645ccc5ea # Parent d03cf2a819d5df30e4c67ba0b733e14cc0d41607 RegisteredProfile: getInstance with wrong hypervisor segfaults wbemgi 'http://localhost:5988/root/interop:Xen_RegisteredProfile.InstanceID="CIM:DSP1042-SystemVirtualization-1.0.0"' on a KVM system segfaults. Signed-off-by: Heidi Eckhart diff -r d03cf2a819d5 -r 405c0a9cdc3f src/Virt_RegisteredProfile.c --- a/src/Virt_RegisteredProfile.c Thu Jan 31 11:01:59 2008 +0100 +++ b/src/Virt_RegisteredProfile.c Fri Feb 01 11:10:00 2008 +0100 @@ -134,8 +134,12 @@ static CMPIStatus get_prof(const CMPIObj int i; conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - return s; + if (conn == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, From heidieck at linux.vnet.ibm.com Fri Feb 1 10:17:01 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 01 Feb 2008 12:17:01 +0200 Subject: [Libvirt-cim] [PATCH] RASD: wrong provider registration for NetRASD Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1201861035 -3600 # Node ID cb0e8b858f4243a7086f627d65a07075b9f31ebc # Parent 405c0a9cdc3f8a2e3fce2a5245f23a1645ccc5ea RASD: wrong provider registration for NetRASD type on registration file - the name of the provider is Virt_RASD instead of Virt_RASDP. Only occurs for NetRASD. Signed-off-by: Heidi Eckhart diff -r 405c0a9cdc3f -r cb0e8b858f42 schema/ResourceAllocationSettingData.registration --- a/schema/ResourceAllocationSettingData.registration Fri Feb 01 11:10:00 2008 +0100 +++ b/schema/ResourceAllocationSettingData.registration Fri Feb 01 11:17:15 2008 +0100 @@ -1,10 +1,10 @@ # Copyright IBM Corp. 2007 # Classname Namespace ProviderName ProviderModule ProviderTypes Xen_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance -Xen_NetResourceAllocationSettingData root/virt Virt_RASDP Virt_RASD instance +Xen_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance -KVM_NetResourceAllocationSettingData root/virt Virt_RASDP Virt_RASD instance +KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance From heidieck at linux.vnet.ibm.com Fri Feb 1 10:21:01 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 01 Feb 2008 12:21:01 +0200 Subject: [Libvirt-cim] [PATCH] RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults Message-ID: <6b1bf8231d82f51f25ac.1201864861@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1201864846 -3600 # Node ID 6b1bf8231d82f51f25ac3d954b63962bfc7484c9 # Parent cb0e8b858f4243a7086f627d65a07075b9f31ebc RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults wbemein http://localhost/root/virt:CIM_ResourcePoolConfigurationService on a KVM system with no Xen segfaults. The same happens to wbemgi 'http://localhost:5988/root/virt:Xen_ResourcePoolConfigurationService.SystemCreationClassName="Xen_HostSystem",SystemName="localhost.localdomain",CreationClassName="Xen_ResourcePoolConfigurationService",Name="RPCS"' This patch also makes RPCS aware of the supported hypervisor type. Now only instances of the machine's supported hypervisor are returned. This approach is used all over the libvirt-cim providers, but was broken here. Signed-off-by: Heidi Eckhart diff -r cb0e8b858f42 -r 6b1bf8231d82 src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 11:17:15 2008 +0100 +++ b/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 12:20:46 2008 +0100 @@ -100,15 +100,20 @@ CMPIStatus rpcs_instance(const CMPIObjec { CMPIInstance *inst; CMPIInstance *host; - CMPIStatus s; + CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIData prop; + virConnectPtr conn = NULL; + + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); + if (conn == NULL) + goto out; s = get_host_cs(broker, reference, &host); if (s.rc != CMPI_RC_OK) goto out; inst = get_typed_instance(broker, - CLASSNAME(reference), + pfx_from_conn(conn), "ResourcePoolConfigurationService", NAMESPACE(reference)); if (inst == NULL) { @@ -145,7 +150,10 @@ CMPIStatus rpcs_instance(const CMPIObjec (CMPIValue *)&prop.value.string, CMPI_string); *_inst = inst; + out: + virConnectClose(conn); + return s; } @@ -155,13 +163,17 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - CMPIInstance *inst; + CMPIInstance *inst = NULL; CMPIStatus s; const char *prop = NULL; s = rpcs_instance(reference, &inst, _BROKER); - if (s.rc != CMPI_RC_OK) + if (s.rc != CMPI_RC_OK || inst == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); return s; + } prop = cu_compare_ref(reference, inst); if (prop != NULL) { @@ -180,11 +192,11 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - CMPIInstance *inst; - CMPIStatus s; - - s = rpcs_instance(reference, &inst, _BROKER); - if (s.rc == CMPI_RC_OK) + CMPIInstance *inst = NULL; + CMPIStatus s; + + s = rpcs_instance(reference, &inst, _BROKER); + if (s.rc == CMPI_RC_OK && inst != NULL) cu_return_instance_name(results, inst); return s; @@ -197,11 +209,11 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - CMPIInstance *inst; - CMPIStatus s; - - s = rpcs_instance(reference, &inst, _BROKER); - if (s.rc == CMPI_RC_OK) + CMPIInstance *inst = NULL; + CMPIStatus s; + + s = rpcs_instance(reference, &inst, _BROKER); + if (s.rc == CMPI_RC_OK && inst != NULL) CMReturnInstance(results, inst); return s; From heidieck at linux.vnet.ibm.com Fri Feb 1 11:28:39 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 01 Feb 2008 13:28:39 +0200 Subject: [Libvirt-cim] [PATCH 1 of 2] RPCC: returns instances of Xen on a KVM only system In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1201865505 -3600 # Node ID d4b86a39d55d2208c5f56a6666ccc212ab60a240 # Parent 6b1bf8231d82f51f25ac3d954b63962bfc7484c9 RPCC: returns instances of Xen on a KVM only system This breaks the approach that is used all over libvirt-cim providers, where only instances of the currently supported hypervisor type are returned. Signed-off-by: Heidi Eckhart diff -r 6b1bf8231d82 -r d4b86a39d55d src/Virt_ResourcePoolConfigurationCapabilities.c --- a/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Feb 01 12:20:46 2008 +0100 +++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Feb 01 12:31:45 2008 +0100 @@ -51,28 +51,39 @@ static CMPIStatus get_rpc_cap(const CMPI const CMPIObjectPath *reference, CMPIInstance **_inst) { - CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn = NULL; + + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); + if (conn == NULL) + goto out; inst = get_typed_instance(broker, - CLASSNAME(reference), + pfx_from_conn(conn), "ResourcePoolConfigurationCapabilities", NAMESPACE(reference)); if (inst == NULL) - return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL}; + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Can't create ResourcePoolConfigurationCapabilities instance"); CMSetProperty(inst, "InstanceID", (CMPIValue *)"RPCC", CMPI_chars); /* No method currently supported */ + out: *_inst = inst; - - return (CMPIStatus){CMPI_RC_OK, NULL}; + virConnectClose(conn); + + return s; } static CMPIStatus return_rpc_cap(const CMPIObjectPath *reference, const CMPIResult *results, - bool names_only) + bool names_only, + bool getInstance) { CMPIStatus s; CMPIInstance *inst; @@ -81,11 +92,19 @@ static CMPIStatus return_rpc_cap(const C if (s.rc != CMPI_RC_OK) goto out; + if (inst == NULL) { + if (getInstance) + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + if (names_only) cu_return_instance_name(results, inst); else CMReturnInstance(results, inst); - + out: return s; } @@ -95,7 +114,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_rpc_cap(reference, results, 1); + return return_rpc_cap(reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -105,7 +124,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_rpc_cap(reference, results, 0); + return return_rpc_cap(reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -114,7 +133,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - return return_rpc_cap(reference, results, 0); + return return_rpc_cap(reference, results, false, true); } From heidieck at linux.vnet.ibm.com Fri Feb 1 11:28:38 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 01 Feb 2008 13:28:38 +0200 Subject: [Libvirt-cim] [PATCH 0 of 2] RPCC: ignores supported hypervisor type and wrong object path Message-ID: This patch set fixes RPCC's handling of the supported hypervisor and enables checking the client given object path on gi calls. From heidieck at linux.vnet.ibm.com Fri Feb 1 11:28:40 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 01 Feb 2008 13:28:40 +0200 Subject: [Libvirt-cim] [PATCH 2 of 2] RPCC: getInstance does not take care of client given object path In-Reply-To: Message-ID: <21fecbdb0f84910eb9a8.1201868920@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1201868641 -3600 # Node ID 21fecbdb0f84910eb9a889319db6486882bd7194 # Parent d4b86a39d55d2208c5f56a6666ccc212ab60a240 RPCC: getInstance does not take care of client given object path wbemgi 'http://localhost:5988/root/virt:KVM_ResourcePoolConfigurationCapabilities.InstanceID="wrong"' returns the instance instead of NOT_FOUND. Signed-off-by: Heidi Eckhart diff -r d4b86a39d55d -r 21fecbdb0f84 src/Virt_ResourcePoolConfigurationCapabilities.c --- a/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Feb 01 12:31:45 2008 +0100 +++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Feb 01 13:24:01 2008 +0100 @@ -99,6 +99,12 @@ static CMPIStatus return_rpc_cap(const C "No such instance"); goto out; } + + if (getInstance) { + s = cu_validate_ref(_BROKER, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } if (names_only) cu_return_instance_name(results, inst); From kaitlin at linux.vnet.ibm.com Fri Feb 1 15:44:50 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 01 Feb 2008 07:44:50 -0800 Subject: [Libvirt-cim] [PATCH] (2) Remove the embedded object parsing pieces from VirtualSystemManagmentService In-Reply-To: <47A2E73C.3030201@linux.vnet.ibm.com> References: <47A2E73C.3030201@linux.vnet.ibm.com> Message-ID: <47A33E72.6020600@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> # HG changeset patch >> # User Kaitlin Rupert >> # Date 1201801531 28800 >> # Node ID e27208a0ac3f69df3f704ecd32fdfdc78b79dc7c >> # Parent b8d69e734306e618b4efb53e23c17ffdd8bab128 >> (2) Remove the embedded object parsing pieces from >> VirtualSystemManagmentService. >> >> Updates from set 1 to set 2: >> Removed unsused sys_op from define_system() >> Removed unused list from update_resource_setting() >> Changed CMPIArray **out_arr to **ret_arr in rasd_refs_to_insts() >> >> > Opps, sorry, I'm sure I was not very clear on what I meant with the > out_arr. I thought something like this might look better in the code ... > instead of submitting *out_arr submitting a ret_arr (which itself > becomes the content of *out_arr at the end). Oh, yes - I did misunderstand. Thanks for the clarification. =) However, I'm not sure what benefit this gives us. I think I'm missing something - does this change prevent an error condition of some sort? Thanks! > >> static CMPIStatus rasd_refs_to_insts(const CMPIContext *ctx, >> const CMPIObjectPath *reference, >> CMPIArray *arr, >> - struct inst_list *list) >> + CMPIArray **ret_arr) >> { >> CMPIStatus s; >> int i; >> >> > CMPIArray *ret_arr; >> @@ -1049,6 +994,11 @@ static CMPIStatus rasd_refs_to_insts(con >> c = CMGetArrayCount(arr, &s); >> if (s.rc != CMPI_RC_OK) >> return s; >> + >> + *ret_arr = CMNewArray(_BROKER, >> > ret_arr = CMNewArray(_BROKER, >> + c, >> + CMPI_instance, >> + &s); >> for (i = 0; i < c; i++) { >> CMPIData d; >> @@ -1079,7 +1029,9 @@ static CMPIStatus rasd_refs_to_insts(con >> >> inst = get_rasd_instance(ctx, reference, _BROKER, id, >> type); >> if (inst != NULL) >> - inst_list_add(list, inst); >> + CMSetArrayElementAt(*ret_arr, i, >> > CMSetArrayElementAt(ret_arr, i, >> + &inst, >> + CMPI_instance); >> else >> CU_DEBUG("Failed to get instance for `%s'", >> REF2STR(ref)); >> >> > ret_arr = *out_arr; > -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Fri Feb 1 15:49:46 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 01 Feb 2008 07:49:46 -0800 Subject: [Libvirt-cim] [PATCH] RegisteredProfile: getInstance with wrong hypervisor segfaults In-Reply-To: <405c0a9cdc3f8a2e3fce.1201864597@localhost.localdomain> References: <405c0a9cdc3f8a2e3fce.1201864597@localhost.localdomain> Message-ID: <47A33F9A.9030703@linux.vnet.ibm.com> Heidi Eckhart wrote: > # HG changeset patch > # User Heidi Eckhart > # Date 1201860600 -3600 > # Node ID 405c0a9cdc3f8a2e3fce2a5245f23a1645ccc5ea > # Parent d03cf2a819d5df30e4c67ba0b733e14cc0d41607 > RegisteredProfile: getInstance with wrong hypervisor segfaults Another good catch Heidi. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Fri Feb 1 15:52:02 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 01 Feb 2008 07:52:02 -0800 Subject: [Libvirt-cim] [PATCH] RASD: wrong provider registration for NetRASD In-Reply-To: References: Message-ID: <47A34022.9060507@linux.vnet.ibm.com> Heidi Eckhart wrote: > # HG changeset patch > # User Heidi Eckhart > # Date 1201861035 -3600 > # Node ID cb0e8b858f4243a7086f627d65a07075b9f31ebc > # Parent 405c0a9cdc3f8a2e3fce2a5245f23a1645ccc5ea > RASD: wrong provider registration for NetRASD > > type on registration file - the name of the provider is > Virt_RASD instead of Virt_RASDP. Only occurs for NetRASD. > > Signed-off-by: Heidi Eckhart > > diff -r 405c0a9cdc3f -r cb0e8b858f42 schema/ResourceAllocationSettingData.registration > --- a/schema/ResourceAllocationSettingData.registration Fri Feb 01 11:10:00 2008 +0100 > +++ b/schema/ResourceAllocationSettingData.registration Fri Feb 01 11:17:15 2008 +0100 > @@ -1,10 +1,10 @@ > # Copyright IBM Corp. 2007 > # Classname Namespace ProviderName ProviderModule ProviderTypes > Xen_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > -Xen_NetResourceAllocationSettingData root/virt Virt_RASDP Virt_RASD instance > +Xen_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > Xen_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > -KVM_NetResourceAllocationSettingData root/virt Virt_RASDP Virt_RASD instance > +KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > That's an interesting typo -- good eye. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Fri Feb 1 16:06:02 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 01 Feb 2008 08:06:02 -0800 Subject: [Libvirt-cim] [PATCH] RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults In-Reply-To: <6b1bf8231d82f51f25ac.1201864861@localhost.localdomain> References: <6b1bf8231d82f51f25ac.1201864861@localhost.localdomain> Message-ID: <47A3436A.1090008@linux.vnet.ibm.com> Heidi Eckhart wrote: > # HG changeset patch > # User Heidi Eckhart > # Date 1201864846 -3600 > # Node ID 6b1bf8231d82f51f25ac3d954b63962bfc7484c9 > # Parent cb0e8b858f4243a7086f627d65a07075b9f31ebc > RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults > > wbemein http://localhost/root/virt:CIM_ResourcePoolConfigurationService > on a KVM system with no Xen segfaults. > > The same happens to > wbemgi 'http://localhost:5988/root/virt:Xen_ResourcePoolConfigurationService.SystemCreationClassName="Xen_HostSystem",SystemName="localhost.localdomain",CreationClassName="Xen_ResourcePoolConfigurationService",Name="RPCS"' > > This patch also makes RPCS aware of the supported hypervisor type. Now only > instances of the machine's supported hypervisor are returned. This approach > is used all over the libvirt-cim providers, but was broken here. > > Signed-off-by: Heidi Eckhart > > diff -r cb0e8b858f42 -r 6b1bf8231d82 src/Virt_ResourcePoolConfigurationService.c > --- a/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 11:17:15 2008 +0100 > +++ b/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 12:20:46 2008 +0100 > @@ -100,15 +100,20 @@ CMPIStatus rpcs_instance(const CMPIObjec > { > CMPIInstance *inst; > CMPIInstance *host; > - CMPIStatus s; > + CMPIStatus s = {CMPI_RC_OK, NULL}; > CMPIData prop; > + virConnectPtr conn = NULL; > + > + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); > + if (conn == NULL) > + goto out; I would also set the status here. This would mean we don't need to check for a NULL instance everywhere rpcs_instance() is called. Virt_HostedService calls rpcs_instance(), but currently doesn't check for a NULL. So if don't set the status here, HostedService will need to be updated to check for a NULL instance. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From grendel at linux.vnet.ibm.com Fri Feb 1 16:19:05 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 01 Feb 2008 11:19:05 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider In-Reply-To: Message-ID: # HG changeset patch # User Jay Gagnon # Date 1201882409 18000 # Node ID a17039d1b29cd5275ecd126782bb1757a415a0c0 # Parent 6d86529bbdce9eb68b26a7fc5339fd66a1f2fdd2 Add calls into VSMigrationService to utilize new MigrationIndication provider. Signed-off-by: Jay Gagnon diff -r 6d86529bbdce -r a17039d1b29c src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Fri Feb 01 11:13:26 2008 -0500 +++ b/src/Virt_VSMigrationService.c Fri Feb 01 11:13:29 2008 -0500 @@ -34,6 +34,7 @@ #include "misc_util.h" #include #include +#include #include "Virt_VSMigrationService.h" #include "Virt_HostSystem.h" @@ -264,11 +265,32 @@ static CMPIStatus vs_migratable_system(C return vs_migratable(ref, name, dname, results, argsout); } +static bool raise_indication(const CMPIContext *context, + const char *base_type, + const char *ns, + const CMPIInstance *ind) +{ + char *type; + CMPIStatus s; + + /* Seems like this shouldn't be hardcoded. */ + type = get_typed_class("Xen", base_type); + + s = stdi_raise_indication(_BROKER, context, type, ns, ind); + + free(type); + + return s.rc == CMPI_RC_OK; +} + static void migrate_job_set_state(struct migration_job *job, uint16_t state, const char *status) { CMPIInstance *inst; + CMPIInstance *prev_inst; + CMPIInstance *ind; + bool rc; CMPIStatus s; CMPIObjectPath *op; @@ -297,12 +319,50 @@ static void migrate_job_set_state(struct CMSetProperty(inst, "Status", (CMPIValue *)status, CMPI_chars); + CU_DEBUG("Creating indication."); + /* Prefix needs to be dynamic */ + ind = get_typed_instance(_BROKER, + "Xen", + "ComputerSystemMigrationIndication", + job->ref_ns); + /* Prefix needs to be dynamic */ + if (ind == NULL) { + CU_DEBUG("Failed to create ind, type '%s:%s_%s'", + job->ref_ns, + "Xen", + "ComputerSystemMigrationIndication"); + } + + /* Need to copy job inst before attaching as PreviousInstance because + otherwise the changes we are about to make to job inst are made + to PreviousInstance as well. */ + s = cu_dup_instance(_BROKER, inst, &prev_inst); + if (s.rc != CMPI_RC_OK || prev_inst == NULL) { + CU_DEBUG("dup_instance failed (%i:%s)", s.rc, s.msg); + return; + } + + CU_DEBUG("Setting PreviousInstance"); + CMSetProperty(ind, "PreviousInstance", + (CMPIValue *)&prev_inst, CMPI_instance); + CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status); s = CBModifyInstance(_BROKER, job->context, op, inst, NULL); if (s.rc != CMPI_RC_OK) CU_DEBUG("Failed to update job instance: %s", CMGetCharPtr(s.msg)); + + CU_DEBUG("Setting SourceInstance"); + CMSetProperty(ind, "SourceInstance", + (CMPIValue *)&inst, CMPI_instance); + + rc = raise_indication(job->context, + "ComputerSystemMigrationIndication", + job->ref_ns, + ind); + if (!rc) + CU_DEBUG("Failed to raise indication"); } static CMPIStatus migrate_vs(struct migration_job *job) From grendel at linux.vnet.ibm.com Fri Feb 1 16:19:04 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 01 Feb 2008 11:19:04 -0500 Subject: [Libvirt-cim] [PATCH 0 of 2] MigrationIndications Message-ID: These two patches together are dependent on some libcmpiutil changes I'll be sending out shortly; one for dup_instance, and another for raise functionality. The four patches together give us Migration Indications. Any time VSMigrationService is used to trigger a migration, the appropriate indications will be fired. The big caveat for these patches is that migration is still a bit flaky on my system, so while I have tested that the "started" and "failed" indications work I haven't had a chance to see "succeeded" fire. I have no reason to believe it won't, because of the way the raising happens, but it would be good to confirm. From grendel at linux.vnet.ibm.com Fri Feb 1 16:19:06 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 01 Feb 2008 11:19:06 -0500 Subject: [Libvirt-cim] [PATCH 2 of 2] ComputerSystemMigrationIndication In-Reply-To: Message-ID: <6d86529bbdce9eb68b26.1201882746@wulfgar> # HG changeset patch # User Jay Gagnon # Date 1201882406 18000 # Node ID 6d86529bbdce9eb68b26a7fc5339fd66a1f2fdd2 # Parent 2920e184226248f7885dd87a28e30eb1a90005c9 ComputerSystemMigrationIndication Indication to keep clients up to date on CS migrations, along with relevant makefile and schema work. Signed-off-by: Jay Gagnon diff -r 2920e1842262 -r 6d86529bbdce Makefile.am --- a/Makefile.am Wed Jan 30 10:52:58 2008 -0800 +++ b/Makefile.am Fri Feb 01 11:13:26 2008 -0500 @@ -24,6 +24,7 @@ MOFS = \ schema/RegisteredProfile.mof \ schema/ElementConformsToProfile.mof \ schema/ComputerSystemIndication.mof \ + schema/ComputerSystemMigrationIndication.mof \ schema/ResourceAllocationSettingData.mof \ schema/ResourcePoolConfigurationService.mof \ schema/ResourcePoolConfigurationCapabilities.mof \ @@ -65,6 +66,7 @@ REGS = \ schema/DiskPool.registration \ schema/HostedResourcePool.registration \ schema/ComputerSystemIndication.registration \ + schema/ComputerSystemMigrationIndication.registration \ schema/ResourceAllocationSettingData.registration \ schema/ResourcePoolConfigurationService.registration \ schema/ResourcePoolConfigurationCapabilities.registration \ @@ -109,4 +111,4 @@ clean-local: clean-local: rm -f $(find . -name "*.orig") rm -f $(find . -name "*.rej") - rm -f $(find . -name "*~") \ No newline at end of file + rm -f $(find . -name "*~") diff -r 2920e1842262 -r 6d86529bbdce schema/ComputerSystemMigrationIndication.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/ComputerSystemMigrationIndication.mof Fri Feb 01 11:13:26 2008 -0500 @@ -0,0 +1,15 @@ +// Copyright IBM Corp. 2007 + +[Description ("Xen_ComputerSystem migration status"), + Provider("cmpi::Virt_ComputerSystemModificationIndication") +] +class Xen_ComputerSystemMigrationIndication : CIM_InstModification +{ +}; + +[Description ("KVM_ComputerSystem migration status"), + Provider("cmpi::Virt_ComputerSystemModificationIndication") +] +class KVM_ComputerSystemMigrationIndication : CIM_InstModification +{ +}; diff -r 2920e1842262 -r 6d86529bbdce schema/ComputerSystemMigrationIndication.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/ComputerSystemMigrationIndication.registration Fri Feb 01 11:13:26 2008 -0500 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndication Virt_ComputerSystemMigrationIndication indication method +KVM_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndication Virt_ComputerSystemMigrationIndication indication method diff -r 2920e1842262 -r 6d86529bbdce src/Makefile.am --- a/src/Makefile.am Wed Jan 30 10:52:58 2008 -0800 +++ b/src/Makefile.am Fri Feb 01 11:13:26 2008 -0500 @@ -30,6 +30,7 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_Device.la \ libVirt_SystemDevice.la \ libVirt_ComputerSystemIndication.la \ + libVirt_ComputerSystemMigrationIndication.la \ libVirt_RASD.la \ libVirt_HostSystem.la \ libVirt_VirtualSystemManagementService.la \ @@ -61,6 +62,10 @@ libVirt_ComputerSystemIndication_la_DEPE libVirt_ComputerSystemIndication_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_ComputerSystemIndication_la_SOURCES = Virt_ComputerSystemIndication.c libVirt_ComputerSystemIndication_la_LIBADD = -lVirt_ComputerSystem -lpthread -lrt + +libVirt_ComputerSystemMigrationIndication_la_DEPENDENCIES = libVirt_ComputerSystem.la +libVirt_ComputerSystemMigrationIndication_la_SOURCES = Virt_ComputerSystemMigrationIndication.c +libVirt_ComputerSystemMigrationIndication_la_LIBADD = -lVirt_ComputerSystem libVirt_VirtualSystemManagementService_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_ComputerSystemIndication.la libVirt_RASD.la libVirt_HostSystem.la libVirt_VirtualSystemManagementService_la_SOURCES = Virt_VirtualSystemManagementService.c diff -r 2920e1842262 -r 6d86529bbdce src/Virt_ComputerSystemMigrationIndication.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_ComputerSystemMigrationIndication.c Fri Feb 01 11:13:26 2008 -0500 @@ -0,0 +1,120 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "config.h" + +#include "Virt_ComputerSystem.h" + +static const CMPIBroker *_BROKER; + +#ifdef CMPI_EI_VOID +# define _EI_RTYPE void +# define _EI_RET() return +#else +# define _EI_RTYPE CMPIStatus +# define _EI_RET() return (CMPIStatus){CMPI_RC_OK, NULL} +#endif + +static CMPIStatus ActivateFilter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean first) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + return s; +} + +static CMPIStatus DeActivateFilter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean last) +{ + return (CMPIStatus){CMPI_RC_OK, NULL}; +} + +static _EI_RTYPE EnableIndications(CMPIIndicationMI* mi, + const CMPIContext *ctx) +{ + struct std_indication_ctx *_ctx; + _ctx = (struct std_indication_ctx *)mi->hdl; + _ctx->enabled = true; + CU_DEBUG("ComputerSystemModifiedIndication enabled"); + + _EI_RET(); +} + +static _EI_RTYPE DisableIndications(CMPIIndicationMI* mi, + const CMPIContext *ctx) +{ + struct std_indication_ctx *_ctx; + _ctx = (struct std_indication_ctx *)mi->hdl; + _ctx->enabled = false; + CU_DEBUG("ComputerSystemModifiedIndication disabled"); + + _EI_RET(); +} + +static struct std_indication_handler csi = { + .raise_fn = NULL, + .trigger_fn = NULL, +}; + +DEFAULT_IND_CLEANUP(); +DEFAULT_AF(); +DEFAULT_MP(); + +STDI_IndicationMIStub(, + Virt_ComputerSystemMigrationIndication, + _BROKER, + libvirt_cim_init(), + &csi); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From grendel at linux.vnet.ibm.com Fri Feb 1 16:23:17 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 01 Feb 2008 11:23:17 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: Message-ID: # HG changeset patch # User Jay Gagnon # Date 1201795147 18000 # Node ID ec7428b062f45db8eef730c5398d061d8731ce60 # Parent ab0e3b05a10e7b5db7eb493920f01bb402d2feae [CU] Add dup_instance function to libcmpiutil It appears there are some situations where we have to duplicate an instance; this seemed like the kind of thing that would belong in libcmpiutil. Signed-off-by: Jay Gagnon diff -r ab0e3b05a10e -r ec7428b062f4 instance_util.c --- a/instance_util.c Wed Jan 30 11:15:32 2008 -0800 +++ b/instance_util.c Thu Jan 31 10:59:07 2008 -0500 @@ -204,6 +204,28 @@ CMPIStatus cu_copy_prop(const CMPIBroker return s; } +CMPIStatus cu_dup_instance(const CMPIBroker *broker, + CMPIInstance *src, + CMPIInstance **dest) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *ref; + + ref = CMGetObjectPath(src, NULL); + if ((s.rc != CMPI_RC_OK) || CMIsNullObject(ref)) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Could not get objectpath from instance"); + goto out; + } + + *dest = NULL; + *dest = CMNewInstance(broker, ref, &s); + + out: + return s; +} + /* * Local Variables: * mode: C diff -r ab0e3b05a10e -r ec7428b062f4 libcmpiutil.h --- a/libcmpiutil.h Wed Jan 30 11:15:32 2008 -0800 +++ b/libcmpiutil.h Thu Jan 31 10:59:07 2008 -0500 @@ -164,6 +164,18 @@ CMPIrc cu_get_u16_path(const CMPIObjectP CMPIrc cu_get_u16_path(const CMPIObjectPath *reference, const char *key, uint16_t *target); + +/** + * Create a copy of an instance + * + * @param src Source instance + * @param dest Destination instance + * @returns {CMPI_RC_OK, NULL} if success, CMPI_RC ERR_FAILED and + * error message otherwise + */ +CMPIStatus cu_dup_instance(const CMPIBroker *broker, + CMPIInstance *src, + CMPIInstance **dest); /* Forward declaration */ struct inst_list; From grendel at linux.vnet.ibm.com Fri Feb 1 16:23:18 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 01 Feb 2008 11:23:18 -0500 Subject: [Libvirt-cim] [PATCH 2 of 2] [CU] Improve std_indication's raise functionality In-Reply-To: Message-ID: <8669586635358e4858e5.1201882998@wulfgar> # HG changeset patch # User Jay Gagnon # Date 1201882988 18000 # Node ID 8669586635358e4858e56fe2dec8587af784cd47 # Parent ec7428b062f45db8eef730c5398d061d8731ce60 [CU] Improve std_indication's raise functionality Turns out STDI_IndicationMIStub was not creating the CMPIFooMIFTs correctly; this patch fixes that. It also adds a default_raise function to std_indication. This is for indication providers that don't need to do anything other than call CBDeliverIndication, which will most likely be the majority. Signed-off-by: Jay Gagnon diff -r ec7428b062f4 -r 866958663535 std_indication.c --- a/std_indication.c Thu Jan 31 10:59:07 2008 -0500 +++ b/std_indication.c Fri Feb 01 11:23:08 2008 -0500 @@ -19,6 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include @@ -40,19 +41,40 @@ static CMPIStatus trigger(struct std_ind return ctx->handler->trigger_fn(context); } +static CMPIStatus default_raise(const CMPIBroker *broker, + const CMPIContext *context, + CMPIInstance *ind) +{ + CMPIObjectPath *ref; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + ref = CMGetObjectPath(ind, NULL); + + CBDeliverIndication(broker, + context, + NAMESPACE(ref), + ind); + return s; +} + static CMPIStatus raise(struct std_indication_ctx *ctx, const CMPIContext *context, const CMPIArgs *argsin) { CMPIInstance *inst; - if (ctx->handler->raise_fn == NULL) - return (CMPIStatus){CMPI_RC_OK, NULL}; + if (!ctx->enabled) { + CU_DEBUG("Indication disabled, not raising."); + return (CMPIStatus) {CMPI_RC_OK, NULL}; + } if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK) return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL}; - return ctx->handler->raise_fn(context, inst); + if (ctx->handler->raise_fn == NULL) + return default_raise(ctx->brkr, context, inst); + + return ctx->handler->raise_fn(ctx->brkr, context, inst); } CMPIStatus stdi_handler(CMPIMethodMI *self, diff -r ec7428b062f4 -r 866958663535 std_indication.h --- a/std_indication.h Thu Jan 31 10:59:07 2008 -0500 +++ b/std_indication.h Fri Feb 01 11:23:08 2008 -0500 @@ -24,6 +24,7 @@ #include #include #include +#include #include "libcmpiutil.h" #include "std_invokemethod.h" @@ -51,7 +52,8 @@ CMPIStatus stdi_cleanup(CMPIMethodMI *se const CMPIContext *context, CMPIBoolean terminating); -typedef CMPIStatus (*raise_indication_t)(const CMPIContext *ctx, +typedef CMPIStatus (*raise_indication_t)(const CMPIBroker *broker, + const CMPIContext *ctx, const CMPIInstance *ind); typedef CMPIStatus (*trigger_indication_t)(const CMPIContext *ctx); @@ -64,14 +66,44 @@ struct std_indication_ctx { struct std_indication_ctx { const CMPIBroker *brkr; struct std_indication_handler *handler; + bool enabled; }; #define STDI_IndicationMIStub(pfx, pn, _broker, hook, _handler) \ + static struct std_indication_ctx _ctx = { \ + .brkr = NULL, \ + .handler = _handler, \ + .enabled = false, \ + }; \ + \ + static CMPIIndicationMIFT indMIFT__ = { \ + CMPICurrentVersion, \ + CMPICurrentVersion, \ + "Indication" #pn, \ + pfx##IndicationCleanup, \ + pfx##AuthorizeFilter, \ + pfx##MustPoll, \ + pfx##ActivateFilter, \ + pfx##DeActivateFilter, \ + CMIndicationMIStubExtensions(pfx) \ + }; \ CMPIIndicationMI * \ pn##_Create_IndicationMI(const CMPIBroker *, \ - const CMPIContext *, \ - CMPIStatus *); \ - CMIndicationMIStub(pfx, pn, _broker, hook); \ + const CMPIContext *, \ + CMPIStatus *); \ + CMPIIndicationMI * \ + pn##_Create_IndicationMI(const CMPIBroker *brkr, \ + const CMPIContext *ctx, \ + CMPIStatus *rc) { \ + static CMPIIndicationMI mi = { \ + &_ctx, \ + &indMIFT__, \ + }; \ + _ctx.brkr = brkr; \ + _broker = brkr; \ + hook; \ + return &mi; \ + } \ \ static CMPIMethodMIFT methMIFT__ = { \ CMPICurrentVersion, \ @@ -88,13 +120,11 @@ struct std_indication_ctx { CMPIMethodMI *pn##_Create_MethodMI(const CMPIBroker *brkr, \ const CMPIContext *ctx, \ CMPIStatus *rc) { \ - static struct std_indication_ctx _ctx; \ static CMPIMethodMI mi = { \ &_ctx, \ &methMIFT__, \ }; \ _ctx.brkr = brkr; \ - _ctx.handler = _handler; \ _broker = brkr; \ hook; \ return &mi; \ From grendel at linux.vnet.ibm.com Fri Feb 1 16:23:16 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 01 Feb 2008 11:23:16 -0500 Subject: [Libvirt-cim] [PATCH 0 of 2] [CU] Migration Indication related libcmpi changes Message-ID: These provide libcmpiutil support copying instances and raising indications, which are required by the new MigrationIndication provider. From kaitlin at linux.vnet.ibm.com Fri Feb 1 16:25:29 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 01 Feb 2008 08:25:29 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] RPCC: returns instances of Xen on a KVM only system In-Reply-To: References: Message-ID: <47A347F9.4000206@linux.vnet.ibm.com> Heidi Eckhart wrote: > # HG changeset patch > # User Heidi Eckhart > # Date 1201865505 -3600 > # Node ID d4b86a39d55d2208c5f56a6666ccc212ab60a240 > # Parent 6b1bf8231d82f51f25ac3d954b63962bfc7484c9 > RPCC: returns instances of Xen on a KVM only system > > This breaks the approach that is used all over libvirt-cim > providers, where only instances of the currently supported > hypervisor type are returned. > > Signed-off-by: Heidi Eckhart > > diff -r 6b1bf8231d82 -r d4b86a39d55d src/Virt_ResourcePoolConfigurationCapabilities.c > --- a/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Feb 01 12:20:46 2008 +0100 > +++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Feb 01 12:31:45 2008 +0100 > @@ -51,28 +51,39 @@ static CMPIStatus get_rpc_cap(const CMPI > const CMPIObjectPath *reference, > CMPIInstance **_inst) > { > - CMPIInstance *inst; > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + CMPIInstance *inst = NULL; > + virConnectPtr conn = NULL; > + > + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); > + if (conn == NULL) > + goto out; Not sure if everyone will agree, but would it be a good idea to set an error status here? Currently, only Virt_ResourcePoolConfigurationCapabilities is calling this function, but I think that's a potential bug. ElementCapabilities doesn't support this Capabilities class, but I think it should based on the ResourceAllocation profile. Of course, that's a subject of a different patch. However, if we set the status here, then ElementCapabilities won't have to worry about checking whether the instance is NULL. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From grendel at linux.vnet.ibm.com Fri Feb 1 16:34:03 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 01 Feb 2008 11:34:03 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] RPCC: returns instances of Xen on a KVM only system In-Reply-To: <47A347F9.4000206@linux.vnet.ibm.com> References: <47A347F9.4000206@linux.vnet.ibm.com> Message-ID: <47A349FB.5030808@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Heidi Eckhart wrote: >> # HG changeset patch >> # User Heidi Eckhart >> # Date 1201865505 -3600 >> # Node ID d4b86a39d55d2208c5f56a6666ccc212ab60a240 >> # Parent 6b1bf8231d82f51f25ac3d954b63962bfc7484c9 >> RPCC: returns instances of Xen on a KVM only system >> >> This breaks the approach that is used all over libvirt-cim >> providers, where only instances of the currently supported >> hypervisor type are returned. >> >> Signed-off-by: Heidi Eckhart >> >> diff -r 6b1bf8231d82 -r d4b86a39d55d >> src/Virt_ResourcePoolConfigurationCapabilities.c >> --- a/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Feb 01 >> 12:20:46 2008 +0100 >> +++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Feb 01 >> 12:31:45 2008 +0100 >> @@ -51,28 +51,39 @@ static CMPIStatus get_rpc_cap(const CMPI >> const CMPIObjectPath *reference, >> CMPIInstance **_inst) >> { >> - CMPIInstance *inst; >> + CMPIStatus s = {CMPI_RC_OK, NULL}; >> + CMPIInstance *inst = NULL; >> + virConnectPtr conn = NULL; >> + >> + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); >> + if (conn == NULL) >> + goto out; > > Not sure if everyone will agree, but would it be a good idea to set an > error status here? > > Currently, only Virt_ResourcePoolConfigurationCapabilities is calling > this function, but I think that's a potential bug. > ElementCapabilities doesn't support this Capabilities class, but I > think it should based on the ResourceAllocation profile. > > Of course, that's a subject of a different patch. However, if we set > the status here, then ElementCapabilities won't have to worry about > checking whether the instance is NULL. I think this might be one of those places where setting a negative status could cause an error code to filter up to the CIMOM when we don't want it to. Something like the distinction between "CMPI_RC_ERR" and "CMPI_RC_NOT_FOUND" or whatever that was. -- -Jay From danms at us.ibm.com Fri Feb 1 16:42:21 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 01 Feb 2008 08:42:21 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] RPCC: returns instances of Xen on a KVM only system In-Reply-To: <47A347F9.4000206@linux.vnet.ibm.com> (Kaitlin Rupert's message of "Fri, 01 Feb 2008 08:25:29 -0800") References: <47A347F9.4000206@linux.vnet.ibm.com> Message-ID: <87sl0csk5u.fsf@caffeine.beaverton.ibm.com> KR> Not sure if everyone will agree, but would it be a good idea to KR> set an error status here? Yeah, I think you're right. If the calling function of this currently needs to return a CMPI_RC_OK instead of an error, then it probably needs to detect it and return appropriately. If this function makes more sense (in the general case) to return an error, then we should do that. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Fri Feb 1 16:59:49 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 01 Feb 2008 08:59:49 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: (Jay Gagnon's message of "Fri, 01 Feb 2008 11:23:17 -0500") References: Message-ID: <87odb0sjcq.fsf@caffeine.beaverton.ibm.com> JG> +CMPIStatus cu_dup_instance(const CMPIBroker *broker, JG> + CMPIInstance *src, JG> + CMPIInstance **dest) JG> +{ JG> + CMPIStatus s = {CMPI_RC_OK, NULL}; JG> + CMPIObjectPath *ref; JG> + JG> + ref = CMGetObjectPath(src, NULL); JG> + if ((s.rc != CMPI_RC_OK) || CMIsNullObject(ref)) { JG> + cu_statusf(broker, &s, JG> + CMPI_RC_ERR_FAILED, JG> + "Could not get objectpath from instance"); JG> + goto out; JG> + } JG> + JG> + *dest = NULL; Why set it to NULL and then set it to the instance right after this? JG> + *dest = CMNewInstance(broker, ref, &s); JG> + JG> + out: JG> + return s; JG> +} What about all the properties of the instance? This gets a new instance structure, yes, but all it has is an object path. Maybe that is all you need at the moment, but I don't think this does what other consumers of the library would think by the name :) It should be easy to loop through all the properties and copy them over. It will look similar to the array copy/filter code in Kaitlin's libcmpiutil CO patch. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Fri Feb 1 17:06:47 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 01 Feb 2008 09:06:47 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] [CU] Migration Indication related libcmpi changes In-Reply-To: References: Message-ID: <47A351A7.5050802@linux.vnet.ibm.com> This set looks good. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From grendel at linux.vnet.ibm.com Fri Feb 1 17:11:16 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 01 Feb 2008 12:11:16 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: <87odb0sjcq.fsf@caffeine.beaverton.ibm.com> References: <87odb0sjcq.fsf@caffeine.beaverton.ibm.com> Message-ID: <47A352B4.4030909@linux.vnet.ibm.com> Dan Smith wrote: > JG> +CMPIStatus cu_dup_instance(const CMPIBroker *broker, > JG> + CMPIInstance *src, > JG> + CMPIInstance **dest) > JG> +{ > JG> + CMPIStatus s = {CMPI_RC_OK, NULL}; > JG> + CMPIObjectPath *ref; > JG> + > JG> + ref = CMGetObjectPath(src, NULL); > JG> + if ((s.rc != CMPI_RC_OK) || CMIsNullObject(ref)) { > JG> + cu_statusf(broker, &s, > JG> + CMPI_RC_ERR_FAILED, > JG> + "Could not get objectpath from instance"); > JG> + goto out; > JG> + } > JG> + > JG> + *dest = NULL; > > Why set it to NULL and then set it to the instance right after this? > I think I was going with "not sure what *dest becomes if NewInstance" fails, and so I figured better safe than sorry. I'd rather have it NULL than undefined. > JG> + *dest = CMNewInstance(broker, ref, &s); > JG> + > JG> + out: > JG> + return s; > JG> +} > > What about all the properties of the instance? This gets a new > instance structure, yes, but all it has is an object path. Maybe that > is all you need at the moment, but I don't think this does what other > consumers of the library would think by the name :) > > It should be easy to loop through all the properties and copy them > over. It will look similar to the array copy/filter code in Kaitlin's > libcmpiutil CO patch. > I'm pleading CIM ignorance on this one. I thought the ObjectPath encompassed the properties, and thought that my testing showed it happening (I don't manually move the JobState over but it is est), but I could have been wrong. -- -Jay From danms at us.ibm.com Fri Feb 1 17:14:51 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 01 Feb 2008 09:14:51 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] [CU] Improve std_indication's raise functionality In-Reply-To: <8669586635358e4858e5.1201882998@wulfgar> (Jay Gagnon's message of "Fri, 01 Feb 2008 11:23:18 -0500") References: <8669586635358e4858e5.1201882998@wulfgar> Message-ID: <87k5losino.fsf@caffeine.beaverton.ibm.com> JG> # HG changeset patch JG> # User Jay Gagnon JG> # Date 1201882988 18000 JG> # Node ID 8669586635358e4858e56fe2dec8587af784cd47 JG> # Parent ec7428b062f45db8eef730c5398d061d8731ce60 JG> [CU] Improve std_indication's raise functionality This one looks okay to me, and I think I can apply it independently of the other, correct? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Fri Feb 1 17:21:04 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 01 Feb 2008 09:21:04 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider In-Reply-To: References: Message-ID: <47A35500.8020403@linux.vnet.ibm.com> Jay Gagnon wrote: > # HG changeset patch > # User Jay Gagnon > # Date 1201882409 18000 > # Node ID a17039d1b29cd5275ecd126782bb1757a415a0c0 > # Parent 6d86529bbdce9eb68b26a7fc5339fd66a1f2fdd2 > Add calls into VSMigrationService to utilize new MigrationIndication provider. > > static void migrate_job_set_state(struct migration_job *job, > uint16_t state, > const char *status) > { > CMPIInstance *inst; > + CMPIInstance *prev_inst; > + CMPIInstance *ind; > + bool rc; > CMPIStatus s; > CMPIObjectPath *op; > > @@ -297,12 +319,50 @@ static void migrate_job_set_state(struct > CMSetProperty(inst, "Status", > (CMPIValue *)status, CMPI_chars); > > + CU_DEBUG("Creating indication."); > + /* Prefix needs to be dynamic */ > + ind = get_typed_instance(_BROKER, > + "Xen", > + "ComputerSystemMigrationIndication", > + job->ref_ns); > + /* Prefix needs to be dynamic */ I'm showing my indication ignorance here.. Would it be possible to get the prefix from the ref in migrate_do? You could then add a prefix value to the migration job struct. You already do something similar with the namespace. However, I'm not entirely sure the ref has the proper prefix you need. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Fri Feb 1 19:32:13 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 01 Feb 2008 11:32:13 -0800 Subject: [Libvirt-cim] [PATCH] Fix Virt_Device crash due to improper virConnectClose() Message-ID: <5d554b65865ebaabf526.1201894333@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1201894237 28800 # Node ID 5d554b65865ebaabf5261f7e8557dd7a40bf6175 # Parent 6c3c30bf8e026c9b3609195c55766c6c3f757b99 Fix Virt_Device crash due to improper virConnectClose() This was identified as being necessary in the first round, but it actually breaks things. The conn here is not new, it's just the one from the current dom pointer, which means that the first time we close it, all subsequent devices break (or crash) Signed-off-by: Dan Smith diff -r 6c3c30bf8e02 -r 5d554b65865e src/Virt_Device.c --- a/src/Virt_Device.c Fri Feb 01 11:17:15 2008 +0100 +++ b/src/Virt_Device.c Fri Feb 01 11:30:37 2008 -0800 @@ -224,7 +224,6 @@ static int device_set_systemname(CMPIIns CMSetProperty(instance, "SystemCreationClassName", (CMPIValue *)sccn, CMPI_chars); free(sccn); - virConnectClose(conn); } return 1; From danms at us.ibm.com Fri Feb 1 20:06:40 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 01 Feb 2008 12:06:40 -0800 Subject: [Libvirt-cim] [PATCH] Fix stale issue with threads in Virt_HostedDependency association Message-ID: <84ee0633c377768529c4.1201896400@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1201896389 28800 # Node ID 84ee0633c377768529c41463f0bf95b1c88c42e2 # Parent 5d554b65865ebaabf5261f7e8557dd7a40bf6175 Fix stale issue with threads in Virt_HostedDependency association This crept in when we converted to lists of association classes with std_assoc. It's a trivial fix, but it has to be done do all of our associations, barring any that are correct already. Signed-off-by: Dan Smith diff -r 5d554b65865e -r 84ee0633c377 src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Fri Feb 01 11:30:37 2008 -0800 +++ b/src/Virt_HostedDependency.c Fri Feb 01 12:06:29 2008 -0800 @@ -84,19 +84,19 @@ static CMPIStatus host_to_vs(const CMPIO LIBVIRT_CIM_DEFAULT_MAKEREF() -char* antecedent[] = { +static char* antecedent[] = { "Xen_ComputerSystem", "KVM_ComputerSystem", NULL }; -char* dependent[] = { +static char* dependent[] = { "Xen_HostSystem", "KVM_HostSystem", NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_HostedDependency", "KVM_HostedDependency", NULL From danms at us.ibm.com Fri Feb 1 20:13:29 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 01 Feb 2008 12:13:29 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: <47A352B4.4030909@linux.vnet.ibm.com> (Jay Gagnon's message of "Fri, 01 Feb 2008 12:11:16 -0500") References: <87odb0sjcq.fsf@caffeine.beaverton.ibm.com> <47A352B4.4030909@linux.vnet.ibm.com> Message-ID: <87ejbwsady.fsf@caffeine.beaverton.ibm.com> JG> I'm pleading CIM ignorance on this one. I thought the ObjectPath JG> encompassed the properties, and thought that my testing showed it JG> happening (I don't manually move the JobState over but it is est), JG> but I could have been wrong. You're only half ignorant here :) The ObjectPath has the key properties, but not the rest. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Fri Feb 1 20:46:04 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 01 Feb 2008 12:46:04 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider In-Reply-To: (Jay Gagnon's message of "Fri, 01 Feb 2008 11:19:05 -0500") References: Message-ID: <878x24s8vn.fsf@caffeine.beaverton.ibm.com> JG> +static bool raise_indication(const CMPIContext *context, JG> + const char *base_type, JG> + const char *ns, JG> + const CMPIInstance *ind) JG> +{ JG> + char *type; JG> + CMPIStatus s; JG> + JG> + /* Seems like this shouldn't be hardcoded. */ JG> + type = get_typed_class("Xen", base_type); JG> + JG> + s = stdi_raise_indication(_BROKER, context, type, ns, ind); JG> + JG> + free(type); JG> + JG> + return s.rc == CMPI_RC_OK; JG> +} So, this actually brings up an interesting point which I think we glazed over when we put the migration provider in the first time. I left the migration job classname as Virt_MigrationJob, thus not having a specific platform prefix on it. I did that because it seemed to me that clients could potentially use the job as an entry point, needing to see what guests were leaving a host at any point, and then following the ref's to platform-specific details. However, as Jay points out, I think that the indication should be typed per-platform as usual. So, should we type the job to match, since we'll need to persist the information for typing the indication as well? Heidi, maybe you have some input here? JG> @@ -297,12 +319,50 @@ static void migrate_job_set_state(struct JG> CMSetProperty(inst, "Status", JG> (CMPIValue *)status, CMPI_chars); JG> + CU_DEBUG("Creating indication."); JG> + /* Prefix needs to be dynamic */ JG> + ind = get_typed_instance(_BROKER, JG> + "Xen", JG> + "ComputerSystemMigrationIndication", JG> + job->ref_ns); JG> + /* Prefix needs to be dynamic */ JG> + if (ind == NULL) { JG> + CU_DEBUG("Failed to create ind, type '%s:%s_%s'", JG> + job->ref_ns, JG> + "Xen", JG> + "ComputerSystemMigrationIndication"); JG> + } JG> + JG> + /* Need to copy job inst before attaching as PreviousInstance because JG> + otherwise the changes we are about to make to job inst are made JG> + to PreviousInstance as well. */ JG> + s = cu_dup_instance(_BROKER, inst, &prev_inst); I didn't quite understand from the other patch, but I don't think this is what you want to do. You create an instance with a set of properties set (like CCN) with the get_typed_instance() call, but then just overwrite the ObjectPath of it here. I think the semantics of the cu_dup_instance() call should be that it creates you a new instance. Something like this maybe: new_inst = cu_dup_instance(_BROKER, src_inst, &s); JG> + if (s.rc != CMPI_RC_OK || prev_inst == NULL) { JG> + CU_DEBUG("dup_instance failed (%i:%s)", s.rc, s.msg); JG> + return; JG> + } JG> + JG> + CU_DEBUG("Setting PreviousInstance"); JG> + CMSetProperty(ind, "PreviousInstance", JG> + (CMPIValue *)&prev_inst, CMPI_instance); JG> + JG> CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status); JG> s = CBModifyInstance(_BROKER, job->context, op, inst, NULL); JG> if (s.rc != CMPI_RC_OK) JG> CU_DEBUG("Failed to update job instance: %s", JG> CMGetCharPtr(s.msg)); JG> + JG> + CU_DEBUG("Setting SourceInstance"); JG> + CMSetProperty(ind, "SourceInstance", JG> + (CMPIValue *)&inst, CMPI_instance); JG> + JG> + rc = raise_indication(job->context, JG> + "ComputerSystemMigrationIndication", JG> + job->ref_ns, JG> + ind); JG> + if (!rc) JG> + CU_DEBUG("Failed to raise indication"); JG> } These changes make the migrate_job_set_state() function quite a bit longer. Can we break out these out into a separate function? If it just returns an indication instance, then maybe something like this could work: ind = prepare_indication(job_inst); /* Existing job_inst update code */ raise_indication(ind, job_inst); The prepare call would dup the old instance and create the indication instance, and the raise call would add the updated version and do the actual raise. What do you think? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Fri Feb 1 20:52:32 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 01 Feb 2008 12:52:32 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] ComputerSystemMigrationIndication In-Reply-To: <6d86529bbdce9eb68b26.1201882746@wulfgar> (Jay Gagnon's message of "Fri, 01 Feb 2008 11:19:06 -0500") References: <6d86529bbdce9eb68b26.1201882746@wulfgar> Message-ID: <874pcss8kv.fsf@caffeine.beaverton.ibm.com> JG> + * Dan Smith While I'd love to take credit, I think you better fix this. You also need to add your name to CSI, as it resembles less of my original work than yours, I'm sure. Otherwise the provider looks good (not much to complain about). The default_raise() idea was obviously killer :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Fri Feb 1 22:28:20 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 01 Feb 2008 14:28:20 -0800 Subject: [Libvirt-cim] [PATCH] Set additional attribute values in Virt_ComputerSystem.c Message-ID: <3b1671a9934018891019.1201904900@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1201904890 28800 # Node ID 3b1671a993401889101969b3f5e3a25e45d13400 # Parent 19bd4c5ede1512bcd411a98b3c09acebc506b38e Set additional attribute values in Virt_ComputerSystem.c OtherIdentifyingInfo property and IdentifyingDescriptions. Modify instance_from_dom() to take a prefix parameter. Signed-off-by: Kaitlin Rupert diff -r 19bd4c5ede15 -r 3b1671a99340 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Fri Feb 01 10:55:58 2008 -0800 +++ b/src/Virt_ComputerSystem.c Fri Feb 01 14:28:10 2008 -0800 @@ -71,7 +71,9 @@ static int set_name_from_dom(virDomainPt } /* Set the "UUID" property of an instance from a domain */ -static int set_uuid_from_dom(virDomainPtr dom, CMPIInstance *instance) +static int set_uuid_from_dom(virDomainPtr dom, + CMPIInstance *instance, + char **out_uuid) { char uuid[VIR_UUID_STRING_BUFLEN]; int ret; @@ -82,6 +84,8 @@ static int set_uuid_from_dom(virDomainPt CMSetProperty(instance, "UUID", (CMPIValue *)uuid, CMPI_chars); + + *out_uuid = strdup(uuid); return 1; } @@ -239,17 +243,91 @@ static int set_creation_class(CMPIInstan return 1; } +static int set_other_id_info(const CMPIBroker *broker, + char *uuid, + const char *prefix, + CMPIInstance *instance) +{ + CMPIStatus s; + CMPIArray *id_info; + char *info[3]; + int count = 3; + char *type = "Virtual System"; + char *model; + int i; + + id_info = CMNewArray(broker, + count, + CMPI_string, + &s); + + if (s.rc != CMPI_RC_OK) + return 0; + + if (asprintf(&model, "%s%s", prefix, type) == 1) + return 0; + + info[0] = uuid; + info[1] = model; + info[2] = type; + + for (i = 0; i < count; i++) { + CMPIString *tmp = CMNewString(broker, info[i], NULL); + CMSetArrayElementAt(id_info, i, + &tmp, + CMPI_string); + } + + CMSetProperty(instance, "OtherIdentifyingInfo", + &id_info, CMPI_stringA); + + return 1; +} + +static int set_id_desc(const CMPIBroker *broker, + CMPIInstance *instance) +{ + CMPIStatus s; + CMPIArray *id_desc; + char *desc[3] = {"Type", "Model", "UUID"}; + int count = 3; + int i; + + id_desc = CMNewArray(broker, + count, + CMPI_string, + &s); + + if (s.rc != CMPI_RC_OK) + return 0; + + for (i = 0; i < count; i++) { + CMPIString *tmp = CMNewString(broker, desc[i], NULL); + CMSetArrayElementAt(id_desc, i, + &tmp, + CMPI_string); + } + + CMSetProperty(instance, "IdentifyingDescriptions", + (CMPIValue *)&id_desc, CMPI_stringA); + + return 1; +} + /* Populate an instance with information from a domain */ static int instance_from_dom(const CMPIBroker *broker, virDomainPtr dom, + const char *prefix, CMPIInstance *instance) { + char *uuid; + if (!set_name_from_dom(dom, instance)) { /* Print trace error */ return 0; } - if (!set_uuid_from_dom(dom, instance)) { + if (!set_uuid_from_dom(dom, instance, &uuid)) { /* Print trace error */ return 0; } @@ -269,7 +347,20 @@ static int instance_from_dom(const CMPIB return 0; } + if (!set_other_id_info(broker, uuid, prefix, instance)) { + /* Print trace error */ + free(uuid); + return 0; + } + + if (!set_id_desc(broker, instance)) { + /* Print trace error */ + return 0; + } + /* More attributes here, of course */ + + free(uuid); return 1; } @@ -294,7 +385,10 @@ CMPIInstance *instance_from_name(const C if (instance == NULL) goto out; - if (!instance_from_dom(broker, dom, instance)) + if (!instance_from_dom(broker, + dom, + pfx_from_conn(conn), + instance)) instance = NULL; out: @@ -327,7 +421,10 @@ int enum_domains(const CMPIBroker *broke if (inst == NULL) goto end; - if (instance_from_dom(broker, list[i], inst)) + if (instance_from_dom(broker, + list[i], + pfx_from_conn(conn), + inst)) inst_list_add(instlist, inst); end: From kaitlin at linux.vnet.ibm.com Sat Feb 2 19:06:50 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Sat, 02 Feb 2008 11:06:50 -0800 Subject: [Libvirt-cim] [PATCH] Fix Virt_Device crash due to improper virConnectClose() In-Reply-To: <5d554b65865ebaabf526.1201894333@caffeine.beaverton.ibm.com> References: <5d554b65865ebaabf526.1201894333@caffeine.beaverton.ibm.com> Message-ID: <47A4BF4A.90302@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1201894237 28800 > # Node ID 5d554b65865ebaabf5261f7e8557dd7a40bf6175 > # Parent 6c3c30bf8e026c9b3609195c55766c6c3f757b99 > Fix Virt_Device crash due to improper virConnectClose() > I tested this out, and it worked for me. No crash after applying this patch. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Sat Feb 2 19:24:50 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Sat, 02 Feb 2008 11:24:50 -0800 Subject: [Libvirt-cim] [PATCH] Fix stale issue with threads in Virt_HostedDependency association In-Reply-To: <84ee0633c377768529c4.1201896400@caffeine.beaverton.ibm.com> References: <84ee0633c377768529c4.1201896400@caffeine.beaverton.ibm.com> Message-ID: <47A4C382.7020704@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1201896389 28800 > # Node ID 84ee0633c377768529c41463f0bf95b1c88c42e2 > # Parent 5d554b65865ebaabf5261f7e8557dd7a40bf6175 > Fix stale issue with threads in Virt_HostedDependency association > > This crept in when we converted to lists of association classes with > std_assoc. It's a trivial fix, but it has to be done do all of our > associations, barring any that are correct already. > Tested this patch using forceProviderProcesses=false with Pegasus. The handler for HostedDependency no longer causes a problem. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From yunguol at cn.ibm.com Sat Feb 2 20:00:48 2008 From: yunguol at cn.ibm.com (Guo Lian Yun) Date: Sun, 3 Feb 2008 04:00:48 +0800 Subject: [Libvirt-cim] Guo Lian Yun is out of the office. Message-ID: I will be out of the office starting 2008-02-03 and will not return until 2008-02-15. I will respond to your message when I return. -------------- next part -------------- An HTML attachment was scrubbed... URL: From heidieck at linux.vnet.ibm.com Mon Feb 4 09:03:27 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 04 Feb 2008 10:03:27 +0100 Subject: [Libvirt-cim] [PATCH] (2) Remove the embedded object parsing pieces from VirtualSystemManagmentService In-Reply-To: <47A33E72.6020600@linux.vnet.ibm.com> References: <47A2E73C.3030201@linux.vnet.ibm.com> <47A33E72.6020600@linux.vnet.ibm.com> Message-ID: <47A6D4DF.6090903@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Heidi Eckhart wrote: >> Kaitlin Rupert wrote: >>> # HG changeset patch >>> # User Kaitlin Rupert >>> # Date 1201801531 28800 >>> # Node ID e27208a0ac3f69df3f704ecd32fdfdc78b79dc7c >>> # Parent b8d69e734306e618b4efb53e23c17ffdd8bab128 >>> (2) Remove the embedded object parsing pieces from >>> VirtualSystemManagmentService. >>> >>> Updates from set 1 to set 2: >>> Removed unsused sys_op from define_system() >>> Removed unused list from update_resource_setting() >>> Changed CMPIArray **out_arr to **ret_arr in rasd_refs_to_insts() >>> >>> >> Opps, sorry, I'm sure I was not very clear on what I meant with the >> out_arr. I thought something like this might look better in the code >> ... instead of submitting *out_arr submitting a ret_arr (which itself >> becomes the content of *out_arr at the end). > > Oh, yes - I did misunderstand. Thanks for the clarification. =) > > However, I'm not sure what benefit this gives us. I think I'm missing > something - does this change prevent an error condition of some sort? No, absolutely not. Its only for common look and feel of the code. I see a lot of functions, where an incoming " **param" is handled internally as " *_param" which is set as "*param=_param" at the end. So I thought this is some kind of common for the providers. That's all. > > Thanks! > -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Mon Feb 4 09:46:20 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 04 Feb 2008 10:46:20 +0100 Subject: [Libvirt-cim] [PATCH] RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults In-Reply-To: <47A3436A.1090008@linux.vnet.ibm.com> References: <6b1bf8231d82f51f25ac.1201864861@localhost.localdomain> <47A3436A.1090008@linux.vnet.ibm.com> Message-ID: <47A6DEEC.8000106@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Heidi Eckhart wrote: >> diff -r cb0e8b858f42 -r 6b1bf8231d82 >> src/Virt_ResourcePoolConfigurationService.c >> --- a/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 >> 11:17:15 2008 +0100 >> +++ b/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 >> 12:20:46 2008 +0100 >> @@ -100,15 +100,20 @@ CMPIStatus rpcs_instance(const CMPIObjec >> { >> CMPIInstance *inst; >> CMPIInstance *host; >> - CMPIStatus s; >> + CMPIStatus s = {CMPI_RC_OK, NULL}; >> CMPIData prop; >> + virConnectPtr conn = NULL; >> + >> + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); >> + if (conn == NULL) >> + goto out; > > I would also set the status here. This would mean we don't need to > check for a NULL instance everywhere rpcs_instance() is called. Well, this function is used for enumeration and get requests. Setting an error code for conn==NULL would break the CIM model for enumeration request. An enumeration against CIM_RPCS on a Xen system with no KVM, would get the error for KVM and valid instances for Xen. But this KVM error would then cause the CIMOM to skip all returned and valid Xen instances. In the case of a get, setting this error code indeed is required. But the idea behind your comment is good. I will reorganize the functions a bit and will resend the patch. > > Virt_HostedService calls rpcs_instance(), but currently doesn't check > for a NULL. So if don't set the status here, HostedService will need > to be updated to check for a NULL instance. > Thanks for this hint :). I will fix this. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Mon Feb 4 12:25:50 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 04 Feb 2008 14:25:50 +0200 Subject: [Libvirt-cim] [PATCH 0 of 4] #2 - RPCS and RPCC ignores supported hypervisor type and wrong object path, adopt changes to HS Message-ID: This patch set is now the combination of the one patch against RPCS and the two patches against RPCC, I sent out on friday. The reason to combine these three patches in one patch set is, that both provider - RPCS and RPCC - look very similar now. This brought me to the idea, that it is possible to also define a common interface for instances providers - as this is already done for associations -, where the common functions could do a main part of the error handling (which is currently done again and again in each single provider itself). In addition patch 4 updates HS (thanks to Kaitlin) with the new interface of RPCS. From heidieck at linux.vnet.ibm.com Mon Feb 4 12:25:51 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 04 Feb 2008 14:25:51 +0200 Subject: [Libvirt-cim] [PATCH 1 of 4] RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1202131336 -3600 # Node ID f3ea51dea6f805fa354d173f38a9c5037e4785a3 # Parent 6c3c30bf8e026c9b3609195c55766c6c3f757b99 RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults wbemein http://localhost/root/virt:CIM_ResourcePoolConfigurationService on a KVM system with no Xen segfaults. The same happens to wbemgi 'http://localhost:5988/root/virt:Xen_ResourcePoolConfigurationService.SystemCreationClassName="Xen_HostSystem",SystemName="localhost.localdomain",CreationClassName="Xen_ResourcePoolConfigurationService",Name="RPCS"' This patch also makes RPCS aware of the supported hypervisor type. Now only instances of the machine's supported hypervisor are returned. This approach is used all over the libvirt-cim providers, but was broken here. Signed-off-by: Heidi Eckhart diff -r 6c3c30bf8e02 -r f3ea51dea6f8 src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 11:17:15 2008 +0100 +++ b/src/Virt_ResourcePoolConfigurationService.c Mon Feb 04 14:22:16 2008 +0100 @@ -94,21 +94,28 @@ DEFAULT_EQ(); DEFAULT_EQ(); DEFAULT_INST_CLEANUP(); -CMPIStatus rpcs_instance(const CMPIObjectPath *reference, - CMPIInstance **_inst, - const CMPIBroker *broker) +CMPIStatus get_rpcs(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool getInstance) { CMPIInstance *inst; - CMPIInstance *host; - CMPIStatus s; - CMPIData prop; - - s = get_host_cs(broker, reference, &host); - if (s.rc != CMPI_RC_OK) - goto out; + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + const char *name = NULL; + const char *ccname = NULL; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + if (getInstance) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } inst = get_typed_instance(broker, - CLASSNAME(reference), + pfx_from_conn(conn), "ResourcePoolConfigurationService", NAMESPACE(reference)); if (inst == NULL) { @@ -119,32 +126,57 @@ CMPIStatus rpcs_instance(const CMPIObjec goto out; } - CMSetProperty(inst, "Name", - (CMPIValue *)"RPCS", CMPI_chars); - - prop = CMGetProperty(host, "CreationClassName", &s); + s = get_host_system_properties(&name, + &ccname, + reference, + broker); if (s.rc != CMPI_RC_OK) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, - "Unable to get CreationClassName from HostSystem"); - goto out; - } + "Unable to get host attributes"); + goto out; + } + + CMSetProperty(inst, "Name", + (CMPIValue *)"RPCS", CMPI_chars); + + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); CMSetProperty(inst, "SystemCreationClassName", - (CMPIValue *)&prop.value.string, CMPI_string); - - prop = CMGetProperty(host, "Name", NULL); - if (s.rc != CMPI_RC_OK) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Unable to get Name from HostSystem"); - goto out; - } - - CMSetProperty(inst, "SystemName", - (CMPIValue *)&prop.value.string, CMPI_string); + (CMPIValue *)ccname, CMPI_chars); + + if (getInstance) { + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } *_inst = inst; + + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_rpcs(const CMPIResult *results, + const CMPIObjectPath *reference, + bool names_only, + bool getInstance) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_rpcs(reference, &inst, _BROKER, getInstance); + if (s.rc != CMPI_RC_OK || inst == NULL) + goto out; + + if (names_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + out: return s; } @@ -155,24 +187,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - CMPIInstance *inst; - CMPIStatus s; - const char *prop = NULL; - - s = rpcs_instance(reference, &inst, _BROKER); - if (s.rc != CMPI_RC_OK) - return s; - - prop = cu_compare_ref(reference, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } else { - CMReturnInstance(results, inst); - } - - return s; + return return_rpcs(results, reference, false, true); } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -180,14 +195,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - CMPIInstance *inst; - CMPIStatus s; - - s = rpcs_instance(reference, &inst, _BROKER); - if (s.rc == CMPI_RC_OK) - cu_return_instance_name(results, inst); - - return s; + return return_rpcs(results, reference, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -196,15 +204,7 @@ static CMPIStatus EnumInstances(CMPIInst const CMPIObjectPath *reference, const char **properties) { - - CMPIInstance *inst; - CMPIStatus s; - - s = rpcs_instance(reference, &inst, _BROKER); - if (s.rc == CMPI_RC_OK) - CMReturnInstance(results, inst); - - return s; + return return_rpcs(results, reference, false, false); } diff -r 6c3c30bf8e02 -r f3ea51dea6f8 src/Virt_ResourcePoolConfigurationService.h --- a/src/Virt_ResourcePoolConfigurationService.h Fri Feb 01 11:17:15 2008 +0100 +++ b/src/Virt_ResourcePoolConfigurationService.h Mon Feb 04 14:22:16 2008 +0100 @@ -19,6 +19,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -CMPIStatus rpcs_instance(const CMPIObjectPath *reference, - CMPIInstance **_inst, - const CMPIBroker *broker); +CMPIStatus get_rpcs(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool getInstance); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From heidieck at linux.vnet.ibm.com Mon Feb 4 12:25:52 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 04 Feb 2008 14:25:52 +0200 Subject: [Libvirt-cim] [PATCH 2 of 4] RPCC: returns instances of Xen on a KVM only system In-Reply-To: Message-ID: <4f877945eeba7e1c6a69.1202131552@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202131344 -3600 # Node ID 4f877945eeba7e1c6a690150057b0221a882d002 # Parent f3ea51dea6f805fa354d173f38a9c5037e4785a3 RPCC: returns instances of Xen on a KVM only system This breaks the approach that is used all over libvirt-cim providers, where only instances of the currently supported hypervisor type are returned. Signed-off-by: Heidi Eckhart diff -r f3ea51dea6f8 -r 4f877945eeba src/Virt_ResourcePoolConfigurationCapabilities.c --- a/src/Virt_ResourcePoolConfigurationCapabilities.c Mon Feb 04 14:22:16 2008 +0100 +++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Mon Feb 04 14:22:24 2008 +0100 @@ -47,45 +47,63 @@ DEFAULT_EQ(); DEFAULT_EQ(); DEFAULT_INST_CLEANUP(); -static CMPIStatus get_rpc_cap(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **_inst) +static CMPIStatus get_rpc_cap(const CMPIObjectPath *reference, + CMPIInstance **_inst, + bool getInstance) { - CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn = NULL; - inst = get_typed_instance(broker, - CLASSNAME(reference), + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); + if (conn == NULL) + goto out; + + inst = get_typed_instance(_BROKER, + pfx_from_conn(conn), "ResourcePoolConfigurationCapabilities", NAMESPACE(reference)); if (inst == NULL) - return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL}; + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Can't create ResourcePoolConfigurationCapabilities instance"); CMSetProperty(inst, "InstanceID", (CMPIValue *)"RPCC", CMPI_chars); /* No method currently supported */ + if (getInstance) { + s = cu_validate_ref(_BROKER, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + *_inst = inst; - return (CMPIStatus){CMPI_RC_OK, NULL}; + out: + virConnectClose(conn); + + return s; } static CMPIStatus return_rpc_cap(const CMPIObjectPath *reference, const CMPIResult *results, - bool names_only) + bool names_only, + bool getInstance) { CMPIStatus s; - CMPIInstance *inst; + CMPIInstance *inst = NULL; - s = get_rpc_cap(_BROKER, reference, &inst); - if (s.rc != CMPI_RC_OK) + s = get_rpc_cap(reference, &inst, getInstance); + if (s.rc != CMPI_RC_OK || inst == NULL) goto out; - + if (names_only) cu_return_instance_name(results, inst); else CMReturnInstance(results, inst); - + out: return s; } @@ -95,7 +113,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_rpc_cap(reference, results, 1); + return return_rpc_cap(reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -105,7 +123,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_rpc_cap(reference, results, 0); + return return_rpc_cap(reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -114,7 +132,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - return return_rpc_cap(reference, results, 0); + return return_rpc_cap(reference, results, false, true); } From heidieck at linux.vnet.ibm.com Mon Feb 4 12:25:53 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 04 Feb 2008 14:25:53 +0200 Subject: [Libvirt-cim] [PATCH 3 of 4] RPCC: getInstance does not take care of client given object path In-Reply-To: Message-ID: <971b870679bd5c11fb87.1202131553@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202131345 -3600 # Node ID 971b870679bd5c11fb872c27b09150f612040eb9 # Parent 4f877945eeba7e1c6a690150057b0221a882d002 RPCC: getInstance does not take care of client given object path wbemgi 'http://localhost:5988/root/virt:KVM_ResourcePoolConfigurationCapabilities.InstanceID="wrong"' returns the instance instead of NOT_FOUND. Signed-off-by: Heidi Eckhart diff -r 4f877945eeba -r 971b870679bd src/Virt_ResourcePoolConfigurationCapabilities.c --- a/src/Virt_ResourcePoolConfigurationCapabilities.c Mon Feb 04 14:22:24 2008 +0100 +++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Mon Feb 04 14:22:25 2008 +0100 @@ -56,8 +56,13 @@ static CMPIStatus get_rpc_cap(const CMPI virConnectPtr conn = NULL; conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); - if (conn == NULL) + if (conn == NULL) { + if (getInstance) + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); goto out; + } inst = get_typed_instance(_BROKER, pfx_from_conn(conn), From heidieck at linux.vnet.ibm.com Mon Feb 4 12:25:54 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 04 Feb 2008 14:25:54 +0200 Subject: [Libvirt-cim] [PATCH 4 of 4] HS: adopt change in RPCS interface (get_rpcs_instance) In-Reply-To: Message-ID: <11ede99c6a8e94c93087.1202131554@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202131346 -3600 # Node ID 11ede99c6a8e94c930870f840af6d1a795bb6b63 # Parent 971b870679bd5c11fb872c27b09150f612040eb9 HS: adopt change in RPCS interface (get_rpcs_instance) Signed-off-by: Heidi Eckhart diff -r 971b870679bd -r 11ede99c6a8e src/Virt_HostedService.c --- a/src/Virt_HostedService.c Mon Feb 04 14:22:25 2008 +0100 +++ b/src/Virt_HostedService.c Mon Feb 04 14:22:26 2008 +0100 @@ -49,7 +49,7 @@ static CMPIStatus validate_service_ref(c if (STREQC(classname, "VirtualSystemManagementService")) { s = get_vsms(ref, &inst, _BROKER); } else if (STREQC(classname, "ResourcePoolConfigurationService")) { - s = rpcs_instance(ref, &inst, _BROKER); + s = get_rpcs(ref, &inst, _BROKER, true); } else if (STREQC(classname, "VirtualSystemMigrationService")) { s = get_migration_service(ref, &inst, _BROKER); } @@ -105,7 +105,7 @@ static CMPIStatus host_to_service(const if (s.rc != CMPI_RC_OK) return s; - s = rpcs_instance(ref, &inst, _BROKER); + s = get_rpcs(ref, &inst, _BROKER, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) From kaitlin at linux.vnet.ibm.com Mon Feb 4 14:37:12 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 04 Feb 2008 06:37:12 -0800 Subject: [Libvirt-cim] [PATCH 0 of 4] #2 - RPCS and RPCC ignores supported hypervisor type and wrong object path, adopt changes to HS In-Reply-To: References: Message-ID: <47A72318.9000802@linux.vnet.ibm.com> Heidi Eckhart wrote: > This patch set is now the combination of the one patch against RPCS and the two patches against RPCC, I sent out on friday. The reason to combine these three patches in one patch set is, that both provider - RPCS and RPCC - look very similar now. This brought me to the idea, that it is possible to also define a common interface for instances providers - as this is already done for associations -, where the common functions could do a main part of the error handling (which is currently done again and again in each single provider itself). > In addition patch 4 updates HS (thanks to Kaitlin) with the new interface of RPCS. > I like the new interface of RPCS - good idea. =) +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From grendel at linux.vnet.ibm.com Mon Feb 4 15:02:50 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 04 Feb 2008 10:02:50 -0500 Subject: [Libvirt-cim] [PATCH 2 of 2] [CU] Improve std_indication's raise functionality In-Reply-To: <87k5losino.fsf@caffeine.beaverton.ibm.com> References: <8669586635358e4858e5.1201882998@wulfgar> <87k5losino.fsf@caffeine.beaverton.ibm.com> Message-ID: <47A7291A.6030405@linux.vnet.ibm.com> Dan Smith wrote: > JG> # HG changeset patch > JG> # User Jay Gagnon > JG> # Date 1201882988 18000 > JG> # Node ID 8669586635358e4858e56fe2dec8587af784cd47 > JG> # Parent ec7428b062f45db8eef730c5398d061d8731ce60 > JG> [CU] Improve std_indication's raise functionality > > This one looks okay to me, and I think I can apply it independently of > the other, correct? > > > ------------------------------------------------------------------------ > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim Yea, this should be able to go in independently. Migration is the only indication that uses raise, so we won't be pulling the rug out from under anybody. -- -Jay From grendel at linux.vnet.ibm.com Mon Feb 4 15:37:45 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 04 Feb 2008 10:37:45 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider In-Reply-To: <878x24s8vn.fsf@caffeine.beaverton.ibm.com> References: <878x24s8vn.fsf@caffeine.beaverton.ibm.com> Message-ID: <47A73149.8070703@linux.vnet.ibm.com> Dan Smith wrote: > However, as Jay points out, I think that the indication should be > typed per-platform as usual. So, should we type the job to match, > since we'll need to persist the information for typing the indication > as well? > > I'm no Heidi, but it seems like we should be prefixing this. We prefix every other class we create, and if somebody doesn't want to deal with the Xen/KVM distinction they are welcome to subscribe to/filter on/whatever they want the CIM super class and get both, right? As to where the prefix comes from, I think Kaitlin was on to something with the ref that comes in from migrate_do, although I think it can be even easier than she said. We don't actually need to attach the prefix to the migration_job structure; we're already attaching the classname, so all we need is a call to class_prefix_name and we've got a prefix. > > JG> @@ -297,12 +319,50 @@ static void migrate_job_set_state(struct > JG> CMSetProperty(inst, "Status", > JG> (CMPIValue *)status, CMPI_chars); > > JG> + CU_DEBUG("Creating indication."); > JG> + /* Prefix needs to be dynamic */ > JG> + ind = get_typed_instance(_BROKER, > JG> + "Xen", > JG> + "ComputerSystemMigrationIndication", > JG> + job->ref_ns); > JG> + /* Prefix needs to be dynamic */ > JG> + if (ind == NULL) { > JG> + CU_DEBUG("Failed to create ind, type '%s:%s_%s'", > JG> + job->ref_ns, > JG> + "Xen", > JG> + "ComputerSystemMigrationIndication"); > JG> + } > JG> + > JG> + /* Need to copy job inst before attaching as PreviousInstance because > JG> + otherwise the changes we are about to make to job inst are made > JG> + to PreviousInstance as well. */ > JG> + s = cu_dup_instance(_BROKER, inst, &prev_inst); > > I didn't quite understand from the other patch, but I don't think this > is what you want to do. You create an instance with a set of > properties set (like CCN) with the get_typed_instance() call, but then > just overwrite the ObjectPath of it here. > > I think the semantics of the cu_dup_instance() call should be that it > creates you a new instance. Something like this maybe: > > new_inst = cu_dup_instance(_BROKER, src_inst, &s); > As was already brought to light by my first run at cu_dup_instance, I get easily turned around when I start working with actual instances and such, so I'd like to make sure I follow this. Let's say I fix up cu_dup_instance so that it creates a new instance using the existing instances ObjectPath, then copies all the properties correctly. Then I wouldn't have to call get_typed_instance in the first place, because everything that it does is already taken care of, right? > JG> + if (s.rc != CMPI_RC_OK || prev_inst == NULL) { > JG> + CU_DEBUG("dup_instance failed (%i:%s)", s.rc, s.msg); > JG> + return; > JG> + } > JG> + > JG> + CU_DEBUG("Setting PreviousInstance"); > JG> + CMSetProperty(ind, "PreviousInstance", > JG> + (CMPIValue *)&prev_inst, CMPI_instance); > JG> + > JG> CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status); > > JG> s = CBModifyInstance(_BROKER, job->context, op, inst, NULL); > JG> if (s.rc != CMPI_RC_OK) > JG> CU_DEBUG("Failed to update job instance: %s", > JG> CMGetCharPtr(s.msg)); > JG> + > JG> + CU_DEBUG("Setting SourceInstance"); > JG> + CMSetProperty(ind, "SourceInstance", > JG> + (CMPIValue *)&inst, CMPI_instance); > JG> + > JG> + rc = raise_indication(job->context, > JG> + "ComputerSystemMigrationIndication", > JG> + job->ref_ns, > JG> + ind); > JG> + if (!rc) > JG> + CU_DEBUG("Failed to raise indication"); > JG> } > > These changes make the migrate_job_set_state() function quite a bit > longer. Can we break out these out into a separate function? If it > just returns an indication instance, then maybe something like this > could work: > > ind = prepare_indication(job_inst); > > /* Existing job_inst update code */ > > raise_indication(ind, job_inst); > > The prepare call would dup the old instance and create the indication > instance, and the raise call would add the updated version and do the > actual raise. What do you think? > Sure that's fine. I didn't think too much about code structure when I was in "wait is that gonna work?" mode; should have cleaned up a little more before I sent it out. -- -Jay From grendel at linux.vnet.ibm.com Mon Feb 4 15:39:22 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 04 Feb 2008 10:39:22 -0500 Subject: [Libvirt-cim] [PATCH 2 of 2] ComputerSystemMigrationIndication In-Reply-To: <874pcss8kv.fsf@caffeine.beaverton.ibm.com> References: <6d86529bbdce9eb68b26.1201882746@wulfgar> <874pcss8kv.fsf@caffeine.beaverton.ibm.com> Message-ID: <47A731AA.9090804@linux.vnet.ibm.com> Dan Smith wrote: > JG> + * Dan Smith > > While I'd love to take credit, I think you better fix this. > Heh. I noticed it once but was in the middle of something that required too much attention, so I promptly forgot it. -- -Jay From danms at us.ibm.com Mon Feb 4 16:04:09 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 04 Feb 2008 08:04:09 -0800 Subject: [Libvirt-cim] [PATCH] Set additional attribute values in Virt_ComputerSystem.c In-Reply-To: <3b1671a9934018891019.1201904900@elm3b41.beaverton.ibm.com> (Kaitlin Rupert's message of "Fri, 01 Feb 2008 14:28:20 -0800") References: <3b1671a9934018891019.1201904900@elm3b41.beaverton.ibm.com> Message-ID: <87wspkr9mu.fsf@caffeine.beaverton.ibm.com> KR> +static int set_other_id_info(const CMPIBroker *broker, KR> + char *uuid, KR> + const char *prefix, KR> + CMPIInstance *instance) KR> +{ KR> + CMPIStatus s; KR> + CMPIArray *id_info; KR> + char *info[3]; KR> + int count = 3; KR> + char *type = "Virtual System"; KR> + char *model; KR> + int i; KR> + KR> + id_info = CMNewArray(broker, KR> + count, KR> + CMPI_string, KR> + &s); KR> + KR> + if (s.rc != CMPI_RC_OK) KR> + return 0; KR> + KR> + if (asprintf(&model, "%s%s", prefix, type) == 1) KR> + return 0; KR> + KR> + info[0] = uuid; KR> + info[1] = model; KR> + info[2] = type; KR> + KR> + for (i = 0; i < count; i++) { KR> + CMPIString *tmp = CMNewString(broker, info[i], NULL); KR> + CMSetArrayElementAt(id_info, i, KR> + &tmp, KR> + CMPI_string); KR> + } KR> + KR> + CMSetProperty(instance, "OtherIdentifyingInfo", KR> + &id_info, CMPI_stringA); KR> + KR> + return 1; KR> +} This is a style thing, I guess, but wouldn't it be easier to combine this function with the one that sets the descriptions? You could loop through both string arrays at the same time and construct the two CMPIArrays together. The two functions are almost identical, so I think doing them together would add six lines to the above function instead of the 30 it takes for the separate function. KR> static int instance_from_dom(const CMPIBroker *broker, KR> virDomainPtr dom, KR> + const char *prefix, KR> CMPIInstance *instance) KR> { KR> + char *uuid; KR> + KR> if (!set_name_from_dom(dom, instance)) { KR> /* Print trace error */ KR> return 0; KR> } KR> - if (!set_uuid_from_dom(dom, instance)) { KR> + if (!set_uuid_from_dom(dom, instance, &uuid)) { KR> /* Print trace error */ KR> return 0; KR> } KR> @@ -269,7 +347,20 @@ static int instance_from_dom(const CMPIB KR> return 0; Leak UUID here... KR> } KR> + if (!set_other_id_info(broker, uuid, prefix, instance)) { KR> + /* Print trace error */ KR> + free(uuid); KR> + return 0; ...but not here... KR> + } KR> + KR> + if (!set_id_desc(broker, instance)) { KR> + /* Print trace error */ KR> + return 0; ...and then again here. KR> + } KR> + KR> /* More attributes here, of course */ KR> + KR> + free(uuid); KR> return 1; KR> } Can we get either an "err:" target or a return variable and an "out:" target please? :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 4 16:07:08 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 04 Feb 2008 08:07:08 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider In-Reply-To: <47A73149.8070703@linux.vnet.ibm.com> (Jay Gagnon's message of "Mon, 04 Feb 2008 10:37:45 -0500") References: <878x24s8vn.fsf@caffeine.beaverton.ibm.com> <47A73149.8070703@linux.vnet.ibm.com> Message-ID: <87r6fsr9hv.fsf@caffeine.beaverton.ibm.com> JG> We prefix every other class we create, and if somebody doesn't JG> want to deal with the Xen/KVM distinction they are welcome to JG> subscribe to/filter on/whatever they want the CIM super class and JG> get both, right? Yeah, okay, then the plan is to type the job. I guess we can leave the hard-coded "Xen" in place for now. JG> Let's say I fix up cu_dup_instance so that it creates a new JG> instance using the existing instances ObjectPath, then copies all JG> the properties correctly. Then I wouldn't have to call JG> get_typed_instance in the first place, because everything that it JG> does is already taken care of, right? Yep. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Mon Feb 4 16:27:51 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 04 Feb 2008 08:27:51 -0800 Subject: [Libvirt-cim] [PATCH] Set additional attribute values in Virt_ComputerSystem.c In-Reply-To: <87wspkr9mu.fsf@caffeine.beaverton.ibm.com> References: <3b1671a9934018891019.1201904900@elm3b41.beaverton.ibm.com> <87wspkr9mu.fsf@caffeine.beaverton.ibm.com> Message-ID: <47A73D07.3060403@linux.vnet.ibm.com> Dan Smith wrote: > This is a style thing, I guess, but wouldn't it be easier to combine > this function with the one that sets the descriptions? You could loop > through both string arrays at the same time and construct the two > CMPIArrays together. The two functions are almost identical, so I > think doing them together would add six lines to the above function > instead of the 30 it takes for the separate function. Good suggestion - much cleaner as one function. > ...and then again here. > > KR> + } > KR> + > KR> /* More attributes here, of course */ > KR> + > KR> + free(uuid); > > KR> return 1; > KR> } > > Can we get either an "err:" target or a return variable and an "out:" > target please? :) > Yep - will send a new patch with this issue cleaned up. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Mon Feb 4 16:36:11 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 04 Feb 2008 08:36:11 -0800 Subject: [Libvirt-cim] [PATCH] (#2) Set additional attribute values in Virt_ComputerSystem.c Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1202142903 28800 # Node ID b0e81f29cb255066f588931c4630225836e448cc # Parent 70eeb1d09fab3c596e2aae395802b8cf428a4da9 (#2) Set additional attribute values in Virt_ComputerSystem.c Update from patch 1 to patch 2: -Condensed the functions for OtherIdentifyingInfo and IdentifyingDescriptions into one function -Added a return variable to catch the return value of the functions called in instance_from_dom() - added a goto out in case of error. -In the out: block, free the uuid. OtherIdentifyingInfo property and IdentifyingDescriptions. Modify instance_from_dom() to take a prefix parameter. Signed-off-by: Kaitlin Rupert diff -r 70eeb1d09fab -r b0e81f29cb25 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Mon Feb 04 07:35:29 2008 -0800 +++ b/src/Virt_ComputerSystem.c Mon Feb 04 08:35:03 2008 -0800 @@ -71,7 +71,9 @@ static int set_name_from_dom(virDomainPt } /* Set the "UUID" property of an instance from a domain */ -static int set_uuid_from_dom(virDomainPtr dom, CMPIInstance *instance) +static int set_uuid_from_dom(virDomainPtr dom, + CMPIInstance *instance, + char **out_uuid) { char uuid[VIR_UUID_STRING_BUFLEN]; int ret; @@ -82,6 +84,8 @@ static int set_uuid_from_dom(virDomainPt CMSetProperty(instance, "UUID", (CMPIValue *)uuid, CMPI_chars); + + *out_uuid = strdup(uuid); return 1; } @@ -239,39 +243,114 @@ static int set_creation_class(CMPIInstan return 1; } +static int set_other_id_info(const CMPIBroker *broker, + char *uuid, + const char *prefix, + CMPIInstance *instance) +{ + CMPIStatus s; + CMPIArray *id_info; + CMPIArray *id_desc; + char *desc[3] = {"Type", "Model", "UUID"}; + char *info[3]; + int count = 3; + char *type = "Virtual System"; + char *model; + int i; + + id_info = CMNewArray(broker, + count, + CMPI_string, + &s); + + if (s.rc != CMPI_RC_OK) + return 0; + + id_desc = CMNewArray(broker, + count, + CMPI_string, + &s); + + if (s.rc != CMPI_RC_OK) + return 0; + + if (asprintf(&model, "%s%s", prefix, type) == -1) + return 0; + + info[0] = uuid; + info[1] = model; + info[2] = type; + + for (i = 0; i < count; i++) { + CMPIString *tmp = CMNewString(broker, info[i], NULL); + CMSetArrayElementAt(id_info, i, + &tmp, + CMPI_string); + + tmp = CMNewString(broker, desc[i], NULL); + CMSetArrayElementAt(id_desc, i, + &tmp, + CMPI_string); + } + + CMSetProperty(instance, "OtherIdentifyingInfo", + &id_info, CMPI_stringA); + + CMSetProperty(instance, "IdentifyingDescriptions", + (CMPIValue *)&id_desc, CMPI_stringA); + return 1; +} + /* Populate an instance with information from a domain */ static int instance_from_dom(const CMPIBroker *broker, virDomainPtr dom, + const char *prefix, CMPIInstance *instance) { + char *uuid = NULL; + int ret = 1; + if (!set_name_from_dom(dom, instance)) { /* Print trace error */ return 0; } - if (!set_uuid_from_dom(dom, instance)) { + if (!set_uuid_from_dom(dom, instance, &uuid)) { /* Print trace error */ - return 0; + ret = 0; + goto out; } if (!set_capdesc_from_dom(dom, instance)) { /* Print trace error */ - return 0; + ret = 0; + goto out; } if (!set_state_from_dom(broker, dom, instance)) { /* Print trace error */ - return 0; + ret = 0; + goto out; } if (!set_creation_class(instance)) { /* Print trace error */ - return 0; + ret = 0; + goto out; + } + + if (!set_other_id_info(broker, uuid, prefix, instance)) { + /* Print trace error */ + ret = 0; + goto out; } /* More attributes here, of course */ - return 1; + out: + free(uuid); + + return ret; } /* Given a hypervisor connection and a domain name, return an instance */ @@ -294,7 +373,10 @@ CMPIInstance *instance_from_name(const C if (instance == NULL) goto out; - if (!instance_from_dom(broker, dom, instance)) + if (!instance_from_dom(broker, + dom, + pfx_from_conn(conn), + instance)) instance = NULL; out: @@ -327,7 +409,10 @@ int enum_domains(const CMPIBroker *broke if (inst == NULL) goto end; - if (instance_from_dom(broker, list[i], inst)) + if (instance_from_dom(broker, + list[i], + pfx_from_conn(conn), + inst)) inst_list_add(instlist, inst); end: From kaitlin at linux.vnet.ibm.com Mon Feb 4 17:40:47 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 04 Feb 2008 09:40:47 -0800 Subject: [Libvirt-cim] [PATCH] (2) Remove the embedded object parsing pieces from VirtualSystemManagmentService In-Reply-To: <47A6D4DF.6090903@linux.vnet.ibm.com> References: <47A2E73C.3030201@linux.vnet.ibm.com> <47A33E72.6020600@linux.vnet.ibm.com> <47A6D4DF.6090903@linux.vnet.ibm.com> Message-ID: <47A74E1F.3000000@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> Heidi Eckhart wrote: >>> Kaitlin Rupert wrote: >>>> # HG changeset patch >>>> # User Kaitlin Rupert >>>> # Date 1201801531 28800 >>>> # Node ID e27208a0ac3f69df3f704ecd32fdfdc78b79dc7c >>>> # Parent b8d69e734306e618b4efb53e23c17ffdd8bab128 >>>> (2) Remove the embedded object parsing pieces from >>>> VirtualSystemManagmentService. >>>> >>>> Updates from set 1 to set 2: >>>> Removed unsused sys_op from define_system() >>>> Removed unused list from update_resource_setting() >>>> Changed CMPIArray **out_arr to **ret_arr in rasd_refs_to_insts() >>>> >>>> >>> Opps, sorry, I'm sure I was not very clear on what I meant with the >>> out_arr. I thought something like this might look better in the code >>> ... instead of submitting *out_arr submitting a ret_arr (which itself >>> becomes the content of *out_arr at the end). >> >> Oh, yes - I did misunderstand. Thanks for the clarification. =) >> >> However, I'm not sure what benefit this gives us. I think I'm missing >> something - does this change prevent an error condition of some sort? > No, absolutely not. Its only for common look and feel of the code. I see > a lot of functions, where an incoming " **param" is handled > internally as " *_param" which is set as "*param=_param" at the > end. So I thought this is some kind of common for the providers. That's > all. Oh, I see. Sure, I'll send a new patch. =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Mon Feb 4 17:53:59 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 04 Feb 2008 09:53:59 -0800 Subject: [Libvirt-cim] [PATCH] (#3) Remove the embedded object parsing pieces from VirtualSystemManagmentService Message-ID: <245bbbe2d23427d18bbb.1202147639@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202147609 28800 # Node ID 245bbbe2d23427d18bbb476442ed5eef39ba12f2 # Parent 84ee0633c377768529c41463f0bf95b1c88c42e2 (#3) Remove the embedded object parsing pieces from VirtualSystemManagmentService. Updates from set 2 to 3: Added a tmp CMPIArray to rasd_refs_to_insts() to match usual out param style. Updates from set 1 to set 2: Removed unsused sys_op from define_system() Removed unused list from update_resource_setting() Changed CMPIArray **out_arr to **ret_arr in rasd_refs_to_insts() Changed ReferencedConfiguration to ReferenceConfiguration in the definesystem handler. Remove embedded object parsing since libcmpiutil now handles this. Also update the method handlers to expect instances instead of strings as arguments. The following methods have been updated: DefineSystem AddResourceSettings ModifyResourceSettings ModifySystemSettings Signed-off-by: Kaitlin Rupert diff -r 84ee0633c377 -r 245bbbe2d234 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Fri Feb 01 12:06:29 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Mon Feb 04 09:53:29 2008 -0800 @@ -57,69 +57,23 @@ enum ResourceAction { RESOURCE_MOD, }; -static int parse_str_inst_array(CMPIArray *array, - const char *ns, - struct inst_list *list) -{ - int count; - int i; - - count = CMGetArrayCount(array, NULL); - - for (i = 0; i < count; i++) { - CMPIInstance *inst; - CMPIData item; - int ret; - - item = CMGetArrayElementAt(array, i, NULL); - /* FIXME: Check for string here */ - - ret = cu_parse_embedded_instance(CMGetCharPtr(item.value.string), - _BROKER, - ns, - &inst); - - if (ret == 0) - inst_list_add(list, inst); - } - - return 1; -} - static CMPIStatus define_system_parse_args(const CMPIArgs *argsin, CMPIInstance **sys, const char *ns, - struct inst_list *res) + CMPIArray **res) { CMPIStatus s = {CMPI_RC_ERR_FAILED, NULL}; - const char *sys_str = NULL; - CMPIArray *res_arr; - int ret; - - if (cu_get_str_arg(argsin, "SystemSettings", &sys_str) != CMPI_RC_OK) { + + if (cu_get_inst_arg(argsin, "SystemSettings", sys) != CMPI_RC_OK) { CU_DEBUG("No SystemSettings string argument"); goto out; } - ret = cu_parse_embedded_instance(sys_str, - _BROKER, - ns, - sys); - if (ret) { - CU_DEBUG("Unable to parse SystemSettings instance"); - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "SystemSettings parse error"); - goto out; - } - - if (cu_get_array_arg(argsin, "ResourceSettings", &res_arr) != + if (cu_get_array_arg(argsin, "ResourceSettings", res) != CMPI_RC_OK) { CU_DEBUG("Failed to get array arg"); goto out; } - - ret = parse_str_inst_array(res_arr, ns, res); CMSetStatus(&s, CMPI_RC_OK); @@ -317,24 +271,34 @@ static int rasd_to_vdev(CMPIInstance *in return 0; } -static int classify_resources(struct inst_list *all, +static int classify_resources(CMPIArray *resources, struct domain *domain) { int i; uint16_t type; + int count; domain->dev_disk_ct = domain->dev_net_ct = 0; domain->dev_vcpu_ct = domain->dev_mem_ct = 0; - - domain->dev_disk = calloc(all->cur, sizeof(struct virt_device)); - domain->dev_vcpu = calloc(all->cur, sizeof(struct virt_device)); - domain->dev_mem = calloc(all->cur, sizeof(struct virt_device)); - domain->dev_net = calloc(all->cur, sizeof(struct virt_device)); - - for (i = 0; i < all->cur; i++) { + + count = CMGetArrayCount(resources, NULL); + if (count < 1) + return 0; + + domain->dev_disk = calloc(count, sizeof(struct virt_device)); + domain->dev_vcpu = calloc(count, sizeof(struct virt_device)); + domain->dev_mem = calloc(count, sizeof(struct virt_device)); + domain->dev_net = calloc(count, sizeof(struct virt_device)); + + for (i = 0; i < count; i++) { CMPIObjectPath *op; - - op = CMGetObjectPath(all->list[i], NULL); + CMPIData item; + + item = CMGetArrayElementAt(resources, i, NULL); + if (CMIsNullObject(item.value.inst)) + return 0; + + op = CMGetObjectPath(item.value.inst, NULL); if (op == NULL) return 0; @@ -343,16 +307,16 @@ static int classify_resources(struct ins return 0; if (type == CIM_RASD_TYPE_PROC) - rasd_to_vdev(all->list[i], + rasd_to_vdev(item.value.inst, &domain->dev_vcpu[domain->dev_vcpu_ct++]); else if (type == CIM_RASD_TYPE_MEM) - rasd_to_vdev(all->list[i], + rasd_to_vdev(item.value.inst, &domain->dev_mem[domain->dev_mem_ct++]); else if (type == CIM_RASD_TYPE_DISK) - rasd_to_vdev(all->list[i], + rasd_to_vdev(item.value.inst, &domain->dev_disk[domain->dev_disk_ct++]); else if (type == CIM_RASD_TYPE_NET) - rasd_to_vdev(all->list[i], + rasd_to_vdev(item.value.inst, &domain->dev_net[domain->dev_net_ct++]); } @@ -398,7 +362,7 @@ static CMPIInstance *connect_and_create( } static CMPIInstance *create_system(CMPIInstance *vssd, - struct inst_list *resources, + CMPIArray *resources, const CMPIObjectPath *ref, CMPIStatus *s) { @@ -466,11 +430,8 @@ static CMPIStatus define_system(CMPIMeth { CMPIInstance *vssd; CMPIInstance *sys; - CMPIObjectPath *sys_op; - struct inst_list res; + CMPIArray *res; CMPIStatus s; - - inst_list_init(&res); CU_DEBUG("DefineSystem"); @@ -478,15 +439,12 @@ static CMPIStatus define_system(CMPIMeth if (s.rc != CMPI_RC_OK) goto out; - sys = create_system(vssd, &res, reference, &s); + sys = create_system(vssd, res, reference, &s); if (sys == NULL) goto out; - inst_list_free(&res); - CMAddArg(argsout, "ResultingSystem", &sys, CMPI_instance); - sys_op = CMGetObjectPath(sys, NULL); trigger_indication(context, "ComputerSystemCreatedIndication", NAMESPACE(reference)); @@ -623,27 +581,14 @@ static CMPIStatus mod_system_settings(CM const CMPIArgs *argsin, CMPIArgs *argsout) { - const char *inst_str; CMPIInstance *inst; - if (cu_get_str_arg(argsin, "SystemSettings", &inst_str) != CMPI_RC_OK) { + if (cu_get_inst_arg(argsin, "SystemSettings", &inst) != CMPI_RC_OK) { CMPIStatus s; cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing SystemSettings"); - return s; - } - - if (cu_parse_embedded_instance(inst_str, - _BROKER, - NAMESPACE(reference), - &inst)) { - CMPIStatus s; - - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Internal Parse Error on SystemSettings"); return s; } @@ -953,23 +898,30 @@ static CMPIStatus _update_resources_for( } static CMPIStatus _update_resource_settings(const CMPIObjectPath *ref, - struct inst_list *list, + CMPIArray *resources, resmod_fn func) { int i; virConnectPtr conn = NULL; CMPIStatus s; + int count; conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) goto out; - for (i = 0; i < list->cur; i++) { - CMPIInstance *inst = list->list[i]; + count = CMGetArrayCount(resources, NULL); + + for (i = 0; i < count; i++) { + CMPIData item; + CMPIInstance *inst; const char *id = NULL; char *name = NULL; char *devid = NULL; virDomainPtr dom = NULL; + + item = CMGetArrayElementAt(resources, i, NULL); + inst = item.value.inst; if (cu_get_str_prop(inst, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, @@ -1016,9 +968,6 @@ static CMPIStatus update_resource_settin { CMPIArray *arr; CMPIStatus s; - struct inst_list list; - - inst_list_init(&list); if (cu_get_array_arg(argsin, "ResourceSettings", &arr) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, @@ -1027,28 +976,30 @@ static CMPIStatus update_resource_settin goto out; } - parse_str_inst_array(arr, NAMESPACE(ref), &list); - - s = _update_resource_settings(ref, &list, func); - - out: - inst_list_free(&list); - + s = _update_resource_settings(ref, arr, func); + + out: return s; } static CMPIStatus rasd_refs_to_insts(const CMPIContext *ctx, const CMPIObjectPath *reference, CMPIArray *arr, - struct inst_list *list) + CMPIArray **ret_arr) { CMPIStatus s; + CMPIArray *tmp_arr; int i; int c; c = CMGetArrayCount(arr, &s); if (s.rc != CMPI_RC_OK) return s; + + tmp_arr = CMNewArray(_BROKER, + c, + CMPI_instance, + &s); for (i = 0; i < c; i++) { CMPIData d; @@ -1079,13 +1030,16 @@ static CMPIStatus rasd_refs_to_insts(con inst = get_rasd_instance(ctx, reference, _BROKER, id, type); if (inst != NULL) - inst_list_add(list, inst); + CMSetArrayElementAt(tmp_arr, i, + &inst, + CMPI_instance); else CU_DEBUG("Failed to get instance for `%s'", REF2STR(ref)); } CMSetStatus(&s, CMPI_RC_OK); + *ret_arr = tmp_arr; return s; } @@ -1122,10 +1076,8 @@ static CMPIStatus rm_resource_settings(C */ CMPIArray *arr; + CMPIArray *resource_arr; CMPIStatus s; - struct inst_list list; - - inst_list_init(&list); if (cu_get_array_arg(argsin, "ResourceSettings", &arr) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, @@ -1134,23 +1086,21 @@ static CMPIStatus rm_resource_settings(C goto out; } - s = rasd_refs_to_insts(context, reference, arr, &list); + s = rasd_refs_to_insts(context, reference, arr, &resource_arr); if (s.rc != CMPI_RC_OK) goto out; - s = _update_resource_settings(reference, &list, resource_del); - out: - inst_list_free(&list); - + s = _update_resource_settings(reference, resource_arr, resource_del); + out: return s; } static struct method_handler DefineSystem = { .name = "DefineSystem", .handler = define_system, - .args = {{"SystemSettings", CMPI_string}, - {"ResourceSettings", CMPI_stringA}, - {"ReferencedConfiguration", CMPI_string}, + .args = {{"SystemSettings", CMPI_instance}, + {"ResourceSettings", CMPI_instanceA}, + {"ReferenceConfiguration", CMPI_string}, ARG_END } }; @@ -1167,7 +1117,7 @@ static struct method_handler AddResource .name = "AddResourceSettings", .handler = add_resource_settings, .args = {{"AffectedConfiguration", CMPI_ref}, - {"ResourceSettings", CMPI_stringA}, + {"ResourceSettings", CMPI_instanceA}, ARG_END } }; @@ -1175,7 +1125,7 @@ static struct method_handler ModifyResou static struct method_handler ModifyResourceSettings = { .name = "ModifyResourceSettings", .handler = mod_resource_settings, - .args = {{"ResourceSettings", CMPI_stringA}, + .args = {{"ResourceSettings", CMPI_instanceA}, ARG_END } }; @@ -1183,7 +1133,7 @@ static struct method_handler ModifySyste static struct method_handler ModifySystemSettings = { .name = "ModifySystemSettings", .handler = mod_system_settings, - .args = {{"SystemSettings", CMPI_string}, + .args = {{"SystemSettings", CMPI_instance}, ARG_END } }; From danms at us.ibm.com Mon Feb 4 19:16:53 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 04 Feb 2008 11:16:53 -0800 Subject: [Libvirt-cim] [PATCH] (#3) Remove the embedded object parsing pieces from VirtualSystemManagmentService In-Reply-To: <245bbbe2d23427d18bbb.1202147639@elm3b41.beaverton.ibm.com> (Kaitlin Rupert's message of "Mon, 04 Feb 2008 09:53:59 -0800") References: <245bbbe2d23427d18bbb.1202147639@elm3b41.beaverton.ibm.com> Message-ID: <87hcgopm56.fsf@caffeine.beaverton.ibm.com> KR> # HG changeset patch KR> # User Kaitlin Rupert KR> # Date 1202147609 28800 KR> # Node ID 245bbbe2d23427d18bbb476442ed5eef39ba12f2 KR> # Parent 84ee0633c377768529c41463f0bf95b1c88c42e2 KR> (#3) Remove the embedded object parsing pieces from KR> VirtualSystemManagmentService. Okay, I've applied this. Users should note that this requires a simultaneous update of their libcmpiutil tree to match. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 4 19:20:54 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 04 Feb 2008 11:20:54 -0800 Subject: [Libvirt-cim] [PATCH 1 of 4] RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults In-Reply-To: (Heidi Eckhart's message of "Mon, 04 Feb 2008 14:25:51 +0200") References: Message-ID: <87d4rcplyh.fsf@caffeine.beaverton.ibm.com> HE> +CMPIStatus get_rpcs(const CMPIObjectPath *reference, HE> + CMPIInstance **_inst, HE> + const CMPIBroker *broker, HE> + bool getInstance) I think the functionality you're building in here is a good thing. I have a minor issue with the new parameter. The camelCase differs From the rest of our style. Perhaps something like "is_gi" would be more appropriate and also convey the message? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 4 19:22:40 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 04 Feb 2008 11:22:40 -0800 Subject: [Libvirt-cim] [PATCH 2 of 4] RPCC: returns instances of Xen on a KVM only system In-Reply-To: <4f877945eeba7e1c6a69.1202131552@localhost.localdomain> (Heidi Eckhart's message of "Mon, 04 Feb 2008 14:25:52 +0200") References: <4f877945eeba7e1c6a69.1202131552@localhost.localdomain> Message-ID: <878x20plvj.fsf@caffeine.beaverton.ibm.com> HE> +static CMPIStatus get_rpc_cap(const CMPIObjectPath *reference, HE> + CMPIInstance **_inst, HE> + bool getInstance) This adds camelCase as well. Otherwise looks good. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From heidieck at linux.vnet.ibm.com Tue Feb 5 08:54:05 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 09:54:05 +0100 Subject: [Libvirt-cim] [PATCH 2 of 4] RPCC: returns instances of Xen on a KVM only system In-Reply-To: <878x20plvj.fsf@caffeine.beaverton.ibm.com> References: <4f877945eeba7e1c6a69.1202131552@localhost.localdomain> <878x20plvj.fsf@caffeine.beaverton.ibm.com> Message-ID: <47A8242D.8090306@linux.vnet.ibm.com> Dan Smith wrote: > HE> +static CMPIStatus get_rpc_cap(const CMPIObjectPath *reference, > HE> + CMPIInstance **_inst, > HE> + bool getInstance) > > This adds camelCase as well. > > Oopps ... I really don't know which horse was riding me here ... will fix this. Thanks. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Tue Feb 5 08:25:38 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 10:25:38 +0200 Subject: [Libvirt-cim] [PATCH 0 of 4] #3 - RPCS and RPCC ignores supported hypervisor type and wrong object path, adopt changes to HS Message-ID: This patch set is now the combination of the one patch against RPCS and the two patches against RPCC, I sent out on friday. The reason to combine these three patches in one patch set is, that both provider - RPCS and RPCC - look very similar now. This brought me to the idea, that it is possible to also define a common interface for instances providers - as this is already done for associations -, where the common functions could do a main part of the error handling (which is currently done again and again in each single provider itself). In addition patch 4 updates HS (thanks to Kaitlin) with the new interface of RPCS. diff to patch set 2: - renamed parameter getInstance to is_get_inst for style conformance From heidieck at linux.vnet.ibm.com Tue Feb 5 08:25:39 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 10:25:39 +0200 Subject: [Libvirt-cim] [PATCH 1 of 4] RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults In-Reply-To: Message-ID: <81c6269fff598c777f20.1202203539@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202203369 -3600 # Node ID 81c6269fff598c777f203b93a6ae3d9d2c3cd718 # Parent c2ff6825e25f513417f395ea334f4f7963f2729c RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults wbemein http://localhost/root/virt:CIM_ResourcePoolConfigurationService on a KVM system with no Xen segfaults. The same happens to wbemgi 'http://localhost:5988/root/virt:Xen_ResourcePoolConfigurationService.SystemCreationClassName="Xen_HostSystem",SystemName="localhost.localdomain",CreationClassName="Xen_ResourcePoolConfigurationService",Name="RPCS"' This patch also makes RPCS aware of the supported hypervisor type. Now only instances of the machine's supported hypervisor are returned. This approach is used all over the libvirt-cim providers, but was broken here. Signed-off-by: Heidi Eckhart diff -r c2ff6825e25f -r 81c6269fff59 src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Mon Feb 04 09:53:29 2008 -0800 +++ b/src/Virt_ResourcePoolConfigurationService.c Tue Feb 05 10:22:49 2008 +0100 @@ -94,21 +94,28 @@ DEFAULT_EQ(); DEFAULT_EQ(); DEFAULT_INST_CLEANUP(); -CMPIStatus rpcs_instance(const CMPIObjectPath *reference, - CMPIInstance **_inst, - const CMPIBroker *broker) +CMPIStatus get_rpcs(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst) { CMPIInstance *inst; - CMPIInstance *host; - CMPIStatus s; - CMPIData prop; - - s = get_host_cs(broker, reference, &host); - if (s.rc != CMPI_RC_OK) - goto out; + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + const char *name = NULL; + const char *ccname = NULL; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } inst = get_typed_instance(broker, - CLASSNAME(reference), + pfx_from_conn(conn), "ResourcePoolConfigurationService", NAMESPACE(reference)); if (inst == NULL) { @@ -119,32 +126,57 @@ CMPIStatus rpcs_instance(const CMPIObjec goto out; } - CMSetProperty(inst, "Name", - (CMPIValue *)"RPCS", CMPI_chars); - - prop = CMGetProperty(host, "CreationClassName", &s); + s = get_host_system_properties(&name, + &ccname, + reference, + broker); if (s.rc != CMPI_RC_OK) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, - "Unable to get CreationClassName from HostSystem"); - goto out; - } + "Unable to get host attributes"); + goto out; + } + + CMSetProperty(inst, "Name", + (CMPIValue *)"RPCS", CMPI_chars); + + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); CMSetProperty(inst, "SystemCreationClassName", - (CMPIValue *)&prop.value.string, CMPI_string); - - prop = CMGetProperty(host, "Name", NULL); - if (s.rc != CMPI_RC_OK) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Unable to get Name from HostSystem"); - goto out; - } - - CMSetProperty(inst, "SystemName", - (CMPIValue *)&prop.value.string, CMPI_string); + (CMPIValue *)ccname, CMPI_chars); + + if (is_get_inst) { + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } *_inst = inst; + + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_rpcs(const CMPIResult *results, + const CMPIObjectPath *reference, + bool names_only, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_rpcs(reference, &inst, _BROKER, is_get_inst); + if (s.rc != CMPI_RC_OK || inst == NULL) + goto out; + + if (names_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + out: return s; } @@ -155,24 +187,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - CMPIInstance *inst; - CMPIStatus s; - const char *prop = NULL; - - s = rpcs_instance(reference, &inst, _BROKER); - if (s.rc != CMPI_RC_OK) - return s; - - prop = cu_compare_ref(reference, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } else { - CMReturnInstance(results, inst); - } - - return s; + return return_rpcs(results, reference, false, true); } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -180,14 +195,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - CMPIInstance *inst; - CMPIStatus s; - - s = rpcs_instance(reference, &inst, _BROKER); - if (s.rc == CMPI_RC_OK) - cu_return_instance_name(results, inst); - - return s; + return return_rpcs(results, reference, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -196,15 +204,7 @@ static CMPIStatus EnumInstances(CMPIInst const CMPIObjectPath *reference, const char **properties) { - - CMPIInstance *inst; - CMPIStatus s; - - s = rpcs_instance(reference, &inst, _BROKER); - if (s.rc == CMPI_RC_OK) - CMReturnInstance(results, inst); - - return s; + return return_rpcs(results, reference, false, false); } diff -r c2ff6825e25f -r 81c6269fff59 src/Virt_ResourcePoolConfigurationService.h --- a/src/Virt_ResourcePoolConfigurationService.h Mon Feb 04 09:53:29 2008 -0800 +++ b/src/Virt_ResourcePoolConfigurationService.h Tue Feb 05 10:22:49 2008 +0100 @@ -19,6 +19,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -CMPIStatus rpcs_instance(const CMPIObjectPath *reference, - CMPIInstance **_inst, - const CMPIBroker *broker); +CMPIStatus get_rpcs(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From heidieck at linux.vnet.ibm.com Tue Feb 5 08:25:40 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 10:25:40 +0200 Subject: [Libvirt-cim] [PATCH 2 of 4] RPCC: returns instances of Xen on a KVM only system In-Reply-To: Message-ID: <8805a8c0a8ee8bdcedfb.1202203540@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202203372 -3600 # Node ID 8805a8c0a8ee8bdcedfb60883a4436177d657cc3 # Parent 81c6269fff598c777f203b93a6ae3d9d2c3cd718 RPCC: returns instances of Xen on a KVM only system This breaks the approach that is used all over libvirt-cim providers, where only instances of the currently supported hypervisor type are returned. Signed-off-by: Heidi Eckhart diff -r 81c6269fff59 -r 8805a8c0a8ee src/Virt_ResourcePoolConfigurationCapabilities.c --- a/src/Virt_ResourcePoolConfigurationCapabilities.c Tue Feb 05 10:22:49 2008 +0100 +++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Tue Feb 05 10:22:52 2008 +0100 @@ -47,45 +47,63 @@ DEFAULT_EQ(); DEFAULT_EQ(); DEFAULT_INST_CLEANUP(); -static CMPIStatus get_rpc_cap(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **_inst) +static CMPIStatus get_rpc_cap(const CMPIObjectPath *reference, + CMPIInstance **_inst, + bool is_get_inst) { - CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn = NULL; - inst = get_typed_instance(broker, - CLASSNAME(reference), + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); + if (conn == NULL) + goto out; + + inst = get_typed_instance(_BROKER, + pfx_from_conn(conn), "ResourcePoolConfigurationCapabilities", NAMESPACE(reference)); if (inst == NULL) - return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL}; + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Can't create ResourcePoolConfigurationCapabilities instance"); CMSetProperty(inst, "InstanceID", (CMPIValue *)"RPCC", CMPI_chars); /* No method currently supported */ + if (is_get_inst) { + s = cu_validate_ref(_BROKER, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + *_inst = inst; - return (CMPIStatus){CMPI_RC_OK, NULL}; + out: + virConnectClose(conn); + + return s; } static CMPIStatus return_rpc_cap(const CMPIObjectPath *reference, const CMPIResult *results, - bool names_only) + bool names_only, + bool is_get_inst) { CMPIStatus s; - CMPIInstance *inst; + CMPIInstance *inst = NULL; - s = get_rpc_cap(_BROKER, reference, &inst); - if (s.rc != CMPI_RC_OK) + s = get_rpc_cap(reference, &inst, is_get_inst); + if (s.rc != CMPI_RC_OK || inst == NULL) goto out; - + if (names_only) cu_return_instance_name(results, inst); else CMReturnInstance(results, inst); - + out: return s; } @@ -95,7 +113,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_rpc_cap(reference, results, 1); + return return_rpc_cap(reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -105,7 +123,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_rpc_cap(reference, results, 0); + return return_rpc_cap(reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -114,7 +132,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - return return_rpc_cap(reference, results, 0); + return return_rpc_cap(reference, results, false, true); } From heidieck at linux.vnet.ibm.com Tue Feb 5 08:25:42 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 10:25:42 +0200 Subject: [Libvirt-cim] [PATCH 4 of 4] HS: adopt change in RPCS interface (get_rpcs_instance) In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1202203373 -3600 # Node ID bd791ff33ba623d1355ca26b3876df0b32ad2d4b # Parent 1a648234fb0f0332580b546a8a5dd75746441a7a HS: adopt change in RPCS interface (get_rpcs_instance) Signed-off-by: Heidi Eckhart diff -r 1a648234fb0f -r bd791ff33ba6 src/Virt_HostedService.c --- a/src/Virt_HostedService.c Tue Feb 05 10:22:52 2008 +0100 +++ b/src/Virt_HostedService.c Tue Feb 05 10:22:53 2008 +0100 @@ -49,7 +49,7 @@ static CMPIStatus validate_service_ref(c if (STREQC(classname, "VirtualSystemManagementService")) { s = get_vsms(ref, &inst, _BROKER); } else if (STREQC(classname, "ResourcePoolConfigurationService")) { - s = rpcs_instance(ref, &inst, _BROKER); + s = get_rpcs(ref, &inst, _BROKER, true); } else if (STREQC(classname, "VirtualSystemMigrationService")) { s = get_migration_service(ref, &inst, _BROKER); } @@ -105,7 +105,7 @@ static CMPIStatus host_to_service(const if (s.rc != CMPI_RC_OK) return s; - s = rpcs_instance(ref, &inst, _BROKER); + s = get_rpcs(ref, &inst, _BROKER, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) From heidieck at linux.vnet.ibm.com Tue Feb 5 08:25:41 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 10:25:41 +0200 Subject: [Libvirt-cim] [PATCH 3 of 4] RPCC: getInstance does not take care of client given object path In-Reply-To: Message-ID: <1a648234fb0f0332580b.1202203541@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202203372 -3600 # Node ID 1a648234fb0f0332580b546a8a5dd75746441a7a # Parent 8805a8c0a8ee8bdcedfb60883a4436177d657cc3 RPCC: getInstance does not take care of client given object path wbemgi 'http://localhost:5988/root/virt:KVM_ResourcePoolConfigurationCapabilities.InstanceID="wrong"' returns the instance instead of NOT_FOUND. Signed-off-by: Heidi Eckhart diff -r 8805a8c0a8ee -r 1a648234fb0f src/Virt_ResourcePoolConfigurationCapabilities.c --- a/src/Virt_ResourcePoolConfigurationCapabilities.c Tue Feb 05 10:22:52 2008 +0100 +++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Tue Feb 05 10:22:52 2008 +0100 @@ -56,8 +56,13 @@ static CMPIStatus get_rpc_cap(const CMPI virConnectPtr conn = NULL; conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); - if (conn == NULL) + if (conn == NULL) { + if (is_get_inst) + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); goto out; + } inst = get_typed_instance(_BROKER, pfx_from_conn(conn), From heidieck at linux.vnet.ibm.com Tue Feb 5 08:29:44 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 10:29:44 +0200 Subject: [Libvirt-cim] [PATCH] HostSystem: fix style issue with parameter naming Message-ID: <083ff6db76d5b5efd04d.1202203784@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202203758 -3600 # Node ID 083ff6db76d5b5efd04d094bc4f9736b1c11c50c # Parent bd791ff33ba623d1355ca26b3876df0b32ad2d4b HostSystem: fix style issue with parameter naming renamed getInstance to is_get_inst for style conformance Signed-off-by: Heidi Eckhart diff -r bd791ff33ba6 -r 083ff6db76d5 src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Tue Feb 05 10:22:53 2008 +0100 +++ b/src/Virt_HostSystem.c Tue Feb 05 10:29:18 2008 +0100 @@ -107,7 +107,7 @@ static CMPIStatus return_host_cs(const C static CMPIStatus return_host_cs(const CMPIObjectPath *reference, const CMPIResult *results, bool name_only, - bool getInstance) + bool is_get_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *instance; @@ -117,14 +117,14 @@ static CMPIStatus return_host_cs(const C goto out; if (instance == NULL) { - if (getInstance) + if (is_get_inst) cu_statusf(_BROKER, &s, CMPI_RC_ERR_NOT_FOUND, "No such instance"); goto out; } - if (getInstance) { + if (is_get_inst) { s = cu_validate_ref(_BROKER, reference, instance); if (s.rc != CMPI_RC_OK) goto out; From heidieck at linux.vnet.ibm.com Tue Feb 5 09:32:36 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 10:32:36 +0100 Subject: [Libvirt-cim] [PATCH] Fix stale issue with threads in Virt_HostedDependency association In-Reply-To: <84ee0633c377768529c4.1201896400@caffeine.beaverton.ibm.com> References: <84ee0633c377768529c4.1201896400@caffeine.beaverton.ibm.com> Message-ID: <47A82D34.60302@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1201896389 28800 > # Node ID 84ee0633c377768529c41463f0bf95b1c88c42e2 > # Parent 5d554b65865ebaabf5261f7e8557dd7a40bf6175 > Fix stale issue with threads in Virt_HostedDependency association > > This crept in when we converted to lists of association classes with > std_assoc. It's a trivial fix, but it has to be done do all of our > associations, barring any that are correct already. > > Signed-off-by: Dan Smith > > Ooops ... I have to be blamed for it ... and will send out a patch set for all effected assocs. An excellent catch ... thank you, Dan :). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Tue Feb 5 09:44:51 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 10:44:51 +0100 Subject: [Libvirt-cim] [PATCH] (#2) Set additional attribute values in Virt_ComputerSystem.c In-Reply-To: References: Message-ID: <47A83013.30201@linux.vnet.ibm.com> Kaitlin Rupert wrote: > # HG changeset patch > # User Kaitlin Rupert > # Date 1202142903 28800 > # Node ID b0e81f29cb255066f588931c4630225836e448cc > # Parent 70eeb1d09fab3c596e2aae395802b8cf428a4da9 > (#2) Set additional attribute values in Virt_ComputerSystem.c > > Update from patch 1 to patch 2: > -Condensed the functions for OtherIdentifyingInfo and IdentifyingDescriptions into one function > -Added a return variable to catch the return value of the functions called in instance_from_dom() - added a goto out in case of error. > -In the out: block, free the uuid. > > OtherIdentifyingInfo property and IdentifyingDescriptions. Modify instance_from_dom() to take a prefix parameter. > > Signed-off-by: Kaitlin Rupert > > This is working fine for me ... +1. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:22 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:22 +0200 Subject: [Libvirt-cim] [PATCH 02 of 11] EC: fix stale issue with threads In-Reply-To: Message-ID: <5e2fe5b7a96c3a1835de.1202205802@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202205591 -3600 # Node ID 5e2fe5b7a96c3a1835de1cb72305be929e337db0 # Parent 32d3353796600f7ee064b77ecca0d22d17e3104e EC: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 32d335379660 -r 5e2fe5b7a96c src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Tue Feb 05 10:49:28 2008 +0100 +++ b/src/Virt_ElementCapabilities.c Tue Feb 05 10:59:51 2008 +0100 @@ -233,19 +233,19 @@ static CMPIStatus pool_to_alloc(const CM LIBVIRT_CIM_DEFAULT_MAKEREF() -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_ElementCapabilities", "KVM_ElementCapabilities", NULL }; -char* host_system[] = { +static char* host_system[] = { "Xen_HostSystem", "KVM_HostSystem", NULL }; -char* virtual_system_management_capabilities[] = { +static char* virtual_system_management_capabilities[] = { "Xen_VirtualSystemManagementCapabilities", "Xen_VirtualSystemMigrationCapabilities", "KVM_VirtualSystemManagementCapabilities", @@ -253,7 +253,7 @@ char* virtual_system_management_capabili NULL, }; -struct std_assoc system_to_vsm_cap = { +static struct std_assoc system_to_vsm_cap = { .source_class = (char**)&host_system, .source_prop = "ManagedElement", @@ -266,7 +266,7 @@ struct std_assoc system_to_vsm_cap = { .make_ref = make_ref }; -struct std_assoc vsm_cap_to_system = { +static struct std_assoc vsm_cap_to_system = { .source_class = (char**)&virtual_system_management_capabilities, .source_prop = "Capabilities", @@ -279,19 +279,19 @@ struct std_assoc vsm_cap_to_system = { .make_ref = make_ref }; -char* computer_system[] = { +static static char* computer_system[] = { "Xen_ComputerSystem", "KVM_ComputerSystem", NULL }; -char* enabled_logical_element_capabilities[] = { +static static char* enabled_logical_element_capabilities[] = { "Xen_EnabledLogicalElementCapabilities", "KVM_EnabledLogicalElementCapabilities", NULL }; -struct std_assoc ele_cap_to_cs = { +static struct std_assoc ele_cap_to_cs = { .source_class = (char**)&enabled_logical_element_capabilities, .source_prop = "Capabilities", @@ -304,7 +304,7 @@ struct std_assoc ele_cap_to_cs = { .make_ref = make_ref }; -struct std_assoc cs_to_ele_cap = { +static struct std_assoc cs_to_ele_cap = { .source_class = (char**)&computer_system, .source_prop = "ManagedElement", @@ -317,13 +317,13 @@ struct std_assoc cs_to_ele_cap = { .make_ref = make_ref }; -char* allocation_capabilities[] = { +static char* allocation_capabilities[] = { "Xen_AllocationCapabilities", "KVM_AllocationCapabilities", NULL }; -char* resource_pool[] = { +static char* resource_pool[] = { "Xen_ProcessorPool", "Xen_MemoryPool", "Xen_NetworkPool", @@ -335,7 +335,7 @@ char* resource_pool[] = { NULL }; -struct std_assoc alloc_cap_to_resource_pool = { +static struct std_assoc alloc_cap_to_resource_pool = { .source_class = (char**)&allocation_capabilities, .source_prop = "Capabilities", @@ -348,7 +348,7 @@ struct std_assoc alloc_cap_to_resource_p .make_ref = make_ref }; -struct std_assoc resource_pool_to_alloc_cap = { +static struct std_assoc resource_pool_to_alloc_cap = { .source_class = (char**)&resource_pool, .source_prop = "ManagedElement", @@ -361,7 +361,7 @@ struct std_assoc resource_pool_to_alloc_ .make_ref = make_ref }; -struct std_assoc *assoc_handlers[] = { +static struct std_assoc *assoc_handlers[] = { &system_to_vsm_cap, &vsm_cap_to_system, &ele_cap_to_cs, From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:27 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:27 +0200 Subject: [Libvirt-cim] [PATCH 07 of 11] RAFP: fix stale issue with threads In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1202205678 -3600 # Node ID aac8a4de2503eabddd5a734d034bddd4bae3d482 # Parent 5a27100b0540202a139cc86dc5e8c08ea30bd5b2 RAFP: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 5a27100b0540 -r aac8a4de2503 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Tue Feb 05 11:01:00 2008 +0100 +++ b/src/Virt_ResourceAllocationFromPool.c Tue Feb 05 11:01:18 2008 +0100 @@ -245,7 +245,7 @@ static CMPIStatus pool_to_rasd(const CMP LIBVIRT_CIM_DEFAULT_MAKEREF() -char* antecedent[] = { +static char* antecedent[] = { "Xen_ProcessorPool", "Xen_MemoryPool", "Xen_NetworkPool", @@ -257,7 +257,7 @@ char* antecedent[] = { NULL }; -char* dependent[] = { +static char* dependent[] = { "Xen_DiskResourceAllocationSettingData", "Xen_MemResourceAllocationSettingData", "Xen_NetResourceAllocationSettingData", @@ -269,7 +269,7 @@ char* dependent[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_ResourceAllocationFromPool", "KVM_ResourceAllocationFromPool", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:29 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:29 +0200 Subject: [Libvirt-cim] [PATCH 09 of 11] SDS: fix stale issue with threads In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1202205721 -3600 # Node ID d115dcc00cde07404c2d86798d71b15e23f296b5 # Parent f0b4c691abc5da51dce9ba8528bd3fc0769e4cde SDS: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r f0b4c691abc5 -r d115dcc00cde src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Tue Feb 05 11:02:00 2008 +0100 +++ b/src/Virt_SettingsDefineState.c Tue Feb 05 11:02:01 2008 +0100 @@ -290,7 +290,7 @@ static CMPIStatus vssd_to_vs(const CMPIO LIBVIRT_CIM_DEFAULT_MAKEREF() -char* logical_device[] = { +static char* logical_device[] = { "Xen_Processor", "Xen_Memory", "Xen_NetworkPort", @@ -302,7 +302,7 @@ char* logical_device[] = { NULL }; -char* resource_allocation_setting_data[] = { +static char* resource_allocation_setting_data[] = { "Xen_DiskResourceAllocationSettingData", "Xen_MemResourceAllocationSettingData", "Xen_NetResourceAllocationSettingData", @@ -314,19 +314,19 @@ char* resource_allocation_setting_data[] NULL }; -char* computer_system[] = { +static char* computer_system[] = { "Xen_ComputerSystem", "KVM_ComputerSystem", NULL }; -char* virtual_system_setting_data[] = { +static char* virtual_system_setting_data[] = { "Xen_VirtualSystemSettingData", "KVM_VirtualSystemSettingData", NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_SettingsDefineState", "KVM_SettingsDefineState", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:26 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:26 +0200 Subject: [Libvirt-cim] [PATCH 06 of 11] HS: fix stale issue with threads In-Reply-To: Message-ID: <5a27100b0540202a139c.1202205806@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202205660 -3600 # Node ID 5a27100b0540202a139cc86dc5e8c08ea30bd5b2 # Parent 73c3b0b5eb89308ba4e700c942ac23575d687263 HS: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 73c3b0b5eb89 -r 5a27100b0540 src/Virt_HostedService.c --- a/src/Virt_HostedService.c Tue Feb 05 11:00:59 2008 +0100 +++ b/src/Virt_HostedService.c Tue Feb 05 11:01:00 2008 +0100 @@ -128,13 +128,13 @@ static CMPIStatus host_to_service(const LIBVIRT_CIM_DEFAULT_MAKEREF() -char* antecedent[] = { +static char* antecedent[] = { "Xen_HostSystem", "KVM_HostSystem", NULL }; -char* dependent[] = { +static char* dependent[] = { "Xen_ResourcePoolConfigurationService", "Xen_VirtualSystemManagementService", "Xen_VirtualSystemMigrationService", @@ -144,7 +144,7 @@ char* dependent[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_HostedService", "KVM_HostedService", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:21 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:21 +0200 Subject: [Libvirt-cim] [PATCH 01 of 11] EAFP: fix stale issue with threads In-Reply-To: Message-ID: <32d3353796600f7ee064.1202205801@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202204968 -3600 # Node ID 32d3353796600f7ee064b77ecca0d22d17e3104e # Parent 108f192632bfd801a1f0520b8f20341a2c3a2f53 EAFP: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 108f192632bf -r 32d335379660 src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Mon Feb 04 08:35:03 2008 -0800 +++ b/src/Virt_ElementAllocatedFromPool.c Tue Feb 05 10:49:28 2008 +0100 @@ -228,7 +228,7 @@ static CMPIStatus pool_to_vdev(const CMP LIBVIRT_CIM_DEFAULT_MAKEREF() -char* antecedent[] = { +static char* antecedent[] = { "Xen_ProcessorPool", "Xen_MemoryPool", "Xen_NetworkPool", @@ -240,7 +240,7 @@ char* antecedent[] = { NULL }; -char* dependent[] = { +static char* dependent[] = { "Xen_Processor", "Xen_Memory", "Xen_NetworkPort", @@ -252,7 +252,7 @@ char* dependent[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_ElementAllocatedFromPool", "KVM_ElementAllocatedFromPool", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:31 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:31 +0200 Subject: [Libvirt-cim] [PATCH 11 of 11] VSSDC: fix stale issue with threads In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1202205753 -3600 # Node ID cc4749ebb05274873ed204c8263bfbc57af4f037 # Parent fb21f67bf6294c49b620bc39e6329d9e712dc967 VSSDC: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r fb21f67bf629 -r cc4749ebb052 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Tue Feb 05 11:02:19 2008 +0100 +++ b/src/Virt_VSSDComponent.c Tue Feb 05 11:02:33 2008 +0100 @@ -154,13 +154,13 @@ static CMPIStatus rasd_to_vssd(const CMP LIBVIRT_CIM_DEFAULT_MAKEREF() -char* group_component[] = { +static char* group_component[] = { "Xen_VirtualSystemSettingData", "KVM_VirtualSystemSettingData", NULL }; -char* part_component[] = { +static char* part_component[] = { "Xen_DiskResourceAllocationSettingData", "Xen_MemResourceAllocationSettingData", "Xen_NetResourceAllocationSettingData", @@ -172,7 +172,7 @@ char* part_component[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_VirtualSystemSettingDataComponent", "KVM_VirtualSystemSettingDataComponent", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:30 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:30 +0200 Subject: [Libvirt-cim] [PATCH 10 of 11] SD: fix stale issue with threads In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1202205739 -3600 # Node ID fb21f67bf6294c49b620bc39e6329d9e712dc967 # Parent d115dcc00cde07404c2d86798d71b15e23f296b5 SD: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r d115dcc00cde -r fb21f67bf629 src/Virt_SystemDevice.c --- a/src/Virt_SystemDevice.c Tue Feb 05 11:02:01 2008 +0100 +++ b/src/Virt_SystemDevice.c Tue Feb 05 11:02:19 2008 +0100 @@ -210,13 +210,13 @@ static CMPIStatus dev_to_sys(const CMPIO LIBVIRT_CIM_DEFAULT_MAKEREF() -char* group_component[] = { +static char* group_component[] = { "Xen_ComputerSystem", "KVM_ComputerSystem", NULL }; -char* part_component[] = { +static char* part_component[] = { "Xen_Processor", "Xen_Memory", "Xen_NetworkPort", @@ -228,7 +228,7 @@ char* part_component[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_SystemDevice", "KVM_SystemDevice", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:24 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:24 +0200 Subject: [Libvirt-cim] [PATCH 04 of 11] ESD: fix stale issue with threads In-Reply-To: Message-ID: <58a4e8db2a0e326d8a34.1202205804@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202205617 -3600 # Node ID 58a4e8db2a0e326d8a34bcc9191a09b9216a1e8c # Parent 36f5adc3895ebbf2962dc55f3d534e2ce6401f69 ESD: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 36f5adc3895e -r 58a4e8db2a0e src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Tue Feb 05 11:00:17 2008 +0100 +++ b/src/Virt_ElementSettingData.c Tue Feb 05 11:00:17 2008 +0100 @@ -160,13 +160,13 @@ static CMPIInstance *make_ref(const CMPI return refinst; } -char* virtual_system_setting_data[] = { +static char* virtual_system_setting_data[] = { "Xen_VirtualSystemSettingData", "KVM_VirtualSystemSettingData", NULL }; -char* resource_allocation_setting_data[] = { +static char* resource_allocation_setting_data[] = { "Xen_DiskResourceAllocationSettingData", "Xen_MemResourceAllocationSettingData", "Xen_NetResourceAllocationSettingData", @@ -178,7 +178,7 @@ char* resource_allocation_setting_data[] NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_ElementSettingData", "KVM_ElementSettingData", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:20 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:20 +0200 Subject: [Libvirt-cim] [PATCH 00 of 11] Fix stale issue with threads for assocs Message-ID: This patch set adds the missing static declarations to assocs. From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:23 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:23 +0200 Subject: [Libvirt-cim] [PATCH 03 of 11] ECTP: fix stale issue with threads In-Reply-To: Message-ID: <36f5adc3895ebbf2962d.1202205803@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202205617 -3600 # Node ID 36f5adc3895ebbf2962dc55f3d534e2ce6401f69 # Parent 5e2fe5b7a96c3a1835de1cb72305be929e337db0 ECTP: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 5e2fe5b7a96c -r 36f5adc3895e src/Virt_ElementConformsToProfile.c --- a/src/Virt_ElementConformsToProfile.c Tue Feb 05 10:59:51 2008 +0100 +++ b/src/Virt_ElementConformsToProfile.c Tue Feb 05 11:00:17 2008 +0100 @@ -192,13 +192,13 @@ static CMPIStatus elem_to_prof(const CMP LIBVIRT_CIM_DEFAULT_MAKEREF() -char* conformant_standard[] = { +static char* conformant_standard[] = { "Xen_RegisteredProfile", "KVM_RegisteredProfile", NULL }; -char* managed_element[] = { +static char* managed_element[] = { "Xen_HostSystem", "Xen_ComputerSystem", "KVM_HostSystem", @@ -206,13 +206,13 @@ char* managed_element[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_ElementConformsToProfile", "KVM_ElementConformsToProfile", NULL }; -struct std_assoc forward = { +static struct std_assoc forward = { .source_class = (char**)&conformant_standard, .source_prop = "ConformantStandard", @@ -225,7 +225,7 @@ struct std_assoc forward = { .make_ref = make_ref }; -struct std_assoc backward = { +static struct std_assoc backward = { .source_class = (char**)&managed_element, .source_prop = "ManagedElement", @@ -238,7 +238,7 @@ struct std_assoc backward = { .make_ref = make_ref }; -struct std_assoc *assoc_handlers[] = { +static struct std_assoc *assoc_handlers[] = { &forward, &backward, NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:25 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:25 +0200 Subject: [Libvirt-cim] [PATCH 05 of 11] HRP: fix stale issue with threads In-Reply-To: Message-ID: <73c3b0b5eb89308ba4e7.1202205805@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202205659 -3600 # Node ID 73c3b0b5eb89308ba4e700c942ac23575d687263 # Parent 58a4e8db2a0e326d8a34bcc9191a09b9216a1e8c HRP: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 58a4e8db2a0e -r 73c3b0b5eb89 src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Tue Feb 05 11:00:17 2008 +0100 +++ b/src/Virt_HostedResourcePool.c Tue Feb 05 11:00:59 2008 +0100 @@ -94,13 +94,13 @@ static CMPIStatus sys_to_pool(const CMPI LIBVIRT_CIM_DEFAULT_MAKEREF() -char* group_component[] = { +static char* group_component[] = { "Xen_HostSystem", "KVM_HostSystem", NULL }; -char* part_component[] = { +static char* part_component[] = { "Xen_ProcessorPool", "Xen_MemoryPool", "Xen_NetworkPool", @@ -112,13 +112,13 @@ char* part_component[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_HostedResourcePool", "KVM_HostedResourcePool", NULL }; -struct std_assoc forward = { +static struct std_assoc forward = { .source_class = (char**)&part_component, .source_prop = "PartComponent", @@ -131,7 +131,7 @@ struct std_assoc forward = { .make_ref = make_ref }; -struct std_assoc backward = { +static struct std_assoc backward = { .source_class = (char**)&group_component, .source_prop = "GroupComponent", @@ -144,7 +144,7 @@ struct std_assoc backward = { .make_ref = make_ref }; -struct std_assoc *assoc_handlers[] = { +static struct std_assoc *assoc_handlers[] = { &forward, &backward, NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 09:03:28 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:03:28 +0200 Subject: [Libvirt-cim] [PATCH 08 of 11] SDC: fix stale issue with threads In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1202205720 -3600 # Node ID f0b4c691abc5da51dce9ba8528bd3fc0769e4cde # Parent aac8a4de2503eabddd5a734d034bddd4bae3d482 SDC: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r aac8a4de2503 -r f0b4c691abc5 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Tue Feb 05 11:01:18 2008 +0100 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Feb 05 11:02:00 2008 +0100 @@ -827,13 +827,13 @@ static CMPIStatus rasd_to_alloc_cap(cons LIBVIRT_CIM_DEFAULT_MAKEREF() -char* group_component[] = { +static char* group_component[] = { "Xen_AllocationCapabilities", "KVM_AllocationCapabilities", NULL }; -char* part_component[] = { +static char* part_component[] = { "Xen_DiskResourceAllocationSettingData", "Xen_MemResourceAllocationSettingData", "Xen_NetResourceAllocationSettingData", @@ -845,13 +845,13 @@ char* part_component[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_SettingsDefineCapabilities", "KVM_SettingsDefineCapabilities", NULL }; -struct std_assoc _alloc_cap_to_rasd = { +static struct std_assoc _alloc_cap_to_rasd = { .source_class = (char**)&group_component, .source_prop = "GroupComponent", @@ -864,7 +864,7 @@ struct std_assoc _alloc_cap_to_rasd = { .make_ref = make_ref }; -struct std_assoc _rasd_to_alloc_cap = { +static struct std_assoc _rasd_to_alloc_cap = { .source_class = (char**)&part_component, .source_prop = "PartComponent", @@ -877,7 +877,7 @@ struct std_assoc _rasd_to_alloc_cap = { .make_ref = make_ref }; -struct std_assoc *assoc_handlers[] = { +static struct std_assoc *assoc_handlers[] = { &_alloc_cap_to_rasd, &_rasd_to_alloc_cap, NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:03 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:14:03 +0100 Subject: [Libvirt-cim] [PATCH 1 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider In-Reply-To: <47A73149.8070703@linux.vnet.ibm.com> References: <878x24s8vn.fsf@caffeine.beaverton.ibm.com> <47A73149.8070703@linux.vnet.ibm.com> Message-ID: <47A836EB.4040406@linux.vnet.ibm.com> Jay Gagnon wrote: > Dan Smith wrote: >> However, as Jay points out, I think that the indication should be >> typed per-platform as usual. So, should we type the job to match, >> since we'll need to persist the information for typing the indication >> as well? >> >> > I'm no Heidi, but it seems like we should be prefixing this. We > prefix every other class we create, and if somebody doesn't want to > deal with the Xen/KVM distinction they are welcome to subscribe > to/filter on/whatever they want the CIM super class and get both, right? Sorry for my late jump into this discussion. I know, its already decided and only wanted to add my thought too. I also agree to prefixing the job with either Xen or KVM. This also means to update the mof files to directly derive these two classes from CIM_ConcreteJob - or maybe better - rename Virt_MigrationJob to CIM_MigrationJob as placeholder for the upcoming migration profile and derive from CIM_MigrationJob. > > As to where the prefix comes from, I think Kaitlin was on to something > with the ref that comes in from migrate_do, although I think it can be > even easier than she said. We don't actually need to attach the > prefix to the migration_job structure; we're already attaching the > classname, so all we need is a call to class_prefix_name and we've got > a prefix. > Straightforward idea :). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Tue Feb 5 10:58:38 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 11:58:38 +0100 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: <87ejbwsady.fsf@caffeine.beaverton.ibm.com> References: <87odb0sjcq.fsf@caffeine.beaverton.ibm.com> <47A352B4.4030909@linux.vnet.ibm.com> <87ejbwsady.fsf@caffeine.beaverton.ibm.com> Message-ID: <47A8415E.1000809@linux.vnet.ibm.com> Dan Smith wrote: > JG> I'm pleading CIM ignorance on this one. I thought the ObjectPath > JG> encompassed the properties, and thought that my testing showed it > JG> happening (I don't manually move the JobState over but it is est), > JG> but I could have been wrong. > > You're only half ignorant here :) > > The ObjectPath has the key properties, but not the rest. > > But it can also be, that some of the none-key properties contain a value. This happens, if within the DMTF's mof files a default value was defined. Might this be for JobState ? -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:06 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:14:06 +0200 Subject: [Libvirt-cim] [PATCH 07 of 11] RAFP: fix stale issue with threads In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1202208797 -3600 # Node ID c49e722599eee4b1fb6296b1da6e64c0d879d829 # Parent 639072fe628db4eb506e9af1d47cb0e90d5291ad RAFP: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 639072fe628d -r c49e722599ee src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Tue Feb 05 11:53:16 2008 +0100 +++ b/src/Virt_ResourceAllocationFromPool.c Tue Feb 05 11:53:17 2008 +0100 @@ -245,7 +245,7 @@ static CMPIStatus pool_to_rasd(const CMP LIBVIRT_CIM_DEFAULT_MAKEREF() -char* antecedent[] = { +static char* antecedent[] = { "Xen_ProcessorPool", "Xen_MemoryPool", "Xen_NetworkPool", @@ -257,7 +257,7 @@ char* antecedent[] = { NULL }; -char* dependent[] = { +static char* dependent[] = { "Xen_DiskResourceAllocationSettingData", "Xen_MemResourceAllocationSettingData", "Xen_NetResourceAllocationSettingData", @@ -269,7 +269,7 @@ char* dependent[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_ResourceAllocationFromPool", "KVM_ResourceAllocationFromPool", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:07 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:14:07 +0200 Subject: [Libvirt-cim] [PATCH 08 of 11] SDC: fix stale issue with threads In-Reply-To: Message-ID: <1208c17a1a11df7fd3fa.1202210047@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202208798 -3600 # Node ID 1208c17a1a11df7fd3fa118c6f222c95f4efd083 # Parent c49e722599eee4b1fb6296b1da6e64c0d879d829 SDC: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r c49e722599ee -r 1208c17a1a11 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Tue Feb 05 11:53:17 2008 +0100 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Feb 05 11:53:18 2008 +0100 @@ -827,13 +827,13 @@ static CMPIStatus rasd_to_alloc_cap(cons LIBVIRT_CIM_DEFAULT_MAKEREF() -char* group_component[] = { +static char* group_component[] = { "Xen_AllocationCapabilities", "KVM_AllocationCapabilities", NULL }; -char* part_component[] = { +static char* part_component[] = { "Xen_DiskResourceAllocationSettingData", "Xen_MemResourceAllocationSettingData", "Xen_NetResourceAllocationSettingData", @@ -845,13 +845,13 @@ char* part_component[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_SettingsDefineCapabilities", "KVM_SettingsDefineCapabilities", NULL }; -struct std_assoc _alloc_cap_to_rasd = { +static struct std_assoc _alloc_cap_to_rasd = { .source_class = (char**)&group_component, .source_prop = "GroupComponent", @@ -864,7 +864,7 @@ struct std_assoc _alloc_cap_to_rasd = { .make_ref = make_ref }; -struct std_assoc _rasd_to_alloc_cap = { +static struct std_assoc _rasd_to_alloc_cap = { .source_class = (char**)&part_component, .source_prop = "PartComponent", @@ -877,7 +877,7 @@ struct std_assoc _rasd_to_alloc_cap = { .make_ref = make_ref }; -struct std_assoc *assoc_handlers[] = { +static struct std_assoc *assoc_handlers[] = { &_alloc_cap_to_rasd, &_rasd_to_alloc_cap, NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 10:13:59 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:13:59 +0200 Subject: [Libvirt-cim] [PATCH 00 of 11] #2 - Fix stale issue with threads for assocs Message-ID: This patch set adds the missing static declarations to assocs. diff to patch set 1: - EC contained two typos From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:03 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:14:03 +0200 Subject: [Libvirt-cim] [PATCH 04 of 11] ESD: fix stale issue with threads In-Reply-To: Message-ID: <50e5e752477d1784421c.1202210043@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202208795 -3600 # Node ID 50e5e752477d1784421c0daa279df45958ae59d8 # Parent a74de7c13f806b7d9ba233c84c48277f7d1d92ce ESD: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r a74de7c13f80 -r 50e5e752477d src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Tue Feb 05 11:53:15 2008 +0100 +++ b/src/Virt_ElementSettingData.c Tue Feb 05 11:53:15 2008 +0100 @@ -160,13 +160,13 @@ static CMPIInstance *make_ref(const CMPI return refinst; } -char* virtual_system_setting_data[] = { +static char* virtual_system_setting_data[] = { "Xen_VirtualSystemSettingData", "KVM_VirtualSystemSettingData", NULL }; -char* resource_allocation_setting_data[] = { +static char* resource_allocation_setting_data[] = { "Xen_DiskResourceAllocationSettingData", "Xen_MemResourceAllocationSettingData", "Xen_NetResourceAllocationSettingData", @@ -178,7 +178,7 @@ char* resource_allocation_setting_data[] NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_ElementSettingData", "KVM_ElementSettingData", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:04 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:14:04 +0200 Subject: [Libvirt-cim] [PATCH 05 of 11] HRP: fix stale issue with threads In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1202208796 -3600 # Node ID ea9ba48df4ae5d383720b6dae6ed5d3176555bc8 # Parent 50e5e752477d1784421c0daa279df45958ae59d8 HRP: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 50e5e752477d -r ea9ba48df4ae src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Tue Feb 05 11:53:15 2008 +0100 +++ b/src/Virt_HostedResourcePool.c Tue Feb 05 11:53:16 2008 +0100 @@ -94,13 +94,13 @@ static CMPIStatus sys_to_pool(const CMPI LIBVIRT_CIM_DEFAULT_MAKEREF() -char* group_component[] = { +static char* group_component[] = { "Xen_HostSystem", "KVM_HostSystem", NULL }; -char* part_component[] = { +static char* part_component[] = { "Xen_ProcessorPool", "Xen_MemoryPool", "Xen_NetworkPool", @@ -112,13 +112,13 @@ char* part_component[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_HostedResourcePool", "KVM_HostedResourcePool", NULL }; -struct std_assoc forward = { +static struct std_assoc forward = { .source_class = (char**)&part_component, .source_prop = "PartComponent", @@ -131,7 +131,7 @@ struct std_assoc forward = { .make_ref = make_ref }; -struct std_assoc backward = { +static struct std_assoc backward = { .source_class = (char**)&group_component, .source_prop = "GroupComponent", @@ -144,7 +144,7 @@ struct std_assoc backward = { .make_ref = make_ref }; -struct std_assoc *assoc_handlers[] = { +static struct std_assoc *assoc_handlers[] = { &forward, &backward, NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:02 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:14:02 +0200 Subject: [Libvirt-cim] [PATCH 03 of 11] ECTP: fix stale issue with threads In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1202208795 -3600 # Node ID a74de7c13f806b7d9ba233c84c48277f7d1d92ce # Parent 760d970b2ff7ac3fdc15450e15f7ab4e937d94af ECTP: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 760d970b2ff7 -r a74de7c13f80 src/Virt_ElementConformsToProfile.c --- a/src/Virt_ElementConformsToProfile.c Tue Feb 05 11:53:00 2008 +0100 +++ b/src/Virt_ElementConformsToProfile.c Tue Feb 05 11:53:15 2008 +0100 @@ -192,13 +192,13 @@ static CMPIStatus elem_to_prof(const CMP LIBVIRT_CIM_DEFAULT_MAKEREF() -char* conformant_standard[] = { +static char* conformant_standard[] = { "Xen_RegisteredProfile", "KVM_RegisteredProfile", NULL }; -char* managed_element[] = { +static char* managed_element[] = { "Xen_HostSystem", "Xen_ComputerSystem", "KVM_HostSystem", @@ -206,13 +206,13 @@ char* managed_element[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_ElementConformsToProfile", "KVM_ElementConformsToProfile", NULL }; -struct std_assoc forward = { +static struct std_assoc forward = { .source_class = (char**)&conformant_standard, .source_prop = "ConformantStandard", @@ -225,7 +225,7 @@ struct std_assoc forward = { .make_ref = make_ref }; -struct std_assoc backward = { +static struct std_assoc backward = { .source_class = (char**)&managed_element, .source_prop = "ManagedElement", @@ -238,7 +238,7 @@ struct std_assoc backward = { .make_ref = make_ref }; -struct std_assoc *assoc_handlers[] = { +static struct std_assoc *assoc_handlers[] = { &forward, &backward, NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:10 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:14:10 +0200 Subject: [Libvirt-cim] [PATCH 11 of 11] VSSDC: fix stale issue with threads In-Reply-To: Message-ID: <0bbd401701982deb1926.1202210050@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202208799 -3600 # Node ID 0bbd401701982deb19263023b560415a2cb69360 # Parent 4bab53fec75afc0e3efdf25fbfcaa4a668182d71 VSSDC: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 4bab53fec75a -r 0bbd40170198 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Tue Feb 05 11:53:19 2008 +0100 +++ b/src/Virt_VSSDComponent.c Tue Feb 05 11:53:19 2008 +0100 @@ -154,13 +154,13 @@ static CMPIStatus rasd_to_vssd(const CMP LIBVIRT_CIM_DEFAULT_MAKEREF() -char* group_component[] = { +static char* group_component[] = { "Xen_VirtualSystemSettingData", "KVM_VirtualSystemSettingData", NULL }; -char* part_component[] = { +static char* part_component[] = { "Xen_DiskResourceAllocationSettingData", "Xen_MemResourceAllocationSettingData", "Xen_NetResourceAllocationSettingData", @@ -172,7 +172,7 @@ char* part_component[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_VirtualSystemSettingDataComponent", "KVM_VirtualSystemSettingDataComponent", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:05 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:14:05 +0200 Subject: [Libvirt-cim] [PATCH 06 of 11] HS: fix stale issue with threads In-Reply-To: Message-ID: <639072fe628db4eb506e.1202210045@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202208796 -3600 # Node ID 639072fe628db4eb506e9af1d47cb0e90d5291ad # Parent ea9ba48df4ae5d383720b6dae6ed5d3176555bc8 HS: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r ea9ba48df4ae -r 639072fe628d src/Virt_HostedService.c --- a/src/Virt_HostedService.c Tue Feb 05 11:53:16 2008 +0100 +++ b/src/Virt_HostedService.c Tue Feb 05 11:53:16 2008 +0100 @@ -128,13 +128,13 @@ static CMPIStatus host_to_service(const LIBVIRT_CIM_DEFAULT_MAKEREF() -char* antecedent[] = { +static char* antecedent[] = { "Xen_HostSystem", "KVM_HostSystem", NULL }; -char* dependent[] = { +static char* dependent[] = { "Xen_ResourcePoolConfigurationService", "Xen_VirtualSystemManagementService", "Xen_VirtualSystemMigrationService", @@ -144,7 +144,7 @@ char* dependent[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_HostedService", "KVM_HostedService", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:01 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:14:01 +0200 Subject: [Libvirt-cim] [PATCH 02 of 11] EC: fix stale issue with threads In-Reply-To: Message-ID: <760d970b2ff7ac3fdc15.1202210041@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202208780 -3600 # Node ID 760d970b2ff7ac3fdc15450e15f7ab4e937d94af # Parent 32d3353796600f7ee064b77ecca0d22d17e3104e EC: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 32d335379660 -r 760d970b2ff7 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Tue Feb 05 10:49:28 2008 +0100 +++ b/src/Virt_ElementCapabilities.c Tue Feb 05 11:53:00 2008 +0100 @@ -233,19 +233,19 @@ static CMPIStatus pool_to_alloc(const CM LIBVIRT_CIM_DEFAULT_MAKEREF() -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_ElementCapabilities", "KVM_ElementCapabilities", NULL }; -char* host_system[] = { +static char* host_system[] = { "Xen_HostSystem", "KVM_HostSystem", NULL }; -char* virtual_system_management_capabilities[] = { +static char* virtual_system_management_capabilities[] = { "Xen_VirtualSystemManagementCapabilities", "Xen_VirtualSystemMigrationCapabilities", "KVM_VirtualSystemManagementCapabilities", @@ -253,7 +253,7 @@ char* virtual_system_management_capabili NULL, }; -struct std_assoc system_to_vsm_cap = { +static struct std_assoc system_to_vsm_cap = { .source_class = (char**)&host_system, .source_prop = "ManagedElement", @@ -266,7 +266,7 @@ struct std_assoc system_to_vsm_cap = { .make_ref = make_ref }; -struct std_assoc vsm_cap_to_system = { +static struct std_assoc vsm_cap_to_system = { .source_class = (char**)&virtual_system_management_capabilities, .source_prop = "Capabilities", @@ -279,19 +279,19 @@ struct std_assoc vsm_cap_to_system = { .make_ref = make_ref }; -char* computer_system[] = { +static char* computer_system[] = { "Xen_ComputerSystem", "KVM_ComputerSystem", NULL }; -char* enabled_logical_element_capabilities[] = { +static char* enabled_logical_element_capabilities[] = { "Xen_EnabledLogicalElementCapabilities", "KVM_EnabledLogicalElementCapabilities", NULL }; -struct std_assoc ele_cap_to_cs = { +static struct std_assoc ele_cap_to_cs = { .source_class = (char**)&enabled_logical_element_capabilities, .source_prop = "Capabilities", @@ -304,7 +304,7 @@ struct std_assoc ele_cap_to_cs = { .make_ref = make_ref }; -struct std_assoc cs_to_ele_cap = { +static struct std_assoc cs_to_ele_cap = { .source_class = (char**)&computer_system, .source_prop = "ManagedElement", @@ -317,13 +317,13 @@ struct std_assoc cs_to_ele_cap = { .make_ref = make_ref }; -char* allocation_capabilities[] = { +static char* allocation_capabilities[] = { "Xen_AllocationCapabilities", "KVM_AllocationCapabilities", NULL }; -char* resource_pool[] = { +static char* resource_pool[] = { "Xen_ProcessorPool", "Xen_MemoryPool", "Xen_NetworkPool", @@ -335,7 +335,7 @@ char* resource_pool[] = { NULL }; -struct std_assoc alloc_cap_to_resource_pool = { +static struct std_assoc alloc_cap_to_resource_pool = { .source_class = (char**)&allocation_capabilities, .source_prop = "Capabilities", @@ -348,7 +348,7 @@ struct std_assoc alloc_cap_to_resource_p .make_ref = make_ref }; -struct std_assoc resource_pool_to_alloc_cap = { +static struct std_assoc resource_pool_to_alloc_cap = { .source_class = (char**)&resource_pool, .source_prop = "ManagedElement", @@ -361,7 +361,7 @@ struct std_assoc resource_pool_to_alloc_ .make_ref = make_ref }; -struct std_assoc *assoc_handlers[] = { +static struct std_assoc *assoc_handlers[] = { &system_to_vsm_cap, &vsm_cap_to_system, &ele_cap_to_cs, From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:08 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:14:08 +0200 Subject: [Libvirt-cim] [PATCH 09 of 11] SDS: fix stale issue with threads In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1202208798 -3600 # Node ID ca631d19373b61f60e83eddc4be4ca4176653647 # Parent 1208c17a1a11df7fd3fa118c6f222c95f4efd083 SDS: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 1208c17a1a11 -r ca631d19373b src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Tue Feb 05 11:53:18 2008 +0100 +++ b/src/Virt_SettingsDefineState.c Tue Feb 05 11:53:18 2008 +0100 @@ -290,7 +290,7 @@ static CMPIStatus vssd_to_vs(const CMPIO LIBVIRT_CIM_DEFAULT_MAKEREF() -char* logical_device[] = { +static char* logical_device[] = { "Xen_Processor", "Xen_Memory", "Xen_NetworkPort", @@ -302,7 +302,7 @@ char* logical_device[] = { NULL }; -char* resource_allocation_setting_data[] = { +static char* resource_allocation_setting_data[] = { "Xen_DiskResourceAllocationSettingData", "Xen_MemResourceAllocationSettingData", "Xen_NetResourceAllocationSettingData", @@ -314,19 +314,19 @@ char* resource_allocation_setting_data[] NULL }; -char* computer_system[] = { +static char* computer_system[] = { "Xen_ComputerSystem", "KVM_ComputerSystem", NULL }; -char* virtual_system_setting_data[] = { +static char* virtual_system_setting_data[] = { "Xen_VirtualSystemSettingData", "KVM_VirtualSystemSettingData", NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_SettingsDefineState", "KVM_SettingsDefineState", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:09 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:14:09 +0200 Subject: [Libvirt-cim] [PATCH 10 of 11] SD: fix stale issue with threads In-Reply-To: Message-ID: <4bab53fec75afc0e3efd.1202210049@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202208799 -3600 # Node ID 4bab53fec75afc0e3efdf25fbfcaa4a668182d71 # Parent ca631d19373b61f60e83eddc4be4ca4176653647 SD: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r ca631d19373b -r 4bab53fec75a src/Virt_SystemDevice.c --- a/src/Virt_SystemDevice.c Tue Feb 05 11:53:18 2008 +0100 +++ b/src/Virt_SystemDevice.c Tue Feb 05 11:53:19 2008 +0100 @@ -210,13 +210,13 @@ static CMPIStatus dev_to_sys(const CMPIO LIBVIRT_CIM_DEFAULT_MAKEREF() -char* group_component[] = { +static char* group_component[] = { "Xen_ComputerSystem", "KVM_ComputerSystem", NULL }; -char* part_component[] = { +static char* part_component[] = { "Xen_Processor", "Xen_Memory", "Xen_NetworkPort", @@ -228,7 +228,7 @@ char* part_component[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_SystemDevice", "KVM_SystemDevice", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 10:14:00 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 12:14:00 +0200 Subject: [Libvirt-cim] [PATCH 01 of 11] EAFP: fix stale issue with threads In-Reply-To: Message-ID: <32d3353796600f7ee064.1202210040@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202204968 -3600 # Node ID 32d3353796600f7ee064b77ecca0d22d17e3104e # Parent 108f192632bfd801a1f0520b8f20341a2c3a2f53 EAFP: fix stale issue with threads Signed-off-by: Heidi Eckhart diff -r 108f192632bf -r 32d335379660 src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Mon Feb 04 08:35:03 2008 -0800 +++ b/src/Virt_ElementAllocatedFromPool.c Tue Feb 05 10:49:28 2008 +0100 @@ -228,7 +228,7 @@ static CMPIStatus pool_to_vdev(const CMP LIBVIRT_CIM_DEFAULT_MAKEREF() -char* antecedent[] = { +static char* antecedent[] = { "Xen_ProcessorPool", "Xen_MemoryPool", "Xen_NetworkPool", @@ -240,7 +240,7 @@ char* antecedent[] = { NULL }; -char* dependent[] = { +static char* dependent[] = { "Xen_Processor", "Xen_Memory", "Xen_NetworkPort", @@ -252,7 +252,7 @@ char* dependent[] = { NULL }; -char* assoc_classname[] = { +static char* assoc_classname[] = { "Xen_ElementAllocatedFromPool", "KVM_ElementAllocatedFromPool", NULL From heidieck at linux.vnet.ibm.com Tue Feb 5 11:38:11 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 13:38:11 +0200 Subject: [Libvirt-cim] [PATCH 0 of 2] SD: check client given object path Message-ID: To enable the check of the client's given object path for Devices, the first tiny reorg in the Device provider is necessary. Thereby the get_device() function is made available for external use. The second patch fixes the missing check of the client's given object in SystemDevice provider - for both directions. From heidieck at linux.vnet.ibm.com Tue Feb 5 11:38:13 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 13:38:13 +0200 Subject: [Libvirt-cim] [PATCH 2 of 2] SD: does not check client given object path In-Reply-To: Message-ID: <360734df2cd2eabbc2a2.1202215093@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202215071 -3600 # Node ID 360734df2cd2eabbc2a2a9095a95d022f6c4130f # Parent 9163192a3407b4b0f02ab15d291830f52b5261fa SD: does not check client given object path wbemrin -arc CIM_SystemDevice 'http://localhost/root/virt:KVM_ComputerSystem.CreationClassName="KVM_ComputerSystem",Name="wrong"' returns nothing instead of NOT_FOUND. The object path for devices is also not checked. Signed-off-by: Heidi Eckhart diff -r 9163192a3407 -r 360734df2cd2 src/Virt_SystemDevice.c --- a/src/Virt_SystemDevice.c Tue Feb 05 13:33:41 2008 +0100 +++ b/src/Virt_SystemDevice.c Tue Feb 05 13:37:51 2008 +0100 @@ -134,10 +134,15 @@ static CMPIStatus sys_to_dev(const CMPIO { const char *host = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; int ret; if (!match_hypervisor_prefix(ref, info)) return s; + + s = get_domain(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "Name", &host) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, @@ -171,10 +176,15 @@ static CMPIStatus dev_to_sys(const CMPIO char *host = NULL; char *dev = NULL; CMPIInstance *sys; + CMPIInstance *inst = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; if (!match_hypervisor_prefix(ref, info)) return s; + + s = get_device(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "DeviceID", &devid) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, From heidieck at linux.vnet.ibm.com Tue Feb 5 11:38:12 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 05 Feb 2008 13:38:12 +0200 Subject: [Libvirt-cim] [PATCH 1 of 2] Device: make get_device() function available for use by SD assoc In-Reply-To: Message-ID: <9163192a3407b4b0f02a.1202215092@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1202214821 -3600 # Node ID 9163192a3407b4b0f02ab15d291830f52b5261fa # Parent 0bbd401701982deb19263023b560415a2cb69360 Device: make get_device() function available for use by SD assoc Signed-off-by: Heidi Eckhart diff -r 0bbd40170198 -r 9163192a3407 src/Virt_Device.c --- a/src/Virt_Device.c Tue Feb 05 11:53:19 2008 +0100 +++ b/src/Virt_Device.c Tue Feb 05 13:33:41 2008 +0100 @@ -451,47 +451,70 @@ CMPIInstance *instance_from_devid(const return instance; } -static CMPIStatus get_device(const CMPIObjectPath *reference, - const CMPIResult *results, - const char *devid) +CMPIStatus get_device(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; virConnectPtr conn; CMPIInstance *inst; const char *cn; + const char *devid; cn = CLASSNAME(reference); - conn = connect_by_classname(_BROKER, cn, &s); + conn = connect_by_classname(broker, cn, &s); if (conn == NULL) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, "No such instance"); goto out; - } - - inst = instance_from_devid(_BROKER, + } + + if (cu_get_str_path(reference, "DeviceID", &devid) != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "No DeviceID specified"); + goto out; + } + + inst = instance_from_devid(broker, conn, devid, NAMESPACE(reference), device_type_from_classname(cn)); if (inst == NULL) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, "No such instance (%s)", devid); goto out; } - s = cu_validate_ref(_BROKER, reference, inst); + s = cu_validate_ref(broker, reference, inst); if (s.rc != CMPI_RC_OK) goto out; - CMReturnInstance(results, inst); + *_inst = inst; out: virConnectClose(conn); return s; +} + +static CMPIStatus return_device(const CMPIResult *results, + const CMPIObjectPath *reference) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_device(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK || inst == NULL) + return s; + + CMReturnInstance(results, inst); + + return s; } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -517,19 +540,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - const char *devid; - - if (cu_get_str_path(reference, "DeviceID", &devid) != CMPI_RC_OK) { - CMPIStatus s; - - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No DeviceID specified"); - - return s; - } - - return get_device(reference, results, devid); + return return_device(results, reference); } DEFAULT_CI(); diff -r 0bbd40170198 -r 9163192a3407 src/Virt_Device.h --- a/src/Virt_Device.h Tue Feb 05 11:53:19 2008 +0100 +++ b/src/Virt_Device.h Tue Feb 05 13:33:41 2008 +0100 @@ -42,6 +42,19 @@ int dom_devices(const CMPIBroker *broker struct inst_list *list); /** + * Returns the device instance defined by the reference + * + * @param broker A pointer to the CIM broker + * @param reference The object path identifying the instance + * @param inst Contains the pointer to the instance in case + * of success + * @returns CMPIStatus of the operation + */ +CMPIStatus get_device(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); + +/** * Return a device instance for a given devid * * @param broker A pointer to the CIM broker From grendel at linux.vnet.ibm.com Tue Feb 5 14:21:40 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 09:21:40 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: <47A8415E.1000809@linux.vnet.ibm.com> References: <87odb0sjcq.fsf@caffeine.beaverton.ibm.com> <47A352B4.4030909@linux.vnet.ibm.com> <87ejbwsady.fsf@caffeine.beaverton.ibm.com> <47A8415E.1000809@linux.vnet.ibm.com> Message-ID: <47A870F4.1030109@linux.vnet.ibm.com> Heidi Eckhart wrote: > Dan Smith wrote: >> JG> I'm pleading CIM ignorance on this one. I thought the ObjectPath >> JG> encompassed the properties, and thought that my testing showed it >> JG> happening (I don't manually move the JobState over but it is est), >> JG> but I could have been wrong. >> >> You're only half ignorant here :) >> >> The ObjectPath has the key properties, but not the rest. >> >> > But it can also be, that some of the none-key properties contain a > value. This happens, if within the DMTF's mof files a default value > was defined. Might this be for JobState ? > Right on the money. I was looking for something that didn't appear to copy correctly, in order to confirm the fix when I'm done working on cu_dup_instance, and JobState was the first one I found. -- -Jay From grendel at linux.vnet.ibm.com Tue Feb 5 14:27:17 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 09:27:17 -0500 Subject: [Libvirt-cim] [PATCH] HostSystem: fix style issue with parameter naming In-Reply-To: <083ff6db76d5b5efd04d.1202203784@localhost.localdomain> References: <083ff6db76d5b5efd04d.1202203784@localhost.localdomain> Message-ID: <47A87245.9070201@linux.vnet.ibm.com> Heidi Eckhart wrote: > # HG changeset patch > # User Heidi Eckhart > # Date 1202203758 -3600 > # Node ID 083ff6db76d5b5efd04d094bc4f9736b1c11c50c > # Parent bd791ff33ba623d1355ca26b3876df0b32ad2d4b > HostSystem: fix style issue with parameter naming > > renamed getInstance to is_get_inst for style conformance > > Signed-off-by: Heidi Eckhart > > > Obviously no problems here. +1 -- -Jay From grendel at linux.vnet.ibm.com Tue Feb 5 14:41:09 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 09:41:09 -0500 Subject: [Libvirt-cim] [PATCH 00 of 11] #2 - Fix stale issue with threads for assocs In-Reply-To: References: Message-ID: <47A87585.60108@linux.vnet.ibm.com> Heidi Eckhart wrote: > This patch set adds the missing static declarations to assocs. > > diff to patch set 1: > - EC contained two typos > > Set looks good to me. Thanks for taking care of this, Heidi. +1 -- -Jay From kaitlin at linux.vnet.ibm.com Tue Feb 5 14:45:46 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 06:45:46 -0800 Subject: [Libvirt-cim] [PATCH 0 of 4] #3 - RPCS and RPCC ignores supported hypervisor type and wrong object path, adopt changes to HS In-Reply-To: References: Message-ID: <47A8769A.7030304@linux.vnet.ibm.com> Heidi Eckhart wrote: > This patch set is now the combination of the one patch against RPCS and the two patches against RPCC, I sent out on friday. The reason to combine these three patches in one patch set is, that both provider - RPCS and RPCC - look very similar now. This brought me to the idea, that it is possible to also define a common interface for instances providers - as this is already done for associations -, where the common functions could do a main part of the error handling (which is currently done again and again in each single provider itself). > In addition patch 4 updates HS (thanks to Kaitlin) with the new interface of RPCS. > > diff to patch set 2: > - renamed parameter getInstance to is_get_inst for style conformance > I think this set looks good - style issues fixed. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Tue Feb 5 15:26:14 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 07:26:14 -0800 Subject: [Libvirt-cim] [PATCH 00 of 11] #2 - Fix stale issue with threads for assocs In-Reply-To: References: Message-ID: <47A88016.7010407@linux.vnet.ibm.com> I tested out this set - looks good. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Tue Feb 5 15:55:27 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 07:55:27 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] SD: check client given object path In-Reply-To: References: Message-ID: <47A886EF.9070106@linux.vnet.ibm.com> Heidi Eckhart wrote: > To enable the check of the client's given object path for Devices, the first tiny reorg in the Device provider is necessary. Thereby the get_device() function is made available for external use. > The second patch fixes the missing check of the client's given object in SystemDevice provider - for both directions. > This looks fine and tested fine for me. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From grendel at linux.vnet.ibm.com Tue Feb 5 18:54:08 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 13:54:08 -0500 Subject: [Libvirt-cim] [PATCH 2 of 2] [CU] Improve std_indication's raise functionality In-Reply-To: Message-ID: <0f243b1c487b137583b5.1202237648@naegling> # HG changeset patch # User Jay Gagnon # Date 1202236788 18000 # Node ID 0f243b1c487b137583b5990e3ee97fac3a7f5a78 # Parent f9065b274d0a1e689f8e0b4d8d5ca0642db470f6 [CU] Improve std_indication's raise functionality Turns out STDI_IndicationMIStub was not creating the CMPIFooMIFTs correctly; this patch fixes that. It also adds a default_raise function to std_indication. This is for indication providers that don't need to do anything other than call CBDeliverIndication, which will most likely be the majority. Signed-off-by: Jay Gagnon diff -r f9065b274d0a -r 0f243b1c487b std_indication.c --- a/std_indication.c Tue Feb 05 13:39:45 2008 -0500 +++ b/std_indication.c Tue Feb 05 13:39:48 2008 -0500 @@ -19,6 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include @@ -40,19 +41,40 @@ static CMPIStatus trigger(struct std_ind return ctx->handler->trigger_fn(context); } +static CMPIStatus default_raise(const CMPIBroker *broker, + const CMPIContext *context, + CMPIInstance *ind) +{ + CMPIObjectPath *ref; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + ref = CMGetObjectPath(ind, NULL); + + CBDeliverIndication(broker, + context, + NAMESPACE(ref), + ind); + return s; +} + static CMPIStatus raise(struct std_indication_ctx *ctx, const CMPIContext *context, const CMPIArgs *argsin) { CMPIInstance *inst; - if (ctx->handler->raise_fn == NULL) - return (CMPIStatus){CMPI_RC_OK, NULL}; + if (!ctx->enabled) { + CU_DEBUG("Indication disabled, not raising."); + return (CMPIStatus) {CMPI_RC_OK, NULL}; + } if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK) return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL}; - return ctx->handler->raise_fn(context, inst); + if (ctx->handler->raise_fn == NULL) + return default_raise(ctx->brkr, context, inst); + + return ctx->handler->raise_fn(ctx->brkr, context, inst); } CMPIStatus stdi_handler(CMPIMethodMI *self, diff -r f9065b274d0a -r 0f243b1c487b std_indication.h --- a/std_indication.h Tue Feb 05 13:39:45 2008 -0500 +++ b/std_indication.h Tue Feb 05 13:39:48 2008 -0500 @@ -24,6 +24,7 @@ #include #include #include +#include #include "libcmpiutil.h" #include "std_invokemethod.h" @@ -51,7 +52,8 @@ CMPIStatus stdi_cleanup(CMPIMethodMI *se const CMPIContext *context, CMPIBoolean terminating); -typedef CMPIStatus (*raise_indication_t)(const CMPIContext *ctx, +typedef CMPIStatus (*raise_indication_t)(const CMPIBroker *broker, + const CMPIContext *ctx, const CMPIInstance *ind); typedef CMPIStatus (*trigger_indication_t)(const CMPIContext *ctx); @@ -64,14 +66,44 @@ struct std_indication_ctx { struct std_indication_ctx { const CMPIBroker *brkr; struct std_indication_handler *handler; + bool enabled; }; #define STDI_IndicationMIStub(pfx, pn, _broker, hook, _handler) \ + static struct std_indication_ctx _ctx = { \ + .brkr = NULL, \ + .handler = _handler, \ + .enabled = false, \ + }; \ + \ + static CMPIIndicationMIFT indMIFT__ = { \ + CMPICurrentVersion, \ + CMPICurrentVersion, \ + "Indication" #pn, \ + pfx##IndicationCleanup, \ + pfx##AuthorizeFilter, \ + pfx##MustPoll, \ + pfx##ActivateFilter, \ + pfx##DeActivateFilter, \ + CMIndicationMIStubExtensions(pfx) \ + }; \ CMPIIndicationMI * \ pn##_Create_IndicationMI(const CMPIBroker *, \ - const CMPIContext *, \ - CMPIStatus *); \ - CMIndicationMIStub(pfx, pn, _broker, hook); \ + const CMPIContext *, \ + CMPIStatus *); \ + CMPIIndicationMI * \ + pn##_Create_IndicationMI(const CMPIBroker *brkr, \ + const CMPIContext *ctx, \ + CMPIStatus *rc) { \ + static CMPIIndicationMI mi = { \ + &_ctx, \ + &indMIFT__, \ + }; \ + _ctx.brkr = brkr; \ + _broker = brkr; \ + hook; \ + return &mi; \ + } \ \ static CMPIMethodMIFT methMIFT__ = { \ CMPICurrentVersion, \ @@ -88,13 +120,11 @@ struct std_indication_ctx { CMPIMethodMI *pn##_Create_MethodMI(const CMPIBroker *brkr, \ const CMPIContext *ctx, \ CMPIStatus *rc) { \ - static struct std_indication_ctx _ctx; \ static CMPIMethodMI mi = { \ &_ctx, \ &methMIFT__, \ }; \ _ctx.brkr = brkr; \ - _ctx.handler = _handler; \ _broker = brkr; \ hook; \ return &mi; \ From grendel at linux.vnet.ibm.com Tue Feb 5 18:54:07 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 13:54:07 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: Message-ID: # HG changeset patch # User Jay Gagnon # Date 1202236785 18000 # Node ID f9065b274d0a1e689f8e0b4d8d5ca0642db470f6 # Parent ab0e3b05a10e7b5db7eb493920f01bb402d2feae [CU] Add dup_instance function to libcmpiutil It appears there are some situations where we have to duplicate an instance; this seemed like the kind of thing that would belong in libcmpiutil. Changes from #1 to #2: cu dup_instance returns instance, sets status using pointer cu_dup_instance copies all properties Signed-off-by: Jay Gagnon diff -r ab0e3b05a10e -r f9065b274d0a instance_util.c --- a/instance_util.c Wed Jan 30 11:15:32 2008 -0800 +++ b/instance_util.c Tue Feb 05 13:39:45 2008 -0500 @@ -202,6 +202,52 @@ CMPIStatus cu_copy_prop(const CMPIBroker out: return s; +} + +CMPIInstance *cu_dup_instance(const CMPIBroker *broker, + CMPIInstance *src, + CMPIStatus *s) +{ + int i; + int prop_count; + CMPIData data; + CMPIObjectPath *ref; + CMPIInstance *dest = NULL; + + ref = CMGetObjectPath(src, NULL); + if ((s->rc != CMPI_RC_OK) || CMIsNullObject(ref)) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Could not get objectpath from instance"); + goto out; + } + + dest = CMNewInstance(broker, ref, s); + + prop_count = CMGetPropertyCount(src, s); + if (s->rc != CMPI_RC_OK) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Could not get property count for copy"); + goto out; + } + + for (i = 0; i < prop_count; i++) { + CMPIString *prop_name; + data = CMGetPropertyAt(src, i, &prop_name, s); + if (s->rc != CMPI_RC_OK) { + goto out; + } + + *s = CMSetProperty(dest, (char *)(prop_name->hdl), + &(data.value), data.type); + if (s->rc != CMPI_RC_OK) { + goto out; + } + } + + out: + return dest; } /* diff -r ab0e3b05a10e -r f9065b274d0a libcmpiutil.h --- a/libcmpiutil.h Wed Jan 30 11:15:32 2008 -0800 +++ b/libcmpiutil.h Tue Feb 05 13:39:45 2008 -0500 @@ -164,6 +164,18 @@ CMPIrc cu_get_u16_path(const CMPIObjectP CMPIrc cu_get_u16_path(const CMPIObjectPath *reference, const char *key, uint16_t *target); + +/** + * Create a copy of an instance + * + * @param src Source instance + * @param dest Destination instance + * @returns {CMPI_RC_OK, NULL} if success, CMPI_RC ERR_FAILED and + * error message otherwise + */ +CMPIInstance *cu_dup_instance(const CMPIBroker *broker, + CMPIInstance *src, + CMPIStatus *s); /* Forward declaration */ struct inst_list; From grendel at linux.vnet.ibm.com Tue Feb 5 18:54:06 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 13:54:06 -0500 Subject: [Libvirt-cim] [PATCH 0 of 2] (#2) [CU] Migration Indication libcmpiutil changes Message-ID: Just fixing up the complaints from last time. Fixes are detailed per patch. From grendel at linux.vnet.ibm.com Tue Feb 5 18:59:21 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 13:59:21 -0500 Subject: [Libvirt-cim] [PATCH 0 of 2] (#2) MigrationIndications Message-ID: 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. From grendel at linux.vnet.ibm.com Tue Feb 5 18:59:23 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 13:59:23 -0500 Subject: [Libvirt-cim] [PATCH 2 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider In-Reply-To: Message-ID: # HG changeset patch # User Jay Gagnon # Date 1202224718 18000 # Node ID c24b2e6d1bce44af234d379cfc8b7ee116621109 # Parent fdce6fa993b5a9dce654b3e0cf527599f86b9f67 Add calls into VSMigrationService to utilize new MigrationIndication provider. Changes from #1 to #2: Break out indication code from migration_job_set_state. Changed cu_dup_instance call to match new signature. Signed-off-by: Jay Gagnon diff -r fdce6fa993b5 -r c24b2e6d1bce src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Tue Feb 05 10:18:37 2008 -0500 +++ b/src/Virt_VSMigrationService.c Tue Feb 05 10:18:38 2008 -0500 @@ -34,6 +34,7 @@ #include "misc_util.h" #include #include +#include #include "Virt_VSMigrationService.h" #include "Virt_HostSystem.h" @@ -264,11 +265,76 @@ static CMPIStatus vs_migratable_system(C return vs_migratable(ref, name, dname, results, argsout); } +static bool raise_indication(const CMPIContext *context, + const char *base_type, + const char *ns, + CMPIInstance *inst, + const CMPIInstance *ind) +{ + char *type; + CMPIStatus s; + + CU_DEBUG("Setting SourceInstance"); + CMSetProperty(ind, "SourceInstance", + (CMPIValue *)&inst, CMPI_instance); + + /* Seems like this shouldn't be hardcoded. */ + type = get_typed_class("Xen", base_type); + + s = stdi_raise_indication(_BROKER, context, type, ns, ind); + + free(type); + + return s.rc == CMPI_RC_OK; +} + +static CMPIInstance *prepare_indication(const CMPIBroker *broker, + CMPIInstance *inst, + char *ns, + CMPIStatus *s) +{ + CMPIInstance *ind = NULL; + CMPIInstance *prev_inst = NULL; + + CU_DEBUG("Creating indication."); + /* Prefix needs to be dynamic */ + ind = get_typed_instance(broker, + "Xen", + "ComputerSystemMigrationIndication", + ns); + /* Prefix needs to be dynamic */ + if (ind == NULL) { + CU_DEBUG("Failed to create ind, type '%s:%s_%s'", + ns, + "Xen", + "ComputerSystemMigrationIndication"); + } + + /* Need to copy job inst before attaching as PreviousInstance because + otherwise the changes we are about to make to job inst are made + to PreviousInstance as well. */ + prev_inst = cu_dup_instance(_BROKER, inst, s); + if (s->rc != CMPI_RC_OK || prev_inst == NULL) { + CU_DEBUG("dup_instance failed (%i:%s)", s->rc, s->msg); + ind = NULL; + goto out; + } + + CU_DEBUG("Setting PreviousInstance"); + CMSetProperty(ind, "PreviousInstance", + (CMPIValue *)&prev_inst, CMPI_instance); + + out: + return ind; +} + static void migrate_job_set_state(struct migration_job *job, uint16_t state, const char *status) { CMPIInstance *inst; + CMPIInstance *ind; + bool rc; CMPIStatus s; CMPIObjectPath *op; @@ -292,6 +358,8 @@ static void migrate_job_set_state(struct return; } + ind = prepare_indication(_BROKER, inst, job->ref_ns, &s); + CMSetProperty(inst, "JobState", (CMPIValue *)&state, CMPI_uint16); CMSetProperty(inst, "Status", @@ -303,6 +371,14 @@ static void migrate_job_set_state(struct if (s.rc != CMPI_RC_OK) CU_DEBUG("Failed to update job instance: %s", CMGetCharPtr(s.msg)); + + rc = raise_indication(job->context, + "ComputerSystemMigrationIndication", + job->ref_ns, + inst, + ind); + if (!rc) + CU_DEBUG("Failed to raise indication"); } static CMPIStatus migrate_vs(struct migration_job *job) From grendel at linux.vnet.ibm.com Tue Feb 5 18:59:22 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 13:59:22 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] (#2) ComputerSystemMigrationIndication In-Reply-To: Message-ID: # HG changeset patch # User Jay Gagnon # Date 1202224717 18000 # Node ID fdce6fa993b5a9dce654b3e0cf527599f86b9f67 # Parent c2ff6825e25f513417f395ea334f4f7963f2729c (#2) ComputerSystemMigrationIndication Indication to keep clients up to date on CS migrations, along with relevant makefile and schema work. Changes from #1 to #2: Fix author field Signed-off-by: Jay Gagnon diff -r c2ff6825e25f -r fdce6fa993b5 Makefile.am --- a/Makefile.am Mon Feb 04 09:53:29 2008 -0800 +++ b/Makefile.am Tue Feb 05 10:18:37 2008 -0500 @@ -24,6 +24,7 @@ MOFS = \ schema/RegisteredProfile.mof \ schema/ElementConformsToProfile.mof \ schema/ComputerSystemIndication.mof \ + schema/ComputerSystemMigrationIndication.mof \ schema/ResourceAllocationSettingData.mof \ schema/ResourcePoolConfigurationService.mof \ schema/ResourcePoolConfigurationCapabilities.mof \ @@ -65,6 +66,7 @@ REGS = \ schema/DiskPool.registration \ schema/HostedResourcePool.registration \ schema/ComputerSystemIndication.registration \ + schema/ComputerSystemMigrationIndication.registration \ schema/ResourceAllocationSettingData.registration \ schema/ResourcePoolConfigurationService.registration \ schema/ResourcePoolConfigurationCapabilities.registration \ @@ -109,4 +111,4 @@ clean-local: clean-local: rm -f $(find . -name "*.orig") rm -f $(find . -name "*.rej") - rm -f $(find . -name "*~") \ No newline at end of file + rm -f $(find . -name "*~") diff -r c2ff6825e25f -r fdce6fa993b5 schema/ComputerSystemMigrationIndication.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/ComputerSystemMigrationIndication.mof Tue Feb 05 10:18:37 2008 -0500 @@ -0,0 +1,15 @@ +// Copyright IBM Corp. 2007 + +[Description ("Xen_ComputerSystem migration status"), + Provider("cmpi::Virt_ComputerSystemModificationIndication") +] +class Xen_ComputerSystemMigrationIndication : CIM_InstModification +{ +}; + +[Description ("KVM_ComputerSystem migration status"), + Provider("cmpi::Virt_ComputerSystemModificationIndication") +] +class KVM_ComputerSystemMigrationIndication : CIM_InstModification +{ +}; diff -r c2ff6825e25f -r fdce6fa993b5 schema/ComputerSystemMigrationIndication.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/ComputerSystemMigrationIndication.registration Tue Feb 05 10:18:37 2008 -0500 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndication Virt_ComputerSystemMigrationIndication indication method +KVM_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndication Virt_ComputerSystemMigrationIndication indication method diff -r c2ff6825e25f -r fdce6fa993b5 src/Makefile.am --- a/src/Makefile.am Mon Feb 04 09:53:29 2008 -0800 +++ b/src/Makefile.am Tue Feb 05 10:18:37 2008 -0500 @@ -30,6 +30,7 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_Device.la \ libVirt_SystemDevice.la \ libVirt_ComputerSystemIndication.la \ + libVirt_ComputerSystemMigrationIndication.la \ libVirt_RASD.la \ libVirt_HostSystem.la \ libVirt_VirtualSystemManagementService.la \ @@ -61,6 +62,10 @@ libVirt_ComputerSystemIndication_la_DEPE libVirt_ComputerSystemIndication_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_ComputerSystemIndication_la_SOURCES = Virt_ComputerSystemIndication.c libVirt_ComputerSystemIndication_la_LIBADD = -lVirt_ComputerSystem -lpthread -lrt + +libVirt_ComputerSystemMigrationIndication_la_DEPENDENCIES = libVirt_ComputerSystem.la +libVirt_ComputerSystemMigrationIndication_la_SOURCES = Virt_ComputerSystemMigrationIndication.c +libVirt_ComputerSystemMigrationIndication_la_LIBADD = -lVirt_ComputerSystem libVirt_VirtualSystemManagementService_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_ComputerSystemIndication.la libVirt_RASD.la libVirt_HostSystem.la libVirt_VirtualSystemManagementService_la_SOURCES = Virt_VirtualSystemManagementService.c diff -r c2ff6825e25f -r fdce6fa993b5 src/Virt_ComputerSystemMigrationIndication.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_ComputerSystemMigrationIndication.c Tue Feb 05 10:18:37 2008 -0500 @@ -0,0 +1,120 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Jay Gagnon + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "config.h" + +#include "Virt_ComputerSystem.h" + +static const CMPIBroker *_BROKER; + +#ifdef CMPI_EI_VOID +# define _EI_RTYPE void +# define _EI_RET() return +#else +# define _EI_RTYPE CMPIStatus +# define _EI_RET() return (CMPIStatus){CMPI_RC_OK, NULL} +#endif + +static CMPIStatus ActivateFilter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean first) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + return s; +} + +static CMPIStatus DeActivateFilter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean last) +{ + return (CMPIStatus){CMPI_RC_OK, NULL}; +} + +static _EI_RTYPE EnableIndications(CMPIIndicationMI* mi, + const CMPIContext *ctx) +{ + struct std_indication_ctx *_ctx; + _ctx = (struct std_indication_ctx *)mi->hdl; + _ctx->enabled = true; + CU_DEBUG("ComputerSystemModifiedIndication enabled"); + + _EI_RET(); +} + +static _EI_RTYPE DisableIndications(CMPIIndicationMI* mi, + const CMPIContext *ctx) +{ + struct std_indication_ctx *_ctx; + _ctx = (struct std_indication_ctx *)mi->hdl; + _ctx->enabled = false; + CU_DEBUG("ComputerSystemModifiedIndication disabled"); + + _EI_RET(); +} + +static struct std_indication_handler csi = { + .raise_fn = NULL, + .trigger_fn = NULL, +}; + +DEFAULT_IND_CLEANUP(); +DEFAULT_AF(); +DEFAULT_MP(); + +STDI_IndicationMIStub(, + Virt_ComputerSystemMigrationIndication, + _BROKER, + libvirt_cim_init(), + &csi); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From grendel at linux.vnet.ibm.com Tue Feb 5 20:06:23 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 15:06:23 -0500 Subject: [Libvirt-cim] [PATCH] Update author field on CSI Message-ID: # HG changeset patch # User Jay Gagnon # Date 1202241964 18000 # Node ID c286514082efd898f008a21fc8f27d299bd95fa4 # Parent c24b2e6d1bce44af234d379cfc8b7ee116621109 Update author field on CSI How's this for an egocentric patch? Signed-off-by: Jay Gagnon diff -r c24b2e6d1bce -r c286514082ef src/Virt_ComputerSystemIndication.c --- a/src/Virt_ComputerSystemIndication.c Tue Feb 05 10:18:38 2008 -0500 +++ b/src/Virt_ComputerSystemIndication.c Tue Feb 05 15:06:04 2008 -0500 @@ -3,6 +3,7 @@ * * Authors: * Dan Smith + * Jay Gagnon * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public From danms at us.ibm.com Tue Feb 5 20:31:41 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 05 Feb 2008 12:31:41 -0800 Subject: [Libvirt-cim] [PATCH] Make the ProcRASD show CPU pinning information Message-ID: # HG changeset patch # User Dan Smith # Date 1202243439 28800 # Node ID e6d442b5bf122889708e9ad24545ae0b42b8c3bb # Parent f8ee9b04d92abf1d74bf4c72fac1f3a4128923dd 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. Signed-off-by: Dan Smith diff -r f8ee9b04d92a -r e6d442b5bf12 src/Virt_RASD.c --- a/src/Virt_RASD.c Tue Feb 05 13:37:51 2008 +0100 +++ b/src/Virt_RASD.c Tue Feb 05 12:30:39 2008 -0800 @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -91,6 +92,158 @@ char *rasd_to_xml(CMPIInstance *rasd) { /* FIXME: Remove this */ return NULL; +} + +static bool proc_set_physical_ref(const CMPIBroker *broker, + uint32_t physnum, + CMPIInstance *rasd) +{ + CMPIObjectPath *op = NULL; + CMPIStatus s; + char hostname[255]; + char *devid = NULL; + CMPIArray *array; + 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; + } + + array = CMNewArray(broker, 1, CMPI_instance, &s); + if ((array == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to make array"); + goto out; + } + + CMSetArrayElementAt(array, 0, (CMPIValue *)&inst, CMPI_instance); + CMSetProperty(rasd, "HostResource", + (CMPIValue *)&array, CMPI_instanceA); + + result = true; + out: + free(devid); + + return result; +} + +static uint32_t proc_get_cpu(const CMPIBroker *broker, + virDomainPtr dom, + struct virt_device *dev) +{ + virVcpuInfoPtr vinfo = NULL; + virDomainInfo info; + int ret; + uint32_t cpu = -1; + + 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; + } + + ret = virDomainGetVcpus(dom, vinfo, info.nrVirtCpu, NULL, 0); + if (ret < info.nrVirtCpu) { + CU_DEBUG("Failed to get VCPU info for %s", + virDomainGetName(dom)); + goto out; + } + + cpu = vinfo[dev->dev.vcpu.number].cpu; + + CU_DEBUG("VCPU %i is pinned to CPU %i", + dev->dev.vcpu.number, + cpu); + out: + free(vinfo); + + return cpu; +} + +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; + CMPIStatus s; + uint32_t pcpu; + + 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; + } + + pcpu = proc_get_cpu(broker, dom, dev); + if (pcpu >= 0) + proc_set_physical_ref(broker, pcpu, inst); + + out: + virDomainFree(dom); + virConnectClose(conn); + + return s; } static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, @@ -159,6 +312,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 */ From danms at us.ibm.com Tue Feb 5 20:42:59 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 05 Feb 2008 12:42:59 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: (Jay Gagnon's message of "Tue, 05 Feb 2008 13:54:07 -0500") References: Message-ID: <87fxw7m8x8.fsf@caffeine.beaverton.ibm.com> JG> + *s = CMSetProperty(dest, (char *)(prop_name->hdl), JG> + &(data.value), data.type); Use CMGetCharPtr() here, instead of accessing prop_name->hdl directly. Looks good otherwise. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Tue Feb 5 20:58:08 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 05 Feb 2008 12:58:08 -0800 Subject: [Libvirt-cim] [PATCH] Make the ProcRASD show CPU pinning information In-Reply-To: (Dan Smith's message of "Tue, 05 Feb 2008 12:31:41 -0800") References: Message-ID: <87bq6vm87z.fsf@caffeine.beaverton.ibm.com> DS> # HG changeset patch DS> # User Dan Smith DS> # Date 1202243439 28800 DS> # Node ID e6d442b5bf122889708e9ad24545ae0b42b8c3bb DS> # Parent f8ee9b04d92abf1d74bf4c72fac1f3a4128923dd DS> Make the ProcRASD show CPU pinning information I just realized that I didn't utilize the libvirt vcpu information correctly, so ignore this one and I'll spin it again. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From grendel at linux.vnet.ibm.com Tue Feb 5 20:58:10 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 15:58:10 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: <87fxw7m8x8.fsf@caffeine.beaverton.ibm.com> References: <87fxw7m8x8.fsf@caffeine.beaverton.ibm.com> Message-ID: <47A8CDE2.3080709@linux.vnet.ibm.com> Dan Smith wrote: > JG> + *s = CMSetProperty(dest, (char *)(prop_name->hdl), > JG> + &(data.value), data.type); > > Use CMGetCharPtr() here, instead of accessing prop_name->hdl > directly. > > Looks good otherwise. > > I was wondering if there was a nicer way to do that. I've really got to get better at finding the appropriate thing in cmpimacs. Okay, will resend shortly. -- -Jay From grendel at linux.vnet.ibm.com Tue Feb 5 21:06:22 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 16:06:22 -0500 Subject: [Libvirt-cim] [PATCH 2 of 2] [CU] Improve std_indication's raise functionality In-Reply-To: Message-ID: # HG changeset patch # User Jay Gagnon # Date 1202245300 18000 # Node ID c544bc4a7470f80f53765f1eeac344ffba946969 # Parent 493b8a943286a780e2fb7c2829cd49e60ccaa264 [CU] Improve std_indication's raise functionality Turns out STDI_IndicationMIStub was not creating the CMPIFooMIFTs correctly; this patch fixes that. It also adds a default_raise function to std_indication. This is for indication providers that don't need to do anything other than call CBDeliverIndication, which will most likely be the majority. Signed-off-by: Jay Gagnon diff -r 493b8a943286 -r c544bc4a7470 std_indication.c --- a/std_indication.c Tue Feb 05 16:01:32 2008 -0500 +++ b/std_indication.c Tue Feb 05 16:01:40 2008 -0500 @@ -19,6 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include @@ -40,19 +41,40 @@ static CMPIStatus trigger(struct std_ind return ctx->handler->trigger_fn(context); } +static CMPIStatus default_raise(const CMPIBroker *broker, + const CMPIContext *context, + CMPIInstance *ind) +{ + CMPIObjectPath *ref; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + ref = CMGetObjectPath(ind, NULL); + + CBDeliverIndication(broker, + context, + NAMESPACE(ref), + ind); + return s; +} + static CMPIStatus raise(struct std_indication_ctx *ctx, const CMPIContext *context, const CMPIArgs *argsin) { CMPIInstance *inst; - if (ctx->handler->raise_fn == NULL) - return (CMPIStatus){CMPI_RC_OK, NULL}; + if (!ctx->enabled) { + CU_DEBUG("Indication disabled, not raising."); + return (CMPIStatus) {CMPI_RC_OK, NULL}; + } if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK) return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL}; - return ctx->handler->raise_fn(context, inst); + if (ctx->handler->raise_fn == NULL) + return default_raise(ctx->brkr, context, inst); + + return ctx->handler->raise_fn(ctx->brkr, context, inst); } CMPIStatus stdi_handler(CMPIMethodMI *self, diff -r 493b8a943286 -r c544bc4a7470 std_indication.h --- a/std_indication.h Tue Feb 05 16:01:32 2008 -0500 +++ b/std_indication.h Tue Feb 05 16:01:40 2008 -0500 @@ -24,6 +24,7 @@ #include #include #include +#include #include "libcmpiutil.h" #include "std_invokemethod.h" @@ -51,7 +52,8 @@ CMPIStatus stdi_cleanup(CMPIMethodMI *se const CMPIContext *context, CMPIBoolean terminating); -typedef CMPIStatus (*raise_indication_t)(const CMPIContext *ctx, +typedef CMPIStatus (*raise_indication_t)(const CMPIBroker *broker, + const CMPIContext *ctx, const CMPIInstance *ind); typedef CMPIStatus (*trigger_indication_t)(const CMPIContext *ctx); @@ -64,14 +66,44 @@ struct std_indication_ctx { struct std_indication_ctx { const CMPIBroker *brkr; struct std_indication_handler *handler; + bool enabled; }; #define STDI_IndicationMIStub(pfx, pn, _broker, hook, _handler) \ + static struct std_indication_ctx _ctx = { \ + .brkr = NULL, \ + .handler = _handler, \ + .enabled = false, \ + }; \ + \ + static CMPIIndicationMIFT indMIFT__ = { \ + CMPICurrentVersion, \ + CMPICurrentVersion, \ + "Indication" #pn, \ + pfx##IndicationCleanup, \ + pfx##AuthorizeFilter, \ + pfx##MustPoll, \ + pfx##ActivateFilter, \ + pfx##DeActivateFilter, \ + CMIndicationMIStubExtensions(pfx) \ + }; \ CMPIIndicationMI * \ pn##_Create_IndicationMI(const CMPIBroker *, \ - const CMPIContext *, \ - CMPIStatus *); \ - CMIndicationMIStub(pfx, pn, _broker, hook); \ + const CMPIContext *, \ + CMPIStatus *); \ + CMPIIndicationMI * \ + pn##_Create_IndicationMI(const CMPIBroker *brkr, \ + const CMPIContext *ctx, \ + CMPIStatus *rc) { \ + static CMPIIndicationMI mi = { \ + &_ctx, \ + &indMIFT__, \ + }; \ + _ctx.brkr = brkr; \ + _broker = brkr; \ + hook; \ + return &mi; \ + } \ \ static CMPIMethodMIFT methMIFT__ = { \ CMPICurrentVersion, \ @@ -88,13 +120,11 @@ struct std_indication_ctx { CMPIMethodMI *pn##_Create_MethodMI(const CMPIBroker *brkr, \ const CMPIContext *ctx, \ CMPIStatus *rc) { \ - static struct std_indication_ctx _ctx; \ static CMPIMethodMI mi = { \ &_ctx, \ &methMIFT__, \ }; \ _ctx.brkr = brkr; \ - _ctx.handler = _handler; \ _broker = brkr; \ hook; \ return &mi; \ From grendel at linux.vnet.ibm.com Tue Feb 5 21:06:20 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 16:06:20 -0500 Subject: [Libvirt-cim] [PATCH 0 of 2] (#3) [CU] Migration Indication libcmpiutil changes Message-ID: One last fix to cu_dup_instances, and this should be good to go. From grendel at linux.vnet.ibm.com Tue Feb 5 21:06:21 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 16:06:21 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: Message-ID: <493b8a943286a780e2fb.1202245581@naegling> # HG changeset patch # User Jay Gagnon # Date 1202245292 18000 # Node ID 493b8a943286a780e2fb7c2829cd49e60ccaa264 # Parent ab0e3b05a10e7b5db7eb493920f01bb402d2feae [CU] Add dup_instance function to libcmpiutil It appears there are some situations where we have to duplicate an instance; this seemed like the kind of thing that would belong in libcmpiutil. Changes from #1 to #2: cu dup_instance returns instance, sets status using pointer cu_dup_instance copies all properties Changes from #2 to #3: use CMGetCharPtr instead of doing char * cast manually Signed-off-by: Jay Gagnon diff -r ab0e3b05a10e -r 493b8a943286 instance_util.c --- a/instance_util.c Wed Jan 30 11:15:32 2008 -0800 +++ b/instance_util.c Tue Feb 05 16:01:32 2008 -0500 @@ -202,6 +202,55 @@ CMPIStatus cu_copy_prop(const CMPIBroker out: return s; +} + +CMPIInstance *cu_dup_instance(const CMPIBroker *broker, + CMPIInstance *src, + CMPIStatus *s) +{ + int i; + int prop_count; + CMPIData data; + CMPIObjectPath *ref; + CMPIInstance *dest = NULL; + + ref = CMGetObjectPath(src, NULL); + if ((s->rc != CMPI_RC_OK) || CMIsNullObject(ref)) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Could not get objectpath from instance"); + goto out; + } + + dest = CMNewInstance(broker, ref, s); + + prop_count = CMGetPropertyCount(src, s); + if (s->rc != CMPI_RC_OK) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Could not get property count for copy"); + goto out; + } + + for (i = 0; i < prop_count; i++) { + CMPIString *prop; + char *prop_name; + + data = CMGetPropertyAt(src, i, &prop, s); + prop_name = CMGetCharPtr(prop); + if (s->rc != CMPI_RC_OK) { + goto out; + } + + *s = CMSetProperty(dest, prop_name, + &(data.value), data.type); + if (s->rc != CMPI_RC_OK) { + goto out; + } + } + + out: + return dest; } /* diff -r ab0e3b05a10e -r 493b8a943286 libcmpiutil.h --- a/libcmpiutil.h Wed Jan 30 11:15:32 2008 -0800 +++ b/libcmpiutil.h Tue Feb 05 16:01:32 2008 -0500 @@ -164,6 +164,18 @@ CMPIrc cu_get_u16_path(const CMPIObjectP CMPIrc cu_get_u16_path(const CMPIObjectPath *reference, const char *key, uint16_t *target); + +/** + * Create a copy of an instance + * + * @param src Source instance + * @param dest Destination instance + * @returns {CMPI_RC_OK, NULL} if success, CMPI_RC ERR_FAILED and + * error message otherwise + */ +CMPIInstance *cu_dup_instance(const CMPIBroker *broker, + CMPIInstance *src, + CMPIStatus *s); /* Forward declaration */ struct inst_list; From grendel at linux.vnet.ibm.com Tue Feb 5 21:31:20 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 05 Feb 2008 16:31:20 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: <493b8a943286a780e2fb.1202245581@naegling> References: <493b8a943286a780e2fb.1202245581@naegling> Message-ID: <47A8D5A8.5010104@linux.vnet.ibm.com> Jay Gagnon wrote: > + for (i = 0; i < prop_count; i++) { > + CMPIString *prop; > + char *prop_name; > + > + data = CMGetPropertyAt(src, i, &prop, s); > + prop_name = CMGetCharPtr(prop); > + if (s->rc != CMPI_RC_OK) { > + goto out; > + } > + > + *s = CMSetProperty(dest, prop_name, > + &(data.value), data.type); > + if (s->rc != CMPI_RC_OK) { > + goto out; > + } > + } > + > + out: > + return dest; > } > > It's probably worth pointing out that CMGetCharPtr simply does the casting for me; there is no strdup, so I believe it is not necessary to free prop_name here. I only say this because up until today when I looked it up, if I saw someone using CMGetCharPtr, I would have asked where the free is. -- -Jay From danms at us.ibm.com Tue Feb 5 21:33:41 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 05 Feb 2008 13:33:41 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Add dup_instance function to libcmpiutil In-Reply-To: <47A8D5A8.5010104@linux.vnet.ibm.com> (Jay Gagnon's message of "Tue, 05 Feb 2008 16:31:20 -0500") References: <493b8a943286a780e2fb.1202245581@naegling> <47A8D5A8.5010104@linux.vnet.ibm.com> Message-ID: <877ihjm6kq.fsf@caffeine.beaverton.ibm.com> JG> It's probably worth pointing out that CMGetCharPtr simply does the JG> casting for me; there is no strdup, so I believe it is not JG> necessary to free prop_name here. I only say this because up JG> until today when I looked it up, if I saw someone using JG> CMGetCharPtr, I would have asked where the free is. Correct, no free() needed. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Tue Feb 5 21:40:47 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 13:40:47 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add new provider - VirtualSystemMigrationSettingData In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1202246829 28800 # Node ID ef8484e9a30f5940653b0641d0bc2a72a780ed72 # Parent 06459df42e99beb1626dc4be039b7a1530847b4d Add new provider - VirtualSystemMigrationSettingData. Signed-off-by: Kaitlin Rupert diff -r 06459df42e99 -r ef8484e9a30f src/Virt_VSMigrationSettingData.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VSMigrationSettingData.c Tue Feb 05 13:27:09 2008 -0800 @@ -0,0 +1,160 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Kaitlin Rupert + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "misc_util.h" + +const static CMPIBroker *_BROKER; + +static CMPIStatus set_properties(const CMPIBroker *broker, + CMPIInstance *inst) +{ + CMPIStatus s; + uint16_t type = 3; /* Use live migration as default */ + uint16_t priority = 0; /* Use default priority */ + + CMSetProperty(inst, "MigrationType", + (CMPIValue *)&type, CMPI_uint16); + + CMSetProperty(inst, "Priority", + (CMPIValue *)&priority, CMPI_uint16); + + + CMSetStatus(&s, CMPI_RC_OK); + + return s; +} + +static CMPIStatus get_migration_sd(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst) +{ + CMPIInstance *inst; + CMPIStatus s; + + inst = get_typed_instance(broker, + CLASSNAME(ref), + "VirtualSystemMigrationSettingData", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get instance for %s", CLASSNAME(ref)); + goto out; + } + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)"MigrationSettingData", CMPI_chars); + + s = set_properties(broker, inst); + + if (s.rc != CMPI_RC_OK) + goto out; + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + + out: + return s; +} + +static CMPIStatus return_vsmsd(const CMPIObjectPath *ref, + const CMPIResult *results, + bool name_only, + bool is_get_inst) +{ + CMPIInstance *inst; + CMPIStatus s; + + s = get_migration_sd(ref, &inst, _BROKER, is_get_inst); + + if (s.rc == CMPI_RC_OK) { + if (name_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + } + + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref) +{ + return return_vsmsd(ref, results, true, false); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + return return_vsmsd(ref, results, false, false); +} + + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + return return_vsmsd(ref, results, false, true); +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, + Virt_VSMigrationSettingData, + _BROKER, + libvirt_cim_init()); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From kaitlin at linux.vnet.ibm.com Tue Feb 5 21:40:46 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 13:40:46 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] Add provider for VirtualSystemMigratonSettingData Message-ID: This patchset adds support for the VirtualSystemMigrationSettingData provider. From kaitlin at linux.vnet.ibm.com Tue Feb 5 21:40:48 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 13:40:48 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Add necessary pieces to build Virt_VSMigrationSettingData.c In-Reply-To: Message-ID: <4299c8dc5291bd6922e2.1202247648@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202246831 28800 # Node ID 4299c8dc5291bd6922e27dbd34e6ef6ecc67c49b # Parent ef8484e9a30f5940653b0641d0bc2a72a780ed72 Add necessary pieces to build Virt_VSMigrationSettingData.c Signed-off-by: Kaitlin Rupert diff -r ef8484e9a30f -r 4299c8dc5291 Makefile.am --- a/Makefile.am Tue Feb 05 13:27:09 2008 -0800 +++ b/Makefile.am Tue Feb 05 13:27:11 2008 -0800 @@ -35,7 +35,8 @@ MOFS = \ schema/HostedService.mof \ schema/ElementSettingData.mof \ schema/VSMigrationCapabilities.mof \ - schema/VSMigrationService.mof + schema/VSMigrationService.mof \ + schema/VSMigrationSettingData.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -77,7 +78,8 @@ REGS = \ schema/ElementSettingData.registration \ schema/VSMigrationCapabilities.registration \ schema/VSMigrationService.registration \ - schema/ElementConformsToProfile.registration + schema/ElementConformsToProfile.registration \ + schema/VSMigrationSettingData.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ @@ -109,4 +111,5 @@ clean-local: clean-local: rm -f $(find . -name "*.orig") rm -f $(find . -name "*.rej") - rm -f $(find . -name "*~") \ No newline at end of file + rm -f $(find . -name "*~") + diff -r ef8484e9a30f -r 4299c8dc5291 schema/VSMigrationSettingData.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationSettingData.mof Tue Feb 05 13:27:11 2008 -0800 @@ -0,0 +1,15 @@ +// Copyright IBM Corp. 2007 + +class CIM_VirtualSystemMigrationSettingData : CIM_SettingData { + uint16 MigrationType; + + uint16 Priority; +}; + +[Provider("cmpi::Virt_VSMigrationSettingData")] +class Xen_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { +}; + +[Provider("cmpi::Virt_VSMigrationSettingData")] +class KVM_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { +}; diff -r ef8484e9a30f -r 4299c8dc5291 schema/VSMigrationSettingData.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationSettingData.registration Tue Feb 05 13:27:11 2008 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemMigrationSettingData root/virt Virt_VSMigrationSettingData Virt_VSMigrationSettingData instance +KVM_VirtualSystemMigrationSettingData root/virt Virt_VSMigrationSettingData Virt_VSMigrationSettingData instance diff -r ef8484e9a30f -r 4299c8dc5291 src/Makefile.am --- a/src/Makefile.am Tue Feb 05 13:27:09 2008 -0800 +++ b/src/Makefile.am Tue Feb 05 13:27:11 2008 -0800 @@ -53,7 +53,8 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_HostedService.la \ libVirt_ElementSettingData.la \ libVirt_VSMigrationCapabilities.la \ - libVirt_VSMigrationService.la + libVirt_VSMigrationService.la \ + libVirt_VSMigrationSettingData.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -150,3 +151,5 @@ libVirt_VSMigrationService_la_SOURCES = libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem +libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c + From kaitlin at linux.vnet.ibm.com Tue Feb 5 21:50:15 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 13:50:15 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] Add VSMigrationSettingData support to SettingsDefineState Message-ID: Per the VirtualSystemMigration Profile, there needs to be a SettingsDefineCapabilities association between VSMigrationCapabilities and VSMigrationSettingData. From kaitlin at linux.vnet.ibm.com Tue Feb 5 21:50:16 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 13:50:16 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Make get_migration_sd() of VSmigrationSettingData.c staitc In-Reply-To: Message-ID: <939ed8ed24f4842ddde6.1202248216@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202248164 28800 # Node ID 939ed8ed24f4842ddde6ca06bdcaaeab4168ff9b # Parent 4299c8dc5291bd6922e27dbd34e6ef6ecc67c49b Make get_migration_sd() of VSmigrationSettingData.c staitc. SettingsDefineCapabilities will need to call this function. Signed-off-by: Kaitlin Rupert diff -r 4299c8dc5291 -r 939ed8ed24f4 src/Virt_VSMigrationSettingData.c --- a/src/Virt_VSMigrationSettingData.c Tue Feb 05 13:27:11 2008 -0800 +++ b/src/Virt_VSMigrationSettingData.c Tue Feb 05 13:49:24 2008 -0800 @@ -30,6 +30,7 @@ #include #include "misc_util.h" +#include "Virt_VSMigrationSettingData.h" const static CMPIBroker *_BROKER; @@ -52,10 +53,10 @@ static CMPIStatus set_properties(const C return s; } -static CMPIStatus get_migration_sd(const CMPIObjectPath *ref, - CMPIInstance **_inst, - const CMPIBroker *broker, - bool is_get_inst) +CMPIStatus get_migration_sd(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst) { CMPIInstance *inst; CMPIStatus s; diff -r 4299c8dc5291 -r 939ed8ed24f4 src/Virt_VSMigrationSettingData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VSMigrationSettingData.h Tue Feb 05 13:49:24 2008 -0800 @@ -0,0 +1,35 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Kaitlin Rupert + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +CMPIStatus get_migration_sd(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst); +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ + From kaitlin at linux.vnet.ibm.com Tue Feb 5 21:50:17 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 13:50:17 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Update SettingsDefineCapabilities so that it supports VSMigrationSettingData In-Reply-To: Message-ID: <4a3c49398498fc69bf10.1202248217@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202248173 28800 # Node ID 4a3c49398498fc69bf1063bfdec45fa6fb553f32 # Parent 939ed8ed24f4842ddde6ca06bdcaaeab4168ff9b Update SettingsDefineCapabilities so that it supports VSMigrationSettingData. Signed-off-by: Kaitlin Rupert diff -r 939ed8ed24f4 -r 4a3c49398498 src/Makefile.am --- a/src/Makefile.am Tue Feb 05 13:49:24 2008 -0800 +++ b/src/Makefile.am Tue Feb 05 13:49:33 2008 -0800 @@ -103,9 +103,12 @@ libVirt_ElementCapabilities_la_LIBADD = -lVirt_VSMigrationCapabilities \ -lVirt_AllocationCapabilities -libVirt_SettingsDefineCapabilities_la_DEPENDENCIES = libVirt_RASD.la libVirt_DevicePool.la +libVirt_SettingsDefineCapabilities_la_DEPENDENCIES = libVirt_RASD.la libVirt_DevicePool.la libVirt_VSMigrationCapabilities.la libVirt_VSMigrationSettingData.la libVirt_SettingsDefineCapabilities_la_SOURCES = Virt_SettingsDefineCapabilities.c -libVirt_SettingsDefineCapabilities_la_LIBADD = -lVirt_RASD -lVirt_DevicePool +libVirt_SettingsDefineCapabilities_la_LIBADD = -lVirt_RASD \ + -lVirt_DevicePool \ + -lVirt_VSMigrationCapabilities \ + -lVirt_VSMigrationSettingData libVirt_RegisteredProfile_la_SOURCES = Virt_RegisteredProfile.c diff -r 939ed8ed24f4 -r 4a3c49398498 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Tue Feb 05 13:49:24 2008 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Feb 05 13:49:33 2008 -0800 @@ -43,6 +43,8 @@ #include "Virt_SettingsDefineCapabilities.h" #include "Virt_DevicePool.h" #include "Virt_RASD.h" +#include "Virt_VSMigrationCapabilities.h" +#include "Virt_VSMigrationSettingData.h" const static CMPIBroker *_BROKER; @@ -825,6 +827,50 @@ static CMPIStatus rasd_to_alloc_cap(cons RETURN_UNSUPPORTED(); } +static CMPIStatus migrate_cap_to_vsmvs(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK}; + CMPIInstance *inst; + + if (!match_hypervisor_prefix(ref, info)) + return s; + + s = get_migration_caps(ref, &inst, _BROKER); + if (s.rc != CMPI_RC_OK) + goto out; + + s = get_migration_sd(ref, &inst, _BROKER, false); + if (s.rc == CMPI_RC_OK) + inst_list_add(list, inst); + + out: + return s; +} + +static CMPIStatus vsmvs_to_migrate_cap(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK}; + CMPIInstance *inst; + + if (!match_hypervisor_prefix(ref, info)) + return s; + + s = get_migration_sd(ref, &inst, _BROKER, true); + if (s.rc != CMPI_RC_OK) + goto out; + + s = get_migration_caps(ref, &inst, _BROKER); + if (s.rc == CMPI_RC_OK) + inst_list_add(list, inst); + + out: + return s; +} + LIBVIRT_CIM_DEFAULT_MAKEREF() static char* group_component[] = { @@ -877,9 +923,49 @@ static struct std_assoc _rasd_to_alloc_c .make_ref = make_ref }; +static char* migrate_cap[] = { + "Xen_VirtualSystemMigrationCapabilities", + "KVM_VirtualSystemMigrationCapabilities", + NULL +}; + +static char* migrate_sd[] = { + "Xen_VirtualSystemMigrationSettingData", + "KVM_VirtualSystemMigrationSettingData", + NULL +}; + +static struct std_assoc _migrate_cap_to_vsmvs = { + .source_class = (char**)&migrate_cap, + .source_prop = "GroupComponent", + + .target_class = (char**)&migrate_sd, + .target_prop = "PartComponent", + + .assoc_class = (char**)&assoc_classname, + + .handler = migrate_cap_to_vsmvs, + .make_ref = make_ref +}; + +static struct std_assoc _vsmvs_to_migrate_cap = { + .source_class = (char**)&migrate_sd, + .source_prop = "PartComponent", + + .target_class = (char**)&migrate_cap, + .target_prop = "GroupComponent", + + .assoc_class = (char**)&assoc_classname, + + .handler = vsmvs_to_migrate_cap, + .make_ref = make_ref +}; + static struct std_assoc *assoc_handlers[] = { &_alloc_cap_to_rasd, &_rasd_to_alloc_cap, + &_migrate_cap_to_vsmvs, + &_vsmvs_to_migrate_cap, NULL }; From kaitlin at linux.vnet.ibm.com Tue Feb 5 22:12:11 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 14:12:11 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Update SettingsDefineCapabilities so that it supports VSMigrationSettingData In-Reply-To: <4a3c49398498fc69bf10.1202248217@elm3b41.beaverton.ibm.com> References: <4a3c49398498fc69bf10.1202248217@elm3b41.beaverton.ibm.com> Message-ID: <47A8DF3B.6060801@linux.vnet.ibm.com> Kaitlin Rupert wrote: } > > +static CMPIStatus migrate_cap_to_vsmvs(const CMPIObjectPath *ref, > + struct std_assoc_info *info, > + struct inst_list *list) > +{ > + CMPIStatus s = {CMPI_RC_OK}; > + CMPIInstance *inst; > + > + if (!match_hypervisor_prefix(ref, info)) > + return s; > + > + s = get_migration_caps(ref, &inst, _BROKER); > + if (s.rc != CMPI_RC_OK) > + goto out; get_migration_cap() currently doesn't validate the keys of the reference. I've seen a lot of ref validation fixes from Heidi, and so I don't work up a colliding patch. If no one is working on this, I can look into it. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Tue Feb 5 22:20:20 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 14:20:20 -0800 Subject: [Libvirt-cim] [PATCH] Update author field on CSI In-Reply-To: References: Message-ID: <47A8E124.1010304@linux.vnet.ibm.com> Jay Gagnon wrote: > # HG changeset patch > # User Jay Gagnon > # Date 1202241964 18000 > # Node ID c286514082efd898f008a21fc8f27d299bd95fa4 > # Parent c24b2e6d1bce44af234d379cfc8b7ee116621109 > Update author field on CSI > > How's this for an egocentric patch? > Excellent commit log. Can I give a plus 2 for that? =) +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Tue Feb 5 21:40:48 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 13:40:48 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Add necessary pieces to build Virt_VSMigrationSettingData.c In-Reply-To: Message-ID: <4299c8dc5291bd6922e2.1202247648@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202246831 28800 # Node ID 4299c8dc5291bd6922e27dbd34e6ef6ecc67c49b # Parent ef8484e9a30f5940653b0641d0bc2a72a780ed72 Add necessary pieces to build Virt_VSMigrationSettingData.c Signed-off-by: Kaitlin Rupert diff -r ef8484e9a30f -r 4299c8dc5291 Makefile.am --- a/Makefile.am Tue Feb 05 13:27:09 2008 -0800 +++ b/Makefile.am Tue Feb 05 13:27:11 2008 -0800 @@ -35,7 +35,8 @@ MOFS = \ schema/HostedService.mof \ schema/ElementSettingData.mof \ schema/VSMigrationCapabilities.mof \ - schema/VSMigrationService.mof + schema/VSMigrationService.mof \ + schema/VSMigrationSettingData.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -77,7 +78,8 @@ REGS = \ schema/ElementSettingData.registration \ schema/VSMigrationCapabilities.registration \ schema/VSMigrationService.registration \ - schema/ElementConformsToProfile.registration + schema/ElementConformsToProfile.registration \ + schema/VSMigrationSettingData.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ @@ -109,4 +111,5 @@ clean-local: clean-local: rm -f $(find . -name "*.orig") rm -f $(find . -name "*.rej") - rm -f $(find . -name "*~") \ No newline at end of file + rm -f $(find . -name "*~") + diff -r ef8484e9a30f -r 4299c8dc5291 schema/VSMigrationSettingData.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationSettingData.mof Tue Feb 05 13:27:11 2008 -0800 @@ -0,0 +1,15 @@ +// Copyright IBM Corp. 2007 + +class CIM_VirtualSystemMigrationSettingData : CIM_SettingData { + uint16 MigrationType; + + uint16 Priority; +}; + +[Provider("cmpi::Virt_VSMigrationSettingData")] +class Xen_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { +}; + +[Provider("cmpi::Virt_VSMigrationSettingData")] +class KVM_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { +}; diff -r ef8484e9a30f -r 4299c8dc5291 schema/VSMigrationSettingData.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationSettingData.registration Tue Feb 05 13:27:11 2008 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemMigrationSettingData root/virt Virt_VSMigrationSettingData Virt_VSMigrationSettingData instance +KVM_VirtualSystemMigrationSettingData root/virt Virt_VSMigrationSettingData Virt_VSMigrationSettingData instance diff -r ef8484e9a30f -r 4299c8dc5291 src/Makefile.am --- a/src/Makefile.am Tue Feb 05 13:27:09 2008 -0800 +++ b/src/Makefile.am Tue Feb 05 13:27:11 2008 -0800 @@ -53,7 +53,8 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_HostedService.la \ libVirt_ElementSettingData.la \ libVirt_VSMigrationCapabilities.la \ - libVirt_VSMigrationService.la + libVirt_VSMigrationService.la \ + libVirt_VSMigrationSettingData.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -150,3 +151,5 @@ libVirt_VSMigrationService_la_SOURCES = libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem +libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c + From kaitlin at linux.vnet.ibm.com Tue Feb 5 22:26:11 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 14:26:11 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] (#3) [CU] Migration Indication libcmpiutil changes In-Reply-To: References: Message-ID: <47A8E283.9020607@linux.vnet.ibm.com> Jay Gagnon wrote: > One last fix to cu_dup_instances, and this should be good to go. > Agreed - I think this set is good. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Tue Feb 5 22:33:44 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 14:33:44 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] (#2) MigrationIndications In-Reply-To: References: Message-ID: <47A8E448.3000907@linux.vnet.ibm.com> Jay Gagnon wrote: > 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. > I think this is good to go - assuming there are no further complaints with the cu_dup_instance() patch. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Tue Feb 5 22:44:25 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 05 Feb 2008 14:44:25 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Add more meaningful return messages to EO parsing functions Message-ID: <7cdea1fba87f7aea14d9.1202251465@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # 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 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; From heidieck at linux.vnet.ibm.com Wed Feb 6 09:16:47 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 06 Feb 2008 10:16:47 +0100 Subject: [Libvirt-cim] [PATCH 1 of 2] Add new provider - VirtualSystemMigrationSettingData In-Reply-To: References: Message-ID: <47A97AFF.5070107@linux.vnet.ibm.com> Kaitlin Rupert wrote: > +static CMPIStatus get_migration_sd(const CMPIObjectPath *ref, > + CMPIInstance **_inst, > + const CMPIBroker *broker, > + bool is_get_inst) > +{ > + CMPIInstance *inst; > + CMPIStatus s; > Please check if you can get a connection to libvirt with the given classname. Otherwise you return Xen instances on a KVM only system (and reverse). ResourcePoolConfigurationService is already doing so (was a fix some days ago). Thanks. > + > + inst = get_typed_instance(broker, > + CLASSNAME(ref), > + "VirtualSystemMigrationSettingData", > + NAMESPACE(ref)); > + if (inst == NULL) { > + cu_statusf(broker, &s, > + CMPI_RC_ERR_FAILED, > + "Unable to get instance for %s", CLASSNAME(ref)); > + goto out; > + } > + > + CMSetProperty(inst, "InstanceID", > + (CMPIValue *)"MigrationSettingData", CMPI_chars); > + > + s = set_properties(broker, inst); > + > + if (s.rc != CMPI_RC_OK) > + goto out; > + > + if (is_get_inst) { > + s = cu_validate_ref(broker, ref, inst); > + if (s.rc != CMPI_RC_OK) > + goto out; > + } > + > + *_inst = inst; > + > + out: > + return s; > +} > + Besides this tiny thing ... great ! :) -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 6 09:51:10 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 06 Feb 2008 10:51:10 +0100 Subject: [Libvirt-cim] [PATCH 0 of 2] Add VSMigrationSettingData support to SettingsDefineState In-Reply-To: References: Message-ID: <47A9830E.8020900@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Per the VirtualSystemMigration Profile, there needs to be a SettingsDefineCapabilities association between VSMigrationCapabilities and VSMigrationSettingData. > > Only one comment ... great work :) ... +1 -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 6 09:58:25 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 06 Feb 2008 10:58:25 +0100 Subject: [Libvirt-cim] [PATCH 2 of 2] Update SettingsDefineCapabilities so that it supports VSMigrationSettingData In-Reply-To: <47A8DF3B.6060801@linux.vnet.ibm.com> References: <4a3c49398498fc69bf10.1202248217@elm3b41.beaverton.ibm.com> <47A8DF3B.6060801@linux.vnet.ibm.com> Message-ID: <47A984C1.5090601@linux.vnet.ibm.com> Kaitlin Rupert wrote: > get_migration_cap() currently doesn't validate the keys of the reference. You are very attentive :). > > I've seen a lot of ref validation fixes from Heidi, and so I don't > work up a colliding patch. If no one is working on this, I can look > into it. Sure, that would really help me. And its always good to spread knowledge all over the team ;). Please can you also rename the superclass from Virt_VirtualSystemMigrationCapabilities to CIM_... ? Dan agreed on this update some weeks ago, but I did not had the time to fix it yet. > > Thanks! > I have to say Thanks ! -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 6 11:22:14 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 06 Feb 2008 12:22:14 +0100 Subject: [Libvirt-cim] [PATCH] [CU] Add more meaningful return messages to EO parsing functions In-Reply-To: <7cdea1fba87f7aea14d9.1202251465@elm3b41.beaverton.ibm.com> References: <7cdea1fba87f7aea14d9.1202251465@elm3b41.beaverton.ibm.com> Message-ID: <47A99866.9030505@linux.vnet.ibm.com> Kaitlin Rupert wrote: > # HG changeset patch > # User Kaitlin Rupert > # 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 > > 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, > The error code should stay 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_FAILED, > The same here: 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; > > thanks -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 6 11:25:20 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 06 Feb 2008 12:25:20 +0100 Subject: [Libvirt-cim] [PATCH] Update author field on CSI In-Reply-To: References: Message-ID: <47A99920.5010003@linux.vnet.ibm.com> Jay Gagnon wrote: > # HG changeset patch > # User Jay Gagnon > # Date 1202241964 18000 > # Node ID c286514082efd898f008a21fc8f27d299bd95fa4 > # Parent c24b2e6d1bce44af234d379cfc8b7ee116621109 > Update author field on CSI > > How's this for an egocentric patch? > > Signed-off-by: Jay Gagnon > > diff -r c24b2e6d1bce -r c286514082ef src/Virt_ComputerSystemIndication.c > --- a/src/Virt_ComputerSystemIndication.c Tue Feb 05 10:18:38 2008 -0500 > +++ b/src/Virt_ComputerSystemIndication.c Tue Feb 05 15:06:04 2008 -0500 > @@ -3,6 +3,7 @@ > * > * Authors: > * Dan Smith > + * Jay Gagnon > * > * This library is free software; you can redistribute it and/or > * modify it under the terms of the GNU Lesser General Public > > very nice ;) ... +1 -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 6 11:47:17 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 06 Feb 2008 12:47:17 +0100 Subject: [Libvirt-cim] [PATCH 2 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider In-Reply-To: References: Message-ID: <47A99E45.3020609@linux.vnet.ibm.com> Jay Gagnon wrote: > # HG changeset patch > # User Jay Gagnon > # Date 1202224718 18000 > # Node ID c24b2e6d1bce44af234d379cfc8b7ee116621109 > # Parent fdce6fa993b5a9dce654b3e0cf527599f86b9f67 > Add calls into VSMigrationService to utilize new MigrationIndication provider. > > Changes from #1 to #2: > Break out indication code from migration_job_set_state. > Changed cu_dup_instance call to match new signature. > > Signed-off-by: Jay Gagnon > > diff -r fdce6fa993b5 -r c24b2e6d1bce src/Virt_VSMigrationService.c > --- a/src/Virt_VSMigrationService.c Tue Feb 05 10:18:37 2008 -0500 > +++ b/src/Virt_VSMigrationService.c Tue Feb 05 10:18:38 2008 -0500 > @@ -34,6 +34,7 @@ > #include "misc_util.h" > #include > #include > +#include > It's maybe my ignorance now, but should this also be "#include " as in the lines before ? -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 6 11:54:34 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 06 Feb 2008 12:54:34 +0100 Subject: [Libvirt-cim] [PATCH 2 of 2] [CU] Improve std_indication's raise functionality In-Reply-To: References: Message-ID: <47A99FFA.2070605@linux.vnet.ibm.com> Jay Gagnon wrote: > # HG changeset patch > # User Jay Gagnon > # Date 1202245300 18000 > # Node ID c544bc4a7470f80f53765f1eeac344ffba946969 > # Parent 493b8a943286a780e2fb7c2829cd49e60ccaa264 > [CU] Improve std_indication's raise functionality > > Turns out STDI_IndicationMIStub was not creating the CMPIFooMIFTs correctly; this patch fixes that. It also adds a default_raise function to std_indication. This is for indication providers that don't need to do anything other than call CBDeliverIndication, which will most likely be the majority. > > Signed-off-by: Jay Gagnon > > > Sorry, but I can not apply this patch to the latest libcmpiutil. Am I missing something ? -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From grendel at linux.vnet.ibm.com Wed Feb 6 13:47:04 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Wed, 06 Feb 2008 08:47:04 -0500 Subject: [Libvirt-cim] [PATCH 2 of 2] [CU] Improve std_indication's raise functionality In-Reply-To: <47A99FFA.2070605@linux.vnet.ibm.com> References: <47A99FFA.2070605@linux.vnet.ibm.com> Message-ID: <47A9BA58.5030608@linux.vnet.ibm.com> Heidi Eckhart wrote: > Jay Gagnon wrote: >> # HG changeset patch >> # User Jay Gagnon >> # Date 1202245300 18000 >> # Node ID c544bc4a7470f80f53765f1eeac344ffba946969 >> # Parent 493b8a943286a780e2fb7c2829cd49e60ccaa264 >> [CU] Improve std_indication's raise functionality >> >> Turns out STDI_IndicationMIStub was not creating the CMPIFooMIFTs >> correctly; this patch fixes that. It also adds a default_raise >> function to std_indication. This is for indication providers that >> don't need to do anything other than call CBDeliverIndication, which >> will most likely be the majority. >> >> Signed-off-by: Jay Gagnon >> >> >> > Sorry, but I can not apply this patch to the latest libcmpiutil. Am I > missing something ? > I just made sure my local tree was up to date and it looks like Dan applied the raise functionality patch last time, since that one was not dependent on the others and there were no issues with it. Did you get something like this when you tried to apply? 2 out of 2 hunks ignored -- saving rejects to file std_indication.c.rej 4 out of 4 hunks ignored -- saving rejects to file std_indication.h.rej That's what I got, and when I checked the changesets that had been added in my last update I noticed the raise functionality patch was already in. -- -Jay From grendel at linux.vnet.ibm.com Wed Feb 6 14:20:26 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Wed, 06 Feb 2008 09:20:26 -0500 Subject: [Libvirt-cim] [PATCH 2 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider In-Reply-To: <47A99E45.3020609@linux.vnet.ibm.com> References: <47A99E45.3020609@linux.vnet.ibm.com> Message-ID: <47A9C22A.6060206@linux.vnet.ibm.com> Heidi Eckhart wrote: > Jay Gagnon wrote: >> # HG changeset patch >> # User Jay Gagnon >> # Date 1202224718 18000 >> # Node ID c24b2e6d1bce44af234d379cfc8b7ee116621109 >> # Parent fdce6fa993b5a9dce654b3e0cf527599f86b9f67 >> Add calls into VSMigrationService to utilize new MigrationIndication >> provider. >> >> Changes from #1 to #2: >> Break out indication code from migration_job_set_state. >> Changed cu_dup_instance call to match new signature. >> >> Signed-off-by: Jay Gagnon >> >> diff -r fdce6fa993b5 -r c24b2e6d1bce src/Virt_VSMigrationService.c >> --- a/src/Virt_VSMigrationService.c Tue Feb 05 10:18:37 2008 -0500 >> +++ b/src/Virt_VSMigrationService.c Tue Feb 05 10:18:38 2008 -0500 >> @@ -34,6 +34,7 @@ >> #include "misc_util.h" >> #include >> #include >> +#include >> > It's maybe my ignorance now, but should this also be "#include > " as in the lines before ? > > > No, I'd imagine you're right there. I'm not sure how I didn't notice the prefix when I put that line in; it all compiles and links so I never went back to look at that line again. Dan, is this the kind of thing you can fix when you put the patch in? If this is the only remaining issue it seems a little silly to resend the set again, but I of course can if that's preferred. -- -Jay From danms at us.ibm.com Wed Feb 6 15:02:04 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 06 Feb 2008 07:02:04 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider In-Reply-To: <47A9C22A.6060206@linux.vnet.ibm.com> (Jay Gagnon's message of "Wed, 06 Feb 2008 09:20:26 -0500") References: <47A99E45.3020609@linux.vnet.ibm.com> <47A9C22A.6060206@linux.vnet.ibm.com> Message-ID: <873as63z83.fsf@caffeine.beaverton.ibm.com> JG> Dan, is this the kind of thing you can fix when you put the patch JG> in? If this is the only remaining issue it seems a little silly JG> to resend the set again, but I of course can if that's preferred. Fixed and applied. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From grendel at linux.vnet.ibm.com Wed Feb 6 15:42:46 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Wed, 06 Feb 2008 10:42:46 -0500 Subject: [Libvirt-cim] [PATCH 2 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider In-Reply-To: <873as63z83.fsf@caffeine.beaverton.ibm.com> References: <47A99E45.3020609@linux.vnet.ibm.com> <47A9C22A.6060206@linux.vnet.ibm.com> <873as63z83.fsf@caffeine.beaverton.ibm.com> Message-ID: <47A9D576.2030105@linux.vnet.ibm.com> Dan Smith wrote: > JG> Dan, is this the kind of thing you can fix when you put the patch > JG> in? If this is the only remaining issue it seems a little silly > JG> to resend the set again, but I of course can if that's preferred. > > Fixed and applied. > Cool, thanks. I promise not to make a regular habit of that. :) -- -Jay From kaitlin at linux.vnet.ibm.com Wed Feb 6 15:51:34 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 07:51:34 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] #2 Add provider for VirtualSystemMigratonSettingData Message-ID: This patchset adds support for the VirtualSystemMigrationSettingData provider. Updates: -Add connect_by_classname() check. From kaitlin at linux.vnet.ibm.com Wed Feb 6 15:51:35 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 07:51:35 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add new provider - VirtualSystemMigrationSettingData In-Reply-To: Message-ID: <031e213e496178a7fc82.1202313095@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202312785 28800 # Node ID 031e213e496178a7fc82ce1ca895a28bc223fdf6 # Parent 06459df42e99beb1626dc4be039b7a1530847b4d Add new provider - VirtualSystemMigrationSettingData. Update from set 1 to set 2: -Add connect_by_classname() check. Signed-off-by: Kaitlin Rupert diff -r 06459df42e99 -r 031e213e4961 src/Virt_VSMigrationSettingData.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VSMigrationSettingData.c Wed Feb 06 07:46:25 2008 -0800 @@ -0,0 +1,170 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Kaitlin Rupert + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "misc_util.h" + +const static CMPIBroker *_BROKER; + +static CMPIStatus set_properties(const CMPIBroker *broker, + CMPIInstance *inst) +{ + CMPIStatus s; + uint16_t type = 3; /* Use live migration as default */ + uint16_t priority = 0; /* Use default priority */ + + CMSetProperty(inst, "MigrationType", + (CMPIValue *)&type, CMPI_uint16); + + CMSetProperty(inst, "Priority", + (CMPIValue *)&priority, CMPI_uint16); + + + CMSetStatus(&s, CMPI_RC_OK); + + return s; +} + +static CMPIStatus get_migration_sd(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst) +{ + CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + inst = get_typed_instance(broker, + CLASSNAME(ref), + "VirtualSystemMigrationSettingData", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get instance for %s", CLASSNAME(ref)); + goto out; + } + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)"MigrationSettingData", CMPI_chars); + + s = set_properties(broker, inst); + + if (s.rc != CMPI_RC_OK) + goto out; + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + + out: + return s; +} + +static CMPIStatus return_vsmsd(const CMPIObjectPath *ref, + const CMPIResult *results, + bool name_only, + bool is_get_inst) +{ + CMPIInstance *inst = NULL; + CMPIStatus s; + + s = get_migration_sd(ref, &inst, _BROKER, is_get_inst); + + if (s.rc == CMPI_RC_OK) { + if (name_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + } + + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref) +{ + return return_vsmsd(ref, results, true, false); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + return return_vsmsd(ref, results, false, false); +} + + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + return return_vsmsd(ref, results, false, true); +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, + Virt_VSMigrationSettingData, + _BROKER, + libvirt_cim_init()); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From kaitlin at linux.vnet.ibm.com Wed Feb 6 15:51:36 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 07:51:36 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Add necessary pieces to build Virt_VSMigrationSettingData.c In-Reply-To: Message-ID: <55a390d37b3f3fd2a137.1202313096@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202312788 28800 # Node ID 55a390d37b3f3fd2a1372198ed6e6740a328ee99 # Parent 031e213e496178a7fc82ce1ca895a28bc223fdf6 Add necessary pieces to build Virt_VSMigrationSettingData.c Signed-off-by: Kaitlin Rupert diff -r 031e213e4961 -r 55a390d37b3f Makefile.am --- a/Makefile.am Wed Feb 06 07:46:25 2008 -0800 +++ b/Makefile.am Wed Feb 06 07:46:28 2008 -0800 @@ -35,7 +35,8 @@ MOFS = \ schema/HostedService.mof \ schema/ElementSettingData.mof \ schema/VSMigrationCapabilities.mof \ - schema/VSMigrationService.mof + schema/VSMigrationService.mof \ + schema/VSMigrationSettingData.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -77,7 +78,8 @@ REGS = \ schema/ElementSettingData.registration \ schema/VSMigrationCapabilities.registration \ schema/VSMigrationService.registration \ - schema/ElementConformsToProfile.registration + schema/ElementConformsToProfile.registration \ + schema/VSMigrationSettingData.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ @@ -109,4 +111,5 @@ clean-local: clean-local: rm -f $(find . -name "*.orig") rm -f $(find . -name "*.rej") - rm -f $(find . -name "*~") \ No newline at end of file + rm -f $(find . -name "*~") + diff -r 031e213e4961 -r 55a390d37b3f schema/VSMigrationSettingData.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationSettingData.mof Wed Feb 06 07:46:28 2008 -0800 @@ -0,0 +1,15 @@ +// Copyright IBM Corp. 2007 + +class CIM_VirtualSystemMigrationSettingData : CIM_SettingData { + uint16 MigrationType; + + uint16 Priority; +}; + +[Provider("cmpi::Virt_VSMigrationSettingData")] +class Xen_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { +}; + +[Provider("cmpi::Virt_VSMigrationSettingData")] +class KVM_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { +}; diff -r 031e213e4961 -r 55a390d37b3f schema/VSMigrationSettingData.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationSettingData.registration Wed Feb 06 07:46:28 2008 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemMigrationSettingData root/virt Virt_VSMigrationSettingData Virt_VSMigrationSettingData instance +KVM_VirtualSystemMigrationSettingData root/virt Virt_VSMigrationSettingData Virt_VSMigrationSettingData instance diff -r 031e213e4961 -r 55a390d37b3f src/Makefile.am --- a/src/Makefile.am Wed Feb 06 07:46:25 2008 -0800 +++ b/src/Makefile.am Wed Feb 06 07:46:28 2008 -0800 @@ -53,7 +53,8 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_HostedService.la \ libVirt_ElementSettingData.la \ libVirt_VSMigrationCapabilities.la \ - libVirt_VSMigrationService.la + libVirt_VSMigrationService.la \ + libVirt_VSMigrationSettingData.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -150,3 +151,5 @@ libVirt_VSMigrationService_la_SOURCES = libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem +libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c + From kaitlin at linux.vnet.ibm.com Wed Feb 6 15:52:33 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 07:52:33 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add new provider - VirtualSystemMigrationSettingData In-Reply-To: <47A97AFF.5070107@linux.vnet.ibm.com> References: <47A97AFF.5070107@linux.vnet.ibm.com> Message-ID: <47A9D7C1.2090505@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> +static CMPIStatus get_migration_sd(const CMPIObjectPath *ref, >> + CMPIInstance **_inst, >> + const CMPIBroker *broker, >> + bool is_get_inst) >> +{ >> + CMPIInstance *inst; >> + CMPIStatus s; >> > Please check if you can get a connection to libvirt with the given > classname. Otherwise you return Xen instances on a KVM only system (and > reverse). ResourcePoolConfigurationService is already doing so (was a > fix some days ago). Thanks. Oh yes, excellent point. I've sent a new patch. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Wed Feb 6 16:22:38 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 08:22:38 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] Add VSMigrationSettingData support to SettingsDefineState In-Reply-To: <47A9830E.8020900@linux.vnet.ibm.com> References: <47A9830E.8020900@linux.vnet.ibm.com> Message-ID: <47A9DECE.7050805@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> Per the VirtualSystemMigration Profile, there needs to be a >> SettingsDefineCapabilities association between VSMigrationCapabilities >> and VSMigrationSettingData. >> >> > Only one comment ... great work :) ... +1 > The only comment was regarding the name change for the superclass Virt_VirtualSystemMigrationCapabilities to CIM_, right? If so, I'll fix that (and the VirtualSystemMigrationCapabilities reference checking) in a separate patch. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Wed Feb 6 16:23:25 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 08:23:25 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Add more meaningful return messages to EO parsing functions In-Reply-To: <47A99866.9030505@linux.vnet.ibm.com> References: <7cdea1fba87f7aea14d9.1202251465@elm3b41.beaverton.ibm.com> <47A99866.9030505@linux.vnet.ibm.com> Message-ID: <47A9DEFD.2070201@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> # HG changeset patch >> # User Kaitlin Rupert >> # 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 >> >> 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, >> > The error code should stay CMPI_RC_ERR_INVALID_PARAMETER Oops, that was careless of me, Thanks for catching this. =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Wed Feb 6 16:27:20 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 08:27:20 -0800 Subject: [Libvirt-cim] [PATCH] [CU] #2 Add more meaningful return messages to EO parsing functions Message-ID: <2760beb95b59fde75f33.1202315240@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # 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 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; From danms at us.ibm.com Wed Feb 6 16:48:20 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 06 Feb 2008 08:48:20 -0800 Subject: [Libvirt-cim] [PATCH] (#2) Make the ProcRASD show CPU pinning information Message-ID: <1f9cfddac518f134de81.1202316500@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # 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 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 #include #include +#include #include #include @@ -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 */ From danms at us.ibm.com Wed Feb 6 16:51:07 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 06 Feb 2008 08:51:07 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add new provider - VirtualSystemMigrationSettingData In-Reply-To: <031e213e496178a7fc82.1202313095@elm3b41.beaverton.ibm.com> (Kaitlin Rupert's message of "Wed, 06 Feb 2008 07:51:35 -0800") References: <031e213e496178a7fc82.1202313095@elm3b41.beaverton.ibm.com> Message-ID: <87tzkm2flw.fsf@caffeine.beaverton.ibm.com> KR> + conn = connect_by_classname(broker, CLASSNAME(ref), &s); You open a connection here... KR> + if (conn == NULL) { KR> + if (is_get_inst) KR> + cu_statusf(broker, &s, KR> + CMPI_RC_ERR_NOT_FOUND, KR> + "No such instance"); KR> + goto out; KR> + } KR> + KR> + inst = get_typed_instance(broker, KR> + CLASSNAME(ref), KR> + "VirtualSystemMigrationSettingData", KR> + NAMESPACE(ref)); KR> + if (inst == NULL) { KR> + cu_statusf(broker, &s, KR> + CMPI_RC_ERR_FAILED, KR> + "Unable to get instance for %s", CLASSNAME(ref)); KR> + goto out; KR> + } KR> + KR> + CMSetProperty(inst, "InstanceID", KR> + (CMPIValue *)"MigrationSettingData", CMPI_chars); KR> + KR> + s = set_properties(broker, inst); KR> + KR> + if (s.rc != CMPI_RC_OK) KR> + goto out; KR> + KR> + if (is_get_inst) { KR> + s = cu_validate_ref(broker, ref, inst); KR> + if (s.rc != CMPI_RC_OK) KR> + goto out; KR> + } KR> + KR> + *_inst = inst; KR> + KR> + out: KR> + return s; KR> +} ...and then leak it here :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Wed Feb 6 17:18:06 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 09:18:06 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add new provider - VirtualSystemMigrationSettingData In-Reply-To: <87tzkm2flw.fsf@caffeine.beaverton.ibm.com> References: <031e213e496178a7fc82.1202313095@elm3b41.beaverton.ibm.com> <87tzkm2flw.fsf@caffeine.beaverton.ibm.com> Message-ID: <47A9EBCE.4020707@linux.vnet.ibm.com> Dan Smith wrote: > KR> + conn = connect_by_classname(broker, CLASSNAME(ref), &s); > > You open a connection here... > KR> + out: > KR> + return s; > KR> +} > > ...and then leak it here :) Indeed. =) New patch soon... -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Wed Feb 6 17:26:29 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 09:26:29 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Add necessary pieces to build Virt_VSMigrationSettingData.c In-Reply-To: Message-ID: <8eb16e4040cd61d235aa.1202318789@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202318303 28800 # Node ID 8eb16e4040cd61d235aa8b34901f84b949adc080 # Parent cb802f02eb0d7de8d478d87703613d5e1319fd45 Add necessary pieces to build Virt_VSMigrationSettingData.c Signed-off-by: Kaitlin Rupert diff -r cb802f02eb0d -r 8eb16e4040cd Makefile.am --- a/Makefile.am Wed Feb 06 09:18:19 2008 -0800 +++ b/Makefile.am Wed Feb 06 09:18:23 2008 -0800 @@ -36,7 +36,8 @@ MOFS = \ schema/HostedService.mof \ schema/ElementSettingData.mof \ schema/VSMigrationCapabilities.mof \ - schema/VSMigrationService.mof + schema/VSMigrationService.mof \ + schema/VSMigrationSettingData.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -79,7 +80,8 @@ REGS = \ schema/ElementSettingData.registration \ schema/VSMigrationCapabilities.registration \ schema/VSMigrationService.registration \ - schema/ElementConformsToProfile.registration + schema/ElementConformsToProfile.registration \ + schema/VSMigrationSettingData.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ @@ -112,3 +114,4 @@ clean-local: rm -f $(find . -name "*.orig") rm -f $(find . -name "*.rej") rm -f $(find . -name "*~") + diff -r cb802f02eb0d -r 8eb16e4040cd schema/VSMigrationSettingData.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationSettingData.mof Wed Feb 06 09:18:23 2008 -0800 @@ -0,0 +1,15 @@ +// Copyright IBM Corp. 2007 + +class CIM_VirtualSystemMigrationSettingData : CIM_SettingData { + uint16 MigrationType; + + uint16 Priority; +}; + +[Provider("cmpi::Virt_VSMigrationSettingData")] +class Xen_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { +}; + +[Provider("cmpi::Virt_VSMigrationSettingData")] +class KVM_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { +}; diff -r cb802f02eb0d -r 8eb16e4040cd schema/VSMigrationSettingData.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationSettingData.registration Wed Feb 06 09:18:23 2008 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemMigrationSettingData root/virt Virt_VSMigrationSettingData Virt_VSMigrationSettingData instance +KVM_VirtualSystemMigrationSettingData root/virt Virt_VSMigrationSettingData Virt_VSMigrationSettingData instance diff -r cb802f02eb0d -r 8eb16e4040cd src/Makefile.am --- a/src/Makefile.am Wed Feb 06 09:18:19 2008 -0800 +++ b/src/Makefile.am Wed Feb 06 09:18:23 2008 -0800 @@ -54,7 +54,8 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_HostedService.la \ libVirt_ElementSettingData.la \ libVirt_VSMigrationCapabilities.la \ - libVirt_VSMigrationService.la + libVirt_VSMigrationService.la \ + libVirt_VSMigrationSettingData.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -155,3 +156,5 @@ libVirt_VSMigrationService_la_SOURCES = libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem +libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c + From kaitlin at linux.vnet.ibm.com Wed Feb 6 17:26:28 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 09:26:28 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add new provider - VirtualSystemMigrationSettingData In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1202318299 28800 # Node ID cb802f02eb0d7de8d478d87703613d5e1319fd45 # Parent a64a399d1593d304c31ef146fd7661ef47d0619d Add new provider - VirtualSystemMigrationSettingData. Update from set 2 to set 3: -Be sure to close the connection Update from set 1 to set 2: -Add connect_by_classname() check. Signed-off-by: Kaitlin Rupert diff -r a64a399d1593 -r cb802f02eb0d src/Virt_VSMigrationSettingData.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VSMigrationSettingData.c Wed Feb 06 09:18:19 2008 -0800 @@ -0,0 +1,172 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Kaitlin Rupert + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "misc_util.h" + +const static CMPIBroker *_BROKER; + +static CMPIStatus set_properties(const CMPIBroker *broker, + CMPIInstance *inst) +{ + CMPIStatus s; + uint16_t type = 3; /* Use live migration as default */ + uint16_t priority = 0; /* Use default priority */ + + CMSetProperty(inst, "MigrationType", + (CMPIValue *)&type, CMPI_uint16); + + CMSetProperty(inst, "Priority", + (CMPIValue *)&priority, CMPI_uint16); + + + CMSetStatus(&s, CMPI_RC_OK); + + return s; +} + +static CMPIStatus get_migration_sd(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst) +{ + CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + inst = get_typed_instance(broker, + CLASSNAME(ref), + "VirtualSystemMigrationSettingData", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get instance for %s", CLASSNAME(ref)); + goto out; + } + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)"MigrationSettingData", CMPI_chars); + + s = set_properties(broker, inst); + + if (s.rc != CMPI_RC_OK) + goto out; + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_vsmsd(const CMPIObjectPath *ref, + const CMPIResult *results, + bool name_only, + bool is_get_inst) +{ + CMPIInstance *inst = NULL; + CMPIStatus s; + + s = get_migration_sd(ref, &inst, _BROKER, is_get_inst); + + if (s.rc == CMPI_RC_OK) { + if (name_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + } + + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref) +{ + return return_vsmsd(ref, results, true, false); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + return return_vsmsd(ref, results, false, false); +} + + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + return return_vsmsd(ref, results, false, true); +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, + Virt_VSMigrationSettingData, + _BROKER, + libvirt_cim_init()); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From kaitlin at linux.vnet.ibm.com Wed Feb 6 17:26:27 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 09:26:27 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] #3 Add provider for VirtualSystemMigratonSettingData Message-ID: This patchset adds support for the VirtualSystemMigrationSettingData provider. Updates: -(#3) Be sure to close the connection. -(#2) Add connect_by_classname() check. From danms at us.ibm.com Wed Feb 6 17:57:57 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 06 Feb 2008 09:57:57 -0800 Subject: [Libvirt-cim] [PATCH] (#3) Make the ProcRASD show CPU pinning information Message-ID: # HG changeset patch # User Dan Smith # 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 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 #include #include +#include #include #include @@ -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 */ From kaitlin at linux.vnet.ibm.com Wed Feb 6 18:08:28 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 06 Feb 2008 10:08:28 -0800 Subject: [Libvirt-cim] [PATCH] (#3) Make the ProcRASD show CPU pinning information In-Reply-To: References: Message-ID: <47A9F79C.80108@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # 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 > I think this is ready to go. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From heidieck at linux.vnet.ibm.com Thu Feb 7 08:08:37 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 07 Feb 2008 09:08:37 +0100 Subject: [Libvirt-cim] [PATCH 0 of 2] Add VSMigrationSettingData support to SettingsDefineState In-Reply-To: <47A9DECE.7050805@linux.vnet.ibm.com> References: <47A9830E.8020900@linux.vnet.ibm.com> <47A9DECE.7050805@linux.vnet.ibm.com> Message-ID: <47AABC85.6030504@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Heidi Eckhart wrote: >> Kaitlin Rupert wrote: >>> Per the VirtualSystemMigration Profile, there needs to be a >>> SettingsDefineCapabilities association between >>> VSMigrationCapabilities and VSMigrationSettingData. >>> >>> >> Only one comment ... great work :) ... +1 >> > > The only comment was regarding the name change for the superclass > Virt_VirtualSystemMigrationCapabilities to CIM_, right? > > If so, I'll fix that (and the VirtualSystemMigrationCapabilities > reference checking) in a separate patch. > > Thanks! > Yes, thank you :) ! -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Thu Feb 7 08:46:24 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 07 Feb 2008 09:46:24 +0100 Subject: [Libvirt-cim] [PATCH 2 of 2] [CU] Improve std_indication's raise functionality In-Reply-To: <47A9BA58.5030608@linux.vnet.ibm.com> References: <47A99FFA.2070605@linux.vnet.ibm.com> <47A9BA58.5030608@linux.vnet.ibm.com> Message-ID: <47AAC560.3030305@linux.vnet.ibm.com> Jay Gagnon wrote: > 2 out of 2 hunks ignored -- saving rejects to file std_indication.c.rej > 4 out of 4 hunks ignored -- saving rejects to file std_indication.h.rej > > That's what I got, and when I checked the changesets that had been > added in my last update I noticed the raise functionality patch was > already in. > Yes, that's exactly what I got. So fine. Then everything is ok :). Thanks. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Thu Feb 7 09:02:14 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 07 Feb 2008 10:02:14 +0100 Subject: [Libvirt-cim] [PATCH 1 of 2] Add new provider - VirtualSystemMigrationSettingData In-Reply-To: References: Message-ID: <47AAC916.8060104@linux.vnet.ibm.com> Kaitlin Rupert wrote: > +static CMPIStatus return_vsmsd(const CMPIObjectPath *ref, > + const CMPIResult *results, > + bool name_only, > + bool is_get_inst) > +{ > + CMPIInstance *inst = NULL; > + CMPIStatus s; > + > + s = get_migration_sd(ref, &inst, _BROKER, is_get_inst); > This is seg faulting the provider for a request against Xen on a KVM only system (and reverse). The reason is that get_migration_sd() returns with OK but no instances for Xen. This inst==NULL seg faults the following returns. > + > + if (s.rc == CMPI_RC_OK) { > + if (name_only) > + cu_return_instance_name(results, inst); > + else > + CMReturnInstance(results, inst); > + } > + > + return s; > +} > + > -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From kaitlin at linux.vnet.ibm.com Thu Feb 7 16:29:53 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 07 Feb 2008 08:29:53 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add new provider - VirtualSystemMigrationSettingData In-Reply-To: <47AAC916.8060104@linux.vnet.ibm.com> References: <47AAC916.8060104@linux.vnet.ibm.com> Message-ID: <47AB3201.3070100@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> +static CMPIStatus return_vsmsd(const CMPIObjectPath *ref, >> + const CMPIResult *results, >> + bool name_only, >> + bool is_get_inst) >> +{ >> + CMPIInstance *inst = NULL; >> + CMPIStatus s; >> + >> + s = get_migration_sd(ref, &inst, _BROKER, is_get_inst); >> > This is seg faulting the provider for a request against Xen on a KVM > only system (and reverse). The reason is that get_migration_sd() returns > with OK but no instances for Xen. This inst==NULL seg faults the > following returns. > Thanks Heidi - I thought I had tested for this, but I had tested incorrectly. I didn't have CMPIInstance *inst = NULL; in the previous patch, but I got compiler warnings this time around. I'll send a fix with a check for if ((s.rc == CMPI_RC_OK) && (inst != NULL)) since this is a case where we don't want to return an error if we cannot connect, but we also don't want to seg fault either. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Thu Feb 7 16:37:03 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 07 Feb 2008 08:37:03 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] #4 Add provider for VirtualSystemMigratonSettingData Message-ID: This patchset adds support for the VirtualSystemMigrationSettingData provider. Updates: -(#4) Fix seg fault -(#3) Be sure to close the connection. -(#2) Add connect_by_classname() check. From kaitlin at linux.vnet.ibm.com Thu Feb 7 16:37:04 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 07 Feb 2008 08:37:04 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add new provider - VirtualSystemMigrationSettingData In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1202402048 28800 # Node ID ddcfb601c4798a29ae70cfc8c68f49a83427daa6 # Parent f367616697ad657f3e1fa85e6ce897de9ea2c45e Add new provider - VirtualSystemMigrationSettingData. Update from set 3 to set 4: -Add check for inst != NULL so the provider doesn't seg fault in the case where it couldn't connect to libvirt with the give uri. Update from set 2 to set 3: -Be sure to close the connection Update from set 1 to set 2: -Add connect_by_classname() check. Signed-off-by: Kaitlin Rupert diff -r f367616697ad -r ddcfb601c479 src/Virt_VSMigrationSettingData.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VSMigrationSettingData.c Thu Feb 07 08:34:08 2008 -0800 @@ -0,0 +1,172 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Kaitlin Rupert + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "misc_util.h" + +const static CMPIBroker *_BROKER; + +static CMPIStatus set_properties(const CMPIBroker *broker, + CMPIInstance *inst) +{ + CMPIStatus s; + uint16_t type = 3; /* Use live migration as default */ + uint16_t priority = 0; /* Use default priority */ + + CMSetProperty(inst, "MigrationType", + (CMPIValue *)&type, CMPI_uint16); + + CMSetProperty(inst, "Priority", + (CMPIValue *)&priority, CMPI_uint16); + + + CMSetStatus(&s, CMPI_RC_OK); + + return s; +} + +static CMPIStatus get_migration_sd(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst) +{ + CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + inst = get_typed_instance(broker, + CLASSNAME(ref), + "VirtualSystemMigrationSettingData", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get instance for %s", CLASSNAME(ref)); + goto out; + } + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)"MigrationSettingData", CMPI_chars); + + s = set_properties(broker, inst); + + if (s.rc != CMPI_RC_OK) + goto out; + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_vsmsd(const CMPIObjectPath *ref, + const CMPIResult *results, + bool name_only, + bool is_get_inst) +{ + CMPIInstance *inst = NULL; + CMPIStatus s; + + s = get_migration_sd(ref, &inst, _BROKER, is_get_inst); + + if ((s.rc == CMPI_RC_OK) && (inst != NULL)) { + if (name_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + } + + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref) +{ + return return_vsmsd(ref, results, true, false); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + return return_vsmsd(ref, results, false, false); +} + + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + return return_vsmsd(ref, results, false, true); +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, + Virt_VSMigrationSettingData, + _BROKER, + libvirt_cim_init()); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From kaitlin at linux.vnet.ibm.com Thu Feb 7 16:37:05 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 07 Feb 2008 08:37:05 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Add necessary pieces to build Virt_VSMigrationSettingData.c In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1202402210 28800 # Node ID c7c549e7c93bc757c6a5db1cb52e1375b9199c34 # Parent ddcfb601c4798a29ae70cfc8c68f49a83427daa6 Add necessary pieces to build Virt_VSMigrationSettingData.c Signed-off-by: Kaitlin Rupert diff -r ddcfb601c479 -r c7c549e7c93b Makefile.am --- a/Makefile.am Thu Feb 07 08:34:08 2008 -0800 +++ b/Makefile.am Thu Feb 07 08:36:50 2008 -0800 @@ -36,7 +36,8 @@ MOFS = \ schema/HostedService.mof \ schema/ElementSettingData.mof \ schema/VSMigrationCapabilities.mof \ - schema/VSMigrationService.mof + schema/VSMigrationService.mof \ + schema/VSMigrationSettingData.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -79,7 +80,8 @@ REGS = \ schema/ElementSettingData.registration \ schema/VSMigrationCapabilities.registration \ schema/VSMigrationService.registration \ - schema/ElementConformsToProfile.registration + schema/ElementConformsToProfile.registration \ + schema/VSMigrationSettingData.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ @@ -112,3 +114,4 @@ clean-local: rm -f $(find . -name "*.orig") rm -f $(find . -name "*.rej") rm -f $(find . -name "*~") + diff -r ddcfb601c479 -r c7c549e7c93b schema/VSMigrationSettingData.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationSettingData.mof Thu Feb 07 08:36:50 2008 -0800 @@ -0,0 +1,15 @@ +// Copyright IBM Corp. 2007 + +class CIM_VirtualSystemMigrationSettingData : CIM_SettingData { + uint16 MigrationType; + + uint16 Priority; +}; + +[Provider("cmpi::Virt_VSMigrationSettingData")] +class Xen_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { +}; + +[Provider("cmpi::Virt_VSMigrationSettingData")] +class KVM_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { +}; diff -r ddcfb601c479 -r c7c549e7c93b schema/VSMigrationSettingData.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationSettingData.registration Thu Feb 07 08:36:50 2008 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemMigrationSettingData root/virt Virt_VSMigrationSettingData Virt_VSMigrationSettingData instance +KVM_VirtualSystemMigrationSettingData root/virt Virt_VSMigrationSettingData Virt_VSMigrationSettingData instance diff -r ddcfb601c479 -r c7c549e7c93b src/Makefile.am --- a/src/Makefile.am Thu Feb 07 08:34:08 2008 -0800 +++ b/src/Makefile.am Thu Feb 07 08:36:50 2008 -0800 @@ -54,7 +54,8 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_HostedService.la \ libVirt_ElementSettingData.la \ libVirt_VSMigrationCapabilities.la \ - libVirt_VSMigrationService.la + libVirt_VSMigrationService.la \ + libVirt_VSMigrationSettingData.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -155,3 +156,5 @@ libVirt_VSMigrationService_la_SOURCES = libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem +libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c + From grendel at linux.vnet.ibm.com Thu Feb 7 21:39:40 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Thu, 07 Feb 2008 16:39:40 -0500 Subject: [Libvirt-cim] [PATCH] [RFC] [CU] Turn std_indication's awesome knob to eleven Message-ID: <7feaabeb36cea13611d6.1202420380@naegling> # HG changeset patch # User Jay Gagnon # Date 1202420200 18000 # Node ID 7feaabeb36cea13611d6dc045cd2bd946528032b # Parent 60ecfe23d68caaa9dda1f115289f168ea8f4a297 [RFC] [CU] Turn std_indication's awesome knob to eleven This is the prototype of a new std_indication that will handle Enable/DisableIndications and Activate/DeactivateFilter correctly, even on a per-indication basis when one provider handles more than one indication. Those functions will also now have default_foo equivalents in std_indication, as many providers (especially raise-style ones) will have no special needs there. The hope is that this will *require* minimal change from existing Indicatio providers, but *allow* for code reduction in most, and of course new providers should try to utilize this. Signed-off-by: Jay Gagnon diff -r 60ecfe23d68c -r 7feaabeb36ce instance_util.c --- a/instance_util.c Tue Feb 05 16:01:32 2008 -0500 +++ b/instance_util.c Thu Feb 07 16:36:40 2008 -0500 @@ -251,6 +251,27 @@ CMPIInstance *cu_dup_instance(const CMPI out: return dest; +} + +char *classname_from_inst(const CMPIBroker *broker, + CMPIInstance *inst, + CMPIStatus *s) +{ + char *ret = NULL; + + CMPIObjectPath *ref; + ref = CMGetObjectPath(inst, s); + if ((s->rc != CMPI_RC_OK) || CMIsNullObject(ref)) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Could not get objectpath from instance"); + goto out; + } + + ret = strdup(CLASSNAME(ref)); + + out: + return ret; } /* diff -r 60ecfe23d68c -r 7feaabeb36ce libcmpiutil.h --- a/libcmpiutil.h Tue Feb 05 16:01:32 2008 -0500 +++ b/libcmpiutil.h Thu Feb 07 16:36:40 2008 -0500 @@ -413,6 +413,19 @@ CMPIStatus cu_validate_ref(const CMPIBro CMPIStatus cu_validate_ref(const CMPIBroker *broker, const CMPIObjectPath *ref, const CMPIInstance *inst); + +/** + * Returns the classname from an instance without forcing user to get + * ObjectPath first. + * + * @param broker A pointer to the current broker + * @param inst Instance to examine + * @param s An out pointer for returning status if error occurs + * @returns Classname of instance (must be freed), NULL on failure + */ +char *classname_from_inst(const CMPIBroker *broker, + CMPIInstance *inst, + CMPIStatus *s); #define DEFAULT_EIN(pn) \ static CMPIStatus pn##EnumInstanceNames(CMPIInstanceMI *self, \ diff -r 60ecfe23d68c -r 7feaabeb36ce std_indication.c --- a/std_indication.c Tue Feb 05 16:01:32 2008 -0500 +++ b/std_indication.c Thu Feb 07 16:36:40 2008 -0500 @@ -32,6 +32,45 @@ #include "std_indication.h" +static struct std_ind_state *get_ind_state(struct std_ind_state **list, + char *ind_name) +{ + int i; + struct std_ind_state *state = NULL; + + for (i = 0; list[i] != NULL; i++) { + if (STREQC((list[i])->ind_name, ind_name)) { + state = list[i]; + break; + } + } + + if (state == NULL) + CU_DEBUG("get_ind_state: failed to find %s", ind_name); + + return state; +} + +static bool is_ind_enabled(struct std_indication_ctx *ctx, + char *ind_name, + CMPIStatus *s) +{ + bool ret = false; + struct std_ind_state *state; + + state = get_ind_state(ctx->ind_states, ind_name); + if (state == NULL) { + cu_statusf(ctx->brkr, s, + CMPI_RC_ERR_FAILED, + "No std_ind_state for %s", ind_name); + goto out; + } + + ret = state->enabled; + out: + return ret; +} + static CMPIStatus trigger(struct std_indication_ctx *ctx, const CMPIContext *context) { @@ -61,20 +100,85 @@ static CMPIStatus raise(struct std_indic const CMPIContext *context, const CMPIArgs *argsin) { + bool enabled; CMPIInstance *inst; - - if (!ctx->enabled) { - CU_DEBUG("Indication disabled, not raising."); - return (CMPIStatus) {CMPI_RC_OK, NULL}; - } - - if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK) - return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL}; - + CMPIStatus s = {CMPI_RC_OK, NULL}; + char *ind_name = NULL; + + if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK) { + cu_statusf(ctx->brkr, &s, + CMPI_RC_ERR_FAILED, + "Could not get indication to raise"); + goto out; + } + + ind_name = classname_from_inst(ctx->brkr, inst, &s); + if (s.rc != CMPI_RC_OK || ind_name == NULL) { + cu_statusf(ctx->brkr, &s, + CMPI_RC_ERR_FAILED, + "Couldn't get indication name for enable check."); + } + + enabled = is_ind_enabled(ctx, ind_name, &s); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Problem checking enabled: '%s'", CMGetCharPtr(s.msg)); + goto out; + } + if (!enabled) { + CU_DEBUG("%s disabled, not raising", ind_name); + goto out; + } + + CU_DEBUG("Calling appropriate raise function"); if (ctx->handler->raise_fn == NULL) - return default_raise(ctx->brkr, context, inst); - - return ctx->handler->raise_fn(ctx->brkr, context, inst); + s = default_raise(ctx->brkr, context, inst); + else + s = ctx->handler->raise_fn(ctx->brkr, context, inst); + + out: + free(ind_name); + return s; +} + +CMPIStatus stdi_set_ind_state_prop(struct std_indication_ctx *ctx, + char *ind_name, + int prop, + bool value) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + struct std_ind_state *state; + + CU_DEBUG("In stdi_set_ind_state_prop"); + + state = get_ind_state(ctx->ind_states, ind_name); + if (state == NULL) { + CU_DEBUG("state == NULL, exiting"); + cu_statusf(ctx->brkr, &s, + CMPI_RC_ERR_FAILED, + "Provider has no indication '%s'", ind_name); + goto out; + } + + CU_DEBUG("entering switch"); + switch (prop) { + case STDI_PROP_FILTER: + state->filter_active = value; + CU_DEBUG("Filter: %s set to %d", ind_name, value); + break; + case STDI_PROP_ENABLE: + state->enabled = value; + CU_DEBUG("Enable: %s set to %d", ind_name, value); + break; + default: + CU_DEBUG("default case"); + cu_statusf(ctx->brkr, &s, + CMPI_RC_ERR_FAILED, + "Invalid indication state property: %d", prop); + goto out; + } + + out: + return s; } CMPIStatus stdi_handler(CMPIMethodMI *self, diff -r 60ecfe23d68c -r 7feaabeb36ce std_indication.h --- a/std_indication.h Tue Feb 05 16:01:32 2008 -0500 +++ b/std_indication.h Thu Feb 07 16:36:40 2008 -0500 @@ -58,22 +58,36 @@ typedef CMPIStatus (*raise_indication_t) typedef CMPIStatus (*trigger_indication_t)(const CMPIContext *ctx); +enum {STDI_PROP_FILTER, + STDI_PROP_ENABLE}; + struct std_indication_handler { raise_indication_t raise_fn; trigger_indication_t trigger_fn; }; +struct std_ind_state { + char *ind_name; + bool filter_active; + bool enabled; +}; + struct std_indication_ctx { const CMPIBroker *brkr; struct std_indication_handler *handler; - bool enabled; + struct std_ind_state **ind_states; }; -#define STDI_IndicationMIStub(pfx, pn, _broker, hook, _handler) \ +CMPIStatus stdi_set_ind_state_prop(struct std_indication_ctx *ctx, + char *ind_name, + int prop, + bool state); + +#define STDI_IndicationMIStub(pfx, pn, _broker, hook, _handler, states) \ static struct std_indication_ctx _ctx = { \ .brkr = NULL, \ .handler = _handler, \ - .enabled = false, \ + .ind_states = states, \ }; \ \ static CMPIIndicationMIFT indMIFT__ = { \ From grendel at linux.vnet.ibm.com Thu Feb 7 21:39:16 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Thu, 07 Feb 2008 16:39:16 -0500 Subject: [Libvirt-cim] [PATCH] [RFC] Changes required to work with new std_indication. The trigger changes were very light, which was nice Message-ID: # HG changeset patch # User Jay Gagnon # Date 1202420324 18000 # Node ID a82dd87a3830eadda678b88bf4bfcfd4f8cb1ca4 # Parent c7dd4a8358a187a3469c3d8a177950625898a227 [RFC] Changes required to work with new std_indication. The trigger changes were very light, which was nice. Signed-off-by: Jay Gagnon diff -r c7dd4a8358a1 -r a82dd87a3830 src/Virt_ComputerSystemIndication.c --- a/src/Virt_ComputerSystemIndication.c Wed Feb 06 07:00:00 2008 -0800 +++ b/src/Virt_ComputerSystemIndication.c Thu Feb 07 16:38:44 2008 -0500 @@ -488,7 +488,8 @@ STDI_IndicationMIStub(, Virt_ComputerSystemIndication, _BROKER, libvirt_cim_init(), - &csi); + &csi, + NULL); /* * Local Variables: diff -r c7dd4a8358a1 -r a82dd87a3830 src/Virt_ComputerSystemMigrationIndication.c --- a/src/Virt_ComputerSystemMigrationIndication.c Wed Feb 06 07:00:00 2008 -0800 +++ b/src/Virt_ComputerSystemMigrationIndication.c Thu Feb 07 16:38:44 2008 -0500 @@ -58,7 +58,13 @@ static CMPIStatus ActivateFilter(CMPIInd CMPIBoolean first) { CMPIStatus s = {CMPI_RC_OK, NULL}; + struct std_indication_ctx *_ctx; + _ctx = (struct std_indication_ctx *)mi->hdl; + s = stdi_set_ind_state_prop(_ctx, + "Xen_ComputerSystemMigrationIndication", + STDI_PROP_FILTER, + true); return s; } @@ -69,16 +75,31 @@ static CMPIStatus DeActivateFilter(CMPII const CMPIObjectPath* op, CMPIBoolean last) { - return (CMPIStatus){CMPI_RC_OK, NULL}; + CMPIStatus s = {CMPI_RC_OK, NULL}; + struct std_indication_ctx *_ctx; + + _ctx = (struct std_indication_ctx *)mi->hdl; + s = stdi_set_ind_state_prop(_ctx, + "Xen_ComputerSystemMigrationIndication", + STDI_PROP_FILTER, + true); + return s; } static _EI_RTYPE EnableIndications(CMPIIndicationMI* mi, const CMPIContext *ctx) { + CMPIStatus s = {CMPI_RC_OK, NULL}; struct std_indication_ctx *_ctx; _ctx = (struct std_indication_ctx *)mi->hdl; - _ctx->enabled = true; - CU_DEBUG("ComputerSystemModifiedIndication enabled"); + + CU_DEBUG("New enable. Cross your fingers"); + s = stdi_set_ind_state_prop(_ctx, + "Xen_ComputerSystemMigrationIndication", + STDI_PROP_ENABLE, + true); + + CU_DEBUG("ComputerSystemMigrationIndication enabled"); _EI_RET(); } @@ -86,10 +107,16 @@ static _EI_RTYPE DisableIndications(CMPI static _EI_RTYPE DisableIndications(CMPIIndicationMI* mi, const CMPIContext *ctx) { + CMPIStatus s = {CMPI_RC_OK, NULL}; struct std_indication_ctx *_ctx; _ctx = (struct std_indication_ctx *)mi->hdl; - _ctx->enabled = false; - CU_DEBUG("ComputerSystemModifiedIndication disabled"); + + s = stdi_set_ind_state_prop(_ctx, + "Xen_ComputerSystemMigrationIndication", + STDI_PROP_ENABLE, + false); + + CU_DEBUG("ComputerSystemMigrationIndication disabled"); _EI_RET(); } @@ -97,6 +124,17 @@ static struct std_indication_handler csi static struct std_indication_handler csi = { .raise_fn = NULL, .trigger_fn = NULL, +}; + +static struct std_ind_state migrate = { + .ind_name = "Xen_ComputerSystemMigrationIndication", + .filter_active = false, + .enabled = false, +}; + +static struct std_ind_state *states[] = { + &migrate, + NULL, }; DEFAULT_IND_CLEANUP(); @@ -107,7 +145,8 @@ STDI_IndicationMIStub(, Virt_ComputerSystemMigrationIndication, _BROKER, libvirt_cim_init(), - &csi); + &csi, + states); /* * Local Variables: From heidieck at linux.vnet.ibm.com Fri Feb 8 09:04:24 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 08 Feb 2008 10:04:24 +0100 Subject: [Libvirt-cim] [PATCH 0 of 2] #4 Add provider for VirtualSystemMigratonSettingData In-Reply-To: References: Message-ID: <47AC1B18.1080707@linux.vnet.ibm.com> Kaitlin Rupert wrote: > This patchset adds support for the VirtualSystemMigrationSettingData provider. > > Updates: > -(#4) Fix seg fault > -(#3) Be sure to close the connection. > -(#2) Add connect_by_classname() check. > > An excellent patch set and ready to go now :) ... + -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 8 09:37:54 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 08 Feb 2008 10:37:54 +0100 Subject: [Libvirt-cim] [PATCH] [RFC] [CU] Turn std_indication's awesome knob to eleven In-Reply-To: <7feaabeb36cea13611d6.1202420380@naegling> References: <7feaabeb36cea13611d6.1202420380@naegling> Message-ID: <47AC22F2.6080904@linux.vnet.ibm.com> Jay Gagnon wrote: > diff -r 60ecfe23d68c -r 7feaabeb36ce instance_util.c > --- a/instance_util.c Tue Feb 05 16:01:32 2008 -0500 > +++ b/instance_util.c Thu Feb 07 16:36:40 2008 -0500 > @@ -251,6 +251,27 @@ CMPIInstance *cu_dup_instance(const CMPI > > out: > return dest; > +} > + > +char *classname_from_inst(const CMPIBroker *broker, > + CMPIInstance *inst, > + CMPIStatus *s) > +{ > + char *ret = NULL; > + > + CMPIObjectPath *ref; > + ref = CMGetObjectPath(inst, s); > + if ((s->rc != CMPI_RC_OK) || CMIsNullObject(ref)) { > + cu_statusf(broker, s, > + CMPI_RC_ERR_FAILED, > + "Could not get objectpath from instance"); > + goto out; > + } > + > + ret = strdup(CLASSNAME(ref)); > + > + out: > + return ret; > } > > /* > diff -r 60ecfe23d68c -r 7feaabeb36ce libcmpiutil.h > --- a/libcmpiutil.h Tue Feb 05 16:01:32 2008 -0500 > +++ b/libcmpiutil.h Thu Feb 07 16:36:40 2008 -0500 > @@ -413,6 +413,19 @@ CMPIStatus cu_validate_ref(const CMPIBro > CMPIStatus cu_validate_ref(const CMPIBroker *broker, > const CMPIObjectPath *ref, > const CMPIInstance *inst); > + > +/** > + * Returns the classname from an instance without forcing user to get > + * ObjectPath first. > + * > + * @param broker A pointer to the current broker > + * @param inst Instance to examine > + * @param s An out pointer for returning status if error occurs > + * @returns Classname of instance (must be freed), NULL on failure > + */ > +char *classname_from_inst(const CMPIBroker *broker, > + CMPIInstance *inst, > + CMPIStatus *s); > > #define DEFAULT_EIN(pn) \ > static CMPIStatus pn##EnumInstanceNames(CMPIInstanceMI *self, \ > > Please let me play the PatchCO today - is this really part of the indication patch ;) ? -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 8 10:30:20 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 08 Feb 2008 11:30:20 +0100 Subject: [Libvirt-cim] [PATCH] [RFC] Changes required to work with new std_indication. The trigger changes were very light, which was nice In-Reply-To: References: Message-ID: <47AC2F3C.5000903@linux.vnet.ibm.com> Jay Gagnon wrote: > # HG changeset patch > # User Jay Gagnon > # Date 1202420324 18000 > # Node ID a82dd87a3830eadda678b88bf4bfcfd4f8cb1ca4 > # Parent c7dd4a8358a187a3469c3d8a177950625898a227 > [RFC] Changes required to work with new std_indication. The trigger changes were very light, which was nice. > > Signed-off-by: Jay Gagnon > > diff -r c7dd4a8358a1 -r a82dd87a3830 src/Virt_ComputerSystemIndication.c > --- a/src/Virt_ComputerSystemIndication.c Wed Feb 06 07:00:00 2008 -0800 > +++ b/src/Virt_ComputerSystemIndication.c Thu Feb 07 16:38:44 2008 -0500 > @@ -488,7 +488,8 @@ STDI_IndicationMIStub(, > Virt_ComputerSystemIndication, > _BROKER, > libvirt_cim_init(), > - &csi); > + &csi, > + NULL); > > /* > * Local Variables: > I'm interested in the other changes that are necessary to the CSIndication provider to make use of the std_indication reorg - also make use of the states and not setting it to NULL ;). > diff -r c7dd4a8358a1 -r a82dd87a3830 src/Virt_ComputerSystemMigrationIndication.c > --- a/src/Virt_ComputerSystemMigrationIndication.c Wed Feb 06 07:00:00 2008 -0800 > +++ b/src/Virt_ComputerSystemMigrationIndication.c Thu Feb 07 16:38:44 2008 -0500 > If I got this right, then the MigrationIndication provider is currently only switching the migrate.filter_activate and migrate.enabled values. Potentially it could deliver an indication (by the default_raise function), but it can not as the trigger_fn is not implemented and so nothing is monitored, right ? Well, in sum - I like the approach :) - but I would even go farther. I think its possible to write one indication engine (that would become part of libcmpiutil) that handles all the CIM_InstModification, CIM_InstCreation and CIM_InstDeletion indications at once. This engine would be a large part of the CSIndication provider and maybe only the compare functions (dom_in_list, dom_changed) need to stay provider specific. But that's a guess at the moment and is worth to be evaluated (now I hope that you volunteer for this job ;) ). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From grendel at linux.vnet.ibm.com Fri Feb 8 14:38:16 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 08 Feb 2008 09:38:16 -0500 Subject: [Libvirt-cim] [PATCH] [RFC] [CU] Turn std_indication's awesome knob to eleven In-Reply-To: <47AC22F2.6080904@linux.vnet.ibm.com> References: <7feaabeb36cea13611d6.1202420380@naegling> <47AC22F2.6080904@linux.vnet.ibm.com> Message-ID: <47AC6958.8060404@linux.vnet.ibm.com> Heidi Eckhart wrote: > Jay Gagnon wrote: >> diff -r 60ecfe23d68c -r 7feaabeb36ce instance_util.c >> --- a/instance_util.c Tue Feb 05 16:01:32 2008 -0500 >> +++ b/instance_util.c Thu Feb 07 16:36:40 2008 -0500 >> @@ -251,6 +251,27 @@ CMPIInstance *cu_dup_instance(const CMPI >> >> out: >> return dest; >> +} >> + >> +char *classname_from_inst(const CMPIBroker *broker, >> + CMPIInstance *inst, >> + CMPIStatus *s) >> +{ >> + char *ret = NULL; >> + >> + CMPIObjectPath *ref; >> + ref = CMGetObjectPath(inst, s); >> + if ((s->rc != CMPI_RC_OK) || CMIsNullObject(ref)) { >> + cu_statusf(broker, s, >> + CMPI_RC_ERR_FAILED, >> + "Could not get objectpath from instance"); >> + goto out; >> + } >> + + ret = strdup(CLASSNAME(ref)); >> + >> + out: >> + return ret; >> } >> >> /* >> diff -r 60ecfe23d68c -r 7feaabeb36ce libcmpiutil.h >> --- a/libcmpiutil.h Tue Feb 05 16:01:32 2008 -0500 >> +++ b/libcmpiutil.h Thu Feb 07 16:36:40 2008 -0500 >> @@ -413,6 +413,19 @@ CMPIStatus cu_validate_ref(const CMPIBro >> CMPIStatus cu_validate_ref(const CMPIBroker *broker, >> const CMPIObjectPath *ref, >> const CMPIInstance *inst); >> + >> +/** >> + * Returns the classname from an instance without forcing user to >> get + * ObjectPath first. >> + * >> + * @param broker A pointer to the current broker >> + * @param inst Instance to examine >> + * @param s An out pointer for returning status if error occurs >> + * @returns Classname of instance (must be freed), NULL on failure >> + */ >> +char *classname_from_inst(const CMPIBroker *broker, >> + CMPIInstance *inst, >> + CMPIStatus *s); >> >> #define >> DEFAULT_EIN(pn) \ >> static CMPIStatus pn##EnumInstanceNames(CMPIInstanceMI >> *self, \ >> >> > Please let me play the PatchCO today - is this really part of the > indication patch ;) ? > Touche! :) No, you're right, it doesn't really belong. I unfortunately sent these two out in a bit of a rush right before I left yesterday, so I spent all of 30 seconds scanning for patch quality. I'm sure there are a bunch of little things, and I promise they'll be fixed in the next version, but for the most part I'm just looking for a sanity check here. Just want to make sure that I'm not doing something really crazy before I invest much more time into this. -- -Jay From grendel at linux.vnet.ibm.com Fri Feb 8 14:59:47 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 08 Feb 2008 09:59:47 -0500 Subject: [Libvirt-cim] [PATCH] [RFC] Changes required to work with new std_indication. The trigger changes were very light, which was nice In-Reply-To: <47AC2F3C.5000903@linux.vnet.ibm.com> References: <47AC2F3C.5000903@linux.vnet.ibm.com> Message-ID: <47AC6E63.9010300@linux.vnet.ibm.com> Heidi Eckhart wrote: > Jay Gagnon wrote: >> # HG changeset patch >> # User Jay Gagnon >> # Date 1202420324 18000 >> # Node ID a82dd87a3830eadda678b88bf4bfcfd4f8cb1ca4 >> # Parent c7dd4a8358a187a3469c3d8a177950625898a227 >> [RFC] Changes required to work with new std_indication. The trigger >> changes were very light, which was nice. >> >> Signed-off-by: Jay Gagnon >> >> diff -r c7dd4a8358a1 -r a82dd87a3830 src/Virt_ComputerSystemIndication.c >> --- a/src/Virt_ComputerSystemIndication.c Wed Feb 06 07:00:00 2008 >> -0800 >> +++ b/src/Virt_ComputerSystemIndication.c Thu Feb 07 16:38:44 2008 >> -0500 >> @@ -488,7 +488,8 @@ STDI_IndicationMIStub(, >> Virt_ComputerSystemIndication, >> _BROKER, >> libvirt_cim_init(), - &csi); >> + &csi, >> + NULL); >> >> /* >> * Local Variables: >> > I'm interested in the other changes that are necessary to the > CSIndication provider to make use of the std_indication reorg - also > make use of the states and not setting it to NULL ;). Haha yea it's just set to NULL here in the interest of using the minimal amount of change to not break it. When I have everything else in place I'll make sure CSIndication fully utilizes the new code. >> diff -r c7dd4a8358a1 -r a82dd87a3830 >> src/Virt_ComputerSystemMigrationIndication.c >> --- a/src/Virt_ComputerSystemMigrationIndication.c Wed Feb 06 >> 07:00:00 2008 -0800 >> +++ b/src/Virt_ComputerSystemMigrationIndication.c Thu Feb 07 >> 16:38:44 2008 -0500 >> > If I got this right, then the MigrationIndication provider is > currently only switching the migrate.filter_activate and > migrate.enabled values. Potentially it could deliver an indication (by > the default_raise function), but it can not as the trigger_fn is not > implemented and so nothing is monitored, right ? That is correct, and that's actually the intended behavior. Attempting to monitor out of band migrations is not a problem I'm terribly interested in solving at the moment, and the raise functionality is tied into by VSMigrationService in a previous patch. The end result is that whenever our providers are asked to do a migration task, VSMigrationService uses MigrationIndication's raise call to send the indication. > > Well, in sum - I like the approach :) - but I would even go farther. I > think its possible to write one indication engine (that would become > part of libcmpiutil) that handles all the CIM_InstModification, > CIM_InstCreation and CIM_InstDeletion indications at once. This engine > would be a large part of the CSIndication provider and maybe only the > compare functions (dom_in_list, dom_changed) need to stay provider > specific. But that's a guess at the moment and is worth to be > evaluated (now I hope that you volunteer for this job ;) ). > Yes, this will definitely go further. This is basically phase one of three. -- -Jay From danms at us.ibm.com Fri Feb 8 15:06:58 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 08 Feb 2008 07:06:58 -0800 Subject: [Libvirt-cim] [PATCH] [RFC] Changes required to work with new std_indication. The trigger changes were very light, which was nice In-Reply-To: (Jay Gagnon's message of "Thu, 07 Feb 2008 16:39:16 -0500") References: Message-ID: <87sl031o8d.fsf@caffeine.beaverton.ibm.com> I agree with Heidi. I think you've opened the door to take it a little further so that the calls in Enable/Disable and Activate/Deactivate are automated for the simple case. Maybe this is already planned? JG> +static struct std_ind_state migrate = { JG> + .ind_name = "Xen_ComputerSystemMigrationIndication", JG> + .filter_active = false, JG> + .enabled = false, JG> +}; This is a really minor thing, but this definition has some fields that must always be set to false on initialization to avoid badness. Now, since these are static, they are all initialized to zero, which should cover you in the case that someone just doesn't set filter_active and enabled. However, perhaps setting the precedent with something like a constructor macro would be appropriate? #define DECLARE_IND(ident, name) \ static struct std_ind_state ident = { \ .ind_name = name, \ .filter_active = false, \ .enabled = false, \ }; Which would make the above definition look like this: DECLARE_IND(migrate, "Xen_ComputerSystemMigrationIndication"); Thoughts? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Fri Feb 8 15:07:14 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 08 Feb 2008 07:07:14 -0800 Subject: [Libvirt-cim] [PATCH] [RFC] [CU] Turn std_indication's awesome knob to eleven References: <7feaabeb36cea13611d6.1202420380@naegling> Message-ID: <87fxw31o7x.fsf@caffeine.beaverton.ibm.com> JG> +char *classname_from_inst(const CMPIBroker *broker, JG> + CMPIInstance *inst, JG> + CMPIStatus *s) JG> +{ JG> + char *ret = NULL; JG> + JG> + CMPIObjectPath *ref; JG> + ref = CMGetObjectPath(inst, s); JG> + if ((s->rc != CMPI_RC_OK) || CMIsNullObject(ref)) { JG> + cu_statusf(broker, s, JG> + CMPI_RC_ERR_FAILED, JG> + "Could not get objectpath from instance"); JG> + goto out; JG> + } JG> + JG> + ret = strdup(CLASSNAME(ref)); JG> + JG> + out: JG> + return ret; JG> } This could probably be a distinct patch as well. Also, why strdup the result of CLASSNAME()? It's CIMOM-managed memory, and most of the other libcu functions have been modified to avoid dynamic memory where possible. The return value should be const char * after this change. Also, why not just signal your single error case by returning NULL? That way you can avoid having to pass in the broker and the status pointers and the function becomes a bit cleaner. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From grendel at linux.vnet.ibm.com Fri Feb 8 15:35:03 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 08 Feb 2008 10:35:03 -0500 Subject: [Libvirt-cim] [PATCH] [RFC] Changes required to work with new std_indication. The trigger changes were very light, which was nice In-Reply-To: <87sl031o8d.fsf@caffeine.beaverton.ibm.com> References: <87sl031o8d.fsf@caffeine.beaverton.ibm.com> Message-ID: <47AC76A7.5000307@linux.vnet.ibm.com> Dan Smith wrote: > I agree with Heidi. I think you've opened the door to take it a > little further so that the calls in Enable/Disable and > Activate/Deactivate are automated for the simple case. Maybe this is > already planned? > > Yup, those are phase two. > JG> +static struct std_ind_state migrate = { > JG> + .ind_name = "Xen_ComputerSystemMigrationIndication", > JG> + .filter_active = false, > JG> + .enabled = false, > JG> +}; > > This is a really minor thing, but this definition has some fields that > must always be set to false on initialization to avoid badness. Now, > since these are static, they are all initialized to zero, which should > cover you in the case that someone just doesn't set filter_active and > enabled. However, perhaps setting the precedent with something like a > constructor macro would be appropriate? > > #define DECLARE_IND(ident, name) \ > static struct std_ind_state ident = { \ > .ind_name = name, \ > .filter_active = false, \ > .enabled = false, \ > }; > > Which would make the above definition look like this: > > DECLARE_IND(migrate, "Xen_ComputerSystemMigrationIndication"); > > Thoughts? > > Ooh, I like that. I'll definitely use it. -- -Jay From grendel at linux.vnet.ibm.com Fri Feb 8 15:41:11 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 08 Feb 2008 10:41:11 -0500 Subject: [Libvirt-cim] [PATCH] [RFC] [CU] Turn std_indication's awesome knob to eleven In-Reply-To: <87fxw31o7x.fsf@caffeine.beaverton.ibm.com> References: <7feaabeb36cea13611d6.1202420380@naegling> <87fxw31o7x.fsf@caffeine.beaverton.ibm.com> Message-ID: <47AC7817.2040602@linux.vnet.ibm.com> Dan Smith wrote: > JG> +char *classname_from_inst(const CMPIBroker *broker, > JG> + CMPIInstance *inst, > JG> + CMPIStatus *s) > JG> +{ > JG> + char *ret = NULL; > JG> + > JG> + CMPIObjectPath *ref; > JG> + ref = CMGetObjectPath(inst, s); > JG> + if ((s->rc != CMPI_RC_OK) || CMIsNullObject(ref)) { > JG> + cu_statusf(broker, s, > JG> + CMPI_RC_ERR_FAILED, > JG> + "Could not get objectpath from instance"); > JG> + goto out; > JG> + } > JG> + > JG> + ret = strdup(CLASSNAME(ref)); > JG> + > JG> + out: > JG> + return ret; > JG> } > > This could probably be a distinct patch as well. > > Also, why strdup the result of CLASSNAME()? It's CIMOM-managed > memory, and most of the other libcu functions have been modified to > avoid dynamic memory where possible. The return value should be const > char * after this change. > As this illustrates, I'm never really sure whether or not strdup is the right thing to do. It would appear that it's unnecessary here, so I'll take it out. > Also, why not just signal your single error case by returning NULL? > That way you can avoid having to pass in the broker and the status > pointers and the function becomes a bit cleaner. > Probably just my natural tendency to over-complicate. I'll fix that as well. -- -Jay From danms at us.ibm.com Fri Feb 8 15:57:19 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 08 Feb 2008 07:57:19 -0800 Subject: [Libvirt-cim] [PATCH] (#4) Make the ProcRASD show CPU pinning information Message-ID: # HG changeset patch # User Dan Smith # Date 1202486140 28800 # Node ID a9d5094d7af37968f66e8c10c641f7682e2def3e # Parent da31d60724565fb6da4bed307bcc69d710680306 (#4) 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: - Set the values on the instance and not as keys in the ref - Remove silly double-semicolons from proc_set_cpu() - Actually report the correct pinning information Signed-off-by: Dan Smith diff -r da31d6072456 -r a9d5094d7af3 src/Virt_RASD.c --- a/src/Virt_RASD.c Wed Feb 06 09:18:23 2008 -0800 +++ b/src/Virt_RASD.c Fri Feb 08 07:55:40 2008 -0800 @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -91,6 +92,191 @@ 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; + } + + inst = CMNewInstance(broker, op, &s); + if ((inst == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to make instance"); + goto out; + } + + CMSetProperty(inst, "CreationClassName", + (CMPIValue *)"Linux_Processor", CMPI_chars); + CMSetProperty(inst, "SystemName", + (CMPIValue *)hostname, CMPI_chars); + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)"Linux_ComputerSystem", CMPI_chars); + CMSetProperty(inst, "DeviceID", + (CMPIValue *)devid, CMPI_chars); + + 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 +345,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 */ From kaitlin at linux.vnet.ibm.com Fri Feb 8 17:01:21 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 08 Feb 2008 09:01:21 -0800 Subject: [Libvirt-cim] [PATCH] Update EC to add support for VSMS to VSMC association Message-ID: <54ffc7df5a17a13811ad.1202490081@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202490035 28800 # Node ID 54ffc7df5a17a13811ad65f968b7d780330630f7 # Parent 59c1d98cf8989adff7530eac08abee7b79a6cc03 Update EC to add support for VSMS to VSMC association. Removed the instance property validation. The get_vsms() (etc) calls will need to be updated to handle the reference validation. Signed-off-by: Kaitlin Rupert diff -r 59c1d98cf898 -r 54ffc7df5a17 src/Makefile.am --- a/src/Makefile.am Fri Feb 08 07:59:01 2008 -0800 +++ b/src/Makefile.am Fri Feb 08 09:00:35 2008 -0800 @@ -99,14 +99,16 @@ libVirt_AllocationCapabilities_la_SOURCE libVirt_AllocationCapabilities_la_SOURCES = Virt_AllocationCapabilities.c libVirt_AllocationCapabilities_la_LIBADD = -lVirt_DevicePool -libVirt_ElementCapabilities_la_DEPENDENCIES = libVirt_VirtualSystemManagementCapabilities.la libVirt_EnabledLogicalElementCapabilities.la libVirt_ComputerSystem.la libVirt_HostSystem.la libVirt_VSMigrationCapabilities.la +libVirt_ElementCapabilities_la_DEPENDENCIES = libVirt_VirtualSystemManagementCapabilities.la libVirt_EnabledLogicalElementCapabilities.la libVirt_ComputerSystem.la libVirt_HostSystem.la libVirt_VSMigrationCapabilities.la libVirt_VirtualSystemManagementService.la libVirt_VSMigrationService.la libVirt_ElementCapabilities_la_SOURCES = Virt_ElementCapabilities.c libVirt_ElementCapabilities_la_LIBADD = -lVirt_VirtualSystemManagementCapabilities \ -lVirt_EnabledLogicalElementCapabilities \ -lVirt_ComputerSystem \ -lVirt_HostSystem \ -lVirt_VSMigrationCapabilities \ - -lVirt_AllocationCapabilities + -lVirt_AllocationCapabilities \ + -lVirt_VirtualSystemManagementService \ + -lVirt_VSMigrationService libVirt_SettingsDefineCapabilities_la_DEPENDENCIES = libVirt_RASD.la libVirt_DevicePool.la libVirt_SettingsDefineCapabilities_la_SOURCES = Virt_SettingsDefineCapabilities.c diff -r 59c1d98cf898 -r 54ffc7df5a17 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Fri Feb 08 07:59:01 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Fri Feb 08 09:00:35 2008 -0800 @@ -33,6 +33,8 @@ #include #include "Virt_VirtualSystemManagementCapabilities.h" +#include "Virt_VirtualSystemManagementService.h" +#include "Virt_VSMigrationService.h" #include "Virt_EnabledLogicalElementCapabilities.h" #include "Virt_ComputerSystem.h" #include "Virt_HostSystem.h" @@ -48,31 +50,63 @@ const static CMPIBroker *_BROKER; -static CMPIStatus validate_host_caps_ref(const CMPIObjectPath *ref) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - const char *prop; - char* classname; - +static CMPIStatus validate_caps_get_service(const CMPIObjectPath *ref, + CMPIInstance **inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *_inst; + char* classname; + classname = class_base_name(CLASSNAME(ref)); if (STREQC(classname, "VirtualSystemManagementCapabilities")) { - s = get_vsm_cap(_BROKER, ref, &inst); + s = get_vsm_cap(_BROKER, ref, &_inst); + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) + goto out; + + s = get_vsms(ref, &_inst, _BROKER); } else if (STREQC(classname, "VirtualSystemMigrationCapabilities")) { - s = get_migration_caps(ref, &inst, _BROKER); - } - - if (s.rc != CMPI_RC_OK) - goto out; - - prop = cu_compare_ref(ref, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } - + s = get_migration_caps(ref, &_inst, _BROKER); + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) + goto out; + + s = get_migration_service(ref, &_inst, _BROKER); + } else + CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); + + *inst = _inst; + out: + free(classname); + + return s; +} + +static CMPIStatus validate_service_get_caps(const CMPIObjectPath *ref, + CMPIInstance **inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *_inst; + char* classname; + + classname = class_base_name(CLASSNAME(ref)); + + if (STREQC(classname, "VirtualSystemManagementService")) { + s = get_vsms(ref, &_inst, _BROKER); + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) + goto out; + + s = get_vsm_cap(_BROKER, ref, &_inst); + } else if (STREQC(classname, "VirtualSystemMigrationService")) { + s = get_migration_service(ref, &_inst, _BROKER); + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) + goto out; + + s = get_migration_caps(ref, &_inst, _BROKER); + } else + CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); + + *inst = _inst; + out: free(classname); @@ -105,19 +139,22 @@ static CMPIStatus sys_to_cap(const CMPIO return s; } -static CMPIStatus cap_to_sys(const CMPIObjectPath *ref, - struct std_assoc_info *info, - struct inst_list *list) -{ - CMPIInstance *inst; - CMPIStatus s = {CMPI_RC_OK, NULL}; - - if (!match_hypervisor_prefix(ref, info)) - goto out; - - s = validate_host_caps_ref(ref); - if (s.rc != CMPI_RC_OK) - goto out; +static CMPIStatus cap_to_sys_or_service(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIInstance *inst = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = validate_caps_get_service(ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + if (inst != NULL) + inst_list_add(list, inst); s = get_host_cs(_BROKER, ref, &inst); if (s.rc != CMPI_RC_OK) @@ -125,6 +162,26 @@ static CMPIStatus cap_to_sys(const CMPIO inst_list_add(list, inst); + out: + return s; +} + +static CMPIStatus service_to_cap(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIInstance *inst = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = validate_service_get_caps(ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + if (inst != NULL) + inst_list_add(list, inst); out: return s; } @@ -245,6 +302,16 @@ static char* host_system[] = { NULL }; +static char* host_sys_and_service[] = { + "Xen_HostSystem", + "KVM_HostSystem", + "Xen_VirtualSystemManagementService", + "KVM_VirtualSystemManagementService", + "Xen_VirtualSystemMigrationService", + "KVM_VirtualSystemMigrationService", + NULL +}; + static char* virtual_system_management_capabilities[] = { "Xen_VirtualSystemManagementCapabilities", "Xen_VirtualSystemMigrationCapabilities", @@ -266,16 +333,37 @@ static struct std_assoc system_to_vsm_ca .make_ref = make_ref }; -static struct std_assoc vsm_cap_to_system = { +static struct std_assoc vsm_cap_to_sys_or_service = { .source_class = (char**)&virtual_system_management_capabilities, .source_prop = "Capabilities", - .target_class = (char**)&host_system, + .target_class = (char**)&host_sys_and_service, .target_prop = "ManagedElement", .assoc_class = (char**)&assoc_classname, - .handler = cap_to_sys, + .handler = cap_to_sys_or_service, + .make_ref = make_ref +}; + +static char* service[] = { + "Xen_VirtualSystemManagementService", + "KVM_VirtualSystemManagementService", + "Xen_VirtualSystemMigrationService", + "KVM_VirtualSystemMigrationService", + NULL +}; + +static struct std_assoc _service_to_cap = { + .source_class = (char**)&service, + .source_prop = "ManagedElement", + + .target_class = (char**)&virtual_system_management_capabilities, + .target_prop = "Capabilities", + + .assoc_class = (char**)&assoc_classname, + + .handler = service_to_cap, .make_ref = make_ref }; @@ -363,7 +451,8 @@ static struct std_assoc resource_pool_to static struct std_assoc *assoc_handlers[] = { &system_to_vsm_cap, - &vsm_cap_to_system, + &vsm_cap_to_sys_or_service, + &_service_to_cap, &ele_cap_to_cs, &cs_to_ele_cap, &alloc_cap_to_resource_pool, From kaitlin at linux.vnet.ibm.com Fri Feb 8 17:12:29 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 08 Feb 2008 09:12:29 -0800 Subject: [Libvirt-cim] [PATCH] Update EC to add support for VSMS to VSMC association In-Reply-To: <54ffc7df5a17a13811ad.1202490081@elm3b41.beaverton.ibm.com> References: <54ffc7df5a17a13811ad.1202490081@elm3b41.beaverton.ibm.com> Message-ID: <47AC8D7D.6020705@linux.vnet.ibm.com> Kaitlin Rupert wrote: > # HG changeset patch > # User Kaitlin Rupert > # Date 1202490035 28800 > # Node ID 54ffc7df5a17a13811ad65f968b7d780330630f7 > # Parent 59c1d98cf8989adff7530eac08abee7b79a6cc03 > Update EC to add support for VSMS to VSMC association. > > Removed the instance property validation. The get_vsms() (etc) calls will need to be updated to handle the reference validation. > > Signed-off-by: Kaitlin Rupert > > +static CMPIStatus validate_caps_get_service(const CMPIObjectPath *ref, > + CMPIInstance **inst) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + CMPIInstance *_inst; > + char* classname; > + > classname = class_base_name(CLASSNAME(ref)); > > if (STREQC(classname, "VirtualSystemManagementCapabilities")) { > - s = get_vsm_cap(_BROKER, ref, &inst); > + s = get_vsm_cap(_BROKER, ref, &_inst); > + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) > + goto out; > + > + s = get_vsms(ref, &_inst, _BROKER); > } else if (STREQC(classname, "VirtualSystemMigrationCapabilities")) { > - s = get_migration_caps(ref, &inst, _BROKER); > - } > - > - if (s.rc != CMPI_RC_OK) > - goto out; > - > - prop = cu_compare_ref(ref, inst); > - if (prop != NULL) { > - cu_statusf(_BROKER, &s, > - CMPI_RC_ERR_NOT_FOUND, > - "No such instance (%s)", prop); > - } > - I understand that this currently breaks the reference checking, but I think it's a good idea to have the class get_<> functions do that checking. Thoughts? Also, I'm sure that this function, the validate_service_get_caps() and validate_service_ref() can be consolidated somehow, but I haven't worked up a clean solution yet, So this patch is a first step in a set of related changes. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Fri Feb 8 17:44:31 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 08 Feb 2008 09:44:31 -0800 Subject: [Libvirt-cim] [PATCH] (#4) Make the ProcRASD show CPU pinning information In-Reply-To: References: Message-ID: <47AC94FF.6000308@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1202486140 28800 > # Node ID a9d5094d7af37968f66e8c10c641f7682e2def3e > # Parent da31d60724565fb6da4bed307bcc69d710680306 > (#4) 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: > - Set the values on the instance and not as keys in the ref This is a good change, I think. +1 > - Remove silly double-semicolons from proc_set_cpu() > - Actually report the correct pinning information -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Fri Feb 8 21:53:39 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 08 Feb 2008 13:53:39 -0800 Subject: [Libvirt-cim] [PATCH] (#3) Set additional attribute values in Virt_ComputerSystem.c Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1202485701 28800 # Node ID d75e7e59ae2a4acd1e8599f7851c59e1aef0d2dd # Parent c7dd4a8358a187a3469c3d8a177950625898a227 (#3) Set additional attribute values in Virt_ComputerSystem.c Update from patch 2 to 3: -Fixed ordering of OtherIdentifyingInfo -Fixed type in model string. Update from patch 1 to patch 2: -Condensed the functions for OtherIdentifyingInfo and IdentifyingDescriptions into one function -Added a return variable to catch the return value of the functions called in instance_from_dom() - added a goto out in case of error. -In the out: block, free the uuid. OtherIdentifyingInfo property and IdentifyingDescriptions. Modify instance_from_dom() to take a prefix parameter. Signed-off-by: Kaitlin Rupert diff -r c7dd4a8358a1 -r d75e7e59ae2a src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Wed Feb 06 07:00:00 2008 -0800 +++ b/src/Virt_ComputerSystem.c Fri Feb 08 07:48:21 2008 -0800 @@ -71,7 +71,9 @@ static int set_name_from_dom(virDomainPt } /* Set the "UUID" property of an instance from a domain */ -static int set_uuid_from_dom(virDomainPtr dom, CMPIInstance *instance) +static int set_uuid_from_dom(virDomainPtr dom, + CMPIInstance *instance, + char **out_uuid) { char uuid[VIR_UUID_STRING_BUFLEN]; int ret; @@ -82,6 +84,8 @@ static int set_uuid_from_dom(virDomainPt CMSetProperty(instance, "UUID", (CMPIValue *)uuid, CMPI_chars); + + *out_uuid = strdup(uuid); return 1; } @@ -239,39 +243,114 @@ static int set_creation_class(CMPIInstan return 1; } +static int set_other_id_info(const CMPIBroker *broker, + char *uuid, + const char *prefix, + CMPIInstance *instance) +{ + CMPIStatus s; + CMPIArray *id_info; + CMPIArray *id_desc; + char *desc[3] = {"Type", "Model", "UUID"}; + char *info[3]; + int count = 3; + char *type = "Virtual System"; + char *model; + int i; + + id_info = CMNewArray(broker, + count, + CMPI_string, + &s); + + if (s.rc != CMPI_RC_OK) + return 0; + + id_desc = CMNewArray(broker, + count, + CMPI_string, + &s); + + if (s.rc != CMPI_RC_OK) + return 0; + + if (asprintf(&model, "%s %s", prefix, type) == -1) + return 0; + + info[0] = type; + info[1] = model; + info[2] = uuid; + + for (i = 0; i < count; i++) { + CMPIString *tmp = CMNewString(broker, info[i], NULL); + CMSetArrayElementAt(id_info, i, + &tmp, + CMPI_string); + + tmp = CMNewString(broker, desc[i], NULL); + CMSetArrayElementAt(id_desc, i, + &tmp, + CMPI_string); + } + + CMSetProperty(instance, "OtherIdentifyingInfo", + &id_info, CMPI_stringA); + + CMSetProperty(instance, "IdentifyingDescriptions", + (CMPIValue *)&id_desc, CMPI_stringA); + return 1; +} + /* Populate an instance with information from a domain */ static int instance_from_dom(const CMPIBroker *broker, virDomainPtr dom, + const char *prefix, CMPIInstance *instance) { + char *uuid = NULL; + int ret = 1; + if (!set_name_from_dom(dom, instance)) { /* Print trace error */ return 0; } - if (!set_uuid_from_dom(dom, instance)) { + if (!set_uuid_from_dom(dom, instance, &uuid)) { /* Print trace error */ - return 0; + ret = 0; + goto out; } if (!set_capdesc_from_dom(dom, instance)) { /* Print trace error */ - return 0; + ret = 0; + goto out; } if (!set_state_from_dom(broker, dom, instance)) { /* Print trace error */ - return 0; + ret = 0; + goto out; } if (!set_creation_class(instance)) { /* Print trace error */ - return 0; + ret = 0; + goto out; + } + + if (!set_other_id_info(broker, uuid, prefix, instance)) { + /* Print trace error */ + ret = 0; + goto out; } /* More attributes here, of course */ - return 1; + out: + free(uuid); + + return ret; } /* Given a hypervisor connection and a domain name, return an instance */ @@ -294,7 +373,10 @@ CMPIInstance *instance_from_name(const C if (instance == NULL) goto out; - if (!instance_from_dom(broker, dom, instance)) + if (!instance_from_dom(broker, + dom, + pfx_from_conn(conn), + instance)) instance = NULL; out: @@ -327,7 +409,10 @@ int enum_domains(const CMPIBroker *broke if (inst == NULL) goto end; - if (instance_from_dom(broker, list[i], inst)) + if (instance_from_dom(broker, + list[i], + pfx_from_conn(conn), + inst)) inst_list_add(instlist, inst); end: From danms at us.ibm.com Fri Feb 8 23:16:48 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 08 Feb 2008 15:16:48 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] [CU] Rename symbol in EO MOF parser to avoid conflict with CLASSNAME() In-Reply-To: Message-ID: <79271d1d325748849dc3.1202512608@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202512515 28800 # Node ID 79271d1d325748849dc312a51053ef680eb98b86 # Parent cc846858f60cb7ce5b859015c9a120d784074eed [CU] Rename symbol in EO MOF parser to avoid conflict with CLASSNAME() Signed-off-by: Dan Smith diff -r cc846858f60c -r 79271d1d3257 eo_util_lexer.l --- a/eo_util_lexer.l Wed Feb 06 08:27:12 2008 -0800 +++ b/eo_util_lexer.l Fri Feb 08 15:15:15 2008 -0800 @@ -90,7 +90,7 @@ FALSE { [A-Za-z][A-Za-z0-9_]* { BEGIN INITIAL; /* Go back to normal parsing rules now */ eo_parse_lval.string = (char *)strdup(eo_parse_text); - return(CLASSNAME); + return(CLASS); } /* Propertyname */ diff -r cc846858f60c -r 79271d1d3257 eo_util_parser.y --- a/eo_util_parser.y Wed Feb 06 08:27:12 2008 -0800 +++ b/eo_util_parser.y Fri Feb 08 15:15:15 2008 -0800 @@ -51,7 +51,7 @@ int eo_parse_parseinstance(const CMPIBro %token INSTANCE OF ENDOFFILE /* Define lexical tokens that return a value and their return type */ -%token CLASSNAME +%token CLASS %token PROPERTYNAME %token STRING %token BOOLEAN @@ -62,7 +62,7 @@ int eo_parse_parseinstance(const CMPIBro /* Rules section */ instance: /* empty */ - | INSTANCE OF CLASSNAME '{' + | INSTANCE OF CLASS '{' { EOTRACE("classname = %s\n",$3); CMPIObjectPath *op; From danms at us.ibm.com Fri Feb 8 23:16:49 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 08 Feb 2008 15:16:49 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] [CU] Rename STRING() macro in libcmpiutil In-Reply-To: Message-ID: <2337330e5a9bc8e71afd.1202512609@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202512525 28800 # Node ID 2337330e5a9bc8e71afd04627166155a33dc53f2 # Parent 79271d1d325748849dc312a51053ef680eb98b86 [CU] Rename STRING() macro in libcmpiutil We really shouldn't define a macro with such a blatantly common name. I don't think this actually got used anywhere, but I think it's worth keeping (under a reasonable name) Signed-off-by: Dan Smith diff -r 79271d1d3257 -r 2337330e5a9b libcmpiutil.h --- a/libcmpiutil.h Fri Feb 08 15:15:15 2008 -0800 +++ b/libcmpiutil.h Fri Feb 08 15:15:25 2008 -0800 @@ -44,15 +44,16 @@ #define STREQ(a, b) (strcmp(a, b) == 0) #define STREQC(a, b) (strcasecmp(a, b) == 0) -#define _STRINGIFY(x) #x -#define STRING(x) _STRINGIFY(x) +#define _CU_STRINGIFY(x) #x +#define CU_STRINGIFY(x) _CU_STRINGIFY(x) /** * Dispatch macro for debug_print, fills in the function name and line number * of caller. */ -#define CU_DEBUG(fmt, args...) {debug_print(__FILE__ "(" STRING(__LINE__)"): " \ - fmt "\n", ##args);} +#define CU_DEBUG(fmt, args...) { \ + debug_print(__FILE__ "(" CU_STRINGIFY(__LINE__)"): " \ + fmt "\n", ##args);} /** * Helper for DEBUG macro. Checks environmental variable CU_DEBUG and: From danms at us.ibm.com Fri Feb 8 23:16:47 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 08 Feb 2008 15:16:47 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] [CU] Some cleanups to libcmpiutil Message-ID: Some build and symbol cleanups for libcmpiutil From danms at us.ibm.com Fri Feb 8 23:18:01 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 08 Feb 2008 15:18:01 -0800 Subject: [Libvirt-cim] [PATCH 3 of 3] [RFC][CU] Integrate the CIMXML EO parser with the libcmpiutil interface In-Reply-To: Message-ID: <7839b35e5c52454e7181.1202512681@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202512655 28800 # Node ID 7839b35e5c52454e71812f3ebb6e97bf07778423 # Parent f6559a2f55abab85baeabd56faaf7804c3ea30f3 [RFC][CU] Integrate the CIMXML EO parser with the libcmpiutil interface Signed-off-by: Dan Smith diff -r f6559a2f55ab -r 7839b35e5c52 eo_parser.c --- a/eo_parser.c Fri Feb 08 15:17:35 2008 -0800 +++ b/eo_parser.c Fri Feb 08 15:17:35 2008 -0800 @@ -31,13 +31,14 @@ #include "libcmpiutil.h" #include "eo_util_parser.h" +#include "eo_parser_xml.h" #define TEMPLATE "/tmp/tmp_eo_parse.XXXXXX" void eo_parse_restart(FILE *); int eo_parse_parseinstance(const CMPIBroker *, CMPIInstance **, const char *ns); -static int write_temp(char *eo) +static int write_temp(const char *eo) { int fd; int ret; @@ -62,13 +63,13 @@ static int write_temp(char *eo) return fd; } -int cu_parse_embedded_instance(const char *eo, - const CMPIBroker *broker, - const char *ns, - CMPIInstance **instance) +#ifdef HAVE_EOPARSER +static int parse_ei_mof(const CMPIBroker *broker, + const char *ns, + const char *eo, + CMPIInstance **instance) { int ret; -#ifdef HAVE_EOPARSER int fd; FILE *fp; @@ -81,10 +82,29 @@ int cu_parse_embedded_instance(const cha ret = eo_parse_parseinstance(broker, instance, ns); close(fd); + + return ret; +} +#endif + +int cu_parse_embedded_instance(const char *eo, + const CMPIBroker *broker, + const char *ns, + CMPIInstance **instance) +{ + if (strcasestr(eo, " This is a first stab. Looking for comments and review. It's pretty raw at the moment, but it does work for me. I still need to do nested objects, but if people are happy with it now, we can bring it into the tree and add the nested bit after that (which would be my preference). Keep your eyes peeled for leaks and broken bits, as I'm sure there are some :) From danms at us.ibm.com Fri Feb 8 23:17:59 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 08 Feb 2008 15:17:59 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] [RFC][CU] Make libcmpiutil include libxml libraries/includes In-Reply-To: Message-ID: <03126c9af41607dcaa8b.1202512679@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202512650 28800 # Node ID 03126c9af41607dcaa8b197736dd5059c108261a # Parent 2337330e5a9bc8e71afd04627166155a33dc53f2 [RFC][CU] Make libcmpiutil include libxml libraries/includes As needed for the CIMXML EO parser Signed-off-by: Dan Smith diff -r 2337330e5a9b -r 03126c9af416 acinclude.m4 --- a/acinclude.m4 Fri Feb 08 15:15:25 2008 -0800 +++ b/acinclude.m4 Fri Feb 08 15:17:30 2008 -0800 @@ -92,3 +92,9 @@ AC_DEFUN([CHECK_BROKEN_CMPIFT], ] )]) +AC_DEFUN([CHECK_LIBXML2], + [ + PKG_CHECK_MODULES([LIBXML], [libxml-2.0]) + CPPFLAGS="$CPPFLAGS $LIBXML_CFLAGS" + LDFLAGS="$LDFLAGS $LIBXML_LDFLAGS" + ]) diff -r 2337330e5a9b -r 03126c9af416 configure.ac --- a/configure.ac Fri Feb 08 15:15:25 2008 -0800 +++ b/configure.ac Fri Feb 08 15:17:30 2008 -0800 @@ -50,6 +50,8 @@ AC_ARG_ENABLE([eoparser], AM_CONDITIONAL([build_eoparser],[test x$eoparser = xyes]) +CHECK_LIBXML2 + if test x${eoparser} = xyes; then CFLAGS+=" -DHAVE_EOPARSER" fi From danms at us.ibm.com Fri Feb 8 23:18:00 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 08 Feb 2008 15:18:00 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] [RFC][CU] Add EI CIMXML parser In-Reply-To: Message-ID: # HG changeset patch # User Dan Smith # Date 1202512655 28800 # Node ID f6559a2f55abab85baeabd56faaf7804c3ea30f3 # Parent 03126c9af41607dcaa8b197736dd5059c108261a [RFC][CU] Add EI CIMXML parser This handles strings, bools, integers, and arrays of those. It doesn't yet handle nested objects, as we will need for RASD.HostResource[]. I need to do some further investigation of what the XML for that will look like. I have tested this by taking an existing XML for DefineSystem() and changing the MemResourceAllocationSettingData field to this: <INSTANCE CLASSNAME="Xen_MemResourceAllocationSettingData"> <PROPERTY NAME="CreationClassName" TYPE="string"> <VALUE>Xen_MemResourceAllocationSettingData</VALUE> </PROPERTY> <PROPERTY NAME="InstanceID" TYPE="string"> <VALUE>test/mem</VALUE> </PROPERTY> <PROPERTY NAME="ResourceType" TYPE="uint16"> <VALUE>4</VALUE> </PROPERTY> <PROPERTY NAME="VirtualQuantity" TYPE="uint64"> <VALUE>256 </VALUE> </PROPERTY> <PROPERTY.ARRAY NAME="Foo" TYPE="string"> <VALUE.ARRAY> <VALUE>Bar</VALUE> <VALUE>Baz</VALUE> </VALUE.ARRAY> </PROPERTY.ARRAY> </INSTANCE> (The Foo[] parameter in there is just for testing :) Signed-off-by: Dan Smith diff -r 03126c9af416 -r f6559a2f55ab Makefile.am --- a/Makefile.am Fri Feb 08 15:17:30 2008 -0800 +++ b/Makefile.am Fri Feb 08 15:17:35 2008 -0800 @@ -10,6 +10,8 @@ pkgconfig_DATA = libcmpiutil.pc libcmpiutilincdir = $(includedir)/libcmpiutil +noinst_HEADERS = eo_parser_xml.h + libcmpiutilinc_HEADERS = libcmpiutil.h \ std_invokemethod.h \ std_association.h \ @@ -18,7 +20,7 @@ libcmpiutilinc_HEADERS = libcmpiutil.h \ libcmpiutil_la_SOURCES = args_util.c instance_util.c std_invokemethod.c \ std_association.c inst_list.c std_indication.c \ - debug_util.c + debug_util.c eo_parser_xml.c libcmpiutil_la_CFLAGS = $(CFLAGS) $(CFLAGS_STRICT) libcmpiutil_la_LIBADD = libcmpiutil_la_DEPENDENCIES = diff -r 03126c9af416 -r f6559a2f55ab eo_parser_xml.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eo_parser_xml.c Fri Feb 08 15:17:35 2008 -0800 @@ -0,0 +1,482 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "libcmpiutil.h" + +#include "eo_parser_xml.h" + +static char *get_attr(xmlNode *node, const char *name) +{ + return (char *)xmlGetProp(node, (xmlChar *)name); +} + +static char *get_content(xmlNode *node) +{ + return (char *)xmlNodeGetContent(node); +} + +static CMPIType parse_string_property(const CMPIBroker *broker, + const char *string, + const char *type, + CMPIValue *val) +{ + CMPIString *str; + CMPIStatus s; + + str = CMNewString(broker, string, &s); + if ((str == NULL) || (s.rc != CMPI_RC_OK)) + return CMPI_null; + + val->string = str; + return CMPI_string; +} + +static CMPIType parse_bool_property(const char *string, + const char *type, + CMPIValue *val) +{ + val->boolean = STREQC(string, "true"); + + return CMPI_boolean; +} + +static CMPIType parse_int_property(const char *string, + const char *type, + CMPIValue *val) +{ + int size; + bool sign; + CMPIType t; + int ret; + + if (sscanf(type, "uint%i", &size) == 1) + sign = false; + else if (sscanf(type, "int%i", &size) == 1) + sign = true; + else { + printf("Unknown integer type: `%s'", type); + return 0; + } + + if (sign) { + int64_t _val; + ret = sscanf(string, "%" SCNi64, &_val); + val->sint64 = _val; + } else { + uint64_t _val; + ret = sscanf(string, "%" SCNu64, &_val); + val->uint64 = _val; + } + + if (ret != 1) { + printf("Failed to scan value `%s'\n", string); + return 0; + } + + switch (size) { + case 8: t = sign ? CMPI_sint8 : CMPI_uint8; break; + case 16: t = sign ? CMPI_sint16 : CMPI_uint16; break; + case 32: t = sign ? CMPI_sint32 : CMPI_uint32; break; + default: + case 64: t = sign ? CMPI_sint64 : CMPI_uint64; break; + }; + + return t; +} + +static CMPIType get_property_value(const CMPIBroker *broker, + const char *tstr, + const char *content, + CMPIValue *value) +{ + CMPIType type = CMPI_null; + + if (STREQC(tstr, "string")) + type = parse_string_property(broker, content, tstr, value); + else if (STREQC(tstr, "boolean")) + type = parse_bool_property(content, tstr, value); + else if (strstr(tstr, "int")) + type = parse_int_property(content, tstr, value); + else { + printf("Unhandled type: %s\n", tstr); + goto out; + } + + if (type == CMPI_null) { + printf("Unable to parse type %s\n", tstr); + goto out; + } + + out: + return type; +} + +static CMPIType get_node_value(const CMPIBroker *broker, + xmlNode *node, + const char *tstr, + CMPIValue *val) +{ + CMPIType type = CMPI_null; + char *content = NULL; + + if (node->type != XML_ELEMENT_NODE) { + CU_DEBUG("Non-element node: %s", node->name); + goto out; + } + + if (!STREQC((char *)node->name, "value")) { + CU_DEBUG("Expected but got <%s>", node->name); + goto out; + } + + content = get_content(node); + CU_DEBUG("Node content: %s", content); + type = get_property_value(broker, tstr, content, val); + free(content); + out: + return type; +} + +static CMPIType parse_array(const CMPIBroker *broker, + const char *tstr, + xmlNode *root, + CMPIArray **array) +{ + xmlNode *value; + CMPIValue *list = NULL; + int size = 0; + int cur = 0; + CMPIStatus s; + CMPIType type = CMPI_null; + int i; + + for (value = root->children; value; value = value->next) { + + if (value->type != XML_ELEMENT_NODE) + continue; + + if (cur == size) { + CMPIValue *tmp; + + size += 4; + tmp = realloc(list, sizeof(CMPIValue) * size); + if (tmp == NULL) { + CU_DEBUG("Failed to alloc %i", + sizeof(CMPIValue) * size); + goto out; + } + + list = tmp; + } + + type = get_node_value(broker, value, tstr, &list[cur]); + if (type == CMPI_null) { + CU_DEBUG("Got nothing from child"); + } else { + CU_DEBUG("Array value type %i", type); + cur++; + } + } + + if (cur == 0) + return CMPI_null; + + *array = CMNewArray(broker, cur, type, &s); + if ((*array == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to alloc CMPIArray of %i", cur); + goto out; + } + + for (i = 0; i < cur; i++) + CMSetArrayElementAt((*array), i, &list[i], type); + + out: + free(list); + + return type; +} + +static bool parse_array_property(const CMPIBroker *broker, + xmlNode *node, + CMPIInstance *inst) +{ + char *name = NULL; + char *tstr = NULL; + bool ret = false; + xmlNode *val_arr; + CMPIArray *array; + CMPIType type; + + name = get_attr(node, "NAME"); + if (name == NULL) { + printf("Unnamed property\n"); + goto out; + } + + tstr = get_attr(node, "TYPE"); + if (tstr == NULL) { + printf("No type\n"); + goto out; + } + + printf("Array property `%s' of type `%s'\n", name, tstr); + + for (val_arr = node->children; val_arr; val_arr = val_arr->next) { + if (val_arr->type != XML_ELEMENT_NODE) + continue; + + if (!STREQC((char *)val_arr->name, "value.array")) { + printf("Expected but got <%s>", + val_arr->name); + goto out; + } + + break; + } + + type = parse_array(broker, tstr, val_arr, &array); + if (type != CMPI_null) { + CU_DEBUG("Setting array property"); + CMSetProperty(inst, name, &array, (CMPI_ARRAY | type)); + } + + out: + free(name); + free(tstr); + + return ret; +} + +static bool parse_property(const CMPIBroker *broker, + xmlNode *node, + CMPIInstance *inst) +{ + char *name = NULL; + char *tstr = NULL; + CMPIValue value; + CMPIType type = CMPI_null; + xmlNode *ptr; + + name = get_attr(node, "NAME"); + if (name == NULL) { + printf("Unnamed property\n"); + goto out; + } + + tstr = get_attr(node, "TYPE"); + if (tstr == NULL) { + printf("No type\n"); + goto out; + } + + CU_DEBUG("Property %s: %s", name, tstr); + + for (ptr = node->children; ptr; ptr = ptr->next) { + type = get_node_value(broker, ptr, tstr, &value); + if (type != CMPI_null) { + CMSetProperty(inst, name, &value, type); + break; + } + } + out: + free(name); + free(tstr); + + return type != CMPI_null; +} + +static CMPIStatus parse_instance(const CMPIBroker *broker, + const char *ns, + xmlNode *root, + CMPIInstance **inst) +{ + char *class = NULL; + xmlNode *child; + CMPIStatus s; + CMPIObjectPath *op; + + if (root->type != XML_ELEMENT_NODE) { + printf("First node is not \n"); + goto out; + } + + if (!STREQC((char *)root->name, "instance")) { + printf("Got node %s, expecting INSTANCE\n", root->name); + goto out; + } + + class = get_attr(root, "CLASSNAME"); + if (class == NULL) { + printf("No Classname\n"); + goto out; + } + + CU_DEBUG("Instance of %s", class); + + op = CMNewObjectPath(broker, ns, class, &s); + if ((op == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Unable to create path for %s:%s", ns, class); + goto out; + } + + *inst = CMNewInstance(broker, op, &s); + if ((*inst == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Unable to create inst for %s:%s", ns, class); + goto out; + } + + for (child = root->children; child; child = child->next) { + if (child->type == XML_ELEMENT_NODE){ + if (STREQC((char *)child->name, "property")) + parse_property(broker, child, *inst); + else if (STREQC((char *)child->name, "property.array")) + parse_array_property(broker, child, *inst); + else + printf("Unexpected node: %s\n", child->name); + } + } + + out: + free(class); + + return s; +} + +#if 0 + +/* This isn't currently used but I think I might need it for nested + * instances, depending on how they look. + */ + +static char *parse_esc(const char *start, char *result) +{ + char *delim; + char *escape = NULL; + int len = 1; + + delim = strchr(start, ';'); + if (delim == NULL) + goto out; + + escape = strndup(start, delim - start + 1); + if (escape == NULL) { + CU_DEBUG("Memory alloc failed (%i)", delim-start); + return NULL; + } + + CU_DEBUG("Escape is: %s", escape); + + if (STREQC(escape, "<")) + *result = '<'; + else if (STREQC(escape, ">")) + *result = '>'; + else if (STREQC(escape, """)) + *result = '\"'; + else + CU_DEBUG("Unhandled escape: `%s'", escape); + + len = strlen(escape); + + out: + free(escape); + + return (char *)start + len; +} + +static char *xml_decode(const char *input) +{ + const char *iptr = input; + char *optr; + char *res = NULL; + + res = malloc(strlen(input) + 1); + if (res == NULL) + return res; + + optr = res; + + while (iptr && (*iptr != '\0')) { + if (*iptr == '&') { + iptr = parse_esc(iptr, optr); + } else { + *optr = *iptr; + iptr++; + } + + optr++; + } + + return res; +} + +#endif + +int cu_parse_ei_xml(const CMPIBroker *broker, + const char *ns, + const char *xml, + CMPIInstance **instance) +{ + xmlDoc *doc = NULL; + xmlNode *root = NULL; + int ret = 0; + + doc = xmlReadMemory(xml, strlen(xml), NULL, NULL, 0); + if (doc == NULL) { + CU_DEBUG("Error reading decoded XML from memory"); + goto out; + } + + root = xmlDocGetRootElement(doc); + if (root == NULL) { + CU_DEBUG("Error getting root XML node"); + goto out; + } + + parse_instance(broker, ns, root, instance); + + out: + xmlFreeDoc(doc); + + return ret; +} + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff -r 03126c9af416 -r f6559a2f55ab eo_parser_xml.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eo_parser_xml.h Fri Feb 08 15:17:35 2008 -0800 @@ -0,0 +1,40 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * 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 __EO_PARSER_XML_H +#define __EO_PARSER_XML_H + +int cu_parse_ei_xml(const CMPIBroker *broker, + const char *ns, + const char *xml, + CMPIInstance **instance); + +#endif + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From kaitlin at linux.vnet.ibm.com Sat Feb 9 00:30:15 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 08 Feb 2008 16:30:15 -0800 Subject: [Libvirt-cim] [PATCH] Update EC to add support for VSMS to VSMC association In-Reply-To: <47AC8D7D.6020705@linux.vnet.ibm.com> References: <54ffc7df5a17a13811ad.1202490081@elm3b41.beaverton.ibm.com> <47AC8D7D.6020705@linux.vnet.ibm.com> Message-ID: <47ACF417.2080201@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Kaitlin Rupert wrote: >> # HG changeset patch >> # User Kaitlin Rupert >> # Date 1202490035 28800 >> # Node ID 54ffc7df5a17a13811ad65f968b7d780330630f7 >> # Parent 59c1d98cf8989adff7530eac08abee7b79a6cc03 >> Update EC to add support for VSMS to VSMC association. >> >> Removed the instance property validation. The get_vsms() (etc) calls >> will need to be updated to handle the reference validation. >> >> Signed-off-by: Kaitlin Rupert >> +static CMPIStatus validate_caps_get_service(const CMPIObjectPath >> *ref, >> + CMPIInstance **inst) >> +{ >> + CMPIStatus s = {CMPI_RC_OK, NULL}; >> + CMPIInstance *_inst; >> + char* classname; >> + >> classname = class_base_name(CLASSNAME(ref)); >> >> if (STREQC(classname, "VirtualSystemManagementCapabilities")) { >> - s = get_vsm_cap(_BROKER, ref, &inst); >> + s = get_vsm_cap(_BROKER, ref, &_inst); >> + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) >> + goto out; >> + >> + s = get_vsms(ref, &_inst, _BROKER); >> } else if (STREQC(classname, >> "VirtualSystemMigrationCapabilities")) { >> - s = get_migration_caps(ref, &inst, _BROKER); >> - } >> - - if (s.rc != CMPI_RC_OK) >> - goto out; >> - - prop = cu_compare_ref(ref, inst); >> - if (prop != NULL) { >> - cu_statusf(_BROKER, &s, >> - CMPI_RC_ERR_NOT_FOUND, >> - "No such instance (%s)", prop); >> - } >> - > > I understand that this currently breaks the reference checking, but I > think it's a good idea to have the class get_<> functions do that > checking. Thoughts? > > Also, I'm sure that this function, the validate_service_get_caps() and > validate_service_ref() can be consolidated somehow, but I haven't worked > up a clean solution yet, > > So this patch is a first step in a set of related changes. I should also note that I have reference validation patches worked out for get_vsms(), get_vsm_cap(), get_migration_service(), get_migration_caps() that I can send out once this patch is approved. They're dependent on this patch, and it's quite a large set, so I thought I'd wait to send them. Thanks =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From veillard at redhat.com Sun Feb 10 21:07:27 2008 From: veillard at redhat.com (Daniel Veillard) Date: Sun, 10 Feb 2008 16:07:27 -0500 Subject: [Libvirt-cim] [PATCH 2 of 3] [RFC][CU] Add EI CIMXML parser In-Reply-To: References: Message-ID: <20080210210727.GA8207@redhat.com> On Fri, Feb 08, 2008 at 03:18:00PM -0800, Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1202512655 28800 > # Node ID f6559a2f55abab85baeabd56faaf7804c3ea30f3 > # Parent 03126c9af41607dcaa8b197736dd5059c108261a > [RFC][CU] Add EI CIMXML parser > > This handles strings, bools, integers, and arrays of those. It doesn't yet > handle nested objects, as we will need for RASD.HostResource[]. I need > to do some further investigation of what the XML for that will look like. > > I have tested this by taking an existing XML for DefineSystem() and > changing the MemResourceAllocationSettingData field to this: > > <INSTANCE CLASSNAME="Xen_MemResourceAllocationSettingData"> > <PROPERTY NAME="CreationClassName" TYPE="string"> > <VALUE>Xen_MemResourceAllocationSettingData</VALUE> > </PROPERTY> > <PROPERTY NAME="InstanceID" TYPE="string"> > <VALUE>test/mem</VALUE> > </PROPERTY> > <PROPERTY NAME="ResourceType" TYPE="uint16"> > <VALUE>4</VALUE> > </PROPERTY> > <PROPERTY NAME="VirtualQuantity" TYPE="uint64"> > <VALUE>256 </VALUE> > </PROPERTY> > <PROPERTY.ARRAY NAME="Foo" TYPE="string"> > <VALUE.ARRAY> > <VALUE>Bar</VALUE> > <VALUE>Baz</VALUE> > </VALUE.ARRAY> > </PROPERTY.ARRAY> > </INSTANCE> Oh the escaping fun :-) [...] > +static CMPIType get_node_value(const CMPIBroker *broker, > + xmlNode *node, > + const char *tstr, > + CMPIValue *val) > +{ > + CMPIType type = CMPI_null; > + char *content = NULL; > + > + if (node->type != XML_ELEMENT_NODE) { > + CU_DEBUG("Non-element node: %s", node->name); > + goto out; > + } > + > + if (!STREQC((char *)node->name, "value")) { > + CU_DEBUG("Expected but got <%s>", node->name); > + goto out; > + } Assuming I understand the example, there is also no namespace in those element, checking node->ns == NULL might be a good idea (or not if namespaced) > + content = get_content(node); > + CU_DEBUG("Node content: %s", content); > + type = get_property_value(broker, tstr, content, val); > + free(content); > + out: > + return type; > +} > + > +static CMPIType parse_array(const CMPIBroker *broker, > + const char *tstr, > + xmlNode *root, > + CMPIArray **array) > +{ > + xmlNode *value; > + CMPIValue *list = NULL; > + int size = 0; > + int cur = 0; > + CMPIStatus s; > + CMPIType type = CMPI_null; > + int i; > + > + for (value = root->children; value; value = value->next) { > + > + if (value->type != XML_ELEMENT_NODE) > + continue; > + > + if (cur == size) { > + CMPIValue *tmp; > + > + size += 4; > + tmp = realloc(list, sizeof(CMPIValue) * size); when i have realloc in loop I usually do things like size *= 2 to escape a linear growing model. [..] > + for (child = root->children; child; child = child->next) { > + if (child->type == XML_ELEMENT_NODE){ check namespace here ? > + if (STREQC((char *)child->name, "property")) > + parse_property(broker, child, *inst); > + CU_DEBUG("Escape is: %s", escape); > + > + if (STREQC(escape, "<")) > + *result = '<'; > + else if (STREQC(escape, ">")) > + *result = '>'; > + else if (STREQC(escape, """)) > + *result = '\"'; Add & -> & and ' -> ''' would be good for completeness [...] > +int cu_parse_ei_xml(const CMPIBroker *broker, > + const char *ns, > + const char *xml, > + CMPIInstance **instance) > +{ > + xmlDoc *doc = NULL; > + xmlNode *root = NULL; > + int ret = 0; > + > + doc = xmlReadMemory(xml, strlen(xml), NULL, NULL, 0); I would add (XML_PARSE_NOENT | XML_PARSE_NOCDATA | XML_PARSE_NONET) to ask the parser to replace entities references, change CDATA section into normal text and forbid network access (should not occur, but better safe than sorry :-) > + if (doc == NULL) { > + CU_DEBUG("Error reading decoded XML from memory"); > + goto out; > + } > + > + root = xmlDocGetRootElement(doc); > + if (root == NULL) { > + CU_DEBUG("Error getting root XML node"); > + goto out; > + } > + Looks fine, maybe a small check that no memory allocation is lost is in order though, it's easy to forget something. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard at redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ From kaitlin at linux.vnet.ibm.com Mon Feb 11 16:44:10 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 11 Feb 2008 08:44:10 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] [RFC][CU] Add EI CIMXML parser In-Reply-To: References: Message-ID: <47B07B5A.5030804@linux.vnet.ibm.com> >+static CMPIType parse_int_property(const char *string, >+ const char *type, >+ CMPIValue *val) >+{ >+ int size; >+ bool sign; >+ CMPIType t; >+ int ret; >+ >+ if (sscanf(type, "uint%i", &size) == 1) >+ sign = false; >+ else if (sscanf(type, "int%i", &size) == 1) >+ sign = true; >+ else { >+ printf("Unknown integer type: `%s'", type); >+ return 0; Should this be CMPI_null? I know they're equivalent, but it might be good to use CMPI_null for clarity (and the unlikely chance that the value for CMPI_null is changed) > + > +static bool parse_array_property(const CMPIBroker *broker, > + xmlNode *node, > + CMPIInstance *inst) > +{ > + char *name = NULL; > + char *tstr = NULL; > + bool ret = false; > + xmlNode *val_arr; > + CMPIArray *array; > + CMPIType type; > + > + name = get_attr(node, "NAME"); > + if (name == NULL) { > + printf("Unnamed property\n"); > + goto out; > + } > + > + tstr = get_attr(node, "TYPE"); > + if (tstr == NULL) { > + printf("No type\n"); > + goto out; > + } > + > + printf("Array property `%s' of type `%s'\n", name, tstr); > + > + for (val_arr = node->children; val_arr; val_arr = val_arr->next) { > + if (val_arr->type != XML_ELEMENT_NODE) > + continue; > + > + if (!STREQC((char *)val_arr->name, "value.array")) { > + printf("Expected but got <%s>", > + val_arr->name); > + goto out; > + } > + > + break; > + } Should we use some kind of found flag here? What if val_arr->type never equals XML_ELEMENT_NODE. Then we pass the last value of val_arr to the function below, even if the element type doesn't equal XML_ELEMENT_NODE. Or do we know for sure that val_arr will have an element with XML_ELEMENT_NODE type? > + > + type = parse_array(broker, tstr, val_arr, &array); > + if (type != CMPI_null) { > + CU_DEBUG("Setting array property"); > + CMSetProperty(inst, name, &array, (CMPI_ARRAY | type)); > + } > + > + out: > + free(name); > + free(tstr); > + > + return ret; > +} > + > + > +static CMPIStatus parse_instance(const CMPIBroker *broker, > + const char *ns, > + xmlNode *root, > + CMPIInstance **inst) > +{ > + char *class = NULL; > + xmlNode *child; > + CMPIStatus s; > + CMPIObjectPath *op; > + > + if (root->type != XML_ELEMENT_NODE) { > + printf("First node is not \n"); > + goto out; > + } > + > + if (!STREQC((char *)root->name, "instance")) { > + printf("Got node %s, expecting INSTANCE\n", root->name); > + goto out; > + } > + > + class = get_attr(root, "CLASSNAME"); > + if (class == NULL) { > + printf("No Classname\n"); > + goto out; > + } For these statements above, should we set s.rc to some kind of error return code? Otherwise, we are returning a non-initialized status. Currently, this isn't a problem since the return value of parse_instance() isn't caught (see cu_parse_ei_xml() below)... so this might not need to be changed. > + > + CU_DEBUG("Instance of %s", class); > + > + op = CMNewObjectPath(broker, ns, class, &s); > + if ((op == NULL) || (s.rc != CMPI_RC_OK)) { > + CU_DEBUG("Unable to create path for %s:%s", ns, class); > + goto out; > + } > + > + *inst = CMNewInstance(broker, op, &s); > + if ((*inst == NULL) || (s.rc != CMPI_RC_OK)) { > + CU_DEBUG("Unable to create inst for %s:%s", ns, class); > + goto out; > + } > + > + for (child = root->children; child; child = child->next) { > + if (child->type == XML_ELEMENT_NODE){ > + if (STREQC((char *)child->name, "property")) > + parse_property(broker, child, *inst); > + else if (STREQC((char *)child->name, "property.array")) > + parse_array_property(broker, child, *inst); > + else > + printf("Unexpected node: %s\n", child->name); > + } > + } > + > + out: > + free(class); > + > + return s; > +} > + > +#if 0 > + > +/* This isn't currently used but I think I might need it for nested > + * instances, depending on how they look. > + */ > + > +static char *parse_esc(const char *start, char *result) > +{ > + char *delim; > + char *escape = NULL; > + int len = 1; > + > + delim = strchr(start, ';'); > + if (delim == NULL) > + goto out; > + > + escape = strndup(start, delim - start + 1); > + if (escape == NULL) { > + CU_DEBUG("Memory alloc failed (%i)", delim-start); > + return NULL; > + } > + > + CU_DEBUG("Escape is: %s", escape); > + > + if (STREQC(escape, "<")) > + *result = '<'; > + else if (STREQC(escape, ">")) > + *result = '>'; > + else if (STREQC(escape, """)) > + *result = '\"'; > + else > + CU_DEBUG("Unhandled escape: `%s'", escape); Would it be worthwhile to return NULL here? We return a pointer to a string, but the string might not be a valid element name because the escape isn't supported. Or should the caller check the result to make sure it's valid before continuing on? > + > + len = strlen(escape); > + > + out: > + free(escape); > + > + return (char *)start + len; > +} > + > +static char *xml_decode(const char *input) > +{ > + const char *iptr = input; > + char *optr; > + char *res = NULL; > + > + res = malloc(strlen(input) + 1); > + if (res == NULL) > + return res; > + > + optr = res; > + > + while (iptr && (*iptr != '\0')) { Just a style note, but for non-boolean variables, aren't we trying to use something like: (iptr != NULL)? > + if (*iptr == '&') { > + iptr = parse_esc(iptr, optr); > + } else { > + *optr = *iptr; > + iptr++; > + } > + > + optr++; > + } > + > + return res; > +} > + > +#endif > + > +int cu_parse_ei_xml(const CMPIBroker *broker, > + const char *ns, > + const char *xml, > + CMPIInstance **instance) > +{ > + xmlDoc *doc = NULL; > + xmlNode *root = NULL; > + int ret = 0; > + > + doc = xmlReadMemory(xml, strlen(xml), NULL, NULL, 0); > + if (doc == NULL) { > + CU_DEBUG("Error reading decoded XML from memory"); > + goto out; ret isn't updated to indicate an error here. > + } > + > + root = xmlDocGetRootElement(doc); > + if (root == NULL) { > + CU_DEBUG("Error getting root XML node"); > + goto out; > + } > + > + parse_instance(broker, ns, root, instance); The return status isn't caught here. parse_instance() could return something other than CMPI_RC_OK if CMNewObjectPath() or CMNewInstance() fail. > + > + out: > + xmlFreeDoc(doc); > + > + return ret; > +} > + I know this just and RFC, but don't forget to remove printfs or convert them to CU_DEBUGs. =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Mon Feb 11 17:04:34 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 11 Feb 2008 09:04:34 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] [CU] Some cleanups to libcmpiutil In-Reply-To: References: Message-ID: <47B08022.6000107@linux.vnet.ibm.com> Dan Smith wrote: > Some build and symbol cleanups for libcmpiutil This set looks reasonable to me. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Mon Feb 11 18:34:45 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 11 Feb 2008 10:34:45 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] [RFC][CU] Add EI CIMXML parser In-Reply-To: <47B07B5A.5030804@linux.vnet.ibm.com> (Kaitlin Rupert's message of "Mon, 11 Feb 2008 08:44:10 -0800") References: <47B07B5A.5030804@linux.vnet.ibm.com> Message-ID: <87hcgfxry2.fsf@caffeine.beaverton.ibm.com> KR> Should this be CMPI_null? I know they're equivalent, but it might be KR> good to use CMPI_null for clarity (and the unlikely chance that the KR> value for CMPI_null is changed) Yes, it should. I changed the signature of that function (about 1000 times) and forgot to update that return. KR> Should we use some kind of found flag here? What if val_arr->type KR> never equals XML_ELEMENT_NODE. Then we pass the last value of KR> val_arr to the function below, even if the element type doesn't KR> equal XML_ELEMENT_NODE. Technically the next call will fail appropriately, but yes, it should be handled better. KR> For these statements above, should we set s.rc to some kind of error KR> return code? Otherwise, we are returning a non-initialized status. Yes :) KR> Just a style note, but for non-boolean variables, aren't we trying to KR> use something like: (iptr != NULL)? Yes :) KR> The return status isn't caught here. parse_instance() could KR> return something other than CMPI_RC_OK if CMNewObjectPath() or KR> CMNewInstance() fail. Yep, that's broken indeed. KR> I know this just and RFC, but don't forget to remove printfs or KR> convert them to CU_DEBUGs. =) Gah! Every...Single...Time... :) Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 11 18:41:02 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 11 Feb 2008 10:41:02 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] [RFC][CU] Add EI CIMXML parser In-Reply-To: <20080210210727.GA8207@redhat.com> (Daniel Veillard's message of "Sun, 10 Feb 2008 16:07:27 -0500") References: <20080210210727.GA8207@redhat.com> Message-ID: <87d4r3xrnl.fsf@caffeine.beaverton.ibm.com> DV> Assuming I understand the example, there is also no namespace in DV> those element, checking node->ns == NULL might be a good idea (or DV> not if namespaced) Excuse my ignorance here, but why is this important? DV> when i have realloc in loop I usually do things like size *= 2 to DV> escape a linear growing model. Fair enough. DV> Add & -> & and ' -> ''' would be good for completeness Ah, yes, I actually meant to put something in my patch message asking what other escapes I should add. DV> I would add (XML_PARSE_NOENT | XML_PARSE_NOCDATA | DV> XML_PARSE_NONET) to ask the parser to replace entities references, DV> change CDATA section into normal text and forbid network access DV> (should not occur, but better safe than sorry :-) Okay. DV> Looks fine, maybe a small check that no memory allocation is lost is in DV> order though, it's easy to forget something. Yeah, I need to go back through with a fine-toothed comb. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Mon Feb 11 23:52:35 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 11 Feb 2008 15:52:35 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Add support for optional method arguments Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1202773946 28800 # Node ID b36fabb5b94524b5252cb8ed355d54f648a219fa # Parent cc846858f60cb7ce5b859015c9a120d784074eed [CU] Add support for optional method arguments. If no argument is supplied for a given parameter, skip any additional argument validation. Signed-off-by: Kaitlin Rupert diff -r cc846858f60c -r b36fabb5b945 std_invokemethod.c --- a/std_invokemethod.c Wed Feb 06 08:27:12 2008 -0800 +++ b/std_invokemethod.c Mon Feb 11 15:52:26 2008 -0800 @@ -184,7 +184,8 @@ static int validate_arg_type(struct meth int ret; argdata = CMGetArg(args, arg->name, s); - if ((s->rc != CMPI_RC_OK) || (CMIsNullValue(argdata))) { + if (((s->rc != CMPI_RC_OK) || (CMIsNullValue(argdata))) + && !arg->optional) { CMSetStatus(s, CMPI_RC_ERR_INVALID_PARAMETER); CU_DEBUG("Method parameter `%s' missing", arg->name); @@ -204,12 +205,14 @@ static int validate_arg_type(struct meth if (ret != 1) return 0; - } else { + } else if (!arg->optional) { CMSetStatus(s, CMPI_RC_ERR_TYPE_MISMATCH); CU_DEBUG("Method parameter `%s' type check failed", arg->name); return 0; - } + } else + CU_DEBUG("No optional parameter supplied for `%s'", + arg->name); } else { *s = CMAddArg(new_args, arg->name, diff -r cc846858f60c -r b36fabb5b945 std_invokemethod.h --- a/std_invokemethod.h Wed Feb 06 08:27:12 2008 -0800 +++ b/std_invokemethod.h Mon Feb 11 15:52:26 2008 -0800 @@ -45,6 +45,7 @@ struct method_arg { struct method_arg { char *name; CMPIType type; + bool optional; }; struct method_handler { From kaitlin at linux.vnet.ibm.com Mon Feb 11 23:54:26 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 11 Feb 2008 15:54:26 -0800 Subject: [Libvirt-cim] [PATCH] Update the method param structs to support new optional struct element Message-ID: <41f5de794c5b1d9575ee.1202774066@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202774057 28800 # Node ID 41f5de794c5b1d9575eea874e48bd50c978e153e # Parent f93b5748946ab3486649094ec23e9d7fef5257dc Update the method param structs to support new optional struct element. This patch is dependant on the optional argument libcmpiutil patch. For now, all arguments are required. But future support for optional parameters is needed. Signed-off-by: Kaitlin Rupert diff -r f93b5748946a -r 41f5de794c5b src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Fri Feb 08 14:13:34 2008 -0800 +++ b/src/Virt_ComputerSystem.c Mon Feb 11 15:54:17 2008 -0800 @@ -782,8 +782,8 @@ static struct method_handler RequestStat static struct method_handler RequestStateChange = { .name = "RequestStateChange", .handler = state_change, - .args = {{"RequestedState", CMPI_uint16}, - {"TimeoutPeriod", CMPI_dateTime}, + .args = {{"RequestedState", CMPI_uint16, false}, + {"TimeoutPeriod", CMPI_dateTime, false}, ARG_END } }; diff -r f93b5748946a -r 41f5de794c5b src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Fri Feb 08 14:13:34 2008 -0800 +++ b/src/Virt_VSMigrationService.c Mon Feb 11 15:54:17 2008 -0800 @@ -704,8 +704,8 @@ static struct method_handler vsimth = { static struct method_handler vsimth = { .name = "CheckVirtualSystemIsMigratableToHost", .handler = vs_migratable_host, - .args = {{"ComputerSystem", CMPI_ref}, - {"DestinationHost", CMPI_string}, + .args = {{"ComputerSystem", CMPI_ref, false}, + {"DestinationHost", CMPI_string, false}, ARG_END } }; @@ -713,8 +713,8 @@ static struct method_handler vsimts = { static struct method_handler vsimts = { .name = "CheckVirtualSystemIsMigratableToSystem", .handler = vs_migratable_system, - .args = {{"ComputerSystem", CMPI_ref}, - {"DestinationSystem", CMPI_ref}, + .args = {{"ComputerSystem", CMPI_ref, false}, + {"DestinationSystem", CMPI_ref, false}, ARG_END } }; @@ -722,8 +722,8 @@ static struct method_handler mvsth = { static struct method_handler mvsth = { .name = "MigrateVirtualSystemToHost", .handler = migrate_vs_host, - .args = {{"ComputerSystem", CMPI_ref}, - {"DestinationHost", CMPI_string}, + .args = {{"ComputerSystem", CMPI_ref, false}, + {"DestinationHost", CMPI_string, false}, ARG_END } }; @@ -731,8 +731,8 @@ static struct method_handler mvsts = { static struct method_handler mvsts = { .name = "MigrateVirtualSystemToSystem", .handler = migrate_vs_system, - .args = {{"ComputerSystem", CMPI_ref}, - {"DestinationSystem", CMPI_ref}, + .args = {{"ComputerSystem", CMPI_ref, false}, + {"DestinationSystem", CMPI_ref, false}, ARG_END } }; diff -r f93b5748946a -r 41f5de794c5b src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Fri Feb 08 14:13:34 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Mon Feb 11 15:54:17 2008 -0800 @@ -1098,9 +1098,9 @@ static struct method_handler DefineSyste static struct method_handler DefineSystem = { .name = "DefineSystem", .handler = define_system, - .args = {{"SystemSettings", CMPI_instance}, - {"ResourceSettings", CMPI_instanceA}, - {"ReferenceConfiguration", CMPI_string}, + .args = {{"SystemSettings", CMPI_instance, false}, + {"ResourceSettings", CMPI_instanceA, false}, + {"ReferenceConfiguration", CMPI_string, false}, ARG_END } }; @@ -1108,7 +1108,7 @@ static struct method_handler DestroySyst static struct method_handler DestroySystem = { .name = "DestroySystem", .handler = destroy_system, - .args = {{"AffectedSystem", CMPI_ref}, + .args = {{"AffectedSystem", CMPI_ref, false}, ARG_END } }; @@ -1116,8 +1116,8 @@ static struct method_handler AddResource static struct method_handler AddResourceSettings = { .name = "AddResourceSettings", .handler = add_resource_settings, - .args = {{"AffectedConfiguration", CMPI_ref}, - {"ResourceSettings", CMPI_instanceA}, + .args = {{"AffectedConfiguration", CMPI_ref, false}, + {"ResourceSettings", CMPI_instanceA, false}, ARG_END } }; @@ -1125,7 +1125,7 @@ static struct method_handler ModifyResou static struct method_handler ModifyResourceSettings = { .name = "ModifyResourceSettings", .handler = mod_resource_settings, - .args = {{"ResourceSettings", CMPI_instanceA}, + .args = {{"ResourceSettings", CMPI_instanceA, false}, ARG_END } }; @@ -1133,7 +1133,7 @@ static struct method_handler ModifySyste static struct method_handler ModifySystemSettings = { .name = "ModifySystemSettings", .handler = mod_system_settings, - .args = {{"SystemSettings", CMPI_instance}, + .args = {{"SystemSettings", CMPI_instance, false}, ARG_END } }; @@ -1141,7 +1141,7 @@ static struct method_handler RemoveResou static struct method_handler RemoveResourceSettings = { .name = "RemoveResourceSettings", .handler = rm_resource_settings, - .args = {{"ResourceSettings", CMPI_refA}, + .args = {{"ResourceSettings", CMPI_refA, false}, ARG_END } }; From veillard at redhat.com Tue Feb 12 07:55:47 2008 From: veillard at redhat.com (Daniel Veillard) Date: Tue, 12 Feb 2008 02:55:47 -0500 Subject: [Libvirt-cim] [PATCH 2 of 3] [RFC][CU] Add EI CIMXML parser In-Reply-To: <87d4r3xrnl.fsf@caffeine.beaverton.ibm.com> References: <20080210210727.GA8207@redhat.com> <87d4r3xrnl.fsf@caffeine.beaverton.ibm.com> Message-ID: <20080212075547.GD23417@redhat.com> On Mon, Feb 11, 2008 at 10:41:02AM -0800, Dan Smith wrote: > DV> Assuming I understand the example, there is also no namespace in > DV> those element, checking node->ns == NULL might be a good idea (or > DV> not if namespaced) > > Excuse my ignorance here, but why is this important? To not misinterpret an element from a foreign namespace which could be used for something completeley different. Assuming your XML vocabulary is not defined to be in a namespace, just add the && (node->ns == NULL) to the test, it just help keeping the X of XML (eXtensible). It's cheap :-) Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard at redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ From danms at us.ibm.com Tue Feb 12 14:30:08 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 12 Feb 2008 06:30:08 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] [RFC][CU] Add EI CIMXML parser In-Reply-To: <20080212075547.GD23417@redhat.com> (Daniel Veillard's message of "Tue, 12 Feb 2008 02:55:47 -0500") References: <20080210210727.GA8207@redhat.com> <87d4r3xrnl.fsf@caffeine.beaverton.ibm.com> <20080212075547.GD23417@redhat.com> Message-ID: <87k5la2qof.fsf@caffeine.beaverton.ibm.com> DV> To not misinterpret an element from a foreign namespace which DV> could be used for something completeley different. Assuming your DV> XML vocabulary is not defined to be in a namespace, just add the DV> && (node->ns == NULL) to the test, it just help keeping the X of DV> XML (eXtensible). It's cheap :-) Ah, okay, that makes sense. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Tue Feb 12 16:46:16 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 12 Feb 2008 08:46:16 -0800 Subject: [Libvirt-cim] [PATCH 3 of 3] [CU] Integrate the CIMXML EO parser with the libcmpiutil interface In-Reply-To: Message-ID: <9fce57574cea5d9c9dd0.1202834776@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202834758 28800 # Node ID 9fce57574cea5d9c9dd00ba2606e671c139b9fad # Parent 4675887c96e72b9869d2924326cfe4e7370dc8f7 [CU] Integrate the CIMXML EO parser with the libcmpiutil interface Signed-off-by: Dan Smith diff -r 4675887c96e7 -r 9fce57574cea eo_parser.c --- a/eo_parser.c Tue Feb 12 08:45:51 2008 -0800 +++ b/eo_parser.c Tue Feb 12 08:45:58 2008 -0800 @@ -31,13 +31,14 @@ #include "libcmpiutil.h" #include "eo_util_parser.h" +#include "eo_parser_xml.h" #define TEMPLATE "/tmp/tmp_eo_parse.XXXXXX" void eo_parse_restart(FILE *); int eo_parse_parseinstance(const CMPIBroker *, CMPIInstance **, const char *ns); -static int write_temp(char *eo) +static int write_temp(const char *eo) { int fd; int ret; @@ -62,13 +63,13 @@ static int write_temp(char *eo) return fd; } -int cu_parse_embedded_instance(const char *eo, - const CMPIBroker *broker, - const char *ns, - CMPIInstance **instance) +#ifdef HAVE_EOPARSER +static int parse_ei_mof(const CMPIBroker *broker, + const char *ns, + const char *eo, + CMPIInstance **instance) { int ret; -#ifdef HAVE_EOPARSER int fd; FILE *fp; @@ -81,10 +82,29 @@ int cu_parse_embedded_instance(const cha ret = eo_parse_parseinstance(broker, instance, ns); close(fd); + + return ret; +} +#endif + +int cu_parse_embedded_instance(const char *eo, + const CMPIBroker *broker, + const char *ns, + CMPIInstance **instance) +{ + if (strcasestr(eo, " Message-ID: <520d0cf3451a118877bf.1202834774@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202834750 28800 # Node ID 520d0cf3451a118877bf623b8927ff4f46a8e899 # Parent 5fc07aeb10b77e6560d3be415887842b61d69d95 [CU] Make libcmpiutil include libxml libraries/includes As needed for the CIMXML EO parser Signed-off-by: Dan Smith diff -r 5fc07aeb10b7 -r 520d0cf3451a acinclude.m4 --- a/acinclude.m4 Mon Feb 11 15:52:26 2008 -0800 +++ b/acinclude.m4 Tue Feb 12 08:45:50 2008 -0800 @@ -92,3 +92,9 @@ AC_DEFUN([CHECK_BROKEN_CMPIFT], ] )]) +AC_DEFUN([CHECK_LIBXML2], + [ + PKG_CHECK_MODULES([LIBXML], [libxml-2.0]) + CPPFLAGS="$CPPFLAGS $LIBXML_CFLAGS" + LDFLAGS="$LDFLAGS $LIBXML_LDFLAGS" + ]) diff -r 5fc07aeb10b7 -r 520d0cf3451a configure.ac --- a/configure.ac Mon Feb 11 15:52:26 2008 -0800 +++ b/configure.ac Tue Feb 12 08:45:50 2008 -0800 @@ -50,6 +50,8 @@ AC_ARG_ENABLE([eoparser], AM_CONDITIONAL([build_eoparser],[test x$eoparser = xyes]) +CHECK_LIBXML2 + if test x${eoparser} = xyes; then CFLAGS+=" -DHAVE_EOPARSER" fi From danms at us.ibm.com Tue Feb 12 16:46:15 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 12 Feb 2008 08:46:15 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] [CU] Add EI CIMXML parser In-Reply-To: Message-ID: <4675887c96e72b9869d2.1202834775@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202834751 28800 # Node ID 4675887c96e72b9869d2924326cfe4e7370dc8f7 # Parent 520d0cf3451a118877bf623b8927ff4f46a8e899 [CU] Add EI CIMXML parser This handles strings, bools, integers, and arrays of those. It doesn't yet handle nested objects, as we will need for RASD.HostResource[]. I need to do some further investigation of what the XML for that will look like. I have tested this by taking an existing XML for DefineSystem() and changing the MemResourceAllocationSettingData field to this: <INSTANCE CLASSNAME="Xen_MemResourceAllocationSettingData"> <PROPERTY NAME="CreationClassName" TYPE="string"> <VALUE>Xen_MemResourceAllocationSettingData</VALUE> </PROPERTY> <PROPERTY NAME="InstanceID" TYPE="string"> <VALUE>test/mem</VALUE> </PROPERTY> <PROPERTY NAME="ResourceType" TYPE="uint16"> <VALUE>4</VALUE> </PROPERTY> <PROPERTY NAME="VirtualQuantity" TYPE="uint64"> <VALUE>256 </VALUE> </PROPERTY> <PROPERTY.ARRAY NAME="Foo" TYPE="string"> <VALUE.ARRAY> <VALUE>Bar</VALUE> <VALUE>Baz</VALUE> </VALUE.ARRAY> </PROPERTY.ARRAY> </INSTANCE> (The Foo[] parameter in there is just for testing :) Changes: - Fixes as noted by Kaitlin - XML namespace and parse flags, as noted by DV Signed-off-by: Dan Smith diff -r 520d0cf3451a -r 4675887c96e7 Makefile.am --- a/Makefile.am Tue Feb 12 08:45:50 2008 -0800 +++ b/Makefile.am Tue Feb 12 08:45:51 2008 -0800 @@ -10,6 +10,8 @@ pkgconfig_DATA = libcmpiutil.pc libcmpiutilincdir = $(includedir)/libcmpiutil +noinst_HEADERS = eo_parser_xml.h + libcmpiutilinc_HEADERS = libcmpiutil.h \ std_invokemethod.h \ std_association.h \ @@ -18,7 +20,7 @@ libcmpiutilinc_HEADERS = libcmpiutil.h \ libcmpiutil_la_SOURCES = args_util.c instance_util.c std_invokemethod.c \ std_association.c inst_list.c std_indication.c \ - debug_util.c + debug_util.c eo_parser_xml.c libcmpiutil_la_CFLAGS = $(CFLAGS) $(CFLAGS_STRICT) libcmpiutil_la_LIBADD = libcmpiutil_la_DEPENDENCIES = diff -r 520d0cf3451a -r 4675887c96e7 eo_parser_xml.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eo_parser_xml.c Tue Feb 12 08:45:51 2008 -0800 @@ -0,0 +1,515 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "libcmpiutil.h" + +#include "eo_parser_xml.h" + +static char *get_attr(xmlNode *node, const char *name) +{ + return (char *)xmlGetProp(node, (xmlChar *)name); +} + +static char *get_content(xmlNode *node) +{ + return (char *)xmlNodeGetContent(node); +} + +static CMPIType parse_string_property(const CMPIBroker *broker, + const char *string, + const char *type, + CMPIValue *val) +{ + CMPIString *str; + CMPIStatus s; + + str = CMNewString(broker, string, &s); + if ((str == NULL) || (s.rc != CMPI_RC_OK)) + return CMPI_null; + + val->string = str; + return CMPI_string; +} + +static CMPIType parse_bool_property(const char *string, + const char *type, + CMPIValue *val) +{ + val->boolean = STREQC(string, "true"); + + return CMPI_boolean; +} + +static CMPIType parse_int_property(const char *string, + const char *type, + CMPIValue *val) +{ + int size; + bool sign; + CMPIType t; + int ret; + + if (sscanf(type, "uint%i", &size) == 1) + sign = false; + else if (sscanf(type, "int%i", &size) == 1) + sign = true; + else { + printf("Unknown integer type: `%s'", type); + return CMPI_null; + } + + if (sign) { + int64_t _val; + ret = sscanf(string, "%" SCNi64, &_val); + val->sint64 = _val; + } else { + uint64_t _val; + ret = sscanf(string, "%" SCNu64, &_val); + val->uint64 = _val; + } + + if (ret != 1) { + printf("Failed to scan value `%s'\n", string); + return CMPI_null; + } + + switch (size) { + case 8: t = sign ? CMPI_sint8 : CMPI_uint8; break; + case 16: t = sign ? CMPI_sint16 : CMPI_uint16; break; + case 32: t = sign ? CMPI_sint32 : CMPI_uint32; break; + default: + case 64: t = sign ? CMPI_sint64 : CMPI_uint64; break; + }; + + return t; +} + +static CMPIType get_property_value(const CMPIBroker *broker, + const char *tstr, + const char *content, + CMPIValue *value) +{ + CMPIType type = CMPI_null; + + if (STREQC(tstr, "string")) + type = parse_string_property(broker, content, tstr, value); + else if (STREQC(tstr, "boolean")) + type = parse_bool_property(content, tstr, value); + else if (strstr(tstr, "int")) + type = parse_int_property(content, tstr, value); + else { + printf("Unhandled type: %s\n", tstr); + goto out; + } + + if (type == CMPI_null) { + printf("Unable to parse type %s\n", tstr); + goto out; + } + + out: + return type; +} + +static CMPIType get_node_value(const CMPIBroker *broker, + xmlNode *node, + const char *tstr, + CMPIValue *val) +{ + CMPIType type = CMPI_null; + char *content = NULL; + + if (node->type != XML_ELEMENT_NODE) { + CU_DEBUG("Non-element node: %s", node->name); + goto out; + } + + if (!STREQC((char *)node->name, "value") && + (node->ns == NULL)) { + CU_DEBUG("Expected but got <%s>", node->name); + goto out; + } + + content = get_content(node); + CU_DEBUG("Node content: %s", content); + type = get_property_value(broker, tstr, content, val); + free(content); + out: + return type; +} + +static CMPIType parse_array(const CMPIBroker *broker, + const char *tstr, + xmlNode *root, + CMPIArray **array) +{ + xmlNode *value; + CMPIValue *list = NULL; + int size = 0; + int cur = 0; + CMPIStatus s; + CMPIType type = CMPI_null; + int i; + + for (value = root->children; value; value = value->next) { + + if (value->type != XML_ELEMENT_NODE) + continue; + + if (cur == size) { + CMPIValue *tmp; + + size *= 2; + tmp = realloc(list, sizeof(CMPIValue) * size); + if (tmp == NULL) { + CU_DEBUG("Failed to alloc %i", + sizeof(CMPIValue) * size); + goto out; + } + + list = tmp; + } + + type = get_node_value(broker, value, tstr, &list[cur]); + if (type == CMPI_null) { + CU_DEBUG("Got nothing from child"); + } else { + CU_DEBUG("Array value type %i", type); + cur++; + } + } + + if (cur == 0) + return CMPI_null; + + *array = CMNewArray(broker, cur, type, &s); + if ((*array == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to alloc CMPIArray of %i", cur); + goto out; + } + + for (i = 0; i < cur; i++) + CMSetArrayElementAt((*array), i, &list[i], type); + + out: + free(list); + + return type; +} + +static bool parse_array_property(const CMPIBroker *broker, + xmlNode *node, + CMPIInstance *inst) +{ + char *name = NULL; + char *tstr = NULL; + bool ret = false; + xmlNode *val_arr; + CMPIArray *array; + CMPIType type; + + name = get_attr(node, "NAME"); + if (name == NULL) { + printf("Unnamed property\n"); + goto out; + } + + tstr = get_attr(node, "TYPE"); + if (tstr == NULL) { + printf("No type\n"); + goto out; + } + + printf("Array property `%s' of type `%s'\n", name, tstr); + + for (val_arr = node->children; val_arr; val_arr = val_arr->next) { + if (val_arr->type != XML_ELEMENT_NODE) + continue; + + if (!STREQC((char *)val_arr->name, "value.array")) { + printf("Expected but got <%s>", + val_arr->name); + val_arr = NULL; + goto out; + } + + break; + } + + if (val_arr != NULL) { + type = parse_array(broker, tstr, val_arr, &array); + if (type != CMPI_null) { + CU_DEBUG("Setting array property"); + CMSetProperty(inst, name, &array, (CMPI_ARRAY | type)); + } + } + + out: + free(name); + free(tstr); + + return ret; +} + +static bool parse_property(const CMPIBroker *broker, + xmlNode *node, + CMPIInstance *inst) +{ + char *name = NULL; + char *tstr = NULL; + CMPIValue value; + CMPIType type = CMPI_null; + xmlNode *ptr; + + name = get_attr(node, "NAME"); + if (name == NULL) { + printf("Unnamed property\n"); + goto out; + } + + tstr = get_attr(node, "TYPE"); + if (tstr == NULL) { + printf("No type\n"); + goto out; + } + + CU_DEBUG("Property %s: %s", name, tstr); + + for (ptr = node->children; ptr; ptr = ptr->next) { + type = get_node_value(broker, ptr, tstr, &value); + if (type != CMPI_null) { + CMSetProperty(inst, name, &value, type); + break; + } + } + out: + free(name); + free(tstr); + + return type != CMPI_null; +} + +static CMPIStatus parse_instance(const CMPIBroker *broker, + const char *ns, + xmlNode *root, + CMPIInstance **inst) +{ + char *class = NULL; + xmlNode *child; + CMPIStatus s; + CMPIObjectPath *op; + + if (root->type != XML_ELEMENT_NODE) { + CU_DEBUG("First node is not "); + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "First node of object is not name, "instance")) { + CU_DEBUG("Got node %s, expecting INSTANCE", root->name); + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "First node of object is not children; child; child = child->next) { + if ((child->type == XML_ELEMENT_NODE) && + (child->ns == NULL)) { + if (STREQC((char *)child->name, "property")) + parse_property(broker, child, *inst); + else if (STREQC((char *)child->name, "property.array")) + parse_array_property(broker, child, *inst); + else + printf("Unexpected node: %s\n", child->name); + } + } + + out: + free(class); + + return s; +} + +#if 0 + +/* This isn't currently used but I think I might need it for nested + * instances, depending on how they look. + */ + +static char *parse_esc(const char *start, char *result) +{ + char *delim; + char *escape = NULL; + int len = 1; + + delim = strchr(start, ';'); + if (delim == NULL) + goto out; + + escape = strndup(start, delim - start + 1); + if (escape == NULL) { + CU_DEBUG("Memory alloc failed (%i)", delim-start); + return NULL; + } + + CU_DEBUG("Escape is: %s", escape); + + if (STREQC(escape, "<")) + *result = '<'; + else if (STREQC(escape, ">")) + *result = '>'; + else if (STREQC(escape, """)) + *result = '\"'; + else if (STREQC(escape, "&")) + *result = '&'; + else if (STREQC(escape, "'")) + *result = '\''; + else + CU_DEBUG("Unhandled escape: `%s'", escape); + + len = strlen(escape); + + out: + free(escape); + + return (char *)start + len; +} + +static char *xml_decode(const char *input) +{ + const char *iptr = input; + char *optr; + char *res = NULL; + + res = malloc(strlen(input) + 1); + if (res == NULL) + return res; + + optr = res; + + while ((iptr != NULL) && (*iptr != '\0')) { + if (*iptr == '&') { + iptr = parse_esc(iptr, optr); + } else { + *optr = *iptr; + iptr++; + } + + optr++; + } + + return res; +} + +#endif + +int cu_parse_ei_xml(const CMPIBroker *broker, + const char *ns, + const char *xml, + CMPIInstance **instance) +{ + xmlDoc *doc = NULL; + xmlNode *root = NULL; + int ret = 1; + CMPIStatus s; + + doc = xmlReadMemory(xml, + strlen(xml), + NULL, + NULL, + (XML_PARSE_NOENT | + XML_PARSE_NOCDATA | + XML_PARSE_NONET)); + if (doc == NULL) { + CU_DEBUG("Error reading decoded XML from memory"); + goto out; + } + + root = xmlDocGetRootElement(doc); + if (root == NULL) { + CU_DEBUG("Error getting root XML node"); + goto out; + } + + s = parse_instance(broker, ns, root, instance); + if (s.rc != CMPI_RC_OK) { + *instance = NULL; + CU_DEBUG("CIMXML EI Parsing failed: %s", + CMGetCharPtr(s.msg)); + goto out; + } + + ret = 0; + + out: + xmlFreeDoc(doc); + + return ret; +} + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff -r 520d0cf3451a -r 4675887c96e7 eo_parser_xml.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eo_parser_xml.h Tue Feb 12 08:45:51 2008 -0800 @@ -0,0 +1,40 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * 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 __EO_PARSER_XML_H +#define __EO_PARSER_XML_H + +int cu_parse_ei_xml(const CMPIBroker *broker, + const char *ns, + const char *xml, + CMPIInstance **instance); + +#endif + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From danms at us.ibm.com Tue Feb 12 16:46:13 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 12 Feb 2008 08:46:13 -0800 Subject: [Libvirt-cim] [PATCH 0 of 3] (#2) [CU] Add CIMXML EO parser Message-ID: Updated based on review comments From danms at us.ibm.com Tue Feb 12 18:20:36 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 12 Feb 2008 10:20:36 -0800 Subject: [Libvirt-cim] [PATCH] Update EC to add support for VSMS to VSMC association In-Reply-To: <54ffc7df5a17a13811ad.1202490081@elm3b41.beaverton.ibm.com> (Kaitlin Rupert's message of "Fri, 08 Feb 2008 09:01:21 -0800") References: <54ffc7df5a17a13811ad.1202490081@elm3b41.beaverton.ibm.com> Message-ID: <87wspa11fv.fsf@caffeine.beaverton.ibm.com> KR> +static CMPIStatus service_to_cap(const CMPIObjectPath *ref, KR> + struct std_assoc_info *info, KR> + struct inst_list *list) KR> +{ KR> + CMPIInstance *inst = NULL; KR> + CMPIStatus s = {CMPI_RC_OK, NULL}; KR> + KR> + if (!match_hypervisor_prefix(ref, info)) KR> + goto out; KR> + KR> + s = validate_service_get_caps(ref, &inst); Whitespace issue. Otherwise this seems fine to me. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Tue Feb 12 18:37:21 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 12 Feb 2008 10:37:21 -0800 Subject: [Libvirt-cim] [PATCH] Update EC to add support for VSMS to VSMC association In-Reply-To: <87wspa11fv.fsf@caffeine.beaverton.ibm.com> References: <54ffc7df5a17a13811ad.1202490081@elm3b41.beaverton.ibm.com> <87wspa11fv.fsf@caffeine.beaverton.ibm.com> Message-ID: <47B1E761.4000704@linux.vnet.ibm.com> Dan Smith wrote: > KR> +static CMPIStatus service_to_cap(const CMPIObjectPath *ref, > KR> + struct std_assoc_info *info, > KR> + struct inst_list *list) > KR> +{ > KR> + CMPIInstance *inst = NULL; > KR> + CMPIStatus s = {CMPI_RC_OK, NULL}; > KR> + > KR> + if (!match_hypervisor_prefix(ref, info)) > KR> + goto out; > KR> + > KR> + s = validate_service_get_caps(ref, &inst); > > Whitespace issue. > > Otherwise this seems fine to me. > Good eye - I missed this when I reviewed the patch before sending it out. Will resend =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Tue Feb 12 20:19:52 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 12 Feb 2008 12:19:52 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] [CU] Make libcmpiutil include libxml libraries/includes In-Reply-To: Message-ID: <520d0cf3451a118877bf.1202847592@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202834750 28800 # Node ID 520d0cf3451a118877bf623b8927ff4f46a8e899 # Parent 5fc07aeb10b77e6560d3be415887842b61d69d95 [CU] Make libcmpiutil include libxml libraries/includes As needed for the CIMXML EO parser Signed-off-by: Dan Smith diff -r 5fc07aeb10b7 -r 520d0cf3451a acinclude.m4 --- a/acinclude.m4 Mon Feb 11 15:52:26 2008 -0800 +++ b/acinclude.m4 Tue Feb 12 08:45:50 2008 -0800 @@ -92,3 +92,9 @@ AC_DEFUN([CHECK_BROKEN_CMPIFT], ] )]) +AC_DEFUN([CHECK_LIBXML2], + [ + PKG_CHECK_MODULES([LIBXML], [libxml-2.0]) + CPPFLAGS="$CPPFLAGS $LIBXML_CFLAGS" + LDFLAGS="$LDFLAGS $LIBXML_LDFLAGS" + ]) diff -r 5fc07aeb10b7 -r 520d0cf3451a configure.ac --- a/configure.ac Mon Feb 11 15:52:26 2008 -0800 +++ b/configure.ac Tue Feb 12 08:45:50 2008 -0800 @@ -50,6 +50,8 @@ AC_ARG_ENABLE([eoparser], AM_CONDITIONAL([build_eoparser],[test x$eoparser = xyes]) +CHECK_LIBXML2 + if test x${eoparser} = xyes; then CFLAGS+=" -DHAVE_EOPARSER" fi From danms at us.ibm.com Tue Feb 12 20:19:54 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 12 Feb 2008 12:19:54 -0800 Subject: [Libvirt-cim] [PATCH 3 of 3] [CU] Integrate the CIMXML EO parser with the libcmpiutil interface In-Reply-To: Message-ID: <6043289449b78acf6c96.1202847594@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202847571 28800 # Node ID 6043289449b78acf6c96f79053ef5c1c43e3e285 # Parent 7dcf0ca88f1873778f94bd8920c437f5cfa65e78 [CU] Integrate the CIMXML EO parser with the libcmpiutil interface Signed-off-by: Dan Smith diff -r 7dcf0ca88f18 -r 6043289449b7 eo_parser.c --- a/eo_parser.c Tue Feb 12 12:19:25 2008 -0800 +++ b/eo_parser.c Tue Feb 12 12:19:31 2008 -0800 @@ -31,13 +31,14 @@ #include "libcmpiutil.h" #include "eo_util_parser.h" +#include "eo_parser_xml.h" #define TEMPLATE "/tmp/tmp_eo_parse.XXXXXX" void eo_parse_restart(FILE *); int eo_parse_parseinstance(const CMPIBroker *, CMPIInstance **, const char *ns); -static int write_temp(char *eo) +static int write_temp(const char *eo) { int fd; int ret; @@ -62,13 +63,13 @@ static int write_temp(char *eo) return fd; } -int cu_parse_embedded_instance(const char *eo, - const CMPIBroker *broker, - const char *ns, - CMPIInstance **instance) +#ifdef HAVE_EOPARSER +static int parse_ei_mof(const CMPIBroker *broker, + const char *ns, + const char *eo, + CMPIInstance **instance) { int ret; -#ifdef HAVE_EOPARSER int fd; FILE *fp; @@ -81,10 +82,29 @@ int cu_parse_embedded_instance(const cha ret = eo_parse_parseinstance(broker, instance, ns); close(fd); + + return ret; +} +#endif + +int cu_parse_embedded_instance(const char *eo, + const CMPIBroker *broker, + const char *ns, + CMPIInstance **instance) +{ + if (strcasestr(eo, " ...and this time without the printf()'s From danms at us.ibm.com Tue Feb 12 20:19:53 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 12 Feb 2008 12:19:53 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] [CU] Add EI CIMXML parser In-Reply-To: Message-ID: <7dcf0ca88f1873778f94.1202847593@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202847565 28800 # Node ID 7dcf0ca88f1873778f94bd8920c437f5cfa65e78 # Parent 520d0cf3451a118877bf623b8927ff4f46a8e899 [CU] Add EI CIMXML parser This handles strings, bools, integers, and arrays of those. It doesn't yet handle nested objects, as we will need for RASD.HostResource[]. I need to do some further investigation of what the XML for that will look like. I have tested this by taking an existing XML for DefineSystem() and changing the MemResourceAllocationSettingData field to this: <INSTANCE CLASSNAME="Xen_MemResourceAllocationSettingData"> <PROPERTY NAME="CreationClassName" TYPE="string"> <VALUE>Xen_MemResourceAllocationSettingData</VALUE> </PROPERTY> <PROPERTY NAME="InstanceID" TYPE="string"> <VALUE>test/mem</VALUE> </PROPERTY> <PROPERTY NAME="ResourceType" TYPE="uint16"> <VALUE>4</VALUE> </PROPERTY> <PROPERTY NAME="VirtualQuantity" TYPE="uint64"> <VALUE>256 </VALUE> </PROPERTY> <PROPERTY.ARRAY NAME="Foo" TYPE="string"> <VALUE.ARRAY> <VALUE>Bar</VALUE> <VALUE>Baz</VALUE> </VALUE.ARRAY> </PROPERTY.ARRAY> </INSTANCE> (The Foo[] parameter in there is just for testing :) Changes: - Fixes as noted by Kaitlin - XML namespace and parse flags, as noted by DV Signed-off-by: Dan Smith diff -r 520d0cf3451a -r 7dcf0ca88f18 Makefile.am --- a/Makefile.am Tue Feb 12 08:45:50 2008 -0800 +++ b/Makefile.am Tue Feb 12 12:19:25 2008 -0800 @@ -10,6 +10,8 @@ pkgconfig_DATA = libcmpiutil.pc libcmpiutilincdir = $(includedir)/libcmpiutil +noinst_HEADERS = eo_parser_xml.h + libcmpiutilinc_HEADERS = libcmpiutil.h \ std_invokemethod.h \ std_association.h \ @@ -18,7 +20,7 @@ libcmpiutilinc_HEADERS = libcmpiutil.h \ libcmpiutil_la_SOURCES = args_util.c instance_util.c std_invokemethod.c \ std_association.c inst_list.c std_indication.c \ - debug_util.c + debug_util.c eo_parser_xml.c libcmpiutil_la_CFLAGS = $(CFLAGS) $(CFLAGS_STRICT) libcmpiutil_la_LIBADD = libcmpiutil_la_DEPENDENCIES = diff -r 520d0cf3451a -r 7dcf0ca88f18 eo_parser_xml.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eo_parser_xml.c Tue Feb 12 12:19:25 2008 -0800 @@ -0,0 +1,515 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "libcmpiutil.h" + +#include "eo_parser_xml.h" + +static char *get_attr(xmlNode *node, const char *name) +{ + return (char *)xmlGetProp(node, (xmlChar *)name); +} + +static char *get_content(xmlNode *node) +{ + return (char *)xmlNodeGetContent(node); +} + +static CMPIType parse_string_property(const CMPIBroker *broker, + const char *string, + const char *type, + CMPIValue *val) +{ + CMPIString *str; + CMPIStatus s; + + str = CMNewString(broker, string, &s); + if ((str == NULL) || (s.rc != CMPI_RC_OK)) + return CMPI_null; + + val->string = str; + return CMPI_string; +} + +static CMPIType parse_bool_property(const char *string, + const char *type, + CMPIValue *val) +{ + val->boolean = STREQC(string, "true"); + + return CMPI_boolean; +} + +static CMPIType parse_int_property(const char *string, + const char *type, + CMPIValue *val) +{ + int size; + bool sign; + CMPIType t; + int ret; + + if (sscanf(type, "uint%i", &size) == 1) + sign = false; + else if (sscanf(type, "int%i", &size) == 1) + sign = true; + else { + CU_DEBUG("Unknown integer type: `%s'", type); + return CMPI_null; + } + + if (sign) { + int64_t _val; + ret = sscanf(string, "%" SCNi64, &_val); + val->sint64 = _val; + } else { + uint64_t _val; + ret = sscanf(string, "%" SCNu64, &_val); + val->uint64 = _val; + } + + if (ret != 1) { + CU_DEBUG("Failed to scan value `%s'\n", string); + return CMPI_null; + } + + switch (size) { + case 8: t = sign ? CMPI_sint8 : CMPI_uint8; break; + case 16: t = sign ? CMPI_sint16 : CMPI_uint16; break; + case 32: t = sign ? CMPI_sint32 : CMPI_uint32; break; + default: + case 64: t = sign ? CMPI_sint64 : CMPI_uint64; break; + }; + + return t; +} + +static CMPIType get_property_value(const CMPIBroker *broker, + const char *tstr, + const char *content, + CMPIValue *value) +{ + CMPIType type = CMPI_null; + + if (STREQC(tstr, "string")) + type = parse_string_property(broker, content, tstr, value); + else if (STREQC(tstr, "boolean")) + type = parse_bool_property(content, tstr, value); + else if (strstr(tstr, "int")) + type = parse_int_property(content, tstr, value); + else { + CU_DEBUG("Unhandled type: %s\n", tstr); + goto out; + } + + if (type == CMPI_null) { + CU_DEBUG("Unable to parse type %s\n", tstr); + goto out; + } + + out: + return type; +} + +static CMPIType get_node_value(const CMPIBroker *broker, + xmlNode *node, + const char *tstr, + CMPIValue *val) +{ + CMPIType type = CMPI_null; + char *content = NULL; + + if (node->type != XML_ELEMENT_NODE) { + CU_DEBUG("Non-element node: %s", node->name); + goto out; + } + + if (!STREQC((char *)node->name, "value") && + (node->ns == NULL)) { + CU_DEBUG("Expected but got <%s>", node->name); + goto out; + } + + content = get_content(node); + CU_DEBUG("Node content: %s", content); + type = get_property_value(broker, tstr, content, val); + free(content); + out: + return type; +} + +static CMPIType parse_array(const CMPIBroker *broker, + const char *tstr, + xmlNode *root, + CMPIArray **array) +{ + xmlNode *value; + CMPIValue *list = NULL; + int size = 0; + int cur = 0; + CMPIStatus s; + CMPIType type = CMPI_null; + int i; + + for (value = root->children; value; value = value->next) { + + if (value->type != XML_ELEMENT_NODE) + continue; + + if (cur == size) { + CMPIValue *tmp; + + size *= 2; + tmp = realloc(list, sizeof(CMPIValue) * size); + if (tmp == NULL) { + CU_DEBUG("Failed to alloc %i", + sizeof(CMPIValue) * size); + goto out; + } + + list = tmp; + } + + type = get_node_value(broker, value, tstr, &list[cur]); + if (type == CMPI_null) { + CU_DEBUG("Got nothing from child"); + } else { + CU_DEBUG("Array value type %i", type); + cur++; + } + } + + if (cur == 0) + return CMPI_null; + + *array = CMNewArray(broker, cur, type, &s); + if ((*array == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to alloc CMPIArray of %i", cur); + goto out; + } + + for (i = 0; i < cur; i++) + CMSetArrayElementAt((*array), i, &list[i], type); + + out: + free(list); + + return type; +} + +static bool parse_array_property(const CMPIBroker *broker, + xmlNode *node, + CMPIInstance *inst) +{ + char *name = NULL; + char *tstr = NULL; + bool ret = false; + xmlNode *val_arr; + CMPIArray *array; + CMPIType type; + + name = get_attr(node, "NAME"); + if (name == NULL) { + CU_DEBUG("Unnamed property\n"); + goto out; + } + + tstr = get_attr(node, "TYPE"); + if (tstr == NULL) { + CU_DEBUG("No type\n"); + goto out; + } + + CU_DEBUG("Array property `%s' of type `%s'\n", name, tstr); + + for (val_arr = node->children; val_arr; val_arr = val_arr->next) { + if (val_arr->type != XML_ELEMENT_NODE) + continue; + + if (!STREQC((char *)val_arr->name, "value.array")) { + CU_DEBUG("Expected but got <%s>", + val_arr->name); + val_arr = NULL; + goto out; + } + + break; + } + + if (val_arr != NULL) { + type = parse_array(broker, tstr, val_arr, &array); + if (type != CMPI_null) { + CU_DEBUG("Setting array property"); + CMSetProperty(inst, name, &array, (CMPI_ARRAY | type)); + } + } + + out: + free(name); + free(tstr); + + return ret; +} + +static bool parse_property(const CMPIBroker *broker, + xmlNode *node, + CMPIInstance *inst) +{ + char *name = NULL; + char *tstr = NULL; + CMPIValue value; + CMPIType type = CMPI_null; + xmlNode *ptr; + + name = get_attr(node, "NAME"); + if (name == NULL) { + CU_DEBUG("Unnamed property\n"); + goto out; + } + + tstr = get_attr(node, "TYPE"); + if (tstr == NULL) { + CU_DEBUG("No type\n"); + goto out; + } + + CU_DEBUG("Property %s: %s", name, tstr); + + for (ptr = node->children; ptr; ptr = ptr->next) { + type = get_node_value(broker, ptr, tstr, &value); + if (type != CMPI_null) { + CMSetProperty(inst, name, &value, type); + break; + } + } + out: + free(name); + free(tstr); + + return type != CMPI_null; +} + +static CMPIStatus parse_instance(const CMPIBroker *broker, + const char *ns, + xmlNode *root, + CMPIInstance **inst) +{ + char *class = NULL; + xmlNode *child; + CMPIStatus s; + CMPIObjectPath *op; + + if (root->type != XML_ELEMENT_NODE) { + CU_DEBUG("First node is not "); + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "First node of object is not name, "instance")) { + CU_DEBUG("Got node %s, expecting INSTANCE", root->name); + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "First node of object is not children; child; child = child->next) { + if ((child->type == XML_ELEMENT_NODE) && + (child->ns == NULL)) { + if (STREQC((char *)child->name, "property")) + parse_property(broker, child, *inst); + else if (STREQC((char *)child->name, "property.array")) + parse_array_property(broker, child, *inst); + else + CU_DEBUG("Unexpected node: %s\n", child->name); + } + } + + out: + free(class); + + return s; +} + +#if 0 + +/* This isn't currently used but I think I might need it for nested + * instances, depending on how they look. + */ + +static char *parse_esc(const char *start, char *result) +{ + char *delim; + char *escape = NULL; + int len = 1; + + delim = strchr(start, ';'); + if (delim == NULL) + goto out; + + escape = strndup(start, delim - start + 1); + if (escape == NULL) { + CU_DEBUG("Memory alloc failed (%i)", delim-start); + return NULL; + } + + CU_DEBUG("Escape is: %s", escape); + + if (STREQC(escape, "<")) + *result = '<'; + else if (STREQC(escape, ">")) + *result = '>'; + else if (STREQC(escape, """)) + *result = '\"'; + else if (STREQC(escape, "&")) + *result = '&'; + else if (STREQC(escape, "'")) + *result = '\''; + else + CU_DEBUG("Unhandled escape: `%s'", escape); + + len = strlen(escape); + + out: + free(escape); + + return (char *)start + len; +} + +static char *xml_decode(const char *input) +{ + const char *iptr = input; + char *optr; + char *res = NULL; + + res = malloc(strlen(input) + 1); + if (res == NULL) + return res; + + optr = res; + + while ((iptr != NULL) && (*iptr != '\0')) { + if (*iptr == '&') { + iptr = parse_esc(iptr, optr); + } else { + *optr = *iptr; + iptr++; + } + + optr++; + } + + return res; +} + +#endif + +int cu_parse_ei_xml(const CMPIBroker *broker, + const char *ns, + const char *xml, + CMPIInstance **instance) +{ + xmlDoc *doc = NULL; + xmlNode *root = NULL; + int ret = 1; + CMPIStatus s; + + doc = xmlReadMemory(xml, + strlen(xml), + NULL, + NULL, + (XML_PARSE_NOENT | + XML_PARSE_NOCDATA | + XML_PARSE_NONET)); + if (doc == NULL) { + CU_DEBUG("Error reading decoded XML from memory"); + goto out; + } + + root = xmlDocGetRootElement(doc); + if (root == NULL) { + CU_DEBUG("Error getting root XML node"); + goto out; + } + + s = parse_instance(broker, ns, root, instance); + if (s.rc != CMPI_RC_OK) { + *instance = NULL; + CU_DEBUG("CIMXML EI Parsing failed: %s", + CMGetCharPtr(s.msg)); + goto out; + } + + ret = 0; + + out: + xmlFreeDoc(doc); + + return ret; +} + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff -r 520d0cf3451a -r 7dcf0ca88f18 eo_parser_xml.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eo_parser_xml.h Tue Feb 12 12:19:25 2008 -0800 @@ -0,0 +1,40 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * 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 __EO_PARSER_XML_H +#define __EO_PARSER_XML_H + +int cu_parse_ei_xml(const CMPIBroker *broker, + const char *ns, + const char *xml, + CMPIInstance **instance); + +#endif + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From danms at us.ibm.com Tue Feb 12 20:55:44 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 12 Feb 2008 12:55:44 -0800 Subject: [Libvirt-cim] [PATCH] Remove added leading slash to namespace in .spec Message-ID: # HG changeset patch # User Dan Smith # Date 1202849741 28800 # Node ID e8db1c1626222a38f02e5c43b9c8c403d3a07154 # Parent 388ec19f6b4a0230002b2ef096a8ed7cdb5783cb Remove added leading slash to namespace in .spec This was reported to cause a problem with some versions of Pegasus Signed-off-by: Dan Smith diff -r 388ec19f6b4a -r e8db1c162622 libvirt-cim.spec.in --- a/libvirt-cim.spec.in Tue Feb 12 12:42:55 2008 -0800 +++ b/libvirt-cim.spec.in Tue Feb 12 12:55:41 2008 -0800 @@ -52,7 +52,7 @@ rm -fr $RPM_BUILD_ROOT %define SCHEMA %{_datadir}/%{name}/*.mof %{_datadir}/%{name}/provider-register.sh -d -t pegasus \ - -n /@CIM_VIRT_NS@ \ + -n @CIM_VIRT_NS@ \ -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true %post @@ -63,12 +63,12 @@ rm -fr $RPM_BUILD_ROOT /etc/init.d/tog-pegasus restart %{_datadir}/%{name}/provider-register.sh -t pegasus \ - -n /@CIM_VIRT_NS@ \ + -n @CIM_VIRT_NS@ \ -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true %preun %{_datadir}/%{name}/provider-register.sh -d -t pegasus \ - -n /@CIM_VIRT_NS@ \ + -n @CIM_VIRT_NS@ \ -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true %postun -p /sbin/ldconfig From kaitlin at linux.vnet.ibm.com Tue Feb 12 23:40:29 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 12 Feb 2008 15:40:29 -0800 Subject: [Libvirt-cim] [PATCH] (#2) Update EC to add support for VSMS to VSMC association Message-ID: <182035ee85c375cf9ff9.1202859629@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202859592 28800 # Node ID 182035ee85c375cf9ff908014f64513ad42cb418 # Parent 15c8041aa453df5eebd50d4dd17a2170bc9c1f86 (#2) Update EC to add support for VSMS to VSMC association. Updates - fixed whitespace issue with validate_service_get_caps() call. Removed the instance property validation. The get_vsms() (etc) calls will need to be updated to handle the reference validation. Signed-off-by: Kaitlin Rupert diff -r 15c8041aa453 -r 182035ee85c3 src/Makefile.am --- a/src/Makefile.am Mon Feb 11 15:54:17 2008 -0800 +++ b/src/Makefile.am Tue Feb 12 15:39:52 2008 -0800 @@ -99,14 +99,16 @@ libVirt_AllocationCapabilities_la_SOURCE libVirt_AllocationCapabilities_la_SOURCES = Virt_AllocationCapabilities.c libVirt_AllocationCapabilities_la_LIBADD = -lVirt_DevicePool -libVirt_ElementCapabilities_la_DEPENDENCIES = libVirt_VirtualSystemManagementCapabilities.la libVirt_EnabledLogicalElementCapabilities.la libVirt_ComputerSystem.la libVirt_HostSystem.la libVirt_VSMigrationCapabilities.la +libVirt_ElementCapabilities_la_DEPENDENCIES = libVirt_VirtualSystemManagementCapabilities.la libVirt_EnabledLogicalElementCapabilities.la libVirt_ComputerSystem.la libVirt_HostSystem.la libVirt_VSMigrationCapabilities.la libVirt_VirtualSystemManagementService.la libVirt_VSMigrationService.la libVirt_ElementCapabilities_la_SOURCES = Virt_ElementCapabilities.c libVirt_ElementCapabilities_la_LIBADD = -lVirt_VirtualSystemManagementCapabilities \ -lVirt_EnabledLogicalElementCapabilities \ -lVirt_ComputerSystem \ -lVirt_HostSystem \ -lVirt_VSMigrationCapabilities \ - -lVirt_AllocationCapabilities + -lVirt_AllocationCapabilities \ + -lVirt_VirtualSystemManagementService \ + -lVirt_VSMigrationService libVirt_SettingsDefineCapabilities_la_DEPENDENCIES = libVirt_RASD.la libVirt_DevicePool.la libVirt_SettingsDefineCapabilities_la_SOURCES = Virt_SettingsDefineCapabilities.c diff -r 15c8041aa453 -r 182035ee85c3 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Mon Feb 11 15:54:17 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Tue Feb 12 15:39:52 2008 -0800 @@ -33,6 +33,8 @@ #include #include "Virt_VirtualSystemManagementCapabilities.h" +#include "Virt_VirtualSystemManagementService.h" +#include "Virt_VSMigrationService.h" #include "Virt_EnabledLogicalElementCapabilities.h" #include "Virt_ComputerSystem.h" #include "Virt_HostSystem.h" @@ -48,31 +50,63 @@ const static CMPIBroker *_BROKER; -static CMPIStatus validate_host_caps_ref(const CMPIObjectPath *ref) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - const char *prop; - char* classname; - +static CMPIStatus validate_caps_get_service(const CMPIObjectPath *ref, + CMPIInstance **inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *_inst; + char* classname; + classname = class_base_name(CLASSNAME(ref)); if (STREQC(classname, "VirtualSystemManagementCapabilities")) { - s = get_vsm_cap(_BROKER, ref, &inst); + s = get_vsm_cap(_BROKER, ref, &_inst); + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) + goto out; + + s = get_vsms(ref, &_inst, _BROKER); } else if (STREQC(classname, "VirtualSystemMigrationCapabilities")) { - s = get_migration_caps(ref, &inst, _BROKER); - } - - if (s.rc != CMPI_RC_OK) - goto out; - - prop = cu_compare_ref(ref, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } - + s = get_migration_caps(ref, &_inst, _BROKER); + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) + goto out; + + s = get_migration_service(ref, &_inst, _BROKER); + } else + CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); + + *inst = _inst; + out: + free(classname); + + return s; +} + +static CMPIStatus validate_service_get_caps(const CMPIObjectPath *ref, + CMPIInstance **inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *_inst; + char* classname; + + classname = class_base_name(CLASSNAME(ref)); + + if (STREQC(classname, "VirtualSystemManagementService")) { + s = get_vsms(ref, &_inst, _BROKER); + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) + goto out; + + s = get_vsm_cap(_BROKER, ref, &_inst); + } else if (STREQC(classname, "VirtualSystemMigrationService")) { + s = get_migration_service(ref, &_inst, _BROKER); + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) + goto out; + + s = get_migration_caps(ref, &_inst, _BROKER); + } else + CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); + + *inst = _inst; + out: free(classname); @@ -105,19 +139,22 @@ static CMPIStatus sys_to_cap(const CMPIO return s; } -static CMPIStatus cap_to_sys(const CMPIObjectPath *ref, - struct std_assoc_info *info, - struct inst_list *list) -{ - CMPIInstance *inst; - CMPIStatus s = {CMPI_RC_OK, NULL}; - - if (!match_hypervisor_prefix(ref, info)) - goto out; - - s = validate_host_caps_ref(ref); - if (s.rc != CMPI_RC_OK) - goto out; +static CMPIStatus cap_to_sys_or_service(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIInstance *inst = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = validate_caps_get_service(ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + if (inst != NULL) + inst_list_add(list, inst); s = get_host_cs(_BROKER, ref, &inst); if (s.rc != CMPI_RC_OK) @@ -125,6 +162,26 @@ static CMPIStatus cap_to_sys(const CMPIO inst_list_add(list, inst); + out: + return s; +} + +static CMPIStatus service_to_cap(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIInstance *inst = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = validate_service_get_caps(ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + if (inst != NULL) + inst_list_add(list, inst); out: return s; } @@ -245,6 +302,16 @@ static char* host_system[] = { NULL }; +static char* host_sys_and_service[] = { + "Xen_HostSystem", + "KVM_HostSystem", + "Xen_VirtualSystemManagementService", + "KVM_VirtualSystemManagementService", + "Xen_VirtualSystemMigrationService", + "KVM_VirtualSystemMigrationService", + NULL +}; + static char* virtual_system_management_capabilities[] = { "Xen_VirtualSystemManagementCapabilities", "Xen_VirtualSystemMigrationCapabilities", @@ -266,16 +333,37 @@ static struct std_assoc system_to_vsm_ca .make_ref = make_ref }; -static struct std_assoc vsm_cap_to_system = { +static struct std_assoc vsm_cap_to_sys_or_service = { .source_class = (char**)&virtual_system_management_capabilities, .source_prop = "Capabilities", - .target_class = (char**)&host_system, + .target_class = (char**)&host_sys_and_service, .target_prop = "ManagedElement", .assoc_class = (char**)&assoc_classname, - .handler = cap_to_sys, + .handler = cap_to_sys_or_service, + .make_ref = make_ref +}; + +static char* service[] = { + "Xen_VirtualSystemManagementService", + "KVM_VirtualSystemManagementService", + "Xen_VirtualSystemMigrationService", + "KVM_VirtualSystemMigrationService", + NULL +}; + +static struct std_assoc _service_to_cap = { + .source_class = (char**)&service, + .source_prop = "ManagedElement", + + .target_class = (char**)&virtual_system_management_capabilities, + .target_prop = "Capabilities", + + .assoc_class = (char**)&assoc_classname, + + .handler = service_to_cap, .make_ref = make_ref }; @@ -363,7 +451,8 @@ static struct std_assoc resource_pool_to static struct std_assoc *assoc_handlers[] = { &system_to_vsm_cap, - &vsm_cap_to_system, + &vsm_cap_to_sys_or_service, + &_service_to_cap, &ele_cap_to_cs, &cs_to_ele_cap, &alloc_cap_to_resource_pool, From kaitlin at linux.vnet.ibm.com Tue Feb 12 23:42:31 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 12 Feb 2008 15:42:31 -0800 Subject: [Libvirt-cim] [PATCH 0 of 3] (#3) [CU] Add CIMXML EO parser In-Reply-To: References: Message-ID: <47B22EE7.4000403@linux.vnet.ibm.com> Dan Smith wrote: > ...and this time without the printf()'s > No complaints with this set. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Tue Feb 12 23:44:24 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 12 Feb 2008 15:44:24 -0800 Subject: [Libvirt-cim] [PATCH] Remove added leading slash to namespace in .spec In-Reply-To: References: Message-ID: <47B22F58.9090602@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1202849741 28800 > # Node ID e8db1c1626222a38f02e5c43b9c8c403d3a07154 > # Parent 388ec19f6b4a0230002b2ef096a8ed7cdb5783cb > Remove added leading slash to namespace in .spec > > This was reported to cause a problem with some versions of Pegasus > From what I have seen, there's no need for the preceding slash. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Wed Feb 13 15:57:54 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 13 Feb 2008 07:57:54 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Make the spec require libxml2-devel for build Message-ID: # HG changeset patch # User Dan Smith # Date 1202917532 28800 # Node ID bd9472d3aa5f9f91553813e25731ae90c2555917 # Parent 6043289449b78acf6c96f79053ef5c1c43e3e285 [CU] Make the spec require libxml2-devel for build Signed-off-by: Dan Smith diff -r 6043289449b7 -r bd9472d3aa5f libcmpiutil.spec.in --- a/libcmpiutil.spec.in Tue Feb 12 12:19:31 2008 -0800 +++ b/libcmpiutil.spec.in Wed Feb 13 07:45:32 2008 -0800 @@ -12,6 +12,7 @@ BuildRequires: tog-pegasus-devel BuildRequires: tog-pegasus-devel BuildRequires: flex BuildRequires: bison +BuildRequires: libxml2-devel BuildConflicts: sblim-cmpi-devel %description From danms at us.ibm.com Wed Feb 13 15:58:04 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 13 Feb 2008 07:58:04 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Fix warning in cu_dup_instance() that breaks build Message-ID: # HG changeset patch # User Dan Smith # Date 1202917533 28800 # Node ID c19e321766902af6dba29025be964d8d45537c51 # Parent bd9472d3aa5f9f91553813e25731ae90c2555917 [CU] Fix warning in cu_dup_instance() that breaks build Signed-off-by: Dan Smith diff -r bd9472d3aa5f -r c19e32176690 instance_util.c --- a/instance_util.c Wed Feb 13 07:45:32 2008 -0800 +++ b/instance_util.c Wed Feb 13 07:45:33 2008 -0800 @@ -234,7 +234,7 @@ CMPIInstance *cu_dup_instance(const CMPI for (i = 0; i < prop_count; i++) { CMPIString *prop; - char *prop_name; + const char *prop_name; data = CMGetPropertyAt(src, i, &prop, s); prop_name = CMGetCharPtr(prop); From kaitlin at linux.vnet.ibm.com Wed Feb 13 16:13:18 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 13 Feb 2008 08:13:18 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Fix warning in cu_dup_instance() that breaks build In-Reply-To: References: Message-ID: <47B3171E.2020501@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1202917533 28800 > # Node ID c19e321766902af6dba29025be964d8d45537c51 > # Parent bd9472d3aa5f9f91553813e25731ae90c2555917 > [CU] Fix warning in cu_dup_instance() that breaks build > > Signed-off-by: Dan Smith > > diff -r bd9472d3aa5f -r c19e32176690 instance_util.c > --- a/instance_util.c Wed Feb 13 07:45:32 2008 -0800 > +++ b/instance_util.c Wed Feb 13 07:45:33 2008 -0800 > @@ -234,7 +234,7 @@ CMPIInstance *cu_dup_instance(const CMPI > > for (i = 0; i < prop_count; i++) { > CMPIString *prop; > - char *prop_name; > + const char *prop_name; > > data = CMGetPropertyAt(src, i, &prop, s); > prop_name = CMGetCharPtr(prop); Since we're getting the value for prop_name from the CIMOM, this const here makes sense. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From grendel at linux.vnet.ibm.com Wed Feb 13 16:15:24 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Wed, 13 Feb 2008 11:15:24 -0500 Subject: [Libvirt-cim] [PATCH] [CU] Make the spec require libxml2-devel for build In-Reply-To: References: Message-ID: <47B3179C.1010402@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1202917532 28800 > # Node ID bd9472d3aa5f9f91553813e25731ae90c2555917 > # Parent 6043289449b78acf6c96f79053ef5c1c43e3e285 > [CU] Make the spec require libxml2-devel for build > > Signed-off-by: Dan Smith > > diff -r 6043289449b7 -r bd9472d3aa5f libcmpiutil.spec.in > --- a/libcmpiutil.spec.in Tue Feb 12 12:19:31 2008 -0800 > +++ b/libcmpiutil.spec.in Wed Feb 13 07:45:32 2008 -0800 > @@ -12,6 +12,7 @@ BuildRequires: tog-pegasus-devel > BuildRequires: tog-pegasus-devel > BuildRequires: flex > BuildRequires: bison > +BuildRequires: libxml2-devel > BuildConflicts: sblim-cmpi-devel > > %description > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > Patch of the Week, right here. I now it's only Wednesday but I'm calling it. +1 -- -Jay From grendel at linux.vnet.ibm.com Wed Feb 13 16:18:37 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Wed, 13 Feb 2008 11:18:37 -0500 Subject: [Libvirt-cim] [PATCH] [CU] Fix warning in cu_dup_instance() that breaks build In-Reply-To: References: Message-ID: <47B3185D.6020206@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1202917533 28800 > # Node ID c19e321766902af6dba29025be964d8d45537c51 > # Parent bd9472d3aa5f9f91553813e25731ae90c2555917 > [CU] Fix warning in cu_dup_instance() that breaks build > > Signed-off-by: Dan Smith > > diff -r bd9472d3aa5f -r c19e32176690 instance_util.c > --- a/instance_util.c Wed Feb 13 07:45:32 2008 -0800 > +++ b/instance_util.c Wed Feb 13 07:45:33 2008 -0800 > @@ -234,7 +234,7 @@ CMPIInstance *cu_dup_instance(const CMPI > > for (i = 0; i < prop_count; i++) { > CMPIString *prop; > - char *prop_name; > + const char *prop_name; > > data = CMGetPropertyAt(src, i, &prop, s); > prop_name = CMGetCharPtr(prop); > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > Oops, my bad; I knew I would miss one of those somewhere. +1 -- -Jay From kaitlin at linux.vnet.ibm.com Wed Feb 13 16:17:36 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 13 Feb 2008 08:17:36 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Update calls to get_vsms() to include value for new is_get_inst param In-Reply-To: Message-ID: <30beb44bdb1ffb789a03.1202919456@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202919397 28800 # Node ID 30beb44bdb1ffb789a031bd860e316f1e500abbb # Parent 88e4cf39a5b342606d6a126c429eb9f0f1c38ab8 Update calls to get_vsms() to include value for new is_get_inst param. Signed-off-by: Kaitlin Rupert diff -r 88e4cf39a5b3 -r 30beb44bdb1f src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Wed Feb 13 08:14:07 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Wed Feb 13 08:16:37 2008 -0800 @@ -64,7 +64,7 @@ static CMPIStatus validate_caps_get_serv if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; - s = get_vsms(ref, &_inst, _BROKER); + s = get_vsms(ref, &_inst, _BROKER, false); } else if (STREQC(classname, "VirtualSystemMigrationCapabilities")) { s = get_migration_caps(ref, &_inst, _BROKER); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) @@ -91,7 +91,7 @@ static CMPIStatus validate_service_get_c classname = class_base_name(CLASSNAME(ref)); if (STREQC(classname, "VirtualSystemManagementService")) { - s = get_vsms(ref, &_inst, _BROKER); + s = get_vsms(ref, &_inst, _BROKER, true); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; diff -r 88e4cf39a5b3 -r 30beb44bdb1f src/Virt_HostedService.c --- a/src/Virt_HostedService.c Wed Feb 13 08:14:07 2008 -0800 +++ b/src/Virt_HostedService.c Wed Feb 13 08:16:37 2008 -0800 @@ -47,7 +47,7 @@ static CMPIStatus validate_service_ref(c classname = class_base_name(CLASSNAME(ref)); if (STREQC(classname, "VirtualSystemManagementService")) { - s = get_vsms(ref, &inst, _BROKER); + s = get_vsms(ref, &inst, _BROKER, true); } else if (STREQC(classname, "ResourcePoolConfigurationService")) { s = get_rpcs(ref, &inst, _BROKER, true); } else if (STREQC(classname, "VirtualSystemMigrationService")) { @@ -111,7 +111,7 @@ static CMPIStatus host_to_service(const if (!CMIsNullObject(inst)) inst_list_add(list, inst); - s = get_vsms(ref, &inst, _BROKER); + s = get_vsms(ref, &inst, _BROKER, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) From kaitlin at linux.vnet.ibm.com Wed Feb 13 16:17:34 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 13 Feb 2008 08:17:34 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] Update get_vsms() to validate references passed in. Message-ID: From kaitlin at linux.vnet.ibm.com Wed Feb 13 16:17:35 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 13 Feb 2008 08:17:35 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Update get_vsms() in VSMS to validate reference In-Reply-To: Message-ID: <88e4cf39a5b342606d6a.1202919455@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202919247 28800 # Node ID 88e4cf39a5b342606d6a126c429eb9f0f1c38ab8 # Parent be18b4c2084a6b2b1f1c3a1cdae25a98034d7d54 Update get_vsms() in VSMS to validate reference. Also change names_only from an int to a bool. Signed-off-by: Kaitlin Rupert diff -r be18b4c2084a -r 88e4cf39a5b3 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Tue Feb 12 15:39:52 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Wed Feb 13 08:14:07 2008 -0800 @@ -1161,7 +1161,8 @@ STDIM_MethodMIStub(, Virt_VirtualSystemM CMPIStatus get_vsms(const CMPIObjectPath *reference, CMPIInstance **_inst, - const CMPIBroker *broker) + const CMPIBroker *broker, + bool is_get_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; @@ -1171,8 +1172,14 @@ CMPIStatus get_vsms(const CMPIObjectPath *_inst = NULL; conn = connect_by_classname(broker, CLASSNAME(reference), &s); - if (conn == NULL) + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + return s; + } inst = get_typed_instance(broker, pfx_from_conn(conn), @@ -1207,6 +1214,12 @@ CMPIStatus get_vsms(const CMPIObjectPath CMSetProperty(inst, "SystemCreationClassName", (CMPIValue *)ccname, CMPI_chars); + if (is_get_inst) { + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + CMSetStatus(&s, CMPI_RC_OK); out: @@ -1218,12 +1231,13 @@ CMPIStatus get_vsms(const CMPIObjectPath static CMPIStatus return_vsms(const CMPIObjectPath *reference, const CMPIResult *results, - int name_only) + bool name_only, + bool is_get_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - s = get_vsms(reference, &inst, _BROKER); + s = get_vsms(reference, &inst, _BROKER, is_get_inst); if (s.rc != CMPI_RC_OK || inst == NULL) goto out; @@ -1240,7 +1254,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_vsms(reference, results, 1); + return return_vsms(reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -1250,7 +1264,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_vsms(reference, results, 0); + return return_vsms(reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -1259,25 +1273,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *ref, const char **properties) { - CMPIInstance *inst; - CMPIStatus s; - const char *prop; - - s = get_vsms(ref, &inst, _BROKER); - if (s.rc != CMPI_RC_OK) - return s; - - prop = cu_compare_ref(ref, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } else { - CMSetStatus(&s, CMPI_RC_OK); - CMReturnInstance(results, inst); - } - - return s; + return return_vsms(ref, results, false, true); } DEFAULT_CI(); diff -r be18b4c2084a -r 88e4cf39a5b3 src/Virt_VirtualSystemManagementService.h --- a/src/Virt_VirtualSystemManagementService.h Tue Feb 12 15:39:52 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.h Wed Feb 13 08:14:07 2008 -0800 @@ -21,4 +21,5 @@ CMPIStatus get_vsms(const CMPIObjectPath *reference, CMPIInstance **_inst, - const CMPIBroker *broker); + const CMPIBroker *broker, + bool is_get_inst); From danms at us.ibm.com Wed Feb 13 17:28:20 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 13 Feb 2008 09:28:20 -0800 Subject: [Libvirt-cim] [PATCH] Fix misplaced const Message-ID: <460476bb31d6d3d2e400.1202923700@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202923672 28800 # Node ID 460476bb31d6d3d2e400396e3797cfc6697744fd # Parent be18b4c2084a6b2b1f1c3a1cdae25a98034d7d54 Fix misplaced const This causes a warning on some versions of GCC because we're passing in the inst to be modified, which means it can't be const. Not sure why more GCC versions aren't catching this, but it needs to be fixed. Signed-off-by: Dan Smith diff -r be18b4c2084a -r 460476bb31d6 src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Tue Feb 12 15:39:52 2008 -0800 +++ b/src/Virt_VSMigrationService.c Wed Feb 13 09:27:52 2008 -0800 @@ -269,7 +269,7 @@ static bool raise_indication(const CMPIC const char *base_type, const char *ns, CMPIInstance *inst, - const CMPIInstance *ind) + CMPIInstance *ind) { char *type; CMPIStatus s; From veillard at redhat.com Wed Feb 13 17:39:10 2008 From: veillard at redhat.com (Daniel Veillard) Date: Wed, 13 Feb 2008 12:39:10 -0500 Subject: [Libvirt-cim] [PATCH] [CU] Make the spec require libxml2-devel for build In-Reply-To: References: Message-ID: <20080213173910.GE12378@redhat.com> On Wed, Feb 13, 2008 at 07:57:54AM -0800, Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1202917532 28800 > # Node ID bd9472d3aa5f9f91553813e25731ae90c2555917 > # Parent 6043289449b78acf6c96f79053ef5c1c43e3e285 > [CU] Make the spec require libxml2-devel for build > > Signed-off-by: Dan Smith > > diff -r 6043289449b7 -r bd9472d3aa5f libcmpiutil.spec.in > --- a/libcmpiutil.spec.in Tue Feb 12 12:19:31 2008 -0800 > +++ b/libcmpiutil.spec.in Wed Feb 13 07:45:32 2008 -0800 > @@ -12,6 +12,7 @@ BuildRequires: tog-pegasus-devel > BuildRequires: tog-pegasus-devel > BuildRequires: flex > BuildRequires: bison > +BuildRequires: libxml2-devel > BuildConflicts: sblim-cmpi-devel > > %description +1 Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard at redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ From grendel at linux.vnet.ibm.com Wed Feb 13 18:34:45 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Wed, 13 Feb 2008 13:34:45 -0500 Subject: [Libvirt-cim] [PATCH] Fix misplaced const In-Reply-To: <460476bb31d6d3d2e400.1202923700@caffeine.beaverton.ibm.com> References: <460476bb31d6d3d2e400.1202923700@caffeine.beaverton.ibm.com> Message-ID: <47B33845.1020904@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1202923672 28800 > # Node ID 460476bb31d6d3d2e400396e3797cfc6697744fd > # Parent be18b4c2084a6b2b1f1c3a1cdae25a98034d7d54 > Fix misplaced const > > This causes a warning on some versions of GCC because we're passing in > the inst to be modified, which means it can't be const. Not sure why > more GCC versions aren't catching this, but it needs to be fixed. > > It appears I use my const keywords with about as much care as I use salt. Thanks for finding another one. +1 -- -Jay From danms at us.ibm.com Wed Feb 13 21:37:45 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 13 Feb 2008 13:37:45 -0800 Subject: [Libvirt-cim] [PATCH] Fix missing Virt_AllocationCapabilities.h header inclusion in dist Message-ID: # HG changeset patch # User Dan Smith # Date 1202938649 28800 # Node ID abb9ef8863c4cc27abaac3d98ac43dded5b9f19e # Parent 460476bb31d6d3d2e400396e3797cfc6697744fd Fix missing Virt_AllocationCapabilities.h header inclusion in dist Signed-off-by: Dan Smith diff -r 460476bb31d6 -r abb9ef8863c4 src/Makefile.am --- a/src/Makefile.am Wed Feb 13 09:27:52 2008 -0800 +++ b/src/Makefile.am Wed Feb 13 13:37:29 2008 -0800 @@ -16,7 +16,8 @@ noinst_HEADERS = profiles.h svpc_types.h Virt_VirtualSystemManagementService.h \ Virt_VSSD.h \ Virt_VSMigrationCapabilities.h \ - Virt_VSMigrationService.h + Virt_VSMigrationService.h \ + Virt_AllocationCapabilities.h XKUADD = $(top_builddir)/libxkutil/libxkutil.la From kaitlin at linux.vnet.ibm.com Wed Feb 13 21:43:16 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 13 Feb 2008 13:43:16 -0800 Subject: [Libvirt-cim] [PATCH] Fix missing Virt_AllocationCapabilities.h header inclusion in dist In-Reply-To: References: Message-ID: <47B36474.2030306@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1202938649 28800 > # Node ID abb9ef8863c4cc27abaac3d98ac43dded5b9f19e > # Parent 460476bb31d6d3d2e400396e3797cfc6697744fd > Fix missing Virt_AllocationCapabilities.h header inclusion in dist > I like the short patches recently. =) +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Wed Feb 13 22:24:08 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 13 Feb 2008 14:24:08 -0800 Subject: [Libvirt-cim] [PATCH] This changes any uses of CMSetStatus() to cu_statusf() Message-ID: <7e6bffb32e40c55323fe.1202941448@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1202940826 28800 # Node ID 7e6bffb32e40c55323fe98f0ec0658cd6ea32a78 # Parent abb9ef8863c4cc27abaac3d98ac43dded5b9f19e This changes any uses of CMSetStatus() to cu_statusf() With new versions of GCC, the check for (s != NULL) in the macro sets off the "Address of `s' will always be true" warning. We don't want to turn that warning off, so this seems like the better choice Signed-off-by: Dan Smith diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_ComputerSystem.c Wed Feb 13 14:13:46 2008 -0800 @@ -440,7 +440,9 @@ static CMPIStatus return_enum_domains(co inst_list_init(&list); ret = enum_domains(_BROKER, conn, NAMESPACE(reference), &list); if (!ret) { - CMSetStatus(&s, CMPI_RC_ERR_FAILED); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to get domain list"); goto out; } @@ -449,8 +451,9 @@ static CMPIStatus return_enum_domains(co else cu_return_instances(results, &list); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: inst_list_free(&list); @@ -734,7 +737,9 @@ static CMPIStatus __state_change(const c else if (state == CIM_STATE_RESET) s = state_change_reset(dom, &info); else - CMSetStatus(&s, CMPI_RC_ERR_NOT_SUPPORTED); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_SUPPORTED, + "State not supported"); out: virDomainFree(dom); @@ -757,7 +762,9 @@ static CMPIStatus state_change(CMPIMetho ret = cu_get_u16_arg(argsin, "RequestedState", &state); if (ret != CMPI_RC_OK) { - CMSetStatus(&s, CMPI_RC_ERR_INVALID_PARAMETER); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Invalid RequestedState"); goto out; } diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_Device.c --- a/src/Virt_Device.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_Device.c Wed Feb 13 14:13:46 2008 -0800 @@ -371,7 +371,9 @@ static CMPIStatus enum_devices(const CMP inst_list_free(&list); out: - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); virConnectClose(conn); return s; diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_DevicePool.c Wed Feb 13 14:13:46 2008 -0800 @@ -795,7 +795,9 @@ static CMPIStatus return_pool(const CMPI &list); if (s.rc == CMPI_RC_OK) { __return_pool(results, &list, name_only); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_ElementAllocatedFromPool.c Wed Feb 13 14:13:46 2008 -0800 @@ -102,7 +102,9 @@ static CMPIStatus vdev_to_pool(const CMP pool = get_pool_by_id(_BROKER, conn, poolid, NAMESPACE(ref)); if (pool != NULL) { inst_list_add(list, pool); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -220,8 +222,9 @@ static CMPIStatus pool_to_vdev(const CMP devs_from_pool(type, ref, poolid, list); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: return s; } diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Wed Feb 13 14:13:46 2008 -0800 @@ -72,7 +72,9 @@ static CMPIStatus validate_caps_get_serv s = get_migration_service(ref, &_inst, _BROKER); } else - CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "Not found"); *inst = _inst; out: @@ -103,7 +105,9 @@ static CMPIStatus validate_service_get_c s = get_migration_caps(ref, &_inst, _BROKER); } else - CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + ""); *inst = _inst; diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_HostedDependency.c Wed Feb 13 14:13:46 2008 -0800 @@ -70,14 +70,18 @@ static CMPIStatus host_to_vs(const CMPIO ret = enum_domains(_BROKER, conn, NAMESPACE(ref), list); if (ret) { - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Failed to get domain list"); } - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); return s; } diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_HostedResourcePool.c Wed Feb 13 14:13:46 2008 -0800 @@ -87,7 +87,9 @@ static CMPIStatus sys_to_pool(const CMPI NAMESPACE(ref), list); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); return s; } diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_RegisteredProfile.c --- a/src/Virt_RegisteredProfile.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_RegisteredProfile.c Wed Feb 13 14:13:46 2008 -0800 @@ -162,7 +162,9 @@ static CMPIStatus get_prof(const CMPIObj if(instance) CMReturnInstance(results, instance); else - CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "Profile instance not found"); out: virConnectClose(conn); diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_ResourceAllocationFromPool.c Wed Feb 13 14:13:46 2008 -0800 @@ -112,7 +112,9 @@ static CMPIStatus rasd_to_pool(const CMP NAMESPACE(ref)); if (pool != NULL) { inst_list_add(list, pool); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -237,8 +239,9 @@ static CMPIStatus pool_to_rasd(const CMP poolid, list); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: return s; } diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_SettingsDefineState.c Wed Feb 13 14:13:46 2008 -0800 @@ -104,8 +104,9 @@ static CMPIStatus dev_to_rasd(const CMPI if (rasd != NULL) inst_list_add(list, rasd); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: free(name); free(devid); @@ -184,8 +185,9 @@ static CMPIStatus rasd_to_dev(const CMPI inst_list_add(list, dev); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: return s; } @@ -226,8 +228,9 @@ static CMPIStatus vs_to_vssd(const CMPIO if (vssd != NULL) inst_list_add(list, vssd); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: virDomainFree(dom); virConnectClose(conn); @@ -277,8 +280,9 @@ static CMPIStatus vssd_to_vs(const CMPIO if (cs != NULL) inst_list_add(list, cs); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: free(name); free(pfx); diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_SystemDevice.c --- a/src/Virt_SystemDevice.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_SystemDevice.c Wed Feb 13 14:13:46 2008 -0800 @@ -157,7 +157,9 @@ static CMPIStatus sys_to_dev(const CMPIO NAMESPACE(ref)); if (ret >= 0) { - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -208,7 +210,9 @@ static CMPIStatus dev_to_sys(const CMPIO "Unable to find DeviceID `%s'", devid); else { inst_list_add(list, sys); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } out: diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_VSMigrationCapabilities.c --- a/src/Virt_VSMigrationCapabilities.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_VSMigrationCapabilities.c Wed Feb 13 14:13:46 2008 -0800 @@ -73,8 +73,9 @@ static CMPIStatus set_method_properties( CMSetProperty(inst, "SynchronousMethodsSupported", (CMPIValue *)&array, CMPI_uint16A); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); return s; } diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_VSMigrationService.c Wed Feb 13 14:13:46 2008 -0800 @@ -114,7 +114,9 @@ static CMPIStatus check_hver(virConnectP if (remote >= local) { CU_DEBUG("Version check OK (%lu >= %lu)", remote, local); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { CU_DEBUG("Version check FAILED (%lu < %lu)", remote, local); cu_statusf(_BROKER, &s, @@ -123,8 +125,9 @@ static CMPIStatus check_hver(virConnectP remote, local); } - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: return s; } @@ -172,8 +175,9 @@ static CMPIStatus vs_migratable(const CM goto out; retcode = 0; - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); @@ -432,8 +436,9 @@ static CMPIStatus migrate_vs(struct migr } CU_DEBUG("Migration succeeded"); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: free(uri); virDomainFree(dom); @@ -788,8 +793,10 @@ CMPIStatus get_migration_service(const C CMSetProperty(inst, "SystemCreationClassName", (CMPIValue *)ccname, CMPI_chars); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); + *_inst = inst; out: diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_VSMigrationSettingData.c --- a/src/Virt_VSMigrationSettingData.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_VSMigrationSettingData.c Wed Feb 13 14:13:46 2008 -0800 @@ -47,7 +47,9 @@ static CMPIStatus set_properties(const C (CMPIValue *)&priority, CMPI_uint16); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(broker, &s, + CMPI_RC_OK, + ""); return s; } diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_VSSD.c --- a/src/Virt_VSSD.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_VSSD.c Wed Feb 13 14:13:46 2008 -0800 @@ -182,7 +182,9 @@ static CMPIStatus enum_vssd(const CMPIOb "Failed to enumerate domains"); goto out; } else if (count == 0) { - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); goto out; } @@ -200,7 +202,9 @@ static CMPIStatus enum_vssd(const CMPIOb CMReturnInstance(results, inst); } - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: free(list); @@ -271,7 +275,9 @@ static CMPIStatus GetInstance(CMPIInstan if (inst) CMReturnInstance(results, inst); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); free(locid); diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_VSSDComponent.c Wed Feb 13 14:13:46 2008 -0800 @@ -69,8 +69,9 @@ static CMPIStatus vssd_to_rasd(const CMP list); } - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: free(name); @@ -103,8 +104,9 @@ static CMPIStatus vssd_for_name(const ch CMPI_RC_ERR_FAILED, "Error getting VSSD for `%s'", host); else - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: virDomainFree(dom); virConnectClose(conn); diff -r abb9ef8863c4 -r 7e6bffb32e40 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Wed Feb 13 13:37:29 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Wed Feb 13 14:13:46 2008 -0800 @@ -75,8 +75,9 @@ static CMPIStatus define_system_parse_ar goto out; } - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: return s; } @@ -373,7 +374,9 @@ static CMPIInstance *create_system(CMPII domain = calloc(1, sizeof(*domain)); if (domain == NULL) { - CMSetStatus(s, CMPI_RC_ERR_FAILED); + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Failed to allocate memory"); goto out; } @@ -492,7 +495,9 @@ static CMPIStatus destroy_system(CMPIMet rc.uint32 = IM_RC_OK; } else { rc.uint32 = IM_RC_FAILED; - CMSetStatus(&status, CMPI_RC_ERR_FAILED); + cu_statusf(_BROKER, &status, + CMPI_RC_ERR_FAILED, + "Domain already exists"); } virDomainFree(dom); trigger_indication(context, @@ -665,7 +670,9 @@ static CMPIStatus _resource_dynamic(stru if (!domain_online(dom)) { CU_DEBUG("VS `%s' not online; skipping dynamic update", dominfo->name); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); goto out; } @@ -676,7 +683,9 @@ static CMPIStatus _resource_dynamic(stru CMPI_RC_ERR_FAILED, "Unable to change (%i) device", action); } else { - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } out: virDomainFree(dom); @@ -769,7 +778,9 @@ static CMPIStatus resource_add(struct do list = realloc(*_list, ((*count)+1)*sizeof(struct virt_device)); if (list == NULL) { /* No memory */ - CMSetStatus(&s, CMPI_RC_ERR_FAILED); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to allocate memory"); goto out; } @@ -786,7 +797,9 @@ static CMPIStatus resource_add(struct do if (s.rc != CMPI_RC_OK) goto out; - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); (*count)++; out: @@ -1038,7 +1051,9 @@ static CMPIStatus rasd_refs_to_insts(con REF2STR(ref)); } - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); *ret_arr = tmp_arr; return s; @@ -1207,8 +1222,9 @@ CMPIStatus get_vsms(const CMPIObjectPath CMSetProperty(inst, "SystemCreationClassName", (CMPIValue *)ccname, CMPI_chars); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: virConnectClose(conn); *_inst = inst; @@ -1273,7 +1289,9 @@ static CMPIStatus GetInstance(CMPIInstan CMPI_RC_ERR_NOT_FOUND, "No such instance (%s)", prop); } else { - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); CMReturnInstance(results, inst); } From kaitlin at linux.vnet.ibm.com Fri Feb 15 00:23:34 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 14 Feb 2008 16:23:34 -0800 Subject: [Libvirt-cim] [PATCH] This changes any uses of CMSetStatus() to cu_statusf() In-Reply-To: <7e6bffb32e40c55323fe.1202941448@caffeine.beaverton.ibm.com> References: <7e6bffb32e40c55323fe.1202941448@caffeine.beaverton.ibm.com> Message-ID: <47B4DB86.1020600@linux.vnet.ibm.com> > virDomainFree(dom); > @@ -757,7 +762,9 @@ static CMPIStatus state_change(CMPIMetho > > ret = cu_get_u16_arg(argsin, "RequestedState", &state); > if (ret != CMPI_RC_OK) { > - CMSetStatus(&s, CMPI_RC_ERR_INVALID_PARAMETER); > + cu_statusf(_BROKER, &s, > + CMPI_RC_ERR_FAILED, > + "Invalid RequestedState"); The original RC was CMPI_RC_ERR_INVALID_PARAMETER, but you're setting it as CMPI_RC_ERR_FAILED. Sorry for the late review... -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Fri Feb 15 15:13:53 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 15 Feb 2008 07:13:53 -0800 Subject: [Libvirt-cim] [PATCH] (#2) This changes any uses of CMSetStatus() to cu_statusf() Message-ID: <72f9d41f72aaf7d0eb06.1203088433@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1203088430 28800 # Node ID 72f9d41f72aaf7d0eb06191f4170efdb9f490d9d # Parent ae2cfc5a6a853690af1fc6821b1767e383f0d24a (#2) This changes any uses of CMSetStatus() to cu_statusf() With new versions of GCC, the check for (s != NULL) in the macro sets off the "Address of `s' will always be true" warning. We don't want to turn that warning off, so this seems like the better choice Changes: - Fix broken error code Signed-off-by: Dan Smith diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_ComputerSystem.c Fri Feb 15 07:13:50 2008 -0800 @@ -440,7 +440,9 @@ static CMPIStatus return_enum_domains(co inst_list_init(&list); ret = enum_domains(_BROKER, conn, NAMESPACE(reference), &list); if (!ret) { - CMSetStatus(&s, CMPI_RC_ERR_FAILED); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to get domain list"); goto out; } @@ -449,8 +451,9 @@ static CMPIStatus return_enum_domains(co else cu_return_instances(results, &list); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: inst_list_free(&list); @@ -734,7 +737,9 @@ static CMPIStatus __state_change(const c else if (state == CIM_STATE_RESET) s = state_change_reset(dom, &info); else - CMSetStatus(&s, CMPI_RC_ERR_NOT_SUPPORTED); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_SUPPORTED, + "State not supported"); out: virDomainFree(dom); @@ -757,7 +762,9 @@ static CMPIStatus state_change(CMPIMetho ret = cu_get_u16_arg(argsin, "RequestedState", &state); if (ret != CMPI_RC_OK) { - CMSetStatus(&s, CMPI_RC_ERR_INVALID_PARAMETER); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Invalid RequestedState"); goto out; } diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_Device.c --- a/src/Virt_Device.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_Device.c Fri Feb 15 07:13:50 2008 -0800 @@ -371,7 +371,9 @@ static CMPIStatus enum_devices(const CMP inst_list_free(&list); out: - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); virConnectClose(conn); return s; diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_DevicePool.c Fri Feb 15 07:13:50 2008 -0800 @@ -795,7 +795,9 @@ static CMPIStatus return_pool(const CMPI &list); if (s.rc == CMPI_RC_OK) { __return_pool(results, &list, name_only); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_ElementAllocatedFromPool.c Fri Feb 15 07:13:50 2008 -0800 @@ -102,7 +102,9 @@ static CMPIStatus vdev_to_pool(const CMP pool = get_pool_by_id(_BROKER, conn, poolid, NAMESPACE(ref)); if (pool != NULL) { inst_list_add(list, pool); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -220,8 +222,9 @@ static CMPIStatus pool_to_vdev(const CMP devs_from_pool(type, ref, poolid, list); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: return s; } diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Fri Feb 15 07:13:50 2008 -0800 @@ -72,7 +72,9 @@ static CMPIStatus validate_caps_get_serv s = get_migration_service(ref, &_inst, _BROKER); } else - CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "Not found"); *inst = _inst; out: @@ -103,7 +105,9 @@ static CMPIStatus validate_service_get_c s = get_migration_caps(ref, &_inst, _BROKER); } else - CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + ""); *inst = _inst; diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_HostedDependency.c Fri Feb 15 07:13:50 2008 -0800 @@ -70,14 +70,18 @@ static CMPIStatus host_to_vs(const CMPIO ret = enum_domains(_BROKER, conn, NAMESPACE(ref), list); if (ret) { - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Failed to get domain list"); } - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); return s; } diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_HostedResourcePool.c Fri Feb 15 07:13:50 2008 -0800 @@ -87,7 +87,9 @@ static CMPIStatus sys_to_pool(const CMPI NAMESPACE(ref), list); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); return s; } diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_RegisteredProfile.c --- a/src/Virt_RegisteredProfile.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_RegisteredProfile.c Fri Feb 15 07:13:50 2008 -0800 @@ -162,7 +162,9 @@ static CMPIStatus get_prof(const CMPIObj if(instance) CMReturnInstance(results, instance); else - CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "Profile instance not found"); out: virConnectClose(conn); diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_ResourceAllocationFromPool.c Fri Feb 15 07:13:50 2008 -0800 @@ -112,7 +112,9 @@ static CMPIStatus rasd_to_pool(const CMP NAMESPACE(ref)); if (pool != NULL) { inst_list_add(list, pool); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -237,8 +239,9 @@ static CMPIStatus pool_to_rasd(const CMP poolid, list); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: return s; } diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_SettingsDefineState.c Fri Feb 15 07:13:50 2008 -0800 @@ -104,8 +104,9 @@ static CMPIStatus dev_to_rasd(const CMPI if (rasd != NULL) inst_list_add(list, rasd); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: free(name); free(devid); @@ -184,8 +185,9 @@ static CMPIStatus rasd_to_dev(const CMPI inst_list_add(list, dev); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: return s; } @@ -226,8 +228,9 @@ static CMPIStatus vs_to_vssd(const CMPIO if (vssd != NULL) inst_list_add(list, vssd); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: virDomainFree(dom); virConnectClose(conn); @@ -277,8 +280,9 @@ static CMPIStatus vssd_to_vs(const CMPIO if (cs != NULL) inst_list_add(list, cs); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: free(name); free(pfx); diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_SystemDevice.c --- a/src/Virt_SystemDevice.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_SystemDevice.c Fri Feb 15 07:13:50 2008 -0800 @@ -157,7 +157,9 @@ static CMPIStatus sys_to_dev(const CMPIO NAMESPACE(ref)); if (ret >= 0) { - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -208,7 +210,9 @@ static CMPIStatus dev_to_sys(const CMPIO "Unable to find DeviceID `%s'", devid); else { inst_list_add(list, sys); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } out: diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VSMigrationCapabilities.c --- a/src/Virt_VSMigrationCapabilities.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_VSMigrationCapabilities.c Fri Feb 15 07:13:50 2008 -0800 @@ -73,8 +73,9 @@ static CMPIStatus set_method_properties( CMSetProperty(inst, "SynchronousMethodsSupported", (CMPIValue *)&array, CMPI_uint16A); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); return s; } diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_VSMigrationService.c Fri Feb 15 07:13:50 2008 -0800 @@ -114,7 +114,9 @@ static CMPIStatus check_hver(virConnectP if (remote >= local) { CU_DEBUG("Version check OK (%lu >= %lu)", remote, local); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } else { CU_DEBUG("Version check FAILED (%lu < %lu)", remote, local); cu_statusf(_BROKER, &s, @@ -123,8 +125,9 @@ static CMPIStatus check_hver(virConnectP remote, local); } - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: return s; } @@ -172,8 +175,9 @@ static CMPIStatus vs_migratable(const CM goto out; retcode = 0; - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); @@ -432,8 +436,9 @@ static CMPIStatus migrate_vs(struct migr } CU_DEBUG("Migration succeeded"); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: free(uri); virDomainFree(dom); @@ -788,8 +793,10 @@ CMPIStatus get_migration_service(const C CMSetProperty(inst, "SystemCreationClassName", (CMPIValue *)ccname, CMPI_chars); - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); + *_inst = inst; out: diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VSMigrationSettingData.c --- a/src/Virt_VSMigrationSettingData.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_VSMigrationSettingData.c Fri Feb 15 07:13:50 2008 -0800 @@ -47,7 +47,9 @@ static CMPIStatus set_properties(const C (CMPIValue *)&priority, CMPI_uint16); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(broker, &s, + CMPI_RC_OK, + ""); return s; } diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VSSD.c --- a/src/Virt_VSSD.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_VSSD.c Fri Feb 15 07:13:50 2008 -0800 @@ -182,7 +182,9 @@ static CMPIStatus enum_vssd(const CMPIOb "Failed to enumerate domains"); goto out; } else if (count == 0) { - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); goto out; } @@ -200,7 +202,9 @@ static CMPIStatus enum_vssd(const CMPIOb CMReturnInstance(results, inst); } - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: free(list); @@ -271,7 +275,9 @@ static CMPIStatus GetInstance(CMPIInstan if (inst) CMReturnInstance(results, inst); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); free(locid); diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_VSSDComponent.c Fri Feb 15 07:13:50 2008 -0800 @@ -69,8 +69,9 @@ static CMPIStatus vssd_to_rasd(const CMP list); } - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: free(name); @@ -103,8 +104,9 @@ static CMPIStatus vssd_for_name(const ch CMPI_RC_ERR_FAILED, "Error getting VSSD for `%s'", host); else - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: virDomainFree(dom); virConnectClose(conn); diff -r ae2cfc5a6a85 -r 72f9d41f72aa src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Wed Feb 13 08:16:37 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Fri Feb 15 07:13:50 2008 -0800 @@ -75,8 +75,9 @@ static CMPIStatus define_system_parse_ar goto out; } - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: return s; } @@ -373,7 +374,9 @@ static CMPIInstance *create_system(CMPII domain = calloc(1, sizeof(*domain)); if (domain == NULL) { - CMSetStatus(s, CMPI_RC_ERR_FAILED); + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Failed to allocate memory"); goto out; } @@ -492,7 +495,9 @@ static CMPIStatus destroy_system(CMPIMet rc.uint32 = IM_RC_OK; } else { rc.uint32 = IM_RC_FAILED; - CMSetStatus(&status, CMPI_RC_ERR_FAILED); + cu_statusf(_BROKER, &status, + CMPI_RC_ERR_FAILED, + "Domain already exists"); } virDomainFree(dom); trigger_indication(context, @@ -665,7 +670,9 @@ static CMPIStatus _resource_dynamic(stru if (!domain_online(dom)) { CU_DEBUG("VS `%s' not online; skipping dynamic update", dominfo->name); - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); goto out; } @@ -676,7 +683,9 @@ static CMPIStatus _resource_dynamic(stru CMPI_RC_ERR_FAILED, "Unable to change (%i) device", action); } else { - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); } out: virDomainFree(dom); @@ -769,7 +778,9 @@ static CMPIStatus resource_add(struct do list = realloc(*_list, ((*count)+1)*sizeof(struct virt_device)); if (list == NULL) { /* No memory */ - CMSetStatus(&s, CMPI_RC_ERR_FAILED); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to allocate memory"); goto out; } @@ -786,7 +797,9 @@ static CMPIStatus resource_add(struct do if (s.rc != CMPI_RC_OK) goto out; - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); (*count)++; out: @@ -1038,7 +1051,9 @@ static CMPIStatus rasd_refs_to_insts(con REF2STR(ref)); } - CMSetStatus(&s, CMPI_RC_OK); + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); *ret_arr = tmp_arr; return s; @@ -1220,8 +1235,9 @@ CMPIStatus get_vsms(const CMPIObjectPath goto out; } - CMSetStatus(&s, CMPI_RC_OK); - + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); out: virConnectClose(conn); *_inst = inst; From kaitlin at linux.vnet.ibm.com Fri Feb 15 18:14:23 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 15 Feb 2008 10:14:23 -0800 Subject: [Libvirt-cim] [PATCH] (#2) This changes any uses of CMSetStatus() to cu_statusf() In-Reply-To: <72f9d41f72aaf7d0eb06.1203088433@caffeine.beaverton.ibm.com> References: <72f9d41f72aaf7d0eb06.1203088433@caffeine.beaverton.ibm.com> Message-ID: <47B5D67F.9060402@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1203088430 28800 > # Node ID 72f9d41f72aaf7d0eb06191f4170efdb9f490d9d > # Parent ae2cfc5a6a853690af1fc6821b1767e383f0d24a > (#2) This changes any uses of CMSetStatus() to cu_statusf() > > With new versions of GCC, the check for (s != NULL) in the macro sets off > the "Address of `s' will always be true" warning. We don't want to turn > that warning off, so this seems like the better choice > > Changes: > - Fix broken error code > This looks good +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Fri Feb 15 19:44:06 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 15 Feb 2008 11:44:06 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] Add reference validation to get_vsm_cap(). Message-ID: Have get_vsm_cap() validate references. Also update providers that call get_vsm_cap(). From kaitlin at linux.vnet.ibm.com Fri Feb 15 19:44:07 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 15 Feb 2008 11:44:07 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add reference validation to get_vsm_cap() In-Reply-To: Message-ID: <485d129ffabd639f7d28.1203104647@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1203104501 28800 # Node ID 485d129ffabd639f7d28f29584065550dba4a267 # Parent 6792d7ab0cc36e99d95b6b8afd50fec887334007 Add reference validation to get_vsm_cap(). Adds reference validation to VirtualSystemManagementCapabilities. Also change names_only of return_vsm_cap() from an int to a bool. Signed-off-by: Kaitlin Rupert diff -r 6792d7ab0cc3 -r 485d129ffabd src/Virt_VirtualSystemManagementCapabilities.c --- a/src/Virt_VirtualSystemManagementCapabilities.c Fri Feb 15 09:57:43 2008 -0800 +++ b/src/Virt_VirtualSystemManagementCapabilities.c Fri Feb 15 11:41:41 2008 -0800 @@ -83,11 +83,22 @@ static CMPIStatus set_inst_properties(co CMPIStatus get_vsm_cap(const CMPIBroker *broker, const CMPIObjectPath *ref, - CMPIInstance **inst) + CMPIInstance **inst, + bool is_get_inst) { CMPIStatus s; CMPIObjectPath *op; + virConnectPtr conn = NULL; char *classname = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } classname = get_typed_class(CLASSNAME(ref), "VirtualSystemManagementCapabilities"); @@ -116,26 +127,29 @@ CMPIStatus get_vsm_cap(const CMPIBroker s = set_inst_properties(broker, *inst, classname); + if (is_get_inst) { + s = cu_validate_ref(broker, ref, *inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + out: free(classname); + virConnectClose(conn); return s; } static CMPIStatus return_vsm_cap(const CMPIObjectPath *ref, const CMPIResult *results, - int names_only) + bool names_only, + bool is_get_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; - virConnectPtr conn = NULL; - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - s = get_vsm_cap(_BROKER, ref, &inst); - if (s.rc != CMPI_RC_OK) + + s = get_vsm_cap(_BROKER, ref, &inst, is_get_inst); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) goto out; if (names_only) @@ -143,8 +157,6 @@ static CMPIStatus return_vsm_cap(const C else CMReturnInstance(results, inst); out: - virConnectClose(conn); - return s; } @@ -153,7 +165,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_vsm_cap(reference, results, 1); + return return_vsm_cap(reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -163,7 +175,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_vsm_cap(reference, results, 0); + return return_vsm_cap(reference, results, true, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -172,24 +184,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - CMPIInstance *inst; - CMPIStatus s; - const char *prop; - - s = get_vsm_cap(_BROKER, reference, &inst); - if (s.rc != CMPI_RC_OK) - return s; - - prop = cu_compare_ref(reference, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } else { - CMReturnInstance(results, inst); - } - - return s; + return return_vsm_cap(reference, results, false, true); } DEFAULT_CI(); diff -r 6792d7ab0cc3 -r 485d129ffabd src/Virt_VirtualSystemManagementCapabilities.h --- a/src/Virt_VirtualSystemManagementCapabilities.h Fri Feb 15 09:57:43 2008 -0800 +++ b/src/Virt_VirtualSystemManagementCapabilities.h Fri Feb 15 11:41:41 2008 -0800 @@ -20,7 +20,8 @@ */ CMPIStatus get_vsm_cap(const CMPIBroker *broker, const CMPIObjectPath *ref, - CMPIInstance **inst); + CMPIInstance **inst, + bool is_get_inst); /* * Local Variables: * mode: C From kaitlin at linux.vnet.ibm.com Fri Feb 15 19:44:08 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 15 Feb 2008 11:44:08 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Update calls to get_vsm_cap() to use new param In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1203104631 28800 # Node ID fa322bc4b62e52fd6afafa93bc933860c714f2af # Parent 485d129ffabd639f7d28f29584065550dba4a267 Update calls to get_vsm_cap() to use new param. This param indicates whether the reference should be validated, or if an instance (without ref validation) should be returned. Signed-off-by: Kaitlin Rupert diff -r 485d129ffabd -r fa322bc4b62e src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Fri Feb 15 11:41:41 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Fri Feb 15 11:43:51 2008 -0800 @@ -60,7 +60,7 @@ static CMPIStatus validate_caps_get_serv classname = class_base_name(CLASSNAME(ref)); if (STREQC(classname, "VirtualSystemManagementCapabilities")) { - s = get_vsm_cap(_BROKER, ref, &_inst); + s = get_vsm_cap(_BROKER, ref, &_inst, true); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; @@ -97,7 +97,7 @@ static CMPIStatus validate_service_get_c if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; - s = get_vsm_cap(_BROKER, ref, &_inst); + s = get_vsm_cap(_BROKER, ref, &_inst, false); } else if (STREQC(classname, "VirtualSystemMigrationService")) { s = get_migration_service(ref, &_inst, _BROKER); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) @@ -131,7 +131,7 @@ static CMPIStatus sys_to_cap(const CMPIO if (s.rc != CMPI_RC_OK) goto out; - s = get_vsm_cap(_BROKER, ref, &inst); + s = get_vsm_cap(_BROKER, ref, &inst, false); if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); From kaitlin at linux.vnet.ibm.com Fri Feb 15 21:35:54 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 15 Feb 2008 13:35:54 -0800 Subject: [Libvirt-cim] [PATCH] Update cu_statusf() in get_vsms() Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1203111331 28800 # Node ID cbe6502dfe7f201fa09fd2d3d105babb1c62e573 # Parent 6792d7ab0cc36e99d95b6b8afd50fec887334007 Update cu_statusf() in get_vsms(). Use broker local to function instead of the broker belonging to the provider. Signed-off-by: Kaitlin Rupert diff -r 6792d7ab0cc3 -r cbe6502dfe7f src/Virt_VSMigrationCapabilities.c --- a/src/Virt_VSMigrationCapabilities.c Fri Feb 15 09:57:43 2008 -0800 +++ b/src/Virt_VSMigrationCapabilities.c Fri Feb 15 13:35:31 2008 -0800 @@ -73,7 +73,7 @@ static CMPIStatus set_method_properties( CMSetProperty(inst, "SynchronousMethodsSupported", (CMPIValue *)&array, CMPI_uint16A); - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_OK, ""); return s; diff -r 6792d7ab0cc3 -r cbe6502dfe7f src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Fri Feb 15 09:57:43 2008 -0800 +++ b/src/Virt_VSMigrationService.c Fri Feb 15 13:35:31 2008 -0800 @@ -793,7 +793,7 @@ CMPIStatus get_migration_service(const C CMSetProperty(inst, "SystemCreationClassName", (CMPIValue *)ccname, CMPI_chars); - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_OK, ""); diff -r 6792d7ab0cc3 -r cbe6502dfe7f src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Fri Feb 15 09:57:43 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Fri Feb 15 13:35:31 2008 -0800 @@ -1235,7 +1235,7 @@ CMPIStatus get_vsms(const CMPIObjectPath goto out; } - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_OK, ""); out: From kaitlin at linux.vnet.ibm.com Sat Feb 16 00:59:48 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 15 Feb 2008 16:59:48 -0800 Subject: [Libvirt-cim] [PATCH 2 of 4] Update calls to get_migration_service() to use new param In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1203123478 28800 # Node ID fe50fd4e9cfa5b858c9c5c6ce312031ca9af7dee # Parent 9b93bc85520bc6a9cb486066e83acd8af2432c6a Update calls to get_migration_service() to use new param. This param indicates whether the reference should be validated, or if an instance (without ref validation) should be returned. Signed-off-by: Kaitlin Rupert diff -r 9b93bc85520b -r fe50fd4e9cfa src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Fri Feb 15 16:56:21 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Fri Feb 15 16:57:58 2008 -0800 @@ -70,12 +70,16 @@ static CMPIStatus validate_caps_get_serv if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; - s = get_migration_service(ref, &_inst, _BROKER); + s = get_migration_service(ref, &_inst, _BROKER, false); } else cu_statusf(_BROKER, &s, CMPI_RC_ERR_NOT_FOUND, "Not found"); + + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) + goto out; + *inst = _inst; out: free(classname); @@ -99,7 +103,7 @@ static CMPIStatus validate_service_get_c s = get_vsm_cap(_BROKER, ref, &_inst, false); } else if (STREQC(classname, "VirtualSystemMigrationService")) { - s = get_migration_service(ref, &_inst, _BROKER); + s = get_migration_service(ref, &_inst, _BROKER, true); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; diff -r 9b93bc85520b -r fe50fd4e9cfa src/Virt_HostedService.c --- a/src/Virt_HostedService.c Fri Feb 15 16:56:21 2008 -0800 +++ b/src/Virt_HostedService.c Fri Feb 15 16:57:58 2008 -0800 @@ -51,7 +51,7 @@ static CMPIStatus validate_service_ref(c } else if (STREQC(classname, "ResourcePoolConfigurationService")) { s = get_rpcs(ref, &inst, _BROKER, true); } else if (STREQC(classname, "VirtualSystemMigrationService")) { - s = get_migration_service(ref, &inst, _BROKER); + s = get_migration_service(ref, &inst, _BROKER, true); } if (s.rc != CMPI_RC_OK) @@ -117,7 +117,7 @@ static CMPIStatus host_to_service(const if (!CMIsNullObject(inst)) inst_list_add(list, inst); - s = get_migration_service(ref, &inst, _BROKER); + s = get_migration_service(ref, &inst, _BROKER, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) diff -r 9b93bc85520b -r fe50fd4e9cfa src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Fri Feb 15 16:56:21 2008 -0800 +++ b/src/Virt_VSMigrationService.c Fri Feb 15 16:57:58 2008 -0800 @@ -847,7 +847,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *ref) { - return return_vsms(ref, results, true, false, false); + return return_vsms(ref, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -857,7 +857,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_vsms(ref, results, false, false, false); + return return_vsms(ref, results, false, false); } @@ -867,7 +867,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *ref, const char **properties) { - return return_vsms(ref, results, false, true, true); + return return_vsms(ref, results, false, true); } DEFAULT_CI(); From kaitlin at linux.vnet.ibm.com Sat Feb 16 00:59:49 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 15 Feb 2008 16:59:49 -0800 Subject: [Libvirt-cim] [PATCH 3 of 4] Add support for ref checking to VSMigrationCapabilities In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1203123517 28800 # Node ID f074335959a5eebb4b1a6300f421fbc2a94e3f2a # Parent fe50fd4e9cfa5b858c9c5c6ce312031ca9af7dee Add support for ref checking to VSMigrationCapabilities. Signed-off-by: Kaitlin Rupert diff -r fe50fd4e9cfa -r f074335959a5 src/Virt_VSMigrationCapabilities.c --- a/src/Virt_VSMigrationCapabilities.c Fri Feb 15 16:57:58 2008 -0800 +++ b/src/Virt_VSMigrationCapabilities.c Fri Feb 15 16:58:37 2008 -0800 @@ -81,10 +81,21 @@ static CMPIStatus set_method_properties( CMPIStatus get_migration_caps(const CMPIObjectPath *ref, CMPIInstance **_inst, - const CMPIBroker *broker) + const CMPIBroker *broker, + bool is_get_inst) { CMPIInstance *inst; CMPIStatus s; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } inst = get_typed_instance(broker, CLASSNAME(ref), @@ -102,28 +113,42 @@ CMPIStatus get_migration_caps(const CMPI s = set_method_properties(broker, inst); - if (s.rc == CMPI_RC_OK) - *_inst = inst; + if (s.rc != CMPI_RC_OK) + goto out; + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + + out: + + virConnectClose(conn); return s; } static CMPIStatus return_vsmc(const CMPIObjectPath *ref, const CMPIResult *results, - bool name_only) + bool name_only, + bool is_get_inst) { CMPIInstance *inst; CMPIStatus s; - s = get_migration_caps(ref, &inst, _BROKER); - - if (s.rc == CMPI_RC_OK) { - if (name_only) - cu_return_instance_name(results, inst); - else - CMReturnInstance(results, inst); - } - + s = get_migration_caps(ref, &inst, _BROKER, is_get_inst); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + goto out; + + if (name_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + + out: return s; } @@ -132,7 +157,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *ref) { - return return_vsmc(ref, results, true); + return return_vsmc(ref, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -142,7 +167,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_vsmc(ref, results, false); + return return_vsmc(ref, results, false, false); } @@ -152,24 +177,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *ref, const char **properties) { - CMPIInstance *inst; - CMPIStatus s; - const char *prop; - - s = get_migration_caps(ref, &inst, _BROKER); - if (s.rc != CMPI_RC_OK) - return s; - - prop = cu_compare_ref(ref, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } else { - CMReturnInstance(results, inst); - } - - return s; + return return_vsmc(ref, results, false, true); } DEFAULT_CI(); diff -r fe50fd4e9cfa -r f074335959a5 src/Virt_VSMigrationCapabilities.h --- a/src/Virt_VSMigrationCapabilities.h Fri Feb 15 16:57:58 2008 -0800 +++ b/src/Virt_VSMigrationCapabilities.h Fri Feb 15 16:58:37 2008 -0800 @@ -21,7 +21,8 @@ CMPIStatus get_migration_caps(const CMPIObjectPath *reference, CMPIInstance **_inst, - const CMPIBroker *broker); + const CMPIBroker *broker, + bool is_get_inst); /* * Local Variables: From kaitlin at linux.vnet.ibm.com Sat Feb 16 00:59:47 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 15 Feb 2008 16:59:47 -0800 Subject: [Libvirt-cim] [PATCH 1 of 4] Add reference validation to get_migration_service() In-Reply-To: Message-ID: <9b93bc85520bc6a9cb48.1203123587@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1203123381 28800 # Node ID 9b93bc85520bc6a9cb486066e83acd8af2432c6a # Parent db0f626f74052bc78be3d62e9b530f6af6d7ae3b Add reference validation to get_migration_service(). Adds reference validation to VirtualSystemMigrationService. Signed-off-by: Kaitlin Rupert diff -r db0f626f7405 -r 9b93bc85520b src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Fri Feb 15 13:50:26 2008 -0800 +++ b/src/Virt_VSMigrationService.c Fri Feb 15 16:56:21 2008 -0800 @@ -755,12 +755,23 @@ STDIM_MethodMIStub(, Virt_VSMigrationSer CMPIStatus get_migration_service(const CMPIObjectPath *ref, CMPIInstance **_inst, - const CMPIBroker *broker) + const CMPIBroker *broker, + bool is_get_inst) { CMPIInstance *inst; CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; const char *name = NULL; const char *ccname = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } inst = get_typed_instance(broker, CLASSNAME(ref), @@ -793,6 +804,12 @@ CMPIStatus get_migration_service(const C CMSetProperty(inst, "SystemCreationClassName", (CMPIValue *)ccname, CMPI_chars); + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + cu_statusf(broker, &s, CMPI_RC_OK, ""); @@ -800,24 +817,28 @@ CMPIStatus get_migration_service(const C *_inst = inst; out: + virConnectClose(conn); + return s; } static CMPIStatus return_vsms(const CMPIObjectPath *ref, const CMPIResult *results, - bool name_only) + bool name_only, + bool is_get_inst) { CMPIInstance *inst; CMPIStatus s; - s = get_migration_service(ref, &inst, _BROKER); - if (s.rc == CMPI_RC_OK) { - if (name_only) - cu_return_instance_name(results, inst); - else - CMReturnInstance(results, inst); - } - + s = get_migration_service(ref, &inst, _BROKER, is_get_inst); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + goto out; + + if (name_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + out: return s; } @@ -826,7 +847,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *ref) { - return return_vsms(ref, results, true); + return return_vsms(ref, results, true, false, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -836,7 +857,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_vsms(ref, results, false); + return return_vsms(ref, results, false, false, false); } @@ -846,24 +867,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *ref, const char **properties) { - CMPIInstance *inst; - CMPIStatus s; - const char *prop; - - s = get_migration_service(ref, &inst, _BROKER); - if (s.rc != CMPI_RC_OK) - return s; - - prop = cu_compare_ref(ref, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } else { - CMReturnInstance(results, inst); - } - - return s; + return return_vsms(ref, results, false, true, true); } DEFAULT_CI(); diff -r db0f626f7405 -r 9b93bc85520b src/Virt_VSMigrationService.h --- a/src/Virt_VSMigrationService.h Fri Feb 15 13:50:26 2008 -0800 +++ b/src/Virt_VSMigrationService.h Fri Feb 15 16:56:21 2008 -0800 @@ -21,7 +21,8 @@ CMPIStatus get_migration_service(const CMPIObjectPath *reference, CMPIInstance **_inst, - const CMPIBroker *broker); + const CMPIBroker *broker, + bool is_get_inst); /* * Local Variables: From kaitlin at linux.vnet.ibm.com Sat Feb 16 00:59:46 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 15 Feb 2008 16:59:46 -0800 Subject: [Libvirt-cim] [PATCH 0 of 4] Add reference validation to VSMigrationService and VSMigrateCap. Message-ID: More reference validation updates. This patch set is dependant on the get_vsm_cap() reference validation set. From kaitlin at linux.vnet.ibm.com Sat Feb 16 00:59:50 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 15 Feb 2008 16:59:50 -0800 Subject: [Libvirt-cim] [PATCH 4 of 4] Update the get_migration_caps() calls to include new param In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1203123548 28800 # Node ID c7b46732e06984c108bf4991e9f216ba60cffd67 # Parent f074335959a5eebb4b1a6300f421fbc2a94e3f2a Update the get_migration_caps() calls to include new param. This extra param indicates that the reference need to be validated. Signed-off-by: Kaitlin Rupert diff -r f074335959a5 -r c7b46732e069 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Fri Feb 15 16:58:37 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Fri Feb 15 16:59:08 2008 -0800 @@ -66,7 +66,7 @@ static CMPIStatus validate_caps_get_serv s = get_vsms(ref, &_inst, _BROKER, false); } else if (STREQC(classname, "VirtualSystemMigrationCapabilities")) { - s = get_migration_caps(ref, &_inst, _BROKER); + s = get_migration_caps(ref, &_inst, _BROKER, true); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; @@ -107,7 +107,7 @@ static CMPIStatus validate_service_get_c if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; - s = get_migration_caps(ref, &_inst, _BROKER); + s = get_migration_caps(ref, &_inst, _BROKER, false); } else cu_statusf(_BROKER, &s, CMPI_RC_ERR_NOT_FOUND, @@ -139,7 +139,7 @@ static CMPIStatus sys_to_cap(const CMPIO if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); - s = get_migration_caps(ref, &inst, _BROKER); + s = get_migration_caps(ref, &inst, _BROKER, false); if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); From kaitlin at linux.vnet.ibm.com Sat Feb 16 01:02:11 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 15 Feb 2008 17:02:11 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] Add VSMigrationSettingData support to SettingsDefineState In-Reply-To: <47AABC85.6030504@linux.vnet.ibm.com> References: <47A9830E.8020900@linux.vnet.ibm.com> <47A9DECE.7050805@linux.vnet.ibm.com> <47AABC85.6030504@linux.vnet.ibm.com> Message-ID: <47B63613.7040204@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> Heidi Eckhart wrote: >>> Kaitlin Rupert wrote: >>>> Per the VirtualSystemMigration Profile, there needs to be a >>>> SettingsDefineCapabilities association between >>>> VSMigrationCapabilities and VSMigrationSettingData. >>>> >>>> >>> Only one comment ... great work :) ... +1 >>> >> >> The only comment was regarding the name change for the superclass >> Virt_VirtualSystemMigrationCapabilities to CIM_, right? >> >> If so, I'll fix that (and the VirtualSystemMigrationCapabilities >> reference checking) in a separate patch. >> >> Thanks! >> > Yes, thank you :) ! > I haven't forgotten about this fix. I'll send the fix out once the current reference validation patches are approved. =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From heidieck at linux.vnet.ibm.com Mon Feb 18 13:33:18 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 18 Feb 2008 14:33:18 +0100 Subject: [Libvirt-cim] [PATCH 0 of 4] Add reference validation to VSMigrationService and VSMigrateCap. In-Reply-To: References: Message-ID: <47B9891E.7080108@linux.vnet.ibm.com> Kaitlin Rupert wrote: > More reference validation updates. > > This patch set is dependant on the get_vsm_cap() reference validation set. > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > I applied patch set "Add reference validation to get_vsm_cap()." and this one and run into the following problems: wbemein http://localhost/root/virt:Virt_VirtualSystemMigrationCapabilities is seg faulting sfcb with misc_util.c(74): Unable to connect to `xen' -#- Virt_VSMigrationCapabilities - 29723 provider exiting due to a SIGSEGV signal wbemein http://localhost/root/virt:CIM_VirtualSystemMigrationService is hanging sfcb misc_util.c(74): Unable to connect to `xen' -#- Virt_VSMigrationService - 29631 provider exiting due to a SIGSEGV signal -#- Serious provider id / provider process mismatch --- terminating process. Did I miss some patch to apply ? -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From danms at us.ibm.com Mon Feb 18 16:48:09 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 18 Feb 2008 08:48:09 -0800 Subject: [Libvirt-cim] [PATCH 0 of 4] Add reference validation to VSMigrationService and VSMigrateCap. In-Reply-To: <47B9891E.7080108@linux.vnet.ibm.com> (Heidi Eckhart's message of "Mon, 18 Feb 2008 14:33:18 +0100") References: <47B9891E.7080108@linux.vnet.ibm.com> Message-ID: <873arqfbxy.fsf@caffeine.beaverton.ibm.com> HE> is seg faulting sfcb with HE> misc_util.c(74): Unable to connect to `xen' HE> -#- Virt_VSMigrationCapabilities - 29723 provider exiting due to a HE> SIGSEGV signal I don't see a segfault on SFCB. It returns the VSMCaps object as expected, for both Xen and KVM. If I stop xend, I just get a KVM object back (as expected), and no crash. HE> is hanging sfcb HE> misc_util.c(74): Unable to connect to `xen' HE> -#- Virt_VSMigrationService - 29631 provider exiting due to a SIGSEGV signal HE> -#- Serious provider id / provider process mismatch --- terminating process. I don't see this hang either. The providers return the expected result. Perhaps you have an old version of libcmpiutil, or just need to reinstall all the providers cleanly? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Mon Feb 18 16:59:53 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 18 Feb 2008 08:59:53 -0800 Subject: [Libvirt-cim] [PATCH 0 of 4] Add reference validation to VSMigrationService and VSMigrateCap. In-Reply-To: <873arqfbxy.fsf@caffeine.beaverton.ibm.com> References: <47B9891E.7080108@linux.vnet.ibm.com> <873arqfbxy.fsf@caffeine.beaverton.ibm.com> Message-ID: <47B9B989.6000905@linux.vnet.ibm.com> Dan Smith wrote: > HE> is seg faulting sfcb with > HE> misc_util.c(74): Unable to connect to `xen' > HE> -#- Virt_VSMigrationCapabilities - 29723 provider exiting due to a > HE> SIGSEGV signal > > I don't see a segfault on SFCB. It returns the VSMCaps object as > expected, for both Xen and KVM. If I stop xend, I just get a KVM > object back (as expected), and no crash. I did see a segfault once using Pegasus just now. I'm wondering if this is related to a race condition with libvirt. Does this query segfault for you every time? > > HE> is hanging sfcb > HE> misc_util.c(74): Unable to connect to `xen' > HE> -#- Virt_VSMigrationService - 29631 provider exiting due to a SIGSEGV signal > HE> -#- Serious provider id / provider process mismatch --- terminating process. > > I don't see this hang either. The providers return the expected > result. > > Perhaps you have an old version of libcmpiutil, or just need to > reinstall all the providers cleanly? -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Mon Feb 18 22:27:06 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 18 Feb 2008 14:27:06 -0800 Subject: [Libvirt-cim] [PATCH] Add Enumeration support to RASD Message-ID: <4618b355bc157e201cec.1203373626@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1203373617 28800 # Node ID 4618b355bc157e201cec22d5eeb8e265e3a84fd6 # Parent 7b5611c03994d1568ba69560f5afad284df06bd0 Add Enumeration support to RASD Supports enumerating a specific RASD type, as well as the parent classes KVM_RASD, Xen_RASD, as well as CIM_RASD. Signed-off-by: Dan Smith diff -r 7b5611c03994 -r 4618b355bc15 src/Virt_RASD.c --- a/src/Virt_RASD.c Fri Feb 15 13:35:31 2008 -0800 +++ b/src/Virt_RASD.c Mon Feb 18 14:26:57 2008 -0800 @@ -34,6 +34,7 @@ #include "device_parsing.h" #include "misc_util.h" +#include "cs_util.h" #include "Virt_RASD.h" #include "svpc_types.h" @@ -442,6 +443,100 @@ CMPIrc rasd_classname_from_type(uint16_t return rc; } +static CMPIStatus _enum_rasds(const CMPIObjectPath *ref, + struct inst_list *list) +{ + virConnectPtr conn = NULL; + virDomainPtr *domains = NULL; + int count; + int i, j; + uint16_t type; + CMPIStatus s; + uint16_t types[] = {CIM_RASD_TYPE_PROC, + CIM_RASD_TYPE_DISK, + CIM_RASD_TYPE_NET, + CIM_RASD_TYPE_MEM, + 0}; + + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) + return s; + + count = get_domain_list(conn, &domains); + if (count <= 0) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get domain list"); + goto out; + } + + if (rasd_type_from_classname(CLASSNAME(ref), &type) == CMPI_RC_OK) { + types[0] = type; + types[1] = 0; + } + + for (i = 0; i < count; i++) { + for (j = 0; types[j] != 0; j++) { + printf("Doing RASD type %i for %s\n", + type, virDomainGetName(domains[i])); + rasds_for_domain(_BROKER, + virDomainGetName(domains[i]), + types[j], + ref, + list); + } + virDomainFree(domains[i]); + } + + s = (CMPIStatus){CMPI_RC_OK, NULL}; + + out: + virConnectClose(conn); + free(domains); + + return s; +} + +static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref, + const CMPIResult *results, + const bool names_only) +{ + struct inst_list list; + CMPIStatus s; + + inst_list_init(&list); + + s = _enum_rasds(ref, &list); + if (s.rc == CMPI_RC_OK) { + if (names_only) + cu_return_instance_names(results, &list); + else + cu_return_instances(results, &list); + } + + inst_list_free(&list); + + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference) +{ + return return_enum_rasds(reference, results, true); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + + return return_enum_rasds(reference, results, false); +} + static CMPIStatus GetInstance(CMPIInstanceMI *self, const CMPIContext *context, const CMPIResult *results, @@ -516,8 +611,6 @@ DEFAULT_CI(); DEFAULT_CI(); DEFAULT_MI(); DEFAULT_DI(); -DEFAULT_EI(); -DEFAULT_EIN(); DEFAULT_INST_CLEANUP(); DEFAULT_EQ(); From danms at us.ibm.com Mon Feb 18 22:32:45 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 18 Feb 2008 14:32:45 -0800 Subject: [Libvirt-cim] [PATCH] (#2) Add Enumeration support to RASD Message-ID: # HG changeset patch # User Dan Smith # Date 1203373962 28800 # Node ID c118dc77598088e3bd866df48787e5999aeb9d10 # Parent 7b5611c03994d1568ba69560f5afad284df06bd0 (#2) Add Enumeration support to RASD Supports enumerating a specific RASD type, as well as the parent classes KVM_RASD, Xen_RASD, as well as CIM_RASD. Changes: - Remove printf() in place of a CU_DEBUG() (before Kaitlin got a chance to complain, I'll have you know) Signed-off-by: Dan Smith diff -r 7b5611c03994 -r c118dc775980 src/Virt_RASD.c --- a/src/Virt_RASD.c Fri Feb 15 13:35:31 2008 -0800 +++ b/src/Virt_RASD.c Mon Feb 18 14:32:42 2008 -0800 @@ -34,6 +34,7 @@ #include "device_parsing.h" #include "misc_util.h" +#include "cs_util.h" #include "Virt_RASD.h" #include "svpc_types.h" @@ -442,6 +443,100 @@ CMPIrc rasd_classname_from_type(uint16_t return rc; } +static CMPIStatus _enum_rasds(const CMPIObjectPath *ref, + struct inst_list *list) +{ + virConnectPtr conn = NULL; + virDomainPtr *domains = NULL; + int count; + int i, j; + uint16_t type; + CMPIStatus s; + uint16_t types[] = {CIM_RASD_TYPE_PROC, + CIM_RASD_TYPE_DISK, + CIM_RASD_TYPE_NET, + CIM_RASD_TYPE_MEM, + 0}; + + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) + return s; + + count = get_domain_list(conn, &domains); + if (count <= 0) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get domain list"); + goto out; + } + + if (rasd_type_from_classname(CLASSNAME(ref), &type) == CMPI_RC_OK) { + types[0] = type; + types[1] = 0; + } + + for (i = 0; i < count; i++) { + for (j = 0; types[j] != 0; j++) { + CU_DEBUG(("Doing RASD type %i for %s", + type, virDomainGetName(domains[i])); + rasds_for_domain(_BROKER, + virDomainGetName(domains[i]), + types[j], + ref, + list); + } + virDomainFree(domains[i]); + } + + s = (CMPIStatus){CMPI_RC_OK, NULL}; + + out: + virConnectClose(conn); + free(domains); + + return s; +} + +static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref, + const CMPIResult *results, + const bool names_only) +{ + struct inst_list list; + CMPIStatus s; + + inst_list_init(&list); + + s = _enum_rasds(ref, &list); + if (s.rc == CMPI_RC_OK) { + if (names_only) + cu_return_instance_names(results, &list); + else + cu_return_instances(results, &list); + } + + inst_list_free(&list); + + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference) +{ + return return_enum_rasds(reference, results, true); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + + return return_enum_rasds(reference, results, false); +} + static CMPIStatus GetInstance(CMPIInstanceMI *self, const CMPIContext *context, const CMPIResult *results, @@ -516,8 +611,6 @@ DEFAULT_CI(); DEFAULT_CI(); DEFAULT_MI(); DEFAULT_DI(); -DEFAULT_EI(); -DEFAULT_EIN(); DEFAULT_INST_CLEANUP(); DEFAULT_EQ(); From kaitlin at linux.vnet.ibm.com Mon Feb 18 23:25:14 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 18 Feb 2008 15:25:14 -0800 Subject: [Libvirt-cim] [PATCH] (#2) Add Enumeration support to RASD In-Reply-To: References: Message-ID: <47BA13DA.8040403@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1203373962 28800 > # Node ID c118dc77598088e3bd866df48787e5999aeb9d10 > # Parent 7b5611c03994d1568ba69560f5afad284df06bd0 > (#2) Add Enumeration support to RASD > > Supports enumerating a specific RASD type, as well as the parent classes > KVM_RASD, Xen_RASD, as well as CIM_RASD. > > Changes: > - Remove printf() in place of a CU_DEBUG() (before Kaitlin got a chance to > complain, I'll have you know) > > + > + if (rasd_type_from_classname(CLASSNAME(ref), &type) == CMPI_RC_OK) { > + types[0] = type; > + types[1] = 0; > + } > + > + for (i = 0; i < count; i++) { > + for (j = 0; types[j] != 0; j++) { > + CU_DEBUG(("Doing RASD type %i for %s", I had troubles compiling with this patch applied - you have an extra open paren here. Also, I was unable to query the CIM_ superclass: wbemcli ein http://localhost/root/virt:CIM_ResourceAllocationSettingData Since the classname is not specify, we're unable to get a domain list from the connection. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Mon Feb 18 23:29:20 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 18 Feb 2008 15:29:20 -0800 Subject: [Libvirt-cim] [PATCH] (#2) Add Enumeration support to RASD In-Reply-To: <47BA13DA.8040403@linux.vnet.ibm.com> (Kaitlin Rupert's message of "Mon, 18 Feb 2008 15:25:14 -0800") References: <47BA13DA.8040403@linux.vnet.ibm.com> Message-ID: <87ir0letdb.fsf@caffeine.beaverton.ibm.com> KR> I had troubles compiling with this patch applied - you have an KR> extra open paren here. Ah, well, I was trying to beat you to the punch. Oh well :) KR> Also, I was unable to query the CIM_ superclass: KR> wbemcli ein http://localhost/root/virt:CIM_ResourceAllocationSettingData KR> Since the classname is not specify, we're unable to get a domain list KR> from the connection. Hmm, it worked just fine for me because Pegasus translates that into a call of each type. Was this on SFCB perhaps? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Mon Feb 18 23:35:24 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 18 Feb 2008 15:35:24 -0800 Subject: [Libvirt-cim] [PATCH] (#2) Add Enumeration support to RASD In-Reply-To: <87ir0letdb.fsf@caffeine.beaverton.ibm.com> References: <47BA13DA.8040403@linux.vnet.ibm.com> <87ir0letdb.fsf@caffeine.beaverton.ibm.com> Message-ID: <47BA163C.8060503@linux.vnet.ibm.com> Dan Smith wrote: > KR> I had troubles compiling with this patch applied - you have an > KR> extra open paren here. > > Ah, well, I was trying to beat you to the punch. Oh well :) > > KR> Also, I was unable to query the CIM_ superclass: > > KR> wbemcli ein http://localhost/root/virt:CIM_ResourceAllocationSettingData > > KR> Since the classname is not specify, we're unable to get a domain list > KR> from the connection. > > Hmm, it worked just fine for me because Pegasus translates that into a > call of each type. Was this on SFCB perhaps? > Hmm.. interesting. No, this was with Pegasus. Here's error - I don't see anything strange in the CU_DEBUG output. [kaitlin at elm3b41 libvirt-cim]$ wbemcli ein http://localhost/root/virt:CIM_ResourceAllocationSettingData * * wbemcli: Cim: (1) CIM_ERR_FAILED: A general error occurred that is not covered by a more specific error code: "Unable to get domain list" I see the following with ei: [kaitlin at elm3b41 libvirt-cim]$ wbemcli ei http://localhost/root/virt:CIM_ResourceAllocationSettingData * * wbemcli: Cim: (2) CIM_ERR_ACCESS_DENIED: Access to a CIM resource was not available to the client: "Recursive Use of CIMOMHandle Attempted" -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From heidieck at linux.vnet.ibm.com Tue Feb 19 08:28:42 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 19 Feb 2008 09:28:42 +0100 Subject: [Libvirt-cim] [PATCH 0 of 4] Add reference validation to VSMigrationService and VSMigrateCap. In-Reply-To: <47B9B989.6000905@linux.vnet.ibm.com> References: <47B9891E.7080108@linux.vnet.ibm.com> <873arqfbxy.fsf@caffeine.beaverton.ibm.com> <47B9B989.6000905@linux.vnet.ibm.com> Message-ID: <47BA933A.2070103@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Dan Smith wrote: >> HE> is seg faulting sfcb with >> HE> misc_util.c(74): Unable to connect to `xen' >> HE> -#- Virt_VSMigrationCapabilities - 29723 provider exiting due to a >> HE> SIGSEGV signal >> >> I don't see a segfault on SFCB. It returns the VSMCaps object as >> expected, for both Xen and KVM. If I stop xend, I just get a KVM >> object back (as expected), and no crash. > > I did see a segfault once using Pegasus just now. I'm wondering if > this is related to a race condition with libvirt. > > Does this query segfault for you every time? > I will try to to find out what's going wrong on my system and will come back ... hopefully by end of my day. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From lizg at cn.ibm.com Tue Feb 19 09:05:21 2008 From: lizg at cn.ibm.com (lizg at cn.ibm.com) Date: Tue, 19 Feb 2008 17:05:21 +0800 Subject: [Libvirt-cim] [PATCH] Fix names_only tag in VSMC EI Message-ID: <9f40e7cbae6915450613.1203411921@zeit.cn.ibm.com> # HG changeset patch # User Zhengang Li # Date 1203411892 -28800 # Node ID 9f40e7cbae6915450613f1c1056df31ec721f692 # Parent 7b5611c03994d1568ba69560f5afad284df06bd0 Fix names_only tag in VSMC EI VirtualSystemManagementCapabilities' EI method has a 'true' names_only param. This causes sfcb fail to give a correct response. wbemcli gave me the following on the original code: wbemei http://localhost/root/virt:Xen_VirtualSystemManagementCapabilities * * wbemei: Http Exception: server returned nothing (no headers, no data) * Signed-off-by: Zhengang Li diff -r 7b5611c03994 -r 9f40e7cbae69 src/Virt_VirtualSystemManagementCapabilities.c --- a/src/Virt_VirtualSystemManagementCapabilities.c Fri Feb 15 13:35:31 2008 -0800 +++ b/src/Virt_VirtualSystemManagementCapabilities.c Tue Feb 19 17:04:52 2008 +0800 @@ -175,7 +175,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_vsm_cap(reference, results, true, false); + return return_vsm_cap(reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, From heidieck at linux.vnet.ibm.com Tue Feb 19 09:56:44 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 19 Feb 2008 10:56:44 +0100 Subject: [Libvirt-cim] [PATCH 3 of 4] Add support for ref checking to VSMigrationCapabilities In-Reply-To: References: Message-ID: <47BAA7DC.8040409@linux.vnet.ibm.com> Kaitlin Rupert wrote: > @@ -81,10 +81,21 @@ static CMPIStatus set_method_properties( > > CMPIStatus get_migration_caps(const CMPIObjectPath *ref, > CMPIInstance **_inst, > - const CMPIBroker *broker) > + const CMPIBroker *broker, > + bool is_get_inst) > { > CMPIInstance *inst; > CMPIStatus s; > Please initialize the Status s to become absolutely sure, that a valid status is returned. > + virConnectPtr conn = NULL; > + > + conn = connect_by_classname(broker, CLASSNAME(ref), &s); > + if (conn == NULL) { > + if (is_get_inst) > + cu_statusf(broker, &s, > + CMPI_RC_ERR_NOT_FOUND, > + "No such instance"); > + goto out; > + } > > inst = get_typed_instance(broker, > CLASSNAME(ref), > As the connection is established at this point in time and through all the other code we use pfx_from_conn(conn) in that case, it might be good to also use this here instead of CLASSNAME(ref). But that's more a convenience thing. > static CMPIStatus return_vsmc(const CMPIObjectPath *ref, > const CMPIResult *results, > - bool name_only) > + bool name_only, > + bool is_get_inst) > { > CMPIInstance *inst; > This is causing the reproducible seg fault on my system. Please initialize inst = NULL. In the case of a Xen request on a KVM only system this uninitialized inst is disorienting the check for inst ==NULL and afterwards seg faulting the return instance functions - as inst is only containing garbage. > CMPIStatus s; > > - s = get_migration_caps(ref, &inst, _BROKER); > - > - if (s.rc == CMPI_RC_OK) { > - if (name_only) > - cu_return_instance_name(results, inst); > - else > - CMReturnInstance(results, inst); > - } > - > + s = get_migration_caps(ref, &inst, _BROKER, is_get_inst); > + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) > + goto out; > + > + if (name_only) > + cu_return_instance_name(results, inst); > + else > + CMReturnInstance(results, inst); > + > + out: > return s; > } > -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Tue Feb 19 10:42:32 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 19 Feb 2008 11:42:32 +0100 Subject: [Libvirt-cim] [PATCH 1 of 4] Add reference validation to get_migration_service() In-Reply-To: <9b93bc85520bc6a9cb48.1203123587@elm3b41.beaverton.ibm.com> References: <9b93bc85520bc6a9cb48.1203123587@elm3b41.beaverton.ibm.com> Message-ID: <47BAB298.30506@linux.vnet.ibm.com> Kaitlin Rupert wrote: > static CMPIStatus return_vsms(const CMPIObjectPath *ref, > const CMPIResult *results, > - bool name_only) > + bool name_only, > + bool is_get_inst) > { > CMPIInstance *inst; > The same reason here ... please init inst=NULL to avoid seg faulting the return instance functions. > CMPIStatus s; > > - s = get_migration_service(ref, &inst, _BROKER); > - if (s.rc == CMPI_RC_OK) { > - if (name_only) > - cu_return_instance_name(results, inst); > - else > - CMReturnInstance(results, inst); > - } > - > + s = get_migration_service(ref, &inst, _BROKER, is_get_inst); > + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) > + goto out; > + > + if (name_only) > + cu_return_instance_name(results, inst); > + else > + CMReturnInstance(results, inst); > + out: > return s; > } > -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Tue Feb 19 11:32:05 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 19 Feb 2008 12:32:05 +0100 Subject: [Libvirt-cim] [PATCH] VSMC: use get_typed_instance function (tiny optimization) Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203420624 -3600 # Node ID d96a062a7996bee0109172f8779ae3482cfab6d5 # Parent 8b7a10c27b1cad1b140083dc5fd8b9abab2597ef VSMC: use get_typed_instance function (tiny optimization) Signed-off-by: Heidi Eckhart diff -r 8b7a10c27b1c -r d96a062a7996 src/Virt_VirtualSystemManagementCapabilities.c --- a/src/Virt_VirtualSystemManagementCapabilities.c Tue Feb 19 12:17:08 2008 +0100 +++ b/src/Virt_VirtualSystemManagementCapabilities.c Tue Feb 19 12:30:24 2008 +0100 @@ -46,15 +46,11 @@ enum {ADD_RESOURCES = 1, static CMPIStatus set_inst_properties(const CMPIBroker *broker, - CMPIInstance *inst, - const char *classname) + CMPIInstance *inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIArray *array; uint16_t element; - - CMSetProperty(inst, "CreationClassName", - (CMPIValue *)classname, CMPI_chars); CMSetProperty(inst, "InstanceID", (CMPIValue *)"ManagementCapabilities", CMPI_chars); @@ -83,13 +79,12 @@ static CMPIStatus set_inst_properties(co CMPIStatus get_vsm_cap(const CMPIBroker *broker, const CMPIObjectPath *ref, - CMPIInstance **inst, + CMPIInstance **_inst, bool is_get_inst) { - CMPIStatus s; - CMPIObjectPath *op; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; virConnectPtr conn = NULL; - char *classname = NULL; conn = connect_by_classname(broker, CLASSNAME(ref), &s); if (conn == NULL) { @@ -100,41 +95,26 @@ CMPIStatus get_vsm_cap(const CMPIBroker goto out; } - classname = get_typed_class(CLASSNAME(ref), - "VirtualSystemManagementCapabilities"); - if (classname == NULL) { - cu_statusf(broker, &s, + inst = get_typed_instance(_BROKER, + pfx_from_conn(conn), + "VirtualSystemManagementCapabilities", + NAMESPACE(ref)); + if (inst == NULL) + cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Invalid class"); - goto out; - } + "Can't create VirtualSystemManagementCapabilities instance"); - op = CMNewObjectPath(broker, NAMESPACE(ref), classname, &s); - if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Cannot get object path for VSMCapabilities"); - goto out; - } - - *inst = CMNewInstance(broker, op, &s); - if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(*inst))) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Failed to instantiate HostSystem"); - goto out; - } - - s = set_inst_properties(broker, *inst, classname); + s = set_inst_properties(broker, inst); if (is_get_inst) { - s = cu_validate_ref(broker, ref, *inst); + s = cu_validate_ref(broker, ref, inst); if (s.rc != CMPI_RC_OK) goto out; } + *_inst = inst; + out: - free(classname); virConnectClose(conn); return s; From heidieck at linux.vnet.ibm.com Tue Feb 19 12:05:59 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 19 Feb 2008 13:05:59 +0100 Subject: [Libvirt-cim] [PATCH] (#2) Add Enumeration support to RASD In-Reply-To: <47BA163C.8060503@linux.vnet.ibm.com> References: <47BA13DA.8040403@linux.vnet.ibm.com> <87ir0letdb.fsf@caffeine.beaverton.ibm.com> <47BA163C.8060503@linux.vnet.ibm.com> Message-ID: <47BAC627.3080203@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Dan Smith wrote: >> KR> I had troubles compiling with this patch applied - you have an >> KR> extra open paren here. >> >> Ah, well, I was trying to beat you to the punch. Oh well :) >> >> KR> Also, I was unable to query the CIM_ superclass: >> >> KR> wbemcli ein >> http://localhost/root/virt:CIM_ResourceAllocationSettingData >> >> KR> Since the classname is not specify, we're unable to get a domain >> list >> KR> from the connection. >> >> Hmm, it worked just fine for me because Pegasus translates that into a >> call of each type. Was this on SFCB perhaps? For class providers sfcb is acting like Pegasus. It translates the CIM_RASD call into a separate provider request for each subclass. >> > > Hmm.. interesting. No, this was with Pegasus. Here's error - I don't > see anything strange in the CU_DEBUG output. > > [kaitlin at elm3b41 libvirt-cim]$ wbemcli ein > http://localhost/root/virt:CIM_ResourceAllocationSettingData > * > * wbemcli: Cim: (1) CIM_ERR_FAILED: A general error occurred that is > not covered by a more specific error code: "Unable to get domain list" > > > I see the following with ei: > > [kaitlin at elm3b41 libvirt-cim]$ wbemcli ei > http://localhost/root/virt:CIM_ResourceAllocationSettingData > * > * wbemcli: Cim: (2) CIM_ERR_ACCESS_DENIED: Access to a CIM resource > was not available to the client: "Recursive Use of CIMOMHandle Attempted" > Besides that tiny compilation issue I had no trouble with the provider - neither with sfcb nor with Pegasus. And by reviewing the code I have no idea, where this behavior could come from. For me everything looks fine. What is really strange is, that for nearly the same call two different functions are returning errors: - for the first one (ein) the provider is returning the error - for the second one (ei) the CIMOM is returning the error ... and that error looks like Pegasus is having trouble with calling the same provider for different subclasses Please can you reinstall, restart Pegasus and try again ? What happens ? -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From kaitlin at linux.vnet.ibm.com Tue Feb 19 14:28:43 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 19 Feb 2008 06:28:43 -0800 Subject: [Libvirt-cim] [PATCH] Fix names_only tag in VSMC EI In-Reply-To: <9f40e7cbae6915450613.1203411921@zeit.cn.ibm.com> References: <9f40e7cbae6915450613.1203411921@zeit.cn.ibm.com> Message-ID: <47BAE79B.10807@linux.vnet.ibm.com> lizg at cn.ibm.com wrote: > # HG changeset patch > # User Zhengang Li > # Date 1203411892 -28800 > # Node ID 9f40e7cbae6915450613f1c1056df31ec721f692 > # Parent 7b5611c03994d1568ba69560f5afad284df06bd0 > Fix names_only tag in VSMC EI > > VirtualSystemManagementCapabilities' EI method has a 'true' names_only > param. This causes sfcb fail to give a correct response. wbemcli gave > me the following on the original code: > > wbemei http://localhost/root/virt:Xen_VirtualSystemManagementCapabilities > * > * wbemei: Http Exception: server returned nothing (no headers, no data) > * > Thanks Zhengang - the last patch I submitted had a copy and paste error. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Tue Feb 19 16:39:58 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 19 Feb 2008 08:39:58 -0800 Subject: [Libvirt-cim] [PATCH] (#3) Add Enumeration support to RASD Message-ID: <95c56a7a865df18bbdf1.1203439198@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1203439144 28800 # Node ID 95c56a7a865df18bbdf1066d8b04d5d4b75e7d44 # Parent 030c012f1698cbccc0cdd0b34f51e377ced6eb16 (#3) Add Enumeration support to RASD Supports enumerating a specific RASD type, as well as the parent classes KVM_RASD, Xen_RASD, as well as CIM_RASD. Changes: - Remove printf() in place of a CU_DEBUG() (before Kaitlin got a chance to complain, I'll have you know) - Fix silly compile error Signed-off-by: Dan Smith diff -r 030c012f1698 -r 95c56a7a865d src/Virt_RASD.c --- a/src/Virt_RASD.c Tue Feb 19 17:04:52 2008 +0800 +++ b/src/Virt_RASD.c Tue Feb 19 08:39:04 2008 -0800 @@ -34,6 +34,7 @@ #include "device_parsing.h" #include "misc_util.h" +#include "cs_util.h" #include "Virt_RASD.h" #include "svpc_types.h" @@ -442,6 +443,100 @@ CMPIrc rasd_classname_from_type(uint16_t return rc; } +static CMPIStatus _enum_rasds(const CMPIObjectPath *ref, + struct inst_list *list) +{ + virConnectPtr conn = NULL; + virDomainPtr *domains = NULL; + int count; + int i, j; + uint16_t type; + CMPIStatus s; + uint16_t types[] = {CIM_RASD_TYPE_PROC, + CIM_RASD_TYPE_DISK, + CIM_RASD_TYPE_NET, + CIM_RASD_TYPE_MEM, + 0}; + + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) + return s; + + count = get_domain_list(conn, &domains); + if (count <= 0) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get domain list"); + goto out; + } + + if (rasd_type_from_classname(CLASSNAME(ref), &type) == CMPI_RC_OK) { + types[0] = type; + types[1] = 0; + } + + for (i = 0; i < count; i++) { + for (j = 0; types[j] != 0; j++) { + CU_DEBUG("Doing RASD type %i for %s", + type, virDomainGetName(domains[i])); + rasds_for_domain(_BROKER, + virDomainGetName(domains[i]), + types[j], + ref, + list); + } + virDomainFree(domains[i]); + } + + s = (CMPIStatus){CMPI_RC_OK, NULL}; + + out: + virConnectClose(conn); + free(domains); + + return s; +} + +static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref, + const CMPIResult *results, + const bool names_only) +{ + struct inst_list list; + CMPIStatus s; + + inst_list_init(&list); + + s = _enum_rasds(ref, &list); + if (s.rc == CMPI_RC_OK) { + if (names_only) + cu_return_instance_names(results, &list); + else + cu_return_instances(results, &list); + } + + inst_list_free(&list); + + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference) +{ + return return_enum_rasds(reference, results, true); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + + return return_enum_rasds(reference, results, false); +} + static CMPIStatus GetInstance(CMPIInstanceMI *self, const CMPIContext *context, const CMPIResult *results, @@ -516,8 +611,6 @@ DEFAULT_CI(); DEFAULT_CI(); DEFAULT_MI(); DEFAULT_DI(); -DEFAULT_EI(); -DEFAULT_EIN(); DEFAULT_INST_CLEANUP(); DEFAULT_EQ(); From kaitlin at linux.vnet.ibm.com Tue Feb 19 20:58:38 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 19 Feb 2008 12:58:38 -0800 Subject: [Libvirt-cim] [PATCH] (#3) Add Enumeration support to RASD In-Reply-To: <95c56a7a865df18bbdf1.1203439198@caffeine.beaverton.ibm.com> References: <95c56a7a865df18bbdf1.1203439198@caffeine.beaverton.ibm.com> Message-ID: <47BB42FE.9040807@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1203439144 28800 > # Node ID 95c56a7a865df18bbdf1066d8b04d5d4b75e7d44 > # Parent 030c012f1698cbccc0cdd0b34f51e377ced6eb16 > (#3) Add Enumeration support to RASD > > Supports enumerating a specific RASD type, as well as the parent classes > KVM_RASD, Xen_RASD, as well as CIM_RASD. > > Changes: > - Remove printf() in place of a CU_DEBUG() (before Kaitlin got a chance to > complain, I'll have you know) > - Fix silly compile error > I'm still seeing issues with wbemcli ein http://localhost/root/virt:CIM_ResourceAllocationSettingData, but I don't see an obvious reason from the code. However, wbemcli ein http://localhost/root/virt:Xen_ResourceAllocationSettingData works for me, so I think we can apply this so that we have some working functionality. I'll debug further on my system. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Tue Feb 19 23:30:25 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 19 Feb 2008 15:30:25 -0800 Subject: [Libvirt-cim] [PATCH 3 of 4] Add support for ref checking to VSMigrationCapabilities In-Reply-To: <47BAA7DC.8040409@linux.vnet.ibm.com> References: <47BAA7DC.8040409@linux.vnet.ibm.com> Message-ID: <47BB6691.9090808@linux.vnet.ibm.com> >> + } >> >> inst = get_typed_instance(broker, >> CLASSNAME(ref), >> > As the connection is established at this point in time and through all > the other code we use pfx_from_conn(conn) in that case, it might be good > to also use this here instead of CLASSNAME(ref). But that's more a > convenience thing. Good point. =) >> static CMPIStatus return_vsmc(const CMPIObjectPath *ref, >> const CMPIResult *results, >> - bool name_only) >> + bool name_only, >> + bool is_get_inst) >> { >> CMPIInstance *inst; >> > This is causing the reproducible seg fault on my system. Please > initialize inst = NULL. In the case of a Xen request on a KVM only > system this uninitialized inst is disorienting the check for inst ==NULL > and afterwards seg faulting the return instance functions - as inst is > only containing garbage. Thanks for tracking this down! I'll send a new patch to fix this and the other issues you mentioned. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Tue Feb 19 23:37:40 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 19 Feb 2008 15:37:40 -0800 Subject: [Libvirt-cim] [PATCH 3 of 4] Add support for ref checking to VSMigrationCapabilities In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1203463791 28800 # Node ID b59709a9c0ae71d78399327d411e703b19080177 # Parent 839b8d433ef5157fc34f5bb7f003e9cb8ed700c7 Add support for ref checking to VSMigrationCapabilities. Updates: -Initialize inst to NULL in return_vsmc() to prevent seg fault -Use pfx_from_conn() in get_migration_caps() instead of CLASSNAME(ref) -Initialize CMPIStatus s in get_migration_caps() Signed-off-by: Kaitlin Rupert diff -r 839b8d433ef5 -r b59709a9c0ae src/Virt_VSMigrationCapabilities.c --- a/src/Virt_VSMigrationCapabilities.c Tue Feb 19 15:27:18 2008 -0800 +++ b/src/Virt_VSMigrationCapabilities.c Tue Feb 19 15:29:51 2008 -0800 @@ -81,13 +81,24 @@ static CMPIStatus set_method_properties( CMPIStatus get_migration_caps(const CMPIObjectPath *ref, CMPIInstance **_inst, - const CMPIBroker *broker) + const CMPIBroker *broker, + bool is_get_inst) { CMPIInstance *inst; - CMPIStatus s; + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } inst = get_typed_instance(broker, - CLASSNAME(ref), + pfx_from_conn(conn), "VirtualSystemMigrationCapabilities", NAMESPACE(ref)); if (inst == NULL) { @@ -102,28 +113,42 @@ CMPIStatus get_migration_caps(const CMPI s = set_method_properties(broker, inst); - if (s.rc == CMPI_RC_OK) - *_inst = inst; + if (s.rc != CMPI_RC_OK) + goto out; + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + + out: + + virConnectClose(conn); return s; } static CMPIStatus return_vsmc(const CMPIObjectPath *ref, const CMPIResult *results, - bool name_only) -{ - CMPIInstance *inst; + bool name_only, + bool is_get_inst) +{ + CMPIInstance *inst = NULL; CMPIStatus s; - s = get_migration_caps(ref, &inst, _BROKER); - - if (s.rc == CMPI_RC_OK) { - if (name_only) - cu_return_instance_name(results, inst); - else - CMReturnInstance(results, inst); - } - + s = get_migration_caps(ref, &inst, _BROKER, is_get_inst); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + goto out; + + if (name_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + + out: return s; } @@ -132,7 +157,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *ref) { - return return_vsmc(ref, results, true); + return return_vsmc(ref, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -142,7 +167,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_vsmc(ref, results, false); + return return_vsmc(ref, results, false, false); } @@ -152,24 +177,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *ref, const char **properties) { - CMPIInstance *inst; - CMPIStatus s; - const char *prop; - - s = get_migration_caps(ref, &inst, _BROKER); - if (s.rc != CMPI_RC_OK) - return s; - - prop = cu_compare_ref(ref, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } else { - CMReturnInstance(results, inst); - } - - return s; + return return_vsmc(ref, results, false, true); } DEFAULT_CI(); diff -r 839b8d433ef5 -r b59709a9c0ae src/Virt_VSMigrationCapabilities.h --- a/src/Virt_VSMigrationCapabilities.h Tue Feb 19 15:27:18 2008 -0800 +++ b/src/Virt_VSMigrationCapabilities.h Tue Feb 19 15:29:51 2008 -0800 @@ -21,7 +21,8 @@ CMPIStatus get_migration_caps(const CMPIObjectPath *reference, CMPIInstance **_inst, - const CMPIBroker *broker); + const CMPIBroker *broker, + bool is_get_inst); /* * Local Variables: From kaitlin at linux.vnet.ibm.com Tue Feb 19 23:37:39 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 19 Feb 2008 15:37:39 -0800 Subject: [Libvirt-cim] [PATCH 2 of 4] Update calls to get_migration_service() to use new param In-Reply-To: Message-ID: <839b8d433ef5157fc34f.1203464259@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1203463638 28800 # Node ID 839b8d433ef5157fc34f5bb7f003e9cb8ed700c7 # Parent 0d38670abc3cd4be2560daddbd038ebce630f3fb Update calls to get_migration_service() to use new param. This param indicates whether the reference should be validated, or if an instance (without ref validation) should be returned. Signed-off-by: Kaitlin Rupert diff -r 0d38670abc3c -r 839b8d433ef5 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Tue Feb 19 15:27:15 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Tue Feb 19 15:27:18 2008 -0800 @@ -70,12 +70,16 @@ static CMPIStatus validate_caps_get_serv if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; - s = get_migration_service(ref, &_inst, _BROKER); + s = get_migration_service(ref, &_inst, _BROKER, false); } else cu_statusf(_BROKER, &s, CMPI_RC_ERR_NOT_FOUND, "Not found"); + + if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) + goto out; + *inst = _inst; out: free(classname); @@ -99,7 +103,7 @@ static CMPIStatus validate_service_get_c s = get_vsm_cap(_BROKER, ref, &_inst, false); } else if (STREQC(classname, "VirtualSystemMigrationService")) { - s = get_migration_service(ref, &_inst, _BROKER); + s = get_migration_service(ref, &_inst, _BROKER, true); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; diff -r 0d38670abc3c -r 839b8d433ef5 src/Virt_HostedService.c --- a/src/Virt_HostedService.c Tue Feb 19 15:27:15 2008 -0800 +++ b/src/Virt_HostedService.c Tue Feb 19 15:27:18 2008 -0800 @@ -51,7 +51,7 @@ static CMPIStatus validate_service_ref(c } else if (STREQC(classname, "ResourcePoolConfigurationService")) { s = get_rpcs(ref, &inst, _BROKER, true); } else if (STREQC(classname, "VirtualSystemMigrationService")) { - s = get_migration_service(ref, &inst, _BROKER); + s = get_migration_service(ref, &inst, _BROKER, true); } if (s.rc != CMPI_RC_OK) @@ -117,7 +117,7 @@ static CMPIStatus host_to_service(const if (!CMIsNullObject(inst)) inst_list_add(list, inst); - s = get_migration_service(ref, &inst, _BROKER); + s = get_migration_service(ref, &inst, _BROKER, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) diff -r 0d38670abc3c -r 839b8d433ef5 src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Tue Feb 19 15:27:15 2008 -0800 +++ b/src/Virt_VSMigrationService.c Tue Feb 19 15:27:18 2008 -0800 @@ -847,7 +847,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *ref) { - return return_vsms(ref, results, true, false, false); + return return_vsms(ref, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -857,7 +857,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_vsms(ref, results, false, false, false); + return return_vsms(ref, results, false, false); } @@ -867,7 +867,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *ref, const char **properties) { - return return_vsms(ref, results, false, true, true); + return return_vsms(ref, results, false, true); } DEFAULT_CI(); From kaitlin at linux.vnet.ibm.com Tue Feb 19 23:37:41 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 19 Feb 2008 15:37:41 -0800 Subject: [Libvirt-cim] [PATCH 4 of 4] Update the get_migration_caps() calls to include new param In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1203463792 28800 # Node ID f932effa29a1878a03a0441e2792184e46caa018 # Parent b59709a9c0ae71d78399327d411e703b19080177 Update the get_migration_caps() calls to include new param. This extra param indicates that the reference need to be validated. Signed-off-by: Kaitlin Rupert diff -r b59709a9c0ae -r f932effa29a1 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Tue Feb 19 15:29:51 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Tue Feb 19 15:29:52 2008 -0800 @@ -66,7 +66,7 @@ static CMPIStatus validate_caps_get_serv s = get_vsms(ref, &_inst, _BROKER, false); } else if (STREQC(classname, "VirtualSystemMigrationCapabilities")) { - s = get_migration_caps(ref, &_inst, _BROKER); + s = get_migration_caps(ref, &_inst, _BROKER, true); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; @@ -107,7 +107,7 @@ static CMPIStatus validate_service_get_c if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; - s = get_migration_caps(ref, &_inst, _BROKER); + s = get_migration_caps(ref, &_inst, _BROKER, false); } else cu_statusf(_BROKER, &s, CMPI_RC_ERR_NOT_FOUND, @@ -139,7 +139,7 @@ static CMPIStatus sys_to_cap(const CMPIO if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); - s = get_migration_caps(ref, &inst, _BROKER); + s = get_migration_caps(ref, &inst, _BROKER, false); if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); From kaitlin at linux.vnet.ibm.com Tue Feb 19 23:37:38 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 19 Feb 2008 15:37:38 -0800 Subject: [Libvirt-cim] [PATCH 1 of 4] Add reference validation to get_migration_service() In-Reply-To: Message-ID: <0d38670abc3cd4be2560.1203464258@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1203463635 28800 # Node ID 0d38670abc3cd4be2560daddbd038ebce630f3fb # Parent 95c56a7a865df18bbdf1066d8b04d5d4b75e7d44 Add reference validation to get_migration_service(). Adds reference validation to VirtualSystemMigrationService. Updates: -Initialize inst to NULL in return_vsms() to prevent seg fault -Use pfx_from_conn() in get_migration_service() instead of CLASSNAME(ref) Signed-off-by: Kaitlin Rupert diff -r 95c56a7a865d -r 0d38670abc3c src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Tue Feb 19 08:39:04 2008 -0800 +++ b/src/Virt_VSMigrationService.c Tue Feb 19 15:27:15 2008 -0800 @@ -755,15 +755,26 @@ STDIM_MethodMIStub(, Virt_VSMigrationSer CMPIStatus get_migration_service(const CMPIObjectPath *ref, CMPIInstance **_inst, - const CMPIBroker *broker) + const CMPIBroker *broker, + bool is_get_inst) { CMPIInstance *inst; CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; const char *name = NULL; const char *ccname = NULL; + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + inst = get_typed_instance(broker, - CLASSNAME(ref), + pfx_from_conn(conn), "VirtualSystemMigrationService", NAMESPACE(ref)); if (inst == NULL) { @@ -793,6 +804,12 @@ CMPIStatus get_migration_service(const C CMSetProperty(inst, "SystemCreationClassName", (CMPIValue *)ccname, CMPI_chars); + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + cu_statusf(broker, &s, CMPI_RC_OK, ""); @@ -800,24 +817,28 @@ CMPIStatus get_migration_service(const C *_inst = inst; out: + virConnectClose(conn); + return s; } static CMPIStatus return_vsms(const CMPIObjectPath *ref, const CMPIResult *results, - bool name_only) -{ - CMPIInstance *inst; - CMPIStatus s; - - s = get_migration_service(ref, &inst, _BROKER); - if (s.rc == CMPI_RC_OK) { - if (name_only) - cu_return_instance_name(results, inst); - else - CMReturnInstance(results, inst); - } - + bool name_only, + bool is_get_inst) +{ + CMPIInstance *inst = NULL; + CMPIStatus s; + + s = get_migration_service(ref, &inst, _BROKER, is_get_inst); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + goto out; + + if (name_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + out: return s; } @@ -826,7 +847,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *ref) { - return return_vsms(ref, results, true); + return return_vsms(ref, results, true, false, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -836,7 +857,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_vsms(ref, results, false); + return return_vsms(ref, results, false, false, false); } @@ -846,24 +867,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *ref, const char **properties) { - CMPIInstance *inst; - CMPIStatus s; - const char *prop; - - s = get_migration_service(ref, &inst, _BROKER); - if (s.rc != CMPI_RC_OK) - return s; - - prop = cu_compare_ref(ref, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } else { - CMReturnInstance(results, inst); - } - - return s; + return return_vsms(ref, results, false, true, true); } DEFAULT_CI(); diff -r 95c56a7a865d -r 0d38670abc3c src/Virt_VSMigrationService.h --- a/src/Virt_VSMigrationService.h Tue Feb 19 08:39:04 2008 -0800 +++ b/src/Virt_VSMigrationService.h Tue Feb 19 15:27:15 2008 -0800 @@ -21,7 +21,8 @@ CMPIStatus get_migration_service(const CMPIObjectPath *reference, CMPIInstance **_inst, - const CMPIBroker *broker); + const CMPIBroker *broker, + bool is_get_inst); /* * Local Variables: From kaitlin at linux.vnet.ibm.com Tue Feb 19 23:37:37 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 19 Feb 2008 15:37:37 -0800 Subject: [Libvirt-cim] [PATCH 0 of 4] #2 Add reference validation to VSMigrationService and VSMigrateCap. Message-ID: More reference validation updates. This patch set is dependent on the get_vsm_cap() reference validation set. See commit logs for updates from set 1 to set 2: -Add reference validation to get_migration_service() - Add support for ref checking to VSMigrationCapabilities From kaitlin at linux.vnet.ibm.com Wed Feb 20 01:35:54 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 19 Feb 2008 17:35:54 -0800 Subject: [Libvirt-cim] [PATCH] VSMC: use get_typed_instance function (tiny optimization) In-Reply-To: References: Message-ID: <47BB83FA.3080104@linux.vnet.ibm.com> Heidi Eckhart wrote: > # HG changeset patch > # User Heidi Eckhart > # Date 1203420624 -3600 > # Node ID d96a062a7996bee0109172f8779ae3482cfab6d5 > # Parent 8b7a10c27b1cad1b140083dc5fd8b9abab2597ef > VSMC: use get_typed_instance function (tiny optimization) > Signed-off-by: Heidi Eckhart > > diff -r 8b7a10c27b1c -r d96a062a7996 src/Virt_VirtualSystemManagementCapabilities.c Nice! And it tested fine on my system. =) +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From heidieck at linux.vnet.ibm.com Wed Feb 20 09:23:32 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 20 Feb 2008 10:23:32 +0100 Subject: [Libvirt-cim] [PATCH 0 of 4] #2 Add reference validation to VSMigrationService and VSMigrateCap. In-Reply-To: References: Message-ID: <47BBF194.5040800@linux.vnet.ibm.com> Kaitlin Rupert wrote: > More reference validation updates. > > This patch set is dependent on the get_vsm_cap() reference validation set. > > See commit logs for updates from set 1 to set 2: > -Add reference validation to get_migration_service() > - Add support for ref checking to VSMigrationCapabilities > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > That's an excellent patch set ... +1 :) ! -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 20 12:21:30 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 20 Feb 2008 13:21:30 +0100 Subject: [Libvirt-cim] [PATCH 0 of 3] Enable VSSD to validate client given object path and Adopt changed to VSSD interface to ESD & SDS Message-ID: From heidieck at linux.vnet.ibm.com Wed Feb 20 12:21:31 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 20 Feb 2008 13:21:31 +0100 Subject: [Libvirt-cim] [PATCH 1 of 3] VSSD: validate client given object path In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203507766 -3600 # Node ID c77500943eae17131c7d0522a99d16b3e2f43489 # Parent 60e38dd96ca6871856d64056305fc200d718b3a5 VSSD: validate client given object path wbemgi 'http://localhost:5988/root/virt:KVM_VirtualSystemSettingData.InstanceID="Xen:kvm1-f8"' on a KVM only system is returning an instance, but should not. wbemgi 'http://localhost:5988/root/virt:Xen_VirtualSystemSettingData.InstanceID="KVM:kvm1-f8"' on a KVM only system is seg faulting, but should not ;). Signed-off-by: Heidi Eckhart diff -r 60e38dd96ca6 -r c77500943eae src/Virt_VSSD.c --- a/src/Virt_VSSD.c Tue Feb 19 15:29:52 2008 -0800 +++ b/src/Virt_VSSD.c Wed Feb 20 12:42:46 2008 +0100 @@ -135,42 +135,46 @@ static int instance_from_dom(virDomainPt return ret; } -CMPIInstance *get_vssd_instance(virDomainPtr dom, - const CMPIBroker *broker, - const CMPIObjectPath *ref) -{ - CMPIInstance *inst; - +static CMPIInstance *_get_vssd(const CMPIBroker *broker, + const CMPIObjectPath *reference, + virConnectPtr conn, + virDomainPtr dom, + CMPIStatus *s) +{ + CMPIInstance *inst = NULL; + inst = get_typed_instance(broker, - CLASSNAME(ref), + pfx_from_conn(conn), "VirtualSystemSettingData", - NAMESPACE(ref)); - - if (inst == NULL) - return NULL; - - if (instance_from_dom(dom, inst)) - return inst; - else - return NULL; -} - -static CMPIStatus enum_vssd(const CMPIObjectPath *reference, - const CMPIResult *results, - int names_only) + NAMESPACE(reference)); + + if (inst == NULL) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to init VirtualSystemSettingData instance"); + goto out; + } + + if (!instance_from_dom(dom, inst)) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to get VSSD instance from Domain"); + } + + out: + return inst; +} + +static CMPIStatus return_enum_vssd(const CMPIObjectPath *reference, + const CMPIResult *results, + bool names_only) { virConnectPtr conn; virDomainPtr *list; int count; int i; - CMPIStatus s; - const char *ns; - - if (!provider_is_responsible(_BROKER, reference, &s)) - return s; - - ns = NAMESPACE(reference); - + CMPIStatus s = {CMPI_RC_OK, NULL}; + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); if (conn == NULL) return s; @@ -181,60 +185,90 @@ static CMPIStatus enum_vssd(const CMPIOb CMPI_RC_ERR_FAILED, "Failed to enumerate domains"); goto out; - } else if (count == 0) { - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - goto out; - } + } else if (count == 0) + goto out; for (i = 0; i < count; i++) { - CMPIInstance *inst; - - inst = get_vssd_instance(list[i], _BROKER, reference); + CMPIInstance *inst = NULL; + + inst = _get_vssd(_BROKER, reference, conn, list[i], &s); + virDomainFree(list[i]); if (inst == NULL) continue; - + if (names_only) cu_return_instance_name(results, inst); else CMReturnInstance(results, inst); } - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: free(list); return s; - -} - -static CMPIInstance *get_vssd_for_name(const CMPIObjectPath *reference, - char *name) +} + +CMPIStatus get_vssd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst) { virConnectPtr conn; virDomainPtr dom; - CMPIStatus s; - CMPIInstance *inst = NULL; - - conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); - if (conn == NULL) - return NULL; - + CMPIStatus s = {CMPI_RC_OK, NULL}; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + dom = virDomainLookupByName(conn, name); - if (dom == NULL) - goto out; - - inst = get_vssd_instance(dom, _BROKER, reference); - + if (dom == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } + + *_inst = _get_vssd(broker, reference, conn, dom, &s); + + virDomainFree(dom); + out: virConnectClose(conn); - virDomainFree(dom); - - return inst; + + return s; +} + +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + char *name = NULL; + + if (!parse_instanceid(reference, NULL, &name)) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (InstanceID)"); + goto out; + } + + s = get_vssd_by_name(broker, reference, name, _inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, *_inst); + + free(name); + + out: + return s; } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -242,7 +276,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return enum_vssd(reference, results, 1); + return return_enum_vssd(reference, results, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -251,7 +285,7 @@ static CMPIStatus EnumInstances(CMPIInst const CMPIObjectPath *reference, const char **properties) { - return enum_vssd(reference, results, 0); + return return_enum_vssd(reference, results, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -261,26 +295,15 @@ static CMPIStatus GetInstance(CMPIInstan const char **properties) { CMPIStatus s; - CMPIInstance *inst; - char *locid; - - if (!parse_instanceid(reference, NULL, &locid)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Invalid InstanceID specified"); - return s; - } - - inst = get_vssd_for_name(reference, locid); - if (inst) - CMReturnInstance(results, inst); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - - free(locid); - + CMPIInstance *inst = NULL; + + s = get_vssd_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: return s; } diff -r 60e38dd96ca6 -r c77500943eae src/Virt_VSSD.h --- a/src/Virt_VSSD.h Tue Feb 19 15:29:52 2008 -0800 +++ b/src/Virt_VSSD.h Wed Feb 20 12:42:46 2008 +0100 @@ -21,8 +21,14 @@ #ifndef __VIRT_VSSD_H #define __VIRT_VSSD_H -CMPIInstance *get_vssd_instance(virDomainPtr dom, - const CMPIBroker *broker, - const CMPIObjectPath *ref); +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); + +CMPIStatus get_vssd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst); + #endif From heidieck at linux.vnet.ibm.com Wed Feb 20 12:21:32 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 20 Feb 2008 13:21:32 +0100 Subject: [Libvirt-cim] [PATCH 2 of 3] ESD: adopt interface changes in VSSD In-Reply-To: Message-ID: <4a89baa025dfffc42cdd.1203510092@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203508871 -3600 # Node ID 4a89baa025dfffc42cdd5f15c725b7b42fcb1212 # Parent c77500943eae17131c7d0522a99d16b3e2f43489 ESD: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r c77500943eae -r 4a89baa025df src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Wed Feb 20 12:42:46 2008 +0100 +++ b/src/Virt_ElementSettingData.c Wed Feb 20 13:01:11 2008 +0100 @@ -41,47 +41,20 @@ static CMPIStatus vssd_to_vssd(const CMP { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; - char *host = NULL; - + if (!match_hypervisor_prefix(ref, info)) return s; - if (!parse_instanceid(ref, NULL, &host)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to get system name"); - goto out; - } - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, host); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such system `%s'", host); - goto out; - } - - inst = get_vssd_instance(dom, _BROKER, ref); - if (inst == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Error getting VSSD for `%s'", host); - goto out; - } - + /* Special association case: + * VSSD instance is pointing to itself + */ + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + inst_list_add(list, inst); - + out: - virDomainFree(dom); - virConnectClose(conn); - free(host); - return s; } From heidieck at linux.vnet.ibm.com Wed Feb 20 12:21:33 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 20 Feb 2008 13:21:33 +0100 Subject: [Libvirt-cim] [PATCH 3 of 3] SDS: adopt interface changes in VSSD In-Reply-To: Message-ID: <163ff2951cfcabe67653.1203510093@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203509638 -3600 # Node ID 163ff2951cfcabe676535d6fcfe1c84f65271ba4 # Parent 4a89baa025dfffc42cdd5f15c725b7b42fcb1212 SDS: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r 4a89baa025df -r 163ff2951cfc src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Wed Feb 20 13:01:11 2008 +0100 +++ b/src/Virt_SettingsDefineState.c Wed Feb 20 13:13:58 2008 +0100 @@ -196,18 +196,16 @@ static CMPIStatus vs_to_vssd(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; const char *name; - CMPIInstance *vssd; - CMPIStatus s = {CMPI_RC_OK, NULL}; - + if (!match_hypervisor_prefix(ref, info)) return s; - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - return s; + + s = get_domain(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "Name", &name) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, @@ -215,28 +213,15 @@ static CMPIStatus vs_to_vssd(const CMPIO "Missing Name property"); goto out; } - - dom = virDomainLookupByName(conn, name); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such domain `%s'", name); - goto out; - } - - vssd = get_vssd_instance(dom, _BROKER, ref); - if (vssd != NULL) - inst_list_add(list, vssd); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - out: - virDomainFree(dom); - virConnectClose(conn); - + + s = get_vssd_by_name(_BROKER, ref, name, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, inst); + + out: return s; - } static CMPIStatus vssd_to_vs(const CMPIObjectPath *ref, @@ -250,9 +235,14 @@ static CMPIStatus vssd_to_vs(const CMPIO virConnectPtr conn = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *cs; + CMPIInstance *inst; if (!match_hypervisor_prefix(ref, info)) return s; + + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, From danms at us.ibm.com Wed Feb 20 20:45:10 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 20 Feb 2008 12:45:10 -0800 Subject: [Libvirt-cim] [PATCH] Make sure to set status in eo_parser_xml to avoid crash Message-ID: # HG changeset patch # User Dan Smith # Date 1203540299 28800 # Node ID ff79f3c78309209c682bad229cde371ebeef2576 # Parent c19e321766902af6dba29025be964d8d45537c51 Make sure to set status in eo_parser_xml to avoid crash if the caller tries to print the error message. Signed-off-by: Dan Smith diff -r c19e32176690 -r ff79f3c78309 eo_parser_xml.c --- a/eo_parser_xml.c Wed Feb 13 07:45:33 2008 -0800 +++ b/eo_parser_xml.c Wed Feb 20 12:44:59 2008 -0800 @@ -360,12 +360,18 @@ static CMPIStatus parse_instance(const C op = CMNewObjectPath(broker, ns, class, &s); if ((op == NULL) || (s.rc != CMPI_RC_OK)) { CU_DEBUG("Unable to create path for %s:%s", ns, class); + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to create path for %s:%s", ns, class); goto out; } *inst = CMNewInstance(broker, op, &s); if ((*inst == NULL) || (s.rc != CMPI_RC_OK)) { CU_DEBUG("Unable to create inst for %s:%s", ns, class); + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to create instance for %s:%s", ns, class); goto out; } @@ -380,6 +386,10 @@ static CMPIStatus parse_instance(const C CU_DEBUG("Unexpected node: %s\n", child->name); } } + + cu_statusf(broker, &s, + CMPI_RC_OK, + ""); out: free(class); From yunguol at cn.ibm.com Thu Feb 21 09:45:36 2008 From: yunguol at cn.ibm.com (Guo Lian Yun) Date: Thu, 21 Feb 2008 17:45:36 +0800 Subject: [Libvirt-cim] arguments issue in indication_tester.py Message-ID: Hi, There are four parameters in define xml of filter, handler and subscription, but only there are passes to them, that *sysname* is missed. On the former version of libcmpiutil, only three parameters in their define method. So I don't know what's the original idea of it, three or four arguments? Or it's just a minor mistake. Below are some parts of code. ... def filter_xml(name, type, ns, sysname): ... def handler_xml(name, port, sysname): ... def subscription_xml(name, sysname): ... def dump_xml(name, typ, ns): filter_str = filter_xml(name, typ, ns) handler_str = handler_xml(name, 8000) subscript_str = subscription_xml(name) ... Also, I'm not sure of instances deletion order, which including filter, handler and subscription instance. They are created by filter, handler and subscription order, and then deletion order it the same as created in coding. I'm not sure whether the subscription instance have to be deleted firstly. Thanks! Best, Regards Daisy Guo Lian Yun E-mail: yunguol at cn.ibm.com IBM China Development Lab, Shanghai, China TEL: (86)-21-61008057 -------------- next part -------------- An HTML attachment was scrubbed... URL: From heidieck at linux.vnet.ibm.com Thu Feb 21 12:09:10 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 21 Feb 2008 13:09:10 +0100 Subject: [Libvirt-cim] [PATCH] Enhance default setting of property CreationClassName Message-ID: <3c39412cd297e3ea3d15.1203595750@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203595620 -3600 # Node ID 3c39412cd297e3ea3d152f6a2ca2119236290093 # Parent 6fffc34df9c9b5cd1915f1fdd9f196b1f12a2477 Enhance default setting of property CreationClassName Not all CIM classes define the property CreationClassName. This patch adds a check if CreationClassName is property of the class and sets it only if there. Signed-off-by: Heidi Eckhart diff -r 6fffc34df9c9 -r 3c39412cd297 libxkutil/misc_util.c --- a/libxkutil/misc_util.c Thu Feb 21 12:55:13 2008 +0100 +++ b/libxkutil/misc_util.c Thu Feb 21 13:07:00 2008 +0100 @@ -236,6 +236,7 @@ CMPIInstance *get_typed_instance(const C CMPIObjectPath *op; CMPIInstance *inst = NULL; CMPIStatus s; + CMPIData data; new_cn = get_typed_class(refcn, base); if (new_cn == NULL) @@ -248,9 +249,11 @@ CMPIInstance *get_typed_instance(const C inst = CMNewInstance(broker, op, &s); if ((s.rc != CMPI_RC_OK) || CMIsNullObject(inst)) goto out; - - CMSetProperty(inst, "CreationClassName", - (CMPIValue *)new_cn, CMPI_chars); + + data = CMGetProperty(inst, "CreationClassName", &s); + if (s.rc ==CMPI_RC_OK) + CMSetProperty(inst, "CreationClassName", + (CMPIValue *)new_cn, CMPI_chars); out: free(new_cn); From heidieck at linux.vnet.ibm.com Thu Feb 21 12:10:24 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 21 Feb 2008 13:10:24 +0100 Subject: [Libvirt-cim] [PATCH 0 of 2] Enable ELEC to validate client given object path and Adopt changed to ELEC interface to EC Message-ID: ELEC does now take care of the client given object path. The resulting interface changes have been adopted to EC by the second patch From heidieck at linux.vnet.ibm.com Thu Feb 21 12:10:25 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 21 Feb 2008 13:10:25 +0100 Subject: [Libvirt-cim] [PATCH 1 of 2] ELEC: seg faults by wrong client given object path In-Reply-To: Message-ID: <0edc1241e58d872c2514.1203595825@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203594741 -3600 # Node ID 0edc1241e58d872c251473c424758a425efa19b6 # Parent 163ff2951cfcabe676535d6fcfe1c84f65271ba4 ELEC: seg faults by wrong client given object path wbemgi 'http://localhost:5988/root/virt:KVM_EnabledLogicalElementCapabilities.InstanceID="wrong"' seg faults wbemgi 'http://localhost:5988/root/virt:Xen_EnabledLogicalElementCapabilities.InstanceID="kvm1-f8"' seg faults on a KVM only system Signed-off-by: Heidi Eckhart diff -r 163ff2951cfc -r 0edc1241e58d src/Virt_EnabledLogicalElementCapabilities.c --- a/src/Virt_EnabledLogicalElementCapabilities.c Wed Feb 20 13:13:58 2008 +0100 +++ b/src/Virt_EnabledLogicalElementCapabilities.c Thu Feb 21 12:52:21 2008 +0100 @@ -46,26 +46,33 @@ enum {ENABLED = 2, QUIESCE, REBOOT, RESET}; - - - -static CMPIStatus set_inst_properties(const CMPIBroker *broker, - CMPIInstance *inst, - const char *classname, - const char *sys_name) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; + +static CMPIInstance *_get_elec(const CMPIBroker *broker, + const CMPIObjectPath *reference, + virConnectPtr conn, + const char *name, + CMPIStatus *s) +{ + CMPIInstance *inst = NULL; CMPIArray *array; uint16_t element; int edit_name = 0; - - CMSetProperty(inst, "CreationClassName", - (CMPIValue *)classname, CMPI_chars); - - CMSetProperty(inst, "InstanceID", (CMPIValue *)sys_name, CMPI_chars); - - array = CMNewArray(broker, 5, CMPI_uint16, &s); - if ((s.rc != CMPI_RC_OK) || CMIsNullObject(array)) + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "EnabledLogicalElementCapabilities", + NAMESPACE(reference)); + if (inst == NULL) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to init EnabledLogicalElementCapabilities instance"); + goto out; + } + + CMSetProperty(inst, "InstanceID", (CMPIValue *)name, CMPI_chars); + + array = CMNewArray(broker, 5, CMPI_uint16, s); + if ((s->rc != CMPI_RC_OK) || CMIsNullObject(array)) goto out; element = (uint16_t)ENABLED; @@ -88,56 +95,14 @@ static CMPIStatus set_inst_properties(co CMSetProperty(inst, "ElementNameEditSupported", (CMPIValue *)&edit_name, CMPI_boolean); - out: - return s; -} - -CMPIStatus get_ele_cap(const CMPIBroker *broker, - const CMPIObjectPath *ref, - const char *sys_name, - CMPIInstance **inst) -{ - CMPIStatus s; - CMPIObjectPath *op; - char *classname = NULL; - - classname = get_typed_class(CLASSNAME(ref), - "EnabledLogicalElementCapabilities"); - if (classname == NULL) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Invalid class"); - goto out; - } - - op = CMNewObjectPath(broker, NAMESPACE(ref), classname, &s); - if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Cannot get object path for ELECapabilities"); - goto out; - } - - *inst = CMNewInstance(broker, op, &s); - if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(*inst))) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Failed to instantiate HostSystem"); - goto out; - } - - s = set_inst_properties(broker, *inst, classname, sys_name); - - out: - free(classname); - - return s; -} - -static CMPIStatus return_ele_cap(const CMPIObjectPath *ref, - const CMPIResult *results, - int names_only, - const char *id) + + out: + return inst; +} + +static CMPIStatus return_enum_elec(const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; @@ -154,7 +119,7 @@ static CMPIStatus return_ele_cap(const C count = get_domain_list(conn, &list); if (count <= 0) goto out; - + for (i = 0; i < count; i++) { name = virDomainGetName(list[i]); if (name == NULL) { @@ -163,31 +128,84 @@ static CMPIStatus return_ele_cap(const C "Unable to get domain names"); goto end; } - - if (id && (!STREQ(name, id))) - goto end; - - s = get_ele_cap(_BROKER, ref, name, &inst); + + inst = _get_elec(_BROKER, ref, conn, name, &s); if (s.rc != CMPI_RC_OK) goto end; - + if (names_only) cu_return_instance_name(results, inst); else CMReturnInstance(results, inst); - - end: + + end: virDomainFree(list[i]); - - if ((s.rc != CMPI_RC_OK) || (id && (STREQ(name, id)))) - goto out; } out: free(list); - virConnectClose(conn); + return s; +} + +CMPIStatus get_elec_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn; + virDomainPtr dom; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + dom = virDomainLookupByName(conn, name); + if (dom == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } + + *_inst = _get_elec(broker, reference, conn, name, &s); + + virDomainFree(dom); + + out: + virConnectClose(conn); + + return s; +} + +CMPIStatus get_elec_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + const char *name; + + if (cu_get_str_path(reference, "InstanceID", &name) != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "No InstanceID specified"); + goto out; + } + + s = get_elec_by_name(broker, reference, name, _inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, *_inst); + + out: return s; } @@ -196,7 +214,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_ele_cap(reference, results, 1, NULL); + return return_enum_elec(reference, results, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -206,7 +224,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_ele_cap(reference, results, 0, NULL); + return return_enum_elec(reference, results, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -216,16 +234,16 @@ static CMPIStatus GetInstance(CMPIInstan const char **properties) { CMPIStatus s = {CMPI_RC_OK, NULL}; - const char* id; - - if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No InstanceID specified"); - return s; - } - - return return_ele_cap(reference, results, 0, id); + CMPIInstance *inst = NULL; + + s = get_elec_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: + return s; } DEFAULT_CI(); diff -r 163ff2951cfc -r 0edc1241e58d src/Virt_EnabledLogicalElementCapabilities.h --- a/src/Virt_EnabledLogicalElementCapabilities.h Wed Feb 20 13:13:58 2008 +0100 +++ b/src/Virt_EnabledLogicalElementCapabilities.h Thu Feb 21 12:52:21 2008 +0100 @@ -18,10 +18,15 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -CMPIStatus get_ele_cap(const CMPIBroker *broker, - const CMPIObjectPath *ref, - const char *sys_name, - CMPIInstance **inst); +CMPIStatus get_elec_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst); + +CMPIStatus get_elec_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); + /* * Local Variables: * mode: C From heidieck at linux.vnet.ibm.com Thu Feb 21 12:10:26 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 21 Feb 2008 13:10:26 +0100 Subject: [Libvirt-cim] [PATCH 2 of 2] EC: adopt interface changes to ELEC In-Reply-To: Message-ID: <6fffc34df9c9b5cd1915.1203595826@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203594913 -3600 # Node ID 6fffc34df9c9b5cd1915f1fdd9f196b1f12a2477 # Parent 0edc1241e58d872c251473c424758a425efa19b6 EC: adopt interface changes to ELEC Signed-off-by: Heidi Eckhart diff -r 0edc1241e58d -r 6fffc34df9c9 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Thu Feb 21 12:52:21 2008 +0100 +++ b/src/Virt_ElementCapabilities.c Thu Feb 21 12:55:13 2008 +0100 @@ -216,7 +216,7 @@ static CMPIStatus cs_to_cap(const CMPIOb goto out; } - s = get_ele_cap(_BROKER, ref, sys_name, &inst); + s = get_elec_by_name(_BROKER, ref, sys_name, &inst); if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); @@ -234,6 +234,10 @@ static CMPIStatus cap_to_cs(const CMPIOb CMPIStatus s = {CMPI_RC_OK, NULL}; if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = get_elec_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) goto out; if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) { From heidieck at linux.vnet.ibm.com Thu Feb 21 13:23:34 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 21 Feb 2008 14:23:34 +0100 Subject: [Libvirt-cim] [PATCH] Make sure to set status in eo_parser_xml to avoid crash In-Reply-To: References: Message-ID: <47BD7B56.4010005@linux.vnet.ibm.com> Dan Smith wrote: > @@ -380,6 +386,10 @@ static CMPIStatus parse_instance(const C > CU_DEBUG("Unexpected node: %s\n", child->name); > } > } > Maybe you can define CMPIStatus s = {CMPI_RC_OK, ""}; instead of setting it later. The result would be the same. > + > + cu_statusf(broker, &s, > + CMPI_RC_OK, > + ""); > > out: > free(class); > Other than that ... makes sense and applies fine ... +1. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From danms at us.ibm.com Thu Feb 21 15:29:41 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 21 Feb 2008 07:29:41 -0800 Subject: [Libvirt-cim] arguments issue in indication_tester.py In-Reply-To: (Guo Lian Yun's message of "Thu, 21 Feb 2008 17:45:36 +0800") References: Message-ID: <87ve4ipbtm.fsf@caffeine.beaverton.ibm.com> GY> There are four parameters in define xml of filter, handler and GY> subscription, but only there are passes to them, that *sysname* is GY> missed. The sysname parameter is not missed. It's taken from the URI, which is "localhost:5988" by default. For Pegasus, the URI and the sysname in the XML must be the FQDN of the host system, so you need to specify an appropriate URI with the -u parameter. GY> On the former version of libcmpiutil, only three parameters in GY> their define method. So I don't know what's the original idea of GY> it, three or four arguments? Or it's just a minor mistake. No, it's not a mistake, it's a change required to use the tester against Pegasus :) GY> Below are some parts of code. GY> ... GY> def filter_xml(name, type, ns, sysname): GY> ... GY> def handler_xml(name, port, sysname): GY> ... GY> def subscription_xml(name, sysname): GY> ... GY> def dump_xml(name, typ, ns): GY> filter_str = filter_xml(name, typ, ns) GY> handler_str = handler_xml(name, 8000) GY> subscript_str = subscription_xml(name) GY> ... You should be able to look at the CIMIndicationSubscription, which has "subscribe" and "unsubscribe" methods. Those show the proper way to do the operations. In order to use the code as a module, the CIMIndicationSubscription interface should be all you need and will handle everything for you. GY> Also, I'm not sure of instances deletion order, which including GY> filter, handler and subscription instance. They are created by GY> filter, handler and subscription order, and then deletion order it GY> the same as created in coding. I'm not sure whether the GY> subscription instance have to be deleted firstly. The subscription must be deleted first, followed by the filter and handler (in either order). The code does this correctly. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Thu Feb 21 15:33:11 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 21 Feb 2008 07:33:11 -0800 Subject: [Libvirt-cim] [PATCH] Enhance default setting of property CreationClassName In-Reply-To: <3c39412cd297e3ea3d15.1203595750@localhost.localdomain> (Heidi Eckhart's message of "Thu, 21 Feb 2008 13:09:10 +0100") References: <3c39412cd297e3ea3d15.1203595750@localhost.localdomain> Message-ID: <87r6f6pbns.fsf@caffeine.beaverton.ibm.com> HE> Not all CIM classes define the property CreationClassName. This HE> patch adds a check if CreationClassName is property of the class HE> and sets it only if there. This looks like a good idea to me. I seem to remember SFCB being a bit different in how it initializes new instance properties. Did you test this on SFCB? HE> + data = CMGetProperty(inst, "CreationClassName", &s); HE> + if (s.rc ==CMPI_RC_OK) ^^^^^^^^^^^^ You need some whitespace there. Other than that, I think it's good. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Thu Feb 21 15:44:11 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 21 Feb 2008 07:44:11 -0800 Subject: [Libvirt-cim] [PATCH] Make sure to set status in eo_parser_xml to avoid crash Message-ID: <393e3ca977954e418837.1203608651@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1203608641 28800 # Node ID 393e3ca977954e41883756bc8c1093ed20f2e601 # Parent c19e321766902af6dba29025be964d8d45537c51 Make sure to set status in eo_parser_xml to avoid crash if the caller tries to print the error message. Signed-off-by: Dan Smith diff -r c19e32176690 -r 393e3ca97795 eo_parser_xml.c --- a/eo_parser_xml.c Wed Feb 13 07:45:33 2008 -0800 +++ b/eo_parser_xml.c Thu Feb 21 07:44:01 2008 -0800 @@ -327,7 +327,7 @@ static CMPIStatus parse_instance(const C { char *class = NULL; xmlNode *child; - CMPIStatus s; + CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIObjectPath *op; if (root->type != XML_ELEMENT_NODE) { @@ -360,12 +360,18 @@ static CMPIStatus parse_instance(const C op = CMNewObjectPath(broker, ns, class, &s); if ((op == NULL) || (s.rc != CMPI_RC_OK)) { CU_DEBUG("Unable to create path for %s:%s", ns, class); + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to create path for %s:%s", ns, class); goto out; } *inst = CMNewInstance(broker, op, &s); if ((*inst == NULL) || (s.rc != CMPI_RC_OK)) { CU_DEBUG("Unable to create inst for %s:%s", ns, class); + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to create instance for %s:%s", ns, class); goto out; } From danms at us.ibm.com Thu Feb 21 15:44:45 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 21 Feb 2008 07:44:45 -0800 Subject: [Libvirt-cim] [PATCH] Make sure to set status in eo_parser_xml to avoid crash In-Reply-To: <47BD7B56.4010005@linux.vnet.ibm.com> (Heidi Eckhart's message of "Thu, 21 Feb 2008 14:23:34 +0100") References: <47BD7B56.4010005@linux.vnet.ibm.com> Message-ID: <87mypupb4i.fsf@caffeine.beaverton.ibm.com> HE> Maybe you can define CMPIStatus s = {CMPI_RC_OK, ""}; instead of HE> setting it later. The result would be the same. That was pretty silly of me. I'll resend :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Fri Feb 22 04:22:34 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 21 Feb 2008 20:22:34 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] VSSD: validate client given object path In-Reply-To: References: Message-ID: <47BE4E0A.3080705@linux.vnet.ibm.com> Heidi Eckhart wrote: > # HG changeset patch > # User Heidi Eckhart > # Date 1203507766 -3600 > # Node ID c77500943eae17131c7d0522a99d16b3e2f43489 > # Parent 60e38dd96ca6871856d64056305fc200d718b3a5 > VSSD: validate client given object path > > wbemgi 'http://localhost:5988/root/virt:KVM_VirtualSystemSettingData.InstanceID="Xen:kvm1-f8"' > on a KVM only system is returning an instance, but should not. > > wbemgi 'http://localhost:5988/root/virt:Xen_VirtualSystemSettingData.InstanceID="KVM:kvm1-f8"' > on a KVM only system is seg faulting, but should not ;). > > Signed-off-by: Heidi Eckhart > > diff -r 60e38dd96ca6 -r c77500943eae src/Virt_VSSD.c > - > -static CMPIStatus enum_vssd(const CMPIObjectPath *reference, > - const CMPIResult *results, > - int names_only) > + NAMESPACE(reference)); > + > + if (inst == NULL) { > + cu_statusf(broker, s, > + CMPI_RC_ERR_FAILED, > + "Unable to init VirtualSystemSettingData instance"); > + goto out; > + } > + > + if (!instance_from_dom(dom, inst)) { Probably not worth a resend, but since instance_from_dom() returns an int, this should be if (!instance_from_dom(dom, inst) != 1) { > + > + s = cu_validate_ref(broker, reference, *_inst); If we encounter an error here, do we need to set a status message? > + > + free(name); > + > + out: > + return s; -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Fri Feb 22 04:23:59 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 21 Feb 2008 20:23:59 -0800 Subject: [Libvirt-cim] [PATCH 0 of 3] Enable VSSD to validate client given object path and Adopt changed to VSSD interface to ESD & SDS In-Reply-To: References: Message-ID: <47BE4E5F.2010307@linux.vnet.ibm.com> I'm unable to build with this set applied because VSSDC calls get_vssd_instance(). Otherwise, this set looks good. Awesome job on cleaning up ESD and SDS. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From heidieck at linux.vnet.ibm.com Fri Feb 22 09:18:45 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:18:45 +0100 Subject: [Libvirt-cim] [PATCH] Make sure to set status in eo_parser_xml to avoid crash In-Reply-To: <393e3ca977954e418837.1203608651@caffeine.beaverton.ibm.com> References: <393e3ca977954e418837.1203608651@caffeine.beaverton.ibm.com> Message-ID: <47BE9375.1030600@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1203608641 28800 > # Node ID 393e3ca977954e41883756bc8c1093ed20f2e601 > # Parent c19e321766902af6dba29025be964d8d45537c51 > Make sure to set status in eo_parser_xml to avoid crash > if the caller tries to print the error message. > > Signed-off-by: Dan Smith > +1 :) -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 22 09:30:19 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:30:19 +0100 Subject: [Libvirt-cim] [PATCH 0 of 4] #2 - Enable VSSD to validate client given object path and Adopt changed to VSSD interface to ESD & SDS & VSSDC Message-ID: VSSD does now take care of the client given object path. The resulting interface changes have been adopted to - ESD by the second patch - SDS by the third patch - VSSDC by the fourth patch (diff to patch set 1) From heidieck at linux.vnet.ibm.com Fri Feb 22 09:30:20 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:30:20 +0100 Subject: [Libvirt-cim] [PATCH 1 of 4] VSSD: validate client given object path In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203670718 -3600 # Node ID bcac7f93329a9ab20f7deb1849890e136a77cf5b # Parent d72742466a8892154997d2f210cb9ceeff035962 VSSD: validate client given object path wbemgi 'http://localhost:5988/root/virt:KVM_VirtualSystemSettingData.InstanceID="Xen:kvm1-f8"' on a KVM only system is returning an instance, but should not. wbemgi 'http://localhost:5988/root/virt:Xen_VirtualSystemSettingData.InstanceID="KVM:kvm1-f8"' on a KVM only system is seg faulting, but should not ;). Signed-off-by: Heidi Eckhart diff -r d72742466a88 -r bcac7f93329a src/Virt_VSSD.c --- a/src/Virt_VSSD.c Tue Feb 19 15:29:52 2008 -0800 +++ b/src/Virt_VSSD.c Fri Feb 22 09:58:38 2008 +0100 @@ -135,42 +135,46 @@ static int instance_from_dom(virDomainPt return ret; } -CMPIInstance *get_vssd_instance(virDomainPtr dom, - const CMPIBroker *broker, - const CMPIObjectPath *ref) -{ - CMPIInstance *inst; - +static CMPIInstance *_get_vssd(const CMPIBroker *broker, + const CMPIObjectPath *reference, + virConnectPtr conn, + virDomainPtr dom, + CMPIStatus *s) +{ + CMPIInstance *inst = NULL; + inst = get_typed_instance(broker, - CLASSNAME(ref), + pfx_from_conn(conn), "VirtualSystemSettingData", - NAMESPACE(ref)); - - if (inst == NULL) - return NULL; - - if (instance_from_dom(dom, inst)) - return inst; - else - return NULL; -} - -static CMPIStatus enum_vssd(const CMPIObjectPath *reference, - const CMPIResult *results, - int names_only) + NAMESPACE(reference)); + + if (inst == NULL) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to init VirtualSystemSettingData instance"); + goto out; + } + + if (!instance_from_dom(dom, inst)) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to get VSSD instance from Domain"); + } + + out: + return inst; +} + +static CMPIStatus return_enum_vssd(const CMPIObjectPath *reference, + const CMPIResult *results, + bool names_only) { virConnectPtr conn; virDomainPtr *list; int count; int i; - CMPIStatus s; - const char *ns; - - if (!provider_is_responsible(_BROKER, reference, &s)) - return s; - - ns = NAMESPACE(reference); - + CMPIStatus s = {CMPI_RC_OK, NULL}; + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); if (conn == NULL) return s; @@ -181,60 +185,90 @@ static CMPIStatus enum_vssd(const CMPIOb CMPI_RC_ERR_FAILED, "Failed to enumerate domains"); goto out; - } else if (count == 0) { - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - goto out; - } + } else if (count == 0) + goto out; for (i = 0; i < count; i++) { - CMPIInstance *inst; - - inst = get_vssd_instance(list[i], _BROKER, reference); + CMPIInstance *inst = NULL; + + inst = _get_vssd(_BROKER, reference, conn, list[i], &s); + virDomainFree(list[i]); if (inst == NULL) continue; - + if (names_only) cu_return_instance_name(results, inst); else CMReturnInstance(results, inst); } - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: free(list); return s; - -} - -static CMPIInstance *get_vssd_for_name(const CMPIObjectPath *reference, - char *name) +} + +CMPIStatus get_vssd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst) { virConnectPtr conn; virDomainPtr dom; - CMPIStatus s; - CMPIInstance *inst = NULL; - - conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); - if (conn == NULL) - return NULL; - + CMPIStatus s = {CMPI_RC_OK, NULL}; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + dom = virDomainLookupByName(conn, name); - if (dom == NULL) - goto out; - - inst = get_vssd_instance(dom, _BROKER, reference); - + if (dom == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } + + *_inst = _get_vssd(broker, reference, conn, dom, &s); + + virDomainFree(dom); + out: virConnectClose(conn); - virDomainFree(dom); - - return inst; + + return s; +} + +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + char *name = NULL; + + if (!parse_instanceid(reference, NULL, &name)) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (InstanceID)"); + goto out; + } + + s = get_vssd_by_name(broker, reference, name, _inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, *_inst); + + free(name); + + out: + return s; } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -242,7 +276,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return enum_vssd(reference, results, 1); + return return_enum_vssd(reference, results, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -251,7 +285,7 @@ static CMPIStatus EnumInstances(CMPIInst const CMPIObjectPath *reference, const char **properties) { - return enum_vssd(reference, results, 0); + return return_enum_vssd(reference, results, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -261,26 +295,15 @@ static CMPIStatus GetInstance(CMPIInstan const char **properties) { CMPIStatus s; - CMPIInstance *inst; - char *locid; - - if (!parse_instanceid(reference, NULL, &locid)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Invalid InstanceID specified"); - return s; - } - - inst = get_vssd_for_name(reference, locid); - if (inst) - CMReturnInstance(results, inst); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - - free(locid); - + CMPIInstance *inst = NULL; + + s = get_vssd_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: return s; } diff -r d72742466a88 -r bcac7f93329a src/Virt_VSSD.h --- a/src/Virt_VSSD.h Tue Feb 19 15:29:52 2008 -0800 +++ b/src/Virt_VSSD.h Fri Feb 22 09:58:38 2008 +0100 @@ -21,8 +21,14 @@ #ifndef __VIRT_VSSD_H #define __VIRT_VSSD_H -CMPIInstance *get_vssd_instance(virDomainPtr dom, - const CMPIBroker *broker, - const CMPIObjectPath *ref); +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); + +CMPIStatus get_vssd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst); + #endif From heidieck at linux.vnet.ibm.com Fri Feb 22 09:30:21 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:30:21 +0100 Subject: [Libvirt-cim] [PATCH 2 of 4] ESD: adopt interface changes in VSSD In-Reply-To: Message-ID: <982b5aa81c2f2b2f827f.1203672621@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203670731 -3600 # Node ID 982b5aa81c2f2b2f827fd473755a8d148f0fed56 # Parent bcac7f93329a9ab20f7deb1849890e136a77cf5b ESD: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r bcac7f93329a -r 982b5aa81c2f src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Fri Feb 22 09:58:38 2008 +0100 +++ b/src/Virt_ElementSettingData.c Fri Feb 22 09:58:51 2008 +0100 @@ -41,47 +41,20 @@ static CMPIStatus vssd_to_vssd(const CMP { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; - char *host = NULL; - + if (!match_hypervisor_prefix(ref, info)) return s; - if (!parse_instanceid(ref, NULL, &host)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to get system name"); - goto out; - } - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, host); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such system `%s'", host); - goto out; - } - - inst = get_vssd_instance(dom, _BROKER, ref); - if (inst == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Error getting VSSD for `%s'", host); - goto out; - } - + /* Special association case: + * VSSD instance is pointing to itself + */ + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + inst_list_add(list, inst); - + out: - virDomainFree(dom); - virConnectClose(conn); - free(host); - return s; } From heidieck at linux.vnet.ibm.com Fri Feb 22 09:30:22 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:30:22 +0100 Subject: [Libvirt-cim] [PATCH 3 of 4] SDS: adopt interface changes in VSSD In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203670741 -3600 # Node ID bef4df9bf1109545c067010d83af3b12782632d0 # Parent 982b5aa81c2f2b2f827fd473755a8d148f0fed56 SDS: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r 982b5aa81c2f -r bef4df9bf110 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Fri Feb 22 09:58:51 2008 +0100 +++ b/src/Virt_SettingsDefineState.c Fri Feb 22 09:59:01 2008 +0100 @@ -196,18 +196,16 @@ static CMPIStatus vs_to_vssd(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; const char *name; - CMPIInstance *vssd; - CMPIStatus s = {CMPI_RC_OK, NULL}; - + if (!match_hypervisor_prefix(ref, info)) return s; - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - return s; + + s = get_domain(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "Name", &name) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, @@ -215,28 +213,15 @@ static CMPIStatus vs_to_vssd(const CMPIO "Missing Name property"); goto out; } - - dom = virDomainLookupByName(conn, name); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such domain `%s'", name); - goto out; - } - - vssd = get_vssd_instance(dom, _BROKER, ref); - if (vssd != NULL) - inst_list_add(list, vssd); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - out: - virDomainFree(dom); - virConnectClose(conn); - + + s = get_vssd_by_name(_BROKER, ref, name, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, inst); + + out: return s; - } static CMPIStatus vssd_to_vs(const CMPIObjectPath *ref, @@ -250,9 +235,14 @@ static CMPIStatus vssd_to_vs(const CMPIO virConnectPtr conn = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *cs; + CMPIInstance *inst; if (!match_hypervisor_prefix(ref, info)) return s; + + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, From heidieck at linux.vnet.ibm.com Fri Feb 22 09:30:23 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:30:23 +0100 Subject: [Libvirt-cim] [PATCH 4 of 4] VSSDC: adopt interface changes in VSSD In-Reply-To: Message-ID: <4ff6b2e7bf752cdb4d60.1203672623@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203672204 -3600 # Node ID 4ff6b2e7bf752cdb4d60841e62815740a3deee05 # Parent bef4df9bf1109545c067010d83af3b12782632d0 VSSDC: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r bef4df9bf110 -r 4ff6b2e7bf75 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Fri Feb 22 09:59:01 2008 +0100 +++ b/src/Virt_VSSDComponent.c Fri Feb 22 10:23:24 2008 +0100 @@ -41,6 +41,7 @@ static CMPIStatus vssd_to_rasd(const CMP struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; char *name = NULL; int i = 0; int types[] = { @@ -52,7 +53,11 @@ static CMPIStatus vssd_to_rasd(const CMP }; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; + + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (!parse_instanceid(ref, NULL, &name)) { cu_statusf(_BROKER, &s, @@ -69,48 +74,9 @@ static CMPIStatus vssd_to_rasd(const CMP list); } - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - out: free(name); - return s; -} - -static CMPIStatus vssd_for_name(const char *host, - const CMPIObjectPath *ref, - CMPIInstance **inst) -{ - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; - CMPIStatus s; - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, host); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such system `%s'", host); - goto out; - } - - *inst = get_vssd_instance(dom, _BROKER, ref); - if (*inst == NULL) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Error getting VSSD for `%s'", host); - else - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: - virDomainFree(dom); - virConnectClose(conn); - return s; } @@ -143,9 +109,11 @@ static CMPIStatus rasd_to_vssd(const CMP goto out; } - s = vssd_for_name(host, ref, &vssd); - if (vssd) - inst_list_add(list, vssd); + s = get_vssd_by_name(_BROKER, ref, host, &vssd); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, vssd); out: free(host); From heidieck at linux.vnet.ibm.com Fri Feb 22 09:36:44 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:36:44 +0100 Subject: [Libvirt-cim] [PATCH 1 of 3] VSSD: validate client given object path In-Reply-To: <47BE4E0A.3080705@linux.vnet.ibm.com> References: <47BE4E0A.3080705@linux.vnet.ibm.com> Message-ID: <47BE97AC.4040704@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Heidi Eckhart wrote: >> + } >> + + if (!instance_from_dom(dom, inst)) { > > Probably not worth a resend, but since instance_from_dom() returns an > int, this should be if (!instance_from_dom(dom, inst) != 1) { sure ... I will resend again :) ... sorry, was too fast with my resend #2 and will create a #3 (oops) > > >> + + s = cu_validate_ref(broker, reference, *_inst); > > If we encounter an error here, do we need to set a status message? > The correct status is set by cu_validate_ref() and directly returned to the client. So this is not necessary here. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 22 09:38:07 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:38:07 +0100 Subject: [Libvirt-cim] [PATCH 0 of 4] #3 - Enable VSSD to validate client given object path and Adopt changed to VSSD interface to ESD & SDS & VSSDC Message-ID: VSSD does now take care of the client given object path. The resulting interface changes have been adopted to - ESD by the second patch - SDS by the third patch - VSSDC by the fourth patch (diff to patch set 1) diff to patch set 2: - updated VSSD to compare a returned integer result explicitely From heidieck at linux.vnet.ibm.com Fri Feb 22 09:38:08 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:38:08 +0100 Subject: [Libvirt-cim] [PATCH 1 of 4] VSSD: validate client given object path In-Reply-To: Message-ID: <644476f8ee52477f05fc.1203673088@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203672857 -3600 # Node ID 644476f8ee52477f05fc3080baa517f697497eee # Parent d72742466a8892154997d2f210cb9ceeff035962 VSSD: validate client given object path wbemgi 'http://localhost:5988/root/virt:KVM_VirtualSystemSettingData.InstanceID="Xen:kvm1-f8"' on a KVM only system is returning an instance, but should not. wbemgi 'http://localhost:5988/root/virt:Xen_VirtualSystemSettingData.InstanceID="KVM:kvm1-f8"' on a KVM only system is seg faulting, but should not ;). Signed-off-by: Heidi Eckhart diff -r d72742466a88 -r 644476f8ee52 src/Virt_VSSD.c --- a/src/Virt_VSSD.c Tue Feb 19 15:29:52 2008 -0800 +++ b/src/Virt_VSSD.c Fri Feb 22 10:34:17 2008 +0100 @@ -135,42 +135,46 @@ static int instance_from_dom(virDomainPt return ret; } -CMPIInstance *get_vssd_instance(virDomainPtr dom, - const CMPIBroker *broker, - const CMPIObjectPath *ref) -{ - CMPIInstance *inst; - +static CMPIInstance *_get_vssd(const CMPIBroker *broker, + const CMPIObjectPath *reference, + virConnectPtr conn, + virDomainPtr dom, + CMPIStatus *s) +{ + CMPIInstance *inst = NULL; + inst = get_typed_instance(broker, - CLASSNAME(ref), + pfx_from_conn(conn), "VirtualSystemSettingData", - NAMESPACE(ref)); - - if (inst == NULL) - return NULL; - - if (instance_from_dom(dom, inst)) - return inst; - else - return NULL; -} - -static CMPIStatus enum_vssd(const CMPIObjectPath *reference, - const CMPIResult *results, - int names_only) + NAMESPACE(reference)); + + if (inst == NULL) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to init VirtualSystemSettingData instance"); + goto out; + } + + if (instance_from_dom(dom, inst) != 1) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to get VSSD instance from Domain"); + } + + out: + return inst; +} + +static CMPIStatus return_enum_vssd(const CMPIObjectPath *reference, + const CMPIResult *results, + bool names_only) { virConnectPtr conn; virDomainPtr *list; int count; int i; - CMPIStatus s; - const char *ns; - - if (!provider_is_responsible(_BROKER, reference, &s)) - return s; - - ns = NAMESPACE(reference); - + CMPIStatus s = {CMPI_RC_OK, NULL}; + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); if (conn == NULL) return s; @@ -181,60 +185,90 @@ static CMPIStatus enum_vssd(const CMPIOb CMPI_RC_ERR_FAILED, "Failed to enumerate domains"); goto out; - } else if (count == 0) { - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - goto out; - } + } else if (count == 0) + goto out; for (i = 0; i < count; i++) { - CMPIInstance *inst; - - inst = get_vssd_instance(list[i], _BROKER, reference); + CMPIInstance *inst = NULL; + + inst = _get_vssd(_BROKER, reference, conn, list[i], &s); + virDomainFree(list[i]); if (inst == NULL) continue; - + if (names_only) cu_return_instance_name(results, inst); else CMReturnInstance(results, inst); } - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: free(list); return s; - -} - -static CMPIInstance *get_vssd_for_name(const CMPIObjectPath *reference, - char *name) +} + +CMPIStatus get_vssd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst) { virConnectPtr conn; virDomainPtr dom; - CMPIStatus s; - CMPIInstance *inst = NULL; - - conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); - if (conn == NULL) - return NULL; - + CMPIStatus s = {CMPI_RC_OK, NULL}; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + dom = virDomainLookupByName(conn, name); - if (dom == NULL) - goto out; - - inst = get_vssd_instance(dom, _BROKER, reference); - + if (dom == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } + + *_inst = _get_vssd(broker, reference, conn, dom, &s); + + virDomainFree(dom); + out: virConnectClose(conn); - virDomainFree(dom); - - return inst; + + return s; +} + +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + char *name = NULL; + + if (!parse_instanceid(reference, NULL, &name)) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (InstanceID)"); + goto out; + } + + s = get_vssd_by_name(broker, reference, name, _inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, *_inst); + + free(name); + + out: + return s; } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -242,7 +276,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return enum_vssd(reference, results, 1); + return return_enum_vssd(reference, results, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -251,7 +285,7 @@ static CMPIStatus EnumInstances(CMPIInst const CMPIObjectPath *reference, const char **properties) { - return enum_vssd(reference, results, 0); + return return_enum_vssd(reference, results, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -261,26 +295,15 @@ static CMPIStatus GetInstance(CMPIInstan const char **properties) { CMPIStatus s; - CMPIInstance *inst; - char *locid; - - if (!parse_instanceid(reference, NULL, &locid)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Invalid InstanceID specified"); - return s; - } - - inst = get_vssd_for_name(reference, locid); - if (inst) - CMReturnInstance(results, inst); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - - free(locid); - + CMPIInstance *inst = NULL; + + s = get_vssd_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: return s; } diff -r d72742466a88 -r 644476f8ee52 src/Virt_VSSD.h --- a/src/Virt_VSSD.h Tue Feb 19 15:29:52 2008 -0800 +++ b/src/Virt_VSSD.h Fri Feb 22 10:34:17 2008 +0100 @@ -21,8 +21,14 @@ #ifndef __VIRT_VSSD_H #define __VIRT_VSSD_H -CMPIInstance *get_vssd_instance(virDomainPtr dom, - const CMPIBroker *broker, - const CMPIObjectPath *ref); +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); + +CMPIStatus get_vssd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst); + #endif From heidieck at linux.vnet.ibm.com Fri Feb 22 09:38:10 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:38:10 +0100 Subject: [Libvirt-cim] [PATCH 3 of 4] SDS: adopt interface changes in VSSD In-Reply-To: Message-ID: <5b9393cbce63ab45b6d5.1203673090@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203672860 -3600 # Node ID 5b9393cbce63ab45b6d5be07e1c6d5a866248ca5 # Parent 5713725abc8c466a8d621d90fe00454b7dfb3801 SDS: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r 5713725abc8c -r 5b9393cbce63 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Fri Feb 22 10:34:20 2008 +0100 +++ b/src/Virt_SettingsDefineState.c Fri Feb 22 10:34:20 2008 +0100 @@ -196,18 +196,16 @@ static CMPIStatus vs_to_vssd(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; const char *name; - CMPIInstance *vssd; - CMPIStatus s = {CMPI_RC_OK, NULL}; - + if (!match_hypervisor_prefix(ref, info)) return s; - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - return s; + + s = get_domain(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "Name", &name) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, @@ -215,28 +213,15 @@ static CMPIStatus vs_to_vssd(const CMPIO "Missing Name property"); goto out; } - - dom = virDomainLookupByName(conn, name); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such domain `%s'", name); - goto out; - } - - vssd = get_vssd_instance(dom, _BROKER, ref); - if (vssd != NULL) - inst_list_add(list, vssd); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - out: - virDomainFree(dom); - virConnectClose(conn); - + + s = get_vssd_by_name(_BROKER, ref, name, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, inst); + + out: return s; - } static CMPIStatus vssd_to_vs(const CMPIObjectPath *ref, @@ -250,9 +235,14 @@ static CMPIStatus vssd_to_vs(const CMPIO virConnectPtr conn = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *cs; + CMPIInstance *inst; if (!match_hypervisor_prefix(ref, info)) return s; + + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, From heidieck at linux.vnet.ibm.com Fri Feb 22 09:38:11 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:38:11 +0100 Subject: [Libvirt-cim] [PATCH 4 of 4] VSSDC: adopt interface changes in VSSD In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203672861 -3600 # Node ID b9cbac659a845feda6f170fe23663ea7f187bf21 # Parent 5b9393cbce63ab45b6d5be07e1c6d5a866248ca5 VSSDC: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r 5b9393cbce63 -r b9cbac659a84 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Fri Feb 22 10:34:20 2008 +0100 +++ b/src/Virt_VSSDComponent.c Fri Feb 22 10:34:21 2008 +0100 @@ -41,6 +41,7 @@ static CMPIStatus vssd_to_rasd(const CMP struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; char *name = NULL; int i = 0; int types[] = { @@ -52,7 +53,11 @@ static CMPIStatus vssd_to_rasd(const CMP }; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; + + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (!parse_instanceid(ref, NULL, &name)) { cu_statusf(_BROKER, &s, @@ -69,48 +74,9 @@ static CMPIStatus vssd_to_rasd(const CMP list); } - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - out: free(name); - return s; -} - -static CMPIStatus vssd_for_name(const char *host, - const CMPIObjectPath *ref, - CMPIInstance **inst) -{ - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; - CMPIStatus s; - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, host); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such system `%s'", host); - goto out; - } - - *inst = get_vssd_instance(dom, _BROKER, ref); - if (*inst == NULL) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Error getting VSSD for `%s'", host); - else - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: - virDomainFree(dom); - virConnectClose(conn); - return s; } @@ -143,9 +109,11 @@ static CMPIStatus rasd_to_vssd(const CMP goto out; } - s = vssd_for_name(host, ref, &vssd); - if (vssd) - inst_list_add(list, vssd); + s = get_vssd_by_name(_BROKER, ref, host, &vssd); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, vssd); out: free(host); From heidieck at linux.vnet.ibm.com Fri Feb 22 09:38:09 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:38:09 +0100 Subject: [Libvirt-cim] [PATCH 2 of 4] ESD: adopt interface changes in VSSD In-Reply-To: Message-ID: <5713725abc8c466a8d62.1203673089@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203672860 -3600 # Node ID 5713725abc8c466a8d621d90fe00454b7dfb3801 # Parent 644476f8ee52477f05fc3080baa517f697497eee ESD: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r 644476f8ee52 -r 5713725abc8c src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Fri Feb 22 10:34:17 2008 +0100 +++ b/src/Virt_ElementSettingData.c Fri Feb 22 10:34:20 2008 +0100 @@ -41,47 +41,20 @@ static CMPIStatus vssd_to_vssd(const CMP { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; - char *host = NULL; - + if (!match_hypervisor_prefix(ref, info)) return s; - if (!parse_instanceid(ref, NULL, &host)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to get system name"); - goto out; - } - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, host); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such system `%s'", host); - goto out; - } - - inst = get_vssd_instance(dom, _BROKER, ref); - if (inst == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Error getting VSSD for `%s'", host); - goto out; - } - + /* Special association case: + * VSSD instance is pointing to itself + */ + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + inst_list_add(list, inst); - + out: - virDomainFree(dom); - virConnectClose(conn); - free(host); - return s; } From heidieck at linux.vnet.ibm.com Fri Feb 22 09:40:51 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:40:51 +0100 Subject: [Libvirt-cim] [PATCH 0 of 3] Enable VSSD to validate client given object path and Adopt changed to VSSD interface to ESD & SDS In-Reply-To: <47BE4E5F.2010307@linux.vnet.ibm.com> References: <47BE4E5F.2010307@linux.vnet.ibm.com> Message-ID: <47BE98A3.5040202@linux.vnet.ibm.com> Kaitlin Rupert wrote: > I'm unable to build with this set applied because VSSDC calls > get_vssd_instance(). > That's a very good point ! I was too inattentive when patching the association providers. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 22 09:51:06 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:51:06 +0100 Subject: [Libvirt-cim] [PATCH] Enhance default setting of property CreationClassName In-Reply-To: <87r6f6pbns.fsf@caffeine.beaverton.ibm.com> References: <3c39412cd297e3ea3d15.1203595750@localhost.localdomain> <87r6f6pbns.fsf@caffeine.beaverton.ibm.com> Message-ID: <47BE9B0A.7070305@linux.vnet.ibm.com> Dan Smith wrote: > HE> Not all CIM classes define the property CreationClassName. This > HE> patch adds a check if CreationClassName is property of the class > HE> and sets it only if there. > > This looks like a good idea to me. I seem to remember SFCB being a > bit different in how it initializes new instance properties. Did you > test this on SFCB? > Its tested on sfcb and Pegasus and works for both. > HE> + data = CMGetProperty(inst, "CreationClassName", &s); > HE> + if (s.rc ==CMPI_RC_OK) > ^^^^^^^^^^^^ > > You need some whitespace there. > Hehe ... yes, you are right :) ! -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 22 09:52:44 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 10:52:44 +0100 Subject: [Libvirt-cim] [PATCH] Enhance default setting of property CreationClassName Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203673820 -3600 # Node ID e6f0c8edd6bf2fff9681195e3edc8c1d601fe78f # Parent b9cbac659a845feda6f170fe23663ea7f187bf21 Enhance default setting of property CreationClassName Not all CIM classes define the property CreationClassName. This patch adds a check if CreationClassName is property of the class and sets it only if there. Signed-off-by: Heidi Eckhart diff -r b9cbac659a84 -r e6f0c8edd6bf libxkutil/misc_util.c --- a/libxkutil/misc_util.c Fri Feb 22 10:34:21 2008 +0100 +++ b/libxkutil/misc_util.c Fri Feb 22 10:50:20 2008 +0100 @@ -236,6 +236,7 @@ CMPIInstance *get_typed_instance(const C CMPIObjectPath *op; CMPIInstance *inst = NULL; CMPIStatus s; + CMPIData data; new_cn = get_typed_class(refcn, base); if (new_cn == NULL) @@ -248,9 +249,11 @@ CMPIInstance *get_typed_instance(const C inst = CMNewInstance(broker, op, &s); if ((s.rc != CMPI_RC_OK) || CMIsNullObject(inst)) goto out; - - CMSetProperty(inst, "CreationClassName", - (CMPIValue *)new_cn, CMPI_chars); + + data = CMGetProperty(inst, "CreationClassName", &s); + if (s.rc == CMPI_RC_OK) + CMSetProperty(inst, "CreationClassName", + (CMPIValue *)new_cn, CMPI_chars); out: free(new_cn); From yunguol at cn.ibm.com Fri Feb 22 10:09:15 2008 From: yunguol at cn.ibm.com (Guo Lian Yun) Date: Fri, 22 Feb 2008 18:09:15 +0800 Subject: [Libvirt-cim] Got indication on sfcb successfully, but still in watching status on Pegasus Message-ID: Hi, I can get indication of Xen_ComputerSystemCreatedIndication successfully after define a new domain, which done by "python indication_tester.py Xen_ComputerSystemCreateddIndication" on sfcb. On Pegasus, we have to pass three arguments at least, right? Below is the execution command: "python indication_tester.py -u localhost:5988 -U root -P password Xen_ComputerSystemDeletedIndication". However, it's still in watching status, and I can't get any info for several minutes. Who knows why it is? Is there some mistake in my operation on Pegasus? Thanks! Best, Regards Daisy Guo Lian Yun E-mail: yunguol at cn.ibm.com IBM China Development Lab, Shanghai, China TEL: (86)-21-61008057 -------------- next part -------------- An HTML attachment was scrubbed... URL: From heidieck at linux.vnet.ibm.com Fri Feb 22 12:04:31 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 13:04:31 +0100 Subject: [Libvirt-cim] [PATCH 0 of 5] Add get_rasd_... functions to RASD and adopt interface changes to assocs Message-ID: Added get_rasd_by_ref() and get_rasd_by_name() to RASD provider to clean up / fasten the access to a specific RASD instance. This interface change has been adopted by the appropriate associaton providers, who need this access. From heidieck at linux.vnet.ibm.com Fri Feb 22 12:04:32 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 13:04:32 +0100 Subject: [Libvirt-cim] [PATCH 1 of 5] RASD: add function get_rasd_by_ref() for usage in associations In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203681287 -3600 # Node ID d67ec3ae8446a3c9e68b36e511f63ef292689a8c # Parent 46e9fe0ea3e8dca8ad930b77f8171f744928f00c RASD: add function get_rasd_by_ref() for usage in associations Signed-off-by: Heidi Eckhart diff -r 46e9fe0ea3e8 -r d67ec3ae8446 src/Virt_RASD.c --- a/src/Virt_RASD.c Fri Feb 22 10:54:01 2008 +0100 +++ b/src/Virt_RASD.c Fri Feb 22 12:54:47 2008 +0100 @@ -357,38 +357,92 @@ static CMPIInstance *rasd_from_vdev(cons return inst; } -CMPIInstance *get_rasd_instance(const CMPIContext *context, - const CMPIObjectPath *ref, - const CMPIBroker *broker, - const char *id, - const uint16_t type) +CMPIStatus get_rasd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + const uint16_t type, + CMPIInstance **_inst) { CMPIInstance *inst = NULL; - CMPIStatus s; + CMPIStatus s = {CMPI_RC_OK, NULL}; int ret; char *host = NULL; char *devid = NULL; virConnectPtr conn = NULL; struct virt_device *dev; - ret = parse_fq_devid((char *)id, &host, &devid); - if (!ret) - return NULL; - - conn = connect_by_classname(broker, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + ret = parse_fq_devid((char *)name, &host, &devid); + if (ret != 1) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } dev = find_dev(conn, type, host, devid); - if (dev) - inst = rasd_from_vdev(broker, dev, host, ref); - + if (!dev) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } + + inst = rasd_from_vdev(broker, dev, host, reference); + if (inst == NULL) + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Failed to set instance properties"); + else + *_inst = inst; + out: virConnectClose(conn); free(host); free(devid); - return inst; + return s; +} + +CMPIStatus get_rasd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + const char *name = NULL; + uint16_t type; + + if (cu_get_str_path(reference, "InstanceID", &name) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Missing InstanceID"); + goto out; + } + + if (rasd_type_from_classname(CLASSNAME(reference), &type) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to determine RASD type"); + goto out; + } + + s = get_rasd_by_name(broker, reference, name, type, _inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, *_inst); + + out: + return s; } CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type) @@ -544,32 +598,14 @@ static CMPIStatus GetInstance(CMPIInstan const char **properties) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - const char *id = NULL; - uint16_t type; - - if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Missing InstanceID"); - goto out; - } - - if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to determine RASD type"); - goto out; - } - - inst = get_rasd_instance(context, ref, _BROKER, id, type); - - if (inst != NULL) - CMReturnInstance(results, inst); - else - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", id); + CMPIInstance *inst = NULL; + + s = get_rasd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + out: return s; } diff -r 46e9fe0ea3e8 -r d67ec3ae8446 src/Virt_RASD.h --- a/src/Virt_RASD.h Fri Feb 22 10:54:01 2008 +0100 +++ b/src/Virt_RASD.h Fri Feb 22 12:54:47 2008 +0100 @@ -42,11 +42,15 @@ CMPIrc rasd_type_from_classname(const ch CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type); CMPIrc rasd_classname_from_type(uint16_t type, const char **cn); -CMPIInstance *get_rasd_instance(const CMPIContext *context, - const CMPIObjectPath *ref, - const CMPIBroker *broker, - const char *id, - const uint16_t type); +CMPIStatus get_rasd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + const uint16_t type, + CMPIInstance **_inst); + +CMPIStatus get_rasd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); #endif From heidieck at linux.vnet.ibm.com Fri Feb 22 12:04:33 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 13:04:33 +0100 Subject: [Libvirt-cim] [PATCH 2 of 5] VSMS: adopt interface changes of RASD In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203681290 -3600 # Node ID acb930f1a7c5886d906e30b524d09d4844bbffa3 # Parent d67ec3ae8446a3c9e68b36e511f63ef292689a8c VSMS: adopt interface changes of RASD Signed-off-by: Heidi Eckhart diff -r d67ec3ae8446 -r acb930f1a7c5 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Fri Feb 22 12:54:47 2008 +0100 +++ b/src/Virt_VirtualSystemManagementService.c Fri Feb 22 12:54:50 2008 +0100 @@ -1000,7 +1000,7 @@ static CMPIStatus rasd_refs_to_insts(con CMPIArray *arr, CMPIArray **ret_arr) { - CMPIStatus s; + CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIArray *tmp_arr; int i; int c; @@ -1017,7 +1017,7 @@ static CMPIStatus rasd_refs_to_insts(con for (i = 0; i < c; i++) { CMPIData d; CMPIObjectPath *ref; - CMPIInstance *inst; + CMPIInstance *inst = NULL; const char *id; uint16_t type; @@ -1041,21 +1041,18 @@ static CMPIStatus rasd_refs_to_insts(con continue; } - inst = get_rasd_instance(ctx, reference, _BROKER, id, type); - if (inst != NULL) - CMSetArrayElementAt(tmp_arr, i, - &inst, - CMPI_instance); - else - CU_DEBUG("Failed to get instance for `%s'", - REF2STR(ref)); - } - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); + s = get_rasd_by_name(_BROKER, reference, id, type, &inst); + if (s.rc != CMPI_RC_OK) + continue; + + CMSetArrayElementAt(tmp_arr, i, + &inst, + CMPI_instance); + + } + *ret_arr = tmp_arr; - + return s; } From heidieck at linux.vnet.ibm.com Fri Feb 22 12:04:34 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 13:04:34 +0100 Subject: [Libvirt-cim] [PATCH 3 of 5] SDS: adopt interface changes of RASD In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203681291 -3600 # Node ID e12a643f2af88b12b3031de23bb3fd5698badaba # Parent acb930f1a7c5886d906e30b524d09d4844bbffa3 SDS: adopt interface changes of RASD Signed-off-by: Heidi Eckhart diff -r acb930f1a7c5 -r e12a643f2af8 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Fri Feb 22 12:54:50 2008 +0100 +++ b/src/Virt_SettingsDefineState.c Fri Feb 22 12:54:51 2008 +0100 @@ -159,6 +159,7 @@ static CMPIStatus rasd_to_dev(const CMPI { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *dev = NULL; + CMPIInstance *inst = NULL; const char *id = NULL; uint16_t type; @@ -178,6 +179,10 @@ static CMPIStatus rasd_to_dev(const CMPI "Missing ResourceType"); goto out; } + + s = get_rasd_by_name(_BROKER, ref, id, type, &inst); + if (s.rc != CMPI_RC_OK) + goto out; dev = _get_typed_device(id, type, ref, &s); if (dev == NULL) @@ -185,9 +190,6 @@ static CMPIStatus rasd_to_dev(const CMPI inst_list_add(list, dev); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: return s; } From heidieck at linux.vnet.ibm.com Fri Feb 22 12:04:35 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 13:04:35 +0100 Subject: [Libvirt-cim] [PATCH 4 of 5] RAFP: adopt interface changes to RASD In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203681292 -3600 # Node ID d31116669eb24e1ff8691a33b4c1d5a91421fd20 # Parent e12a643f2af88b12b3031de23bb3fd5698badaba RAFP: adopt interface changes to RASD Signed-off-by: Heidi Eckhart diff -r e12a643f2af8 -r d31116669eb2 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Fri Feb 22 12:54:51 2008 +0100 +++ b/src/Virt_ResourceAllocationFromPool.c Fri Feb 22 12:54:52 2008 +0100 @@ -37,28 +37,6 @@ const static CMPIBroker *_BROKER; -static CMPIStatus validate_rasd_ref(const CMPIContext *context, - const CMPIObjectPath *ref, - uint16_t type, - const char *id) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *rasd = NULL; - - rasd = get_rasd_instance(context, - ref, - _BROKER, - id, - type); - - if (CMIsNullObject(rasd)) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", id); - - return s; -} - static CMPIStatus rasd_to_pool(const CMPIObjectPath *ref, struct std_assoc_info *info, struct inst_list *list) @@ -69,6 +47,7 @@ static CMPIStatus rasd_to_pool(const CMP char *poolid = NULL; virConnectPtr conn = NULL; CMPIInstance *pool = NULL; + CMPIInstance *inst = NULL; if (!match_hypervisor_prefix(ref, info)) return s; @@ -87,10 +66,7 @@ static CMPIStatus rasd_to_pool(const CMP goto out; } - s = validate_rasd_ref(info->context, - ref, - type, - id); + s = get_rasd_by_name(_BROKER, ref, id, type, &inst); if (s.rc != CMPI_RC_OK) goto out; From heidieck at linux.vnet.ibm.com Fri Feb 22 12:04:36 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 22 Feb 2008 13:04:36 +0100 Subject: [Libvirt-cim] [PATCH 5 of 5] ESD: adopt interface changes to RASD In-Reply-To: Message-ID: <6f70bca8f5caf8f7ff3e.1203681876@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203681292 -3600 # Node ID 6f70bca8f5caf8f7ff3eeaede8112dca27b3b072 # Parent d31116669eb24e1ff8691a33b4c1d5a91421fd20 ESD: adopt interface changes to RASD Signed-off-by: Heidi Eckhart diff -r d31116669eb2 -r 6f70bca8f5ca src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Fri Feb 22 12:54:52 2008 +0100 +++ b/src/Virt_ElementSettingData.c Fri Feb 22 12:54:52 2008 +0100 @@ -63,38 +63,20 @@ static CMPIStatus rasd_to_rasd(const CMP struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - const char *id = NULL; - uint16_t type; + CMPIInstance *inst = NULL; if (!match_hypervisor_prefix(ref, info)) return s; - if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Missing InstanceID"); + /* Special association case: + * RASD instance is pointing to itself + */ + s = get_rasd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) goto out; - } - - if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to determine RASD type"); - goto out; - } - - inst = get_rasd_instance(info->context, ref, _BROKER, id, type); - if (inst == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Error getting associated RASD"); - - goto out; - } - + inst_list_add(list, inst); - + out: return s; } From danms at us.ibm.com Fri Feb 22 14:55:44 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 22 Feb 2008 06:55:44 -0800 Subject: [Libvirt-cim] Got indication on sfcb successfully, but still in watching status on Pegasus In-Reply-To: (Guo Lian Yun's message of "Fri, 22 Feb 2008 18:09:15 +0800") References: Message-ID: <87fxvlniq7.fsf@caffeine.beaverton.ibm.com> GY> On Pegasus, we have to pass three arguments at least, right? Below is the GY> execution command: GY> "python indication_tester.py -u localhost:5988 -U root -P password You *must* use the FQDN for Pegasus. Using localhost will not work. If you're unsure, use the output of "hostname -f". -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Fri Feb 22 15:57:25 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 22 Feb 2008 07:57:25 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] Enable ELEC to validate client given object path and Adopt changed to ELEC interface to EC In-Reply-To: References: Message-ID: <47BEF0E5.6030506@linux.vnet.ibm.com> Heidi Eckhart wrote: > ELEC does now take care of the client given object path. > The resulting interface changes have been adopted to EC by the second patch > This set looks good. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Fri Feb 22 16:15:05 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 22 Feb 2008 08:15:05 -0800 Subject: [Libvirt-cim] [PATCH 0 of 4] #3 - Enable VSSD to validate client given object path and Adopt changed to VSSD interface to ESD & SDS & VSSDC In-Reply-To: References: Message-ID: <47BEF509.5080102@linux.vnet.ibm.com> Heidi Eckhart wrote: > VSSD does now take care of the client given object path. > The resulting interface changes have been adopted to > - ESD by the second patch > - SDS by the third patch > - VSSDC by the fourth patch (diff to patch set 1) > > diff to patch set 2: > - updated VSSD to compare a returned integer result explicitely > This set tested out fine on my system. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Fri Feb 22 16:17:52 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 22 Feb 2008 08:17:52 -0800 Subject: [Libvirt-cim] [PATCH] Enhance default setting of property CreationClassName In-Reply-To: References: Message-ID: <47BEF5B0.6030707@linux.vnet.ibm.com> Heidi Eckhart wrote: > # HG changeset patch > # User Heidi Eckhart > # Date 1203673820 -3600 > # Node ID e6f0c8edd6bf2fff9681195e3edc8c1d601fe78f > # Parent b9cbac659a845feda6f170fe23663ea7f187bf21 > Enhance default setting of property CreationClassName > > Not all CIM classes define the property CreationClassName. > This patch adds a check if CreationClassName is property of > the class and sets it only if there. > Signed-off-by: Heidi Eckhart > This is a nice catch! +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Fri Feb 22 16:46:59 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 22 Feb 2008 08:46:59 -0800 Subject: [Libvirt-cim] [PATCH 0 of 5] Add get_rasd_... functions to RASD and adopt interface changes to assocs In-Reply-To: References: Message-ID: <47BEFC83.6000508@linux.vnet.ibm.com> Heidi Eckhart wrote: > Added get_rasd_by_ref() and get_rasd_by_name() to RASD provider to clean up / fasten the access to a specific RASD instance. > This interface change has been adopted by the appropriate associaton providers, who need this access. I really like this set of changes. It condenses a lot of the code, which makes the resulting files easier to read. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Fri Feb 22 18:13:32 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 22 Feb 2008 10:13:32 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add property filtering to RASD provider In-Reply-To: Message-ID: <2bff66d74872c62ef38f.1203704012@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1203702578 28800 # Node ID 2bff66d74872c62ef38fca81fafd32f0d7fb126a # Parent d02f5729977381ec6f5aec3503dc5f970a428b88 Add property filtering to RASD provider. wbemcli is unable to parse embedded instance arrays, so this additional property filtering support will allow queries to exclude the HostResource property. Failing Query: wbemcli ei http://localhost/root/virt:Xen_ProcResourceAllocationSettingData * * wbemcli: Parse Exception: Unknown attribute in list for PROPERTY.ARRAY (EMBEDDEDOB) Passing Query: wbemcli ei http://localhost/root/virt:Xen_ProcResourceAllocationSettingData ResourceType Signed-off-by: Kaitlin Rupert diff -r d02f57299773 -r 2bff66d74872 src/Virt_RASD.c --- a/src/Virt_RASD.c Fri Feb 22 12:54:52 2008 +0100 +++ b/src/Virt_RASD.c Fri Feb 22 09:49:38 2008 -0800 @@ -283,8 +283,10 @@ static CMPIInstance *rasd_from_vdev(cons static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, - const CMPIObjectPath *ref) -{ + const CMPIObjectPath *ref, + const char **properties) +{ + CMPIStatus s; CMPIInstance *inst; uint16_t type; char *base; @@ -312,6 +314,14 @@ static CMPIInstance *rasd_from_vdev(cons NAMESPACE(ref)); if (inst == NULL) return inst; + + if (properties != NULL) { + const char *keys[] = {"InstanceID", NULL}; + s = CMSetPropertyFilter(inst, properties, keys); + /* FIXME - in case of an error, should we continue on? */ + if (s.rc != CMPI_RC_OK) + CU_DEBUG("Unable to set property filter: %d", s.rc); + } id = get_fq_devid((char *)host, dev->id); @@ -361,6 +371,7 @@ CMPIStatus get_rasd_by_name(const CMPIBr const CMPIObjectPath *reference, const char *name, const uint16_t type, + const char **properties, CMPIInstance **_inst) { CMPIInstance *inst = NULL; @@ -397,7 +408,7 @@ CMPIStatus get_rasd_by_name(const CMPIBr goto out; } - inst = rasd_from_vdev(broker, dev, host, reference); + inst = rasd_from_vdev(broker, dev, host, reference, properties); if (inst == NULL) cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, @@ -415,6 +426,7 @@ CMPIStatus get_rasd_by_name(const CMPIBr CMPIStatus get_rasd_by_ref(const CMPIBroker *broker, const CMPIObjectPath *reference, + const char **properties, CMPIInstance **_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -435,7 +447,7 @@ CMPIStatus get_rasd_by_ref(const CMPIBro goto out; } - s = get_rasd_by_name(broker, reference, name, type, _inst); + s = get_rasd_by_name(broker, reference, name, type, properties, _inst); if (s.rc != CMPI_RC_OK) goto out; @@ -498,6 +510,7 @@ CMPIrc rasd_classname_from_type(uint16_t } static CMPIStatus _enum_rasds(const CMPIObjectPath *ref, + const char **properties, struct inst_list *list) { virConnectPtr conn = NULL; @@ -537,6 +550,7 @@ static CMPIStatus _enum_rasds(const CMPI virDomainGetName(domains[i]), types[j], ref, + properties, list); } virDomainFree(domains[i]); @@ -553,6 +567,7 @@ static CMPIStatus _enum_rasds(const CMPI static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref, const CMPIResult *results, + const char **properties, const bool names_only) { struct inst_list list; @@ -560,7 +575,7 @@ static CMPIStatus return_enum_rasds(cons inst_list_init(&list); - s = _enum_rasds(ref, &list); + s = _enum_rasds(ref, properties, &list); if (s.rc == CMPI_RC_OK) { if (names_only) cu_return_instance_names(results, &list); @@ -578,7 +593,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_enum_rasds(reference, results, true); + return return_enum_rasds(reference, results, NULL, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -588,7 +603,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_enum_rasds(reference, results, false); + return return_enum_rasds(reference, results, properties, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -600,7 +615,7 @@ static CMPIStatus GetInstance(CMPIInstan CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; - s = get_rasd_by_ref(_BROKER, ref, &inst); + s = get_rasd_by_ref(_BROKER, ref, properties, &inst); if (s.rc != CMPI_RC_OK) goto out; @@ -614,6 +629,7 @@ int rasds_for_domain(const CMPIBroker *b const char *name, const uint16_t type, const CMPIObjectPath *ref, + const char **properties, struct inst_list *_list) { struct virt_device *list; @@ -631,7 +647,7 @@ int rasds_for_domain(const CMPIBroker *b for (i = 0; i < count; i++) { CMPIInstance *inst; - inst = rasd_from_vdev(broker, &list[i], name, ref); + inst = rasd_from_vdev(broker, &list[i], name, ref, properties); if (inst != NULL) inst_list_add(_list, inst); } diff -r d02f57299773 -r 2bff66d74872 src/Virt_RASD.h --- a/src/Virt_RASD.h Fri Feb 22 12:54:52 2008 +0100 +++ b/src/Virt_RASD.h Fri Feb 22 09:49:38 2008 -0800 @@ -37,6 +37,7 @@ int rasds_for_domain(const CMPIBroker *b const char *name, const uint16_t type, const CMPIObjectPath *ref, + const char **properties, struct inst_list *_list); CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type); @@ -46,10 +47,12 @@ CMPIStatus get_rasd_by_name(const CMPIBr const CMPIObjectPath *reference, const char *name, const uint16_t type, + const char **properties, CMPIInstance **_inst); CMPIStatus get_rasd_by_ref(const CMPIBroker *broker, const CMPIObjectPath *reference, + const char **properties, CMPIInstance **_inst); #endif From kaitlin at linux.vnet.ibm.com Fri Feb 22 18:13:33 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 22 Feb 2008 10:13:33 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Update providers that call rasd_for_domain() and get_rasd_instance() In-Reply-To: Message-ID: <743b306e9bc680cab97c.1203704013@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1203702667 28800 # Node ID 743b306e9bc680cab97c2afb60dfe9547e1d182c # Parent 2bff66d74872c62ef38fca81fafd32f0d7fb126a Update providers that call rasd_for_domain() and get_rasd_instance(). Signed-off-by: Kaitlin Rupert diff -r 2bff66d74872 -r 743b306e9bc6 src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Fri Feb 22 09:49:38 2008 -0800 +++ b/src/Virt_ElementSettingData.c Fri Feb 22 09:51:07 2008 -0800 @@ -98,7 +98,7 @@ static CMPIStatus rasd_to_rasd(const CMP /* Special association case: * RASD instance is pointing to itself */ - s = get_rasd_by_ref(_BROKER, ref, &inst); + s = get_rasd_by_ref(_BROKER, ref, info->properties, &inst); if (s.rc != CMPI_RC_OK) goto out; diff -r 2bff66d74872 -r 743b306e9bc6 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Fri Feb 22 09:49:38 2008 -0800 +++ b/src/Virt_ResourceAllocationFromPool.c Fri Feb 22 09:51:07 2008 -0800 @@ -66,7 +66,7 @@ static CMPIStatus rasd_to_pool(const CMP goto out; } - s = get_rasd_by_name(_BROKER, ref, id, type, &inst); + s = get_rasd_by_name(_BROKER, ref, id, type, NULL, &inst); if (s.rc != CMPI_RC_OK) goto out; @@ -138,6 +138,7 @@ static int rasds_from_pool(uint16_t type static int rasds_from_pool(uint16_t type, const CMPIObjectPath *ref, const char *poolid, + const char **properties, struct inst_list *list) { CMPIStatus s; @@ -164,6 +165,7 @@ static int rasds_from_pool(uint16_t type name, type, ref, + properties, &tmp); filter_by_pool(list, &tmp, poolid); @@ -213,6 +215,7 @@ static CMPIStatus pool_to_rasd(const CMP rasds_from_pool(type, ref, poolid, + info->properties, list); cu_statusf(_BROKER, &s, diff -r 2bff66d74872 -r 743b306e9bc6 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Fri Feb 22 09:49:38 2008 -0800 +++ b/src/Virt_SettingsDefineState.c Fri Feb 22 09:51:07 2008 -0800 @@ -98,6 +98,7 @@ static CMPIStatus dev_to_rasd(const CMPI name, device_type_from_classname(CLASSNAME(ref)), ref, + info->properties, &rasds); rasd = find_rasd(&rasds, id); @@ -180,7 +181,7 @@ static CMPIStatus rasd_to_dev(const CMPI goto out; } - s = get_rasd_by_name(_BROKER, ref, id, type, &inst); + s = get_rasd_by_name(_BROKER, ref, id, type, NULL, &inst); if (s.rc != CMPI_RC_OK) goto out; diff -r 2bff66d74872 -r 743b306e9bc6 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Fri Feb 22 09:49:38 2008 -0800 +++ b/src/Virt_VSSDComponent.c Fri Feb 22 09:51:07 2008 -0800 @@ -66,6 +66,7 @@ static CMPIStatus vssd_to_rasd(const CMP name, types[i], ref, + info->properties, list); } diff -r 2bff66d74872 -r 743b306e9bc6 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Fri Feb 22 09:49:38 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Fri Feb 22 09:51:07 2008 -0800 @@ -1041,7 +1041,7 @@ static CMPIStatus rasd_refs_to_insts(con continue; } - s = get_rasd_by_name(_BROKER, reference, id, type, &inst); + s = get_rasd_by_name(_BROKER, reference, id, type, NULL, &inst); if (s.rc != CMPI_RC_OK) continue; From kaitlin at linux.vnet.ibm.com Fri Feb 22 18:13:31 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 22 Feb 2008 10:13:31 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] [RFC] Add property filtering to RASD. Message-ID: This patchset is built on top of Heidi's RASD patches. From danms at us.ibm.com Fri Feb 22 19:24:33 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 22 Feb 2008 11:24:33 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] ELEC: seg faults by wrong client given object path In-Reply-To: <0edc1241e58d872c2514.1203595825@localhost.localdomain> (Heidi Eckhart's message of "Thu, 21 Feb 2008 13:10:25 +0100") References: <0edc1241e58d872c2514.1203595825@localhost.localdomain> Message-ID: <87pruon6a6.fsf@caffeine.beaverton.ibm.com> HE> + s = get_elec_by_name(broker, reference, name, _inst); HE> + if (s.rc != CMPI_RC_OK) HE> + goto out; HE> + HE> + s = cu_validate_ref(broker, reference, *_inst); HE> + Assuming the caller checks the status, there shouldn't be an issue, but maybe we shouldn't set _inst until we've validated the path? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Fri Feb 22 19:38:42 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 22 Feb 2008 11:38:42 -0800 Subject: [Libvirt-cim] [PATCH 1 of 4] VSSD: validate client given object path In-Reply-To: <644476f8ee52477f05fc.1203673088@localhost.localdomain> (Heidi Eckhart's message of "Fri, 22 Feb 2008 10:38:08 +0100") References: <644476f8ee52477f05fc.1203673088@localhost.localdomain> Message-ID: <87lk5cn5ml.fsf@caffeine.beaverton.ibm.com> HE> dom = virDomainLookupByName(conn, name); HE> - if (dom == NULL) HE> - goto out; HE> - HE> - inst = get_vssd_instance(dom, _BROKER, reference); HE> - HE> + if (dom == NULL) { HE> + cu_statusf(broker, &s, HE> + CMPI_RC_ERR_NOT_FOUND, HE> + "No such instance (%s)", HE> + name); HE> + goto out; I think you leak dom here, since you moved the virDomainFree before the out target: HE> + } HE> + HE> + *_inst = _get_vssd(broker, reference, conn, dom, &s); HE> + HE> + virDomainFree(dom); HE> + HE> out: HE> virConnectClose(conn); HE> - virDomainFree(dom); HE> - HE> - return inst; HE> + HE> + return s; HE> +} ... HE> +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, HE> + const CMPIObjectPath *reference, HE> + CMPIInstance **_inst) HE> +{ HE> + CMPIStatus s = {CMPI_RC_OK, NULL}; HE> + char *name = NULL; HE> + HE> + if (!parse_instanceid(reference, NULL, &name)) { HE> + cu_statusf(broker, &s, HE> + CMPI_RC_ERR_NOT_FOUND, HE> + "No such instance (InstanceID)"); HE> + goto out; HE> + } HE> + HE> + s = get_vssd_by_name(broker, reference, name, _inst); HE> + if (s.rc != CMPI_RC_OK) HE> + goto out; You leak name here because the free is before the out: HE> + HE> + s = cu_validate_ref(broker, reference, *_inst); HE> + HE> + free(name); HE> + HE> + out: HE> + return s; HE> } -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Fri Feb 22 19:54:11 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 22 Feb 2008 11:54:11 -0800 Subject: [Libvirt-cim] [PATCH 1 of 5] RASD: add function get_rasd_by_ref() for usage in associations In-Reply-To: (Heidi Eckhart's message of "Fri, 22 Feb 2008 13:04:32 +0100") References: Message-ID: <87hcg0n4ws.fsf@caffeine.beaverton.ibm.com> HE> + s = get_rasd_by_name(broker, reference, name, type, _inst); HE> + if (s.rc != CMPI_RC_OK) HE> + goto out; HE> + HE> + s = cu_validate_ref(broker, reference, *_inst); HE> + HE> + out: HE> + return s; HE> } Potentially the same change is required here, depending on your thoughts on my previous comment :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Fri Feb 22 20:05:53 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 22 Feb 2008 12:05:53 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add property filtering to RASD provider In-Reply-To: <2bff66d74872c62ef38f.1203704012@elm3b41.beaverton.ibm.com> (Kaitlin Rupert's message of "Fri, 22 Feb 2008 10:13:32 -0800") References: <2bff66d74872c62ef38f.1203704012@elm3b41.beaverton.ibm.com> Message-ID: <87d4qon4da.fsf@caffeine.beaverton.ibm.com> KR> + const char *keys[] = {"InstanceID", NULL}; KR> + s = CMSetPropertyFilter(inst, properties, keys); KR> + /* FIXME - in case of an error, should we continue on? */ I think we should do exactly what you have: log a message and continue on. I doubt much more will work if this part fails (due to memory or something), so the error will be caught later. If it's unrelated and the rest can proceed, I think that's better than dying here, since the property filter is really just an optimization. Since we don't do it anywhere else, a failure here will just make RASD behave like everything else :) +1 from me. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Sat Feb 23 02:47:38 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 22 Feb 2008 18:47:38 -0800 Subject: [Libvirt-cim] [PATCH] EC seg faults due to wrong CMPIBroker used in get_vsm_cap() Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1203733266 28800 # Node ID b950586612cfddcc119e0c0d2a53faaf06a1d8c9 # Parent 743b306e9bc680cab97c2afb60dfe9547e1d182c EC seg faults due to wrong CMPIBroker used in get_vsm_cap(). Also, make sure function returns in case of error, and shorten error meesage since it spans a line. Signed-off-by: Kaitlin Rupert diff -r 743b306e9bc6 -r b950586612cf src/Virt_VirtualSystemManagementCapabilities.c --- a/src/Virt_VirtualSystemManagementCapabilities.c Fri Feb 22 09:51:07 2008 -0800 +++ b/src/Virt_VirtualSystemManagementCapabilities.c Fri Feb 22 18:21:06 2008 -0800 @@ -95,14 +95,16 @@ CMPIStatus get_vsm_cap(const CMPIBroker goto out; } - inst = get_typed_instance(_BROKER, + inst = get_typed_instance(broker, pfx_from_conn(conn), "VirtualSystemManagementCapabilities", NAMESPACE(ref)); - if (inst == NULL) - cu_statusf(_BROKER, &s, + if (inst == NULL) { + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, - "Can't create VirtualSystemManagementCapabilities instance"); + "Can't create instance for %s", CLASSNAME(ref)); + goto out; + } s = set_inst_properties(broker, inst); From heidieck at linux.vnet.ibm.com Mon Feb 25 09:59:46 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 10:59:46 +0100 Subject: [Libvirt-cim] [PATCH 1 of 4] VSSD: validate client given object path In-Reply-To: <87lk5cn5ml.fsf@caffeine.beaverton.ibm.com> References: <644476f8ee52477f05fc.1203673088@localhost.localdomain> <87lk5cn5ml.fsf@caffeine.beaverton.ibm.com> Message-ID: <47C29192.7090401@linux.vnet.ibm.com> Dan Smith wrote: > HE> + if (dom == NULL) { > HE> + cu_statusf(broker, &s, > HE> + CMPI_RC_ERR_NOT_FOUND, > HE> + "No such instance (%s)", > HE> + name); > HE> + goto out; > > I think you leak dom here, since you moved the virDomainFree before > the out target: > Mhh, I think not. If dom==NULL we "goto out". If dom is there, then _get_vssd() is called and virDomainFree right after. So there is no "goto out" jump in between these steps. > HE> + } > HE> + > HE> + *_inst = _get_vssd(broker, reference, conn, dom, &s); > HE> + > HE> + virDomainFree(dom); > HE> + > HE> out: > HE> virConnectClose(conn); > HE> + > HE> + return s; > HE> +} > > ... > > HE> +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, > HE> + const CMPIObjectPath *reference, > HE> + CMPIInstance **_inst) > HE> +{ > HE> + CMPIStatus s = {CMPI_RC_OK, NULL}; > HE> + char *name = NULL; > HE> + > HE> + if (!parse_instanceid(reference, NULL, &name)) { > HE> + cu_statusf(broker, &s, > HE> + CMPI_RC_ERR_NOT_FOUND, > HE> + "No such instance (InstanceID)"); > HE> + goto out; > HE> + } > HE> + > HE> + s = get_vssd_by_name(broker, reference, name, _inst); > HE> + if (s.rc != CMPI_RC_OK) > HE> + goto out; > > You leak name here because the free is before the out: > Good catch ... will fix this. Thanks :). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Mon Feb 25 10:15:29 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:15:29 +0100 Subject: [Libvirt-cim] [PATCH 1 of 2] ELEC: seg faults by wrong client given object path In-Reply-To: <87pruon6a6.fsf@caffeine.beaverton.ibm.com> References: <0edc1241e58d872c2514.1203595825@localhost.localdomain> <87pruon6a6.fsf@caffeine.beaverton.ibm.com> Message-ID: <47C29541.209@linux.vnet.ibm.com> Dan Smith wrote: > HE> + s = get_elec_by_name(broker, reference, name, _inst); > HE> + if (s.rc != CMPI_RC_OK) > HE> + goto out; > HE> + > HE> + s = cu_validate_ref(broker, reference, *_inst); > HE> + > > Assuming the caller checks the status, there shouldn't be an issue, > but maybe we shouldn't set _inst until we've validated the path? > Yes, you are absolutely right. I've changed this in the patches for ELEC, RASD and VSSD. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Mon Feb 25 10:20:50 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:20:50 +0100 Subject: [Libvirt-cim] [PATCH 0 of 2] #2 - Enable ELEC to validate client given object path and Adopt changed to ELEC interface to EC Message-ID: ELEC does now take care of the client given object path. The resulting interface changes have been adopted to EC by the second patch diff to patch set 1: - fixed get_elec_by_name and get_elec_by_ref to only return a valid instance pointer in case of success From heidieck at linux.vnet.ibm.com Mon Feb 25 10:20:51 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:20:51 +0100 Subject: [Libvirt-cim] [PATCH 1 of 2] ELEC: seg faults by wrong client given object path In-Reply-To: Message-ID: <631eee1e6165c349e37e.1203934851@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203934188 -3600 # Node ID 631eee1e6165c349e37e9552ff65c95726f72e4b # Parent 89ecbeb1ae6bd6a79bf9b0403a3f638c8732f2c7 ELEC: seg faults by wrong client given object path wbemgi 'http://localhost:5988/root/virt:KVM_EnabledLogicalElementCapabilities.InstanceID="wrong"' seg faults wbemgi 'http://localhost:5988/root/virt:Xen_EnabledLogicalElementCapabilities.InstanceID="kvm1-f8"' seg faults on a KVM only system Signed-off-by: Heidi Eckhart diff -r 89ecbeb1ae6b -r 631eee1e6165 src/Virt_EnabledLogicalElementCapabilities.c --- a/src/Virt_EnabledLogicalElementCapabilities.c Mon Feb 25 11:09:47 2008 +0100 +++ b/src/Virt_EnabledLogicalElementCapabilities.c Mon Feb 25 11:09:48 2008 +0100 @@ -46,26 +46,33 @@ enum {ENABLED = 2, QUIESCE, REBOOT, RESET}; - - - -static CMPIStatus set_inst_properties(const CMPIBroker *broker, - CMPIInstance *inst, - const char *classname, - const char *sys_name) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; + +static CMPIInstance *_get_elec(const CMPIBroker *broker, + const CMPIObjectPath *reference, + virConnectPtr conn, + const char *name, + CMPIStatus *s) +{ + CMPIInstance *inst = NULL; CMPIArray *array; uint16_t element; int edit_name = 0; - - CMSetProperty(inst, "CreationClassName", - (CMPIValue *)classname, CMPI_chars); - - CMSetProperty(inst, "InstanceID", (CMPIValue *)sys_name, CMPI_chars); - - array = CMNewArray(broker, 5, CMPI_uint16, &s); - if ((s.rc != CMPI_RC_OK) || CMIsNullObject(array)) + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "EnabledLogicalElementCapabilities", + NAMESPACE(reference)); + if (inst == NULL) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to init EnabledLogicalElementCapabilities instance"); + goto out; + } + + CMSetProperty(inst, "InstanceID", (CMPIValue *)name, CMPI_chars); + + array = CMNewArray(broker, 5, CMPI_uint16, s); + if ((s->rc != CMPI_RC_OK) || CMIsNullObject(array)) goto out; element = (uint16_t)ENABLED; @@ -88,56 +95,14 @@ static CMPIStatus set_inst_properties(co CMSetProperty(inst, "ElementNameEditSupported", (CMPIValue *)&edit_name, CMPI_boolean); - out: - return s; -} - -CMPIStatus get_ele_cap(const CMPIBroker *broker, - const CMPIObjectPath *ref, - const char *sys_name, - CMPIInstance **inst) -{ - CMPIStatus s; - CMPIObjectPath *op; - char *classname = NULL; - - classname = get_typed_class(CLASSNAME(ref), - "EnabledLogicalElementCapabilities"); - if (classname == NULL) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Invalid class"); - goto out; - } - - op = CMNewObjectPath(broker, NAMESPACE(ref), classname, &s); - if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Cannot get object path for ELECapabilities"); - goto out; - } - - *inst = CMNewInstance(broker, op, &s); - if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(*inst))) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Failed to instantiate HostSystem"); - goto out; - } - - s = set_inst_properties(broker, *inst, classname, sys_name); - - out: - free(classname); - - return s; -} - -static CMPIStatus return_ele_cap(const CMPIObjectPath *ref, - const CMPIResult *results, - int names_only, - const char *id) + + out: + return inst; +} + +static CMPIStatus return_enum_elec(const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; @@ -154,7 +119,7 @@ static CMPIStatus return_ele_cap(const C count = get_domain_list(conn, &list); if (count <= 0) goto out; - + for (i = 0; i < count; i++) { name = virDomainGetName(list[i]); if (name == NULL) { @@ -163,31 +128,93 @@ static CMPIStatus return_ele_cap(const C "Unable to get domain names"); goto end; } - - if (id && (!STREQ(name, id))) - goto end; - - s = get_ele_cap(_BROKER, ref, name, &inst); + + inst = _get_elec(_BROKER, ref, conn, name, &s); if (s.rc != CMPI_RC_OK) goto end; - + if (names_only) cu_return_instance_name(results, inst); else CMReturnInstance(results, inst); - - end: + + end: virDomainFree(list[i]); - - if ((s.rc != CMPI_RC_OK) || (id && (STREQ(name, id)))) - goto out; } out: free(list); - virConnectClose(conn); + return s; +} + +CMPIStatus get_elec_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn; + virDomainPtr dom; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + dom = virDomainLookupByName(conn, name); + if (dom == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } + + inst = _get_elec(broker, reference, conn, name, &s); + virDomainFree(dom); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + + out: + virConnectClose(conn); + + return s; +} + +CMPIStatus get_elec_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + const char *name; + + if (cu_get_str_path(reference, "InstanceID", &name) != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "No InstanceID specified"); + goto out; + } + + s = get_elec_by_name(broker, reference, name, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + + out: return s; } @@ -196,7 +223,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_ele_cap(reference, results, 1, NULL); + return return_enum_elec(reference, results, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -206,7 +233,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_ele_cap(reference, results, 0, NULL); + return return_enum_elec(reference, results, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -216,16 +243,16 @@ static CMPIStatus GetInstance(CMPIInstan const char **properties) { CMPIStatus s = {CMPI_RC_OK, NULL}; - const char* id; - - if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No InstanceID specified"); - return s; - } - - return return_ele_cap(reference, results, 0, id); + CMPIInstance *inst = NULL; + + s = get_elec_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: + return s; } DEFAULT_CI(); diff -r 89ecbeb1ae6b -r 631eee1e6165 src/Virt_EnabledLogicalElementCapabilities.h --- a/src/Virt_EnabledLogicalElementCapabilities.h Mon Feb 25 11:09:47 2008 +0100 +++ b/src/Virt_EnabledLogicalElementCapabilities.h Mon Feb 25 11:09:48 2008 +0100 @@ -18,10 +18,15 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -CMPIStatus get_ele_cap(const CMPIBroker *broker, - const CMPIObjectPath *ref, - const char *sys_name, - CMPIInstance **inst); +CMPIStatus get_elec_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst); + +CMPIStatus get_elec_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); + /* * Local Variables: * mode: C From heidieck at linux.vnet.ibm.com Mon Feb 25 10:20:52 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:20:52 +0100 Subject: [Libvirt-cim] [PATCH 2 of 2] EC: adopt interface changes to ELEC In-Reply-To: Message-ID: <875e54efe5feb2f65572.1203934852@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203934189 -3600 # Node ID 875e54efe5feb2f65572c0b4d786081506e65cc8 # Parent 631eee1e6165c349e37e9552ff65c95726f72e4b EC: adopt interface changes to ELEC Signed-off-by: Heidi Eckhart diff -r 631eee1e6165 -r 875e54efe5fe src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Mon Feb 25 11:09:48 2008 +0100 +++ b/src/Virt_ElementCapabilities.c Mon Feb 25 11:09:49 2008 +0100 @@ -216,7 +216,7 @@ static CMPIStatus cs_to_cap(const CMPIOb goto out; } - s = get_ele_cap(_BROKER, ref, sys_name, &inst); + s = get_elec_by_name(_BROKER, ref, sys_name, &inst); if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); @@ -234,6 +234,10 @@ static CMPIStatus cap_to_cs(const CMPIOb CMPIStatus s = {CMPI_RC_OK, NULL}; if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = get_elec_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) goto out; if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) { From heidieck at linux.vnet.ibm.com Mon Feb 25 10:23:12 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:23:12 +0100 Subject: [Libvirt-cim] [PATCH 0 of 4] #4 - Enable VSSD to validate client given object path and Adopt changed to VSSD interface to ESD & SDS & VSSDC Message-ID: VSSD does now take care of the client given object path. The resulting interface changes have been adopted to - ESD by the second patch - SDS by the third patch - VSSDC by the fourth patch (diff to patch set 1) diff to patch set 2: - updated VSSD to compare a returned integer result explicitely diff to patch set 3: - fixed memory leak (on name) in get_vssd_by_ref - fixed get_vssd_by_name and get_vssd_by_ref to only return a valid instance pointer in case of success From heidieck at linux.vnet.ibm.com Mon Feb 25 10:23:14 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:23:14 +0100 Subject: [Libvirt-cim] [PATCH 2 of 4] ESD: adopt interface changes in VSSD In-Reply-To: Message-ID: <014d278b320ab85bd317.1203934994@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203934185 -3600 # Node ID 014d278b320ab85bd3172b569df0a4485809b9cb # Parent 51a9cb4ae2646fda717932e0b1f712d26a255511 ESD: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r 51a9cb4ae264 -r 014d278b320a src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Mon Feb 25 11:09:43 2008 +0100 +++ b/src/Virt_ElementSettingData.c Mon Feb 25 11:09:45 2008 +0100 @@ -41,47 +41,20 @@ static CMPIStatus vssd_to_vssd(const CMP { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; - char *host = NULL; - + if (!match_hypervisor_prefix(ref, info)) return s; - if (!parse_instanceid(ref, NULL, &host)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to get system name"); - goto out; - } - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, host); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such system `%s'", host); - goto out; - } - - inst = get_vssd_instance(dom, _BROKER, ref); - if (inst == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Error getting VSSD for `%s'", host); - goto out; - } - + /* Special association case: + * VSSD instance is pointing to itself + */ + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + inst_list_add(list, inst); - + out: - virDomainFree(dom); - virConnectClose(conn); - free(host); - return s; } From heidieck at linux.vnet.ibm.com Mon Feb 25 10:23:15 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:23:15 +0100 Subject: [Libvirt-cim] [PATCH 3 of 4] SDS: adopt interface changes in VSSD In-Reply-To: Message-ID: <974c0863140b29682d45.1203934995@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203934186 -3600 # Node ID 974c0863140b29682d450b8f9e0edec8052e1bae # Parent 014d278b320ab85bd3172b569df0a4485809b9cb SDS: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r 014d278b320a -r 974c0863140b src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Mon Feb 25 11:09:45 2008 +0100 +++ b/src/Virt_SettingsDefineState.c Mon Feb 25 11:09:46 2008 +0100 @@ -196,18 +196,16 @@ static CMPIStatus vs_to_vssd(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; const char *name; - CMPIInstance *vssd; - CMPIStatus s = {CMPI_RC_OK, NULL}; - + if (!match_hypervisor_prefix(ref, info)) return s; - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - return s; + + s = get_domain(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "Name", &name) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, @@ -215,28 +213,15 @@ static CMPIStatus vs_to_vssd(const CMPIO "Missing Name property"); goto out; } - - dom = virDomainLookupByName(conn, name); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such domain `%s'", name); - goto out; - } - - vssd = get_vssd_instance(dom, _BROKER, ref); - if (vssd != NULL) - inst_list_add(list, vssd); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - out: - virDomainFree(dom); - virConnectClose(conn); - + + s = get_vssd_by_name(_BROKER, ref, name, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, inst); + + out: return s; - } static CMPIStatus vssd_to_vs(const CMPIObjectPath *ref, @@ -250,9 +235,14 @@ static CMPIStatus vssd_to_vs(const CMPIO virConnectPtr conn = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *cs; + CMPIInstance *inst; if (!match_hypervisor_prefix(ref, info)) return s; + + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, From heidieck at linux.vnet.ibm.com Mon Feb 25 10:23:16 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:23:16 +0100 Subject: [Libvirt-cim] [PATCH 4 of 4] VSSDC: adopt interface changes in VSSD In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203934187 -3600 # Node ID e54e9297a7a5d5a14bcf8962ba4f36ba6a0cef2d # Parent 974c0863140b29682d450b8f9e0edec8052e1bae VSSDC: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r 974c0863140b -r e54e9297a7a5 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Mon Feb 25 11:09:46 2008 +0100 +++ b/src/Virt_VSSDComponent.c Mon Feb 25 11:09:47 2008 +0100 @@ -41,6 +41,7 @@ static CMPIStatus vssd_to_rasd(const CMP struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; char *name = NULL; int i = 0; int types[] = { @@ -52,7 +53,11 @@ static CMPIStatus vssd_to_rasd(const CMP }; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; + + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (!parse_instanceid(ref, NULL, &name)) { cu_statusf(_BROKER, &s, @@ -69,48 +74,9 @@ static CMPIStatus vssd_to_rasd(const CMP list); } - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - out: free(name); - return s; -} - -static CMPIStatus vssd_for_name(const char *host, - const CMPIObjectPath *ref, - CMPIInstance **inst) -{ - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; - CMPIStatus s; - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, host); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such system `%s'", host); - goto out; - } - - *inst = get_vssd_instance(dom, _BROKER, ref); - if (*inst == NULL) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Error getting VSSD for `%s'", host); - else - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: - virDomainFree(dom); - virConnectClose(conn); - return s; } @@ -143,9 +109,11 @@ static CMPIStatus rasd_to_vssd(const CMP goto out; } - s = vssd_for_name(host, ref, &vssd); - if (vssd) - inst_list_add(list, vssd); + s = get_vssd_by_name(_BROKER, ref, host, &vssd); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, vssd); out: free(host); From heidieck at linux.vnet.ibm.com Mon Feb 25 10:23:13 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:23:13 +0100 Subject: [Libvirt-cim] [PATCH 1 of 4] VSSD: validate client given object path In-Reply-To: Message-ID: <51a9cb4ae2646fda7179.1203934993@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203934183 -3600 # Node ID 51a9cb4ae2646fda717932e0b1f712d26a255511 # Parent d72742466a8892154997d2f210cb9ceeff035962 VSSD: validate client given object path wbemgi 'http://localhost:5988/root/virt:KVM_VirtualSystemSettingData.InstanceID="Xen:kvm1-f8"' on a KVM only system is returning an instance, but should not. wbemgi 'http://localhost:5988/root/virt:Xen_VirtualSystemSettingData.InstanceID="KVM:kvm1-f8"' on a KVM only system is seg faulting, but should not ;). Signed-off-by: Heidi Eckhart diff -r d72742466a88 -r 51a9cb4ae264 src/Virt_VSSD.c --- a/src/Virt_VSSD.c Tue Feb 19 15:29:52 2008 -0800 +++ b/src/Virt_VSSD.c Mon Feb 25 11:09:43 2008 +0100 @@ -135,42 +135,46 @@ static int instance_from_dom(virDomainPt return ret; } -CMPIInstance *get_vssd_instance(virDomainPtr dom, - const CMPIBroker *broker, - const CMPIObjectPath *ref) -{ - CMPIInstance *inst; - +static CMPIInstance *_get_vssd(const CMPIBroker *broker, + const CMPIObjectPath *reference, + virConnectPtr conn, + virDomainPtr dom, + CMPIStatus *s) +{ + CMPIInstance *inst = NULL; + inst = get_typed_instance(broker, - CLASSNAME(ref), + pfx_from_conn(conn), "VirtualSystemSettingData", - NAMESPACE(ref)); - - if (inst == NULL) - return NULL; - - if (instance_from_dom(dom, inst)) - return inst; - else - return NULL; -} - -static CMPIStatus enum_vssd(const CMPIObjectPath *reference, - const CMPIResult *results, - int names_only) + NAMESPACE(reference)); + + if (inst == NULL) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to init VirtualSystemSettingData instance"); + goto out; + } + + if (instance_from_dom(dom, inst) != 1) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to get VSSD instance from Domain"); + } + + out: + return inst; +} + +static CMPIStatus return_enum_vssd(const CMPIObjectPath *reference, + const CMPIResult *results, + bool names_only) { virConnectPtr conn; virDomainPtr *list; int count; int i; - CMPIStatus s; - const char *ns; - - if (!provider_is_responsible(_BROKER, reference, &s)) - return s; - - ns = NAMESPACE(reference); - + CMPIStatus s = {CMPI_RC_OK, NULL}; + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); if (conn == NULL) return s; @@ -181,60 +185,101 @@ static CMPIStatus enum_vssd(const CMPIOb CMPI_RC_ERR_FAILED, "Failed to enumerate domains"); goto out; - } else if (count == 0) { - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - goto out; - } + } else if (count == 0) + goto out; for (i = 0; i < count; i++) { - CMPIInstance *inst; - - inst = get_vssd_instance(list[i], _BROKER, reference); + CMPIInstance *inst = NULL; + + inst = _get_vssd(_BROKER, reference, conn, list[i], &s); + virDomainFree(list[i]); if (inst == NULL) continue; - + if (names_only) cu_return_instance_name(results, inst); else CMReturnInstance(results, inst); } - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: free(list); return s; - -} - -static CMPIInstance *get_vssd_for_name(const CMPIObjectPath *reference, - char *name) +} + +CMPIStatus get_vssd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst) { virConnectPtr conn; virDomainPtr dom; - CMPIStatus s; - CMPIInstance *inst = NULL; - - conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); - if (conn == NULL) - return NULL; - + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + dom = virDomainLookupByName(conn, name); - if (dom == NULL) - goto out; - - inst = get_vssd_instance(dom, _BROKER, reference); - + if (dom == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } + + inst = _get_vssd(broker, reference, conn, dom, &s); + + virDomainFree(dom); + + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + out: virConnectClose(conn); - virDomainFree(dom); - - return inst; + + return s; +} + +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + char *name = NULL; + + if (!parse_instanceid(reference, NULL, &name)) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (InstanceID)"); + goto out; + } + + s = get_vssd_by_name(broker, reference, name, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + + out: + free(name); + + return s; } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -242,7 +287,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return enum_vssd(reference, results, 1); + return return_enum_vssd(reference, results, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -251,7 +296,7 @@ static CMPIStatus EnumInstances(CMPIInst const CMPIObjectPath *reference, const char **properties) { - return enum_vssd(reference, results, 0); + return return_enum_vssd(reference, results, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -261,26 +306,15 @@ static CMPIStatus GetInstance(CMPIInstan const char **properties) { CMPIStatus s; - CMPIInstance *inst; - char *locid; - - if (!parse_instanceid(reference, NULL, &locid)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Invalid InstanceID specified"); - return s; - } - - inst = get_vssd_for_name(reference, locid); - if (inst) - CMReturnInstance(results, inst); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - - free(locid); - + CMPIInstance *inst = NULL; + + s = get_vssd_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: return s; } diff -r d72742466a88 -r 51a9cb4ae264 src/Virt_VSSD.h --- a/src/Virt_VSSD.h Tue Feb 19 15:29:52 2008 -0800 +++ b/src/Virt_VSSD.h Mon Feb 25 11:09:43 2008 +0100 @@ -21,8 +21,14 @@ #ifndef __VIRT_VSSD_H #define __VIRT_VSSD_H -CMPIInstance *get_vssd_instance(virDomainPtr dom, - const CMPIBroker *broker, - const CMPIObjectPath *ref); +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); + +CMPIStatus get_vssd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst); + #endif From heidieck at linux.vnet.ibm.com Mon Feb 25 10:26:54 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:26:54 +0100 Subject: [Libvirt-cim] [PATCH 0 of 5] #2 - Add get_rasd_... functions to RASD and adopt interface changes to assocs Message-ID: Added get_rasd_by_ref() and get_rasd_by_name() to RASD provider to clean up / fasten the access to a specific RASD instance. This interface change has been adopted by the appropriate associaton providers, who need this access. diff to patch set 1: - fixed get_rasd_by_name and get_rasd_by_ref to only return a valid instance pointer in case of success From heidieck at linux.vnet.ibm.com Mon Feb 25 10:26:55 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:26:55 +0100 Subject: [Libvirt-cim] [PATCH 1 of 5] RASD: add function get_rasd_by_ref() for usage in associations In-Reply-To: Message-ID: <6e25b6b5b541ee6a3547.1203935215@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203934392 -3600 # Node ID 6e25b6b5b541ee6a3547ab2125937a7207bd21fc # Parent 875e54efe5feb2f65572c0b4d786081506e65cc8 RASD: add function get_rasd_by_ref() for usage in associations Signed-off-by: Heidi Eckhart diff -r 875e54efe5fe -r 6e25b6b5b541 src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Feb 25 11:09:49 2008 +0100 +++ b/src/Virt_RASD.c Mon Feb 25 11:13:12 2008 +0100 @@ -357,38 +357,97 @@ static CMPIInstance *rasd_from_vdev(cons return inst; } -CMPIInstance *get_rasd_instance(const CMPIContext *context, - const CMPIObjectPath *ref, - const CMPIBroker *broker, - const char *id, - const uint16_t type) +CMPIStatus get_rasd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + const uint16_t type, + CMPIInstance **_inst) { CMPIInstance *inst = NULL; - CMPIStatus s; + CMPIStatus s = {CMPI_RC_OK, NULL}; int ret; char *host = NULL; char *devid = NULL; virConnectPtr conn = NULL; struct virt_device *dev; - ret = parse_fq_devid((char *)id, &host, &devid); - if (!ret) - return NULL; - - conn = connect_by_classname(broker, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + ret = parse_fq_devid((char *)name, &host, &devid); + if (ret != 1) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } dev = find_dev(conn, type, host, devid); - if (dev) - inst = rasd_from_vdev(broker, dev, host, ref); - + if (!dev) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } + + inst = rasd_from_vdev(broker, dev, host, reference); + if (inst == NULL) + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Failed to set instance properties"); + else + *_inst = inst; + out: virConnectClose(conn); free(host); free(devid); - return inst; + return s; +} + +CMPIStatus get_rasd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + const char *name = NULL; + uint16_t type; + + if (cu_get_str_path(reference, "InstanceID", &name) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Missing InstanceID"); + goto out; + } + + if (rasd_type_from_classname(CLASSNAME(reference), &type) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to determine RASD type"); + goto out; + } + + s = get_rasd_by_name(broker, reference, name, type, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + + out: + return s; } CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type) @@ -544,32 +603,14 @@ static CMPIStatus GetInstance(CMPIInstan const char **properties) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - const char *id = NULL; - uint16_t type; - - if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Missing InstanceID"); - goto out; - } - - if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to determine RASD type"); - goto out; - } - - inst = get_rasd_instance(context, ref, _BROKER, id, type); - - if (inst != NULL) - CMReturnInstance(results, inst); - else - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", id); + CMPIInstance *inst = NULL; + + s = get_rasd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + out: return s; } diff -r 875e54efe5fe -r 6e25b6b5b541 src/Virt_RASD.h --- a/src/Virt_RASD.h Mon Feb 25 11:09:49 2008 +0100 +++ b/src/Virt_RASD.h Mon Feb 25 11:13:12 2008 +0100 @@ -42,11 +42,15 @@ CMPIrc rasd_type_from_classname(const ch CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type); CMPIrc rasd_classname_from_type(uint16_t type, const char **cn); -CMPIInstance *get_rasd_instance(const CMPIContext *context, - const CMPIObjectPath *ref, - const CMPIBroker *broker, - const char *id, - const uint16_t type); +CMPIStatus get_rasd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + const uint16_t type, + CMPIInstance **_inst); + +CMPIStatus get_rasd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); #endif From heidieck at linux.vnet.ibm.com Mon Feb 25 10:26:56 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:26:56 +0100 Subject: [Libvirt-cim] [PATCH 2 of 5] VSMS: adopt interface changes of RASD In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203934430 -3600 # Node ID fdda40f15fcfd38c50a8918ad1075714e19efa7a # Parent 6e25b6b5b541ee6a3547ab2125937a7207bd21fc VSMS: adopt interface changes of RASD Signed-off-by: Heidi Eckhart diff -r 6e25b6b5b541 -r fdda40f15fcf src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon Feb 25 11:13:12 2008 +0100 +++ b/src/Virt_VirtualSystemManagementService.c Mon Feb 25 11:13:50 2008 +0100 @@ -1000,7 +1000,7 @@ static CMPIStatus rasd_refs_to_insts(con CMPIArray *arr, CMPIArray **ret_arr) { - CMPIStatus s; + CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIArray *tmp_arr; int i; int c; @@ -1017,7 +1017,7 @@ static CMPIStatus rasd_refs_to_insts(con for (i = 0; i < c; i++) { CMPIData d; CMPIObjectPath *ref; - CMPIInstance *inst; + CMPIInstance *inst = NULL; const char *id; uint16_t type; @@ -1041,21 +1041,18 @@ static CMPIStatus rasd_refs_to_insts(con continue; } - inst = get_rasd_instance(ctx, reference, _BROKER, id, type); - if (inst != NULL) - CMSetArrayElementAt(tmp_arr, i, - &inst, - CMPI_instance); - else - CU_DEBUG("Failed to get instance for `%s'", - REF2STR(ref)); - } - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); + s = get_rasd_by_name(_BROKER, reference, id, type, &inst); + if (s.rc != CMPI_RC_OK) + continue; + + CMSetArrayElementAt(tmp_arr, i, + &inst, + CMPI_instance); + + } + *ret_arr = tmp_arr; - + return s; } From heidieck at linux.vnet.ibm.com Mon Feb 25 10:26:58 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:26:58 +0100 Subject: [Libvirt-cim] [PATCH 4 of 5] RAFP: adopt interface changes to RASD In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1203934433 -3600 # Node ID a8bd1f2980451ea709a720d2846300c52e089de0 # Parent 50360523c174c877639dbc2100fd5723b2193226 RAFP: adopt interface changes to RASD Signed-off-by: Heidi Eckhart diff -r 50360523c174 -r a8bd1f298045 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Mon Feb 25 11:13:53 2008 +0100 +++ b/src/Virt_ResourceAllocationFromPool.c Mon Feb 25 11:13:53 2008 +0100 @@ -37,28 +37,6 @@ const static CMPIBroker *_BROKER; -static CMPIStatus validate_rasd_ref(const CMPIContext *context, - const CMPIObjectPath *ref, - uint16_t type, - const char *id) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *rasd = NULL; - - rasd = get_rasd_instance(context, - ref, - _BROKER, - id, - type); - - if (CMIsNullObject(rasd)) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", id); - - return s; -} - static CMPIStatus rasd_to_pool(const CMPIObjectPath *ref, struct std_assoc_info *info, struct inst_list *list) @@ -69,6 +47,7 @@ static CMPIStatus rasd_to_pool(const CMP char *poolid = NULL; virConnectPtr conn = NULL; CMPIInstance *pool = NULL; + CMPIInstance *inst = NULL; if (!match_hypervisor_prefix(ref, info)) return s; @@ -87,10 +66,7 @@ static CMPIStatus rasd_to_pool(const CMP goto out; } - s = validate_rasd_ref(info->context, - ref, - type, - id); + s = get_rasd_by_name(_BROKER, ref, id, type, &inst); if (s.rc != CMPI_RC_OK) goto out; From heidieck at linux.vnet.ibm.com Mon Feb 25 10:26:59 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:26:59 +0100 Subject: [Libvirt-cim] [PATCH 5 of 5] ESD: adopt interface changes to RASD In-Reply-To: Message-ID: <09459d892a7ba1f25fdd.1203935219@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203934434 -3600 # Node ID 09459d892a7ba1f25fdd396dd41ff0e77fb6c234 # Parent a8bd1f2980451ea709a720d2846300c52e089de0 ESD: adopt interface changes to RASD Signed-off-by: Heidi Eckhart diff -r a8bd1f298045 -r 09459d892a7b src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Mon Feb 25 11:13:53 2008 +0100 +++ b/src/Virt_ElementSettingData.c Mon Feb 25 11:13:54 2008 +0100 @@ -63,38 +63,20 @@ static CMPIStatus rasd_to_rasd(const CMP struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - const char *id = NULL; - uint16_t type; + CMPIInstance *inst = NULL; if (!match_hypervisor_prefix(ref, info)) return s; - if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Missing InstanceID"); + /* Special association case: + * RASD instance is pointing to itself + */ + s = get_rasd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) goto out; - } - - if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to determine RASD type"); - goto out; - } - - inst = get_rasd_instance(info->context, ref, _BROKER, id, type); - if (inst == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Error getting associated RASD"); - - goto out; - } - + inst_list_add(list, inst); - + out: return s; } From heidieck at linux.vnet.ibm.com Mon Feb 25 10:26:57 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 11:26:57 +0100 Subject: [Libvirt-cim] [PATCH 3 of 5] SDS: adopt interface changes of RASD In-Reply-To: Message-ID: <50360523c174c877639d.1203935217@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1203934433 -3600 # Node ID 50360523c174c877639dbc2100fd5723b2193226 # Parent fdda40f15fcfd38c50a8918ad1075714e19efa7a SDS: adopt interface changes of RASD Signed-off-by: Heidi Eckhart diff -r fdda40f15fcf -r 50360523c174 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Mon Feb 25 11:13:50 2008 +0100 +++ b/src/Virt_SettingsDefineState.c Mon Feb 25 11:13:53 2008 +0100 @@ -159,6 +159,7 @@ static CMPIStatus rasd_to_dev(const CMPI { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *dev = NULL; + CMPIInstance *inst = NULL; const char *id = NULL; uint16_t type; @@ -178,6 +179,10 @@ static CMPIStatus rasd_to_dev(const CMPI "Missing ResourceType"); goto out; } + + s = get_rasd_by_name(_BROKER, ref, id, type, &inst); + if (s.rc != CMPI_RC_OK) + goto out; dev = _get_typed_device(id, type, ref, &s); if (dev == NULL) @@ -185,9 +190,6 @@ static CMPIStatus rasd_to_dev(const CMPI inst_list_add(list, dev); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: return s; } From heidieck at linux.vnet.ibm.com Mon Feb 25 11:24:34 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Mon, 25 Feb 2008 12:24:34 +0100 Subject: [Libvirt-cim] [PATCH 1 of 2] Add property filtering to RASD provider In-Reply-To: <2bff66d74872c62ef38f.1203704012@elm3b41.beaverton.ibm.com> References: <2bff66d74872c62ef38f.1203704012@elm3b41.beaverton.ibm.com> Message-ID: <47C2A572.2080401@linux.vnet.ibm.com> Kaitlin Rupert wrote: > # HG changeset patch > # User Kaitlin Rupert > # Date 1203702578 28800 > # Node ID 2bff66d74872c62ef38fca81fafd32f0d7fb126a > # Parent d02f5729977381ec6f5aec3503dc5f970a428b88 > Add property filtering to RASD provider. > > wbemcli is unable to parse embedded instance arrays, so this additional property filtering support will allow queries to exclude the HostResource property. > > Failing Query: > wbemcli ei http://localhost/root/virt:Xen_ProcResourceAllocationSettingData > * > * wbemcli: Parse Exception: Unknown attribute in list for PROPERTY.ARRAY (EMBEDDEDOB) > > Passing Query: > wbemcli ei http://localhost/root/virt:Xen_ProcResourceAllocationSettingData ResourceType > > Signed-off-by: Kaitlin Rupert > > diff -r d02f57299773 -r 2bff66d74872 src/Virt_RASD.c > --- a/src/Virt_RASD.c Fri Feb 22 12:54:52 2008 +0100 > +++ b/src/Virt_RASD.c Fri Feb 22 09:49:38 2008 -0800 > @@ -312,6 +314,14 @@ static CMPIInstance *rasd_from_vdev(cons > NAMESPACE(ref)); > if (inst == NULL) > return inst; > + > + if (properties != NULL) { > + const char *keys[] = {"InstanceID", NULL}; > + s = CMSetPropertyFilter(inst, properties, keys); > + /* FIXME - in case of an error, should we continue on? */ > + if (s.rc != CMPI_RC_OK) > + CU_DEBUG("Unable to set property filter: %d", s.rc); > + } > That's a very good point to enable the provider interfaces for the property filtering :). I think it makes sense to move this code into get_typed_instance() of libxkutil, to avoid implementing these lines for every provider. What's then only necessary is routing the properties list through the interfaces. But you will now think ... and how about the keys ? Well, that's an interesting thing. The CMPI 2.0 spec tells the following about the keys: CMPI 2.0 Spec; "The keyList argument shall be ignored by the MB; it is here to maintain binary compatibility with previous specifications. Providers should explicitly set the key names and values via the CMPIInstanceMI.setObjectPath() function." Translated I think this means, that we can ignore the keys by setting it to NULL. Do you agree ? You can also skip the check if a the properties filter is there, as NULL is interpreted as "all properties accepted". CMPI 2.0 Spec: "The propertyList argument defines the properties that will be accepted by subsequent setProperty() operations. The propertyList argument is an array of pointers to character strings, terminated by a NULL pointer. A NULL value effectively means that all properties will be accepted. A pointer to an empty list means that no properties will be accepted." > > CMPIStatus get_rasd_by_ref(const CMPIBroker *broker, > const CMPIObjectPath *reference, > + const char **properties, > CMPIInstance **_inst) > { > CMPIStatus s = {CMPI_RC_OK, NULL}; > @@ -435,7 +447,7 @@ CMPIStatus get_rasd_by_ref(const CMPIBro > goto out; > } > > - s = get_rasd_by_name(broker, reference, name, type, _inst); > + s = get_rasd_by_name(broker, reference, name, type, properties, _inst); > Sorry, I broker your patch with my previous changes at this line. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From danms at us.ibm.com Mon Feb 25 15:04:58 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 25 Feb 2008 07:04:58 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add property filtering to RASD provider In-Reply-To: <47C2A572.2080401@linux.vnet.ibm.com> (Heidi Eckhart's message of "Mon, 25 Feb 2008 12:24:34 +0100") References: <2bff66d74872c62ef38f.1203704012@elm3b41.beaverton.ibm.com> <47C2A572.2080401@linux.vnet.ibm.com> Message-ID: <873arhm605.fsf@caffeine.beaverton.ibm.com> HE> I think it makes sense to move this code into get_typed_instance() HE> of libxkutil, to avoid implementing these lines for every HE> provider. What's then only necessary is routing the properties HE> list through the interfaces. Yes, I think that's a good idea, but it will require a lot of silly changes, so it's probably best to wait until after we finish with some of our more important correctness issues. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 25 15:07:50 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 25 Feb 2008 07:07:50 -0800 Subject: [Libvirt-cim] [PATCH 1 of 4] VSSD: validate client given object path In-Reply-To: <47C29192.7090401@linux.vnet.ibm.com> (Heidi Eckhart's message of "Mon, 25 Feb 2008 10:59:46 +0100") References: <644476f8ee52477f05fc.1203673088@localhost.localdomain> <87lk5cn5ml.fsf@caffeine.beaverton.ibm.com> <47C29192.7090401@linux.vnet.ibm.com> Message-ID: <87y799krax.fsf@caffeine.beaverton.ibm.com> HE> Mhh, I think not. If dom==NULL we "goto out". If dom is there, HE> then _get_vssd() is called and virDomainFree right after. So there HE> is no "goto out" jump in between these steps. Right, sorry, I was reading the diff incorrectly :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 25 15:35:30 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 25 Feb 2008 07:35:30 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] ELEC: seg faults by wrong client given object path In-Reply-To: <631eee1e6165c349e37e.1203934851@localhost.localdomain> (Heidi Eckhart's message of "Mon, 25 Feb 2008 11:20:51 +0100") References: <631eee1e6165c349e37e.1203934851@localhost.localdomain> Message-ID: <87tzjxkq0t.fsf@caffeine.beaverton.ibm.com> HE> - HE> + You're *adding* a line with leading whitespace here. Please remove it. HE> - HE> + Here too. HE> - HE> - end: HE> + HE> + end: I think the 'end' placement was correct before, wasn't it? You're also adding a line with leading whitespace here. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 25 15:43:57 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 25 Feb 2008 07:43:57 -0800 Subject: [Libvirt-cim] [PATCH 1 of 4] VSSD: validate client given object path In-Reply-To: <51a9cb4ae2646fda7179.1203934993@localhost.localdomain> (Heidi Eckhart's message of "Mon, 25 Feb 2008 11:23:13 +0100") References: <51a9cb4ae2646fda7179.1203934993@localhost.localdomain> Message-ID: <87prulkpmq.fsf@caffeine.beaverton.ibm.com> HE> - HE> + Sorry to be nitpicky, but you add leading whitespace here too :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 25 15:54:10 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 25 Feb 2008 07:54:10 -0800 Subject: [Libvirt-cim] [PATCH 2 of 4] ESD: adopt interface changes in VSSD In-Reply-To: <014d278b320ab85bd317.1203934994@localhost.localdomain> (Heidi Eckhart's message of "Mon, 25 Feb 2008 11:23:14 +0100") References: <014d278b320ab85bd317.1203934994@localhost.localdomain> Message-ID: <87lk59kp5p.fsf@caffeine.beaverton.ibm.com> HE> - virConnectPtr conn = NULL; HE> - virDomainPtr dom = NULL; HE> - char *host = NULL; HE> - HE> + ...whitespace :) HE> + if (s.rc != CMPI_RC_OK) HE> + goto out; HE> + HE> inst_list_add(list, inst); HE> - HE> + ...whitespace :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 25 15:55:39 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 25 Feb 2008 07:55:39 -0800 Subject: [Libvirt-cim] [PATCH 3 of 4] SDS: adopt interface changes in VSSD In-Reply-To: <974c0863140b29682d45.1203934995@localhost.localdomain> (Heidi Eckhart's message of "Mon, 25 Feb 2008 11:23:15 +0100") References: <974c0863140b29682d45.1203934995@localhost.localdomain> Message-ID: <87hcfxkp38.fsf@caffeine.beaverton.ibm.com> HE> - CMPIInstance *vssd; HE> - CMPIStatus s = {CMPI_RC_OK, NULL}; HE> - HE> + ...whitespace. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Mon Feb 25 16:37:17 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 25 Feb 2008 08:37:17 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add property filtering to RASD provider In-Reply-To: <47C2A572.2080401@linux.vnet.ibm.com> References: <2bff66d74872c62ef38f.1203704012@elm3b41.beaverton.ibm.com> <47C2A572.2080401@linux.vnet.ibm.com> Message-ID: <47C2EEBD.7040803@linux.vnet.ibm.com> >> + >> + if (properties != NULL) { >> + const char *keys[] = {"InstanceID", NULL}; >> + s = CMSetPropertyFilter(inst, properties, keys); >> + /* FIXME - in case of an error, should we continue >> on? */ >> + if (s.rc != CMPI_RC_OK) >> + CU_DEBUG("Unable to set property filter: %d", >> s.rc); >> + } >> > That's a very good point to enable the provider interfaces for the > property filtering :). I think it makes sense to move this code into > get_typed_instance() of libxkutil, to avoid implementing these lines for > every provider. What's then only necessary is routing the properties > list through the interfaces. But you will now think ... and how about > the keys ? Well, that's an interesting thing. The CMPI 2.0 spec tells > the following about the keys: > CMPI 2.0 Spec; "The keyList argument shall be ignored by the MB; it is > here to maintain binary compatibility with previous specifications. > Providers should explicitly set the key names and values via the > CMPIInstanceMI.setObjectPath() function." > Translated I think this means, that we can ignore the keys by setting it > to NULL. Do you agree ? I tried using NULL for the keys based on the same line from the CMPI spec, but this crashed the provider. I might be missing something though. > > You can also skip the check if a the properties filter is there, as NULL > is interpreted as "all properties accepted". > CMPI 2.0 Spec: "The propertyList argument defines the properties that > will be accepted by subsequent setProperty() operations. The > propertyList argument is an array of pointers to character strings, > terminated by a NULL pointer. A NULL value effectively means that all > properties will be accepted. A pointer to an empty list means that no > properties will be accepted." Ah, good to know. I'll remove this check and rebase the patch on your recent changes. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Mon Feb 25 17:09:18 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 25 Feb 2008 09:09:18 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add property filtering to RASD provider In-Reply-To: Message-ID: <78743e525952642fea86.1203959358@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1203959338 28800 # Node ID 78743e525952642fea86b43c2599e128d87b8bab # Parent 4da0767cf1fe8b1330ab14a9321700a53c07b827 Add property filtering to RASD provider. Updates from set 1 to set 2: -Removed the check to see if properties is NULL since CMSetPropertyFilter() accepts a NULL list. wbemcli is unable to parse embedded instance arrays, so this additional property filtering support will allow queries to exclude the HostResource property. Failing Query: wbemcli ei http://localhost/root/virt:Xen_ProcResourceAllocationSettingData * * wbemcli: Parse Exception: Unknown attribute in list for PROPERTY.ARRAY (EMBEDDEDOB) Passing Query: wbemcli ei http://localhost/root/virt:Xen_ProcResourceAllocationSettingData ResourceType Signed-off-by: Kaitlin Rupert diff -r 4da0767cf1fe -r 78743e525952 src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Feb 25 11:13:54 2008 +0100 +++ b/src/Virt_RASD.c Mon Feb 25 09:08:58 2008 -0800 @@ -283,8 +283,10 @@ static CMPIInstance *rasd_from_vdev(cons static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, - const CMPIObjectPath *ref) -{ + const CMPIObjectPath *ref, + const char **properties) +{ + CMPIStatus s; CMPIInstance *inst; uint16_t type; char *base; @@ -312,6 +314,12 @@ static CMPIInstance *rasd_from_vdev(cons NAMESPACE(ref)); if (inst == NULL) return inst; + + const char *keys[] = {"InstanceID", NULL}; + s = CMSetPropertyFilter(inst, properties, keys); + + if (s.rc != CMPI_RC_OK) + CU_DEBUG("Unable to set property filter: %d", s.rc); id = get_fq_devid((char *)host, dev->id); @@ -361,6 +369,7 @@ CMPIStatus get_rasd_by_name(const CMPIBr const CMPIObjectPath *reference, const char *name, const uint16_t type, + const char **properties, CMPIInstance **_inst) { CMPIInstance *inst = NULL; @@ -397,7 +406,7 @@ CMPIStatus get_rasd_by_name(const CMPIBr goto out; } - inst = rasd_from_vdev(broker, dev, host, reference); + inst = rasd_from_vdev(broker, dev, host, reference, properties); if (inst == NULL) cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, @@ -415,6 +424,7 @@ CMPIStatus get_rasd_by_name(const CMPIBr CMPIStatus get_rasd_by_ref(const CMPIBroker *broker, const CMPIObjectPath *reference, + const char **properties, CMPIInstance **_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -436,7 +446,7 @@ CMPIStatus get_rasd_by_ref(const CMPIBro goto out; } - s = get_rasd_by_name(broker, reference, name, type, &inst); + s = get_rasd_by_name(broker, reference, name, type, properties, &inst); if (s.rc != CMPI_RC_OK) goto out; @@ -503,6 +513,7 @@ CMPIrc rasd_classname_from_type(uint16_t } static CMPIStatus _enum_rasds(const CMPIObjectPath *ref, + const char **properties, struct inst_list *list) { virConnectPtr conn = NULL; @@ -542,6 +553,7 @@ static CMPIStatus _enum_rasds(const CMPI virDomainGetName(domains[i]), types[j], ref, + properties, list); } virDomainFree(domains[i]); @@ -558,6 +570,7 @@ static CMPIStatus _enum_rasds(const CMPI static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref, const CMPIResult *results, + const char **properties, const bool names_only) { struct inst_list list; @@ -565,7 +578,7 @@ static CMPIStatus return_enum_rasds(cons inst_list_init(&list); - s = _enum_rasds(ref, &list); + s = _enum_rasds(ref, properties, &list); if (s.rc == CMPI_RC_OK) { if (names_only) cu_return_instance_names(results, &list); @@ -583,7 +596,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_enum_rasds(reference, results, true); + return return_enum_rasds(reference, results, NULL, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -593,7 +606,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_enum_rasds(reference, results, false); + return return_enum_rasds(reference, results, properties, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -605,7 +618,7 @@ static CMPIStatus GetInstance(CMPIInstan CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; - s = get_rasd_by_ref(_BROKER, ref, &inst); + s = get_rasd_by_ref(_BROKER, ref, properties, &inst); if (s.rc != CMPI_RC_OK) goto out; @@ -619,6 +632,7 @@ int rasds_for_domain(const CMPIBroker *b const char *name, const uint16_t type, const CMPIObjectPath *ref, + const char **properties, struct inst_list *_list) { struct virt_device *list; @@ -636,7 +650,7 @@ int rasds_for_domain(const CMPIBroker *b for (i = 0; i < count; i++) { CMPIInstance *inst; - inst = rasd_from_vdev(broker, &list[i], name, ref); + inst = rasd_from_vdev(broker, &list[i], name, ref, properties); if (inst != NULL) inst_list_add(_list, inst); } diff -r 4da0767cf1fe -r 78743e525952 src/Virt_RASD.h --- a/src/Virt_RASD.h Mon Feb 25 11:13:54 2008 +0100 +++ b/src/Virt_RASD.h Mon Feb 25 09:08:58 2008 -0800 @@ -37,6 +37,7 @@ int rasds_for_domain(const CMPIBroker *b const char *name, const uint16_t type, const CMPIObjectPath *ref, + const char **properties, struct inst_list *_list); CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type); @@ -46,10 +47,12 @@ CMPIStatus get_rasd_by_name(const CMPIBr const CMPIObjectPath *reference, const char *name, const uint16_t type, + const char **properties, CMPIInstance **_inst); CMPIStatus get_rasd_by_ref(const CMPIBroker *broker, const CMPIObjectPath *reference, + const char **properties, CMPIInstance **_inst); #endif From kaitlin at linux.vnet.ibm.com Mon Feb 25 17:09:17 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 25 Feb 2008 09:09:17 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] Add property filtering to RASD. Message-ID: This patchset is built on top of Heidi's RASD patches. From kaitlin at linux.vnet.ibm.com Mon Feb 25 17:09:19 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 25 Feb 2008 09:09:19 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Update providers that call rasd_for_domain() and get_rasd_instance() In-Reply-To: Message-ID: <9440a0147ef999307f21.1203959359@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1203959342 28800 # Node ID 9440a0147ef999307f2110f68f7654fcdd77c472 # Parent 78743e525952642fea86b43c2599e128d87b8bab Update providers that call rasd_for_domain() and get_rasd_instance(). Signed-off-by: Kaitlin Rupert diff -r 78743e525952 -r 9440a0147ef9 src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Mon Feb 25 09:08:58 2008 -0800 +++ b/src/Virt_ElementSettingData.c Mon Feb 25 09:09:02 2008 -0800 @@ -98,7 +98,7 @@ static CMPIStatus rasd_to_rasd(const CMP /* Special association case: * RASD instance is pointing to itself */ - s = get_rasd_by_ref(_BROKER, ref, &inst); + s = get_rasd_by_ref(_BROKER, ref, info->properties, &inst); if (s.rc != CMPI_RC_OK) goto out; diff -r 78743e525952 -r 9440a0147ef9 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Mon Feb 25 09:08:58 2008 -0800 +++ b/src/Virt_ResourceAllocationFromPool.c Mon Feb 25 09:09:02 2008 -0800 @@ -66,7 +66,7 @@ static CMPIStatus rasd_to_pool(const CMP goto out; } - s = get_rasd_by_name(_BROKER, ref, id, type, &inst); + s = get_rasd_by_name(_BROKER, ref, id, type, NULL, &inst); if (s.rc != CMPI_RC_OK) goto out; @@ -138,6 +138,7 @@ static int rasds_from_pool(uint16_t type static int rasds_from_pool(uint16_t type, const CMPIObjectPath *ref, const char *poolid, + const char **properties, struct inst_list *list) { CMPIStatus s; @@ -164,6 +165,7 @@ static int rasds_from_pool(uint16_t type name, type, ref, + properties, &tmp); filter_by_pool(list, &tmp, poolid); @@ -213,6 +215,7 @@ static CMPIStatus pool_to_rasd(const CMP rasds_from_pool(type, ref, poolid, + info->properties, list); cu_statusf(_BROKER, &s, diff -r 78743e525952 -r 9440a0147ef9 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Mon Feb 25 09:08:58 2008 -0800 +++ b/src/Virt_SettingsDefineState.c Mon Feb 25 09:09:02 2008 -0800 @@ -98,6 +98,7 @@ static CMPIStatus dev_to_rasd(const CMPI name, device_type_from_classname(CLASSNAME(ref)), ref, + info->properties, &rasds); rasd = find_rasd(&rasds, id); @@ -180,7 +181,7 @@ static CMPIStatus rasd_to_dev(const CMPI goto out; } - s = get_rasd_by_name(_BROKER, ref, id, type, &inst); + s = get_rasd_by_name(_BROKER, ref, id, type, NULL, &inst); if (s.rc != CMPI_RC_OK) goto out; diff -r 78743e525952 -r 9440a0147ef9 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Mon Feb 25 09:08:58 2008 -0800 +++ b/src/Virt_VSSDComponent.c Mon Feb 25 09:09:02 2008 -0800 @@ -66,6 +66,7 @@ static CMPIStatus vssd_to_rasd(const CMP name, types[i], ref, + info->properties, list); } diff -r 78743e525952 -r 9440a0147ef9 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon Feb 25 09:08:58 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Mon Feb 25 09:09:02 2008 -0800 @@ -1041,7 +1041,7 @@ static CMPIStatus rasd_refs_to_insts(con continue; } - s = get_rasd_by_name(_BROKER, reference, id, type, &inst); + s = get_rasd_by_name(_BROKER, reference, id, type, NULL, &inst); if (s.rc != CMPI_RC_OK) continue; From kaitlin at linux.vnet.ibm.com Mon Feb 25 17:13:52 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 25 Feb 2008 09:13:52 -0800 Subject: [Libvirt-cim] [PATCH 2 of 5] VSMS: adopt interface changes of RASD In-Reply-To: References: Message-ID: <47C2F750.4000602@linux.vnet.ibm.com> Heidi Eckhart wrote: > # HG changeset patch > # User Heidi Eckhart > # Date 1203934430 -3600 > # Node ID fdda40f15fcfd38c50a8918ad1075714e19efa7a > # Parent 6e25b6b5b541ee6a3547ab2125937a7207bd21fc > VSMS: adopt interface changes of RASD > Signed-off-by: Heidi Eckhart > > diff -r 6e25b6b5b541 -r fdda40f15fcf src/Virt_VirtualSystemManagementService.c > + > *ret_arr = tmp_arr; > - > + > return s; > } > Whitespace here. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Mon Feb 25 17:14:42 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 25 Feb 2008 09:14:42 -0800 Subject: [Libvirt-cim] [PATCH 5 of 5] ESD: adopt interface changes to RASD In-Reply-To: <09459d892a7ba1f25fdd.1203935219@localhost.localdomain> References: <09459d892a7ba1f25fdd.1203935219@localhost.localdomain> Message-ID: <47C2F782.9010204@linux.vnet.ibm.com> Heidi Eckhart wrote: > # HG changeset patch > # User Heidi Eckhart > # Date 1203934434 -3600 > # Node ID 09459d892a7ba1f25fdd396dd41ff0e77fb6c234 > # Parent a8bd1f2980451ea709a720d2846300c52e089de0 > ESD: adopt interface changes to RASD > Signed-off-by: Heidi Eckhart > > diff -r a8bd1f298045 -r 09459d892a7b src/Virt_ElementSettingData.c > - > + > inst_list_add(list, inst); > - > + > out: > return s; > } Also whitespace here. Otherwise, this set looks good. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Mon Feb 25 17:47:36 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Mon, 25 Feb 2008 09:47:36 -0800 Subject: [Libvirt-cim] [PATCH 5 of 5] ESD: adopt interface changes to RASD In-Reply-To: <47C2F782.9010204@linux.vnet.ibm.com> References: <09459d892a7ba1f25fdd.1203935219@localhost.localdomain> <47C2F782.9010204@linux.vnet.ibm.com> Message-ID: <47C2FF38.4070803@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Heidi Eckhart wrote: >> # HG changeset patch >> # User Heidi Eckhart >> # Date 1203934434 -3600 >> # Node ID 09459d892a7ba1f25fdd396dd41ff0e77fb6c234 >> # Parent a8bd1f2980451ea709a720d2846300c52e089de0 >> ESD: adopt interface changes to RASD >> Signed-off-by: Heidi Eckhart >> >> diff -r a8bd1f298045 -r 09459d892a7b src/Virt_ElementSettingData.c Nevermind on this comment and the comment for src/Virt_VirtualSystemManagementService.c. I think my mail client was displaying things incorrectly. =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From grendel at linux.vnet.ibm.com Mon Feb 25 20:54:31 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 25 Feb 2008 15:54:31 -0500 Subject: [Libvirt-cim] [PATCH 3 of 3] [CU] classname_from_inst In-Reply-To: Message-ID: # HG changeset patch # User Jay Gagnon # Date 1203959116 18000 # Node ID d424467c183864fcf2c308ebe02e81f2f208e9b5 # Parent ad33899f5782b926070a0290ec8622fe164b5a27 [CU] classname_from_inst Function that pulls a classname out of an instance. Nothing fancy, just saves a few lines whenever this is needed. This is used by the new std_indication stuff. Signed-off-by: Jay Gagnon diff -r ad33899f5782 -r d424467c1838 instance_util.c --- a/instance_util.c Mon Feb 25 12:05:15 2008 -0500 +++ b/instance_util.c Mon Feb 25 12:05:16 2008 -0500 @@ -251,6 +251,21 @@ CMPIInstance *cu_dup_instance(const CMPI out: return dest; +} + +const char *classname_from_inst(CMPIInstance *inst) +{ + char *ret = NULL; + + CMPIObjectPath *ref; + ref = CMGetObjectPath(inst, NULL); + if (CMIsNullObject(ref)) + goto out; + + ret = CLASSNAME(ref); + + out: + return ret; } /* diff -r ad33899f5782 -r d424467c1838 libcmpiutil.h --- a/libcmpiutil.h Mon Feb 25 12:05:15 2008 -0500 +++ b/libcmpiutil.h Mon Feb 25 12:05:16 2008 -0500 @@ -414,6 +414,15 @@ CMPIStatus cu_validate_ref(const CMPIBro CMPIStatus cu_validate_ref(const CMPIBroker *broker, const CMPIObjectPath *ref, const CMPIInstance *inst); + +/** + * Returns the classname from an instance without forcing user to get + * ObjectPath first. + * + * @param inst Instance to examine + * @returns Classname of instance , NULL on failure + */ +const char *classname_from_inst(CMPIInstance *inst); #define DEFAULT_EIN(pn) \ static CMPIStatus pn##EnumInstanceNames(CMPIInstanceMI *self, \ From grendel at linux.vnet.ibm.com Mon Feb 25 20:54:28 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 25 Feb 2008 15:54:28 -0500 Subject: [Libvirt-cim] [PATCH 0 of 3] [CU] Standard Indication goes to eleven Message-ID: Serious re-vamp of the std_indication code. I pulled as many things as possible out of the providers and into std_indication. This helps keeps the code base small as the number of indications grows, plus makes the task of writing a new indication a bit more approachable. Changes are detailed in the patchsets. From grendel at linux.vnet.ibm.com Mon Feb 25 20:54:29 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 25 Feb 2008 15:54:29 -0500 Subject: [Libvirt-cim] [PATCH 1 of 3] [CU] Turn std_indication's awesome knob to eleven In-Reply-To: Message-ID: # HG changeset patch # User Jay Gagnon # Date 1203957417 18000 # Node ID f30365d472ed40da0af04d7ea3671ba3ac113580 # Parent af61b6c75b143067444f4eefe694d1e9709d2ccb [CU] Turn std_indication's awesome knob to eleven The new std_indication handles Enable/DisableIndications and Activate/DeactivateFilter correctly, even on a per-indication basis when one provider handles more than one indication. Those functions also now have default_foo equivalents in std_indication, as many providers (especially raise-style ones) will have no special needs there. Changes required to make it work: new struct to track which of a providers indications are active in the filter little macro to make declaring the new filter struct nice and clean new std_indication_ctx members for filters and global (per-provider) enabled flags stdi_foo functions that do the default behavior and dispatch work moving ind_args and CMPI_EI_VOID ifdef into std_indication My apologies for: how much there is in this one patch the reordering going on in std_indication.h, which I know isn't very PCO, I have some ready-made excuses for those that require them :) Signed-off-by: Jay Gagnon diff -r af61b6c75b14 -r f30365d472ed std_indication.c --- a/std_indication.c Wed Feb 13 08:26:56 2008 -0800 +++ b/std_indication.c Mon Feb 25 11:36:57 2008 -0500 @@ -32,10 +32,65 @@ #include "std_indication.h" +void stdi_free_ind_args (struct ind_args **args) +{ + free((*args)->ns); + free((*args)->classname); + free(*args); + *args = NULL; +} + +static struct std_ind_filter *get_ind_filter(struct std_ind_filter **list, + const char *ind_name) +{ + int i; + struct std_ind_filter *filter = NULL; + + for (i = 0; list[i] != NULL; i++) { + if (STREQC((list[i])->ind_name, ind_name)) { + filter = list[i]; + break; + } + } + + if (filter == NULL) + CU_DEBUG("get_ind_filter: failed to find %s", ind_name); + + return filter; +} + +static bool is_ind_enabled(struct std_indication_ctx *ctx, + const char *ind_name, + CMPIStatus *s) +{ + bool ret = false; + struct std_ind_filter *filter; + + if (!ctx->enabled) { + CU_DEBUG("Indications disabled for this provider"); + ret = false; + goto out; + } + + filter = get_ind_filter(ctx->filters, ind_name); + if (filter == NULL) { + cu_statusf(ctx->brkr, s, + CMPI_RC_ERR_FAILED, + "No std_ind_filter for %s", ind_name); + goto out; + } + + ret = filter->active; + if (!ret) + CU_DEBUG("Indication '%s' not in active filter", ind_name); + out: + return ret; +} + static CMPIStatus trigger(struct std_indication_ctx *ctx, const CMPIContext *context) { - if (ctx->handler->trigger_fn == NULL) + if (ctx->handler == NULL || ctx->handler->trigger_fn == NULL) return (CMPIStatus){CMPI_RC_OK, NULL}; return ctx->handler->trigger_fn(context); @@ -61,20 +116,171 @@ static CMPIStatus raise(struct std_indic const CMPIContext *context, const CMPIArgs *argsin) { + bool enabled; CMPIInstance *inst; - - if (!ctx->enabled) { - CU_DEBUG("Indication disabled, not raising."); - return (CMPIStatus) {CMPI_RC_OK, NULL}; - } - - if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK) - return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL}; - - if (ctx->handler->raise_fn == NULL) - return default_raise(ctx->brkr, context, inst); - - return ctx->handler->raise_fn(ctx->brkr, context, inst); + CMPIStatus s = {CMPI_RC_OK, NULL}; + const char *ind_name = NULL; + + if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK) { + cu_statusf(ctx->brkr, &s, + CMPI_RC_ERR_FAILED, + "Could not get indication to raise"); + goto out; + } + + ind_name = classname_from_inst(inst); + if (ind_name == NULL) { + cu_statusf(ctx->brkr, &s, + CMPI_RC_ERR_FAILED, + "Couldn't get indication name for enable check."); + } + + enabled = is_ind_enabled(ctx, ind_name, &s); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Problem checking enabled: '%s'", CMGetCharPtr(s.msg)); + goto out; + } + + if (!enabled) + goto out; + + if (ctx->handler == NULL || ctx->handler->raise_fn == NULL) + s = default_raise(ctx->brkr, context, inst); + else + s = ctx->handler->raise_fn(ctx->brkr, context, inst); + + out: + return s; +} +CMPIStatus stdi_deliver(const CMPIBroker *broker, + const CMPIContext *ctx, + struct ind_args *args, + CMPIInstance *ind) +{ + bool enabled; + const char *ind_name; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + ind_name = classname_from_inst(ind); + if (ind_name == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Couldn't get indication name for enable check."); + } + + enabled = is_ind_enabled(args->_ctx, ind_name, &s); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Problem checking enabled: '%s'", CMGetCharPtr(s.msg)); + goto out; + } + + if (enabled) + s = CBDeliverIndication(broker, ctx, args->ns, ind); + + out: + return s; +} + +CMPIStatus stdi_set_ind_filter_state(struct std_indication_ctx *ctx, + char *ind_name, + bool state) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + struct std_ind_filter *filter; + + filter = get_ind_filter(ctx->filters, ind_name); + if (filter == NULL) { + cu_statusf(ctx->brkr, &s, + CMPI_RC_ERR_FAILED, + "Provider has no indication '%s'", ind_name); + goto out; + } + + filter->active = state; + + out: + return s; +} + +CMPIStatus stdi_activate_filter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean first) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + struct std_indication_ctx *_ctx; + _ctx = (struct std_indication_ctx *)mi->hdl; + char *cn = NULL; + + _ctx = (struct std_indication_ctx *)mi->hdl; + cn = CLASSNAME(op); + s = stdi_set_ind_filter_state(_ctx, cn, true); + + if (_ctx->handler != NULL && _ctx->handler->activate_fn != NULL) { + CU_DEBUG("Calling handler->activate_fn"); + s = _ctx->handler->activate_fn(mi, ctx, se, ns, op, first); + goto out; + } + + out: + return s; +} + +CMPIStatus stdi_deactivate_filter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean last) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + struct std_indication_ctx *_ctx; + _ctx = (struct std_indication_ctx *)mi->hdl; + char *cn = NULL; + + _ctx = (struct std_indication_ctx *)mi->hdl; + cn = CLASSNAME(op); + s = stdi_set_ind_filter_state(_ctx, cn, false); + + if (_ctx->handler != NULL && _ctx->handler->deactivate_fn != NULL) { + s = _ctx->handler->deactivate_fn(mi, ctx, se, ns, op, last); + goto out; + } + + out: + return s; +} + +_EI_RTYPE stdi_enable_indications (CMPIIndicationMI* mi, + const CMPIContext *ctx) +{ + struct std_indication_ctx *_ctx; + _ctx = (struct std_indication_ctx *)mi->hdl; + + CU_DEBUG("enabling indications"); + _ctx->enabled = true; + + if (_ctx->handler != NULL && _ctx->handler->enable_fn != NULL) + return _ctx->handler->enable_fn(mi, ctx); + + _EI_RET(); +} + +_EI_RTYPE stdi_disable_indications (CMPIIndicationMI* mi, + const CMPIContext *ctx) +{ + struct std_indication_ctx *_ctx; + _ctx = (struct std_indication_ctx *)mi->hdl; + + CU_DEBUG("disabling indications"); + _ctx->enabled = false; + + if (_ctx->handler != NULL && _ctx->handler->disable_fn != NULL) + return _ctx->handler->disable_fn(mi, ctx); + + _EI_RET(); } CMPIStatus stdi_handler(CMPIMethodMI *self, diff -r af61b6c75b14 -r f30365d472ed std_indication.h --- a/std_indication.h Wed Feb 13 08:26:56 2008 -0800 +++ b/std_indication.h Mon Feb 25 11:36:57 2008 -0500 @@ -26,8 +26,74 @@ #include #include +#include "config.h" + #include "libcmpiutil.h" #include "std_invokemethod.h" + +#ifdef CMPI_EI_VOID +# define _EI_RTYPE void +# define _EI_RET() return +#else +# define _EI_RTYPE CMPIStatus +# define _EI_RET() return (CMPIStatus){CMPI_RC_OK, NULL} +#endif + +typedef CMPIStatus (*raise_indication_t)(const CMPIBroker *broker, + const CMPIContext *ctx, + const CMPIInstance *ind); + +typedef CMPIStatus (*trigger_indication_t)(const CMPIContext *ctx); + +typedef CMPIStatus (*activate_function_t) (CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean first); + +typedef CMPIStatus (*deactivate_function_t) (CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean last); + +typedef _EI_RTYPE (*enable_function_t) (CMPIIndicationMI* mi, + const CMPIContext *ctx); + +typedef _EI_RTYPE (*disable_function_t) (CMPIIndicationMI* mi, + const CMPIContext *ctx); + +struct std_indication_handler { + raise_indication_t raise_fn; + trigger_indication_t trigger_fn; + activate_function_t activate_fn; + deactivate_function_t deactivate_fn; + enable_function_t enable_fn; + disable_function_t disable_fn; +}; + +struct std_ind_filter { + char *ind_name; + bool active; +}; + +struct std_indication_ctx { + const CMPIBroker *brkr; + struct std_indication_handler *handler; + struct std_ind_filter **filters; + bool enabled; +}; + +struct ind_args { + CMPIContext *context; + char *ns; + char *classname; + struct std_indication_ctx *_ctx; +}; + +void stdi_free_ind_args (struct ind_args **args); CMPIStatus stdi_trigger_indication(const CMPIBroker *broker, const CMPIContext *context, @@ -39,6 +105,31 @@ CMPIStatus stdi_raise_indication(const C const char *type, const char *ns, const CMPIInstance *ind); + +CMPIStatus stdi_deliver(const CMPIBroker *broker, + const CMPIContext *ctx, + struct ind_args *args, + CMPIInstance *ind); + +CMPIStatus stdi_activate_filter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean first); + +CMPIStatus stdi_deactivate_filter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean last); + +_EI_RTYPE stdi_enable_indications (CMPIIndicationMI* mi, + const CMPIContext *ctx); + +_EI_RTYPE stdi_disable_indications (CMPIIndicationMI* mi, + const CMPIContext *ctx); CMPIStatus stdi_handler(CMPIMethodMI *self, const CMPIContext *context, @@ -52,27 +143,22 @@ CMPIStatus stdi_cleanup(CMPIMethodMI *se const CMPIContext *context, CMPIBoolean terminating); -typedef CMPIStatus (*raise_indication_t)(const CMPIBroker *broker, - const CMPIContext *ctx, - const CMPIInstance *ind); - -typedef CMPIStatus (*trigger_indication_t)(const CMPIContext *ctx); - -struct std_indication_handler { - raise_indication_t raise_fn; - trigger_indication_t trigger_fn; -}; - -struct std_indication_ctx { - const CMPIBroker *brkr; - struct std_indication_handler *handler; - bool enabled; -}; - -#define STDI_IndicationMIStub(pfx, pn, _broker, hook, _handler) \ - static struct std_indication_ctx _ctx = { \ +CMPIStatus stdi_set_ind_filter_state(struct std_indication_ctx *ctx, + char *ind_name, + bool state); + +/* This doesn't work, but should be made to. */ +#define DECLARE_FILTER(ident, name) \ + static struct std_ind_filter ident = { \ + .ind_name = name, \ + .active = false, \ + }; \ + +#define STDI_IndicationMIStub(pfx, pn, _broker, hook, _handler, filters)\ + static struct std_indication_ctx pn##_ctx = { \ .brkr = NULL, \ .handler = _handler, \ + .filters = filters, \ .enabled = false, \ }; \ \ @@ -83,9 +169,10 @@ struct std_indication_ctx { pfx##IndicationCleanup, \ pfx##AuthorizeFilter, \ pfx##MustPoll, \ - pfx##ActivateFilter, \ - pfx##DeActivateFilter, \ - CMIndicationMIStubExtensions(pfx) \ + stdi_activate_filter, \ + stdi_deactivate_filter, \ + stdi_enable_indications, \ + stdi_disable_indications, \ }; \ CMPIIndicationMI * \ pn##_Create_IndicationMI(const CMPIBroker *, \ @@ -96,10 +183,10 @@ struct std_indication_ctx { const CMPIContext *ctx, \ CMPIStatus *rc) { \ static CMPIIndicationMI mi = { \ - &_ctx, \ + &pn##_ctx, \ &indMIFT__, \ }; \ - _ctx.brkr = brkr; \ + pn##_ctx.brkr = brkr; \ _broker = brkr; \ hook; \ return &mi; \ @@ -121,10 +208,10 @@ struct std_indication_ctx { const CMPIContext *ctx, \ CMPIStatus *rc) { \ static CMPIMethodMI mi = { \ - &_ctx, \ + &pn##_ctx, \ &methMIFT__, \ }; \ - _ctx.brkr = brkr; \ + pn##_ctx.brkr = brkr; \ _broker = brkr; \ hook; \ return &mi; \ From grendel at linux.vnet.ibm.com Mon Feb 25 20:54:30 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 25 Feb 2008 15:54:30 -0500 Subject: [Libvirt-cim] [PATCH 2 of 3] [CU] add cmpi void to check to libcmpiutil In-Reply-To: Message-ID: # HG changeset patch # User Jay Gagnon # Date 1203959115 18000 # Node ID ad33899f5782b926070a0290ec8622fe164b5a27 # Parent f30365d472ed40da0af04d7ea3671ba3ac113580 [CU] add cmpi void to check to libcmpiutil This used to be only required by libvirt-cim, but the new functionality in std_indication has made it necessary in libcmpiutil as well. Signed-off-by: Jay Gagnon diff -r f30365d472ed -r ad33899f5782 acinclude.m4 --- a/acinclude.m4 Mon Feb 25 11:36:57 2008 -0500 +++ b/acinclude.m4 Mon Feb 25 12:05:15 2008 -0500 @@ -92,6 +92,34 @@ AC_DEFUN([CHECK_BROKEN_CMPIFT], ] )]) +# +# Check for void EnableIndications return +# +AC_DEFUN([CHECK_IND_VOID], [ + AH_TEMPLATE([CMPI_EI_VOID], + [Defined if return type of EnableIndications + should be void]) + AC_MSG_CHECKING([return type for indications]) + CFLAGS_TMP=$CFLAGS + CFLAGS="-Werror" + AC_TRY_COMPILE([ + #include + static void ei(CMPIIndicationMI *mi, const CMPIContext *c) { + return; + } + ],[ + struct _CMPIIndicationMIFT ft; + ft.enableIndications = ei; + return 0; + ], [ + echo "void" + AC_DEFINE_UNQUOTED([CMPI_EI_VOID], [yes]) + ], [ + echo "CMPIStatus" + ]) + CFLAGS=$CFLAGS_TMP +]) + AC_DEFUN([CHECK_LIBXML2], [ PKG_CHECK_MODULES([LIBXML], [libxml-2.0]) diff -r f30365d472ed -r ad33899f5782 configure.ac --- a/configure.ac Mon Feb 25 11:36:57 2008 -0500 +++ b/configure.ac Mon Feb 25 12:05:15 2008 -0500 @@ -4,6 +4,7 @@ AC_CONFIG_SRCDIR([libcmpiutil.h]) AC_CONFIG_SRCDIR([libcmpiutil.h]) CHECK_CMPI +CHECK_IND_VOID AC_CHECK_HEADERS([cmpidt.h cmpift.h cmpimacs.h]) @@ -22,7 +23,7 @@ CC_WARNINGS="\ CFLAGS="$CFLAGS $CC_WARNINGS -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE" -#AC_CONFIG_HEADER([config.h]) +AC_CONFIG_HEADER([config.h]) topdir=`pwd` AC_SUBST(topdir) From grendel at linux.vnet.ibm.com Mon Feb 25 20:57:04 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 25 Feb 2008 15:57:04 -0500 Subject: [Libvirt-cim] [PATCH 2 of 3] Add "Provider" to end of provider names for indications In-Reply-To: Message-ID: <3434ff4b4321cc649d36.1203973024@naegling> # HG changeset patch # User Jay Gagnon # Date 1203954855 18000 # Node ID 3434ff4b4321cc649d36cb15171cc1e685186f18 # Parent f09ab8e032c9cac3d3815a0f539f40437c1c115f Add "Provider" to end of provider names for indications Not directly related to new std_indication, but some debugging work revealed that the provider name and .so name were identical, which isn't great policy since you can't tell which is which in debug output. Signed-off-by: Jay Gagnon diff -r f09ab8e032c9 -r 3434ff4b4321 schema/ComputerSystemIndication.registration --- a/schema/ComputerSystemIndication.registration Mon Feb 25 10:54:10 2008 -0500 +++ b/schema/ComputerSystemIndication.registration Mon Feb 25 10:54:15 2008 -0500 @@ -1,8 +1,8 @@ # Copyright IBM Corp. 2007 # Classname Namespace ProviderName ProviderModule ProviderTypes -Xen_ComputerSystemCreatedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method -Xen_ComputerSystemDeletedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method -Xen_ComputerSystemModifiedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method -KVM_ComputerSystemCreatedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method -KVM_ComputerSystemDeletedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method -KVM_ComputerSystemModifiedIndication root/virt Virt_ComputerSystemIndication Virt_ComputerSystemIndication indication method +Xen_ComputerSystemCreatedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method +Xen_ComputerSystemDeletedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method +Xen_ComputerSystemModifiedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method +KVM_ComputerSystemCreatedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method +KVM_ComputerSystemDeletedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method +KVM_ComputerSystemModifiedIndication root/virt Virt_ComputerSystemIndicationProvider Virt_ComputerSystemIndication indication method diff -r f09ab8e032c9 -r 3434ff4b4321 schema/ComputerSystemMigrationIndication.registration --- a/schema/ComputerSystemMigrationIndication.registration Mon Feb 25 10:54:10 2008 -0500 +++ b/schema/ComputerSystemMigrationIndication.registration Mon Feb 25 10:54:15 2008 -0500 @@ -1,4 +1,4 @@ # Copyright IBM Corp. 2007 # Classname Namespace ProviderName ProviderModule ProviderTypes -Xen_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndication Virt_ComputerSystemMigrationIndication indication method -KVM_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndication Virt_ComputerSystemMigrationIndication indication method +Xen_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndicationProvider Virt_ComputerSystemMigrationIndication indication method +KVM_ComputerSystemMigrationIndication root/virt Virt_ComputerSystemMigrationIndicationProvider Virt_ComputerSystemMigrationIndication indication method From grendel at linux.vnet.ibm.com Mon Feb 25 20:57:05 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 25 Feb 2008 15:57:05 -0500 Subject: [Libvirt-cim] [PATCH 3 of 3] Bring ComputerSystemIndication up to speed with new std_indication In-Reply-To: Message-ID: <03485e8f9b04c3b6b016.1203973025@naegling> # HG changeset patch # User Jay Gagnon # Date 1203954964 18000 # Node ID 03485e8f9b04c3b6b01629116f436d6c78bee89e # Parent 3434ff4b4321cc649d36cb15171cc1e685186f18 Bring ComputerSystemIndication up to speed with new std_indication Move ind_args to std_indication Switch from using CBDeliver to using stdi_deliver Add new structs for new function table, enable/disable, filter mechanisms Move CMPI_VOID check to std_indication Pass ind_args around instead of individual components, add std_indication_ctx to ind_args. Signed-off-by: Jay Gagnon diff -r 3434ff4b4321 -r 03485e8f9b04 src/Virt_ComputerSystemIndication.c --- a/src/Virt_ComputerSystemIndication.c Mon Feb 25 10:54:15 2008 -0500 +++ b/src/Virt_ComputerSystemIndication.c Mon Feb 25 10:56:04 2008 -0500 @@ -59,36 +59,14 @@ static bool lifecycle_enabled = 0; #define WAIT_TIME 180 #define FAIL_WAIT_TIME 2 -#ifdef CMPI_EI_VOID -# define _EI_RTYPE void -# define _EI_RET() return -#else -# define _EI_RTYPE CMPIStatus -# define _EI_RET() return (CMPIStatus){CMPI_RC_OK, NULL} -#endif - struct dom_xml { char uuid[VIR_UUID_STRING_BUFLEN]; char *xml; }; -struct ind_args { - CMPIContext *context; - char *ns; - char *classname; -}; - static void free_dom_xml (struct dom_xml dom) { free(dom.xml); -} - -static void free_ind_args (struct ind_args **args) -{ - free((*args)->ns); - free((*args)->classname); - free(*args); - *args = NULL; } static char *sys_name_from_xml(char *xml) @@ -168,7 +146,7 @@ static bool _do_indication(const CMPIBro int ind_type, const char *ind_type_name, char *prefix, - char *ns) + struct ind_args *args) { CMPIObjectPath *affected_op; CMPIObjectPath *ind_op; @@ -179,13 +157,13 @@ static bool _do_indication(const CMPIBro ind = get_typed_instance(broker, prefix, ind_type_name, - ns); + args->ns); /* Generally report errors and hope to continue, since we have no one to actually return status to. */ if (ind == NULL) { CU_DEBUG("Failed to create ind, type '%s:%s_%s'", - ns, + args->ns, prefix, ind_type_name); ret = false; @@ -218,10 +196,7 @@ static bool _do_indication(const CMPIBro CU_DEBUG("Delivering Indication: %s", CMGetCharPtr(CMObjectPathToString(ind_op, NULL))); - CBDeliverIndication(broker, - ctx, - ns, - ind); + stdi_deliver(broker, ctx, args, ind); CU_DEBUG("Delivered"); out: @@ -261,7 +236,7 @@ static bool async_ind(CMPIContext *conte int ind_type, struct dom_xml prev_dom, char *prefix, - char *ns) + struct ind_args *args) { bool rc; char *name = NULL; @@ -271,7 +246,7 @@ static bool async_ind(CMPIContext *conte affected_inst = get_typed_instance(_BROKER, prefix, "ComputerSystem", - ns); + args->ns); name = sys_name_from_xml(prev_dom.xml); CU_DEBUG("Name for system: '%s'", name); @@ -298,7 +273,7 @@ static bool async_ind(CMPIContext *conte (CMPIValue *)prev_dom.uuid, CMPI_chars); rc = _do_indication(_BROKER, context, affected_inst, - ind_type, type_name, prefix, ns); + ind_type, type_name, prefix, args); out: free(name); @@ -317,7 +292,6 @@ static CMPI_THREAD_RETURN lifecycle_thre struct dom_xml *prev_xml = NULL; virConnectPtr conn; char *prefix = class_prefix_name(args->classname); - char *ns = args->ns; conn = connect_by_classname(_BROKER, args->classname, &s); if (conn == NULL) { @@ -358,7 +332,7 @@ static CMPI_THREAD_RETURN lifecycle_thre res = dom_in_list(cur_xml[i].uuid, prev_count, prev_xml); if (!res) async_ind(context, conn, CS_CREATED, - cur_xml[i], prefix, ns); + cur_xml[i], prefix, args); } @@ -366,14 +340,14 @@ static CMPI_THREAD_RETURN lifecycle_thre res = dom_in_list(prev_xml[i].uuid, cur_count, cur_xml); if (!res) async_ind(context, conn, CS_DELETED, - prev_xml[i], prefix, ns); + prev_xml[i], prefix, args); } for (i = 0; i < prev_count; i++) { res = dom_changed(prev_xml[i], cur_xml, cur_count); if (res) { async_ind(context, conn, CS_MODIFIED, - prev_xml[i], prefix, ns); + prev_xml[i], prefix, args); } free_dom_xml(prev_xml[i]); @@ -393,7 +367,7 @@ static CMPI_THREAD_RETURN lifecycle_thre out: pthread_mutex_unlock(&lifecycle_mutex); - free_ind_args(&args); + stdi_free_ind_args(&args); free(prefix); virConnectClose(conn); @@ -411,7 +385,10 @@ static CMPIStatus ActivateFilter(CMPIInd { CU_DEBUG("ActivateFilter"); CMPIStatus s = {CMPI_RC_OK, NULL}; + struct std_indication_ctx *_ctx; struct ind_args *args = malloc(sizeof(struct ind_args)); + + _ctx = (struct std_indication_ctx *)mi->hdl; if (CMIsNullObject(op)) { cu_statusf(_BROKER, &s, @@ -421,6 +398,7 @@ static CMPIStatus ActivateFilter(CMPIInd } args->ns = strdup(NAMESPACE(op)); args->classname = strdup(CLASSNAME(op)); + args->_ctx = _ctx; if (lifecycle_thread_id == 0) { args->context = CBPrepareAttachThread(_BROKER, ctx); @@ -451,8 +429,6 @@ static _EI_RTYPE EnableIndications(CMPII lifecycle_enabled = true; pthread_mutex_unlock(&lifecycle_mutex); - CU_DEBUG("ComputerSystemIndication enabled"); - _EI_RET(); } @@ -463,8 +439,6 @@ static _EI_RTYPE DisableIndications(CMPI lifecycle_enabled = false; pthread_mutex_unlock(&lifecycle_mutex); - CU_DEBUG("ComputerSystemIndication disabled"); - _EI_RET(); } @@ -478,17 +452,34 @@ static struct std_indication_handler csi static struct std_indication_handler csi = { .raise_fn = NULL, .trigger_fn = trigger_indication, + .activate_fn = ActivateFilter, + .deactivate_fn = DeActivateFilter, + .enable_fn = EnableIndications, + .disable_fn = DisableIndications, }; + +DECLARE_FILTER(xen_created, "Xen_ComputerSystemCreatedIndication"); +DECLARE_FILTER(xen_deleted, "Xen_ComputerSystemDeletedIndication"); +DECLARE_FILTER(xen_modified, "Xen_ComputerSystemModifiedIndication"); + +static struct std_ind_filter *filters[] = { + &xen_created, + &xen_deleted, + &xen_modified, + NULL, +}; + DEFAULT_IND_CLEANUP(); DEFAULT_AF(); DEFAULT_MP(); STDI_IndicationMIStub(, - Virt_ComputerSystemIndication, + Virt_ComputerSystemIndicationProvider, _BROKER, libvirt_cim_init(), - &csi); + &csi, + filters); /* * Local Variables: From grendel at linux.vnet.ibm.com Mon Feb 25 20:57:03 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 25 Feb 2008 15:57:03 -0500 Subject: [Libvirt-cim] [PATCH 1 of 3] Update ComputerSystemMigration to new std_indication In-Reply-To: Message-ID: # HG changeset patch # User Jay Gagnon # Date 1203954850 18000 # Node ID f09ab8e032c9cac3d3815a0f539f40437c1c115f # Parent d72742466a8892154997d2f210cb9ceeff035962 Update ComputerSystemMigration to new std_indication Essentially, it's been gutted. All this provider ever needed to be was a skeleton that passed along CSMI instances. All it does now is enough to tell std_indication that all the defaults are just fine. Signed-off-by: Jay Gagnon diff -r d72742466a88 -r f09ab8e032c9 src/Virt_ComputerSystemMigrationIndication.c --- a/src/Virt_ComputerSystemMigrationIndication.c Tue Feb 19 15:29:52 2008 -0800 +++ b/src/Virt_ComputerSystemMigrationIndication.c Mon Feb 25 10:54:10 2008 -0500 @@ -42,61 +42,11 @@ static const CMPIBroker *_BROKER; -#ifdef CMPI_EI_VOID -# define _EI_RTYPE void -# define _EI_RET() return -#else -# define _EI_RTYPE CMPIStatus -# define _EI_RET() return (CMPIStatus){CMPI_RC_OK, NULL} -#endif +DECLARE_FILTER(xen_migrate, "Xen_ComputerSystemMigrationIndication"); -static CMPIStatus ActivateFilter(CMPIIndicationMI* mi, - const CMPIContext* ctx, - const CMPISelectExp* se, - const char *ns, - const CMPIObjectPath* op, - CMPIBoolean first) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - - return s; -} - -static CMPIStatus DeActivateFilter(CMPIIndicationMI* mi, - const CMPIContext* ctx, - const CMPISelectExp* se, - const char *ns, - const CMPIObjectPath* op, - CMPIBoolean last) -{ - return (CMPIStatus){CMPI_RC_OK, NULL}; -} - -static _EI_RTYPE EnableIndications(CMPIIndicationMI* mi, - const CMPIContext *ctx) -{ - struct std_indication_ctx *_ctx; - _ctx = (struct std_indication_ctx *)mi->hdl; - _ctx->enabled = true; - CU_DEBUG("ComputerSystemModifiedIndication enabled"); - - _EI_RET(); -} - -static _EI_RTYPE DisableIndications(CMPIIndicationMI* mi, - const CMPIContext *ctx) -{ - struct std_indication_ctx *_ctx; - _ctx = (struct std_indication_ctx *)mi->hdl; - _ctx->enabled = false; - CU_DEBUG("ComputerSystemModifiedIndication disabled"); - - _EI_RET(); -} - -static struct std_indication_handler csi = { - .raise_fn = NULL, - .trigger_fn = NULL, +static struct std_ind_filter *filters[] = { + &xen_migrate, + NULL, }; DEFAULT_IND_CLEANUP(); @@ -104,10 +54,11 @@ DEFAULT_MP(); DEFAULT_MP(); STDI_IndicationMIStub(, - Virt_ComputerSystemMigrationIndication, + Virt_ComputerSystemMigrationIndicationProvider, _BROKER, libvirt_cim_init(), - &csi); + NULL, + filters); /* * Local Variables: From grendel at linux.vnet.ibm.com Mon Feb 25 20:57:02 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 25 Feb 2008 15:57:02 -0500 Subject: [Libvirt-cim] [PATCH 0 of 3] Bring providers up to speed with new std_indication Message-ID: Not a ton of explanation needed here. This is the sister set to the new libcmpiutil std_indication changes. From danms at us.ibm.com Mon Feb 25 21:47:21 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 25 Feb 2008 13:47:21 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] [CU] Turn std_indication's awesome knob to eleven In-Reply-To: (Jay Gagnon's message of "Mon, 25 Feb 2008 15:54:29 -0500") References: Message-ID: <87fxvgk8t2.fsf@caffeine.beaverton.ibm.com> JG> static CMPIStatus trigger(struct std_indication_ctx *ctx, JG> const CMPIContext *context) JG> { JG> - if (ctx->handler->trigger_fn == NULL) JG> + if (ctx->handler == NULL || ctx->handler->trigger_fn == NULL) JG> return (CMPIStatus){CMPI_RC_OK, NULL}; Maybe I'm misreading the diff, but do you check for enabled/activated on trigger? JG> +CMPIStatus stdi_activate_filter(CMPIIndicationMI* mi, JG> + const CMPIContext* ctx, JG> + const CMPISelectExp* se, JG> + const char *ns, JG> + const CMPIObjectPath* op, JG> + CMPIBoolean first) JG> +{ JG> + CMPIStatus s = {CMPI_RC_OK, NULL}; JG> + struct std_indication_ctx *_ctx; JG> + _ctx = (struct std_indication_ctx *)mi->hdl; JG> + char *cn = NULL; JG> + JG> + _ctx = (struct std_indication_ctx *)mi->hdl; Looks like you have the _ctx initialization twice in here. Remove the first to avoid intermixed statements and declarations. JG> +CMPIStatus stdi_deactivate_filter(CMPIIndicationMI* mi, JG> + const CMPIContext* ctx, JG> + const CMPISelectExp* se, JG> + const char *ns, JG> + const CMPIObjectPath* op, JG> + CMPIBoolean last) JG> +{ JG> + CMPIStatus s = {CMPI_RC_OK, NULL}; JG> + struct std_indication_ctx *_ctx; JG> + _ctx = (struct std_indication_ctx *)mi->hdl; JG> + char *cn = NULL; JG> + JG> + _ctx = (struct std_indication_ctx *)mi->hdl; Here too. JG> +_EI_RTYPE stdi_enable_indications (CMPIIndicationMI* mi, JG> + const CMPIContext *ctx) JG> +{ JG> + struct std_indication_ctx *_ctx; JG> + _ctx = (struct std_indication_ctx *)mi->hdl; JG> + JG> + CU_DEBUG("enabling indications"); I think this debug would be a lot more useful if it had the indication type in it. Would that be much trouble? JG> +_EI_RTYPE stdi_disable_indications (CMPIIndicationMI* mi, JG> + const CMPIContext *ctx) JG> +{ JG> + struct std_indication_ctx *_ctx; JG> + _ctx = (struct std_indication_ctx *)mi->hdl; JG> + JG> + CU_DEBUG("disabling indications"); This one too. Otherwise this looks fantastic...Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 25 21:48:47 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 25 Feb 2008 13:48:47 -0800 Subject: [Libvirt-cim] [PATCH 3 of 3] [CU] classname_from_inst In-Reply-To: (Jay Gagnon's message of "Mon, 25 Feb 2008 15:54:31 -0500") References: Message-ID: <87bq64k8qo.fsf@caffeine.beaverton.ibm.com> JG> # HG changeset patch JG> # User Jay Gagnon JG> # Date 1203959116 18000 JG> # Node ID d424467c183864fcf2c308ebe02e81f2f208e9b5 JG> # Parent ad33899f5782b926070a0290ec8622fe164b5a27 JG> [CU] classname_from_inst Can you prefix this with cu_ like (most of) the rest of the libcmpiutil functions? Also, can you order them so that this comes before patch 1 so that we don't have a changeset that fails to build? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 25 21:51:09 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 25 Feb 2008 13:51:09 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] Update ComputerSystemMigration to new std_indication In-Reply-To: (Jay Gagnon's message of "Mon, 25 Feb 2008 15:57:03 -0500") References: Message-ID: <877igsk8mq.fsf@caffeine.beaverton.ibm.com> JG> # HG changeset patch JG> # User Jay Gagnon JG> # Date 1203954850 18000 JG> # Node ID f09ab8e032c9cac3d3815a0f539f40437c1c115f JG> # Parent d72742466a8892154997d2f210cb9ceeff035962 JG> Update ComputerSystemMigration to new std_indication Hard to complain with a diffstat like this: Virt_ComputerSystemMigrationIndication.c | 63 +++---------------------------- 1 file changed, 7 insertions(+), 56 deletions(-) +1 from me :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Mon Feb 25 21:54:24 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 25 Feb 2008 13:54:24 -0800 Subject: [Libvirt-cim] [PATCH 3 of 3] Bring ComputerSystemIndication up to speed with new std_indication In-Reply-To: <03485e8f9b04c3b6b016.1203973025@naegling> (Jay Gagnon's message of "Mon, 25 Feb 2008 15:57:05 -0500") References: <03485e8f9b04c3b6b016.1203973025@naegling> Message-ID: <873argk8hb.fsf@caffeine.beaverton.ibm.com> JG> +DECLARE_FILTER(xen_created, "Xen_ComputerSystemCreatedIndication"); JG> +DECLARE_FILTER(xen_deleted, "Xen_ComputerSystemDeletedIndication"); JG> +DECLARE_FILTER(xen_modified, "Xen_ComputerSystemModifiedIndication"); No KVM love? I guess we need a follow-on patch to this to make the thread and everything else aware of KVM domains... -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From grendel at linux.vnet.ibm.com Mon Feb 25 22:00:16 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 25 Feb 2008 17:00:16 -0500 Subject: [Libvirt-cim] [PATCH 3 of 3] Bring ComputerSystemIndication up to speed with new std_indication In-Reply-To: <873argk8hb.fsf@caffeine.beaverton.ibm.com> References: <03485e8f9b04c3b6b016.1203973025@naegling> <873argk8hb.fsf@caffeine.beaverton.ibm.com> Message-ID: <47C33A70.6070802@linux.vnet.ibm.com> Dan Smith wrote: > JG> +DECLARE_FILTER(xen_created, "Xen_ComputerSystemCreatedIndication"); > JG> +DECLARE_FILTER(xen_deleted, "Xen_ComputerSystemDeletedIndication"); > JG> +DECLARE_FILTER(xen_modified, "Xen_ComputerSystemModifiedIndication"); > > No KVM love? > > I guess we need a follow-on patch to this to make the thread and > everything else aware of KVM domains... > > > Yea, I noticed that we don't really do anything with KVM in all of that, so I figured it would all get taken care of at once. -- -Jay From grendel at linux.vnet.ibm.com Mon Feb 25 22:02:43 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 25 Feb 2008 17:02:43 -0500 Subject: [Libvirt-cim] [PATCH 3 of 3] [CU] classname_from_inst In-Reply-To: <87bq64k8qo.fsf@caffeine.beaverton.ibm.com> References: <87bq64k8qo.fsf@caffeine.beaverton.ibm.com> Message-ID: <47C33B03.3090707@linux.vnet.ibm.com> Dan Smith wrote: > JG> # HG changeset patch > JG> # User Jay Gagnon > JG> # Date 1203959116 18000 > JG> # Node ID d424467c183864fcf2c308ebe02e81f2f208e9b5 > JG> # Parent ad33899f5782b926070a0290ec8622fe164b5a27 > JG> [CU] classname_from_inst > > Can you prefix this with cu_ like (most of) the rest of the > libcmpiutil functions? > Oops, sorry. > Also, can you order them so that this comes before patch 1 so that we > don't have a changeset that fails to build? > > > Ah, that hadn't occurred to me when I was breaking them up. No problem. -- -Jay From grendel at linux.vnet.ibm.com Mon Feb 25 22:05:47 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Mon, 25 Feb 2008 17:05:47 -0500 Subject: [Libvirt-cim] [PATCH 1 of 3] [CU] Turn std_indication's awesome knob to eleven In-Reply-To: <87fxvgk8t2.fsf@caffeine.beaverton.ibm.com> References: <87fxvgk8t2.fsf@caffeine.beaverton.ibm.com> Message-ID: <47C33BBB.3020706@linux.vnet.ibm.com> Dan Smith wrote: > JG> static CMPIStatus trigger(struct std_indication_ctx *ctx, > JG> const CMPIContext *context) > JG> { > JG> - if (ctx->handler->trigger_fn == NULL) > JG> + if (ctx->handler == NULL || ctx->handler->trigger_fn == NULL) > JG> return (CMPIStatus){CMPI_RC_OK, NULL}; > > Maybe I'm misreading the diff, but do you check for enabled/activated > on trigger? > I don't here, but when the trigger loop tries to use stdi_deliver to send off its indication, I check there. I guess it would be easy to check here, and save a bit of work, so I can add that in. > JG> +CMPIStatus stdi_activate_filter(CMPIIndicationMI* mi, > JG> + const CMPIContext* ctx, > JG> + const CMPISelectExp* se, > JG> + const char *ns, > JG> + const CMPIObjectPath* op, > JG> + CMPIBoolean first) > JG> +{ > JG> + CMPIStatus s = {CMPI_RC_OK, NULL}; > JG> + struct std_indication_ctx *_ctx; > JG> + _ctx = (struct std_indication_ctx *)mi->hdl; > JG> + char *cn = NULL; > JG> + > JG> + _ctx = (struct std_indication_ctx *)mi->hdl; > > Looks like you have the _ctx initialization twice in here. Remove the > first to avoid intermixed statements and declarations. > Ah, the dreaded oh-look-I-copied-and-pasted-and-didn't-even-proofread-it! > JG> +CMPIStatus stdi_deactivate_filter(CMPIIndicationMI* mi, > JG> + const CMPIContext* ctx, > JG> + const CMPISelectExp* se, > JG> + const char *ns, > JG> + const CMPIObjectPath* op, > JG> + CMPIBoolean last) > JG> +{ > JG> + CMPIStatus s = {CMPI_RC_OK, NULL}; > JG> + struct std_indication_ctx *_ctx; > JG> + _ctx = (struct std_indication_ctx *)mi->hdl; > JG> + char *cn = NULL; > JG> + > JG> + _ctx = (struct std_indication_ctx *)mi->hdl; > > Here too. > > JG> +_EI_RTYPE stdi_enable_indications (CMPIIndicationMI* mi, > JG> + const CMPIContext *ctx) > JG> +{ > JG> + struct std_indication_ctx *_ctx; > JG> + _ctx = (struct std_indication_ctx *)mi->hdl; > JG> + > JG> + CU_DEBUG("enabling indications"); > > I think this debug would be a lot more useful if it had the indication > type in it. Would that be much trouble? > I *think* it should be easy enough. With the mi and the context I should be able to find it somewhere. > JG> +_EI_RTYPE stdi_disable_indications (CMPIIndicationMI* mi, > JG> + const CMPIContext *ctx) > JG> +{ > JG> + struct std_indication_ctx *_ctx; > JG> + _ctx = (struct std_indication_ctx *)mi->hdl; > JG> + > JG> + CU_DEBUG("disabling indications"); > > This one too. > > Otherwise this looks fantastic...Thanks! > > > -- -Jay From danms at us.ibm.com Mon Feb 25 22:13:02 2008 From: danms at us.ibm.com (Dan Smith) Date: Mon, 25 Feb 2008 14:13:02 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] [CU] Turn std_indication's awesome knob to eleven In-Reply-To: <47C33BBB.3020706@linux.vnet.ibm.com> (Jay Gagnon's message of "Mon, 25 Feb 2008 17:05:47 -0500") References: <87fxvgk8t2.fsf@caffeine.beaverton.ibm.com> <47C33BBB.3020706@linux.vnet.ibm.com> Message-ID: <87y798it1t.fsf@caffeine.beaverton.ibm.com> JG> I don't here, but when the trigger loop tries to use stdi_deliver JG> to send off its indication, I check there. I guess it would be JG> easy to check here, and save a bit of work, so I can add that in. Ah, okay, that's fine, I was just comparing it to raise below. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From heidieck at linux.vnet.ibm.com Tue Feb 26 09:10:18 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 10:10:18 +0100 Subject: [Libvirt-cim] [PATCH 2 of 4] ESD: adopt interface changes in VSSD In-Reply-To: Message-ID: <9e52e86e0765b889e775.1204017018@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1204016142 -3600 # Node ID 9e52e86e0765b889e7755c5c5c885342d644ed2c # Parent 330455bd74683ef91240d1d290da2339c7719a6c ESD: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r 330455bd7468 -r 9e52e86e0765 src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Tue Feb 26 09:51:45 2008 +0100 +++ b/src/Virt_ElementSettingData.c Tue Feb 26 09:55:42 2008 +0100 @@ -41,47 +41,20 @@ static CMPIStatus vssd_to_vssd(const CMP { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; - char *host = NULL; if (!match_hypervisor_prefix(ref, info)) return s; - if (!parse_instanceid(ref, NULL, &host)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to get system name"); + /* Special association case: + * VSSD instance is pointing to itself + */ + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) goto out; - } - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, host); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such system `%s'", host); - goto out; - } - - inst = get_vssd_instance(dom, _BROKER, ref); - if (inst == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Error getting VSSD for `%s'", host); - goto out; - } inst_list_add(list, inst); out: - virDomainFree(dom); - virConnectClose(conn); - free(host); - return s; } From heidieck at linux.vnet.ibm.com Tue Feb 26 09:10:19 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 10:10:19 +0100 Subject: [Libvirt-cim] [PATCH 3 of 4] SDS: adopt interface changes in VSSD In-Reply-To: Message-ID: <972e31994c47cfbd4af6.1204017019@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1204016311 -3600 # Node ID 972e31994c47cfbd4af63b83c1138bc83e6d2b23 # Parent 9e52e86e0765b889e7755c5c5c885342d644ed2c SDS: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r 9e52e86e0765 -r 972e31994c47 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Tue Feb 26 09:55:42 2008 +0100 +++ b/src/Virt_SettingsDefineState.c Tue Feb 26 09:58:31 2008 +0100 @@ -199,18 +199,16 @@ static CMPIStatus vs_to_vssd(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; const char *name; - CMPIInstance *vssd; - CMPIStatus s = {CMPI_RC_OK, NULL}; if (!match_hypervisor_prefix(ref, info)) return s; - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - return s; + s = get_domain(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "Name", &name) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, @@ -219,27 +217,14 @@ static CMPIStatus vs_to_vssd(const CMPIO goto out; } - dom = virDomainLookupByName(conn, name); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such domain `%s'", name); - goto out; - } - - vssd = get_vssd_instance(dom, _BROKER, ref); - if (vssd != NULL) - inst_list_add(list, vssd); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - out: - virDomainFree(dom); - virConnectClose(conn); - + s = get_vssd_by_name(_BROKER, ref, name, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, inst); + + out: return s; - } static CMPIStatus vssd_to_vs(const CMPIObjectPath *ref, @@ -253,9 +238,14 @@ static CMPIStatus vssd_to_vs(const CMPIO virConnectPtr conn = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *cs; + CMPIInstance *inst; if (!match_hypervisor_prefix(ref, info)) return s; + + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, From heidieck at linux.vnet.ibm.com Tue Feb 26 09:10:16 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 10:10:16 +0100 Subject: [Libvirt-cim] [PATCH 0 of 4] #5 - Enable VSSD to validate client given object path and Adopt changed to VSSD interface to ESD & SDS & VSSDC Message-ID: VSSD does now take care of the client given object path. The resulting interface changes have been adopted to - ESD by the second patch - SDS by the third patch - VSSDC by the fourth patch (diff to patch set 1) diff to patch set 2: - updated VSSD to compare a returned integer result explicitely diff to patch set 3: - fixed memory leak (on name) in get_vssd_by_ref - fixed get_vssd_by_name and get_vssd_by_ref to only return a valid instance pointer in case of success diff to patch set 4: - fix whitespace issues From heidieck at linux.vnet.ibm.com Tue Feb 26 09:10:20 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 10:10:20 +0100 Subject: [Libvirt-cim] [PATCH 4 of 4] VSSDC: adopt interface changes in VSSD In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1204016361 -3600 # Node ID f3320ebdb7dae05d2137349af824fbaf28f49f67 # Parent 972e31994c47cfbd4af63b83c1138bc83e6d2b23 VSSDC: adopt interface changes in VSSD Signed-off-by: Heidi Eckhart diff -r 972e31994c47 -r f3320ebdb7da src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Tue Feb 26 09:58:31 2008 +0100 +++ b/src/Virt_VSSDComponent.c Tue Feb 26 09:59:21 2008 +0100 @@ -41,6 +41,7 @@ static CMPIStatus vssd_to_rasd(const CMP struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; char *name = NULL; int i = 0; int types[] = { @@ -52,7 +53,11 @@ static CMPIStatus vssd_to_rasd(const CMP }; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; + + s = get_vssd_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (!parse_instanceid(ref, NULL, &name)) { cu_statusf(_BROKER, &s, @@ -70,48 +75,9 @@ static CMPIStatus vssd_to_rasd(const CMP list); } - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - out: free(name); - return s; -} - -static CMPIStatus vssd_for_name(const char *host, - const CMPIObjectPath *ref, - CMPIInstance **inst) -{ - virConnectPtr conn = NULL; - virDomainPtr dom = NULL; - CMPIStatus s; - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - dom = virDomainLookupByName(conn, host); - if (dom == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No such system `%s'", host); - goto out; - } - - *inst = get_vssd_instance(dom, _BROKER, ref); - if (*inst == NULL) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Error getting VSSD for `%s'", host); - else - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: - virDomainFree(dom); - virConnectClose(conn); - return s; } @@ -144,9 +110,11 @@ static CMPIStatus rasd_to_vssd(const CMP goto out; } - s = vssd_for_name(host, ref, &vssd); - if (vssd) - inst_list_add(list, vssd); + s = get_vssd_by_name(_BROKER, ref, host, &vssd); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, vssd); out: free(host); From heidieck at linux.vnet.ibm.com Tue Feb 26 09:10:17 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 10:10:17 +0100 Subject: [Libvirt-cim] [PATCH 1 of 4] VSSD: validate client given object path In-Reply-To: Message-ID: <330455bd74683ef91240.1204017017@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1204015905 -3600 # Node ID 330455bd74683ef91240d1d290da2339c7719a6c # Parent 1aef50fa67a9ba1a3687afe03e3b1bf455d57685 VSSD: validate client given object path wbemgi 'http://localhost:5988/root/virt:KVM_VirtualSystemSettingData.InstanceID="Xen:kvm1-f8"' on a KVM only system is returning an instance, but should not. wbemgi 'http://localhost:5988/root/virt:Xen_VirtualSystemSettingData.InstanceID="KVM:kvm1-f8"' on a KVM only system is seg faulting, but should not ;). Signed-off-by: Heidi Eckhart diff -r 1aef50fa67a9 -r 330455bd7468 src/Virt_VSSD.c --- a/src/Virt_VSSD.c Mon Feb 25 09:09:02 2008 -0800 +++ b/src/Virt_VSSD.c Tue Feb 26 09:51:45 2008 +0100 @@ -135,42 +135,46 @@ static int instance_from_dom(virDomainPt return ret; } -CMPIInstance *get_vssd_instance(virDomainPtr dom, - const CMPIBroker *broker, - const CMPIObjectPath *ref) -{ - CMPIInstance *inst; - +static CMPIInstance *_get_vssd(const CMPIBroker *broker, + const CMPIObjectPath *reference, + virConnectPtr conn, + virDomainPtr dom, + CMPIStatus *s) +{ + CMPIInstance *inst = NULL; + inst = get_typed_instance(broker, - CLASSNAME(ref), + pfx_from_conn(conn), "VirtualSystemSettingData", - NAMESPACE(ref)); - - if (inst == NULL) - return NULL; - - if (instance_from_dom(dom, inst)) - return inst; - else - return NULL; -} - -static CMPIStatus enum_vssd(const CMPIObjectPath *reference, - const CMPIResult *results, - int names_only) + NAMESPACE(reference)); + + if (inst == NULL) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to init VirtualSystemSettingData instance"); + goto out; + } + + if (instance_from_dom(dom, inst) != 1) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to get VSSD instance from Domain"); + } + + out: + return inst; +} + +static CMPIStatus return_enum_vssd(const CMPIObjectPath *reference, + const CMPIResult *results, + bool names_only) { virConnectPtr conn; virDomainPtr *list; int count; int i; - CMPIStatus s; - const char *ns; - - if (!provider_is_responsible(_BROKER, reference, &s)) - return s; - - ns = NAMESPACE(reference); - + CMPIStatus s = {CMPI_RC_OK, NULL}; + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); if (conn == NULL) return s; @@ -181,17 +185,14 @@ static CMPIStatus enum_vssd(const CMPIOb CMPI_RC_ERR_FAILED, "Failed to enumerate domains"); goto out; - } else if (count == 0) { - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - goto out; - } + } else if (count == 0) + goto out; for (i = 0; i < count; i++) { - CMPIInstance *inst; - - inst = get_vssd_instance(list[i], _BROKER, reference); + CMPIInstance *inst = NULL; + + inst = _get_vssd(_BROKER, reference, conn, list[i], &s); + virDomainFree(list[i]); if (inst == NULL) continue; @@ -202,39 +203,83 @@ static CMPIStatus enum_vssd(const CMPIOb CMReturnInstance(results, inst); } - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: free(list); return s; - -} - -static CMPIInstance *get_vssd_for_name(const CMPIObjectPath *reference, - char *name) +} + +CMPIStatus get_vssd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst) { virConnectPtr conn; virDomainPtr dom; - CMPIStatus s; - CMPIInstance *inst = NULL; - - conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); - if (conn == NULL) - return NULL; - + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + dom = virDomainLookupByName(conn, name); - if (dom == NULL) - goto out; - - inst = get_vssd_instance(dom, _BROKER, reference); - + if (dom == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } + + inst = _get_vssd(broker, reference, conn, dom, &s); + + virDomainFree(dom); + + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + out: virConnectClose(conn); - virDomainFree(dom); - - return inst; + + return s; +} + +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + char *name = NULL; + + if (!parse_instanceid(reference, NULL, &name)) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (InstanceID)"); + goto out; + } + + s = get_vssd_by_name(broker, reference, name, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + + out: + free(name); + + return s; } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -242,7 +287,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return enum_vssd(reference, results, 1); + return return_enum_vssd(reference, results, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -251,7 +296,7 @@ static CMPIStatus EnumInstances(CMPIInst const CMPIObjectPath *reference, const char **properties) { - return enum_vssd(reference, results, 0); + return return_enum_vssd(reference, results, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -261,26 +306,15 @@ static CMPIStatus GetInstance(CMPIInstan const char **properties) { CMPIStatus s; - CMPIInstance *inst; - char *locid; - - if (!parse_instanceid(reference, NULL, &locid)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Invalid InstanceID specified"); - return s; - } - - inst = get_vssd_for_name(reference, locid); - if (inst) - CMReturnInstance(results, inst); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - - free(locid); - + CMPIInstance *inst = NULL; + + s = get_vssd_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: return s; } diff -r 1aef50fa67a9 -r 330455bd7468 src/Virt_VSSD.h --- a/src/Virt_VSSD.h Mon Feb 25 09:09:02 2008 -0800 +++ b/src/Virt_VSSD.h Tue Feb 26 09:51:45 2008 +0100 @@ -21,8 +21,14 @@ #ifndef __VIRT_VSSD_H #define __VIRT_VSSD_H -CMPIInstance *get_vssd_instance(virDomainPtr dom, - const CMPIBroker *broker, - const CMPIObjectPath *ref); +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); + +CMPIStatus get_vssd_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst); + #endif From heidieck at linux.vnet.ibm.com Tue Feb 26 09:17:52 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 10:17:52 +0100 Subject: [Libvirt-cim] [PATCH 1 of 2] Add property filtering to RASD provider In-Reply-To: <873arhm605.fsf@caffeine.beaverton.ibm.com> References: <2bff66d74872c62ef38f.1203704012@elm3b41.beaverton.ibm.com> <47C2A572.2080401@linux.vnet.ibm.com> <873arhm605.fsf@caffeine.beaverton.ibm.com> Message-ID: <47C3D940.2080904@linux.vnet.ibm.com> Dan Smith wrote: > HE> I think it makes sense to move this code into get_typed_instance() > HE> of libxkutil, to avoid implementing these lines for every > HE> provider. What's then only necessary is routing the properties > HE> list through the interfaces. > > Yes, I think that's a good idea, but it will require a lot of silly > changes, so it's probably best to wait until after we finish with some > of our more important correctness issues. > Absolutely ! I can only agree. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Tue Feb 26 09:34:26 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 10:34:26 +0100 Subject: [Libvirt-cim] [PATCH 1 of 2] Add property filtering to RASD provider In-Reply-To: <47C2EEBD.7040803@linux.vnet.ibm.com> References: <2bff66d74872c62ef38f.1203704012@elm3b41.beaverton.ibm.com> <47C2A572.2080401@linux.vnet.ibm.com> <47C2EEBD.7040803@linux.vnet.ibm.com> Message-ID: <47C3DD22.6030806@linux.vnet.ibm.com> Kaitlin Rupert wrote: >>> + >>> + if (properties != NULL) { >>> + const char *keys[] = {"InstanceID", NULL}; >>> + s = CMSetPropertyFilter(inst, properties, keys); >>> + /* FIXME - in case of an error, should we continue >>> on? */ >>> + if (s.rc != CMPI_RC_OK) >>> + CU_DEBUG("Unable to set property filter: >>> %d", s.rc); >>> + } >>> >> That's a very good point to enable the provider interfaces for the >> property filtering :). I think it makes sense to move this code into >> get_typed_instance() of libxkutil, to avoid implementing these lines >> for every provider. What's then only necessary is routing the >> properties list through the interfaces. But you will now think ... >> and how about the keys ? Well, that's an interesting thing. The CMPI >> 2.0 spec tells the following about the keys: >> CMPI 2.0 Spec; "The keyList argument shall be ignored by the MB; it >> is here to maintain binary compatibility with previous >> specifications. Providers should explicitly set the key names and >> values via the CMPIInstanceMI.setObjectPath() function." >> Translated I think this means, that we can ignore the keys by setting >> it to NULL. Do you agree ? > > I tried using NULL for the keys based on the same line from the CMPI > spec, but this crashed the provider. I might be missing something > though. I've tested it with Pegasus and sfcb: Pegasus returns with FAILED and does not set the propertylist sfcb is crashing So my interpretation of this description seem to be wrong and the keyList is needed. Thanks for evaluating this. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Tue Feb 26 09:54:14 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 10:54:14 +0100 Subject: [Libvirt-cim] [PATCH 2 of 2] EC: adopt interface changes to ELEC In-Reply-To: Message-ID: <8ce1fe84f5831b7f3e32.1204019654@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1204016904 -3600 # Node ID 8ce1fe84f5831b7f3e32832901845a749a429c78 # Parent 308a23419d5182dfab9febc1ae6c08ae2a45613c EC: adopt interface changes to ELEC Signed-off-by: Heidi Eckhart diff -r 308a23419d51 -r 8ce1fe84f583 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Tue Feb 26 10:07:17 2008 +0100 +++ b/src/Virt_ElementCapabilities.c Tue Feb 26 10:08:24 2008 +0100 @@ -216,7 +216,7 @@ static CMPIStatus cs_to_cap(const CMPIOb goto out; } - s = get_ele_cap(_BROKER, ref, sys_name, &inst); + s = get_elec_by_name(_BROKER, ref, sys_name, &inst); if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); @@ -234,6 +234,10 @@ static CMPIStatus cap_to_cs(const CMPIOb CMPIStatus s = {CMPI_RC_OK, NULL}; if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = get_elec_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) goto out; if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) { From heidieck at linux.vnet.ibm.com Tue Feb 26 09:54:13 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 10:54:13 +0100 Subject: [Libvirt-cim] [PATCH 1 of 2] ELEC: seg faults by wrong client given object path In-Reply-To: Message-ID: <308a23419d5182dfab9f.1204019653@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1204016837 -3600 # Node ID 308a23419d5182dfab9febc1ae6c08ae2a45613c # Parent f3320ebdb7dae05d2137349af824fbaf28f49f67 ELEC: seg faults by wrong client given object path wbemgi 'http://localhost:5988/root/virt:KVM_EnabledLogicalElementCapabilities.InstanceID="wrong"' seg faults wbemgi 'http://localhost:5988/root/virt:Xen_EnabledLogicalElementCapabilities.InstanceID="kvm1-f8"' seg faults on a KVM only system Signed-off-by: Heidi Eckhart diff -r f3320ebdb7da -r 308a23419d51 src/Virt_EnabledLogicalElementCapabilities.c --- a/src/Virt_EnabledLogicalElementCapabilities.c Tue Feb 26 09:59:21 2008 +0100 +++ b/src/Virt_EnabledLogicalElementCapabilities.c Tue Feb 26 10:07:17 2008 +0100 @@ -46,26 +46,33 @@ enum {ENABLED = 2, QUIESCE, REBOOT, RESET}; - - - -static CMPIStatus set_inst_properties(const CMPIBroker *broker, - CMPIInstance *inst, - const char *classname, - const char *sys_name) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; + +static CMPIInstance *_get_elec(const CMPIBroker *broker, + const CMPIObjectPath *reference, + virConnectPtr conn, + const char *name, + CMPIStatus *s) +{ + CMPIInstance *inst = NULL; CMPIArray *array; uint16_t element; int edit_name = 0; - - CMSetProperty(inst, "CreationClassName", - (CMPIValue *)classname, CMPI_chars); - - CMSetProperty(inst, "InstanceID", (CMPIValue *)sys_name, CMPI_chars); - - array = CMNewArray(broker, 5, CMPI_uint16, &s); - if ((s.rc != CMPI_RC_OK) || CMIsNullObject(array)) + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "EnabledLogicalElementCapabilities", + NAMESPACE(reference)); + if (inst == NULL) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to init EnabledLogicalElementCapabilities instance"); + goto out; + } + + CMSetProperty(inst, "InstanceID", (CMPIValue *)name, CMPI_chars); + + array = CMNewArray(broker, 5, CMPI_uint16, s); + if ((s->rc != CMPI_RC_OK) || CMIsNullObject(array)) goto out; element = (uint16_t)ENABLED; @@ -88,56 +95,14 @@ static CMPIStatus set_inst_properties(co CMSetProperty(inst, "ElementNameEditSupported", (CMPIValue *)&edit_name, CMPI_boolean); - out: - return s; -} - -CMPIStatus get_ele_cap(const CMPIBroker *broker, - const CMPIObjectPath *ref, - const char *sys_name, - CMPIInstance **inst) -{ - CMPIStatus s; - CMPIObjectPath *op; - char *classname = NULL; - - classname = get_typed_class(CLASSNAME(ref), - "EnabledLogicalElementCapabilities"); - if (classname == NULL) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Invalid class"); - goto out; - } - - op = CMNewObjectPath(broker, NAMESPACE(ref), classname, &s); - if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Cannot get object path for ELECapabilities"); - goto out; - } - - *inst = CMNewInstance(broker, op, &s); - if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(*inst))) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Failed to instantiate HostSystem"); - goto out; - } - - s = set_inst_properties(broker, *inst, classname, sys_name); - - out: - free(classname); - - return s; -} - -static CMPIStatus return_ele_cap(const CMPIObjectPath *ref, - const CMPIResult *results, - int names_only, - const char *id) + + out: + return inst; +} + +static CMPIStatus return_enum_elec(const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; @@ -164,10 +129,7 @@ static CMPIStatus return_ele_cap(const C goto end; } - if (id && (!STREQ(name, id))) - goto end; - - s = get_ele_cap(_BROKER, ref, name, &inst); + inst = _get_elec(_BROKER, ref, conn, name, &s); if (s.rc != CMPI_RC_OK) goto end; @@ -178,16 +140,81 @@ static CMPIStatus return_ele_cap(const C end: virDomainFree(list[i]); - - if ((s.rc != CMPI_RC_OK) || (id && (STREQ(name, id)))) - goto out; } out: free(list); - virConnectClose(conn); + return s; +} + +CMPIStatus get_elec_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn; + virDomainPtr dom; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + dom = virDomainLookupByName(conn, name); + if (dom == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } + + inst = _get_elec(broker, reference, conn, name, &s); + virDomainFree(dom); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + + out: + virConnectClose(conn); + + return s; +} + +CMPIStatus get_elec_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + const char *name; + + if (cu_get_str_path(reference, "InstanceID", &name) != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "No InstanceID specified"); + goto out; + } + + s = get_elec_by_name(broker, reference, name, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = inst; + + out: return s; } @@ -196,7 +223,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_ele_cap(reference, results, 1, NULL); + return return_enum_elec(reference, results, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -206,7 +233,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_ele_cap(reference, results, 0, NULL); + return return_enum_elec(reference, results, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -216,16 +243,16 @@ static CMPIStatus GetInstance(CMPIInstan const char **properties) { CMPIStatus s = {CMPI_RC_OK, NULL}; - const char* id; - - if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "No InstanceID specified"); - return s; - } - - return return_ele_cap(reference, results, 0, id); + CMPIInstance *inst = NULL; + + s = get_elec_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: + return s; } DEFAULT_CI(); diff -r f3320ebdb7da -r 308a23419d51 src/Virt_EnabledLogicalElementCapabilities.h --- a/src/Virt_EnabledLogicalElementCapabilities.h Tue Feb 26 09:59:21 2008 +0100 +++ b/src/Virt_EnabledLogicalElementCapabilities.h Tue Feb 26 10:07:17 2008 +0100 @@ -18,10 +18,15 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -CMPIStatus get_ele_cap(const CMPIBroker *broker, - const CMPIObjectPath *ref, - const char *sys_name, - CMPIInstance **inst); +CMPIStatus get_elec_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + CMPIInstance **_inst); + +CMPIStatus get_elec_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); + /* * Local Variables: * mode: C From heidieck at linux.vnet.ibm.com Tue Feb 26 09:54:12 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 10:54:12 +0100 Subject: [Libvirt-cim] [PATCH 0 of 2] #3 - Enable ELEC to validate client given object path and Adopt changed to ELEC interface to EC Message-ID: fix whitespace issues From heidieck at linux.vnet.ibm.com Tue Feb 26 12:51:49 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 13:51:49 +0100 Subject: [Libvirt-cim] [PATCH 2 of 3] SDS: validate client given object path of devices In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1204029555 -3600 # Node ID cb5e9f764dc5acde83c436232a37cb39945a8bc1 # Parent c9ac31ec5a89cd5b2d165c34d218412cbbb6c47d SDS: validate client given object path of devices wbemain -ac CIM_SettingsDefineState 'http://localhost/root/virt:KVM_Memory.DeviceID="kvm1-f8/mem",CreationClassName="",SystemName="wrong",SystemCreationClassName=""' is returning an instance instead of NOT_FOUND Signed-off-by: Heidi Eckhart diff -r c9ac31ec5a89 -r cb5e9f764dc5 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Tue Feb 26 13:39:12 2008 +0100 +++ b/src/Virt_SettingsDefineState.c Tue Feb 26 13:39:15 2008 +0100 @@ -39,119 +39,41 @@ const static CMPIBroker *_BROKER; -static CMPIInstance *find_rasd(struct inst_list *list, - const char *devid) -{ - int i; - CMPIInstance *inst; - - for (i = 0; i < list->cur; i++) { - const char *id; - int ret; - - inst = list->list[i]; - - ret = cu_get_str_prop(inst, "InstanceID", &id); - if (ret != CMPI_RC_OK) - continue; - - if (STREQ(id, devid)) - return inst; - } - - return NULL; -} - static CMPIStatus dev_to_rasd(const CMPIObjectPath *ref, struct std_assoc_info *info, struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *rasd; - struct inst_list rasds; - const char *id = NULL; - char *name = NULL; - char *devid = NULL; - int ret; - - if (!match_hypervisor_prefix(ref, info)) - return s; - - inst_list_init(&rasds); - - if (cu_get_str_path(ref, "DeviceID", &id) != CMPI_RC_OK) { + CMPIInstance *inst = NULL; + const char *name = NULL; + + if (!match_hypervisor_prefix(ref, info)) + return s; + + s = get_device_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + if (cu_get_str_path(ref, "DeviceID", &name) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing DeviceID"); goto out; - } - - ret = parse_fq_devid(id, &name, &devid); - if (!ret) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Invalid DeviceID"); - goto out; - } - - ret = rasds_for_domain(_BROKER, - name, - device_type_from_classname(CLASSNAME(ref)), - ref, - info->properties, - &rasds); - - rasd = find_rasd(&rasds, id); - if (rasd != NULL) - inst_list_add(list, rasd); - - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - out: - free(name); - free(devid); - - return s; -} - -static CMPIInstance *_get_typed_device(const char *id, - int type, - const CMPIObjectPath *ref, - CMPIStatus *s) -{ - virConnectPtr conn = NULL; - CMPIInstance *dev = NULL; - const char *typestr; - - conn = connect_by_classname(_BROKER, CLASSNAME(ref), s); - if (conn == NULL) - goto out; - - if (type == CIM_RASD_TYPE_DISK) - typestr = "LogicalDisk"; - else if (type == CIM_RASD_TYPE_MEM) - typestr = "Memory"; - else if (type == CIM_RASD_TYPE_PROC) - typestr = "Processor"; - else if (type == CIM_RASD_TYPE_NET) - typestr = "NetworkPort"; - else { - cu_statusf(_BROKER, s, - CMPI_RC_ERR_FAILED, - "Invalid device type (%i)", type); - goto out; - } - - dev = instance_from_devid(_BROKER, - conn, - id, - NAMESPACE(ref), - device_type_from_classname(typestr)); - out: - virConnectClose(conn); - - return dev; + } + + s = get_rasd_by_name(_BROKER, + ref, + name, + device_type_from_classname(CLASSNAME(ref)), + NULL, + &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, inst); + + out: + return s; } static CMPIStatus rasd_to_dev(const CMPIObjectPath *ref, @@ -159,15 +81,18 @@ static CMPIStatus rasd_to_dev(const CMPI struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *dev = NULL; CMPIInstance *inst = NULL; - const char *id = NULL; + const char *name = NULL; uint16_t type; if (!match_hypervisor_prefix(ref, info)) return s; - if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { + s = get_rasd_by_ref(_BROKER, ref, NULL, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + if (cu_get_str_path(ref, "InstanceID", &name) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Missing InstanceID"); @@ -180,16 +105,12 @@ static CMPIStatus rasd_to_dev(const CMPI "Missing ResourceType"); goto out; } - - s = get_rasd_by_name(_BROKER, ref, id, type, NULL, &inst); - if (s.rc != CMPI_RC_OK) - goto out; - - dev = _get_typed_device(id, type, ref, &s); - if (dev == NULL) - goto out; - - inst_list_add(list, dev); + + s = get_device_by_name(_BROKER, ref, name, type, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, inst); out: return s; From heidieck at linux.vnet.ibm.com Tue Feb 26 12:51:50 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 13:51:50 +0100 Subject: [Libvirt-cim] [PATCH 3 of 3] SD: adopt interface change of Device provider In-Reply-To: Message-ID: <59b90560cdd2dc274858.1204030310@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1204029556 -3600 # Node ID 59b90560cdd2dc2748589747294e6d4d658fb3b8 # Parent cb5e9f764dc5acde83c436232a37cb39945a8bc1 SD: adopt interface change of Device provider Signed-off-by: Heidi Eckhart diff -r cb5e9f764dc5 -r 59b90560cdd2 src/Virt_SystemDevice.c --- a/src/Virt_SystemDevice.c Tue Feb 26 13:39:15 2008 +0100 +++ b/src/Virt_SystemDevice.c Tue Feb 26 13:39:16 2008 +0100 @@ -184,7 +184,7 @@ static CMPIStatus dev_to_sys(const CMPIO if (!match_hypervisor_prefix(ref, info)) return s; - s = get_device(_BROKER, ref, &inst); + s = get_device_by_ref(_BROKER, ref, &inst); if (s.rc != CMPI_RC_OK) goto out; From heidieck at linux.vnet.ibm.com Tue Feb 26 12:51:47 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 13:51:47 +0100 Subject: [Libvirt-cim] [PATCH 0 of 3] Add get_device_by_name/ref to Device provider and Adopt interfaces in SDS and SD Message-ID: Add functions get_device_by_ref and get_device_by_name to Device provider. Adopt these two interfaces in SD and SDS assoc providers. From heidieck at linux.vnet.ibm.com Tue Feb 26 12:51:48 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Tue, 26 Feb 2008 13:51:48 +0100 Subject: [Libvirt-cim] [PATCH 1 of 3] Device: implement get_dev_by_ref and get_dev_by_name for usage in assocs In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1204029552 -3600 # Node ID c9ac31ec5a89cd5b2d165c34d218412cbbb6c47d # Parent 8ce1fe84f5831b7f3e32832901845a749a429c78 Device: implement get_dev_by_ref and get_dev_by_name for usage in assocs Signed-off-by: Heidi Eckhart diff -r 8ce1fe84f583 -r c9ac31ec5a89 src/Virt_Device.c --- a/src/Virt_Device.c Tue Feb 26 10:08:24 2008 +0100 +++ b/src/Virt_Device.c Tue Feb 26 13:39:12 2008 +0100 @@ -268,7 +268,7 @@ static CMPIInstance *device_instance(con return instance; } -int device_type_from_classname(const char *classname) +uint16_t device_type_from_classname(const char *classname) { if (strstr(classname, "NetworkPort")) return VIRT_DEV_NET; @@ -419,79 +419,96 @@ static struct virt_device *find_dom_dev( return dev; } -CMPIInstance *instance_from_devid(const CMPIBroker *broker, - virConnectPtr conn, - const char *devid, - const char *ns, - int type) -{ +CMPIStatus get_device_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + const uint16_t type, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; char *domain = NULL; char *device = NULL; CMPIInstance *instance = NULL; + virConnectPtr conn = NULL; virDomainPtr dom = NULL; struct virt_device *dev = NULL; - if (!parse_devid(devid, &domain, &device)) - return NULL; - - dom = virDomainLookupByName(conn, domain); - if (!dom) - goto out; - - dev = find_dom_dev(dom, device, type); - if (!dev) - goto out; - - instance = device_instance(broker, dev, dom, ns); - cleanup_virt_device(dev); - - out: - virDomainFree(dom); - free(domain); - free(device); - - return instance; -} - -CMPIStatus get_device(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **_inst) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - virConnectPtr conn; - CMPIInstance *inst; - const char *cn; - const char *devid; - - cn = CLASSNAME(reference); - - conn = connect_by_classname(broker, cn, &s); + conn = connect_by_classname(broker, CLASSNAME(reference), &s); if (conn == NULL) { cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, "No such instance"); goto out; - } - - if (cu_get_str_path(reference, "DeviceID", &devid) != CMPI_RC_OK) { + } + + if (parse_devid(name, &domain, &device) != 1) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto out; + } + + dom = virDomainLookupByName(conn, domain); + if (dom == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto err; + } + + dev = find_dom_dev(dom, device, type); + if (!dev) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + name); + goto err; + } + + instance = device_instance(broker, + dev, + dom, + NAMESPACE(reference)); + cleanup_virt_device(dev); + + *_inst = instance; + + err: + virDomainFree(dom); + free(domain); + free(device); + + out: + virConnectClose(conn); + + return s; +} + +CMPIStatus get_device_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + const char *name = NULL; + + if (cu_get_str_path(reference, "DeviceID", &name) != CMPI_RC_OK) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "No DeviceID specified"); goto out; } - - inst = instance_from_devid(broker, - conn, - devid, - NAMESPACE(reference), - device_type_from_classname(cn)); - if (inst == NULL) { - cu_statusf(broker, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", devid); - goto out; - } - + + s = get_device_by_name(broker, + reference, + name, + device_type_from_classname(CLASSNAME(reference)), + &inst); + if (s.rc != CMPI_RC_OK) + goto out; + s = cu_validate_ref(broker, reference, inst); if (s.rc != CMPI_RC_OK) goto out; @@ -499,24 +516,7 @@ CMPIStatus get_device(const CMPIBroker * *_inst = inst; out: - virConnectClose(conn); - return s; -} - -static CMPIStatus return_device(const CMPIResult *results, - const CMPIObjectPath *reference) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst = NULL; - - s = get_device(_BROKER, reference, &inst); - if (s.rc != CMPI_RC_OK || inst == NULL) - return s; - - CMReturnInstance(results, inst); - - return s; } static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, @@ -542,7 +542,17 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - return return_device(results, reference); + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_device_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: + return s; } DEFAULT_CI(); diff -r 8ce1fe84f583 -r c9ac31ec5a89 src/Virt_Device.h --- a/src/Virt_Device.h Tue Feb 26 10:08:24 2008 +0100 +++ b/src/Virt_Device.h Tue Feb 26 13:39:12 2008 +0100 @@ -46,30 +46,31 @@ int dom_devices(const CMPIBroker *broker * * @param broker A pointer to the CIM broker * @param reference The object path identifying the instance - * @param inst Contains the pointer to the instance in case + * @param _inst Contains the pointer to the instance in case * of success * @returns CMPIStatus of the operation */ -CMPIStatus get_device(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **_inst); +CMPIStatus get_device_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst); /** - * Return a device instance for a given devid + * Returns the device instance for a given name and type * * @param broker A pointer to the CIM broker - * @param conn The libvirt connection to use - * @param devid The device id - * @param reference the namespace - * @returns The instance, or NULL if not found + * @param reference The object path containing namespace info + * @param name The name "/" + * @param type The resource type + * @param _inst The instance pointer in case of success + * @returns The result as CMPIStatus */ -CMPIInstance *instance_from_devid(const CMPIBroker *broker, - virConnectPtr conn, - const char *devid, - const char *ns, - int type); +CMPIStatus get_device_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + const uint16_t type, + CMPIInstance **_inst); -int device_type_from_classname(const char *classname); +uint16_t device_type_from_classname(const char *classname); #endif From danms at us.ibm.com Tue Feb 26 14:40:03 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 26 Feb 2008 06:40:03 -0800 Subject: [Libvirt-cim] [PATCH 0 of 4] #5 - Enable VSSD to validate client given object path and Adopt changed to VSSD interface to ESD & SDS & VSSDC In-Reply-To: (Heidi Eckhart's message of "Tue, 26 Feb 2008 10:10:16 +0100") References: Message-ID: <87prujixx8.fsf@caffeine.beaverton.ibm.com> HE> diff to patch set 4: HE> - fix whitespace issues Thanks Heidi :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Tue Feb 26 15:31:58 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 26 Feb 2008 07:31:58 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Add VirtualSystemSnapshotService build support In-Reply-To: Message-ID: <822e09efc574c5f28920.1204039918@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1204039908 28800 # Node ID 822e09efc574c5f2892095a8b1e6d48cf1fa7e2e # Parent c173208c9c4c70d4ca736f31a19f278268e73971 Add VirtualSystemSnapshotService build support Signed-off-by: Dan Smith diff -r c173208c9c4c -r 822e09efc574 Makefile.am --- a/Makefile.am Tue Feb 26 07:28:58 2008 -0800 +++ b/Makefile.am Tue Feb 26 07:31:48 2008 -0800 @@ -37,7 +37,8 @@ MOFS = \ schema/ElementSettingData.mof \ schema/VSMigrationCapabilities.mof \ schema/VSMigrationService.mof \ - schema/VSMigrationSettingData.mof + schema/VSMigrationSettingData.mof \ + schema/VirtualSystemSnapshotService.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -81,7 +82,8 @@ REGS = \ schema/VSMigrationCapabilities.registration \ schema/VSMigrationService.registration \ schema/ElementConformsToProfile.registration \ - schema/VSMigrationSettingData.registration + schema/VSMigrationSettingData.registration \ + schema/VirtualSystemSnapshotService.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ diff -r c173208c9c4c -r 822e09efc574 schema/VirtualSystemSnapshotService.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotService.mof Tue Feb 26 07:31:48 2008 -0800 @@ -0,0 +1,7 @@ +// Copyright IBM Corp. 2008 + +[Description ( "Snapshot types are as follows: " + "32768: Memory-only snapshot (suspend, resume, keep image)" + "32769: Memory-only, terminal (domain is offline after op)")] +class Xen_VirtualSystemSnapshotService : CIM_VirtualSystemSnapshotService { }; +class KVM_VirtualSystemSnapshotService : CIM_VirtualSystemSnapshotService { }; diff -r c173208c9c4c -r 822e09efc574 schema/VirtualSystemSnapshotService.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotService.registration Tue Feb 26 07:31:48 2008 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemSnapshotService root/virt Virt_VirtualSystemSnapshotService Virt_VirtualSystemSnapshotService method +KVM_VirtualSystemSnapshotService root/virt Virt_VirtualSystemSnapshotService Virt_VirtualSystemSnapshotService method diff -r c173208c9c4c -r 822e09efc574 src/Makefile.am --- a/src/Makefile.am Tue Feb 26 07:28:58 2008 -0800 +++ b/src/Makefile.am Tue Feb 26 07:31:48 2008 -0800 @@ -56,7 +56,8 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_ElementSettingData.la \ libVirt_VSMigrationCapabilities.la \ libVirt_VSMigrationService.la \ - libVirt_VSMigrationSettingData.la + libVirt_VSMigrationSettingData.la \ + libVirt_VirtualSystemSnapshotService.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -161,3 +162,6 @@ libVirt_VSMigrationService_la_LIBADD = - libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c +libVirt_VirtualSystemSnapshotService_la_DEPENDENCIES = +libVirt_VirtualSystemSnapshotService_la_SOURCES = Virt_VirtualSystemSnapshotService.c +libVirt_VirtualSystemSnapshotService_la_LIBADD = From danms at us.ibm.com Tue Feb 26 15:31:56 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 26 Feb 2008 07:31:56 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] Add VirtualSystemSnapshotService Message-ID: This adds basic support for the VirtualSystemSnapshotService. Since the service seems to assume that a system can be snapshotted while running (which Xen cannot do), we provide a terminal snapshot and fake a running snapshot by doing a save/resume. Still to be done is adding the Capabilities support, as well as making the VSSD provider expose an additional VSSD for the snapshot, as required by the SVP. From danms at us.ibm.com Tue Feb 26 15:31:57 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 26 Feb 2008 07:31:57 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add VirtualSystemSnapshotService In-Reply-To: Message-ID: # HG changeset patch # User Dan Smith # Date 1204039738 28800 # Node ID c173208c9c4c70d4ca736f31a19f278268e73971 # Parent bb0530f50ea8d4a75ec34cd54f3bc2daebbda556 Add VirtualSystemSnapshotService Signed-off-by: Dan Smith diff -r bb0530f50ea8 -r c173208c9c4c src/Virt_VirtualSystemSnapshotService.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemSnapshotService.c Tue Feb 26 07:28:58 2008 -0800 @@ -0,0 +1,508 @@ +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include "misc_util.h" + +#define CIM_VSSS_SNAPSHOT_FULL 2 +#define CIM_VSSS_SNAPSHOT_DISK 3 + +/* VIR_VSSS_SNAPSHOT_MEM - Attempt to save/restore to create a running snap + * VIR_VSSS_SNAPSHOT_MEMT - Just save and let the domain be "off" + */ +#define VIR_VSSS_SNAPSHOT_MEM 32768 +#define VIR_VSSS_SNAPSHOT_MEMT 32769 + +#define CIM_JOBSTATE_STARTING 3 +#define CIM_JOBSTATE_RUNNING 4 +#define CIM_JOBSTATE_COMPLETE 7 + +static const CMPIBroker *_BROKER; + +struct snap_context { + CMPIContext *context; + char *domain; + char uuid[33]; + char *save_path; + char *ref_ns; + char *ref_cn; + + bool save; + bool restore; +}; + +static void snap_job_free(struct snap_context *ctx) +{ + free(ctx->domain); + free(ctx->save_path); + free(ctx->ref_ns); + free(ctx->ref_cn); + free(ctx); +} + +static void snap_job_set_status(struct snap_context *ctx, + uint16_t state, + const char *status) +{ + CMPIInstance *inst; + CMPIStatus s; + CMPIObjectPath *op; + + op = CMNewObjectPath(_BROKER, + ctx->ref_ns, + "CIM_ConcreteJob", + &s); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Failed to create job path for update"); + return; + } + + CMAddKey(op, "InstanceID", (CMPIValue *)ctx->uuid, CMPI_chars); + + inst = CBGetInstance(_BROKER, ctx->context, op, NULL, &s); + if ((inst == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to get job instance for update of %s", + ctx->uuid); + return; + } + + CMSetProperty(inst, "JobState", + (CMPIValue *)&state, CMPI_uint16); + CMSetProperty(inst, "Status", + (CMPIValue *)status, CMPI_chars); + + s = CBModifyInstance(_BROKER, ctx->context, op, inst, NULL); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Failed to update job instance %s: %s", + ctx->uuid, + CMGetCharPtr(s.msg)); + return; + } + + CU_DEBUG("Set %s status to %i:%s", ctx->uuid, state, status); +} + +static void do_snapshot(struct snap_context *ctx, + virConnectPtr conn, + virDomainPtr dom) +{ + int ret; + + if (ctx->save) { + CU_DEBUG("Starting save to %s", ctx->save_path); + + ret = virDomainSave(dom, ctx->save_path); + if (ret == -1) { + CU_DEBUG("Save failed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Snapshot Failed (save)"); + return; + } + + CU_DEBUG("Save completed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_RUNNING, + "Save finished"); + } + + if (ctx->restore) { + CU_DEBUG("Starting restore from %s", ctx->save_path); + + ret = virDomainRestore(conn, ctx->save_path); + if (ret == -1) { + CU_DEBUG("Restore failed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Snapshot Failed (restore)"); + return; + } + + CU_DEBUG("Restore completed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_RUNNING, + "Restore finished"); + } + + CU_DEBUG("Snapshot (%s/%s) completed", + ctx->save ? "Save" : "None", + ctx->restore ? "Restore" : "None"); + + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Snapshot complete"); + + return; +} + +static CMPI_THREAD_RETURN snapshot_thread(struct snap_context *ctx) +{ + CMPIStatus s; + virConnectPtr conn = NULL; + virDomainPtr dom = NULL; + + CU_DEBUG("Snapshot thread alive"); + + CBAttachThread(_BROKER, ctx->context); + + snap_job_set_status(ctx, CIM_JOBSTATE_RUNNING, "Running"); + + conn = connect_by_classname(_BROKER, ctx->ref_cn, &s); + if (conn == NULL) { + CU_DEBUG("Failed to connect with classname `%s'", ctx->ref_cn); + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Unable to connect to hypervisor"); + goto out; + } + + dom = virDomainLookupByName(conn, ctx->domain); + if (dom == NULL) { + CU_DEBUG("No such domain `%s'", ctx->domain); + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "No such domain"); + goto out; + } + + do_snapshot(ctx, conn, dom); + + out: + virDomainFree(dom); + virConnectClose(conn); + + snap_job_free(ctx); + + return NULL; +} + +static CMPIStatus create_job(const CMPIContext *context, + const CMPIObjectPath *ref, + struct snap_context *ctx, + CMPIObjectPath **job) +{ + CMPIObjectPath *op; + CMPIInstance *inst; + CMPIStatus s; + + op = CMNewObjectPath(_BROKER, + NAMESPACE(ref), + "CIM_ConcreteJob", /*FIXME*/ + &s); + if ((s.rc != CMPI_RC_OK) || (op == NULL)) { + CU_DEBUG("Failed to create job path"); + goto out; + } + + CMSetNameSpace(op, NAMESPACE(ref)); + + inst = CMNewInstance(_BROKER, op, &s); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) { + CU_DEBUG("Failed to create job instance"); + goto out; + } + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)ctx->uuid, CMPI_chars); + + CMSetProperty(inst, "Name", + (CMPIValue *)"Snapshot", CMPI_chars); + + CMSetProperty(inst, "Status", + (CMPIValue *)"Queued", CMPI_chars); + + op = CMGetObjectPath(inst, &s); + if ((op == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to get path of job instance"); + goto out; + } + + CMSetNameSpace(op, NAMESPACE(ref)); + + CU_DEBUG("ref was %s", CMGetCharPtr(CMObjectPathToString(op, NULL))); + + *job = CBCreateInstance(_BROKER, context, op, inst, &s); + if ((*job == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to create job"); + goto out; + } + + ctx->ref_ns = strdup(NAMESPACE(ref)); + ctx->ref_cn = strdup(CLASSNAME(ref)); + + ctx->context = CBPrepareAttachThread(_BROKER, context); + + _BROKER->xft->newThread((void *)snapshot_thread, ctx, 0); + + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); + out: + return s; +} + +static char *get_save_path(const char *domname) +{ + int ret; + char *path = NULL; + + ret = asprintf(&path, + "/var/lib/libvirt/%s.save", domname); + if (ret == -1) + return NULL; + + return path; +} + +static struct snap_context *new_context(const char *name, + CMPIStatus *s) +{ + struct snap_context *ctx; + uuid_t uuid; + + ctx = calloc(1, sizeof(*ctx)); + if (ctx == NULL) { + CU_DEBUG("Failed to alloc snapshot context"); + goto out; + } + + ctx->domain = strdup(name); + + uuid_generate(uuid); + uuid_unparse(uuid, ctx->uuid); + + ctx->save_path = get_save_path(ctx->domain); + if (ctx->save_path == NULL) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Unable to get save_path"); + goto out; + } + + cu_statusf(_BROKER, s, + CMPI_RC_OK, + ""); + out: + if (s->rc != CMPI_RC_OK) { + snap_job_free(ctx); + ctx = NULL; + } + + return ctx; +} + +static CMPIStatus start_snapshot_job(const CMPIObjectPath *ref, + const CMPIContext *context, + const char *name, + uint16_t type) +{ + struct snap_context *ctx; + CMPIStatus s; + CMPIObjectPath *job; + + ctx = new_context(name, &s); + if (ctx == NULL) + goto out; + + ctx->save = (type != 0); + ctx->restore = (type != VIR_VSSS_SNAPSHOT_MEM); + + s = create_job(context, ref, ctx, &job); + + out: + return s; +} + +static CMPIStatus create_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *system; + CMPIInstance *sd; + uint16_t type; + uint32_t retcode = 0; + const char *name; + + if (cu_get_u16_arg(argsin, "SnapshotType", &type) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing SnapshotType"); + goto out; + } + + if ((type != VIR_VSSS_SNAPSHOT_MEM) && + (type != VIR_VSSS_SNAPSHOT_MEMT)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_SUPPORTED, + "Only memory(%i,%i) snapshots are supported", + VIR_VSSS_SNAPSHOT_MEM, + VIR_VSSS_SNAPSHOT_MEMT); + goto out; + } + + if (cu_get_ref_arg(argsin, "AffectedSystem", &system) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing AffectedSystem"); + goto out; + } + + if (cu_get_inst_arg(argsin, "SnapshotSettings", &sd) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing SnapshotSettings"); + goto out; + } + + if (cu_get_str_path(system, "Name", &name) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Name property of AffectedSystem"); + goto out; + } + + s = start_snapshot_job(reference, context, name, type); + + CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); + out: + CU_DEBUG("Returning: %i", s.rc); + return s; +} + +static CMPIStatus destroy_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *snap; + char *name = NULL; + char *path = NULL; + + if (cu_get_ref_arg(argsin, "AffectedSnapshot", &snap) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Snapshot"); + goto out; + } + + if (!parse_instanceid(snap, NULL, &name)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Invalid InstanceID in Snapshot"); + goto out; + } + + path = get_save_path(name); + if (path == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get save_path"); + goto out; + } + + if (unlink(path) == -1) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to remove snapshot: %s", path); + } + out: + free(path); + free(name); + + return s; +} + +static CMPIStatus apply_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *snap; + char *name = NULL; + + if (cu_get_ref_arg(argsin, "AffectedSnapshot", &snap) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Snapshot"); + goto out; + } + + if (!parse_instanceid(snap, NULL, &name)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Invalid InstanceID in Snapshot"); + goto out; + } + + s = start_snapshot_job(reference, context, name, 0); + + out: + free(name); + + return s; +} + +static struct method_handler CreateSnapshot = { + .name = "CreateSnapshot", + .handler = create_snapshot, + .args = {{"AffectedSystem", CMPI_ref, false}, + {"SnapshotSettings", CMPI_instance, false}, + {"SnapshotType", CMPI_uint16, false}, + ARG_END} +}; + +static struct method_handler DestroySnapshot = { + .name = "DestroySnapshot", + .handler = destroy_snapshot, + .args = {{"AffectedSnapshot", CMPI_ref, false}, + ARG_END} +}; + +static struct method_handler ApplySnapshot = { + .name = "ApplySnapshot", + .handler = apply_snapshot, + .args = {{"AffectedSnapshot", CMPI_ref, false}, + ARG_END} +}; + +static struct method_handler *handlers[] = { + &CreateSnapshot, + &DestroySnapshot, + &ApplySnapshot, + NULL +}; + +STDIM_MethodMIStub(, Virt_VirtualSystemSnapshotService, + _BROKER, libvirt_cim_init(), handlers); + + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From kaitlin at linux.vnet.ibm.com Tue Feb 26 17:03:55 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 26 Feb 2008 09:03:55 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Add property filtering to RASD provider In-Reply-To: <47C3DD22.6030806@linux.vnet.ibm.com> References: <2bff66d74872c62ef38f.1203704012@elm3b41.beaverton.ibm.com> <47C2A572.2080401@linux.vnet.ibm.com> <47C2EEBD.7040803@linux.vnet.ibm.com> <47C3DD22.6030806@linux.vnet.ibm.com> Message-ID: <47C4467B.9080206@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >>>> + >>>> + if (properties != NULL) { >>>> + const char *keys[] = {"InstanceID", NULL}; >>>> + s = CMSetPropertyFilter(inst, properties, keys); >>>> + /* FIXME - in case of an error, should we continue >>>> on? */ >>>> + if (s.rc != CMPI_RC_OK) >>>> + CU_DEBUG("Unable to set property filter: >>>> %d", s.rc); >>>> + } >>>> >>> That's a very good point to enable the provider interfaces for the >>> property filtering :). I think it makes sense to move this code into >>> get_typed_instance() of libxkutil, to avoid implementing these lines >>> for every provider. What's then only necessary is routing the >>> properties list through the interfaces. But you will now think ... >>> and how about the keys ? Well, that's an interesting thing. The CMPI >>> 2.0 spec tells the following about the keys: >>> CMPI 2.0 Spec; "The keyList argument shall be ignored by the MB; it >>> is here to maintain binary compatibility with previous >>> specifications. Providers should explicitly set the key names and >>> values via the CMPIInstanceMI.setObjectPath() function." >>> Translated I think this means, that we can ignore the keys by setting >>> it to NULL. Do you agree ? >> >> I tried using NULL for the keys based on the same line from the CMPI >> spec, but this crashed the provider. I might be missing something >> though. > I've tested it with Pegasus and sfcb: > Pegasus returns with FAILED and does not set the propertylist > sfcb is crashing > So my interpretation of this description seem to be wrong and the > keyList is needed. Thanks for evaluating this. > Thanks for confirming this Heidi. I was confused by the behavior, and thought that maybe I was calling the function incorrectly. =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Tue Feb 26 19:51:08 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 26 Feb 2008 11:51:08 -0800 Subject: [Libvirt-cim] [PATCH 0 of 3] (#2) Add VirtualSystemSnapshotService Message-ID: This includes the associated Capabilities object this time. The changes to VSSD (and other related items) will be a separate set From danms at us.ibm.com Tue Feb 26 19:51:09 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 26 Feb 2008 11:51:09 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: Message-ID: # HG changeset patch # User Dan Smith # Date 1204053596 28800 # Node ID fce1a31a53090b42dbfbd788a6db2a1164636197 # Parent bb0530f50ea8d4a75ec34cd54f3bc2daebbda556 Add VirtualSystemSnapshotService Changes: - Added header block Signed-off-by: Dan Smith diff -r bb0530f50ea8 -r fce1a31a5309 src/Virt_VirtualSystemSnapshotService.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemSnapshotService.c Tue Feb 26 11:19:56 2008 -0800 @@ -0,0 +1,521 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include "misc_util.h" + +#include "Virt_VirtualSystemSnapshotService.h" + +#define CIM_JOBSTATE_STARTING 3 +#define CIM_JOBSTATE_RUNNING 4 +#define CIM_JOBSTATE_COMPLETE 7 + +static const CMPIBroker *_BROKER; + +struct snap_context { + CMPIContext *context; + char *domain; + char uuid[33]; + char *save_path; + char *ref_ns; + char *ref_cn; + + bool save; + bool restore; +}; + +static void snap_job_free(struct snap_context *ctx) +{ + free(ctx->domain); + free(ctx->save_path); + free(ctx->ref_ns); + free(ctx->ref_cn); + free(ctx); +} + +static void snap_job_set_status(struct snap_context *ctx, + uint16_t state, + const char *status) +{ + CMPIInstance *inst; + CMPIStatus s; + CMPIObjectPath *op; + + op = CMNewObjectPath(_BROKER, + ctx->ref_ns, + "CIM_ConcreteJob", + &s); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Failed to create job path for update"); + return; + } + + CMAddKey(op, "InstanceID", (CMPIValue *)ctx->uuid, CMPI_chars); + + inst = CBGetInstance(_BROKER, ctx->context, op, NULL, &s); + if ((inst == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to get job instance for update of %s", + ctx->uuid); + return; + } + + CMSetProperty(inst, "JobState", + (CMPIValue *)&state, CMPI_uint16); + CMSetProperty(inst, "Status", + (CMPIValue *)status, CMPI_chars); + + s = CBModifyInstance(_BROKER, ctx->context, op, inst, NULL); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Failed to update job instance %s: %s", + ctx->uuid, + CMGetCharPtr(s.msg)); + return; + } + + CU_DEBUG("Set %s status to %i:%s", ctx->uuid, state, status); +} + +static void do_snapshot(struct snap_context *ctx, + virConnectPtr conn, + virDomainPtr dom) +{ + int ret; + + if (ctx->save) { + CU_DEBUG("Starting save to %s", ctx->save_path); + + ret = virDomainSave(dom, ctx->save_path); + if (ret == -1) { + CU_DEBUG("Save failed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Snapshot Failed (save)"); + return; + } + + CU_DEBUG("Save completed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_RUNNING, + "Save finished"); + } + + if (ctx->restore) { + CU_DEBUG("Starting restore from %s", ctx->save_path); + + ret = virDomainRestore(conn, ctx->save_path); + if (ret == -1) { + CU_DEBUG("Restore failed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Snapshot Failed (restore)"); + return; + } + + CU_DEBUG("Restore completed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_RUNNING, + "Restore finished"); + } + + CU_DEBUG("Snapshot (%s/%s) completed", + ctx->save ? "Save" : "None", + ctx->restore ? "Restore" : "None"); + + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Snapshot complete"); + + return; +} + +static CMPI_THREAD_RETURN snapshot_thread(struct snap_context *ctx) +{ + CMPIStatus s; + virConnectPtr conn = NULL; + virDomainPtr dom = NULL; + + CU_DEBUG("Snapshot thread alive"); + + CBAttachThread(_BROKER, ctx->context); + + snap_job_set_status(ctx, CIM_JOBSTATE_RUNNING, "Running"); + + conn = connect_by_classname(_BROKER, ctx->ref_cn, &s); + if (conn == NULL) { + CU_DEBUG("Failed to connect with classname `%s'", ctx->ref_cn); + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Unable to connect to hypervisor"); + goto out; + } + + dom = virDomainLookupByName(conn, ctx->domain); + if (dom == NULL) { + CU_DEBUG("No such domain `%s'", ctx->domain); + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "No such domain"); + goto out; + } + + do_snapshot(ctx, conn, dom); + + out: + virDomainFree(dom); + virConnectClose(conn); + + snap_job_free(ctx); + + return NULL; +} + +static CMPIStatus create_job(const CMPIContext *context, + const CMPIObjectPath *ref, + struct snap_context *ctx, + CMPIObjectPath **job) +{ + CMPIObjectPath *op; + CMPIInstance *inst; + CMPIStatus s; + + op = CMNewObjectPath(_BROKER, + NAMESPACE(ref), + "CIM_ConcreteJob", /*FIXME*/ + &s); + if ((s.rc != CMPI_RC_OK) || (op == NULL)) { + CU_DEBUG("Failed to create job path"); + goto out; + } + + CMSetNameSpace(op, NAMESPACE(ref)); + + inst = CMNewInstance(_BROKER, op, &s); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) { + CU_DEBUG("Failed to create job instance"); + goto out; + } + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)ctx->uuid, CMPI_chars); + + CMSetProperty(inst, "Name", + (CMPIValue *)"Snapshot", CMPI_chars); + + CMSetProperty(inst, "Status", + (CMPIValue *)"Queued", CMPI_chars); + + op = CMGetObjectPath(inst, &s); + if ((op == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to get path of job instance"); + goto out; + } + + CMSetNameSpace(op, NAMESPACE(ref)); + + CU_DEBUG("ref was %s", CMGetCharPtr(CMObjectPathToString(op, NULL))); + + *job = CBCreateInstance(_BROKER, context, op, inst, &s); + if ((*job == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to create job"); + goto out; + } + + ctx->ref_ns = strdup(NAMESPACE(ref)); + ctx->ref_cn = strdup(CLASSNAME(ref)); + + ctx->context = CBPrepareAttachThread(_BROKER, context); + + _BROKER->xft->newThread((void *)snapshot_thread, ctx, 0); + + cu_statusf(_BROKER, &s, + CMPI_RC_OK, + ""); + out: + return s; +} + +char *vsss_get_save_path(const char *domname) +{ + int ret; + char *path = NULL; + + ret = asprintf(&path, + "/var/lib/libvirt/%s.save", domname); + if (ret == -1) + return NULL; + + return path; +} + +static struct snap_context *new_context(const char *name, + CMPIStatus *s) +{ + struct snap_context *ctx; + uuid_t uuid; + + ctx = calloc(1, sizeof(*ctx)); + if (ctx == NULL) { + CU_DEBUG("Failed to alloc snapshot context"); + goto out; + } + + ctx->domain = strdup(name); + + uuid_generate(uuid); + uuid_unparse(uuid, ctx->uuid); + + ctx->save_path = get_save_path(ctx->domain); + if (ctx->save_path == NULL) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Unable to get save_path"); + goto out; + } + + cu_statusf(_BROKER, s, + CMPI_RC_OK, + ""); + out: + if (s->rc != CMPI_RC_OK) { + snap_job_free(ctx); + ctx = NULL; + } + + return ctx; +} + +static CMPIStatus start_snapshot_job(const CMPIObjectPath *ref, + const CMPIContext *context, + const char *name, + uint16_t type) +{ + struct snap_context *ctx; + CMPIStatus s; + CMPIObjectPath *job; + + ctx = new_context(name, &s); + if (ctx == NULL) + goto out; + + ctx->save = (type != 0); + ctx->restore = (type != VIR_VSSS_SNAPSHOT_MEM); + + s = create_job(context, ref, ctx, &job); + + out: + return s; +} + +static CMPIStatus create_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *system; + CMPIInstance *sd; + uint16_t type; + uint32_t retcode = 0; + const char *name; + + if (cu_get_u16_arg(argsin, "SnapshotType", &type) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing SnapshotType"); + goto out; + } + + if ((type != VIR_VSSS_SNAPSHOT_MEM) && + (type != VIR_VSSS_SNAPSHOT_MEMT)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_SUPPORTED, + "Only memory(%i,%i) snapshots are supported", + VIR_VSSS_SNAPSHOT_MEM, + VIR_VSSS_SNAPSHOT_MEMT); + goto out; + } + + if (cu_get_ref_arg(argsin, "AffectedSystem", &system) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing AffectedSystem"); + goto out; + } + + if (cu_get_inst_arg(argsin, "SnapshotSettings", &sd) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing SnapshotSettings"); + goto out; + } + + if (cu_get_str_path(system, "Name", &name) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Name property of AffectedSystem"); + goto out; + } + + s = start_snapshot_job(reference, context, name, type); + + CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); + out: + CU_DEBUG("Returning: %i", s.rc); + return s; +} + +static CMPIStatus destroy_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *snap; + char *name = NULL; + char *path = NULL; + + if (cu_get_ref_arg(argsin, "AffectedSnapshot", &snap) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Snapshot"); + goto out; + } + + if (!parse_instanceid(snap, NULL, &name)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Invalid InstanceID in Snapshot"); + goto out; + } + + path = get_save_path(name); + if (path == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get save_path"); + goto out; + } + + if (unlink(path) == -1) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to remove snapshot: %s", path); + } + out: + free(path); + free(name); + + return s; +} + +static CMPIStatus apply_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *snap; + char *name = NULL; + + if (cu_get_ref_arg(argsin, "AffectedSnapshot", &snap) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Snapshot"); + goto out; + } + + if (!parse_instanceid(snap, NULL, &name)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Invalid InstanceID in Snapshot"); + goto out; + } + + s = start_snapshot_job(reference, context, name, 0); + + out: + free(name); + + return s; +} + +static struct method_handler CreateSnapshot = { + .name = "CreateSnapshot", + .handler = create_snapshot, + .args = {{"AffectedSystem", CMPI_ref, false}, + {"SnapshotSettings", CMPI_instance, false}, + {"SnapshotType", CMPI_uint16, false}, + ARG_END} +}; + +static struct method_handler DestroySnapshot = { + .name = "DestroySnapshot", + .handler = destroy_snapshot, + .args = {{"AffectedSnapshot", CMPI_ref, false}, + ARG_END} +}; + +static struct method_handler ApplySnapshot = { + .name = "ApplySnapshot", + .handler = apply_snapshot, + .args = {{"AffectedSnapshot", CMPI_ref, false}, + ARG_END} +}; + +static struct method_handler *handlers[] = { + &CreateSnapshot, + &DestroySnapshot, + &ApplySnapshot, + NULL +}; + +STDIM_MethodMIStub(, Virt_VirtualSystemSnapshotService, + _BROKER, libvirt_cim_init(), handlers); + + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff -r bb0530f50ea8 -r fce1a31a5309 src/Virt_VirtualSystemSnapshotService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemSnapshotService.h Tue Feb 26 11:19:56 2008 -0800 @@ -0,0 +1,42 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Returns a malloc()'d string; caller must free() */ +char *vsss_get_save_path(const char *domname); + +#define CIM_VSSS_SNAPSHOT_FULL 2 +#define CIM_VSSS_SNAPSHOT_DISK 3 + +/* VIR_VSSS_SNAPSHOT_MEM - Attempt to save/restore to create a running snap + * VIR_VSSS_SNAPSHOT_MEMT - Just save and let the domain be "off" + */ +#define VIR_VSSS_SNAPSHOT_MEM 32768 +#define VIR_VSSS_SNAPSHOT_MEMT 32769 + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From danms at us.ibm.com Tue Feb 26 19:51:10 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 26 Feb 2008 11:51:10 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] Add VirtualSystemSnapshotCapabilities In-Reply-To: Message-ID: <0f1a316b04aca1fa962f.1204055470@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1204053674 28800 # Node ID 0f1a316b04aca1fa962f624444ae57b960fc2a37 # Parent fce1a31a53090b42dbfbd788a6db2a1164636197 Add VirtualSystemSnapshotCapabilities Signed-off-by: Dan Smith diff -r fce1a31a5309 -r 0f1a316b04ac src/Virt_VirtualSystemSnapshotServiceCapabilities.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemSnapshotServiceCapabilities.c Tue Feb 26 11:21:14 2008 -0800 @@ -0,0 +1,204 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include + +#include + +#include "misc_util.h" + +#include +#include +#include + +#include +#include + +#include "Virt_VirtualSystemSnapshotService.h" + +const static CMPIBroker *_BROKER; + +enum { CREATE_SNAPSHOT = 2, + DESTROY_SNAPSHOT, + APPLY_SNAPSHOT, +}; + +static CMPIStatus set_inst_properties(const CMPIBroker *broker, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIArray *array; + uint16_t element; + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)"SnapshotCapabilities", CMPI_chars); + + array = CMNewArray(broker, 2, CMPI_uint16, &s); + if ((s.rc != CMPI_RC_OK) || (array == NULL)) + goto out; + + element = (uint16_t)CREATE_SNAPSHOT; + CMSetArrayElementAt(array, 0, &element, CMPI_uint16); + + element = (uint16_t)APPLY_SNAPSHOT; + CMSetArrayElementAt(array, 1, &element, CMPI_uint16); + + CMSetProperty(inst, "AsynchronousMethodsSupported", + (CMPIValue *)&array, CMPI_uint16A); + + array = CMNewArray(broker, 1, CMPI_uint16, &s); + if ((s.rc != CMPI_RC_OK) || (array == NULL)) + goto out; + + element = (uint16_t)DESTROY_SNAPSHOT; + CMSetArrayElementAt(array, 0, &element, CMPI_uint16); + + CMSetProperty(inst, "SynchronousMethodsSupported", + (CMPIValue *)&array, CMPI_uint16A); + + array = CMNewArray(broker, 2, CMPI_uint16, &s); + if ((s.rc != CMPI_RC_OK) || (array == NULL)) + goto out; + + element = (uint16_t)CIM_VSSS_SNAPSHOT_MEM; + CMSetArrayElementAt(array, 0, &element, CMPI_uint16); + + element = (uint16_t)CIM_VSSS_SNAPSHOT_MEMT; + CMSetArrayElementAt(array, 1, &element, CMPI_uint16); + + CMSetProperty(inst, "SnapshotTypesSupported", + (CMPIValue *)&array, CMPI_uint16A); + + out: + return s; +} + +static CMPIStatus get_vss_cap(const CMPIBroker *broker, + const CMPIObjectPath *ref, + CMPIInstance **_inst, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "VirtualSystemSnapshotServiceCapabilities", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Can't create instance for %s", CLASSNAME(ref)); + goto out; + } + + s = set_inst_properties(broker, inst); + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_vss_cap(const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_vss_cap(_BROKER, ref, &inst, is_get_inst); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + goto out; + + if (names_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + out: + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference) +{ + return return_vss_cap(reference, results, true, false); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + + return return_vss_cap(reference, results, false, false); +} + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + return return_vss_cap(reference, results, false, true); +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, + Virt_VirtualSystemSnapshotServiceCapabilities, + _BROKER, + libvirt_cim_init()); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From danms at us.ibm.com Tue Feb 26 19:51:11 2008 From: danms at us.ibm.com (Dan Smith) Date: Tue, 26 Feb 2008 11:51:11 -0800 Subject: [Libvirt-cim] [PATCH 3 of 3] Add VirtualSystemSnapshotService{, Capabilities} build support In-Reply-To: Message-ID: # HG changeset patch # User Dan Smith # Date 1204053694 28800 # Node ID ce18bd2b2708e263dd03fbcd3e94ce21182e847d # Parent 0f1a316b04aca1fa962f624444ae57b960fc2a37 Add VirtualSystemSnapshotService{,Capabilities} build support Signed-off-by: Dan Smith diff -r 0f1a316b04ac -r ce18bd2b2708 Makefile.am --- a/Makefile.am Tue Feb 26 11:21:14 2008 -0800 +++ b/Makefile.am Tue Feb 26 11:21:34 2008 -0800 @@ -37,7 +37,9 @@ MOFS = \ schema/ElementSettingData.mof \ schema/VSMigrationCapabilities.mof \ schema/VSMigrationService.mof \ - schema/VSMigrationSettingData.mof + schema/VSMigrationSettingData.mof \ + schema/VirtualSystemSnapshotService.mof \ + schema/VirtualSystemSnapshotServiceCapabilities.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -81,7 +83,9 @@ REGS = \ schema/VSMigrationCapabilities.registration \ schema/VSMigrationService.registration \ schema/ElementConformsToProfile.registration \ - schema/VSMigrationSettingData.registration + schema/VSMigrationSettingData.registration \ + schema/VirtualSystemSnapshotService.registration \ + schema/VirtualSystemSnapshotServiceCapabilities.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ diff -r 0f1a316b04ac -r ce18bd2b2708 schema/VirtualSystemSnapshotService.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotService.mof Tue Feb 26 11:21:34 2008 -0800 @@ -0,0 +1,7 @@ +// Copyright IBM Corp. 2008 + +[Description ( "Snapshot types are as follows: " + "32768: Memory-only snapshot (suspend, resume, keep image)" + "32769: Memory-only, terminal (domain is offline after op)")] +class Xen_VirtualSystemSnapshotService : CIM_VirtualSystemSnapshotService { }; +class KVM_VirtualSystemSnapshotService : CIM_VirtualSystemSnapshotService { }; diff -r 0f1a316b04ac -r ce18bd2b2708 schema/VirtualSystemSnapshotService.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotService.registration Tue Feb 26 11:21:34 2008 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemSnapshotService root/virt Virt_VirtualSystemSnapshotService Virt_VirtualSystemSnapshotService method +KVM_VirtualSystemSnapshotService root/virt Virt_VirtualSystemSnapshotService Virt_VirtualSystemSnapshotService method diff -r 0f1a316b04ac -r ce18bd2b2708 src/Makefile.am --- a/src/Makefile.am Tue Feb 26 11:21:14 2008 -0800 +++ b/src/Makefile.am Tue Feb 26 11:21:34 2008 -0800 @@ -17,7 +17,8 @@ noinst_HEADERS = profiles.h svpc_types.h Virt_VSSD.h \ Virt_VSMigrationCapabilities.h \ Virt_VSMigrationService.h \ - Virt_AllocationCapabilities.h + Virt_AllocationCapabilities.h \ + Virt_VirtualSystemSnapshotService.h XKUADD = $(top_builddir)/libxkutil/libxkutil.la @@ -56,7 +57,9 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_ElementSettingData.la \ libVirt_VSMigrationCapabilities.la \ libVirt_VSMigrationService.la \ - libVirt_VSMigrationSettingData.la + libVirt_VSMigrationSettingData.la \ + libVirt_VirtualSystemSnapshotService.la \ + libVirt_VirtualSystemSnapshotServiceCapabilities.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -161,3 +164,10 @@ libVirt_VSMigrationService_la_LIBADD = - libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c +libVirt_VirtualSystemSnapshotService_la_DEPENDENCIES = +libVirt_VirtualSystemSnapshotService_la_SOURCES = Virt_VirtualSystemSnapshotService.c +libVirt_VirtualSystemSnapshotService_la_LIBADD = + +libVirt_VirtualSystemSnapshotServiceCapabilities_la_DEPENDENCIES = +libVirt_VirtualSystemSnapshotServiceCapabilities_la_SOURCES = Virt_VirtualSystemSnapshotServiceCapabilities.c +libVirt_VirtualSystemSnapshotServiceCapabilities_la_LIBADD = From grendel at linux.vnet.ibm.com Tue Feb 26 20:16:59 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 26 Feb 2008 15:16:59 -0500 Subject: [Libvirt-cim] [PATCH 2 of 3] [CU] (#2) add cmpi void to check to libcmpiutil In-Reply-To: Message-ID: <568bffb0a58444972a9a.1204057019@naegling> # HG changeset patch # User Jay Gagnon # Date 1204056960 18000 # Node ID 568bffb0a58444972a9ae262f45c9b2b9068bbfc # Parent 0840762ff38237d40ca56973d3455a1b54f154b7 [CU] (#2) add cmpi void to check to libcmpiutil This used to be only required by libvirt-cim, but the new functionality in std_indication has made it necessary in libcmpiutil as well. Signed-off-by: Jay Gagnon diff -r 0840762ff382 -r 568bffb0a584 acinclude.m4 --- a/acinclude.m4 Tue Feb 26 15:15:57 2008 -0500 +++ b/acinclude.m4 Tue Feb 26 15:16:00 2008 -0500 @@ -92,6 +92,34 @@ AC_DEFUN([CHECK_BROKEN_CMPIFT], ] )]) +# +# Check for void EnableIndications return +# +AC_DEFUN([CHECK_IND_VOID], [ + AH_TEMPLATE([CMPI_EI_VOID], + [Defined if return type of EnableIndications + should be void]) + AC_MSG_CHECKING([return type for indications]) + CFLAGS_TMP=$CFLAGS + CFLAGS="-Werror" + AC_TRY_COMPILE([ + #include + static void ei(CMPIIndicationMI *mi, const CMPIContext *c) { + return; + } + ],[ + struct _CMPIIndicationMIFT ft; + ft.enableIndications = ei; + return 0; + ], [ + echo "void" + AC_DEFINE_UNQUOTED([CMPI_EI_VOID], [yes]) + ], [ + echo "CMPIStatus" + ]) + CFLAGS=$CFLAGS_TMP +]) + AC_DEFUN([CHECK_LIBXML2], [ PKG_CHECK_MODULES([LIBXML], [libxml-2.0]) diff -r 0840762ff382 -r 568bffb0a584 configure.ac --- a/configure.ac Tue Feb 26 15:15:57 2008 -0500 +++ b/configure.ac Tue Feb 26 15:16:00 2008 -0500 @@ -4,6 +4,7 @@ AC_CONFIG_SRCDIR([libcmpiutil.h]) AC_CONFIG_SRCDIR([libcmpiutil.h]) CHECK_CMPI +CHECK_IND_VOID AC_CHECK_HEADERS([cmpidt.h cmpift.h cmpimacs.h]) @@ -22,7 +23,7 @@ CC_WARNINGS="\ CFLAGS="$CFLAGS $CC_WARNINGS -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE" -#AC_CONFIG_HEADER([config.h]) +AC_CONFIG_HEADER([config.h]) topdir=`pwd` AC_SUBST(topdir) From grendel at linux.vnet.ibm.com Tue Feb 26 20:16:57 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 26 Feb 2008 15:16:57 -0500 Subject: [Libvirt-cim] [PATCH 0 of 3] [CU] (#2) Standard Indication goes to eleven Message-ID: Few minor fix-ups as detailed in individual patches, reordering of patches to make a bit more sense in the tree. From grendel at linux.vnet.ibm.com Tue Feb 26 20:16:58 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 26 Feb 2008 15:16:58 -0500 Subject: [Libvirt-cim] [PATCH 1 of 3] [CU] (#2) Turn std_indication's awesome knob to eleven In-Reply-To: Message-ID: <79e8d86c710722cb49c0.1204057018@naegling> # HG changeset patch # User Jay Gagnon # Date 1204056960 18000 # Node ID 79e8d86c710722cb49c0557a1966c72f910641b5 # Parent 568bffb0a58444972a9ae262f45c9b2b9068bbfc [CU] (#2) Turn std_indication's awesome knob to eleven The new std_indication handles Enable/DisableIndications and Activate/DeactivateFilter correctly, even on a per-indication basis when one provider handles more than one indication. Those functions also now have default_foo equivalents in std_indication, as many providers (especially raise-style ones) will have no special needs there. Changes required to make it work: new struct to track which of a providers indications are active in the filter little macro to make declaring the new filter struct nice and clean new std_indication_ctx members for filters and global (per-provider) enabled flags stdi_foo functions that do the default behavior and dispatch work moving ind_args and CMPI_EI_VOID ifdef into std_indication My apologies for: how much there is in this one patch the reordering going on in std_indication.h, which I know isn't very PCO, I have some ready-made excuses for those that require them :) Changes from 1 to 2: cu_ prefix to classname_from_inst call removed superfluous _ctx assignment in a couple stdi_foo calls adding provider name to enable/disable messages Signed-off-by: Jay Gagnon diff -r 568bffb0a584 -r 79e8d86c7107 std_indication.c --- a/std_indication.c Tue Feb 26 15:16:00 2008 -0500 +++ b/std_indication.c Tue Feb 26 15:16:00 2008 -0500 @@ -32,10 +32,65 @@ #include "std_indication.h" +void stdi_free_ind_args (struct ind_args **args) +{ + free((*args)->ns); + free((*args)->classname); + free(*args); + *args = NULL; +} + +static struct std_ind_filter *get_ind_filter(struct std_ind_filter **list, + const char *ind_name) +{ + int i; + struct std_ind_filter *filter = NULL; + + for (i = 0; list[i] != NULL; i++) { + if (STREQC((list[i])->ind_name, ind_name)) { + filter = list[i]; + break; + } + } + + if (filter == NULL) + CU_DEBUG("get_ind_filter: failed to find %s", ind_name); + + return filter; +} + +static bool is_ind_enabled(struct std_indication_ctx *ctx, + const char *ind_name, + CMPIStatus *s) +{ + bool ret = false; + struct std_ind_filter *filter; + + if (!ctx->enabled) { + CU_DEBUG("Indications disabled for this provider"); + ret = false; + goto out; + } + + filter = get_ind_filter(ctx->filters, ind_name); + if (filter == NULL) { + cu_statusf(ctx->brkr, s, + CMPI_RC_ERR_FAILED, + "No std_ind_filter for %s", ind_name); + goto out; + } + + ret = filter->active; + if (!ret) + CU_DEBUG("Indication '%s' not in active filter", ind_name); + out: + return ret; +} + static CMPIStatus trigger(struct std_indication_ctx *ctx, const CMPIContext *context) { - if (ctx->handler->trigger_fn == NULL) + if (ctx->handler == NULL || ctx->handler->trigger_fn == NULL) return (CMPIStatus){CMPI_RC_OK, NULL}; return ctx->handler->trigger_fn(context); @@ -61,20 +116,169 @@ static CMPIStatus raise(struct std_indic const CMPIContext *context, const CMPIArgs *argsin) { + bool enabled; CMPIInstance *inst; - - if (!ctx->enabled) { - CU_DEBUG("Indication disabled, not raising."); - return (CMPIStatus) {CMPI_RC_OK, NULL}; - } - - if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK) - return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL}; - - if (ctx->handler->raise_fn == NULL) - return default_raise(ctx->brkr, context, inst); - - return ctx->handler->raise_fn(ctx->brkr, context, inst); + CMPIStatus s = {CMPI_RC_OK, NULL}; + const char *ind_name = NULL; + + if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK) { + cu_statusf(ctx->brkr, &s, + CMPI_RC_ERR_FAILED, + "Could not get indication to raise"); + goto out; + } + + ind_name = cu_classname_from_inst(inst); + if (ind_name == NULL) { + cu_statusf(ctx->brkr, &s, + CMPI_RC_ERR_FAILED, + "Couldn't get indication name for enable check."); + } + + enabled = is_ind_enabled(ctx, ind_name, &s); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Problem checking enabled: '%s'", CMGetCharPtr(s.msg)); + goto out; + } + + if (!enabled) + goto out; + + if (ctx->handler == NULL || ctx->handler->raise_fn == NULL) + s = default_raise(ctx->brkr, context, inst); + else + s = ctx->handler->raise_fn(ctx->brkr, context, inst); + + out: + return s; +} +CMPIStatus stdi_deliver(const CMPIBroker *broker, + const CMPIContext *ctx, + struct ind_args *args, + CMPIInstance *ind) +{ + bool enabled; + const char *ind_name; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + ind_name = cu_classname_from_inst(ind); + if (ind_name == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Couldn't get indication name for enable check."); + } + + enabled = is_ind_enabled(args->_ctx, ind_name, &s); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Problem checking enabled: '%s'", CMGetCharPtr(s.msg)); + goto out; + } + + if (enabled) + s = CBDeliverIndication(broker, ctx, args->ns, ind); + + out: + return s; +} + +CMPIStatus stdi_set_ind_filter_state(struct std_indication_ctx *ctx, + char *ind_name, + bool state) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + struct std_ind_filter *filter; + + filter = get_ind_filter(ctx->filters, ind_name); + if (filter == NULL) { + cu_statusf(ctx->brkr, &s, + CMPI_RC_ERR_FAILED, + "Provider has no indication '%s'", ind_name); + goto out; + } + + filter->active = state; + + out: + return s; +} + +CMPIStatus stdi_activate_filter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean first) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + struct std_indication_ctx *_ctx; + char *cn = NULL; + + _ctx = (struct std_indication_ctx *)mi->hdl; + cn = CLASSNAME(op); + s = stdi_set_ind_filter_state(_ctx, cn, true); + + if (_ctx->handler != NULL && _ctx->handler->activate_fn != NULL) { + CU_DEBUG("Calling handler->activate_fn"); + s = _ctx->handler->activate_fn(mi, ctx, se, ns, op, first); + goto out; + } + + out: + return s; +} + +CMPIStatus stdi_deactivate_filter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean last) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + struct std_indication_ctx *_ctx; + char *cn = NULL; + + _ctx = (struct std_indication_ctx *)mi->hdl; + cn = CLASSNAME(op); + s = stdi_set_ind_filter_state(_ctx, cn, false); + + if (_ctx->handler != NULL && _ctx->handler->deactivate_fn != NULL) { + s = _ctx->handler->deactivate_fn(mi, ctx, se, ns, op, last); + goto out; + } + + out: + return s; +} + +_EI_RTYPE stdi_enable_indications (CMPIIndicationMI* mi, + const CMPIContext *ctx) +{ + struct std_indication_ctx *_ctx; + _ctx = (struct std_indication_ctx *)mi->hdl; + + CU_DEBUG("%s: indications enabled", mi->ft->miName); + _ctx->enabled = true; + + if (_ctx->handler != NULL && _ctx->handler->enable_fn != NULL) + return _ctx->handler->enable_fn(mi, ctx); + + _EI_RET(); +} + +_EI_RTYPE stdi_disable_indications (CMPIIndicationMI* mi, + const CMPIContext *ctx) +{ + struct std_indication_ctx *_ctx; + _ctx = (struct std_indication_ctx *)mi->hdl; + + CU_DEBUG("%s: indications disabled", mi->ft->miName); + _ctx->enabled = false; + + if (_ctx->handler != NULL && _ctx->handler->disable_fn != NULL) + return _ctx->handler->disable_fn(mi, ctx); + + _EI_RET(); } CMPIStatus stdi_handler(CMPIMethodMI *self, diff -r 568bffb0a584 -r 79e8d86c7107 std_indication.h --- a/std_indication.h Tue Feb 26 15:16:00 2008 -0500 +++ b/std_indication.h Tue Feb 26 15:16:00 2008 -0500 @@ -26,8 +26,74 @@ #include #include +#include "config.h" + #include "libcmpiutil.h" #include "std_invokemethod.h" + +#ifdef CMPI_EI_VOID +# define _EI_RTYPE void +# define _EI_RET() return +#else +# define _EI_RTYPE CMPIStatus +# define _EI_RET() return (CMPIStatus){CMPI_RC_OK, NULL} +#endif + +typedef CMPIStatus (*raise_indication_t)(const CMPIBroker *broker, + const CMPIContext *ctx, + const CMPIInstance *ind); + +typedef CMPIStatus (*trigger_indication_t)(const CMPIContext *ctx); + +typedef CMPIStatus (*activate_function_t) (CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean first); + +typedef CMPIStatus (*deactivate_function_t) (CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean last); + +typedef _EI_RTYPE (*enable_function_t) (CMPIIndicationMI* mi, + const CMPIContext *ctx); + +typedef _EI_RTYPE (*disable_function_t) (CMPIIndicationMI* mi, + const CMPIContext *ctx); + +struct std_indication_handler { + raise_indication_t raise_fn; + trigger_indication_t trigger_fn; + activate_function_t activate_fn; + deactivate_function_t deactivate_fn; + enable_function_t enable_fn; + disable_function_t disable_fn; +}; + +struct std_ind_filter { + char *ind_name; + bool active; +}; + +struct std_indication_ctx { + const CMPIBroker *brkr; + struct std_indication_handler *handler; + struct std_ind_filter **filters; + bool enabled; +}; + +struct ind_args { + CMPIContext *context; + char *ns; + char *classname; + struct std_indication_ctx *_ctx; +}; + +void stdi_free_ind_args (struct ind_args **args); CMPIStatus stdi_trigger_indication(const CMPIBroker *broker, const CMPIContext *context, @@ -39,6 +105,31 @@ CMPIStatus stdi_raise_indication(const C const char *type, const char *ns, const CMPIInstance *ind); + +CMPIStatus stdi_deliver(const CMPIBroker *broker, + const CMPIContext *ctx, + struct ind_args *args, + CMPIInstance *ind); + +CMPIStatus stdi_activate_filter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean first); + +CMPIStatus stdi_deactivate_filter(CMPIIndicationMI* mi, + const CMPIContext* ctx, + const CMPISelectExp* se, + const char *ns, + const CMPIObjectPath* op, + CMPIBoolean last); + +_EI_RTYPE stdi_enable_indications (CMPIIndicationMI* mi, + const CMPIContext *ctx); + +_EI_RTYPE stdi_disable_indications (CMPIIndicationMI* mi, + const CMPIContext *ctx); CMPIStatus stdi_handler(CMPIMethodMI *self, const CMPIContext *context, @@ -52,27 +143,22 @@ CMPIStatus stdi_cleanup(CMPIMethodMI *se const CMPIContext *context, CMPIBoolean terminating); -typedef CMPIStatus (*raise_indication_t)(const CMPIBroker *broker, - const CMPIContext *ctx, - const CMPIInstance *ind); - -typedef CMPIStatus (*trigger_indication_t)(const CMPIContext *ctx); - -struct std_indication_handler { - raise_indication_t raise_fn; - trigger_indication_t trigger_fn; -}; - -struct std_indication_ctx { - const CMPIBroker *brkr; - struct std_indication_handler *handler; - bool enabled; -}; - -#define STDI_IndicationMIStub(pfx, pn, _broker, hook, _handler) \ - static struct std_indication_ctx _ctx = { \ +CMPIStatus stdi_set_ind_filter_state(struct std_indication_ctx *ctx, + char *ind_name, + bool state); + +/* This doesn't work, but should be made to. */ +#define DECLARE_FILTER(ident, name) \ + static struct std_ind_filter ident = { \ + .ind_name = name, \ + .active = false, \ + }; \ + +#define STDI_IndicationMIStub(pfx, pn, _broker, hook, _handler, filters)\ + static struct std_indication_ctx pn##_ctx = { \ .brkr = NULL, \ .handler = _handler, \ + .filters = filters, \ .enabled = false, \ }; \ \ @@ -83,9 +169,10 @@ struct std_indication_ctx { pfx##IndicationCleanup, \ pfx##AuthorizeFilter, \ pfx##MustPoll, \ - pfx##ActivateFilter, \ - pfx##DeActivateFilter, \ - CMIndicationMIStubExtensions(pfx) \ + stdi_activate_filter, \ + stdi_deactivate_filter, \ + stdi_enable_indications, \ + stdi_disable_indications, \ }; \ CMPIIndicationMI * \ pn##_Create_IndicationMI(const CMPIBroker *, \ @@ -96,10 +183,10 @@ struct std_indication_ctx { const CMPIContext *ctx, \ CMPIStatus *rc) { \ static CMPIIndicationMI mi = { \ - &_ctx, \ + &pn##_ctx, \ &indMIFT__, \ }; \ - _ctx.brkr = brkr; \ + pn##_ctx.brkr = brkr; \ _broker = brkr; \ hook; \ return &mi; \ @@ -121,10 +208,10 @@ struct std_indication_ctx { const CMPIContext *ctx, \ CMPIStatus *rc) { \ static CMPIMethodMI mi = { \ - &_ctx, \ + &pn##_ctx, \ &methMIFT__, \ }; \ - _ctx.brkr = brkr; \ + pn##_ctx.brkr = brkr; \ _broker = brkr; \ hook; \ return &mi; \ From grendel at linux.vnet.ibm.com Tue Feb 26 20:17:00 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Tue, 26 Feb 2008 15:17:00 -0500 Subject: [Libvirt-cim] [PATCH 3 of 3] [CU] (#2) classname_from_inst In-Reply-To: Message-ID: <0840762ff38237d40ca5.1204057020@naegling> # HG changeset patch # User Jay Gagnon # Date 1204056957 18000 # Node ID 0840762ff38237d40ca56973d3455a1b54f154b7 # Parent af61b6c75b143067444f4eefe694d1e9709d2ccb [CU] (#2) classname_from_inst Function that pulls a classname out of an instance. Nothing fancy, just saves a few lines whenever this is needed. This is used by the new std_indication stuff. Changes from 1 to 2: cu_ prefix on function name Signed-off-by: Jay Gagnon diff -r af61b6c75b14 -r 0840762ff382 instance_util.c --- a/instance_util.c Wed Feb 13 08:26:56 2008 -0800 +++ b/instance_util.c Tue Feb 26 15:15:57 2008 -0500 @@ -251,6 +251,21 @@ CMPIInstance *cu_dup_instance(const CMPI out: return dest; +} + +const char *cu_classname_from_inst(CMPIInstance *inst) +{ + char *ret = NULL; + + CMPIObjectPath *ref; + ref = CMGetObjectPath(inst, NULL); + if (CMIsNullObject(ref)) + goto out; + + ret = CLASSNAME(ref); + + out: + return ret; } /* diff -r af61b6c75b14 -r 0840762ff382 libcmpiutil.h --- a/libcmpiutil.h Wed Feb 13 08:26:56 2008 -0800 +++ b/libcmpiutil.h Tue Feb 26 15:15:57 2008 -0500 @@ -414,6 +414,15 @@ CMPIStatus cu_validate_ref(const CMPIBro CMPIStatus cu_validate_ref(const CMPIBroker *broker, const CMPIObjectPath *ref, const CMPIInstance *inst); + +/** + * Returns the classname from an instance without forcing user to get + * ObjectPath first. + * + * @param inst Instance to examine + * @returns Classname of instance , NULL on failure + */ +const char *cu_classname_from_inst(CMPIInstance *inst); #define DEFAULT_EIN(pn) \ static CMPIStatus pn##EnumInstanceNames(CMPIInstanceMI *self, \ From kaitlin at linux.vnet.ibm.com Wed Feb 27 00:03:44 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 26 Feb 2008 16:03:44 -0800 Subject: [Libvirt-cim] [PATCH 3 of 4] Add MigrationType support to VirtualSystemMigrationService In-Reply-To: Message-ID: <09153317203d6a60ede3.1204070624@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1203986185 28800 # Node ID 09153317203d6a60ede32daf5f2ce5765b6d9953 # Parent c089d134bfb70e3ab48d06ea4b7d229be1341646 Add MigrationType support to VirtualSystemMigrationService. This patch only handles the live and static migration cases. Other migration cases to follow. Signed-off-by: Kaitlin Rupert diff -r c089d134bfb7 -r 09153317203d src/Makefile.am --- a/src/Makefile.am Mon Feb 25 16:36:24 2008 -0800 +++ b/src/Makefile.am Mon Feb 25 16:36:25 2008 -0800 @@ -155,9 +155,9 @@ libVirt_ElementSettingData_la_LIBADD = - libVirt_VSMigrationCapabilities_la_SOURCES = Virt_VSMigrationCapabilities.c -libVirt_VSMigrationService_la_DEPENDENCIES = libVirt_HostSystem.la +libVirt_VSMigrationService_la_DEPENDENCIES = libVirt_HostSystem.la libVirt_VSMigrationSettingData.la libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c -libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem +libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem -lVirt_VSMigrationSettingData libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c diff -r c089d134bfb7 -r 09153317203d src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Mon Feb 25 16:36:24 2008 -0800 +++ b/src/Virt_VSMigrationService.c Mon Feb 25 16:36:25 2008 -0800 @@ -38,6 +38,7 @@ #include "Virt_VSMigrationService.h" #include "Virt_HostSystem.h" +#include "Virt_VSMigrationSettingData.h" #define CIM_JOBSTATE_STARTING 3 #define CIM_JOBSTATE_RUNNING 4 @@ -56,6 +57,7 @@ struct migration_job { char *host; char *ref_cn; char *ref_ns; + uint16_t type; char uuid[33]; }; @@ -385,13 +387,35 @@ static void migrate_job_set_state(struct CU_DEBUG("Failed to raise indication"); } +static CMPIStatus handle_migrate(virConnectPtr dconn, + virDomainPtr dom, + char *uri, + int type, + struct migration_job *job) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virDomainPtr ddom = NULL; + + CU_DEBUG("Migrating %s -> %s", job->domain, uri); + ddom = virDomainMigrate(dom, dconn, type, NULL, NULL, 0); + if (ddom == NULL) { + CU_DEBUG("Migration failed"); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Migration Failed"); + } + + virDomainFree(ddom); + + return s; +} + static CMPIStatus migrate_vs(struct migration_job *job) { CMPIStatus s; virConnectPtr conn = NULL; virConnectPtr dconn = NULL; virDomainPtr dom = NULL; - virDomainPtr ddom = NULL; char *uri = NULL; uri = dest_uri(job->ref_cn, job->host); @@ -424,25 +448,39 @@ static CMPIStatus migrate_vs(struct migr goto out; } - CU_DEBUG("Migrating %s -> %s", job->domain, uri); - - ddom = virDomainMigrate(dom, dconn, VIR_MIGRATE_LIVE, NULL, NULL, 0); - if (ddom == NULL) { - CU_DEBUG("Migration failed"); - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Migration Failed"); - goto out; - } + switch(job->type) { + case CIM_MIGRATE_OTHER: + /* FIXME - Handle offline migration here */ + CU_DEBUG("Preparing for offline migration"); + break; + case CIM_MIGRATE_LIVE: + CU_DEBUG("Preparing for live migration"); + s = handle_migrate(dconn, dom, uri, VIR_MIGRATE_LIVE, job); + break; + case CIM_MIGRATE_RESUME: + case CIM_MIGRATE_RESTART: + CU_DEBUG("Preparing for static migration"); + s = handle_migrate(dconn, dom, uri, 0, job); + break; + default: + CU_DEBUG("Unsupported migration type (%d)", job->type); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unsupported migration type (%d)", job->type); + goto out; + } + + if (s.rc != CMPI_RC_OK) + goto out; CU_DEBUG("Migration succeeded"); cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); + out: free(uri); virDomainFree(dom); - virDomainFree(ddom); virConnectClose(conn); virConnectClose(dconn); @@ -568,7 +606,8 @@ static struct migration_job *migrate_job static struct migration_job *migrate_job_prepare(const CMPIContext *context, const CMPIObjectPath *ref, const char *domain, - const char *host) + const char *host, + uint16_t type) { struct migration_job *job; uuid_t uuid; @@ -581,6 +620,7 @@ static struct migration_job *migrate_job job->host = strdup(host); job->ref_cn = strdup(CLASSNAME(ref)); job->ref_ns = strdup(NAMESPACE(ref)); + job->type = type; uuid_generate(uuid); uuid_unparse(uuid, job->uuid); @@ -594,6 +634,7 @@ static CMPIStatus migrate_do(const CMPIO const CMPIContext *context, const char *domain, const char *host, + uint16_t type, const CMPIResult *results, CMPIArgs *argsout) { @@ -603,7 +644,7 @@ static CMPIStatus migrate_do(const CMPIO CMPI_THREAD_TYPE thread; uint32_t retcode = 1; - job = migrate_job_prepare(context, ref, domain, host); + job = migrate_job_prepare(context, ref, domain, host, type); if (job == NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -625,6 +666,36 @@ static CMPIStatus migrate_do(const CMPIO out: CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); + + return s; +} + +static CMPIStatus get_migration_type(const CMPIObjectPath *ref, + const CMPIArgs *argsin, + uint16_t *type) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *msd; + int ret; + + ret = cu_get_inst_arg(argsin, "MigrationSettingData", &msd); + if ((ret != CMPI_RC_OK) || (msd == NULL)) { + CU_DEBUG("Using default values for MigrationSettingData param"); + s = get_migration_sd(ref, &msd, _BROKER, false); + if ((s.rc != CMPI_RC_OK) || (msd == NULL)) { + cu_statusf(_BROKER, &s, + s.rc, + "Unable to get default setting data values"); + return s; + } + } + + ret = cu_get_u16_prop(msd, "MigrationType", type); + if (ret != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + ret, + "Invalid MigrationType value"); + } return s; } @@ -640,7 +711,8 @@ static CMPIStatus migrate_vs_host(CMPIMe const char *dhost = NULL; CMPIObjectPath *system; const char *name = NULL; - + uint16_t type; + cu_get_str_arg(argsin, "DestinationHost", &dhost); cu_get_ref_arg(argsin, "ComputerSystem", &system); @@ -660,7 +732,13 @@ static CMPIStatus migrate_vs_host(CMPIMe return s; } - return migrate_do(ref, ctx, name, dhost, results, argsout); + s = get_migration_type(ref, argsin, &type); + if (s.rc != CMPI_RC_OK) { + METHOD_RETURN(results, 1); + return s; + } + + return migrate_do(ref, ctx, name, dhost, type, results, argsout); } static CMPIStatus migrate_vs_system(CMPIMethodMI *self, @@ -675,6 +753,7 @@ static CMPIStatus migrate_vs_system(CMPI CMPIObjectPath *sys; const char *dname; const char *name; + uint16_t type; cu_get_ref_arg(argsin, "DestinationSystem", &dsys); cu_get_ref_arg(argsin, "ComputerSystem", &sys); @@ -703,7 +782,13 @@ static CMPIStatus migrate_vs_system(CMPI return s; } - return migrate_do(ref, ctx, name, dname, results, argsout); + s = get_migration_type(ref, argsin, &type); + if (s.rc != CMPI_RC_OK) { + METHOD_RETURN(results, 1); + return s; + } + + return migrate_do(ref, ctx, name, dname, type, results, argsout); } static struct method_handler vsimth = { @@ -711,6 +796,7 @@ static struct method_handler vsimth = { .handler = vs_migratable_host, .args = {{"ComputerSystem", CMPI_ref, false}, {"DestinationHost", CMPI_string, false}, + {"MigrationSettingData", CMPI_instance, true}, ARG_END } }; @@ -720,6 +806,7 @@ static struct method_handler vsimts = { .handler = vs_migratable_system, .args = {{"ComputerSystem", CMPI_ref, false}, {"DestinationSystem", CMPI_ref, false}, + {"MigrationSettingData", CMPI_instance, true}, ARG_END } }; @@ -729,6 +816,7 @@ static struct method_handler mvsth = { .handler = migrate_vs_host, .args = {{"ComputerSystem", CMPI_ref, false}, {"DestinationHost", CMPI_string, false}, + {"MigrationSettingData", CMPI_instance, true}, ARG_END } }; @@ -738,6 +826,7 @@ static struct method_handler mvsts = { .handler = migrate_vs_system, .args = {{"ComputerSystem", CMPI_ref, false}, {"DestinationSystem", CMPI_ref, false}, + {"MigrationSettingData", CMPI_instance, true}, ARG_END } }; From kaitlin at linux.vnet.ibm.com Wed Feb 27 00:03:42 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 26 Feb 2008 16:03:42 -0800 Subject: [Libvirt-cim] [PATCH 1 of 4] Make get_migration_sd() of VSMigrationSettingData.c non-staitc In-Reply-To: Message-ID: <89cff8c40cafbce33b90.1204070622@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1202498491 28800 # Node ID 89cff8c40cafbce33b90a55e991721b8302714c2 # Parent 1aef50fa67a9ba1a3687afe03e3b1bf455d57685 Make get_migration_sd() of VSMigrationSettingData.c non-staitc. VSMigrationService will need to call this function to get the default VSMigrationSettingData instance. Signed-off-by: Kaitlin Rupert diff -r 1aef50fa67a9 -r 89cff8c40caf src/Virt_VSMigrationSettingData.c --- a/src/Virt_VSMigrationSettingData.c Mon Feb 25 09:09:02 2008 -0800 +++ b/src/Virt_VSMigrationSettingData.c Fri Feb 08 11:21:31 2008 -0800 @@ -30,6 +30,7 @@ #include #include "misc_util.h" +#include "Virt_VSMigrationSettingData.h" const static CMPIBroker *_BROKER; @@ -54,10 +55,10 @@ static CMPIStatus set_properties(const C return s; } -static CMPIStatus get_migration_sd(const CMPIObjectPath *ref, - CMPIInstance **_inst, - const CMPIBroker *broker, - bool is_get_inst) +CMPIStatus get_migration_sd(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst) { CMPIInstance *inst; CMPIStatus s = {CMPI_RC_OK, NULL}; diff -r 1aef50fa67a9 -r 89cff8c40caf src/Virt_VSMigrationSettingData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VSMigrationSettingData.h Fri Feb 08 11:21:31 2008 -0800 @@ -0,0 +1,35 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Kaitlin Rupert + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +CMPIStatus get_migration_sd(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst); +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ + From kaitlin at linux.vnet.ibm.com Wed Feb 27 00:03:41 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 26 Feb 2008 16:03:41 -0800 Subject: [Libvirt-cim] [PATCH 0 of 4] Update VSMigrationService to support static and offline migration Message-ID: This patchset updates VSMigrationService so that it reads the MigrationType attribute from MigrationSettingData and then launches the appropriate migration method. From kaitlin at linux.vnet.ibm.com Wed Feb 27 00:03:43 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 26 Feb 2008 16:03:43 -0800 Subject: [Libvirt-cim] [PATCH 2 of 4] Add migration types to VSMigrationSettingData.h In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1203986184 28800 # Node ID c089d134bfb70e3ab48d06ea4b7d229be1341646 # Parent 89cff8c40cafbce33b90a55e991721b8302714c2 Add migration types to VSMigrationSettingData.h These values specify the migration types CIM supports. Signed-off-by: Kaitlin Rupert diff -r 89cff8c40caf -r c089d134bfb7 src/Virt_VSMigrationSettingData.c --- a/src/Virt_VSMigrationSettingData.c Fri Feb 08 11:21:31 2008 -0800 +++ b/src/Virt_VSMigrationSettingData.c Mon Feb 25 16:36:24 2008 -0800 @@ -38,7 +38,7 @@ static CMPIStatus set_properties(const C CMPIInstance *inst) { CMPIStatus s; - uint16_t type = 3; /* Use live migration as default */ + uint16_t type = CIM_MIGRATE_LIVE; uint16_t priority = 0; /* Use default priority */ CMSetProperty(inst, "MigrationType", diff -r 89cff8c40caf -r c089d134bfb7 src/Virt_VSMigrationSettingData.h --- a/src/Virt_VSMigrationSettingData.h Fri Feb 08 11:21:31 2008 -0800 +++ b/src/Virt_VSMigrationSettingData.h Mon Feb 25 16:36:24 2008 -0800 @@ -19,6 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +enum {CIM_MIGRATE_OTHER = 1, + CIM_MIGRATE_LIVE = 2, + CIM_MIGRATE_RESUME = 3, + CIM_MIGRATE_RESTART = 4, +} migration_type; + CMPIStatus get_migration_sd(const CMPIObjectPath *ref, CMPIInstance **_inst, const CMPIBroker *broker, From kaitlin at linux.vnet.ibm.com Wed Feb 27 00:03:45 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 26 Feb 2008 16:03:45 -0800 Subject: [Libvirt-cim] [PATCH 4 of 4] Add offline migration support In-Reply-To: Message-ID: <4310ed87a132963947ad.1204070625@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1204070582 28800 # Node ID 4310ed87a132963947ad866eccca7d9697ef8fcf # Parent 09153317203d6a60ede32daf5f2ce5765b6d9953 Add offline migration support. Signed-off-by: Kaitlin Rupert diff -r 09153317203d -r 4310ed87a132 src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Mon Feb 25 16:36:25 2008 -0800 +++ b/src/Virt_VSMigrationService.c Tue Feb 26 16:03:02 2008 -0800 @@ -410,6 +410,69 @@ static CMPIStatus handle_migrate(virConn return s; } +static CMPIStatus prepare_offline_migrate(virDomainPtr dom, + char **xml) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virDomainInfo info; + int ret; + + ret = virDomainGetInfo(dom, &info); + if (ret != 0) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unabled to get info for domain."); + goto out; + } + + if ((const int)info.state != VIR_DOMAIN_SHUTOFF) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Domain must be shutoff for offline migration."); + goto out; + } + + *xml = virDomainGetXMLDesc(dom, 0); + if (*xml == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to retrieve domain XML."); + goto out; + } + + out: + return s; +} + +static CMPIStatus handle_offline_migrate(virConnectPtr dconn, + virDomainPtr dom, + char *uri, + char *xml, + struct migration_job *job) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virDomainPtr new_dom; + + if (domain_exists(dconn, job->domain)) { + CU_DEBUG("This domain already exists on the target system."); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "This domain already exists on the target system"); + goto out; + } + + new_dom = virDomainDefineXML(dconn, xml); + if (new_dom == NULL) { + CU_DEBUG("Failed to define domain from XML"); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to create domain"); + } + + out: + return s; +} + static CMPIStatus migrate_vs(struct migration_job *job) { CMPIStatus s; @@ -417,6 +480,7 @@ static CMPIStatus migrate_vs(struct migr virConnectPtr dconn = NULL; virDomainPtr dom = NULL; char *uri = NULL; + char *xml = NULL; uri = dest_uri(job->ref_cn, job->host); if (uri == NULL) { @@ -439,6 +503,12 @@ static CMPIStatus migrate_vs(struct migr goto out; } + if (job->type == CIM_MIGRATE_OTHER) { + s = prepare_offline_migrate(dom, &xml); + if (s.rc != CMPI_RC_OK) + goto out; + } + dconn = virConnectOpen(uri); if (dconn == NULL) { CU_DEBUG("Failed to connect to remote host (%s)", uri); @@ -450,8 +520,8 @@ static CMPIStatus migrate_vs(struct migr switch(job->type) { case CIM_MIGRATE_OTHER: - /* FIXME - Handle offline migration here */ CU_DEBUG("Preparing for offline migration"); + s = handle_offline_migrate(dconn, dom, uri, xml, job); break; case CIM_MIGRATE_LIVE: CU_DEBUG("Preparing for live migration"); @@ -480,6 +550,7 @@ static CMPIStatus migrate_vs(struct migr out: free(uri); + free(xml); virDomainFree(dom); virConnectClose(conn); virConnectClose(dconn); From kaitlin at linux.vnet.ibm.com Wed Feb 27 01:13:07 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 26 Feb 2008 17:13:07 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: References: Message-ID: <47C4B923.9010908@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1204053596 28800 > # Node ID fce1a31a53090b42dbfbd788a6db2a1164636197 > # Parent bb0530f50ea8d4a75ec34cd54f3bc2daebbda556 > Add VirtualSystemSnapshotService > > Changes: > - Added header block > > Signed-off-by: Dan Smith > > diff -r bb0530f50ea8 -r fce1a31a5309 src/Virt_VirtualSystemSnapshotService.c > +static CMPI_THREAD_RETURN snapshot_thread(struct snap_context *ctx) > +{ > + CMPIStatus s; We don't use this, which is fine. However, leads to a question.. why the decision to have do_snapshot() return void? > + > +char *vsss_get_save_path(const char *domname) The function is defined as vss_get_save_path() here, but called as get_save_path() later on. > +{ > + int ret; > + char *path = NULL; > + > + ret = asprintf(&path, > + "/var/lib/libvirt/%s.save", domname); I assume this path will be valid on all systems / distros? > + > +static struct snap_context *new_context(const char *name, > + CMPIStatus *s) > +{ > + struct snap_context *ctx; > + uuid_t uuid; > + > + ctx = calloc(1, sizeof(*ctx)); > + if (ctx == NULL) { > + CU_DEBUG("Failed to alloc snapshot context"); > + goto out; > + } > + > + ctx->domain = strdup(name); > + > + uuid_generate(uuid); > + uuid_unparse(uuid, ctx->uuid); > + > + ctx->save_path = get_save_path(ctx->domain); Needs to be vsss_get_save_path() > + if (ctx->save_path == NULL) { > + cu_statusf(_BROKER, s, > + CMPI_RC_ERR_FAILED, > + "Unable to get save_path"); > + goto out; > + } > + > + cu_statusf(_BROKER, s, > + CMPI_RC_OK, > + ""); > + out: > + if (s->rc != CMPI_RC_OK) { > + snap_job_free(ctx); > + ctx = NULL; > + } > + > + return ctx; > +} > + > +static CMPIStatus start_snapshot_job(const CMPIObjectPath *ref, > + const CMPIContext *context, > + const char *name, > + uint16_t type) > +{ > + struct snap_context *ctx; > + CMPIStatus s; Need to initialize s here. Or make sure to set the status when the calloc fails in new_context(). > + CMPIObjectPath *job; > + > + ctx = new_context(name, &s); > + if (ctx == NULL) > + goto out; > + > + ctx->save = (type != 0); > + ctx->restore = (type != VIR_VSSS_SNAPSHOT_MEM); > + > + s = create_job(context, ref, ctx, &job); > + > + out: > + return s; > +} > + > + > +static CMPIStatus destroy_snapshot(CMPIMethodMI *self, > + const CMPIContext *context, > + const CMPIResult *results, > + const CMPIObjectPath *reference, > + const CMPIArgs *argsin, > + CMPIArgs *argsout) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + CMPIObjectPath *snap; > + char *name = NULL; > + char *path = NULL; > + path = get_save_path(name); Needs to be vsss_get_save_path() -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Wed Feb 27 01:16:34 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 26 Feb 2008 17:16:34 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] Add VirtualSystemSnapshotCapabilities In-Reply-To: <0f1a316b04aca1fa962f.1204055470@caffeine.beaverton.ibm.com> References: <0f1a316b04aca1fa962f.1204055470@caffeine.beaverton.ibm.com> Message-ID: <47C4B9F2.8000700@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1204053674 28800 > # Node ID 0f1a316b04aca1fa962f624444ae57b960fc2a37 > # Parent fce1a31a53090b42dbfbd788a6db2a1164636197 > Add VirtualSystemSnapshotCapabilities > > Signed-off-by: Dan Smith > > diff -r fce1a31a5309 -r 0f1a316b04ac src/Virt_VirtualSystemSnapshotServiceCapabilities.c > + > +static CMPIStatus set_inst_properties(const CMPIBroker *broker, > + CMPIInstance *inst) > +{ > + > + array = CMNewArray(broker, 2, CMPI_uint16, &s); > + if ((s.rc != CMPI_RC_OK) || (array == NULL)) > + goto out; > + > + element = (uint16_t)CIM_VSSS_SNAPSHOT_MEM; > + CMSetArrayElementAt(array, 0, &element, CMPI_uint16); > + > + element = (uint16_t)CIM_VSSS_SNAPSHOT_MEMT; > + CMSetArrayElementAt(array, 1, &element, CMPI_uint16); These should be VIR_VSSS_SNAPSHOT_MEM and VIR_VSSS_SNAPSHOT_MEMT > + > + CMSetProperty(inst, "SnapshotTypesSupported", > + (CMPIValue *)&array, CMPI_uint16A); > + > + out: > + return s; > +} > + -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Wed Feb 27 01:19:36 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Tue, 26 Feb 2008 17:19:36 -0800 Subject: [Libvirt-cim] [PATCH 3 of 3] Add VirtualSystemSnapshotService{, Capabilities} build support In-Reply-To: References: Message-ID: <47C4BAA8.9080607@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1204053694 28800 > # Node ID ce18bd2b2708e263dd03fbcd3e94ce21182e847d > # Parent 0f1a316b04aca1fa962f624444ae57b960fc2a37 > Add VirtualSystemSnapshotService{,Capabilities} build support > > Signed-off-by: Dan Smith > > diff -r 0f1a316b04ac -r ce18bd2b2708 Makefile.am > --- a/Makefile.am Tue Feb 26 11:21:14 2008 -0800 > +++ b/Makefile.am Tue Feb 26 11:21:34 2008 -0800 > @@ -37,7 +37,9 @@ MOFS = \ > schema/ElementSettingData.mof \ > schema/VSMigrationCapabilities.mof \ > schema/VSMigrationService.mof \ > - schema/VSMigrationSettingData.mof > + schema/VSMigrationSettingData.mof \ > + schema/VirtualSystemSnapshotService.mof \ > + schema/VirtualSystemSnapshotServiceCapabilities.mof VirtualSystemSnapshotServiceCapabilities.mof is added here, but this patch doesn't add the corresponding mof file. > > INTEROP_MOFS = \ > schema/ComputerSystem.mof \ > @@ -81,7 +83,9 @@ REGS = \ > schema/VSMigrationCapabilities.registration \ > schema/VSMigrationService.registration \ > schema/ElementConformsToProfile.registration \ > - schema/VSMigrationSettingData.registration > + schema/VSMigrationSettingData.registration \ > + schema/VirtualSystemSnapshotService.registration \ > + schema/VirtualSystemSnapshotServiceCapabilities.registration Same for registration. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From lizg at cn.ibm.com Wed Feb 27 01:48:27 2008 From: lizg at cn.ibm.com (lizg at cn.ibm.com) Date: Wed, 27 Feb 2008 09:48:27 +0800 Subject: [Libvirt-cim] [PATCH] [CU] Fix const pointer warning Message-ID: <8ef92e008bcbcf2336cb.1204076907@localhost.localdomain> # HG changeset patch # User Zhengang Li # Date 1204076903 -28800 # Node ID 8ef92e008bcbcf2336cbccfa083c2d22f690ca1d # Parent b2606bc023a8a26ecd25464e976fb16606ed3a47 [CU] Fix const pointer warning Signed-off-by: Zhengang Li diff -r b2606bc023a8 -r 8ef92e008bcb instance_util.c --- a/instance_util.c Tue Feb 26 15:16:00 2008 -0500 +++ b/instance_util.c Wed Feb 27 09:48:23 2008 +0800 @@ -255,7 +255,7 @@ CMPIInstance *cu_dup_instance(const CMPI const char *cu_classname_from_inst(CMPIInstance *inst) { - char *ret = NULL; + const char *ret = NULL; CMPIObjectPath *ref; ref = CMGetObjectPath(inst, NULL); diff -r b2606bc023a8 -r 8ef92e008bcb std_indication.c --- a/std_indication.c Tue Feb 26 15:16:00 2008 -0500 +++ b/std_indication.c Wed Feb 27 09:48:23 2008 +0800 @@ -214,7 +214,7 @@ CMPIStatus stdi_activate_filter(CMPIIndi char *cn = NULL; _ctx = (struct std_indication_ctx *)mi->hdl; - cn = CLASSNAME(op); + cn = (char *)CLASSNAME(op); s = stdi_set_ind_filter_state(_ctx, cn, true); if (_ctx->handler != NULL && _ctx->handler->activate_fn != NULL) { @@ -239,7 +239,7 @@ CMPIStatus stdi_deactivate_filter(CMPIIn char *cn = NULL; _ctx = (struct std_indication_ctx *)mi->hdl; - cn = CLASSNAME(op); + cn = (char *)CLASSNAME(op); s = stdi_set_ind_filter_state(_ctx, cn, false); if (_ctx->handler != NULL && _ctx->handler->deactivate_fn != NULL) { From heidieck at linux.vnet.ibm.com Wed Feb 27 10:03:19 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 27 Feb 2008 11:03:19 +0100 Subject: [Libvirt-cim] [PATCH 2 of 3] Add VirtualSystemSnapshotCapabilities In-Reply-To: <0f1a316b04aca1fa962f.1204055470@caffeine.beaverton.ibm.com> References: <0f1a316b04aca1fa962f.1204055470@caffeine.beaverton.ibm.com> Message-ID: <47C53567.60006@linux.vnet.ibm.com> Dan Smith wrote: > +++ b/src/Virt_VirtualSystemSnapshotServiceCapabilities.c Tue Feb 26 11:21:14 2008 -0800 > @@ -0,0 +1,204 @@ > +/* > + * Copyright IBM Corp. 2007 > 2008 ;) > +static CMPIStatus get_vss_cap(const CMPIBroker *broker, > + const CMPIObjectPath *ref, > + CMPIInstance **_inst, > + bool is_get_inst) > As this function is already prepared for external use (e.g. by ElementCapabilities), it makes sense to remove the static and also add the header file right with this patch set. Other than that ... looks very good. Thanks for using the updated interfaces :). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 27 10:34:45 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 27 Feb 2008 11:34:45 +0100 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: References: Message-ID: <47C53CC5.5060507@linux.vnet.ibm.com> Dan Smith wrote: > +static void snap_job_set_status(struct snap_context *ctx, > + uint16_t state, > + const char *status) > +{ > + CMPIInstance *inst; > + CMPIStatus s; > + CMPIObjectPath *op; > + > + op = CMNewObjectPath(_BROKER, > + ctx->ref_ns, > + "CIM_ConcreteJob", > + &s); > + if (s.rc != CMPI_RC_OK) { > + CU_DEBUG("Failed to create job path for update"); > + return; > + } > + > + CMAddKey(op, "InstanceID", (CMPIValue *)ctx->uuid, CMPI_chars); > + > + inst = CBGetInstance(_BROKER, ctx->context, op, NULL, &s); > + if ((inst == NULL) || (s.rc != CMPI_RC_OK)) { > + CU_DEBUG("Failed to get job instance for update of %s", > + ctx->uuid); > + return; > + } > + > + CMSetProperty(inst, "JobState", > + (CMPIValue *)&state, CMPI_uint16); > + CMSetProperty(inst, "Status", > + (CMPIValue *)status, CMPI_chars); > It would be good to also add the domain and save_path information to the Job instance, e.g. as value of the property "Name". > + > + s = CBModifyInstance(_BROKER, ctx->context, op, inst, NULL); > + if (s.rc != CMPI_RC_OK) { > + CU_DEBUG("Failed to update job instance %s: %s", > + ctx->uuid, > + CMGetCharPtr(s.msg)); > + return; > + } > + > + CU_DEBUG("Set %s status to %i:%s", ctx->uuid, state, status); > +} > + Somehow I think that success and error scenarios are merged by this function. Even if a snapshot request failed, the JobState has COMPLETE, which is in general correct. But the client can only interpret the Status property then, if the snapshot was created or not. The CIM_Job mof tells to use ErrorCode and ErrorDescription. I think this is a good way to communicate a snapshot failure. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 27 10:59:25 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 27 Feb 2008 11:59:25 +0100 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: References: Message-ID: <47C5428D.20309@linux.vnet.ibm.com> Dan Smith wrote: > +++ b/src/Virt_VirtualSystemSnapshotService.c Tue Feb 26 11:19:56 2008 -0800 > @@ -0,0 +1,521 @@ > +/* > + * Copyright IBM Corp. 2007 > 2008 ;) > +static void do_snapshot(struct snap_context *ctx, > + virConnectPtr conn, > + virDomainPtr dom) > +{ > + ... > + if (ctx->restore) { > + CU_DEBUG("Starting restore from %s", ctx->save_path); > + > + ret = virDomainRestore(conn, ctx->save_path); > + if (ret == -1) { > + CU_DEBUG("Restore failed"); > + snap_job_set_status(ctx, > + CIM_JOBSTATE_COMPLETE, > + "Snapshot Failed (restore)"); > + return; > + } > + > + CU_DEBUG("Restore completed"); > + snap_job_set_status(ctx, > + CIM_JOBSTATE_RUNNING, > + "Restore finished"); > Please can you explain why you set the status here and overwrite it right afterwards ? I think the CIM_JOBSTATE is already COMPLETE here. > + } > + > + CU_DEBUG("Snapshot (%s/%s) completed", > + ctx->save ? "Save" : "None", > + ctx->restore ? "Restore" : "None"); > + > + snap_job_set_status(ctx, > + CIM_JOBSTATE_COMPLETE, > + "Snapshot complete"); > + > + return; > +} > + > +static CMPI_THREAD_RETURN snapshot_thread(struct snap_context *ctx) > +{... > + conn = connect_by_classname(_BROKER, ctx->ref_cn, &s); > + if (conn == NULL) { > + CU_DEBUG("Failed to connect with classname `%s'", ctx->ref_cn); > + snap_job_set_status(ctx, > + CIM_JOBSTATE_COMPLETE, > + "Unable to connect to hypervisor"); > + goto out; > + } > + > + dom = virDomainLookupByName(conn, ctx->domain); > + if (dom == NULL) { > + CU_DEBUG("No such domain `%s'", ctx->domain); > + snap_job_set_status(ctx, > + CIM_JOBSTATE_COMPLETE, > + "No such domain"); > + goto out; > + } > + > + do_snapshot(ctx, conn, dom); > + > + out: > FYI - I encountered some problems with another provider, where I tried virDomainFree() with a not initialized dom. This could also happen here with the goto out from conn. Maybe virDomainFree() can not handle NULL ? > + virDomainFree(dom); > + virConnectClose(conn); > + > + snap_job_free(ctx); > + > + return NULL; > +} > + > +static CMPIStatus create_job(const CMPIContext *context, > + const CMPIObjectPath *ref, > + struct snap_context *ctx, > + CMPIObjectPath **job) > +{ > + CMPIObjectPath *op; > + CMPIInstance *inst; > + CMPIStatus s; > + > + op = CMNewObjectPath(_BROKER, > + NAMESPACE(ref), > + "CIM_ConcreteJob", /*FIXME*/ > + &s); > + if ((s.rc != CMPI_RC_OK) || (op == NULL)) { > + CU_DEBUG("Failed to create job path"); > + goto out; > + } > + > + CMSetNameSpace(op, NAMESPACE(ref)); > This step is not necessary as NewObjectPath already sets the namespace. > + > + inst = CMNewInstance(_BROKER, op, &s); > + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) { > + CU_DEBUG("Failed to create job instance"); > + goto out; > + } > + > + CMSetProperty(inst, "InstanceID", > + (CMPIValue *)ctx->uuid, CMPI_chars); > + > + CMSetProperty(inst, "Name", > + (CMPIValue *)"Snapshot", CMPI_chars); > + > + CMSetProperty(inst, "Status", > + (CMPIValue *)"Queued", CMPI_chars); > + > + op = CMGetObjectPath(inst, &s); > + if ((op == NULL) || (s.rc != CMPI_RC_OK)) { > + CU_DEBUG("Failed to get path of job instance"); > + goto out; > + } > + > + CMSetNameSpace(op, NAMESPACE(ref)); > This should also be not necessary. But as you debug the ref right afterwards ... did you encounter some problems here ? > + > + CU_DEBUG("ref was %s", CMGetCharPtr(CMObjectPathToString(op, NULL))); > + > + *job = CBCreateInstance(_BROKER, context, op, inst, &s); > + if ((*job == NULL) || (s.rc != CMPI_RC_OK)) { > + CU_DEBUG("Failed to create job"); > + goto out; > + } > + > + ctx->ref_ns = strdup(NAMESPACE(ref)); > + ctx->ref_cn = strdup(CLASSNAME(ref)); > + > + ctx->context = CBPrepareAttachThread(_BROKER, context); > + > + _BROKER->xft->newThread((void *)snapshot_thread, ctx, 0); > + > + cu_statusf(_BROKER, &s, > + CMPI_RC_OK, > + ""); > Its more my personal view, but as you "goto out" each time the status is something else than CMPI_RC_OK, it should still be CMPI_RC_OK at this point, if you initialize it right at the beginning of the function with CMPIStatus s = {CMPI_RC_OK, NULL}; . > + out: > + return s; > +} > + > +char *vsss_get_save_path(const char *domname) > +{ > + int ret; > + char *path = NULL; > You could use a CMPIString and return its char* to the caller. This avoids missing frees. > + > + ret = asprintf(&path, > + "/var/lib/libvirt/%s.save", domname); > + if (ret == -1) > + return NULL; > + > + return path; > +} > + ... > + > + > +static CMPIStatus create_snapshot(CMPIMethodMI *self, > + const CMPIContext *context, > + const CMPIResult *results, > + const CMPIObjectPath *reference, > + const CMPIArgs *argsin, > + CMPIArgs *argsout) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + CMPIObjectPath *system; > + CMPIInstance *sd; > + uint16_t type; > + uint32_t retcode = 0; > + const char *name; > + > + if (cu_get_u16_arg(argsin, "SnapshotType", &type) != CMPI_RC_OK) { > + cu_statusf(_BROKER, &s, > + CMPI_RC_ERR_INVALID_PARAMETER, > + "Missing SnapshotType"); > + goto out; > + } > + ... > + > + s = start_snapshot_job(reference, context, name, type); > + > + CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); > + out: > + CU_DEBUG("Returning: %i", s.rc); > You also need to do a CMReturnData for a failed request. > + return s; > +} > + > +static CMPIStatus destroy_snapshot(CMPIMethodMI *self, > + const CMPIContext *context, > + const CMPIResult *results, > + const CMPIObjectPath *reference, > + const CMPIArgs *argsin, > + CMPIArgs *argsout) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + CMPIObjectPath *snap; > + char *name = NULL; > + char *path = NULL; > + ... > + out: > + free(path); > + free(name); You need to return the uint32 status of this method. The same for apply_snapshot(). > + return s; > +} > + ... > + > +STDIM_MethodMIStub(, Virt_VirtualSystemSnapshotService, > + _BROKER, libvirt_cim_init(), handlers); > I miss the instance provider interface. Do you plan to add this ? -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 27 11:47:36 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 27 Feb 2008 12:47:36 +0100 Subject: [Libvirt-cim] [PATCH 2 of 4] Add migration types to VSMigrationSettingData.h In-Reply-To: References: Message-ID: <47C54DD8.9090305@linux.vnet.ibm.com> Kaitlin Rupert wrote: > - uint16_t type = 3; /* Use live migration as default */ > + uint16_t type = CIM_MIGRATE_LIVE; > ... > +enum {CIM_MIGRATE_OTHER = 1, > + CIM_MIGRATE_LIVE = 2, > + CIM_MIGRATE_RESUME = 3, > + CIM_MIGRATE_RESTART = 4, > +} migration_type; > + > What is now correct ? MIGRATE_LIVE 2 or 3 ? -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 27 12:53:08 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 27 Feb 2008 13:53:08 +0100 Subject: [Libvirt-cim] [PATCH 3 of 4] Add MigrationType support to VirtualSystemMigrationService In-Reply-To: <09153317203d6a60ede3.1204070624@elm3b41.beaverton.ibm.com> References: <09153317203d6a60ede3.1204070624@elm3b41.beaverton.ibm.com> Message-ID: <47C55D34.90700@linux.vnet.ibm.com> Kaitlin Rupert wrote: > @@ -424,25 +448,39 @@ static CMPIStatus migrate_vs(struct migr > goto out; > } > > - CU_DEBUG("Migrating %s -> %s", job->domain, uri); > - > - ddom = virDomainMigrate(dom, dconn, VIR_MIGRATE_LIVE, NULL, NULL, 0); > - if (ddom == NULL) { > - CU_DEBUG("Migration failed"); > - cu_statusf(_BROKER, &s, > - CMPI_RC_ERR_FAILED, > - "Migration Failed"); > - goto out; > - } > + switch(job->type) { > + case CIM_MIGRATE_OTHER: > + /* FIXME - Handle offline migration here */ > + CU_DEBUG("Preparing for offline migration"); > + break; > + case CIM_MIGRATE_LIVE: > + CU_DEBUG("Preparing for live migration"); > + s = handle_migrate(dconn, dom, uri, VIR_MIGRATE_LIVE, job); > Is the type CIM_MIGRATE_LIVE or VIR_MIGRATE_LIVE ? > + break; > + case CIM_MIGRATE_RESUME: > + case CIM_MIGRATE_RESTART: > + CU_DEBUG("Preparing for static migration"); > + s = handle_migrate(dconn, dom, uri, 0, job); > The type should be CIM_MIGRATE_RESTART > + break; > + default: > + CU_DEBUG("Unsupported migration type (%d)", job->type); > + cu_statusf(_BROKER, &s, > + CMPI_RC_ERR_FAILED, > + "Unsupported migration type (%d)", job->type); > + goto out; > + } > + > + if (s.rc != CMPI_RC_OK) > + goto out; > > -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Wed Feb 27 12:54:03 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Wed, 27 Feb 2008 13:54:03 +0100 Subject: [Libvirt-cim] [PATCH 0 of 4] Update VSMigrationService to support static and offline migration In-Reply-To: References: Message-ID: <47C55D6B.6070502@linux.vnet.ibm.com> Kaitlin Rupert wrote: > This patchset updates VSMigrationService so that it reads the MigrationType attribute from MigrationSettingData and then launches the appropriate migration method. > > FYI - I did not had any problems to apply and compile these patches. But haven't tested yet. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From danms at us.ibm.com Wed Feb 27 15:26:30 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 27 Feb 2008 07:26:30 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: <47C4B923.9010908@linux.vnet.ibm.com> (Kaitlin Rupert's message of "Tue, 26 Feb 2008 17:13:07 -0800") References: <47C4B923.9010908@linux.vnet.ibm.com> Message-ID: <87hcfuh13t.fsf@caffeine.beaverton.ibm.com> KR> We don't use this, which is fine. However, leads to a KR> question.. why the decision to have do_snapshot() return void? Because the status and state information is conveyed through the job. What else could the caller do with a return value? It's in a thread. KR> The function is defined as vss_get_save_path() here, but called as KR> get_save_path() later on. Wow, that was dumb. I changed this right before I sent it out, but I think it compiled the first time because I had the function defined in the installed libraries and headers. Thanks :) KR> I assume this path will be valid on all systems / distros? Probably not. We probably need to put this in our configure.ac. KR> Need to initialize s here. Or make sure to set the status when KR> the calloc fails in new_context(). Yep, thanks. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Wed Feb 27 15:28:23 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 27 Feb 2008 07:28:23 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: <47C53CC5.5060507@linux.vnet.ibm.com> (Heidi Eckhart's message of "Wed, 27 Feb 2008 11:34:45 +0100") References: <47C53CC5.5060507@linux.vnet.ibm.com> Message-ID: <87d4qih10o.fsf@caffeine.beaverton.ibm.com> HE> It would be good to also add the domain and save_path information HE> to the Job instance, e.g. as value of the property "Name". Okay, I'll stuff it in there somewhere. HE> Somehow I think that success and error scenarios are merged by HE> this function. Even if a snapshot request failed, the JobState has HE> COMPLETE, which is in general correct. But the client can only HE> interpret the Status property then, if the snapshot was created or HE> not. The CIM_Job mof tells to use ErrorCode and HE> ErrorDescription. I think this is a good way to communicate a HE> snapshot failure. Okay, good point. Having the job status be "complete" for a failed job bugs me, but I'll set the error information. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Wed Feb 27 15:39:35 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 27 Feb 2008 07:39:35 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: <47C5428D.20309@linux.vnet.ibm.com> (Heidi Eckhart's message of "Wed, 27 Feb 2008 11:59:25 +0100") References: <47C5428D.20309@linux.vnet.ibm.com> Message-ID: <878x16h0i0.fsf@caffeine.beaverton.ibm.com> HE> 2008 ;) Whoops, thanks :) HE> Please can you explain why you set the status here and overwrite HE> it right afterwards ? I think the CIM_JOBSTATE is already COMPLETE HE> here. I wanted this function to serve three roles: save, save-then-restore, and restore. In the save-then-restore scenario, we want a status update after the save is complete, of course. Because I like symmetric code, I added the same sort of status update to the end of restore. In the save-only case, this comes out to setting the save status and then changing it to "complete" right afterwards. I don't know if this is a big deal or not, but I think that the code to make it avoid the extra set would be less pretty. Suggestions are welcome, of course :) HE> FYI - I encountered some problems with another provider, where I HE> tried virDomainFree() with a not initialized dom. This could also HE> happen here with the goto out from conn. Maybe virDomainFree() can HE> not handle NULL ? No, it can handle it just fine. We do this in many, many places elsewhere in the code. I think you might get a warning out of it in some cases, but the code does check for NULL. HE> This step is not necessary as NewObjectPath already sets the HE> namespace. It doesn't for me. If I don't do this, the CBCreateInstance fails with "Target namespace does not exist". We do this in the migration job creation code as well. >> + CMSetNameSpace(op, NAMESPACE(ref)); Er, hmm, maybe it's this one. HE> This should also be not necessary. But as you debug the ref right HE> afterwards ... did you encounter some problems here ? Yes, removing at least one of these results in the behavior described above. I'll revisit and see which is the necessary one. HE> Its more my personal view, but as you "goto out" each time the HE> status is something else than CMPI_RC_OK, it should still be HE> CMPI_RC_OK at this point, if you initialize it right at the HE> beginning of the function with CMPIStatus s = {CMPI_RC_OK, NULL}; HE> . The reason I don't like doing this in all cases is because it's implied success at the bottom of the function, instead of making it explicit. Also, if we are in the habit of doing this, and then have a function where we catch s.rc != CMPI_RC_OK somewhere and take a default value, then we might fall through here and return an error when we don't intend to. However, I've changed it in this case. HE> You could use a CMPIString and return its char* to the HE> caller. This avoids missing frees. But then I have to pass a broker pointer, since this is used outside this file. I'll look to see if it makes sense to do that here or not. HE> You also need to do a CMReturnData for a failed request. Ah, yes, thanks. HE> I miss the instance provider interface. Do you plan to add this ? Yes :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Wed Feb 27 15:44:12 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 27 Feb 2008 07:44:12 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] Add VirtualSystemSnapshotCapabilities In-Reply-To: <47C4B9F2.8000700@linux.vnet.ibm.com> (Kaitlin Rupert's message of "Tue, 26 Feb 2008 17:16:34 -0800") References: <0f1a316b04aca1fa962f.1204055470@caffeine.beaverton.ibm.com> <47C4B9F2.8000700@linux.vnet.ibm.com> Message-ID: <874pbuh0ab.fsf@caffeine.beaverton.ibm.com> KR> These should be VIR_VSSS_SNAPSHOT_MEM and VIR_VSSS_SNAPSHOT_MEMT I just realized that these compile errors weren't caught because my build changes were in a separate patch after the code. Thus, I would recompile to test changes, but not actually include the new stuff in the compile. /me is a super-genius Thanks :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Wed Feb 27 15:51:07 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 27 Feb 2008 07:51:07 -0800 Subject: [Libvirt-cim] [PATCH 3 of 3] Add VirtualSystemSnapshotService{, Capabilities} build support In-Reply-To: <47C4BAA8.9080607@linux.vnet.ibm.com> (Kaitlin Rupert's message of "Tue, 26 Feb 2008 17:19:36 -0800") References: <47C4BAA8.9080607@linux.vnet.ibm.com> Message-ID: <87zltmflec.fsf@caffeine.beaverton.ibm.com> KR> VirtualSystemSnapshotServiceCapabilities.mof is added here, but KR> this patch doesn't add the corresponding mof file. Same for KR> registration. Aiee, this has been the set from hell. I'll fix it in the (obviously necessary) resend. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From grendel at linux.vnet.ibm.com Wed Feb 27 15:53:03 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Wed, 27 Feb 2008 10:53:03 -0500 Subject: [Libvirt-cim] [PATCH] [CU] Fix the --dump-xml option in libcmpiutil Message-ID: <9ba30d99c82d67417060.1204127583@naegling> # HG changeset patch # User Jay Gagnon # Date 1204126795 18000 # Node ID 9ba30d99c82d6741706014630a4d8496dbaa4deb # Parent b2606bc023a8a26ecd25464e976fb16606ed3a47 [CU] Fix the --dump-xml option in libcmpiutil It appears that at some point some changes were made that broke the --dump-xml switch. This should fix that up. Signed-off-by: Jay Gagnon diff -r b2606bc023a8 -r 9ba30d99c82d tools/indication_tester.py --- a/tools/indication_tester.py Tue Feb 26 15:16:00 2008 -0500 +++ b/tools/indication_tester.py Wed Feb 27 10:39:55 2008 -0500 @@ -359,13 +359,13 @@ class CIMIndicationSubscription: self.__do_cimpost(self.conn, xml, "DeleteInstance", auth_hdr) -def dump_xml(name, typ, ns): - filter_str = filter_xml(name, typ, ns) - handler_str = handler_xml(name, 8000) - subscript_str = subscription_xml(name) - del_filter_str = delete_inst_xml(name, "Filter") - del_handler_str = delete_inst_xml(name, "Handler") - del_subscript_str = delete_sub_xml(name) +def dump_xml(name, typ, ns, sysname): + filter_str = filter_xml(name, typ, ns, sysname) + handler_str = handler_xml(name, 8000, sysname) + subscript_str = subscription_xml(name, sysname) + del_filter_str = delete_inst_xml(name, "Filter", sysname) + del_handler_str = delete_inst_xml(name, "Handler", sysname) + del_subscript_str = delete_sub_xml(name, sysname) print "CreateFilter:\n%s\n" % filter_str print "DeleteFilter:\n%s\n" % del_filter_str @@ -402,10 +402,6 @@ def main(): print "Fatal: no indication type provided." sys.exit(1) - if options.dump: - dump_xml(options.name, args[0], options.ns) - sys.exit(0) - if options.username: auth = (options.username, options.password) else: @@ -416,6 +412,10 @@ def main(): else: sysname = url + if options.dump: + dump_xml(options.name, args[0], options.ns, sysname) + sys.exit(0) + sub = CIMIndicationSubscription(options.name, args[0], options.ns, options.print_ind, sysname) sub.subscribe(options.url, auth) From kaitlin at linux.vnet.ibm.com Wed Feb 27 16:11:13 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 27 Feb 2008 08:11:13 -0800 Subject: [Libvirt-cim] [PATCH 2 of 4] Add migration types to VSMigrationSettingData.h In-Reply-To: <47C54DD8.9090305@linux.vnet.ibm.com> References: <47C54DD8.9090305@linux.vnet.ibm.com> Message-ID: <47C58BA1.5070104@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> - uint16_t type = 3; /* Use live migration as default */ >> + uint16_t type = CIM_MIGRATE_LIVE; >> ... >> +enum {CIM_MIGRATE_OTHER = 1, >> + CIM_MIGRATE_LIVE = 2, >> + CIM_MIGRATE_RESUME = 3, >> + CIM_MIGRATE_RESTART = 4, >> +} migration_type; >> + >> > What is now correct ? MIGRATE_LIVE 2 or 3 ? > I had a mistake earlier on, MIGRATE_LIVE is 2. Here's the relevant part from the mof: ValueMap {"0","1","2","3","4"}, Values { "Unknown", "Other", "Live", "Resume", "Restart" }] uint16 MigrationType; -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From grendel at linux.vnet.ibm.com Wed Feb 27 16:20:20 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Wed, 27 Feb 2008 11:20:20 -0500 Subject: [Libvirt-cim] [PATCH] [CU] Fix const pointer warning In-Reply-To: <8ef92e008bcbcf2336cb.1204076907@localhost.localdomain> References: <8ef92e008bcbcf2336cb.1204076907@localhost.localdomain> Message-ID: <47C58DC4.3010605@linux.vnet.ibm.com> lizg at cn.ibm.com wrote: > # HG changeset patch > # User Zhengang Li > # Date 1204076903 -28800 > # Node ID 8ef92e008bcbcf2336cbccfa083c2d22f690ca1d > # Parent b2606bc023a8a26ecd25464e976fb16606ed3a47 > [CU] Fix const pointer warning > > Signed-off-by: Zhengang Li > > > Some day, the const keyword and I are gonna sit down and have a long talk. Thanks for catching this. +1 -- -Jay From kaitlin at linux.vnet.ibm.com Wed Feb 27 16:21:40 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 27 Feb 2008 08:21:40 -0800 Subject: [Libvirt-cim] [PATCH 3 of 4] Add MigrationType support to VirtualSystemMigrationService In-Reply-To: <47C55D34.90700@linux.vnet.ibm.com> References: <09153317203d6a60ede3.1204070624@elm3b41.beaverton.ibm.com> <47C55D34.90700@linux.vnet.ibm.com> Message-ID: <47C58E14.3050807@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> @@ -424,25 +448,39 @@ static CMPIStatus migrate_vs(struct migr >> goto out; >> } >> >> - CU_DEBUG("Migrating %s -> %s", job->domain, uri); >> - >> - ddom = virDomainMigrate(dom, dconn, VIR_MIGRATE_LIVE, NULL, >> NULL, 0); >> - if (ddom == NULL) { >> - CU_DEBUG("Migration failed"); >> - cu_statusf(_BROKER, &s, >> - CMPI_RC_ERR_FAILED, >> - "Migration Failed"); >> - goto out; >> - } >> + switch(job->type) { >> + case CIM_MIGRATE_OTHER: >> + /* FIXME - Handle offline migration here */ >> + CU_DEBUG("Preparing for offline migration"); >> + break; >> + case CIM_MIGRATE_LIVE: >> + CU_DEBUG("Preparing for live migration"); >> + s = handle_migrate(dconn, dom, uri, VIR_MIGRATE_LIVE, >> job); >> > Is the type CIM_MIGRATE_LIVE or VIR_MIGRATE_LIVE ? The CIM_MIGRATE_LIVE corresponds to the value defined in the mof, which is 2. However, the value of VIR_MIGRATE_LIVE is defined by libvirt. So when someone specifies a migration type of 2 (CIM_MIGRATE_LIVE) in the MigrationSettingData, we'll need to use VIR_MIGRATE_LIVE when we call virDomainMigrate(). >> + break; >> + case CIM_MIGRATE_RESUME: >> + case CIM_MIGRATE_RESTART: >> + CU_DEBUG("Preparing for static migration"); >> + s = handle_migrate(dconn, dom, uri, 0, job); >> > The type should be CIM_MIGRATE_RESTART For static migration, libvirt uses a value of 0. There's two type values here.. the value set for the MigrationType attribute of MigrationSettingData and the value libvirt uses to differentiate between static and live migration. But it looks like the way I have it coded is confusing. Would the following make more sense: static CMPIStatus handle_migrate(virConnectPtr dconn, virDomainPtr dom, char *uri, int type, struct migration_job *job) { CMPIStatus s = {CMPI_RC_OK, NULL}; virDomainPtr ddom = NULL; CU_DEBUG("Migrating %s -> %s", job->domain, uri); if (type == CIM_MIGRATE_LIVE) ddom = virDomainMigrate(dom, dconn, VIR_MIGRATE_LIVE, NULL, NULL, 0); else if (type == CIM_MIGRATE_RESUME) || (type == CIM_MIGRATE_RESTART) ddom = virDomainMigrate(dom, dconn, 0, NULL, NULL, 0); else //Print error here and return if (ddom == NULL) { CU_DEBUG("Migration failed"); cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Migration Failed"); } virDomainFree(ddom); return s; } And then in migrate_vs() have: switch(job->type) { case CIM_MIGRATE_OTHER: /* FIXME - Handle offline migration here */ CU_DEBUG("Preparing for offline migration"); break; case CIM_MIGRATE_LIVE: case CIM_MIGRATE_RESUME: case CIM_MIGRATE_RESTART: s = handle_migrate(dconn, dom, uri, job->type, job); break; default: CU_DEBUG("Unsupported migration type (%d)", job->type); cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Unsupported migration type (%d)", job->type); goto out; } It is a little more redundant this way, but it might help with readability. >> + break; >> + default: + CU_DEBUG("Unsupported migration >> type (%d)", job->type); >> + cu_statusf(_BROKER, &s, >> + CMPI_RC_ERR_FAILED, >> + "Unsupported migration type (%d)", >> job->type); >> + goto out; >> + } >> + >> + if (s.rc != CMPI_RC_OK) >> + goto out; >> >> > > -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Wed Feb 27 16:23:44 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 27 Feb 2008 08:23:44 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: <87hcfuh13t.fsf@caffeine.beaverton.ibm.com> References: <47C4B923.9010908@linux.vnet.ibm.com> <87hcfuh13t.fsf@caffeine.beaverton.ibm.com> Message-ID: <47C58E90.1090804@linux.vnet.ibm.com> Dan Smith wrote: > KR> We don't use this, which is fine. However, leads to a > KR> question.. why the decision to have do_snapshot() return void? > > Because the status and state information is conveyed through the job. > What else could the caller do with a return value? It's in a thread. > Oh yes, sorry. My mistake. For some reason, I spaced that do_snapshot() was handled in the thread. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Wed Feb 27 15:39:35 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 27 Feb 2008 07:39:35 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: <47C5428D.20309@linux.vnet.ibm.com> (Heidi Eckhart's message of "Wed, 27 Feb 2008 11:59:25 +0100") References: <47C5428D.20309@linux.vnet.ibm.com> Message-ID: <878x16h0i0.fsf@caffeine.beaverton.ibm.com> HE> 2008 ;) Whoops, thanks :) HE> Please can you explain why you set the status here and overwrite HE> it right afterwards ? I think the CIM_JOBSTATE is already COMPLETE HE> here. I wanted this function to serve three roles: save, save-then-restore, and restore. In the save-then-restore scenario, we want a status update after the save is complete, of course. Because I like symmetric code, I added the same sort of status update to the end of restore. In the save-only case, this comes out to setting the save status and then changing it to "complete" right afterwards. I don't know if this is a big deal or not, but I think that the code to make it avoid the extra set would be less pretty. Suggestions are welcome, of course :) HE> FYI - I encountered some problems with another provider, where I HE> tried virDomainFree() with a not initialized dom. This could also HE> happen here with the goto out from conn. Maybe virDomainFree() can HE> not handle NULL ? No, it can handle it just fine. We do this in many, many places elsewhere in the code. I think you might get a warning out of it in some cases, but the code does check for NULL. HE> This step is not necessary as NewObjectPath already sets the HE> namespace. It doesn't for me. If I don't do this, the CBCreateInstance fails with "Target namespace does not exist". We do this in the migration job creation code as well. >> + CMSetNameSpace(op, NAMESPACE(ref)); Er, hmm, maybe it's this one. HE> This should also be not necessary. But as you debug the ref right HE> afterwards ... did you encounter some problems here ? Yes, removing at least one of these results in the behavior described above. I'll revisit and see which is the necessary one. HE> Its more my personal view, but as you "goto out" each time the HE> status is something else than CMPI_RC_OK, it should still be HE> CMPI_RC_OK at this point, if you initialize it right at the HE> beginning of the function with CMPIStatus s = {CMPI_RC_OK, NULL}; HE> . The reason I don't like doing this in all cases is because it's implied success at the bottom of the function, instead of making it explicit. Also, if we are in the habit of doing this, and then have a function where we catch s.rc != CMPI_RC_OK somewhere and take a default value, then we might fall through here and return an error when we don't intend to. However, I've changed it in this case. HE> You could use a CMPIString and return its char* to the HE> caller. This avoids missing frees. But then I have to pass a broker pointer, since this is used outside this file. I'll look to see if it makes sense to do that here or not. HE> You also need to do a CMReturnData for a failed request. Ah, yes, thanks. HE> I miss the instance provider interface. Do you plan to add this ? Yes :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Wed Feb 27 16:44:16 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Wed, 27 Feb 2008 08:44:16 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Add set_int_property() function to EO parse Message-ID: <64e51763141e107bc897.1204130656@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1204130653 28800 # Node ID 64e51763141e107bc89710897ea9dc9c2fc08dbc # Parent e5931f33c94eb4895a359538b53cd1a1d075bb53 [CU] Add set_int_property() function to EO parse. This function attempts to find the appropriate property value type and then sets that property value. This change is needed to properly parse non 64 bit integer. If the property is a uint16 value, and CMPI_uint64 is passed CMSetProperty(), the call will fail. Signed-off-by: Kaitlin Rupert diff -r e5931f33c94e -r 64e51763141e eo_parser.c --- a/eo_parser.c Thu Feb 21 07:44:01 2008 -0800 +++ b/eo_parser.c Wed Feb 27 08:44:13 2008 -0800 @@ -107,6 +107,62 @@ int cu_parse_embedded_instance(const cha } } +static int _set_int_prop(CMPISint64 value, + char *prop, + CMPIType type, + CMPIInstance *inst) +{ + CMPIStatus s; + uint64_t unsigned_val = 0; + int64_t signed_val = 0; + + switch(type) { + case CMPI_uint64: + case CMPI_uint32: + case CMPI_uint16: + case CMPI_uint8: + unsigned_val = value; + s = CMSetProperty(inst, prop, &(unsigned_val), type); + break; + case CMPI_sint64: + case CMPI_sint32: + case CMPI_sint16: + case CMPI_sint8: + default: + signed_val = value; + s = CMSetProperty(inst, prop, &(signed_val), type); + } + + if (s.rc == CMPI_RC_OK) + return 1; + + return 0; +} + +CMPIType set_int_prop(CMPISint64 value, + char *prop, + CMPIInstance *inst) +{ + if (_set_int_prop(value, prop, CMPI_uint64, inst) == 1) + return CMPI_uint64; + else if (_set_int_prop(value, prop, CMPI_uint32, inst) == 1) + return CMPI_uint32; + else if (_set_int_prop(value, prop, CMPI_uint16, inst) == 1) + return CMPI_uint16; + else if (_set_int_prop(value, prop, CMPI_uint8, inst) == 1) + return CMPI_uint8; + else if (_set_int_prop(value, prop, CMPI_sint64, inst) == 1) + return CMPI_sint64; + else if (_set_int_prop(value, prop, CMPI_sint32, inst) == 1) + return CMPI_sint32; + else if (_set_int_prop(value, prop, CMPI_sint16, inst) == 1) + return CMPI_sint16; + else + _set_int_prop(value, prop, CMPI_sint8, inst); + + return CMPI_sint8; +} + /* * Local Variables: * mode: C diff -r e5931f33c94e -r 64e51763141e eo_parser_xml.h --- a/eo_parser_xml.h Thu Feb 21 07:44:01 2008 -0800 +++ b/eo_parser_xml.h Wed Feb 27 08:44:13 2008 -0800 @@ -27,6 +27,10 @@ int cu_parse_ei_xml(const CMPIBroker *br const char *xml, CMPIInstance **instance); +CMPIType set_int_prop(CMPISint64 value, + char *prop, + CMPIInstance *inst); + #endif /* diff -r e5931f33c94e -r 64e51763141e eo_util_parser.y --- a/eo_util_parser.y Thu Feb 21 07:44:01 2008 -0800 +++ b/eo_util_parser.y Wed Feb 27 08:44:13 2008 -0800 @@ -10,9 +10,12 @@ %{ #include #include +#include #include "cmpidt.h" #include "cmpift.h" + +#include "eo_parser_xml.h" /* specify prototypes to get rid of warnings */ int eo_parse_lex (void); @@ -103,12 +106,12 @@ property: PROPERTYNAME '=' STRING ';' | PROPERTYNAME '=' INTEGER ';' { - EOTRACE("propertyname = %s" - "\ttype = CMPI_sint64\n" - "\tvalue = %lld\n", - $1, $3); - unsigned long long value = $3; - CMSetProperty(*_INSTANCE, $1, &(value), CMPI_uint64); + EOTRACE("propertyname = %s\n", $1); + int rc; + //uint64_t value = $3; + CMPIType t = set_int_prop($3, $1, *_INSTANCE); + EOTRACE("\ttype = %d\n" + "\tvalue = %lld\n", t, $3); free($1); } From danms at us.ibm.com Wed Feb 27 21:51:21 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 27 Feb 2008 13:51:21 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] Add VirtualSystemSnapshotCapabilities In-Reply-To: Message-ID: # HG changeset patch # User Dan Smith # Date 1204148971 28800 # Node ID d99c12afe401d8d38ce08ed2ce305bf6766889fe # Parent 40501cb68e8a1e6c7ed6c0f94e96984a9ff50474 Add VirtualSystemSnapshotCapabilities Changes: - Fixed silly compile errors - Expose get_vsss_cap() function Signed-off-by: Dan Smith diff -r 40501cb68e8a -r d99c12afe401 src/Virt_VirtualSystemSnapshotServiceCapabilities.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemSnapshotServiceCapabilities.c Wed Feb 27 13:49:31 2008 -0800 @@ -0,0 +1,205 @@ +/* + * Copyright IBM Corp. 2008 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include + +#include + +#include "misc_util.h" + +#include +#include +#include + +#include +#include + +#include "Virt_VirtualSystemSnapshotService.h" +#include "Virt_VirtualSystemSnapshotServiceCapabilities.h" + +const static CMPIBroker *_BROKER; + +enum { CREATE_SNAPSHOT = 2, + DESTROY_SNAPSHOT, + APPLY_SNAPSHOT, +}; + +static CMPIStatus set_inst_properties(const CMPIBroker *broker, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIArray *array; + uint16_t element; + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)"SnapshotCapabilities", CMPI_chars); + + array = CMNewArray(broker, 2, CMPI_uint16, &s); + if ((s.rc != CMPI_RC_OK) || (array == NULL)) + goto out; + + element = (uint16_t)CREATE_SNAPSHOT; + CMSetArrayElementAt(array, 0, &element, CMPI_uint16); + + element = (uint16_t)APPLY_SNAPSHOT; + CMSetArrayElementAt(array, 1, &element, CMPI_uint16); + + CMSetProperty(inst, "AsynchronousMethodsSupported", + (CMPIValue *)&array, CMPI_uint16A); + + array = CMNewArray(broker, 1, CMPI_uint16, &s); + if ((s.rc != CMPI_RC_OK) || (array == NULL)) + goto out; + + element = (uint16_t)DESTROY_SNAPSHOT; + CMSetArrayElementAt(array, 0, &element, CMPI_uint16); + + CMSetProperty(inst, "SynchronousMethodsSupported", + (CMPIValue *)&array, CMPI_uint16A); + + array = CMNewArray(broker, 2, CMPI_uint16, &s); + if ((s.rc != CMPI_RC_OK) || (array == NULL)) + goto out; + + element = (uint16_t)VIR_VSSS_SNAPSHOT_MEM; + CMSetArrayElementAt(array, 0, &element, CMPI_uint16); + + element = (uint16_t)VIR_VSSS_SNAPSHOT_MEMT; + CMSetArrayElementAt(array, 1, &element, CMPI_uint16); + + CMSetProperty(inst, "SnapshotTypesSupported", + (CMPIValue *)&array, CMPI_uint16A); + + out: + return s; +} + +CMPIStatus get_vss_cap(const CMPIBroker *broker, + const CMPIObjectPath *ref, + CMPIInstance **_inst, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "VirtualSystemSnapshotServiceCapabilities", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Can't create instance for %s", CLASSNAME(ref)); + goto out; + } + + s = set_inst_properties(broker, inst); + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_vss_cap(const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_vss_cap(_BROKER, ref, &inst, is_get_inst); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + goto out; + + if (names_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + out: + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference) +{ + return return_vss_cap(reference, results, true, false); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + + return return_vss_cap(reference, results, false, false); +} + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + return return_vss_cap(reference, results, false, true); +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, + Virt_VirtualSystemSnapshotServiceCapabilities, + _BROKER, + libvirt_cim_init()); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From danms at us.ibm.com Wed Feb 27 21:51:20 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 27 Feb 2008 13:51:20 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: Message-ID: <40501cb68e8a1e6c7ed6.1204149080@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1204148970 28800 # Node ID 40501cb68e8a1e6c7ed6c0f94e96984a9ff50474 # Parent 12d65b8acee40a7b4144dd5dea3fa9fe70fbb8f3 Add VirtualSystemSnapshotService Changes: - Added header block - Added return values for methods - Fixed silly compile errors - Added instance functions Signed-off-by: Dan Smith diff -r 12d65b8acee4 -r 40501cb68e8a src/Virt_VirtualSystemSnapshotService.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemSnapshotService.c Wed Feb 27 13:49:30 2008 -0800 @@ -0,0 +1,715 @@ +/* + * Copyright IBM Corp. 2008 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include "misc_util.h" + +#include "Virt_VirtualSystemSnapshotService.h" +#include "Virt_HostSystem.h" + +#define CIM_JOBSTATE_STARTING 3 +#define CIM_JOBSTATE_RUNNING 4 +#define CIM_JOBSTATE_COMPLETE 7 + +#define CIM_RETURN_COMPLETED 0 +#define CIM_RETURN_FAILED 2 + +static const CMPIBroker *_BROKER; + +struct snap_context { + CMPIContext *context; + char *domain; + char uuid[33]; + char *save_path; + char *ref_ns; + char *ref_cn; + + bool save; + bool restore; +}; + +static void snap_job_free(struct snap_context *ctx) +{ + free(ctx->domain); + free(ctx->save_path); + free(ctx->ref_ns); + free(ctx->ref_cn); + free(ctx); +} + +static void _snap_job_set_status(struct snap_context *ctx, + uint16_t state, + const char *status, + uint16_t errcode, + const char *errdesc) +{ + CMPIInstance *inst; + CMPIStatus s; + CMPIObjectPath *op; + char *desc = NULL; + int ret; + + op = CMNewObjectPath(_BROKER, + ctx->ref_ns, + "CIM_ConcreteJob", + &s); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Failed to create job path for update"); + return; + } + + CMAddKey(op, "InstanceID", (CMPIValue *)ctx->uuid, CMPI_chars); + + inst = CBGetInstance(_BROKER, ctx->context, op, NULL, &s); + if ((inst == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to get job instance for update of %s", + ctx->uuid); + return; + } + + CMSetProperty(inst, "JobState", + (CMPIValue *)&state, CMPI_uint16); + CMSetProperty(inst, "Status", + (CMPIValue *)status, CMPI_chars); + + ret = asprintf(&desc, + "%s of %s (%s)", + ctx->save ? "Snapshot" : "Restore", + ctx->domain, + ctx->save_path); + if (ret != -1) { + CMSetProperty(inst, "Description", + (CMPIValue *)desc, CMPI_chars); + free(desc); + } + + if ((errcode != 0) && (errdesc != NULL)) { + CMSetProperty(inst, "ErrorCode", + (CMPIValue *)&errcode, CMPI_uint16); + CMSetProperty(inst, "ErrorDescription", + (CMPIValue *)errdesc, CMPI_chars); + + CU_DEBUG("Set error properties to %i:%s", + errcode, + errdesc); + } + + s = CBModifyInstance(_BROKER, ctx->context, op, inst, NULL); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Failed to update job instance %s: %s", + ctx->uuid, + CMGetCharPtr(s.msg)); + return; + } + + CU_DEBUG("Set %s status to %i:%s", ctx->uuid, state, status); +} + +static void snap_job_set_status(struct snap_context *ctx, + uint16_t state, + const char *status) +{ + _snap_job_set_status(ctx, state, status, 0, NULL); +} + +static void snap_job_set_failed(struct snap_context *ctx, + uint16_t errcode, + const char *errdesc) +{ + _snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Failed", + errcode, + errdesc); +} + +static void do_snapshot(struct snap_context *ctx, + virConnectPtr conn, + virDomainPtr dom) +{ + int ret; + + if (ctx->save) { + CU_DEBUG("Starting save to %s", ctx->save_path); + + ret = virDomainSave(dom, ctx->save_path); + if (ret == -1) { + CU_DEBUG("Save failed"); + snap_job_set_failed(ctx, + VIR_VSSS_ERR_SAVE_FAILED, + "Save failed"); + return; + } + + CU_DEBUG("Save completed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_RUNNING, + "Save finished"); + } + + if (ctx->restore) { + CU_DEBUG("Starting restore from %s", ctx->save_path); + + ret = virDomainRestore(conn, ctx->save_path); + if (ret == -1) { + CU_DEBUG("Restore failed"); + snap_job_set_failed(ctx, + VIR_VSSS_ERR_REST_FAILED, + "Restore failed"); + return; + } + + CU_DEBUG("Restore completed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_RUNNING, + "Restore finished"); + } + + CU_DEBUG("Snapshot (%s/%s) completed", + ctx->save ? "Save" : "None", + ctx->restore ? "Restore" : "None"); + + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Snapshot complete"); + + return; +} + +static CMPI_THREAD_RETURN snapshot_thread(struct snap_context *ctx) +{ + CMPIStatus s; + virConnectPtr conn = NULL; + virDomainPtr dom = NULL; + + CU_DEBUG("Snapshot thread alive"); + + CBAttachThread(_BROKER, ctx->context); + + snap_job_set_status(ctx, CIM_JOBSTATE_RUNNING, "Running"); + + conn = connect_by_classname(_BROKER, ctx->ref_cn, &s); + if (conn == NULL) { + CU_DEBUG("Failed to connect with classname `%s'", ctx->ref_cn); + snap_job_set_failed(ctx, + VIR_VSSS_ERR_CONN_FAILED, + "Unable to connect to hypervisor"); + goto out; + } + + dom = virDomainLookupByName(conn, ctx->domain); + if (dom == NULL) { + CU_DEBUG("No such domain `%s'", ctx->domain); + snap_job_set_failed(ctx, + VIR_VSSS_ERR_NO_SUCH_DOMAIN, + "No such domain"); + goto out; + } + + do_snapshot(ctx, conn, dom); + + out: + virDomainFree(dom); + virConnectClose(conn); + + snap_job_free(ctx); + + return NULL; +} + +static CMPIStatus create_job(const CMPIContext *context, + const CMPIObjectPath *ref, + struct snap_context *ctx, + CMPIObjectPath **job) +{ + CMPIObjectPath *op; + CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + op = CMNewObjectPath(_BROKER, + NAMESPACE(ref), + "CIM_ConcreteJob", /*FIXME*/ + &s); + if ((s.rc != CMPI_RC_OK) || (op == NULL)) { + CU_DEBUG("Failed to create job path"); + goto out; + } + + CMSetNameSpace(op, NAMESPACE(ref)); + + inst = CMNewInstance(_BROKER, op, &s); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) { + CU_DEBUG("Failed to create job instance"); + goto out; + } + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)ctx->uuid, CMPI_chars); + + CMSetProperty(inst, "Name", + (CMPIValue *)"Snapshot", CMPI_chars); + + CMSetProperty(inst, "Status", + (CMPIValue *)"Queued", CMPI_chars); + + op = CMGetObjectPath(inst, &s); + if ((op == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to get path of job instance"); + goto out; + } + + CMSetNameSpace(op, NAMESPACE(ref)); + + CU_DEBUG("ref was %s", CMGetCharPtr(CMObjectPathToString(op, NULL))); + + *job = CBCreateInstance(_BROKER, context, op, inst, &s); + if ((*job == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to create job"); + goto out; + } + + ctx->ref_ns = strdup(NAMESPACE(ref)); + ctx->ref_cn = strdup(CLASSNAME(ref)); + + ctx->context = CBPrepareAttachThread(_BROKER, context); + + _BROKER->xft->newThread((void *)snapshot_thread, ctx, 0); + out: + return s; +} + +char *vsss_get_save_path(const char *domname) +{ + int ret; + char *path = NULL; + + ret = asprintf(&path, + "/var/lib/libvirt/%s.save", domname); + if (ret == -1) + return NULL; + + return path; +} + +static struct snap_context *new_context(const char *name, + CMPIStatus *s) +{ + struct snap_context *ctx; + uuid_t uuid; + + ctx = calloc(1, sizeof(*ctx)); + if (ctx == NULL) { + CU_DEBUG("Failed to alloc snapshot context"); + goto out; + } + + ctx->domain = strdup(name); + + uuid_generate(uuid); + uuid_unparse(uuid, ctx->uuid); + + ctx->save_path = vsss_get_save_path(ctx->domain); + if (ctx->save_path == NULL) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Unable to get save_path"); + goto out; + } + + cu_statusf(_BROKER, s, + CMPI_RC_OK, + ""); + out: + if (s->rc != CMPI_RC_OK) { + snap_job_free(ctx); + ctx = NULL; + } + + return ctx; +} + +static CMPIStatus start_snapshot_job(const CMPIObjectPath *ref, + const CMPIContext *context, + const char *name, + uint16_t type) +{ + struct snap_context *ctx; + CMPIStatus s; + CMPIObjectPath *job; + + ctx = new_context(name, &s); + if (ctx == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to create snapshot context"); + goto out; + } + + ctx->save = (type != 0); + ctx->restore = (type != VIR_VSSS_SNAPSHOT_MEM); + + s = create_job(context, ref, ctx, &job); + + out: + return s; +} + +static CMPIStatus create_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *system; + CMPIInstance *sd; + uint16_t type; + uint32_t retcode = CIM_RETURN_FAILED; + const char *name; + + if (cu_get_u16_arg(argsin, "SnapshotType", &type) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing SnapshotType"); + goto out; + } + + if ((type != VIR_VSSS_SNAPSHOT_MEM) && + (type != VIR_VSSS_SNAPSHOT_MEMT)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_SUPPORTED, + "Only memory(%i,%i) snapshots are supported", + VIR_VSSS_SNAPSHOT_MEM, + VIR_VSSS_SNAPSHOT_MEMT); + goto out; + } + + if (cu_get_ref_arg(argsin, "AffectedSystem", &system) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing AffectedSystem"); + goto out; + } + + if (cu_get_inst_arg(argsin, "SnapshotSettings", &sd) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing SnapshotSettings"); + goto out; + } + + if (cu_get_str_path(system, "Name", &name) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Name property of AffectedSystem"); + goto out; + } + + s = start_snapshot_job(reference, context, name, type); + + retcode = CIM_RETURN_COMPLETED; + out: + CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); + + return s; +} + +static CMPIStatus destroy_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *snap; + char *name = NULL; + char *path = NULL; + uint32_t retcode = CIM_RETURN_FAILED; + + if (cu_get_ref_arg(argsin, "AffectedSnapshot", &snap) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Snapshot"); + goto out; + } + + if (!parse_instanceid(snap, NULL, &name)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Invalid InstanceID in Snapshot"); + goto out; + } + + path = vsss_get_save_path(name); + if (path == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get save_path"); + goto out; + } + + if (unlink(path) == -1) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to remove snapshot: %s", path); + } + + retcode = CIM_RETURN_COMPLETED; + out: + CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); + + free(path); + free(name); + + return s; +} + +static CMPIStatus apply_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *snap; + char *name = NULL; + uint32_t retcode = CIM_RETURN_FAILED; + + if (cu_get_ref_arg(argsin, "AffectedSnapshot", &snap) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Snapshot"); + goto out; + } + + if (!parse_instanceid(snap, NULL, &name)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Invalid InstanceID in Snapshot"); + goto out; + } + + s = start_snapshot_job(reference, context, name, 0); + + retcode = CIM_RETURN_COMPLETED; + + out: + CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); + + free(name); + + return s; +} + +static struct method_handler CreateSnapshot = { + .name = "CreateSnapshot", + .handler = create_snapshot, + .args = {{"AffectedSystem", CMPI_ref, false}, + {"SnapshotSettings", CMPI_instance, false}, + {"SnapshotType", CMPI_uint16, false}, + ARG_END} +}; + +static struct method_handler DestroySnapshot = { + .name = "DestroySnapshot", + .handler = destroy_snapshot, + .args = {{"AffectedSnapshot", CMPI_ref, false}, + ARG_END} +}; + +static struct method_handler ApplySnapshot = { + .name = "ApplySnapshot", + .handler = apply_snapshot, + .args = {{"AffectedSnapshot", CMPI_ref, false}, + ARG_END} +}; + +static struct method_handler *handlers[] = { + &CreateSnapshot, + &DestroySnapshot, + &ApplySnapshot, + NULL +}; + +STDIM_MethodMIStub(, Virt_VirtualSystemSnapshotService, + _BROKER, libvirt_cim_init(), handlers); + +static CMPIStatus set_inst_properties(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + const char *name; + const char *ccname; + + s = get_host_system_properties(&name, + &ccname, + reference, + broker); + if (s.rc != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get host attributes"); + goto out; + } + + CMSetProperty(inst, "Name", + (CMPIValue *)"SnapshotService", CMPI_chars); + + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); + + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)ccname, CMPI_chars); + + out: + return s; +} + +CMPIStatus get_vsss(const CMPIBroker *broker, + const CMPIObjectPath *ref, + CMPIInstance **_inst, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "VirtualSystemSnapshotService", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Can't create instance for %s", CLASSNAME(ref)); + goto out; + } + + s = set_inst_properties(broker, ref, inst); + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_vsss(const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_vsss(_BROKER, ref, &inst, is_get_inst); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + goto out; + + if (names_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + out: + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference) +{ + return return_vsss(reference, results, true, false); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + + return return_vsss(reference, results, false, false); +} + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + return return_vsss(reference, results, false, true); +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, + Virt_VirtualSystemSnapshotService, + _BROKER, + libvirt_cim_init()); + + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff -r 12d65b8acee4 -r 40501cb68e8a src/Virt_VirtualSystemSnapshotService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemSnapshotService.h Wed Feb 27 13:49:30 2008 -0800 @@ -0,0 +1,52 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Returns a malloc()'d string; caller must free() */ +char *vsss_get_save_path(const char *domname); + +CMPIStatus get_vsss(const CMPIBroker *broker, + const CMPIObjectPath *ref, + CMPIInstance **_inst, + bool is_get_inst); + +#define CIM_VSSS_SNAPSHOT_FULL 2 +#define CIM_VSSS_SNAPSHOT_DISK 3 + +/* VIR_VSSS_SNAPSHOT_MEM - Attempt to save/restore to create a running snap + * VIR_VSSS_SNAPSHOT_MEMT - Just save and let the domain be "off" + */ +#define VIR_VSSS_SNAPSHOT_MEM 32768 +#define VIR_VSSS_SNAPSHOT_MEMT 32769 + +#define VIR_VSSS_ERR_SAVE_FAILED 1 +#define VIR_VSSS_ERR_REST_FAILED 2 +#define VIR_VSSS_ERR_CONN_FAILED 3 +#define VIR_VSSS_ERR_NO_SUCH_DOMAIN 4 + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From danms at us.ibm.com Wed Feb 27 21:51:19 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 27 Feb 2008 13:51:19 -0800 Subject: [Libvirt-cim] [PATCH 0 of 3] (#3) Add VirtualSystemSnapshotService Message-ID: Okay, lets try this again. I think I addressed all the issues, as well as added the instance functions to the service. Changes outlined per patch. From danms at us.ibm.com Wed Feb 27 21:51:22 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 27 Feb 2008 13:51:22 -0800 Subject: [Libvirt-cim] [PATCH 3 of 3] Add VirtualSystemSnapshotService{, Capabilities} build support In-Reply-To: Message-ID: <224ad7217cef6235bccb.1204149082@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1204148971 28800 # Node ID 224ad7217cef6235bccb3377b9b86114ed61d6ae # Parent d99c12afe401d8d38ce08ed2ce305bf6766889fe Add VirtualSystemSnapshotService{,Capabilities} build support Changes: - Added HostSystem provider lib to VSSS for instance functions Signed-off-by: Dan Smith diff -r d99c12afe401 -r 224ad7217cef Makefile.am --- a/Makefile.am Wed Feb 27 13:49:31 2008 -0800 +++ b/Makefile.am Wed Feb 27 13:49:31 2008 -0800 @@ -37,7 +37,9 @@ MOFS = \ schema/ElementSettingData.mof \ schema/VSMigrationCapabilities.mof \ schema/VSMigrationService.mof \ - schema/VSMigrationSettingData.mof + schema/VSMigrationSettingData.mof \ + schema/VirtualSystemSnapshotService.mof \ + schema/VirtualSystemSnapshotServiceCapabilities.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -81,7 +83,9 @@ REGS = \ schema/VSMigrationCapabilities.registration \ schema/VSMigrationService.registration \ schema/ElementConformsToProfile.registration \ - schema/VSMigrationSettingData.registration + schema/VSMigrationSettingData.registration \ + schema/VirtualSystemSnapshotService.registration \ + schema/VirtualSystemSnapshotServiceCapabilities.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ diff -r d99c12afe401 -r 224ad7217cef schema/VirtualSystemSnapshotService.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotService.mof Wed Feb 27 13:49:31 2008 -0800 @@ -0,0 +1,7 @@ +// Copyright IBM Corp. 2008 + +[Description ( "Snapshot types are as follows: " + "32768: Memory-only snapshot (suspend, resume, keep image)" + "32769: Memory-only, terminal (domain is offline after op)")] +class Xen_VirtualSystemSnapshotService : CIM_VirtualSystemSnapshotService { }; +class KVM_VirtualSystemSnapshotService : CIM_VirtualSystemSnapshotService { }; diff -r d99c12afe401 -r 224ad7217cef schema/VirtualSystemSnapshotService.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotService.registration Wed Feb 27 13:49:31 2008 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemSnapshotService root/virt Virt_VirtualSystemSnapshotService Virt_VirtualSystemSnapshotService method instance +KVM_VirtualSystemSnapshotService root/virt Virt_VirtualSystemSnapshotService Virt_VirtualSystemSnapshotService method instance diff -r d99c12afe401 -r 224ad7217cef schema/VirtualSystemSnapshotServiceCapabilities.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotServiceCapabilities.mof Wed Feb 27 13:49:31 2008 -0800 @@ -0,0 +1,4 @@ +// Copyright IBM Corp. 2008 + +class Xen_VirtualSystemSnapshotServiceCapabilities : CIM_VirtualSystemSnapshotServiceCapabilities {}; +class KVM_VirtualSystemSnapshotServiceCapabilities : CIM_VirtualSystemSnapshotServiceCapabilities {}; diff -r d99c12afe401 -r 224ad7217cef schema/VirtualSystemSnapshotServiceCapabilities.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotServiceCapabilities.registration Wed Feb 27 13:49:31 2008 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemSnapshotServiceCapabilities root/virt Virt_VirtualSystemSnapshotServiceCapabilities Virt_VirtualSystemSnapshotServiceCapabilities instance +KVM_VirtualSystemSnapshotServiceCapabilities root/virt Virt_VirtualSystemSnapshotServiceCapabilities Virt_VirtualSystemSnapshotServiceCapabilities instance diff -r d99c12afe401 -r 224ad7217cef src/Makefile.am --- a/src/Makefile.am Wed Feb 27 13:49:31 2008 -0800 +++ b/src/Makefile.am Wed Feb 27 13:49:31 2008 -0800 @@ -17,7 +17,9 @@ noinst_HEADERS = profiles.h svpc_types.h Virt_VSSD.h \ Virt_VSMigrationCapabilities.h \ Virt_VSMigrationService.h \ - Virt_AllocationCapabilities.h + Virt_AllocationCapabilities.h \ + Virt_VirtualSystemSnapshotService.h \ + Virt_VirtualSystemSnapshotServiceCapabilities.h XKUADD = $(top_builddir)/libxkutil/libxkutil.la @@ -56,7 +58,9 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_ElementSettingData.la \ libVirt_VSMigrationCapabilities.la \ libVirt_VSMigrationService.la \ - libVirt_VSMigrationSettingData.la + libVirt_VSMigrationSettingData.la \ + libVirt_VirtualSystemSnapshotService.la \ + libVirt_VirtualSystemSnapshotServiceCapabilities.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -161,3 +165,10 @@ libVirt_VSMigrationService_la_LIBADD = - libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c +libVirt_VirtualSystemSnapshotService_la_DEPENDENCIES = libVirt_HostSystem.la +libVirt_VirtualSystemSnapshotService_la_SOURCES = Virt_VirtualSystemSnapshotService.c +libVirt_VirtualSystemSnapshotService_la_LIBADD = -lVirt_HostSystem + +libVirt_VirtualSystemSnapshotServiceCapabilities_la_DEPENDENCIES = +libVirt_VirtualSystemSnapshotServiceCapabilities_la_SOURCES = Virt_VirtualSystemSnapshotServiceCapabilities.c +libVirt_VirtualSystemSnapshotServiceCapabilities_la_LIBADD = From danms at us.ibm.com Wed Feb 27 22:09:19 2008 From: danms at us.ibm.com (Dan Smith) Date: Wed, 27 Feb 2008 14:09:19 -0800 Subject: [Libvirt-cim] [PATCH] Add TypesSupported[] to VirtualSystemManagementCapabilities Message-ID: <534a933e0202dc425f3f.1204150159@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1204150157 28800 # Node ID 534a933e0202dc425f3f27ba55dfa42e7c42db5f # Parent 224ad7217cef6235bccb3377b9b86114ed61d6ae Add TypesSupported[] to VirtualSystemManagementCapabilities Signed-off-by: Dan Smith diff -r 224ad7217cef -r 534a933e0202 src/Virt_VirtualSystemManagementCapabilities.c --- a/src/Virt_VirtualSystemManagementCapabilities.c Wed Feb 27 13:49:31 2008 -0800 +++ b/src/Virt_VirtualSystemManagementCapabilities.c Wed Feb 27 14:09:17 2008 -0800 @@ -46,11 +46,14 @@ enum {ADD_RESOURCES = 1, static CMPIStatus set_inst_properties(const CMPIBroker *broker, + const CMPIObjectPath *ref, CMPIInstance *inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIArray *array; uint16_t element; + char *prefix = NULL; + CMPIString *str; CMSetProperty(inst, "InstanceID", (CMPIValue *)"ManagementCapabilities", CMPI_chars); @@ -73,7 +76,29 @@ static CMPIStatus set_inst_properties(co CMSetProperty(inst, "SynchronousMethodsSupported", (CMPIValue *)&array, CMPI_uint16A); - out: + + prefix = class_prefix_name(CLASSNAME(ref)); + if (prefix == NULL) { + CU_DEBUG("Prefix of %s was NULL", CLASSNAME(ref)); + goto out; + } + + str = CMNewString(broker, prefix, &s); + if ((str == NULL) || (s.rc != CMPI_RC_OK)) + goto out; + + array = CMNewArray(broker, 1, CMPI_string, &s); + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(array))) + goto out; + + CMSetArrayElementAt(array, 0, (CMPIValue *)&str, CMPI_string); + + CMSetProperty(inst, "TypesSupported", + (CMPIValue *)&array, CMPI_charsA); + + out: + free(prefix); + return s; } @@ -106,7 +131,7 @@ CMPIStatus get_vsm_cap(const CMPIBroker goto out; } - s = set_inst_properties(broker, inst); + s = set_inst_properties(broker, ref, inst); if (is_get_inst) { s = cu_validate_ref(broker, ref, inst); From heidieck at linux.vnet.ibm.com Thu Feb 28 08:22:04 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 28 Feb 2008 09:22:04 +0100 Subject: [Libvirt-cim] [PATCH 3 of 4] Add MigrationType support to VirtualSystemMigrationService In-Reply-To: <47C58E14.3050807@linux.vnet.ibm.com> References: <09153317203d6a60ede3.1204070624@elm3b41.beaverton.ibm.com> <47C55D34.90700@linux.vnet.ibm.com> <47C58E14.3050807@linux.vnet.ibm.com> Message-ID: <47C66F2C.9050202@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Heidi Eckhart wrote: >> Is the type CIM_MIGRATE_LIVE or VIR_MIGRATE_LIVE ? > The CIM_MIGRATE_LIVE corresponds to the value defined in the mof, > which is 2. However, the value of VIR_MIGRATE_LIVE is defined by > libvirt. > > So when someone specifies a migration type of 2 (CIM_MIGRATE_LIVE) in > the MigrationSettingData, we'll need to use VIR_MIGRATE_LIVE when we > call virDomainMigrate(). Thanks for this explanation. > > For static migration, libvirt uses a value of 0. There's two type > values here.. the value set for the MigrationType attribute of > MigrationSettingData and the value libvirt uses to differentiate > between static and live migration. ... > It is a little more redundant this way, but it might help with > readability. Thank you for this very good explanation. This makes now much more sense to me :). But I think recoding as you suggested is not necessary, as it would bring too much redundancy (as you already said) into the code. Now that I understood it, I'm absolutely fine with it. Its not very consistent that libvirt uses VIR_MIGRATE_LIVE and 0 (instead of VIR_MIGRATE_STATIC or something else) as values, but that's something we seem to live with. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Thu Feb 28 08:23:34 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 28 Feb 2008 09:23:34 +0100 Subject: [Libvirt-cim] [PATCH 2 of 4] Add migration types to VSMigrationSettingData.h In-Reply-To: <47C58BA1.5070104@linux.vnet.ibm.com> References: <47C54DD8.9090305@linux.vnet.ibm.com> <47C58BA1.5070104@linux.vnet.ibm.com> Message-ID: <47C66F86.3030604@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Heidi Eckhart wrote: >> What is now correct ? MIGRATE_LIVE 2 or 3 ? >> > I had a mistake earlier on, MIGRATE_LIVE is 2. Here's the relevant > part from the mof: > > ValueMap {"0","1","2","3","4"}, > Values { "Unknown", "Other", "Live", "Resume", "Restart" }] > uint16 MigrationType; > > Ok, thanks :) -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Thu Feb 28 11:27:27 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 28 Feb 2008 12:27:27 +0100 Subject: [Libvirt-cim] [PATCH 2 of 3] Add VirtualSystemSnapshotCapabilities In-Reply-To: References: Message-ID: <47C69A9F.7070905@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1204148971 28800 > # Node ID d99c12afe401d8d38ce08ed2ce305bf6766889fe > # Parent 40501cb68e8a1e6c7ed6c0f94e96984a9ff50474 > Add VirtualSystemSnapshotCapabilities > > Changes: > - Fixed silly compile errors > - Expose get_vsss_cap() function > > Signed-off-by: Dan Smith > The patch does not include the header file, which breaks the build. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Thu Feb 28 12:03:03 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 28 Feb 2008 13:03:03 +0100 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: <878x16h0i0.fsf@caffeine.beaverton.ibm.com> References: <47C5428D.20309@linux.vnet.ibm.com> <878x16h0i0.fsf@caffeine.beaverton.ibm.com> Message-ID: <47C6A2F7.2050708@linux.vnet.ibm.com> Dan Smith wrote: > HE> Please can you explain why you set the status here and overwrite > HE> it right afterwards ? I think the CIM_JOBSTATE is already COMPLETE > HE> here. > > I wanted this function to serve three roles: save, save-then-restore, > and restore. In the save-then-restore scenario, we want a status > update after the save is complete, of course. Ok, thanks - makes sense now for me. > Because I like > symmetric code, I added the same sort of status update to the end of > restore. In the save-only case, this comes out to setting the save > status and then changing it to "complete" right afterwards. > > I don't know if this is a big deal or not, but I think that the code > to make it avoid the extra set would be less pretty. Suggestions are > welcome, of course :) > Well, I have no suggestion to reorder the code - as it would end up in less pretty code (as you already said). But maybe a little description to do_snapshot() would help to understand it better. > > ... > Yes, removing at least one of these results in the behavior described > above. I'll revisit and see which is the necessary one. > Please check if the CMPIInstance contains the namespace information. I guess this will be the leak. > ... > > HE> You could use a CMPIString and return its char* to the > HE> caller. This avoids missing frees. > > But then I have to pass a broker pointer, since this is used outside > this file. I'll look to see if it makes sense to do that here or > not. > Oh yes, I forgot about that. Mhh, then it might be better to not use CMPIString, as this would also break the common look and feel with similar functions in libvirt-cim. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Thu Feb 28 12:17:26 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 28 Feb 2008 13:17:26 +0100 Subject: [Libvirt-cim] [PATCH 0 of 4] Update VSMigrationService to support static and offline migration In-Reply-To: References: Message-ID: <47C6A656.1010105@linux.vnet.ibm.com> Kaitlin Rupert wrote: > This patchset updates VSMigrationService so that it reads the MigrationType attribute from MigrationSettingData and then launches the appropriate migration method. > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > I run into problems with KVM (output with sfcbd): std_invokemethod.c(303): Executing handler for method `CheckVirtualSystemIsMigratableToSystem' misc_util.c(70): Connecting to libvirt with uri `qemu:///system' ssh: kvm2-f8: Name or service not known libvir: Remote error : Connection reset by peer Virt_VSMigrationService.c(164): Failed to connect to remote host (qemu+ssh://kvm2-f8/system) std_invokemethod.c(305): Method `CheckVirtualSystemIsMigratableToSystem' returned 1 Attached is the XML request submitted via wbemexec. Do you know what I'm doing wrong ? thanks -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor -------------- next part -------------- A non-text attachment was scrubbed... Name: migrate-MigrateVirtualSystemToSystem.xml Type: text/xml Size: 2041 bytes Desc: not available URL: From heidieck at linux.vnet.ibm.com Thu Feb 28 12:34:59 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Thu, 28 Feb 2008 13:34:59 +0100 Subject: [Libvirt-cim] [PATCH] RegisteredProfile: add keys parameter to SetPropertyFilter Message-ID: <50d2575dd541ec7d578e.1204202099@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1204201511 -3600 # Node ID 50d2575dd541ec7d578e491e5bfdc710f72408f0 # Parent deae8f1fa76ab1e1fa785495be4944e0fc4e16d7 RegisteredProfile: add keys parameter to SetPropertyFilter This is necessary to avoid error returns. Signed-off-by: Heidi Eckhart diff -r deae8f1fa76a -r 50d2575dd541 src/Virt_RegisteredProfile.c --- a/src/Virt_RegisteredProfile.c Wed Feb 27 13:49:31 2008 -0800 +++ b/src/Virt_RegisteredProfile.c Thu Feb 28 13:25:11 2008 +0100 @@ -62,7 +62,8 @@ CMPIInstance *reg_prof_instance(const CM } if (properties) { - s = CMSetPropertyFilter(instance, properties, NULL); + const char *keys[] = {"InstanceID", NULL}; + s = CMSetPropertyFilter(instance, properties, keys); if (s.rc != CMPI_RC_OK) { goto out; } From danms at us.ibm.com Thu Feb 28 15:13:38 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 07:13:38 -0800 Subject: [Libvirt-cim] [PATCH 3 of 4] Add MigrationType support to VirtualSystemMigrationService In-Reply-To: <47C66F2C.9050202@linux.vnet.ibm.com> (Heidi Eckhart's message of "Thu, 28 Feb 2008 09:22:04 +0100") References: <09153317203d6a60ede3.1204070624@elm3b41.beaverton.ibm.com> <47C55D34.90700@linux.vnet.ibm.com> <47C58E14.3050807@linux.vnet.ibm.com> <47C66F2C.9050202@linux.vnet.ibm.com> Message-ID: <87ejaxdsgt.fsf@caffeine.beaverton.ibm.com> HE> Its not very consistent that libvirt uses VIR_MIGRATE_LIVE and 0 HE> (instead of VIR_MIGRATE_STATIC or something else) as values, but HE> that's something we seem to live with. The reason for this is that it's not a "type" parameter, but a "flags" parameter. Static migration is considered the default, with Live being an option. You could potentially also have a flag like VIR_MIGRATE_SECURE, which would give you the following two combinations: VIR_MIGRATE_SECURE -- Static, secure migration VIR_MIGRATE_SECURE | VIR_MIGRATE_LIVE -- Live, secure migration Make sense? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Thu Feb 28 15:16:08 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 07:16:08 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] Add VirtualSystemSnapshotCapabilities In-Reply-To: <47C69A9F.7070905@linux.vnet.ibm.com> (Heidi Eckhart's message of "Thu, 28 Feb 2008 12:27:27 +0100") References: <47C69A9F.7070905@linux.vnet.ibm.com> Message-ID: <87ablldscn.fsf@caffeine.beaverton.ibm.com> HE> The patch does not include the header file, which breaks the HE> build. Weird. I specifically went back to add the header right before I sent it out because the diffstat didn't look right. I'll send the set again and see if it goes this time... -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Thu Feb 28 15:18:18 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 07:18:18 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: <47C6A2F7.2050708@linux.vnet.ibm.com> (Heidi Eckhart's message of "Thu, 28 Feb 2008 13:03:03 +0100") References: <47C5428D.20309@linux.vnet.ibm.com> <878x16h0i0.fsf@caffeine.beaverton.ibm.com> <47C6A2F7.2050708@linux.vnet.ibm.com> Message-ID: <8763w9ds91.fsf@caffeine.beaverton.ibm.com> HE> Please check if the CMPIInstance contains the namespace HE> information. I guess this will be the leak. Yes, I forgot to check this, so I'll do it before I re-send. HE> Oh yes, I forgot about that. Mhh, then it might be better to not HE> use CMPIString, as this would also break the common look and feel HE> with similar functions in libvirt-cim. I meant to mention that I checked into this and remembered why I did it. If we create a thread and pass in broker memory, then the memory gets free()'d when the current operation returns, which means the thread starts working, but later has a pointer to free()'d memory and crashes. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Thu Feb 28 16:02:56 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 08:02:56 -0800 Subject: [Libvirt-cim] [PATCH 3 of 4] Add MigrationType support to VirtualSystemMigrationService In-Reply-To: <47C66F2C.9050202@linux.vnet.ibm.com> References: <09153317203d6a60ede3.1204070624@elm3b41.beaverton.ibm.com> <47C55D34.90700@linux.vnet.ibm.com> <47C58E14.3050807@linux.vnet.ibm.com> <47C66F2C.9050202@linux.vnet.ibm.com> Message-ID: <47C6DB30.20904@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> Heidi Eckhart wrote: >>> Is the type CIM_MIGRATE_LIVE or VIR_MIGRATE_LIVE ? >> The CIM_MIGRATE_LIVE corresponds to the value defined in the mof, >> which is 2. However, the value of VIR_MIGRATE_LIVE is defined by >> libvirt. >> >> So when someone specifies a migration type of 2 (CIM_MIGRATE_LIVE) in >> the MigrationSettingData, we'll need to use VIR_MIGRATE_LIVE when we >> call virDomainMigrate(). > Thanks for this explanation. >> >> For static migration, libvirt uses a value of 0. There's two type >> values here.. the value set for the MigrationType attribute of >> MigrationSettingData and the value libvirt uses to differentiate >> between static and live migration. > ... >> It is a little more redundant this way, but it might help with >> readability. > > Thank you for this very good explanation. This makes now much more sense > to me :). But I think recoding as you suggested is not necessary, as it > would bring too much redundancy (as you already said) into the code. Now > that I understood it, I'm absolutely fine with it. Its not very > consistent that libvirt uses VIR_MIGRATE_LIVE and 0 (instead of > VIR_MIGRATE_STATIC or something else) as values, but that's something we > seem to live with. > Yes, this confused me too as well. =) When I checked libvirt.h, I was surprised to see only one migration flag listed. I wonder if this will change in the future? -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Thu Feb 28 16:06:03 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 08:06:03 -0800 Subject: [Libvirt-cim] [PATCH 3 of 4] Add MigrationType support to VirtualSystemMigrationService In-Reply-To: <87ejaxdsgt.fsf@caffeine.beaverton.ibm.com> References: <09153317203d6a60ede3.1204070624@elm3b41.beaverton.ibm.com> <47C55D34.90700@linux.vnet.ibm.com> <47C58E14.3050807@linux.vnet.ibm.com> <47C66F2C.9050202@linux.vnet.ibm.com> <87ejaxdsgt.fsf@caffeine.beaverton.ibm.com> Message-ID: <47C6DBEB.1080303@linux.vnet.ibm.com> Dan Smith wrote: > HE> Its not very consistent that libvirt uses VIR_MIGRATE_LIVE and 0 > HE> (instead of VIR_MIGRATE_STATIC or something else) as values, but > HE> that's something we seem to live with. > > The reason for this is that it's not a "type" parameter, but a "flags" > parameter. Static migration is considered the default, with Live > being an option. You could potentially also have a flag like > VIR_MIGRATE_SECURE, which would give you the following two > combinations: > > VIR_MIGRATE_SECURE -- Static, secure migration > VIR_MIGRATE_SECURE | VIR_MIGRATE_LIVE -- Live, secure migration > > Make sense? > The code bit that caused the confusion is: static CMPIStatus handle_migrate(virConnectPtr dconn, virDomainPtr dom, char *uri, int type, struct migration_job *job) { CMPIStatus s = {CMPI_RC_OK, NULL}; virDomainPtr ddom = NULL; CU_DEBUG("Migrating %s -> %s", job->domain, uri); ddom = virDomainMigrate(dom, dconn, type, NULL, NULL, 0); if (ddom == NULL) { CU_DEBUG("Migration failed"); cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Migration Failed"); } virDomainFree(ddom); return s; } Would it be better to change the variable name from int type to int flag? -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Thu Feb 28 16:36:30 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 08:36:30 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Fix const pointer warning In-Reply-To: <8ef92e008bcbcf2336cb.1204076907@localhost.localdomain> (lizg@cn.ibm.com's message of "Wed, 27 Feb 2008 09:48:27 +0800") References: <8ef92e008bcbcf2336cb.1204076907@localhost.localdomain> Message-ID: <87r6exca29.fsf@caffeine.beaverton.ibm.com> ZL> diff -r b2606bc023a8 -r 8ef92e008bcb std_indication.c ZL> --- a/std_indication.c Tue Feb 26 15:16:00 2008 -0500 ZL> +++ b/std_indication.c Wed Feb 27 09:48:23 2008 +0800 ZL> @@ -214,7 +214,7 @@ CMPIStatus stdi_activate_filter(CMPIIndi ZL> char *cn = NULL; ZL> _ctx = (struct std_indication_ctx *)mi->hdl; ZL> - cn = CLASSNAME(op); ZL> + cn = (char *)CLASSNAME(op); ZL> s = stdi_set_ind_filter_state(_ctx, cn, true); Shouldn't we change cn to be a const char *, instead of casting it to char *? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Thu Feb 28 16:54:58 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 08:54:58 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Add set_int_property() function to EO parse In-Reply-To: <64e51763141e107bc897.1204130656@elm3b41.beaverton.ibm.com> (Kaitlin Rupert's message of "Wed, 27 Feb 2008 08:44:16 -0800") References: <64e51763141e107bc897.1204130656@elm3b41.beaverton.ibm.com> Message-ID: <87myplc97h.fsf@caffeine.beaverton.ibm.com> KR> + unsigned_val = value; I think you should cast this explicitly to avoid a warning in the future. We have to compile without strict warnings because the generated parser code is riddled with issues, but I think we should try to make a routine such as this one as clean as possible. KR> + s = CMSetProperty(inst, prop, &(unsigned_val), type); Don't you want a (CMPIValue *) cast in front of your &(unsigned_val)? KR> + EOTRACE("propertyname = %s\n", $1); KR> + int rc; KR> + //uint64_t value = $3; KR> + CMPIType t = set_int_prop($3, $1, *_INSTANCE); I think you've got some whitespace issues here, and I think we can remove the commented-out code, right? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From kaitlin at linux.vnet.ibm.com Thu Feb 28 17:23:19 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 09:23:19 -0800 Subject: [Libvirt-cim] [PATCH 0 of 4] Update VSMigrationService to support static and offline migration In-Reply-To: <47C6A656.1010105@linux.vnet.ibm.com> References: <47C6A656.1010105@linux.vnet.ibm.com> Message-ID: <47C6EE07.6060004@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> This patchset updates VSMigrationService so that it reads the >> MigrationType attribute from MigrationSettingData and then launches >> the appropriate migration method. >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim >> > I run into problems with KVM (output with sfcbd): > > std_invokemethod.c(303): Executing handler for method > `CheckVirtualSystemIsMigratableToSystem' > misc_util.c(70): Connecting to libvirt with uri `qemu:///system' > ssh: kvm2-f8: Name or service not known > libvir: Remote error : Connection reset by peer > Virt_VSMigrationService.c(164): Failed to connect to remote host > (qemu+ssh://kvm2-f8/system) > std_invokemethod.c(305): Method `CheckVirtualSystemIsMigratableToSystem' > returned 1 > > Attached is the XML request submitted via wbemexec. Do you know what I'm > doing wrong ? > > thanks You'll want the DestinationSystem to be the reference of KVM_HostSystem on the target machine. So, something like: KVM_HostSystem target_sys_hostname -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Thu Feb 28 17:25:37 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 09:25:37 -0800 Subject: [Libvirt-cim] [PATCH 0 of 4] Update VSMigrationService to support static and offline migration In-Reply-To: <47C6A656.1010105@linux.vnet.ibm.com> References: <47C6A656.1010105@linux.vnet.ibm.com> Message-ID: <47C6EE91.7050004@linux.vnet.ibm.com> Heidi Eckhart wrote: > Kaitlin Rupert wrote: >> This patchset updates VSMigrationService so that it reads the >> MigrationType attribute from MigrationSettingData and then launches >> the appropriate migration method. >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim >> > I run into problems with KVM (output with sfcbd): > > std_invokemethod.c(303): Executing handler for method > `CheckVirtualSystemIsMigratableToSystem' > misc_util.c(70): Connecting to libvirt with uri `qemu:///system' > ssh: kvm2-f8: Name or service not known > libvir: Remote error : Connection reset by peer > Virt_VSMigrationService.c(164): Failed to connect to remote host > (qemu+ssh://kvm2-f8/system) > std_invokemethod.c(305): Method `CheckVirtualSystemIsMigratableToSystem' > returned 1 > > Attached is the XML request submitted via wbemexec. Do you know what I'm > doing wrong ? > > thanks > I also meant to mention that in order to test MigrateVirtualSystemToHost() and MigrateVirtualSystemToSystem(), you'll need to have the "Add set_int_property() function to EO parse" patch applied. The current EO parser doesn't handle uint16 values, which CIM_VirtualSystemMigrationSettingData has. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Thu Feb 28 17:25:35 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 09:25:35 -0800 Subject: [Libvirt-cim] [PATCH 0 of 3] (#4) Add VirtualSystemSnapshotService Message-ID: Added missing header (hopefully) and removed the extra CMSetNameSpace() From danms at us.ibm.com Thu Feb 28 17:25:38 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 09:25:38 -0800 Subject: [Libvirt-cim] [PATCH 3 of 3] Add VirtualSystemSnapshotService{, Capabilities} build support In-Reply-To: Message-ID: <7749dfc6ff5ed79dedae.1204219538@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1204219129 28800 # Node ID 7749dfc6ff5ed79dedaea3d71e99a99a56cc9734 # Parent 553531770279384cfaa2985868bfa64ea03e85ac Add VirtualSystemSnapshotService{,Capabilities} build support Changes: - Added HostSystem provider lib to VSSS for instance functions Signed-off-by: Dan Smith diff -r 553531770279 -r 7749dfc6ff5e Makefile.am --- a/Makefile.am Thu Feb 28 09:18:49 2008 -0800 +++ b/Makefile.am Thu Feb 28 09:18:49 2008 -0800 @@ -37,7 +37,9 @@ MOFS = \ schema/ElementSettingData.mof \ schema/VSMigrationCapabilities.mof \ schema/VSMigrationService.mof \ - schema/VSMigrationSettingData.mof + schema/VSMigrationSettingData.mof \ + schema/VirtualSystemSnapshotService.mof \ + schema/VirtualSystemSnapshotServiceCapabilities.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -81,7 +83,9 @@ REGS = \ schema/VSMigrationCapabilities.registration \ schema/VSMigrationService.registration \ schema/ElementConformsToProfile.registration \ - schema/VSMigrationSettingData.registration + schema/VSMigrationSettingData.registration \ + schema/VirtualSystemSnapshotService.registration \ + schema/VirtualSystemSnapshotServiceCapabilities.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ diff -r 553531770279 -r 7749dfc6ff5e schema/VirtualSystemSnapshotService.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotService.mof Thu Feb 28 09:18:49 2008 -0800 @@ -0,0 +1,7 @@ +// Copyright IBM Corp. 2008 + +[Description ( "Snapshot types are as follows: " + "32768: Memory-only snapshot (suspend, resume, keep image)" + "32769: Memory-only, terminal (domain is offline after op)")] +class Xen_VirtualSystemSnapshotService : CIM_VirtualSystemSnapshotService { }; +class KVM_VirtualSystemSnapshotService : CIM_VirtualSystemSnapshotService { }; diff -r 553531770279 -r 7749dfc6ff5e schema/VirtualSystemSnapshotService.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotService.registration Thu Feb 28 09:18:49 2008 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemSnapshotService root/virt Virt_VirtualSystemSnapshotService Virt_VirtualSystemSnapshotService method instance +KVM_VirtualSystemSnapshotService root/virt Virt_VirtualSystemSnapshotService Virt_VirtualSystemSnapshotService method instance diff -r 553531770279 -r 7749dfc6ff5e schema/VirtualSystemSnapshotServiceCapabilities.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotServiceCapabilities.mof Thu Feb 28 09:18:49 2008 -0800 @@ -0,0 +1,4 @@ +// Copyright IBM Corp. 2008 + +class Xen_VirtualSystemSnapshotServiceCapabilities : CIM_VirtualSystemSnapshotServiceCapabilities {}; +class KVM_VirtualSystemSnapshotServiceCapabilities : CIM_VirtualSystemSnapshotServiceCapabilities {}; diff -r 553531770279 -r 7749dfc6ff5e schema/VirtualSystemSnapshotServiceCapabilities.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VirtualSystemSnapshotServiceCapabilities.registration Thu Feb 28 09:18:49 2008 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemSnapshotServiceCapabilities root/virt Virt_VirtualSystemSnapshotServiceCapabilities Virt_VirtualSystemSnapshotServiceCapabilities instance +KVM_VirtualSystemSnapshotServiceCapabilities root/virt Virt_VirtualSystemSnapshotServiceCapabilities Virt_VirtualSystemSnapshotServiceCapabilities instance diff -r 553531770279 -r 7749dfc6ff5e src/Makefile.am --- a/src/Makefile.am Thu Feb 28 09:18:49 2008 -0800 +++ b/src/Makefile.am Thu Feb 28 09:18:49 2008 -0800 @@ -17,7 +17,9 @@ noinst_HEADERS = profiles.h svpc_types.h Virt_VSSD.h \ Virt_VSMigrationCapabilities.h \ Virt_VSMigrationService.h \ - Virt_AllocationCapabilities.h + Virt_AllocationCapabilities.h \ + Virt_VirtualSystemSnapshotService.h \ + Virt_VirtualSystemSnapshotServiceCapabilities.h XKUADD = $(top_builddir)/libxkutil/libxkutil.la @@ -56,7 +58,9 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_ElementSettingData.la \ libVirt_VSMigrationCapabilities.la \ libVirt_VSMigrationService.la \ - libVirt_VSMigrationSettingData.la + libVirt_VSMigrationSettingData.la \ + libVirt_VirtualSystemSnapshotService.la \ + libVirt_VirtualSystemSnapshotServiceCapabilities.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -161,3 +165,10 @@ libVirt_VSMigrationService_la_LIBADD = - libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c +libVirt_VirtualSystemSnapshotService_la_DEPENDENCIES = libVirt_HostSystem.la +libVirt_VirtualSystemSnapshotService_la_SOURCES = Virt_VirtualSystemSnapshotService.c +libVirt_VirtualSystemSnapshotService_la_LIBADD = -lVirt_HostSystem + +libVirt_VirtualSystemSnapshotServiceCapabilities_la_DEPENDENCIES = +libVirt_VirtualSystemSnapshotServiceCapabilities_la_SOURCES = Virt_VirtualSystemSnapshotServiceCapabilities.c +libVirt_VirtualSystemSnapshotServiceCapabilities_la_LIBADD = From danms at us.ibm.com Thu Feb 28 17:25:37 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 09:25:37 -0800 Subject: [Libvirt-cim] [PATCH 2 of 3] Add VirtualSystemSnapshotCapabilities In-Reply-To: Message-ID: <553531770279384cfaa2.1204219537@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1204219129 28800 # Node ID 553531770279384cfaa2985868bfa64ea03e85ac # Parent a369132796b8d06848194864256e68b718be279b Add VirtualSystemSnapshotCapabilities Changes: - Fixed silly compile errors - Expose get_vsss_cap() function Signed-off-by: Dan Smith diff -r a369132796b8 -r 553531770279 src/Virt_VirtualSystemSnapshotServiceCapabilities.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemSnapshotServiceCapabilities.c Thu Feb 28 09:18:49 2008 -0800 @@ -0,0 +1,205 @@ +/* + * Copyright IBM Corp. 2008 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include + +#include + +#include "misc_util.h" + +#include +#include +#include + +#include +#include + +#include "Virt_VirtualSystemSnapshotService.h" +#include "Virt_VirtualSystemSnapshotServiceCapabilities.h" + +const static CMPIBroker *_BROKER; + +enum { CREATE_SNAPSHOT = 2, + DESTROY_SNAPSHOT, + APPLY_SNAPSHOT, +}; + +static CMPIStatus set_inst_properties(const CMPIBroker *broker, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIArray *array; + uint16_t element; + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)"SnapshotCapabilities", CMPI_chars); + + array = CMNewArray(broker, 2, CMPI_uint16, &s); + if ((s.rc != CMPI_RC_OK) || (array == NULL)) + goto out; + + element = (uint16_t)CREATE_SNAPSHOT; + CMSetArrayElementAt(array, 0, &element, CMPI_uint16); + + element = (uint16_t)APPLY_SNAPSHOT; + CMSetArrayElementAt(array, 1, &element, CMPI_uint16); + + CMSetProperty(inst, "AsynchronousMethodsSupported", + (CMPIValue *)&array, CMPI_uint16A); + + array = CMNewArray(broker, 1, CMPI_uint16, &s); + if ((s.rc != CMPI_RC_OK) || (array == NULL)) + goto out; + + element = (uint16_t)DESTROY_SNAPSHOT; + CMSetArrayElementAt(array, 0, &element, CMPI_uint16); + + CMSetProperty(inst, "SynchronousMethodsSupported", + (CMPIValue *)&array, CMPI_uint16A); + + array = CMNewArray(broker, 2, CMPI_uint16, &s); + if ((s.rc != CMPI_RC_OK) || (array == NULL)) + goto out; + + element = (uint16_t)VIR_VSSS_SNAPSHOT_MEM; + CMSetArrayElementAt(array, 0, &element, CMPI_uint16); + + element = (uint16_t)VIR_VSSS_SNAPSHOT_MEMT; + CMSetArrayElementAt(array, 1, &element, CMPI_uint16); + + CMSetProperty(inst, "SnapshotTypesSupported", + (CMPIValue *)&array, CMPI_uint16A); + + out: + return s; +} + +CMPIStatus get_vss_cap(const CMPIBroker *broker, + const CMPIObjectPath *ref, + CMPIInstance **_inst, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "VirtualSystemSnapshotServiceCapabilities", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Can't create instance for %s", CLASSNAME(ref)); + goto out; + } + + s = set_inst_properties(broker, inst); + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_vss_cap(const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_vss_cap(_BROKER, ref, &inst, is_get_inst); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + goto out; + + if (names_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + out: + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference) +{ + return return_vss_cap(reference, results, true, false); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + + return return_vss_cap(reference, results, false, false); +} + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + return return_vss_cap(reference, results, false, true); +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, + Virt_VirtualSystemSnapshotServiceCapabilities, + _BROKER, + libvirt_cim_init()); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff -r a369132796b8 -r 553531770279 src/Virt_VirtualSystemSnapshotServiceCapabilities.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemSnapshotServiceCapabilities.h Thu Feb 28 09:18:49 2008 -0800 @@ -0,0 +1,35 @@ +/* + * Copyright IBM Corp. 2008 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +CMPIStatus get_vss_cap(const CMPIBroker *broker, + const CMPIObjectPath *ref, + CMPIInstance **_inst, + bool is_get_inst); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From danms at us.ibm.com Thu Feb 28 17:25:36 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 09:25:36 -0800 Subject: [Libvirt-cim] [PATCH 1 of 3] Add VirtualSystemSnapshotService In-Reply-To: Message-ID: # HG changeset patch # User Dan Smith # Date 1204219127 28800 # Node ID a369132796b8d06848194864256e68b718be279b # Parent 12d65b8acee40a7b4144dd5dea3fa9fe70fbb8f3 Add VirtualSystemSnapshotService Changes: - Added header block - Added return values for methods - Fixed silly compile errors - Added instance functions - Removed unneeded CMSetNameSpace Signed-off-by: Dan Smith diff -r 12d65b8acee4 -r a369132796b8 src/Virt_VirtualSystemSnapshotService.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemSnapshotService.c Thu Feb 28 09:18:47 2008 -0800 @@ -0,0 +1,713 @@ +/* + * Copyright IBM Corp. 2008 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include "misc_util.h" + +#include "Virt_VirtualSystemSnapshotService.h" +#include "Virt_HostSystem.h" + +#define CIM_JOBSTATE_STARTING 3 +#define CIM_JOBSTATE_RUNNING 4 +#define CIM_JOBSTATE_COMPLETE 7 + +#define CIM_RETURN_COMPLETED 0 +#define CIM_RETURN_FAILED 2 + +static const CMPIBroker *_BROKER; + +struct snap_context { + CMPIContext *context; + char *domain; + char uuid[33]; + char *save_path; + char *ref_ns; + char *ref_cn; + + bool save; + bool restore; +}; + +static void snap_job_free(struct snap_context *ctx) +{ + free(ctx->domain); + free(ctx->save_path); + free(ctx->ref_ns); + free(ctx->ref_cn); + free(ctx); +} + +static void _snap_job_set_status(struct snap_context *ctx, + uint16_t state, + const char *status, + uint16_t errcode, + const char *errdesc) +{ + CMPIInstance *inst; + CMPIStatus s; + CMPIObjectPath *op; + char *desc = NULL; + int ret; + + op = CMNewObjectPath(_BROKER, + ctx->ref_ns, + "CIM_ConcreteJob", + &s); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Failed to create job path for update"); + return; + } + + CMAddKey(op, "InstanceID", (CMPIValue *)ctx->uuid, CMPI_chars); + + inst = CBGetInstance(_BROKER, ctx->context, op, NULL, &s); + if ((inst == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to get job instance for update of %s", + ctx->uuid); + return; + } + + CMSetProperty(inst, "JobState", + (CMPIValue *)&state, CMPI_uint16); + CMSetProperty(inst, "Status", + (CMPIValue *)status, CMPI_chars); + + ret = asprintf(&desc, + "%s of %s (%s)", + ctx->save ? "Snapshot" : "Restore", + ctx->domain, + ctx->save_path); + if (ret != -1) { + CMSetProperty(inst, "Description", + (CMPIValue *)desc, CMPI_chars); + free(desc); + } + + if ((errcode != 0) && (errdesc != NULL)) { + CMSetProperty(inst, "ErrorCode", + (CMPIValue *)&errcode, CMPI_uint16); + CMSetProperty(inst, "ErrorDescription", + (CMPIValue *)errdesc, CMPI_chars); + + CU_DEBUG("Set error properties to %i:%s", + errcode, + errdesc); + } + + s = CBModifyInstance(_BROKER, ctx->context, op, inst, NULL); + if (s.rc != CMPI_RC_OK) { + CU_DEBUG("Failed to update job instance %s: %s", + ctx->uuid, + CMGetCharPtr(s.msg)); + return; + } + + CU_DEBUG("Set %s status to %i:%s", ctx->uuid, state, status); +} + +static void snap_job_set_status(struct snap_context *ctx, + uint16_t state, + const char *status) +{ + _snap_job_set_status(ctx, state, status, 0, NULL); +} + +static void snap_job_set_failed(struct snap_context *ctx, + uint16_t errcode, + const char *errdesc) +{ + _snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Failed", + errcode, + errdesc); +} + +static void do_snapshot(struct snap_context *ctx, + virConnectPtr conn, + virDomainPtr dom) +{ + int ret; + + if (ctx->save) { + CU_DEBUG("Starting save to %s", ctx->save_path); + + ret = virDomainSave(dom, ctx->save_path); + if (ret == -1) { + CU_DEBUG("Save failed"); + snap_job_set_failed(ctx, + VIR_VSSS_ERR_SAVE_FAILED, + "Save failed"); + return; + } + + CU_DEBUG("Save completed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_RUNNING, + "Save finished"); + } + + if (ctx->restore) { + CU_DEBUG("Starting restore from %s", ctx->save_path); + + ret = virDomainRestore(conn, ctx->save_path); + if (ret == -1) { + CU_DEBUG("Restore failed"); + snap_job_set_failed(ctx, + VIR_VSSS_ERR_REST_FAILED, + "Restore failed"); + return; + } + + CU_DEBUG("Restore completed"); + snap_job_set_status(ctx, + CIM_JOBSTATE_RUNNING, + "Restore finished"); + } + + CU_DEBUG("Snapshot (%s/%s) completed", + ctx->save ? "Save" : "None", + ctx->restore ? "Restore" : "None"); + + snap_job_set_status(ctx, + CIM_JOBSTATE_COMPLETE, + "Snapshot complete"); + + return; +} + +static CMPI_THREAD_RETURN snapshot_thread(struct snap_context *ctx) +{ + CMPIStatus s; + virConnectPtr conn = NULL; + virDomainPtr dom = NULL; + + CU_DEBUG("Snapshot thread alive"); + + CBAttachThread(_BROKER, ctx->context); + + snap_job_set_status(ctx, CIM_JOBSTATE_RUNNING, "Running"); + + conn = connect_by_classname(_BROKER, ctx->ref_cn, &s); + if (conn == NULL) { + CU_DEBUG("Failed to connect with classname `%s'", ctx->ref_cn); + snap_job_set_failed(ctx, + VIR_VSSS_ERR_CONN_FAILED, + "Unable to connect to hypervisor"); + goto out; + } + + dom = virDomainLookupByName(conn, ctx->domain); + if (dom == NULL) { + CU_DEBUG("No such domain `%s'", ctx->domain); + snap_job_set_failed(ctx, + VIR_VSSS_ERR_NO_SUCH_DOMAIN, + "No such domain"); + goto out; + } + + do_snapshot(ctx, conn, dom); + + out: + virDomainFree(dom); + virConnectClose(conn); + + snap_job_free(ctx); + + return NULL; +} + +static CMPIStatus create_job(const CMPIContext *context, + const CMPIObjectPath *ref, + struct snap_context *ctx, + CMPIObjectPath **job) +{ + CMPIObjectPath *op; + CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + op = CMNewObjectPath(_BROKER, + NAMESPACE(ref), + "CIM_ConcreteJob", /*FIXME*/ + &s); + if ((s.rc != CMPI_RC_OK) || (op == NULL)) { + CU_DEBUG("Failed to create job path"); + goto out; + } + + inst = CMNewInstance(_BROKER, op, &s); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) { + CU_DEBUG("Failed to create job instance"); + goto out; + } + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)ctx->uuid, CMPI_chars); + + CMSetProperty(inst, "Name", + (CMPIValue *)"Snapshot", CMPI_chars); + + CMSetProperty(inst, "Status", + (CMPIValue *)"Queued", CMPI_chars); + + op = CMGetObjectPath(inst, &s); + if ((op == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to get path of job instance"); + goto out; + } + + CMSetNameSpace(op, NAMESPACE(ref)); + + CU_DEBUG("ref was %s", CMGetCharPtr(CMObjectPathToString(op, NULL))); + + *job = CBCreateInstance(_BROKER, context, op, inst, &s); + if ((*job == NULL) || (s.rc != CMPI_RC_OK)) { + CU_DEBUG("Failed to create job"); + goto out; + } + + ctx->ref_ns = strdup(NAMESPACE(ref)); + ctx->ref_cn = strdup(CLASSNAME(ref)); + + ctx->context = CBPrepareAttachThread(_BROKER, context); + + _BROKER->xft->newThread((void *)snapshot_thread, ctx, 0); + out: + return s; +} + +char *vsss_get_save_path(const char *domname) +{ + int ret; + char *path = NULL; + + ret = asprintf(&path, + "/var/lib/libvirt/%s.save", domname); + if (ret == -1) + return NULL; + + return path; +} + +static struct snap_context *new_context(const char *name, + CMPIStatus *s) +{ + struct snap_context *ctx; + uuid_t uuid; + + ctx = calloc(1, sizeof(*ctx)); + if (ctx == NULL) { + CU_DEBUG("Failed to alloc snapshot context"); + goto out; + } + + ctx->domain = strdup(name); + + uuid_generate(uuid); + uuid_unparse(uuid, ctx->uuid); + + ctx->save_path = vsss_get_save_path(ctx->domain); + if (ctx->save_path == NULL) { + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Unable to get save_path"); + goto out; + } + + cu_statusf(_BROKER, s, + CMPI_RC_OK, + ""); + out: + if (s->rc != CMPI_RC_OK) { + snap_job_free(ctx); + ctx = NULL; + } + + return ctx; +} + +static CMPIStatus start_snapshot_job(const CMPIObjectPath *ref, + const CMPIContext *context, + const char *name, + uint16_t type) +{ + struct snap_context *ctx; + CMPIStatus s; + CMPIObjectPath *job; + + ctx = new_context(name, &s); + if (ctx == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to create snapshot context"); + goto out; + } + + ctx->save = (type != 0); + ctx->restore = (type != VIR_VSSS_SNAPSHOT_MEM); + + s = create_job(context, ref, ctx, &job); + + out: + return s; +} + +static CMPIStatus create_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *system; + CMPIInstance *sd; + uint16_t type; + uint32_t retcode = CIM_RETURN_FAILED; + const char *name; + + if (cu_get_u16_arg(argsin, "SnapshotType", &type) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing SnapshotType"); + goto out; + } + + if ((type != VIR_VSSS_SNAPSHOT_MEM) && + (type != VIR_VSSS_SNAPSHOT_MEMT)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_SUPPORTED, + "Only memory(%i,%i) snapshots are supported", + VIR_VSSS_SNAPSHOT_MEM, + VIR_VSSS_SNAPSHOT_MEMT); + goto out; + } + + if (cu_get_ref_arg(argsin, "AffectedSystem", &system) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing AffectedSystem"); + goto out; + } + + if (cu_get_inst_arg(argsin, "SnapshotSettings", &sd) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing SnapshotSettings"); + goto out; + } + + if (cu_get_str_path(system, "Name", &name) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Name property of AffectedSystem"); + goto out; + } + + s = start_snapshot_job(reference, context, name, type); + + retcode = CIM_RETURN_COMPLETED; + out: + CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); + + return s; +} + +static CMPIStatus destroy_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *snap; + char *name = NULL; + char *path = NULL; + uint32_t retcode = CIM_RETURN_FAILED; + + if (cu_get_ref_arg(argsin, "AffectedSnapshot", &snap) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Snapshot"); + goto out; + } + + if (!parse_instanceid(snap, NULL, &name)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Invalid InstanceID in Snapshot"); + goto out; + } + + path = vsss_get_save_path(name); + if (path == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get save_path"); + goto out; + } + + if (unlink(path) == -1) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to remove snapshot: %s", path); + } + + retcode = CIM_RETURN_COMPLETED; + out: + CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); + + free(path); + free(name); + + return s; +} + +static CMPIStatus apply_snapshot(CMPIMethodMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *snap; + char *name = NULL; + uint32_t retcode = CIM_RETURN_FAILED; + + if (cu_get_ref_arg(argsin, "AffectedSnapshot", &snap) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Missing Snapshot"); + goto out; + } + + if (!parse_instanceid(snap, NULL, &name)) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Invalid InstanceID in Snapshot"); + goto out; + } + + s = start_snapshot_job(reference, context, name, 0); + + retcode = CIM_RETURN_COMPLETED; + + out: + CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); + + free(name); + + return s; +} + +static struct method_handler CreateSnapshot = { + .name = "CreateSnapshot", + .handler = create_snapshot, + .args = {{"AffectedSystem", CMPI_ref, false}, + {"SnapshotSettings", CMPI_instance, false}, + {"SnapshotType", CMPI_uint16, false}, + ARG_END} +}; + +static struct method_handler DestroySnapshot = { + .name = "DestroySnapshot", + .handler = destroy_snapshot, + .args = {{"AffectedSnapshot", CMPI_ref, false}, + ARG_END} +}; + +static struct method_handler ApplySnapshot = { + .name = "ApplySnapshot", + .handler = apply_snapshot, + .args = {{"AffectedSnapshot", CMPI_ref, false}, + ARG_END} +}; + +static struct method_handler *handlers[] = { + &CreateSnapshot, + &DestroySnapshot, + &ApplySnapshot, + NULL +}; + +STDIM_MethodMIStub(, Virt_VirtualSystemSnapshotService, + _BROKER, libvirt_cim_init(), handlers); + +static CMPIStatus set_inst_properties(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + const char *name; + const char *ccname; + + s = get_host_system_properties(&name, + &ccname, + reference, + broker); + if (s.rc != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get host attributes"); + goto out; + } + + CMSetProperty(inst, "Name", + (CMPIValue *)"SnapshotService", CMPI_chars); + + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); + + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)ccname, CMPI_chars); + + out: + return s; +} + +CMPIStatus get_vsss(const CMPIBroker *broker, + const CMPIObjectPath *ref, + CMPIInstance **_inst, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "VirtualSystemSnapshotService", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Can't create instance for %s", CLASSNAME(ref)); + goto out; + } + + s = set_inst_properties(broker, ref, inst); + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_vsss(const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_vsss(_BROKER, ref, &inst, is_get_inst); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + goto out; + + if (names_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + out: + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference) +{ + return return_vsss(reference, results, true, false); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + + return return_vsss(reference, results, false, false); +} + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + return return_vsss(reference, results, false, true); +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, + Virt_VirtualSystemSnapshotService, + _BROKER, + libvirt_cim_init()); + + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff -r 12d65b8acee4 -r a369132796b8 src/Virt_VirtualSystemSnapshotService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemSnapshotService.h Thu Feb 28 09:18:47 2008 -0800 @@ -0,0 +1,52 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Returns a malloc()'d string; caller must free() */ +char *vsss_get_save_path(const char *domname); + +CMPIStatus get_vsss(const CMPIBroker *broker, + const CMPIObjectPath *ref, + CMPIInstance **_inst, + bool is_get_inst); + +#define CIM_VSSS_SNAPSHOT_FULL 2 +#define CIM_VSSS_SNAPSHOT_DISK 3 + +/* VIR_VSSS_SNAPSHOT_MEM - Attempt to save/restore to create a running snap + * VIR_VSSS_SNAPSHOT_MEMT - Just save and let the domain be "off" + */ +#define VIR_VSSS_SNAPSHOT_MEM 32768 +#define VIR_VSSS_SNAPSHOT_MEMT 32769 + +#define VIR_VSSS_ERR_SAVE_FAILED 1 +#define VIR_VSSS_ERR_REST_FAILED 2 +#define VIR_VSSS_ERR_CONN_FAILED 3 +#define VIR_VSSS_ERR_NO_SUCH_DOMAIN 4 + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ From kaitlin at linux.vnet.ibm.com Thu Feb 28 18:01:48 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 10:01:48 -0800 Subject: [Libvirt-cim] [PATCH] Add TypesSupported[] to VirtualSystemManagementCapabilities In-Reply-To: <534a933e0202dc425f3f.1204150159@caffeine.beaverton.ibm.com> References: <534a933e0202dc425f3f.1204150159@caffeine.beaverton.ibm.com> Message-ID: <47C6F70C.2090807@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1204150157 28800 > # Node ID 534a933e0202dc425f3f27ba55dfa42e7c42db5f > # Parent 224ad7217cef6235bccb3377b9b86114ed61d6ae > Add TypesSupported[] to VirtualSystemManagementCapabilities > > Signed-off-by: Dan Smith > > diff -r 224ad7217cef -r 534a933e0202 src/Virt_VirtualSystemManagementCapabilities.c > + > + CMSetProperty(inst, "TypesSupported", > + (CMPIValue *)&array, CMPI_charsA); > + I think this should be CMPI_stringA, but otherwise this patch is good. -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From danms at us.ibm.com Thu Feb 28 18:07:12 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 10:07:12 -0800 Subject: [Libvirt-cim] [PATCH] Add TypesSupported[] to VirtualSystemManagementCapabilities In-Reply-To: <47C6F70C.2090807@linux.vnet.ibm.com> (Kaitlin Rupert's message of "Thu, 28 Feb 2008 10:01:48 -0800") References: <534a933e0202dc425f3f.1204150159@caffeine.beaverton.ibm.com> <47C6F70C.2090807@linux.vnet.ibm.com> Message-ID: <873ardc5v3.fsf@caffeine.beaverton.ibm.com> KR> I think this should be CMPI_stringA, but otherwise this patch is KR> good. The CIMOM doesn't seem to care because it converts them all to CMPIString objects anyway, but yes, this should be stringA. I initially had tried adding a CMPI_chars to the array, but I was getting a crash. Creating a CMPIString and changing the type of the array seemed to make it happy, but I forgot to change the type of the property :) I'll resend. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Thu Feb 28 18:07:47 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 10:07:47 -0800 Subject: [Libvirt-cim] [PATCH] Add TypesSupported[] to VirtualSystemManagementCapabilities Message-ID: <7dccdf33b9b102e8c1a2.1204222067@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1204222059 28800 # Node ID 7dccdf33b9b102e8c1a2ffb2ae34292a61ec512e # Parent ab774ea93302e6173b0749a27d7d951469eccc62 Add TypesSupported[] to VirtualSystemManagementCapabilities Signed-off-by: Dan Smith diff -r ab774ea93302 -r 7dccdf33b9b1 src/Virt_VirtualSystemManagementCapabilities.c --- a/src/Virt_VirtualSystemManagementCapabilities.c Thu Feb 28 10:02:10 2008 -0800 +++ b/src/Virt_VirtualSystemManagementCapabilities.c Thu Feb 28 10:07:39 2008 -0800 @@ -46,11 +46,14 @@ enum {ADD_RESOURCES = 1, static CMPIStatus set_inst_properties(const CMPIBroker *broker, + const CMPIObjectPath *ref, CMPIInstance *inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIArray *array; uint16_t element; + char *prefix = NULL; + CMPIString *str; CMSetProperty(inst, "InstanceID", (CMPIValue *)"ManagementCapabilities", CMPI_chars); @@ -73,7 +76,29 @@ static CMPIStatus set_inst_properties(co CMSetProperty(inst, "SynchronousMethodsSupported", (CMPIValue *)&array, CMPI_uint16A); - out: + + prefix = class_prefix_name(CLASSNAME(ref)); + if (prefix == NULL) { + CU_DEBUG("Prefix of %s was NULL", CLASSNAME(ref)); + goto out; + } + + str = CMNewString(broker, prefix, &s); + if ((str == NULL) || (s.rc != CMPI_RC_OK)) + goto out; + + array = CMNewArray(broker, 1, CMPI_string, &s); + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(array))) + goto out; + + CMSetArrayElementAt(array, 0, (CMPIValue *)&str, CMPI_string); + + CMSetProperty(inst, "TypesSupported", + (CMPIValue *)&array, CMPI_stringA); + + out: + free(prefix); + return s; } @@ -106,7 +131,7 @@ CMPIStatus get_vsm_cap(const CMPIBroker goto out; } - s = set_inst_properties(broker, inst); + s = set_inst_properties(broker, ref, inst); if (is_get_inst) { s = cu_validate_ref(broker, ref, inst); From kaitlin at linux.vnet.ibm.com Thu Feb 28 18:10:08 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 10:10:08 -0800 Subject: [Libvirt-cim] [PATCH] RegisteredProfile: add keys parameter to SetPropertyFilter In-Reply-To: <50d2575dd541ec7d578e.1204202099@localhost.localdomain> References: <50d2575dd541ec7d578e.1204202099@localhost.localdomain> Message-ID: <47C6F900.206@linux.vnet.ibm.com> Heidi Eckhart wrote: > # HG changeset patch > # User Heidi Eckhart > # Date 1204201511 -3600 > # Node ID 50d2575dd541ec7d578e491e5bfdc710f72408f0 > # Parent deae8f1fa76ab1e1fa785495be4944e0fc4e16d7 > RegisteredProfile: add keys parameter to SetPropertyFilter > > This is necessary to avoid error returns. > > Signed-off-by: Heidi Eckhart > > diff -r deae8f1fa76a -r 50d2575dd541 src/Virt_RegisteredProfile.c > --- a/src/Virt_RegisteredProfile.c Wed Feb 27 13:49:31 2008 -0800 > +++ b/src/Virt_RegisteredProfile.c Thu Feb 28 13:25:11 2008 +0100 > @@ -62,7 +62,8 @@ CMPIInstance *reg_prof_instance(const CM > } > > if (properties) { > - s = CMSetPropertyFilter(instance, properties, NULL); > + const char *keys[] = {"InstanceID", NULL}; > + s = CMSetPropertyFilter(instance, properties, keys); > if (s.rc != CMPI_RC_OK) { > goto out; > } > Oh, I didn't realize RP also had property filtering. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Thu Feb 28 20:35:38 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 12:35:38 -0800 Subject: [Libvirt-cim] [PATCH] Add TypesSupported[] to VirtualSystemManagementCapabilities In-Reply-To: <7dccdf33b9b102e8c1a2.1204222067@caffeine.beaverton.ibm.com> References: <7dccdf33b9b102e8c1a2.1204222067@caffeine.beaverton.ibm.com> Message-ID: <47C71B1A.3060105@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1204222059 28800 > # Node ID 7dccdf33b9b102e8c1a2ffb2ae34292a61ec512e > # Parent ab774ea93302e6173b0749a27d7d951469eccc62 > Add TypesSupported[] to VirtualSystemManagementCapabilities > > Signed-off-by: Dan Smith > > diff -r ab774ea93302 -r 7dccdf33b9b1 src/Virt_VirtualSystemManagementCapabilities.c This version looks good to me =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Thu Feb 28 22:01:58 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 14:01:58 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Add set_int_property() function to EO parse In-Reply-To: <87myplc97h.fsf@caffeine.beaverton.ibm.com> References: <64e51763141e107bc897.1204130656@elm3b41.beaverton.ibm.com> <87myplc97h.fsf@caffeine.beaverton.ibm.com> Message-ID: <47C72F56.8030405@linux.vnet.ibm.com> Dan Smith wrote: > KR> + unsigned_val = value; > > I think you should cast this explicitly to avoid a warning in the > future. We have to compile without strict warnings because the > generated parser code is riddled with issues, but I think we should > try to make a routine such as this one as clean as possible. Good catch =) > > KR> + s = CMSetProperty(inst, prop, &(unsigned_val), type); > > Don't you want a (CMPIValue *) cast in front of your &(unsigned_val)? I think you can leave this off for integer types - it seems to work both with and without. The original call in eo_util_parse.y didn't have it. But I need to resend, so I'll add it for consistency =) > > KR> + EOTRACE("propertyname = %s\n", $1); > KR> + int rc; > KR> + //uint64_t value = $3; > KR> + CMPIType t = set_int_prop($3, $1, *_INSTANCE); > > I think you've got some whitespace issues here, and I think we can > remove the commented-out code, right? Oops - I though I'd gone back and removed the commented out code. Sending updated patch =) -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From kaitlin at linux.vnet.ibm.com Thu Feb 28 21:58:54 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 13:58:54 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Add set_int_property() function to EO parse Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1204235749 28800 # Node ID e5e14ae1282c26c3ba16976bd239c36714162700 # Parent b07d295f167fe3d66377047b3f8e5c00ea6955be [CU] Add set_int_property() function to EO parse. Updates from set 1 to set 2: -Cast value in _set_int_prop() -Add (CMPIValue *) before unsigned_val/signed_val in CMSetProperty() call -Remove comment and fix whitespace issues in eo_util_parser.y This function attempts to find the appropriate property value type and then sets that property value. This change is needed to properly parse non 64 bit integer. If the property is a uint16 value, and CMPI_uint64 is passed CMSetProperty(), the call will fail. Signed-off-by: Kaitlin Rupert diff -r b07d295f167f -r e5e14ae1282c eo_parser.c --- a/eo_parser.c Wed Feb 27 10:39:55 2008 -0500 +++ b/eo_parser.c Thu Feb 28 13:55:49 2008 -0800 @@ -107,6 +107,68 @@ int cu_parse_embedded_instance(const cha } } +static int _set_int_prop(CMPISint64 value, + char *prop, + CMPIType type, + CMPIInstance *inst) +{ + CMPIStatus s; + uint64_t unsigned_val = 0; + int64_t signed_val = 0; + + switch(type) { + case CMPI_uint64: + case CMPI_uint32: + case CMPI_uint16: + case CMPI_uint8: + unsigned_val = (uint64_t) value; + s = CMSetProperty(inst, + prop, + (CMPIValue *) &(unsigned_val), + type); + break; + case CMPI_sint64: + case CMPI_sint32: + case CMPI_sint16: + case CMPI_sint8: + default: + signed_val = (int64_t) value; + s = CMSetProperty(inst, + prop, + (CMPIValue *) &(signed_val), + type); + } + + if (s.rc == CMPI_RC_OK) + return 1; + + return 0; +} + +CMPIType set_int_prop(CMPISint64 value, + char *prop, + CMPIInstance *inst) +{ + if (_set_int_prop(value, prop, CMPI_uint64, inst) == 1) + return CMPI_uint64; + else if (_set_int_prop(value, prop, CMPI_uint32, inst) == 1) + return CMPI_uint32; + else if (_set_int_prop(value, prop, CMPI_uint16, inst) == 1) + return CMPI_uint16; + else if (_set_int_prop(value, prop, CMPI_uint8, inst) == 1) + return CMPI_uint8; + else if (_set_int_prop(value, prop, CMPI_sint64, inst) == 1) + return CMPI_sint64; + else if (_set_int_prop(value, prop, CMPI_sint32, inst) == 1) + return CMPI_sint32; + else if (_set_int_prop(value, prop, CMPI_sint16, inst) == 1) + return CMPI_sint16; + else + _set_int_prop(value, prop, CMPI_sint8, inst); + + return CMPI_sint8; +} + /* * Local Variables: * mode: C diff -r b07d295f167f -r e5e14ae1282c eo_parser_xml.h --- a/eo_parser_xml.h Wed Feb 27 10:39:55 2008 -0500 +++ b/eo_parser_xml.h Thu Feb 28 13:55:49 2008 -0800 @@ -27,6 +27,10 @@ int cu_parse_ei_xml(const CMPIBroker *br const char *xml, CMPIInstance **instance); +CMPIType set_int_prop(CMPISint64 value, + char *prop, + CMPIInstance *inst); + #endif /* diff -r b07d295f167f -r e5e14ae1282c eo_util_parser.y --- a/eo_util_parser.y Wed Feb 27 10:39:55 2008 -0500 +++ b/eo_util_parser.y Thu Feb 28 13:55:49 2008 -0800 @@ -10,9 +10,12 @@ %{ #include #include +#include #include "cmpidt.h" #include "cmpift.h" + +#include "eo_parser_xml.h" /* specify prototypes to get rid of warnings */ int eo_parse_lex (void); @@ -103,13 +106,12 @@ property: PROPERTYNAME '=' STRING ';' | PROPERTYNAME '=' INTEGER ';' { - EOTRACE("propertyname = %s" - "\ttype = CMPI_sint64\n" - "\tvalue = %lld\n", - $1, $3); - unsigned long long value = $3; - CMSetProperty(*_INSTANCE, $1, &(value), CMPI_uint64); - free($1); + EOTRACE("propertyname = %s\n", $1); + int rc; + CMPIType t = set_int_prop($3, $1, *_INSTANCE); + EOTRACE("\ttype = %d\n" + "\tvalue = %lld\n", t, $3); + free($1); } | PROPERTYNAME '=' BOOLEAN ';' From kaitlin at linux.vnet.ibm.com Thu Feb 28 22:51:16 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 14:51:16 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Change VSMigrationCapabilities from Virt_ to CIM prefix In-Reply-To: Message-ID: <99b1667ee6344ea11db6.1204239076@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1204238624 28800 # Node ID 99b1667ee6344ea11db6c1462524a4edddfaa780 # Parent e9f9fe648fac4642db1607c27bd916ee71d2e479 Change VSMigrationCapabilities from Virt_ to CIM prefix. Signed-off-by: Kaitlin Rupert diff -r e9f9fe648fac -r 99b1667ee634 schema/VSMigrationCapabilities.mof --- a/schema/VSMigrationCapabilities.mof Thu Feb 28 14:39:20 2008 -0800 +++ b/schema/VSMigrationCapabilities.mof Thu Feb 28 14:43:44 2008 -0800 @@ -1,6 +1,6 @@ // Copyright IBM Corp. 2007 -class Virt_VirtualSystemMigrationCapabilities : CIM_Capabilities { +class CIM_VirtualSystemMigrationCapabilities : CIM_Capabilities { uint16 DestinationHostFormatsSupported[]; @@ -11,9 +11,9 @@ class Virt_VirtualSystemMigrationCapabil }; [Provider("cmpi::Virt_VSMigrationCapabilities")] -class Xen_VirtualSystemMigrationCapabilities : Virt_VirtualSystemMigrationCapabilities { +class Xen_VirtualSystemMigrationCapabilities : CIM_VirtualSystemMigrationCapabilities { }; [Provider("cmpi::Virt_VSMigrationCapabilities")] -class KVM_VirtualSystemMigrationCapabilities : Virt_VirtualSystemMigrationCapabilities { +class KVM_VirtualSystemMigrationCapabilities : CIM_VirtualSystemMigrationCapabilities { }; From kaitlin at linux.vnet.ibm.com Thu Feb 28 22:51:15 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 14:51:15 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Update SDC so that it supports VSMigrationSettingData to VSMigrationCapabilities In-Reply-To: Message-ID: # HG changeset patch # User Kaitlin Rupert # Date 1204238360 28800 # Node ID e9f9fe648fac4642db1607c27bd916ee71d2e479 # Parent b5577ad78998fcf535b94ca0d2a1e8730720f3cf Update SDC so that it supports VSMigrationSettingData to VSMigrationCapabilities. Signed-off-by: Kaitlin Rupert diff -r b5577ad78998 -r e9f9fe648fac src/Makefile.am --- a/src/Makefile.am Thu Feb 28 10:30:05 2008 -0800 +++ b/src/Makefile.am Thu Feb 28 14:39:20 2008 -0800 @@ -111,9 +111,12 @@ libVirt_ElementCapabilities_la_LIBADD = -lVirt_VirtualSystemManagementService \ -lVirt_VSMigrationService -libVirt_SettingsDefineCapabilities_la_DEPENDENCIES = libVirt_RASD.la libVirt_DevicePool.la +libVirt_SettingsDefineCapabilities_la_DEPENDENCIES = libVirt_RASD.la libVirt_DevicePool.la libVirt_VSMigrationCapabilities.la libVirt_VSMigrationSettingData.la libVirt_SettingsDefineCapabilities_la_SOURCES = Virt_SettingsDefineCapabilities.c -libVirt_SettingsDefineCapabilities_la_LIBADD = -lVirt_RASD -lVirt_DevicePool +libVirt_SettingsDefineCapabilities_la_LIBADD = -lVirt_RASD \ + -lVirt_DevicePool \ + -lVirt_VSMigrationCapabilities \ + -lVirt_VSMigrationSettingData libVirt_RegisteredProfile_la_SOURCES = Virt_RegisteredProfile.c diff -r b5577ad78998 -r e9f9fe648fac src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Thu Feb 28 10:30:05 2008 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Thu Feb 28 14:39:20 2008 -0800 @@ -43,6 +43,8 @@ #include "Virt_SettingsDefineCapabilities.h" #include "Virt_DevicePool.h" #include "Virt_RASD.h" +#include "Virt_VSMigrationCapabilities.h" +#include "Virt_VSMigrationSettingData.h" const static CMPIBroker *_BROKER; @@ -825,6 +827,50 @@ static CMPIStatus rasd_to_alloc_cap(cons RETURN_UNSUPPORTED(); } +static CMPIStatus migrate_cap_to_vsmsd(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK}; + CMPIInstance *inst; + + if (!match_hypervisor_prefix(ref, info)) + return s; + + s = get_migration_caps(ref, &inst, _BROKER, true); + if (s.rc != CMPI_RC_OK) + goto out; + + s = get_migration_sd(ref, &inst, _BROKER, false); + if (s.rc == CMPI_RC_OK) + inst_list_add(list, inst); + + out: + return s; +} + +static CMPIStatus vsmsd_to_migrate_cap(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK}; + CMPIInstance *inst; + + if (!match_hypervisor_prefix(ref, info)) + return s; + + s = get_migration_sd(ref, &inst, _BROKER, true); + if (s.rc != CMPI_RC_OK) + goto out; + + s = get_migration_caps(ref, &inst, _BROKER, false); + if (s.rc == CMPI_RC_OK) + inst_list_add(list, inst); + + out: + return s; +} + LIBVIRT_CIM_DEFAULT_MAKEREF() static char* group_component[] = { @@ -877,9 +923,49 @@ static struct std_assoc _rasd_to_alloc_c .make_ref = make_ref }; +static char* migrate_cap[] = { + "Xen_VirtualSystemMigrationCapabilities", + "KVM_VirtualSystemMigrationCapabilities", + NULL +}; + +static char* migrate_sd[] = { + "Xen_VirtualSystemMigrationSettingData", + "KVM_VirtualSystemMigrationSettingData", + NULL +}; + +static struct std_assoc _migrate_cap_to_vsmsd = { + .source_class = (char**)&migrate_cap, + .source_prop = "GroupComponent", + + .target_class = (char**)&migrate_sd, + .target_prop = "PartComponent", + + .assoc_class = (char**)&assoc_classname, + + .handler = migrate_cap_to_vsmsd, + .make_ref = make_ref +}; + +static struct std_assoc _vsmsd_to_migrate_cap = { + .source_class = (char**)&migrate_sd, + .source_prop = "PartComponent", + + .target_class = (char**)&migrate_cap, + .target_prop = "GroupComponent", + + .assoc_class = (char**)&assoc_classname, + + .handler = vsmsd_to_migrate_cap, + .make_ref = make_ref +}; + static struct std_assoc *assoc_handlers[] = { &_alloc_cap_to_rasd, &_rasd_to_alloc_cap, + &_migrate_cap_to_vsmsd, + &_vsmsd_to_migrate_cap, NULL }; From kaitlin at linux.vnet.ibm.com Thu Feb 28 22:51:14 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 14:51:14 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] VSMigrationSettingData and VSMigrationCapabilities updates Message-ID: Add support to SDC fot VSMigrationSD and VSMigrationCapabilities. Also fix VSMigrationCapabilities superclass prefix. From kaitlin at linux.vnet.ibm.com Thu Feb 28 23:25:15 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Thu, 28 Feb 2008 15:25:15 -0800 Subject: [Libvirt-cim] [PATCH 0 of 3] (#4) Add VirtualSystemSnapshotService In-Reply-To: References: Message-ID: <47C742DB.8060307@linux.vnet.ibm.com> Dan Smith wrote: > Added missing header (hopefully) and removed the extra CMSetNameSpace() > I haven't really tested this (beyond enumerating the instances of the new classes), however, I have no complaints looking at the code. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From zli at linux.vnet.ibm.com Fri Feb 29 01:43:22 2008 From: zli at linux.vnet.ibm.com (Zhengang Li) Date: Fri, 29 Feb 2008 09:43:22 +0800 Subject: [Libvirt-cim] [PATCH] [CU] Fix const pointer warning In-Reply-To: <87r6exca29.fsf@caffeine.beaverton.ibm.com> References: <8ef92e008bcbcf2336cb.1204076907@localhost.localdomain> <87r6exca29.fsf@caffeine.beaverton.ibm.com> Message-ID: <47C7633A.6040400@linux.vnet.ibm.com> Dan Smith wrote: > ZL> diff -r b2606bc023a8 -r 8ef92e008bcb std_indication.c > ZL> --- a/std_indication.c Tue Feb 26 15:16:00 2008 -0500 > ZL> +++ b/std_indication.c Wed Feb 27 09:48:23 2008 +0800 > ZL> @@ -214,7 +214,7 @@ CMPIStatus stdi_activate_filter(CMPIIndi > ZL> char *cn = NULL; > > ZL> _ctx = (struct std_indication_ctx *)mi->hdl; > ZL> - cn = CLASSNAME(op); > ZL> + cn = (char *)CLASSNAME(op); > ZL> s = stdi_set_ind_filter_state(_ctx, cn, true); > > Shouldn't we change cn to be a const char *, instead of casting it to > char *? It was my 1st idea. And then it turns out the 2nd param to stdi_set_ind_filter_state() is a 'char *'. Change that, too? > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- - Zhengang From danms at us.ibm.com Fri Feb 29 02:05:46 2008 From: danms at us.ibm.com (Dan Smith) Date: Thu, 28 Feb 2008 18:05:46 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Fix const pointer warning In-Reply-To: <47C7633A.6040400@linux.vnet.ibm.com> (Zhengang Li's message of "Fri, 29 Feb 2008 09:43:22 +0800") References: <8ef92e008bcbcf2336cb.1204076907@localhost.localdomain> <87r6exca29.fsf@caffeine.beaverton.ibm.com> <47C7633A.6040400@linux.vnet.ibm.com> Message-ID: <87ejawbjph.fsf@caffeine.beaverton.ibm.com> ZL> It was my 1st idea. And then it turns out the 2nd param to ZL> stdi_set_ind_filter_state() is a 'char *'. Change that, too? Please do :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From heidieck at linux.vnet.ibm.com Fri Feb 29 09:42:28 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 29 Feb 2008 10:42:28 +0100 Subject: [Libvirt-cim] [PATCH 0 of 2] VSMigrationSettingData and VSMigrationCapabilities updates In-Reply-To: References: Message-ID: <47C7D384.7020309@linux.vnet.ibm.com> Kaitlin Rupert wrote: > Add support to SDC fot VSMigrationSD and VSMigrationCapabilities. > > Also fix VSMigrationCapabilities superclass prefix. > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > Great :) ! +1 -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 29 09:48:45 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 29 Feb 2008 10:48:45 +0100 Subject: [Libvirt-cim] [PATCH 0 of 3] (#4) Add VirtualSystemSnapshotService In-Reply-To: References: Message-ID: <47C7D4FD.4080302@linux.vnet.ibm.com> Dan Smith wrote: > Added missing header (hopefully) and removed the extra CMSetNameSpace() > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > Also for me its ready to go ... +1. Great work :) ! -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 29 09:06:19 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 29 Feb 2008 10:06:19 +0100 Subject: [Libvirt-cim] [PATCH 0 of 4] Update VSMigrationService to support static and offline migration In-Reply-To: <47C6EE07.6060004@linux.vnet.ibm.com> References: <47C6A656.1010105@linux.vnet.ibm.com> <47C6EE07.6060004@linux.vnet.ibm.com> Message-ID: <47C7CB0B.4080409@linux.vnet.ibm.com> Kaitlin Rupert wrote: > You'll want the DestinationSystem to be the reference of > KVM_HostSystem on the target machine. > > So, something like: > > > > > > > > > > > KVM_HostSystem > > > target_sys_hostname > > > > > > Thanks. I was able to send the request and got a valid result. Well, the migration failed - but I saw the provider working fine :). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 29 09:06:35 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 29 Feb 2008 10:06:35 +0100 Subject: [Libvirt-cim] [PATCH 0 of 4] Update VSMigrationService to support static and offline migration In-Reply-To: <47C6EE07.6060004@linux.vnet.ibm.com> References: <47C6A656.1010105@linux.vnet.ibm.com> <47C6EE07.6060004@linux.vnet.ibm.com> Message-ID: <47C7CB1B.8000207@linux.vnet.ibm.com> Kaitlin Rupert wrote: > You'll want the DestinationSystem to be the reference of > KVM_HostSystem on the target machine. > > So, something like: > > > > > > > > > > > KVM_HostSystem > > > target_sys_hostname > > > > > > Thanks. I was able to send the request and got a valid result. Well, the migration failed - but I saw the provider working fine :). An excellent work :). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor From heidieck at linux.vnet.ibm.com Fri Feb 29 12:30:32 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 29 Feb 2008 13:30:32 +0100 Subject: [Libvirt-cim] [PATCH 0 of 5] Update single instance interface on HostSystem and Adopt HostSystem interface to assocs Message-ID: This patch set update the HostSystem provider to follow the common look and feel of single instance providers. The interface changes on HostSystem have been adopted to the associations HD, HRP, EC and HS. From heidieck at linux.vnet.ibm.com Fri Feb 29 12:30:33 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 29 Feb 2008 13:30:33 +0100 Subject: [Libvirt-cim] [PATCH 1 of 5] HostSystem: adopt interface of single instance providers In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1204286653 -3600 # Node ID b0bc7c2f51e4585b3b0f3d2548ccee6e625aa670 # Parent 2fe6a1864de83ecfabf7eaae8c9a912af39b8ecc HostSystem: adopt interface of single instance providers During the last updates to single instance providers, a common interface look and feel has established. This patch adopts these changes to HostSystem. Signed-off-by: Heidi Eckhart diff -r 2fe6a1864de8 -r b0bc7c2f51e4 src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Thu Feb 28 14:43:44 2008 -0800 +++ b/src/Virt_HostSystem.c Fri Feb 29 13:04:13 2008 +0100 @@ -36,19 +36,6 @@ const static CMPIBroker *_BROKER; -CMPIStatus validate_host_ref(const CMPIBroker *broker, - const CMPIObjectPath *ref) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - - s = get_host_cs(broker, ref, &inst); - if (inst != NULL) - s = cu_validate_ref(broker, ref, inst); - - return s; -} - static int set_host_system_properties(CMPIInstance *instance) { CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -70,18 +57,23 @@ static int set_host_system_properties(CM return 1; } -CMPIStatus get_host_cs(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **instance) +CMPIStatus get_host(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst, + bool is_get_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; virConnectPtr conn = NULL; - *instance = NULL; conn = connect_by_classname(broker, CLASSNAME(reference), &s); - if (conn == NULL) - return s; + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } inst = get_typed_instance(broker, pfx_from_conn(conn), @@ -97,43 +89,36 @@ CMPIStatus get_host_cs(const CMPIBroker set_host_system_properties(inst); - out: - virConnectClose(conn); - *instance = inst; - - return s; -} - -static CMPIStatus return_host_cs(const CMPIObjectPath *reference, - const CMPIResult *results, - bool name_only, - bool is_get_inst) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *instance; - - s = get_host_cs(_BROKER, reference, &instance); - if (s.rc != CMPI_RC_OK) - goto out; - - if (instance == NULL) { - if (is_get_inst) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance"); - goto out; - } - if (is_get_inst) { - s = cu_validate_ref(_BROKER, reference, instance); + s = cu_validate_ref(broker, reference, inst); if (s.rc != CMPI_RC_OK) goto out; } + *_inst = inst; + + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_host(const CMPIObjectPath *reference, + const CMPIResult *results, + bool name_only, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_host(_BROKER, reference, &inst, is_get_inst); + if (s.rc != CMPI_RC_OK || inst == NULL) + goto out; + if (name_only) - cu_return_instance_name(results, instance); + cu_return_instance_name(results, inst); else - CMReturnInstance(results, instance); + CMReturnInstance(results, inst); out: return s; @@ -147,8 +132,8 @@ CMPIStatus get_host_system_properties(co CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *host = NULL; - s = get_host_cs(broker, ref, &host); - if (s.rc != CMPI_RC_OK) + s = get_host(broker, ref, &host, false); + if (s.rc != CMPI_RC_OK || host == NULL) goto out; if (cu_get_str_prop(host, "Name", name) != CMPI_RC_OK) { @@ -174,10 +159,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_host_cs(reference, - results, - true, - false); + return return_host(reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -187,10 +169,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_host_cs(reference, - results, - false, - false); + return return_host(reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -199,10 +178,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - return return_host_cs(reference, - results, - false, - true); + return return_host(reference, results, false, true); } DEFAULT_CI(); diff -r 2fe6a1864de8 -r b0bc7c2f51e4 src/Virt_HostSystem.h --- a/src/Virt_HostSystem.h Thu Feb 28 14:43:44 2008 -0800 +++ b/src/Virt_HostSystem.h Fri Feb 29 13:04:13 2008 +0100 @@ -21,16 +21,14 @@ #ifndef __VIRT_HOSTSYSTEM_H #define __VIRT_HOSTSYSTEM_H -CMPIStatus get_host_cs(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **instance); +CMPIStatus get_host(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst, + bool is_get_inst); CMPIStatus get_host_system_properties(const char **name, const char **ccname, const CMPIObjectPath *ref, const CMPIBroker *broker); -CMPIStatus validate_host_ref(const CMPIBroker *broker, - const CMPIObjectPath *ref); - #endif From heidieck at linux.vnet.ibm.com Fri Feb 29 12:30:34 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 29 Feb 2008 13:30:34 +0100 Subject: [Libvirt-cim] [PATCH 2 of 5] HD: validate client given object path In-Reply-To: Message-ID: <2c8c7521952cbd89db59.1204288234@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1204286655 -3600 # Node ID 2c8c7521952cbd89db590822bca22775f07fc8e2 # Parent b0bc7c2f51e4585b3b0f3d2548ccee6e625aa670 HD: validate client given object path wbemain -ac KVM_HostedDependency 'http://localhost/root/virt:KVM_HostSystem.CreationClassName="KVM_HostSystem",Name="wrong"' returns instances instead of NOT_FOUND wbemain -ac CIM_HostedDependency 'http://localhost/root/virt:KVM_ComputerSystem.CreationClassName="KVM_ComputerSystem",Name="wrong"' returns an instance instead of NOT_FOUND Signed-off-by: Heidi Eckhart diff -r b0bc7c2f51e4 -r 2c8c7521952c src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Fri Feb 29 13:04:13 2008 +0100 +++ b/src/Virt_HostedDependency.c Fri Feb 29 13:04:15 2008 +0100 @@ -41,15 +41,20 @@ static CMPIStatus vs_to_host(const CMPIO struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *instance; + CMPIInstance *instance = NULL; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; - s = get_host_cs(_BROKER, ref, &instance); + s = get_domain(_BROKER, ref, &instance); + if (s.rc != CMPI_RC_OK) + goto out; + + s = get_host(_BROKER, ref, &instance, false); if (s.rc == CMPI_RC_OK) inst_list_add(list, instance); + out: return s; } @@ -60,29 +65,29 @@ static CMPIStatus host_to_vs(const CMPIO int ret; virConnectPtr conn; CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *instance = NULL; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; + + s = get_host(_BROKER, ref, &instance, true); + if (s.rc != CMPI_RC_OK) + goto out; conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) - return s; + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; ret = enum_domains(_BROKER, conn, NAMESPACE(ref), list); - if (ret) { - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - } else { + if (!ret) cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Failed to get domain list"); - } - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - + out: return s; } From heidieck at linux.vnet.ibm.com Fri Feb 29 12:30:35 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 29 Feb 2008 13:30:35 +0100 Subject: [Libvirt-cim] [PATCH 3 of 5] HRP: adopt HostSystem interface changes In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1204286656 -3600 # Node ID a637832c90faefaf61e674740089774baca4abb9 # Parent 2c8c7521952cbd89db590822bca22775f07fc8e2 HRP: adopt HostSystem interface changes Signed-off-by: Heidi Eckhart diff -r 2c8c7521952c -r a637832c90fa src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Fri Feb 29 13:04:15 2008 +0100 +++ b/src/Virt_HostedResourcePool.c Fri Feb 29 13:04:16 2008 +0100 @@ -41,23 +41,23 @@ static CMPIStatus pool_to_sys(const CMPI struct std_assoc_info *info, struct inst_list *list) { - CMPIInstance *host; CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; + CMPIInstance *inst = NULL; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; s = get_pool_inst(_BROKER, ref, &inst); if ((s.rc != CMPI_RC_OK) || (inst == NULL)) - return s; + goto out; - s = get_host_cs(_BROKER, ref, &host); + s = get_host(_BROKER, ref, &inst, false); if (s.rc != CMPI_RC_OK) - return s; + goto out; - inst_list_add(list, host); + inst_list_add(list, inst); + out: return s; } @@ -66,19 +66,20 @@ static CMPIStatus sys_to_pool(const CMPI struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; int i; virConnectPtr conn; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; - s = validate_host_ref(_BROKER, ref); + s = get_host(_BROKER, ref, &inst, true); if (s.rc != CMPI_RC_OK) - return s; + goto out; conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) - return s; + goto out; for (i = 0; device_pool_names[i]; i++) get_pool_by_type(_BROKER, @@ -87,10 +88,7 @@ static CMPIStatus sys_to_pool(const CMPI NAMESPACE(ref), list); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - + out: return s; } From heidieck at linux.vnet.ibm.com Fri Feb 29 12:30:36 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 29 Feb 2008 13:30:36 +0100 Subject: [Libvirt-cim] [PATCH 4 of 5] EC: adopt HostSystem interface changes In-Reply-To: Message-ID: <9516232d810b1b7a0e5c.1204288236@localhost.localdomain> # HG changeset patch # User Heidi Eckhart # Date 1204286657 -3600 # Node ID 9516232d810b1b7a0e5c9da5801ef96fdbc1775e # Parent a637832c90faefaf61e674740089774baca4abb9 EC: adopt HostSystem interface changes Signed-off-by: Heidi Eckhart diff -r a637832c90fa -r 9516232d810b src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Fri Feb 29 13:04:16 2008 +0100 +++ b/src/Virt_ElementCapabilities.c Fri Feb 29 13:04:17 2008 +0100 @@ -125,13 +125,13 @@ static CMPIStatus sys_to_cap(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - CMPIInstance *inst; - CMPIStatus s = {CMPI_RC_OK, NULL}; - - if (!match_hypervisor_prefix(ref, info)) - goto out; - - s = validate_host_ref(_BROKER, ref); + CMPIInstance *inst = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + if (!match_hypervisor_prefix(ref, info)) + goto out; + + s = get_host(_BROKER, ref, &inst, true); if (s.rc != CMPI_RC_OK) goto out; @@ -164,7 +164,7 @@ static CMPIStatus cap_to_sys_or_service( if (inst != NULL) inst_list_add(list, inst); - s = get_host_cs(_BROKER, ref, &inst); + s = get_host(_BROKER, ref, &inst, false); if (s.rc != CMPI_RC_OK) goto out; From heidieck at linux.vnet.ibm.com Fri Feb 29 12:30:37 2008 From: heidieck at linux.vnet.ibm.com (Heidi Eckhart) Date: Fri, 29 Feb 2008 13:30:37 +0100 Subject: [Libvirt-cim] [PATCH 5 of 5] HS: adopt HostSystem interface changes In-Reply-To: Message-ID: # HG changeset patch # User Heidi Eckhart # Date 1204286657 -3600 # Node ID cddf4a1cab91fa0a375dfb18c7780022e7f322b9 # Parent 9516232d810b1b7a0e5c9da5801ef96fdbc1775e HS: adopt HostSystem interface changes Signed-off-by: Heidi Eckhart diff -r 9516232d810b -r cddf4a1cab91 src/Makefile.am --- a/src/Makefile.am Fri Feb 29 13:04:17 2008 +0100 +++ b/src/Makefile.am Fri Feb 29 13:04:17 2008 +0100 @@ -54,10 +54,10 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_SettingsDefineState.la \ libVirt_ResourceAllocationFromPool.la \ libVirt_ElementAllocatedFromPool.la \ + libVirt_VSMigrationService.la \ libVirt_HostedService.la \ libVirt_ElementSettingData.la \ libVirt_VSMigrationCapabilities.la \ - libVirt_VSMigrationService.la \ libVirt_VSMigrationSettingData.la \ libVirt_VirtualSystemSnapshotService.la \ libVirt_VirtualSystemSnapshotServiceCapabilities.la diff -r 9516232d810b -r cddf4a1cab91 src/Virt_HostedService.c --- a/src/Virt_HostedService.c Fri Feb 29 13:04:17 2008 +0100 +++ b/src/Virt_HostedService.c Fri Feb 29 13:04:17 2008 +0100 @@ -40,8 +40,7 @@ static CMPIStatus validate_service_ref(c static CMPIStatus validate_service_ref(const CMPIObjectPath *ref) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - const char *prop; + CMPIInstance *inst = NULL; char* classname; classname = class_base_name(CLASSNAME(ref)); @@ -54,17 +53,6 @@ static CMPIStatus validate_service_ref(c s = get_migration_service(ref, &inst, _BROKER, true); } - if (s.rc != CMPI_RC_OK) - goto out; - - prop = cu_compare_ref(ref, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } - - out: free(classname); return s; @@ -75,7 +63,7 @@ static CMPIStatus service_to_host(const struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *instance; + CMPIInstance *instance = NULL; if (!match_hypervisor_prefix(ref, info)) return s; @@ -84,7 +72,7 @@ static CMPIStatus service_to_host(const if (s.rc != CMPI_RC_OK) return s; - s = get_host_cs(_BROKER, ref, &instance); + s = get_host(_BROKER, ref, &instance, false); if (s.rc == CMPI_RC_OK) inst_list_add(list, instance); @@ -96,12 +84,12 @@ static CMPIStatus host_to_service(const struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; + CMPIInstance *inst = NULL; if (!match_hypervisor_prefix(ref, info)) return s; - s = validate_host_ref(_BROKER, ref); + s = get_host(_BROKER, ref, &inst, true); if (s.rc != CMPI_RC_OK) return s; From danms at us.ibm.com Fri Feb 29 14:49:57 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 29 Feb 2008 06:49:57 -0800 Subject: [Libvirt-cim] [PATCH] [CU] Add set_int_property() function to EO parse In-Reply-To: <47C72F56.8030405@linux.vnet.ibm.com> (Kaitlin Rupert's message of "Thu, 28 Feb 2008 14:01:58 -0800") References: <64e51763141e107bc897.1204130656@elm3b41.beaverton.ibm.com> <87myplc97h.fsf@caffeine.beaverton.ibm.com> <47C72F56.8030405@linux.vnet.ibm.com> Message-ID: <87tzjrakbu.fsf@caffeine.beaverton.ibm.com> KR> I think you can leave this off for integer types - it seems to KR> work both with and without. The original call in eo_util_parse.y KR> didn't have it. But I need to resend, so I'll add it for KR> consistency =) No, it works in the original code because we don't have -Winsane and -Werror turned on for the EO parser stuff. The rest of the code is so bad that it wouldn't compile otherwise. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms at us.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From danms at us.ibm.com Fri Feb 29 19:28:30 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 29 Feb 2008 11:28:30 -0800 Subject: [Libvirt-cim] [PATCH 2 of 2] Add missing error path In-Reply-To: Message-ID: <282e58e792ba318b6332.1204313310@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1204313296 28800 # Node ID 282e58e792ba318b63329420d3918b02e9af7dd5 # Parent 7ac86cfb8d9344f583998d028ac235dcdeba657b Add missing error path Signed-off-by: Dan Smith diff -r 7ac86cfb8d93 -r 282e58e792ba std_indication.c --- a/std_indication.c Fri Feb 29 11:27:21 2008 -0800 +++ b/std_indication.c Fri Feb 29 11:28:16 2008 -0800 @@ -133,6 +133,7 @@ static CMPIStatus raise(struct std_indic cu_statusf(ctx->brkr, &s, CMPI_RC_ERR_FAILED, "Couldn't get indication name for enable check."); + goto out; } enabled = is_ind_enabled(ctx, ind_name, &s); From danms at us.ibm.com Fri Feb 29 19:28:28 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 29 Feb 2008 11:28:28 -0800 Subject: [Libvirt-cim] [PATCH 0 of 2] Fixes to std_indication Message-ID: Need these to work on pegasus and handle errors properly. From danms at us.ibm.com Fri Feb 29 19:28:29 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 29 Feb 2008 11:28:29 -0800 Subject: [Libvirt-cim] [PATCH 1 of 2] Change "Indication" parameter name to something that isn't a CIM Qualifier In-Reply-To: Message-ID: <7ac86cfb8d9344f58399.1204313309@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1204313241 28800 # Node ID 7ac86cfb8d9344f583998d028ac235dcdeba657b # Parent b41ff87168e31ff492d98b3741b28c4fe0d7c089 Change "Indication" parameter name to something that isn't a CIM Qualifier Signed-off-by: Dan Smith diff -r b41ff87168e3 -r 7ac86cfb8d93 std_indication.c --- a/std_indication.c Thu Feb 28 13:55:49 2008 -0800 +++ b/std_indication.c Fri Feb 29 11:27:21 2008 -0800 @@ -121,7 +121,7 @@ static CMPIStatus raise(struct std_indic CMPIStatus s = {CMPI_RC_OK, NULL}; const char *ind_name = NULL; - if (cu_get_inst_arg(argsin, "Indication", &inst) != CMPI_RC_OK) { + if (cu_get_inst_arg(argsin, "TheIndication", &inst) != CMPI_RC_OK) { cu_statusf(ctx->brkr, &s, CMPI_RC_ERR_FAILED, "Could not get indication to raise"); @@ -370,7 +370,7 @@ CMPIStatus stdi_raise_indication(const C if (s.rc != CMPI_RC_OK) return s; - s = CMAddArg(argsin, "Indication", &ind, CMPI_instance); + s = CMAddArg(argsin, "TheIndication", &ind, CMPI_instance); if (s.rc != CMPI_RC_OK) return s; From grendel at linux.vnet.ibm.com Fri Feb 29 19:56:15 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 29 Feb 2008 14:56:15 -0500 Subject: [Libvirt-cim] [PATCH 1 of 2] Change "Indication" parameter name to something that isn't a CIM Qualifier In-Reply-To: <7ac86cfb8d9344f58399.1204313309@caffeine.beaverton.ibm.com> References: <7ac86cfb8d9344f58399.1204313309@caffeine.beaverton.ibm.com> Message-ID: <47C8635F.1060701@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1204313241 28800 > # Node ID 7ac86cfb8d9344f583998d028ac235dcdeba657b > # Parent b41ff87168e31ff492d98b3741b28c4fe0d7c089 > Change "Indication" parameter name to something that isn't a CIM Qualifier > > Signed-off-by: Dan Smith > > > I guess those people who haven't gone through what was required to figure out that we needed this are just going to have to trust us on this one; this is actually an important change. Thanks, pegasus. -- -Jay From grendel at linux.vnet.ibm.com Fri Feb 29 19:58:51 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 29 Feb 2008 14:58:51 -0500 Subject: [Libvirt-cim] [PATCH 2 of 2] Add missing error path In-Reply-To: <282e58e792ba318b6332.1204313310@caffeine.beaverton.ibm.com> References: <282e58e792ba318b6332.1204313310@caffeine.beaverton.ibm.com> Message-ID: <47C863FB.5000906@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1204313296 28800 > # Node ID 282e58e792ba318b63329420d3918b02e9af7dd5 > # Parent 7ac86cfb8d9344f583998d028ac235dcdeba657b > Add missing error path > > Signed-off-by: Dan Smith > > > Totally my bad here. Thanks! -- -Jay From kaitlin at linux.vnet.ibm.com Fri Feb 29 20:01:57 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 29 Feb 2008 12:01:57 -0800 Subject: [Libvirt-cim] [PATCH] Fix missing braces in HD Message-ID: <9ca3b9b245f8af8f960a.1204315317@elm3b41.beaverton.ibm.com> # HG changeset patch # User Kaitlin Rupert # Date 1204315089 28800 # Node ID 9ca3b9b245f8af8f960a4d1e3557adf536daabee # Parent b2f223ca9105b8f416ab768a1363df910d6815d4 Fix missing braces in HD. Some missing braces cause host_to_vs() to exit before enumerating the instances. Signed-off-by: Kaitlin Rupert diff -r b2f223ca9105 -r 9ca3b9b245f8 src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Fri Feb 29 13:04:15 2008 +0100 +++ b/src/Virt_HostedDependency.c Fri Feb 29 11:58:09 2008 -0800 @@ -75,11 +75,12 @@ static CMPIStatus host_to_vs(const CMPIO goto out; conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) + if (conn == NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_NOT_FOUND, "No such instance"); goto out; + } ret = enum_domains(_BROKER, conn, NAMESPACE(ref), list); if (!ret) From grendel at linux.vnet.ibm.com Fri Feb 29 20:09:47 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 29 Feb 2008 15:09:47 -0500 Subject: [Libvirt-cim] [PATCH] Fix missing braces in HD In-Reply-To: <9ca3b9b245f8af8f960a.1204315317@elm3b41.beaverton.ibm.com> References: <9ca3b9b245f8af8f960a.1204315317@elm3b41.beaverton.ibm.com> Message-ID: <47C8668B.1010803@linux.vnet.ibm.com> Kaitlin Rupert wrote: > # HG changeset patch > # User Kaitlin Rupert > # Date 1204315089 28800 > # Node ID 9ca3b9b245f8af8f960a4d1e3557adf536daabee > # Parent b2f223ca9105b8f416ab768a1363df910d6815d4 > Fix missing braces in HD. > > Some missing braces cause host_to_vs() to exit before enumerating the instances. > > Good thing we have ole Eagle Eyes Rupert on the job. +1 -- -Jay From danms at us.ibm.com Fri Feb 29 20:31:28 2008 From: danms at us.ibm.com (Dan Smith) Date: Fri, 29 Feb 2008 12:31:28 -0800 Subject: [Libvirt-cim] [PATCH] Fix const usage for F9 compile Message-ID: <55cdc06dc576fe541829.1204317088@caffeine.beaverton.ibm.com> # HG changeset patch # User Dan Smith # Date 1204317078 28800 # Node ID 55cdc06dc576fe5418292622daf15acd9b7c3dc8 # Parent 282e58e792ba318b63329420d3918b02e9af7dd5 Fix const usage for F9 compile Signed-off-by: Dan Smith diff -r 282e58e792ba -r 55cdc06dc576 instance_util.c --- a/instance_util.c Fri Feb 29 11:28:16 2008 -0800 +++ b/instance_util.c Fri Feb 29 12:31:18 2008 -0800 @@ -255,7 +255,7 @@ CMPIInstance *cu_dup_instance(const CMPI const char *cu_classname_from_inst(CMPIInstance *inst) { - char *ret = NULL; + const char *ret = NULL; CMPIObjectPath *ref; ref = CMGetObjectPath(inst, NULL); diff -r 282e58e792ba -r 55cdc06dc576 std_indication.c --- a/std_indication.c Fri Feb 29 11:28:16 2008 -0800 +++ b/std_indication.c Fri Feb 29 12:31:18 2008 -0800 @@ -183,7 +183,7 @@ CMPIStatus stdi_deliver(const CMPIBroker } CMPIStatus stdi_set_ind_filter_state(struct std_indication_ctx *ctx, - char *ind_name, + const char *ind_name, bool state) { CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -212,7 +212,7 @@ CMPIStatus stdi_activate_filter(CMPIIndi { CMPIStatus s = {CMPI_RC_OK, NULL}; struct std_indication_ctx *_ctx; - char *cn = NULL; + const char *cn = NULL; _ctx = (struct std_indication_ctx *)mi->hdl; cn = CLASSNAME(op); @@ -237,7 +237,7 @@ CMPIStatus stdi_deactivate_filter(CMPIIn { CMPIStatus s = {CMPI_RC_OK, NULL}; struct std_indication_ctx *_ctx; - char *cn = NULL; + const char *cn = NULL; _ctx = (struct std_indication_ctx *)mi->hdl; cn = CLASSNAME(op); diff -r 282e58e792ba -r 55cdc06dc576 std_indication.h --- a/std_indication.h Fri Feb 29 11:28:16 2008 -0800 +++ b/std_indication.h Fri Feb 29 12:31:18 2008 -0800 @@ -144,7 +144,7 @@ CMPIStatus stdi_cleanup(CMPIMethodMI *se CMPIBoolean terminating); CMPIStatus stdi_set_ind_filter_state(struct std_indication_ctx *ctx, - char *ind_name, + const char *ind_name, bool state); /* This doesn't work, but should be made to. */ From kaitlin at linux.vnet.ibm.com Fri Feb 29 20:42:50 2008 From: kaitlin at linux.vnet.ibm.com (Kaitlin Rupert) Date: Fri, 29 Feb 2008 12:42:50 -0800 Subject: [Libvirt-cim] [PATCH] Fix const usage for F9 compile In-Reply-To: <55cdc06dc576fe541829.1204317088@caffeine.beaverton.ibm.com> References: <55cdc06dc576fe541829.1204317088@caffeine.beaverton.ibm.com> Message-ID: <47C86E4A.9000304@linux.vnet.ibm.com> Dan Smith wrote: > # HG changeset patch > # User Dan Smith > # Date 1204317078 28800 > # Node ID 55cdc06dc576fe5418292622daf15acd9b7c3dc8 > # Parent 282e58e792ba318b63329420d3918b02e9af7dd5 > Fix const usage for F9 compile > > Signed-off-by: Dan Smith > > diff -r 282e58e792ba -r 55cdc06dc576 instance_util.c Went through std_indication.c and instance_util.c - I didn't see any additional char * that needed to be changed. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin at linux.vnet.ibm.com From grendel at linux.vnet.ibm.com Fri Feb 29 20:09:47 2008 From: grendel at linux.vnet.ibm.com (Jay Gagnon) Date: Fri, 29 Feb 2008 15:09:47 -0500 Subject: [Libvirt-cim] [PATCH] Fix missing braces in HD In-Reply-To: <9ca3b9b245f8af8f960a.1204315317@elm3b41.beaverton.ibm.com> References: <9ca3b9b245f8af8f960a.1204315317@elm3b41.beaverton.ibm.com> Message-ID: <47C8668B.1010803@linux.vnet.ibm.com> Kaitlin Rupert wrote: > # HG changeset patch > # User Kaitlin Rupert > # Date 1204315089 28800 > # Node ID 9ca3b9b245f8af8f960a4d1e3557adf536daabee > # Parent b2f223ca9105b8f416ab768a1363df910d6815d4 > Fix missing braces in HD. > > Some missing braces cause host_to_vs() to exit before enumerating the instances. > > Good thing we have ole Eagle Eyes Rupert on the job. +1 -- -Jay