• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 14630481637

23 Apr 2025 07:04PM UTC coverage: 72.178% (-0.002%) from 72.18%
14630481637

push

github

DaanDeMeyer
mkosi: Run clangd within the tools tree instead of the build container

Running within the build sandbox has a number of disadvantages:
- We have a separate clangd cache for each distribution/release combo
- It requires to build the full image before clangd can be used
- It breaks every time the image becomes out of date and requires a
  rebuild
- We can't look at system headers as we don't have the knowledge to map
  them from inside the build sandbox to the corresponding path on the host

Instead, let's have mkosi.clangd run clangd within the tools tree. We
already require building systemd for both the host and the target anyway,
and all the dependencies to build systemd are installed in the tools tree
already for that, as well as clangd since it's installed together with the
other clang tooling we install in the tools tree. Unlike the previous approach,
this approach only requires the mkosi tools tree to be built upfront, which has
a much higher chance of not invalidating its cache. We can also trivially map
system header lookups from within the sandbox to the path within mkosi.tools
on the host so that starts working as well.

297054 of 411557 relevant lines covered (72.18%)

686269.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.75
/src/machine/operation.h
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
#pragma once
3

4
#include <sys/types.h>
5

6
#include "sd-bus.h"
7
#include "sd-event.h"
8
#include "sd-varlink.h"
9

10
#include "list.h"
11

12
typedef struct Machine Machine;
13
typedef struct Manager Manager;
14
typedef struct Operation Operation;
15

16
#define OPERATIONS_MAX 64
17

18
struct Operation {
19
        Manager *manager;
20
        Machine *machine;
21
        pid_t pid;
22

23
        /* only one of these two fields should be set */
24
        sd_varlink *link;
25
        sd_bus_message *message;
26

27
        int errno_fd;
28
        int extra_fd;
29
        sd_event_source *event_source;
30
        int (*done)(Operation *o, int ret, sd_bus_error *error);
31
        LIST_FIELDS(Operation, operations);
32
        LIST_FIELDS(Operation, operations_by_machine);
33
};
34

35
int operation_new(Manager *manager, Machine *machine, pid_t child, int errno_fd, Operation **ret);
36
Operation *operation_free(Operation *o);
37

38
static inline void operation_attach_bus_reply(Operation *op, sd_bus_message *message) {
30✔
39
        assert(op);
30✔
40
        assert(!op->message);
30✔
41
        assert(!op->link);
30✔
42
        assert(message);
30✔
43

44
        op->message = sd_bus_message_ref(message);
30✔
45
}
30✔
46

47
static inline void operation_attach_varlink_reply(Operation *op, sd_varlink *link) {
9✔
48
        assert(op);
9✔
49
        assert(!op->message);
9✔
50
        assert(!op->link);
9✔
51
        assert(link);
9✔
52

53
        op->link = sd_varlink_ref(link);
9✔
54
}
9✔
55

56
static inline int operation_new_with_bus_reply(
25✔
57
                Manager *manager,
58
                Machine *machine,
59
                pid_t child,
60
                sd_bus_message *message,
61
                int errno_fd,
62
                Operation **ret) {
63

64
        Operation *op;
25✔
65
        int r;
25✔
66

67
        r = operation_new(manager, machine, child, errno_fd, &op);
25✔
68
        if (r < 0)
25✔
69
                return r;
25✔
70

71
        operation_attach_bus_reply(op, message);
25✔
72

73
        if (ret)
25✔
74
                *ret = op;
×
75

76
        return 0;
77
}
78

79
static inline int operation_new_with_varlink_reply(
3✔
80
                Manager *manager,
81
                Machine *machine,
82
                pid_t child,
83
                sd_varlink *link,
84
                int errno_fd,
85
                Operation **ret) {
86

87
        Operation *op;
3✔
88
        int r;
3✔
89

90
        r = operation_new(manager, machine, child, errno_fd, &op);
3✔
91
        if (r < 0)
3✔
92
                return r;
3✔
93

94
        operation_attach_varlink_reply(op, link);
3✔
95

96
        if (ret)
3✔
97
                *ret = op;
×
98

99
        return 0;
100
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc