From nobody Sat Apr 20 16:10:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1488029681510402.97516494587694; Sat, 25 Feb 2017 05:34:41 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1PDUkIm015500; Sat, 25 Feb 2017 08:30:47 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1PDUijF010302 for ; Sat, 25 Feb 2017 08:30:44 -0500 Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1PDUiRF008250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sat, 25 Feb 2017 08:30:44 -0500 Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 781C53B74F for ; Sat, 25 Feb 2017 13:30:43 +0000 (UTC) Received: by mail-lf0-f67.google.com with SMTP id z127so3189743lfa.2 for ; Sat, 25 Feb 2017 05:30:42 -0800 (PST) Received: from kloomba.my.domain ([213.147.217.82]) by smtp.gmail.com with ESMTPSA id u30sm2642127ljd.4.2017.02.25.05.30.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Feb 2017 05:30:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2ZK1tci9hUqT1xfZwHkNpfAIKCpipCvwjOPDHOrYe7Q=; b=bKIiD8khIRZGlu7DIyHJMa/s8uTz7fNYOt/46k8QKg4w+D56H3MZnKqUf554BPx/60 uJFClsWQY0ruudMnv8xNtZ2+LWFNUjVwjIS/XjjEUnxDFNIKPn9isFyEeiTWOGFknBAR 13GXi8+DqyGfwqzVwHIuG2aLwHTiBDiqJPs4s5HYIwKnzEf//DR54lHORnsRSWS96BMH z3/NZ8qQtPlB6XLJyMwN2ZB/cAHqeTTkO6dPmR+s8BGld6vBmGFQoL9NspXCIIrcYzUO jpVrdMbzi2j0Iz8k/eLJBmR0JSikPg8AS3JKdbo21bFW2tTQB3LSSx5utvVS2b15GlQ6 LrHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2ZK1tci9hUqT1xfZwHkNpfAIKCpipCvwjOPDHOrYe7Q=; b=U+bGwYgaDxHYMYScoNu5at8TseqQdFe4Su93nG3qpE7A4nNRfd7qMs9y77G1lvSo7t 7h3CtTHPIbftjeff/MxM75+jAipVa2i810xpajQ8iuCeh/xtbb0xACwwIXCMau8U4w1P wn81l1xT0Cqs6uDkCHha89FpTCRzgaq/UIzH7Z/VvsBHoUUn5mxbQghJHfBtSM+lQ7Lk nBqZBbd3OrH+d8ksq58VVe9KOnHS14bJLBndwA86t7pFSICHEy42U7muBwHgumdmFdeX AFMFbu1CgAcrGFU+Hqitt6oB9BEZkFqe6WaaSYSmLWPFmKXCT1mZkPIvyXFZzsTidmvm cyFQ== X-Gm-Message-State: AMke39k6sXtdd/zwr6m35FmSLOtkU+p/SL+gHJpWos96Loy2SLpCVmY2BIQyGAOdUtUnUg== X-Received: by 10.25.163.130 with SMTP id m124mr2009945lfe.19.1488029440448; Sat, 25 Feb 2017 05:30:40 -0800 (PST) From: Roman Bogorodskiy To: libvir-list@redhat.com Date: Sat, 25 Feb 2017 17:30:28 +0400 Message-Id: <20170225133028.36019-1-bogorodskiy@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 25 Feb 2017 13:30:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 25 Feb 2017 13:30:43 +0000 (UTC) for IP:'209.85.215.67' DOMAIN:'mail-lf0-f67.google.com' HELO:'mail-lf0-f67.google.com' FROM:'bogorodskiy@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.17 * (BAYES_50, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.215.67 mail-lf0-f67.google.com 209.85.215.67 mail-lf0-f67.google.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-loop: libvir-list@redhat.com Cc: Roman Bogorodskiy Subject: [libvirt] [PATCH] virt-host-validate: add bhyve support X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add bhyve support to virt-host-validate(1). It checks for the essential kernel modules to be available so that user can actually start VMs, have networking and console access. It uses the kldnext(2)/kldstat(2) routines to retrieve modules list. As bhyve is only available on FreeBSD and these routines were available long before bhyve appeared, not adding any specific configure checks for that. --- po/POTFILES.in | 1 + tools/Makefile.am | 1 + tools/virt-host-validate-bhyve.c | 78 ++++++++++++++++++++++++++++++++++++= ++++ tools/virt-host-validate-bhyve.h | 27 ++++++++++++++ tools/virt-host-validate.c | 12 +++++++ tools/virt-host-validate.pod | 4 +-- 6 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 tools/virt-host-validate-bhyve.c create mode 100644 tools/virt-host-validate-bhyve.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 9f66697d7..51b5859cb 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -306,6 +306,7 @@ tools/virsh-snapshot.c tools/virsh-volume.c tools/virsh.c tools/virt-admin.c +tools/virt-host-validate-bhyve.c tools/virt-host-validate-common.c tools/virt-host-validate-lxc.c tools/virt-host-validate-qemu.c diff --git a/tools/Makefile.am b/tools/Makefile.am index e6ae15025..a8bd3d1c2 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -142,6 +142,7 @@ virt_host_validate_SOURCES =3D \ virt-host-validate-common.c virt-host-validate-common.h \ virt-host-validate-qemu.c virt-host-validate-qemu.h \ virt-host-validate-lxc.c virt-host-validate-lxc.h \ + virt-host-validate-bhyve.c virt-host-validate-bhyve.h \ $(NULL) =20 virt_host_validate_LDFLAGS =3D \ diff --git a/tools/virt-host-validate-bhyve.c b/tools/virt-host-validate-bh= yve.c new file mode 100644 index 000000000..c7bf96f05 --- /dev/null +++ b/tools/virt-host-validate-bhyve.c @@ -0,0 +1,78 @@ +/* + * 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 + * . + * + */ + +#include + +#include +#include +#include + +#include "virt-host-validate-bhyve.h" +#include "virt-host-validate-common.h" + +#define MODULE_STATUS(mod, err_msg, err_code) \ + virHostMsgCheck("BHYVE", _("for %s module"), #mod); \ + if (mod ## _loaded) { \ + virHostMsgPass(); \ + } else { \ + virHostMsgFail(err_code, \ + _("%s module is not loaded, " err_msg), \ + #mod); \ + ret =3D -1; \ + } \ + +#define MODULE_STATUS_FAIL(mod, err_msg) \ + MODULE_STATUS(mod, err_msg, VIR_HOST_VALIDATE_FAIL) + +#define MODULE_STATUS_WARN(mod, err_msg) \ + MODULE_STATUS(mod, err_msg, VIR_HOST_VALIDATE_WARN) + + +int virHostValidateBhyve(void) +{ + int ret =3D 0; + int fileid =3D 0; + struct kld_file_stat stat; + bool vmm_loaded =3D false, if_tap_loaded =3D false; + bool if_bridge_loaded =3D false, nmdm_loaded =3D false; + + for (fileid =3D kldnext(0); fileid > 0; fileid =3D kldnext(fileid)) { + stat.version =3D sizeof(struct kld_file_stat); + if (kldstat(fileid, &stat) < 0) + continue; + + if (STREQ(stat.name, "vmm.ko")) + vmm_loaded =3D true; + else if (STREQ(stat.name, "if_tap.ko")) + if_tap_loaded =3D true; + else if (STREQ(stat.name, "if_bridge.ko")) + if_bridge_loaded =3D true; + else if (STREQ(stat.name, "nmdm.ko")) + nmdm_loaded =3D 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"); + + return ret; +} diff --git a/tools/virt-host-validate-bhyve.h b/tools/virt-host-validate-bh= yve.h new file mode 100644 index 000000000..290d4336f --- /dev/null +++ b/tools/virt-host-validate-bhyve.h @@ -0,0 +1,27 @@ +/* + * virt-host-validate-bhyve.h: 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 + * . + * + */ + +#ifndef __VIRT_HOST_VALIDATE_BHYVE_H__ +# define __VIRT_HOST_VALIDATE_BHYVE_H__ + +int virHostValidateBhyve(void); + +#endif /* __VIRT_HOST_VALIDATE_BHYVE_H__ */ diff --git a/tools/virt-host-validate.c b/tools/virt-host-validate.c index f09282412..29d2482b6 100644 --- a/tools/virt-host-validate.c +++ b/tools/virt-host-validate.c @@ -36,6 +36,9 @@ #if WITH_LXC # include "virt-host-validate-lxc.h" #endif +#if WITH_BHYVE +# include "virt-host-validate-bhyve.h" +#endif =20 static void show_help(FILE *out, const char *argv0) @@ -48,6 +51,7 @@ show_help(FILE *out, const char *argv0) "\n" " - qemu\n" " - lxc\n" + " - bhyve\n" "\n" " Options:\n" " -h, --help Display command line help\n" @@ -130,6 +134,14 @@ main(int argc, char **argv) } #endif =20 +#if WITH_BHYVE + if (!hvname || STREQ(hvname, "bhyve")) { + usedHvname =3D true; + if (virHostValidateBhyve() < 0) + ret =3D EXIT_FAILURE; + } +#endif + if (hvname && !usedHvname) { fprintf(stderr, _("%s: unsupported hypervisor name %s\n"), argv[0], hvname); diff --git a/tools/virt-host-validate.pod b/tools/virt-host-validate.pod index 84917c83b..910114175 100644 --- a/tools/virt-host-validate.pod +++ b/tools/virt-host-validate.pod @@ -12,8 +12,8 @@ This tool validates that the host is configured in a suit= able way to run libvirt hypervisor drivers. If invoked without any arguments it will check support for all hypervisor drivers it is aware of. Optionally it can be given a particular hypervisor -type ('qemu' or 'lxc') to restrict the checks to those relevant -for that virtualization technology +type ('qemu', 'lxc' or 'bhyve') to restrict the checks +to those relevant for that virtualization technology =20 =3Dhead1 OPTIONS =20 --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list