virt-manager/0001-virtinst-Fix-TOCTOU-in-domain-enumeration.patch
DistroBaker c9a2e3af8e Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/virt-manager.git#52737d0d3676305fdffc1db57dae8dd6fe71d83c
2021-01-11 19:02:01 +00:00

45 lines
1.7 KiB
Diff

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