xid: ensure vm is not running

This commit is contained in:
Frédéric Pierret (fepitre) 2020-02-27 10:31:28 +01:00
parent 820500a367
commit 3f4ee9f8d9
No known key found for this signature in database
GPG Key ID: 484010B5CDC576E2

View File

@ -690,7 +690,10 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
if self.libvirt_domain is None:
return -1
try:
return self.libvirt_domain.ID()
if self.is_running():
return self.libvirt_domain.ID()
else:
return -1
except libvirt.libvirtError as e:
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
return -1