This stop building the existing C based virt-host-validate implementation and instead builds the Go implementation. For the RPM spec this is written to rely on pre-packaged RPMs for the 3rd party Go dependencies. These are all already present in supported Fedora releases. Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- libvirt.spec.in | 15 ++++++++ m4/virt-host-validate.m4 | 8 ++-- tools/Makefile.am | 75 ++++++++++++++++-------------------- tools/virt-host-validate.pod | 12 ++++-- 4 files changed, 60 insertions(+), 50 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index 1c74dbb252..f336296a08 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -402,6 +402,9 @@ BuildRequires: firewalld-filesystem %endif BuildRequires: golang >= 1.11 +BuildRequires: golang-ipath(github.com/spf13/pflag) +BuildRequires: golang-ipath(golang.org/x/sys) +BuildRequires: golang-ipath(github.com/ghodss/yaml) Provides: bundled(gnulib) @@ -1167,6 +1170,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/%{name}.spec) # must make a local Go root with the old style # dir naming scheme/hierarchy mkdir -p gocode/src/libvirt.org +ln -s `pwd`/tools/host-validate `pwd`/gocode/src/libvirt.org/host-validate export GO111MODULE=off export GOPATH=/usr/share/gocode:`pwd`/gocode @@ -1890,6 +1894,17 @@ exit 0 %if %{with_qemu} %{_datadir}/systemtap/tapset/libvirt_qemu_probes*.stp %endif +%dir %{_datadir}/libvirt/host-validate +%{_datadir}/libvirt/host-validate/builtin.yaml +%{_datadir}/libvirt/host-validate/cpu.yaml +%{_datadir}/libvirt/host-validate/freebsd-kernel.yaml +%{_datadir}/libvirt/host-validate/linux-acpi.yaml +%{_datadir}/libvirt/host-validate/linux-cgroups.yaml +%{_datadir}/libvirt/host-validate/linux-cpu.yaml +%{_datadir}/libvirt/host-validate/linux-devices.yaml +%{_datadir}/libvirt/host-validate/linux-iommu.yaml +%{_datadir}/libvirt/host-validate/linux-namespaces.yaml +%{_datadir}/libvirt/host-validate/linux-pci.yaml %if %{with_bash_completion} %{_datadir}/bash-completion/completions/virsh diff --git a/m4/virt-host-validate.m4 b/m4/virt-host-validate.m4 index e43cec5366..16f2d36acd 100644 --- a/m4/virt-host-validate.m4 +++ b/m4/virt-host-validate.m4 @@ -21,14 +21,14 @@ AC_DEFUN([LIBVIRT_ARG_HOST_VALIDATE], [ AC_DEFUN([LIBVIRT_CHECK_HOST_VALIDATE], [ if test "x$with_host_validate" != "xno"; then - if test "x$with_win" = "xyes"; then + if test "$with_go" = "no"; then if test "x$with_host_validate" = "xyes"; then - AC_MSG_ERROR([virt-host-validate is not supported on Windows]) + AC_MSG_ERROR([Cannot build virt-host-validate without Go toolchain]) else - with_host_validate=no; + with_host_validate=no fi else - with_host_validate=yes; + with_host_validate=yes fi fi diff --git a/tools/Makefile.am b/tools/Makefile.am index 29fdbfe846..728de475a2 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -157,50 +157,41 @@ libvirt_shell_la_SOURCES = \ vsh-table.c vsh-table.h virt_host_validate_SOURCES = \ - virt-host-validate.c \ - virt-host-validate-common.c virt-host-validate-common.h - -VIRT_HOST_VALIDATE_QEMU = \ - virt-host-validate-qemu.c \ - virt-host-validate-qemu.h -VIRT_HOST_VALIDATE_LXC = \ - virt-host-validate-lxc.c \ - virt-host-validate-lxc.h -VIRT_HOST_VALIDATE_BHYVE = \ - virt-host-validate-bhyve.c \ - virt-host-validate-bhyve.h -if WITH_QEMU -virt_host_validate_SOURCES += $(VIRT_HOST_VALIDATE_QEMU) -else ! WITH_QEMU -EXTRA_DIST += $(VIRT_HOST_VALIDATE_QEMU) -endif ! WITH_QEMU - -if WITH_LXC -virt_host_validate_SOURCES += $(VIRT_HOST_VALIDATE_LXC) -else ! WITH_LXC -EXTRA_DIST += $(VIRT_HOST_VALIDATE_LXC) -endif ! WITH_LXC - -if WITH_BHYVE -virt_host_validate_SOURCES += $(VIRT_HOST_VALIDATE_BHYVE) -else ! WITH_BHYVE -EXTRA_DIST += $(VIRT_HOST_VALIDATE_BHYVE) -endif ! WITH_BHYVE - -virt_host_validate_LDFLAGS = \ - $(AM_LDFLAGS) \ - $(PIE_LDFLAGS) \ - $(COVERAGE_LDFLAGS) \ - $(NULL) + $(srcdir)/host-validate/go.mod \ + $(srcdir)/host-validate/go.sum \ + $(srcdir)/host-validate/main.go \ + $(srcdir)/host-validate/pkg/facts.go \ + $(srcdir)/host-validate/pkg/facts_test.go \ + $(srcdir)/host-validate/pkg/engine.go \ + $(NULL) -virt_host_validate_LDADD = \ - ../src/libvirt.la \ - ../gnulib/lib/libgnu.la \ - $(NULL) +virt_host_validate_rulesdir = $(pkgdatadir)/host-validate +virt_host_validate_rules_DATA = \ + $(srcdir)/host-validate/rules/builtin.yaml \ + $(srcdir)/host-validate/rules/cpu.yaml \ + $(srcdir)/host-validate/rules/freebsd-kernel.yaml \ + $(srcdir)/host-validate/rules/linux-acpi.yaml \ + $(srcdir)/host-validate/rules/linux-cgroups.yaml \ + $(srcdir)/host-validate/rules/linux-cpu.yaml \ + $(srcdir)/host-validate/rules/linux-devices.yaml \ + $(srcdir)/host-validate/rules/linux-iommu.yaml \ + $(srcdir)/host-validate/rules/linux-namespaces.yaml \ + $(srcdir)/host-validate/rules/linux-pci.yaml \ + $(NULL) -virt_host_validate_CFLAGS = \ - $(AM_CFLAGS) \ - $(NULL) +EXTRA_DIST += $(virt_host_validate_rules_DATA) $(virt_host_validate_SOURCES) + +virt-host-validate$(EXEEXT): $(virt_host_validate_SOURCES) + $(AM_V_CC) cd $(srcdir)/host-validate && \ + $(GO) build $(GOBUILDFLAGS) -o $(abs_builddir)/$@ main.go +if WITH_HOST_VALIDATE +check-host-validate: + cd $(srcdir)/host-validate && $(GO) test $(GOTESTFLAGS) ./... +else ! WITH_HOST_VALIDATE +check-host-validate: +endif ! WITH_HOST_VALIDATE + +check-local: check-host-validate # virt-login-shell will be setuid, and must not link to anything # except glibc. It wil scrub the environment and then invoke the diff --git a/tools/virt-host-validate.pod b/tools/virt-host-validate.pod index 121bb7ed7a..df10530916 100644 --- a/tools/virt-host-validate.pod +++ b/tools/virt-host-validate.pod @@ -19,9 +19,13 @@ to those relevant for that virtualization technology =over 4 -=item C<-v>, C<--version> +=item C<-f>, C<--facts> -Display the command version +Display all the key, value pairs set for facts + +=item C<-r>, C<--rules-dir> + +Override the default location of the XML rule files =item C<-h>, C<--help> @@ -52,11 +56,11 @@ Alternatively report bugs to your software distributor / vendor. =head1 COPYRIGHT -Copyright (C) 2012 by Red Hat, Inc. +Copyright (C) 2019 by Red Hat, Inc. =head1 LICENSE -virt-host-validate is distributed under the terms of the GNU GPL v2+. +virt-host-validate is distributed under the terms of the GNU LGPL v2.1+. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list