[PATCH] Redirect stdout & stderr when run as out-of-process provider

# HG changeset patch # User Chip Vincent <cvincent@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@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);

+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@redhat.com wrote on 09/20/2011 03:33:54 PM:
Chip Vincent <cvincent@linux.vnet.ibm.com> Sent by: libvirt-cim-bounces@redhat.com
09/20/2011 03:33 PM
Please respond to List for discussion and development of libvirt CIM <libvirt-cim@redhat.com>
To
libvirt-cim@redhat.com
cc
Subject
[Libvirt-cim] [PATCH] Redirect stdout & stderr when run as out-of- process provider
# HG changeset patch # User Chip Vincent <cvincent@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@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@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

On 09/20/2011 07:33 PM, Chip Vincent wrote:
# HG changeset patch # User Chip Vincent <cvincent@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@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>
Why are you including errno.h? Is it because of freopen(), stdout and stderr? I guess you should be including stdio.h if that is the case. Best regards, Etrunko.
#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@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima@br.ibm.com

On 09/22/2011 03:05 PM, Eduardo Lima (Etrunko) wrote:
On 09/20/2011 07:33 PM, Chip Vincent wrote:
# HG changeset patch # User Chip Vincent<cvincent@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@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>
Why are you including errno.h? Is it because of freopen(), stdout and stderr? I guess you should be including stdio.h if that is the case.
Without including anything new, I got a compilation error. I don't recall the details, but a quick google of the error pointed to errno.h. However, everything I search now points to stdio.h. I'll fix.
Best regards, Etrunko.
#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@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com

On 09/22/2011 07:43 PM, Chip Vincent wrote:
On 09/22/2011 03:05 PM, Eduardo Lima (Etrunko) wrote:
On 09/20/2011 07:33 PM, Chip Vincent wrote:
# HG changeset patch # User Chip Vincent<cvincent@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@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>
Why are you including errno.h? Is it because of freopen(), stdout and stderr? I guess you should be including stdio.h if that is the case.
Without including anything new, I got a compilation error. I don't recall the details, but a quick google of the error pointed to errno.h. However, everything I search now points to stdio.h. I'll fix.
I recall now. errno.h is for the ‘program_invocation_short_name’ varible. http://www.gnu.org/software/hello/manual/gnulib/Glibc-errno_002eh.html#Glibc...
Best regards, Etrunko.
#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@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com

Pushed. On 09/22/2011 08:05 PM, Chip Vincent wrote:
On 09/22/2011 07:43 PM, Chip Vincent wrote:
On 09/22/2011 03:05 PM, Eduardo Lima (Etrunko) wrote:
On 09/20/2011 07:33 PM, Chip Vincent wrote:
# HG changeset patch # User Chip Vincent<cvincent@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@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>
Why are you including errno.h? Is it because of freopen(), stdout and stderr? I guess you should be including stdio.h if that is the case.
Without including anything new, I got a compilation error. I don't recall the details, but a quick google of the error pointed to errno.h. However, everything I search now points to stdio.h. I'll fix.
I recall now. errno.h is for the ‘program_invocation_short_name’ varible.
http://www.gnu.org/software/hello/manual/gnulib/Glibc-errno_002eh.html#Glibc...
Best regards, Etrunko.
#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@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com
participants (3)
-
Chip Vincent
-
Eduardo Lima (Etrunko)
-
Sharad Mishra