|
|
e4cbec |
From 6d6b0823f64d94726d03880400247ded280c7116 Mon Sep 17 00:00:00 2001
|
|
|
e4cbec |
Message-Id: <6d6b0823f64d94726d03880400247ded280c7116@dist-git>
|
|
|
e4cbec |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
e4cbec |
Date: Thu, 28 Mar 2019 14:27:04 +0100
|
|
|
e4cbec |
Subject: [PATCH] cloner: don't fail to clone VM if nvram file doesn't exist
|
|
|
e4cbec |
|
|
|
e4cbec |
If a VM is defined and never started the nvram file might not exist and
|
|
|
e4cbec |
in that case it's created by libvirt automatically on the first start.
|
|
|
e4cbec |
|
|
|
e4cbec |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1679018
|
|
|
e4cbec |
|
|
|
e4cbec |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
e4cbec |
(cherry picked from commit 986097d5f8e7a62d2aa6edd4596302d4e0af4175)
|
|
|
e4cbec |
|
|
|
e4cbec |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1679021
|
|
|
e4cbec |
|
|
|
e4cbec |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
e4cbec |
Reviewed-by: Cole Robinson <crobinso@redhat.com>
|
|
|
e4cbec |
---
|
|
|
e4cbec |
tests/clone-xml/nvram-missing-in.xml | 23 +++++++++++++++++++++++
|
|
|
e4cbec |
tests/clone-xml/nvram-missing-out.xml | 23 +++++++++++++++++++++++
|
|
|
e4cbec |
tests/clonetest.py | 3 +++
|
|
|
e4cbec |
virtinst/cloner.py | 18 +++++++++---------
|
|
|
e4cbec |
4 files changed, 58 insertions(+), 9 deletions(-)
|
|
|
e4cbec |
create mode 100644 tests/clone-xml/nvram-missing-in.xml
|
|
|
e4cbec |
create mode 100644 tests/clone-xml/nvram-missing-out.xml
|
|
|
e4cbec |
|
|
|
e4cbec |
diff --git a/tests/clone-xml/nvram-missing-in.xml b/tests/clone-xml/nvram-missing-in.xml
|
|
|
e4cbec |
new file mode 100644
|
|
|
e4cbec |
index 00000000..fcbce533
|
|
|
e4cbec |
--- /dev/null
|
|
|
e4cbec |
+++ b/tests/clone-xml/nvram-missing-in.xml
|
|
|
e4cbec |
@@ -0,0 +1,23 @@
|
|
|
e4cbec |
+<domain type='kvm'>
|
|
|
e4cbec |
+ <name>clone-orig</name>
|
|
|
e4cbec |
+ <uuid>aaa3ae22-fed2-bfbd-ac02-3bea3bcfad82</uuid>
|
|
|
e4cbec |
+ <memory>262144</memory>
|
|
|
e4cbec |
+ <currentMemory>262144</currentMemory>
|
|
|
e4cbec |
+ <vcpu>1</vcpu>
|
|
|
e4cbec |
+ <os>
|
|
|
e4cbec |
+ <type arch='i686' machine='pc'>hvm</type>
|
|
|
e4cbec |
+ <boot dev='cdrom'/>
|
|
|
e4cbec |
+ <loader readonly='yes' type='pflash'>/usr/share/ovmf/ovmf-efi.fd</loader>
|
|
|
e4cbec |
+ <nvram>/nvram/clone-orig-missing_VARS.fd</nvram>
|
|
|
e4cbec |
+ </os>
|
|
|
e4cbec |
+ <features>
|
|
|
e4cbec |
+ <acpi/>
|
|
|
e4cbec |
+ </features>
|
|
|
e4cbec |
+ <clock offset='utc'/>
|
|
|
e4cbec |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
e4cbec |
+ <on_reboot>restart</on_reboot>
|
|
|
e4cbec |
+ <on_crash>destroy</on_crash>
|
|
|
e4cbec |
+ <devices>
|
|
|
e4cbec |
+ <emulator>/usr/bin/qemu-kvm</emulator>
|
|
|
e4cbec |
+ </devices>
|
|
|
e4cbec |
+</domain>
|
|
|
e4cbec |
diff --git a/tests/clone-xml/nvram-missing-out.xml b/tests/clone-xml/nvram-missing-out.xml
|
|
|
e4cbec |
new file mode 100644
|
|
|
e4cbec |
index 00000000..c59eaea8
|
|
|
e4cbec |
--- /dev/null
|
|
|
e4cbec |
+++ b/tests/clone-xml/nvram-missing-out.xml
|
|
|
e4cbec |
@@ -0,0 +1,23 @@
|
|
|
e4cbec |
+<domain type="kvm">
|
|
|
e4cbec |
+ <name>clone-new</name>
|
|
|
e4cbec |
+ <uuid>12345678-1234-1234-1234-123456789012</uuid>
|
|
|
e4cbec |
+ <memory>262144</memory>
|
|
|
e4cbec |
+ <currentMemory>262144</currentMemory>
|
|
|
e4cbec |
+ <vcpu>1</vcpu>
|
|
|
e4cbec |
+ <os>
|
|
|
e4cbec |
+ <type arch="i686" machine="pc">hvm</type>
|
|
|
e4cbec |
+ <boot dev="cdrom"/>
|
|
|
e4cbec |
+ <loader readonly="yes" type="pflash">/usr/share/ovmf/ovmf-efi.fd</loader>
|
|
|
e4cbec |
+ <nvram>/nvram/clone-new_VARS.fd</nvram>
|
|
|
e4cbec |
+ </os>
|
|
|
e4cbec |
+ <features>
|
|
|
e4cbec |
+ <acpi/>
|
|
|
e4cbec |
+ </features>
|
|
|
e4cbec |
+ <clock offset="utc"/>
|
|
|
e4cbec |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
e4cbec |
+ <on_reboot>restart</on_reboot>
|
|
|
e4cbec |
+ <on_crash>destroy</on_crash>
|
|
|
e4cbec |
+ <devices>
|
|
|
e4cbec |
+ <emulator>/usr/bin/qemu-kvm</emulator>
|
|
|
e4cbec |
+ </devices>
|
|
|
e4cbec |
+</domain>
|
|
|
e4cbec |
diff --git a/tests/clonetest.py b/tests/clonetest.py
|
|
|
e4cbec |
index 5fd51e73..c09133ca 100644
|
|
|
e4cbec |
--- a/tests/clonetest.py
|
|
|
e4cbec |
+++ b/tests/clonetest.py
|
|
|
e4cbec |
@@ -188,6 +188,9 @@ class TestClone(unittest.TestCase):
|
|
|
e4cbec |
base = "nvram-newpool"
|
|
|
e4cbec |
self._clone_helper(base)
|
|
|
e4cbec |
|
|
|
e4cbec |
+ def testCloneNvramMissing(self):
|
|
|
e4cbec |
+ self._clone_helper("nvram-missing")
|
|
|
e4cbec |
+
|
|
|
e4cbec |
def testCloneGraphicsPassword(self):
|
|
|
e4cbec |
base = "graphics-password"
|
|
|
e4cbec |
self._clone_helper(base)
|
|
|
e4cbec |
diff --git a/virtinst/cloner.py b/virtinst/cloner.py
|
|
|
e4cbec |
index 632c3cbf..d54c3f85 100644
|
|
|
e4cbec |
--- a/virtinst/cloner.py
|
|
|
e4cbec |
+++ b/virtinst/cloner.py
|
|
|
e4cbec |
@@ -362,16 +362,15 @@ class Cloner(object):
|
|
|
e4cbec |
self.clone_nvram = os.path.join(nvram_dir,
|
|
|
e4cbec |
"%s_VARS.fd" % self._clone_name)
|
|
|
e4cbec |
|
|
|
e4cbec |
+ old_nvram = VirtualDisk(self.conn)
|
|
|
e4cbec |
+ old_nvram.path = self._guest.os.nvram
|
|
|
e4cbec |
+
|
|
|
e4cbec |
nvram = VirtualDisk(self.conn)
|
|
|
e4cbec |
nvram.path = self.clone_nvram
|
|
|
e4cbec |
+
|
|
|
e4cbec |
if (not self.preserve_dest_disks and
|
|
|
e4cbec |
- nvram.wants_storage_creation()):
|
|
|
e4cbec |
-
|
|
|
e4cbec |
- old_nvram = VirtualDisk(self.conn)
|
|
|
e4cbec |
- old_nvram.path = self._guest.os.nvram
|
|
|
e4cbec |
- if not old_nvram.get_vol_object():
|
|
|
e4cbec |
- raise RuntimeError(_("Path does not exist: %s") %
|
|
|
e4cbec |
- old_nvram.path)
|
|
|
e4cbec |
+ nvram.wants_storage_creation() and
|
|
|
e4cbec |
+ old_nvram.get_vol_object()):
|
|
|
e4cbec |
|
|
|
e4cbec |
nvram_install = VirtualDisk.build_vol_install(
|
|
|
e4cbec |
self.conn, os.path.basename(nvram.path),
|
|
|
e4cbec |
@@ -381,8 +380,9 @@ class Cloner(object):
|
|
|
e4cbec |
nvram_install.reflink = self.reflink
|
|
|
e4cbec |
nvram.set_vol_install(nvram_install)
|
|
|
e4cbec |
|
|
|
e4cbec |
- nvram.validate()
|
|
|
e4cbec |
- self._nvram_disk = nvram
|
|
|
e4cbec |
+ nvram.validate()
|
|
|
e4cbec |
+ self._nvram_disk = nvram
|
|
|
e4cbec |
+
|
|
|
e4cbec |
self._guest.os.nvram = nvram.path
|
|
|
e4cbec |
|
|
|
e4cbec |
|
|
|
e4cbec |
--
|
|
|
e4cbec |
2.20.1
|
|
|
e4cbec |
|