qemu: Add validation for SMMUv3 IOMMU
[libvirt/ericb.git] / tools / virt-host-validate-bhyve.c
blob2f0ec1e36cabfde408dd11a7669ca72419656928
1 /*
2 * virt-host-validate-bhyve.c: Sanity check a bhyve hypervisor host
4 * Copyright (C) 2017 Roman Bogorodskiy
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see
18 * <http://www.gnu.org/licenses/>.
22 #include <config.h>
24 #include <sys/param.h>
25 #include <sys/linker.h>
27 #include "virt-host-validate-bhyve.h"
28 #include "virt-host-validate-common.h"
30 #define MODULE_STATUS(mod, err_msg, err_code) \
31 virHostMsgCheck("BHYVE", _("for %s module"), #mod); \
32 if (mod ## _loaded) { \
33 virHostMsgPass(); \
34 } else { \
35 virHostMsgFail(err_code, \
36 _("%s module is not loaded, " err_msg), \
37 #mod); \
38 ret = -1; \
41 #define MODULE_STATUS_FAIL(mod, err_msg) \
42 MODULE_STATUS(mod, err_msg, VIR_HOST_VALIDATE_FAIL)
44 #define MODULE_STATUS_WARN(mod, err_msg) \
45 MODULE_STATUS(mod, err_msg, VIR_HOST_VALIDATE_WARN)
48 int virHostValidateBhyve(void)
50 int ret = 0;
51 int fileid = 0;
52 struct kld_file_stat stat;
53 bool vmm_loaded = false, if_tap_loaded = false;
54 bool if_bridge_loaded = false, nmdm_loaded = false;
56 for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) {
57 stat.version = sizeof(struct kld_file_stat);
58 if (kldstat(fileid, &stat) < 0)
59 continue;
61 if (STREQ(stat.name, "vmm.ko"))
62 vmm_loaded = true;
63 else if (STREQ(stat.name, "if_tap.ko"))
64 if_tap_loaded = true;
65 else if (STREQ(stat.name, "if_bridge.ko"))
66 if_bridge_loaded = true;
67 else if (STREQ(stat.name, "nmdm.ko"))
68 nmdm_loaded = true;
71 MODULE_STATUS_FAIL(vmm, "will not be able to start VMs");
72 MODULE_STATUS_WARN(if_tap, "networking will not work");
73 MODULE_STATUS_WARN(if_bridge, "bridged networking will not work");
74 MODULE_STATUS_WARN(nmdm, "nmdm console will not work");
76 return ret;