Skip to content

Commit

Permalink
Merge pull request #3795 from PaulYuuu/image-snapshot-size
Browse files Browse the repository at this point in the history
fix: Empty "image_size" in sn_params when "image_snapshot = yes"
  • Loading branch information
YongxueHong authored Nov 29, 2023
2 parents 60ef8ea + b31fc58 commit 065fa0a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion virttest/qemu_devices/qcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2503,13 +2503,19 @@ def images_define_by_params(self, name, image_params, media=None,
raise NotImplementedError("vdpa does NOT support the snapshot!")
if (Flags.BLOCKDEV in self.caps and
image_params.get("image_snapshot") == "yes"):
# FIXME: Most of attributes for the snapshot should be got from the
# base image's metadata, not from the Cartesian parameter,
# so we need to get the base image object, and then use it
# to create the snapshot.
sn_params = Params()
for k, v in image_params.items():
sn_params['%s_%s' % (k, name)] = v
sn = 'vl_%s_%s' % (self.vmname, name)
sn_params['image_chain'] = "%s %s" % (name, sn)
sn_params['image_name'] = sn
sn_params['image_size'] = image_params['image_size']
# Empty the image_size parameter so that qemu-img will align the
# size of the snapshot to the base image
sn_params['image_size'] = ""
sn_img = qemu_storage.QemuImg(sn_params, data_dir.get_data_dir(), sn)
image_filename = sn_img.create(sn_params)[0]
os.chmod(image_filename, stat.S_IRUSR | stat.S_IWUSR)
Expand Down

0 comments on commit 065fa0a

Please sign in to comment.