summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-05-06 12:32:59 -0400
committerRichard W.M. Jones <rjones@redhat.com>2011-05-06 13:03:50 -0400
commita4c28b4ed1c5a102c8de2a7425568eb504d05c34 (patch)
tree8455a3da5605401d8bf9eafc65264284dc139d0e /src
parentc49fc3831d12788c27b90d12f06a1cd69a88e3be (diff)
downloadlibguestfs-a4c28b4ed1c5a102c8de2a7425568eb504d05c34.tar.gz
libguestfs-a4c28b4ed1c5a102c8de2a7425568eb504d05c34.tar.xz
libguestfs-a4c28b4ed1c5a102c8de2a7425568eb504d05c34.zip
add-domain: Suppress libvirt errors on stderr.
Install an error handler on the libvirt error connection so that errors are not printed on stderr (instead they go up through the usual libguestfs error mechanism). Unfortunately this doesn't suppress initial connection error messages to stderr. I cannot see how to do this without affecting the global libvirt error handler, which is not acceptable for a library to be doing.
Diffstat (limited to 'src')
-rw-r--r--src/virt.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/virt.c b/src/virt.c
index aa2c0227..cd488886 100644
--- a/src/virt.c
+++ b/src/virt.c
@@ -53,6 +53,12 @@ init_libxml2 (void)
LIBXML_TEST_VERSION;
}
+static void
+ignore_errors (void *ignore, virErrorPtr ignore2)
+{
+ /* empty */
+}
+
struct guestfs___add_libvirt_dom_argv {
uint64_t bitmask;
#define GUESTFS___ADD_LIBVIRT_DOM_READONLY_BITMASK (UINT64_C(1)<<0)
@@ -102,6 +108,12 @@ guestfs__add_domain (guestfs_h *g, const char *domain_name,
goto cleanup;
}
+ /* Suppress default behaviour of printing errors to stderr. Note
+ * you can't set this to NULL to ignore errors; setting it to NULL
+ * restores the default error handler ...
+ */
+ virConnSetErrorFunc (conn, NULL, ignore_errors);
+
dom = virDomainLookupByName (conn, domain_name);
if (!dom) {
err = virGetLastError ();