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(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>
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(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