[PATCH] (#2) Add domain ref checking to isMigratable

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1205365783 25200 # Node ID c655c11291a0817c4a804f41bcaa64bbcd34efc5 # Parent b739fc9b13320e07a39f3932396c8411c2d4ad75 (#2) Add domain ref checking to isMigratable Tested by adding an invalid key to the ComputerSystem REF, which would pass before. It now fails and points out the offending key, as expected. Changes: - Link to libVirt_ComputerSystem - Use the proper ref and set the namespace, since it's not done for us - Move the Name key extraction up a level to reduce duplication and make the CS ref available for the get_domain_by_ref() call Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r b739fc9b1332 -r c655c11291a0 src/Makefile.am --- a/src/Makefile.am Tue Mar 11 13:28:04 2008 -0700 +++ b/src/Makefile.am Wed Mar 12 16:49:43 2008 -0700 @@ -163,9 +163,9 @@ libVirt_ElementSettingData_la_LIBADD = - libVirt_VSMigrationCapabilities_la_SOURCES = Virt_VSMigrationCapabilities.c -libVirt_VSMigrationService_la_DEPENDENCIES = libVirt_HostSystem.la libVirt_VSMigrationSettingData.la +libVirt_VSMigrationService_la_DEPENDENCIES = libVirt_HostSystem.la libVirt_VSMigrationSettingData.la libVirt_ComputerSystem.la libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c -libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem -lVirt_VSMigrationSettingData +libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem -lVirt_VSMigrationSettingData -lVirt_ComputerSystem libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c diff -r b739fc9b1332 -r c655c11291a0 src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Tue Mar 11 13:28:04 2008 -0700 +++ b/src/Virt_VSMigrationService.c Wed Mar 12 16:49:43 2008 -0700 @@ -38,6 +38,7 @@ #include "Virt_VSMigrationService.h" #include "Virt_HostSystem.h" +#include "Virt_ComputerSystem.h" #include "Virt_VSMigrationSettingData.h" #define CIM_JOBSTATE_STARTING 3 @@ -263,7 +264,7 @@ static CMPIStatus check_hver(virConnectP } static CMPIStatus vs_migratable(const CMPIObjectPath *ref, - const char *domain, + CMPIObjectPath *system, const char *destination, const CMPIResult *results, const CMPIArgs *argsin, @@ -276,6 +277,15 @@ static CMPIStatus vs_migratable(const CM CMPIBoolean isMigratable = 0; uint16_t type; virDomainPtr dom = NULL; + CMPIInstance *dominst; + const char *domain; + + if (cu_get_str_path(system, "Name", &domain) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Missing key (Name) in ComputerSystem"); + goto out; + } s = get_msd_values(ref, destination, argsin, &type, &dconn); if (s.rc != CMPI_RC_OK) @@ -296,6 +306,11 @@ static CMPIStatus vs_migratable(const CM "No such domain"); goto out; } + + CMSetNameSpace(system, NAMESPACE(ref)); + s = get_domain_by_ref(_BROKER, system, &dominst); + if (s.rc != CMPI_RC_OK) + goto out; s = check_caps(conn, dconn); if (s.rc != CMPI_RC_OK) @@ -329,18 +344,9 @@ static CMPIStatus vs_migratable_host(CMP CMPIStatus s; const char *dhost = NULL; CMPIObjectPath *system; - const char *name = NULL; cu_get_str_arg(argsin, "DestinationHost", &dhost); cu_get_ref_arg(argsin, "ComputerSystem", &system); - - if (cu_get_str_path(system, "Name", &name) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Missing key (Name) in ComputerSystem"); - METHOD_RETURN(results, 1); - return s; - } if (!check_refs_pfx_match(ref, system)) { cu_statusf(_BROKER, &s, @@ -350,7 +356,7 @@ static CMPIStatus vs_migratable_host(CMP return s; } - return vs_migratable(ref, name, dhost, results, argsin, argsout); + return vs_migratable(ref, system, dhost, results, argsin, argsout); } static CMPIStatus vs_migratable_system(CMPIMethodMI *self, @@ -364,7 +370,6 @@ static CMPIStatus vs_migratable_system(C CMPIObjectPath *dsys; CMPIObjectPath *sys; const char *dname; - const char *name; cu_get_ref_arg(argsin, "DestinationSystem", &dsys); cu_get_ref_arg(argsin, "ComputerSystem", &sys); @@ -377,14 +382,6 @@ static CMPIStatus vs_migratable_system(C return s; } - if (cu_get_str_path(sys, "Name", &name) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Missing key (Name) in ComputerSystem"); - METHOD_RETURN(results, 1); - return s; - } - if (!check_refs_pfx_match(ref, sys)) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -393,7 +390,7 @@ static CMPIStatus vs_migratable_system(C return s; } - return vs_migratable(ref, name, dname, results, argsin, argsout); + return vs_migratable(ref, sys, dname, results, argsin, argsout); } static const char *ind_type_to_name(int ind_type)

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1205365783 25200 # Node ID c655c11291a0817c4a804f41bcaa64bbcd34efc5 # Parent b739fc9b13320e07a39f3932396c8411c2d4ad75 (#2) Add domain ref checking to isMigratable
Tested by adding an invalid key to the ComputerSystem REF, which would pass before. It now fails and points out the offending key, as expected.
Changes: - Link to libVirt_ComputerSystem - Use the proper ref and set the namespace, since it's not done for us - Move the Name key extraction up a level to reduce duplication and make the CS ref available for the get_domain_by_ref() call
Signed-off-by: Dan Smith <danms@us.ibm.com>
Looks good from here. +1 -- -Jay

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1205365783 25200 # Node ID c655c11291a0817c4a804f41bcaa64bbcd34efc5 # Parent b739fc9b13320e07a39f3932396c8411c2d4ad75 (#2) Add domain ref checking to isMigratable
Tested by adding an invalid key to the ComputerSystem REF, which would pass before. It now fails and points out the offending key, as expected.
Changes: - Link to libVirt_ComputerSystem - Use the proper ref and set the namespace, since it's not done for us - Move the Name key extraction up a level to reduce duplication and make the CS ref available for the get_domain_by_ref() call
Signed-off-by: Dan Smith <danms@us.ibm.com>
diff -r b739fc9b1332 -r c655c11291a0 src/Makefile.am
This patch works much better. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1205365783 25200 # Node ID c655c11291a0817c4a804f41bcaa64bbcd34efc5 # Parent b739fc9b13320e07a39f3932396c8411c2d4ad75 (#2) Add domain ref checking to isMigratable
Tested by adding an invalid key to the ComputerSystem REF, which would pass before. It now fails and points out the offending key, as expected.
Changes: - Link to libVirt_ComputerSystem - Use the proper ref and set the namespace, since it's not done for us - Move the Name key extraction up a level to reduce duplication and make the CS ref available for the get_domain_by_ref() call
Signed-off-by: Dan Smith <danms@us.ibm.com>
I still have local problems to apply patches, but for me it looks good and I trust the others ... +1 :) -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor
participants (4)
-
Dan Smith
-
Heidi Eckhart
-
Jay Gagnon
-
Kaitlin Rupert