mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 08:26:03 +00:00
fix(vrtManager): a template's copy takes qcow2's options only as qcow2
The copy of a template for a new VM always got qcow2's compat and lazy_refcounts, which libvirt refuses for a qcow template, and only a dir pool named it as a file. Every pool of files now does, and only a qcow2 copy gets those options. The pool types of files are one list, which the cloud-init seed check also reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
f952d4e0d0
commit
ff46ae509f
3 changed files with 34 additions and 10 deletions
|
|
@ -39,3 +39,31 @@ class NewVolumeTests(SimpleTestCase):
|
|||
self.assertEqual(volume.findtext("name"), "vm.qcow")
|
||||
self.assertIsNone(volume.find("target/compat"))
|
||||
self.assertIsNone(volume.find("target/features"))
|
||||
|
||||
|
||||
class TemplateCopyTests(SimpleTestCase):
|
||||
def copied(self, pool_type, fmt):
|
||||
"""The XML and flags of the copy of a template of format fmt into a pool of pool_type."""
|
||||
with patch("vrtManager.connection.connection_manager.get_connection") as get:
|
||||
template = get.return_value.storageVolLookupByPath.return_value
|
||||
template.XMLDesc.return_value = f"<volume><target><format type='{fmt}'/></target></volume>"
|
||||
pool = get.return_value.storagePoolLookupByName.return_value
|
||||
pool.XMLDesc.return_value = f"<pool type='{pool_type}'/>"
|
||||
wvmCreate("host", "login", "pw", 1).clone_from_template("vm", "/t/base", "pool1", True)
|
||||
xml, _template, flags = pool.createXMLFrom.call_args.args
|
||||
return etree.fromstring(xml), flags
|
||||
|
||||
def test_a_file_pool_takes_a_file_copy(self):
|
||||
for pool_type in ("dir", "fs", "netfs"):
|
||||
with self.subTest(pool_type):
|
||||
volume, flags = self.copied(pool_type, "qcow2")
|
||||
self.assertEqual((volume.findtext("name"), flags), ("vm.img", True))
|
||||
self.assertIsNotNone(volume.find("target/features/lazy_refcounts"))
|
||||
|
||||
def test_only_a_qcow2_copy_takes_its_options(self):
|
||||
for fmt in ("raw", "qcow"):
|
||||
with self.subTest(fmt):
|
||||
volume, _flags = self.copied("dir", fmt)
|
||||
self.assertEqual(volume.find("target/format").get("type"), fmt)
|
||||
self.assertIsNone(volume.find("target/compat"))
|
||||
self.assertIsNone(volume.find("target/features"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue