1
0
mirror of https://github.com/systemd/systemd synced 2024-07-01 07:34:28 +00:00

Compare commits

...

16 Commits

Author SHA1 Message Date
Lennart Poettering
357f37da3e
Merge 319c8e3189 into 0e445aaa85 2024-06-28 22:54:04 -07:00
Daan De Meyer
0e445aaa85 repart: Log more about filesystem sector size 2024-06-29 02:09:55 +02:00
Luca Boccassi
1c74db68e4
Merge pull request #33518 from DaanDeMeyer/aarch64
Various integration test fixes
2024-06-29 02:09:21 +02:00
Mike Yuan
740cd1e0f2 core/unit: follow merged units before updating SourcePath= timestamp too
Currently, we only follow merged units for unit_load_dropin() call.
But if the unit is an alias, we should always perform operations
on the "canonical" unit.
2024-06-28 21:10:16 +02:00
Daan De Meyer
436474dd43 TEST-54-CREDS: Use UEFI firmware if available
On aarch64, SMBIOS is only available when using UEFI, so let's make
sure that the creds test uses UEFI when available so that it can
read creds from SMBIOS when running in a virtual machine.
2024-06-28 16:23:27 +02:00
Daan De Meyer
f392be9e77 TEST-18-FAILUREACTION: Set auto firmware
This test runs in nspawn by default but will still run in qemu when
tests are run unprivileged so make sure we use UEFI if available to
avoid hangs when using the linux firmware.
2024-06-28 16:23:25 +02:00
Daan De Meyer
3cf38516bb TEST-09-REBOOT: Set auto firmware
This test runs in nspawn by default but will still run in qemu when
tests are run unprivileged so make sure we use UEFI if available to
avoid hangs when using the linux firmware.
2024-06-28 16:21:39 +02:00
Daan De Meyer
7c04137a6f TEST-06-SELINUX: Explicitly pull in autorelabel.service 2024-06-28 15:50:35 +02:00
Daan De Meyer
98f2a332cb TEST-70-TPM2: Use UEFI firmware if available
On x86 this doesn't matter but on aarch64 we need to make sure UEFI
is used so that /sys/kernel/security/tpm0/binary_bios_measurements
is there which is required for TEST-70-TPM2.
2024-06-28 15:47:33 +02:00
Daan De Meyer
24284098a4 TEST-45-TIMEDATE: Use syslog identifier journalctl match
Using a unit match is racy whereas a syslog identifier match is
reliable.
2024-06-28 14:51:10 +02:00
Daan De Meyer
72d121b601 TEST-64-UDEV-STORAGE: Make nvme_subsystem expected pci symlinks more generic
When running the test on aarch64 the symlinks look as follows:

"""
[root@H ~]# ls /dev/disk/by-path
platform-4010000000.pcie-pci-0000:00:04.0-scsi-0:0:0:0       platform-4010000000.pcie-pci-0000:00:04.0-scsi-0:0:0:0-part1  platform-4010000000.pcie-pci-0000:00:05.0-nvme-16
platform-4010000000.pcie-pci-0000:00:04.0-scsi-0:0:0:0-part  platform-4010000000.pcie-pci-0000:00:04.0-scsi-0:0:0:0-part2  platform-4010000000.pcie-pci-0000:00:05.0-nvme-17
"""

So let's make the PCI patterns a little more generic so they match
both the x86 and the aarch64 paths.
2024-06-28 14:20:34 +02:00
Daan De Meyer
3cdc8da5ad mkosi: Install pciutils 2024-06-28 13:41:12 +02:00
Daan De Meyer
32f3617fd7 test: pull in multi-user.target explicitly
Let's make sure we pull in multi-user.target so that we get a console
when a test fails and we're running meson test with --interactive.
2024-06-28 13:34:37 +02:00
Daan De Meyer
4e469c0af2 TEST-64-UDEV-STORAGE: Fix python 3.9 compatibility
Using double quotes in f-strings only works from python 3.12 onwards.
Use single quotes to make sure python 3.9 works as well.

Also clean up quotes a little in general.
2024-06-28 13:18:29 +02:00
Daan De Meyer
7f07f9c8cd TEST-64-UDEV-STORAGE: Use bus pci slot 1 instead of 0
Trying to use bus pci slot 0 fails on aarch64 so let's use 1 instead.

The error:

