[PATCH 3/3] [NOT TO BE APPLIED] inspection: Pass log messages from libguestfs through the virt-manager logging system.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Richard W.M. Jones" <rjones@xxxxxxxxxx>

This requires libguestfs >= 1.16, but that's older than the minimum
supported version of libguestfs, and even Ubuntu has libguestfs 1.18.
---
 virtManager/inspection.py | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/virtManager/inspection.py b/virtManager/inspection.py
index eb50a95..da74541 100644
--- a/virtManager/inspection.py
+++ b/virtManager/inspection.py
@@ -23,7 +23,7 @@ import logging
 import os
 import re
 
-from guestfs import GuestFS  # pylint: disable=F0401
+import guestfs
 
 from virtManager.baseclass import vmmGObject
 from virtManager.domain import vmmInspectionData
@@ -150,7 +150,6 @@ class vmmInspection(vmmGObject):
                           vm.get_name())
             return
 
-        g = GuestFS()
         prettyvm = conn.get_uri() + ":" + vm.get_name()
         ignore = vmuuid
 
@@ -165,6 +164,23 @@ class vmmInspection(vmmGObject):
             logging.debug("%s: nothing to inspect", prettyvm)
             return
 
+        # Create libguestfs handle.
+        g = guestfs.GuestFS()
+
+        # Ensure we capture all log messages into the virt-manager
+        # logging system.
+        def log_callback(ev, eh, buf, array):
+            ignore = eh
+            ignore = array
+            if ev == guestfs.EVENT_APPLIANCE:
+                buf = buf.rstrip()
+            logging.debug("%s", buf)
+
+        events = guestfs.EVENT_LIBRARY
+        if g.get_trace():   events |= guestfs.EVENT_TRACE
+        if g.get_verbose(): events |= guestfs.EVENT_APPLIANCE
+        g.set_event_callback(log_callback, events)
+
         # Add the disks.  Note they *must* be added with readonly flag set.
         for disk in disks:
             path = disk.path
-- 
1.8.2.1

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux