From 60f9c49b16b087d2d7d419ef3a9972a2193f794f Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 25 Nov 2023 20:22:24 +0100 Subject: [PATCH 1/5] test: remove the reboot counter just before spawning container/VM Doing that in test_run() is not enough, since it's called only once and spawns all QEMU/nspawn jobs. --- test/test-functions | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/test-functions b/test/test-functions index e2d3f109a21..b054892e172 100644 --- a/test/test-functions +++ b/test/test-functions @@ -472,6 +472,8 @@ run_qemu() { local CONSOLE=ttyS0 + # Reset the boot counter, if present + rm -f "${initdir:?}/var/tmp/.systemd_reboot_count" rm -f "$initdir"/{testok,failed,skipped} # make sure the initdir is not mounted to avoid concurrent access cleanup_initdir @@ -645,6 +647,8 @@ run_qemu() { # success), or 1 if nspawn is not available. run_nspawn() { [[ -d /run/systemd/system ]] || return 1 + # Reset the boot counter, if present + rm -f "${initdir:?}/var/tmp/.systemd_reboot_count" rm -f "${initdir:?}"/{testok,failed,skipped} local nspawn_cmd=() @@ -3356,9 +3360,6 @@ test_run() { local test_id="${1:?}" mount_initdir - # Reset the boot counter, if present - rm -f "${initdir:?}/var/tmp/.systemd_reboot_count" - if ! get_bool "${TEST_NO_QEMU:=}"; then if run_qemu "$test_id"; then check_result_qemu || { echo "qemu test failed"; return 1; } From a986de6899e218a838c6dff93b8ebacb36d1ddf5 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 25 Nov 2023 20:42:13 +0100 Subject: [PATCH 2/5] import: append % to X_IMPORT_PROGRESS= Since we parse it on the other side via parse_percent() which requires that, otherwise we get an error: [ 8.133131] testsuite-13.sh[649]: + machinectl import-raw /tmp/container.raw container-raw [ 8.175035] machinectl[1143]: Enqueued transfer job 1. Press C-c to continue download in background. [ 8.182130] machinectl[1143]: Importing '/tmp/container.raw', saving as 'container-raw'. [ 8.182377] systemd-importd[1144]: Got invalid percent value '0', ignoring. [ 8.182451] machinectl[1143]: Imported 0%. [ 8.282669] systemd-importd[1144]: Got invalid percent value '40', ignoring. [ 8.282746] machinectl[1143]: Imported 40%. [ 8.366448] machinectl[1143]: Wrote 64.0M. [ 8.366519] machinectl[1143]: Operation completed successfully. [ 8.366617] machinectl[1143]: Exiting. --- src/import/export-raw.c | 2 +- src/import/export-tar.c | 2 +- src/import/import-raw.c | 2 +- src/import/import-tar.c | 2 +- src/import/importd.c | 2 +- src/import/pull-raw.c | 2 +- src/import/pull-tar.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/import/export-raw.c b/src/import/export-raw.c index 5c9c2bbcd94..f4253962615 100644 --- a/src/import/export-raw.c +++ b/src/import/export-raw.c @@ -120,7 +120,7 @@ static void raw_export_report_progress(RawExport *e) { if (!ratelimit_below(&e->progress_ratelimit)) return; - sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent); + sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent); log_info("Exported %u%%.", percent); e->last_percent = percent; diff --git a/src/import/export-tar.c b/src/import/export-tar.c index 2f54cd81148..9e92badfef3 100644 --- a/src/import/export-tar.c +++ b/src/import/export-tar.c @@ -131,7 +131,7 @@ static void tar_export_report_progress(TarExport *e) { if (!ratelimit_below(&e->progress_ratelimit)) return; - sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent); + sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent); log_info("Exported %u%%.", percent); e->last_percent = percent; diff --git a/src/import/import-raw.c b/src/import/import-raw.c index 2db3198ba61..f7ed163d864 100644 --- a/src/import/import-raw.c +++ b/src/import/import-raw.c @@ -147,7 +147,7 @@ static void raw_import_report_progress(RawImport *i) { if (!ratelimit_below(&i->progress_ratelimit)) return; - sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent); + sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent); log_info("Imported %u%%.", percent); i->last_percent = percent; diff --git a/src/import/import-tar.c b/src/import/import-tar.c index 8c184578169..90202709ecc 100644 --- a/src/import/import-tar.c +++ b/src/import/import-tar.c @@ -148,7 +148,7 @@ static void tar_import_report_progress(TarImport *i) { if (!ratelimit_below(&i->progress_ratelimit)) return; - sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent); + sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent); log_info("Imported %u%%.", percent); i->last_percent = percent; diff --git a/src/import/importd.c b/src/import/importd.c index cb5156bf063..e1a1ddc2ee1 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -598,7 +598,7 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void r = parse_percent(p); if (r < 0) { - log_warning("Got invalid percent value, ignoring."); + log_warning("Got invalid percent value '%s', ignoring.", p); return 0; } diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c index e96be4dd7db..66c3f656656 100644 --- a/src/import/pull-raw.c +++ b/src/import/pull-raw.c @@ -232,7 +232,7 @@ static void raw_pull_report_progress(RawPull *i, RawProgress p) { assert_not_reached(); } - sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent); + sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent); log_debug("Combined progress %u%%", percent); } diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c index 2db25192da1..c32fc290143 100644 --- a/src/import/pull-tar.c +++ b/src/import/pull-tar.c @@ -192,7 +192,7 @@ static void tar_pull_report_progress(TarPull *i, TarProgress p) { assert_not_reached(); } - sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent); + sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent); log_debug("Combined progress %u%%", percent); } From 538291b0d8dd157c66d9c340a18fceb57e8424d8 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 25 Nov 2023 21:36:10 +0100 Subject: [PATCH 3/5] systemctl: include unit ID in the property map Otherwise we get a not very nice message when trying to display a non-existent man page: ~# systemctl cat test.service [Unit] Description=Hello [Service] ExecStart=true ~# systemctl help test.service Documentation for (null) not known. --- src/systemctl/systemctl-show.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index 4ec2a7c9413..963ba69ab6e 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -1996,6 +1996,7 @@ static int show_one( bool *ellipsized) { static const struct bus_properties_map property_map[] = { + { "Id", "s", NULL, offsetof(UnitStatusInfo, id) }, { "LoadState", "s", NULL, offsetof(UnitStatusInfo, load_state) }, { "ActiveState", "s", NULL, offsetof(UnitStatusInfo, active_state) }, { "FreezerState", "s", NULL, offsetof(UnitStatusInfo, freezer_state) }, From d1ac1aa5ca8981e00ac97050c257ff5ee6665770 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 25 Nov 2023 21:59:57 +0100 Subject: [PATCH 4/5] test: drop invalid LogTarget= assignment It's been there since the test was introduced and I'm not really sure what was the original intention behind it, but it makes systemd sad: [ 4.909056] systemd[1]: /usr/lib/systemd/tests/testdata/units/testsuite-44.service:13: Unknown key name 'LogTarget' in section 'Service', ignoring. --- test/units/testsuite-44.service | 1 - 1 file changed, 1 deletion(-) diff --git a/test/units/testsuite-44.service b/test/units/testsuite-44.service index e0d4a8c18d0..4dffdeab94a 100644 --- a/test/units/testsuite-44.service +++ b/test/units/testsuite-44.service @@ -10,4 +10,3 @@ After=systemd-journald@foobar.socket systemd-journald-varlink@foobar.socket ExecStartPre=rm -f /failed /testok ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh Type=oneshot -LogTarget=foobar From 7a2d6c2d08ec1e1ebe1eeae46dad4c7e5e084eae Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 25 Nov 2023 22:30:01 +0100 Subject: [PATCH 5/5] test: drop 'noearly' from crypttab It's a Debian thing, we don't support it. [ 30.639971] testsuite-64.sh[475]: + systemctl restart cryptsetup.target [ 30.697667] systemd-cryptsetup[3389]: Encountered unknown /etc/crypttab option 'noearly', ignoring. [ 30.700529] systemd-cryptsetup[3390]: Encountered unknown /etc/crypttab option 'noearly', ignoring. [ 30.700594] systemd-cryptsetup[3391]: Encountered unknown /etc/crypttab option 'noearly', ignoring. [ 30.704638] systemd-cryptsetup[3392]: Encountered unknown /etc/crypttab option 'noearly', ignoring --- test/units/testsuite-64.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh index d223f52b6a2..81edb0ab7a1 100755 --- a/test/units/testsuite-64.sh +++ b/test/units/testsuite-64.sh @@ -756,7 +756,7 @@ EOF udevadm wait --settle --timeout=30 "/dev/disk/by-uuid/deadbeef-dead-dead-beef-11111111111$i" "/dev/disk/by-label/encdisk$i" # Add the device into /etc/crypttab, reload systemd, and then activate # the device so we can create a filesystem on it later - echo "encbtrfs$i UUID=deadbeef-dead-dead-beef-11111111111$i /etc/btrfs_keyfile luks,noearly" >>/etc/crypttab + echo "encbtrfs$i UUID=deadbeef-dead-dead-beef-11111111111$i /etc/btrfs_keyfile luks" >>/etc/crypttab systemctl daemon-reload systemctl start "systemd-cryptsetup@encbtrfs$i" done