From 17ed2a5b50079412f8e19ae4cfa26fb308b1efd1 Mon Sep 17 00:00:00 2001 From: Adam Stephens Date: Sat, 7 Sep 2024 10:42:49 -0400 Subject: [PATCH] incus: apply qemu 9.1 patches --- ...b7e3ec65b4d0e166e2127d9f1835320165b8.patch | 29 ++++++++++++++++ ...fb06f66f83ca95efa1b9386fceeaa1c9e11b.patch | 28 ++++++++++++++++ ...b4eeee8a9e7f9fa9c62443d00f0ec6797078.patch | 33 +++++++++++++++++++ pkgs/by-name/in/incus/package.nix | 7 +++- 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 pkgs/by-name/in/incus/0c37b7e3ec65b4d0e166e2127d9f1835320165b8.patch create mode 100644 pkgs/by-name/in/incus/572afb06f66f83ca95efa1b9386fceeaa1c9e11b.patch create mode 100644 pkgs/by-name/in/incus/58eeb4eeee8a9e7f9fa9c62443d00f0ec6797078.patch diff --git a/pkgs/by-name/in/incus/0c37b7e3ec65b4d0e166e2127d9f1835320165b8.patch b/pkgs/by-name/in/incus/0c37b7e3ec65b4d0e166e2127d9f1835320165b8.patch new file mode 100644 index 000000000000..d4f9cfccc21a --- /dev/null +++ b/pkgs/by-name/in/incus/0c37b7e3ec65b4d0e166e2127d9f1835320165b8.patch @@ -0,0 +1,29 @@ +From 0c37b7e3ec65b4d0e166e2127d9f1835320165b8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?St=C3=A9phane=20Graber?= +Date: Fri, 6 Sep 2024 17:07:11 -0400 +Subject: [PATCH] incusd/instance/qemu: Make O_DIRECT conditional on + directCache +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Stéphane Graber +--- + internal/server/instance/drivers/driver_qemu.go | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/internal/server/instance/drivers/driver_qemu.go b/internal/server/instance/drivers/driver_qemu.go +index 5a94c9db43..9609b73c1b 100644 +--- a/internal/server/instance/drivers/driver_qemu.go ++++ b/internal/server/instance/drivers/driver_qemu.go +@@ -4276,7 +4276,9 @@ func (d *qemu) addDriveConfig(qemuDev map[string]string, bootIndexes map[string] + permissions = unix.O_RDONLY + } + +- permissions |= unix.O_DIRECT ++ if directCache { ++ permissions |= unix.O_DIRECT ++ } + + f, err := os.OpenFile(driveConf.DevPath, permissions, 0) + if err != nil { diff --git a/pkgs/by-name/in/incus/572afb06f66f83ca95efa1b9386fceeaa1c9e11b.patch b/pkgs/by-name/in/incus/572afb06f66f83ca95efa1b9386fceeaa1c9e11b.patch new file mode 100644 index 000000000000..e918deb8569c --- /dev/null +++ b/pkgs/by-name/in/incus/572afb06f66f83ca95efa1b9386fceeaa1c9e11b.patch @@ -0,0 +1,28 @@ +From 572afb06f66f83ca95efa1b9386fceeaa1c9e11b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?St=C3=A9phane=20Graber?= +Date: Fri, 6 Sep 2024 15:51:35 -0400 +Subject: [PATCH] incusd/instance/qemu: Set O_DIRECT when passing in FDs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is required in most cases with QEMU 9.1.0. + +Signed-off-by: Stéphane Graber +--- + internal/server/instance/drivers/driver_qemu.go | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/internal/server/instance/drivers/driver_qemu.go b/internal/server/instance/drivers/driver_qemu.go +index 37da21f42f..e25aab0667 100644 +--- a/internal/server/instance/drivers/driver_qemu.go ++++ b/internal/server/instance/drivers/driver_qemu.go +@@ -4277,6 +4277,8 @@ func (d *qemu) addDriveConfig(qemuDev map[string]string, bootIndexes map[string] + permissions = unix.O_RDONLY + } + ++ permissions |= unix.O_DIRECT ++ + f, err := os.OpenFile(driveConf.DevPath, permissions, 0) + if err != nil { + return fmt.Errorf("Failed opening file descriptor for disk device %q: %w", driveConf.DevName, err) diff --git a/pkgs/by-name/in/incus/58eeb4eeee8a9e7f9fa9c62443d00f0ec6797078.patch b/pkgs/by-name/in/incus/58eeb4eeee8a9e7f9fa9c62443d00f0ec6797078.patch new file mode 100644 index 000000000000..10ca57733409 --- /dev/null +++ b/pkgs/by-name/in/incus/58eeb4eeee8a9e7f9fa9c62443d00f0ec6797078.patch @@ -0,0 +1,33 @@ +From 58eeb4eeee8a9e7f9fa9c62443d00f0ec6797078 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?St=C3=A9phane=20Graber?= +Date: Fri, 6 Sep 2024 17:10:01 -0400 +Subject: [PATCH] incusd/instance/qemu: Force threads I/O mode for + unsafe/writeback +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The default "native" aioMode requires direct I/O which is incompatible +with unsafe/writeback. + +Signed-off-by: Stéphane Graber +--- + internal/server/instance/drivers/driver_qemu.go | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/internal/server/instance/drivers/driver_qemu.go b/internal/server/instance/drivers/driver_qemu.go +index 9609b73c1b..a5a4944d40 100644 +--- a/internal/server/instance/drivers/driver_qemu.go ++++ b/internal/server/instance/drivers/driver_qemu.go +@@ -4088,9 +4088,11 @@ func (d *qemu) addDriveConfig(qemuDev map[string]string, bootIndexes map[string] + noFlushCache := false // Don't ignore any flush requests for the device. + + if cacheMode == "unsafe" { ++ aioMode = "threads" + directCache = false + noFlushCache = true + } else if cacheMode == "writeback" { ++ aioMode = "threads" + directCache = false + } + diff --git a/pkgs/by-name/in/incus/package.nix b/pkgs/by-name/in/incus/package.nix index 8703e43c61c7..d7383c210b12 100644 --- a/pkgs/by-name/in/incus/package.nix +++ b/pkgs/by-name/in/incus/package.nix @@ -2,5 +2,10 @@ import ./generic.nix { hash = "sha256-FdoJI0SUH8KS3Epyw/HejgyhISWGLePsIjYUS2YTBvc="; version = "6.5.0"; vendorHash = "sha256-8e2X7HIy1IEx6p41SHJyq5dNUJ3rRC2maXC4uNaSlnk="; - patches = [ ]; + patches = [ + # qemu 9.1 compat, remove in 6.6 + ./572afb06f66f83ca95efa1b9386fceeaa1c9e11b.patch + ./58eeb4eeee8a9e7f9fa9c62443d00f0ec6797078.patch + ./0c37b7e3ec65b4d0e166e2127d9f1835320165b8.patch + ]; }