mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
Merge pull request #12267 from keszybz/udev-settle-warning
Udev settle warning
This commit is contained in:
commit
03abeb0baf
@ -775,6 +775,7 @@ manpages = [
|
||||
'systemd-tmpfiles-setup.service'],
|
||||
''],
|
||||
['systemd-tty-ask-password-agent', '1', [], ''],
|
||||
['systemd-udev-settle.service', '8', [], ''],
|
||||
['systemd-udevd.service',
|
||||
'8',
|
||||
['systemd-udevd',
|
||||
|
51
man/systemd-udev-settle.service.xml
Normal file
51
man/systemd-udev-settle.service.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version='1.0'?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
|
||||
|
||||
<refentry id="systemd-udev-settle.service"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
|
||||
<refentryinfo>
|
||||
<title>systemd-udev-settle.service</title>
|
||||
<productname>systemd</productname>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>systemd-udev-settle.service</refentrytitle>
|
||||
<manvolnum>8</manvolnum>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>systemd-udev-settle.service</refname>
|
||||
<refpurpose>Wait for all pending udev events to be handled</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<para><filename>systemd-udev-settle.service</filename></para>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1><title>Description</title>
|
||||
<para>This service calls <command>udevadm settle</command> to wait until all events that have been queued
|
||||
by <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry> have been
|
||||
processed. It is a crude way to wait until "all" hardware has been discovered. Services may pull in this
|
||||
service and order themselves after it to wait for the udev queue to be empty.</para>
|
||||
|
||||
<para><emphasis>Using this service is not recommended.</emphasis> There can be no guarantee that hardware
|
||||
is fully discovered at any specific time, because the kernel does hardware detection asynchronously, and
|
||||
certain busses and devices take a very long time to become ready, and also additional hardware may be
|
||||
plugged in at any time. Instead, services should subscribe to udev events and react to any new hardware as
|
||||
it is discovered. Services that, based on configuration, expect certain devices to appear, may warn or
|
||||
report failure after a timeout. This timeout should be tailored to the hardware type. Waiting for
|
||||
<filename>systemd-udev-settle.service</filename> usually slows boot significantly, because it means waiting
|
||||
for all unrelated events too.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>See Also</title>
|
||||
<para>
|
||||
<citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
@ -362,6 +362,10 @@
|
||||
|
||||
<xi:include href="standard-options.xml" xpointer="help" />
|
||||
</variablelist>
|
||||
|
||||
<para>See
|
||||
<citerefentry><refentrytitle>systemd-udev-settle.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
||||
for more information.</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2><title>udevadm control <replaceable>option</replaceable></title>
|
||||
|
@ -13,10 +13,16 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sd-bus.h"
|
||||
#include "sd-login.h"
|
||||
|
||||
#include "libudev-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "time-util.h"
|
||||
#include "udevadm.h"
|
||||
#include "udev-ctrl.h"
|
||||
#include "udevadm.h"
|
||||
#include "unit-def.h"
|
||||
#include "util.h"
|
||||
#include "virt.h"
|
||||
|
||||
@ -79,6 +85,61 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int emit_deprecation_warning(void) {
|
||||
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||
_cleanup_free_ char *unit = NULL, *unit_path = NULL;
|
||||
_cleanup_strv_free_ char **a = NULL, **b = NULL;
|
||||
int r;
|
||||
|
||||
r = sd_pid_get_unit(0, &unit);
|
||||
if (r < 0 || !streq(unit, "systemd-udev-settle.service"))
|
||||
return 0;
|
||||
|
||||
log_notice("systemd-udev-settle.service is deprecated.");
|
||||
|
||||
r = sd_bus_open_system(&bus);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to open system bus, skipping dependency queries: %m");
|
||||
|
||||
unit_path = unit_dbus_path_from_name("systemd-udev-settle.service");
|
||||
if (!unit_path)
|
||||
return -ENOMEM;
|
||||
|
||||
(void) sd_bus_get_property_strv(
|
||||
bus,
|
||||
"org.freedesktop.systemd1",
|
||||
unit_path,
|
||||
"org.freedesktop.systemd1.Unit",
|
||||
"WantedBy",
|
||||
NULL,
|
||||
&a);
|
||||
|
||||
(void) sd_bus_get_property_strv(
|
||||
bus,
|
||||
"org.freedesktop.systemd1",
|
||||
unit_path,
|
||||
"org.freedesktop.systemd1.Unit",
|
||||
"RequiredBy",
|
||||
NULL,
|
||||
&b);
|
||||
|
||||
r = strv_extend_strv(&a, b, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!strv_isempty(a)) {
|
||||
_cleanup_free_ char *t = NULL;
|
||||
|
||||
t = strv_join(a, ", ");
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
|
||||
log_notice("Hint: please fix %s not to pull it in.", t);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int settle_main(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_(udev_queue_unrefp) struct udev_queue *queue = NULL;
|
||||
struct pollfd pfd;
|
||||
@ -128,6 +189,8 @@ int settle_main(int argc, char *argv[], void *userdata) {
|
||||
.fd = r,
|
||||
};
|
||||
|
||||
(void) emit_deprecation_warning();
|
||||
|
||||
for (;;) {
|
||||
if (arg_exists && access(arg_exists, F_OK) >= 0)
|
||||
return 0;
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
[Unit]
|
||||
Description=udev Wait for Complete Device Initialization
|
||||
Documentation=man:udev(7) man:systemd-udevd.service(8)
|
||||
Documentation=man:systemd-udev-settle.service(8)
|
||||
DefaultDependencies=no
|
||||
Wants=systemd-udevd.service
|
||||
After=systemd-udev-trigger.service
|
||||
|
Loading…
x
Reference in New Issue
Block a user