Blame SOURCES/0001-virtinst-Fix-TOCTOU-in-domain-enumeration.patch

610fa1
From 4d0e323227f18e58283c45be4d240b506faacb22 Mon Sep 17 00:00:00 2001
610fa1
Message-Id: <4d0e323227f18e58283c45be4d240b506faacb22.1610390294.git.crobinso@redhat.com>
610fa1
From: Martin Pitt <martin@piware.de>
610fa1
Date: Tue, 24 Nov 2020 14:24:06 +0100
610fa1
Subject: [PATCH virt-manager] virtinst: Fix TOCTOU in domain enumeration
610fa1
610fa1
Similar to commit 49a01b5482, _fetch_all_domains_raw() has a race
610fa1
condition where a domain may disappear (from parallel libvirt
610fa1
operations) in between enumerating and inspecting the objects.
610fa1
610fa1
Ignore these missing domains instead of crashing.
610fa1
610fa1
https://bugzilla.redhat.com/show_bug.cgi?id=1901081
610fa1
Signed-off-by: Cole Robinson <crobinso@redhat.com>
610fa1
---
610fa1
 virtinst/connection.py | 12 ++++++++++--
610fa1
 1 file changed, 10 insertions(+), 2 deletions(-)
610fa1
610fa1
diff --git a/virtinst/connection.py b/virtinst/connection.py
610fa1
index fec273b7..06bc60ad 100644
610fa1
--- a/virtinst/connection.py
610fa1
+++ b/virtinst/connection.py
610fa1
@@ -182,8 +182,16 @@ class VirtinstConnection(object):
610fa1
     def _fetch_all_domains_raw(self):
610fa1
         dummy1, dummy2, ret = pollhelpers.fetch_vms(
610fa1
             self, {}, lambda obj, ignore: obj)
610fa1
-        return [Guest(weakref.proxy(self), parsexml=obj.XMLDesc(0))
610fa1
-                for obj in ret]
610fa1
+        domains = []
610fa1
+        for obj in ret:
610fa1
+            # TOCTOU race: a domain may go away in between enumeration and inspection
610fa1
+            try:
610fa1
+                xml = obj.XMLDesc(0)
610fa1
+            except libvirt.libvirtError as e:  # pragma: no cover
610fa1
+                log.debug("Fetching domain XML failed: %s", e)
610fa1
+                continue
610fa1
+            domains.append(Guest(weakref.proxy(self), parsexml=xml))
610fa1
+        return domains
610fa1
 
610fa1
     def _build_pool_raw(self, poolobj):
610fa1
         return StoragePool(weakref.proxy(self),
610fa1
-- 
610fa1
2.29.2
610fa1