Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for setting virtual_size per qemu variant #2041

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cmd-artifact-disk
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def artifact_cli():
help="Ignition platform to set image to")
manual.add_argument("--convert_options",
help="qemu-img options")
manual.add_argument("--virtual-size", help="Virtual Size to use")

args = parser.parse_args()

Expand All @@ -97,6 +98,7 @@ def artifact_cli():
'image_suffix': args.image_suffix,
'platform': args.platform,
'schema': args.schema,
'virtual_size': args.virtual_size,
}
if args.convert_options:
kwargs["convert_options"] = {'-o': f'{args.convert_options}'}
Expand Down
10 changes: 10 additions & 0 deletions src/cosalib/qemuvariants.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"ibmcloud": {
"image_format": "qcow2",
"platform": "ibmcloud",
"virtual_size": "100G",
},
"openstack": {
"image_format": "qcow2",
Expand Down Expand Up @@ -150,6 +151,7 @@ def __init__(self, **kwargs):
convert_options: optional qemu arguments
platform: the name of the image.
platform_image_name: in case you want to use a different name
virtual_size: in case you want to explicitly set a virtual size

Alternatively, you can provide "variant=<variant>" and defaults will be
used.
Expand All @@ -166,6 +168,7 @@ def __init__(self, **kwargs):
self.force = kwargs.get("force", False)
self.tar_members = kwargs.pop("tar_members", None)
self.tar_flags = kwargs.pop("tar_flags", [DEFAULT_TAR_FLAGS])
self.virtual_size = kwargs.pop("virtual_size", None)

# this is used in case the image has a different disk
# name than the platform
Expand Down Expand Up @@ -229,6 +232,13 @@ def mutate_image(self):

log.info(f"Staging temp image: {work_img}")
self.set_platform()

# Resizing if requested
if self.virtual_size is not None:
resize_cmd = ['qemu-img', 'resize',
self.tmp_image, self.virtual_size]
run_verbose(resize_cmd)

cmd = ['qemu-img', 'convert', '-f', 'qcow2', '-O',
self.image_format, self.tmp_image]
for k, v in self.convert_options.items():
Expand Down