Commit Graph
958 Commits
Author SHA1 Message Date
Ivan Kruglov f6a7328e24 machine: introduce io.systemd.MachineImage.CleanPool 2025-02-04 03:03:00 -08:00
Ivan Kruglov 5a99c9d778 machine: use image_clean_pool_operation() in dbus 2025-02-04 03:03:00 -08:00
Ivan Kruglov a4019c75c2 machine: image_clean_pool_operation() 2025-02-04 03:03:00 -08:00
Ivan Kruglov 2694549ddf machine: rename machine_copy_from_to() -> machine_copy_from_to_operation()
This is done to make it clear that machine_copy_from_to() use and
returns an Operation object.
2025-02-04 02:58:48 -08:00
Yu Watanabe 4658651466 machine: revert type change of "leader" in io.systemd.Machine.Register method
The varlink method io.systemd.Machine.Register() is in v256, hence type
of "leader" cannot be changed.
Let's revert the change by 755cb018c9, and
introduce another field "leaderProcessId", which takes detailed information
of the process.

Fixes a regression caused by 755cb018c9.
Fixes #36155.
2025-01-27 10:18:25 +01:00
Yu Watanabe d7306348b2 tree-wide: insert a space at the end of comments 2025-01-25 05:24:23 +09:00
Lennart Poettering c8127075ae tree-wide: implement generic io.systemd.service Varlink interface in all long-running services
Given we have the generic interface, let's hook it up everywhere.

