Commit graph

181 commits

Author SHA1 Message Date
Robert Hensing e973da60cd
Merge pull request #200225 from pacien/nixos-qemu-vm-restrictnetwork
nixos/qemu-vm: add option "restrictNetwork"
2023-01-13 21:47:21 +01:00
K900 2d3cf010fe
Revert "treewide: use nativeBuildInputs with runCommand instead of inlining" 2022-12-26 21:05:35 +03:00
Sandro Jäckel 26f704b545
treewide: use nativeBuildInputs with runCommand instead of inlining 2022-12-18 23:36:40 +01:00
Naïm Favier 0ff3b35356 nixos/doc: fix some options 2022-12-08 17:52:52 +01:00
Naïm Favier e8927c46b8
nixos/doc: document mkOrder and friends
Add a section on ordering option definitions.

Also mention `mkDefault` in the section on `mkOverride`.

Clarify the code a bit by renaming `defaultPriority` to
`defaultOverridePriority` and introducing `defaultOrderPriority`.
2022-12-02 14:15:24 +01:00
Ryan Lahfa a8a68c3427
Merge pull request #189935 from baloo/baloo/qemu-vm/fixup-efi-partitions
qemu-vm: ensure we do not overwrite the partition table when EFI is in use
2022-12-01 15:16:23 +01:00
pacien e039cb9d97 nixos/qemu-vm: add option "restrictNetwork"
This adds an option to the qemu virtualisation module to isolate the
guest's from the host's and outside networks.

This is particularly useful for development sandboxes for example.

