git: bd4a4e46ceac - main - devd: Add vm_guest variable
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 22 Jul 2025 04:00:53 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=bd4a4e46ceacd8dfc5a5469ec6edd8c92c53605a
commit bd4a4e46ceacd8dfc5a5469ec6edd8c92c53605a
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-07-19 05:31:50 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-07-22 04:00:33 +0000
devd: Add vm_guest variable
Fetch vm_guest on startup in case we're running under a hypervisor.
Co-authored-by: eugen@
PR: 287873
Sponsored by: Netflix
---
sbin/devd/devd.cc | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc
index d7a3fee57870..375ccd817146 100644
--- a/sbin/devd/devd.cc
+++ b/sbin/devd/devd.cc
@@ -153,6 +153,8 @@ static volatile sig_atomic_t romeo_must_die = 0;
static const char *configfile = CF;
+static char vm_guest[80];
+
static void devdlog(int priority, const char* message, ...)
__printflike(2, 3);
static void event_loop(void);
@@ -867,6 +869,8 @@ process_event(char *buffer)
cfg.set_variable("timestamp", timestr);
free(timestr);
+ cfg.set_variable("vm_guest", vm_guest);
+
// Match doesn't have a device, and the format is a little
// different, so handle it separately.
switch (type) {
@@ -1322,6 +1326,7 @@ int
main(int argc, char **argv)
{
int ch;
+ size_t len;
check_devd_enabled();
while ((ch = getopt(argc, argv, "df:l:nq")) != -1) {
@@ -1346,6 +1351,13 @@ main(int argc, char **argv)
}
}
+ len = sizeof(vm_guest);
+ if (sysctlbyname("kern.vm_guest", vm_guest, &len, NULL, 0) < 0) {
+ devdlog(LOG_ERR,
+ "sysctlnametomib(kern.vm_guest) failed: %d\n",
+ errno);
+ }
+
cfg.parse();
if (!no_daemon && daemonize_quick) {
cfg.open_pidfile();