Projects
openEuler:Mainline
systemd
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 10
View file
_service:tar_scm:systemd.spec
Changed
@@ -21,7 +21,7 @@ Name: systemd Url: https://www.freedesktop.org/wiki/Software/systemd Version: 253 -Release: 1 +Release: 3 License: MIT and LGPLv2+ and GPLv2+ Summary: System and Service Manager @@ -46,6 +46,65 @@ Source106: write_net_rules Source107: detect_virt +Patch6001: backport-Revert-sysctl.d-switch-net.ipv4.conf.all.rp_filter-f.patch +Patch6002: backport-Avoid-tmp-being-mounted-as-tmpfs-without-the-user-s-.patch +Patch6003: backport-temporarily-disable-test-seccomp.patch +Patch6004: backport-sd-event-always-initialize-sd_event.perturb.patch +Patch6005: backport-sd-event-fix-error-handling.patch +Patch6006: backport-core-refuse-dbus-activation-if-dbus-is-not-running.patch +Patch6007: backport-core-only-refuse-Type-dbus-service-enqueuing-if-dbus.patch + +Patch9008: update-rtc-with-system-clock-when-shutdown.patch +Patch9009: udev-add-actions-while-rename-netif-failed.patch +Patch9010: fix-two-VF-virtual-machines-have-same-mac-address.patch +Patch9011: logind-set-RemoveIPC-to-false-by-default.patch +Patch9012: rules-add-rule-for-naming-Dell-iDRAC-USB-Virtual-NIC.patch +Patch9013: unit-don-t-add-Requires-for-tmp.mount.patch +Patch9014: rules-add-elevator-kernel-command-line-parameter.patch +Patch9015: rules-add-the-rule-that-adds-elevator-kernel-command.patch +Patch9016: units-add-Install-section-to-tmp.mount.patch +Patch9017: Make-systemd-udevd.service-start-after-systemd-remou.patch +Patch9018: udev-virsh-shutdown-vm.patch +Patch9019: sd-bus-properly-initialize-containers.patch +Patch9020: Revert-core-one-step-back-again-for-nspawn-we-actual.patch +Patch9021: systemd-change-time-log-level.patch +Patch9022: fix-capsh-drop-but-ping-success.patch +Patch9023: resolved-create-etc-resolv.conf-symlink-at-runtime.patch +Patch9024: pid1-bump-DefaultTasksMax-to-80-of-the-kernel-pid.ma.patch +Patch9025: fix-journal-file-descriptors-leak-problems.patch +Patch9026: activation-service-must-be-restarted-when-reactivated.patch +Patch9027: systemd-core-fix-problem-of-dbus-service-can-not-be-started.patch +Patch9028: delay-to-restart-when-a-service-can-not-be-auto-restarted.patch +Patch9029: disable-initialize_clock.patch +Patch9030: systemd-solve-that-rsyslog-reads-journal-s-object-of.patch +Patch9031: check-whether-command_prev-is-null-before-assigning-.patch +Patch9032: revert-rpm-restart-services-in-posttrans.patch +Patch9033: Don-t-set-AlternativeNamesPolicy-by-default.patch +Patch9034: change-NTP-server-to-x.pool.ntp.org.patch +Patch9035: keep-weight-consistent-with-the-set-value.patch +Patch9036: Systemd-Add-sw64-architecture.patch +Patch9037: core-update-arg_default_rlimit-in-bump_rlimit.patch +Patch9038: set-forwardtowall-no-to-avoid-emerg-log-shown-on-she.patch +Patch9039: core-cgroup-support-cpuset.patch +Patch9040: core-cgroup-support-freezer.patch +Patch9041: core-cgroup-support-memorysw.patch +Patch9042: systemd-core-Add-new-rules-for-lower-priority-events.patch +Patch9043: bugfix-also-stop-machine-when-a-machine-un.patch +Patch9044: print-the-process-status-to-console-when-shutdown.patch +Patch9045: Retry-to-handle-the-uevent-when-worker-is-terminated.patch +Patch9046: treat-hyphen-as-valid-hostname-char.patch +Patch9047: process-util-log-more-information-when-runnin.patch +Patch9048: fuser-print-umount-message-to-reboot-umount-msg.patch +Patch9049: shutdown-reboot-when-recieve-crash-signal.patch +Patch9050: core-add-OptionalLog-to-allow-users-change-log-level.patch +Patch9051: core-cgroup-support-default-slice-for-all-uni.patch +Patch9052: core-add-invalidate-cgroup-config.patch +Patch9053: let-the-child-of-one-unit-don-t-affect-each-other.patch +Patch9054: support-disable-cgroup-controllers-we-don-t-want.patch +Patch9055: bugfix-for-cgroup-Swap-cgroup-v1-deletion-and-migration.patch +Patch9056: delete-journal-files-except-system.journal-when-jour.patch +Patch9057: set-the-cpuset.cpus-mems-of-machine.slice-to-all-by-.patch + BuildRequires: gcc, gcc-c++ BuildRequires: libcap-devel, libmount-devel, pam-devel, libselinux-devel BuildRequires: audit-libs-devel, dbus-devel, libacl-devel @@ -228,6 +287,9 @@ %prep %autosetup -n %{name}-%{version} -p1 -Sgit +%ifnarch sw_64 +%patch9029 -R -p1 +%endif %build @@ -420,9 +482,9 @@ fi fi done -# add rpath path /usr/lib/systemd in ld.so.conf.d +# add rpath path _libdir/systemd in ld.so.conf.d mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d -echo "/usr/lib/systemd" > %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf +echo "%{_libdir}/systemd" > %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf %check %ifnarch loongarch64 @@ -880,6 +942,8 @@ /usr/lib/sysusers.d/basic.conf /usr/lib/sysusers.d/systemd-coredump.conf /usr/lib/sysusers.d/systemd-journal.conf +/usr/lib/systemd/system/hwclock-save.service +/usr/lib/systemd/system/sysinit.target.wants/hwclock-save.service %{_systemddir}/systemd-update-done %{_systemddir}/systemd-update-utmp %{_systemddir}/systemd-initctl @@ -905,8 +969,8 @@ %dir %{_systemddir}/system-preset %dir %{_systemddir}/user-environment-generators %{_systemddir}/systemd-shutdown -/usr/lib64/systemd/libsystemd-core-*.so -/usr/lib64/systemd/libsystemd-shared*.so +%{_libdir}/systemd/libsystemd-core-*.so +%{_libdir}/systemd/libsystemd-shared*.so %{_systemddir}/systemd-reply-password %dir %{_systemddir}/system-generators %dir %{_systemddir}/system @@ -1344,6 +1408,8 @@ %dir /usr/lib/udev/rules.d %{_udevrulesdir}/60-autosuspend.rules %{_udevrulesdir}/40-%{vendor}.rules +%{_udevrulesdir}/40-elevator.rules +%{_udevrulesdir}/73-idrac.rules %{_udevrulesdir}/60-block.rules %{_udevrulesdir}/60-input-id.rules %{_udevrulesdir}/71-seat.rules @@ -1498,6 +1564,12 @@ %{_libdir}/security/pam_systemd.so %changelog +* Mon Jul 31 2023 huyubiao <huyubiao@huawei.com> - 253-3 +- sync the patch from v249 + +* Sat Jul 29 2023 huyubiao <huyubiao@huawei.com> - 253-2 +- fix the dynamic library cannot be found + * Thu Jul 20 2023 huyubiao <huyubiao@huawei.com> - 253-1 - systemd update to v253
View file
_service:tar_scm:Don-t-set-AlternativeNamesPolicy-by-default.patch
Added
@@ -0,0 +1,26 @@ +From 1e3f74b7ca5ead53c10e5b37cf8660651f32d181 Mon Sep 17 00:00:00 2001 +From: xujing <xujing125@huawei.com> +Date: Thu, 11 Aug 2022 19:53:35 +0800 +Subject: PATCH Don't set AlternativeNamesPolicy by default + +When a network adapter is renamed, the altname of the network adapter may be +set based on AlternativeNamesPolicy. As a result, the network adapter name +fails to be restored. For example, after enp4s0 is renamed tmp, udev sets the +altname of tmp to enp4s0. If you want to restore tmp to enp4s0, it will fail. +--- + network/99-default.link | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/network/99-default.link b/network/99-default.link +index 31aee37..db48c4d 100644 +--- a/network/99-default.link ++++ b/network/99-default.link +@@ -12,5 +12,4 @@ OriginalName=* + + Link + NamePolicy=keep kernel database onboard slot path +-AlternativeNamesPolicy=database onboard slot path + MACAddressPolicy=none +-- +2.23.0 +
View file
_service:tar_scm:Make-systemd-udevd.service-start-after-systemd-remou.patch
Added
@@ -0,0 +1,24 @@ +From 4c230d1d73e9f9a6d1fe654599a63881c344a00c Mon Sep 17 00:00:00 2001 +From: openEuler Buildteam <buildteam@openeuler.org> +Date: Tue, 29 Jan 2019 22:54:34 -0500 +Subject: PATCH Make systemd-udevd.service start after systemd-remount-fs.service. +--- + units/systemd-udevd.service.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/units/systemd-udevd.service.in b/units/systemd-udevd.service.in +index 9ada3a6a74..17f15bba83 100644 +--- a/units/systemd-udevd.service.in ++++ b/units/systemd-udevd.service.in +@@ -11,7 +11,7 @@ + Description=Rule-based Manager for Device Events and Files + Documentation=man:systemd-udevd.service(8) man:udev(7) + DefaultDependencies=no +-After=systemd-sysusers.service systemd-hwdb-update.service ++After=systemd-sysusers.service systemd-hwdb-update.service systemd-remount-fs.service + Before=sysinit.target + ConditionPathIsReadWrite=/sys + +-- +2.23.0 +
View file
_service:tar_scm:Retry-to-handle-the-uevent-when-worker-is-terminated.patch
Added
@@ -0,0 +1,87 @@ +From a3d2f4261ef9a953904e3e21abafba0dad7daa77 Mon Sep 17 00:00:00 2001 +From: gaoyi <gaoyi15@huawei.com> +Date: Mon, 28 Sep 2020 22:36:37 +0800 +Subject: PATCH Retry to handle the uevent when worker is terminated abnormal + +When processing uevent events fails, retry it. +--- + src/udev/udevd.c | 35 +++++++++++++++++++++++++++++++++-- + 1 file changed, 33 insertions(+), 2 deletions(-) + +diff --git a/src/udev/udevd.c b/src/udev/udevd.c +index c6d24d9..512192e 100644 +--- a/src/udev/udevd.c ++++ b/src/udev/udevd.c +@@ -74,6 +74,7 @@ + #include "version.h" + + #define WORKER_NUM_MAX 2048U ++#define UEVENT_MAX_RETRY_TIMES 3 + #define EVENT_RETRY_INTERVAL_USEC (200 * USEC_PER_MSEC) + #define EVENT_RETRY_TIMEOUT_USEC (3 * USEC_PER_MINUTE) + +@@ -129,6 +130,7 @@ typedef struct Event { + Manager *manager; + Worker *worker; + EventState state; ++ int retry; + + sd_device *dev; + +@@ -182,6 +184,32 @@ typedef enum EventResult { + _EVENT_RESULT_INVALID = -EINVAL, + } EventResult; + ++static bool event_retry(Event *event) { ++ if (!event) ++ return false; ++ ++ assert(event->manager); ++ ++ if (--event->retry < 0) { ++ log_device_error(event->dev, "Retry failed."); ++ return false; ++ } ++ ++ log_device_info(event->dev, "Retry %d times.", UEVENT_MAX_RETRY_TIMES - event->retry); ++ ++ event->timeout_warning_event = sd_event_source_unref(event->timeout_warning_event); ++ event->timeout_event = sd_event_source_unref(event->timeout_event); ++ ++ if (event->worker) { ++ event->worker->event = NULL; ++ event->worker = NULL; ++ } ++ ++ event->state = EVENT_QUEUED; ++ ++ return true; ++} ++ + static Event *event_free(Event *event) { + if (!event) + return NULL; +@@ -1140,6 +1168,7 @@ static int event_queue_insert(Manager *manager, sd_device *dev) { + .devpath_old = devpath_old, + .devnode = devnode, + .state = EVENT_QUEUED, ++ .retry = UEVENT_MAX_RETRY_TIMES, + }; + + if (!manager->events) { +@@ -1513,8 +1542,10 @@ static int on_sigchld(sd_event_source *s, const siginfo_t *si, void *userdata) { + device_delete_db(dev); + device_tag_index(dev, NULL, false); + +- /* Forward kernel event to libudev listeners */ +- device_broadcast(manager->monitor, dev, result); ++ if (event_retry(worker->event) == false) { ++ /* Forward kernel event to libudev listeners */ ++ device_broadcast(manager->monitor, worker->event->dev, result); ++ } + } + + worker_free(worker); +-- +2.33.0 +
View file
_service:tar_scm:Revert-core-one-step-back-again-for-nspawn-we-actual.patch
Added
@@ -0,0 +1,43 @@ +From 9d0046ceca10911361137d6496987cb15ffff132 Mon Sep 17 00:00:00 2001 +From: Lukas Nykryn <lnykryn@redhat.com> +Date: Thu, 25 Jun 2015 09:20:59 +0200 +Subject: PATCH Revert "core: one step back again, for nspawn we + actually can't wait for cgroups running empty since systemd will get exactly + zero notifications about it" + +This reverts commit 743970d2ea6d08aa7c7bff8220f6b7702f2b1db7. + +https://bugzilla.redhat.com/show_bug.cgi?id=1141137 +https://github.com/systemd/systemd/pull/350 + +Resolves: #1703485 + +--- + src/core/unit.c | 11 +---------- + 1 file changed, 1 insertion(+), 10 deletions(-) + +diff --git a/src/core/unit.c b/src/core/unit.c +index 1cadcd4..10e314f 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -4799,16 +4799,7 @@ int unit_kill_context( + + } else if (r > 0) { + +- /* FIXME: For now, on the legacy hierarchy, we will not wait for the cgroup members to die if +- * we are running in a container or if this is a delegation unit, simply because cgroup +- * notification is unreliable in these cases. It doesn't work at all in containers, and outside +- * of containers it can be confused easily by left-over directories in the cgroup — which +- * however should not exist in non-delegated units. On the unified hierarchy that's different, +- * there we get proper events. Hence rely on them. */ +- +- if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) > 0 || +- (detect_container() == 0 && !unit_cgroup_delegate(u))) +- wait_for_exit = true; ++ wait_for_exit = true; + + if (send_sighup) { + set_free(pid_set); +-- +2.19.1 +
View file
_service:tar_scm:Systemd-Add-sw64-architecture.patch
Added
@@ -0,0 +1,864 @@ +From b9043cf1d074497cf77272dd9bf24c2098e56265 Mon Sep 17 00:00:00 2001 +From: rpm-build <rpm-build> +Date: Tue, 25 Oct 2022 15:26:32 +0800 +Subject: PATCH Systemd Add sw64 architecture + +Signed-off-by: rpm-build <rpm-build> +--- + src/basic/architecture.c | 4 + + src/basic/architecture.h | 4 + + src/basic/meson.build | 1 + + src/basic/missing_fcntl.h | 2 + + src/basic/missing_syscall_def.h | 33 ++ + src/basic/missing_syscalls.py | 2 + + src/basic/syscalls-sw_64.txt | 600 ++++++++++++++++++++++++++++++++ + 7 files changed, 646 insertions(+) + create mode 100644 src/basic/syscalls-sw_64.txt + +diff --git a/src/basic/architecture.c b/src/basic/architecture.c +index 773ee3c..59a4e31 100644 +--- a/src/basic/architecture.c ++++ b/src/basic/architecture.c +@@ -49,6 +49,9 @@ Architecture uname_architecture(void) { + #elif defined(__alpha__) + { "alpha" , ARCHITECTURE_ALPHA }, + ++#elif defined(__sw_64__) ++ { "sw_64" , ARCHITECTURE_SW_64 }, ++ + #elif defined(__arc__) + { "arc", ARCHITECTURE_ARC }, + { "arceb", ARCHITECTURE_ARC_BE }, +@@ -145,6 +148,7 @@ static const char *const architecture_table_ARCHITECTURE_MAX = { + ARCHITECTURE_ARM = "arm", + ARCHITECTURE_ARM_BE = "arm-be", + ARCHITECTURE_ALPHA = "alpha", ++ ARCHITECTURE_SW_64 = "sw_64", + ARCHITECTURE_ARC = "arc", + ARCHITECTURE_ARC_BE = "arc-be", + ARCHITECTURE_CRIS = "cris", +diff --git a/src/basic/architecture.h b/src/basic/architecture.h +index 096526a..4c4be03 100644 +--- a/src/basic/architecture.h ++++ b/src/basic/architecture.h +@@ -11,6 +11,7 @@ + + typedef enum { + ARCHITECTURE_ALPHA, ++ ARCHITECTURE_SW_64, + ARCHITECTURE_ARC, + ARCHITECTURE_ARC_BE, + ARCHITECTURE_ARM, +@@ -142,6 +143,9 @@ Architecture uname_architecture(void); + #elif defined(__alpha__) + # define native_architecture() ARCHITECTURE_ALPHA + # define LIB_ARCH_TUPLE "alpha-linux-gnu" ++#elif defined(__sw_64__) ++# define native_architecture() ARCHITECTURE_SW_64 ++# define LIB_ARCH_TUPLE "sw_64-linux-gnu" + #elif defined(__aarch64__) + # if __BYTE_ORDER == __BIG_ENDIAN + # define native_architecture() ARCHITECTURE_ARM64_BE +diff --git a/src/basic/meson.build b/src/basic/meson.build +index 7aae031..f0a0282 100644 +--- a/src/basic/meson.build ++++ b/src/basic/meson.build +@@ -177,6 +177,7 @@ basic_sources += generated_gperf_headers + + arch_list = + 'alpha', ++ 'sw_64', + 'arc', + 'arm', + 'arm64', +diff --git a/src/basic/missing_fcntl.h b/src/basic/missing_fcntl.h +index 00937d2..fff662b 100644 +--- a/src/basic/missing_fcntl.h ++++ b/src/basic/missing_fcntl.h +@@ -45,6 +45,8 @@ + #ifndef __O_TMPFILE + #if defined(__alpha__) + #define __O_TMPFILE 0100000000 ++#elif defined(__sw_64__) ++#define __O_TMPFILE 0100000000 + #elif defined(__parisc__) || defined(__hppa__) + #define __O_TMPFILE 0400000000 + #elif defined(__sparc__) || defined(__sparc64__) +diff --git a/src/basic/missing_syscall_def.h b/src/basic/missing_syscall_def.h +index 402fdd0..9680923 100644 +--- a/src/basic/missing_syscall_def.h ++++ b/src/basic/missing_syscall_def.h +@@ -10,6 +10,7 @@ + * template as the per-syscall blocks below. */ + # if defined(__aarch64__) + # elif defined(__alpha__) ++# elif defined(__sw_64__) + # elif defined(__arc__) || defined(__tilegx__) + # elif defined(__arm__) + # elif defined(__i386__) +@@ -47,6 +48,8 @@ + # define systemd_NR_bpf 280 + # elif defined(__alpha__) + # define systemd_NR_bpf 515 ++# elif defined(__sw_64__) ++# define systemd_NR_bpf 170 + # elif defined(__arc__) || defined(__tilegx__) + # define systemd_NR_bpf 280 + # elif defined(__arm__) +@@ -115,6 +118,8 @@ assert_cc(__NR_bpf == systemd_NR_bpf); + # define systemd_NR_close_range 436 + # elif defined(__alpha__) + # define systemd_NR_close_range 546 ++# elif defined(__sw_64__) ++# define systemd_NR_close_range 283 + # elif defined(__arc__) || defined(__tilegx__) + # define systemd_NR_close_range 436 + # elif defined(__arm__) +@@ -183,6 +188,8 @@ assert_cc(__NR_close_range == systemd_NR_close_range); + # define systemd_NR_copy_file_range 285 + # elif defined(__alpha__) + # define systemd_NR_copy_file_range 519 ++# elif defined(__sw_64__) ++# define systemd_NR_copy_file_range 515 + # elif defined(__arc__) || defined(__tilegx__) + # define systemd_NR_copy_file_range 285 + # elif defined(__arm__) +@@ -251,6 +258,8 @@ assert_cc(__NR_copy_file_range == systemd_NR_copy_file_range); + # define systemd_NR_getrandom 278 + # elif defined(__alpha__) + # define systemd_NR_getrandom 511 ++# elif defined(__sw_64__) ++# define systemd_NR_getrandom 511 + # elif defined(__arc__) || defined(__tilegx__) + # define systemd_NR_getrandom 278 + # elif defined(__arm__) +@@ -319,6 +328,8 @@ assert_cc(__NR_getrandom == systemd_NR_getrandom); + # define systemd_NR_memfd_create 279 + # elif defined(__alpha__) + # define systemd_NR_memfd_create 512 ++# elif defined(__sw_64__) ++# define systemd_NR_memfd_create 512 + # elif defined(__arc__) || defined(__tilegx__) + # define systemd_NR_memfd_create 279 + # elif defined(__arm__) +@@ -387,6 +398,8 @@ assert_cc(__NR_memfd_create == systemd_NR_memfd_create); + # define systemd_NR_mount_setattr 442 + # elif defined(__alpha__) + # define systemd_NR_mount_setattr 552 ++# elif defined(__sw_64__) ++# define systemd_NR_mount_setattr 552 + # elif defined(__arc__) || defined(__tilegx__) + # define systemd_NR_mount_setattr 442 + # elif defined(__arm__) +@@ -455,6 +468,8 @@ assert_cc(__NR_mount_setattr == systemd_NR_mount_setattr); + # define systemd_NR_move_mount 429 + # elif defined(__alpha__) + # define systemd_NR_move_mount 539 ++# elif defined(__sw_64__) ++# define systemd_NR_move_mount 276 + # elif defined(__arc__) || defined(__tilegx__) + # define systemd_NR_move_mount 429 + # elif defined(__arm__) +@@ -523,6 +538,8 @@ assert_cc(__NR_move_mount == systemd_NR_move_mount); + # define systemd_NR_name_to_handle_at 264 + # elif defined(__alpha__) + # define systemd_NR_name_to_handle_at 497 ++# elif defined(__sw_64__) ++# define systemd_NR_name_to_handle_at 497 + # elif defined(__arc__) || defined(__tilegx__) + # define systemd_NR_name_to_handle_at 264 + # elif defined(__arm__) +@@ -591,6 +608,8 @@ assert_cc(__NR_name_to_handle_at == systemd_NR_name_to_handle_at); + # define systemd_NR_open_tree 428 + # elif defined(__alpha__) + # define systemd_NR_open_tree 538 ++# elif defined(__sw_64__) ++# define systemd_NR_open_tree 275 + # elif defined(__arc__) || defined(__tilegx__) + # define systemd_NR_open_tree 428 + # elif defined(__arm__) +@@ -659,6 +678,8 @@ assert_cc(__NR_open_tree == systemd_NR_open_tree); + # define systemd_NR_openat2 437 + # elif defined(__alpha__) + # define systemd_NR_openat2 547 ++# elif defined(__sw_64__) ++# define systemd_NR_openat2 284 + # elif defined(__arc__) || defined(__tilegx__) + # define systemd_NR_openat2 437 + # elif defined(__arm__) +@@ -727,6 +748,8 @@ assert_cc(__NR_openat2 == systemd_NR_openat2); + # define systemd_NR_pidfd_open 434 + # elif defined(__alpha__) + # define systemd_NR_pidfd_open 544 ++# elif defined(__sw_64__) ++# define systemd_NR_pidfd_open 281 + # elif defined(__arc__) || defined(__tilegx__) + # define systemd_NR_pidfd_open 434 + # elif defined(__arm__) +@@ -795,6 +818,8 @@ assert_cc(__NR_pidfd_open == systemd_NR_pidfd_open); + # define systemd_NR_pidfd_send_signal 424
View file
_service:tar_scm:activation-service-must-be-restarted-when-reactivated.patch
Added
@@ -0,0 +1,44 @@ +From 4acc8a3168e5f11b5308cf8558d68bf2a0503444 Mon Sep 17 00:00:00 2001 +From: huangkaibin <huangkaibin@huawei.com> +Date: Mon, 7 Aug 2017 17:06:30 +0800 +Subject: PATCH systemd: Activation service must be restarted when it is already started and re-actived +by dbus + +When dbus-daemon service is killed, every activation service must be restarted +to reestblished dbus connection between dbus-daemon and the service. +Otherwise, there will be problem on the dbus connection. This patch fix this +problem by set JobType to JOB_RESTART when it is re-actived in signal_activation_request function. +--- + src/core/dbus.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/src/core/dbus.c b/src/core/dbus.c +index 29524d4..38940ef 100644 +--- a/src/core/dbus.c ++++ b/src/core/dbus.c +@@ -152,6 +152,8 @@ static int signal_activation_request(sd_bus_message *message, void *userdata, sd + const char *name; + Unit *u; + int r; ++ int jobtype; ++ Service *s = NULL; + + assert(message); + +@@ -177,7 +179,13 @@ static int signal_activation_request(sd_bus_message *message, void *userdata, sd + goto failed; + } + +- r = manager_add_job(m, JOB_START, u, JOB_REPLACE, NULL, &error, NULL); ++ jobtype = JOB_START; ++ s = SERVICE(u); ++ if(s && s->state != SERVICE_DEAD) { ++ jobtype = JOB_RESTART; ++ log_unit_info(u, "Service '%s' will be restarted to activate the service. The current service state is %d.", u->id, s->state); ++ } ++ r = manager_add_job(m, jobtype, u, JOB_REPLACE, NULL, &error, NULL); + if (r < 0) + goto failed; + +-- +1.8.3.1
View file
_service:tar_scm:backport-Avoid-tmp-being-mounted-as-tmpfs-without-the-user-s-.patch
Added
@@ -0,0 +1,36 @@ +From f58c5ced373c2532b5cc44ba2e0c3a28b41472f2 Mon Sep 17 00:00:00 2001 +From: Jan Synacek <jsynacek@redhat.com> +Date: Tue, 15 May 2018 09:24:20 +0200 +Subject: PATCH Avoid /tmp being mounted as tmpfs without the user's + will + +Conflict:adapt context; modify unit_add_dependency_by_name para because of +35d8c19ace6; don't modify because we need tmp.mount to be started when +basic.target is started. +Reference:https://git.centos.org/rpms/systemd/blob/4b8c80a811af8258c136f5e7000fc0cd0adf8dc5/f/SOURCES/0004-Avoid-tmp-being-mounted-as-tmpfs-without-the-user-s-.patch + +Ensure PrivateTmp doesn't require tmpfs through tmp.mount, but rather +adds an After relationship. + +Resolves: #1578772 + +--- + src/core/unit.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/core/unit.c b/src/core/unit.c +index fd84818..e30c14b 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -1271,7 +1271,7 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) { + * tmp.mount so /tmp being masked is supported. However there's no reason to treat + * /tmp specifically and masking other mount units should be handled more + * gracefully too, see PR#16894. */ +- r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_WANTS, "tmp.mount", true, UNIT_DEPENDENCY_FILE); ++ r = unit_add_dependency_by_name(u, UNIT_AFTER, "tmp.mount", true, UNIT_DEPENDENCY_FILE); + if (r < 0) + return r; + +-- +2.23.0 +
View file
_service:tar_scm:backport-Revert-sysctl.d-switch-net.ipv4.conf.all.rp_filter-f.patch
Added
@@ -0,0 +1,35 @@ +From 47b256d63ac092137fe44e27560a14ee4aa5b7c8 Mon Sep 17 00:00:00 2001 +From: Lukas Nykryn <lnykryn@redhat.com> +Date: Fri, 8 Feb 2019 10:54:34 +0100 +Subject: Revert "sysctl.d: switch net.ipv4.conf.all.rp_filter + from 1 to 2" + +Conflict:according def94437934 and 5d4fc0e665a, modify default.rp_filter +and *.rp_filter +Reference:https://github.com/systemd/systemd/commit/230450d4e4f1f5fc9fa4295ed9185eea5b6ea16e + +This reverts commit 75c9af80cf3529c76988451e63f98010c86f48f1. + +Resolves: #1653824 +--- + sysctl.d/50-default.conf | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sysctl.d/50-default.conf b/sysctl.d/50-default.conf +index 1b76b9d..2717a4d 100644 +--- a/sysctl.d/50-default.conf ++++ b/sysctl.d/50-default.conf +@@ -26,8 +26,8 @@ kernel.core_uses_pid = 1 + kernel.core_uses_pid = 1 + + # Source route verification +-net.ipv4.conf.default.rp_filter = 2 +-net.ipv4.conf.*.rp_filter = 2 ++net.ipv4.conf.default.rp_filter = 1 ++net.ipv4.conf.*.rp_filter = 1 + -net.ipv4.conf.all.rp_filter + + # Do not accept source routing +-- +2.23.0 +
View file
_service:tar_scm:backport-core-only-refuse-Type-dbus-service-enqueuing-if-dbus.patch
Added
@@ -0,0 +1,83 @@ +From bee6e755bb8e53a7a436e221b015ce0232ed87c0 Mon Sep 17 00:00:00 2001 +From: Mike Yuan <me@yhndnzj.com> +Date: Wed, 10 May 2023 13:54:15 +0800 +Subject: PATCH core: only refuse Type=dbus service enqueuing if dbus has + stop job + +Follow-up for #27579 + +In #27579 we refused all StartUnit requests for Type=dbus units +if dbus is not running, which means if dbus is manually stopped, +user can't use systemctl to start Type=dbus units again, which +is incorrect. + +The only culprit that leads to the cancellation of the whole +transaction mentioned in #26799 is job type conflict on dbus. +So let's relax the restriction and only refuse job enqueuing +if dbus has a stop job. + +To summarize, the case we want to avoid is: + +1. dbus has a stop job installed +2. StartUnit/ActivationRequest is received +3. Type=dbus service gets started, which has Requires=dbus.socket +4. dbus is pulled in again, resulting in job type conflict + +What we can support is: + +1. dbus is already stopped +2. StartUnit is received (possibly through systemctl, i.e. on private bus) +3. Type=dbus service gets started, which will wait for dbus to start +4. dbus is started again, thus the job for Type=dbus service + +Replaces #27590 +Fixes #27588 +--- + src/core/dbus-unit.c | 31 ++++++++++++++++++++++++------- + 1 file changed, 24 insertions(+), 7 deletions(-) + +diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c +index 5b89c76586..59d541ebfe 100644 +--- a/src/core/dbus-unit.c ++++ b/src/core/dbus-unit.c +@@ -1875,13 +1875,30 @@ int bus_unit_queue_job( + (type == JOB_STOP && u->refuse_manual_stop) || + (IN_SET(type, JOB_RESTART, JOB_TRY_RESTART) && (u->refuse_manual_start || u->refuse_manual_stop)) || + (type == JOB_RELOAD_OR_START && job_type_collapse(type, u) == JOB_START && u->refuse_manual_start)) +- return sd_bus_error_setf(error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, unit %s may be requested by dependency only (it is configured to refuse manual start/stop).", u->id); +- +- /* dbus-broker issues StartUnit for activation requests, so let's apply the same check +- * used in signal_activation_request(). */ +- if (type == JOB_START && u->type == UNIT_SERVICE && +- SERVICE(u)->type == SERVICE_DBUS && !manager_dbus_is_running(u->manager)) +- return sd_bus_error_set(error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is not running."); ++ return sd_bus_error_setf(error, ++ BUS_ERROR_ONLY_BY_DEPENDENCY, ++ "Operation refused, unit %s may be requested by dependency only (it is configured to refuse manual start/stop).", ++ u->id); ++ ++ /* dbus-broker issues StartUnit for activation requests, and Type=dbus services automatically ++ * gain dependency on dbus.socket. Therefore, if dbus has a pending stop job, the new start ++ * job that pulls in dbus again would cause job type conflict. Let's avoid that by rejecting ++ * job enqueuing early. ++ * ++ * Note that unlike signal_activation_request(), we can't use unit_inactive_or_pending() ++ * here. StartUnit is a more generic interface, and thus users are allowed to use e.g. systemctl ++ * to start Type=dbus services even when dbus is inactive. */ ++ if (type == JOB_START && u->type == UNIT_SERVICE && SERVICE(u)->type == SERVICE_DBUS) ++ FOREACH_STRING(dbus_unit, SPECIAL_DBUS_SOCKET, SPECIAL_DBUS_SERVICE) { ++ Unit *dbus; ++ ++ dbus = manager_get_unit(u->manager, dbus_unit); ++ if (dbus && unit_stop_pending(dbus)) ++ return sd_bus_error_setf(error, ++ BUS_ERROR_SHUTTING_DOWN, ++ "Operation for unit %s refused, D-Bus is shutting down.", ++ u->id); ++ } + + r = sd_bus_message_new_method_return(message, &reply); + if (r < 0) +-- +2.33.0 +
View file
_service:tar_scm:backport-core-refuse-dbus-activation-if-dbus-is-not-running.patch
Added
@@ -0,0 +1,43 @@ +From 53964fd26b4a01191609ffc064aa8ccccd28e377 Mon Sep 17 00:00:00 2001 +From: Mike Yuan <me@yhndnzj.com> +Date: Tue, 9 May 2023 00:07:45 +0800 +Subject: PATCH core: refuse dbus activation if dbus is not running + +dbus-broker issues StartUnit directly for activation requests, +so let's add a check on bus state in bus_unit_queue_job to refuse +that if dbus is not running. + +Replaces #27570 +Closes #26799 +--- + src/core/dbus-unit.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c +index c42ae5e..295e271 100644 +--- a/src/core/dbus-unit.c ++++ b/src/core/dbus-unit.c +@@ -21,6 +21,7 @@ + #include "path-util.h" + #include "process-util.h" + #include "selinux-access.h" ++#include "service.h" + #include "signal-util.h" + #include "special.h" + #include "string-table.h" +@@ -1880,6 +1881,12 @@ int bus_unit_queue_job( + (type == JOB_RELOAD_OR_START && job_type_collapse(type, u) == JOB_START && u->refuse_manual_start)) + return sd_bus_error_setf(error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, unit %s may be requested by dependency only (it is configured to refuse manual start/stop).", u->id); + ++ /* dbus-broker issues StartUnit for activation requests, so let's apply the same check ++ * used in signal_activation_request(). */ ++ if (type == JOB_START && u->type == UNIT_SERVICE && ++ SERVICE(u)->type == SERVICE_DBUS && !manager_dbus_is_running(u->manager)) ++ return sd_bus_error_set(error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is not running."); ++ + r = sd_bus_message_new_method_return(message, &reply); + if (r < 0) + return r; +-- +2.33.0 +
View file
_service:tar_scm:backport-sd-event-always-initialize-sd_event.perturb.patch
Added
@@ -0,0 +1,59 @@ +From f1a8b69808777aff37c036fd94a0275873d12407 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe <watanabe.yu+github@gmail.com> +Date: Thu, 23 Feb 2023 07:31:01 +0900 +Subject: PATCH sd-event: always initialize sd_event.perturb + +If the boot ID cannot be obtained, let's first fallback to the machine +ID, and if still cannot, then let's use 0. +Otherwise, no timer event source cannot be triggered. + +Fixes #26549. + +(cherry picked from commit 6d2326e036ceed30f9ccdb0266713c10a44dcf6c) +(cherry picked from commit 58c821af607b61738b7b72ad1452e70f648689a6) +(cherry picked from commit 78976199b2e016600c3f7cf8f39747c9ef6c853b) +(cherry picked from commit ac04d804c30f519918866fb4eeb3bc4a9cbadd43) +--- + src/libsystemd/sd-event/sd-event.c | 21 ++++++++++----------- + 1 file changed, 10 insertions(+), 11 deletions(-) + +diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c +index 89accdce00..37565b17be 100644 +--- a/src/libsystemd/sd-event/sd-event.c ++++ b/src/libsystemd/sd-event/sd-event.c +@@ -1126,22 +1126,21 @@ _public_ int sd_event_add_io( + } + + static void initialize_perturb(sd_event *e) { +- sd_id128_t bootid = {}; ++ sd_id128_t id = {}; + +- /* When we sleep for longer, we try to realign the wakeup to +- the same time within each minute/second/250ms, so that +- events all across the system can be coalesced into a single +- CPU wakeup. However, let's take some system-specific +- randomness for this value, so that in a network of systems +- with synced clocks timer events are distributed a +- bit. Here, we calculate a perturbation usec offset from the +- boot ID. */ ++ /* When we sleep for longer, we try to realign the wakeup to the same time within each ++ * minute/second/250ms, so that events all across the system can be coalesced into a single CPU ++ * wakeup. However, let's take some system-specific randomness for this value, so that in a network ++ * of systems with synced clocks timer events are distributed a bit. Here, we calculate a ++ * perturbation usec offset from the boot ID (or machine ID if failed, e.g. /proc is not mounted). */ + + if (_likely_(e->perturb != USEC_INFINITY)) + return; + +- if (sd_id128_get_boot(&bootid) >= 0) +- e->perturb = (bootid.qwords0 ^ bootid.qwords1) % USEC_PER_MINUTE; ++ if (sd_id128_get_boot(&id) >= 0 || sd_id128_get_machine(&id) > 0) ++ e->perturb = (id.qwords0 ^ id.qwords1) % USEC_PER_MINUTE; ++ else ++ e->perturb = 0; /* This is a super early process without /proc and /etc ?? */ + } + + static int event_setup_timer_fd( +-- +2.33.0 +
View file
_service:tar_scm:backport-sd-event-fix-error-handling.patch
Added
@@ -0,0 +1,31 @@ +From 056fbe84ef67168adcaf41baa37de1b712f6fb74 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe <watanabe.yu+github@gmail.com> +Date: Thu, 23 Feb 2023 07:31:01 +0900 +Subject: PATCH sd-event: fix error handling + +Follow-up for 6d2326e036ceed30f9ccdb0266713c10a44dcf6c. + +(cherry picked from commit 1912f790fee9e0182acd77b77496f500094a140d) +(cherry picked from commit a719c2ec2f410f8b979cec04dcdac9af470ee52b) +(cherry picked from commit dd6561ff3e12314d41954b7ea8e3627101931a18) +(cherry picked from commit 8be4af42044969bc268b32ffe9570cee733fecf6) +--- + src/libsystemd/sd-event/sd-event.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c +index 37565b17be..df4d9037ac 100644 +--- a/src/libsystemd/sd-event/sd-event.c ++++ b/src/libsystemd/sd-event/sd-event.c +@@ -1137,7 +1137,7 @@ static void initialize_perturb(sd_event *e) { + if (_likely_(e->perturb != USEC_INFINITY)) + return; + +- if (sd_id128_get_boot(&id) >= 0 || sd_id128_get_machine(&id) > 0) ++ if (sd_id128_get_boot(&id) >= 0 || sd_id128_get_machine(&id) >= 0) + e->perturb = (id.qwords0 ^ id.qwords1) % USEC_PER_MINUTE; + else + e->perturb = 0; /* This is a super early process without /proc and /etc ?? */ +-- +2.33.0 +
View file
_service:tar_scm:backport-temporarily-disable-test-seccomp.patch
Added
@@ -0,0 +1,24 @@ +From 03a991c00674787d649240adda11f2506f2fcedc Mon Sep 17 00:00:00 2001 +From: xujing <xujing99@huawei.com> +Date: Tue, 22 Feb 2022 20:33:40 +0800 +Subject: PATCH temporarily disable test-seccomp + +--- + src/test/test-seccomp.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c +index 2d06098..a95deb8 100644 +--- a/src/test/test-seccomp.c ++++ b/src/test/test-seccomp.c +@@ -1199,4 +1199,6 @@ TEST(restrict_suid_sgid) { + assert_se(wait_for_terminate_and_check("suidsgidseccomp", pid, WAIT_LOG) == EXIT_SUCCESS); + } + +-DEFINE_TEST_MAIN(LOG_DEBUG); ++int main(int argc, char *argv) { ++ return 77; ++} +-- +2.33.0 +
View file
_service:tar_scm:bugfix-also-stop-machine-when-a-machine-un.patch
Added
@@ -0,0 +1,145 @@ +From 89110c823f246d3d2c398652999826107da446bf Mon Sep 17 00:00:00 2001 +From: yangbin <robin.yb@huawei.com> +Date: Tue, 7 Apr 2020 12:01:39 +0800 +Subject: PATCH systemd-machined: Also stop machine when a machine unit is + active but the leader process is exited + +When a VM machine is created in a scenario as below, it will remain in systemd-machined even though it has already been terminated by libvirtd. +1. libvirtd sends a request to systemd-machined with the leader(the PID of the vm) to create a machine. +2. systemd-machined directs the request to systemd +3. systemd constructs a scope and creates cgroup for the machine. the scope unit is then added to job queue and will be started later. +4. the leader process(the PID of the vm) is terminated by libvirtd(due some reason) before the scope is started. +5. Since the scope unit is yet not started, systemd will not destroy the scope althrough it is noticed with the signal event. +6. systemd starts the scope, and now the scope and machine is in active but no leader process exist. +7. systemd-machined will not stop and destroy the machine, and remains in system until the scope is stopped by others or the OS is restarted. + +This patch fix this problem by ansering yes to stop machine in machine_check_gc +when the machine unit is active but the leader process has already exited. + +Change-Id: I80e3c32832f4ecf08b6cb149735978730ce1d1c0 +--- + src/machine/machine.c | 37 ++++++++++++++++++++++++++++++++++++- + src/machine/machined-dbus.c | 35 +++++++++++++++++++++++++++++++++++ + src/machine/machined.h | 1 + + 3 files changed, 72 insertions(+), 1 deletion(-) + +diff --git a/src/machine/machine.c b/src/machine/machine.c +index c08a645..02fd9f7 100644 +--- a/src/machine/machine.c ++++ b/src/machine/machine.c +@@ -32,6 +32,7 @@ + #include "tmpfile-util.h" + #include "unit-name.h" + #include "user-util.h" ++#include "cgroup-util.h" + + DEFINE_TRIVIAL_CLEANUP_FUNC(Machine*, machine_free); + +@@ -520,6 +521,40 @@ int machine_finalize(Machine *m) { + return 0; + } + ++static bool machine_validate_unit(Machine *m) { ++ int r; ++ _cleanup_free_ char *unit = NULL; ++ _cleanup_free_ char *cgroup = NULL; ++ ++ r = cg_pid_get_unit(m->leader, &unit); ++ if (!r && streq(m->unit, unit)) ++ return true; ++ ++ if (r == -ESRCH) { ++ /* the original leader may exit and be replaced with a new leader when qemu hotreplace is performed. ++ * so we don't return true here, otherwise the vm will be added to the gc list. ++ * */ ++ log_info("Machine unit is in active, but the leader process is exited. " ++ "machine: %s, leader: "PID_FMT", unit: %s.", m->name, m->leader, m->unit); ++ } else if (r) { ++ log_info_errno(r, "Can not get unit from cgroup. " ++ "machine: %s, leader: "PID_FMT", unit: %s, error: %m", m->name, m->leader, m->unit); ++ } else if (unit && !streq(m->unit, unit)) { ++ log_info("Machine unit name not match. " ++ "machine: %s, leader: "PID_FMT", machine unit: %s, real unit: %s", m->name, m->leader, m->unit, unit); ++ } ++ ++ r = manager_get_unit_cgroup_path(m->manager, m->unit, &cgroup); ++ if (!r && !isempty(cgroup) && cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, cgroup) > 0) { ++ log_info("Cgroup is empty in the machine unit. " ++ "machine: %s, leader: "PID_FMT", machine unit: %s.", m->name, m->leader, m->unit); ++ /*The vm will be added to gc list only when there is no any process in the scope*/ ++ return false; ++ } ++ ++ return true; ++} ++ + bool machine_may_gc(Machine *m, bool drop_not_started) { + assert(m); + +@@ -532,7 +567,7 @@ bool machine_may_gc(Machine *m, bool drop_not_started) { + if (m->scope_job && manager_job_is_active(m->manager, m->scope_job)) + return false; + +- if (m->unit && manager_unit_is_active(m->manager, m->unit)) ++ if (m->unit && manager_unit_is_active(m->manager, m->unit) && machine_validate_unit(m)) + return false; + + return true; +diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c +index 0c157a9..10d370f 100644 +--- a/src/machine/machined-dbus.c ++++ b/src/machine/machined-dbus.c +@@ -1509,3 +1509,38 @@ int manager_add_machine(Manager *m, const char *name, Machine **_machine) { + + return 0; + } ++ ++int manager_get_unit_cgroup_path(Manager *manager, const char *unit, char **cgroup) { ++ _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; ++ _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; ++ _cleanup_free_ char *path = NULL; ++ const char *cgroup_path = NULL; ++ int r; ++ ++ assert(manager); ++ assert(unit); ++ ++ path = unit_dbus_path_from_name(unit); ++ if (!path) ++ return -ENOMEM; ++ ++ r = sd_bus_get_property( ++ manager->bus, ++ "org.freedesktop.systemd1", ++ path, ++ endswith(unit, ".scope") ? "org.freedesktop.systemd1.Scope" : "org.freedesktop.systemd1.Service", ++ "ControlGroup", ++ &error, ++ &reply, ++ "s"); ++ if (r < 0) { ++ return r; ++ } ++ ++ r = sd_bus_message_read(reply, "s", &cgroup_path); ++ if (r < 0) ++ return -EINVAL; ++ *cgroup = strdup(cgroup_path); ++ ++ return 0; ++} +diff --git a/src/machine/machined.h b/src/machine/machined.h +index 280c32b..6b8d98b 100644 +--- a/src/machine/machined.h ++++ b/src/machine/machined.h +@@ -58,6 +58,7 @@ int manager_kill_unit(Manager *manager, const char *unit, int signo, sd_bus_erro + int manager_unref_unit(Manager *m, const char *unit, sd_bus_error *error); + int manager_unit_is_active(Manager *manager, const char *unit); + int manager_job_is_active(Manager *manager, const char *path); ++int manager_get_unit_cgroup_path(Manager *manager, const char *unit, char **cgroup); + + #if ENABLE_NSCD + int manager_enqueue_nscd_cache_flush(Manager *m); +-- +2.33.0 +
View file
_service:tar_scm:bugfix-for-cgroup-Swap-cgroup-v1-deletion-and-migration.patch
Added
@@ -0,0 +1,40 @@ +From c003873099e47dccf2e57816291bd6b7de4a5790 Mon Sep 17 00:00:00 2001 +From: jiangchuangang <jiangchuangang@huawei.com> +Date: Wed, 13 Jul 2022 21:39:06 +0800 +Subject: PATCH bugfix for cpuset and Delegate + +--- + src/core/cgroup.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 0e4c94d..e887d49 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -1963,6 +1963,8 @@ static int unit_update_cgroup( + u->cgroup_enabled_mask = result_mask; + + migrate_mask = u->cgroup_realized_mask ^ target_mask; ++ if (u->type != UNIT_SLICE && FLAGS_SET(target_mask, CGROUP_MASK_CPUSET)) ++ migrate_mask |= CGROUP_MASK_CPUSET; + } + + /* Keep track that this is now realized */ +@@ -1977,9 +1979,11 @@ static int unit_update_cgroup( + * delegated units. + */ + if (cg_all_unified() == 0) { +- r = cg_migrate_v1_controllers(u->manager->cgroup_supported, migrate_mask, u->cgroup_path, migrate_callback, u); +- if (r < 0) +- log_unit_warning_errno(u, r, "Failed to migrate controller cgroups from %s, ignoring: %m", empty_to_root(u->cgroup_path)); ++ if (!unit_cgroup_delegate(u)) { ++ r = cg_migrate_v1_controllers(u->manager->cgroup_supported, migrate_mask, u->cgroup_path, migrate_callback, u); ++ if (r < 0) ++ log_unit_warning_errno(u, r, "Failed to migrate controller cgroups from %s, ignoring: %m", empty_to_root(u->cgroup_path)); ++ } + + is_root_slice = unit_has_name(u, SPECIAL_ROOT_SLICE); + r = cg_trim_v1_controllers(u->manager->cgroup_supported, ~target_mask, u->cgroup_path, !is_root_slice); +-- +2.33.0 +
View file
_service:tar_scm:change-NTP-server-to-x.pool.ntp.org.patch
Added
@@ -0,0 +1,25 @@ +From bdf0536bace233a0da7e1ff094c8cb81ded18c38 Mon Sep 17 00:00:00 2001 +From: licunlong <licunlong1@huawei.com> +Date: Tue, 23 Feb 2021 15:07:17 +0800 +Subject: PATCH change NTP server to x.pool.ntp.org + +--- + meson_options.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/meson_options.txt b/meson_options.txt +index 163c8df..ba7adf9 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -312,7 +312,7 @@ option('dns-servers', type : 'string', + value : '1.1.1.1#cloudflare-dns.com 8.8.8.8#dns.google 1.0.0.1#cloudflare-dns.com 8.8.4.4#dns.google 2606:4700:4700::1111#cloudflare-dns.com 2001:4860:4860::8888#dns.google 2606:4700:4700::1001#cloudflare-dns.com 2001:4860:4860::8844#dns.google') + option('ntp-servers', type : 'string', + description : 'space-separated list of default NTP servers', +- value : 'time1.google.com time2.google.com time3.google.com time4.google.com') ++ value : '0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org') + option('support-url', type : 'string', + description : 'the support URL to show in catalog entries included in systemd', + value : 'https://lists.freedesktop.org/mailman/listinfo/systemd-devel') +-- +2.27.0 +
View file
_service:tar_scm:check-whether-command_prev-is-null-before-assigning-.patch
Added
@@ -0,0 +1,35 @@ +From 5fe226b4378a2466d906ae45b8544f1003e9885a Mon Sep 17 00:00:00 2001 +From: yefei25 <yefei25@huawei.com> +Date: Wed, 8 Apr 2020 23:10:58 -0400 +Subject: PATCH 1/2 check whether command_prev is null before assigning value + +--- + src/core/service.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/core/service.c b/src/core/service.c +index 9a26271f72..3c255b3bcc 100644 +--- a/src/core/service.c ++++ b/src/core/service.c +@@ -2569,12 +2569,16 @@ static unsigned service_exec_command_index(Unit *u, ServiceExecCommand id, ExecC + assert(s); + assert(id >= 0); + assert(id < _SERVICE_EXEC_COMMAND_MAX); +- ++ if (!current) ++ return 0; + const ExecCommand *first = s->exec_commandid; + + /* Figure out where we are in the list by walking back to the beginning */ +- for (const ExecCommand *c = current; c != first; c = c->command_prev) ++ for (const ExecCommand *c = current; c != first; c = c->command_prev) { + idx++; ++ if (!c->command_prev) ++ return idx; ++ } + + return idx; + } +-- +2.19.1 +
View file
_service:tar_scm:core-add-OptionalLog-to-allow-users-change-log-level.patch
Added
@@ -0,0 +1,144 @@ +From 637310cf1903f9072a391074a65855fc1c41ae2b Mon Sep 17 00:00:00 2001 +From: licunlong <licunlong1@huawei.com> +Date: Fri, 15 Apr 2022 09:28:15 +0800 +Subject: PATCH core: add OptionalLog to allow users change log level. +This adds log_optional* log_unit_optional* to log messages in LOG_INFO +or LOG_DEBUG. Set "OptionalLog=yes" to log in LOG_INFO. Defaults to no. + +--- + src/basic/log.h | 2 ++ + src/core/dbus-manager.c | 1 + + src/core/main.c | 4 ++++ + src/core/manager.h | 1 + + src/core/mount.c | 2 +- + src/core/system.conf.in | 1 + + src/core/unit.h | 2 ++ + 7 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/src/basic/log.h b/src/basic/log.h +index f73d4c4..d341681 100644 +--- a/src/basic/log.h ++++ b/src/basic/log.h +@@ -243,6 +243,7 @@ int log_emergency_level(void); + #define log_warning(...) log_full(LOG_WARNING, __VA_ARGS__) + #define log_error(...) log_full(LOG_ERR, __VA_ARGS__) + #define log_emergency(...) log_full(log_emergency_level(), __VA_ARGS__) ++#define log_optional(use_info, ...) log_full(((use_info) ? LOG_INFO : LOG_DEBUG), __VA_ARGS__) + + /* Logging triggered by an errno-like error */ + #define log_debug_errno(error, ...) log_full_errno(LOG_DEBUG, error, __VA_ARGS__) +@@ -251,6 +252,7 @@ int log_emergency_level(void); + #define log_warning_errno(error, ...) log_full_errno(LOG_WARNING, error, __VA_ARGS__) + #define log_error_errno(error, ...) log_full_errno(LOG_ERR, error, __VA_ARGS__) + #define log_emergency_errno(error, ...) log_full_errno(log_emergency_level(), error, __VA_ARGS__) ++#define log_optional_errno(error, use_info, ...) log_full_errno(((use_info) ? LOG_INFO : LOG_DEBUG), error, __VA_ARGS__) + + /* This logs at the specified level the first time it is called, and then + * logs at debug. If the specified level is debug, this logs only the first +diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c +index 7e57a32..9ca392b 100644 +--- a/src/core/dbus-manager.c ++++ b/src/core/dbus-manager.c +@@ -2870,6 +2870,7 @@ const sd_bus_vtable bus_manager_vtable = { + BUS_PROPERTY_DUAL_TIMESTAMP("InitRDUnitsLoadFinishTimestamp", offsetof(Manager, timestampsMANAGER_TIMESTAMP_INITRD_UNITS_LOAD_FINISH), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_WRITABLE_PROPERTY("LogLevel", "s", bus_property_get_log_level, property_set_log_level, 0, 0), + SD_BUS_WRITABLE_PROPERTY("LogTarget", "s", bus_property_get_log_target, property_set_log_target, 0, 0), ++ SD_BUS_PROPERTY("OptionalLog", "b", bus_property_get_bool, offsetof(Manager, optional_log), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("NNames", "u", property_get_hashmap_size, offsetof(Manager, units), 0), + SD_BUS_PROPERTY("NFailedUnits", "u", property_get_set_size, offsetof(Manager, failed_units), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), + SD_BUS_PROPERTY("NJobs", "u", property_get_hashmap_size, offsetof(Manager, jobs), 0), +diff --git a/src/core/main.c b/src/core/main.c +index eaae658..809ed76 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -119,6 +119,7 @@ static const char *arg_bus_introspect = NULL; + * defaults are assigned in reset_arguments() below. */ + static char *arg_default_unit; + static bool arg_system; ++static bool arg_optional_log; + bool arg_dump_core; + int arg_crash_chvt; + bool arg_crash_shell; +@@ -626,6 +627,7 @@ static int parse_config_file(void) { + { "Manager", "LogColor", config_parse_color, 0, NULL }, + { "Manager", "LogLocation", config_parse_location, 0, NULL }, + { "Manager", "LogTime", config_parse_time, 0, NULL }, ++ { "Manager", "OptionalLog", config_parse_bool, 0, &arg_optional_log }, + { "Manager", "DumpCore", config_parse_bool, 0, &arg_dump_core }, + { "Manager", "CrashChVT", /* legacy */ config_parse_crash_chvt, 0, &arg_crash_chvt }, + { "Manager", "CrashChangeVT", config_parse_crash_chvt, 0, &arg_crash_chvt }, +@@ -745,6 +747,7 @@ static void set_manager_defaults(Manager *m) { + * affect the manager itself, but are just what newly allocated units will have set if they haven't set + * anything else. (Also see set_manager_settings() for the settings that affect the manager's own behaviour) */ + ++ m->optional_log = arg_optional_log; + m->default_timer_accuracy_usec = arg_default_timer_accuracy_usec; + m->default_std_output = arg_default_std_output; + m->default_std_error = arg_default_std_error; +@@ -2423,6 +2426,7 @@ static void reset_arguments(void) { + + /* arg_system — ignore */ + ++ arg_optional_log = false; + arg_dump_core = true; + arg_crash_chvt = -1; + arg_crash_shell = false; +diff --git a/src/core/manager.h b/src/core/manager.h +index d3f6aa2..814421f 100644 +--- a/src/core/manager.h ++++ b/src/core/manager.h +@@ -385,6 +385,7 @@ struct Manager { + LogTarget original_log_target; + bool log_level_overridden; + bool log_target_overridden; ++ bool optional_log; + + struct rlimit *rlimit_RLIMIT_MAX; + +diff --git a/src/core/mount.c b/src/core/mount.c +index af0eae6..3751cb4 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -756,7 +756,7 @@ static void mount_set_state(Mount *m, MountState state) { + } + + if (state != old_state) +- log_unit_debug(UNIT(m), "Changed %s -> %s", mount_state_to_string(old_state), mount_state_to_string(state)); ++ log_unit_optional(UNIT(m), UNIT(m)->manager->optional_log, "Changed %s -> %s", mount_state_to_string(old_state), mount_state_to_string(state)); + + unit_notify(UNIT(m), state_translation_tableold_state, state_translation_tablestate, + m->reload_result == MOUNT_SUCCESS ? 0 : UNIT_NOTIFY_RELOAD_FAILURE); +diff --git a/src/core/system.conf.in b/src/core/system.conf.in +index 066a9a7..564d146 100644 +--- a/src/core/system.conf.in ++++ b/src/core/system.conf.in +@@ -20,6 +20,7 @@ + #LogColor=yes + #LogLocation=no + #LogTime=no ++#OptionalLog=no + #DumpCore=yes + #ShowStatus=yes + #CrashChangeVT=no +diff --git a/src/core/unit.h b/src/core/unit.h +index 58417eb..cc65d93 100644 +--- a/src/core/unit.h ++++ b/src/core/unit.h +@@ -1097,12 +1097,14 @@ Condition *unit_find_failed_condition(Unit *u); + #define log_unit_notice(unit, ...) log_unit_full(unit, LOG_NOTICE, __VA_ARGS__) + #define log_unit_warning(unit, ...) log_unit_full(unit, LOG_WARNING, __VA_ARGS__) + #define log_unit_error(unit, ...) log_unit_full(unit, LOG_ERR, __VA_ARGS__) ++#define log_unit_optional(unit, use_info, ...) log_unit_full(unit, ((use_info) ? LOG_INFO : LOG_DEBUG), __VA_ARGS__) + + #define log_unit_debug_errno(unit, error, ...) log_unit_full_errno(unit, LOG_DEBUG, error, __VA_ARGS__) + #define log_unit_info_errno(unit, error, ...) log_unit_full_errno(unit, LOG_INFO, error, __VA_ARGS__) + #define log_unit_notice_errno(unit, error, ...) log_unit_full_errno(unit, LOG_NOTICE, error, __VA_ARGS__) + #define log_unit_warning_errno(unit, error, ...) log_unit_full_errno(unit, LOG_WARNING, error, __VA_ARGS__) + #define log_unit_error_errno(unit, error, ...) log_unit_full_errno(unit, LOG_ERR, error, __VA_ARGS__) ++#define log_unit_optional_errno(unit, use_info, error, ...) log_unit_full_errno(unit, ((use_info) ? LOG_INFO : LOG_DEBUG), error, __VA_ARGS__) + + #if LOG_TRACE + # define log_unit_trace(...) log_unit_debug(__VA_ARGS__) +-- +2.33.0 +
View file
_service:tar_scm:core-add-invalidate-cgroup-config.patch
Added
@@ -0,0 +1,118 @@ +From d56b3978bbcd28246b3e3ce3f8c958ac95785dd7 Mon Sep 17 00:00:00 2001 +From: fangxiuning <fangxiuning@huawei.com> +Date: Wed, 22 Apr 2020 11:55:18 +0800 +Subject: + After systemd 239 version, a new feature is added to cgroups. +The processes started by users default to the cgroup group belonging +to user.slice, and the processes started by the system default to +system.slice. This is the direction of github systemd evolution. +However, there are still a large number of operations downstream +that systemd does not perceive to modify the cgroup group, +such as directly echo the process number to system.slice. + +For example: +1. sleep 1000 & +2. echo sleep pid > /sys/fs/cgroup/memory/system.slice/task +3. systemctl daemon-reload +4. cat /proc/sleep pid/cgroup +this kind of operation, systemd is not aware of it. +When systemctl disable service or systemctl daemon-reload operation +is executed, systemd will re-attach each process to its original +Under the group(user.slice). + +--- + src/core/main.c | 4 ++++ + src/core/manager.c | 1 + + src/core/manager.h | 1 + + src/core/system.conf.in | 1 + + src/core/unit-serialize.c | 2 +- + 5 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/src/core/main.c b/src/core/main.c +index 500691a..c6638a0 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -166,6 +166,7 @@ static bool arg_default_cpuset_accounting; + static bool arg_default_freezer_accounting; + static bool arg_default_tasks_accounting; + static TasksMax arg_default_tasks_max; ++static bool arg_default_invalidate_cgroup; + static sd_id128_t arg_machine_id; + static EmergencyAction arg_cad_burst_action; + static OOMPolicy arg_default_oom_policy; +@@ -692,6 +693,7 @@ static int parse_config_file(void) { + { "Manager", "DefaultFreezerAccounting", config_parse_bool, 0, &arg_default_freezer_accounting }, + { "Manager", "DefaultTasksAccounting", config_parse_bool, 0, &arg_default_tasks_accounting }, + { "Manager", "DefaultTasksMax", config_parse_tasks_max, 0, &arg_default_tasks_max }, ++ { "Manager", "DefaultInvalidateCgroup", config_parse_bool, 0, &arg_default_invalidate_cgroup }, + { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, arg_system, &arg_cad_burst_action }, + { "Manager", "DefaultOOMPolicy", config_parse_oom_policy, 0, &arg_default_oom_policy }, + { "Manager", "DefaultOOMScoreAdjust", config_parse_oom_score_adjust, 0, NULL }, +@@ -778,6 +780,7 @@ static void set_manager_defaults(Manager *m) { + m->default_freezer_accounting = arg_default_freezer_accounting; + m->default_tasks_accounting = arg_default_tasks_accounting; + m->default_tasks_max = arg_default_tasks_max; ++ m->default_invalidate_cgroup = arg_default_invalidate_cgroup; + m->default_oom_policy = arg_default_oom_policy; + m->default_oom_score_adjust_set = arg_default_oom_score_adjust_set; + m->default_oom_score_adjust = arg_default_oom_score_adjust; +@@ -2500,6 +2503,7 @@ static void reset_arguments(void) { + arg_default_freezer_accounting = false; + arg_default_tasks_accounting = true; + arg_default_tasks_max = DEFAULT_TASKS_MAX; ++ arg_default_invalidate_cgroup = true; + arg_machine_id = (sd_id128_t) {}; + arg_cad_burst_action = EMERGENCY_ACTION_REBOOT_FORCE; + arg_default_oom_policy = OOM_STOP; +diff --git a/src/core/manager.c b/src/core/manager.c +index 4fa20f8..1a5dcd8 100644 +--- a/src/core/manager.c ++++ b/src/core/manager.c +@@ -837,6 +837,7 @@ int manager_new(LookupScope scope, ManagerTestRunFlags test_run_flags, Manager * + .default_cpuset_accounting = false, + .default_tasks_accounting = true, + .default_tasks_max = TASKS_MAX_UNSET, ++ .default_invalidate_cgroup = true, + .default_timeout_start_usec = manager_default_timeout(scope == LOOKUP_SCOPE_SYSTEM), + .default_timeout_stop_usec = manager_default_timeout(scope == LOOKUP_SCOPE_SYSTEM), + .default_restart_usec = DEFAULT_RESTART_USEC, +diff --git a/src/core/manager.h b/src/core/manager.h +index 9e391b1..ea95efe 100644 +--- a/src/core/manager.h ++++ b/src/core/manager.h +@@ -377,6 +377,7 @@ struct Manager { + + TasksMax default_tasks_max; + usec_t default_timer_accuracy_usec; ++ bool default_invalidate_cgroup; + + OOMPolicy default_oom_policy; + int default_oom_score_adjust; +diff --git a/src/core/system.conf.in b/src/core/system.conf.in +index 564d146..11936cd 100644 +--- a/src/core/system.conf.in ++++ b/src/core/system.conf.in +@@ -76,6 +76,7 @@ DefaultLimitMEMLOCK=64M + #DefaultLimitNICE= + #DefaultLimitRTPRIO= + #DefaultLimitRTTIME= ++#DefaultInvalidateCgroup=yes + #DefaultOOMPolicy=stop + DefaultDFXReboot=yes + #DefaultSmackProcessLabel= +diff --git a/src/core/unit-serialize.c b/src/core/unit-serialize.c +index 21457dc..0398ec8 100644 +--- a/src/core/unit-serialize.c ++++ b/src/core/unit-serialize.c +@@ -548,7 +548,7 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) { + /* Let's make sure that everything that is deserialized also gets any potential new cgroup settings + * applied after we are done. For that we invalidate anything already realized, so that we can + * realize it again. */ +- if (u->cgroup_realized) { ++ if (u->cgroup_realized && u->manager->default_invalidate_cgroup) { + unit_invalidate_cgroup(u, _CGROUP_MASK_ALL); + unit_invalidate_cgroup_bpf(u); + } +-- +2.33.0 +
View file
_service:tar_scm:core-cgroup-support-cpuset.patch
Added
@@ -0,0 +1,845 @@ +From 2ea8175b3d8ec118fa0f42392485ce0f4308456a Mon Sep 17 00:00:00 2001 +From: licunlong <licunlong1@huawei.com> +Date: Thu, 6 May 2021 09:38:54 +0800 +Subject: PATCH core-cgroup: support cpuset + +This patch add support for cpuset subsystem. +--- + src/basic/cgroup-util.c | 3 +- + src/basic/cgroup-util.h | 10 +- + src/basic/string-util.c | 42 +++++++ + src/basic/string-util.h | 1 + + src/core/cgroup.c | 112 ++++++++++++++---- + src/core/cgroup.h | 14 ++- + src/core/dbus-cgroup.c | 60 ++++++++-- + src/core/dbus-manager.c | 1 + + src/core/load-fragment-gperf.gperf.in | 13 +- + src/core/load-fragment.c | 69 +++++++++++ + src/core/load-fragment.h | 1 + + src/core/main.c | 4 + + src/core/manager.c | 1 + + src/core/manager.h | 1 + + src/core/system.conf.in | 1 + + src/core/unit.c | 1 + + src/shared/bus-unit-util.c | 15 ++- + src/shared/cpu-set-util.c | 1 + + src/test/test-cgroup-mask.c | 5 +- + .../fuzz-unit-file/directives-all.service | 5 + + 20 files changed, 309 insertions(+), 51 deletions(-) + +diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c +index feda596..1bb07f7 100644 +--- a/src/basic/cgroup-util.c ++++ b/src/basic/cgroup-util.c +@@ -2248,12 +2248,13 @@ bool fd_is_cgroup_fs(int fd) { + static const char *const cgroup_controller_table_CGROUP_CONTROLLER_MAX = { + CGROUP_CONTROLLER_CPU = "cpu", + CGROUP_CONTROLLER_CPUACCT = "cpuacct", +- CGROUP_CONTROLLER_CPUSET = "cpuset", ++ CGROUP_CONTROLLER_CPUSET2 = "cpuset2", + CGROUP_CONTROLLER_IO = "io", + CGROUP_CONTROLLER_BLKIO = "blkio", + CGROUP_CONTROLLER_MEMORY = "memory", + CGROUP_CONTROLLER_DEVICES = "devices", + CGROUP_CONTROLLER_PIDS = "pids", ++ CGROUP_CONTROLLER_CPUSET = "cpuset", + CGROUP_CONTROLLER_BPF_FIREWALL = "bpf-firewall", + CGROUP_CONTROLLER_BPF_DEVICES = "bpf-devices", + CGROUP_CONTROLLER_BPF_FOREIGN = "bpf-foreign", +diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h +index b69f168..764d47a 100644 +--- a/src/basic/cgroup-util.h ++++ b/src/basic/cgroup-util.h +@@ -21,12 +21,13 @@ typedef enum CGroupController { + /* Original cgroup controllers */ + CGROUP_CONTROLLER_CPU, + CGROUP_CONTROLLER_CPUACCT, /* v1 only */ +- CGROUP_CONTROLLER_CPUSET, /* v2 only */ ++ CGROUP_CONTROLLER_CPUSET2, /* v2 only */ + CGROUP_CONTROLLER_IO, /* v2 only */ + CGROUP_CONTROLLER_BLKIO, /* v1 only */ + CGROUP_CONTROLLER_MEMORY, + CGROUP_CONTROLLER_DEVICES, /* v1 only */ + CGROUP_CONTROLLER_PIDS, ++ CGROUP_CONTROLLER_CPUSET, + + /* BPF-based pseudo-controllers, v2 only */ + CGROUP_CONTROLLER_BPF_FIREWALL, +@@ -48,12 +49,13 @@ typedef enum CGroupController { + typedef enum CGroupMask { + CGROUP_MASK_CPU = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPU), + CGROUP_MASK_CPUACCT = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPUACCT), +- CGROUP_MASK_CPUSET = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPUSET), ++ CGROUP_MASK_CPUSET2 = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPUSET2), + CGROUP_MASK_IO = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_IO), + CGROUP_MASK_BLKIO = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BLKIO), + CGROUP_MASK_MEMORY = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_MEMORY), + CGROUP_MASK_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_DEVICES), + CGROUP_MASK_PIDS = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_PIDS), ++ CGROUP_MASK_CPUSET = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPUSET), + CGROUP_MASK_BPF_FIREWALL = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_FIREWALL), + CGROUP_MASK_BPF_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_DEVICES), + CGROUP_MASK_BPF_FOREIGN = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_FOREIGN), +@@ -61,10 +63,10 @@ typedef enum CGroupMask { + CGROUP_MASK_BPF_RESTRICT_NETWORK_INTERFACES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_RESTRICT_NETWORK_INTERFACES), + + /* All real cgroup v1 controllers */ +- CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS, ++ CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_CPUSET|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS, + + /* All real cgroup v2 controllers */ +- CGROUP_MASK_V2 = CGROUP_MASK_CPU|CGROUP_MASK_CPUSET|CGROUP_MASK_IO|CGROUP_MASK_MEMORY|CGROUP_MASK_PIDS, ++ CGROUP_MASK_V2 = CGROUP_MASK_CPU|CGROUP_MASK_CPUSET2|CGROUP_MASK_IO|CGROUP_MASK_MEMORY|CGROUP_MASK_PIDS, + + /* All cgroup v2 BPF pseudo-controllers */ + CGROUP_MASK_BPF = CGROUP_MASK_BPF_FIREWALL|CGROUP_MASK_BPF_DEVICES|CGROUP_MASK_BPF_FOREIGN|CGROUP_MASK_BPF_SOCKET_BIND|CGROUP_MASK_BPF_RESTRICT_NETWORK_INTERFACES, +diff --git a/src/basic/string-util.c b/src/basic/string-util.c +index ad8c986..755ad11 100644 +--- a/src/basic/string-util.c ++++ b/src/basic/string-util.c +@@ -1159,6 +1159,48 @@ int string_contains_word_strv(const char *string, const char *separators, char * + return !!found; + } + ++int string_isvalid_interval(const char *instr) ++{ ++ const char *pstr = instr; /* tmp */ ++ const char *pstr_front = instr; /* front char */ ++ const char *pstr_behind = instr; /* behind char */ ++ ++ if (isempty(instr)) ++ { ++ return 1; ++ } ++ ++ while (*pstr != '\0') ++ { ++ /* behind */ ++ pstr_behind = pstr + 1; ++ ++ /* 0-3,4,6,7-10 */ ++ if (((*pstr < '0') || (*pstr > '9')) && ++ (*pstr != '-') && ++ (*pstr != ',')) ++ { ++ return 2; ++ } ++ ++ /* - , must is a num */ ++ if (('-' == *pstr) || (',' == *pstr)) ++ { ++ if ((*pstr_front < '0') || (*pstr_front > '9') || ++ (*pstr_behind < '0') || (*pstr_behind > '9')) ++ { ++ return 3; ++ } ++ } ++ ++ /* front */ ++ pstr_front = pstr; ++ pstr++; ++ } ++ ++ return 0; ++} ++ + bool streq_skip_trailing_chars(const char *s1, const char *s2, const char *ok) { + if (!s1 && !s2) + return true; +diff --git a/src/basic/string-util.h b/src/basic/string-util.h +index e0a47a2..b025c06 100644 +--- a/src/basic/string-util.h ++++ b/src/basic/string-util.h +@@ -235,6 +235,7 @@ static inline int string_contains_word(const char *string, const char *separator + return string_contains_word_strv(string, separators, STRV_MAKE(word), NULL); + } + ++int string_isvalid_interval(const char *instr); + bool streq_skip_trailing_chars(const char *s1, const char *s2, const char *ok); + + char *string_replace_char(char *str, char old_char, char new_char); +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index f6ae2ab..a6396e1 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -90,8 +90,8 @@ bool unit_has_startup_cgroup_constraints(Unit *u) { + return c->startup_cpu_shares != CGROUP_CPU_SHARES_INVALID || + c->startup_io_weight != CGROUP_WEIGHT_INVALID || + c->startup_blockio_weight != CGROUP_BLKIO_WEIGHT_INVALID || +- c->startup_cpuset_cpus.set || +- c->startup_cpuset_mems.set; ++ c->startup_cpuset_cpus2.set || ++ c->startup_cpuset_mems2.set; + } + + bool unit_has_host_root_cgroup(Unit *u) { +@@ -277,10 +277,16 @@ void cgroup_context_done(CGroupContext *c) { + + c->restrict_network_interfaces = set_free(c->restrict_network_interfaces); + +- cpu_set_reset(&c->cpuset_cpus); +- cpu_set_reset(&c->startup_cpuset_cpus); +- cpu_set_reset(&c->cpuset_mems); +- cpu_set_reset(&c->startup_cpuset_mems); ++ if (c->cpuset_cpus) ++ c->cpuset_cpus = mfree(c->cpuset_cpus); ++ ++ if (c->cpuset_mems) ++ c->cpuset_mems = mfree(c->cpuset_mems); ++ ++ cpu_set_reset(&c->cpuset_cpus2); ++ cpu_set_reset(&c->startup_cpuset_cpus2); ++ cpu_set_reset(&c->cpuset_mems2); ++ cpu_set_reset(&c->startup_cpuset_mems2); + } + + static int unit_get_kernel_memory_limit(Unit *u, const char *file, uint64_t *ret) { +@@ -415,7 +421,7 @@ static char *format_cgroup_memory_limit_comparison(char *buf, size_t l, Unit *u, + } +
View file
_service:tar_scm:core-cgroup-support-default-slice-for-all-uni.patch
Added
@@ -0,0 +1,217 @@ +From a25f206a49d8a3111ac42791b2eca8a3c9af4991 Mon Sep 17 00:00:00 2001 +From: licunlong <licunlong1@huawei.com> +Date: Thu, 6 May 2021 09:38:55 +0800 +Subject: PATCH core-cgroup: support default slice for all units. + +With this patch, users can specify a default slice for all units by +adding DefaultUnitSlice=xxx.slice in /etc/systemd/system.conf. +--- + src/core/main.c | 22 +++++++++++ + src/core/manager.h | 3 ++ + src/core/unit.c | 98 ++++++++++++++++++++++++++++++++++++++++++---- + 3 files changed, 115 insertions(+), 8 deletions(-) + +diff --git a/src/core/main.c b/src/core/main.c +index 809ed76..500691a 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -171,6 +171,7 @@ static EmergencyAction arg_cad_burst_action; + static OOMPolicy arg_default_oom_policy; + static CPUSet arg_cpu_affinity; + static NUMAPolicy arg_numa_policy; ++static char *arg_default_unit_slice = NULL; + static usec_t arg_clock_usec; + static void *arg_random_seed; + static size_t arg_random_seed_size; +@@ -694,6 +695,7 @@ static int parse_config_file(void) { + { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, arg_system, &arg_cad_burst_action }, + { "Manager", "DefaultOOMPolicy", config_parse_oom_policy, 0, &arg_default_oom_policy }, + { "Manager", "DefaultOOMScoreAdjust", config_parse_oom_score_adjust, 0, NULL }, ++ { "Manager", "DefaultUnitSlice", config_parse_string, 0, &arg_default_unit_slice }, + { "Manager", "ReloadLimitIntervalSec", config_parse_sec, 0, &arg_reload_limit_interval_sec }, + { "Manager", "ReloadLimitBurst", config_parse_unsigned, 0, &arg_reload_limit_burst }, + #if ENABLE_SMACK +@@ -786,6 +788,26 @@ static void set_manager_defaults(Manager *m) { + + (void) manager_default_environment(m); + (void) manager_transient_environment_add(m, arg_default_environment); ++ if (m->default_unit_slice) ++ { ++ free(m->default_unit_slice); ++ m->default_unit_slice = NULL; ++ } ++ ++ if (arg_default_unit_slice) ++ { ++ char *default_unit_slice_tmp = NULL; ++ ++ default_unit_slice_tmp = strdup(arg_default_unit_slice); ++ if (!default_unit_slice_tmp) ++ log_oom(); ++ ++ m->default_unit_slice = default_unit_slice_tmp; ++ ++ /* free */ ++ free(arg_default_unit_slice); ++ arg_default_unit_slice = NULL; ++ } + } + + static void set_manager_settings(Manager *m) { +diff --git a/src/core/manager.h b/src/core/manager.h +index 814421f..9e391b1 100644 +--- a/src/core/manager.h ++++ b/src/core/manager.h +@@ -22,6 +22,7 @@ typedef struct Unit Unit; + + /* Enforce upper limit how many names we allow */ + #define MANAGER_MAX_NAMES 131072 /* 128K */ ++#define DEFAULT_UNIT_NAME_LEN_MAX 32 + + typedef struct Manager Manager; + +@@ -455,6 +456,8 @@ struct Manager { + unsigned sigchldgen; + unsigned notifygen; + ++ char *default_unit_slice; ++ + VarlinkServer *varlink_server; + /* When we're a system manager, this object manages the subscription from systemd-oomd to PID1 that's + * used to report changes in ManagedOOM settings (systemd server - oomd client). When +diff --git a/src/core/unit.c b/src/core/unit.c +index eef05d0..cc74a43 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -3340,6 +3340,58 @@ int unit_set_slice(Unit *u, Unit *slice) { + return 1; + } + ++/* system-xxx.slice, xxx must be (a b c/A B C...and 0 1 2...) */ ++static bool slicename_is_valid(const char *slicename) { ++ const char *str_start = "system-"; ++ const char *str_end = ".slice"; ++ const char *str_tmp = NULL; ++ size_t len_in = 0; ++ size_t len_start = 0; ++ size_t len_end = 0; ++ size_t i = 0; ++ ++ if (isempty(slicename)) ++ return false; ++ ++ len_in = strlen(slicename); ++ len_start = strlen(str_start); ++ len_end = strlen(str_end); ++ ++ if (len_in > DEFAULT_UNIT_NAME_LEN_MAX) ++ return false; ++ ++ if (len_in <= len_start + len_end) ++ return false; ++ ++ /* system- */ ++ if (strncmp(slicename, str_start, len_start) != 0) ++ return false; ++ ++ str_tmp = slicename + len_start; ++ ++ len_in = strlen(str_tmp); ++ if (len_in <= len_end) ++ return false; ++ ++ /* .slice */ ++ if (!strneq(str_tmp + len_in - len_end, str_end, len_end)) ++ return false; ++ ++ /* a b c/A B C...and 0 1 2... */ ++ for (i = 0; i < (len_in - len_end); i++) { ++ char c = *(str_tmp + i); ++ ++ if ((c >= 'a' && c <= 'z') || ++ (c >= 'A' && c <= 'Z') || ++ (c >= '0' && c <= '9')) ++ continue; ++ else ++ return false; ++ } ++ ++ return true; ++} ++ + int unit_set_default_slice(Unit *u) { + const char *slice_name; + Unit *slice; +@@ -3353,6 +3405,20 @@ int unit_set_default_slice(Unit *u) { + if (UNIT_GET_SLICE(u)) + return 0; + ++ bool isdefaultslice = false; ++ char *default_unit_slice = u->manager->default_unit_slice; ++ ++ if (default_unit_slice) { ++ isdefaultslice = true; ++ ++ if (streq(default_unit_slice, SPECIAL_SYSTEM_SLICE)) ++ isdefaultslice = false; ++ else if (!slicename_is_valid(default_unit_slice)) { ++ log_error("default unit slice is error. slice name '%s' is invalid.", default_unit_slice); ++ isdefaultslice = false; ++ } ++ } ++ + if (u->instance) { + _cleanup_free_ char *prefix = NULL, *escaped = NULL; + +@@ -3370,24 +3436,40 @@ int unit_set_default_slice(Unit *u) { + if (!escaped) + return -ENOMEM; + +- if (MANAGER_IS_SYSTEM(u->manager)) +- slice_name = strjoina("system-", escaped, ".slice"); +- else ++ if (MANAGER_IS_SYSTEM(u->manager)) { ++ if (isdefaultslice) { ++ _cleanup_free_ char *default_unit_slice_tmp = NULL; ++ ++ default_unit_slice_tmp = strreplace(default_unit_slice, ".slice", "-"); ++ if (!default_unit_slice_tmp) ++ return -ENOMEM; ++ ++ slice_name = strjoina(default_unit_slice_tmp, escaped, ".slice"); ++ } else ++ slice_name = strjoina("system-", escaped, ".slice"); ++ } else + slice_name = strjoina("app-", escaped, ".slice"); + +- } else if (unit_is_extrinsic(u)) ++ } else if (unit_is_extrinsic(u)) { + /* Keep all extrinsic units (e.g. perpetual units and swap and mount units in user mode) in + * the root slice. They don't really belong in one of the subslices. */ + slice_name = SPECIAL_ROOT_SLICE; +- +- else if (MANAGER_IS_SYSTEM(u->manager)) +- slice_name = SPECIAL_SYSTEM_SLICE; +- else ++ isdefaultslice = false; ++ } else if (MANAGER_IS_SYSTEM(u->manager)) { ++ if (isdefaultslice) ++ slice_name = default_unit_slice;
View file
_service:tar_scm:core-cgroup-support-freezer.patch
Added
@@ -0,0 +1,506 @@ +From 05a0f33b0d0a650b25ce7955a171d725f9c3f5f6 Mon Sep 17 00:00:00 2001 +From: licunlong <licunlong1@huawei.com> +Date: Thu, 6 May 2021 09:38:54 +0800 +Subject: PATCH core-cgroup: support freezer. + +This patch add support for freezer subsystem. +--- + src/basic/cgroup-util.c | 1 + + src/basic/cgroup-util.h | 4 +- + src/core/cgroup.c | 16 +++++++ + src/core/cgroup.h | 4 ++ + src/core/dbus-cgroup.c | 29 +++++++++++++ + src/core/dbus-manager.c | 1 + + src/core/load-fragment-gperf.gperf.in | 2 + + src/core/load-fragment.c | 33 ++++++++++++++ + src/core/load-fragment.h | 1 + + src/core/main.c | 4 ++ + src/core/manager.h | 1 + + src/core/system.conf.in | 1 + + src/core/unit.c | 1 + + src/shared/bus-unit-util.c | 11 +++++ + src/test/meson.build | 6 +++ + src/test/test-cgroup-freezer.c | 43 +++++++++++++++++++ + src/test/test-cgroup-mask.c | 3 +- + .../fuzz-unit-file/directives-all.service | 2 + + 18 files changed, 161 insertions(+), 2 deletions(-) + create mode 100644 src/test/test-cgroup-freezer.c + +diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c +index 1bb07f7..ac25693 100644 +--- a/src/basic/cgroup-util.c ++++ b/src/basic/cgroup-util.c +@@ -2255,6 +2255,7 @@ static const char *const cgroup_controller_table_CGROUP_CONTROLLER_MAX = { + CGROUP_CONTROLLER_DEVICES = "devices", + CGROUP_CONTROLLER_PIDS = "pids", + CGROUP_CONTROLLER_CPUSET = "cpuset", ++ CGROUP_CONTROLLER_FREEZER = "freezer", + CGROUP_CONTROLLER_BPF_FIREWALL = "bpf-firewall", + CGROUP_CONTROLLER_BPF_DEVICES = "bpf-devices", + CGROUP_CONTROLLER_BPF_FOREIGN = "bpf-foreign", +diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h +index 764d47a..147c956 100644 +--- a/src/basic/cgroup-util.h ++++ b/src/basic/cgroup-util.h +@@ -28,6 +28,7 @@ typedef enum CGroupController { + CGROUP_CONTROLLER_DEVICES, /* v1 only */ + CGROUP_CONTROLLER_PIDS, + CGROUP_CONTROLLER_CPUSET, ++ CGROUP_CONTROLLER_FREEZER, + + /* BPF-based pseudo-controllers, v2 only */ + CGROUP_CONTROLLER_BPF_FIREWALL, +@@ -56,6 +57,7 @@ typedef enum CGroupMask { + CGROUP_MASK_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_DEVICES), + CGROUP_MASK_PIDS = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_PIDS), + CGROUP_MASK_CPUSET = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPUSET), ++ CGROUP_MASK_FREEZER = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_FREEZER), + CGROUP_MASK_BPF_FIREWALL = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_FIREWALL), + CGROUP_MASK_BPF_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_DEVICES), + CGROUP_MASK_BPF_FOREIGN = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_FOREIGN), +@@ -63,7 +65,7 @@ typedef enum CGroupMask { + CGROUP_MASK_BPF_RESTRICT_NETWORK_INTERFACES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_RESTRICT_NETWORK_INTERFACES), + + /* All real cgroup v1 controllers */ +- CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_CPUSET|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS, ++ CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_CPUSET|CGROUP_MASK_FREEZER|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS, + + /* All real cgroup v2 controllers */ + CGROUP_MASK_V2 = CGROUP_MASK_CPU|CGROUP_MASK_CPUSET2|CGROUP_MASK_IO|CGROUP_MASK_MEMORY|CGROUP_MASK_PIDS, +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index a6396e1..7d1e59b 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -162,6 +162,7 @@ void cgroup_context_init(CGroupContext *c) { + .startup_blockio_weight = CGROUP_BLKIO_WEIGHT_INVALID, + + .tasks_max = TASKS_MAX_UNSET, ++ .freezer_state = NULL, + + .moom_swap = MANAGED_OOM_AUTO, + .moom_mem_pressure = MANAGED_OOM_AUTO, +@@ -287,6 +288,9 @@ void cgroup_context_done(CGroupContext *c) { + cpu_set_reset(&c->startup_cpuset_cpus2); + cpu_set_reset(&c->cpuset_mems2); + cpu_set_reset(&c->startup_cpuset_mems2); ++ ++ if (c->freezer_state) ++ c->freezer_state = mfree(c->freezer_state); + } + + static int unit_get_kernel_memory_limit(Unit *u, const char *file, uint64_t *ret) { +@@ -451,6 +455,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { + "%sBlockIOAccounting: %s\n" + "%sMemoryAccounting: %s\n" + "%sCPUSetAccounting: %s\n" ++ "%sFreezerAccounting=%s\n" + "%sTasksAccounting: %s\n" + "%sIPAccounting: %s\n" + "%sCPUWeight: %" PRIu64 "\n" +@@ -481,6 +486,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { + "%sCPUSetCloneChildren=%s\n" + "%sCPUSetMemMigrate=%s\n" + "%sTasksMax: %" PRIu64 "\n" ++ "%sFreezerState=%s\n" + "%sDevicePolicy: %s\n" + "%sDisableControllers: %s\n" + "%sDelegate: %s\n" +@@ -493,6 +499,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { + prefix, yes_no(c->blockio_accounting), + prefix, yes_no(c->memory_accounting), + prefix, yes_no(c->cpuset_accounting), ++ prefix, yes_no(c->freezer_accounting), + prefix, yes_no(c->tasks_accounting), + prefix, yes_no(c->ip_accounting), + prefix, c->cpu_weight, +@@ -523,6 +530,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { + prefix, yes_no(c->cpuset_clone_children), + prefix, yes_no(c->cpuset_memory_migrate), + prefix, tasks_max_resolve(&c->tasks_max), ++ prefix, c->freezer_state, + prefix, cgroup_device_policy_to_string(c->device_policy), + prefix, strempty(disable_controllers_str), + prefix, yes_no(c->delegate), +@@ -1722,6 +1730,11 @@ static void cgroup_context_apply( + } + } + ++ if ((apply_mask & CGROUP_MASK_FREEZER) && !is_local_root) { ++ if (c->freezer_state) ++ (void) set_attribute_and_warn(u, "freezer", "freezer.state", c->freezer_state); ++ } ++ + /* On cgroup v2 we can apply BPF everywhere. On cgroup v1 we apply it everywhere except for the root of + * containers, where we leave this to the manager */ + if ((apply_mask & (CGROUP_MASK_DEVICES | CGROUP_MASK_BPF_DEVICES)) && +@@ -1878,6 +1891,9 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) { + c->cpuset_mems) + mask |= CGROUP_MASK_CPUSET; + ++ if (c->freezer_accounting || c->freezer_state) ++ mask |= CGROUP_MASK_FREEZER; ++ + if (c->device_allow || + c->device_policy != CGROUP_DEVICE_POLICY_AUTO) + mask |= CGROUP_MASK_DEVICES | CGROUP_MASK_BPF_DEVICES; +diff --git a/src/core/cgroup.h b/src/core/cgroup.h +index 501cba4..2251548 100644 +--- a/src/core/cgroup.h ++++ b/src/core/cgroup.h +@@ -116,6 +116,7 @@ struct CGroupContext { + bool blockio_accounting; + bool memory_accounting; + bool cpuset_accounting; ++ bool freezer_accounting; + bool tasks_accounting; + bool ip_accounting; + +@@ -196,6 +197,9 @@ struct CGroupContext { + /* Common */ + TasksMax tasks_max; + ++ /* Freezer */ ++ char *freezer_state; ++ + /* Settings for systemd-oomd */ + ManagedOOMMode moom_swap; + ManagedOOMMode moom_mem_pressure; +diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c +index c3b140e..c51a8b7 100644 +--- a/src/core/dbus-cgroup.c ++++ b/src/core/dbus-cgroup.c +@@ -475,6 +475,8 @@ const sd_bus_vtable bus_cgroup_vtable = { + SD_BUS_PROPERTY("CPUSetMems", "s", NULL, offsetof(CGroupContext, cpuset_mems), 0), + SD_BUS_PROPERTY("CPUSetCloneChildren", "b", bus_property_get_bool, offsetof(CGroupContext, cpuset_clone_children), 0), + SD_BUS_PROPERTY("CPUSetMemMigrate", "b", bus_property_get_bool, offsetof(CGroupContext, cpuset_memory_migrate), 0), ++ SD_BUS_PROPERTY("FreezerAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, freezer_accounting), 0), ++ SD_BUS_PROPERTY("FreezerState", "s", NULL, offsetof(CGroupContext, freezer_state), 0), + SD_BUS_PROPERTY("DevicePolicy", "s", property_get_cgroup_device_policy, offsetof(CGroupContext, device_policy), 0), + SD_BUS_PROPERTY("DeviceAllow", "a(ss)", property_get_device_allow, 0, 0), + SD_BUS_PROPERTY("TasksAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, tasks_accounting), 0), +@@ -1137,6 +1139,9 @@ int bus_cgroup_set_property( + if (streq(name, "CPUSetAccounting")) + return bus_cgroup_set_boolean(u, name, &c->cpuset_accounting, CGROUP_MASK_CPUSET, message, flags, error); + ++ if (streq(name, "FreezerAccounting")) ++ return bus_cgroup_set_boolean(u, name, &c->freezer_accounting, CGROUP_MASK_FREEZER, message, flags, error); ++ + if (STR_IN_SET(name, "CPUSetCpus", "CPUSetMems")) { + const char *cpuset_str = NULL; + +@@ -1171,6 +1176,30 @@ int bus_cgroup_set_property( + if (streq(name, "CPUSetMemMigrate")) + return bus_cgroup_set_boolean(u, name, &c->cpuset_memory_migrate, CGROUP_MASK_CPUSET, message, flags, error); + ++ if (streq(name, "FreezerState")) { ++ const char *state = NULL; ++ ++ r = sd_bus_message_read(message, "s", &state); ++ if (r < 0)
View file
_service:tar_scm:core-cgroup-support-memorysw.patch
Added
@@ -0,0 +1,186 @@ +From cfb8a3cf09d9a958388ca1181bb92d9f77ab100e Mon Sep 17 00:00:00 2001 +From: licunlong <licunlong1@huawei.com> +Date: Thu, 6 May 2021 09:38:54 +0800 +Subject: PATCH core-cgroup: support memorysw + +Upstream systemd dosen't support setting memory.memsw.limit_in_bytes. +This patch enables setting memory.memsw.limit_in_bytes by MemoryMemswLimit. +--- + src/core/cgroup.c | 17 +++++++++++++++-- + src/core/cgroup.h | 1 + + src/core/dbus-cgroup.c | 4 ++++ + src/core/load-fragment-gperf.gperf.in | 1 + + src/core/load-fragment.c | 10 ++++++---- + src/shared/bus-print-properties.c | 2 +- + src/shared/bus-unit-util.c | 1 + + test/fuzz/fuzz-unit-file/directives-all.service | 1 + + 8 files changed, 30 insertions(+), 7 deletions(-) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 7d1e59b..f827219 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -154,6 +154,7 @@ void cgroup_context_init(CGroupContext *c) { + .memory_zswap_max = CGROUP_LIMIT_MAX, + + .memory_limit = CGROUP_LIMIT_MAX, ++ .memory_memsw_limit = CGROUP_LIMIT_MAX, + + .io_weight = CGROUP_WEIGHT_INVALID, + .startup_io_weight = CGROUP_WEIGHT_INVALID, +@@ -481,6 +482,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { + "%sMemorySwapMax: %" PRIu64 "%s\n" + "%sMemoryZSwapMax: %" PRIu64 "%s\n" + "%sMemoryLimit: %" PRIu64 "\n" ++ "%sMemoryMemswLimit=%" PRIu64 "\n" + "%sCPUSetCpus=%s\n" + "%sCPUSetMems=%s\n" + "%sCPUSetCloneChildren=%s\n" +@@ -525,6 +527,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { + prefix, c->memory_swap_max, format_cgroup_memory_limit_comparison(cde, sizeof(cde), u, "MemorySwapMax"), + prefix, c->memory_zswap_max, format_cgroup_memory_limit_comparison(cde, sizeof(cde), u, "MemoryZSwapMax"), + prefix, c->memory_limit, ++ prefix, c->memory_memsw_limit, + prefix, c->cpuset_cpus, + prefix, c->cpuset_mems, + prefix, yes_no(c->cpuset_clone_children), +@@ -1673,14 +1676,17 @@ static void cgroup_context_apply( + + } else { + char bufDECIMAL_STR_MAX(uint64_t) + 1; +- uint64_t val; ++ uint64_t val, sw_val; + + if (unit_has_unified_memory_config(u)) { + val = c->memory_max; ++ sw_val = CGROUP_LIMIT_MAX; + if (val != CGROUP_LIMIT_MAX) + log_cgroup_compat(u, "Applying MemoryMax=%" PRIu64 " as MemoryLimit=", val); +- } else ++ } else { + val = c->memory_limit; ++ sw_val = c->memory_memsw_limit; ++ } + + if (val == CGROUP_LIMIT_MAX) + strncpy(buf, "-1\n", sizeof(buf)); +@@ -1688,6 +1694,12 @@ static void cgroup_context_apply( + xsprintf(buf, "%" PRIu64 "\n", val); + + (void) set_attribute_and_warn(u, "memory", "memory.limit_in_bytes", buf); ++ ++ if (sw_val == CGROUP_LIMIT_MAX) ++ strncpy(buf, "-1\n", sizeof(buf)); ++ else ++ xsprintf(buf, "%" PRIu64 "\n", sw_val); ++ (void) set_attribute_and_warn(u, "memory", "memory.memsw.limit_in_bytes", buf); + } + } + +@@ -1883,6 +1895,7 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) { + + if (c->memory_accounting || + c->memory_limit != CGROUP_LIMIT_MAX || ++ c->memory_memsw_limit != CGROUP_LIMIT_MAX || + unit_has_unified_memory_config(u)) + mask |= CGROUP_MASK_MEMORY; + +diff --git a/src/core/cgroup.h b/src/core/cgroup.h +index 2251548..313b63c 100644 +--- a/src/core/cgroup.h ++++ b/src/core/cgroup.h +@@ -187,6 +187,7 @@ struct CGroupContext { + LIST_HEAD(CGroupBlockIODeviceBandwidth, blockio_device_bandwidths); + + uint64_t memory_limit; ++ uint64_t memory_memsw_limit; + + CGroupDevicePolicy device_policy; + LIST_HEAD(CGroupDeviceAllow, device_allow); +diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c +index c51a8b7..e54657e 100644 +--- a/src/core/dbus-cgroup.c ++++ b/src/core/dbus-cgroup.c +@@ -470,6 +470,7 @@ const sd_bus_vtable bus_cgroup_vtable = { + SD_BUS_PROPERTY("MemorySwapMax", "t", NULL, offsetof(CGroupContext, memory_swap_max), 0), + SD_BUS_PROPERTY("MemoryZSwapMax", "t", NULL, offsetof(CGroupContext, memory_zswap_max), 0), + SD_BUS_PROPERTY("MemoryLimit", "t", NULL, offsetof(CGroupContext, memory_limit), 0), ++ SD_BUS_PROPERTY("MemoryMemswLimit", "t", NULL, offsetof(CGroupContext, memory_memsw_limit), 0), + SD_BUS_PROPERTY("CPUSetAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, cpuset_accounting), 0), + SD_BUS_PROPERTY("CPUSetCpus", "s", NULL, offsetof(CGroupContext, cpuset_cpus), 0), + SD_BUS_PROPERTY("CPUSetMems", "s", NULL, offsetof(CGroupContext, cpuset_mems), 0), +@@ -1093,6 +1094,9 @@ int bus_cgroup_set_property( + if (streq(name, "MemoryLimit")) + return bus_cgroup_set_memory(u, name, &c->memory_limit, message, flags, error); + ++ if (streq(name, "MemoryMemswLimit")) ++ return bus_cgroup_set_memory(u, name, &c->memory_memsw_limit, message, flags, error); ++ + if (streq(name, "MemoryMinScale")) { + r = bus_cgroup_set_memory_protection_scale(u, name, &c->memory_min, message, flags, error); + if (r > 0) +diff --git a/src/core/load-fragment-gperf.gperf.in b/src/core/load-fragment-gperf.gperf.in +index eb68807..c1bc771 100644 +--- a/src/core/load-fragment-gperf.gperf.in ++++ b/src/core/load-fragment-gperf.gperf.in +@@ -208,6 +208,7 @@ + {{type}}.MemorySwapMax, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) + {{type}}.MemoryZSwapMax, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) + {{type}}.MemoryLimit, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) ++{{type}}.MemoryMemswLimit, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) + {{type}}.CPUSetAccounting, config_parse_bool, 0, offsetof({{type}}, cgroup_context.cpuset_accounting) + {{type}}.CPUSetCpus, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_cpus) + {{type}}.CPUSetMems, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_mems) +diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c +index d01b6c4..8d2171f 100644 +--- a/src/core/load-fragment.c ++++ b/src/core/load-fragment.c +@@ -3854,6 +3854,8 @@ int config_parse_memory_limit( + c->memory_swap_max = bytes; + else if (streq(lvalue, "MemoryZSwapMax")) + c->memory_zswap_max = bytes; ++ else if (streq(lvalue, "MemoryMemswLimit")) ++ c->memory_memsw_limit = bytes; + else if (streq(lvalue, "MemoryLimit")) { + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Unit uses MemoryLimit=; please use MemoryMax= instead. Support for MemoryLimit= will be removed soon."); +diff --git a/src/shared/bus-print-properties.c b/src/shared/bus-print-properties.c +index 9369866..9e26b71 100644 +--- a/src/shared/bus-print-properties.c ++++ b/src/shared/bus-print-properties.c +@@ -162,7 +162,7 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b + + bus_print_property_value(name, expected_value, flags, "not set"); + +- else if ((STR_IN_SET(name, "DefaultMemoryLow", "DefaultMemoryMin", "MemoryLow", "MemoryHigh", "MemoryMax", "MemorySwapMax", "MemoryZSwapMax", "MemoryLimit", "MemoryAvailable") && u == CGROUP_LIMIT_MAX) || ++ else if ((STR_IN_SET(name, "DefaultMemoryLow", "DefaultMemoryMin", "MemoryLow", "MemoryHigh", "MemoryMax", "MemorySwapMax", "MemoryZSwapMax", "MemoryLimit", "MemoryMemswLimit", "MemoryAvailable") && u == CGROUP_LIMIT_MAX) || + (STR_IN_SET(name, "TasksMax", "DefaultTasksMax") && u == UINT64_MAX) || + (startswith(name, "Limit") && u == UINT64_MAX) || + (startswith(name, "DefaultLimit") && u == UINT64_MAX)) +diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c +index a174e3e..984dfa9 100644 +--- a/src/shared/bus-unit-util.c ++++ b/src/shared/bus-unit-util.c +@@ -547,6 +547,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons + "MemorySwapMax", + "MemoryZSwapMax", + "MemoryLimit", ++ "MemoryMemswLimit", + "TasksMax")) { + + if (streq(eq, "infinity")) { +diff --git a/test/fuzz/fuzz-unit-file/directives-all.service b/test/fuzz/fuzz-unit-file/directives-all.service +index 1a5cd5d..59c693d 100644 +--- a/test/fuzz/fuzz-unit-file/directives-all.service ++++ b/test/fuzz/fuzz-unit-file/directives-all.service +@@ -166,6 +166,7 @@ MemoryHigh= + MemoryLimit= + MemoryLow= + MemoryMax= ++MemoryMemswLimit= + MemorySwapMax= + MemoryZSwapMax= + MessageQueueMaxMessages= +-- +2.33.0 +
View file
_service:tar_scm:core-update-arg_default_rlimit-in-bump_rlimit.patch
Added
@@ -0,0 +1,24 @@ +From a80954ddf69d90d3b02ab62fb025534862069dc3 Mon Sep 17 00:00:00 2001 +From: licunlong <licunlong1@huawei.com> +Date: Wed, 24 Jun 2020 17:23:03 +0800 +Subject: PATCH core-update-arg_default_rlimit-in-bump_rlimit + +--- + src/core/system.conf.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/core/system.conf.in b/src/core/system.conf.in +index a58f65a..4762669 100644 +--- a/src/core/system.conf.in ++++ b/src/core/system.conf.in +@@ -61,7 +61,7 @@ + #DefaultLimitNOFILE=1024:{{HIGH_RLIMIT_NOFILE}} + #DefaultLimitAS= + #DefaultLimitNPROC= +-#DefaultLimitMEMLOCK=8M ++DefaultLimitMEMLOCK=64M + #DefaultLimitLOCKS= + #DefaultLimitSIGPENDING= + #DefaultLimitMSGQUEUE= +-- +2.23.0
View file
_service:tar_scm:delay-to-restart-when-a-service-can-not-be-auto-restarted.patch
Added
@@ -0,0 +1,44 @@ +From 9315c29e4fdfa19c90bb483a364b017881f5cef7 Mon Sep 17 00:00:00 2001 +From: huangkaibin <huangkaibin@huawei.com> +Date: Sat, 21 Apr 2018 17:18:19 +0800 +Subject: PATCH systemd-core: Delay to restart when a service can not be + auto-restarted when there is one STOP_JOB for the service + +When a service current has a STOP job has not scheduled yet, +and also if the service is already scheduled with an auto-restart +with restart-second configured as 0, the service will not be restarted successfully, +and systemd will go into an endless loop to restart the service. +This is because restart-second is 0 and timer task has higher priority than IO tasks when there priority +is same(both with 0), so the STOP job has no chance to be scheduled, and systemd will go into the endless loop +to handle the time task. +This patch fix this problem by delaying 1 second to restart the service to cause STOP job to be scheduled. +--- + src/core/service.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/core/service.c b/src/core/service.c +index e368ec8..9b4b5b1 100644 +--- a/src/core/service.c ++++ b/src/core/service.c +@@ -2262,13 +2262,17 @@ fail: + static void service_enter_restart(Service *s) { + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + int r; ++ int restart_usec; + + assert(s); + + if (unit_has_job_type(UNIT(s), JOB_STOP)) { + /* Don't restart things if we are going down anyway */ + log_unit_info(UNIT(s), "Stop job pending for unit, skipping automatic restart."); +- return; ++ restart_usec = (s->restart_usec == 0) ? 1*USEC_PER_SEC : s->restart_usec; ++ r = service_arm_timer(s, /* relative= */ false, usec_add(now(CLOCK_MONOTONIC), restart_usec)); ++ if (r < 0) ++ goto fail; + } + + /* Any units that are bound to this service must also be +-- +1.8.3.1 +
View file
_service:tar_scm:delete-journal-files-except-system.journal-when-jour.patch
Added
@@ -0,0 +1,184 @@ +From 02d47bd2108d46cf9790500a7568a7523df485f9 Mon Sep 17 00:00:00 2001 +From: xujing <xujing125@huawei.com> +Date: Fri, 26 Aug 2022 20:32:37 +0800 +Subject: PATCH delete journal files except system.journal when journal~ + is generated + +In the case of time change and system panic, the function of invoking +sd_journal_next to obtain logs may not meet expectations(rsyslog cannot obtain +logs). Therefore, when the journal~ file is generated, delete all journal files +except system.journal, to ensure that the sd_journal_next function meets user +expectations. +--- + meson.build | 2 ++ + src/basic/dirent-util.c | 24 +++++++++++++++++ + src/basic/dirent-util.h | 2 ++ + src/libsystemd/sd-journal/journal-file.c | 34 ++++++++++++++++++++++++ + src/libsystemd/sd-journal/sd-journal.c | 22 --------------- + 5 files changed, 62 insertions(+), 22 deletions(-) + +diff --git a/meson.build b/meson.build +index 0372b17..8b1ce23 100644 +--- a/meson.build ++++ b/meson.build +@@ -2001,6 +2001,8 @@ basic_includes = include_directories( + 'src/basic', + 'src/fundamental', + 'src/systemd', ++ 'src/libsystemd/sd-id128', ++ 'src/libsystemd/sd-journal', + '.') + + libsystemd_includes = basic_includes, include_directories( +diff --git a/src/basic/dirent-util.c b/src/basic/dirent-util.c +index 17df6a2..e362554 100644 +--- a/src/basic/dirent-util.c ++++ b/src/basic/dirent-util.c +@@ -7,6 +7,8 @@ + #include "path-util.h" + #include "stat-util.h" + #include "string-util.h" ++#include "id128-util.h" ++#include "syslog-util.h" + + int dirent_ensure_type(int dir_fd, struct dirent *de) { + STRUCT_STATX_DEFINE(sx); +@@ -65,6 +67,28 @@ bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) { + return endswith(de->d_name, suffix); + } + ++bool dirent_is_journal_subdir(const struct dirent *de) { ++ const char *e, *n; ++ assert(de); ++ ++ /* returns true if the specified directory entry looks like a directory that might contain journal ++ * files we might be interested in, i.e. is either a 128bit ID or a 128bit ID suffixed by a ++ * namespace. */ ++ ++ if (!IN_SET(de->d_type, DT_DIR, DT_LNK, DT_UNKNOWN)) ++ return false; ++ ++ e = strchr(de->d_name, '.'); ++ if (!e) ++ return id128_is_valid(de->d_name); /* No namespace */ ++ ++ n = strndupa(de->d_name, e - de->d_name); ++ if (!id128_is_valid(n)) ++ return false; ++ ++ return log_namespace_name_valid(e + 1); ++} ++ + struct dirent *readdir_ensure_type(DIR *d) { + int r; + +diff --git a/src/basic/dirent-util.h b/src/basic/dirent-util.h +index 0f1fb23..2effce3 100644 +--- a/src/basic/dirent-util.h ++++ b/src/basic/dirent-util.h +@@ -12,6 +12,8 @@ bool dirent_is_file(const struct dirent *de) _pure_; + bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) _pure_; + int dirent_ensure_type(int dir_fd, struct dirent *de); + ++bool dirent_is_journal_subdir(const struct dirent *de); ++ + struct dirent *readdir_ensure_type(DIR *d); + struct dirent *readdir_no_dot(DIR *dirp); + +diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c +index 9e6bf6e..561a705 100644 +--- a/src/libsystemd/sd-journal/journal-file.c ++++ b/src/libsystemd/sd-journal/journal-file.c +@@ -38,6 +38,7 @@ + #include "sync-util.h" + #include "user-util.h" + #include "xattr-util.h" ++#include "dirent-util.h" + + #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*sizeof(HashItem)) + #define DEFAULT_FIELD_HASH_TABLE_SIZE (333ULL*sizeof(HashItem)) +@@ -4069,8 +4070,35 @@ int journal_file_archive(JournalFile *f, char **ret_previous_path) { + return 0; + } + ++static void delete_dumped_journal_files(const char *path) { ++ _cleanup_closedir_ DIR *d = NULL; ++ ++ d = opendir(path); ++ if (!d) ++ return; ++ ++ FOREACH_DIRENT_ALL(de, d, return) { ++ if (IN_SET(de->d_type, DT_REG, DT_LNK, DT_UNKNOWN) && ++ (endswith(de->d_name, ".journal") || ++ endswith(de->d_name, ".journal~")) && ++ strcmp(de->d_name, "system.journal") != 0) ++ (void) unlinkat_deallocate(dirfd(d), de->d_name, 0); ++ ++ if (dirent_is_journal_subdir(de)) { ++ _cleanup_free_ char *sub_path = NULL; ++ ++ sub_path = path_join(path, de->d_name); ++ if (!sub_path) ++ continue; ++ ++ delete_dumped_journal_files(sub_path); ++ } ++ } ++} ++ + int journal_file_dispose(int dir_fd, const char *fname) { + _cleanup_free_ char *p = NULL; ++ dual_timestamp boot_timestamp; + + assert(fname); + +@@ -4091,6 +4119,12 @@ int journal_file_dispose(int dir_fd, const char *fname) { + if (renameat(dir_fd, fname, dir_fd, p) < 0) + return -errno; + ++ dual_timestamp_get(&boot_timestamp); ++ if (boot_timestamp.monotonic < 10*USEC_PER_MINUTE) { ++ delete_dumped_journal_files("/var/log/journal"); ++ return 0; ++ } ++ + return 0; + } + +diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c +index f6090dd..8b83f65 100644 +--- a/src/libsystemd/sd-journal/sd-journal.c ++++ b/src/libsystemd/sd-journal/sd-journal.c +@@ -1510,28 +1510,6 @@ static bool dirent_is_journal_file(const struct dirent *de) { + endswith(de->d_name, ".journal~"); + } + +-static bool dirent_is_journal_subdir(const struct dirent *de) { +- const char *e, *n; +- assert(de); +- +- /* returns true if the specified directory entry looks like a directory that might contain journal +- * files we might be interested in, i.e. is either a 128bit ID or a 128bit ID suffixed by a +- * namespace. */ +- +- if (!IN_SET(de->d_type, DT_DIR, DT_LNK, DT_UNKNOWN)) +- return false; +- +- e = strchr(de->d_name, '.'); +- if (!e) +- return id128_is_valid(de->d_name); /* No namespace */ +- +- n = strndupa_safe(de->d_name, e - de->d_name); +- if (!id128_is_valid(n)) +- return false; +- +- return log_namespace_name_valid(e + 1); +-} +- + static int directory_open(sd_journal *j, const char *path, DIR **ret) { + DIR *d; + +-- +2.33.0 +
View file
_service:tar_scm:disable-initialize_clock.patch
Added
@@ -0,0 +1,65 @@ +From fbd28b3b40701f1fda29707dfa09d1e481c4162c Mon Sep 17 00:00:00 2001 +From: hexiaowen<hexiaowen@huawei.com> +Date: Tue, 9 Jul 2019 19:13:43 +0800 +Subject: PATCH delete clock_apply_epoch + +resolved: apply epoch to system time from PID 1 + +For use in timesyncd we already defined a compile-time "epoch" value, which is based on the mtime of the NEWS file, and +specifies a point in time we know lies in the past at runtime. timesyncd uses this to filter out nonsensical timestamp +file data, and bump the system clock to a time that is after the build time of systemd. This patch adds similar bumping +code to earliest PID 1 initialization, so that the system never continues operation with a clock that is in the 1970ies +or even 1930s. we think it is ok when current system time is before build time. + +And, don't restore time when systemd-timesyncd started. + +--- + src/core/main.c | 12 ------------ + src/timesync/timesyncd.c | 8 -------- + 2 files changed, 20 deletions(-) + +diff --git a/src/core/main.c b/src/core/main.c +index 4051a91..c6d16b2 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -1627,18 +1627,6 @@ static void initialize_clock(void) { + */ + (void) clock_reset_timewarp(); + +- ClockChangeDirection change_dir; +- r = clock_apply_epoch(&change_dir); +- if (r > 0 && change_dir == CLOCK_CHANGE_FORWARD) +- log_info("System time before build time, advancing clock."); +- else if (r > 0 && change_dir == CLOCK_CHANGE_BACKWARD) +- log_info("System time is further ahead than %s after build time, resetting clock to build time.", +- FORMAT_TIMESPAN(CLOCK_VALID_RANGE_USEC_MAX, USEC_PER_DAY)); +- else if (r < 0 && change_dir == CLOCK_CHANGE_FORWARD) +- log_error_errno(r, "Current system time is before build time, but cannot correct: %m"); +- else if (r < 0 && change_dir == CLOCK_CHANGE_BACKWARD) +- log_error_errno(r, "Current system time is further ahead %s after build time, but cannot correct: %m", +- FORMAT_TIMESPAN(CLOCK_VALID_RANGE_USEC_MAX, USEC_PER_DAY)); + } + + static void apply_clock_update(void) { +diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c +index e60742c..efe56fd 100644 +--- a/src/timesync/timesyncd.c ++++ b/src/timesync/timesyncd.c +@@ -121,14 +121,6 @@ static int load_clock_timestamp(uid_t uid, gid_t gid) { + if (ct > min) + return 0; + +- /* Not that it matters much, but we actually restore the clock to n+1 here rather than n, simply +- * because we read n as time previously already and we want to progress here, i.e. not report the +- * same time again. */ +- if (clock_settime(CLOCK_REALTIME, TIMESPEC_STORE(min+1)) < 0) { +- log_warning_errno(errno, "Failed to restore system clock, ignoring: %m"); +- return 0; +- } +- + log_struct(LOG_INFO, + "MESSAGE_ID=" SD_MESSAGE_TIME_BUMP_STR, + "REALTIME_USEC=" USEC_FMT, min+1, +-- +2.33.0 +
View file
_service:tar_scm:fix-capsh-drop-but-ping-success.patch
Added
@@ -0,0 +1,29 @@ +From c20f91b6d99ac98a7d883e77f609e52482fe7c3b Mon Sep 17 00:00:00 2001 +From: openEuler Buildteam <buildteam@openeuler.org> +Date: Fri, 17 Jan 2020 23:00:49 +0800 +Subject: PATCH change +fix capsh --drop=cap_net_raw -- -c "/bin/ping -c 1 localhost" +but ping success, the reson is github issue. + +https://github.com/systemd/systemd/pull/13141/commits/0a8ce60ee87de9a817284b31c6ccba062664057f + +--- + sysctl.d/50-default.conf | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysctl.d/50-default.conf b/sysctl.d/50-default.conf +index 41bd1f9..4d9bef8 100644 +--- a/sysctl.d/50-default.conf ++++ b/sysctl.d/50-default.conf +@@ -36,7 +36,7 @@ net.ipv4.conf.all.promote_secondaries = 1 + # #define GID_T_MAX (((gid_t)~0U) >> 1) + # That's not so bad because values between 2^31 and 2^32-1 are reserved on + # systemd-based systems anyway: https://systemd.io/UIDS-GIDS#summary +--net.ipv4.ping_group_range = 0 2147483647 ++net.ipv4.ping_group_range = 1 0 + + # Fair Queue CoDel packet scheduler to fight bufferbloat + -net.core.default_qdisc = fq_codel +-- +1.8.3.1 +
View file
_service:tar_scm:fix-journal-file-descriptors-leak-problems.patch
Added
@@ -0,0 +1,53 @@ +From 4f8cec1924bf00532f5350d9a4d7af8e853241fe Mon Sep 17 00:00:00 2001 +From: huangkaibin <huangkaibin@huawei.com> +Date: Thu, 28 Jun 2018 20:23:45 +0800 +Subject: PATCH systemd-journald: Fix journal file descriptors leak problems. + +Journal files opened and then be removed by external programs(for example, the journal rotation +of systemd-journald will removed jounal files) before journal directory notify watching is added +will not be closed properly. This patch fix this problem by removing and closing these deleted journal files +after notify watching is added. +--- + src/libsystemd/sd-journal/sd-journal.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c +index 5728c53..1238652 100644 +--- a/src/libsystemd/sd-journal/sd-journal.c ++++ b/src/libsystemd/sd-journal/sd-journal.c +@@ -1584,6 +1584,17 @@ fail: + log_debug_errno(errno, "Failed to enumerate directory %s, ignoring: %m", m->path); + } + ++static void remove_nonexistent_journal_files(sd_journal *j) { ++ JournalFile *f = NULL; ++ ORDERED_HASHMAP_FOREACH(f, j->files) { ++ if(f->path && access(f->path, F_OK) < 0) { ++ log_debug("Remove not-existed file from the journal map: %s", f->path); ++ /*Its OK to remove entry from the hashmap although we are iterating on it.*/ ++ remove_file_real(j, f); ++ } ++ } ++} ++ + static void directory_watch(sd_journal *j, Directory *m, int fd, uint32_t mask) { + int r; + +@@ -1612,6 +1623,14 @@ static void directory_watch(sd_journal *j, Directory *m, int fd, uint32_t mask) + (void) inotify_rm_watch(j->inotify_fd, m->wd); + m->wd = -1; + } ++ ++ /* ++ * Before event watching, there were some files opened and if some of these opened files were ++ * deleted due to the journal rotation of systemd-jounald, they will become leaking files and will ++ * never be closed until the process exited. ++ * So here we remove these deleted files from the journal after event watching. ++ */ ++ remove_nonexistent_journal_files(j); + } + + static int add_directory( +-- +2.27.0 +
View file
_service:tar_scm:fix-two-VF-virtual-machines-have-same-mac-address.patch
Added
@@ -0,0 +1,45 @@ +From: fangxiuning <fangxiuning@huawei.com> +Date: Thu, 5 Sep 2019 07:40:41 +0800 +Subject: fix two vf virtual machine has same mac address +through 82599,hns3 physical network cart vf two virtual machine, +two virtual machine have the same mac address. + +MACAddressPolicy= +The policy by which the MAC address should be set. The available +policies are: + +persistent +If the hardware has a persistent MAC address, as most hardware should, +and if it is used by the kernel, nothing is done. Otherwise, a new MAC +address is generated which is guaranteed to be the same on every boot +for the given machine and the given device, but which is otherwise random. +This feature depends on ID_NET_NAME_* properties to exist for the link. +On hardware where these properties are not set, the generation of a +persistent MAC address will fail. + + +random +If the kernel is using a random MAC address, nothing is done. Otherwise, +a new address is randomly generated each time the device appears, +typically at boot. Either way, the random address will have the "unicast" +and "locally administered" bits set. + +none +Keeps the MAC address assigned by the kernel. +--- + network/99-default.link | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/network/99-default.link b/network/99-default.link +index dc7a42bf58..2b8f46a84c 100644 +--- a/network/99-default.link ++++ b/network/99-default.link +@@ -13,4 +13,4 @@ OriginalName=* + Link + NamePolicy=keep kernel database onboard slot path + AlternativeNamesPolicy=database onboard slot path +-MACAddressPolicy=persistent ++MACAddressPolicy=none +-- +2.23.0 +
View file
_service:tar_scm:fuser-print-umount-message-to-reboot-umount-msg.patch
Added
@@ -0,0 +1,228 @@ +From 224b51420b0e3b62cda4bb16f31c6d28e96c7123 Mon Sep 17 00:00:00 2001 +From: sunshihao <sunshihao@huawei.com> +Date: Mon, 25 Jan 2021 14:42:23 +0800 +Subject: PATCH fuser: print umount info to /.reboot-umount-msg.log + +The patch tries to save which processes holds the mountpoint +persistently to /.reboot-umount-msg.log, when the system is +suspended during system restart. + +This patch change the value of DefaultDFXReboot that is set in +/etc/systemd/system.conf file from no to yes.The systemd reboot +feature will open when the process start. + +Signed-off-by: sunshihao <sunshihao@huawei.com> +Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> +Signed-off-by: lixiaokeng <lixiaokeng@huawei.com> +--- + src/core/fuser.c | 57 +++++++++++++++++++++++++++++++++++++---- + src/core/fuser.h | 3 +++ + src/core/job.c | 38 +++++++++++++++++++++++++++ + src/core/system.conf.in | 2 +- + 4 files changed, 94 insertions(+), 6 deletions(-) + +diff --git a/src/core/fuser.c b/src/core/fuser.c +index e943469..94a0812 100644 +--- a/src/core/fuser.c ++++ b/src/core/fuser.c +@@ -383,6 +383,8 @@ static void print_matches(const struct name *name) { + static char P_cmd_longMAX_COMM_LEN; + char cmd_pathPATH_MAX; + int r = 0; ++ FILE *fp = NULL; ++ int flag = 0; + + if (name == NULL) { + manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, +@@ -390,11 +392,29 @@ static void print_matches(const struct name *name) { + return; + } + ++ /* Write the content in the back of previous one */ ++ fp = fopen(REBOOT_UMOUNT_FILE_NAME, "a+"); ++ ++ /* print the time info to /.reboot-umount-msg.log file */ ++ if (fp == NULL) { ++ manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, ++ "Open %s failed!", REBOOT_UMOUNT_FILE_NAME); ++ } ++ + manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, + "\t\tUSER\t\tPID\tCOMMAND"); + manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, + "%s:", name->filename); + ++ /* print the umount fail point to the /.reboot-umount-msg.log file */ ++ if (fp != NULL) { ++ if (strlen(name->filename) <= MOUNT_FILE_NAME_MAX_LEN) { ++ fprintf(fp, "%-20s\t", name->filename); ++ } else { ++ fprintf(fp, "%s\n\t\t\t", name->filename); ++ } ++ } ++ + for (pptr = name->matched_procs; pptr != NULL; pptr = pptr->next) { + if (pwent == NULL || pwent->pw_uid != pptr->uid) + pwent = getpwuid(pptr->uid); //get username +@@ -402,7 +422,7 @@ static void print_matches(const struct name *name) { + r = snprintf(cmd_path, sizeof(cmd_path), "/proc/%d", pptr->pid); + if (r <= 0) { + manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, "Can't snprintf /proc/%d.", pptr->pid); +- return; ++ goto out; + } + + read_cmdline(P_cmd_long, sizeof(P_cmd_long), cmd_path, "cmdline", ' '); +@@ -415,22 +435,49 @@ static void print_matches(const struct name *name) { + if (pptr->command == NULL) + continue; + ++ if (flag > 0) { ++ if (fp != NULL) { ++ fprintf(fp, "\t\t\t"); ++ } ++ } else { ++ flag++; ++ } ++ + if (pwent != NULL) { +- if (pptr->pid != 0) ++ if (pptr->pid != 0) { + manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, + "\t\t%-s\t\t%-d\t%-s", pwent->pw_name, pptr->pid, pptr->command); +- else ++ if (fp != NULL) { ++ fprintf(fp, "%-s\t\t%-d\t%-s\n", pwent->pw_name, pptr->pid, pptr->command); ++ } ++ } else { + manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, + "\t\t%-s\t\t%-s\t%-s", pwent->pw_name, "kernel", pptr->command); ++ if (fp != NULL) { ++ fprintf(fp, "%-s\t\t%-s\t%-s\n", pwent->pw_name, "kernel", pptr->command); ++ } ++ } + } else { +- if (pptr->pid != 0) ++ if (pptr->pid != 0) { + manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, + "\t\t%-u\t\t%-d\t%-s", pptr->uid, pptr->pid, pptr->command); +- else ++ if (fp != NULL) { ++ fprintf(fp, "%-u\t\t%-d\t%-s\n", pptr->uid, pptr->pid, pptr->command); ++ } ++ } else { + manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, + "\t\t%-u\t\t%-s\t%-s", pptr->uid, "kernel", pptr->command); ++ if (fp != NULL) { ++ fprintf(fp, "%-u\t\t%-s\t%-s\n", pptr->uid, "kernel", pptr->command); ++ } ++ } + } + } ++ ++out: ++ if (fp != NULL) { ++ fclose(fp); ++ } + } + + static void free_matched_procs(struct procs *matched_procs) { +diff --git a/src/core/fuser.h b/src/core/fuser.h +index b74b879..2729c9b 100644 +--- a/src/core/fuser.h ++++ b/src/core/fuser.h +@@ -14,6 +14,7 @@ + #include <string.h> + #include <limits.h> + #include <errno.h> ++#include <time.h> + + #include "manager.h" + +@@ -51,5 +52,7 @@ struct device { + #define MAX_COMM_LEN 1024 + #define PROC_MOUNTS "/proc/mounts" + #define PROC_SWAPS "/proc/swaps" ++#define REBOOT_UMOUNT_FILE_NAME "/.reboot-umount-msg.log" ++#define MOUNT_FILE_NAME_MAX_LEN 20 + + int fuser(const char *dir); +diff --git a/src/core/job.c b/src/core/job.c +index d7ad85a..ee48860 100644 +--- a/src/core/job.c ++++ b/src/core/job.c +@@ -31,6 +31,8 @@ + #include "mount.h" + #include "process-util.h" + ++bool g_first_print = true; ++ + Job* job_new_raw(Unit *unit) { + Job *j; + +@@ -706,6 +708,9 @@ static void job_emit_done_message(Unit *u, uint32_t job_id, JobType t, JobResult + const char *ident, *format; + int r = 0; + pid_t pid; ++ FILE *fp = NULL; ++ time_t tmpt; ++ struct tm local_time; + + assert(u); + assert(t >= 0); +@@ -807,6 +812,39 @@ static void job_emit_done_message(Unit *u, uint32_t job_id, JobType t, JobResult + ((u->type == UNIT_MOUNT || u->type == UNIT_AUTOMOUNT) && t == JOB_STOP && result == JOB_FAILED)) { + + Mount *m = MOUNT(u); ++ if (g_first_print) { ++ /* Overwrite previous content at the first time */ ++ fp = fopen(REBOOT_UMOUNT_FILE_NAME, "w+"); ++ ++ /* Only get the local time once */ ++ tmpt = time(NULL); ++ if (!localtime_r(&tmpt, &local_time)) { ++ manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, ++ "Get local time failed!"); ++ } ++ } ++ ++ /* print the time info to /.reboot-umount-msg.log file */ ++ if (g_first_print && fp == NULL) { ++ manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, ++ "Open %s failed!", REBOOT_UMOUNT_FILE_NAME); ++ } else if (g_first_print) { ++ /* Only do this part one time */ ++ g_first_print = false; ++ ++ if (chmod(REBOOT_UMOUNT_FILE_NAME, S_IRUSR | S_IWUSR)) { ++ manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, ++ "Set %s file attributes failed!", REBOOT_UMOUNT_FILE_NAME);
View file
_service:tar_scm:keep-weight-consistent-with-the-set-value.patch
Added
@@ -0,0 +1,36 @@ +From 7424b6c0f38d4a32fd96e74d7078707c026c6c66 Mon Sep 17 00:00:00 2001 +From: wangyuhang <wangyuhang27@huawei.com> +Date: Thu, 9 Jun 2022 20:10:50 +0800 +Subject: PATCH keep weight consistent with the set value + +--- + src/core/cgroup.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 4cac3f6..f6ae2ab 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -1392,7 +1392,8 @@ static void set_io_weight(Unit *u, uint64_t weight) { + + assert(u); + +- (void) set_bfq_weight(u, "io", makedev(0, 0), weight); ++ xsprintf(buf, "%" PRIu64 "\n", weight); ++ (void) set_attribute_and_warn(u, "io", "io.bfq.weight", buf); + + xsprintf(buf, "default %" PRIu64 "\n", weight); + (void) set_attribute_and_warn(u, "io", "io.weight", buf); +@@ -1403,7 +1404,8 @@ static void set_blkio_weight(Unit *u, uint64_t weight) { + + assert(u); + +- (void) set_bfq_weight(u, "blkio", makedev(0, 0), weight); ++ xsprintf(buf, "%" PRIu64 "\n", weight); ++ (void) set_attribute_and_warn(u, "blkio", "blkio.bfq.weight", buf); + + xsprintf(buf, "%" PRIu64 "\n", weight); + (void) set_attribute_and_warn(u, "blkio", "blkio.weight", buf); +-- +2.33.0 +
View file
_service:tar_scm:let-the-child-of-one-unit-don-t-affect-each-other.patch
Added
@@ -0,0 +1,83 @@ +From 8c9de291f2b782f5d7d40447f08553b5e325a34d Mon Sep 17 00:00:00 2001 +From: licunlong <licunlong1@huawei.com> +Date: Fri, 19 Mar 2021 01:29:01 +0800 +Subject: PATCH let the child of one unit don't affect each other. +This should only be used for .slice unit in the Unit section. +To reproduce the problem resolved by this patch, try the following steps: +1. start service A in a slice; +2. change the cgroup property by "echo 512 > service_a/cpu.shares"; +3. systemctl daemon-reload; +4. start service B in a slice; +5. check the cgroup property by "cat service_a/cpu.shares"; +With this directive enabled, the value will stay as 512; if disabled, +if will be restored to the default value of systemd. Defaults to "no". + +--- + src/core/cgroup.c | 3 +++ + src/core/load-fragment-gperf.gperf.in | 1 + + src/core/unit-serialize.c | 2 ++ + src/core/unit.h | 2 ++ + 4 files changed, 8 insertions(+) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 4eedaf7..ab6d602 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -2618,6 +2618,9 @@ void unit_add_family_to_cgroup_realize_queue(Unit *u) { + + UNIT_FOREACH_DEPENDENCY(m, u, UNIT_ATOM_SLICE_OF) { + ++ if (u->independent_child) ++ continue; ++ + /* No point in doing cgroup application for units without active processes. */ + if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(m))) + continue; +diff --git a/src/core/load-fragment-gperf.gperf.in b/src/core/load-fragment-gperf.gperf.in +index 0702aa0..76b1217 100644 +--- a/src/core/load-fragment-gperf.gperf.in ++++ b/src/core/load-fragment-gperf.gperf.in +@@ -286,6 +286,7 @@ Unit.JoinsNamespaceOf, config_parse_unit_deps, + Unit.RequiresOverridable, config_parse_obsolete_unit_deps, UNIT_REQUIRES, 0 + Unit.RequisiteOverridable, config_parse_obsolete_unit_deps, UNIT_REQUISITE, 0 + Unit.RequiresMountsFor, config_parse_unit_requires_mounts_for, 0, 0 ++Unit.IndependentChild, config_parse_bool, 0, offsetof(Unit, independent_child) + Unit.StopWhenUnneeded, config_parse_bool, 0, offsetof(Unit, stop_when_unneeded) + Unit.RefuseManualStart, config_parse_bool, 0, offsetof(Unit, refuse_manual_start) + Unit.RefuseManualStop, config_parse_bool, 0, offsetof(Unit, refuse_manual_stop) +diff --git a/src/core/unit-serialize.c b/src/core/unit-serialize.c +index f3b3e70..b818181 100644 +--- a/src/core/unit-serialize.c ++++ b/src/core/unit-serialize.c +@@ -801,6 +801,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { + if (u->load_state == UNIT_LOADED) { + + fprintf(f, ++ "%s\tIndependentChild:%s\n" + "%s\tStopWhenUnneeded: %s\n" + "%s\tRefuseManualStart: %s\n" + "%s\tRefuseManualStop: %s\n" +@@ -808,6 +809,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { + "%s\tOnSuccessJobMode: %s\n" + "%s\tOnFailureJobMode: %s\n" + "%s\tIgnoreOnIsolate: %s\n", ++ prefix, yes_no(u->independent_child), + prefix, yes_no(u->stop_when_unneeded), + prefix, yes_no(u->refuse_manual_start), + prefix, yes_no(u->refuse_manual_stop), +diff --git a/src/core/unit.h b/src/core/unit.h +index cb85dfc..439714a 100644 +--- a/src/core/unit.h ++++ b/src/core/unit.h +@@ -350,6 +350,8 @@ typedef struct Unit { + sd_id128_t invocation_id; + char invocation_id_stringSD_ID128_STRING_MAX; /* useful when logging */ + ++ bool independent_child; ++ + /* Garbage collect us we nobody wants or requires us anymore */ + bool stop_when_unneeded; + +-- +2.27.0 +
View file
_service:tar_scm:logind-set-RemoveIPC-to-false-by-default.patch
Added
@@ -0,0 +1,53 @@ +From 0b3833d6c3b751c6dfb40eeb2ef852984c58f546 Mon Sep 17 00:00:00 2001 +From: openEuler Buildteam <buildteam@openeuler.org> +Date: Wed, 1 Aug 2018 10:58:28 +0200 +Subject: logind: set RemoveIPC to false by default + +Resolves: #1523233 +--- + man/logind.conf.xml | 2 +- + src/login/logind-core.c | 2 +- + src/login/logind.conf.in | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/man/logind.conf.xml b/man/logind.conf.xml +index b00daf366d..a9fed78aa6 100644 +--- a/man/logind.conf.xml ++++ b/man/logind.conf.xml +@@ -340,7 +340,7 @@ + user fully logs out. Takes a boolean argument. If enabled, the user may not consume IPC resources after the + last of the user's sessions terminated. This covers System V semaphores, shared memory and message queues, as + well as POSIX shared memory and message queues. Note that IPC objects of the root user and other system users +- are excluded from the effect of this setting. Defaults to <literal>yes</literal>.</para></listitem> ++ are excluded from the effect of this setting. Defaults to <literal>no</literal>.</para></listitem> + </varlistentry> + + <varlistentry> +diff --git a/src/login/logind-core.c b/src/login/logind-core.c +index 4289461df6..556945be20 100644 +--- a/src/login/logind-core.c ++++ b/src/login/logind-core.c +@@ -35,7 +35,7 @@ void manager_reset_config(Manager *m) { + + m->n_autovts = 6; + m->reserve_vt = 6; +- m->remove_ipc = true; ++ m->remove_ipc = false; + m->inhibit_delay_max = 5 * USEC_PER_SEC; + m->user_stop_delay = 10 * USEC_PER_SEC; + +diff --git a/src/login/logind.conf.in b/src/login/logind.conf.in +index ed1084b06e..07ff0d195e 100644 +--- a/src/login/logind.conf.in ++++ b/src/login/logind.conf.in +@@ -33,6 +33,6 @@ + #IdleActionSec=30min + #RuntimeDirectorySize=10% + #RuntimeDirectoryInodesMax= +-#RemoveIPC=yes ++#RemoveIPC=no + #InhibitorsMax=8192 + #SessionsMax=8192 +-- +2.23.0 +
View file
_service:tar_scm:pid1-bump-DefaultTasksMax-to-80-of-the-kernel-pid.ma.patch
Added
@@ -0,0 +1,64 @@ +From ad2da19e1e80a9ab9d0dfae17a74f5009e4d1898 Mon Sep 17 00:00:00 2001 +From: openEuler Buildteam <buildteam@openeuler.org> +Date: Tue, 10 Mar 2020 21:01:43 +0800 +Subject: PATCH pid1 bump DefaultTasksMax to 80% of the kernel pid.max value + +--- + man/systemd-system.conf.xml | 2 +- + src/core/main.c | 2 +- + src/core/system.conf.in | 2 +- + units/user-.slice.d/10-defaults.conf | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml +index c11dd46..b259631 100644 +--- a/man/systemd-system.conf.xml ++++ b/man/systemd-system.conf.xml +@@ -389,7 +389,7 @@ + <listitem><para>Configure the default value for the per-unit <varname>TasksMax=</varname> setting. See + <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry> + for details. This setting applies to all unit types that support resource control settings, with the exception +- of slice units. Defaults to 15% of the minimum of <varname>kernel.pid_max=</varname>, <varname>kernel.threads-max=</varname> ++ of slice units. Defaults to 80% of the minimum of <varname>kernel.pid_max=</varname>, <varname>kernel.threads-max=</varname> + and root cgroup <varname>pids.max</varname>. + Kernel has a default value for <varname>kernel.pid_max=</varname> and an algorithm of counting in case of more than 32 cores. + For example, with the default <varname>kernel.pid_max=</varname>, <varname>DefaultTasksMax=</varname> defaults to 4915, +diff --git a/src/core/main.c b/src/core/main.c +index da6c50a..f4fe751 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -92,7 +92,7 @@ + #include <sanitizer/lsan_interface.h> + #endif + +-#define DEFAULT_TASKS_MAX ((TasksMax) { 15U, 100U }) /* 15% */ ++#define DEFAULT_TASKS_MAX ((TasksMax) { 80U, 100U }) /* 80% */ + + static enum { + ACTION_RUN, +diff --git a/src/core/system.conf.in b/src/core/system.conf.in +index e88280b..f2c75fc 100644 +--- a/src/core/system.conf.in ++++ b/src/core/system.conf.in +@@ -54,7 +54,7 @@ + #DefaultIPAccounting=no + #DefaultMemoryAccounting={{ 'yes' if MEMORY_ACCOUNTING_DEFAULT else 'no' }} + #DefaultTasksAccounting=yes +-#DefaultTasksMax=15% ++#DefaultTasksMax=80% + #DefaultLimitCPU= + #DefaultLimitFSIZE= + #DefaultLimitDATA= +diff --git a/units/user-.slice.d/10-defaults.conf b/units/user-.slice.d/10-defaults.conf +index cb3651b..be8fa28 100644 +--- a/units/user-.slice.d/10-defaults.conf ++++ b/units/user-.slice.d/10-defaults.conf +@@ -14,4 +14,4 @@ After=systemd-user-sessions.service + StopWhenUnneeded=yes + + Slice +-TasksMax=33% ++TasksMax=80% +-- +2.27.0 +
View file
_service:tar_scm:print-the-process-status-to-console-when-shutdown.patch
Added
@@ -0,0 +1,1280 @@ +From 5966f7a3b90ee25f23182e9320621a8477a40a51 Mon Sep 17 00:00:00 2001 +From: jiangchuangang <jiangchuangang@huawei.com> +Date: Thu, 2 Sep 2021 12:14:19 +0800 +Subject: PATCH print process status to console when shutdown + +--- + meson.build | 6 +- + src/basic/process-util.c | 58 ++++ + src/basic/process-util.h | 2 + + src/core/fuser.c | 506 +++++++++++++++++++++++++++++++++ + src/core/fuser.h | 55 ++++ + src/core/job.c | 36 +++ + src/core/main.c | 13 +- + src/core/manager.c | 1 + + src/core/manager.h | 2 + + src/core/meson.build | 1 + + src/core/system.conf.in | 1 + + src/shutdown/meson.build | 9 +- + src/shutdown/process-status.c | 143 ++++++++++ + src/shutdown/process-status.h | 24 ++ + src/shutdown/shutdown.c | 45 +++ + src/shutdown/umount.c | 5 + + src/test/meson.build | 15 + + src/test/test-fuser.c | 14 + + src/test/test-process-status.c | 10 + + 19 files changed, 939 insertions(+), 7 deletions(-) + create mode 100644 src/core/fuser.c + create mode 100644 src/core/fuser.h + create mode 100644 src/shutdown/process-status.c + create mode 100644 src/shutdown/process-status.h + create mode 100644 src/test/test-fuser.c + create mode 100644 src/test/test-process-status.c + +diff --git a/meson.build b/meson.build +index bfc8685..0372b17 100644 +--- a/meson.build ++++ b/meson.build +@@ -3882,8 +3882,10 @@ endif + executable( + 'systemd-shutdown', + systemd_shutdown_sources, +- include_directories : includes, +- link_with : libshared, ++ include_directories : includes, ++ core_includes, ++ link_with : libcore, ++ libshared, + dependencies : libmount, + versiondep, + install_rpath : rootpkglibdir, +diff --git a/src/basic/process-util.c b/src/basic/process-util.c +index b6bf83c..eb48f4d 100644 +--- a/src/basic/process-util.c ++++ b/src/basic/process-util.c +@@ -1569,3 +1569,61 @@ static const char* const sched_policy_table = { + }; + + DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(sched_policy, int, INT_MAX); ++ ++unsigned int read_cmdline(char *restrict const dst, unsigned sz, const char* whom, const char *what, char sep) { ++ char pathPATH_MAX; ++ _cleanup_close_ int fd = 0; ++ int len = 0; ++ unsigned n = 0; ++ ++ if (sz <= 0) ++ return 0; ++ ++ if (sz >= INT_MAX) ++ sz = INT_MAX-1; ++ ++ dst0 = '\0'; ++ ++ len = snprintf(path, sizeof(path), "%s/%s", whom, what); ++ if (len <= 0 || (size_t)len >= sizeof(path)) ++ return 0; ++ ++ fd = open(path, O_RDONLY); ++ if (fd == -1) ++ return 0; ++ ++ for (;;) { ++ ssize_t r = read(fd, dst+n, sz-n); ++ ++ if (r == -1) { ++ if (errno == EINTR) ++ continue; ++ break; ++ } ++ ++ if (r <= 0) ++ break; ++ n += r; ++ ++ if (n == sz) { ++ --n; ++ break; ++ } ++ } ++ ++ if (n) { ++ unsigned i = n; ++ ++ while (i && dsti-1 == '\0') ++ --i; ++ ++ while (i--) ++ if (dsti == '\n' || dsti == '\0') dsti = sep; ++ ++ if (dstn-1 == ' ') ++ dstn-1 = '\0'; ++ } ++ ++ dstn = '\0'; ++ return n; ++} +diff --git a/src/basic/process-util.h b/src/basic/process-util.h +index 96da0bb..55cb72b 100644 +--- a/src/basic/process-util.h ++++ b/src/basic/process-util.h +@@ -189,3 +189,5 @@ int pidfd_verify_pid(int pidfd, pid_t pid); + int setpriority_closest(int priority); + + _noreturn_ void freeze(void); ++ ++unsigned int read_cmdline(char *restrict const dst, unsigned sz, const char* whom, const char *what, char sep); +diff --git a/src/core/fuser.c b/src/core/fuser.c +new file mode 100644 +index 0000000..e943469 +--- /dev/null ++++ b/src/core/fuser.c +@@ -0,0 +1,506 @@ ++#include "fuser.h" ++#include "process-util.h" ++ ++static int parse_dir(struct name *this_name, struct inode *match_inode) { ++ if ((this_name == NULL) || (match_inode == NULL)) { ++ manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, ++ "Can't parse dir."); ++ return -1; ++ } ++ ++ if (stat(this_name->filename, &this_name->st) != 0) { ++ manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, ++ "Can't stat dir %s.", this_name->filename); ++ return -1; ++ } ++ ++ match_inode->name = this_name; ++ match_inode->device = this_name->st.st_dev; ++ match_inode->inode = this_name->st.st_ino; ++ ++ return 0; ++} ++ ++static int parse_mounts(struct name *this_name, struct device *match_device) { ++ if ((this_name == NULL) && (match_device == NULL)) { ++ manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, ++ "Can't parse mounts."); ++ return -1; ++ } ++ ++ match_device->name = this_name; ++ ++ if (S_ISBLK(this_name->st.st_mode)) ++ match_device->device = this_name->st.st_rdev; ++ else ++ match_device->device = this_name->st.st_dev; ++ ++ return 0; ++} ++ ++static uid_t getpiduid(const pid_t pid) { ++ char pathnamePATH_MAX; ++ struct stat st; ++ int r = 0; ++ ++ r = snprintf(pathname, sizeof(pathname), "/proc/%d", pid); ++ if (r < 0) { ++ manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, ++ "Snprintf run failed in getpiduid."); ++ return 0; ++ } ++ ++ if (stat(pathname, &st) != 0) ++ return 0; ++ ++ return st.st_uid; ++} ++ ++static struct stat *get_pidstat(const pid_t pid) { ++ char pathnamePATH_MAX; ++ struct stat *st = NULL; ++ int r = 0; ++ ++ st = (struct stat *)malloc(sizeof(struct stat)); ++ if (st == NULL) { ++ manager_status_printf(NULL, STATUS_TYPE_NORMAL, NULL, ++ "Malloc failed in get_pidstat.");
View file
_service:tar_scm:process-util-log-more-information-when-runnin.patch
Added
@@ -0,0 +1,147 @@ +From f4b4008495211c60bda7e1edda45beb36a553bc7 Mon Sep 17 00:00:00 2001 +From: licunlong<licunlong1@huawei.com> +Date: Thu, 14 Jan 2021 15:57:59 +0800 +Subject: PATCH process-util: log more information when running + systemctl. + + Print the PID and its cmdline to the system log when a process + runs systemctl command. +--- + src/basic/process-util.c | 31 +++++++++++++++++++++++++++++++ + src/basic/process-util.h | 1 + + src/systemctl/systemctl.c | 12 ++++++++++++ + src/test/test-process-util.c | 22 ++++++++++++++++++++++ + 4 files changed, 66 insertions(+) + +diff --git a/src/basic/process-util.c b/src/basic/process-util.c +index b6bf83c..aaf5e87 100644 +--- a/src/basic/process-util.c ++++ b/src/basic/process-util.c +@@ -49,6 +49,7 @@ + #include "stdio-util.h" + #include "string-table.h" + #include "string-util.h" ++#include "strv.h" + #include "terminal-util.h" + #include "user-util.h" + #include "utf8.h" +@@ -258,6 +259,36 @@ int get_process_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags + return 0; + } + ++int print_process_cmdline_with_arg(pid_t pid, int argc, char *argv, char *filter) { ++ bool is_filtered = false; ++ int r; ++ const char *arg_cmdline = ""; ++ _cleanup_free_ char *cmdline = NULL; ++ ++ r = get_process_cmdline(pid, SIZE_MAX, 0, &cmdline); ++ if (r < 0) { ++ syslog(LOG_INFO, "Failed to get cmdline of PID %d. Ignoring.", pid); ++ return r; ++ } else { ++ for (int i = 0; i < argc; i++ ) { ++ if (filter && strv_find(filter, argvi)) { ++ is_filtered = true; ++ break; ++ } ++ if (i == 0) { ++ arg_cmdline = strjoina(arg_cmdline, argvi); ++ } else { ++ arg_cmdline = strjoina(arg_cmdline, " ", argvi); ++ } ++ } ++ if (!is_filtered) { ++ syslog(LOG_INFO, "%s called by PID %d (%s)", arg_cmdline, pid, cmdline); ++ } ++ return 0; ++ } ++ ++} ++ + int container_get_leader(const char *machine, pid_t *pid) { + _cleanup_free_ char *s = NULL, *class = NULL; + const char *p; +diff --git a/src/basic/process-util.h b/src/basic/process-util.h +index 96da0bb..135386c 100644 +--- a/src/basic/process-util.h ++++ b/src/basic/process-util.h +@@ -40,6 +40,7 @@ typedef enum ProcessCmdlineFlags { + + int get_process_comm(pid_t pid, char **ret); + int get_process_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags, char **ret); ++int print_process_cmdline_with_arg(pid_t pid, int argc, char *argv, char *filter); + int get_process_exe(pid_t pid, char **ret); + int get_process_uid(pid_t pid, uid_t *ret); + int get_process_gid(pid_t pid, gid_t *ret); +diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c +index 4e7fd04..6143505 100644 +--- a/src/systemctl/systemctl.c ++++ b/src/systemctl/systemctl.c +@@ -2,6 +2,7 @@ + + #include <getopt.h> + #include <locale.h> ++#include <sys/types.h> + #include <unistd.h> + + #include "sd-daemon.h" +@@ -1153,6 +1154,14 @@ static int run(int argc, char *argv) { + _cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL; + _cleanup_(umount_and_rmdir_and_freep) char *mounted_dir = NULL; + int r; ++ pid_t ppid; ++ char *filter = { ++ "status", "show", "cat", ++ "is-active", "is-failed", "is-enabled", "is-system-running", ++ "list-units", "list-sockets", "list-timers", "list-dependencies", ++ "list-unit-files", "list-machines", "list-jobs", ++ "get-default", "show-environment", NULL ++ }; + + setlocale(LC_ALL, ""); + log_setup(); +@@ -1166,6 +1175,9 @@ static int run(int argc, char *argv) { + if (r <= 0) + goto finish; + ++ ppid = getppid(); ++ (void) print_process_cmdline_with_arg(ppid, argc, argv, filter); ++ + if (proc_mounted() == 0) + log_full(arg_no_warn ? LOG_DEBUG : LOG_WARNING, + "%s%s/proc/ is not mounted. This is not a supported mode of operation. Please fix\n" +diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c +index 1864f8a..3a844cf 100644 +--- a/src/test/test-process-util.c ++++ b/src/test/test-process-util.c +@@ -798,4 +798,26 @@ static int intro(void) { + return EXIT_SUCCESS; + } + ++TEST(print_process_cmdline_with_arg) { ++ pid_t pid = getpid(); ++ char *arg_filter_empty = {"", NULL}; ++ char *arg_filter_1_in = {"status", NULL}; ++ char *arg_filter_1_no = {"stop", NULL}; ++ char *arg_filter_2_in = {"restart", "status", NULL}; ++ char *arg_filter_2_no = {"restart", "stop", NULL}; ++ char *arg_var_11 = {"systemctl"}; ++ char *arg_var_1010 = {"systemctl", "restart", "1", "2", "3", "4", "5", "6", "7", "8"}; ++ char *arg_var_filter3 = {"systemctl", "status", "dbus.service"}; ++ assert_se(print_process_cmdline_with_arg(pid, 0, NULL, NULL) >=0); ++ assert_se(print_process_cmdline_with_arg(pid, 1, arg_var_1, NULL) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 10, arg_var_10, NULL) >= 0); ++ assert_se(print_process_cmdline_with_arg(897349, 1, arg_var_1, NULL) < 0); ++ assert_se(print_process_cmdline_with_arg(897349, 10, arg_var_10, NULL) < 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_empty) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_1_in) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_1_no) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_2_in) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_2_no) >= 0); ++} ++ + DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro); +-- +2.33.0 +
View file
_service:tar_scm:resolved-create-etc-resolv.conf-symlink-at-runtime.patch
Added
@@ -0,0 +1,48 @@ +From 0c670fec00f3d5c103d9b7415d4e0510c61ad006 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl> +Date: Fri, 11 Mar 2016 17:06:17 -0500 +Subject: PATCH resolved: create /etc/resolv.conf symlink at runtime + +If the symlink doesn't exists, and we are being started, let's +create it to provie name resolution. + +If it exists, do nothing. In particular, if it is a broken symlink, +we cannot really know if the administator configured it to point to +a location used by some service that hasn't started yet, so we +don't touch it in that case either. + +https://bugzilla.redhat.com/show_bug.cgi?id=1313085 +--- + src/resolve/resolved.c | 5 +++++ + tmpfiles.d/systemd-resolve.conf | 2 -- + 2 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c +index d3bc902..a94d744 100644 +--- a/src/resolve/resolved.c ++++ b/src/resolve/resolved.c +@@ -58,6 +58,11 @@ static int run(int argc, char *argv) { + if (r < 0) + return log_error_errno(r, "Could not create runtime directory: %m"); + ++ r = symlink("../run/systemd/resolve/resolv.conf", "/etc/resolv.conf"); ++ if (r < 0 && errno != EEXIST) ++ log_warning_errno(errno, ++ "Could not create /etc/resolv.conf symlink: %m"); ++ + /* Drop privileges, but keep three caps. Note that we drop two of those too, later on (see below) */ + r = drop_privileges(uid, gid, + (UINT64_C(1) << CAP_NET_RAW)| /* needed for SO_BINDTODEVICE */ +diff --git a/tmpfiles.d/systemd-resolve.conf b/tmpfiles.d/systemd-resolve.conf +index cb1c56d..ce3d1a6 100644 +--- a/tmpfiles.d/systemd-resolve.conf ++++ b/tmpfiles.d/systemd-resolve.conf +@@ -6,5 +6,3 @@ + # (at your option) any later version. + + # See tmpfiles.d(5) for details +- +-L! /etc/resolv.conf - - - - ../run/systemd/resolve/stub-resolv.conf +-- +2.33.0 +
View file
_service:tar_scm:revert-rpm-restart-services-in-posttrans.patch
Added
@@ -0,0 +1,31 @@ +From 3b2ba67cfc83905a88e3ebb88a2b43222a06e869 Mon Sep 17 00:00:00 2001 +From: wangyuhang <wangyuhang27@huawei.com> +Date: Fri, 17 Jun 2022 14:26:16 +0800 +Subject: PATCH revert rpm: restart services in %posttrans +Reason:In version 22.03, if we do not add 'systemctl reload or restart --marked' in +%transfiletriggerpostun, %systemd_postun_with_restart will not restart the +service. In order to maintain compatibility with version 20.03, revert the commit +and use the version 20.03 scheme + +Conflict:NA +Reference:https://github.com/systemd/systemd/commit/fa97d2fcf64e0558054bee673f734f523373b146 +--- + src/rpm/macros.systemd.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/rpm/macros.systemd.in b/src/rpm/macros.systemd.in +index 8880078..b1a297e 100644 +--- a/src/rpm/macros.systemd.in ++++ b/src/rpm/macros.systemd.in +@@ -89,7 +89,7 @@ fi \ + %{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_postun_with_restart}} \ + if $1 -ge 1 && -x "{{SYSTEMD_UPDATE_HELPER_PATH}}" ; then \ + # Package upgrade, not uninstall \ +- {{SYSTEMD_UPDATE_HELPER_PATH}} mark-restart-system-units %{?*} || : \ ++ %{_bindir}/systemctl try-restart %{?*} || : \ + fi \ + %{nil} + +-- +2.33.0 +
View file
_service:tar_scm:rules-add-elevator-kernel-command-line-parameter.patch
Added
@@ -0,0 +1,42 @@ +From 1255584bb0a595fb555af7e14230ab1b7aa6adcd Mon Sep 17 00:00:00 2001 +From: Lukas Nykryn <lnykryn@redhat.com> +Date: Tue, 12 Feb 2019 16:58:16 +0100 +Subject: PATCH rules: add elevator= kernel command line parameter + +Kernel removed the elevator= option + +Resolves: #1670126 +--- + rules.d/40-elevator.rules | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + create mode 100644 rules.d/40-elevator.rules + +diff --git a/rules.d/40-elevator.rules b/rules.d/40-elevator.rules +new file mode 100644 +index 0000000000..5f615bf51a +--- /dev/null ++++ b/rules.d/40-elevator.rules +@@ -0,0 +1,20 @@ ++# We aren't adding devices skip the elevator check ++ACTION!="add", GOTO="sched_out" ++ ++SUBSYSTEM!="block", GOTO="sched_out" ++ENV{DEVTYPE}!="disk", GOTO="sched_out" ++ ++# Technically, dm-multipath can be configured to use an I/O scheduler. ++# However, there are races between the 'add' uevent and the linking in ++# of the queue/scheduler sysfs file. For now, just skip dm- devices. ++KERNEL=="dm-*|md*", GOTO="sched_out" ++ ++# Skip bio-based devices, which don't support an I/O scheduler. ++ATTR{queue/scheduler}=="none", GOTO="sched_out" ++ ++# If elevator= is specified on the kernel command line, change the ++# scheduler to the one specified. ++IMPORT{cmdline}="elevator" ++ENV{elevator}!="", ATTR{queue/scheduler}="$env{elevator}" ++ ++LABEL="sched_out" +-- +2.23.0 +
View file
_service:tar_scm:rules-add-rule-for-naming-Dell-iDRAC-USB-Virtual-NIC.patch
Added
@@ -0,0 +1,40 @@ +From 2991b22f5f40a66ad1cc088e502e7f40ae1806c2 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar <msekleta@redhat.com> +Date: Mon, 22 Sep 2014 07:53:52 +0200 +Subject: rules: add rule for naming Dell iDRAC USB Virtual NIC + as 'idrac' + +Related: #1523227 +--- + rules.d/73-idrac.rules | 6 ++++++ + rules.d/meson.build | 1 + + 2 files changed, 7 insertions(+) + create mode 100644 rules.d/73-idrac.rules + +diff --git a/rules.d/73-idrac.rules b/rules.d/73-idrac.rules +new file mode 100644 +index 0000000..d67fc42 +--- /dev/null ++++ b/rules.d/73-idrac.rules +@@ -0,0 +1,6 @@ ++# do not edit this file, it will be overwritten on update ++ ++# On Dell PowerEdge systems, the iDRAC7 and later support a USB Virtual NIC ++# with terminates in the iDRAC. Help identify this with 'idrac' ++ ++ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", ATTRS{idVendor}=="413c", ATTRS{idProduct}=="a102", NAME="idrac" +diff --git a/rules.d/meson.build b/rules.d/meson.build +index cba9dd4..39e174d 100644 +--- a/rules.d/meson.build ++++ b/rules.d/meson.build +@@ -24,6 +24,7 @@ rules = + '70-joystick.rules', + '70-mouse.rules', + '70-touchpad.rules', ++ '73-idrac.rules', + '75-net-description.rules', + '75-probe_mtd.rules', + '78-sound-card.rules', +-- +2.33.0 +
View file
_service:tar_scm:rules-add-the-rule-that-adds-elevator-kernel-command.patch
Added
@@ -0,0 +1,29 @@ +From 16d1f6e5122038fa24392e166a0a88c6cab41dd0 Mon Sep 17 00:00:00 2001 +From: Lukas Nykryn <lnykryn@redhat.com> +Date: Tue, 26 Feb 2019 15:22:38 +0100 +Subject: PATCH rules: add the rule that adds elevator= kernel + command line parameter + +Resolves: #1670126 + +--- + rules.d/meson.build | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/rules.d/meson.build b/rules.d/meson.build +index 39e174d..e356183 100644 +--- a/rules.d/meson.build ++++ b/rules.d/meson.build +@@ -5,7 +5,8 @@ install_data( + install_dir : udevrulesdir) + + rules = +- files('60-autosuspend.rules', ++ files('40-elevator.rules', ++ '60-autosuspend.rules', + '60-block.rules', + '60-cdrom_id.rules', + '60-drm.rules', +-- +2.33.0 +
View file
_service:tar_scm:sd-bus-properly-initialize-containers.patch
Added
@@ -0,0 +1,31 @@ +From 220a60a61a91153fd8e49e58884b9b0b904888f6 Mon Sep 17 00:00:00 2001 +From: Jan Synacek <jsynacek@redhat.com> +Date: Wed, 31 Oct 2018 12:50:19 +0100 +Subject: PATCH sd-bus: properly initialize containers + +Fixes a SIGSEGV introduced by commit 38a5315a3a6fab745d8c86ff9e486faaf50b28d1. +The same problem doesn't exist upstream, as the container structure +there is initialized using a compound literal, which is zeroed out by +default. + +Related: #1635435 + +--- + src/libsystemd/sd-bus/bus-message.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c +index 9719f97..ec6cd57 100644 +--- a/src/libsystemd/sd-bus/bus-message.c ++++ b/src/libsystemd/sd-bus/bus-message.c +@@ -1783,6 +1783,7 @@ _public_ int sd_bus_message_open_container( + .enclosing = type, + .signature = TAKE_PTR(signature), + .array_size = array_size, ++ .peeked_signature = NULL, + .before = before, + .begin = begin, + }; +-- +2.33.0 +
View file
_service:tar_scm:set-forwardtowall-no-to-avoid-emerg-log-shown-on-she.patch
Added
@@ -0,0 +1,39 @@ +From 22f8c4c2a22d9766d86b23429bd404a0864b0a9e Mon Sep 17 00:00:00 2001 +From: linfeilong <linfeilong@huawei.com> +Date: Sat, 21 Oct 2017 14:48:18 +0800 +Subject: PATCH set forwardtowall no to avoid emerg log shown on shell + +--- + man/journald.conf.xml | 2 +- + src/journal/journald.conf | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/man/journald.conf.xml b/man/journald.conf.xml +index 44fd0d2..8d38fe3 100644 +--- a/man/journald.conf.xml ++++ b/man/journald.conf.xml +@@ -292,7 +292,7 @@ + traditional syslog daemon, to the kernel log buffer (kmsg), to the system console, or sent as wall + messages to all logged-in users. These options take boolean arguments. If forwarding to syslog is + enabled but nothing reads messages from the socket, forwarding to syslog has no effect. By default, +- only forwarding to wall is enabled. These settings may be overridden at boot time with the kernel ++ these four configs are all disabled. These settings may be overridden at boot time with the kernel + command line options <literal>systemd.journald.forward_to_syslog</literal>, + <literal>systemd.journald.forward_to_kmsg</literal>, + <literal>systemd.journald.forward_to_console</literal>, and +diff --git a/src/journal/journald.conf b/src/journal/journald.conf +index 2f1c661..17dda27 100644 +--- a/src/journal/journald.conf ++++ b/src/journal/journald.conf +@@ -32,7 +32,7 @@ + #ForwardToSyslog=no + #ForwardToKMsg=no + #ForwardToConsole=no +-#ForwardToWall=yes ++ForwardToWall=no + #TTYPath=/dev/console + #MaxLevelStore=debug + #MaxLevelSyslog=debug +-- +2.19.1 +
View file
_service:tar_scm:set-the-cpuset.cpus-mems-of-machine.slice-to-all-by-.patch
Added
@@ -0,0 +1,46 @@ +From 14b69596b0bff64f7482d93ea3f043520a716921 Mon Sep 17 00:00:00 2001 +From: rpm-build <rpm-build> +Date: Thu, 8 Jun 2023 20:02:50 +0800 +Subject: PATCH set the cpuset.cpus/mems of machine.slice to all by default + This is necessary after merging core-cgroup-support-cpuset.patch. + +When creating a vm, libvirt will issue a dbus method_call to +systemd-machined. systemd-machined will start transient unit +usually named xxx.scope with Delegate=1 set after receiving +the method_call. If Delegate=1 is set, systemd will create +machine.slice in /sys/fs/cgroup for every cgroup subsystem, this +includes cpuset. cpuset is different, you can't migrate processes +to the created directory unless you have set proper cpuset.cpus +and cpuset.mems. + +Without this patch, libvirt sees machine.slice, it won't check +if cpuset.cpus or cpuset.mems is valid, and just migrate the vm +process to machine.slice. This action will fail because core-cgroup +-support-cpuset.patch only supports create the machine.slice +directory when Delegate=1 is set, but won't set cpuset.cpus +and cpuset.mems automatically. + +Now we have this patch, it will make systemd automatically set +cpuset.cpus and cpuset.mems according to /sys/fs/cgroup/cpuset/{ +cpuset.cpus, cpuset.mems}. Then libvirt can migrate vm processes +freely. +--- + units/machine.slice | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/units/machine.slice b/units/machine.slice +index 501d353..8d87851 100644 +--- a/units/machine.slice ++++ b/units/machine.slice +@@ -11,3 +11,8 @@ + Description=Virtual Machine and Container Slice + Documentation=man:systemd.special(7) + Before=slices.target ++ ++Slice ++CPUSetCpus=all ++CPUSetMems=all ++CPUSetCloneChildren=1 +-- +2.33.0 +
View file
_service:tar_scm:shutdown-reboot-when-recieve-crash-signal.patch
Added
@@ -0,0 +1,63 @@ +From 3ac4d1fc1a067afc0e0d4ca37a44ac252ee8b96b Mon Sep 17 00:00:00 2001 +From: xujing <xujing99@huawei.com> +Date: Tue, 8 Feb 2022 21:02:31 +0800 +Subject: PATCH shutdown: reboot when recieve crash signal + +--- + src/shutdown/shutdown.c | 33 +++++++++++++++++++++++++++++++++ + 1 file changed, 33 insertions(+) + +diff --git a/src/shutdown/shutdown.c b/src/shutdown/shutdown.c +index 1bbabfb..8f68559 100644 +--- a/src/shutdown/shutdown.c ++++ b/src/shutdown/shutdown.c +@@ -322,6 +322,26 @@ static void bump_sysctl_printk_log_level(int min_level) { + log_debug_errno(r, "Failed to bump kernel.printk to %i: %m", min_level + 1); + } + ++_noreturn_ static void crash(int sig) { ++ if (getpid_cached() != 1) ++ /* Pass this on immediately, if this is not PID 1 */ ++ (void) raise(sig); ++ else { ++ bool in_container = detect_container() > 0; ++ ++ log_info("Recieve signal %d.", sig); ++ ++ broadcast_signal(SIGTERM, true, true, arg_timeout); ++ broadcast_signal(SIGKILL, true, false, arg_timeout); ++ ++ if (!in_container) ++ sync_with_progress(); ++ ++ log_info("Rebooting now."); ++ (void) reboot(RB_AUTOBOOT); ++ } ++} ++ + static void init_watchdog(void) { + const char *s; + int r; +@@ -356,6 +376,19 @@ int main(int argc, char *argv) { + usec_t now_time, time_interval; + pid_t pid; + bool fork_failed = false; ++ static const struct sigaction sa = { ++ .sa_handler = crash, ++ .sa_flags = SA_NODEFER, /* So that we can raise the signal again from the signal handler */ ++ }; ++ ++ (void) reset_all_signal_handlers(); ++ (void) ignore_signals(SIGNALS_IGNORE, -1); ++ ++ /* We ignore the return value here, since, we don't mind if we ++ * cannot set up a crash handler */ ++ r = sigaction_many(&sa, SIGNALS_CRASH_HANDLER, -1); ++ if (r < 0) ++ log_debug_errno(r, "I had trouble setting up the crash handler, ignoring: %m"); + + /* The log target defaults to console, but the original systemd process will pass its log target in through a + * command line argument, which will override this default. Also, ensure we'll never log to the journal or +-- +2.33.0 +
View file
_service:tar_scm:support-disable-cgroup-controllers-we-don-t-want.patch
Added
@@ -0,0 +1,216 @@ +From ef31366523d784d92f25abd99b3782acda29a01c Mon Sep 17 00:00:00 2001 +From: xujing <xujing125@huawei.com> +Date: Fri, 8 Jul 2022 19:47:45 +0800 +Subject: PATCH support disable cgroup controllers we don't want + +--- + src/basic/cgroup-util.c | 14 +++++++++++ + src/basic/cgroup-util.h | 1 + + src/core/cgroup.c | 1 + + src/core/main.c | 7 ++++++ + src/core/manager.h | 2 ++ + src/core/system.conf.in | 1 + + src/shared/conf-parser.c | 54 ++++++++++++++++++++++++++++++++++++++++ + src/shared/conf-parser.h | 1 + + 8 files changed, 81 insertions(+) + +diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c +index ac25693..a7c839c 100644 +--- a/src/basic/cgroup-util.c ++++ b/src/basic/cgroup-util.c +@@ -2052,6 +2052,20 @@ int cg_mask_supported(CGroupMask *ret) { + return cg_mask_supported_subtree(root, ret); + } + ++int cg_mask_disable_cgroup(CGroupMask disabled, CGroupMask *ret) { ++ int r; ++ ++ r = cg_all_unified(); ++ if (r < 0) ++ return r; ++ ++ /* We only care CGROUP_V1 */ ++ if (r == 0) ++ *ret &= ~disabled; ++ ++ return 0; ++} ++ + int cg_kernel_controllers(Set **ret) { + _cleanup_set_free_ Set *controllers = NULL; + _cleanup_fclose_ FILE *f = NULL; +diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h +index 147c956..a539327 100644 +--- a/src/basic/cgroup-util.h ++++ b/src/basic/cgroup-util.h +@@ -295,6 +295,7 @@ typedef const char* (*cg_migrate_callback_t)(CGroupMask mask, void *userdata); + + int cg_mask_supported(CGroupMask *ret); + int cg_mask_supported_subtree(const char *root, CGroupMask *ret); ++int cg_mask_disable_cgroup(CGroupMask disabled, CGroupMask *ret); + int cg_mask_from_string(const char *s, CGroupMask *ret); + int cg_mask_to_string(CGroupMask mask, char **ret); + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 9987dac..af58b9b 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -3646,6 +3646,7 @@ int manager_setup_cgroup(Manager *m) { + if (r < 0) + return log_error_errno(r, "Failed to determine supported bpf-based pseudo-controllers: %m"); + m->cgroup_supported |= mask; ++ m->system_cgroup_supported = m->cgroup_supported; + + /* 10. Log which controllers are supported */ + for (CGroupController c = 0; c < _CGROUP_CONTROLLER_MAX; c++) +diff --git a/src/core/main.c b/src/core/main.c +index 990e4d2..5404e24 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -157,6 +157,7 @@ static nsec_t arg_timer_slack_nsec; + static usec_t arg_default_timer_accuracy_usec; + static Set* arg_syscall_archs; + static FILE* arg_serialization; ++static CGroupMask arg_disable_cgroup_controllers; + static int arg_default_cpu_accounting; + static bool arg_default_io_accounting; + static bool arg_default_ip_accounting; +@@ -684,6 +685,7 @@ static int parse_config_file(void) { + { "Manager", "DefaultLimitNICE", config_parse_rlimit, RLIMIT_NICE, arg_default_rlimit }, + { "Manager", "DefaultLimitRTPRIO", config_parse_rlimit, RLIMIT_RTPRIO, arg_default_rlimit }, + { "Manager", "DefaultLimitRTTIME", config_parse_rlimit, RLIMIT_RTTIME, arg_default_rlimit }, ++ { "Manager", "DisableCGroupControllers", config_parse_cgroup, 0, &arg_disable_cgroup_controllers }, + { "Manager", "DefaultCPUAccounting", config_parse_tristate, 0, &arg_default_cpu_accounting }, + { "Manager", "DefaultIOAccounting", config_parse_bool, 0, &arg_default_io_accounting }, + { "Manager", "DefaultIPAccounting", config_parse_bool, 0, &arg_default_ip_accounting }, +@@ -765,6 +767,10 @@ static void set_manager_defaults(Manager *m) { + m->default_start_limit_burst = arg_default_start_limit_burst; + m->default_dfx_reboot = arg_default_dfx_reboot; + ++ m->cgroup_disabled = arg_disable_cgroup_controllers; ++ m->cgroup_supported = m->system_cgroup_supported; ++ (void) cg_mask_disable_cgroup(m->cgroup_disabled, &m->cgroup_supported); ++ + /* On 4.15+ with unified hierarchy, CPU accounting is essentially free as it doesn't require the CPU + * controller to be enabled, so the default is to enable it unless we got told otherwise. */ + if (arg_default_cpu_accounting >= 0) +@@ -2494,6 +2500,7 @@ static void reset_arguments(void) { + + /* arg_serialization — ignore */ + ++ arg_disable_cgroup_controllers = 0; + arg_default_cpu_accounting = -1; + arg_default_io_accounting = false; + arg_default_ip_accounting = false; +diff --git a/src/core/manager.h b/src/core/manager.h +index ea95efe..9bf5454 100644 +--- a/src/core/manager.h ++++ b/src/core/manager.h +@@ -296,6 +296,8 @@ struct Manager { + /* Data specific to the cgroup subsystem */ + Hashmap *cgroup_unit; + CGroupMask cgroup_supported; ++ CGroupMask system_cgroup_supported; ++ CGroupMask cgroup_disabled; + char *cgroup_root; + + /* Notifications from cgroups, when the unified hierarchy is used is done via inotify. */ +diff --git a/src/core/system.conf.in b/src/core/system.conf.in +index 11936cd..e7aecfd 100644 +--- a/src/core/system.conf.in ++++ b/src/core/system.conf.in +@@ -52,6 +52,7 @@ + #DefaultStartLimitIntervalSec=10s + #DefaultStartLimitBurst=5 + #DefaultEnvironment= ++#DisableCGroupControllers=no + #DefaultCPUAccounting=no + #DefaultIOAccounting=no + #DefaultIPAccounting=no +diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c +index 29051ca..2527d31 100644 +--- a/src/shared/conf-parser.c ++++ b/src/shared/conf-parser.c +@@ -10,6 +10,7 @@ + #include "alloc-util.h" + #include "conf-files.h" + #include "conf-parser.h" ++#include "cgroup-util.h" + #include "constants.h" + #include "dns-domain.h" + #include "escape.h" +@@ -1557,6 +1558,59 @@ int config_parse_rlimit( + return 0; + } + ++int config_parse_cgroup( ++ const char *unit, ++ const char *filename, ++ unsigned line, ++ const char *section, ++ unsigned section_line, ++ const char *lvalue, ++ int ltype, ++ const char *rvalue, ++ void *data, ++ void *userdata) { ++ assert(filename); ++ assert(lvalue); ++ assert(rvalue); ++ assert(data); ++ ++ CGroupMask *disabled_mask = data; ++ int r; ++ ++ for (;;) { ++ _cleanup_free_ char *word = NULL; ++ CGroupController cc; ++ int yes_or_no = 0; ++ ++ r = extract_first_word(&rvalue, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE); ++ if (r == 0) ++ break; ++ if (r == -ENOMEM) ++ return log_oom(); ++ if (r < 0) { ++ log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); ++ break; ++ } ++ ++ yes_or_no = parse_boolean(word); ++ if (yes_or_no == 0) { ++ *disabled_mask = 0; ++ break; ++ } else if (yes_or_no == 1) { ++ *disabled_mask = CGROUP_MASK_V1; ++ break; ++ } ++ ++ cc = cgroup_controller_from_string(word); ++ if (cc < 0) { ++ log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse DisableCGroupControllers, ignoring: %s", word); ++ break; ++ } ++ *disabled_mask |= CGROUP_CONTROLLER_TO_MASK(cc); ++ } ++ return 0; ++} ++ + int config_parse_permille(
View file
_service:tar_scm:systemd-change-time-log-level.patch
Added
@@ -0,0 +1,35 @@ +From 7ca51ff9a4213025070f29c7814bba82984b90e7 Mon Sep 17 00:00:00 2001 +From: yefei25 <yefei25@huawei.com> +Date: Tue, 19 Nov 2019 21:49:52 +0800 +Subject: PATCH systemd: change time log level + + +Signed-off-by: yefei25 <yefei25@huawei.com> +--- + src/core/manager.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/core/manager.c b/src/core/manager.c +index 7b39479..1619f8c 100644 +--- a/src/core/manager.c ++++ b/src/core/manager.c +@@ -2937,11 +2937,11 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t + static int manager_dispatch_time_change_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata) { + Manager *m = ASSERT_PTR(userdata); + Unit *u; +- +- log_struct(LOG_DEBUG, +- "MESSAGE_ID=" SD_MESSAGE_TIME_CHANGE_STR, +- LOG_MESSAGE("Time has been changed")); +- ++ if (getpid_cached() == 1) { ++ log_struct(LOG_INFO, ++ "MESSAGE_ID=" SD_MESSAGE_TIME_CHANGE_STR, ++ LOG_MESSAGE("Time has been changed")); ++ } + /* Restart the watch */ + (void) manager_setup_time_change(m); + +-- +2.33.0 +
View file
_service:tar_scm:systemd-core-Add-new-rules-for-lower-priority-events.patch
Added
@@ -0,0 +1,227 @@ +From 135dce487e4637e8afc4090334ccb2cb9feccdf1 Mon Sep 17 00:00:00 2001 +From: yangbin <robin.yb@huawei.com> +Date: Fri, 3 Apr 2020 11:56:41 +0800 +Subject: PATCH systemd-core: Add new rules for lower priority events to + preempt over higher priority events + +1. When a high priority event happenes very frequent, and this event takes long time for execution,systemd will get into busy for handling this event only, and lower priority events will have no any change to dispatch and run. + +2. One example is the event for /proc/self/mountinfo, which have a very high priority with -10. +When there are many mountpoints in mountinfo(for example, there may be many netns mountpoints),this event will take long time to finish. +Then if now there are mountpoints in repeating mounting and unmounting(for example, /run/user/uid mountpoint will be mounted then unmounted when for one su command), +this event will take all time of systemd, and lower priority lower events will not be dispatched anyway. +This will case a very severity problem that zombie process will not be reaped, for the evnet for reaping zombies has a lower priority of -6. + +3. This patch fix this problem by add the following rules to allow lower priority events to preempt over higher priority events. +a) If a higher priority event has already been execute for a certain count in consecutive, it can be preempted by lower priority events. The default value for this count is 10, and can be configured through 'sd_event_source_set_preempt_dispatch_count'. +b) If a lower priority gets into pending for 10 times in consecutive, it can preempt over higher priority events. +c) If a lower priority is in pending, and is not dispatched over 50 iteration, it can preempt over higher priority events. +d) The above rules only works for events with priority equal or higher than 'SD_EVENT_PRIORITY_NORMAL' or evnets with type of SOURCE_DEFER, since SOURCE_DEFER events is used for job running queues. +--- + src/core/mount.c | 4 ++ + src/libsystemd/sd-event/event-source.h | 5 ++ + src/libsystemd/sd-event/sd-event.c | 81 ++++++++++++++++++++++++++ + src/systemd/sd-event.h | 1 + + 4 files changed, 91 insertions(+) + +diff --git a/src/core/mount.c b/src/core/mount.c +index f47c511..af0eae6 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -1984,6 +1984,10 @@ static void mount_enumerate(Manager *m) { + goto fail; + } + ++ r = sd_event_source_set_preempt_dispatch_count(m->mount_event_source, 5); ++ if (r < 0) ++ goto fail; ++ + (void) sd_event_source_set_description(m->mount_event_source, "mount-monitor-dispatch"); + } + +diff --git a/src/libsystemd/sd-event/event-source.h b/src/libsystemd/sd-event/event-source.h +index 6092652..0b2ab7d 100644 +--- a/src/libsystemd/sd-event/event-source.h ++++ b/src/libsystemd/sd-event/event-source.h +@@ -70,6 +70,11 @@ struct sd_event_source { + uint64_t pending_iteration; + uint64_t prepare_iteration; + ++ uint64_t preempted_iteration; /*The iteration that dispatched_count is greater than preempt_dispatch_count*/ ++ unsigned pending_count; /*times of pending not dispatched*/ ++ unsigned dispatched_count; /*consecutive dispatched count*/ ++ unsigned preempt_dispatch_count; /*Will be preempted by lower priority if dispatched count reaches to this*/ ++ + sd_event_destroy_t destroy_callback; + sd_event_handler_t ratelimit_expire_callback; + +diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c +index d3c2d3a..31d4feb 100644 +--- a/src/libsystemd/sd-event/sd-event.c ++++ b/src/libsystemd/sd-event/sd-event.c +@@ -29,6 +29,11 @@ + #include "strxcpyx.h" + #include "time-util.h" + ++#define DEFAULT_PREEMPTED_ITERATION_COUNT (3) ++#define DEFAULT_PREEMPT_DISPATCH_COUNT (10) ++#define DEFAULT_PREEMPT_PENDING_COUNT (10) ++#define DEFAULT_PREEMPT_ITERATION_COUNT (30) ++ + #define DEFAULT_ACCURACY_USEC (250 * USEC_PER_MSEC) + + static bool EVENT_SOURCE_WATCH_PIDFD(sd_event_source *s) { +@@ -154,6 +159,11 @@ struct sd_event { + + LIST_HEAD(sd_event_source, sources); + ++ /*last dispatched source, its type is sd_event_source, ++ * here use void to avoid accessing its members, ++ * for it may have been freed already.*/ ++ void *last_source; ++ + sd_event_source *sigint_event_source, *sigterm_event_source; + + usec_t last_run_usec, last_log_usec; +@@ -169,6 +179,39 @@ static sd_event *event_resolve(sd_event *e) { + return e == SD_EVENT_DEFAULT ? default_event : e; + } + ++static int preempt_prioq_compare(const sd_event_source *x, const sd_event_source *y) { ++ if((x->priority > SD_EVENT_PRIORITY_NORMAL && x->type != SOURCE_DEFER) ++ || (y->priority > SD_EVENT_PRIORITY_NORMAL && y->type != SOURCE_DEFER)) { ++ return 0; /*only high priority evnets can preempt*/ ++ } ++ ++ if(x->priority <= y->priority) { ++ if(x->dispatched_count >= x->preempt_dispatch_count) ++ return 1; ++ if(y->type != SOURCE_DEFER) { /*pending state for defer event is always true*/ ++ /*y has lower priority, but its pending count is greater than x, so y wins*/ ++ if(y->pending_count >= (x->pending_count + DEFAULT_PREEMPT_PENDING_COUNT)) ++ return 1; ++ /*y has lower priority, but is in pending longer than x, so y wins*/ ++ if(x->pending_iteration >= (y->pending_iteration + DEFAULT_PREEMPT_ITERATION_COUNT)) ++ return 1; ++ } ++ } else { ++ if(y->dispatched_count >= y->preempt_dispatch_count) ++ return -1; ++ if(x->type != SOURCE_DEFER) { /*pending state for defer event is always true*/ ++ /*x has lower priority, but its pending count is greater than y, so x wins*/ ++ if(x->pending_count >= (y->pending_count + DEFAULT_PREEMPT_PENDING_COUNT)) ++ return -1; ++ /*x has lower priority, but is in pending longer than y, so x wins*/ ++ if(y->pending_iteration >= (x->pending_iteration + DEFAULT_PREEMPT_ITERATION_COUNT)) ++ return -1; ++ } ++ } ++ ++ return 0; ++} ++ + static int pending_prioq_compare(const void *a, const void *b) { + const sd_event_source *x = a, *y = b; + int r; +@@ -186,6 +229,10 @@ static int pending_prioq_compare(const void *a, const void *b) { + if (r != 0) + return r; + ++ r = preempt_prioq_compare(a, b); ++ if(r != 0) ++ return r; ++ + /* Lower priority values first */ + r = CMP(x->priority, y->priority); + if (r != 0) +@@ -1031,6 +1078,17 @@ static int source_set_pending(sd_event_source *s, bool b) { + assert(s); + assert(s->type != SOURCE_EXIT); + ++ if (b && s->pending == b) ++ s->pending_count++; ++ else ++ s->pending_count = (b ? 1 : 0); ++ if (b && s->preempted_iteration && ++ (s->pending_count >= DEFAULT_PREEMPTED_ITERATION_COUNT || ++ s->event->iteration >= (s->preempted_iteration + DEFAULT_PREEMPTED_ITERATION_COUNT)) ) { ++ s->dispatched_count = 0; ++ s->preempted_iteration = 0; ++ } ++ + if (s->pending == b) + return 0; + +@@ -1090,6 +1148,7 @@ static sd_event_source *source_new(sd_event *e, bool floating, EventSourceType t + .type = type, + .pending_index = PRIOQ_IDX_NULL, + .prepare_index = PRIOQ_IDX_NULL, ++ .preempt_dispatch_count = DEFAULT_PREEMPT_DISPATCH_COUNT, + }; + + if (!floating) +@@ -2511,6 +2570,7 @@ static int event_source_offline( + s->enabled = enabled; + s->ratelimited = ratelimited; + ++ s->pending_count = 0; + switch (s->type) { + + case SOURCE_IO: +@@ -3605,6 +3665,19 @@ static int process_inotify(sd_event *e) { + return done; + } + ++static void source_dispatch_pre(sd_event_source *s) { ++ if(s->event->last_source == s) { ++ s->dispatched_count++; ++ if(s->dispatched_count >= s->preempt_dispatch_count) ++ s->preempted_iteration = s->event->iteration; ++ } else { ++ s->preempted_iteration = 0; ++ s->dispatched_count = 0; ++ } ++ s->event->last_source = s; ++ s->pending_count = 0; ++} ++ + static int source_dispatch(sd_event_source *s) { + EventSourceType saved_type; + sd_event *saved_event; +@@ -3659,6 +3732,7 @@ static int source_dispatch(sd_event_source *s) { + return r; + } + ++ source_dispatch_pre(s); + s->dispatching = true; + + switch (s->type) { +@@ -4624,6 +4698,13 @@ _public_ int sd_event_source_is_ratelimited(sd_event_source *s) {
View file
_service:tar_scm:systemd-core-fix-problem-of-dbus-service-can-not-be-started.patch
Added
@@ -0,0 +1,40 @@ +From bf589755bd5b084f1b5dd099ea3e4917ac9911fd Mon Sep 17 00:00:00 2001 +From: huangkaibin <huangkaibin@huawei.com> +Date: Thu, 14 Sep 2017 12:54:01 +0800 +Subject: PATCH systemd-core: fix problem of dbus service can not be started + when dbus is dead and state of system dbus of systemd stay in + BUS_AUTHENTICATING. + +When systemd starts a dbus communication, it will first authenticate the bus by communicating with polkitd service, and then enter running state. +But if authenticating can not be establised within 25s(default timeout seconds) since authenticating starts +(maybe caused by polkitd service or dbus service can not be activated in time), the dbus state in systemd side will stays in BUS_AUTHENTICATING state, +and systemd will enter a mad state that it will handle authenticating(in bus_process_internal function) very frequently and will have no any change to +service for events of restarting services(by systemctl restart dbus.service --no-ask-password --no-block). So that the dbus service will never be restarted successfully. +systemd will enter such a state is caused by the timeout setting in sd_bus_get_timeout function. When in BUS_AUTHENTICATING state, the timeout is set +to a fix value of bus->auth_timeout(authenticating start time + 25s), if auth_timeout is an expired time, but not a furture time, systemd will always service +for the callback of function of dbus(time_callback) with no any delay when it got its chance, and leave no chance for events of restarting services. +This patch fix this problem by fixing the timeout to a furture time when bus->auth_timeout is expired. +--- + src/libsystemd/sd-bus/sd-bus.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c +index b0a3237..ca626d3 100644 +--- a/src/libsystemd/sd-bus/sd-bus.c ++++ b/src/libsystemd/sd-bus/sd-bus.c +@@ -2267,7 +2267,11 @@ _public_ int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec) { + switch (bus->state) { + + case BUS_AUTHENTICATING: +- *timeout_usec = bus->auth_timeout; ++ //delay 1 second to ensure it is a furture time but not an expired time ++ if(bus->auth_timeout <= now(CLOCK_MONOTONIC)) ++ *timeout_usec = now(CLOCK_MONOTONIC) + USEC_PER_SEC; ++ else ++ *timeout_usec = bus->auth_timeout; + return 1; + + case BUS_RUNNING: +-- +1.8.3.1 +
View file
_service:tar_scm:systemd-solve-that-rsyslog-reads-journal-s-object-of.patch
Added
@@ -0,0 +1,66 @@ +From 6aa35d7d911b6895043f222293703ef7cf60aca1 Mon Sep 17 00:00:00 2001 +From: yefei25 <yefei25@huawei.com> +Date: Thu, 5 Mar 2020 21:45:36 +0800 +Subject: PATCH systemd: solve that rsyslog reads journal's object of +size 0 + + +Signed-off-by: yefei25 <yefei25@huawei.com> + +--- + src/libsystemd/sd-journal/journal-file.c | 5 +++-- + src/libsystemd/sd-journal/sd-journal.c | 7 ++++++- + 2 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c +index 2ead295..9962d3b 100644 +--- a/src/libsystemd/sd-journal/journal-file.c ++++ b/src/libsystemd/sd-journal/journal-file.c +@@ -898,8 +898,9 @@ static int check_object(JournalFile *f, Object *o, uint64_t offset) { + le64toh(o->tag.epoch), offset); + + break; ++ default: ++ return -EBADMSG; + } +- + return 0; + } + +@@ -1804,7 +1805,7 @@ int journal_file_data_payload( + } + + size = le64toh(READ_NOW(o->object.size)); +- if (size < journal_file_data_payload_offset(f)) ++ if (size == 0 || o->object.type == 0 || size < journal_file_data_payload_offset(f)) + return -EBADMSG; + + size -= journal_file_data_payload_offset(f); +diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c +index 898218e..f6090dd 100644 +--- a/src/libsystemd/sd-journal/sd-journal.c ++++ b/src/libsystemd/sd-journal/sd-journal.c +@@ -114,6 +114,10 @@ static void init_location(Location *l, LocationType type, JournalFile *f, Object + assert(IN_SET(type, LOCATION_DISCRETE, LOCATION_SEEK)); + assert(f); + ++ if(o->object.type != OBJECT_ENTRY || o->object.size == 0){ ++ return; ++ } ++ + *l = (Location) { + .type = type, + .seqnum = le64toh(o->entry.seqnum), +@@ -851,7 +855,8 @@ static int real_journal_next(sd_journal *j, direction_t direction) { + return r; + + set_location(j, new_file, o); +- ++ if(o->object.size == 0) ++ return -EBADMSG; + return 1; + } + +-- +2.33.0 +
View file
_service:tar_scm:treat-hyphen-as-valid-hostname-char.patch
Added
@@ -0,0 +1,51 @@ +From c04904a4f54f8949a6a7821a0859e2732366259b Mon Sep 17 00:00:00 2001 +From: licunlong <licunlong1@huawei.com> +Date: Tue, 24 Nov 2020 19:57:38 +0800 +Subject: PATCH treat hyphen as valid hostname char + +--- + src/basic/hostname-util.c | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c +index 5bfa028..b80a2b8 100644 +--- a/src/basic/hostname-util.c ++++ b/src/basic/hostname-util.c +@@ -77,6 +77,16 @@ bool valid_ldh_char(char c) { + c == '-'; + } + ++static bool hostname_valid_char(char c) { ++ return ++ (c >= 'a' && c <= 'z') || ++ (c >= 'A' && c <= 'Z') || ++ (c >= '0' && c <= '9') || ++ c == '-' || ++ c == '_' || ++ c == '.'; ++} ++ + bool hostname_is_valid(const char *s, ValidHostnameFlags flags) { + unsigned n_dots = 0; + const char *p; +@@ -117,7 +127,7 @@ bool hostname_is_valid(const char *s, bool allow_trailing_dot) { + hyphen = true; + + } else { +- if (!valid_ldh_char(*p)) ++ if (!hostname_valid_char(*p)) + return false; + + dot = false; +@@ -160,7 +170,7 @@ char* hostname_cleanup(char *s) { + dot = false; + hyphen = true; + +- } else if (valid_ldh_char(*p)) { ++ } else if (hostname_valid_char(*p)) { + *(d++) = *p; + dot = false; + hyphen = false; +-- +2.23.0 +
View file
_service:tar_scm:udev-add-actions-while-rename-netif-failed.patch
Added
@@ -0,0 +1,83 @@ +From e21318d22359c7160ea7c7f4a610b28a30d48c84 Mon Sep 17 00:00:00 2001 +From: systemd team <systemd-maint@redhat.com> +Date: Tue, 7 Mar 2017 08:20:10 +0000 +Subject: PATCH udev-add-actions-while-rename-netif-failed +--- + src/udev/udev-event.c | 47 +++++++++++++++++++++++++++++++++++++------ + 1 file changed, 41 insertions(+), 6 deletions(-) + +diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c +index ec4ad30..d53a0aa 100644 +--- a/src/udev/udev-event.c ++++ b/src/udev/udev-event.c +@@ -908,6 +908,7 @@ static int rename_netif(UdevEvent *event) { + const char *s; + sd_device *dev; + int ifindex, r; ++ char nameIFNAMSIZ; + + assert(event); + +@@ -978,19 +979,53 @@ static int rename_netif(UdevEvent *event) { + goto revert; + } + +- r = rtnl_set_link_name(&event->rtnl, ifindex, event->name); ++ strscpy(name, IFNAMSIZ, event->name); ++ ++ r = rtnl_set_link_name(&event->rtnl, ifindex, name); + if (r < 0) { + if (r == -EBUSY) { + log_device_info(dev, "Network interface '%s' is already up, cannot rename to '%s'.", + old_sysname, event->name); + r = 0; +- } else +- log_device_error_errno(dev, r, "Failed to rename network interface %i from '%s' to '%s': %m", +- ifindex, old_sysname, event->name); +- goto revert; ++ goto revert; ++ } ++ int loop; ++ if (r != -EEXIST) { ++ log_error_errno(r, "error changing net interface name '%s' to '%s': %m", old_sysname, name); ++ goto revert; ++ } ++ ++ snprintf(name, IFNAMSIZ, "rename%d", ifindex); ++ r = rtnl_set_link_name(&event->rtnl, ifindex, name); ++ if (r < 0) { ++ log_error_errno(r, "error changing net interface name '%s' to '%s': %m", old_sysname, name); ++ goto revert; ++ } ++ ++ log_device_info(dev, "Network interface %i is renamed from '%s' to '%s'", ifindex, old_sysname, name); ++ ++ /* wait 90 seconds for our target to become available */ ++ loop = 90 * 20; ++ while (loop--) { ++ const struct timespec duration = { 0, 1000 * 1000 * 1000 / 20 }; ++ ++ r = rtnl_set_link_name(&event->rtnl, ifindex, event->name); ++ if (r == 0) { ++ log_device_info(dev, "Network interface %i is renamed from '%s' to '%s'", ifindex, name, event->name); ++ goto revert; ++ } ++ ++ if (r != -EEXIST) { ++ log_error_errno(r, "error changing net interface name '%s' to '%s': %m", name, event->name); ++ goto revert; ++ } ++ log_debug( "wait for netif '%s' to become free, loop=%i\n", ++ event->name, (90 * 20) - loop); ++ nanosleep(&duration, NULL); ++ } + } + +- log_device_debug(dev, "Network interface %i is renamed from '%s' to '%s'", ifindex, old_sysname, event->name); ++ log_device_info(dev, "Network interface %i is renamed from '%s' to '%s'", ifindex, old_sysname, event->name); + return 1; + + revert: +-- +2.33.0 +
View file
_service:tar_scm:udev-virsh-shutdown-vm.patch
Added
@@ -0,0 +1,23 @@ +From 3d5e0620b4a3298620c8d985cec42772c7f77c6d Mon Sep 17 00:00:00 2001 +From: openEuler Buildteam <buildteam@openeuler.org> +Date: Thu, 31 Jan 2019 02:24:16 -0500 +Subject: PATCH systemd:virsh shutdown vm + +--- + rules.d/70-power-switch.rules | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/rules.d/70-power-switch.rules b/rules.d/70-power-switch.rules +index 3fb954a..bc79410 100644 +--- a/rules.d/70-power-switch.rules ++++ b/rules.d/70-power-switch.rules +@@ -11,5 +11,6 @@ ACTION=="remove", GOTO="power_switch_end" + + SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_INPUT_SWITCH}=="1", TAG+="power-switch" + SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_INPUT_KEY}=="1", TAG+="power-switch" ++SUBSYSTEM=="input", KERNEL=="event*", SUBSYSTEMS=="platform", ATTRS{keys}=="116", TAG+="power-switch" + + LABEL="power_switch_end" +-- +2.33.0 +
View file
_service:tar_scm:unit-don-t-add-Requires-for-tmp.mount.patch
Added
@@ -0,0 +1,27 @@ +From 03e52d33bbdea731eaa79545bb1d30c5b21abe3d Mon Sep 17 00:00:00 2001 +From: Lukas Nykryn <lnykryn@redhat.com> +Date: Mon, 5 Sep 2016 12:47:09 +0200 +Subject: PATCH unit: don't add Requires for tmp.mount + +Resolves: #1619292 + +--- + src/core/unit.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/core/unit.c b/src/core/unit.c +index c9f756c..721d8d6 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -1421,7 +1421,7 @@ static int unit_add_mount_dependencies(Unit *u) { + return r; + changed = changed || r > 0; + +- if (m->fragment_path) { ++ if (m->fragment_path && !streq(m->id, "tmp.mount")) { + r = unit_add_dependency(u, UNIT_REQUIRES, m, true, di.origin_mask); + if (r < 0) + return r; +-- +1.8.3.1 +
View file
_service:tar_scm:units-add-Install-section-to-tmp.mount.patch
Added
@@ -0,0 +1,25 @@ +From bb3d205bea1c83cbd0e27b504f5f1faa884fb602 Mon Sep 17 00:00:00 2001 +From: Jan Synacek <jsynacek@redhat.com> +Date: Tue, 22 Jan 2019 10:28:42 +0100 +Subject: PATCH units: add Install section to tmp.mount + +Resolves: #1667065 +--- + units/tmp.mount | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/units/tmp.mount b/units/tmp.mount +index cf68378..66d9a32 100644 +--- a/units/tmp.mount ++++ b/units/tmp.mount +@@ -23,3 +23,7 @@ What=tmpfs + Where=/tmp + Type=tmpfs + Options=mode=1777,strictatime,nosuid,nodev,size=50%%,nr_inodes=1m ++ ++# Make 'systemctl enable tmp.mount' work: ++Install ++WantedBy=local-fs.target +-- +2.23.0 +
View file
_service:tar_scm:update-rtc-with-system-clock-when-shutdown.patch
Added
@@ -0,0 +1,51 @@ +From a13f14c6a2da55b9f797b6f33449ba523c07dd46 Mon Sep 17 00:00:00 2001 +From: update-rtc-with-system-clock-when-shutdown +Date: Sat, 2 Feb 2019 02:54:52 -0500 +Subject: PATCH Module: modification summary +--- + units/hwclock-save.service.in | 19 +++++++++++++++++++ + units/meson.build | 2 ++ + 2 files changed, 21 insertions(+) + create mode 100644 units/hwclock-save.service.in + +diff --git a/units/hwclock-save.service.in b/units/hwclock-save.service.in +new file mode 100644 +index 0000000..db33418 +--- /dev/null ++++ b/units/hwclock-save.service.in +@@ -0,0 +1,19 @@ ++# This file is part of systemd. ++# ++# systemd is free software; you can redistribute it and/or modify it+ ++# under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++ ++Unit ++Description=Update RTC With System Clock ++ ++Service ++Type=oneshot ++ExecStart=/usr/bin/true ++ExecStop=/sbin/hwclock --systohc ++RemainAfterExit=yes ++ ++Install ++WantedBy=default.target ++ +diff --git a/units/meson.build b/units/meson.build +index aa2ed11..9992389 100644 +--- a/units/meson.build ++++ b/units/meson.build +@@ -220,6 +220,8 @@ in_units = + 'sysinit.target.wants/', + 'systemd-update-done.service', '', + 'sysinit.target.wants/', ++ 'hwclock-save.service', '', ++ 'sysinit.target.wants/', + 'systemd-update-utmp-runlevel.service', 'ENABLE_UTMP HAVE_SYSV_COMPAT', + 'multi-user.target.wants/ graphical.target.wants/ rescue.target.wants/', + 'systemd-update-utmp.service', 'ENABLE_UTMP', +-- +2.23.0 +
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2