Fix qemu-img rebase code to support Qemu 6.1. Ref https://github.com/GNS3/gns3-server/pull/1962

This commit is contained in:
grossmj
2021-09-05 22:18:46 +09:30
parent 99d7d0c769
commit 611570a863
3 changed files with 10 additions and 6 deletions

View File

@ -118,18 +118,19 @@ class Qcow2:
except Qcow2Error:
return (base_image, None) # non-qcow2 base images are acceptable (e.g. vmdk, raw image)
async def rebase(self, qemu_img, base_image):
async def rebase(self, qemu_img, base_image, backing_file_format):
"""
Rebase a linked clone in order to use the correct disk
:param qemu_img: Path to the qemu-img binary
:param base_image: Path to the base image
:param backing_file_format: File format of the base image
"""
if not os.path.exists(base_image):
raise FileNotFoundError(base_image)
backing_options, _ = Qcow2.backing_options(base_image)
command = [qemu_img, "rebase", "-u", "-b", backing_options, self._path]
command = [qemu_img, "rebase", "-u", "-b", backing_options, "-F", backing_file_format, self._path]
process = await asyncio.create_subprocess_exec(*command)
retcode = await process.wait()
if retcode != 0: