[PATCH 0 of 2] #2 - Check for matching hypervisor prefixes

- renamed helper function to match_hypervisor_prefix to become clearer on the intent - updated ECTP to make use of match_hypervisor_prefix() function If this approach is ok, I can coop up a patch set for all association classes.

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1196245629 -3600 # Node ID 96c97073edc357edb1ff554d8c92207e644998c5 # Parent ebb86619d5ca80ad7815f9d70d2c8a87698a5f0f Add helper function to check for matching hypervisor class prefixes The class prefixes need to be checked for compliance, as a request for KVM_RegisteredProfile with Xen_ECTP as assoc does not return any instances. Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r ebb86619d5ca -r 96c97073edc3 libxkutil/misc_util.c --- a/libxkutil/misc_util.c Wed Nov 28 10:37:10 2007 +0100 +++ b/libxkutil/misc_util.c Wed Nov 28 11:27:09 2007 +0100 @@ -33,6 +33,7 @@ #include "cmpimacs.h" #include "libcmpiutil.h" +#include "std_association.h" #include "misc_util.h" #include "cs_util.h" @@ -304,6 +305,41 @@ bool provider_is_responsible(const CMPIB free(pfx); return rc; } + +bool match_hypervisor_prefix(const CMPIObjectPath *reference, + struct std_assoc_info *info) +{ + char *ref_pfx = NULL; + char *pfx = NULL; + bool rc = true; + + ref_pfx = class_prefix_name(CLASSNAME(reference)); + + if (info->assoc_class) { + pfx = class_prefix_name(info->assoc_class); + + if (!STREQC(ref_pfx, pfx) && + !STREQC("CIM", pfx)) + rc = false; + + free(pfx); + } + + if (info->result_class) { + pfx = class_prefix_name(info->result_class); + + if (!STREQC(ref_pfx, pfx) && + !STREQC("CIM", pfx)) + rc = false; + + free(pfx); + } + + free(ref_pfx); + return rc; +} + + bool domain_online(virDomainPtr dom) { diff -r ebb86619d5ca -r 96c97073edc3 libxkutil/misc_util.h --- a/libxkutil/misc_util.h Wed Nov 28 10:37:10 2007 +0100 +++ b/libxkutil/misc_util.h Wed Nov 28 11:27:09 2007 +0100 @@ -32,6 +32,7 @@ #include "cmpimacs.h" #include <libcmpiutil.h> +#include <std_association.h> /* Check if the provider is reponsible for the given class: * e.g. Xen is running on the system and KVM_... is asked for, @@ -105,6 +106,9 @@ bool libvirt_cim_init(void); #endif +bool match_hypervisor_prefix(const CMPIObjectPath *reference, + struct std_assoc_info *info); + /* * Local Variables: * mode: C

Heidi Eckhart wrote:
# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1196245629 -3600 # Node ID 96c97073edc357edb1ff554d8c92207e644998c5 # Parent ebb86619d5ca80ad7815f9d70d2c8a87698a5f0f Add helper function to check for matching hypervisor class prefixes
The class prefixes need to be checked for compliance, as a request for KVM_RegisteredProfile with Xen_ECTP as assoc does not return any instances. Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com>
This looks like a good set of patches. It seems like a reasonable way to ensure the caller doesn't hand us mismatching VM types. +1 -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1196246395 -3600 # Node ID 89962d7f2e1b440d1ca525a9ec40a6c76cdc0e58 # Parent 96c97073edc357edb1ff554d8c92207e644998c5 ECTP: make use of function to check for hypervisor prefixes Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 96c97073edc3 -r 89962d7f2e1b src/Virt_ElementConformsToProfile.c --- a/src/Virt_ElementConformsToProfile.c Wed Nov 28 11:27:09 2007 +0100 +++ b/src/Virt_ElementConformsToProfile.c Wed Nov 28 11:39:55 2007 +0100 @@ -107,6 +107,9 @@ static CMPIStatus prof_to_elem(const CMP char *id; int i; + if (!match_hypervisor_prefix(ref, info)) + return s; + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL) return s; @@ -146,6 +149,9 @@ static CMPIStatus elem_to_prof(const CMP char *classname; struct reg_prof *candidate; int i; + + if (!match_hypervisor_prefix(ref, info)) + return s; conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); if (conn == NULL)
participants (2)
-
Heidi Eckhart
-
Kaitlin Rupert