Commit Graph
89 Commits
Author SHA1 Message Date
Mike Yuan 6d2a26a136 vmspawn: use openpt_allocate where appropriate 2024-05-19 09:18:48 +08:00
Lennart Poettering ddbfc4d17e machined: return recognizable error when we try to register the same machine name twice 2024-05-13 12:25:22 -06:00
Lennart Poettering 13d6c5de41 varlink: rename vsockCid → vSockCid field 2024-05-14 00:49:45 +08:00
Yu Watanabe e8357737c6 vmspawn: fix finding systemd-journal-remote binary
Follow-up for 258d26940f.

Fixes https://github.com/systemd/systemd/pull/31218#discussion_r1596168449.
2024-05-10 11:37:24 +09:00
Yu Watanabe f607dd58bd vmspawn: trivial cleanups for start_systemd_journal_remote()
- prefix argument for storing result with 'ret_',
- align arguments for strv_new().
2024-05-10 11:37:24 +09:00
Sam Leonard 521e9286aa vmspawn: forward signals to VM PID 1 via D-BUS when available
Allow to gracefully shutdown by initiating the operation from
the guest
2024-05-08 23:25:02 +01:00
Sam Leonard 1e83cfff8d vmspawn: register with io.systemd.Machine.Register
When available, use varlink to register the VM, so that we can talk
over SSH to the guest. Enables 'machinectl shell' for vmspawn guests.
2024-05-08 23:24:54 +01:00
Sam Leonard 506aa3713b vmspawn: add a dropin override to sshd-vsock@.service 2024-05-08 23:24:54 +01:00
Zbigniew Jędrzejewski-Szmek 3ea527d33c vmspawn: indentation 2024-05-08 15:13:14 +02:00
Lennart Poettering d4ffb37bb1 nspawn, vmspawn, run0: add env var for turning off background tinting
Some people are just sad, sad lost souls who don't like even the tiniest
ray of color in their life. Let's add an env var knob for allowing them
to turn the background tinting off, to drive the last bit of color from
their life so that they can stay in their grey grey life.
2024-05-02 23:33:39 +02:00
Lennart Poettering 9573c0ba56 vmspawn: enable vmgenid for all VMs
This passes an ID derived from the vmgenid down to all VMs. This is
useful to have an identifier for this VM generation id. We derive it
from the invocation ID, if we have one, otherwise we randomize it.

Eventually we should make use of the vmgenid changing to re-acquire MAC
addresses, DHCP leases as such. Let's for now enable the VMM side of the
concept as first step towards that.
2024-04-20 12:10:42 +02:00
Lennart Poettering 6f9a1adf6d vmspawn: add env var that can extend the qemu cmdline
This is a bit hackish, but really useful sometimes to play around with
some qemu switches.
2024-04-20 12:10:42 +02:00
Lennart Poettering 77290bc83f vmspawn: enable hyperv enlightenments
THese are generally recommended (and libvirt/gnome-boxes default to them
hence). They are mostly relevant for Windows, but I think it makes sense
to enable them anyway for Linux too, simply to excercise #28001, and
they shouldn't hurt.
2024-04-20 12:10:42 +02:00
Daan De Meyer f5fefec786 vmspawn: Fix shared memory check
We need the shared memory added if we're doing runtime mounts as well.
2024-04-19 16:22:07 +02:00
Sam Leonard c3dd4e20fe vmspawn: generate predicatable TAP device names and MAC addresses 2024-04-15 11:42:06 +01:00
Sam Leonard bf3274e880 vmspawn: insert missing empty line 2024-04-15 11:24:27 +01:00
Sam Leonard 7c64382638 vmspawn: sort headers 2024-04-15 11:24:27 +01:00
Sam Leonard af49ea3371 vmspawn: check firmware target architecture
Fixes issue #32026 by only finding firmwares which explicitly support
the native architecture.
2024-04-13 05:48:05 +09:00
Sam Leonard edd85c8414 vmspawn: add --discard-disk= to control handling of disk discard requests
Fixes issue #32024, using --discard-disk=yes will enable handling of disk
discarding requests, saving space for long running VMs as desired.
2024-04-12 20:32:38 +02:00
Sam Leonard 0f85622950 vmspawn: update parse_boolean to parse_boolean_argument 2024-04-12 13:26:36 +01:00
Sam Leonard 657be6bdc7 vmspawn: enabled free page reporting in qemu by default
Fixes issue #32025, I saw no reason not to enable this by default so I
added it to the initial qemu cmdline.
2024-04-12 06:10:25 +09:00
Antonio Alvarez Feijoo 92966b3ac0 vmspawn: fix sd_bus_message_append() arguments and add missing error check 2024-04-09 06:47:48 +08:00
Yu Watanabe 8c27f1ba4a vmspawn: fix error code 2024-04-04 04:42:55 +09:00
Mike Yuan 8e1a1caa9c Merge pull request #31886 from DaanDeMeyer/logind
logind: Add fallback for when the PIDFDs= property is not available
2024-03-24 19:19:12 +08:00
Daan De Meyer 66b574b0a2 tree-wide: Add allow_pidfd argument to bus_append_scope_pidref() 2024-03-22 17:03:35 +01:00
Sam Leonard 2042aebb55 vmspawn: generate ephemeral SSH keys for the VM 2024-03-14 11:55:54 +00:00
Sam Leonard 4364a542e3 vmspawn: fix FD passing logic 2024-03-13 15:32:08 +00:00
Sam Leonard 002243ea64 vmspawn: prefix extra kernel-cmdline-extra with -smbios 2024-03-13 15:31:52 +00:00
Daan De Meyer 365e90b946 systemd-boot: Add support for reading extra kernel cmdline from SMBIOS
Same as io.systemd.stub.kernel-cmdline-extra, but for type 1 entries
booted by systemd-boot.
2024-03-10 16:30:34 +01:00
Lennart Poettering 9c046d93fe vmspawn: actually pass UUID down to qemu
qemu then adds this to SMBIOS product uuid, and we can actually read it
from the payload.

