[PATCH 0 of 2] (#2) MigrationIndications

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.

# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # 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 <grendel@linux.vnet.ibm.com> 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 <grendel@linux.vnet.ibm.com> + * + * 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 <unistd.h> +#include <stdio.h> +#include <fcntl.h> +#include <string.h> +#include <stdlib.h> +#include <stdbool.h> + +#include <cmpidt.h> +#include <cmpift.h> +#include <cmpimacs.h> + +#include <libvirt/libvirt.h> + +#include <libcmpiutil/libcmpiutil.h> +#include <misc_util.h> +#include <libcmpiutil/std_indication.h> +#include <cs_util.h> + +#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: + */

# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # 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 <grendel@linux.vnet.ibm.com> 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 <libcmpiutil/std_instance.h> #include <libcmpiutil/std_invokemethod.h> +#include <std_indication.h> #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)

Jay Gagnon wrote:
# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # 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 <grendel@linux.vnet.ibm.com>
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 <libcmpiutil/std_instance.h> #include <libcmpiutil/std_invokemethod.h> +#include <std_indication.h>
It's maybe my ignorance now, but should this also be "#include <libcmpiutil/std_indication.h>" as in the lines before ? -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor

Heidi Eckhart wrote:
Jay Gagnon wrote:
# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # 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 <grendel@linux.vnet.ibm.com>
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 <libcmpiutil/std_instance.h> #include <libcmpiutil/std_invokemethod.h> +#include <std_indication.h>
It's maybe my ignorance now, but should this also be "#include <libcmpiutil/std_indication.h>" 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

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@us.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

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@linux.vnet.ibm.com
participants (4)
-
Dan Smith
-
Heidi Eckhart
-
Jay Gagnon
-
Kaitlin Rupert