]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
qemu: Don't synthesize root= if it's provided on the kernel command line
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 3 Dec 2023 13:24:48 +0000 (14:24 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 4 Dec 2023 13:21:46 +0000 (14:21 +0100)
mkosi/qemu.py

index 49ce07a11067c4d569c246579982d8b1b2667b9b..81cd5dc90a69af123f384cb9d10ffc8248ee38c4 100644 (file)
@@ -566,31 +566,31 @@ def run_qemu(args: MkosiArgs, config: MkosiConfig, qemu_device_fds: Mapping[Qemu
                  "--offline=yes",
                  fname])
 
-        root = None
+        if kernel and (KernelType.identify(kernel) != KernelType.uki or not config.architecture.supports_smbios()):
+            kcl = config.kernel_command_line + config.kernel_command_line_extra
+        else:
+            kcl = config.kernel_command_line_extra
+
         if kernel:
             cmdline += ["-kernel", kernel]
 
-            if config.output_format == OutputFormat.disk:
+            if any(s.startswith("root=") for s in kcl):
+                pass
+            elif config.output_format == OutputFormat.disk:
                 # We can't rely on gpt-auto-generator when direct kernel booting so synthesize a root=
                 # kernel argument instead.
                 root = finalize_root(find_partitions(fname))
                 if not root:
                     die("Cannot perform a direct kernel boot without a root or usr partition")
+
+                kcl += [root]
             elif config.output_format == OutputFormat.directory:
                 sock = stack.enter_context(start_virtiofsd(fname, uidmap=False))
                 cmdline += [
                     "-chardev", f"socket,id={sock.name},path={sock}",
                     "-device", f"vhost-user-fs-pci,queue-size=1024,chardev={sock.name},tag=root",
                 ]
-                root = "root=root rootfstype=virtiofs rw"
-
-        if kernel and (KernelType.identify(kernel) != KernelType.uki or not config.architecture.supports_smbios()):
-            kcl = config.kernel_command_line + config.kernel_command_line_extra
-        else:
-            kcl = config.kernel_command_line_extra
-
-        if root:
-            kcl += [root]
+                kcl += ["root=root", "rootfstype=virtiofs", "rw"]
 
         for tree in config.runtime_trees:
             sock = stack.enter_context(start_virtiofsd(tree.source, uidmap=True))