[Libvirt-cim] [PATCH 1 of 2] Add helper function to check for matching hypervisor class prefixes

Heidi Eckhart heidieck at linux.vnet.ibm.com
Wed Nov 28 10:18:28 UTC 2007


# HG changeset patch
# User Heidi Eckhart <heidieck at 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 at 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




More information about the Libvirt-cim mailing list