diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-12-05 08:10:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-05 08:10:29 +0100 |
commit | ec34e7d1ab75dd4b7fc9e5d2b5e59c01b3e5f85f (patch) | |
tree | f9ec5915ab35314dc8eb437b76edb455a1b3b2e8 /src/nspawn | |
parent | Merge pull request #14173 from ssahani/tc-sfq (diff) | |
parent | network: if /sys is rw, then udev should be around (diff) | |
download | systemd-ec34e7d1ab75dd4b7fc9e5d2b5e59c01b3e5f85f.tar.xz systemd-ec34e7d1ab75dd4b7fc9e5d2b5e59c01b3e5f85f.zip |
Merge pull request #14229 from yuwata/nspawn-network-interface-14223
nspawn: do not fail if udev is not running
Diffstat (limited to 'src/nspawn')
-rw-r--r-- | src/nspawn/nspawn-network.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/nspawn/nspawn-network.c b/src/nspawn/nspawn-network.c index 214cf5749b..fa1ec05b62 100644 --- a/src/nspawn/nspawn-network.c +++ b/src/nspawn/nspawn-network.c @@ -19,6 +19,7 @@ #include "stat-util.h" #include "string-util.h" #include "strv.h" +#include "udev-util.h" #include "util.h" #define HOST_HASH_KEY SD_ID128_MAKE(1a,37,6f,c7,46,ec,45,0b,ad,a3,d5,31,06,60,5d,b1) @@ -395,24 +396,33 @@ int remove_bridge(const char *bridge_name) { static int parse_interface(const char *name) { _cleanup_(sd_device_unrefp) sd_device *d = NULL; - char ifi_str[2 + DECIMAL_STR_MAX(int)]; int ifi, r; r = parse_ifindex_or_ifname(name, &ifi); if (r < 0) return log_error_errno(r, "Failed to resolve interface %s: %m", name); - sprintf(ifi_str, "n%i", ifi); - r = sd_device_new_from_device_id(&d, ifi_str); - if (r < 0) - return log_error_errno(r, "Failed to get device for interface %s: %m", name); + if (path_is_read_only_fs("/sys") <= 0) { + char ifi_str[2 + DECIMAL_STR_MAX(int)]; - r = sd_device_get_is_initialized(d); - if (r < 0) - return log_error_errno(r, "Failed to determine whether interface %s is initialized or not: %m", name); - if (r == 0) { - log_error("Network interface %s is not initialized yet.", name); - return -EBUSY; + /* udev should be around. */ + + sprintf(ifi_str, "n%i", ifi); + r = sd_device_new_from_device_id(&d, ifi_str); + if (r < 0) + return log_error_errno(r, "Failed to get device %s: %m", name); + + r = sd_device_get_is_initialized(d); + if (r < 0) + return log_error_errno(r, "Failed to determine whether interface %s is initialized: %m", name); + if (r == 0) + return log_error_errno(SYNTHETIC_ERRNO(EBUSY), "Network interface %s is not initialized yet.", name); + + r = device_is_renaming(d); + if (r < 0) + return log_error_errno(r, "Failed to determine the interface %s is being renamed: %m", name); + if (r > 0) + return log_error_errno(SYNTHETIC_ERRNO(EBUSY), "Interface %s is being renamed.", name); } return ifi; |