"""
qemu-system-aarch64: -device virtio-blk-pci,drive=drive0,scsi=off,bus=pci_bridge25: Unsupported PCI slot 0 for standard hotplug controller. Valid slots are between 1 and 31.
"""
2024-06-28 12:51:26 +02:00
Lennart Poettering
319c8e3189 async: make sure to set argv[0][0] to '@' to avoid being killed in killing spree
Prompted by: #32223
2024-04-16 12:28:58 +02:00
18 changed files with 75 additions and 22 deletions

View File

@ -57,6 +57,7 @@ Packages=
opensc
openssl
p11-kit
pciutils
python3
qrencode
radvd

View File

@ -1457,11 +1457,20 @@ int safe_fork_full(
sigset_t saved_ss, ss;
_unused_ _cleanup_(restore_sigsetp) sigset_t *saved_ssp = NULL;
bool block_signals = false, block_all = false, intermediary = false;
_cleanup_free_ char *prefixed_name = NULL;
int prio, r;
assert(!FLAGS_SET(flags, FORK_DETACH) || !ret_pid);
assert(!FLAGS_SET(flags, FORK_DETACH|FORK_WAIT));
if (name && FLAGS_SET(flags, FORK_ARGV00_AT)) {
/* Optionally, ensure argv[0][0] is '@', in order to implement https://systemd.io/ROOT_STORAGE_DAEMONS */
prefixed_name = strjoin("@", name);
if (!prefixed_name)
return -ENOMEM;
name = prefixed_name;
}
/* A wrapper around fork(), that does a couple of important initializations in addition to mere forking. Always
* returns the child's PID in *ret_pid. Returns == 0 in the child, and > 0 in the parent. */

View File

@ -186,6 +186,7 @@ typedef enum ForkFlags {
FORK_DETACH = 1 << 18, /* Double fork if needed to ensure PID1/subreaper is parent */
FORK_NEW_NETNS = 1 << 19, /* Run child in its own network namespace 💣 DO NOT USE IN THREADED PROGRAMS! 💣 */
FORK_PACK_FDS = 1 << 20, /* Rearrange the passed FDs to be FD 3,4,5,etc. Updates the array in place (combine with FORK_CLOSE_ALL_FDS!) */
FORK_ARGV00_AT = 1 << 21, /* Prefix supplied name with '@', to exclude child process from final killing spree */
} ForkFlags;
int safe_fork_full(

View File

@ -1402,11 +1402,13 @@ int unit_load_fragment_and_dropin(Unit *u, bool fragment_required) {
u->load_state = UNIT_LOADED;
}
u = unit_follow_merge(u);
/* Load drop-in directory data. If u is an alias, we might be reloading the
* target unit needlessly. But we cannot be sure which drops-ins have already
* been loaded and which not, at least without doing complicated book-keeping,
* so let's always reread all drop-ins. */
r = unit_load_dropin(unit_follow_merge(u));
r = unit_load_dropin(u);
if (r < 0)
return r;

View File

@ -2574,8 +2574,10 @@ static int context_load_partition_table(Context *context) {
/* If we found the sector size and we're operating on a block device, use it as the file
* system sector size as well, as we know its the sector size of the actual block device and
* not just the offset at which we found the GPT header. */
if (r > 0 && S_ISBLK(st.st_mode))
if (r > 0 && S_ISBLK(st.st_mode)) {
log_debug("Probed sector size of %s is %" PRIu32 " bytes.", context->node, ssz);
fs_secsz = ssz;
}
}
r = fdisk_save_user_sector_size(c, /* phy= */ 0, ssz);
@ -2639,7 +2641,7 @@ static int context_load_partition_table(Context *context) {
* larger */
grainsz = secsz < 4096 ? 4096 : secsz;
log_debug("Sector size of device is %lu bytes. Using grain size of %" PRIu64 ".", secsz, grainsz);
log_debug("Sector size of device is %lu bytes. Using filesystem sector size of %" PRIu64 " and grain size of %" PRIu64 ".", secsz, fs_secsz, grainsz);
switch (arg_empty) {

View File

@ -6,6 +6,7 @@
#include <sys/wait.h>
#include <unistd.h>
#include "argv-util.h"
#include "async.h"
#include "errno-util.h"
#include "fd-util.h"
@ -22,7 +23,14 @@ int asynchronous_sync(pid_t *ret_pid) {
* original process ever, and a thread would do that as the process can't exit with threads hanging in blocking
* syscalls. */
r = safe_fork("(sd-sync)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|(ret_pid ? 0 : FORK_DETACH), ret_pid);
/* Note that we set argv[0][0] = '@' here if we are called from PID 1, which tells the
* switch-root/soft-reboot/shutdown killing spree to leave this process around. After all the killing
* is likely not going to work anyway, and given the limited scope of the child it's really not worth
* killing it. */
r = safe_fork("(sd-sync)",
FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|(ret_pid ? 0 : FORK_DETACH)|(getpid_cached() == 1 ? FORK_ARGV00_AT : 0),
ret_pid);
if (r < 0)
return r;
if (r == 0) {
@ -41,12 +49,23 @@ int asynchronous_sync(pid_t *ret_pid) {
static int close_func(void *p) {
unsigned v = PTR_TO_UINT(p);
(void) prctl(PR_SET_NAME, (unsigned long*) "(sd-close)");
/* Note: 💣 This function is invoked in a child process created via glibc's clone() wrapper. In such
* children memory allocation is not allowed, since glibc does not release malloc mutexes in
* clone() 💣 */
/* This is a poor man's version of rename_process(). We don't use the real thing to avoid any memory
* allocations. We set argv[0][0] to '@' if invoked by PID 1 to exclude us from the
* switch-root/soft-reboot/shutdown killing spree, since it would likely fail anyway, and with a
* process of such minimal scope is not really worh the effort anyway. */
const char *comm;
if (getppid() == 1) {
if (saved_argc >= 1 && !isempty(saved_argv[0]))
saved_argv[0][0] = '@';
comm = "@(sd-close)";
} else
comm = "(sd-close)";
(void) prctl(PR_SET_NAME, comm);
if (v & NEED_DOUBLE_FORK) {
pid_t pid;
@ -117,9 +136,15 @@ int asynchronous_rm_rf(const char *p, RemoveFlags flags) {
assert(p);
/* Forks off a child that destroys the specified path. This will be best effort only, i.e. the child
* will attempt to do its thing, but we won't wait for it or check its success. */
* will attempt to do its thing, but we won't wait for it or check its success.
*
* We do set argv[0][0] = '@' here however (if we are invoked as PID 1), to ensure that the this is
* excluded from the switch-root/soft-reboot/poweroff killing spree, and can definitely complete it's
* job. */
r = safe_fork("(sd-rmrf)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DETACH, NULL);
r = safe_fork("(sd-rmrf)",
FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DETACH|(getpid_cached() == 1 ? FORK_ARGV00_AT : 0),
/* ret_pid= */ NULL);
if (r != 0)
return r;

View File

@ -3,7 +3,7 @@
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
'cmdline' : integration_test_template['cmdline'] + ['selinux=1', 'lsm=selinux'],
'cmdline' : integration_test_template['cmdline'] + ['systemd.wants=autorelabel.service', 'selinux=1', 'lsm=selinux'],
# FIXME; Figure out why reboot sometimes hangs with 'linux' firmware.
# Use 'auto' to automatically fallback on non-uefi architectures.
'firmware' : 'auto',

View File

@ -4,5 +4,8 @@ integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
'storage' : 'persistent',
# FIXME: Figure out why reboot sometimes hangs with 'linux' firmware.
# Use 'auto' to automatically fallback on non-uefi architectures.
'firmware' : 'auto',
},
]

View File

@ -3,5 +3,8 @@
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
# FIXME: Figure out why reboot sometimes hangs with 'linux' firmware.
# Use 'auto' to automatically fallback on non-uefi architectures.
'firmware' : 'auto',
},
]

View File

@ -27,5 +27,6 @@ integration_tests += [
'-smbios', 'type=11,value=io.systemd.credential.binary:fstab.extra=aW5qZWN0ZWQgL2luamVjdGVkIHRtcGZzIFgtbW91bnQubWtkaXIgMCAwCg==',
'-smbios', 'type=11,value=io.systemd.credential:getty.ttys.container=idontexist',
],
'firmware' : 'auto',
},
]

View File

@ -23,10 +23,9 @@ config["QemuArgs"] += ["-device", "pci-bridge,id=pci_bridge0,chassis_nr=64"]
for bridge in range(1, 26):
config["QemuArgs"] += [
"-device",
f"pci-bridge,id=pci_bridge{bridge},bus=pci_bridge{bridge - 1},"
f"chassis_nr={64 + bridge}"
f"pci-bridge,id=pci_bridge{bridge},bus=pci_bridge{bridge - 1},chassis_nr={64 + bridge},addr=1",
]
config["QemuArgs"] += ["-device", f"virtio-blk-pci,drive=drive0,scsi=off,bus=pci_bridge25"]
config["QemuArgs"] += ["-device", f"virtio-blk-pci,drive=drive0,scsi=off,bus=pci_bridge25,addr=1"]
json.dump(config, sys.stdout)

View File

@ -9,8 +9,8 @@ import sys
config = json.load(sys.stdin)
qemu = f"qemu-system-{os.environ["QEMU_ARCHITECTURE"]}"
result = subprocess.run([qemu, '-device', 'help'], check=True, text=True, stdout=subprocess.PIPE)
qemu = f"qemu-system-{os.environ['QEMU_ARCHITECTURE']}"
result = subprocess.run([qemu, "-device", "help"], check=True, text=True, stdout=subprocess.PIPE)
if 'name "nvme"' not in result.stdout:
print("nvme device driver is not available, skipping test...", file=sys.stderr)
exit(77)

View File

@ -9,8 +9,8 @@ import sys
config = json.load(sys.stdin)
qemu = f"qemu-system-{os.environ["QEMU_ARCHITECTURE"]}"
result = subprocess.run([qemu, '-device', 'help'], check=True, text=True, stdout=subprocess.PIPE)
qemu = f"qemu-system-{os.environ['QEMU_ARCHITECTURE']}"
result = subprocess.run([qemu, "-device", "help"], check=True, text=True, stdout=subprocess.PIPE)
if 'name "nvme"' not in result.stdout:
print("nvme device driver is not available, skipping test...", file=sys.stderr)
exit(77)

View File

@ -9,8 +9,8 @@ import sys
config = json.load(sys.stdin)
qemu = f"qemu-system-{os.environ["QEMU_ARCHITECTURE"]}"
result = subprocess.run([qemu, '-device', 'help'], check=True, text=True, stdout=subprocess.PIPE)
qemu = f"qemu-system-{os.environ['QEMU_ARCHITECTURE']}"
result = subprocess.run([qemu, "-device", "help"], check=True, text=True, stdout=subprocess.PIPE)
if 'name "virtio-scsi-pci"' not in result.stdout:
print("virtio-scsi-pci device driver is not available, skipping test...", file=sys.stderr)
exit(77)

View File

@ -8,5 +8,6 @@ integration_tests += [
'after' : '@0@ tpm2.target'.format(integration_test_template['configuration']['after']),
},
'vm' : true,
'firmware' : 'auto',
},
]

View File

@ -103,6 +103,12 @@ def main():
journal_file = (args.meson_build_dir / (f"test/journal/{name}.journal")).absolute()
journal_file.unlink(missing_ok=True)
else:
dropin += textwrap.dedent(
"""
[Unit]
Wants=multi-user.target
"""
)
journal_file = None
cmd = [

View File

@ -218,7 +218,7 @@ assert_ntp() {
assert_timedated_signal() {
local timestamp="${1:?}"
local value="${2:?}"
local args=(-q -n 1 --since="$timestamp" -p info _SYSTEMD_UNIT="busctl-monitor.service")
local args=(-q -n 1 --since="$timestamp" -p info -t busctl)
journalctl --sync
@ -298,7 +298,7 @@ assert_timesyncd_signal() {
local timestamp="${1:?}"
local property="${2:?}"
local value="${3:?}"
local args=(-q --since="$timestamp" -p info _SYSTEMD_UNIT="busctl-monitor.service")
local args=(-q --since="$timestamp" -p info -t busctl)
journalctl --sync

View File

@ -231,8 +231,8 @@ testcase_nvme_subsystem() {
/dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_deadbeef_16
/dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_deadbeef_17
# Shared namespaces
/dev/disk/by-path/pci-*-nvme-16
/dev/disk/by-path/pci-*-nvme-17
/dev/disk/by-path/*pci*-nvme-16
/dev/disk/by-path/*pci*-nvme-17
)
udevadm wait --settle --timeout=30 "${expected_symlinks[@]}"