Commit graph

222 commits

Author SHA1 Message Date
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
Maximilian Bosch 60e731d1ce
nixos/qemu-vm: fix running VM with QEMU_NET_OPTS
I realized quite recently that running a test VM - as documented in the
manual - like

    QEMU_NET_OPTS='hostfwd=tcp::8080-:80'  ./result/bin/nixos-run-vms

doesn't work anymore on `master`. After bisecting I realized that the
introduction of a forward-port option[1] is the problem since it adds a
trailing comma even if no forwarding options are specified via
`virtualisation.forwardPorts`. In that case, the networking options
would look like `-netdev user,id=user.0,,hostfwd=tcp::8080-:80' which
confused QEMU and thus the VM refused to start.

Now, the trailing comma is only added if additional port forwards are
specified declaratively.

[1] b8bfc81d5b
2021-10-06 22:40:30 +02:00
Naïm Favier 2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
rnhmjoj 1497e8f5f5
nixos/qemu: use set -e in shell script
Also fix this: https://github.com/koalaman/shellcheck/wiki/SC2166
2021-09-29 08:46:03 +02:00
rnhmjoj b29c2f97c3
nixos/lib/qemu-flags: rename to qemu-common
The current name is misleading: it doesn't contain cli arguments,
but several constants and utility functions related to qemu.
This commit also removes the use of `with import ...` for clarity.
2021-09-18 16:58:16 +02:00
rnhmjoj b8bfc81d5b
nixos/qemu: add option to forward ports 2021-09-18 16:47:12 +02:00
rnhmjoj 44d95b773b
nixos/qemu: make display resolution configurable 2021-09-18 16:47:11 +02:00
rnhmjoj ec6c604b6e
nixos/qemu: make shared directories configurable 2021-09-18 16:47:11 +02:00
rnhmjoj 30f0faac22
nixos/qemu: add types to all options 2021-09-18 16:47:11 +02:00
rnhmjoj f1f434c4f7
nixos/qemu: cleaner formatting of the run-machine-vm script 2021-09-18 16:47:11 +02:00
rnhmjoj 2af5413cc6
nixos/qemu: set a reasonable msize by default 2021-09-18 16:47:10 +02:00
rnhmjoj 65e83389ef
nixos/qemu: fix deprecation warning 2021-09-18 16:47:10 +02:00
rnhmjoj c1fd51f490
nixos/qemu: fix several shellcheck issues
- Fix shell quoting issues
- Fix unsafe cd in run-machine-vm script
2021-09-18 16:46:20 +02:00
Artturin f45e8d560e nixos/tmp: add tmpOnTmpfsSize 2021-09-08 19:30:52 +03:00
WORLDofPEACE 1546bea850
Merge pull request #111462 from jakobrs/msize
nixos/qemu-vm: add virtualisation.msize option
2021-02-25 21:06:27 -05:00
Maciej Krüger 45b8e83128
qemu-vm: add virtualisation.fileSystems to allow extra vm mounts 2021-02-11 11:02:45 +01:00
jakobrs 278843e979 nixos/qemu-vm: add virtualisation.msize option 2021-01-31 18:41:22 +01:00
volth bc0d605cf1 treewide: fix double quoted strings in meta.description
Signed-off-by: Ben Siraphob <bensiraphob@gmail.com>
2021-01-24 19:56:59 +07:00
Vladimír Čunát 57a787c9fa
Revert Merge #107275: nixos: fix "nixos-rebuild ...
... build-vm-with-bootloader" for EFI systems

This reverts commit 20257280d9, reversing
changes made to 926a1b2094.
It broke nixosTests.installer.simpleUefiSystemdBoot
and right now channel is lagging behing for two weeks.
2020-12-23 21:24:24 +01:00
Bjørn Forsman 39fad297fd nixos: fix "nixos-rebuild build-vm-with-bootloader" for EFI systems
`nixos-rebuild build-vm-with-bootloader` currently fails with the
default NixOS EFI configuration:

  $ cat >configuration.nix <<EOF
  {
    fileSystems."/".device = "/dev/sda1";
    boot.loader.systemd-boot.enable = true;
    boot.loader.efi.canTouchEfiVariables = true;
  }
  EOF

  $ nixos-rebuild build-vm-with-bootloader -I nixos-config=$PWD/configuration.nix -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.09.tar.gz
  [...]
  insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
  mount: /sys/firmware/efi/efivars: mount point does not exist.
  [    1.908328] reboot: Power down
  builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 32
  [...]

Fix it by setting virtualisation.useEFIBoot = true in qemu-vm.nix, when
efi is needed.

And remove the now unneeded configuration in
./nixos/tests/systemd-boot.nix, since it's handled globally.

Before:
* release-20.03: successful build, unsuccessful run
* release-20.09 (and master): unsuccessful build

After:
* Successful build and run.

Fixes https://github.com/NixOS/nixpkgs/issues/107255
2020-12-21 08:55:13 +01:00
Graham Christensen bc49a0815a
utillinux: rename to util-linux 2020-11-24 12:42:06 -05:00
Mira Ressel a7de454a76 nixos/qemu-vm: Update system.requiredKernelConfig
Verify that all kernel modules which are required for mounting
/nix/store in the VM are present.
2020-10-30 22:22:58 +01:00
Mira Ressel 8ee970442b nixos/qemu-vm: Don't require CONFIG_EXPERIMENTAL
The kernel stopped using this config option with version 3.9 (back in
2013!).
2020-10-30 22:22:57 +01:00
Mira Ressel ef5268bcab nixos/qemu-vm: Fix condition in requiredKernelConfig
'optional' just takes a single item rather than a list
2020-10-30 22:22:13 +01:00
rnhmjoj bc2188b083
nixos: fix qemu_test being used in normal VMs
This is an attempt to fixup PR #49403.
2020-10-21 16:38:04 +02:00
worldofpeace dd2727773a Revert "nixos/qemu-vm: support nix run"
This reverts commit 02590c9620.

02590c9620 (commitcomment-42078853)
2020-09-06 19:45:10 -04:00
worldofpeace 02590c9620 nixos/qemu-vm: support nix run 2020-09-06 14:57:51 -04:00
Antoine Eiche 8595a0d6b9 Remove docker-preloader module and test 2020-08-23 10:49:13 +02:00
ajs124 c708c41c11 qemu-vm: fix master eval 2020-07-21 20:14:49 +02:00
Bas van Dijk d06de760f8 nixos/modules/system/activation/top-level.nix: allow overriding system.name
The toplevel derivations of systems that have `networking.hostName`
set to `""` (because they want their hostname to be set by DHCP) used
to be all named
`nixos-system-unnamed-${config.system.nixos.label}`.
This makes them hard to distinguish.

A similar problem existed in NixOS tests where `vmName` is used in the
`testScript` to refer to the VM. It defaulted to the
`networking.hostName` which when set to `""` won't allow you to refer
to the machine from the `testScript`.

This commit makes the `system.name` configurable. It still defaults to:

```
if config.networking.hostName == ""
then "unnamed"
else config.networking.hostName;
```

but in case `networking.hostName` needs to be to `""` the
`system.name` can be set to a distinguishable name.
2020-07-20 13:44:18 +02:00
Niklas Hambüchen d4d9d9c552
Merge pull request #92122 from nh2/qemu-vm-fix-useBootLoader
qemu-vm: Fix useBootLoader, remove `/boot` read-only restriction
2020-07-06 22:06:20 +02:00
Daniel Fullmer 0b4e216775 qemu-vm: treat EFI vars as state, similarly to diskImage 2020-07-06 12:09:37 -07:00
Daniel Fullmer fec163d21c qemu-vm: add EFI support for aarch64 2020-07-06 12:09:36 -07:00
Daniel Fullmer d7e3312ab1 qemu-vm: split EFI NVRAM into CODE and VARS 2020-07-06 12:08:41 -07:00
Daniel Fullmer 4d14826825 qemu-vm: allow bootloader to set EFI vars
Without this, systemd-boot does not add an EFI boot entry for itself.
The reason it worked before this fix is because it would fall back to
the default installed \EFI\BOOT\BOOTX64.EFI
2020-07-06 12:07:49 -07:00
Niklas Hambüchen 5b16d4c9ce qemu-vm.nix: Fix device name hardcodes on useBootLoader.
boot.loader.grub.device` was hardcoded to `bootDevice`, which is
wrong, because that's the device for `/`, and with `useBootLoader`
the boot loader is not on that device.

