2017-02-24 16:27:56 +00:00
|
|
|
/*
|
|
|
|
* virt-host-validate-bhyve.c: Sanity check a bhyve hypervisor host
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Roman Bogorodskiy
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/linker.h>
|
|
|
|
|
|
|
|
#include "virt-host-validate-bhyve.h"
|
|
|
|
#include "virt-host-validate-common.h"
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define MODULE_STATUS(mod, err_msg, err_code) \
|
2024-06-06 16:07:24 +00:00
|
|
|
virValidateCheck("BHYVE", _("Checking for %1$s module"), #mod); \
|
2017-11-03 12:09:47 +00:00
|
|
|
if (mod ## _loaded) { \
|
2024-06-06 16:07:24 +00:00
|
|
|
virValidatePass(); \
|
2017-11-03 12:09:47 +00:00
|
|
|
} else { \
|
2024-06-06 16:07:24 +00:00
|
|
|
virValidateFail(err_code, \
|
|
|
|
_("%1$s module is not loaded, " err_msg), \
|
2017-11-03 12:09:47 +00:00
|
|
|
#mod); \
|
|
|
|
ret = -1; \
|
2017-10-31 10:47:36 +00:00
|
|
|
}
|
2017-02-24 16:27:56 +00:00
|
|
|
|
|
|
|
#define MODULE_STATUS_FAIL(mod, err_msg) \
|
2024-06-06 16:07:24 +00:00
|
|
|
MODULE_STATUS(mod, err_msg, VIR_VALIDATE_FAIL)
|
2017-02-24 16:27:56 +00:00
|
|
|
|
|
|
|
#define MODULE_STATUS_WARN(mod, err_msg) \
|
2024-06-06 16:07:24 +00:00
|
|
|
MODULE_STATUS(mod, err_msg, VIR_VALIDATE_WARN)
|
2017-02-24 16:27:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
int virHostValidateBhyve(void)
|
|
|
|
{
|
2020-05-05 12:34:00 +00:00
|
|
|
int ret = 0;
|
2017-02-24 16:27:56 +00:00
|
|
|
int fileid = 0;
|
2022-09-20 10:08:50 +00:00
|
|
|
g_autofree struct kld_file_stat *stat = g_new0(struct kld_file_stat, 1);
|
2022-09-20 10:07:12 +00:00
|
|
|
bool vmm_loaded = false;
|
|
|
|
bool if_tap_loaded = false;
|
|
|
|
bool if_bridge_loaded = false;
|
|
|
|
bool nmdm_loaded = false;
|
2017-02-24 16:27:56 +00:00
|
|
|
|
|
|
|
for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) {
|
2022-09-20 10:08:50 +00:00
|
|
|
stat->version = sizeof(struct kld_file_stat);
|
|
|
|
if (kldstat(fileid, stat) < 0)
|
2017-02-24 16:27:56 +00:00
|
|
|
continue;
|
|
|
|
|
2022-09-20 10:08:50 +00:00
|
|
|
if (STREQ(stat->name, "vmm.ko"))
|
2017-02-24 16:27:56 +00:00
|
|
|
vmm_loaded = true;
|
2022-09-20 10:08:50 +00:00
|
|
|
else if (STREQ(stat->name, "if_tap.ko"))
|
2017-02-24 16:27:56 +00:00
|
|
|
if_tap_loaded = true;
|
2022-09-20 10:08:50 +00:00
|
|
|
else if (STREQ(stat->name, "if_bridge.ko"))
|
2017-02-24 16:27:56 +00:00
|
|
|
if_bridge_loaded = true;
|
2022-09-20 10:08:50 +00:00
|
|
|
else if (STREQ(stat->name, "nmdm.ko"))
|
2017-02-24 16:27:56 +00:00
|
|
|
nmdm_loaded = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_STATUS_FAIL(vmm, "will not be able to start VMs");
|
|
|
|
MODULE_STATUS_WARN(if_tap, "networking will not work");
|
|
|
|
MODULE_STATUS_WARN(if_bridge, "bridged networking will not work");
|
|
|
|
MODULE_STATUS_WARN(nmdm, "nmdm console will not work");
|
|
|
|
|
2020-05-05 12:34:00 +00:00
|
|
|
return ret;
|
2017-02-24 16:27:56 +00:00
|
|
|
}
|