diff --git a/chv.nix b/chv.nix index 1656922..f636654 100644 --- a/chv.nix +++ b/chv.nix @@ -14,38 +14,42 @@ let # Crane lib with proper Rust toolchain craneLib' = craneLib.overrideToolchain rustToolchain; - commonArgs = { - meta = cloud-hypervisor-meta; + commonArgs = + let + src = craneLib'.cleanCargoSource cloud-hypervisor-src; + in + { + inherit src; + # Since Nov 2025 (v50), Cloud Hypervisor has a virtual manifest and the + # main package was moved into a sub directory. + cargoToml = "${src}/cloud-hypervisor/Cargo.toml"; + meta = cloud-hypervisor-meta; - src = craneLib'.cleanCargoSource cloud-hypervisor-src; + # Pragmatic release profile with debug-ability and faster + # compilation times in mind. + env = { + CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS = "true"; + CARGO_PROFILE_RELEASE_OPT_LEVEL = 2; + CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS = "true"; + CARGO_PROFILE_RELEASE_LTO = "no"; + }; - # Pragmatic release profile with debug-ability and faster - # compilation times in mind. - env = { - CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS = "true"; - CARGO_PROFILE_RELEASE_OPT_LEVEL = 2; - CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS = "true"; - CARGO_PROFILE_RELEASE_LTO = "no"; + nativeBuildInputs = [ + pkg-config + ]; + buildInputs = [ + openssl + ]; + # Fix build. Reference: + # - https://github.com/sfackler/rust-openssl/issues/1430 + # - https://docs.rs/openssl/latest/openssl/ + OPENSSL_NO_VENDOR = true; }; - nativeBuildInputs = [ - pkg-config - ]; - buildInputs = [ - openssl - ]; - # Fix build. Reference: - # - https://github.com/sfackler/rust-openssl/issues/1430 - # - https://docs.rs/openssl/latest/openssl/ - OPENSSL_NO_VENDOR = true; - }; - # Downloaded and compiled dependencies. cargoArtifacts = craneLib'.buildDepsOnly ( commonArgs // { - # "suffix '-deps' will be appended - pname = "cloud-hypervisor"; doCheck = false; } ); @@ -54,7 +58,6 @@ let commonArgs // { inherit cargoArtifacts; - pname = "cloud-hypervisor"; # Don't execute tests here. We want this in a dedicated step. doCheck = false; cargoExtraArgs = "--features kvm"; diff --git a/flake.lock b/flake.lock index eaab4c8..35f5c14 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,27 @@ "cloud-hypervisor-src": { "flake": false, "locked": { - "lastModified": 1764947614, - "narHash": "sha256-ptMDewPVs13ZOFdJLAJhLXvfa8A3PihAzjiSPbLxZ7M=", + "lastModified": 1765965589, + "narHash": "sha256-A4q/mZbe2cZD5L6w8nL3EwsKNlM9onfESIlQQze/iXE=", + "ref": "refs/heads/next-gardenlinux-v49", + "rev": "89ab61df57d7c57363f4618ca667a788479a34c2", + "revCount": 9120, + "type": "git", + "url": "file:/home/pschuster/dev/cloud-hypervisor" + }, + "original": { + "type": "git", + "url": "file:/home/pschuster/dev/cloud-hypervisor" + } + }, + "cloud-hypervisor-src_2": { + "flake": false, + "locked": { + "lastModified": 1765211060, + "narHash": "sha256-prSgUWqgZQAH90hqTRD08Ie6d3WYYKV4SyWOMD/SVFY=", "owner": "cyberus-technology", "repo": "cloud-hypervisor", - "rev": "d4cb05de4d7fe1b4300ce4d6bed56ae7fc04e19b", + "rev": "0d9477d1fc8c3549c5d1feca4bb90f70608187ea", "type": "github" }, "original": { @@ -33,6 +49,22 @@ "type": "github" } }, + "crane_2": { + "locked": { + "lastModified": 1764903584, + "narHash": "sha256-RSkJtNtx0SEaQiYqsoFoRynwfZLo2OZ9z6rUq1DJR6g=", + "owner": "ipetkov", + "repo": "crane", + "rev": "2b3a5a88d852575758e1eb6ac9ee677fcd633fc1", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "ref": "master", + "repo": "crane", + "type": "github" + } + }, "dried-nix-flakes": { "locked": { "lastModified": 1756139350, @@ -48,6 +80,21 @@ "type": "github" } }, + "dried-nix-flakes_2": { + "locked": { + "lastModified": 1756139350, + "narHash": "sha256-pObQv94NclXVXjJV8sTiKwFes4fGEWpkNzDsXw5DqnY=", + "owner": "cyberus-technology", + "repo": "dried-nix-flakes", + "rev": "1b2ba62710c6c1d9eba0e8e3adc029cc2e9291a4", + "type": "github" + }, + "original": { + "owner": "cyberus-technology", + "repo": "dried-nix-flakes", + "type": "github" + } + }, "edk2-src": { "flake": false, "locked": { @@ -67,6 +114,25 @@ "url": "https://github.com/cyberus-technology/edk2" } }, + "edk2-src_2": { + "flake": false, + "locked": { + "lastModified": 1753177921, + "narHash": "sha256-NGSNYuIlmktpc6Jux17pdnaXLhIxZxofA47w6s8dasg=", + "ref": "gardenlinux", + "rev": "838aba54db575012bea74a683d15d4ee900bbad9", + "revCount": 34304, + "submodules": true, + "type": "git", + "url": "https://github.com/cyberus-technology/edk2" + }, + "original": { + "ref": "gardenlinux", + "submodules": true, + "type": "git", + "url": "https://github.com/cyberus-technology/edk2" + } + }, "fcntl-tool": { "inputs": { "nixpkgs": [ @@ -87,6 +153,65 @@ "type": "github" } }, + "fcntl-tool_2": { + "inputs": { + "nixpkgs": [ + "libvirt-chv", + "libvirt-tests", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1764620651, + "narHash": "sha256-OOoCw8Bo36VGDkSPqYYxY8JSJarI1FTmwK0G47K6KKQ=", + "owner": "phip1611", + "repo": "fcntl-tool", + "rev": "ca5d70e4096eb1ea7d32fac93bd2fd4b9c617345", + "type": "github" + }, + "original": { + "owner": "phip1611", + "repo": "fcntl-tool", + "type": "github" + } + }, + "keycodemapdb": { + "flake": false, + "locked": { + "lastModified": 1752156361, + "narHash": "sha256-gfrQPAwgShtgkDWZOkivDO1Aj7UUdaGTitirGy+RA70=", + "ref": "refs/heads/master", + "rev": "54788039c0b3486a8883090d6736c2500177af29", + "revCount": 89, + "type": "git", + "url": "https://gitlab.com/keycodemap/keycodemapdb.git" + }, + "original": { + "type": "git", + "url": "https://gitlab.com/keycodemap/keycodemapdb.git" + } + }, + "libvirt-chv": { + "inputs": { + "cloud-hypervisor-src": "cloud-hypervisor-src_2", + "keycodemapdb": "keycodemapdb", + "libvirt-tests": "libvirt-tests", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1765977330, + "narHash": "sha256-eCOxgC46lfU+BwdZW5u/ZJDK4PRgzykFSk0WUztYsUk=", + "ref": "refs/heads/nix-2", + "rev": "1322649dfbedc1f2b100d1ba0e0b863cb2ee00ca", + "revCount": 52428, + "type": "git", + "url": "file:/home/pschuster/dev/libvirt" + }, + "original": { + "type": "git", + "url": "file:/home/pschuster/dev/libvirt" + } + }, "libvirt-src": { "flake": false, "locked": { @@ -106,7 +231,54 @@ "url": "https://github.com/cyberus-technology/libvirt" } }, + "libvirt-tests": { + "inputs": { + "cloud-hypervisor-src": [ + "libvirt-chv", + "cloud-hypervisor-src" + ], + "crane": "crane_2", + "dried-nix-flakes": "dried-nix-flakes_2", + "edk2-src": "edk2-src_2", + "fcntl-tool": "fcntl-tool_2", + "libvirt-src": "libvirt-src", + "nixpkgs": [ + "libvirt-chv", + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1765882764, + "narHash": "sha256-m6Fmaj+OavgqXpyJu5z/QU+gR6OUU3M99lYq6fcn+yM=", + "owner": "cyberus-technology", + "repo": "libvirt-tests", + "rev": "e448e6b00b274da58e5f52a695b3f76c703d7485", + "type": "github" + }, + "original": { + "owner": "cyberus-technology", + "repo": "libvirt-tests", + "type": "github" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1764522689, + "narHash": "sha256-SqUuBFjhl/kpDiVaKLQBoD8TLD+/cTUzzgVFoaHrkqY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "8bb5646e0bed5dbd3ab08c7a7cc15b75ab4e1d0f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-25.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1764831616, "narHash": "sha256-OtzF5wBvO0jgW1WW1rQU9cMGx7zuvkF7CAVJ1ypzkxA=", @@ -129,12 +301,34 @@ "dried-nix-flakes": "dried-nix-flakes", "edk2-src": "edk2-src", "fcntl-tool": "fcntl-tool", - "libvirt-src": "libvirt-src", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" + "libvirt-chv": "libvirt-chv", + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay_2" } }, "rust-overlay": { + "inputs": { + "nixpkgs": [ + "libvirt-chv", + "libvirt-tests", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1764902447, + "narHash": "sha256-wNqkDBj+tjK619sTHPEA7uhjr7DHHEY8OsFou31dxy0=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "d914a744a83098eeb28125d2848ad383b209223f", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_2": { "inputs": { "nixpkgs": [ "nixpkgs" diff --git a/flake.nix b/flake.nix index c33847d..b408960 100644 --- a/flake.nix +++ b/flake.nix @@ -5,17 +5,16 @@ dried-nix-flakes.url = "github:cyberus-technology/dried-nix-flakes"; nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-25.11"; - # A local path can be used for developing or testing local changes. Make - # sure the submodules in a local libvirt checkout are populated. - libvirt-src = { - # url = "git+file:?submodules=1"; - url = "git+https://github.com/cyberus-technology/libvirt?ref=gardenlinux&submodules=1"; - # url = "git+ssh://git@gitlab.cyberus-technology.de/cyberus/cloud/libvirt?ref=managedsave-fix&submodules=1"; - flake = false; + # Our patched libvirt for Cloud Hypervisor. + libvirt-chv = { + # A local path can be used for developing or testing local changes. + url = "git+file:/home/pschuster/dev/libvirt"; + #url = "git+https://github.com/phip1611/libvirt?ref=nix-2&submodules=1"; + # url = "git+ssh://git@gitlab.cyberus-technology.de/pschuster/libvirt?ref=nix-2&submodules=1"; }; cloud-hypervisor-src = { - # url = "git+file:"; - url = "github:cyberus-technology/cloud-hypervisor?ref=gardenlinux"; + url = "git+file:/home/pschuster/dev/cloud-hypervisor"; + # url = "github:cyberus-technology/cloud-hypervisor?ref=gardenlinux"; flake = false; }; edk2-src = { @@ -39,19 +38,7 @@ inputs: let dnf = (inputs.dried-nix-flakes.for inputs).override { - # Expose only platforms that the most restrictive set of packages supports. - systems = - let - # The `x86_64-linux` attribute is used arbitrarily to access lib and the derivation's attributes. - pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; - inherit (pkgs) lib; - intersectAll = - lists: builtins.foldl' lib.intersectLists (builtins.head lists) (builtins.tail lists); - in - intersectAll [ - pkgs.cloud-hypervisor.meta.platforms - pkgs.OVMF-cloud-hypervisor.meta.platforms - ]; + systems = [ "x86_64-linux" ]; }; inherit (dnf) exportOutputs @@ -65,7 +52,7 @@ crane, edk2-src, fcntl-tool, - libvirt-src, + libvirt-chv, nixpkgs, rust-overlay, ... @@ -105,6 +92,7 @@ ''; in { + inherit inputs; checks = let fs = pkgs.lib.fileset; @@ -178,21 +166,76 @@ gitlint ]; }; - packages = { - # Export of the overlay'ed package - inherit (pkgs) cloud-hypervisor; - inherit nixos-image; - chv-ovmf = pkgs.runCommand "OVMF-CLOUHDHV.fd" { } '' - cp ${chv-ovmf.fd}/FV/CLOUDHV.fd $out - ''; - }; + packages = + let + # For quicker rebuilds, which we experience quite often during development + # and prototyping,, we remove all unneeded functionality. + libvirt-chv-testsuite = libvirt-chv.packages.libvirt-debugoptimized.overrideAttrs (old: { + # Reduce files needed to compile. We cut the build-time in half. + mesonFlags = old.mesonFlags ++ [ + # Disabling tests: 1500 -> 1200 + "-Dtests=disabled" + "-Dexpensive_tests=disabled" + # Disabling docs: 1200 -> 800 + "-Ddocs=disabled" + # Disabling unneeded backends: 800 -> 685 + "-Ddriver_ch=enabled" + "-Ddriver_qemu=disabled" + "-Ddriver_bhyve=disabled" + "-Ddriver_esx=disabled" + "-Ddriver_hyperv=disabled" + "-Ddriver_libxl=disabled" + "-Ddriver_lxc=disabled" + "-Ddriver_openvz=disabled" + "-Ddriver_secrets=disabled" + "-Ddriver_vbox=disabled" + "-Ddriver_vmware=disabled" + "-Ddriver_vz=disabled" + # Disabling unneeded backends: 685 -> 609 + "-Dstorage_dir=disabled" + "-Dstorage_disk=disabled" + "-Dstorage_fs=enabled" # for netfs + "-Dstorage_gluster=disabled" + "-Dstorage_iscsi=disabled" + "-Dstorage_iscsi_direct=disabled" + "-Dstorage_lvm=disabled" + "-Dstorage_mpath=disabled" + "-Dstorage_rbd=disabled" + "-Dstorage_scsi=disabled" + "-Dstorage_vstorage=disabled" + "-Dstorage_zfs=disabled" + "-Dapparmor=disabled" + "-Dwireshark_dissector=disabled" + "-Dselinux=disabled" + "-Dsecdriver_apparmor=disabled" + "-Dsecdriver_selinux=disabled" + "-Db_sanitize=leak" + "-Db_sanitize=address,undefined" + # Enabling the sanitizers has led to warnings about inlining macro + # generated cleanup methods of the glib which spam the build log. + # Ignoring and suppressing the warnings seems like the only option. + # "warning: inlining failed in call to 'glib_autoptr_cleanup_virNetlinkMsg': call is unlikely and code size would grow [-Winline]" + "-Dc_args=-Wno-inline" + ]; + }); + in + { + # Export of the overlay'ed package + inherit (pkgs) cloud-hypervisor; + inherit libvirt-chv-testsuite; + inherit nixos-image; + chv-ovmf = pkgs.runCommand "OVMF-CLOUHDHV.fd" { } '' + cp ${chv-ovmf.fd}/FV/CLOUDHV.fd $out + ''; + } + // libvirt-chv.packages; tests = import ./tests/default.nix { inherit pkgs - libvirt-src nixos-image chv-ovmf ; + libvirt-chv = self.packages.libvirt-chv-testsuite; }; } ); diff --git a/patches/libvirt/0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch b/patches/libvirt/0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch deleted file mode 100644 index 974c2ff..0000000 --- a/patches/libvirt/0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch +++ /dev/null @@ -1,472 +0,0 @@ -From 98388f8f2619b18edc666d93d49ae3b484690993 Mon Sep 17 00:00:00 2001 -From: Stefan Kober -Date: Tue, 20 May 2025 10:29:35 +0200 -Subject: [PATCH] meson: patch in an install prefix for building on nix - -Used in the nixpkgs version of libvirt so that we can install things in -the nix store, but read them from the root filesystem. ---- - meson.build | 9 +++++++ - meson_options.txt | 2 ++ - src/ch/meson.build | 6 ++--- - src/interface/meson.build | 2 +- - src/libxl/meson.build | 18 +++++++------- - src/locking/meson.build | 8 +++---- - src/lxc/meson.build | 10 ++++---- - src/meson.build | 18 +++++++------- - src/network/meson.build | 14 +++++------ - src/node_device/meson.build | 2 +- - src/nwfilter/meson.build | 6 ++--- - src/nwfilter/xml/meson.build | 2 +- - src/qemu/meson.build | 40 +++++++++++++++---------------- - src/remote/meson.build | 10 ++++---- - src/secret/meson.build | 4 ++-- - src/security/apparmor/meson.build | 6 ++--- - src/storage/meson.build | 6 ++--- - tools/meson.build | 2 +- - tools/ssh-proxy/meson.build | 2 +- - 19 files changed, 89 insertions(+), 78 deletions(-) - -diff --git a/meson.build b/meson.build -index bb0436e072..65c9531dc4 100644 ---- a/meson.build -+++ b/meson.build -@@ -51,6 +51,8 @@ if host_machine.system() == 'windows' - conf.set('WINVER', '0x0600') # Win Vista / Server 2008 - endif - -+# patched in for nix -+install_prefix = get_option('install_prefix') - - # set various paths - -@@ -69,6 +71,13 @@ else - sysconfdir = prefix / get_option('sysconfdir') - endif - -+# nix: don't prefix the localstatedir; some things need to write to it, so it -+# can't be in the nix store, and that's what the prefix is. -+# We'll prefix things ourselves where needed -+localstatedir = get_option('localstatedir') -+# Same for sysconfidr -+sysconfdir = get_option('sysconfdir') -+ - # if --prefix is /usr, don't use /usr/var for localstatedir or /usr/etc for - # sysconfdir as this makes a lot of things break in testing situations - if prefix == '/usr' -diff --git a/meson_options.txt b/meson_options.txt -index 3dc3e8667b..49fbfce0bc 100644 ---- a/meson_options.txt -+++ b/meson_options.txt -@@ -1,3 +1,5 @@ -+option('install_prefix', type: 'string', value: '', description: 'prefix for nix store installation') -+ - option('no_git', type: 'boolean', value: false, description: 'Disable git submodule update') - option('packager', type: 'string', value: '', description: 'Extra packager name') - option('packager_version', type: 'string', value: '', description: 'Extra packager version') -diff --git a/src/ch/meson.build b/src/ch/meson.build -index 0b4a5aeb49..45b00e6d48 100644 ---- a/src/ch/meson.build -+++ b/src/ch/meson.build -@@ -78,8 +78,8 @@ if conf.has('WITH_CH') - } - - virt_install_dirs += [ -- localstatedir / 'lib' / 'libvirt' / 'ch', -- localstatedir / 'log' / 'libvirt' / 'ch', -- runstatedir / 'libvirt' / 'ch', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'ch', -+ install_prefix + localstatedir / 'log' / 'libvirt' / 'ch', -+ install_prefix + runstatedir / 'libvirt' / 'ch', - ] - endif -diff --git a/src/interface/meson.build b/src/interface/meson.build -index 3d2991315e..20f3266738 100644 ---- a/src/interface/meson.build -+++ b/src/interface/meson.build -@@ -59,6 +59,6 @@ if conf.has('WITH_INTERFACE') - } - - virt_install_dirs += [ -- runstatedir / 'libvirt' / 'interface', -+ install_prefix + runstatedir / 'libvirt' / 'interface', - ] - endif -diff --git a/src/libxl/meson.build b/src/libxl/meson.build -index e75a8f2fdb..d1800b4ea5 100644 ---- a/src/libxl/meson.build -+++ b/src/libxl/meson.build -@@ -81,14 +81,14 @@ if conf.has('WITH_LIBXL') - } - - virt_install_dirs += [ -- confdir / 'libxl', -- confdir / 'libxl' / 'autostart', -- localstatedir / 'lib' / 'libvirt' / 'libxl', -- localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel', -- localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel' / 'target', -- localstatedir / 'lib' / 'libvirt' / 'libxl' / 'dump', -- localstatedir / 'lib' / 'libvirt' / 'libxl' / 'save', -- localstatedir / 'log' / 'libvirt' / 'libxl', -- runstatedir / 'libvirt' / 'libxl', -+ install_prefix + confdir / 'libxl', -+ install_prefix + confdir / 'libxl' / 'autostart', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel' / 'target', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'dump', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'save', -+ install_prefix + localstatedir / 'log' / 'libvirt' / 'libxl', -+ install_prefix + runstatedir / 'libvirt' / 'libxl', - ] - endif -diff --git a/src/locking/meson.build b/src/locking/meson.build -index 934e47593b..e82943f31d 100644 ---- a/src/locking/meson.build -+++ b/src/locking/meson.build -@@ -247,14 +247,14 @@ if conf.has('WITH_LIBVIRTD') - } - - virt_install_dirs += [ -- localstatedir / 'lib' / 'libvirt' / 'lockd', -- localstatedir / 'lib' / 'libvirt' / 'lockd' / 'files', -- runstatedir / 'libvirt' / 'lockd', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'lockd', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'lockd' / 'files', -+ install_prefix + runstatedir / 'libvirt' / 'lockd', - ] - - if conf.has('WITH_SANLOCK') - virt_install_dirs += [ -- localstatedir / 'lib' / 'libvirt' / 'sanlock', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'sanlock', - ] - endif - endif -diff --git a/src/lxc/meson.build b/src/lxc/meson.build -index bf9afabc0f..6e9547000a 100644 ---- a/src/lxc/meson.build -+++ b/src/lxc/meson.build -@@ -190,10 +190,10 @@ if conf.has('WITH_LXC') - } - - virt_install_dirs += [ -- confdir / 'lxc', -- confdir / 'lxc' / 'autostart', -- localstatedir / 'lib' / 'libvirt' / 'lxc', -- localstatedir / 'log' / 'libvirt' / 'lxc', -- runstatedir / 'libvirt' / 'lxc', -+ install_prefix + confdir / 'lxc', -+ install_prefix + confdir / 'lxc' / 'autostart', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'lxc', -+ install_prefix + localstatedir / 'log' / 'libvirt' / 'lxc', -+ install_prefix + runstatedir / 'libvirt' / 'lxc', - ] - endif -diff --git a/src/meson.build b/src/meson.build -index 9a818dab50..5a3dd63d8c 100644 ---- a/src/meson.build -+++ b/src/meson.build -@@ -226,7 +226,7 @@ openrc_init_files = [] - - # virt_install_dirs: - # list of directories to create during installation --virt_install_dirs = [ confdir ] -+virt_install_dirs = [ install_prefix + confdir ] - - # driver_source_files: - # driver source files to check -@@ -703,7 +703,7 @@ endforeach - - virt_conf_files += 'libvirt.conf' - --install_data(virt_conf_files, install_dir: confdir) -+install_data(virt_conf_files, install_dir: install_prefix + confdir) - install_data(virt_aug_files, install_dir: virt_aug_dir) - - # augeas_test_data: -@@ -766,7 +766,7 @@ foreach data : virt_daemon_confs - output: '@0@.conf'.format(data['name']), - configuration: daemon_conf, - install: true, -- install_dir: confdir, -+ install_dir: install_prefix + confdir, - ) - - if data.get('with_ip', false) -@@ -914,7 +914,7 @@ if conf.has('WITH_LIBVIRTD') - - install_data( - init_file, -- install_dir: sysconfdir / 'init.d', -+ install_dir: install_prefix + sysconfdir / 'init.d', - install_mode: 'rwxr-xr-x', - rename: [ init['name'] ], - ) -@@ -922,7 +922,7 @@ if conf.has('WITH_LIBVIRTD') - if init.has_key('confd') - install_data( - init['confd'], -- install_dir: sysconfdir / 'conf.d', -+ install_dir: install_prefix + sysconfdir / 'conf.d', - rename: [ init['name'] ], - ) - endif -@@ -949,10 +949,10 @@ endif - # Install empty directories - - virt_install_dirs += [ -- localstatedir / 'cache' / 'libvirt', -- localstatedir / 'lib' / 'libvirt' / 'images', -- localstatedir / 'lib' / 'libvirt' / 'filesystems', -- localstatedir / 'lib' / 'libvirt' / 'boot', -+ install_prefix + localstatedir / 'cache' / 'libvirt', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'images', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'filesystems', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'boot', - ] - - if conf.has('WITH_LIBVIRTD') -diff --git a/src/network/meson.build b/src/network/meson.build -index 07cd5cda55..699309bb66 100644 ---- a/src/network/meson.build -+++ b/src/network/meson.build -@@ -115,11 +115,11 @@ if conf.has('WITH_NETWORK') - } - - virt_install_dirs += [ -- confdir / 'qemu' / 'networks', -- confdir / 'qemu' / 'networks' / 'autostart', -- localstatedir / 'lib' / 'libvirt' / 'network', -- localstatedir / 'lib' / 'libvirt' / 'dnsmasq', -- runstatedir / 'libvirt' / 'network', -+ install_prefix + confdir / 'qemu' / 'networks', -+ install_prefix + confdir / 'qemu' / 'networks' / 'autostart', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'network', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'dnsmasq', -+ install_prefix + runstatedir / 'libvirt' / 'network', - ] - - configure_file( -@@ -127,12 +127,12 @@ if conf.has('WITH_NETWORK') - output: '@BASENAME@', - configuration: configmake_conf, - install: true, -- install_dir: confdir / 'qemu' / 'networks', -+ install_dir: install_prefix + confdir / 'qemu' / 'networks', - ) - - meson.add_install_script( - meson_python_prog.full_path(), python3_prog.full_path(), meson_install_symlink_prog.full_path(), -- confdir / 'qemu' / 'networks' / 'autostart', -+ install_prefix + confdir / 'qemu' / 'networks' / 'autostart', - '../default.xml', 'default.xml', - ) - -diff --git a/src/node_device/meson.build b/src/node_device/meson.build -index d66c02a0e2..f883b65431 100644 ---- a/src/node_device/meson.build -+++ b/src/node_device/meson.build -@@ -67,6 +67,6 @@ if conf.has('WITH_NODE_DEVICES') - } - - virt_install_dirs += [ -- runstatedir / 'libvirt' / 'nodedev', -+ install_prefix + runstatedir / 'libvirt' / 'nodedev', - ] - endif -diff --git a/src/nwfilter/meson.build b/src/nwfilter/meson.build -index de3d202267..346c435ee7 100644 ---- a/src/nwfilter/meson.build -+++ b/src/nwfilter/meson.build -@@ -65,9 +65,9 @@ if conf.has('WITH_NWFILTER') - } - - virt_install_dirs += [ -- confdir / 'nwfilter', -- runstatedir / 'libvirt' / 'nwfilter-binding', -- runstatedir / 'libvirt' / 'nwfilter', -+ install_prefix + confdir / 'nwfilter', -+ install_prefix + runstatedir / 'libvirt' / 'nwfilter-binding', -+ install_prefix + runstatedir / 'libvirt' / 'nwfilter', - ] - - subdir('xml') -diff --git a/src/nwfilter/xml/meson.build b/src/nwfilter/xml/meson.build -index 0d96c54ebe..66c92a1016 100644 ---- a/src/nwfilter/xml/meson.build -+++ b/src/nwfilter/xml/meson.build -@@ -25,4 +25,4 @@ nwfilter_xml_files = [ - 'qemu-announce-self.xml', - ] - --install_data(nwfilter_xml_files, install_dir: sysconfdir / 'libvirt' / 'nwfilter') -+install_data(nwfilter_xml_files, install_dir: install_prefix + sysconfdir / 'libvirt' / 'nwfilter') -diff --git a/src/qemu/meson.build b/src/qemu/meson.build -index 5cf20f426f..578e342705 100644 ---- a/src/qemu/meson.build -+++ b/src/qemu/meson.build -@@ -219,25 +219,25 @@ if conf.has('WITH_QEMU') - endif - - virt_install_dirs += [ -- confdir / 'qemu', -- confdir / 'qemu' / 'autostart', -- localstatedir / 'cache' / 'libvirt' / 'qemu', -- localstatedir / 'lib' / 'libvirt' / 'qemu', -- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel', -- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel' / 'target', -- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'checkpoint', -- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'dump', -- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'nvram', -- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'ram', -- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'save', -- localstatedir / 'lib' / 'libvirt' / 'qemu' / 'snapshot', -- localstatedir / 'lib' / 'libvirt' / 'swtpm', -- localstatedir / 'log' / 'libvirt' / 'qemu', -- localstatedir / 'log' / 'swtpm' / 'libvirt' / 'qemu', -- runstatedir / 'libvirt' / 'qemu', -- runstatedir / 'libvirt' / 'qemu' / 'dbus', -- runstatedir / 'libvirt' / 'qemu' / 'passt', -- runstatedir / 'libvirt' / 'qemu' / 'slirp', -- runstatedir / 'libvirt' / 'qemu' / 'swtpm', -+ install_prefix + confdir / 'qemu', -+ install_prefix + confdir / 'qemu' / 'autostart', -+ install_prefix + localstatedir / 'cache' / 'libvirt' / 'qemu', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel' / 'target', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'checkpoint', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'dump', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'nvram', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'ram', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'save', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'snapshot', -+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'swtpm', -+ install_prefix + localstatedir / 'log' / 'libvirt' / 'qemu', -+ install_prefix + localstatedir / 'log' / 'swtpm' / 'libvirt' / 'qemu', -+ install_prefix + runstatedir / 'libvirt' / 'qemu', -+ install_prefix + runstatedir / 'libvirt' / 'qemu' / 'dbus', -+ install_prefix + runstatedir / 'libvirt' / 'qemu' / 'passt', -+ install_prefix + runstatedir / 'libvirt' / 'qemu' / 'slirp', -+ install_prefix + runstatedir / 'libvirt' / 'qemu' / 'swtpm', - ] - endif -diff --git a/src/remote/meson.build b/src/remote/meson.build -index e503263266..e0c660d8c9 100644 ---- a/src/remote/meson.build -+++ b/src/remote/meson.build -@@ -261,9 +261,9 @@ if conf.has('WITH_REMOTE') - } - - virt_install_dirs += [ -- localstatedir / 'log' / 'libvirt', -- runstatedir / 'libvirt', -- runstatedir / 'libvirt' / 'common', -+ install_prefix + localstatedir / 'log' / 'libvirt', -+ install_prefix + runstatedir / 'libvirt', -+ install_prefix + runstatedir / 'libvirt' / 'common', - ] - - logrotate_conf = configuration_data({ -@@ -278,7 +278,7 @@ if conf.has('WITH_REMOTE') - ) - install_data( - log_file, -- install_dir: sysconfdir / 'logrotate.d', -+ install_dir: install_prefix + sysconfdir / 'logrotate.d', - rename: [ name ], - ) - endforeach -@@ -338,7 +338,7 @@ endif - if conf.has('WITH_SASL') - install_data( - 'libvirtd.sasl', -- install_dir: sysconfdir / 'sasl2', -+ install_dir: install_prefix + sysconfdir / 'sasl2', - rename: [ 'libvirt.conf' ], - ) - endif -diff --git a/src/secret/meson.build b/src/secret/meson.build -index 3b859ea7b4..ccddb3e805 100644 ---- a/src/secret/meson.build -+++ b/src/secret/meson.build -@@ -48,7 +48,7 @@ if conf.has('WITH_SECRETS') - } - - virt_install_dirs += [ -- confdir / 'secrets', -- runstatedir / 'libvirt' / 'secrets', -+ install_prefix + confdir / 'secrets', -+ install_prefix + runstatedir / 'libvirt' / 'secrets', - ] - endif -diff --git a/src/security/apparmor/meson.build b/src/security/apparmor/meson.build -index 09d9fac02c..ee0c74ceec 100644 ---- a/src/security/apparmor/meson.build -+++ b/src/security/apparmor/meson.build -@@ -20,16 +20,16 @@ foreach name : apparmor_gen_profiles - output: name, - configuration: apparmor_gen_profiles_conf, - install: true, -- install_dir: apparmor_dir, -+ install_dir: install_prefix + apparmor_dir, - ) - endforeach - - install_data( - [ 'libvirt-qemu', 'libvirt-lxc' ], -- install_dir: apparmor_dir / 'abstractions', -+ install_dir: install_prefix + apparmor_dir / 'abstractions', - ) - - install_data( - [ 'TEMPLATE.qemu', 'TEMPLATE.lxc' ], -- install_dir: apparmor_dir / 'libvirt', -+ install_dir: install_prefix + apparmor_dir / 'libvirt', - ) -diff --git a/src/storage/meson.build b/src/storage/meson.build -index f6f28757ef..2bf815fd03 100644 ---- a/src/storage/meson.build -+++ b/src/storage/meson.build -@@ -124,9 +124,9 @@ if conf.has('WITH_STORAGE') - } - - virt_install_dirs += [ -- confdir / 'storage', -- confdir / 'storage' / 'autostart', -- runstatedir / 'libvirt' / 'storage', -+ install_prefix + confdir / 'storage', -+ install_prefix + confdir / 'storage' / 'autostart', -+ install_prefix + runstatedir / 'libvirt' / 'storage', - ] - endif - -diff --git a/tools/meson.build b/tools/meson.build -index 4d5c9e4bba..29077f2be6 100644 ---- a/tools/meson.build -+++ b/tools/meson.build -@@ -122,7 +122,7 @@ if conf.has('WITH_LOGIN_SHELL') - install_rpath: libvirt_rpath, - ) - -- install_data('virt-login-shell.conf', install_dir: sysconfdir / 'libvirt') -+ install_data('virt-login-shell.conf', install_dir: install_prefix + sysconfdir / 'libvirt') - - # Install the sysuser config for the setgid binary - install_data( -diff --git a/tools/ssh-proxy/meson.build b/tools/ssh-proxy/meson.build -index e9f312fa25..95d5d8fe0b 100644 ---- a/tools/ssh-proxy/meson.build -+++ b/tools/ssh-proxy/meson.build -@@ -20,6 +20,6 @@ if conf.has('WITH_SSH_PROXY') - output: '@BASENAME@', - configuration: tools_conf, - install: true, -- install_dir : sshconfdir, -+ install_dir : install_prefix + sshconfdir, - ) - endif --- -2.49.0 - diff --git a/patches/libvirt/0002-substitute-zfs-and-zpool-commands.patch b/patches/libvirt/0002-substitute-zfs-and-zpool-commands.patch deleted file mode 100644 index 9f38053..0000000 --- a/patches/libvirt/0002-substitute-zfs-and-zpool-commands.patch +++ /dev/null @@ -1,27 +0,0 @@ -From dc5e3df2fd29a547ef0f9545e190a0ce3a73c95c Mon Sep 17 00:00:00 2001 -From: Tako Marks -Date: Tue, 6 Sep 2022 20:19:26 +0200 -Subject: [PATCH] substitute zfs and zpool commands - ---- - src/storage/storage_backend_zfs.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c -index 2a5d74357d..460b3025c4 100644 ---- a/src/storage/storage_backend_zfs.c -+++ b/src/storage/storage_backend_zfs.c -@@ -33,8 +33,8 @@ - - VIR_LOG_INIT("storage.storage_backend_zfs"); - --#define ZFS "zfs" --#define ZPOOL "zpool" -+#define ZFS "@zfs@" -+#define ZPOOL "@zpool@" - - /* - * Some common flags of zfs and zpool commands we use: --- -2.36.2 - diff --git a/tests/common.nix b/tests/common.nix index c55d438..feaabcd 100644 --- a/tests/common.nix +++ b/tests/common.nix @@ -1,11 +1,11 @@ # Returns a NixOS module. { - libvirt-src, + libvirt-chv, nixos-image, chv-ovmf, }: -{ pkgs, ... }: +{ pkgs, system, ... }: let cirros_qcow = pkgs.fetchurl { url = "https://download.cirros-cloud.net/0.6.2/cirros-0.6.2-x86_64-disk.img"; @@ -177,81 +177,7 @@ in virtualisation.libvirtd = { enable = true; sshProxy = false; - package = pkgs.libvirt.overrideAttrs (old: { - src = libvirt-src; - name = "libvirt-gardenlinux"; - version = - let - fallback = builtins.trace "WARN: cannot obtain version from libvirt fork" "0.0.0-unknown"; - mesonBuild = builtins.readFile "${libvirt-src}/meson.build"; - # Searches for the line `version: '11.3.0'` and captures the version. - matches = builtins.match ".*[[:space:]]*version:[[:space:]]'([0-9]+.[0-9]+.[0-9]+)'.*" mesonBuild; - version = builtins.elemAt matches 0; - in - if matches != null then version else fallback; - debug = true; - doInstallCheck = false; - doCheck = false; - patches = [ - ../patches/libvirt/0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch - ../patches/libvirt/0002-substitute-zfs-and-zpool-commands.patch - ]; - - # Use the optimized debug build - mesonBuildType = "debugoptimized"; - - # IMPORTANT: donStrip is required because otherwise, nix will strip all - # debug info from the binaries in its fixupPhase. Having the debug info - # is crucial for getting source code info from the sanitizers, as well as - # when using GDB. - dontStrip = true; - - # Reduce files needed to compile. We cut the build-time in half. - mesonFlags = old.mesonFlags ++ [ - # Disabling tests: 1500 -> 1200 - "-Dtests=disabled" - "-Dexpensive_tests=disabled" - # Disabling docs: 1200 -> 800 - "-Ddocs=disabled" - # Disabling unneeded backends: 800 -> 685 - "-Ddriver_ch=enabled" - "-Ddriver_qemu=disabled" - "-Ddriver_bhyve=disabled" - "-Ddriver_esx=disabled" - "-Ddriver_hyperv=disabled" - "-Ddriver_libxl=disabled" - "-Ddriver_lxc=disabled" - "-Ddriver_openvz=disabled" - "-Ddriver_secrets=disabled" - "-Ddriver_vbox=disabled" - "-Ddriver_vmware=disabled" - "-Ddriver_vz=disabled" - "-Dstorage_dir=disabled" - "-Dstorage_disk=disabled" - "-Dstorage_fs=enabled" # for netfs - "-Dstorage_gluster=disabled" - "-Dstorage_iscsi=disabled" - "-Dstorage_iscsi_direct=disabled" - "-Dstorage_lvm=disabled" - "-Dstorage_mpath=disabled" - "-Dstorage_rbd=disabled" - "-Dstorage_scsi=disabled" - "-Dstorage_vstorage=disabled" - "-Dstorage_zfs=disabled" - "-Dapparmor=disabled" - "-Dwireshark_dissector=disabled" - "-Dselinux=disabled" - "-Dsecdriver_apparmor=disabled" - "-Dsecdriver_selinux=disabled" - "-Db_sanitize=leak" - "-Db_sanitize=address,undefined" - # Enabling the sanitizers has led to warnings about inlining macro - # generated cleanup methods of the glib which spam the build log. - # Ignoring and suppressing the warnings seems like the only option. - # "warning: inlining failed in call to 'glib_autoptr_cleanup_virNetlinkMsg': call is unlikely and code size would grow [-Winline]" - "-Dc_args=-Wno-inline" - ]; - }); + package = libvirt-chv; }; systemd.services.virtstoraged.path = [ pkgs.mount ]; diff --git a/tests/default.nix b/tests/default.nix index e92695b..6a6415d 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -1,6 +1,6 @@ { pkgs, - libvirt-src, + libvirt-chv, nixos-image, chv-ovmf, }: @@ -8,7 +8,7 @@ { default = pkgs.callPackage ./libvirt-test.nix { inherit - libvirt-src + libvirt-chv nixos-image chv-ovmf ; @@ -17,7 +17,7 @@ long_migration_with_load = pkgs.callPackage ./libvirt-test.nix { inherit - libvirt-src + libvirt-chv nixos-image chv-ovmf ; diff --git a/tests/libvirt-test.nix b/tests/libvirt-test.nix index 8c55e01..9a04711 100644 --- a/tests/libvirt-test.nix +++ b/tests/libvirt-test.nix @@ -4,13 +4,13 @@ { pkgs, - libvirt-src, + libvirt-chv, nixos-image, chv-ovmf, testScriptFile, }: let - common = import ./common.nix { inherit libvirt-src nixos-image chv-ovmf; }; + common = import ./common.nix { inherit libvirt-chv nixos-image chv-ovmf; }; tls = let