-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi,

since commit 7e9c816b (included since qubes-core-dom0 3.2.5)
QubesWatch._register_watches() is called twice for dom0 [0]. This
uncovered that _register_watches() does not handle multiple calls for
dom0 correctly (see commit message for details). This leads to (at
least) two bugs in qubes-manager:

1) qubes-manager misses when a block device becomes available during
   runtime of qubes-manager so no notification is shown and you cannot
   attached it through the GUI.

2) qubes-manager misses the qrexec startup when a VM is started
   externaly (e.g. qvm-start ...). Therefore it thinks qrexec does not
   run and for example "Run Command in VM" hangs.

While debugging two things in QubesWatch.__init__ raised my attention:

1) Is _register_watches() intentionally called a second time in L711 for
   dom0? (Might be a preparation for not Xen based libvirt backends)

2) L708 should be a 'continue', right?

HW42

[0]: It was already called twice before but _register_watches()
     mishandled the libvirt_domain object for dom0, so effectively it was
     only called once.
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJXi+40AAoJEOSsySeKZGgWkFMQAJAFkve3+td92o1sQS2p2kSU
qmF5Z3gP+316+/pPjwN8zGVjGlWT2bRLV/+PTGq+tXXIOAF4HmJYOFFj2tXYNDBk
siiM1bJqcIEWmKe45W2D5135rIo40/tVbBbQSerTsg7yFx1UzEimbTCQgQHOj6pj
hMW/StQoux4DBZNXC51vevZVGvfDmdE6Gjifyp5QWWkDAS0r+OSkAA0g5FVDrtSb
47S/9ZHmUT82i4OSYfHwkXDc+44ZcWMGBoYfRGnNKkwVri1Zltq/6z3lcbaNMtHV
ayE6m2fk0ouhISKKTZHb6QPp/LeMmQLiGygX2v51elFJhVkdC5sLyNf4Lp1uTIJG
ReidxAJejNEes3f+lfS+V2V+MkihKZ7mG6GaUgYrvkulHozm2wF4LOckdzm70CzV
eur8LEFc3QbOtJKQVq1WObTg/IAXreoou67sgoKeUKW9R4396qKTHGQJ2w0bPP2s
r+G773YPzclt/kQpCHEzkFOQNv0+253LSdOyvii2SNtFao49aMW+oBD7YaXSMvt8
btbBHosS5UJoucR3p7mD64xqf89miXBGNsS4lYJXnTfxW1dMcju+99gDXrrPHVc8
A5s8j5UCETq2pn8ttmZAJPpV1hkECzO5/FRYtzNlmxcxtlMtYp7mdBh7nYDv5dQu
tuntAp1/0/yieXkyVi6z
=BxBq
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-devel/638466af-2136-fa3f-41c3-b709eac180c7%40ipsumj.de.
For more options, visit https://groups.google.com/d/optout.
From f6ccaad77eb7035431e2acafc3031fdcde6465f4 Mon Sep 17 00:00:00 2001
From: HW42 <[email protected]>
Date: Sun, 17 Jul 2016 21:35:16 +0200
Subject: [PATCH] QubesWatch: do not create multiple dom0 QubesDB connections

When calling _register_watches() multiple times for dom0 (by passing
None or since 7e9c816b by passing the corresponding libvirt domain) the
check was missing if there is already a QubesDB in _qdb. Therefore a new
QubesDB was created and the old one is destroyed by the GC. As a
consequence the watch_fd is closed but the libvirt event handle for this
fd is still registered. So when libvirt calls poll() it returns
immediately POLLNVAL with the closed fd. This is not caught in libvirt
and the callback is called as if an event happened. _qdb_handler() now
calls read_watch() on the new fd for dom0 and thereby hangs the thread.
This leads (at leads) to qubes-manager to miss VM status updates and
block device events.
---
 core/qubesutils.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/qubesutils.py b/core/qubesutils.py
index 1f1a4f4..90c2ef8 100644
--- a/core/qubesutils.py
+++ b/core/qubesutils.py
@@ -761,6 +761,8 @@ class QubesWatch(object):
                 return
         else:
             name = "dom0"
+            if name in self._qdb:
+                return
             self._qdb[name] = QubesDB(name)
         try:
             self._qdb[name].watch('/qubes-block-devices')
-- 
2.8.1

Attachment: 0001-QubesWatch-do-not-create-multiple-dom0-QubesDB-conne.patch.sig
Description: PGP signature

Reply via email to