From 910f793c619b9a01b0f69b84f49f328f6d5d05c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 25 Jul 2017 14:20:42 +0200 Subject: [PATCH] storage: fix Storage.clone and Storage.clone_volume 1. Volume.import_volume expect volume to be created first. 2. asyncio.wait do not accept generator, it must be concrete iterable. --- qubes/storage/__init__.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index 97e2bda0..afbdcc68 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -513,13 +513,22 @@ class Storage(object): src_volume = src_vm.volumes[name] msg = "Importing volume {!s} from vm {!s}" self.vm.log.info(msg.format(src_volume.name, src_vm.name)) + + # First create the destination volume + create_op_ret = dst.create() + # clone/import functions may be either synchronous or asynchronous + # in the later case, we need to wait for them to finish + if asyncio.iscoroutine(create_op_ret): + yield from create_op_ret + + # Then import data from source volume clone_op_ret = dst.import_volume(src_volume) # clone/import functions may be either synchronous or asynchronous # in the later case, we need to wait for them to finish if asyncio.iscoroutine(clone_op_ret): - clone_op_ret = yield from clone_op_ret - self.vm.volumes[name] = clone_op_ret + yield from clone_op_ret + self.vm.volumes[name] = dst return self.vm.volumes[name] @asyncio.coroutine @@ -528,8 +537,8 @@ class Storage(object): self.vm.volumes = {} with VmCreationManager(self.vm): - yield from asyncio.wait(self.clone_volume(src_vm, vol_name) - for vol_name in self.vm.volume_config.keys()) + yield from asyncio.wait([self.clone_volume(src_vm, vol_name) + for vol_name in self.vm.volume_config.keys()]) @property def outdated_volumes(self):