Missed some change upstream so squashed this in so everything should be
in sync now.
diff --git a/libvirt-cim.conf b/libvirt-cim.conf
--- a/libvirt-cim.conf
+++ b/libvirt-cim.conf
@@ -6,7 +6,7 @@
#
# readonly (boolean)
-# Defines wether connection to libvirt is read-only or not
+# Defines if connection to libvirt is read-only or not
# Possible values: {true,false}
# Default value: false
#
diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c
--- a/libxkutil/misc_util.c
+++ b/libxkutil/misc_util.c
@@ -66,8 +66,8 @@
ret = config_read_file(&conf, LIBVIRTCIM_CONF);
if (ret == CONFIG_FALSE) {
- CU_DEBUG("Error reading config file(%d): '%s'\n",
- conf.error_type, conf.error_text);
+ CU_DEBUG("Error reading config file at liine %d:
'%s'\n",
+ conf.error_line, conf.error_text);
goto out;
}
On 06/28/2011 03:30 PM, Chip Vincent wrote:
According to cimtest, setting readonly = true works. I see lots of
this
on RHEL 6:
omputerSystem - 41_cs_to_settingdefinestate.py: FAIL
ERROR - Got CIM error Unauthorized with return code 0
ERROR - Failed to define the dom: CrossClass_GuestDom
InvokeMethod(DefineSystem): Unauthorized
--------------------------------------------------------------------
ComputerSystem - 42_cs_gi_errs.py: FAIL
ERROR - Got CIM error Unauthorized with return code 0
ERROR - Unable to define guest ETdomain
InvokeMethod(DefineSystem): Unauthorized
--------------------------------------------------------------------
+1. Pushed. Thanks.
On 06/28/2011 02:13 PM, Eduardo Lima (Etrunko) wrote:
> # HG changeset patch
> # User Eduardo Lima (Etrunko)<eblima(a)br.ibm.com>
> # Date 1308270993 14400
> # Node ID 83f0e989145d86bc84dac05ef371c536a9734673
> # Parent a2f523cd39c29977ed07247a38316d44f5123874
> Add read-only support.
>
> This patch enables a consumer of libvirt-cim to put it in read-only
> mode by adding the key-value pair 'readonly=true' to libvirt-cim.conf.
>
> Also clean-up some extra whitespace in touched files.
>
> Changes from #1:
> - Fix build error on RHEL 6
> Changes from #2:
> - Small typo in libvirt-cim.conf
> Changes from #3:
> - Removed unecessary debug messages
>
> Signed-off-by: Chip Vincent<cvincent(a)us.ibm.com>
> Signed-off-by: Eduardo Lima (Etrunko)<eblima(a)br.ibm.com>
>
> diff --git a/Makefile.am b/Makefile.am
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -172,6 +172,9 @@
>
> pkgdata_SCRIPTS = provider-register.sh
>
> +libvirtcim_confdir = @sysconfdir@
> +dist_libvirtcim_conf_DATA = @PACKAGE@.conf
> +
> EXTRA_DIST = schema $(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS) \
> $(pkgdata_SCRIPTS) libvirt-cim.spec.in libvirt-cim.spec \
> doc/CodingStyle doc/SubmittingPatches \
> diff --git a/acinclude.m4 b/acinclude.m4
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -270,6 +270,15 @@
> LDFLAGS="$LDFLAGS $LIBUUID_LIBS"
> ])
>
> +AC_DEFUN([CHECK_LIBCONFIG],
> + [
> + PKG_CHECK_MODULES([LIBCONFIG], [libconfig])
> + AC_SUBST([LIBCONFIG_CFLAGS])
> + AC_SUBST([LIBCONFIG_LIBS])
> + CPPFLAGS="$CPPFLAGS $LIBCONFIG_CFLAGS"
> + LDFLAGS="$LDFLAGS $LIBCONFIG_LIBS"
> + ])
> +
> # A convenience macro that spits out a fail message for a particular test
> #
> # AC_CHECK_FAIL($LIBNAME,$PACKAGE_SUGGEST,$URL,$EXTRA)
> diff --git a/configure.ac b/configure.ac
> --- a/configure.ac
> +++ b/configure.ac
> @@ -166,6 +166,7 @@
> CHECK_LIBXML2
> CHECK_LIBCU
> CHECK_LIBUUID
> +CHECK_LIBCONFIG
>
> CFLAGS_STRICT="-Werror"
>
> diff --git a/libvirt-cim.conf b/libvirt-cim.conf
> new file mode 100644
> --- /dev/null
> +++ b/libvirt-cim.conf
> @@ -0,0 +1,13 @@
> +#
> +# libvirt-cim config file
> +#
> +# This config file is based on the libconfig format. For more
> information,
> +# please check
http://www.hyperrealm.com/libconfig/
> +#
> +
> +# readonly (boolean)
> +# Defines if connection to libvirt is read-only or not
> +# Possible values: {true,false}
> +# Default value: false
> +#
> +# readonly = false;
> diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in
> --- a/libvirt-cim.spec.in
> +++ b/libvirt-cim.spec.in
> @@ -26,6 +26,7 @@
>
> BuildRequires: libxml2-devel
> BuildRequires: libcmpiutil-devel
> +BuildRequires: libconfig-devel
> BuildConflicts: sblim-cmpi-devel
>
> %description
> @@ -135,6 +136,7 @@
> %{_datadir}/libvirt-cim/*.registration
> %{_datadir}/libvirt-cim/cim_schema_*-MOFs.zip
> %{_sysconfdir}/ld.so.conf.d/libvirt-cim.conf
> +%{_sysconfdir}/libvirt-cim.conf
>
> %changelog
> * Wed Oct 28 2009 Richard Maciel<rmaciel(a)linux.vnet.ibm.com> - 0.1-1
> diff --git a/libxkutil/Makefile.am b/libxkutil/Makefile.am
> --- a/libxkutil/Makefile.am
> +++ b/libxkutil/Makefile.am
> @@ -1,7 +1,8 @@
> # Copyright IBM Corp. 2007
> SUBDIRS = tests
>
> -CFLAGS += $(CFLAGS_STRICT)
> +AM_CFLAGS = $(CFLAGS_STRICT) \
> + -DLIBVIRTCIM_CONF=\"@sysconfdir@/@PACKAGE@.conf\"
>
> noinst_HEADERS = cs_util.h misc_util.h device_parsing.h xmlgen.h
> infostore.h \
> pool_parsing.h acl_parsing.h
> diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c
> --- a/libxkutil/misc_util.c
> +++ b/libxkutil/misc_util.c
> @@ -35,11 +35,12 @@
>
> #include<libcmpiutil/libcmpiutil.h>
> #include<libcmpiutil/std_association.h>
> +#include<libconfig.h>
>
> #include "misc_util.h"
> #include "cs_util.h"
>
> -#include<config.h>
> +#include "config.h"
>
> #define URI_ENV "HYPURI"
>
> @@ -55,6 +56,37 @@
> return NULL;
> }
>
> +static int is_read_only(void)
> +{
> + config_t conf;
> + int ret, readonly = 0;
> + const char *readonly_str = "readonly";
> +
> + config_init(&conf);
> +
> + ret = config_read_file(&conf, LIBVIRTCIM_CONF);
> + if (ret == CONFIG_FALSE) {
> + CU_DEBUG("Error reading config file at line %d: '%s'\n",
> + conf.error_line, conf.error_text);
> + goto out;
> + }
> +
> + ret = config_lookup_bool(&conf, readonly_str,&readonly);
> + if (ret == CONFIG_FALSE) {
> + CU_DEBUG("Error: '%s' not found in config file\n",
> + readonly_str);
> + goto out;
> + }
> +
> + CU_DEBUG("'%s' value in '%s' config file: %d\n",
readonly_str,
> + LIBVIRTCIM_CONF, readonly);
> +out:
> + config_destroy(&conf);
> +
> + /* Default value is 0 (false) */
> + return readonly;
> +}
> +
> virConnectPtr connect_by_classname(const CMPIBroker *broker,
> const char *classname,
> CMPIStatus *s)
> @@ -66,7 +98,7 @@
>
> uri = cn_to_uri(classname);
> if (!uri) {
> - cu_statusf(broker, s,
> + cu_statusf(broker, s,
> CMPI_RC_ERR_FAILED,
> "Unable to generate URI from classname");
> return NULL;
> @@ -74,7 +106,11 @@
>
> CU_DEBUG("Connecting to libvirt with uri `%s'", uri);
>
> - conn = virConnectOpen(uri);
> + if (is_read_only())
> + conn = virConnectOpenReadOnly(uri);
> + else
> + conn = virConnectOpen(uri);
> +
> if (!conn) {
> CU_DEBUG("Unable to connect to `%s'", uri);
> return NULL;
> @@ -258,7 +294,7 @@
> inst = CMNewInstance(broker, op,&s);
> if ((s.rc != CMPI_RC_OK) || CMIsNullObject(inst))
> goto out;
> -
> +
> CMSetProperty(inst, "CreationClassName",
> (CMPIValue *)new_cn, CMPI_chars);
>
> @@ -310,7 +346,7 @@
> if (STREQC(pfx, "CIM")) {
> cu_statusf(broker, status,
> CMPI_RC_ERR_FAILED,
> - "Please exactly specify the class (check CIMOM behavior!): %s",
> + "Please exactly specify the class (check CIMOM behavior!): %s",
> CLASSNAME(reference));
> rc = false;
> }
> @@ -347,7 +383,7 @@
>
> free(pfx);
> }
> -
> +
> free(ref_pfx);
> return rc;
> }
> @@ -367,13 +403,13 @@
> CLASSNAME(source_ref),
> assoc_classname,
> NAMESPACE(source_ref));
> -
> +
> if (ref_inst != NULL) {
> CMPIObjectPath *target_ref;
> -
> +
> target_ref = CMGetObjectPath(target_inst, NULL);
>
> - set_reference(assoc, ref_inst,
> + set_reference(assoc, ref_inst,
> source_ref, target_ref);
> }
>
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim(a)redhat.com
>
https://www.redhat.com/mailman/listinfo/libvirt-cim
--
Chip Vincent
Open Virtualization
IBM Linux Technology Center
cvincent(a)linux.vnet.ibm.com