+1
Code looks fine.
I have not built or tested it. Please run cimtests before pushing.
Regards,
Sharad Mishra
Open Virtualization
Linux Technology Center
IBM
libvirt-cim-bounces(a)redhat.com wrote on 09/20/2011 03:33:54 PM:
Chip Vincent <cvincent(a)linux.vnet.ibm.com>
Sent by: libvirt-cim-bounces(a)redhat.com
09/20/2011 03:33 PM
Please respond to
List for discussion and development of libvirt CIM
<libvirt-cim(a)redhat.com>
To
libvirt-cim(a)redhat.com
cc
Subject
[Libvirt-cim] [PATCH] Redirect stdout & stderr when run as out-of-
process provider
# HG changeset patch
# User Chip Vincent <cvincent(a)us.ibm.com>
# Date 1316557881 14400
# Node ID 4d95f2e9f2d8eac1565307def96bd158f5dcf160
# Parent db809376d763493849c2a19f587969eaec619b75
Redirect stdout & stderr when run as out-of-process provider
When a provider is loaded in-process by Pegasus, messages sent to
stdout and stderr are suppressed. However, when loaded out-of-process,
those same messages appear on the console. This happens excessively when
libvirt-cim LXC_ and XEN_ classes are enumerated and libvirt sends
"libvir: error : no connection driver available for..." messages to
stderr.
In development, this can sometimes prevent console usage. Until a fix
is
made to Pegasus, we'll suppress console output during provider
initialization
when run in out-of-process mode.
Signed-off-by: Chip Vincent <cvincent(a)us.ibm.com>
diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c
--- a/libxkutil/misc_util.c
+++ b/libxkutil/misc_util.c
@@ -29,6 +29,7 @@
#include <stdarg.h>
#include <unistd.h>
#include <pthread.h>
+#include <errno.h>
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
@@ -540,6 +541,17 @@
{
int ret = 0;
+ /* The tog-pegasus out-of-process provider feature does not
+ * redirect stdout and stderr, so it's done here to prevent
+ * any messages from taking over the console. One example is
+ * verbose connection failures sent to stdout by libvirt. */
+ if (strstr(program_invocation_short_name, "cimprovagt") != NULL)
{
+ CU_DEBUG("Redirecting stdout and
stderr");
+
+ stdout = freopen("/dev/null", "a", stdout);
+ stderr = freopen("/dev/null", "a", stderr);
+ }
+
/* double-check lock pattern used for performance reasons */
if (libvirt_initialized == 0) {
pthread_mutex_lock(&libvirt_mutex);
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim