domain: rename: Fix when nvram pool is newly created

We don't have any way at the momemnt to synchronously update cached
object lists. So if old_nvram will create a pool for the nvram dir
(/var/lib/libvirt/qemu/nvram), new_nvram won't see that new object
in our cache, will attempt to create it itself, and raise an error.
Next attempts succeed though.

We can avoid this by not even setting new_nvram.path, that step was
redundant anyways since we are setting a vol_install right afterwards.
This way, new_nvram is getting a reference to the parent_pool object
via the vol_install, so it doesn't even check the pool object cache.
This commit is contained in:
Cole Robinson 2017-03-08 14:20:41 -05:00
parent a9e3e50046
commit f61e586b77

View File

@ -567,13 +567,11 @@ class vmmDomain(vmmLibvirtObject):
nvram_dir = os.path.dirname(old_nvram.path)
new_nvram_path = os.path.join(nvram_dir, "%s_VARS.fd" % new_name)
new_nvram = VirtualDisk(self.conn.get_backend())
new_nvram.path = new_nvram_path
nvram_install = VirtualDisk.build_vol_install(
self.conn.get_backend(), os.path.basename(new_nvram.path),
new_nvram.get_parent_pool(), new_nvram.get_size(), False)
self.conn.get_backend(), os.path.basename(new_nvram_path),
old_nvram.get_parent_pool(), old_nvram.get_size(), False)
nvram_install.input_vol = old_nvram.get_vol_object()
nvram_install.sync_input_vol(only_format=True)