Explorar o código

Avoid libvirt access in qubes.vm.qubesvm.QubesVM

Bahtiar `kalkin-` Gadimov %!s(int64=8) %!d(string=hai) anos
pai
achega
bba9b38e8e
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      qubes/vm/qubesvm.py

+ 5 - 1
qubes/vm/qubesvm.py

@@ -1099,7 +1099,11 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
         :param qubes.vm.qubesvm.QubesVM src: source VM
         '''
 
-        if not self.is_halted():
+        # If the current vm name is not a part of `self.app.domains.keys()`,
+        # then the current vm is in creation process. Calling
+        # `self.is_halted()` at this point, would instantiate libvirt, we want
+        # avoid that.
+        if self.name in self.app.domains.keys() and not self.is_halted():
             raise qubes.exc.QubesVMNotHaltedError(
                 self, 'Cannot clone a running domain {!r}'.format(self.name))