]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Drop --qcow2 and --bmap options
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 2 Apr 2023 15:06:31 +0000 (17:06 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 6 Apr 2023 18:31:39 +0000 (20:31 +0200)
Let's reduce the support surface by removing some fringe options

NEWS.md
mkosi.md
mkosi/__init__.py
mkosi/backend.py
tests/test_backend.py
tests/test_parse_load_args.py

diff --git a/NEWS.md b/NEWS.md
index 5c6a36e1502071ec24ab87f032419e6670b8b9ad..92b9649e499213692b959a4b315418793ce65f69 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -58,8 +58,9 @@
   runtime. Use the new `--qemu-gui` option to start qemu in its graphical interface.
 - Removed `--netdev`. Can be replaced by manually installing systemd-networkd, putting a network file in the
   image and enabling systemd-networkd.
-- If `mkosi.extra/` or `mkosi.skeleton/` exist, they are now always used instead of only when no explicit
-  extra/skeleton trees are defined.
+- If `mkosi.extra/` exists, it is now always used instead of only when no explicit extra trees are defined.
+- Removed `--qcow2` option in favor of supporting only raw disk images as the disk image output format.
+- Removed `--bmap` option as it can be trivially added manually by utilizing a finalize script.
 
 ## v14
 
index 4e2b8cac9a20f25ea01cf73b76c17246db910751..8e19bd70c52c199dc5dcf9bd2b37ab3f1a294873 100644 (file)
--- a/mkosi.md
+++ b/mkosi.md
@@ -381,13 +381,6 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0",
   the `shell`, `boot`, `qemu` verbs are not available when this option
   is used. Implied for `tar` and `cpio`.
 
-`QCow2=`, `--qcow2`
-
-: Encode the resulting image as QEMU QCOW2 image. This only applies when
-  generating disk images. QCOW2 images can be read natively by `qemu`, but
-  not by the Linux kernel. This means the `shell` and `boot` verbs are not
-  available when this option is used, however `qemu` will work.
-
 `Hostname=`, `--hostname=`
 
 : Set the image's hostname to the specified name.
@@ -771,11 +764,6 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0",
 : Select the `gpg` key to use for signing `SHA256SUMS`. This key must
   be already present in the `gpg` keyring.
 
-`BMap=`, `--bmap`
-
-: Generate a `bmap` file for usage with `bmaptool` from the generated
-  image file.
-
 ### [Host] Section
 
 `ExtraSearchPaths=`, `--extra-search-paths=`
index ca8507f744427ff1868a60e791ae43837e3d56c7..299e4a6e8abc95b91fea09b8736c5c41a270b25c 100644 (file)
@@ -888,20 +888,6 @@ def compress_output(config: MkosiConfig, src: Path, uid: int, gid: int) -> None:
             run(compressor_command(compress, src), user=uid, group=gid)
 
 
-def qcow2_output(state: MkosiState) -> None:
-    if not state.config.output_format == OutputFormat.disk:
-        return
-
-    if not state.config.qcow2:
-        return
-
-    with complete_step("Converting image file to qcow2…"):
-        run(["qemu-img", "convert", "-onocow=on", "-fraw", "-Oqcow2",
-             state.staging / state.config.output.name,
-             state.workspace / "qemu.img"])
-        os.rename(state.workspace / "qemu.img", state.staging / state.config.output.name)
-
-
 def copy_nspawn_settings(state: MkosiState) -> None:
     if state.config.nspawn_settings is None:
         return None
@@ -954,24 +940,6 @@ def calculate_signature(state: MkosiState) -> None:
         run(cmdline)
 
 
-def calculate_bmap(state: MkosiState) -> None:
-    if not state.config.bmap:
-        return
-
-    if not state.config.output_format == OutputFormat.disk:
-        return
-
-    with complete_step("Creating BMAP file…"):
-        cmdline: list[PathString] = [
-            "bmaptool",
-            "create",
-            "--output", state.staging / state.config.output_bmap.name,
-            state.staging / state.config.output.name,
-        ]
-
-        run(cmdline)
-
-
 def acl_toggle_remove(config: MkosiConfig, root: Path, uid: int, *, allow: bool) -> None:
     if not config.acl:
         return
@@ -1267,7 +1235,6 @@ class ArgumentParserMkosi(argparse.ArgumentParser):
 
     # Mapping of parameters supported in config files but not as command line arguments.
     SPECIAL_MKOSI_DEFAULT_PARAMS = {
-        "QCow2": "--qcow2",
         "OutputDirectory": "--output-dir",
         "WorkspaceDirectory": "--workspace-dir",
         "CacheDirectory": "--cache-dir",
@@ -1275,7 +1242,6 @@ class ArgumentParserMkosi(argparse.ArgumentParser):
         "BuildDirectory": "--build-dir",
         "NSpawnSettings": "--settings",
         "CheckSum": "--checksum",
-        "BMap": "--bmap",
         "Packages": "--package",
         "RemovePackages": "--remove-package",
         "ExtraTrees": "--extra-tree",
@@ -1576,12 +1542,6 @@ def create_parser() -> ArgumentParserMkosi:
         metavar="ALG",
         help="Enable whole-output compression (with images or archives)",
     )
-    group.add_argument(
-        "--qcow2",
-        action=BooleanAction,
-        metavar="BOOL",
-        help="Convert resulting image to qcow2",
-    )
     group.add_argument("--hostname", help="Set hostname")
     group.add_argument("--image-version", help="Set version for image")
     group.add_argument("--image-id", help="Set ID for image")
@@ -1804,12 +1764,6 @@ def create_parser() -> ArgumentParserMkosi:
         help="Write and sign SHA256SUMS file",
     )
     group.add_argument("--key", help="GPG key to use for signing")