Followup for b0dc766852
2024-03-01 22:23:45 +01:00
Luca Boccassi 9b61d422ff Merge pull request #31430 from CodethinkLabs/vmspawn/machinectl_vmspawn_support
machinectl: initial vmspawn support
2024-02-29 11:27:02 +00:00
Sam Leonard eb77d24baa vmspawn: only add to cmdline if tpm was started 2024-02-28 22:05:33 +01:00
Sam Leonard b0dc766852 vmspawn: support machined registration 2024-02-28 17:49:00 +00:00
Lennart Poettering 795ec90cda vmspawn: use our own ptyfwd code for the console of a VM
Let's make systemd-nspawn use our own ptyfwd logic to handle the TTY by
default.

This adds a new setting --console=, inspired by nspawn's setting of the
same name. If --console=interactive= is used, then we'll do the TTY
dance on our own via ptyfwd, and thus get tinting, our usual hotkey
handling and similar.

Since qemu's own console is useful too, let's keep it around via
--console=native.

FInally, replace the --qemu-gui switch by --console=gui.
2024-02-26 11:54:37 +01:00
Luca Boccassi bb394133cb Merge pull request #31464 from poettering/vmspawn-limit-bank
vmspawn: disable all TPM PCR banks, except for SHA256
2024-02-23 22:04:44 +00:00
Lennart Poettering db7136ec73 signal-util: imply sentinel -1 in sigprocmask_many() + sigset_add_many() args list 2024-02-23 09:35:12 -08:00
Lennart Poettering 519bad6c2c vmspawn: disable all PCR banks but SHA256
By default swtpm runs with four banks: SHA1, SHA256, SHA384, SHA512.
This means all data that is part of the boot will be hashed four times,
which slows everything down.

Let's restrict things to SHA256 only, which is the one that really
matters. SHA1 is no up to today's standards anyway, and noone really
consumes the other two, hence no point in enabling this.

To disable the banks we need to call swtpm_setup with --pcr-banks. Do
so.
2024-02-23 17:27:56 +01:00
Lennart Poettering d90a05b68f vmspawn: drop "const" from string we free
I am a bit surprised this compiled at all...
2024-02-23 17:27:18 +01:00
Lennart Poettering 2c0061c784 vmspawn: rename "qemu" specific switches to not carry the "qemu" prefix
This renames a few of the switches vmspawn takes, such as --qemu-mem=
and --qemu-smp= to names without the "qemu" moniker and uses less
cryptic names (i.e. --ram= and --cpus=).

I think it's a bit unsystematic that so far we use the "qemu" prefix for
some options but not for others. At least I could not figure out a
system when we use it and when we don't. Hence let's clean it up and
just use simpler names without suffix.

After all we might want to plug other hypervisors behind vmspawn one
day, hence I think there's value in sticking to generic names for these
switches that allow us to switch out backends easily. In particular for
--ram= and --cpus= which are probably the most fundamental of VM settings
there are.

The old switches are support for compat, but not advertised in man page
or --help text anymore.

I left "--qemu-gui" under its current name, since it fundamentally is a
a qemu concept, exposing a qemu specific graphical UI.
2024-02-21 16:35:53 +01:00
Lennart Poettering cf9de8ef21 vspawn: prefer "VSOCK" spelling over "vsock" and "VSock"
The vsock(7) man page appears to prefer "VSOCK" spelling for the
concept, let's also use it as much as we can.
2024-02-21 16:18:24 +01:00
Sam Leonard 1ec3218e82 vmspawn: add --extra-drive= 2024-02-21 10:22:40 +00:00
Sam Leonard 018cc9eaf6 vmspawn: correctly escape ',' in certain values passed to qemu 2024-02-21 10:22:40 +00:00
Zbigniew Jędrzejewski-Szmek 7e2c6c74cf vmspawn: rework --help
In this context, "VM" doesn't need explaining. Make the texts more precise
and try to make them fit in one line. Help output is much easier to read
when it's not wrapped.
2024-02-19 11:56:28 +01:00
Luca Boccassi 92d1419eb8 Merge pull request #31218 from CodethinkLabs/vmspawn/journal_forwarding
vmspawn: support journal forwarding
2024-02-16 12:09:52 +00:00
Sam Leonard ec3d2f2e9d vmspawn: fix possible NULL dereference in discover_boot_entry 2024-02-16 12:45:08 +01:00
Sam Leonard 258d26940f vmspawn: add --forward-journal= 2024-02-15 14:08:21 +00:00
Yu Watanabe 8c3f988880 vmspawn: fix alignment of merged initrd
Follow-up for 811ad9e6b2.

Fixes CID#1534481.
2024-02-15 09:11:55 +01:00
Sam Leonard b064cc563a vmspawn: search for machines when only passed -M/--machine= 2024-02-13 12:31:03 +00:00
Sam Leonard 6af6d44230 vmspawn: discover bootloader for directory type images 2024-02-13 12:31:03 +00:00
Sam Leonard 811ad9e6b2 vmspawn: support multiple initrds via merging 2024-02-13 12:26:33 +00:00