]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: move logging from varlink clients in nsresource.c/dissect-image.c into...
authorLennart Poettering <lennart@amutable.com>
Mon, 16 Feb 2026 08:37:58 +0000 (09:37 +0100)
committerLennart Poettering <lennart@amutable.com>
Thu, 19 Feb 2026 14:05:15 +0000 (15:05 +0100)
These calls are "library-like", hence better should only debug log on
their own, not more.

src/dissect/dissect.c
src/import/export-tar.c
src/import/import-tar.c
src/import/pull-tar.c
src/nspawn/nspawn.c
src/portable/portable.c
src/shared/dissect-image.c
src/shared/nsresource.c

index a699c007bf60b85526381aafa7e46133652dbf83..7303cfc3bd87103a20df2a05cd76932152e595c8 100644 (file)
@@ -2261,7 +2261,7 @@ static int run(int argc, char *argv[]) {
                                         arg_flags,
                                         &m);
                         if (r < 0)
-                                return r;
+                                return log_error_errno(r, "Failed to mount image via mountfsd: %m");
                 }
         }
 
index e945abe8c37ad1565b43b06581292b418dc96cf6..81fab3714bd5bbb0099573872daa0124f82f41a2 100644 (file)
@@ -365,7 +365,7 @@ int tar_export_start(
                 _cleanup_close_ int mapped_fd = -EBADF;
                 r = mountfsd_mount_directory_fd(directory_fd, e->userns_fd, DISSECT_IMAGE_FOREIGN_UID, &mapped_fd);
                 if (r < 0)
-                        return r;
+                        return log_error_errno(r, "Failed to mount directory via mountfsd: %m");
 
                 /* Drop O_PATH */
                 e->tree_fd = fd_reopen(mapped_fd, O_DIRECTORY|O_CLOEXEC);
index ed96e27222bea969698607550846de488bff0729..b3d3fc61040c121d10a7637eb8d5549aded1d1df 100644 (file)
@@ -259,11 +259,11 @@ static int tar_import_fork_tar(TarImport *i) {
                 _cleanup_close_ int directory_fd = -EBADF;
                 r = mountfsd_make_directory(d, MODE_INVALID, /* flags= */ 0, &directory_fd);
                 if (r < 0)
-                        return r;
+                        return log_error_errno(r, "Failed to make directory via mountfsd: %m");
 
                 r = mountfsd_mount_directory_fd(directory_fd, i->userns_fd, DISSECT_IMAGE_FOREIGN_UID, &i->tree_fd);
                 if (r < 0)
-                        return r;
+                        return log_error_errno(r, "Failed mount directory via mountfsd: %m");
         } else {
                 if (i->flags & IMPORT_BTRFS_SUBVOL)
                         r = btrfs_subvol_make_fallback(AT_FDCWD, d, 0755);
index b0cafd95f4903367e6702c659a8478a0df48738b..b3d80921067ae18e14f30aae2b1e9359894da0fa 100644 (file)
@@ -296,18 +296,18 @@ static int tar_pull_make_local_copy(TarPull *p) {
 
                                 r = mountfsd_mount_directory_fd(directory_fd, p->userns_fd, DISSECT_IMAGE_FOREIGN_UID, &p->tree_fd);
                                 if (r < 0)
-                                        return r;
+                                        return log_error_errno(r, "Failed to mount directory via mountfsd: %m");
                         }
 
                         _cleanup_close_ int directory_fd = -EBADF;
                         r = mountfsd_make_directory(t, MODE_INVALID, /* flags= */ 0, &directory_fd);
                         if (r < 0)
-                                return r;
+                                return log_error_errno(r, "Failed to make directory via mountfsd: %m");
 
                         _cleanup_close_ int copy_fd = -EBADF;
                         r = mountfsd_mount_directory_fd(directory_fd, p->userns_fd, DISSECT_IMAGE_FOREIGN_UID, &copy_fd);
                         if (r < 0)
-                                return r;
+                                return log_error_errno(r, "Failed to mount directory via mountfsd: %m");
 
                         r = copy_tree_at_foreign(p->tree_fd, copy_fd, p->userns_fd);
                         if (r < 0)
@@ -614,11 +614,11 @@ static int tar_pull_job_on_open_disk_tar(PullJob *j) {
                 _cleanup_close_ int directory_fd = -EBADF;
                 r = mountfsd_make_directory(where, MODE_INVALID, /* flags= */ 0, &directory_fd);
                 if (r < 0)
-                        return r;
+                        return log_error_errno(r, "Failed to make directory via mountfsd: %m");
 
                 r = mountfsd_mount_directory_fd(directory_fd, p->userns_fd, DISSECT_IMAGE_FOREIGN_UID, &p->tree_fd);
                 if (r < 0)
-                        return r;
+                        return log_error_errno(r, "Failed to mount directory via mountfsd: %m");
         } else {
                 if (p->flags & IMPORT_BTRFS_SUBVOL)
                         r = btrfs_subvol_make_fallback(AT_FDCWD, where, 0755);
index 623de6d9328f2d3ee8ee3bcd4a18a252ad5d0284..47300ff7e3c13362124cbb6f6853a34ac5886539 100644 (file)
@@ -6297,8 +6297,10 @@ static int run(int argc, char *argv[]) {
                                         userns_fd,
                                         determine_dissect_image_flags(),
                                         &mount_fd);
-                        if (r < 0)
+                        if (r < 0) {
+                                log_error_errno(r, "Failed to mount directory via mountfsd: %m");
                                 goto finish;
+                        }
                 }
 
         } else if (arg_image) {
@@ -6448,8 +6450,10 @@ static int run(int argc, char *argv[]) {
                                         &arg_verity_settings,
                                         dissect_image_flags,
                                         &dissected_image);
-                        if (r < 0)
+                        if (r < 0) {
+                                log_error_errno(r, "Failed to mount image via mountfsd: %m");
                                 goto finish;
+                        }
                 }
 
                 /* Now that we mounted the image, let's try to remove it again, if it is ephemeral */
@@ -6474,8 +6478,10 @@ static int run(int argc, char *argv[]) {
                 r = mstack_load(arg_mstack,
                                 /* dir_fd= */ -EBADF,
                                 &mstack);
-                if (r < 0)
+                if (r < 0) {
+                        log_error_errno(r, "Failed to load .mstack/ directory '%s': %m", arg_mstack);
                         goto finish;
+                }
 
                 r = mstack_open_images(
                                 mstack,
index 403a05005cea98d954aa45cc3f099d32e02e3229..ed249fed9bc1adc81fec6bcafa52f01ce294d398 100644 (file)
@@ -490,7 +490,7 @@ static int portable_extract_by_path(
                         _cleanup_close_ int mfd = -EBADF;
                         r = mountfsd_mount_directory_fd(rfd, userns_fd, DISSECT_IMAGE_FOREIGN_UID, &mfd);
                         if (r < 0)
-                                return log_debug_errno(r, "Failed to open '%s' via mountfsd: %m", path);
+                                return r;
 
                         _cleanup_close_pair_ int seq[2] = EBADF_PAIR;
                         if (socketpair(AF_UNIX, SOCK_SEQPACKET|SOCK_CLOEXEC, 0, seq) < 0)
index 4156903774414f755fdd2123c38845f3b2a45929..0c0274fbc52ea2bde1aa2f8568f6fa6df8e89003 100644 (file)
@@ -5173,32 +5173,32 @@ int mountfsd_mount_image_fd(
 
         image_fd = fd_reopen_condition(image_fd, O_CLOEXEC|O_NOCTTY|O_NONBLOCK|(FLAGS_SET(flags, DISSECT_IMAGE_MOUNT_READ_ONLY) ? O_RDONLY : O_RDWR), O_PATH, &reopened_fd);
         if (image_fd < 0)
-                return log_error_errno(image_fd, "Failed to reopen fd: %m");
+                return log_debug_errno(image_fd, "Failed to reopen fd: %m");
 
         r = sd_varlink_push_dup_fd(vl, image_fd);
         if (r < 0)
-                return log_error_errno(r, "Failed to push image fd into varlink connection: %m");
+                return log_debug_errno(r, "Failed to push image fd into varlink connection: %m");
 
         if (userns_fd >= 0) {
                 r = sd_varlink_push_dup_fd(vl, userns_fd);
                 if (r < 0)
-                        return log_error_errno(r, "Failed to push image fd into varlink connection: %m");
+                        return log_debug_errno(r, "Failed to push image fd into varlink connection: %m");
         }
 
         if (image_policy) {
                 r = image_policy_to_string(image_policy, /* simplify= */ false, &ps);
                 if (r < 0)
-                        return log_error_errno(r, "Failed to format image policy to string: %m");
+                        return log_debug_errno(r, "Failed to format image policy to string: %m");
         }
 
         if (verity && verity->data_path) {
                 verity_data_fd = open(verity->data_path, O_RDONLY|O_CLOEXEC);
                 if (verity_data_fd < 0)
-                        return log_error_errno(errno, "Failed to open verity data file '%s': %m", verity->data_path);
+                        return log_debug_errno(errno, "Failed to open verity data file '%s': %m", verity->data_path);
 
                 r = sd_varlink_push_dup_fd(vl, verity_data_fd);
                 if (r < 0)
-                        return log_error_errno(r, "Failed to push verity data fd into varlink connection: %m");
+                        return log_debug_errno(r, "Failed to push verity data fd into varlink connection: %m");
         }
 
         _cleanup_(sd_json_variant_unrefp) sd_json_variant *mount_options = NULL;
@@ -5220,7 +5220,7 @@ int mountfsd_mount_image_fd(
                                         /* ret_values= */ NULL,
                                         &filtered);
                         if (r < 0)
-                                return log_error_errno(r, "Failed to filter mount options: %m");
+                                return log_debug_errno(r, "Failed to filter mount options: %m");
 
                         if (isempty(filtered))
                                 continue;
@@ -5230,7 +5230,7 @@ int mountfsd_mount_image_fd(
                                 &mount_options,
                                 SD_JSON_BUILD_PAIR_STRING(partition_designator_to_string(i), filtered ?: o));
                 if (r < 0)
-                        return log_error_errno(r, "Failed to build mount options array: %m");
+                        return log_debug_errno(r, "Failed to build mount options array: %m");
         }
 
         sd_json_variant *reply = NULL;
@@ -5256,7 +5256,7 @@ int mountfsd_mount_image_fd(
 
         r = sd_json_dispatch(reply, dispatch_table, SD_JSON_ALLOW_EXTENSIONS, &p);
         if (r < 0)
-                return log_error_errno(r, "Failed to parse MountImage() reply: %m");
+                return log_debug_errno(r, "Failed to parse MountImage() reply: %m");
 
         log_debug("Effective image policy: %s", p.image_policy);
 
@@ -5289,7 +5289,7 @@ int mountfsd_mount_image_fd(
 
                 r = sd_json_dispatch(i, partition_dispatch_table, SD_JSON_ALLOW_EXTENSIONS, &pp);
                 if (r < 0)
-                        return log_error_errno(r, "Failed to parse partition data: %m");
+                        return log_debug_errno(r, "Failed to parse partition data: %m");
 
                 if (pp.fsmount_fd_idx != UINT_MAX) {
                         fsmount_fd = sd_varlink_take_fd(vl, pp.fsmount_fd_idx);
@@ -5302,11 +5302,11 @@ int mountfsd_mount_image_fd(
                 if (!di) {
                         r = dissected_image_new(/* path= */ NULL, &di);
                         if (r < 0)
-                                return log_error_errno(r, "Failed to allocated new dissected image structure: %m");
+                                return log_debug_errno(r, "Failed to allocated new dissected image structure: %m");
                 }
 
                 if (di->partitions[pp.designator].found)
-                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Duplicate partition data for '%s'.", partition_designator_to_string(pp.designator));
+                        return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "Duplicate partition data for '%s'.", partition_designator_to_string(pp.designator));
 
                 di->partitions[pp.designator] = (DissectedPartition) {
                         .found = true,
@@ -5352,7 +5352,7 @@ int mountfsd_mount_image(
 
         _cleanup_close_ int image_fd = open(path, O_RDONLY|O_CLOEXEC);
         if (image_fd < 0)
-                return log_error_errno(errno, "Failed to open '%s': %m", path);
+                return log_debug_errno(errno, "Failed to open '%s': %m", path);
 
         _cleanup_(dissected_image_unrefp) DissectedImage *di = NULL;
         r = mountfsd_mount_image_fd(image_fd, userns_fd, options, image_policy, verity, flags, &di);
@@ -5398,12 +5398,12 @@ int mountfsd_mount_directory_fd(
 
         r = sd_varlink_push_dup_fd(vl, directory_fd);
         if (r < 0)
-                return log_error_errno(r, "Failed to push directory fd into varlink connection: %m");
+                return log_debug_errno(r, "Failed to push directory fd into varlink connection: %m");
 
         if (userns_fd >= 0) {
                 r = sd_varlink_push_dup_fd(vl, userns_fd);
                 if (r < 0)
-                        return log_error_errno(r, "Failed to push user namespace fd into varlink connection: %m");
+                        return log_debug_errno(r, "Failed to push user namespace fd into varlink connection: %m");
         }
 
         sd_json_variant *reply = NULL;
@@ -5430,11 +5430,11 @@ int mountfsd_mount_directory_fd(
         unsigned fsmount_fd_idx = UINT_MAX;
         r = sd_json_dispatch(reply, dispatch_table, SD_JSON_ALLOW_EXTENSIONS, &fsmount_fd_idx);
         if (r < 0)
-                return log_error_errno(r, "Failed to parse MountImage() reply: %m");
+                return log_debug_errno(r, "Failed to parse MountImage() reply: %m");
 
         _cleanup_close_ int fsmount_fd = sd_varlink_take_fd(vl, fsmount_fd_idx);
         if (fsmount_fd < 0)
-                return log_error_errno(fsmount_fd, "Failed to take mount fd from Varlink connection: %m");
+                return log_debug_errno(fsmount_fd, "Failed to take mount fd from Varlink connection: %m");
 
         *ret_mount_fd = TAKE_FD(fsmount_fd);
         return 0;
@@ -5451,7 +5451,7 @@ int mountfsd_mount_directory(
 
         _cleanup_close_ int directory_fd = open(path, O_DIRECTORY|O_RDONLY|O_CLOEXEC|O_PATH);
         if (directory_fd < 0)
-                return log_error_errno(errno, "Failed to open '%s': %m", path);
+                return log_debug_errno(errno, "Failed to open '%s': %m", path);
 
         return mountfsd_mount_directory_fd(directory_fd, userns_fd, flags, ret_mount_fd);
 }
@@ -5483,7 +5483,7 @@ int mountfsd_make_directory_fd(
 
         r = sd_varlink_push_dup_fd(vl, parent_fd);
         if (r < 0)
-                return log_error_errno(r, "Failed to push parent fd into varlink connection: %m");
+                return log_debug_errno(r, "Failed to push parent fd into varlink connection: %m");
 
         sd_json_variant *reply = NULL;
         const char *error_id = NULL;
@@ -5507,11 +5507,11 @@ int mountfsd_make_directory_fd(
         unsigned directory_fd_idx = UINT_MAX;
         r = sd_json_dispatch(reply, dispatch_table, SD_JSON_ALLOW_EXTENSIONS, &directory_fd_idx);
         if (r < 0)
-                return log_error_errno(r, "Failed to parse MountImage() reply: %m");
+                return log_debug_errno(r, "Failed to parse MountImage() reply: %m");
 
         _cleanup_close_ int directory_fd = sd_varlink_take_fd(vl, directory_fd_idx);
         if (directory_fd < 0)
-                return log_error_errno(directory_fd, "Failed to take directory fd from Varlink connection: %m");
+                return log_debug_errno(directory_fd, "Failed to take directory fd from Varlink connection: %m");
 
         if (ret_directory_fd)
                 *ret_directory_fd = TAKE_FD(directory_fd);
@@ -5529,16 +5529,16 @@ int mountfsd_make_directory(
         _cleanup_free_ char *parent = NULL;
         r = path_extract_directory(path, &parent);
         if (r < 0)
-                return log_error_errno(r, "Failed to extract parent directory from '%s': %m", path);
+                return log_debug_errno(r, "Failed to extract parent directory from '%s': %m", path);
 
         _cleanup_free_ char *dirname = NULL;
         r = path_extract_filename(path, &dirname);
         if (r < 0)
-                return log_error_errno(r, "Failed to extract directory name from '%s': %m", path);
+                return log_debug_errno(r, "Failed to extract directory name from '%s': %m", path);
 
         _cleanup_close_ int fd = open(parent, O_DIRECTORY|O_CLOEXEC);
         if (fd < 0)
-                return log_error_errno(r, "Failed to open '%s': %m", parent);
+                return log_debug_errno(r, "Failed to open '%s': %m", parent);
 
         return mountfsd_make_directory_fd(fd, dirname, mode, flags, ret_directory_fd);
 }
index 31d96bad7cc2243e122b847e28997729e6f0b9f7..651d9bdf4d64256e81ee9dbde54f90d3815aee83 100644 (file)
@@ -195,11 +195,11 @@ int nsresource_add_mount(int userns_fd, int mount_fd) {
 
         userns_fd_idx = sd_varlink_push_dup_fd(vl, userns_fd);
         if (userns_fd_idx < 0)
-                return log_error_errno(userns_fd_idx, "Failed to push userns fd into varlink connection: %m");
+                return log_debug_errno(userns_fd_idx, "Failed to push userns fd into varlink connection: %m");
 
         mount_fd_idx = sd_varlink_push_dup_fd(vl, mount_fd);
         if (mount_fd_idx < 0)
-                return log_error_errno(mount_fd_idx, "Failed to push mount fd into varlink connection: %m");
+                return log_debug_errno(mount_fd_idx, "Failed to push mount fd into varlink connection: %m");
 
         sd_json_variant *reply = NULL;
         r = sd_varlink_callbo(
@@ -210,13 +210,13 @@ int nsresource_add_mount(int userns_fd, int mount_fd) {
                         SD_JSON_BUILD_PAIR_UNSIGNED("userNamespaceFileDescriptor", userns_fd_idx),
                         SD_JSON_BUILD_PAIR_UNSIGNED("mountFileDescriptor", mount_fd_idx));
         if (r < 0)
-                return log_error_errno(r, "Failed to call AddMountToUserNamespace() varlink call: %m");
+                return log_debug_errno(r, "Failed to call AddMountToUserNamespace() varlink call: %m");
         if (streq_ptr(error_id, "io.systemd.NamespaceResource.UserNamespaceNotRegistered")) {
-                log_notice("User namespace has not been allocated via namespace resource registry, not adding mount to registration.");
+                log_debug("User namespace has not been allocated via namespace resource registry, not adding mount to registration.");
                 return 0;
         }
         if (error_id)
-                return log_error_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to mount image: %s", error_id);
+                return log_debug_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to mount image: %s", error_id);
 
         return 1;
 }
@@ -264,7 +264,7 @@ int nsresource_add_cgroup(int userns_fd, int cgroup_fd) {
         if (r < 0)
                 return log_debug_errno(r, "Failed to call AddControlGroupToUserNamespace() varlink call: %m");
         if (streq_ptr(error_id, "io.systemd.NamespaceResource.UserNamespaceNotRegistered")) {
-                log_notice("User namespace has not been allocated via namespace resource registry, not adding cgroup to registration.");
+                log_debug("User namespace has not been allocated via namespace resource registry, not adding cgroup to registration.");
                 return 0;
         }
         if (error_id)
@@ -343,7 +343,7 @@ int nsresource_add_netif_veth(
         if (r < 0)
                 return log_debug_errno(r, "Failed to call AddNetworkToUserNamespace() varlink call: %m");
         if (streq_ptr(error_id, "io.systemd.NamespaceResource.UserNamespaceNotRegistered")) {
-                log_notice("User namespace has not been allocated via namespace resource registry, not adding network to registration.");
+                log_debug("User namespace has not been allocated via namespace resource registry, not adding network to registration.");
                 return 0;
         }
         if (error_id)