From nobody Sat Feb 7 08:44:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569588828; cv=none; d=zoho.com; s=zohoarc; b=hYGOt2JB9VyX5grG/Xb+GPC49OlX6a6We6Fty2eUqiuhpp2H4rxDG1FQe1vD+tU0GyDMLzw3cLoMSBySZsMeef3e2sxPzS0xlCNIcznglKlGAC3kFQXduymok7KnM+726x76qipc8nL89yzB8lmSsABV3qVDIliDt9eTUoNgiqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569588828; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=mdV1RoXaGZeEIaJZt4jtge/lpIA5KvL3ZF5pEVIqSx4=; b=XYX/MkOPO/ws/gXTaW0LENhV7maXgaXN8r6LXmcTLNga497RqEoBQ8gWaR4pfJ6kRDCIrjl31EbbEMfxkFLo0y8o70PcukGLxbByYFDs5szRd7Bd9voQdecNgXNxaI2k+1odE6/U9fFd3ee6iSzbyBsICDeQiMbSWEtlY8iYxsA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1569588828809283.07882336988575; Fri, 27 Sep 2019 05:53:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A1D5300D219; Fri, 27 Sep 2019 12:53:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00E4060BF3; Fri, 27 Sep 2019 12:53:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BC761180B536; Fri, 27 Sep 2019 12:53:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8RCqYT1002572 for ; Fri, 27 Sep 2019 08:52:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id BD1AC1001B13; Fri, 27 Sep 2019 12:52:34 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (dhcp-94.gsslab.fab.redhat.com [10.33.9.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 313181001938; Fri, 27 Sep 2019 12:52:34 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 27 Sep 2019 13:52:23 +0100 Message-Id: <20190927125225.22432-5-berrange@redhat.com> In-Reply-To: <20190927125225.22432-1-berrange@redhat.com> References: <20190927125225.22432-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 4/6] tools: switch to build the new virt-host-validate impl 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 27 Sep 2019 12:53:47 +0000 (UTC) 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=C3=A9 --- 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 =20 BuildRequires: golang >=3D 1.11 +BuildRequires: golang-ipath(github.com/spf13/pflag) +BuildRequires: golang-ipath(golang.org/x/sys) +BuildRequires: golang-ipath(github.com/ghodss/yaml) =20 Provides: bundled(gnulib) =20 @@ -1167,6 +1170,7 @@ export SOURCE_DATE_EPOCH=3D$(stat --printf=3D'%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 =20 export GO111MODULE=3Doff export GOPATH=3D/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 =20 %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], [ =20 AC_DEFUN([LIBVIRT_CHECK_HOST_VALIDATE], [ if test "x$with_host_validate" !=3D "xno"; then - if test "x$with_win" =3D "xyes"; then + if test "$with_go" =3D "no"; then if test "x$with_host_validate" =3D "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=3Dno; + with_host_validate=3Dno fi else - with_host_validate=3Dyes; + with_host_validate=3Dyes fi fi =20 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 =3D \ vsh-table.c vsh-table.h =20 virt_host_validate_SOURCES =3D \ - virt-host-validate.c \ - virt-host-validate-common.c virt-host-validate-common.h - -VIRT_HOST_VALIDATE_QEMU =3D \ - virt-host-validate-qemu.c \ - virt-host-validate-qemu.h -VIRT_HOST_VALIDATE_LXC =3D \ - virt-host-validate-lxc.c \ - virt-host-validate-lxc.h -VIRT_HOST_VALIDATE_BHYVE =3D \ - virt-host-validate-bhyve.c \ - virt-host-validate-bhyve.h -if WITH_QEMU -virt_host_validate_SOURCES +=3D $(VIRT_HOST_VALIDATE_QEMU) -else ! WITH_QEMU -EXTRA_DIST +=3D $(VIRT_HOST_VALIDATE_QEMU) -endif ! WITH_QEMU - -if WITH_LXC -virt_host_validate_SOURCES +=3D $(VIRT_HOST_VALIDATE_LXC) -else ! WITH_LXC -EXTRA_DIST +=3D $(VIRT_HOST_VALIDATE_LXC) -endif ! WITH_LXC - -if WITH_BHYVE -virt_host_validate_SOURCES +=3D $(VIRT_HOST_VALIDATE_BHYVE) -else ! WITH_BHYVE -EXTRA_DIST +=3D $(VIRT_HOST_VALIDATE_BHYVE) -endif ! WITH_BHYVE - -virt_host_validate_LDFLAGS =3D \ - $(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) =20 -virt_host_validate_LDADD =3D \ - ../src/libvirt.la \ - ../gnulib/lib/libgnu.la \ - $(NULL) +virt_host_validate_rulesdir =3D $(pkgdatadir)/host-validate +virt_host_validate_rules_DATA =3D \ + $(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) =20 -virt_host_validate_CFLAGS =3D \ - $(AM_CFLAGS) \ - $(NULL) +EXTRA_DIST +=3D $(virt_host_validate_rules_DATA) $(virt_host_validate_SOUR= CES) + +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 =20 # 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 =20 =3Dover 4 =20 -=3Ditem C<-v>, C<--version> +=3Ditem C<-f>, C<--facts> =20 -Display the command version +Display all the key, value pairs set for facts + +=3Ditem C<-r>, C<--rules-dir> + +Override the default location of the XML rule files =20 =3Ditem C<-h>, C<--help> =20 @@ -52,11 +56,11 @@ Alternatively report bugs to your software distributor = / vendor. =20 =3Dhead1 COPYRIGHT =20 -Copyright (C) 2012 by Red Hat, Inc. +Copyright (C) 2019 by Red Hat, Inc. =20 =3Dhead1 LICENSE =20 -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 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list