The option is disabled by default to preserve the current behaviour.
2022-11-08 17:54:31 +01:00
pennae d98322834b nixos/*: fix docbook deprecation notices
mostly no rendering changes except in buildkite, which used markdown
where docbook was expected without marking up its markdown.
2022-09-10 18:23:13 +02:00
Arthur Gautier 7f026cc6d0 qemu-vm: ensure we do not overwrite the partition table when EFI is in use 2022-09-05 17:18:06 -07:00
pennae 3bddcf5f90
Merge branch 'master' into option-docs-md 2022-09-01 16:10:09 +02:00
pennae 722b99bc0e nixos/*: convert options with admonitions to MD
rendering changes only slightly, most changes are in spacing.
2022-08-31 16:36:16 +02:00
pennae 9547123258 nixos/*: convert internal option descriptions to MD
we'll have to do it eventually, may as well be now.
2022-08-31 16:32:54 +02:00
pennae 1013069f52 nixos/*: convert more partially-md option descriptions
this mostly means marking options that use markdown already
appropriately and making a few adjustments so they still render
correctly. notable for nftables we have to transform the md links
because the manpage would not render them correctly otherwise.
2022-08-31 16:32:14 +02:00
Silvan Mosberger 04648b8dcf nixos/qemu: Add pkgs option for allowing other systems to run the VM 2022-08-25 16:59:09 +04:00
Raito Bezarius c91d0713ac ovmf: expose EFI prefixes and refactor qemu-vm with it 2022-08-23 12:13:06 +02:00
pennae 6039648c50 nixos/*: automatically convert option docs 2022-08-19 22:40:58 +02:00
pennae 8f8e101527 nixos/*: normalize <package> to <literal>
this renders the same in the manpage and a little more clearly in the
html manual. in the manpage there continues to be no distinction from
regular text, the html manual gets code-type markup (which was probably
the intention for most of these uses anyway).
2022-08-19 22:40:58 +02:00
Robert Hensing 6851adc178 nixos/qemu-vm: Fix warning message 2022-08-14 12:48:43 +02:00
Robert Hensing bd3fb4069d
Merge pull request #181746 from hercules-ci/nixosTest-erofs
nixos/qemu-vm: Use disposable EROFS for store when writableStore = false
2022-08-14 08:46:21 +02:00
pennae 087472b1e5 nixos/*: automatically convert option docs 2022-08-06 20:39:12 +02:00
pennae 9c8531c8a5 nixos/*: replace <replaceable>s with «thing»
we can't embed syntactic annotations of this kind in markdown code
blocks without yet another extension. replaceable is rare enough to make
this not much worth it, so we'll go with «thing» instead. the module
system already uses this format for its placeholder names in attrsOf
paths.
2022-08-03 21:08:58 +02:00
Alyssa Ross 5330c0a1af
treewide: use isAarch where appropriate 2022-07-30 16:18:27 +00:00
Robert Hensing 438f6f17de nixos/qemu-vm: Warn when wasting space 2022-07-17 14:56:35 +02:00
Robert Hensing afc60d017b nixos/qemu-vm: Use disposable EROFS for store when writableStore = false
This avoids putting a large disk image in the store (and possibly
in a binary cache), while improving runtime performance.

Assuming you're running an SSD, and/or with plenty of cache (?)
it is feasible to preempt the virtualization overhead before
VM start, in single-digit seconds.

For some tests that perform many reads on the store, the improved
performance of EROFS is sufficient that not only the image creation
overhead is compensated for, but is actually faster.

Stats for nixosTests.gitlab:

Baseline without useNixStoreImage: >1000s

Baseline with useNixStoreImage without writableStore = false
ext4 image in store: 277 seconds
  + significant image build time and/or disk space

Disposable erofs image: 249 seconds _including_ image build time

Custom erofs overlay on 9p host store: 391 seconds; presumably
because the overlay still performs too many 9p accesses, or perhaps
some other overhead. This solution had no obvious performance
advantage, while requiring extra options to work, so it was
discarded.
2022-07-17 14:56:35 +02:00
T0astBread 87cd533a32
nixos/qemu-vm: allow custom partitions and filesystems in VM
Potential use cases for disabling `useDefaultFilesystems` include:

  - Testing with uncommon filesystem layouts
  - Testing scenarios where swapping occurs
  - Testing with LUKS-encrypted disks

Closes #177963
2022-07-02 15:37:08 +02:00
Janne Heß 007108f04d
nixos/*qemu*: Add systemd initrd support 2022-04-30 20:47:42 +02:00
Sam Hug cdef7bcb5b nixos/qemu-vm: sanitize generated environment variable name 2022-04-09 11:53:58 -07:00
Robert Hensing dd0d10bbb6
Merge pull request #165583 from bosu/patch-1
nixos/qemu-vm: allow booting VM with the custom kernel
2022-04-04 14:33:35 +02:00
Janne Heß 7cdc4dd5d1
Merge pull request #164943 from ElvishJerricco/systemd-initrd-reuse-systemd-module
initrd: Opt-in bare bones systemd-based initrd
2022-04-03 15:53:02 +02:00
Michael Hoang 2c102d19c0 nixos/qemu-vm: Set mainProgram for nix run 2022-04-01 01:34:26 +11:00
Boris Sukholitko 6af3e61632 nixos/qemu-vm: allow booting VM with the custom kernel
While doing kernel development with the nixos testing infrastructure, it
is useful to quickly compile the kernel on the side and boot it in the testing VM.

This patch allows overriding the kernel through the environment
variable. For example, the following:

$ NIXPKGS_QEMU_KERNEL_testvm=$LINUX_SRC/arch/x86/boot/bzImage $VM/bin/nixos-test-driver

runs testvm testing VM with the fresh kernel compiled in $LINUX_SRC.

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2022-03-25 17:38:19 +03:00
Will Fancher 213de9b108 systemd-initrd: autoFormat and autoResize in initrd 2022-03-22 21:28:51 -04:00
Will Fancher be10e86c95 systemd-initrd: Partially fix qemu-vm
TODO: Auto formatting / partitioning / resizing
2022-03-22 21:28:50 -04:00
Robert Hensing eb8b70c020 nixos: Make config.nix.enable pass test 2022-03-21 23:14:10 +01:00
Babbaj 56109be38b
nixos/qemu-vm: Create option for virtio-keyboard device 2022-02-06 01:55:49 -05:00
pennae fc614c37c6 nixos/documentation: split options doc build
most modules can be evaluated for their documentation in a very
restricted environment that doesn't include all of nixpkgs. this
evaluation can then be cached and reused for subsequent builds, merging
only documentation that has changed into the cached set. since nixos
ships with a large number of modules of which only a few are used in any
given config this can save evaluation a huge percentage of nixos
options available in any given config.

in tests of this caching, despite having to copy most of nixos/, saves
about 80% of the time needed to build the system manual, or about two
second on the machine used for testing. build time for a full system
config shrank from 9.4s to 7.4s, while turning documentation off
entirely shortened the build to 7.1s.
2022-01-02 19:46:13 +01:00
Artturin 39c5525cb1 nixos/qemu-vm: add -device virtio-keyboard to opts
by default a ps/2 keyboard input is used which seems to cause issues
on aarch64-linux when the machine is used high load, causing the keymap
qwertz test to always fail and azerty to sometimes fail
See https://github.com/NixOS/nixpkgs/issues/147294
2021-12-10 01:04:33 +02:00
pennae 2512455639 nixos/*: add trivial defaultText for options with simple defaults 2021-12-02 22:35:04 +01:00
Artturi c4851c0d71
Revert msize related commits (#147180) 2021-11-24 02:33:53 +02:00
Artturi 53edfe1d1c
Merge pull request #146804 from Artturin/qemudefaultmem 2021-11-21 17:48:08 +02:00
Artturin 54ece050b8 nixos/qemu-vm: default memorySize 384 -> 1024
the default hasn't been changed since 2009
this can improve our test performances

nixos/tests: remove explicit memorySize <1024

1024MiB is now the default
2021-11-21 17:27:58 +02:00
Ryan Burns 2175b157ac treewide: refactor isi686 && isx86_64 -> isx86 2021-11-20 17:50:41 -08:00
Artturi dd4ce550b3
Merge pull request #146456 from Artturin/misc-updates1 2021-11-20 01:14:44 +02:00
Janne Heß ecf388e90b
vmTools: Make msize larger to silence warning
See https://issues.guix.gnu.org/47225
2021-11-18 21:21:49 +01:00
Artturin a96a6e7515 nixos/qemu-vm: fix deprecation readonly -> readonly=on
machine # qemu-system-x86_64: -drive if=pflash,format=raw,unit=0,readonly,...: warning:
short-form boolean option 'readonly' deprecated
vm-test-run-systemd-boot-specialisation> machine # Please use readonly=on instead
2021-11-18 21:32:56 +02:00
Robert Hensing 4ec119009b virtualisation/qemu-vm: Double the default diskSize
The default has been unchanged for a decade. Space is cheaper and
software catches up with that. Let's not make our testing harder
than necessary by default.
2021-11-05 21:06:08 +01:00
Alyssa Ross e791519f0f
nixos/qemu-vm: use qemu_kvm
qemu_kvm is only built for one architecture, so it's smaller and takes
MUCH less time to build if it has to be built from source.  And this
module doesn't support running a VM for one architecture from another
architecture, so the one architecture is all we'll need.
2021-11-01 12:04:45 +00:00
talyz af9f6d9a2a nixos/qemu-vm: Rename pathsInNixDB to additionalPaths
pathsInNixDB isn't a very accurate name when a Nix store image is
built (virtualisation.useNixStoreImage); rename it to additionalPaths,
which should be general enough to cover both cases.
2021-10-28 12:55:01 +02:00
talyz 84839b395f nixos/qemu-vm: Allow building a Nix store image instead of using 9p
Add the `useNixStoreImage` option, allowing a disk image with the
necessary contents from the Nix store to be built using
make-disk-image.nix. The image will be mounted at `/nix/store` and
acts as a drop-in replacement for the usual 9p mounting of the host's
Nix store.

This removes the performance penalty of 9p, drastically improving
execution speed of applications which do lots of reads from the Nix
store. The caveats are increased disk space usage and image build
time.
2021-10-28 12:55:01 +02:00
Maximilian Bosch f700a92d5c
nixos/qemu-vm: quote QEMU_NET_OPTS
Co-authored-by: Michele Guerini Rocco <rnhmjoj@users.noreply.github.com>
2021-10-06 23:12:53 +02:00