]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Set qemu drive caching options for qemu drives as well
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 23 Oct 2024 09:50:15 +0000 (11:50 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 25 Oct 2024 12:02:48 +0000 (14:02 +0200)
We already set these for the scratch device, let's make sure we set
them for any drives we allocate as well.

We also make sure the drive size is aligned to the page size so qemu
can use O_DIRECT.

mkosi/qemu.py

index d2534d06fe16acc95b9d0d6b9357bcf2d651dec3..511f4106232f3a7aeb3637ca1df9979b6e69a458 100644 (file)
@@ -752,7 +752,7 @@ def finalize_drive(config: Config, drive: QemuDrive) -> Iterator[Path]:
         prefix=f"mkosi-drive-{drive.id}",
     ) as file:
         make_nocow(config, Path(file.name))
-        file.truncate(drive.size)
+        file.truncate(round_up(drive.size, resource.getpagesize()))
         yield Path(file.name)
 
 
@@ -1348,7 +1348,7 @@ def run_qemu(args: Args, config: Config) -> None:
             file = stack.enter_context(finalize_drive(config, drives[0]))
 
             for drive in drives:
-                arg = f"if=none,id={drive.id},file={file},format=raw,file.locking=off"
+                arg = f"if=none,id={drive.id},file={file},format=raw,file.locking=off,cache.writeback=on,cache.direct=on,cache.no-flush=yes,aio=io_uring"  # noqa: E501
                 if drive.options:
                     arg += f",{drive.options}"