mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
tools: add virt-host-validate-ch for ch driver
Signed-off-by: Wei-Chen Chen <weicche@microsoft.com> Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
4c0cf7c4dc
commit
a0ec7165e3
@ -369,6 +369,7 @@
|
|||||||
@SRCDIR@tools/virsh.h
|
@SRCDIR@tools/virsh.h
|
||||||
@SRCDIR@tools/virt-admin.c
|
@SRCDIR@tools/virt-admin.c
|
||||||
@SRCDIR@tools/virt-host-validate-bhyve.c
|
@SRCDIR@tools/virt-host-validate-bhyve.c
|
||||||
|
@SRCDIR@tools/virt-host-validate-ch.c
|
||||||
@SRCDIR@tools/virt-host-validate-common.c
|
@SRCDIR@tools/virt-host-validate-common.c
|
||||||
@SRCDIR@tools/virt-host-validate-lxc.c
|
@SRCDIR@tools/virt-host-validate-lxc.c
|
||||||
@SRCDIR@tools/virt-host-validate-qemu.c
|
@SRCDIR@tools/virt-host-validate-qemu.c
|
||||||
|
@ -58,6 +58,11 @@ if conf.has('WITH_HOST_VALIDATE')
|
|||||||
'virt-host-validate-bhyve.c',
|
'virt-host-validate-bhyve.c',
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
if conf.has('WITH_CH')
|
||||||
|
virt_host_validate_sources += [
|
||||||
|
'virt-host-validate-ch.c',
|
||||||
|
]
|
||||||
|
endif
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
'virt-host-validate',
|
'virt-host-validate',
|
||||||
|
84
tools/virt-host-validate-ch.c
Normal file
84
tools/virt-host-validate-ch.c
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* virt-host-validate-ch.c: Sanity check a CH hypervisor host
|
||||||
|
*
|
||||||
|
* Copyright Microsoft Corp. 2020-2021
|
||||||
|
*
|
||||||
|
* 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 "virarch.h"
|
||||||
|
#include "virbitmap.h"
|
||||||
|
#include "virt-host-validate-ch.h"
|
||||||
|
#include "virt-host-validate-common.h"
|
||||||
|
|
||||||
|
int virHostValidateCh(void)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
virBitmap *flags;
|
||||||
|
bool hasHwVirt = false;
|
||||||
|
bool hasVirtFlag = false;
|
||||||
|
virArch arch = virArchFromHost();
|
||||||
|
const char *kvmhint =
|
||||||
|
_("Check that CPU and firmware supports virtualization "
|
||||||
|
"and kvm module is loaded");
|
||||||
|
|
||||||
|
if (!(flags = virHostValidateGetCPUFlags()))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Cloud-Hypervisor only supports x86_64 and aarch64 */
|
||||||
|
switch ((int)arch) {
|
||||||
|
case VIR_ARCH_X86_64:
|
||||||
|
hasVirtFlag = true;
|
||||||
|
kvmhint = _("Check that the 'kvm-intel' or 'kvm-amd' modules are "
|
||||||
|
"loaded & the BIOS has enabled virtualization");
|
||||||
|
if (virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SVM) ||
|
||||||
|
virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_VMX))
|
||||||
|
hasHwVirt = true;
|
||||||
|
break;
|
||||||
|
case VIR_ARCH_AARCH64:
|
||||||
|
hasVirtFlag = true;
|
||||||
|
hasHwVirt = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
hasHwVirt = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasVirtFlag) {
|
||||||
|
virHostMsgCheck("CH", "%s", _("for hardware virtualization"));
|
||||||
|
if (hasHwVirt) {
|
||||||
|
virHostMsgPass();
|
||||||
|
} else {
|
||||||
|
virHostMsgFail(VIR_HOST_VALIDATE_FAIL,
|
||||||
|
_("Only emulated CPUs are available, performance will be "
|
||||||
|
"significantly limited"));
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasHwVirt || !hasVirtFlag) {
|
||||||
|
if (virHostValidateDeviceExists("CH", "/dev/kvm", VIR_HOST_VALIDATE_FAIL,
|
||||||
|
kvmhint) < 0)
|
||||||
|
ret = -1;
|
||||||
|
else if (virHostValidateDeviceAccessible("CH", "/dev/kvm", VIR_HOST_VALIDATE_FAIL,
|
||||||
|
_("Check /dev/kvm is world writable or you are in "
|
||||||
|
"a group that is allowed to access it")) < 0)
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
24
tools/virt-host-validate-ch.h
Normal file
24
tools/virt-host-validate-ch.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* virt-host-validate-ch.h: Sanity check a CH hypervisor host
|
||||||
|
*
|
||||||
|
* Copyright Microsoft Corp. 2020-2021
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
int virHostValidateCh(void);
|
@ -40,6 +40,9 @@
|
|||||||
#if WITH_BHYVE
|
#if WITH_BHYVE
|
||||||
# include "virt-host-validate-bhyve.h"
|
# include "virt-host-validate-bhyve.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if WITH_CH
|
||||||
|
# include "virt-host-validate-ch.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_help(FILE *out, const char *argv0)
|
show_help(FILE *out, const char *argv0)
|
||||||
@ -53,6 +56,7 @@ show_help(FILE *out, const char *argv0)
|
|||||||
" - qemu\n"
|
" - qemu\n"
|
||||||
" - lxc\n"
|
" - lxc\n"
|
||||||
" - bhyve\n"
|
" - bhyve\n"
|
||||||
|
" - ch\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Options:\n"
|
" Options:\n"
|
||||||
" -h, --help Display command line help\n"
|
" -h, --help Display command line help\n"
|
||||||
@ -146,6 +150,14 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if WITH_CH
|
||||||
|
if (!hvname || STREQ(hvname, "ch")) {
|
||||||
|
usedHvname = true;
|
||||||
|
if (virHostValidateCh() < 0)
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hvname && !usedHvname) {
|
if (hvname && !usedHvname) {
|
||||||
fprintf(stderr, _("%s: unsupported hypervisor name %s\n"),
|
fprintf(stderr, _("%s: unsupported hypervisor name %s\n"),
|
||||||
argv[0], hvname);
|
argv[0], hvname);
|
||||||
|
Loading…
Reference in New Issue
Block a user