From 4e033c305e47b05c5ba299f48cb0298223d016a0 Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Fri, 14 Feb 2025 08:36:25 -0500 Subject: [PATCH] stages: add more options to qemu vmdk disk type The CoreOS team uses the compat6 and adapter_type options when creating a VMDK for AWS. https://github.com/coreos/coreos-assembler/blob/e1943d6adb8f0cb257630a76d02d0aa333261c70/src/cosalib/qemuvariants.py#L48 --- stages/org.osbuild.qemu | 14 ++++++++++++-- stages/org.osbuild.qemu.meta.json | 15 +++++++++++++++ test/data/stages/qemu/qemu.json | 28 ++++++++++++++++++++++++++++ test/data/stages/qemu/qemu.mpp.yaml | 17 +++++++++++++++++ 4 files changed, 72 insertions(+), 2 deletions(-) diff --git a/stages/org.osbuild.qemu b/stages/org.osbuild.qemu index a6df9166..caad5e88 100755 --- a/stages/org.osbuild.qemu +++ b/stages/org.osbuild.qemu @@ -21,14 +21,24 @@ def qcow2_arguments(options): def vmdk_arguments(options): argv = [] + adapter_type = options.get("adapter_type") + compat6 = options.get("compat6", False) compression = options.get("compression", True) subformat = options.get("subformat") if compression: argv += ["-c"] - if subformat: - argv += ["-o", f"subformat={subformat}"] + if compat6 or subformat or adapter_type: + opts = [] + if adapter_type: + opts += [f"adapter_type={adapter_type}"] + if compat6: + opts += ["compat6"] + if subformat: + opts += [f"subformat={subformat}"] + argv += ["-o", ",".join(opts)] + return argv diff --git a/stages/org.osbuild.qemu.meta.json b/stages/org.osbuild.qemu.meta.json index 5542d27f..5fb38e04 100644 --- a/stages/org.osbuild.qemu.meta.json +++ b/stages/org.osbuild.qemu.meta.json @@ -68,6 +68,21 @@ "vmdk" ] }, + "adapter_type": { + "description": "Virtual adapter type", + "type": "string", + "enum": [ + "ide", + "lsilogic", + "buslogic", + "legacyESX" + ] + }, + "compat6": { + "description": "VMDK version 6 image", + "type": "boolean", + "default": false + }, "compression": { "description": "Enable/disable compression of the vmdk image", "type": "boolean", diff --git a/test/data/stages/qemu/qemu.json b/test/data/stages/qemu/qemu.json index 3781e24a..b443c0c2 100644 --- a/test/data/stages/qemu/qemu.json +++ b/test/data/stages/qemu/qemu.json @@ -638,6 +638,34 @@ } ] }, + { + "name": "image-compat6-adapter-type.vmdk", + "build": "name:build", + "stages": [ + { + "type": "org.osbuild.qemu", + "inputs": { + "image": { + "type": "org.osbuild.files", + "origin": "org.osbuild.pipeline", + "references": { + "name:image": { + "file": "image.raw" + } + } + } + }, + "options": { + "filename": "image-stream.vmdk", + "format": { + "type": "vmdk", + "compat6": true, + "adapter_type": "lsilogic" + } + } + } + ] + }, { "name": "image.vpc", "build": "name:build", diff --git a/test/data/stages/qemu/qemu.mpp.yaml b/test/data/stages/qemu/qemu.mpp.yaml index cf1b4b80..30e0c218 100644 --- a/test/data/stages/qemu/qemu.mpp.yaml +++ b/test/data/stages/qemu/qemu.mpp.yaml @@ -91,6 +91,23 @@ pipelines: format: type: vmdk subformat: streamOptimized + - name: image-compat6-adapter-type.vmdk + build: name:build + stages: + - type: org.osbuild.qemu + inputs: + image: + type: org.osbuild.files + origin: org.osbuild.pipeline + references: + name:image: + file: image.raw + options: + filename: image-stream.vmdk + format: + type: vmdk + compat6: true + adapter_type: lsilogic - name: image.vpc build: name:build stages: