git: 0111be0a4092 - stable/13 - devd: Add vm_guest variable
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 26 Jul 2025 07:17:19 UTC
The branch stable/13 has been updated by eugen:
URL: https://cgit.FreeBSD.org/src/commit/?id=0111be0a409294763a1bfda21f4bff2b26545cb8
commit 0111be0a409294763a1bfda21f4bff2b26545cb8
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-07-19 05:31:50 +0000
Commit: Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2025-07-26 07:16:09 +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
(cherry picked from commit bd4a4e46ceacd8dfc5a5469ec6edd8c92c53605a)
---
sbin/devd/devd.cc | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc
index c1b3e032d3e5..139bb912881d 100644
--- a/sbin/devd/devd.cc
+++ b/sbin/devd/devd.cc
@@ -154,6 +154,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);
@@ -855,6 +857,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) {
@@ -1289,6 +1293,7 @@ int
main(int argc, char **argv)
{
int ch;
+ size_t len;
check_devd_enabled();
while ((ch = getopt(argc, argv, "df:l:nq")) != -1) {
@@ -1313,6 +1318,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();