While writing code that automatically chooses and migrates virtual machines using python 3.5 and libvirt. I got it working one way, but returning a guest to it's previous host fails (as of now I only have 2 hosts, but it should change in the future).
What I did:
Migrated a guest G from host SRC to Host DST.
- Got the capacity of the source image on SRC using
conn.storagePoolLookupByName('default') stgvol = pool.storageVolLookupByName(stgvolname).info()[1]
- Created a destination image on DST:
subprocess.run(['qemu-img', 'create', '-f', 'qcow2', vm_image_path, size_str])
- Migrated the guest from SRC to DST:
dom = conn.lookupByName(domain_name) new_dom = dom.migrate(dest_conn, libvirt.VIR_MIGRATE_LIVE, None, None, 0)
- Got the capacity of the source image on SRC using
Tried to migrate guest G back from B to A using the same steps in (1.) But got
libvirt.libvirtError: Storage volume not found: no storage vol with matching name 'guest-name'
on the line withstorageVolLookupByName
.
So it seems the image is not registering in the default pool during migration. Any thought on why this might be, or what can I do to fix it?