This doesnt bother with the Reload() call usually, since that's more
involved, but hooks up the other relevant functions where applicable.
2025-01-18 23:24:29 +01:00
Mike Yuan d693ba5f8e terminal-util: drop unused open_terminal_in_namespace()
With our baseline including TIOCGPTPEER we now systematically
open pty peer through ioctl(), i.e. this sits unused
since 1d522f1a86. Kill it!
2025-01-15 17:46:10 +01:00
Ivan Kruglov 8342390161 machine: introduce io.systemd.MachineImage.SetPoolLimit 2025-01-15 02:47:58 -08:00
Ivan Kruglov efe47f5895 machine: use image_set_pool_limit() in dbus 2025-01-15 02:47:58 -08:00
Lennart Poettering 1d522f1a86 terminal-util: drop support for pre-TIOCGPTPEER kernels
Our minimum baseline is now far beyond 4.13, hence let's drop these
fallback paths.
2025-01-15 10:39:04 +01:00
Mike Yuan ab33edb05b shared/bus-util: move bus_message_read_id128() to bus-message-util 2025-01-13 16:24:44 +01:00
Lennart Poettering 361327e929 convert more code to PidRef (#35895) 2025-01-11 23:14:33 +01:00
Lennart Poettering b25430deab terminal-util: pidref'ify two terminal related calls 2025-01-10 14:09:48 +01:00
Ivan Kruglov d423f231f7 machine: VARLINK_ERROR_MACHINE_IMAGE_* defines 2025-01-10 11:49:49 +01:00
Ivan Kruglov c85e837744 machine: VARLINK_ERROR_MACHINE_* defines 2025-01-10 11:49:49 +01:00
Ivan Kruglov 6b77efe47e machine: fix logging of errno in machine_open_root_directory() 2025-01-10 11:49:49 +01:00
Ivan Kruglov 04bf637e25 machine: set SD_VARLINK_SERVER_ALLOW_FD_PASSING_OUTPUT for varlink server 2025-01-09 10:51:18 +01:00
Ivan Kruglov 8633bf5836 machine: introduce io.systemd.Machine.OpenRootDirectory 2025-01-09 10:51:18 +01:00
Ivan Kruglov 307458a6f4 machine: use machine_open_root_directory() in dbus 2025-01-09 10:51:18 +01:00
Ivan Kruglov 65275cfbe5 machine: machine_open_root_directory() 2025-01-09 10:51:18 +01:00
Yu Watanabe 2bef5d187d machine: update log message and comments
Follow-up for 9af9d66184 and
453f2359ff.
2025-01-07 09:11:09 +01:00
Lennart Poettering 237aca5fbe machine: switch to using cleanup handling for child process cleanup 2025-01-06 23:37:45 +01:00
Lennart Poettering c0381ba6e8 machine: transition back to host mount ns before copying files from/to container
When copying files from or to a container we so far opened the host side
fd first, then entered the container (specifically, joined it's mount
namespace) in a forked off child process, and opened the other side
there, followed by the (potentially slow) copying from inside the
container mount namespace.

This commit changes this so that we rejoin the host mount namespace
before doing the copying routine. This is relevant, so that we can rely
on /proc/self/fd/… to work, which is not the case otherwise, as we'll
see /proc/ from a pidns that is not our own, in wich case
/proc/self/fd/… is refused. By moving back to the host mount namespace
our own pidns and the pidns the /proc/ mount belongs to will be in sync
again, and all is good.

This is in particular preparation for the next commit, that makes the
copy routine strictly depending on /proc/ being accessible and working.
2025-01-06 23:37:45 +01:00
Ivan Kruglov 453f2359ff machine: introduce io.system.Machine.{CopyFrom, CopyTo} methods 2025-01-06 14:51:57 +01:00
Ivan Kruglov 8632e7ae23 machine: use machine_copy_from_to() in dbus implementation 2025-01-06 14:51:57 +01:00
Ivan Kruglov 9af9d66184 machine: introduce machine_copy_from_to() helper 2025-01-06 14:51:57 +01:00
Ivan Kruglov 347a1105a4 machine: split operation initialization into two steps 2025-01-06 14:41:49 +01:00
Ivan Kruglov ee71079aba machine: adjust operation callback logic for varlink
This is to simplyfy varlink callback. There is no use of this logic atm.
So, no harm.
2025-01-06 14:41:49 +01:00
Daan De Meyer eaf0f79293 machine: several follow-ups for #35066 (#35868)
Addresses the post-merge review comments.
2025-01-06 11:59:55 +01:00
Yu Watanabe 8551ac2092 machine: use json_dispatch_const_path() where applicable
Follow-up for #35066 and 3866e9ce9d.
2025-01-06 17:09:43 +09:00
Mike Yuan 92b8e5e72f namespace-util: introduce pidref_in_same_namespace() 2025-01-04 17:08:01 +01:00
Mike Yuan 0577339d7d various: add missing include for namespace-util.h
Preparation for later commits for removing inclusion
of namespace-util from process-util.h
2025-01-04 17:08:00 +01:00
Daan De Meyer d0d647e084 Introduce systemd-pty-forward (#35761)
This allows running a command with tinted terminal background.
2025-01-03 19:34:42 +01:00
Daan De Meyer 9fbecf12fb tree-wide: Rename ret_slave to ret_peer 2025-01-03 09:28:13 +01:00
Ivan Kruglov d12b63f168 machine: introduce io.systemd.Machine.BindMount method 2025-01-02 16:58:16 +01:00
Yu Watanabe 51a0a3b049 machine: GC machine when no leader PID is set
After d8854ff1ac, if a serialized
leader PID of a machine is already dead when deserialized, then the
leader PID and PIDFD are unset for the machine, and subsequent
machine_start() -> machine_watch_pidfd() will trigger an assertion.
This makes a Machine object without leader PID GCed.

Fixes a bug introduced by the combination of
d8854ff1ac (v255) and
1762c2c045 (v257).

Fixes #35602.
2024-12-28 12:03:20 +00:00
Ivan Kruglov 544b7718b3 machine: add debugging info to trace #35115 2024-12-23 16:38:22 +00:00
Lennart Poettering 1c0ade2e1f discover-image: introduce per-user image directories
We nowadays support unprivileged invocation of systemd-nspawn +
systemd-vmspawn, but there was no support for discovering suitable disk
images (i.e. no per-user counterpart of /var/lib/machines). Add this
now, and hook it up everywhere.

Instead of hardcoding machined's, importd's, portabled's, sysupdated's
image discovery to RUNTIME_SCOPE_SYSTEM I introduced a field that make
the scope variable, even if this field is always initialized to
RUNTIME_SCOPE_SYSTEM for now. I think these four services should
eventually be updated to support a per-user concept too, this is
preparation for that, even though it doesn't outright add support for
this.

This is for the largest part not user visible, except for in nspawn,
vmspawn and the dissect tool. For the latter I added a pair of
--user/--system switches to select the discovery scope.
2024-12-20 18:04:01 +01:00
Yu Watanabe 64b504bde3 machinectl: explicitly assign PTY forwarder to sd_bus_slot
No functional change, just refactoring.
2024-12-18 20:28:28 +09:00
Yu Watanabe 12807b5a49 ptyfwd: always flush buffer and disconnect before exit
Then, it is not necessary to manually drain PTY forwarder by the user
side. Also, not necessary to free PTY forwarder earlier explicitly to
make it disconnected.
2024-12-18 20:28:07 +09:00
Yu Watanabe 4a4e7ec0e9 ptyfwd: always write additional line break on stop
Currently we do that in the user of PTY forwarder, e.g. nspawn.
But, let's do that unconditionally in the PTY forwarder.
2024-12-18 20:26:58 +09:00
Ivan Kruglov 8351463f67 machine: introduce io.systemd.Machine.{MapFrom, MapTo} methods 2024-12-17 11:25:24 +01:00
Zbigniew Jędrzejewski-Szmek fd409ff0e0 various: set info on varlink server object
The values that were previously hardcoded in sd-varlink.c are now defined
in new varlink_set_info_systemd() and that function is called everywhere
where we create a server.
2024-12-10 10:51:56 +01:00
Luca Boccassi d99fe076b5 introduce report_errno_and_exit() helper (#35028)
This is a follow for https://github.com/systemd/systemd/pull/34853. In
particular, this comment
https://github.com/systemd/systemd/pull/34853#discussion_r1825837705.
2024-11-06 13:51:10 +00:00
Ivan Kruglov a686bedb88 machine: introduce io.systemd.Machine.Open method 2024-11-06 11:37:51 +01:00
Ivan Kruglov b0eca6dee0 machine: machine_default_shell_path() & machine_default_shell_args() helper functions 2024-11-06 11:37:51 +01:00
Ivan Kruglov 41f1f283d7 machine: introduce machine_start_getty() and machine_start_shell() helpers 2024-11-06 11:37:51 +01:00
Ivan Kruglov a567de392d process-util: introduce report_errno_and_exit() as part of src/basic/process-util.{h,c} 2024-11-06 11:18:38 +01:00
Ivan Kruglov 88d0b72833 machine: use ImageUpdateParameters in io.systemd.MachineImage.Update 2024-11-01 15:30:39 +01:00