Merge remote-tracking branch 'qubesos/pr/228'

* qubesos/pr/228:
  storage/lvm: filter out warning about intended over-provisioning
  tests: fix getting kernel package version inside VM
  tests/extra: add start_guid option to VMWrapper
  vm/qubesvm: fire 'domain-start-failed' event even if fail was early
  vm/qubesvm: check if all required devices are available before start
  storage/lvm: fix reporting lvm command error
  storage/lvm: save pool's revision_to_keep property
This commit is contained in:
Marek Marczykowski-Górecki 2018-09-07 01:06:59 +02:00
commit 7f1e2741ec
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
4 changed files with 27 additions and 7 deletions

View File

@ -102,7 +102,8 @@ class ThinPool(qubes.storage.Pool):
'name': self.name, 'name': self.name,
'volume_group': self.volume_group, 'volume_group': self.volume_group,
'thin_pool': self.thin_pool, 'thin_pool': self.thin_pool,
'driver': ThinPool.driver 'driver': ThinPool.driver,
'revisions_to_keep': self.revisions_to_keep,
} }
def destroy(self): def destroy(self):
@ -702,6 +703,12 @@ def qubes_lvm(cmd, log=logging.getLogger('qubes.storage.lvm')):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
close_fds=True, env=environ) close_fds=True, env=environ)
out, err = p.communicate() out, err = p.communicate()
err = err.decode()
# Filter out warning about intended over-provisioning.
# Upstream discussion about missing option to silence it:
# https://bugzilla.redhat.com/1347008
err = '\n'.join(line for line in err.splitlines()
if 'exceeds the size of thin pool' not in line)
return_code = p.returncode return_code = p.returncode
if out: if out:
log.debug(out) log.debug(out)
@ -709,6 +716,7 @@ def qubes_lvm(cmd, log=logging.getLogger('qubes.storage.lvm')):
log.warning(err) log.warning(err)
elif return_code != 0: elif return_code != 0:
assert err, "Command exited unsuccessful, but printed nothing to stderr" assert err, "Command exited unsuccessful, but printed nothing to stderr"
err = err.replace('%', '%%')
raise qubes.storage.StoragePoolException(err) raise qubes.storage.StoragePoolException(err)
return True return True

View File

@ -66,8 +66,9 @@ class VMWrapper(object):
def __hash__(self): def __hash__(self):
return hash(self._vm) return hash(self._vm)
def start(self): def start(self, start_guid=True):
return self._loop.run_until_complete(self._vm.start()) return self._loop.run_until_complete(
self._vm.start(start_guid=start_guid))
def shutdown(self): def shutdown(self):
return self._loop.run_until_complete(self._vm.shutdown()) return self._loop.run_until_complete(self._vm.shutdown())

View File

@ -70,7 +70,7 @@ class TC_40_PVGrub(object):
def get_kernel_version(self, vm): def get_kernel_version(self, vm):
if self.template.startswith('fedora-'): if self.template.startswith('fedora-'):
cmd_get_kernel_version = 'rpm -q kernel-core|sort -n|tail -1|' \ cmd_get_kernel_version = 'rpm -q kernel-core|sort -V|tail -1|' \
'cut -d - -f 3-' 'cut -d - -f 3-'
elif self.template.startswith('debian-'): elif self.template.startswith('debian-'):
cmd_get_kernel_version = \ cmd_get_kernel_version = \

View File

@ -912,9 +912,20 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
self.log.info('Starting {}'.format(self.name)) self.log.info('Starting {}'.format(self.name))
try:
yield from self.fire_event_async('domain-pre-start', yield from self.fire_event_async('domain-pre-start',
pre_event=True, pre_event=True,
start_guid=start_guid, mem_required=mem_required) start_guid=start_guid, mem_required=mem_required)
except Exception as exc:
yield from self.fire_event_async('domain-start-failed',
reason=str(exc))
raise
for devclass in self.devices:
for dev in self.devices[devclass].persistent():
if isinstance(dev, qubes.devices.UnknownDevice):
raise qubes.exc.QubesException(
'{} device {} not available'.format(devclass, dev))
qmemman_client = None qmemman_client = None
try: try: