From a719e0d93d890b23a027dc70a709cc61d3485aa6 Mon Sep 17 00:00:00 2001 From: Wojtek Porczyk Date: Thu, 2 Jun 2016 17:18:33 +0200 Subject: [PATCH] qubes/vm/qubesvm: allow looking up by UUID Also, allow lookup using VM from other app. QubesOS/qubes-issues#866 --- qubes/app.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qubes/app.py b/qubes/app.py index e5e75d07..3bc8065b 100644 --- a/qubes/app.py +++ b/qubes/app.py @@ -414,8 +414,12 @@ class VMCollection(object): raise KeyError(key) if isinstance(key, qubes.vm.BaseVM): - if key in self: - return key + key = key.uuid + + if isinstance(key, uuid.UUID): + for vm in self: + if vm.uuid == key: + return vm raise KeyError(key) raise KeyError(key)