Merge remote-tracking branch 'qubesos/pr/51' into core3-devel
* qubesos/pr/51: Make pylint happy ♥ qubes.storage.lvm Fix lvm AppVM startup from lvm qubes.storage.lvm.qubes_lvm use debug not info Fix qvm-create lvm based AppVM qvm-block & qvm-pool add better Exception handling Remove unexpected property qvm-start --debug don't catch exceptions
This commit is contained in:
commit
6cb624daf3
@ -43,7 +43,7 @@ class ThinPool(qubes.storage.Pool):
|
||||
self.log = logging.getLogger('qube.storage.lvm.%s' % self._pool_id)
|
||||
|
||||
def clone(self, source, target):
|
||||
cmd = ['clone', source.vid, target.vid]
|
||||
cmd = ['clone', str(source), str(target)]
|
||||
qubes_lvm(cmd, self.log)
|
||||
return target
|
||||
|
||||
@ -217,8 +217,10 @@ class ThinPool(qubes.storage.Pool):
|
||||
def stop(self, volume):
|
||||
if volume.save_on_stop:
|
||||
self._commit(volume)
|
||||
|
||||
if volume._is_volatile:
|
||||
if volume._is_snapshot:
|
||||
cmd = ['remove', volume._vid_snap]
|
||||
qubes_lvm(cmd, self.log)
|
||||
elif volume._is_volatile:
|
||||
cmd = ['remove', volume.vid]
|
||||
qubes_lvm(cmd, self.log)
|
||||
else:
|
||||
@ -227,6 +229,12 @@ class ThinPool(qubes.storage.Pool):
|
||||
return volume
|
||||
|
||||
def _snapshot(self, volume):
|
||||
try:
|
||||
cmd = ['remove', volume._vid_snap]
|
||||
qubes_lvm(cmd, self.log)
|
||||
except: # pylint: disable=bare-except
|
||||
pass
|
||||
|
||||
if volume.source is None:
|
||||
cmd = ['clone', volume.vid, volume._vid_snap]
|
||||
else:
|
||||
@ -342,7 +350,7 @@ def qubes_lvm(cmd, log=logging.getLogger('qube.storage.lvm')):
|
||||
out, err = p.communicate()
|
||||
return_code = p.returncode
|
||||
if out:
|
||||
log.info(out)
|
||||
log.debug(out)
|
||||
if return_code == 0 and err:
|
||||
log.warning(err)
|
||||
elif return_code != 0:
|
||||
|
@ -229,8 +229,13 @@ def get_parser():
|
||||
|
||||
def main(args=None):
|
||||
'''Main routine of :program:`qvm-block`.'''
|
||||
args = get_parser().parse_args(args)
|
||||
args.func(args)
|
||||
parser = get_parser()
|
||||
try:
|
||||
args = parser.parse_args(args)
|
||||
args.func(args)
|
||||
except qubes.exc.QubesException as e:
|
||||
parser.print_error(e.message)
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -187,7 +187,12 @@ def main(args=None):
|
||||
command line.
|
||||
'''
|
||||
parser = get_parser()
|
||||
args = parser.parse_args(args)
|
||||
try:
|
||||
args = parser.parse_args(args)
|
||||
except qubes.exc.QubesException as e:
|
||||
parser.print_error(e.message)
|
||||
return 1
|
||||
|
||||
if args.command is None or args.command == 'list':
|
||||
list_pools(args.app)
|
||||
elif args.command == 'add':
|
||||
|
@ -133,13 +133,17 @@ def main(args=None):
|
||||
if args.debug:
|
||||
vm.debug = args.debug
|
||||
|
||||
try:
|
||||
if args.debug:
|
||||
vm.start(
|
||||
preparing_dvm=args.preparing_dvm,
|
||||
start_guid=args.start_guid)
|
||||
except qubes.exc.QubesException as e:
|
||||
parser.error_runtime('Qubes error: {!r}'.format(e))
|
||||
|
||||
else:
|
||||
try:
|
||||
vm.start(
|
||||
preparing_dvm=args.preparing_dvm,
|
||||
start_guid=args.start_guid)
|
||||
except qubes.exc.QubesException as e:
|
||||
parser.error_runtime('Qubes error: {!r}'.format(e))
|
||||
return 0
|
||||
|
||||
|
||||
|
@ -164,7 +164,7 @@ class NetVMMixin(qubes.events.Emitter):
|
||||
pass
|
||||
|
||||
try:
|
||||
vm.attach_network(wait=False)
|
||||
vm.attach_network()
|
||||
except qubes.exc.QubesException:
|
||||
vm.log.warning('Cannot attach network', exc_info=1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user