[PATCH] Fix missing InstanceID in ResourcePoolConfigurationCapabilities
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1196965106 28800
# Node ID 25193cc30daf4db213e989ee04573b7765785405
# Parent ebc42d00406a9800662470bb47fe5196e34c99a3
Fix missing InstanceID in ResourcePoolConfigurationCapabilities
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r ebc42d00406a -r 25193cc30daf src/Virt_ResourcePoolConfigurationCapabilities.c
--- a/src/Virt_ResourcePoolConfigurationCapabilities.c Thu Dec 06 10:15:15 2007 -0800
+++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Thu Dec 06 10:18:26 2007 -0800
@@ -60,6 +60,9 @@ static CMPIStatus get_rpc_cap(const CMPI
if (inst == NULL)
return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL};
+ CMSetProperty(inst, "InstanceID",
+ (CMPIValue *)"RPCC", CMPI_chars);
+
/* No method currently supported */
*_inst = inst;
17 years
[PATCH] Fix missing migration header for distribution
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1196959081 28800
# Node ID 9645be7b079b882978e9ef636c128fef95967497
# Parent d9af4651f76314647dbda82f5ccf3d926ce9dc05
Fix missing migration header for distribution
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r d9af4651f763 -r 9645be7b079b src/Makefile.am
--- a/src/Makefile.am Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Makefile.am Thu Dec 06 08:38:01 2007 -0800
@@ -15,7 +15,9 @@ noinst_HEADERS = profiles.h svpc_types.h
Virt_SettingsDefineCapabilities.h \
Virt_VirtualSystemManagementCapabilities.h \
Virt_VirtualSystemManagementService.h \
- Virt_VSSD.h
+ Virt_VSSD.h \
+ Virt_VSMigrationCapabilities.h \
+ Virt_VSMigrationService.h
XKUADD = $(top_builddir)/libxkutil/libxkutil.la
17 years
[PATCH 0 of 3] Add automated base schema installation
by Dan Smith
This set adds support for automated base schema installation. This will be handy for users of the source tree, as well as required for proper installation via RPM. I have only tested with Pegasus, so sfcb testing would be appreciated.
The first patch adds the schema patch and interop mof.
The second adds the installation script.
The third makes the required changes to the build system to fetch the CIM schema zip during build.
Testing can be easily accomplished by running "make preinstall" after building. Testing of the whole process as part of the RPM install would be good too.
For Pegasus, remove the entire /var/lib/Pegasus/repository/root#virt directory before testing. For SFCB, removing /usr/local/share/sfcb/CIM/* should be sufficient. After preinstall, make sure postinstall works and that the providers load and work.
/
17 years
IMPORTANT: configure Pegasus with "forceProviderProcesses=true"
by Heidi Eckhart
Hi all,
due to the changes made to the associations (registering the Virt_
provider for each subclass), it is now very important that Pegasus is
configured for "forceProviderProcesses=true". Otherwise only strange
things are happening ...
... Heidi
--
Regards
Heidi Eckhart
Software Engineer
Linux Technology Center - Open Hypervisor
heidieck(a)linux.vnet.ibm.com
**************************************************
IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Herbert Kircher
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
17 years
[PATCH] Rpm changes, per Fedora package review process
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1196962105 28800
# Node ID 84aa3e272c6d8195ce07dd3a54bc8743fd771945
# Parent 9645be7b079b882978e9ef636c128fef95967497
Rpm changes, per Fedora package review process
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 9645be7b079b -r 84aa3e272c6d libvirt-cim.spec.in
--- a/libvirt-cim.spec.in Thu Dec 06 08:38:01 2007 -0800
+++ b/libvirt-cim.spec.in Thu Dec 06 09:28:25 2007 -0800
@@ -4,10 +4,10 @@ Name: libvirt-cim
Name: libvirt-cim
Version: @PACKAGE_VERSION@
Release: 1%{?dist}%{?extra_release}
-License: LGPL
+License: LGPLv2+
Group: Development/Libraries
Source: libvirt-cim-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-root
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
URL: http://libvirt.org/CIM/
Requires: libxml2
Requires: libvirt >= 0.2.3
@@ -26,23 +26,23 @@ platforms with a single provider.
%prep
%setup -q
+chmod -x src/* libxkutil/* schema/*
%build
%configure --disable-werror
-make
+make %{?_smp_mflags}
%install
-rm -fr %{buildroot}
+rm -fr $RPM_BUILD_ROOT
-%makeinstall PROVIDERDIR=%{buildroot}%{_libdir}/cmpi
-cp provider-register.sh %{buildroot}%{_datadir}/libvirt-cim/
+make DESTDIR=$RPM_BUILD_ROOT install
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
rm -f $RPM_BUILD_ROOT%{_libdir}/cmpi/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/cmpi/*.a
%clean
-rm -fr %{buildroot}
+rm -fr $RPM_BUILD_ROOT
%pre
%define REGISTRATION %{_datadir}/%{name}/*.registration
@@ -64,8 +64,7 @@ rm -fr %{buildroot}
-n /@CIM_VIRT_NS@ \
-r %{REGISTRATION} -m %{SCHEMA} || true
-%postun
-/sbin/ldconfig
+%postun -p /sbin/ldconfig
%files
%defattr(-, root, root)
17 years
[PATCH] [RFC] Cleanup libvirt checks in acinclude.m4
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1196967953 28800
# Node ID 3c54117986d7f346f42edd1fd3f0d2b90a1c68d7
# Parent 25193cc30daf4db213e989ee04573b7765785405
[RFC] Cleanup libvirt checks in acinclude.m4
This changes the existing (hard to follow, debug, and change) libvirt
detection code with the standard pkg-config method. This gives us an
easy version check, as well as access to the package-specified information
about CPPFLAGS and LDFLAGS. It also makes us obey the system package
search path.
This will require a change to any source file that includes libvirt.h,
to #include <libvirt/libvirt.h>, which is the proper way anyway. If
people like this, I'll resubmit with the necessary changes.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 25193cc30daf -r 3c54117986d7 acinclude.m4
--- a/acinclude.m4 Thu Dec 06 10:18:26 2007 -0800
+++ b/acinclude.m4 Thu Dec 06 11:05:53 2007 -0800
@@ -325,39 +325,10 @@ AC_DEFUN([_CHECK_LIBVIRT],
AC_DEFUN([CHECK_LIBVIRT],
[
- AC_MSG_CHECKING(for libvirt package)
- LIBVIRT_CPP_FLAGS="$CPPFLAGS"
- dnl The standard include paths worked.
- _CHECK_LIBVIRT(standard)
- if test x"$LIBVIRTDIR" == x ; then
- _DIRS_="/usr/include/libvirt \
- /usr/local/include/libvirt"
- else
- _DIRS_="$LIBVIRTDIR/include/libvirt"
- fi
- for _DIR_ in $_DIRS_
- do
- _cppflags=$CPPFLAGS
- _include_LIBVIRT="$_DIR_"
- CPPFLAGS="$CPPFLAGS -I$_include_LIBVIRT"
- _CHECK_LIBVIRT($_DIR_)
- if test "$have_LIBVIRT" == "yes"; then
- dnl Found it
- AC_MSG_RESULT(yes)
- dnl Save the new -I parameter
- LIBVIRT_CPP_FLAGS="$CPPFLAGS"
- LIBLIBVIRT=-lvirt
- break
- fi
- CPPFLAGS=$_cppflags
- done
- CPPFLAGS=$LIBVIRT_CPP_FLAGS
- AC_SUBST(LIBLIBVIRT)
- if test "$have_LIBVIRT" == "no"; then
- AC_MSG_ERROR(no. The required libvirt package is missing.)
- fi
- ]
-)
+ PKG_CHECK_MODULES([LIBVIRT], [libvirt >= 0.3.2])
+ CPPFLAGS="$CPPFLAGS $LIBVIRT_CFLAGS"
+ LDFLAGS="$LDFLAGS $LIBVIRT_LIBS"
+ ])
dnl
dnl The check for the SBLIM test suite
17 years
[PATCH] Introduce generic LIBVIRT_CIM_DEFAULT_MAKEREF macro
by Heidi Eckhart
# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1196935598 -3600
# Node ID 618509ea5c6089678975cde7f4b5a687aa1e68f0
# Parent d9af4651f76314647dbda82f5ccf3d926ce9dc05
Introduce generic LIBVIRT_CIM_DEFAULT_MAKEREF macro
Moved the content of association's make_ref() to
make_reference() in libxkutil to generalize it. The
make_reference can be used via
LIBVIRT_CIM_DEFAULT_MAKEREF macro by each association.
Reduces lines of code per provider.
Updated all association providers to make use of
make_reference() and LIBVIRT_CIM_DEFAULT_MAKEREF.
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r d9af4651f763 -r 618509ea5c60 libxkutil/misc_util.c
--- a/libxkutil/misc_util.c Wed Dec 05 09:42:26 2007 +0100
+++ b/libxkutil/misc_util.c Thu Dec 06 11:06:38 2007 +0100
@@ -342,7 +342,35 @@ bool match_hypervisor_prefix(const CMPIO
return rc;
}
-
+CMPIInstance *make_reference(const CMPIBroker *broker,
+ const CMPIObjectPath *source_ref,
+ const CMPIInstance *target_inst,
+ struct std_assoc_info *info,
+ struct std_assoc *assoc)
+{
+ CMPIInstance *ref_inst = NULL;
+ char* assoc_classname;
+
+ assoc_classname = class_base_name(assoc->assoc_class[0]);
+
+ ref_inst = get_typed_instance(broker,
+ 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,
+ source_ref, target_ref);
+ }
+
+ free(assoc_classname);
+
+ return ref_inst;
+}
bool domain_online(virDomainPtr dom)
{
diff -r d9af4651f763 -r 618509ea5c60 libxkutil/misc_util.h
--- a/libxkutil/misc_util.h Wed Dec 05 09:42:26 2007 +0100
+++ b/libxkutil/misc_util.h Thu Dec 06 11:06:38 2007 +0100
@@ -109,6 +109,26 @@ bool match_hypervisor_prefix(const CMPIO
bool match_hypervisor_prefix(const CMPIObjectPath *reference,
struct std_assoc_info *info);
+CMPIInstance *make_reference(const CMPIBroker *broker,
+ const CMPIObjectPath *source_ref,
+ const CMPIInstance *target_inst,
+ struct std_assoc_info *info,
+ struct std_assoc *assoc);
+
+
+#define LIBVIRT_CIM_DEFAULT_MAKEREF() \
+ static CMPIInstance* make_ref(const CMPIObjectPath *source_ref, \
+ const CMPIInstance *target_inst, \
+ struct std_assoc_info *info, \
+ struct std_assoc *assoc) \
+ { \
+ return make_reference(_BROKER, \
+ source_ref, \
+ target_inst, \
+ info, \
+ assoc); \
+ }
+
/*
* Local Variables:
* mode: C
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_ElementAllocatedFromPool.c
--- a/src/Virt_ElementAllocatedFromPool.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_ElementAllocatedFromPool.c Thu Dec 06 11:06:38 2007 +0100
@@ -247,28 +247,7 @@ static CMPIStatus pool_to_vdev(const CMP
return s;
}
-static CMPIInstance *make_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- struct std_assoc_info *info,
- struct std_assoc *assoc)
-{
- CMPIInstance *refinst = NULL;
-
- refinst = get_typed_instance(_BROKER,
- CLASSNAME(ref),
- "ElementAllocatedFromPool",
- NAMESPACE(ref));
-
- if (refinst != NULL) {
- CMPIObjectPath *instop;
-
- instop = CMGetObjectPath(inst, NULL);
-
- set_reference(assoc, refinst, ref, instop);
- }
-
- return refinst;
-}
+LIBVIRT_CIM_DEFAULT_MAKEREF()
char* antecedent[] = {
"Xen_ProcessorPool",
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_ElementCapabilities.c
--- a/src/Virt_ElementCapabilities.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_ElementCapabilities.c Thu Dec 06 11:06:38 2007 +0100
@@ -210,39 +210,7 @@ static CMPIStatus pool_to_alloc(const CM
return s;
}
-static CMPIInstance *make_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- struct std_assoc_info *info,
- struct std_assoc *assoc)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- CMPIInstance *refinst = NULL;
- virConnectPtr conn = NULL;
-
- conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
- if (conn == NULL)
- return NULL;
-
- refinst = get_typed_instance(_BROKER,
- pfx_from_conn(conn),
- "ElementCapabilities",
- NAMESPACE(ref));
-
- if (refinst != NULL) {
- CMPIObjectPath *instop;
-
- instop = CMGetObjectPath(inst, NULL);
-
- CMSetProperty(refinst, assoc->source_prop,
- (CMPIValue *)&ref, CMPI_ref);
- CMSetProperty(refinst, assoc->target_prop,
- (CMPIValue *)&instop, CMPI_ref);
- }
-
- virConnectClose(conn);
-
- return refinst;
-}
+LIBVIRT_CIM_DEFAULT_MAKEREF()
char* assoc_classname[] = {
"Xen_ElementCapabilities",
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_ElementConformsToProfile.c
--- a/src/Virt_ElementConformsToProfile.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_ElementConformsToProfile.c Thu Dec 06 11:06:38 2007 +0100
@@ -190,38 +190,7 @@ static CMPIStatus elem_to_prof(const CMP
return s;
}
-static CMPIInstance *make_ref(const CMPIObjectPath *source_op,
- const CMPIInstance *target_inst,
- struct std_assoc_info *info,
- struct std_assoc *assoc)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- CMPIInstance *assoc_inst = NULL;
- virConnectPtr conn = NULL;
-
- conn = connect_by_classname(_BROKER, CLASSNAME(source_op), &s);
- if (conn == NULL)
- return NULL;
-
- assoc_inst = get_typed_instance(_BROKER,
- pfx_from_conn(conn),
- "ElementConformsToProfile",
- NAMESPACE(source_op));
-
- if (!CMIsNullObject(assoc_inst)) {
- CMPIObjectPath *target_op;
- target_op = CMGetObjectPath(target_inst, NULL);
-
- CMSetProperty(assoc_inst, assoc->source_prop,
- (CMPIValue *)&(source_op), CMPI_ref);
- CMSetProperty(assoc_inst, assoc->target_prop,
- (CMPIValue *)&(target_op), CMPI_ref);
- }
-
- virConnectClose(conn);
-
- return assoc_inst;
-}
+LIBVIRT_CIM_DEFAULT_MAKEREF()
char* conformant_standard[] = {
"Xen_RegisteredProfile",
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_ElementSettingData.c
--- a/src/Virt_ElementSettingData.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_ElementSettingData.c Thu Dec 06 11:06:38 2007 +0100
@@ -126,50 +126,37 @@ static CMPIStatus rasd_to_rasd(const CMP
return s;
}
-static CMPIInstance *make_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
+static CMPIInstance *make_ref(const CMPIObjectPath *source_ref,
+ const CMPIInstance *target_inst,
struct std_assoc_info *info,
struct std_assoc *assoc)
{
- CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *refinst = NULL;
- virConnectPtr conn = NULL;
uint16_t prop_value = 1;
- conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
- if (conn == NULL)
- return NULL;
-
- refinst = get_typed_instance(_BROKER,
- pfx_from_conn(conn),
- "ElementSettingData",
- NAMESPACE(ref));
+ refinst = make_reference(_BROKER,
+ source_ref,
+ target_inst,
+ info,
+ assoc);
if (refinst != NULL) {
- CMPIObjectPath *instop;
-
- instop = CMGetObjectPath(inst, NULL);
-
- set_reference(assoc, refinst, ref, instop);
-
/* Set additional properties with values
* defined in the "Virtual System Profile."
*/
CMSetProperty(refinst, "IsDefault",
- (CMPIValue *)&prop_value, CMPI_uint16);
-
+ (CMPIValue *)&prop_value, CMPI_uint16);
+
CMSetProperty(refinst, "IsNext",
- (CMPIValue *)&prop_value, CMPI_uint16);
+ (CMPIValue *)&prop_value, CMPI_uint16);
CMSetProperty(refinst, "IsMinimum",
- (CMPIValue *)&prop_value, CMPI_uint16);
-
+ (CMPIValue *)&prop_value, CMPI_uint16);
+
CMSetProperty(refinst, "IsMaximum",
- (CMPIValue *)&prop_value, CMPI_uint16);
- }
-
- virConnectClose(conn);
-
+ (CMPIValue *)&prop_value, CMPI_uint16);
+ }
+
return refinst;
}
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_HostedDependency.c
--- a/src/Virt_HostedDependency.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_HostedDependency.c Thu Dec 06 11:06:38 2007 +0100
@@ -82,28 +82,7 @@ static CMPIStatus host_to_vs(const CMPIO
return s;
}
-static CMPIInstance *make_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- struct std_assoc_info *info,
- struct std_assoc *assoc)
-{
- CMPIInstance *refinst = NULL;
-
- refinst = get_typed_instance(_BROKER,
- CLASSNAME(ref),
- "HostedDependency",
- NAMESPACE(ref));
-
- if (refinst != NULL) {
- CMPIObjectPath *instop;
-
- instop = CMGetObjectPath(inst, NULL);
-
- set_reference(assoc, refinst, ref, instop);
- }
-
- return refinst;
-}
+LIBVIRT_CIM_DEFAULT_MAKEREF()
char* antecedent[] = {
"Xen_ComputerSystem",
@@ -149,7 +128,6 @@ static struct std_assoc _host_to_vs = {
.make_ref = make_ref
};
-
static struct std_assoc *handlers[] = {
&_vs_to_host,
&_host_to_vs,
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_HostedResourcePool.c
--- a/src/Virt_HostedResourcePool.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_HostedResourcePool.c Thu Dec 06 11:06:38 2007 +0100
@@ -97,32 +97,7 @@ static CMPIStatus sys_to_pool(const CMPI
return s;
}
-static CMPIInstance *make_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- struct std_assoc_info *info,
- struct std_assoc *assoc)
-{
- CMPIInstance *refinst;
- char *base;
-
- base = class_base_name(info->assoc_class);
-
- refinst = get_typed_instance(_BROKER,
- CLASSNAME(ref),
- base,
- NAMESPACE(ref));
- if (refinst != NULL) {
- CMPIObjectPath *instop;
-
- instop = CMGetObjectPath(inst, NULL);
-
- set_reference(assoc, refinst, ref, instop);
- }
-
- free(base);
-
- return refinst;
-}
+LIBVIRT_CIM_DEFAULT_MAKEREF()
char* group_component[] = {
"Xen_HostSystem",
@@ -180,7 +155,6 @@ struct std_assoc *assoc_handlers[] = {
NULL
};
-
STDA_AssocMIStub(, Virt_HostedResourcePoolProvider, _BROKER, libvirt_cim_init(), assoc_handlers);
/*
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_HostedService.c
--- a/src/Virt_HostedService.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_HostedService.c Thu Dec 06 11:06:38 2007 +0100
@@ -85,36 +85,7 @@ static CMPIStatus host_to_service(const
return s;
}
-static CMPIInstance *make_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- struct std_assoc_info *info,
- struct std_assoc *assoc)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- CMPIInstance *refinst = NULL;
- virConnectPtr conn = NULL;
-
- conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
- if (conn == NULL)
- return NULL;
-
- refinst = get_typed_instance(_BROKER,
- pfx_from_conn(conn),
- "HostedService",
- NAMESPACE(ref));
-
- if (refinst != NULL) {
- CMPIObjectPath *instop;
-
- instop = CMGetObjectPath(inst, NULL);
-
- set_reference(assoc, refinst, ref, instop);
- }
-
- virConnectClose(conn);
-
- return refinst;
-}
+LIBVIRT_CIM_DEFAULT_MAKEREF()
char* antecedent[] = {
"Xen_HostSystem",
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_ResourceAllocationFromPool.c
--- a/src/Virt_ResourceAllocationFromPool.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_ResourceAllocationFromPool.c Thu Dec 06 11:06:38 2007 +0100
@@ -226,28 +226,7 @@ static CMPIStatus pool_to_rasd(const CMP
return s;
}
-static CMPIInstance *make_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- struct std_assoc_info *info,
- struct std_assoc *assoc)
-{
- CMPIInstance *refinst = NULL;
-
- refinst = get_typed_instance(_BROKER,
- CLASSNAME(ref),
- "ResourceAllocationFromPool",
- NAMESPACE(ref));
-
- if (refinst != NULL) {
- CMPIObjectPath *instop;
-
- instop = CMGetObjectPath(inst, NULL);
-
- set_reference(assoc, refinst, ref, instop);
- }
-
- return refinst;
-}
+LIBVIRT_CIM_DEFAULT_MAKEREF()
char* antecedent[] = {
"Xen_ProcessorPool",
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_SettingsDefineCapabilities.c Thu Dec 06 11:06:38 2007 +0100
@@ -812,39 +812,8 @@ static CMPIStatus rasd_to_alloc_cap(cons
return s;
}
-static CMPIInstance *make_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- struct std_assoc_info *info,
- struct std_assoc *assoc)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- CMPIInstance *refinst = NULL;
- virConnectPtr conn = NULL;
-
- conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
- if (conn == NULL)
- return NULL;
-
- refinst = get_typed_instance(_BROKER,
- pfx_from_conn(conn),
- "SettingsDefineCapabilities",
- NAMESPACE(ref));
-
- if (refinst != NULL) {
- CMPIObjectPath *instop;
-
- instop = CMGetObjectPath(inst, NULL);
-
- CMSetProperty(refinst, assoc->source_prop,
- (CMPIValue *)&ref, CMPI_ref);
- CMSetProperty(refinst, assoc->target_prop,
- (CMPIValue *)&instop, CMPI_ref);
- }
-
- virConnectClose(conn);
-
- return refinst;
-}
+
+LIBVIRT_CIM_DEFAULT_MAKEREF()
char* group_component[] = {
"Xen_AllocationCapabilities",
@@ -902,7 +871,6 @@ struct std_assoc *assoc_handlers[] = {
NULL
};
-
STDA_AssocMIStub(, Virt_SettingsDefineCapabilitiesProvider, _BROKER, libvirt_cim_init(), assoc_handlers);
/*
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_SettingsDefineState.c
--- a/src/Virt_SettingsDefineState.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_SettingsDefineState.c Thu Dec 06 11:06:38 2007 +0100
@@ -288,28 +288,7 @@ static CMPIStatus vssd_to_vs(const CMPIO
return s;
}
-static CMPIInstance *make_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- struct std_assoc_info *info,
- struct std_assoc *assoc)
-{
- CMPIInstance *refinst = NULL;
-
- refinst = get_typed_instance(_BROKER,
- CLASSNAME(ref),
- "SettingsDefineState",
- NAMESPACE(ref));
-
- if (refinst != NULL) {
- CMPIObjectPath *instop;
-
- instop = CMGetObjectPath(inst, NULL);
-
- set_reference(assoc, refinst, ref, instop);
- }
-
- return refinst;
-}
+LIBVIRT_CIM_DEFAULT_MAKEREF()
char* logical_device[] = {
"Xen_Processor",
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_SystemDevice.c
--- a/src/Virt_SystemDevice.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_SystemDevice.c Thu Dec 06 11:06:38 2007 +0100
@@ -130,30 +130,6 @@ static CMPIInstance *host_instance(char
return inst;
}
-
-static CMPIInstance *make_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- struct std_assoc_info *info,
- struct std_assoc *assoc)
-{
- CMPIInstance *refinst = NULL;
-
- refinst = get_typed_instance(_BROKER,
- CLASSNAME(ref),
- "SystemDevice",
- NAMESPACE(ref));
-
- if (refinst != NULL) {
- CMPIObjectPath *instop;
-
- instop = CMGetObjectPath(inst, NULL);
-
- set_reference(assoc, refinst, ref, instop);
- }
-
- return refinst;
-}
-
static CMPIStatus sys_to_dev(const CMPIObjectPath *ref,
struct std_assoc_info *info,
struct inst_list *list)
@@ -233,6 +209,8 @@ static CMPIStatus dev_to_sys(const CMPIO
return s;
}
+
+LIBVIRT_CIM_DEFAULT_MAKEREF()
char* group_component[] = {
"Xen_ComputerSystem",
diff -r d9af4651f763 -r 618509ea5c60 src/Virt_VSSDComponent.c
--- a/src/Virt_VSSDComponent.c Wed Dec 05 09:42:26 2007 +0100
+++ b/src/Virt_VSSDComponent.c Thu Dec 06 11:06:38 2007 +0100
@@ -152,28 +152,7 @@ static CMPIStatus rasd_to_vssd(const CMP
return s;
}
-static CMPIInstance *make_ref(const CMPIObjectPath *ref,
- const CMPIInstance *inst,
- struct std_assoc_info *info,
- struct std_assoc *assoc)
-{
- CMPIInstance *refinst = NULL;
-
- refinst = get_typed_instance(_BROKER,
- CLASSNAME(ref),
- "VirtualSystemSettingDataComponent",
- NAMESPACE(ref));
-
- if (refinst != NULL) {
- CMPIObjectPath *instop;
-
- instop = CMGetObjectPath(inst, NULL);
-
- set_reference(assoc, refinst, ref, instop);
- }
-
- return refinst;
-}
+LIBVIRT_CIM_DEFAULT_MAKEREF()
char* group_component[] = {
"Xen_VirtualSystemSettingData",
@@ -199,7 +178,6 @@ char* assoc_classname[] = {
NULL
};
-
static struct std_assoc forward = {
.source_class = (char**)&group_component,
.source_prop = "GroupComponent",
17 years
[PATCH] [CU] Several small fixes for indication_tester.py:
by Jay Gagnon
# HG changeset patch
# User Jay Gagnon <grendel(a)linux.vnet.ibm.com>
# Date 1196959002 18000
# Node ID 43172447a69a867b00bdf1bf8fbed3c50a199fd5
# Parent 8459ef1378807def1f91addfc6ba54fd16a44cf2
[CU] Several small fixes for indication_tester.py:
Move #! interpreter line to top (otherwise it is ignored).
Add usage message that includes mandatory argument.
Exit cleanly with error message when mandatory arg missing.
Fix default namespace in indication tester to root/virt.
Use OptionParser's way to specify defaults.
Remove itest.c
Signed-off-by: Jay Gagnon <grendel(a)linux.vnet.ibm.com>
diff -r 8459ef137880 -r 43172447a69a tools/indication_tester.py
--- a/tools/indication_tester.py Fri Nov 30 14:14:41 2007 -0800
+++ b/tools/indication_tester.py Thu Dec 06 11:36:42 2007 -0500
@@ -1,5 +1,5 @@
+#!/usr/bin/python
# Copyright IBM Corp. 2007
-#!/usr/bin/python
#
# indication_tester.py - Tool for testing indication subscription and
# delivery against a CIMOM
@@ -325,22 +325,20 @@ class CIMIndicationSubscription:
self.__do_cimpost(self.conn, delete_inst_xml(self.name, "Filter"))
def main():
- parser = OptionParser()
- parser.add_option("-u", "--url", dest="url",
+ parser = OptionParser(usage="usage: %prog [options] type")
+ parser.add_option("-u", "--url", dest="url", default="localhost:5988",
help="URL of CIMOM to connect to (host:port)")
- parser.add_option("-N", "--ns", dest="ns",
- help="Namespace (default is root/ibmsd)")
- parser.add_option("-n", "--name", dest="name",
+ parser.add_option("-N", "--ns", dest="ns", default="root/virt",
+ help="Namespace (default is root/virt)")
+ parser.add_option("-n", "--name", dest="name", default="Test",
help="Base name for filter, handler, subscription")
(options, args) = parser.parse_args()
- if not options.url:
- options.url = "localhost:5988"
- if not options.ns:
- options.ns = "root/ibmsd"
- if not options.name:
- options.name = "Test"
-
+
+ if len(args) == 0:
+ print "Fatal: no indication type provided."
+ sys.exit(1)
+
sub = CIMIndicationSubscription(options.name, args[0], options.ns)
sub.subscribe(options.url)
print "Watching for %s" % args[0]
diff -r 8459ef137880 -r 43172447a69a tools/itest.c
--- a/tools/itest.c Fri Nov 30 14:14:41 2007 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,609 +0,0 @@
-/*
- * Copyright IBM Corp. 2007
- *
- * Authors:
- * Dan Smith <danms(a)us.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 <stdio.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <netdb.h>
-#include <string.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <getopt.h>
-
-static int tcp_incoming(int port)
-{
- struct sockaddr_in srvaddr;
- int s = -1;
- int ret;
-
- s = socket(AF_INET, SOCK_STREAM, 0);
- if (s < 0) {
- perror("socket");
- return -1;
- }
-
- memset(&srvaddr, 0, sizeof(srvaddr));
-
- srvaddr.sin_family = AF_INET;
- srvaddr.sin_addr.s_addr = htonl(INADDR_ANY);
- srvaddr.sin_port = htons(port);
-
- ret = bind(s, (struct sockaddr *)&srvaddr, sizeof(srvaddr));
- if (ret) {
- perror("bind");
- goto err;
- }
-
- ret = listen(s, 1);
- if (ret) {
- perror("listen");
- goto err;
- }
-
- return s;
-
- err:
- close(s);
- return -1;
-}
-
-static int create_filter(FILE *pipe,
- const char *name,
- const char *type,
- const char *ns)
-{
- int ret = 0;
- char *xml = NULL;
- const char *filter_fmt = " \
-<?xml version=\"1.0\" encoding=\"utf-8\"?> \
-<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\"> \
- <MESSAGE ID=\"4711\" PROTOCOLVERSION=\"1.0\"> \
- <SIMPLEREQ> \
- <IMETHODCALL NAME=\"CreateInstance\"> \
- <LOCALNAMESPACEPATH> \
- <NAMESPACE NAME=\"root\"/> \
- <NAMESPACE NAME=\"PG_InterOp\"/> \
- </LOCALNAMESPACEPATH> \
- <IPARAMVALUE NAME=\"NewInstance\"> \
- <INSTANCE CLASSNAME=\"CIM_IndicationFilter\">\
- <PROPERTY NAME=\"SystemCreationClassName\" TYPE=\"string\"> \
- <VALUE>CIM_ComputerSystem</VALUE> \
- </PROPERTY> \
- <PROPERTY NAME=\"SystemName\" TYPE=\"string\"> \
- <VALUE>localhost.localdomain</VALUE> \
- </PROPERTY> \
- <PROPERTY NAME=\"CreationClassName\" TYPE=\"string\"> \
- <VALUE>CIM_IndicationFilter</VALUE> \
- </PROPERTY> \
- <PROPERTY NAME=\"Name\" TYPE=\"string\"> \
- <VALUE>%sFilter</VALUE> \
- </PROPERTY> \
- <PROPERTY NAME=\"Query\" TYPE=\"string\"> \
- <VALUE> SELECT * FROM %s \
- </VALUE> \
- </PROPERTY> \
- <PROPERTY NAME=\"QueryLanguage\" TYPE=\"string\"> \
- <VALUE>WQL</VALUE> \
- </PROPERTY> \
- <PROPERTY NAME=\"SourceNamespace\" TYPE=\"string\"> \
- <VALUE>%s</VALUE> \
- </PROPERTY> \
- </INSTANCE> \
- </IPARAMVALUE> \
- </IMETHODCALL> \
- </SIMPLEREQ> \
- </MESSAGE> \
-</CIM>";
-
- ret = asprintf(&xml, filter_fmt, name, type, ns);
- if (ret == -1)
- goto out;
-
- ret = fwrite(xml, strlen(xml), 1, pipe);
- ret = (ret == strlen(xml));
-
- out:
- free(xml);
-
- return ret;
-}
-
-static int create_handler(FILE *pipe, int port, const char *name)
-{
- int ret = 0;
- char *xml = NULL;
- const char * handler_fmt = " \
-<?xml version=\"1.0\" encoding=\"utf-8\"?> \
-<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\"> \
- <MESSAGE ID=\"4711\" PROTOCOLVERSION=\"1.0\"> \
- <SIMPLEREQ> \
- <IMETHODCALL NAME=\"CreateInstance\"> \
- <LOCALNAMESPACEPATH> \
- <NAMESPACE NAME=\"root\"/> \
- <NAMESPACE NAME=\"PG_InterOp\"/> \
- </LOCALNAMESPACEPATH> \
- <IPARAMVALUE NAME=\"NewInstance\"> \
- <INSTANCE CLASSNAME=\"CIM_IndicationHandlerCIMXML\"> \
- <PROPERTY NAME=\"SystemCreationClassName\" TYPE=\"string\"> \
- <VALUE>CIM_ComputerSystem</VALUE> \
- </PROPERTY> \
- <PROPERTY NAME=\"SystemName\" TYPE=\"string\"> \
- <VALUE>localhost.localdomain</VALUE> \
- </PROPERTY> \
- <PROPERTY NAME=\"CreationClassName\" TYPE=\"string\"> \
- <VALUE>CIM_IndicationHandlerCIMXML</VALUE> \
- </PROPERTY> \
- <PROPERTY NAME=\"Name\" TYPE=\"string\"> \
- <VALUE>%sHandler</VALUE> \
- </PROPERTY> \
- <PROPERTY NAME=\"Destination\" TYPE=\"string\"> \
- <VALUE>localhost:%i</VALUE> \
- </PROPERTY> \
- </INSTANCE> \
- </IPARAMVALUE> \
- </IMETHODCALL> \
- </SIMPLEREQ> \
- </MESSAGE> \
-</CIM>";
-
- ret = asprintf(&xml, handler_fmt, name, port);
- if (ret == -1)
- return 0;
-
- ret = fwrite(xml, strlen(xml), 1, pipe);
- ret = (ret == strlen(xml));
-
- free(xml);
-
- return ret;
-}
-
-static int create_subscription(FILE *pipe, const char *name)
-{
- int ret = 0;
- char *xml = NULL;
- const char *sub_fmt = " \
-<?xml version=\"1.0\" encoding=\"utf-8\"?> \
-<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\"> \
- <MESSAGE ID=\"4711\" PROTOCOLVERSION=\"1.0\"> \
- <SIMPLEREQ> \
- <IMETHODCALL NAME=\"CreateInstance\"> \
- <LOCALNAMESPACEPATH> \
- <NAMESPACE NAME=\"root\"/> \
- <NAMESPACE NAME=\"PG_InterOp\"/> \
- </LOCALNAMESPACEPATH> \
- <IPARAMVALUE NAME=\"NewInstance\"> \
- <INSTANCE CLASSNAME=\"CIM_IndicationSubscription\"> \
- <PROPERTY.REFERENCE NAME=\"Filter\" \
- REFERENCECLASS=\"CIM_IndicationFilter\"> \
- <VALUE.REFERENCE> \
- <INSTANCENAME CLASSNAME=\"CIM_IndicationFilter\"> \
- <KEYBINDING NAME=\"SystemCreationClassName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- CIM_ComputerSystem \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"SystemName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- localhost.localdomain \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"CreationClassName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- CIM_IndicationFilter \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"Name\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- %sFilter \
- </KEYVALUE> \
- </KEYBINDING> \
- </INSTANCENAME> \
- </VALUE.REFERENCE> \
- </PROPERTY.REFERENCE> \
- <PROPERTY.REFERENCE NAME=\"Handler\" \
- REFERENCECLASS=\"CIM_IndicationHandler\"> \
- <VALUE.REFERENCE> \
- <INSTANCENAME CLASSNAME=\"CIM_IndicationHandlerCIMXML\"> \
- <KEYBINDING NAME=\"SystemCreationClassName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- CIM_ComputerSystem \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"SystemName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- localhost.localdomain \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"CreationClassName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- CIM_IndicationHandlerCIMXML \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"Name\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- %sHandler \
- </KEYVALUE> \
- </KEYBINDING> \
- </INSTANCENAME> \
- </VALUE.REFERENCE> \
- </PROPERTY.REFERENCE> \
- <PROPERTY NAME=\"SubscriptionState\" TYPE=\"uint16\"> \
- <VALUE> 2 </VALUE> \
- </PROPERTY> \
- </INSTANCE> \
- </IPARAMVALUE> \
- </IMETHODCALL> \
- </SIMPLEREQ> \
- </MESSAGE> \
-</CIM>";
-
- ret = asprintf(&xml, sub_fmt, name, name);
- if (ret == -1)
- goto out;
-
- ret = fwrite(xml, strlen(xml), 1, pipe);
- ret = (ret == strlen(xml));
-
- out:
- free(xml);
-
- return ret;
-}
-
-static int delete_inst(FILE *pipe, const char *name, const char *type)
-{
- int ret;
- char *xml = NULL;
- const char *fmt = "\
-<?xml version=\"1.0\" encoding=\"utf-8\"?> \
-<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\"> \
- <MESSAGE ID=\"4711\" PROTOCOLVERSION=\"1.0\"> \
- <SIMPLEREQ> \
- <IMETHODCALL NAME=\"DeleteInstance\"> \
- <LOCALNAMESPACEPATH> \
- <NAMESPACE NAME=\"root\"/> \
- <NAMESPACE NAME=\"PG_InterOp\"/> \
- </LOCALNAMESPACEPATH> \
- <IPARAMVALUE NAME=\"InstanceName\"> \
- <INSTANCENAME CLASSNAME=\"CIM_Indication%sCIMXML\"> \
- <KEYBINDING NAME=\"SystemCreationClassName\"> \
- <KEYVALUE>CIM_ComputerSystem</KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"SystemName\"> \
- <KEYVALUE>localhost.localdomain</KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"CreationClassName\"> \
- <KEYVALUE>CIM_Indication%sCIMXML</KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"Name\"> \
- <KEYVALUE>%s%s</KEYVALUE> \
- </KEYBINDING> \
- </INSTANCENAME> \
- </IPARAMVALUE> \
- </IMETHODCALL> \
- </SIMPLEREQ> \
- </MESSAGE> \
-</CIM>";
-
- ret = asprintf(&xml, fmt, type, type, name, type);
- if (ret == -1)
- return 0;
-
- ret = fwrite(xml, strlen(xml), 1, pipe);
- ret = (ret == strlen(xml));
-
- free(xml);
-
- return ret;
-}
-
-static int delete_subscription(FILE *pipe, char *name)
-{
- int ret;
- char *xml = NULL;
- const char *fmt = "\
-<?xml version=\"1.0\" encoding=\"utf-8\"?> \
-<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\"> \
- <MESSAGE ID=\"4711\" PROTOCOLVERSION=\"1.0\"> \
- <SIMPLEREQ> \
- <IMETHODCALL NAME=\"DeleteInstance\"> \
- <LOCALNAMESPACEPATH> \
- <NAMESPACE NAME=\"root\"/> \
- <NAMESPACE NAME=\"PG_InterOp\"/> \
- </LOCALNAMESPACEPATH> \
- <IPARAMVALUE NAME=\"InstanceName\"> \
- <INSTANCENAME CLASSNAME=\"CIM_IndicationSubscription\"> \
- <KEYBINDING NAME=\"Filter\"> \
- <VALUE.REFERENCE> \
- <INSTANCENAME CLASSNAME=\"CIM_IndicationFilter\"> \
- <KEYBINDING NAME=\"SystemCreationClassName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- CIM_ComputerSystem \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"SystemName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- localhost.localdomain \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"CreationClassName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- CIM_IndicationFilter \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"Name\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- %sFilter \
- </KEYVALUE> \
- </KEYBINDING> \
- </INSTANCENAME> \
- </VALUE.REFERENCE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"Handler\"> \
- <VALUE.REFERENCE> \
- <INSTANCENAME CLASSNAME=\"CIM_IndicationHandlerCIMXML\"> \
- <KEYBINDING NAME=\"SystemCreationClassName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- CIM_ComputerSystem \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"SystemName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- localhost.localdomain \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"CreationClassName\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- CIM_IndicationHandlerCIMXML \
- </KEYVALUE> \
- </KEYBINDING> \
- <KEYBINDING NAME=\"Name\"> \
- <KEYVALUE VALUETYPE=\"string\"> \
- %sHandler \
- </KEYVALUE> \
- </KEYBINDING> \
- </INSTANCENAME> \
- </VALUE.REFERENCE> \
- </KEYBINDING> \
- </INSTANCENAME> \
- </IPARAMVALUE> \
- </IMETHODCALL> \
- </SIMPLEREQ> \
- </MESSAGE> \
-</CIM>";
-
- ret = asprintf(&xml, fmt, name, name);
- if (ret == -1)
- return 0;
-
- ret = fwrite(xml, strlen(xml), 1, pipe);
- ret = (ret == strlen(xml));
-
- free(xml);
-
- return 1;
-}
-
-int interrupted;
-
-static int monitor_indications(int fd, int howmany)
-{
- int i;
- char buf[4096];
- struct sockaddr saddr;
- unsigned int len;
-
- int flags;
-
- flags = fcntl(fd, F_GETFD);
- fcntl(fd, F_SETFD, flags | O_NONBLOCK);
-
- interrupted = 0;
-
- for (i = 0; i < howmany; i++) {
- int ret;
- int s;
- fd_set fds;
-
- if (interrupted)
- break;
-
- FD_ZERO(&fds);
- FD_SET(fd, &fds);
-
- ret = select(fd+1, &fds, NULL, NULL, NULL);
- if (ret <= 0)
- continue;
-
- s = accept(fd, &saddr, &len);
- if (s < 0)
- continue;
-
- ret = read(s, buf, sizeof(buf));
- if (ret > 0)
- printf("Got indication\n");
-
- close(s);
- }
-
- return i;
-}
-
-static void interrupt(int sig)
-{
- interrupted = 1;
-}
-
-struct config {
- char *type;
- int port;
- char *name;
- char *ns;
- int iter;
- int debug;
-};
-
-static void usage(char *name)
-{
- printf("Usage:\n"
- "%s [OPTIONS]\n"
- "\n"
- " -t,--type=class Indication type to watch for\n"
- " -p,--port=1234 TCP port to listen to\n"
- " -n,--name=foo Indication instance name base\n"
- " -N,--ns=foo Namespace\n"
- " -i,--iter=1 Number of instances to receive before exit\n"
- " -d,--debug Enable debugging\n"
- " -h,--help This help text\n",
- name);
-}
-
-static int parse_args(int argc, char **argv, struct config *config)
-{
- int idx;
- static struct option opts[] = {
- {"type", 1, 0, 't'},
- {"port", 1, 0, 'p'},
- {"name", 1, 0, 'n'},
- {"ns", 1, 0, 'N'},
- {"iter", 1, 0, 'i'},
- {"help", 0, 0, 'h'},
- {"debug", 0, 0, 'd'},
- {0, 0, 0, 0}};
-
- config->type = "CIM_InstCreation";
- config->port = 1234;
- config->name = "TestIndication";
- config->ns = "root/ibmsd";
- config->iter = 1;
- config->debug = 0;
-
- while (1) {
- int c;
-
- c = getopt_long(argc, argv, "t:p:n:N:i:hd", opts, &idx);
- if (c == -1)
- break;
-
- switch (c) {
- case 't':
- config->type = optarg;
- break;
-
- case'n':
- config->name = optarg;
- break;
-
- case 'N':
- config->ns = optarg;
- break;
-
- case 'p':
- config->port = atoi(optarg);
- break;
-
- case 'i':
- config->iter = atoi(optarg);
- break;
-
- case 'd':
- config->debug = 1;
- break;
-
- case 'h':
- case '?':
- usage(argv[0]);
- return 0;
- break;
- };
- }
-
- return 1;
-}
-
-#define WBEMCAT(f) \
- if (config.debug) \
- pipe = popen("wbemcat", "w"); \
- else \
- pipe = popen("wbemcat >/dev/null 2>&1", "w"); \
- f; \
- ret = fclose(pipe);
-
-int main(int argc, char **argv)
-{
- int s;
- FILE *pipe;
- int ret;
- struct config config;
-
- if (!parse_args(argc, argv, &config))
- return 1;
-
- signal(SIGINT, interrupt);
- signal(SIGTERM, interrupt);
-
- s = tcp_incoming(config.port);
- if (s < 0) {
- printf("Unable to listen on port %i\n", config.port);
- return 1;
- }
-
- WBEMCAT(create_filter(pipe, config.name, config.type, config.ns));
- if (ret) {
- printf("Failed to create filter\n");
- return 1;
- }
-
- WBEMCAT(create_handler(pipe, config.port, config.name));
- if (ret) {
- printf("Failed to create handler\n");
- goto out1;
- }
-
- WBEMCAT(create_subscription(pipe, config.name));
- if (ret) {
- printf("Failed to create subscription\n");
- goto out2;
- }
-
- monitor_indications(s, config.iter);
-
- WBEMCAT(delete_subscription(pipe, config.name));
- out2:
- WBEMCAT(delete_inst(pipe, config.name, "Handler"));
- out1:
- WBEMCAT(delete_inst(pipe, config.name, "Filter"));
-
- close(s);
-
- return 0;
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-set-style: "K&R"
- * tab-width: 8
- * c-basic-offset: 8
- * indent-tabs-mode: nil
- * End:
- */
17 years