-    group.add_argument(
-        "--bmap",
-        metavar="BOOL",
-        action=BooleanAction,
-        help="Write block map file (.bmap) for bmaptool usage",
-    )
 
     group = parser.add_argument_group("Host configuration options")
     group.add_argument(
@@ -2063,9 +2017,6 @@ def unlink_output(config: MkosiConfig) -> None:
         if config.sign:
             unlink_try_hard(config.output_signature)
 
-        if config.bmap:
-            unlink_try_hard(config.output_bmap)
-
         if config.output_split_kernel.parent.exists():
             for p in config.output_split_kernel.parent.iterdir():
                 if p.name.startswith(config.output_split_kernel.name):
@@ -2399,7 +2350,7 @@ def load_args(args: argparse.Namespace) -> MkosiConfig:
         prefix = f"{iid}_{args.image_version}" if args.image_version is not None else iid
 
         if args.output_format == OutputFormat.disk:
-            output = prefix + (".qcow2" if args.qcow2 else ".raw")
+            output = f"{prefix}.raw"
         elif args.output_format == OutputFormat.tar:
             output = f"{prefix}.tar"
         elif args.output_format == OutputFormat.cpio:
@@ -2493,8 +2444,6 @@ def load_args(args: argparse.Namespace) -> MkosiConfig:
             die(f"Sorry, can't {opname} with a {args.output_format} archive.", MkosiNotSupportedException)
         if should_compress_output(args):
             die(f"Sorry, can't {opname} with a compressed image.", MkosiNotSupportedException)
-        if args.qcow2:
-            die(f"Sorry, can't {opname} using a qcow2 image.", MkosiNotSupportedException)
 
     if args.verb == Verb.qemu:
         if not args.output_format == OutputFormat.disk:
@@ -2601,7 +2550,6 @@ def check_outputs(config: MkosiConfig) -> None:
         config.output,
         config.output_checksum if config.checksum else None,
         config.output_signature if config.sign else None,
-        config.output_bmap if config.bmap else None,
         config.output_nspawn_settings if config.nspawn_settings is not None else None,
         config.output_sshkey if config.ssh else None,
     ):
@@ -2707,15 +2655,11 @@ def print_summary(config: MkosiConfig) -> None:
     print("                    Output:", config.output)
     print("           Output Checksum:", none_to_na(config.output_checksum if config.checksum else None))
     print("          Output Signature:", none_to_na(config.output_signature if config.sign else None))
-    print("               Output Bmap:", none_to_na(config.output_bmap if config.bmap else None))
     print("    Output nspawn Settings:", none_to_na(config.output_nspawn_settings if config.nspawn_settings is not None else None))
 
     print("               Incremental:", yes_no(config.incremental))
     print("               Compression:", should_compress_output(config) or "no")
 
