vm/qubesvm: handle libvirt reporting domain already dead when killing

If domain die when trying to kill it, qubesd may loose a race and try to
kill it anyway. Handle libvirt exception in that case and conver it to
QubesVMNotStartedError - as it would be if qubesd would win the race.

Fixes QubesOS/qubes-issues#3755
This commit is contained in:
Marek Marczykowski-Górecki 2018-04-02 23:56:03 +02:00
parent 1e9bf18bcf
commit f4be284331
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -1024,7 +1024,13 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
if not self.is_running() and not self.is_paused(): if not self.is_running() and not self.is_paused():
raise qubes.exc.QubesVMNotStartedError(self) raise qubes.exc.QubesVMNotStartedError(self)
try:
self.libvirt_domain.destroy() self.libvirt_domain.destroy()
except libvirt.libvirtError as e:
if e.get_error_code() == libvirt.VIR_ERR_OPERATION_INVALID:
raise qubes.exc.QubesVMNotStartedError(self)
else:
raise
return self return self