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

Re: [virt-tools-list] [virt-manager][PATCH v3] Add delete VM option in console viewer.

On 06/17/2013 02:06 PM, Leonardo Garcia wrote:
diff --git a/virtManager/console.py b/virtManager/console.py
index b9186ce..001318e 100644
--- a/virtManager/console.py
+++ b/virtManager/console.py
@@ -651,7 +651,10 @@ class vmmConsolePages(vmmGObjectUI):

      def is_visible(self):
-        return self.topwin.get_visible()
+        if self.topwin:
+            return self.topwin.get_visible()
+        else:
+            return False

      def _cleanup(self):
          self.vm = None
@@ -892,6 +895,9 @@ class vmmConsolePages(vmmGObjectUI):

      def view_vm_status(self):
+        if not self.vm:
+            # window has been closed and no pages to update are available.
+            return
          status = self.vm.status()
          if status == libvirt.VIR_DOMAIN_SHUTOFF:
              self.activate_unavailable_page(_("Guest not running"))
@@ -900,7 +906,6 @@ class vmmConsolePages(vmmGObjectUI):
                  self.activate_unavailable_page(_("Guest has crashed"))

      def close_viewer(self):
-        viewport = self.widget("console-gfx-viewport")
          if self.viewer is None:

@@ -908,6 +913,7 @@ class vmmConsolePages(vmmGObjectUI):
          self.viewer = None
          w = v.display

+        viewport = self.widget("console-gfx-viewport")
          if w and w in viewport.get_children():
As I think this part of the patch proposal will rise some questions, let me try to explain why this is needed.

Again, this is a race condition with the fact that the console viewer will be destroyed when the running VM is deleted.

When the VM is deleted, we have: vmmEngine._do_vm_removed -> vmmDetails.close -> vmmConsolePages.close_viewer.

However, at some point in time, a call to SpiceViewer._main_channel_event_cb will be queued by the channel-event signal, and this callback will be executed after the vmmDetails has already closed the viewer. In this situation:

SpiceViewer._main_channel_event_cb -> vmmConsolePages.disconnected -> vmmConsolePages.close_viewer

So, we need some extra code to make sure that the call to close_viewer is successful when the viewer does not exist anymore.

I initially thought this was being caused by the fact that the channel-event signal is being listened with connect_after and was being handled too late. But even after using GObject.connect I was still hitting this error. So I think the event from the spice protocol is hitting the application after the vmmDetails has been closed.

Best regards,

Leonardo Garcia

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