core: improve handling dead domains when talking to QubesDB daemon
Provide vm.refresh(), which will force to reconnect do QubesDB daemon, and also get new libvirt object (including new ID, if any). Use this method whenever QubesDB call returns DisconnectedError exception. Also raise that exception when someone is trying to talk to not running QubesDB - instead of returning None.
This commit is contained in:
parent
124a26ec97
commit
bb958fd1c8
@ -654,9 +654,8 @@ class QubesVm(object):
|
||||
@property
|
||||
def qdb(self):
|
||||
if self._qdb_connection is None:
|
||||
if self.is_running():
|
||||
from qubes.qdb import QubesDB
|
||||
self._qdb_connection = QubesDB(self.name)
|
||||
from qubes.qdb import QubesDB
|
||||
self._qdb_connection = QubesDB(self.name)
|
||||
return self._qdb_connection
|
||||
|
||||
@property
|
||||
@ -705,6 +704,10 @@ class QubesVm(object):
|
||||
# obsoleted
|
||||
return self.uuid
|
||||
|
||||
def refresh(self):
|
||||
self._libvirt_domain = None
|
||||
self._qdb_connection = None
|
||||
|
||||
def get_mem(self):
|
||||
if dry_run:
|
||||
return 666
|
||||
|
@ -244,8 +244,7 @@ def block_list_vm(vm, system_disks = False):
|
||||
try:
|
||||
untrusted_devices = vm.qdb.multiread('/qubes-block-devices/')
|
||||
except DisconnectedError:
|
||||
# FIXME: find some better way to do that
|
||||
vm._qdb_connection = None
|
||||
vm.refresh()
|
||||
return {}
|
||||
|
||||
def get_dev_item(dev, item):
|
||||
|
Loading…
Reference in New Issue
Block a user