This bug probably came into existence because of bad naming;
`virtualisation.bootDevice` has description
"The disk to be used for the root filesystem", which is very confusing;
it should be `.rootDevice` then!
Unfortunately, the description is right and the attribute name is wrong,
so it is not easy to change this without deprecation.

This commit ensures that even if you use `useBootLoader` and
`diskInterface == "scsi"`, the created VM can boot through, and can run
`nixos-rebuild afterwards.

It also adds extra commentary to explain what's going on in this module
in general in relation to `useBootLoader`.
2020-07-04 14:47:36 +02:00
Niklas Hambüchen 2fa351b6a5 qemu-vm.nix: Do not mount /boot read-only.
There does not seem to be a good reason to do this, and it breaks running
`nixos-rebuild boot --install-bootloader` inside the VM.
2020-07-04 14:44:33 +02:00
Chuck e74755c422 nixos/qemu-vm: Don't assume boot drive is always vdb 2020-07-04 14:40:42 +02:00
Chuck a5e211dd7f nixos/qemu-vm: Generalize drive naming 2020-07-03 19:36:45 -07:00
Chuck 800639f287 nixos/qemu-vm: Refactor: Combine duplicate disk definitions 2020-07-03 11:31:43 -07:00
Alexandre Esteves 063043fa63
Fix typo 2020-06-08 16:47:46 +01:00
Florian Klink 3590f02e7d
Merge pull request #88574 from JJJollyjim/qemu-vm-qboot-opt
nixos/qemu-vm: add option to use qboot
2020-06-08 10:46:11 +02:00
Jamie McClymont 55912f3535 nixos/qemu-vm: add option to use a non-standard BIOS
I'd like to change the default on x86 platforms to qboot at some point, since it
saves a fair bit of startup time.
2020-06-08 11:21:53 +12:00
Florian Klink 8a388c8296
Merge pull request #82258 from erikarvstedt/fix-xchg-caching
fix inconsistent caching of VM xchg dirs
2020-06-01 22:34:48 +02:00
Erik Arvstedt d85dc4f690
qemu-vm: fix inconsistent caching of xchg dirs
xchg is advertised as a bidirectional exchange dir, but file content
transfer from host to VM fails due to caching:
If a file is read in the VM and then modified on the host, subsequent
re-reads in the VM can yield old, cached data.
This is caused by the use of 9p's cache=loose mode that is explicitly
meant for read-only mounts.

9p doesn't provide any suitable cache modes, so fix this by disabling
caching.

Also, remove a now unnecessary sync in the test driver.
2020-06-01 21:55:33 +02:00
Daniel Fullmer 37676e77cb nixos/systemd-boot: Add basic test 2020-05-05 14:18:18 -04:00
worldofpeace a7ca287ecb nixos/qemu-vm: don't set -vga std
This has been default since QEMU 2.2, it also prevents using a different
-vga
2020-04-27 20:04:03 +02:00
Christian Kauhaus edbf94d2ee connman: move options to services
As part of the networking.* name space cleanup, connman should be moved
to services.connman. The same will happen for example with
networkmanager in a separate PR.
2019-11-24 16:23:32 -05:00
Jean-Philippe Braun 376b2ef2b8 nixos/qemu-vm: declarative drives
Adds `virtualisation.qemu.drives` option to specify drives to be used by
qemu.

Also fix boot when `virtualisation.useBootLoader` is set to true. Since
the boot disk is second qemu doesn't boot on it. Added `bootindex=1` to
the boot disk device.
2019-02-12 16:55:02 +01:00
lewo 3fb4eb1c43 nixos/dockerPreloader: preload docker images (#49379)
This module permits to preload Docker image in a VM in order to reduce
OIs on file copies. This module has to be only used in testing
environments, when the test requires several Docker images such as in
Kubernetes tests. In this case,
`virtualisation.dockerPreloader.images` can replace the
`services.kubernetes.kubelet.seedDockerImages` options.

The idea is to populate the /var/lib/docker directory by mounting qcow
files (we uses qcow file to avoid permission issues) that contain images.

For each image specified in
config.virtualisation.dockerPreloader.images:
1. The image is loaded by Docker in a VM
2. The resulting /var/lib/docker is written to a QCOW file

This set of QCOW files can then be used to populate the
/var/lib/docker:
1. Each QCOW is mounted in the VM
2. Symlink are created from these mount points to /var/lib/docker
3. A /var/lib/docker/image/overlay2/repositories.json file is generated
4. The docker daemon is started.
2018-11-03 01:00:53 +01:00
Sarah Brofeldt ded8f28c3a Revert "virtualization/qemu-vm: fix and improve virtio/scsi switching"
This reverts commit f777d2b719.
cc #34409
This breaks evaluation of the tested job:
attribute 'diskInterface' missing, at /nix/store/5k9kk52bv6zsvsyyvpxhm8xmwyn2yjvx-source/pkgs/build-support/vm/default.nix:316:24
2018-09-25 11:10:10 +02:00
Stefan Junker f777d2b719 virtualization/qemu-vm: fix and improve virtio/scsi switching 2018-09-22 23:29:19 +02:00
Sarah Brofeldt 78fb4bd644 nixos/qemu-vm: Don't explicitly mknod /dev/vda*
And don't need to source the uevent files anymore either since $MAJOR
or $MINOR aren't used elsewhere.

[dezgeg: The reason these are no longer needed is that 0d27df280f
switched /tmp to a devtmpfs which automatically creates such device
nodes]
2018-08-16 14:19:41 +03:00
aszlig fb9f5e4a03
nixos/testing: Fix output of systemd messages
Regression introduced by d4468bedb5.

No systemd messages are shown anymore during VM test runs, which is not
very helpful if you want to find out about failures.

There is a bit of a conflict between testing and the change that
introduced the regression. While the mentioned commit makes sure that
the primary console is tty0 for virtualisation.graphics = false, our VM
tests need to have the serial console as primary console.

So in order to support both, I added a new virtualisation.qemu.consoles
option, which allows to specify those options using the module system.

The default of this option is to use the changes that were introduced
and in test-instrumentation.nix we use only the serial console the same
way as before.

For test-instrumentation.nix I didn't add a baudrate to the serial
console because I can't find a reason on top of my head why it should
need it. There also wasn't a reason stated when that was introduced in
7499e4a5b9.

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @flokli, @dezgeg, @edolstra
2018-05-10 08:21:20 +02:00
xeji 3d6f752c51
Merge pull request #39099 from teto/qemu_agent
qemu-guest-agent: init module
2018-05-10 01:22:52 +02:00
Florian Klink 7499e4a5b9 modules/virtualisation/qemu-vm: set console baudrate to 115200 2018-05-07 19:23:47 +03:00
Florian Klink d4468bedb5 modules/virtualisation/qemu-vm: always enable serial console
Always enable both tty and serial console, but set preferred console
depending on cfg.graphical.
Even in qemu graphical mode, you can switch to the serial console via
Ctrl+Alt+3.

With that being done, you also don't need to specify
`systemd.services."serial-getty@ttyS0".enable = true;` either as described in
https://nixos.wiki/wiki/Cheatsheet#Building_a_service_as_a_VM_.28for_testing.29,
as systemd automatically spawns a getty on consoles passwd via cmdline.

This also means, vms built by 'nixos-rebuild build-vm' can simply be run
properly in nographic mode by appending `-nographic` to `result/bin/run-*-vm`,
without the need to explicitly add platform-specific QEMU_KERNEL_PARAMS.
2018-05-07 19:23:47 +03:00
Florian Klink 36f4b7f6ba virtualisation/qemu-vm.nix: remove ttys
unused.
2018-05-07 19:23:47 +03:00
Florian Klink 046e374c99 virtualisation/qemu-vm.nix: use lib.optionalString 2018-05-07 19:23:47 +03:00
aszlig f148c5c4a1
nixos/tests: Fix QEMU flags for SCSI disks
The ability to specify "-drive if=scsi" has been removed in QEMU version
2.12 (introduced in 3e3b39f173).

Quote from https://wiki.qemu.org/ChangeLog/2.12#Incompatible_changes:

> The deprecated way of configuring SCSI devices with "-drive if=scsi"
> on x86 has been removed. Use an appropriate SCSI controller together
> "-device scsi-hd" or "-device scsi-cd" and a corresponding "-blockdev"
> parameter instead.

So whenever the diskInterface is "scsi" we use the new way to specify
the drive and fall back to the deprecated way for the time being. The
reason why I'm not using the new way for "virtio" and "ide" as well is
because there is no simple generic way anymore to specify these.

This also turns the type of the virtualisation.qemu.diskInterface option
to be an enum, so the user knows which values are allowed but we can
also make sure the right value is provided to prevent typos.

I've tested this against a few non-disk-related NixOS VM tests but also
the installer.grub1 test (because it uses "ide" as its drive interface),
the installer.simple test (just to be sure it still works with
"virtio") and all the tests in nixos/tests/boot.nix.

In order to be able to run the grub1 test I had to go back to
8b1cf100cd (which is a known commit where
that test still works) and apply the QEMU update and this very commit,
because right now the test is broken.

Apart from the tests here in nixpkgs, I also ran another[1] test in
another repository which uses the "scsi" disk interface as well (in
comparison to most of the installer tests, this one actually failed
prior to this commit).

All of them now succeed.

[1]: 9b5a119972/tests/system/kernel/bfq.nix

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @edostra, @grahamc, @dezgeg, @abbradar, @ts468
2018-04-30 03:02:59 +02:00