summaryrefslogtreecommitdiff
path: root/virtinst/cloner.py
diff options
context:
space:
mode:
authorPavel Hrdina <phrdina@redhat.com>2019-03-28 14:27:04 +0100
committerPavel Hrdina <phrdina@redhat.com>2019-03-28 16:07:13 +0100
commit986097d5f8e7a62d2aa6edd4596302d4e0af4175 (patch)
tree223bc898261a5519c3f1caac67851616360f3058 /virtinst/cloner.py
parentffe7be601b91f6dfec67c386ccc9f2c852abd727 (diff)
downloadvirt-manager-986097d5f8e7a62d2aa6edd4596302d4e0af4175.tar.gz
cloner: don't fail to clone VM if nvram file doesn't exist
If a VM is defined and never started the nvram file might not exist and in that case it's created by libvirt automatically on the first start. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1679018 Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Diffstat (limited to 'virtinst/cloner.py')
-rw-r--r--virtinst/cloner.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/virtinst/cloner.py b/virtinst/cloner.py
index b29027e3..65315b8e 100644
--- a/virtinst/cloner.py
+++ b/virtinst/cloner.py
@@ -346,16 +346,15 @@ class Cloner(object):
self.clone_nvram = os.path.join(nvram_dir,
"%s_VARS.fd" % self._clone_name)
+ old_nvram = DeviceDisk(self.conn)
+ old_nvram.path = self._guest.os.nvram
+
nvram = DeviceDisk(self.conn)
nvram.path = self.clone_nvram
- if (not self.preserve_dest_disks and
- nvram.wants_storage_creation()):
- old_nvram = DeviceDisk(self.conn)
- old_nvram.path = self._guest.os.nvram
- if not old_nvram.get_vol_object():
- raise RuntimeError(_("Path does not exist: %s") %
- old_nvram.path)
+ if (not self.preserve_dest_disks and
+ nvram.wants_storage_creation() and
+ old_nvram.get_vol_object()):
nvram_install = DeviceDisk.build_vol_install(
self.conn, os.path.basename(nvram.path),
@@ -365,8 +364,9 @@ class Cloner(object):
nvram_install.reflink = self.reflink
nvram.set_vol_install(nvram_install)
- nvram.validate()
- self._nvram_disk = nvram
+ nvram.validate()
+ self._nvram_disk = nvram
+
self._guest.os.nvram = nvram.path