summary refs log tree commit diff
path: root/host/start-vm
Commit message (Collapse)AuthorAge
* Remove unused hasSuffix inheritsAlyssa Ross2023-03-12
| | | | | | | | | This was widely used when each component was responsible for filtering out its own Nix files, but now that's centralised, all these bindings can be cleaned up. Fixes: 0149885 ("nix: centralise source cleaning") Signed-off-by: Alyssa Ross <hi@alyssa.is>
* host/start-vm: implement shared directoriesAlyssa Ross2023-02-26
| | | | | Signed-off-by: Alyssa Ross <hi@alyssa.is> Message-Id: <20221010232909.1953738-3-hi@alyssa.is>
* host/start-vm: use MAP_SHARED memory for VMsAlyssa Ross2023-02-26
| | | | | | | | | This is required for any use of vhost-user. Since any VM might have a vhost-user device hotplugged, this needs to be on from the start for all VMs. Signed-off-by: Alyssa Ross <hi@alyssa.is> Message-Id: <20221010232909.1953738-2-hi@alyssa.is>
* lib/common.mk: initAlyssa Ross2023-02-22
| | | | | | | | | | | | | | | | | | | | | | | | | We can simplify our Makefiles a bit by moving some things into a library file. So far, I've done this for non-component-specific macros, and inference rules. Some tar2ext4 rules used a temporary file for the tar2ext4 invocation, and then moved the file into place when it was done, to prevent a half-built image sticking around if tar2ext4 died. According to POSIX, make should clean up any targets that didn't finish building if it's interrupted, so we should only end up with a half-built image if tar2ext4 crashes, e.g. due to running out of disk space. I think we should just ignore that possibility, since otherwise we'd have to write annoying make rules using temporary file names for every target, and if it does happen recovery is just a make clean away. With this, I've also made a small reorganisation. I got rid of the "nix" directory and created a "lib" directory, where I put eval-config.nix and the new common.mk file, since both are library code. checks.nix isn't really a library though, so I moved it into the "release" directory, since the only reference to it is in release.nix. Signed-off-by: Alyssa Ross <hi@alyssa.is>
* nix/eval-config.nix: fix custom configurationAlyssa Ross2023-02-22
| | | | | | | | | | | | | | | | | When I introduced the global src attribute, I broke custom configurations, since they wouldn't be passing that key in, and nor should they. To allow for non-customisable globals like src, we need to separate them from config. Here, I've modified eval-config.nix to take a callback, so that it can provide multiple attributes, and handle command line arguments itself so that doesn't need to be in every entry point any more. This gives us an interface similar to the NixOS module system's, where a variety of globals are available that can be pulled out of the passed attribute set as required, but with the additional advantage that files are usable directly from nix-build, and support command line arguments. Signed-off-by: Alyssa Ross <hi@alyssa.is> Fixes: 0149885 ("nix: centralise source cleaning")
* nix: centralise source cleaningAlyssa Ross2023-02-22
| | | | | | | | | This was getting very repetitive. Having a single copy of the sources shared between builds will also save on store space, and means we don't need to support overriding the path to the scripts directory in Makefiles. Signed-off-by: Alyssa Ross <hi@alyssa.is>
* host/start-vm: boot using partition labelAlyssa Ross2022-11-13
| | | | | | | | | This will allow booting reliably from multiple disk images, without relying on order. Thanks-to: Puck Meerburg <puck@puckipedia.com> Signed-off-by: Alyssa Ross <hi@alyssa.is> Message-Id: <20221009114036.463071-5-hi@alyssa.is>
* host/start-vm: support multiple block devicesAlyssa Ross2022-11-13
| | | | | | | | | | | | | | This is the first step to being able to do things like having a static base image for an application VM, and another image containing the application to run. When we actually use multiple images we'll need to change how we boot so we know the kernel is booting from the right image — probably by PARTUUID or PARTLABEL — because we can't guarantee how the kernel orders disks inside the VM. Signed-off-by: Alyssa Ross <hi@alyssa.is> Message-Id: <20221009114036.463071-2-hi@alyssa.is>
* host/start-vm: tell Meson that Rust tests are RustAlyssa Ross2022-10-09
| | | | | | | With this, Meson will show the status of subtests inside the "Rust unit tests" test. Signed-off-by: Alyssa Ross <hi@alyssa.is>
* host/start-vm: test cloud-hypervisor commandAlyssa Ross2022-10-09
| | | | | Pull out all the logic from start-vm into its own file, that can be built as a library and tested.
* host/start-vm: use argv0 base name for errorsAlyssa Ross2022-10-09
| | | | | | | Otherwise, if start-vm was run by path, it would print the whole path used to invoke it as an error message prefix. Signed-off-by: Alyssa Ross <hi@alyssa.is>
* host/start-vm: remove unused callPackage argumentAlyssa Ross2022-10-09
| | | | Signed-off-by: Alyssa Ross <hi@alyssa.is>
* Introduce a build configuration fileAlyssa Ross2022-09-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default, a file called "config.nix" in the root of the Spectrum repository will be read if it exists. That file should contain an attribute set. Currently, only a "pkgs" key is supported, which allows specifying a custom package set that will be used throughout the Spectrum Nix files. This will allow us to provide configuartion options for people who want to build Spectrum in ways that are probably not suitable for upstreaming. For example, using the "pkgs" config option I'm introducing here, it would be possible to use an overlay to patch individual components, like so: { pkgs = import <nixpkgs> { overlays = [ (final: super: { weston = super.weston.overrideAttrs ({ patches ? [], ... }: { patches = patches ++ [ path/to/weston.patch ]; }); }) ]; }; } Signed-off-by: Alyssa Ross <hi@alyssa.is> Message-Id: <20220831093727.282797-1-hi@alyssa.is> Reviewed-by: Ville Ilvonen <ville.ilvonen@unikie.com> Tested-by: José Pekkarinen <jose.pekkarinen@unikie.com>
* Clarify EUPL SPDX expressionAlyssa Ross2022-05-23
| | | | | | | | | | | | | | | | | | This isn't a license change — the code was always available under potential future EUPL versions because of this language in the EUPL: > Copyleft clause: If the Licensee distributes or communicates copies of the > Original Works or Derivative Works, this Distribution or Communication will be > done under the terms of this Licence or of a later version of this Licence > unless the Original Work is expressly distributed only under this version of the > Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee > (becoming Licensor) cannot offer or impose any additional terms or conditions on > the Work or Derivative Work that alter or restrict the terms of the Licence. But now that reuse 1.0.0 is out, and supports SPDX '+' expressions, we can express this more clearly in SPDX. Signed-off-by: Alyssa Ross <hi@alyssa.is>
* Remove Nix files in copyPathToStoreAlyssa Ross2022-05-16
| | | | | | Nix files shouldn't be considered part of the sources, and so they should be filtered out. This way, changes to them (that don't change their meaning) won't force rebuilds.
* host/start-vm: abort on panicAlyssa Ross2022-04-30
| | | | | | | | | | | | | There's nothing we could do to recover from a panic, and since we use FFI extensively, to safely use unwinding panics we would have to wrap every Rust function callable from C in a catch_unwind[1]. It's not currently possible[2] to use this with Rust unit tests, so we keep panic=unwind there. It's unlikely that a Rust unit test will call C which calls Rust anyway. [1]: https://doc.rust-lang.org/nomicon/unwinding.html [2]: https://github.com/rust-lang/rust/issues/67650
* host/start-vm: fix typos in commentAlyssa Ross2022-04-27
|
* host/start-vm: don't allow VM name to contain ','Alyssa Ross2022-04-27
| | | | | cloud-hypervisor would misintepret these if they were passed on its command line.
* host/start-vm: use returns instead of early exitsAlyssa Ross2022-04-27
| | | | | I thought that returning early would make the code more noisy, but with String as the error type, it doesn't!
* host/start-vm: drop Meson patchAlyssa Ross2022-04-26
| | | | The patch made its way into the Meson release now in Nixpkgs!
* host/rootfs: remove unnecessary modprobesAlyssa Ross2022-03-22
| | | | | | | | | Now that we're using a proper modprobe implementation, some of these weird modprobes we shouldn't have needed in the first place can actually be removed. Message-Id: <20220321140107.1043654-2-hi@alyssa.is> Tested-by: Ville Ilvonen <ville.ilvonen@unikie.com>
* host/start-vm: fix typo in doc commentAlyssa Ross2022-03-19
|
* host/start-vm: remove unused Nix argumentAlyssa Ross2022-03-19
|
* host/start-vm: stripAlyssa Ross2022-02-21
| | | | This was a leftover from debugging a crash.
* host/start-vm: skip tests if no /sysAlyssa Ross2022-02-21
|
* host/start-vm: skip tests if no /dev/net/tunAlyssa Ross2022-02-21
|
* host/start-vm: add tests for if functionsAlyssa Ross2022-02-21
|
* host/start-vm: if_rename: reject names with %Alyssa Ross2022-02-21
| | | | | Just like with bridge_add, the kernel doesn't tell us what the new name is, so we can't return it.
* host/start-vm: if_rename: check length of new nameAlyssa Ross2022-02-21
|
* host/start-vm: tap_open: check length before copyAlyssa Ross2022-02-21
| | | | | | This way of doing it stops GCC's stringop-truncation warning in this case. (But it still fires spuriously in other cases so we're keeping it disabled.)
* host/start-vm: add tests for bridge functionsAlyssa Ross2022-02-21
|
* host/start-vm: bridge_add: check name lengthAlyssa Ross2022-02-21
|
* host/start-vm: bridge_add: don't accept % in namesAlyssa Ross2022-02-21
| | | | | | | | | | | | | | | Linux will accept %d and dynamically fill it in, but it doesn't update the string it was given, so there's no way to know what name was chosen with this API. If we wanted to support this, we'd probably have to use the netlink API instead. Right now, we don't need the kernel to allocate bridge names for us, so let's just reject the names we can't handle instead. We only need to check for the presence of a % character, rather than doing anything more complicated, because network interfaces aren't actually allowed to have % in their names, so any % character is either part of a %d that gets replaced, or will be rejected by the kernel.
* host/start-vm: tap_open: return name of tapAlyssa Ross2022-02-21
| | | | | | This is important when using %d to dynamically choose a tap name in the kernel. It's not needed for the start-vm program, but supporting dynamic names makes writing tests easier.
* host/start-vm: add tests for tap_openAlyssa Ross2022-02-21
|
* host/start-vm: drop prototype for removed functionAlyssa Ross2022-02-20
|
* host/start-vm: tap_open: check name lengthAlyssa Ross2022-02-20
|
* host/start-vm: fix a compiler warningAlyssa Ross2022-02-20
|
* host/rootfs: don't autostart VM consolesAlyssa Ross2022-02-19
| | | | | | Aside from the experience benefit of not popping the netvm console open when it's not required, this also simplifies the implementation a lot, because it means each VM only has to be a single service.
* host/start-vm; check exit_listener_setup failureAlyssa Ross2022-02-18
| | | | | If we know ahead of time we won't be able to cleanup after ourselves, it's probably better to fail early.
* host/start-vm: fix missing include with MuslAlyssa Ross2022-02-17
|
* host/start-vm: use meson attributeAlyssa Ross2022-02-17
| | | | | The meson mess in Nixpkgs has been resolved, and "meson" is now a recent version that the patch applies to.
* host/start-vm: run tests in Nix buildAlyssa Ross2022-02-15
|
* host/start-vm: fix indentationAlyssa Ross2022-02-15
|
* host/start-vm: implement format_mac in RustAlyssa Ross2022-02-15
| | | | | All callers are Rust at this point, so there's no point having a C version available.
* host/start-vm: add format_mac testsAlyssa Ross2022-02-15
|
* host/start-vm: standardize variable namingAlyssa Ross2022-02-15
|
* host/start-vm: clean up net after VM shuts downAlyssa Ross2022-02-15
|
* host/start-vm: don't list Rust files in meson.buildAlyssa Ross2022-02-15
| | | | | As far as I can tell, this isn't required for anything, ninja uses the dependency information emitted by rustc.
* host/rootfs: dynamically generate s6-rc servicesAlyssa Ross2022-02-14
This way, we don't allow arbitrary code from the ext partition to run on the host system, which gives us better integrity guarantees when paired with Secure Boot. This new scheme also makes it easy to introspect VMs, since they're defined using a very limited configuration language.