# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1196167642 -3600
# Node ID 901bcb9e9fb3272956e55b01d2b1eb05f7e35a9c
# Parent 6200efdd04aafa69f2f76b1cbc0c3567406e829f
[RFC] Check for matching hypervisor 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(a)linux.vnet.ibm.com>
diff -r 6200efdd04aa -r 901bcb9e9fb3 libxkutil/misc_util.c
--- a/libxkutil/misc_util.c Tue Nov 27 11:12:59 2007 +0100
+++ b/libxkutil/misc_util.c Tue Nov 27 13:47:22 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,43 @@ bool provider_is_responsible(const CMPIB
free(pfx);
return rc;
}
+
+bool assoc_match_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)) {
+ if (!STREQC("CIM", pfx))
+ rc = false;
+ }
+
+ free(pfx);
+ }
+
+ if (info->result_class) {
+ pfx = class_prefix_name(info->result_class);
+
+ if (!STREQC(ref_pfx, pfx)) {
+ if (!STREQC("CIM", pfx))
+ rc = false;
+ }
+
+ free(pfx);
+ }
+
+ free(ref_pfx);
+ return rc;
+}
+
+
bool domain_online(virDomainPtr dom)
{
diff -r 6200efdd04aa -r 901bcb9e9fb3 libxkutil/misc_util.h
--- a/libxkutil/misc_util.h Tue Nov 27 11:12:59 2007 +0100
+++ b/libxkutil/misc_util.h Tue Nov 27 13:47:22 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 assoc_match_prefix(const CMPIObjectPath *reference,
+ struct std_assoc_info *info);
+
/*
* Local Variables:
* mode: C
diff -r 6200efdd04aa -r 901bcb9e9fb3 src/Virt_ElementConformsToProfile.c
--- a/src/Virt_ElementConformsToProfile.c Tue Nov 27 11:12:59 2007 +0100
+++ b/src/Virt_ElementConformsToProfile.c Tue Nov 27 13:47:22 2007 +0100
@@ -107,6 +107,9 @@ static CMPIStatus prof_to_elem(const CMP
char *id;
int i;
+ if (!assoc_match_prefix(ref, info))
+ goto out;
+
conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
if (conn == NULL)
return s;
@@ -147,6 +150,9 @@ static CMPIStatus elem_to_prof(const CMP
char *classname;
struct reg_prof *candidate;
int i;
+
+ if (!assoc_match_prefix(ref, info))
+ goto out;
conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
if (conn == NULL)
Show replies by date
HE> + if (info->assoc_class) {
HE> + pfx = class_prefix_name(info->assoc_class);
HE> +
HE> + if (!STREQC(ref_pfx, pfx)) {
HE> + if (!STREQC("CIM", pfx))
I would rather this be:
if (!STREQC(ref_pfx, pfx) &&
!STREQC("CIM", pfx))
rc = false;
It cuts down on the nesting and makes the true condition clearer, I
think.
Also, could we name this function a little better to avoid confusion
with the ASSOC_MATCH macro? ASSOC_MATCH should probably be named
ASSOC_MATCH_PN, but it would be easier to make the name of this new
function more explicit.
Thanks!
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms(a)us.ibm.com