-    if config.output_format == OutputFormat.disk:
-        print("                     QCow2:", yes_no(config.qcow2))
-
     print("                  Bootable:", yes_no(config.bootable))
 
     if config.bootable:
@@ -3220,8 +3164,6 @@ def build_stuff(uid: int, gid: int, config: MkosiConfig) -> None:
             state = dataclasses.replace(state, for_cache=False)
             build_image(state, manifest=manifest)
 
-        qcow2_output(state)
-        calculate_bmap(state)
         copy_nspawn_settings(state)
         calculate_sha256sum(state)
         calculate_signature(state)
@@ -3572,12 +3514,12 @@ def run_qemu(config: MkosiConfig) -> None:
         if config.distribution == Distribution.debian:
             cmdline += [
                 "-drive",
-                f"if=virtio,id=hd,file={fname},format={'qcow2' if config.qcow2 else 'raw'}",
+                f"if=virtio,id=hd,file={fname},format=raw",
             ]
         else:
             cmdline += [
                 "-drive",
-                f"if=none,id=hd,file={fname},format={'qcow2' if config.qcow2 else 'raw'}",
+                f"if=none,id=hd,file={fname},format=raw",
                 "-device",
                 "virtio-scsi-pci,id=scsi",
                 "-device",
index a72ab70ea137f56b1befde6a52d490d517ef4687..d0110193ce55902879c8e8721faaf75717b2a490 100644 (file)
@@ -205,7 +205,6 @@ KNOWN_SUFFIXES = {
     ".raw",
     ".tar",
     ".cpio",
-    ".qcow2",
 }
 
 
@@ -250,7 +249,6 @@ class MkosiConfig:
     secure_boot_common_name: str
     sign_expected_pcr: bool
     compress_output: Union[None, str, bool]
-    qcow2: bool
     image_version: Optional[str]
     image_id: Optional[str]
     hostname: Optional[str]
@@ -283,7 +281,6 @@ class MkosiConfig:
     split_artifacts: bool
     sign: bool
     key: Optional[str]
-    bmap: bool
     password: Optional[str]
     password_is_hashed: bool
     autologin: bool
@@ -328,10 +325,6 @@ class MkosiConfig:
     def output_signature(self) -> Path:
         return Path("SHA256SUMS.gpg")
 
-    @property
-    def output_bmap(self) -> Path:
-        return build_auxiliary_output_path(self, ".bmap")
-
     @property
     def output_sshkey(self) -> Path:
         return build_auxiliary_output_path(self, ".ssh")
@@ -351,7 +344,6 @@ class MkosiConfig:
             self.output_nspawn_settings,
             self.output_checksum,
             self.output_signature,
-            self.output_bmap,
             self.output_sshkey,
             self.output_manifest,
             self.output_changelog,
index 9a8034b0886b96502a55233ff5fefaa4af530d1d..be8b966bd279b305fefb124aa4758b8451074f0b 100644 (file)
@@ -68,7 +68,6 @@ def test_strip_suffixes() -> None:
     assert strip_suffixes(Path("home/test.raw")) == Path("home/test")
     assert strip_suffixes(Path("home/test.tar")) == Path("home/test")
     assert strip_suffixes(Path("home/test.cpio")) == Path("home/test")
-    assert strip_suffixes(Path("home/test.qcow2")) == Path("home/test")
     assert strip_suffixes(Path("home.xz/test.xz")) == Path("home.xz/test")
     assert strip_suffixes(Path("home.xz/test")) == Path("home.xz/test")
     assert strip_suffixes(Path("home.xz/test.txt")) == Path("home.xz/test.txt")
index 297a8ecc97fe05a97f420c2c5f4e7b4037745c62..137f45adce0523b11b251abe77e04c0975590804 100644 (file)
@@ -91,9 +91,6 @@ def test_shell_boot() -> None:
     with pytest.raises(MkosiException, match=".boot.*compressed" ):
         parse(["--format", "disk", "--compress-output=yes", "boot"])
 
-    with pytest.raises(MkosiException, match=".boot.*qcow2"):
-        parse(["--format", "disk", "--qcow2", "boot"])
-
 def test_compression() -> None:
     assert not parse(["--format", "disk", "--compress-output", "False"]).compress_output