From 81db21bbe8da0855ab1f2fdb3158d52e6415bda1 Mon Sep 17 00:00:00 2001 From: Didik Supriadi Date: Fri, 1 Oct 2021 01:05:05 +0200 Subject: [PATCH 01/16] Translated using Weblate (Indonesian) Currently translated at 100.0% (84 of 84 strings) Translation: virt-top/master Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/id/ --- po/id.po | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/po/id.po b/po/id.po index 614a010..d7d3752 100644 --- a/po/id.po +++ b/po/id.po @@ -5,13 +5,14 @@ # Translators: # Andika Triwidada , 2014, 2021. # Andika Triwidada , 2017. #zanata, 2021. +# Didik Supriadi , 2021. msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2017-03-27 11:32+0000\n" -"PO-Revision-Date: 2021-05-26 14:02+0000\n" -"Last-Translator: Andika Triwidada \n" +"PO-Revision-Date: 2021-08-22 11:04+0000\n" +"Last-Translator: Didik Supriadi \n" "Language-Team: Indonesian \n" "Language: id\n" @@ -19,7 +20,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.6.2\n" +"X-Generator: Weblate 4.8\n" #: ../src/top.ml:1670 msgid "# %s virt-top configuration file\n" @@ -118,7 +119,7 @@ msgstr "CPU: %2.1f%% Mem: %Ld MB (%Ld MB oleh guest)" #: ../src/top.ml:1493 msgid "Change delay from %.1f to: " -msgstr "Ubah tundaan dari %.1f ke:" +msgstr "Ubah delay dari %.1f ke: " #: ../src/top.ml:177 ../src/top.ml:175 msgid "Connect to libvirt URI" @@ -343,7 +344,7 @@ msgstr "Menulis pengaturan ke %s" #: ../src/top.ml:1745 msgid "default" -msgstr "baku" +msgstr "default" #: ../src/top.ml:210 msgid "dump output to stdout (no userinterface)" -- 1.8.3.1 From 01ab7183772e2b2a8a42a088d4521832577a0883 Mon Sep 17 00:00:00 2001 From: Pavel Borecki Date: Fri, 1 Oct 2021 01:05:05 +0200 Subject: [PATCH 02/16] Translated using Weblate (Czech) Currently translated at 100.0% (84 of 84 strings) Translation: virt-top/master Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/cs/ --- po/cs.po | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/po/cs.po b/po/cs.po index 2152b87..fea852f 100644 --- a/po/cs.po +++ b/po/cs.po @@ -1,20 +1,21 @@ # Zdenek , 2016. #zanata # Zdenek , 2017. #zanata -# Pavel Borecki , 2018. #zanata +# Pavel Borecki , 2018. #zanata, 2021. msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2017-03-27 11:32+0000\n" -"PO-Revision-Date: 2018-11-27 06:18-0500\n" +"PO-Revision-Date: 2021-09-04 20:04+0000\n" "Last-Translator: Pavel Borecki \n" -"Language-Team: Czech\n" +"Language-Team: Czech \n" "Language: cs\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2\n" -"X-Generator: Zanata 4.6.2\n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" +"X-Generator: Weblate 4.8\n" #: ../src/top.ml:1670 msgid "# %s virt-top configuration file\n" @@ -255,7 +256,7 @@ msgstr "Zabezpečený („kiosk“) režim" #: ../src/top.ml:1780 msgid "Select sort field" -msgstr "Vybrat pole řazení" +msgstr "Vybrat kolonku, podle které řadit" #: ../src/top.ml:191 msgid "Send debug messages to file" @@ -323,7 +324,7 @@ msgstr "Přepnout fyzické procesory" #: ../src/top.ml:1515 msgid "Type key or use up and down cursor keys." -msgstr "Zadejte klávesu nebo použijte klávesy šipka nahoru a dolů" +msgstr "Zadejte klávesu nebo použijte klávesy šipka nahoru a dolů." #: ../src/top.ml:1809 msgid "Unknown command - try 'h' for help" -- 1.8.3.1 From 5405de2920fa56529b56f61ff683806e72ddfa6a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 1 Oct 2021 15:33:29 +0100 Subject: [PATCH 03/16] Convert to using automake --- .gitignore | 34 ++- ChangeLog | 82 +++++++ MANIFEST | 78 ------- Make.rules.in | 78 ------- Makefile.am | 69 ++++++ Makefile.in | 68 ------ config.h.in | 19 -- config.rpath | 684 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 91 ++++++-- ocaml-dep.sh.in | 83 +++++++ ocaml-link.sh.in | 58 +++++ po/LINGUAS | 1 + po/Makefile.am | 95 ++++++++ po/Makefile.in | 80 ------- po/POTFILES | 15 +- po/POTFILES-ml | 14 ++ po/virt-top.pot | 203 +++++++++-------- src/.depend | 160 ++++++++++--- src/Makefile.am | 125 ++++++++++ src/Makefile.in | 111 --------- src/dummy.c | 2 + 21 files changed, 1539 insertions(+), 611 deletions(-) delete mode 100644 MANIFEST delete mode 100644 Make.rules.in create mode 100644 Makefile.am delete mode 100644 Makefile.in delete mode 100644 config.h.in create mode 100755 config.rpath create mode 100755 ocaml-dep.sh.in create mode 100755 ocaml-link.sh.in create mode 100644 po/Makefile.am delete mode 100644 po/Makefile.in create mode 100644 po/POTFILES-ml create mode 100644 src/Makefile.am delete mode 100644 src/Makefile.in create mode 100644 src/dummy.c diff --git a/.gitignore b/.gitignore index e3f77e7..3eacd90 100644 --- a/.gitignore +++ b/.gitignore @@ -6,26 +6,38 @@ *.cmxa *.dll *.exe +*.gmo *.o *.opt *.orig *.so *~ -META Makefile -aclocal.m4 -config.cache -config.h -config.log -config.status -configure -core -core.* -html +Makefile.in +.deps + +/META +/aclocal.m4 +/compile +/config.cache +/config.h +/config.h.in +/config.log +/config.status +/configure +/core +/core.* +/depcomp +/html +/missing +/ocaml-dep.sh +/ocaml-link.sh +/src/.depend +/stamp-h1 -/Make.rules /autom4te.cache +/local* /po/*.mo /po/*.po.bak /src/opt_gettext.ml diff --git a/ChangeLog b/ChangeLog index 6690b45..08dd5ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,85 @@ +2021-10-01 Richard W.M. Jones + + Convert to using automake + +2020-09-21 Richard W.M. Jones + + Merge remote-tracking branch 'weblate/master' into master + +2020-09-13 Emilio Herrera + + Translated using Weblate (Spanish) + Currently translated at 84.5% (71 of 84 strings) + + Translation: virt-top/master + Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/es/ + +2020-08-28 Julien Humbert + + Translated using Weblate (French) + Currently translated at 20.2% (17 of 84 strings) + + Translation: virt-top/master + Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/fr/ + +2020-08-28 Yuri Chornoivan + + Translated using Weblate (Ukrainian) + Currently translated at 100.0% (84 of 84 strings) + + Translation: virt-top/master + Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/uk/ + +2020-08-28 Göran Uddeborg + + Translated using Weblate (Swedish) + Currently translated at 100.0% (84 of 84 strings) + + Translation: virt-top/master + Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/sv/ + +2020-08-28 Oğuz Ersen + + Translated using Weblate (Turkish) + Currently translated at 100.0% (84 of 84 strings) + + Translation: virt-top/master + Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/tr/ + +2020-08-28 Piotr Drąg + + Translated using Weblate (Polish) + Currently translated at 100.0% (84 of 84 strings) + + Translation: virt-top/master + Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/pl/ + + Translated using Weblate (Polish) + + Currently translated at 100.0% (84 of 84 strings) + + Translation: virt-top/master + Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/pl/ + +2020-08-28 Weblate + + Update translation files + Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. + + Translation: virt-top/master + Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/ + +2020-08-27 Richard W.M. Jones + + Update translations from Zanata (RHBZ#1868108). + +2019-08-21 Stephane Glondu + + libvirt: Handle VIR_DOMAIN_PMSUSPENDED state. + Fixes FTBFS with ocaml-libvirt 0.6.1.5. + + RWMJ: Added documentation and changed the letter to 'M'. + 2019-08-20 Richard W.M. Jones Version 1.0.9. diff --git a/MANIFEST b/MANIFEST deleted file mode 100644 index 4e4014b..0000000 --- a/MANIFEST +++ /dev/null @@ -1,78 +0,0 @@ -.gitignore -ChangeLog -config.guess -config.h.in -config.sub -configure.ac -COPYING -COPYING.LIB -HACKING -gitlog-to-changelog -install-sh -Makefile.in -Make.rules.in -MANIFEST -m4/ocaml.m4 -po/as.po -po/ca.po -po/de.po -po/es.po -po/eu.po -po/fr.po -po/gu.po -po/hu.po -po/id.po -po/it.po -po/ja.po -po/ka.po -po/kn.po -po/LINGUAS -po/Makefile.in -po/ml.po -po/mr.po -po/nl.po -po/or.po -po/pa.po -po/pl.po -po/pt_BR.po -po/pt.po -po/POTFILES -po/ru.po -po/sr.po -po/sv.po -po/te.po -po/tg.po -po/tr.po -po/uk.po -po/virt-top.pot -po/zanata-pull.sh -po/zanata.xml -po/zh_CN.po -po/zh_TW.po -README -TODO -src/.depend -src/Makefile.in -src/README -src/collect.ml -src/collect.mli -src/csv_output.ml -src/csv_output.mli -src/main.ml -src/opt_calendar.ml -src/opt_csv.ml -src/opt_xml.ml -src/redraw.ml -src/redraw.mli -src/screen.ml -src/screen.mli -src/stream_output.ml -src/stream_output.mli -src/top.ml -src/top.mli -src/types.ml -src/types.mli -src/utils.ml -src/utils.mli -src/version.ml.in -src/virt-top.pod diff --git a/Make.rules.in b/Make.rules.in deleted file mode 100644 index 12037e1..0000000 --- a/Make.rules.in +++ /dev/null @@ -1,78 +0,0 @@ -# ocaml-libvirt -# Copyright (C) 2007-2009 Red Hat Inc., Richard W.M. Jones -# -# 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 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, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -# This file is included by Makefiles in subdirectories. - -OCAMLFIND = @OCAMLFIND@ -OCAMLDEP = @OCAMLDEP@ -OCAMLC = @OCAMLC@ -OCAMLOPT = @OCAMLOPT@ - -# Common rules for building OCaml objects. - -ifneq ($(OCAMLFIND),) -.mli.cmi: - $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $< -.ml.cmo: - $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $< -.ml.cmx: - $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $< -else -.mli.cmi: - $(OCAMLC) $(OCAMLCFLAGS) $(OCAMLCINCS) -c $< -.ml.cmo: - $(OCAMLC) $(OCAMLCFLAGS) $(OCAMLCINCS) -c $< -.ml.cmx: - $(OCAMLOPT) $(OCAMLOPTFLAGS) $(OCAMLOPTINCS) -c $< -endif - -%.ml %.mli: %.mly - ocamlyacc $< -.mll.ml: - ocamllex $< - -# Dependencies. - -depend: .depend - -ifneq ($(OCAMLFIND),) -.depend: $(wildcard *.mli) $(wildcard *.ml) - rm -f $@ $@-t - $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) $(OCAMLDEPFLAGS) $^ | \ - sed 's/ :/:/' | \ - sed 's/ *$$//' | \ - sed -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \ - sort > $@-t - mv $@-t $@ -else -.depend: $(wildcard *.mli) $(wildcard *.ml) - rm -f $@ $@-t - $(OCAMLDEP) $(OCAMLCINCS) $(OCAMLDEPFLAGS) $^ | \ - sed 's/ :/:/' | \ - sed 's/ *$$//' | \ - sed -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \ - sort > $@-t - mv $@-t $@ -endif - -ifeq ($(wildcard .depend),.depend) -include .depend -endif - -.PHONY: depend dist check-manifest dpkg doc - -.SUFFIXES: .cmo .cmi .cmx .ml .mli .mll .mly diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..699ccce --- /dev/null +++ b/Makefile.am @@ -0,0 +1,69 @@ +# virt-top +# Copyright (C) 2007-2021 Red Hat Inc., Richard W.M. Jones +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +SUBDIRS = src po + +EXTRA_DIST = \ + .gitignore \ + gitlog-to-changelog \ + HACKING + +dist-hook: po/POTFILES po/POTFILES-ml + +po/POTFILES: configure.ac + rm -f $@ $@-t + find . -name '*.c' | \ + grep -v '/$(PACKAGE_NAME)-$(PACKAGE_VERSION)/' | \ + LC_ALL=C sort > $@-t + mv $@-t $@ + +po/POTFILES-ml: configure.ac + rm -f $@ $@-t + find . -name '*.ml' | \ + grep -v '/$(PACKAGE_NAME)-$(PACKAGE_VERSION)/' | \ + LC_ALL=C sort > $@-t + mv $@-t $@ + +# Commit everything in current directory to HEAD, and set commit +# message to current version (only for maintainer). + +maintainer-commit: + git commit -a -m "Version $(VERSION)." + +# Tag HEAD with current version (only for maintainer). + +maintainer-tag: + git tag -a "v$(VERSION)" -m "Version $(VERSION)" -f + +# Maintainer only: check no files are missing from EXTRA_DIST rules, +# and that all generated files have been included in the tarball. +# (Note you must have done 'make dist') + +maintainer-check-extra-dist: + zcat $(PACKAGE_NAME)-$(VERSION).tar.gz | tar tf - | sort | \ + sed 's,^$(PACKAGE_NAME)-$(VERSION)/,,' > tarfiles + git ls-files | sort > gitfiles + comm -13 tarfiles gitfiles > comm-out + @echo Checking for differences between EXTRA_DIST and git ... + cat comm-out + [ ! -s comm-out ] + rm tarfiles gitfiles comm-out + @echo PASS: EXTRA_DIST tests + +ChangeLog: $(shell find -type f) + ./gitlog-to-changelog > $@.new + mv $@.new $@ diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index d0aec17..0000000 --- a/Makefile.in +++ /dev/null @@ -1,68 +0,0 @@ -# virt-top -# Copyright (C) 2007-2014 Red Hat Inc., Richard W.M. Jones -# -# 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 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, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -PACKAGE = @PACKAGE_NAME@ -VERSION = @PACKAGE_VERSION@ - -INSTALL = @INSTALL@ - -MAKENSIS = @MAKENSIS@ - -SUBDIRS = src - -all opt depend install: - $(MAKE) -C src $@ - -clean: - for d in . $(SUBDIRS); do \ - (cd $$d; rm -f *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so *.opt *~ *.dll *.exe core); \ - done - rm -f src/virt-top - -distclean: clean - rm -f config.h config.log config.status configure - rm -rf autom4te.cache - rm -f Makefile - rm -f src/Makefile - -# Distribution. - -dist: ChangeLog - $(MAKE) check-manifest - rm -rf $(PACKAGE)-$(VERSION) - mkdir $(PACKAGE)-$(VERSION) - tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf - - $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/ - $(INSTALL) -m 0644 aclocal.m4 $(PACKAGE)-$(VERSION)/ - $(INSTALL) -m 0644 src/virt-top.1 $(PACKAGE)-$(VERSION)/src/ - $(INSTALL) -m 0644 src/virt-top.txt $(PACKAGE)-$(VERSION)/src/ - tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION) - rm -rf $(PACKAGE)-$(VERSION) - ls -l $(PACKAGE)-$(VERSION).tar.gz - -check-manifest: - git ls-files | sort > .check-manifest; \ - sort MANIFEST > .orig-manifest; \ - diff -u .orig-manifest .check-manifest; rv=$$?; \ - rm -f .orig-manifest .check-manifest; \ - exit $$rv - -ChangeLog: $(shell find -type f) - ./gitlog-to-changelog > $@.new - mv $@.new $@ - -.PHONY: all opt depend install clean distclean force diff --git a/config.h.in b/config.h.in deleted file mode 100644 index f80de9c..0000000 --- a/config.h.in +++ /dev/null @@ -1,19 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION diff --git a/config.rpath b/config.rpath new file mode 100755 index 0000000..4b7dc49 --- /dev/null +++ b/config.rpath @@ -0,0 +1,684 @@ +#! /bin/sh +# Output a system dependent set of variables, describing how to set the +# run time search path of shared libraries in an executable. +# +# Copyright 1996-2021 Free Software Foundation, Inc. +# Taken from GNU libtool, 2001 +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's _LT_CC_BASENAME. + +for cc_temp in $CC""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` + +# Code taken from libtool.m4's _LT_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + mingw* | cygwin* | pw32* | os2* | cegcc*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu) + case $cc_basename in + ecc*) + wl='-Wl,' + ;; + icc* | ifort*) + wl='-Wl,' + ;; + lf95*) + wl='-Wl,' + ;; + nagfor*) + wl='-Wl,-Wl,,' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + wl='-Wl,' + ;; + ccc*) + wl='-Wl,' + ;; + xl* | bgxl* | bgf* | mpixl*) + wl='-Wl,' + ;; + como) + wl='-lopt=' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ F* | *Sun*Fortran*) + wl= + ;; + *Sun\ C*) + wl='-Wl,' + ;; + esac + ;; + esac + ;; + newsos6) + ;; + *nto* | *qnx*) + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + rdos*) + ;; + solaris*) + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + wl='-Qoption ld ' + ;; + *) + wl='-Wl,' + ;; + esac + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; + unicos*) + wl='-Wl,' + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's _LT_LINKER_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +case "$host_os" in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + case "$host_os" in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + case "$host_cpu" in + powerpc) + ;; + m68k) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32* | cegcc*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + haiku*) + ;; + interix[3-9]*) + hardcode_direct=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + else + ld_shlibs=no + fi + ;; + esac + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = no; then + hardcode_libdir_flag_spec= + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + else + aix_use_runtimelinking=no + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + fi + if test -z "$aix_libpath"; then + aix_libpath="/usr/lib:/lib" + fi + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + case "$host_cpu" in + powerpc) + ;; + m68k) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + bsdi[45]*) + ;; + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + hardcode_direct=no + if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then + : + else + ld_shlibs=no + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd2.[01]*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd* | dragonfly* | midnightbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + hpux11*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + ;; + *) + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + *nto* | *qnx*) + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + ;; + sysv5* | sco3.2v5* | sco5v6*) + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. +# Unlike libtool.m4, here we don't care about _all_ names of the library, but +# only about the one the linker finds when passed -lNAME. This is the last +# element of library_names_spec in libtool.m4, or possibly two of them if the +# linker has special search rules. +library_names_spec= # the last element of library_names_spec in libtool.m4 +libname_spec='lib$name' +case "$host_os" in + aix3*) + library_names_spec='$libname.a' + ;; + aix[4-9]*) + library_names_spec='$libname$shrext' + ;; + amigaos*) + case "$host_cpu" in + powerpc*) + library_names_spec='$libname$shrext' ;; + m68k) + library_names_spec='$libname.a' ;; + esac + ;; + beos*) + library_names_spec='$libname$shrext' + ;; + bsdi[45]*) + library_names_spec='$libname$shrext' + ;; + cygwin* | mingw* | pw32* | cegcc*) + shrext=.dll + library_names_spec='$libname.dll.a $libname.lib' + ;; + darwin* | rhapsody*) + shrext=.dylib + library_names_spec='$libname$shrext' + ;; + dgux*) + library_names_spec='$libname$shrext' + ;; + freebsd[23].*) + library_names_spec='$libname$shrext$versuffix' + ;; + freebsd* | dragonfly* | midnightbsd*) + library_names_spec='$libname$shrext' + ;; + gnu*) + library_names_spec='$libname$shrext' + ;; + haiku*) + library_names_spec='$libname$shrext' + ;; + hpux9* | hpux10* | hpux11*) + case $host_cpu in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + library_names_spec='$libname$shrext' + ;; + interix[3-9]*) + library_names_spec='$libname$shrext' + ;; + irix5* | irix6* | nonstopux*) + library_names_spec='$libname$shrext' + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu) + library_names_spec='$libname$shrext' + ;; + knetbsd*-gnu) + library_names_spec='$libname$shrext' + ;; + netbsd*) + library_names_spec='$libname$shrext' + ;; + newsos6) + library_names_spec='$libname$shrext' + ;; + *nto* | *qnx*) + library_names_spec='$libname$shrext' + ;; + openbsd*) + library_names_spec='$libname$shrext$versuffix' + ;; + os2*) + libname_spec='$name' + shrext=.dll + library_names_spec='$libname.a' + ;; + osf3* | osf4* | osf5*) + library_names_spec='$libname$shrext' + ;; + rdos*) + ;; + solaris*) + library_names_spec='$libname$shrext' + ;; + sunos4*) + library_names_spec='$libname$shrext$versuffix' + ;; + sysv4 | sysv4.3*) + library_names_spec='$libname$shrext' + ;; + sysv4*MP*) + library_names_spec='$libname$shrext' + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + library_names_spec='$libname$shrext' + ;; + tpf*) + library_names_spec='$libname$shrext' + ;; + uts4*) + library_names_spec='$libname$shrext' + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <= 4.03, but in theory might be disabled by +dnl downstream distros. +OCAML_RUNTIME_VARIANT_PIC_OPTION="" +if test "x$OCAMLC" != "xno"; then + AC_MSG_CHECKING([if OCaml ‘-runtime-variant _pic’ works]) + rm -f conftest.ml contest + echo 'print_endline "hello world"' > conftest.ml + if $OCAMLOPT conftest.ml -runtime-variant _pic -o conftest >&5 2>&5 ; then + AC_MSG_RESULT([yes]) + OCAML_RUNTIME_VARIANT_PIC_OPTION="-runtime-variant _pic" + else + AC_MSG_RESULT([no]) + fi + rm -f conftest.ml contest +fi +AC_SUBST([OCAML_RUNTIME_VARIANT_PIC_OPTION]) dnl Check for optional perldoc (for building manual pages). -AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc) +AC_CHECK_PROG([HAVE_PERLDOC], perldoc, perldoc) +AM_CONDITIONAL([HAVE_PERLDOC], [test "x$HAVE_PERLDOC" = "xperldoc"]) dnl Check for recommended ocaml-gettext tool. -AC_CHECK_PROG(OCAML_GETTEXT,ocaml-gettext,ocaml-gettext) - -dnl Check for msgfmt tool. -AC_CHECK_PROG(MSGFMT,msgfmt,msgfmt) +AC_CHECK_PROG([OCAML_GETTEXT], ocaml-gettext, ocaml-gettext) +AM_CONDITIONAL([HAVE_OCAML_GETTEXT],[test "x$OCAML_GETTEXT" = "xocaml-gettext"]) + +dnl Check for GNU gettext tools (optional). +AC_CHECK_PROG([XGETTEXT],[xgettext],[xgettext],[no]) +AC_CHECK_PROG([MSGCAT],[msgcat],[msgcat],[no]) +AC_CHECK_PROG([MSGFMT],[msgfmt],[msgfmt],[no]) +AC_CHECK_PROG([MSGMERGE],[msgmerge],[msgmerge],[no]) + +dnl Check they are the GNU gettext tools. +AC_MSG_CHECKING([msgfmt is GNU tool]) +if $MSGFMT --version >/dev/null 2>&1 && $MSGFMT --version | grep -q 'GNU gettext +'; then + msgfmt_is_gnu=yes +else + msgfmt_is_gnu=no +fi +AC_MSG_RESULT([$msgfmt_is_gnu]) +AM_CONDITIONAL([HAVE_GNU_GETTEXT], + [test "x$XGETTEXT" != "xno" && test "x$MSGCAT" != "xno" && test "x$MSGFMT" != "xno" && test "x$MSGMERGE" != "xno" && test "x$msgfmt_is_gnu" != "xno"]) -dnl Substitute CFLAGS and LDFLAGS if set. -AC_SUBST([CFLAGS]) -AC_SUBST([LDFLAGS]) +dnl Check for gettext. +AM_GNU_GETTEXT([external]) dnl Write gettext modules for the programs. dnl http://www.le-gall.net/sylvain+violaine/documentation/ocaml-gettext/html/reference-manual/ch03s04.html @@ -120,8 +170,9 @@ echo "------------------------------------------------------------" dnl Produce output files. AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_FILES([ocaml-dep.sh], [chmod +x,-w ocaml-dep.sh]) +AC_CONFIG_FILES([ocaml-link.sh], [chmod +x,-w ocaml-link.sh]) AC_CONFIG_FILES([Makefile - Make.rules po/Makefile src/Makefile src/version.ml diff --git a/ocaml-dep.sh.in b/ocaml-dep.sh.in new file mode 100755 index 0000000..49c816a --- /dev/null +++ b/ocaml-dep.sh.in @@ -0,0 +1,83 @@ +#!/bin/bash - +# (C) Copyright 2009-2020 Red Hat Inc. +# @configure_input@ +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# This is a smarter wrapper around ocamldep(1) which is used to create +# the .depend files which are present in each subdirectory that builds +# OCaml code. +# +# Usage: +# .depend: *.mli *.ml +# $(top_builddir)/ocaml-dep.sh $^ +# -include .depend + +set -e + +# List of directories that contain common OCaml libraries. If it +# contains OCaml code that can be included from another directory, +# then it should go here. Note that OCaml modules in these +# directories must have unique names (eg. not ‘Utils’) else +# dependencies don't get built right. +include_dirs=" +common/mlgettext +common/mlpcre +common/mlprogress +common/mlstdutils +common/mltools +common/mlutils +common/mlv2v +common/mlvisit +common/mlxml +lib +" + +# Output file is always created in the current directory. +output=.depend + +subdir=$(realpath --relative-to=@abs_top_builddir@ .) +srcdir=$(realpath --relative-to=. @abs_top_srcdir@/${subdir}) +srcdir_re=$(realpath --relative-to=. @abs_top_srcdir@/${subdir} | sed 's/\./[.]/g') +top_builddir=$(realpath --relative-to=. @abs_top_builddir@) + +includes="-I @abs_top_srcdir@/$subdir -I @abs_top_builddir@/$subdir" +for i in $include_dirs; do + includes="$includes -I @abs_top_srcdir@/$i -I @abs_top_builddir@/$i" +done + +rm -f $output $output-t + +echo "# OCaml dependencies generated by $0" > $output-t +echo >> $output-t + +# Rewrite paths +# 1. Normalize absolute srcdir to relative path +# 2. Object files (*.cm*, *.o), in srcdir: Rewrite to builddir +# 3. Generated _config.ml in srcdir: Rewrite to builddir +# 4. Other object files below abs_top_srcdir: rewrite to corresponding builddir +# 5. Eliminate "./" prefix +@OCAMLFIND@ ocamldep @OCAMLDEP_ALL@ @OCAMLDEP_ONE_LINE@ $includes "$@" \ + | sed \ + -e "s,@abs_top_srcdir@/${subdir},.,g" \ + -e "s,\B${srcdir_re}/\\([^ ]*[.]\\)\\(cm[^ ]*\\|o\\),\\1\\2,g" \ + -e "s,\B${srcdir_re}/\\([^ /]*_config[.]ml\\),\\1,g" \ + -e "s,@abs_top_srcdir@/\\([^ ]*[.]\\)\\(cm[^ ]*\\|o\\),${top_builddir}/\\1\\2,g" \ + -e 's,\(^\| \)./,\1,g' \ + >> $output-t + +chmod -w $output-t + +mv $output-t $output diff --git a/ocaml-link.sh.in b/ocaml-link.sh.in new file mode 100755 index 0000000..8f77dc2 --- /dev/null +++ b/ocaml-link.sh.in @@ -0,0 +1,58 @@ +#!/bin/bash - +# Script used to link OCaml programs. +# @configure_input@ +# (C) Copyright 2015-2020 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# See guestfs-hacking(1) section "HOW OCAML PROGRAMS ARE COMPILED AND LINKED" + +# Hack automake to link OCaml-based binaries properly. +# There is no other way to add the -cclib parameter to the end of +# the command line. + +# Usage: +# ./ocaml-link.sh -cclib '...' -- ARGS +# Pass the cclib argument separately, and the rest as separated +# arguments. + +TEMP=`getopt -a -o '' --long 'cclib:' \ + -n "$(basename $0)" -- "$@"` +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi +eval set -- "$TEMP" + +cclib= + +while true ; do + case "$1" in + -cclib|--cclib) cclib="$2" ; shift 2 ;; + --) shift ; break ;; + *) echo "Internal error!" ; exit 1 ;; + esac +done + +# Integration with silent rules of automake: print the full command +# line option in verbose mode. +if [ x"${V:-@AM_DEFAULT_VERBOSITY@}" = x1 ]; then + echo "$@" \ + @OCAML_RUNTIME_VARIANT_PIC_OPTION@ \ + -linkpkg \ + -cclib "'@LDFLAGS@ $cclib'" +fi +# NB -cclib must come last. +exec "$@" \ + @OCAML_RUNTIME_VARIANT_PIC_OPTION@ \ + -linkpkg \ + -cclib "@LDFLAGS@ $cclib" diff --git a/po/LINGUAS b/po/LINGUAS index b2c02a2..296b113 100644 --- a/po/LINGUAS +++ b/po/LINGUAS @@ -1,5 +1,6 @@ as ca +cs de es eu diff --git a/po/Makefile.am b/po/Makefile.am new file mode 100644 index 0000000..fc13f94 --- /dev/null +++ b/po/Makefile.am @@ -0,0 +1,95 @@ +# libguestfs +# Copyright (C) 2009-2020 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +DOMAIN = $(PACKAGE_NAME) +COPYRIGHT_HOLDER = Red Hat Inc. +MSGID_BUGS_ADDRESS = https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools + +# Languages. +# Don't use LINGUAS (uppercase) as Gentoo defines it (RHBZ#804464). +linguas := $(shell cat $(srcdir)/LINGUAS) + +POTFILES := $(shell $(SED) 's,^,$(top_srcdir)/,' $(srcdir)/POTFILES) +POTFILES_ML := $(shell $(SED) 's,^,$(top_srcdir)/,' $(srcdir)/POTFILES-ml) +POFILES := $(linguas:%=%.po) +GMOFILES := $(linguas:%=%.gmo) + +EXTRA_DIST = \ + LINGUAS \ + POTFILES POTFILES-ml \ + $(DOMAIN).pot \ + $(POFILES) \ + $(GMOFILES) \ + zanata-pull.sh \ + zanata.xml + +if HAVE_GNU_GETTEXT + +XGETTEXT_ARGS = \ + --default-domain=$(DOMAIN) \ + --from-code=utf-8 \ + --add-comments=TRANSLATORS: \ + --keyword=_ --keyword=N_ --keyword=__ --keyword=__x \ + --flag=error:3:c-format \ + --flag=error_at_line:5:c-format \ + --flag=asprintf:2:c-format \ + --flag=vasprintf:2:c-format \ + --flag=xasprintf:1:c-format \ + --copyright-holder='$(COPYRIGHT_HOLDER)' \ + --package-name="$(PACKAGE_NAME)" \ + --package-version="$(PACKAGE_VERSION)" \ + --msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" \ + --directory=$(top_srcdir) + +# For explanation, see +# http://mingw-users.1079350.n2.nabble.com/Getting-rid-of-xgettext-s-quot-CHARSET-quot-warning-td5620533.html +FIX_CHARSET = \ + $(SED) -i 's|text/plain; charset=CHARSET|text/plain; charset=utf-8|g' + +$(DOMAIN).pot: Makefile POTFILES $(POTFILES) POTFILES-ml $(POTFILES_ML) + rm -f $@-t + touch $@-t +if HAVE_OCAML_GETTEXT + cd $(top_srcdir) && $(OCAML_GETTEXT) --action extract --extract-pot $(abs_srcdir)/$@-t $(shell cat $(abs_srcdir)/POTFILES-ml) + \ + $(FIX_CHARSET) $@-t +endif + $(XGETTEXT) -j -o $@-t $(XGETTEXT_ARGS) \ + --files-from=$(abs_srcdir)/POTFILES + $(FIX_CHARSET) $@-t + mv $@-t $@ + +.po.gmo: + rm -f $@ $@-t + $(MSGFMT) -c -o $@-t $(srcdir)/$< + mv $@-t $@ + +# Install. +# Cannot use 'localedir' since this conflicts with autoconf. +langinstdir = $(datadir)/locale + +install-data-hook: $(GMOFILES) + mkdir -p $(DESTDIR)$(langinstdir) + for lang in $(linguas); do \ + d=$(DESTDIR)$(langinstdir)/$$lang/LC_MESSAGES; \ + mkdir -p $$d; \ + install -m 0644 $$lang.gmo $$d/$(DOMAIN).mo; \ + done + +.PRECIOUS: $(DOMAIN).pot $(POFILES) + +endif diff --git a/po/Makefile.in b/po/Makefile.in deleted file mode 100644 index 949c2d9..0000000 --- a/po/Makefile.in +++ /dev/null @@ -1,80 +0,0 @@ -# Makefile for po subdirectory. -# @configure_input@ -# -# Copyright (C) 2007-2008 Red Hat Inc. -# Written by Richard W.M. Jones -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -OCAML_GETTEXT_PACKAGE = virt-top -LINGUAS = $(shell cat LINGUAS) -SOURCES = POTFILES - -MSGFMT = @MSGFMT@ - -OCAML_GETTEXT = @OCAML_GETTEXT@ -OCAML_GETTEXT_EXTRACT_OPTIONS = -OCAML_GETTEXT_COMPILE_OPTIONS = -OCAML_GETTEXT_INSTALL_OPTIONS = -OCAML_GETTEXT_MERGE_OPTIONS = - -PODIR = @prefix@/share/locale - -POFILES = $(addsuffix .po,$(LINGUAS)) -MOFILES = $(addsuffix .mo,$(LINGUAS)) -POTFILE = $(OCAML_GETTEXT_PACKAGE).pot - -all: $(MOFILES) $(POTFILE) - -install: install-po - -uninstall: uninstall-po - -clean:: clean-po - -%.mo: %.po - $(MSGFMT) -o $@ $^ - -%.pot: $(SOURCES) $(shell cat $(SOURCES)) - $(OCAML_GETTEXT) --action extract $(OCAML_GETTEXT_EXTRACT_OPTIONS) \ - --extract-pot $@ $< - -# Also includes a fix for incorrectly escaped multi-byte sequences. -%.po: $(POTFILE) - $(OCAML_GETTEXT) --action merge $(OCAML_GETTEXT_MERGE_OPTIONS) \ - --merge-pot $(POTFILE) $@ - mv $@ $@.orig - perl -wpe 's/\\(\d{3})/pack "C*", $$1/ge' < $@.orig > $@ - -$(BUILDPO): - mkdir -p $(BUILDPO) - -.PRECIOUS: $(POTFILE) - -install-po: $(MOFILES) - $(OCAML_GETTEXT) --action install $(OCAML_GETTEXT_INSTALL_OPTIONS) \ - --install-textdomain $(OCAML_GETTEXT_PACKAGE) \ - --install-destdir $(PODIR) $(MOFILES) - -uninstall-po: - $(OCAML_GETTEXT) --action uninstall $(OCAML_GETTEXT_INSTALL_OPTIONS) \ - --uninstall-textdomain $(OCAML_GETTEXT_PACKAGE) \ - --uninstall-orgdir $(PODIR) $(MOFILES) - -clean-po: - -$(OCAML_GETTEXT) --action uninstall $(OCAML_GETTEXT_INSTALL_OPTIONS) \ - --uninstall-textdomain $(OCAML_GETTEXT_PACKAGE) \ - --uninstall-orgdir $(BUILDPO) $(MOFILES) - -$(RM) $(MOFILES) diff --git a/po/POTFILES b/po/POTFILES index 6150703..22b1625 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -1,14 +1 @@ -../src/collect.ml -../src/csv_output.ml -../src/main.ml -../src/opt_calendar.ml -../src/opt_csv.ml -../src/opt_gettext.ml -../src/opt_xml.ml -../src/redraw.ml -../src/screen.ml -../src/stream.ml -../src/top.ml -../src/types.ml -../src/utils.ml -../src/version.ml +./src/dummy.c diff --git a/po/POTFILES-ml b/po/POTFILES-ml new file mode 100644 index 0000000..b6356eb --- /dev/null +++ b/po/POTFILES-ml @@ -0,0 +1,14 @@ +./src/collect.ml +./src/csv_output.ml +./src/main.ml +./src/opt_calendar.ml +./src/opt_csv.ml +./src/opt_gettext.ml +./src/opt_xml.ml +./src/redraw.ml +./src/screen.ml +./src/stream_output.ml +./src/top.ml +./src/types.ml +./src/utils.ml +./src/version.ml diff --git a/po/virt-top.pot b/po/virt-top.pot index 3d7a1e5..09cd370 100644 --- a/po/virt-top.pot +++ b/po/virt-top.pot @@ -1,355 +1,366 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. +# Copyright (C) YEAR Red Hat Inc. +# This file is distributed under the same license as the virt-top package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-03-27 11:32+0000\n" +"Project-Id-Version: virt-top 1.0.9\n" +"Report-Msgid-Bugs-To: https://bugzilla.redhat.com/enter_bug.cgi?" +"component=libguestfs&product=Virtualization+Tools\n" +"POT-Creation-Date: 2021-10-01 16:15+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -#: ../src/top.ml:1670 +#: src/top.ml:588 msgid "# %s virt-top configuration file\n" msgstr "" -#: ../src/top.ml:1688 +#: src/top.ml:606 msgid "# Enable CSV output to the named file\n" msgstr "" -#: ../src/top.ml:1691 +#: src/top.ml:609 msgid "# To protect this file from being overwritten, uncomment next line\n" msgstr "" -#: ../src/top.ml:1685 +#: src/top.ml:603 msgid "# To send debug and error messages to a file, uncomment next line\n" msgstr "" -#: ../src/top.ml:1671 +#: src/top.ml:589 msgid "# generated on %s by %s\n" msgstr "" -#: ../src/top.ml:65 +#: src/types.ml:43 msgid "%CPU" msgstr "" -#: ../src/top.ml:66 +#: src/types.ml:44 msgid "%MEM" msgstr "" -#: ../src/top.ml:1237 -msgid "%d domains, %d active, %d running, %d sleeping, %d paused, %d inactive D:%d O:%d X:%d" +#: src/redraw.ml:481 +msgid "" +"%d domains, %d active, %d running, %d sleeping, %d paused, %d inactive D:%d " +"O:%d X:%d" msgstr "" -#: ../src/top.ml:245 +#: src/top.ml:177 msgid "%s: could not parse '%s' in init file: expecting %s" msgstr "" -#: ../src/top.ml:240 +#: src/top.ml:172 msgid "%s: could not parse '%s' in init file: expecting a number" msgstr "" -#: ../src/top.ml:235 +#: src/top.ml:167 msgid "%s: could not parse '%s' in init file: expecting an integer" msgstr "" -#: ../src/top.ml:105 +#: src/types.ml:83 msgid "%s: display should be %s" msgstr "" -#: ../src/top.ml:83 +#: src/types.ml:61 msgid "%s: sort order should be: %s" msgstr "" -#: ../src/top.ml:217 +#: src/top.ml:149 msgid "%s: unknown parameter" msgstr "" -#: ../src/top.ml:269 -msgid "%s:%d: configuration item ``%s'' ignored\n%!" +#: src/top.ml:201 +msgid "" +"%s:%d: configuration item ``%s'' ignored\n" +"%!" msgstr "" -#: ../src/top.ml:147 +#: src/top.ml:79 msgid "-d: cannot set a negative delay" msgstr "" -#: ../src/top.ml:173 +#: src/top.ml:105 msgid "Batch mode" msgstr "" -#: ../src/top.ml:72 +#: src/types.ml:50 msgid "Block read reqs" msgstr "" -#: ../src/top.ml:73 +#: src/types.ml:51 msgid "Block write reqs" msgstr "" -#: ../src/top.ml:1244 +#: src/redraw.ml:488 msgid "CPU: %2.1f%% Mem: %Ld MB (%Ld MB by guests)" msgstr "" -#: ../src/top.ml:1493 +#: src/top.ml:411 msgid "Change delay from %.1f to: " msgstr "" -#: ../src/top.ml:177 ../src/top.ml:175 +#: src/top.ml:109 src/top.ml:107 msgid "Connect to libvirt URI" msgstr "" -#: ../src/top.ml:1744 +#: src/top.ml:662 msgid "Connect: %s; Hostname: %s" msgstr "" -#: ../src/top.ml:1783 +#: src/top.ml:701 msgid "DISPLAY MODES" msgstr "" -#: ../src/top.ml:1500 +#: src/top.ml:418 msgid "Delay must be > 0" msgstr "" -#: ../src/top.ml:189 +#: src/top.ml:121 msgid "Delay time interval (seconds)" msgstr "" -#: ../src/top.ml:1737 +#: src/top.ml:655 msgid "Delay: %.1f secs; Batch: %s; Secure: %s; Sort: %s" msgstr "" -#: ../src/top.ml:181 +#: src/top.ml:113 msgid "Disable CPU stats in CSV" msgstr "" -#: ../src/top.ml:185 +#: src/top.ml:117 msgid "Disable block device stats in CSV" msgstr "" -#: ../src/top.ml:183 +#: src/top.ml:115 msgid "Disable memory stats in CSV" msgstr "" -#: ../src/top.ml:187 +#: src/top.ml:119 msgid "Disable net stats in CSV" msgstr "" -#: ../src/top.ml:214 +#: src/top.ml:146 msgid "Display version number and exit" msgstr "" -#: ../src/top.ml:199 +#: src/top.ml:131 msgid "Do not read init file" msgstr "" -#: ../src/top.ml:68 +#: src/types.ml:46 msgid "Domain ID" msgstr "" -#: ../src/top.ml:69 +#: src/types.ml:47 msgid "Domain name" msgstr "" -#: ../src/top.ml:1797 +#: src/top.ml:715 msgid "Domains display" msgstr "" -#: ../src/main.ml:69 ../src/main.ml:44 ../src/top.ml:1711 ../src/top.ml:1708 +#: src/top.ml:629 src/top.ml:626 src/main.ml:69 src/main.ml:44 msgid "Error" msgstr "" -#: ../src/top.ml:193 +#: src/top.ml:125 msgid "Exit at given time" msgstr "" -#: ../src/top.ml:1766 +#: src/top.ml:684 msgid "Help" msgstr "" -#: ../src/top.ml:195 +#: src/top.ml:127 msgid "Historical CPU delay" msgstr "" -#: ../src/top.ml:179 +#: src/top.ml:111 msgid "Log statistics to CSV file" msgstr "" -#: ../src/top.ml:1749 +#: src/top.ml:667 msgid "MAIN KEYS" msgstr "" -#: ../src/top.ml:1804 +#: src/top.ml:722 msgid "More help in virt-top(1) man page. Press any key to return." msgstr "" -#: ../src/top.ml:294 -msgid "NB: If you want to monitor a local hypervisor, you usually need to be root" +#: src/top.ml:226 +msgid "" +"NB: If you want to monitor a local hypervisor, you usually need to be root" msgstr "" -#: ../src/top.ml:70 +#: src/types.ml:48 msgid "Net RX bytes" msgstr "" -#: ../src/top.ml:71 +#: src/types.ml:49 msgid "Net TX bytes" msgstr "" -#: ../src/top.ml:1506 +#: src/top.ml:424 msgid "Not a valid number" msgstr "" -#: ../src/top.ml:201 +#: src/top.ml:133 msgid "Number of iterations to run" msgstr "" -#: ../src/top.ml:1740 ../src/top.ml:1739 +#: src/top.ml:658 src/top.ml:657 msgid "Off" msgstr "" -#: ../src/top.ml:1740 ../src/top.ml:1739 +#: src/top.ml:658 src/top.ml:657 msgid "On" msgstr "" -#: ../src/top.ml:1764 +#: src/top.ml:682 msgid "Quit" msgstr "" -#: ../src/top.ml:208 +#: src/top.ml:140 msgid "Run from a script (no user interface)" msgstr "" -#: ../src/top.ml:1771 +#: src/top.ml:689 msgid "SORTING" msgstr "" -#: ../src/top.ml:206 +#: src/top.ml:138 msgid "Secure (\"kiosk\") mode" msgstr "" -#: ../src/top.ml:1780 +#: src/top.ml:698 msgid "Select sort field" msgstr "" -#: ../src/top.ml:191 +#: src/top.ml:123 msgid "Send debug messages to file" msgstr "" -#: ../src/top.ml:197 +#: src/top.ml:129 msgid "Set name of init file" msgstr "" -#: ../src/top.ml:203 +#: src/top.ml:135 msgid "Set sort order (%s)" msgstr "" -#: ../src/top.ml:1514 +#: src/top.ml:432 msgid "Set sort order for main display" msgstr "" -#: ../src/top.ml:1765 +#: src/top.ml:683 msgid "Set update interval" msgstr "" -#: ../src/top.ml:1776 +#: src/top.ml:694 msgid "Sort by %CPU" msgstr "" -#: ../src/top.ml:1777 +#: src/top.ml:695 msgid "Sort by %MEM" msgstr "" -#: ../src/top.ml:1779 +#: src/top.ml:697 msgid "Sort by ID" msgstr "" -#: ../src/top.ml:1778 +#: src/top.ml:696 msgid "Sort by TIME" msgstr "" -#: ../src/top.ml:171 +#: src/top.ml:103 msgid "Start by displaying block devices" msgstr "" -#: ../src/top.ml:169 +#: src/top.ml:101 msgid "Start by displaying network interfaces" msgstr "" -#: ../src/top.ml:167 +#: src/top.ml:99 msgid "Start by displaying pCPUs (default: tasks)" msgstr "" -#: ../src/top.ml:67 +#: src/types.ml:45 msgid "TIME (CPU time)" msgstr "" -#: ../src/top.ml:1800 +#: src/top.ml:718 msgid "Toggle block devices" msgstr "" -#: ../src/top.ml:1799 +#: src/top.ml:717 msgid "Toggle network interfaces" msgstr "" -#: ../src/top.ml:1798 +#: src/top.ml:716 msgid "Toggle physical CPUs" msgstr "" -#: ../src/top.ml:1515 +#: src/top.ml:433 msgid "Type key or use up and down cursor keys." msgstr "" -#: ../src/top.ml:1809 +#: src/top.ml:727 msgid "Unknown command - try 'h' for help" msgstr "" -#: ../src/top.ml:1763 +#: src/top.ml:681 msgid "Update display" msgstr "" -#: ../src/top.ml:1703 +#: src/top.ml:621 msgid "Wrote settings to %s" msgstr "" -#: ../src/top.ml:1745 +#: src/top.ml:663 msgid "default" msgstr "" -#: ../src/top.ml:210 +#: src/top.ml:142 msgid "dump output to stdout (no userinterface)" msgstr "" -#: ../src/opt_xml.ml:46 +#: src/opt_xml.ml:46 msgid "get_xml_desc didn't return " msgstr "" -#: ../src/top.ml:212 +#: src/top.ml:144 msgid "show block device load in bytes rather than reqs" msgstr "" -#: ../src/top.ml:1767 +#: src/top.ml:685 msgid "toggle block info req/bytes" msgstr "" -#: ../src/top.ml:1725 +#: src/top.ml:643 msgid "virt-top %s ocaml-libvirt %s libvirt %d.%d.%d by Red Hat" msgstr "" -#: ../src/top.ml:218 -msgid "virt-top : a 'top'-like utility for virtualization\n\nSUMMARY\n virt-top [-options]\n\nOPTIONS" +#: src/top.ml:150 +msgid "" +"virt-top : a 'top'-like utility for virtualization\n" +"\n" +"SUMMARY\n" +" virt-top [-options]\n" +"\n" +"OPTIONS" msgstr "" -#: ../src/top.ml:42 +#: src/top.ml:39 msgid "virt-top was compiled without support for CSV files" msgstr "" -#: ../src/top.ml:53 +#: src/top.ml:46 msgid "virt-top was compiled without support for dates and times" msgstr "" - diff --git a/src/.depend b/src/.depend index 1075f36..ce785dd 100644 --- a/src/.depend +++ b/src/.depend @@ -1,36 +1,124 @@ -collect.cmi: types.cmi -collect.cmo: utils.cmi types.cmi collect.cmi -collect.cmx: utils.cmx types.cmx collect.cmi -csv_output.cmi: types.cmi collect.cmi -csv_output.cmo: collect.cmi csv_output.cmi -csv_output.cmx: collect.cmx csv_output.cmi -main.cmo: top.cmi opt_gettext.cmo -main.cmx: top.cmx opt_gettext.cmx -opt_calendar.cmo: top.cmi opt_gettext.cmo -opt_calendar.cmx: top.cmx opt_gettext.cmx -opt_csv.cmo: top.cmi opt_gettext.cmo csv_output.cmi -opt_csv.cmx: top.cmx opt_gettext.cmx csv_output.cmx -opt_gettext.cmo: -opt_gettext.cmx: -opt_xml.cmo: opt_gettext.cmo collect.cmi -opt_xml.cmx: opt_gettext.cmx collect.cmx -redraw.cmi: types.cmi collect.cmi -redraw.cmo: utils.cmi types.cmi screen.cmi opt_gettext.cmo collect.cmi redraw.cmi -redraw.cmx: utils.cmx types.cmx screen.cmx opt_gettext.cmx collect.cmx redraw.cmi -screen.cmi: -screen.cmo: screen.cmi -screen.cmx: screen.cmi -stream_output.cmi: types.cmi collect.cmi -stream_output.cmo: utils.cmi screen.cmi collect.cmi stream_output.cmi -stream_output.cmx: utils.cmx screen.cmx collect.cmx stream_output.cmi -top.cmi: types.cmi -top.cmo: version.cmo utils.cmi types.cmi stream_output.cmi screen.cmi redraw.cmi opt_gettext.cmo csv_output.cmi collect.cmi top.cmi -top.cmx: version.cmx utils.cmx types.cmx stream_output.cmx screen.cmx redraw.cmx opt_gettext.cmx csv_output.cmx collect.cmx top.cmi -types.cmi: -types.cmo: utils.cmi opt_gettext.cmo types.cmi -types.cmx: utils.cmx opt_gettext.cmx types.cmi -utils.cmi: -utils.cmo: utils.cmi -utils.cmx: utils.cmi -version.cmo: -version.cmx: +# OCaml dependencies generated by ../ocaml-dep.sh + +collect.cmo : \ + utils.cmi \ + types.cmi \ + collect.cmi +collect.cmx : \ + utils.cmx \ + types.cmx \ + collect.cmi +collect.cmi : \ + types.cmi +csv_output.cmo : \ + collect.cmi \ + csv_output.cmi +csv_output.cmx : \ + collect.cmx \ + csv_output.cmi +csv_output.cmi : \ + types.cmi \ + collect.cmi +main.cmo : \ + top.cmi \ + opt_gettext.cmo +main.cmx : \ + top.cmx \ + opt_gettext.cmx +opt_calendar.cmo : \ + top.cmi \ + opt_gettext.cmo +opt_calendar.cmx : \ + top.cmx \ + opt_gettext.cmx +opt_csv.cmo : \ + top.cmi \ + opt_gettext.cmo \ + csv_output.cmi +opt_csv.cmx : \ + top.cmx \ + opt_gettext.cmx \ + csv_output.cmx +opt_gettext.cmo : +opt_gettext.cmx : +opt_xml.cmo : \ + opt_gettext.cmo \ + collect.cmi +opt_xml.cmx : \ + opt_gettext.cmx \ + collect.cmx +redraw.cmo : \ + utils.cmi \ + types.cmi \ + screen.cmi \ + opt_gettext.cmo \ + collect.cmi \ + redraw.cmi +redraw.cmx : \ + utils.cmx \ + types.cmx \ + screen.cmx \ + opt_gettext.cmx \ + collect.cmx \ + redraw.cmi +redraw.cmi : \ + types.cmi \ + collect.cmi +screen.cmo : \ + screen.cmi +screen.cmx : \ + screen.cmi +screen.cmi : +stream_output.cmo : \ + utils.cmi \ + screen.cmi \ + collect.cmi \ + stream_output.cmi +stream_output.cmx : \ + utils.cmx \ + screen.cmx \ + collect.cmx \ + stream_output.cmi +stream_output.cmi : \ + types.cmi \ + collect.cmi +top.cmo : \ + version.cmo \ + utils.cmi \ + types.cmi \ + stream_output.cmi \ + screen.cmi \ + redraw.cmi \ + opt_gettext.cmo \ + csv_output.cmi \ + collect.cmi \ + top.cmi +top.cmx : \ + version.cmx \ + utils.cmx \ + types.cmx \ + stream_output.cmx \ + screen.cmx \ + redraw.cmx \ + opt_gettext.cmx \ + csv_output.cmx \ + collect.cmx \ + top.cmi +top.cmi : \ + types.cmi +types.cmo : \ + utils.cmi \ + opt_gettext.cmo \ + types.cmi +types.cmx : \ + utils.cmx \ + opt_gettext.cmx \ + types.cmi +types.cmi : +utils.cmo : \ + utils.cmi +utils.cmx : \ + utils.cmi +utils.cmi : +version.cmo : +version.cmx : diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..32a51ac --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,125 @@ +# virt-top +# Copyright (C) 2007-2021 Red Hat Inc., Richard W.M. Jones +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +CLEANFILES = *~ *.bak *.orig *.rej +CLEANFILES += *.cmi *.cmo *.cma *.cmx *.cmxa dll*.so *.a *.annot + +EXTRA_DIST = \ + .depend \ + collect.ml \ + collect.mli \ + csv_output.ml \ + csv_output.mli \ + dummy.c \ + main.ml \ + opt_calendar.ml \ + opt_csv.ml \ + opt_gettext.ml \ + opt_xml.ml \ + redraw.ml \ + redraw.mli \ + screen.ml \ + screen.mli \ + stream_output.ml \ + stream_output.mli \ + top.ml \ + top.mli \ + types.ml \ + types.mli \ + utils.ml \ + utils.mli \ + version.ml \ + virt-top.pod + +OCAMLPACKAGES = -package unix,extlib,curses,str,libvirt + +if HAVE_PKG_GETTEXT +OCAMLPACKAGES += -package gettext-stub +endif + +BOBJS = \ + version.cmo \ + opt_gettext.cmo \ + utils.cmo \ + types.cmo \ + collect.cmo \ + screen.cmo \ + redraw.cmo \ + csv_output.cmo \ + stream_output.cmo \ + top.cmo +if HAVE_PKG_XML_LIGHT +BOBJS += opt_xml.cmo +OCAMLPACKAGES += -package xml-light +endif +if HAVE_PKG_CSV +BOBJS += opt_csv.cmo +OCAMLPACKAGES += -package csv +endif +if HAVE_PKG_CALENDAR +BOBJS += opt_calendar.cmo +OCAMLPACKAGES += -package calendar +endif +BOBJS += main.cmo + +XOBJS = $(BOBJS:.cmo=.cmx) + +OCAMLFLAGS = -g -warn-error CDEFLMPSUVYZX-3 -ccopt '@CFLAGS@' +OCAMLLIBS = + +bin_PROGRAMS = virt-top + +virt_top_SOURCES = dummy.c + +if !HAVE_OCAMLOPT +OBJECTS = $(BOBJS) +else +OBJECTS = $(XOBJS) +endif + +virt_top_DEPENDENCIES = $(OBJECTS) +virt_top_LINK = \ + ../ocaml-link.sh -cclib '$(OCAMLLIBS)' -- \ + $(OCAMLFIND) $(OCAMLBEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) \ + $(OBJECTS) -o $@ + +.mli.cmi: + $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ +.ml.cmo: + $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ +.ml.cmx: + $(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ + +# Dependencies. +.depend: $(srcdir)/*.ml $(srcdir)/*.mli + ../ocaml-dep.sh $^ +-include .depend + +# Manual page. +if HAVE_PERLDOC + +virt-top.1: virt-top.pod + pod2man -u --section 1 -c "Virtualization Support" \ + --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \ + $< > $@ + +virt-top.txt: virt-top.pod + pod2text $< > $@ + +CLEANFILES += virt-top.1 virt-top.txt + +endif diff --git a/src/Makefile.in b/src/Makefile.in deleted file mode 100644 index ba4eb1d..0000000 --- a/src/Makefile.in +++ /dev/null @@ -1,111 +0,0 @@ -# virt-top -# Copyright (C) 2007-2014 Red Hat Inc., Richard W.M. Jones -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -PACKAGE := @PACKAGE_NAME@ -VERSION := @PACKAGE_VERSION@ - -INSTALL := @INSTALL@ -HAVE_PERLDOC := @HAVE_PERLDOC@ - -prefix = @prefix@ -exec_prefix = @exec_prefix@ -bindir = @bindir@ - -OCAML_PKG_curses = @OCAML_PKG_curses@ -OCAML_PKG_xml_light = @OCAML_PKG_xml_light@ -OCAML_PKG_csv = @OCAML_PKG_csv@ -OCAML_PKG_calendar = @OCAML_PKG_calendar@ -OCAML_PKG_gettext = @OCAML_PKG_gettext@ - -OCAMLCPACKAGES := -package unix,extlib,curses,str,libvirt - -ifneq ($(OCAML_PKG_gettext),no) -OCAMLCPACKAGES += -package gettext-stub -endif - -OBJS := \ - version.cmo \ - opt_gettext.cmo \ - utils.cmo \ - types.cmo \ - collect.cmo \ - screen.cmo \ - redraw.cmo \ - csv_output.cmo \ - stream_output.cmo \ - top.cmo -ifneq ($(OCAML_PKG_xml_light),no) -OBJS += opt_xml.cmo -OCAMLCPACKAGES += -package xml-light -endif -ifneq ($(OCAML_PKG_csv),no) -OBJS += opt_csv.cmo -OCAMLCPACKAGES += -package csv -endif -ifneq ($(OCAML_PKG_calendar),no) -OBJS += opt_calendar.cmo -OCAMLCPACKAGES += -package calendar -endif -OBJS += main.cmo - -XOBJS := $(OBJS:.cmo=.cmx) - -OCAMLCFLAGS := -g -warn-error CDEFLMPSUVYZX-3 -ccopt '@CFLAGS@' -OCAMLCLIBS := -linkpkg -runtime-variant _pic -cclib '@LDFLAGS@' - -OCAMLOPTPACKAGES := $(OCAMLCPACKAGES) -OCAMLOPTFLAGS := $(OCAMLCFLAGS) -OCAMLOPTLIBS := $(OCAMLCLIBS) - -BYTE_TARGETS := virt-top -OPT_TARGETS := virt-top.opt - -ifeq ($(HAVE_PERLDOC),perldoc) -BYTE_TARGETS += virt-top.1 virt-top.txt -OPT_TARGETS += virt-top.1 virt-top.txt -endif - -all: $(BYTE_TARGETS) - -opt: $(OPT_TARGETS) - -virt-top: $(OBJS) - ocamlfind ocamlc $(OCAMLCPACKAGES) $(OCAMLCFLAGS) $(OCAMLCLIBS) \ - -o $@ $^ - -virt-top.opt: $(XOBJS) - ocamlfind ocamlopt \ - $(OCAMLOPTPACKAGES) $(OCAMLOPTFLAGS) $(OCAMLOPTLIBS) \ - -o $@ $^ - -# Manual page. -ifeq ($(HAVE_PERLDOC),perldoc) -virt-top.1: virt-top.pod - pod2man -c "Virtualization Support" --release "$(PACKAGE)-$(VERSION)" \ - $< > $@ - -virt-top.txt: virt-top.pod - pod2text $< > $@ -endif - -install: - if [ -x virt-top.opt ]; then \ - mkdir -p $(DESTDIR)$(bindir); \ - $(INSTALL) -m 0755 virt-top.opt $(DESTDIR)$(bindir)/virt-top; \ - fi - -include ../Make.rules diff --git a/src/dummy.c b/src/dummy.c new file mode 100644 index 0000000..ebab619 --- /dev/null +++ b/src/dummy.c @@ -0,0 +1,2 @@ +/* Dummy source, to be used for OCaml-based tools with no C sources. */ +enum { foo = 1 }; -- 1.8.3.1 From 90bf80103a6dd15fb2bba06e2e0b5d10e9ad713d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 1 Oct 2021 16:15:41 +0100 Subject: [PATCH 04/16] Remove old Zanata files We're meant to be using Weblate now. --- po/Makefile.am | 4 +-- po/zanata-pull.sh | 30 ---------------- po/zanata.xml | 106 ------------------------------------------------------ 3 files changed, 1 insertion(+), 139 deletions(-) delete mode 100755 po/zanata-pull.sh delete mode 100644 po/zanata.xml diff --git a/po/Makefile.am b/po/Makefile.am index fc13f94..791baa3 100644 --- a/po/Makefile.am +++ b/po/Makefile.am @@ -33,9 +33,7 @@ EXTRA_DIST = \ POTFILES POTFILES-ml \ $(DOMAIN).pot \ $(POFILES) \ - $(GMOFILES) \ - zanata-pull.sh \ - zanata.xml + $(GMOFILES) if HAVE_GNU_GETTEXT diff --git a/po/zanata-pull.sh b/po/zanata-pull.sh deleted file mode 100755 index d051b7a..0000000 --- a/po/zanata-pull.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# Pull translations from Zanata. -# Copyright (C) 2011-2015 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -set -e - -echo zanata po pull -zanata po pull - -# Remove PO files that have no translations in them. -for f in *.po; do - if ! grep -q '^msgstr "[^"]' $f; then - echo rm $f - rm $f - fi -done diff --git a/po/zanata.xml b/po/zanata.xml deleted file mode 100644 index 64810f9..0000000 --- a/po/zanata.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - https://fedora.zanata.org - virt-top - master - gettext - - - sq - ar - as - ast - bal - eu - bn - bn-IN - brx - bs - br - bg - ca - zh-CN - zh-HK - zh-TW - kw - kw-GB - cs - da - nl - en-GB - eo - et - fi - fr - gl - ka - de - el - gu - he - hi - hu - is - id - ia - it - ja - kn - kk - km - ky - ko - lt - nds - mk - mai - ms - ml - mr - mn - ne - nb - nn - or - pa - fa - pl - pt - pt-BR - ro - ru - sr - sr@latin - si - sk - sl - es - sv - tg - ta - te - bo - tr - uk - ur - wba - cy - lv - kw@uccor - kw@kkcor - af - am - be - hr - de-CH - th - vi - zu - ilo - nso - tw - yo - anp - - - -- 1.8.3.1 From 7b39eb2f4340321ca1504831eecf86535a3f57fd Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 1 Oct 2021 16:16:29 +0100 Subject: [PATCH 05/16] Remove Changelog file Users can easily read the git logs if they want this information. --- ChangeLog | 552 ---------------------------------------------------- Makefile.am | 5 - gitlog-to-changelog | 186 ------------------ 3 files changed, 743 deletions(-) delete mode 100644 ChangeLog delete mode 100755 gitlog-to-changelog diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 08dd5ed..0000000 --- a/ChangeLog +++ /dev/null @@ -1,552 +0,0 @@ -2021-10-01 Richard W.M. Jones - - Convert to using automake - -2020-09-21 Richard W.M. Jones - - Merge remote-tracking branch 'weblate/master' into master - -2020-09-13 Emilio Herrera - - Translated using Weblate (Spanish) - Currently translated at 84.5% (71 of 84 strings) - - Translation: virt-top/master - Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/es/ - -2020-08-28 Julien Humbert - - Translated using Weblate (French) - Currently translated at 20.2% (17 of 84 strings) - - Translation: virt-top/master - Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/fr/ - -2020-08-28 Yuri Chornoivan - - Translated using Weblate (Ukrainian) - Currently translated at 100.0% (84 of 84 strings) - - Translation: virt-top/master - Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/uk/ - -2020-08-28 Göran Uddeborg - - Translated using Weblate (Swedish) - Currently translated at 100.0% (84 of 84 strings) - - Translation: virt-top/master - Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/sv/ - -2020-08-28 Oğuz Ersen - - Translated using Weblate (Turkish) - Currently translated at 100.0% (84 of 84 strings) - - Translation: virt-top/master - Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/tr/ - -2020-08-28 Piotr Drąg - - Translated using Weblate (Polish) - Currently translated at 100.0% (84 of 84 strings) - - Translation: virt-top/master - Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/pl/ - - Translated using Weblate (Polish) - - Currently translated at 100.0% (84 of 84 strings) - - Translation: virt-top/master - Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/pl/ - -2020-08-28 Weblate - - Update translation files - Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. - - Translation: virt-top/master - Translate-URL: https://translate.fedoraproject.org/projects/virt-top/master/ - -2020-08-27 Richard W.M. Jones - - Update translations from Zanata (RHBZ#1868108). - -2019-08-21 Stephane Glondu - - libvirt: Handle VIR_DOMAIN_PMSUSPENDED state. - Fixes FTBFS with ocaml-libvirt 0.6.1.5. - - RWMJ: Added documentation and changed the letter to 'M'. - -2019-08-20 Richard W.M. Jones - - Version 1.0.9. - - src/top.ml: Don't depend on exact value of Failure argument. - File "top.ml", line 423, characters 14-31: - 423 | Failure "float_of_string" -> - ^^^^^^^^^^^^^^^^^ - Warning 52: Code should not depend on the actual values of - this constructor's arguments. They are only for information - and may change in future versions. (See manual section 9.5) - -2018-09-20 Richard W.M. Jones - - build: Pass through CFLAGS and LDFLAGS to ocaml compiler (RHBZ#1630636). - -2017-11-18 Richard W.M. Jones - - Link with -fPIC runtime. - - Fixes for -safe-string in OCaml 4.06. - -2017-03-28 Richard W.M. Jones - - chmod -x COPYING* files. - - Use virConnectGetAllDomainStats API to collect domain stats (RHBZ#1422795). - This is much faster than using the basic libvirt APIs to collect - stats for each domain individually. - - Note this will not work unless you have the latest ocaml-libvirt - package which includes this new API binding. - - Remove unused variable is_calendar2. - Fixes commit effd1ec5897a2cac6e897ae7bce72f6b1e617b90. - -2017-03-27 Richard W.M. Jones - - Move block_in_bytes entirely to the presentation layer. - Simplifies and updates commit dbef8dd3bf00417e75a12c851b053e49c9e1a79e. - - Split up huge Top module into smaller modules. - This change is hopefully pure refactoring, splitting up the very large - and highly interlinked module into more manageable modules with - well-defined (or at least *better*-defined) interfaces between them. - - src: Fix some comments which referred to the old filenames. - Fixes commit b7c3ef13cbd9c9cd49005a32ffb70faf6f5bbe8c. - - Remove support for OCaml Calendar v1. - Calendar v2 was released in 2008 (9 years ago!), thus remove support - for v1. - - This was already broken by commit dc0e217390132f7e76a4d9c0a8a81a9556d19081 - so it likely didn't work anyway. - - Update PO files. - - Fix po/POTFILES for new location of source files. - Fixes commit b7c3ef13cbd9c9cd49005a32ffb70faf6f5bbe8c. - - Refresh HACKING file. - Fixes commit b7c3ef13cbd9c9cd49005a32ffb70faf6f5bbe8c. - - Remove +x (executable) permission on several source files. - Not sure why it was there, but it was incorrect. - - Enable same warnings as libguestfs. - In particular 'warning 3' was still enabled before, meaning that the - code would fail with newer OCaml compilers: - - File "top.ml", line 377, characters 12-25: - Warning 3: deprecated: String.create - Use Bytes.create instead. - - Since we want to continue using old OCaml for now, don't enable - this warning. - -2016-10-31 Richard W.M. Jones - - Rename source directory and files. - This renames the source directory from virt-top to src/ and removes - the unnecessary virt_top_* prefix from many source files. - - This is entirely refactoring and makes no functional change. - - Also this fixes the MANIFEST file and removes old Transifex - configuration, fixing commit defe5bdd4a32e0206a786d279e0f9cfc238e5e17. - -2016-01-04 Richard W.M. Jones - - build: Add -g flag to ocamlopt. - Modern ocamlopt supports the -g flag fine (very old versions did not). - -2015-02-21 Richard W.M. Jones - - Update translations from Zanata. - - Move upstream translations from Tranifex to Zanata. - This is at the request of the Fedora localization team. - For further information see: - - https://www.redhat.com/archives/libguestfs/2015-February/msg00168.html - -2014-08-02 Richard W.M. Jones - - Disable warning about immutable strings (for OCaml 4.02). - -2012-10-12 Richard W.M. Jones - - Version 1.0.8. - -2012-10-12 Hu Tao - - show `vcpu usages' by `virt-top -1' - Before this patch, `virt-top -1' shows total cpu usages - which euqal to `vcpu usages' + `hypervisor usages'. This - patch adds another column for domains showing `vcpu - usages'. An example is: - - PHYCPU %CPU example_domain - 0 10.4 10.4 0.8 - 1 1.6 1.6 1.4 - 2 2.6 2.6 2.6 - 3 0.0 0.0 0.1 - - RWMJ: I cleaned up this patch a little, but it should be - functionally the same. - - Rename find_usages_from_stats as find_cpu_usages. - This is just code motion. - -2012-10-12 Richard W.M. Jones - - OCaml stable dependencies. - - Remove D.get_cpu_stats second parameter. - In upstream ocaml-libvirt, this second parameter has been removed, - because it was found that nr_pcpus can be found by calling the libvirt - API directly. - -2012-09-28 Richard W.M. Jones - - Make the main code and exception handling simpler. - - Better error messages when parsing the init file (RHBZ#836231). - - Add missing sort order options in --help output (RHBZ#807176). - - Man page: Add an explanation of columns (RHBZ#834208). - - man page: Update copyright date. - -2012-03-06 Richard W.M. Jones - - Version 1.0.7. - - Ignore aclocal.m4. - - Document requirements in README file. - -2012-03-06 Lai Jiangshan - - virt-top: correct "virt-top -1" command via cpuacct cgroup - Old "virt-top -1" is not correct, its output is generated by guess: - use average usage for pinned physical CPUs. - - example(old "virt-top -1"): - - PHYCPU %CPU rhel6 Windows - 0 0.6 0.1= 0.5= - 1 0.6 0.1= 0.5=# - 2 0.6 0.1= 0.5= - 3 0.6 0.1=# 0.5= - - The output almost makes no sense(all the value are just average, not real). - - This is new implement, it use cpuacct cgroup to gain *real* physical usages - via cpuacct cgroup by virDomainGetCPUStats() API. - - new result: - - PHYCPU %CPU rhel6 Windows - 0 1.3 0.3 1.0 - 1 2.3 0.3 2.0 - 2 2.2 0.5 1.7 - 3 2.5 0.4 2.1 - - PHYCPU %CPU rhel6 Windows - 0 1.7 0.4 1.3 - 1 3.6 1.0 2.7 - 2 1.6 0.4 1.2 - 3 4.8 3.1 1.7 - - Note: average flag(=) is dropped, there is not average value in here. - Note: running flag(#) is dropped, because if the value is not empty, - it means the guest was once running in the physical CPU in this period - between updates. - - Changed from V3: - use new virDomainGetCPUStats() libvirt-API. - add a new function find_usages_from_stats() to gain cpu usages. - -2011-08-15 Richard W.M. Jones - - Ensure manpages get built when using native compiler (thanks Laurent Léonard). - -2011-08-12 Richard W.M. Jones - - Version 1.0.6. - - Update MANIFEST and fix 'make dist'. - make dist now copies the generated manual pages into the tarball, so - that we don't have to keep these generated files in git. - - Fix ordering of csv_mode and stream_mode in tuple. - Note that this bug could have been avoided by using a struct instead - of a tuple here. - - This updates commit daf79631f3eff904ba89297148c4125ac7dfee39. - -2011-08-11 Richard W.M. Jones - - docs: Explain how to debug libvirt initialization problems (RHBZ#680031). - -2011-04-02 Richard W.M. Jones - - Pull translations from Transifex. - -2011-03-08 Richard W.M. Jones - - Fix --end-time option with absolute times. - Assume the user enters a local time, and convert it to UTC. - - This also adds some clarifying comments to the relative time - code (but doesn't change that code). - - Note that the obsolete Calendar1 code is *not* updated by this change. - - docs: Fix documentation for virt-top -c option. - Because of changes in libvirt, this no longer connects to Xen by - default. Instead the default is to connect to the libvirt default - hypervisor (which could be Xen, KVM or others). Update the --help - documentation and manual page accordingly. - - Remove generated man pages from git. - -2011-03-07 KAMEZAWA Hiroyuki - - add memory stats to --csv mode. - In csv mode, memory usage in kbytes and %mem against total system - memory is shown. - -2011-03-07 KAMEZAWA Hiroyuki - - Record memory statistics information to 'rd' object. - This helps to share the calculation (between modes) and - will help to show memory statistics in --csv mode - - Signged-off-by: KAMEZAWA Hiroyuki - -2011-03-07 Richard W.M. Jones - - Import virt-top into transifex. - http://www.transifex.net/projects/p/virttop/ - -2011-02-02 Richard W.M. Jones - - Update generated man page files. - -2011-02-02 KAMEZAWA Hiroyuki - - Add --block-in-bytes option. - This option and the 'B' key toggles block I/O stats between - requests and bytes. - - Add --stream flag. - Output is sent to stdout (similar to the top -b option). - -2011-01-24 Richard W.M. Jones - - Obey virt-top --end-time down to near millisecond accuracy (RHBZ#637964). - Adjust the final delay down so that the --end-time option is obeyed - down to near millisecond accuracy. - - The 'usleep' function has been renamed more accurately as 'millisleep' - since it sleeps for milliseconds not microseconds. - -2011-01-06 Richard W.M. Jones - - Version 1.0.5. - - Add aclocal.m4 file to git. - This file is sort of generated, but at the moment only has - a single line which includes m4/ocaml.m4, that is vital for - the build. - - Re-add virt-top/README file. - This seems to have been dropped during the hg->git transition. - - Document background noise of RX packets from bridges (RHBZ#647987). - For more information see: - https://bugzilla.redhat.com/show_bug.cgi?id=647987#c9 - - man page: Remove excess blank line. - - main: Record and print full exception stack traces. - This turns on stack trace recording unconditionally (the same - effect as if OCAMLRUNPARAM=b was always supplied), and also prints - stack traces to the log file if there is an exception. - - See also: - http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printexc.html - - Note that this requires OCaml >= 3.11.0. - - Fix pad function to work for negative widths (RHBZ#634435). - The pad function is supposed to pad a string to a width. Under some - circumstances, the width parameter could be negative resulting in a - call to String.sub such as: - - String.sub str 0 (-1) - - which caused an exception to be thrown and not caught, causing - virt-top to exit. Fix the pad function to return an empty string if - width <= 0 instead of throwing an exception. - - See also: - https://bugzilla.redhat.com/show_bug.cgi?id=634435 - - Update dependencies. - - Update generated man pages. - - Fix virt-top --end-time option when TZ<>UTC (RHBZ#637964). - Return the end time as seconds since 1970, and don't adjust it - for timezone. In the main module the end time is compared against - the result of Unix.gettimeofday, which is also seconds since 1970, - so the comparison now works. - - Tested with TZ=UTC-05, TZ=UTC and TZ=UTC+05. - - NB: This has not been tested against ocaml-calendar 1.x, although - that version of calendar is obsolete and no one should be using it. - - Update dependencies file. - - man page: memory option shows total guest memory (RHBZ#647991). - - man page: Update copyright date and link to web pages. - - Remove references to xm/xentop manual pages (RHBZ#648186). - These Xen tools are obsolete since virsh/virt-top works across - all hypervisors. - -2010-09-02 Richard Jones - - Change order of return values from getyx - fixes display of historical CPU. - In this commit: - http://cvs.savannah.gnu.org/viewvc/ocaml-tmk/functions.c?root=ocaml-tmk&r1=1.2&r2=1.3 - Sam changed (fixed) the order that the coordinates are returned - from the ncurses 'getyx' call. Since this commit was made 3 years - ago it should be safe to assume everyone is using the new ocaml-ncurses - by now. - - This meant the historical %CPU was being displayed off the bottom of - the screen instead of on the top row at the right. Now it is displayed - in the correct place. - -2010-06-15 Kiyoto Hashida - - Update Japanese translations (RHBZ#493799). - -2010-03-05 Yulia - - Updated Russian translations (RHBZ#493799). - -2010-03-05 Richard Jones - - Newer autoconf adds PACKAGE_URL definition. - -2010-02-12 Richard Jones - - zh_CN: Remove bogus Plural-Forms line. - - Japanese: update bogus 'Plural-Forms: Plural-Forms'. - -2010-02-12 Hajime Taira - - Update Japanese translations (RHBZ#493799). - -2010-01-28 Richard Jones - - Rename te_IN.po -> te.po (Piotr Drąg). - - Telugu translation added by Krishna Babu K (RHBZ#493799c32) - - Polish translation updated by Piotr Drag (RHBZ#493799c31) - - Portuguese translation added by Glaucia Cintra (RHBZ#493799c30) - - Chinese translation updated by Wei Liu (RHBZ#493799c29) - - Oriya translation added by Manoj Kumar Giri (RHBZ#493799c28) - - Spanish translation updated by Daniel Cabrera (RHBZ#493799c27) - -2009-12-30 Richard Jones - - Update to ocaml-autoconf macros 1.1 - - Fix detection of ocaml-findlib. - -2009-10-06 Richard Jones - - HACKING file, update (C) messages. - - Update PO files. - - Remove extra spaces after s_ and f_ operators. - - Safer curses functions. - Add safer curses functions which don't require use of dangerous - ignore() function. - - Replace failwith (sprintf...) with failwithf - - Remove -w s and fix so it compiles without warnings. - - Remove NSIS installer. - - Change over to using ocaml.m4 macros. - -2009-10-05 Richard Jones - - Updated MANIFEST. - - TODO.virt-top renamed as TODO - - Typo fixed. - - Update manpage with --version option. - - Add virt-top --version command line option. - - Add the real virt-top version to help display. - - Version 1.0.4 for release. - - Fix changelog and manifest files. - - gitlog-to-changelog: If the date field is empty, don't barf. - - Added Jim Meyering's gitlog-to-changelog program. - - Add total hardware memory field (RHBZ#521785) - - Don't need to explicitly link against ncurses. - - Update PO files. - - Add Japanese to list of translations. - - Use msgfmt to generate *.mo files correctly. - - Update documentation. - - Update dependencies. - - Rename .hgignore -> .gitignore, update dependencies. diff --git a/Makefile.am b/Makefile.am index 699ccce..51530c7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,6 @@ SUBDIRS = src po EXTRA_DIST = \ .gitignore \ - gitlog-to-changelog \ HACKING dist-hook: po/POTFILES po/POTFILES-ml @@ -63,7 +62,3 @@ maintainer-check-extra-dist: [ ! -s comm-out ] rm tarfiles gitfiles comm-out @echo PASS: EXTRA_DIST tests - -ChangeLog: $(shell find -type f) - ./gitlog-to-changelog > $@.new - mv $@.new $@ diff --git a/gitlog-to-changelog b/gitlog-to-changelog deleted file mode 100755 index cf0fef0..0000000 --- a/gitlog-to-changelog +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/perl -# Convert git log output to ChangeLog format. - -my $VERSION = '2009-10-05 15:04'; # UTC -# The definition above must lie within the first 8 lines in order -# for the Emacs time-stamp write hook (at end) to update it. -# If you change this file with Emacs, please let the write hook -# do its job. Otherwise, update this string manually. - -# Copyright (C) 2008, 2009 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program 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 General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Written by Jim Meyering - -use strict; -use warnings; -use Getopt::Long; -use POSIX qw(strftime); - -(my $ME = $0) =~ s|.*/||; - -# use File::Coda; # http://meyering.net/code/Coda/ -END { - defined fileno STDOUT or return; - close STDOUT and return; - warn "$ME: failed to close standard output: $!\n"; - $? ||= 1; -} - -sub usage ($) -{ - my ($exit_code) = @_; - my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR); - if ($exit_code != 0) - { - print $STREAM "Try `$ME --help' for more information.\n"; - } - else - { - print $STREAM < ChangeLog - $ME -- -n 5 foo > last-5-commits-to-branch-foo - -EOF - } - exit $exit_code; -} - -# If the string $S is a well-behaved file name, simply return it. -# If it contains white space, quotes, etc., quote it, and return the new string. -sub shell_quote($) -{ - my ($s) = @_; - if ($s =~ m![^\w+/.,-]!) - { - # Convert each single quote to '\'' - $s =~ s/\'/\'\\\'\'/g; - # Then single quote the string. - $s = "'$s'"; - } - return $s; -} - -sub quoted_cmd(@) -{ - return join (' ', map {shell_quote $_} @_); -} - -{ - my $since_date = '1970-01-01 UTC'; - my $format_string = '%s%n%b%n'; - GetOptions - ( - help => sub { usage 0 }, - version => sub { print "$ME version $VERSION\n"; exit }, - 'since=s' => \$since_date, - 'format=s' => \$format_string, - ) or usage 1; - - my @cmd = (qw (git log --log-size), "--since=$since_date", - '--pretty=format:%ct %an <%ae>%n%n'.$format_string, @ARGV); - open PIPE, '-|', @cmd - or die ("$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n" - . "(Is your Git too old? Version 1.5.1 or later is required.)\n"); - - my $prev_date_line = ''; - while (1) - { - defined (my $in = ) - or last; - $in =~ /^log size (\d+)$/ - or die "$ME:$.: Invalid line (expected log size):\n$in"; - my $log_nbytes = $1; - - my $log; - my $n_read = read PIPE, $log, $log_nbytes; - $n_read == $log_nbytes - or die "$ME:$.: unexpected EOF\n"; - - my @line = split "\n", $log; - my $author_line = shift @line; - defined $author_line - or die "$ME:$.: unexpected EOF\n"; - if ($author_line =~ /^(\d+) (.*>)$/) { - my $date_line = sprintf "%s $2\n", strftime ("%F", localtime ($1)); - # If this line would be the same as the previous date/name/email - # line, then arrange not to print it. - if ($date_line ne $prev_date_line) - { - $prev_date_line eq '' - or print "\n"; - print $date_line; - } - $prev_date_line = $date_line; - } - - # Omit "Signed-off-by..." lines. - @line = grep !/^Signed-off-by: .*>$/, @line; - - # If there were any lines - if (@line == 0) - { - warn "$ME: warning: empty commit message:\n $prev_date_line\n"; - } - else - { - # Remove leading and trailing blank lines. - while ($line[0] =~ /^\s*$/) { shift @line; } - while ($line[$#line] =~ /^\s*$/) { pop @line; } - - # Prefix each non-empty line with a TAB. - @line = map { length $_ ? "\t$_" : '' } @line; - - print "\n", join ("\n", @line), "\n"; - } - - defined ($in = ) - or last; - $in ne "\n" - and die "$ME:$.: unexpected line:\n$in"; - } - - close PIPE - or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n"; - # FIXME-someday: include $PROCESS_STATUS in the diagnostic -} - -# Local Variables: -# indent-tabs-mode: nil -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "my $VERSION = '" -# time-stamp-format: "%:y-%02m-%02d %02H:%02M" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "'; # UTC" -# End: -- 1.8.3.1 From 521c3d78cdf7009c74e4fd9c4716fff91bcbc71e Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 1 Oct 2021 16:17:20 +0100 Subject: [PATCH 06/16] Version 1.1.0. Move to the more usual (for us) even = stable, odd = unstable semantic-ish versioning system, as used by olden days Linux. This is the first in a new development series. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 946466a..3286941 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([virt-top],[1.0.9]) +AC_INIT([virt-top],[1.1.0]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_MACRO_DIR([m4]) -- 1.8.3.1 From 4c608eef2274bc267d45d62550aafe2151514013 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 3 Nov 2021 11:50:10 +0000 Subject: [PATCH 07/16] build: Use non-deprecated form of warning flags In OCaml 4.13: Alert ocaml_deprecated_cli: Setting a warning with a sequence of lowercase or uppercase letters, like 'CDEFLMPSUVYZX', is deprecated. Use the equivalent signed form: +C+D+E+F+L+M+P+S+U+V+Y+Z+X-3. --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 32a51ac..d10f223 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -78,7 +78,7 @@ BOBJS += main.cmo XOBJS = $(BOBJS:.cmo=.cmx) -OCAMLFLAGS = -g -warn-error CDEFLMPSUVYZX-3 -ccopt '@CFLAGS@' +OCAMLFLAGS = -g -warn-error +C+D+E+F+L+M+P+S+U+V+Y+Z+X-3 -ccopt '@CFLAGS@' OCAMLLIBS = bin_PROGRAMS = virt-top -- 1.8.3.1 From 1aedabd0caf7a0562a3f314dddd13d49e0165c92 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 3 Nov 2021 11:47:13 +0000 Subject: [PATCH 08/16] Remove dependency on ocaml-extlib We only used a handful of small functions from this library, so we can completely remove the dependency easily. --- README | 3 +-- configure.ac | 5 ----- src/.depend | 2 ++ src/Makefile.am | 2 +- src/collect.ml | 1 - src/csv_output.ml | 6 +++--- src/opt_calendar.ml | 8 ++++++-- src/opt_xml.ml | 2 -- src/redraw.ml | 9 ++++----- src/stream_output.ml | 3 +-- src/top.ml | 1 - src/utils.ml | 23 ++++++++++++++++++++++- src/utils.mli | 6 ++++++ 13 files changed, 46 insertions(+), 25 deletions(-) diff --git a/README b/README index d97fa62..1ad45a2 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ virt-top ---------------------------------------------------------------------- -Copyright (C) 2007-2016 Richard W.M. Jones, Red Hat Inc. +Copyright (C) 2007-2021 Richard W.M. Jones, Red Hat Inc. http://et.redhat.com/~rjones/virt-top/ http://libvirt.org/ocaml/ http://libvirt.org/ @@ -19,7 +19,6 @@ Requirements OCaml >= 3.11.0 ocaml-libvirt >= 0.6.1.1 (for virDomainGetCPUStats support) -OCaml extlib OCaml curses Optional: diff --git a/configure.ac b/configure.ac index 3286941..7eca0f6 100644 --- a/configure.ac +++ b/configure.ac @@ -57,11 +57,6 @@ if test "x$OCAML_PKG_unix" = "xno"; then AC_MSG_ERROR([Cannot find required OCaml package 'unix']) fi -AC_CHECK_OCAML_PKG(extlib) -if test "x$OCAML_PKG_extlib" = "xno"; then - AC_MSG_ERROR([Cannot find required OCaml package 'extlib']) -fi - AC_CHECK_OCAML_PKG(libvirt) if test "x$OCAML_PKG_libvirt" = "xno"; then AC_MSG_ERROR([Cannot find required OCaml package 'libvirt']) diff --git a/src/.depend b/src/.depend index ce785dd..997a051 100644 --- a/src/.depend +++ b/src/.depend @@ -11,9 +11,11 @@ collect.cmx : \ collect.cmi : \ types.cmi csv_output.cmo : \ + utils.cmi \ collect.cmi \ csv_output.cmi csv_output.cmx : \ + utils.cmx \ collect.cmx \ csv_output.cmi csv_output.cmi : \ diff --git a/src/Makefile.am b/src/Makefile.am index d10f223..aa55078 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -45,7 +45,7 @@ EXTRA_DIST = \ version.ml \ virt-top.pod -OCAMLPACKAGES = -package unix,extlib,curses,str,libvirt +OCAMLPACKAGES = -package unix,curses,str,libvirt if HAVE_PKG_GETTEXT OCAMLPACKAGES += -package gettext-stub diff --git a/src/collect.ml b/src/collect.ml index a1e50a1..0c673e1 100644 --- a/src/collect.ml +++ b/src/collect.ml @@ -21,7 +21,6 @@ module C = Libvirt.Connect module D = Libvirt.Domain open Printf -open ExtList open Utils open Types diff --git a/src/csv_output.ml b/src/csv_output.ml index f23d673..cb373d5 100644 --- a/src/csv_output.ml +++ b/src/csv_output.ml @@ -20,8 +20,8 @@ (* CSV output functions. *) open Printf -open ExtList +open Utils open Collect module C = Libvirt.Connect @@ -92,9 +92,9 @@ let append_csv (_, _, _, _, _, node_info, hostname, _) (* setup *) let cmp (_, { rd_domid = rd_domid1 }) (_, { rd_domid = rd_domid2 }) = compare rd_domid1 rd_domid2 in - let doms = List.sort ~cmp doms in + let doms = List.sort cmp doms in - let string_of_int64_option = Option.map_default Int64.to_string "" in + let string_of_int64_option = map_default Int64.to_string "" in let domain_fields = List.map ( fun (domname, rd) -> diff --git a/src/opt_calendar.ml b/src/opt_calendar.ml index fd93704..89c5598 100644 --- a/src/opt_calendar.ml +++ b/src/opt_calendar.ml @@ -22,14 +22,18 @@ open CalendarLib open Printf -open ExtString open Opt_gettext.Gettext ;; Top.parse_date_time := fun time -> let cal : Calendar.t = - if String.starts_with time "+" then ( (* +something *) + (* time is "+something" *) + let is_plus = + let n = String.length time in + n >= 1 && time.[0] = '+' + in + if is_plus then ( let period = String.sub time 1 (String.length time - 1) in let period = if String.contains period ':' then ( (* +HH:MM:SS *) diff --git a/src/opt_xml.ml b/src/opt_xml.ml index 1037b85..25ef0ad 100644 --- a/src/opt_xml.ml +++ b/src/opt_xml.ml @@ -19,8 +19,6 @@ This file contains all code which requires xml-light. *) -open ExtList - open Opt_gettext.Gettext module C = Libvirt.Connect diff --git a/src/redraw.ml b/src/redraw.ml index 0403158..7031e66 100644 --- a/src/redraw.ml +++ b/src/redraw.ml @@ -17,7 +17,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *) -open ExtList open Curses open Printf @@ -137,7 +136,7 @@ let redraw display_mode sort_order if r <> 0 then r else compare name1 name2 in - List.sort ~cmp doms in + List.sort cmp doms in (* Print domains. *) attron A.reverse; @@ -316,7 +315,7 @@ let redraw display_mode sort_order if r <> 0 then r else compare (dev1, name1) (dev2, name2) in - List.sort ~cmp devs in + List.sort cmp devs in (* Print the header for network devices. *) attron A.reverse; @@ -428,7 +427,7 @@ let redraw display_mode sort_order if r <> 0 then r else compare (dev1, name1) (dev2, name2) in - List.sort ~cmp devs in + List.sort cmp devs in (* Print the header for block devices. *) attron A.reverse; @@ -491,7 +490,7 @@ let redraw display_mode sort_order (* Time to grab another historical %CPU for the list? *) if time >= !historical_cpu_last_time +. float historical_cpu_delay then ( - historical_cpu := percent_cpu :: List.take 10 !historical_cpu; + historical_cpu := percent_cpu :: list_take 10 !historical_cpu; historical_cpu_last_time := time ); diff --git a/src/stream_output.ml b/src/stream_output.ml index c3af99b..2b9e087 100644 --- a/src/stream_output.ml +++ b/src/stream_output.ml @@ -20,7 +20,6 @@ (* [--stream] mode output functions. *) open Printf -open ExtList open Utils open Collect @@ -54,7 +53,7 @@ let append_stream (_, _, _, _, _, node_info, hostname, _) (* setup *) | Inactive, Inactive -> 0) in let cmp (name1, dom1) (name2, dom2) = compare(dom1, dom2) in - List.sort ~cmp doms in + List.sort cmp doms in (*Print domains *) let dump_domain = fun name rd -> begin diff --git a/src/top.ml b/src/top.ml index c38239c..5fb6e03 100644 --- a/src/top.ml +++ b/src/top.ml @@ -18,7 +18,6 @@ *) open Printf -open ExtList open Curses open Opt_gettext.Gettext diff --git a/src/utils.ml b/src/utils.ml index 4332ff7..1f00803 100644 --- a/src/utils.ml +++ b/src/utils.ml @@ -75,6 +75,14 @@ let trimr ?(test = isspace) str = let trim ?(test = isspace) str = trimr (triml str) +(* Split string on the first instance of 'sep' character. *) +let split str sep = + try + let i = String.index str sep in + String.sub str 0 i, String.sub str (i+1) (String.length str - 1) + with + Not_found -> str, "" + (* Read a configuration file as a list of (key, value) pairs. * If the config file is missing this returns an empty list. *) @@ -103,7 +111,7 @@ let read_config_file filename = (* Convert to key, value pairs. *) List.map ( fun (lineno, line) -> - let key, value = ExtString.String.split line " " in + let key, value = split line ' ' in lineno, trim key, trim value ) lines @@ -117,6 +125,19 @@ let pad width str = else (* if n < width then *) str ^ String.make (width-n) ' ' ) +(* Take up to n elements of xs, if available. *) +let rec list_take n xs = + if n <= 0 then [] + else ( + match xs with + | [] -> [] + | x :: xs -> x :: list_take (n-1) xs + ) + +let map_default f def = function + | None -> def + | Some v -> f v + module Show = struct (* Show a percentage in 4 chars. *) let percent percent = diff --git a/src/utils.mli b/src/utils.mli index 3c966f8..2679dc9 100644 --- a/src/utils.mli +++ b/src/utils.mli @@ -36,6 +36,12 @@ val read_config_file : string -> (int * string * string) list (* Pad or truncate a string to a fixed width. *) val pad : int -> string -> string +(* Take up to n elements of xs, if available. *) +val list_take : int -> 'a list -> 'a list + +(* Apply function f to [Some v], return default for [None] *) +val map_default : ('a -> 'b) -> 'b -> 'a option -> 'b + (* Int64 operators for convenience. *) val (+^) : int64 -> int64 -> int64 val (-^) : int64 -> int64 -> int64 -- 1.8.3.1 From 42de3812f0bd97c3fa5114b39d9bb23c483d364b Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 3 Nov 2021 11:28:58 +0000 Subject: [PATCH 09/16] Remove external dependency on ocaml-csv We only used a tiny number of features from this library, and it is distributed under a compatible license so we might as well inline the function we need. --- README | 1 - configure.ac | 2 -- src/.depend | 8 ----- src/Makefile.am | 5 --- src/README | 7 +--- src/csv_output.ml | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++---- src/csv_output.mli | 5 ++- src/opt_csv.ml | 40 ----------------------- src/top.ml | 8 +---- src/top.mli | 3 -- src/virt-top.pod | 4 --- 11 files changed, 93 insertions(+), 86 deletions(-) delete mode 100644 src/opt_csv.ml diff --git a/README b/README index 1ad45a2..70d0683 100644 --- a/README +++ b/README @@ -24,7 +24,6 @@ OCaml curses Optional: OCaml gettext OCaml xml-light -OCaml CSV OCaml Calendar, version 2 is preferred perldoc msgfmt diff --git a/configure.ac b/configure.ac index 7eca0f6..316be00 100644 --- a/configure.ac +++ b/configure.ac @@ -69,12 +69,10 @@ fi dnl Check for optional OCaml packages. AC_CHECK_OCAML_PKG(calendar) -AC_CHECK_OCAML_PKG(csv) AC_CHECK_OCAML_PKG(gettext) AC_CHECK_OCAML_PKG(xml-light) AM_CONDITIONAL([HAVE_PKG_CALENDAR], [test "x$OCAML_PKG_calendar" != "xno"]) -AM_CONDITIONAL([HAVE_PKG_CSV], [test "x$OCAML_PKG_csv" != "xno"]) AM_CONDITIONAL([HAVE_PKG_GETTEXT], [test "x$OCAML_PKG_gettext" != "xno"]) AM_CONDITIONAL([HAVE_PKG_XML_LIGHT],[test "x$OCAML_PKG_xml_light" != "xno"]) diff --git a/src/.depend b/src/.depend index 997a051..ffca8e3 100644 --- a/src/.depend +++ b/src/.depend @@ -33,14 +33,6 @@ opt_calendar.cmo : \ opt_calendar.cmx : \ top.cmx \ opt_gettext.cmx -opt_csv.cmo : \ - top.cmi \ - opt_gettext.cmo \ - csv_output.cmi -opt_csv.cmx : \ - top.cmx \ - opt_gettext.cmx \ - csv_output.cmx opt_gettext.cmo : opt_gettext.cmx : opt_xml.cmo : \ diff --git a/src/Makefile.am b/src/Makefile.am index aa55078..03e4b1c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,7 +27,6 @@ EXTRA_DIST = \ dummy.c \ main.ml \ opt_calendar.ml \ - opt_csv.ml \ opt_gettext.ml \ opt_xml.ml \ redraw.ml \ @@ -66,10 +65,6 @@ if HAVE_PKG_XML_LIGHT BOBJS += opt_xml.cmo OCAMLPACKAGES += -package xml-light endif -if HAVE_PKG_CSV -BOBJS += opt_csv.cmo -OCAMLPACKAGES += -package csv -endif if HAVE_PKG_CALENDAR BOBJS += opt_calendar.cmo OCAMLPACKAGES += -package calendar diff --git a/src/README b/src/README index 1fd4be3..61d2c77 100644 --- a/src/README +++ b/src/README @@ -53,11 +53,6 @@ The code is structured into these files: The reason for having it in a separate file is so that we don't depend on xml-light. - opt_csv.ml - - Any code which needs the optional ocaml-csv library goes - in here. - opt_calendar.ml Any code which needs the optional ocaml-calendar library @@ -67,7 +62,7 @@ The code is structured into these files: main.ml This is just a small bit of code to glue the modules together - Top + Opt_xml? + Opt_csv? + Opt_calendar? + Top + Opt_xml? + Opt_calendar? The man-page is generated from the single file: diff --git a/src/csv_output.ml b/src/csv_output.ml index cb373d5..42fed9d 100644 --- a/src/csv_output.ml +++ b/src/csv_output.ml @@ -1,5 +1,5 @@ (* 'top'-like tool for libvirt domains. - (C) Copyright 2007-2017 Richard W.M. Jones, Red Hat Inc. + (C) Copyright 2007-2021 Richard W.M. Jones, Red Hat Inc. http://libvirt.org/ This program is free software; you can redistribute it and/or modify @@ -26,15 +26,97 @@ open Collect module C = Libvirt.Connect -(* Hook for CSV support (see [opt_csv.ml]). *) -let csv_write : (string list -> unit) ref = - ref ( - fun _ -> () +let chan = ref None + +let csv_set_filename filename = chan := Some (open_out filename) + +(* This code is adapted from OCaml CSV, published under the LGPLv2+ + * which is compatible with the license of virt-top. + *) + +let nl = Bytes.make 1 '\n' +let comma = Bytes.make 1 ',' +let quote = Bytes.make 1 '"' +let output_newline chan = output chan nl 0 1 +let output_comma chan = output chan comma 0 1 +let output_quote chan = output chan quote 0 1 + +let is_space_or_tab c = c = ' ' || c = '\t' + +let must_escape = Array.make 256 false +let () = + List.iter (fun c -> must_escape.(Char.code c) <- true) + ['\"'; '\\'; '\000'; '\b'; '\n'; '\r'; '\t'; '\026'] + +let must_quote chan s len = + let quote = ref (is_space_or_tab (String.unsafe_get s 0) + || is_space_or_tab (String.unsafe_get s (len - 1))) in + let n = ref 0 in + for i = 0 to len-1 do + let c = String.unsafe_get s i in + if c = ',' || c = '\n' || c = '\r' then quote := true + else if c = '"' then ( + quote := true; + incr n + ) + done; + if !quote then !n else -1 + +let write_escaped chan field = + let len = String.length field in + if len > 0 then ( + let n = must_quote chan field len in + if n < 0 then + output chan (Bytes.unsafe_of_string field) 0 len + else ( + let field = + if n <= 0 then Bytes.unsafe_of_string field + else (* There are some quotes to escape *) + let s = Bytes.create (len + n) in + let j = ref 0 in + for i = 0 to len - 1 do + let c = String.unsafe_get field i in + if c = '"' then ( + Bytes.unsafe_set s !j '"'; incr j; + Bytes.unsafe_set s !j '"'; incr j + ) + else (Bytes.unsafe_set s !j c; incr j) + done; + s + in + output_quote chan; + output chan field 0 (Bytes.length field); + output_quote chan + ) ) +let save_out chan = function + | [] -> output_newline chan + | [f] -> + write_escaped chan f; + output_newline chan + | f :: tl -> + write_escaped chan f; + List.iter ( + fun f -> + output_comma chan; + write_escaped chan f + ) tl; + output_newline chan + +let csv_write row = + match !chan with + | None -> () (* CSV output not enabled *) + | Some chan -> + save_out chan row; + (* Flush the output to the file immediately because we don't + * explicitly close the channel. + *) + flush chan + (* Write CSV header row. *) let write_csv_header (csv_cpu, csv_mem, csv_block, csv_net) block_in_bytes = - (!csv_write) ( + csv_write ( [ "Hostname"; "Time"; "Arch"; "Physical CPUs"; "Count"; "Running"; "Blocked"; "Paused"; "Shutdown"; "Shutoff"; "Crashed"; "Active"; "Inactive"; @@ -121,4 +203,4 @@ let append_csv (_, _, _, _, _, node_info, hostname, _) (* setup *) ) doms in let domain_fields = List.flatten domain_fields in - (!csv_write) (summary_fields @ domain_fields) + csv_write (summary_fields @ domain_fields) diff --git a/src/csv_output.mli b/src/csv_output.mli index 4064be5..71838eb 100644 --- a/src/csv_output.mli +++ b/src/csv_output.mli @@ -1,5 +1,5 @@ (* 'top'-like tool for libvirt domains. - (C) Copyright 2007-2017 Richard W.M. Jones, Red Hat Inc. + (C) Copyright 2007-2021 Richard W.M. Jones, Red Hat Inc. http://libvirt.org/ This program is free software; you can redistribute it and/or modify @@ -19,8 +19,7 @@ (** CSV output functions. *) -(* Hook for [Opt_csv] to override (if present). *) -val csv_write : (string list -> unit) ref +val csv_set_filename : string -> unit val write_csv_header : bool * bool * bool * bool -> bool -> unit diff --git a/src/opt_csv.ml b/src/opt_csv.ml deleted file mode 100644 index 6625c61..0000000 --- a/src/opt_csv.ml +++ /dev/null @@ -1,40 +0,0 @@ -(* 'top'-like tool for libvirt domains. - (C) Copyright 2007-2009 Richard W.M. Jones, Red Hat Inc. - http://libvirt.org/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - This file contains all code which requires CSV support. -*) - -open Opt_gettext.Gettext - -(* Output channel, or None if CSV output not enabled. *) -let chan = ref None ;; - -Top.csv_start := - fun filename -> - chan := Some (open_out filename) ;; - -Csv_output.csv_write := - fun row -> - match !chan with - | None -> () (* CSV output not enabled. *) - | Some chan -> - Csv.save_out chan [row]; - (* Flush the output to the file immediately because we don't - * explicitly close this file. - *) - flush chan diff --git a/src/top.ml b/src/top.ml index 5fb6e03..75fbcb9 100644 --- a/src/top.ml +++ b/src/top.ml @@ -32,12 +32,6 @@ module N = Libvirt.Network let rcfile = ".virt-toprc" -(* Hooks for CSV support (see [opt_csv.ml]). *) -let csv_start : (string -> unit) ref = - ref ( - fun _ -> failwith (s_"virt-top was compiled without support for CSV files") - ) - (* Hook for calendar support (see [opt_calendar.ml]). *) let parse_date_time : (string -> float) ref = ref ( @@ -83,7 +77,7 @@ let start_up () = and set_net_mode () = display_mode := NetDisplay and set_block_mode () = display_mode := BlockDisplay and set_csv filename = - (!csv_start) filename; + Csv_output.csv_set_filename filename; csv_enabled := true and no_init_file () = init_file := NoInitFile and set_init_file filename = init_file := InitFile filename diff --git a/src/top.mli b/src/top.mli index b625910..f609325 100644 --- a/src/top.mli +++ b/src/top.mli @@ -17,9 +17,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *) -(* Hook for [Opt_csv] to override (if present). *) -val csv_start : (string -> unit) ref - (* Hook for [Opt_calendar] to override (if present). *) val parse_date_time : (string -> float) ref diff --git a/src/virt-top.pod b/src/virt-top.pod index 76ad3f9..315b9b6 100644 --- a/src/virt-top.pod +++ b/src/virt-top.pod @@ -114,10 +114,6 @@ Currently the statistics which this records vary between releases of virt-top (but the column headers will stay the same, so you can use those to process the CSV file). -Not every version of virt-top supports CSV output - it depends how the -program was compiled (see I file in the source distribution -for details). - To save space you can compress your CSV files (if your shell supports this feature, eg. I): -- 1.8.3.1 From b8a058e62e65b4c7bd0b387d979d503b3d7f2543 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 3 Nov 2021 19:59:22 +0000 Subject: [PATCH 10/16] build: Remove bogus directory list in ocaml-dep.sh.in This was a cut and paste error when I copied this file over from libguestfs. Fixes: commit 5405de2920fa56529b56f61ff683806e72ddfa6a --- ocaml-dep.sh.in | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ocaml-dep.sh.in b/ocaml-dep.sh.in index 49c816a..7a1f169 100755 --- a/ocaml-dep.sh.in +++ b/ocaml-dep.sh.in @@ -33,16 +33,6 @@ set -e # directories must have unique names (eg. not ‘Utils’) else # dependencies don't get built right. include_dirs=" -common/mlgettext -common/mlpcre -common/mlprogress -common/mlstdutils -common/mltools -common/mlutils -common/mlv2v -common/mlvisit -common/mlxml -lib " # Output file is always created in the current directory. -- 1.8.3.1 From 5937a2ef820c7a0ddc4039202c0509a6fd52583d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 3 Nov 2021 19:24:22 +0000 Subject: [PATCH 11/16] Remove dependency on xml-light, replace with libxml2 This commit removes the dependency on the ancient and dead upstream xml-light light. It is replaced with the C library libxml2. This introduces a small amount of C code to interface with libxml2 and parse the libvirt domain XML into the list of block devices and network devices (using XPath). --- README | 2 +- configure.ac | 5 ++- po/POTFILES | 2 +- po/POTFILES-ml | 2 +- src/.depend | 10 ++--- src/Makefile.am | 23 ++++++----- src/README | 12 +----- src/collect.ml | 10 +---- src/collect.mli | 4 -- src/dummy.c | 2 - src/opt_xml.ml | 67 ------------------------------ src/xml-c.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/xml.ml | 32 +++++++++++++++ 13 files changed, 183 insertions(+), 112 deletions(-) delete mode 100644 src/dummy.c delete mode 100644 src/opt_xml.ml create mode 100644 src/xml-c.c create mode 100644 src/xml.ml diff --git a/README b/README index 70d0683..da72740 100644 --- a/README +++ b/README @@ -20,10 +20,10 @@ Requirements OCaml >= 3.11.0 ocaml-libvirt >= 0.6.1.1 (for virDomainGetCPUStats support) OCaml curses +libxml2 Optional: OCaml gettext -OCaml xml-light OCaml Calendar, version 2 is preferred perldoc msgfmt diff --git a/configure.ac b/configure.ac index 316be00..d31d042 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,9 @@ AM_PROG_CC_C_O dnl Check support for 64 bit file offsets. AC_SYS_LARGEFILE +dnl Check for libxml2 (required). +PKG_CHECK_MODULES([LIBXML2], [libxml-2.0]) + dnl Check for basic OCaml environment & findlib. AC_PROG_OCAML if test "$OCAMLC" = "no"; then @@ -70,11 +73,9 @@ fi dnl Check for optional OCaml packages. AC_CHECK_OCAML_PKG(calendar) AC_CHECK_OCAML_PKG(gettext) -AC_CHECK_OCAML_PKG(xml-light) AM_CONDITIONAL([HAVE_PKG_CALENDAR], [test "x$OCAML_PKG_calendar" != "xno"]) AM_CONDITIONAL([HAVE_PKG_GETTEXT], [test "x$OCAML_PKG_gettext" != "xno"]) -AM_CONDITIONAL([HAVE_PKG_XML_LIGHT],[test "x$OCAML_PKG_xml_light" != "xno"]) dnl Check if ocamlc/ocamlopt -runtime-variant _pic works. It was dnl added in OCaml >= 4.03, but in theory might be disabled by diff --git a/po/POTFILES b/po/POTFILES index 22b1625..22c6267 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -1 +1 @@ -./src/dummy.c +./src/xml-c.c diff --git a/po/POTFILES-ml b/po/POTFILES-ml index b6356eb..249c66b 100644 --- a/po/POTFILES-ml +++ b/po/POTFILES-ml @@ -4,7 +4,6 @@ ./src/opt_calendar.ml ./src/opt_csv.ml ./src/opt_gettext.ml -./src/opt_xml.ml ./src/redraw.ml ./src/screen.ml ./src/stream_output.ml @@ -12,3 +11,4 @@ ./src/types.ml ./src/utils.ml ./src/version.ml +./src/xml.ml diff --git a/src/.depend b/src/.depend index ffca8e3..aad72ab 100644 --- a/src/.depend +++ b/src/.depend @@ -1,10 +1,12 @@ # OCaml dependencies generated by ../ocaml-dep.sh collect.cmo : \ + xml.cmo \ utils.cmi \ types.cmi \ collect.cmi collect.cmx : \ + xml.cmx \ utils.cmx \ types.cmx \ collect.cmi @@ -35,12 +37,6 @@ opt_calendar.cmx : \ opt_gettext.cmx opt_gettext.cmo : opt_gettext.cmx : -opt_xml.cmo : \ - opt_gettext.cmo \ - collect.cmi -opt_xml.cmx : \ - opt_gettext.cmx \ - collect.cmx redraw.cmo : \ utils.cmi \ types.cmi \ @@ -116,3 +112,5 @@ utils.cmx : \ utils.cmi : version.cmo : version.cmx : +xml.cmo : +xml.cmx : diff --git a/src/Makefile.am b/src/Makefile.am index 03e4b1c..baf8ce4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,11 +24,9 @@ EXTRA_DIST = \ collect.mli \ csv_output.ml \ csv_output.mli \ - dummy.c \ main.ml \ opt_calendar.ml \ opt_gettext.ml \ - opt_xml.ml \ redraw.ml \ redraw.mli \ screen.ml \ @@ -42,7 +40,9 @@ EXTRA_DIST = \ utils.ml \ utils.mli \ version.ml \ - virt-top.pod + virt-top.pod \ + xml-c.c \ + xml.ml OCAMLPACKAGES = -package unix,curses,str,libvirt @@ -55,16 +55,13 @@ BOBJS = \ opt_gettext.cmo \ utils.cmo \ types.cmo \ + xml.cmo \ collect.cmo \ screen.cmo \ redraw.cmo \ csv_output.cmo \ stream_output.cmo \ top.cmo -if HAVE_PKG_XML_LIGHT -BOBJS += opt_xml.cmo -OCAMLPACKAGES += -package xml-light -endif if HAVE_PKG_CALENDAR BOBJS += opt_calendar.cmo OCAMLPACKAGES += -package calendar @@ -73,12 +70,18 @@ BOBJS += main.cmo XOBJS = $(BOBJS:.cmo=.cmx) -OCAMLFLAGS = -g -warn-error +C+D+E+F+L+M+P+S+U+V+Y+Z+X-3 -ccopt '@CFLAGS@' -OCAMLLIBS = +OCAMLFLAGS = \ + -g \ + -warn-error +C+D+E+F+L+M+P+S+U+V+Y+Z+X-3 \ + -ccopt '$(CFLAGS)' +OCAMLLIBS = $(LIBXML2_LIBS) bin_PROGRAMS = virt-top -virt_top_SOURCES = dummy.c +virt_top_SOURCES = xml-c.c +virt_top_CFLAGS = \ + $(LIBXML2_CFLAGS) \ + -I$(libdir)/ocaml if !HAVE_OCAMLOPT OBJECTS = $(BOBJS) diff --git a/src/README b/src/README index 61d2c77..e49fd48 100644 --- a/src/README +++ b/src/README @@ -41,18 +41,10 @@ The code is structured into these files: to deal with keypresses, help screens and so on. opt_gettext.ml + A generated file which adds gettext support if ocaml-gettext was found at configure time, or else stubs it out. - opt_xml.ml - - Any code which needs the optional xml-light library goes - in here. Mainly for parsing domain XML descriptions to get - the list of block devices and network interfaces. - - The reason for having it in a separate file is so that we - don't depend on xml-light. - opt_calendar.ml Any code which needs the optional ocaml-calendar library @@ -62,7 +54,7 @@ The code is structured into these files: main.ml This is just a small bit of code to glue the modules together - Top + Opt_xml? + Opt_calendar? + Top + Opt_calendar? The man-page is generated from the single file: diff --git a/src/collect.ml b/src/collect.ml index 0c673e1..c8a390c 100644 --- a/src/collect.ml +++ b/src/collect.ml @@ -1,5 +1,5 @@ (* 'top'-like tool for libvirt domains. - (C) Copyright 2007-2017 Richard W.M. Jones, Red Hat Inc. + (C) Copyright 2007-2021 Richard W.M. Jones, Red Hat Inc. http://libvirt.org/ This program is free software; you can redistribute it and/or modify @@ -25,12 +25,6 @@ open Printf open Utils open Types -(* Hook for XML support (see [opt_xml.ml]). *) -let parse_device_xml : (int -> [>`R] D.t -> string list * string list) ref = - ref ( - fun _ _ -> [], [] - ) - (* Intermediate "domain + stats" structure that we use to collect * everything we know about a domain within the collect function. *) @@ -94,7 +88,7 @@ let devices = Hashtbl.create 13 let get_devices id dom = try Hashtbl.find devices id with Not_found -> - let blkdevs, netifs = (!parse_device_xml) id dom in + let blkdevs, netifs = Xml.parse_device_xml dom in Hashtbl.replace devices id (blkdevs, netifs); blkdevs, netifs diff --git a/src/collect.mli b/src/collect.mli index 3c5492f..72f0800 100644 --- a/src/collect.mli +++ b/src/collect.mli @@ -17,10 +17,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *) -(* Hook for [Opt_xml] to override (if present). *) -val parse_device_xml : - (int -> [ `R ] Libvirt.Domain.t -> string list * string list) ref - (* Intermediate "domain + stats" structure that we use to collect * everything we know about a domain within the collect function. *) diff --git a/src/dummy.c b/src/dummy.c deleted file mode 100644 index ebab619..0000000 --- a/src/dummy.c +++ /dev/null @@ -1,2 +0,0 @@ -/* Dummy source, to be used for OCaml-based tools with no C sources. */ -enum { foo = 1 }; diff --git a/src/opt_xml.ml b/src/opt_xml.ml deleted file mode 100644 index 25ef0ad..0000000 --- a/src/opt_xml.ml +++ /dev/null @@ -1,67 +0,0 @@ -(* 'top'-like tool for libvirt domains. - (C) Copyright 2007-2009 Richard W.M. Jones, Red Hat Inc. - http://libvirt.org/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - This file contains all code which requires xml-light. -*) - -open Opt_gettext.Gettext - -module C = Libvirt.Connect -module D = Libvirt.Domain -module N = Libvirt.Network ;; - -Collect.parse_device_xml := -fun id dom -> - try - let xml = D.get_xml_desc dom in - let xml = Xml.parse_string xml in - let devices = - match xml with - | Xml.Element ("domain", _, children) -> - let devices = - List.filter_map ( - function - | Xml.Element ("devices", _, devices) -> Some devices - | _ -> None - ) children in - List.concat devices - | _ -> - failwith (s_ "get_xml_desc didn't return ") in - let rec target_dev_of = function - | [] -> None - | Xml.Element ("target", attrs, _) :: rest -> - (try Some (List.assoc "dev" attrs) - with Not_found -> target_dev_of rest) - | _ :: rest -> target_dev_of rest - in - let blkdevs = - List.filter_map ( - function - | Xml.Element ("disk", _, children) -> target_dev_of children - | _ -> None - ) devices in - let netifs = - List.filter_map ( - function - | Xml.Element ("interface", _, children) -> target_dev_of children - | _ -> None - ) devices in - blkdevs, netifs - with - | Xml.Error _ - | Libvirt.Virterror _ -> [], [] (* ignore transient errs *) diff --git a/src/xml-c.c b/src/xml-c.c new file mode 100644 index 0000000..72042bf --- /dev/null +++ b/src/xml-c.c @@ -0,0 +1,124 @@ +/* 'top'-like tool for libvirt domains. + (C) Copyright 2007-2021 Richard W.M. Jones, Red Hat Inc. + http://libvirt.org/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +/* xpathobj contains a list of dev attributes, return the list + * as an OCaml array of strings. + */ +static value +get_devs (xmlDocPtr doc, xmlXPathObjectPtr xpathobj) +{ + CAMLparam0 (); + CAMLlocal2 (rv, nodev); + const xmlNodeSetPtr nodes = xpathobj->nodesetval; + size_t i, nr_nodes; + xmlNodePtr node; + char *str; + xmlAttrPtr attr; + + if (nodes == NULL || nodes->nodeNr == 0) + rv = caml_alloc (0, 0); + else { + /* Count the nodes that contain data. */ + nr_nodes = 0; + for (i = 0; i < nodes->nodeNr; ++i) { + node = nodes->nodeTab[i]; + if (node->type != XML_ATTRIBUTE_NODE) + continue; + nr_nodes++; + } + + rv = caml_alloc (nr_nodes, 0); + nr_nodes = 0; + for (i = 0; i < nodes->nodeNr; ++i) { + node = nodes->nodeTab[i]; + if (node->type != XML_ATTRIBUTE_NODE) + continue; + attr = (xmlAttrPtr) node; + str = (char *) xmlNodeListGetString (doc, attr->children, 1); + nodev = caml_copy_string (str); + free (str); + Store_field (rv, nr_nodes, nodev); + nr_nodes++; + } + } + + CAMLreturn (rv); +} + +/* external get_blk_net_devs : string -> string array * string array */ +value +get_blk_net_devs (value xmlv) +{ + CAMLparam1 (xmlv); + CAMLlocal3 (rv, blkdevs, netifs); + xmlDocPtr doc; + xmlXPathContextPtr xpathctx; + xmlXPathObjectPtr xpathobj; + const char *expr; + + /* For security reasons, call xmlReadMemory (not xmlParseMemory) and + * pass XML_PARSE_NONET. + */ + doc = xmlReadMemory (String_val (xmlv), caml_string_length (xmlv), + NULL, NULL, XML_PARSE_NONET); + if (doc == NULL) + caml_invalid_argument ("xmlReadMemory: unable to parse XML"); + + xpathctx = xmlXPathNewContext (doc); + if (xpathctx == NULL) + caml_invalid_argument ("xmlXPathNewContext: unable to create new context"); + + expr = "//devices/disk/target/@dev"; + xpathobj = xmlXPathEvalExpression (BAD_CAST expr, xpathctx); + if (xpathobj == NULL) + caml_invalid_argument (expr); + + blkdevs = get_devs (doc, xpathobj); + xmlXPathFreeObject (xpathobj); + + expr = "//devices/interface/target/@dev"; + xpathobj = xmlXPathEvalExpression (BAD_CAST expr, xpathctx); + if (xpathobj == NULL) + caml_invalid_argument (expr); + + netifs = get_devs (doc, xpathobj); + xmlXPathFreeObject (xpathobj); + + xmlXPathFreeContext (xpathctx); + xmlFreeDoc (doc); + + rv = caml_alloc (2, 0); + Store_field (rv, 0, blkdevs); + Store_field (rv, 1, netifs); + CAMLreturn (rv); +} diff --git a/src/xml.ml b/src/xml.ml new file mode 100644 index 0000000..d11ce45 --- /dev/null +++ b/src/xml.ml @@ -0,0 +1,32 @@ +(* 'top'-like tool for libvirt domains. + (C) Copyright 2007-2021 Richard W.M. Jones, Red Hat Inc. + http://libvirt.org/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*) + +module D = Libvirt.Domain + +external get_blk_net_devs : string -> string array * string array + = "get_blk_net_devs" + +let parse_device_xml dom = + try + let xml = D.get_xml_desc dom in + let blkdevs, netifs = get_blk_net_devs xml in + Array.to_list blkdevs, Array.to_list netifs + with + | Invalid_argument _ + | Libvirt.Virterror _ -> [], [] (* ignore transient errors *) -- 1.8.3.1 From 042706796c00adaaadbd0f01b0fa48357a8927aa Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 3 Nov 2021 20:11:07 +0000 Subject: [PATCH 12/16] src/collect.ml: Don't die if a domain goes away during lookup libvirt: VIR_ERR_NO_DOMAIN: VIR_FROM_QEMU: Domain not found: no domain with matching uuid '231eb609-fe6c-4de5-abbc-e1f834457c37' Raised by primitive operation at Libvirt in file "libvirt.ml" (inlined), line 573, characters 0-1023 Called from Collect.collect.(fun) in file "collect.ml", line 168, characters 18-44 Called from Stdlib__List.map in file "list.ml", line 92, characters 20-23 Called from Stdlib__List.map in file "list.ml", line 92, characters 32-39 Called from Collect.collect in file "collect.ml", line 138, characters 4-1023 Called from Top.main_loop in file "top.ml", line 318, characters 16-29 Called from Main in file "main.ml", line 50, characters 4-19 --- src/collect.ml | 345 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 178 insertions(+), 167 deletions(-) diff --git a/src/collect.ml b/src/collect.ml index c8a390c..7d1aadc 100644 --- a/src/collect.ml +++ b/src/collect.ml @@ -137,174 +137,185 @@ let collect (conn, _, _, _, _, node_info, _, _) = let doms = Array.to_list doms in List.map ( fun { D.dom_uuid = uuid; D.params = params } -> - let nr_params = Array.length params in - let get_param name = - let rec loop i = - if i = nr_params then None - else if fst params.(i) = name then Some (snd params.(i)) - else loop (i+1) + try + let nr_params = Array.length params in + let get_param name = + let rec loop i = + if i = nr_params then None + else if fst params.(i) = name then Some (snd params.(i)) + else loop (i+1) + in + loop 0 in - loop 0 - in - let get_param_int name default = - match get_param name with - | None -> None - | Some (D.TypedFieldInt32 i) - | Some (D.TypedFieldUInt32 i) -> Some (Int32.to_int i) - | Some (D.TypedFieldInt64 i) - | Some (D.TypedFieldUInt64 i) -> Some (Int64.to_int i) - | _ -> default - in - let get_param_int64 name default = - match get_param name with - | None -> None - | Some (D.TypedFieldInt32 i) - | Some (D.TypedFieldUInt32 i) -> Some (Int64.of_int32 i) - | Some (D.TypedFieldInt64 i) - | Some (D.TypedFieldUInt64 i) -> Some i - | _ -> default - in - - let dom = D.lookup_by_uuid conn uuid in - let id = D.get_id dom in - let name = D.get_name dom in - let state = get_param_int "state.state" None in - - if state = Some 5 (* VIR_DOMAIN_SHUTOFF *) then - (name, Inactive) - else ( - (* Active domain. *) - - (* Synthesize a D.info struct out of the data we have - * from virConnectGetAllDomainStats. Doing this is an - * artifact from the old APIs we used to use to fetch - * stats, we could simplify here, and also return the - * RSS memory. XXX - *) - let state = - match state with - | None | Some 0 -> D.InfoNoState - | Some 1 -> D.InfoRunning - | Some 2 -> D.InfoBlocked - | Some 3 -> D.InfoPaused - | Some 4 -> D.InfoShutdown - | Some 5 -> D.InfoShutoff - | Some 6 -> D.InfoCrashed - | Some 7 -> D.InfoPaused (* XXX really VIR_DOMAIN_PMSUSPENDED *) - | _ -> D.InfoNoState in - let memory = - match get_param_int64 "balloon.current" None with - | None -> 0_L - | Some m -> m in - let nr_virt_cpu = - match get_param_int "vcpu.current" None with - | None -> 1 - | Some v -> v in - let cpu_time = - (* NB: libvirt does not return cpu.time for non-root domains. *) - match get_param_int64 "cpu.time" None with - | None -> 0_L - | Some ns -> ns in - let info = { - D.state = state; - max_mem = -1_L; (* not used anywhere in virt-top *) - memory = memory; - nr_virt_cpu = nr_virt_cpu; - cpu_time = cpu_time - } in - - let nr_block_devs = - match get_param_int "block.count" None with - | None -> 0 - | Some i -> i in - let block_stats = - List.map ( - fun i -> - let dev = - match get_param (sprintf "block.%d.name" i) with - | None -> sprintf "blk%d" i - | Some (D.TypedFieldString s) -> s - | _ -> assert false in - dev, { - D.rd_req = - (match get_param_int64 (sprintf "block.%d.rd.reqs" i) None - with None -> 0_L | Some v -> v); - rd_bytes = - (match get_param_int64 (sprintf "block.%d.rd.bytes" i) None - with None -> 0_L | Some v -> v); - wr_req = - (match get_param_int64 (sprintf "block.%d.wr.reqs" i) None - with None -> 0_L | Some v -> v); - wr_bytes = - (match get_param_int64 (sprintf "block.%d.wr.bytes" i) None - with None -> 0_L | Some v -> v); - errs = 0_L - } - ) (range 0 (nr_block_devs-1)) in - - let nr_interface_devs = - match get_param_int "net.count" None with - | None -> 0 - | Some i -> i in - let interface_stats = - List.map ( - fun i -> - let dev = - match get_param (sprintf "net.%d.name" i) with - | None -> sprintf "net%d" i - | Some (D.TypedFieldString s) -> s - | _ -> assert false in - dev, { - D.rx_bytes = - (match get_param_int64 (sprintf "net.%d.rx.bytes" i) None - with None -> 0_L | Some v -> v); - rx_packets = - (match get_param_int64 (sprintf "net.%d.rx.pkts" i) None - with None -> 0_L | Some v -> v); - rx_errs = - (match get_param_int64 (sprintf "net.%d.rx.errs" i) None - with None -> 0_L | Some v -> v); - rx_drop = - (match get_param_int64 (sprintf "net.%d.rx.drop" i) None - with None -> 0_L | Some v -> v); - tx_bytes = - (match get_param_int64 (sprintf "net.%d.tx.bytes" i) None - with None -> 0_L | Some v -> v); - tx_packets = - (match get_param_int64 (sprintf "net.%d.tx.pkts" i) None - with None -> 0_L | Some v -> v); - tx_errs = - (match get_param_int64 (sprintf "net.%d.tx.errs" i) None - with None -> 0_L | Some v -> v); - tx_drop = - (match get_param_int64 (sprintf "net.%d.tx.drop" i) None - with None -> 0_L | Some v -> v); - } - ) (range 0 (nr_interface_devs-1)) in - - let prev_info, prev_block_stats, prev_interface_stats = - try - let prev_info, prev_block_stats, prev_interface_stats = - Hashtbl.find last_info uuid in - Some prev_info, prev_block_stats, prev_interface_stats - with Not_found -> None, [], [] in - - (name, - Active { - rd_domid = id; rd_domuuid = uuid; rd_dom = dom; - rd_info = info; - rd_block_stats = block_stats; - rd_interface_stats = interface_stats; - rd_prev_info = prev_info; - rd_prev_block_stats = prev_block_stats; - rd_prev_interface_stats = prev_interface_stats; - rd_cpu_time = 0.; rd_percent_cpu = 0.; - rd_mem_bytes = 0L; rd_mem_percent = 0L; - rd_block_rd_reqs = None; rd_block_wr_reqs = None; - rd_block_rd_bytes = None; rd_block_wr_bytes = None; - rd_net_rx_bytes = None; rd_net_tx_bytes = None; - }) - ) + let get_param_int name default = + match get_param name with + | None -> None + | Some (D.TypedFieldInt32 i) + | Some (D.TypedFieldUInt32 i) -> Some (Int32.to_int i) + | Some (D.TypedFieldInt64 i) + | Some (D.TypedFieldUInt64 i) -> Some (Int64.to_int i) + | _ -> default + in + let get_param_int64 name default = + match get_param name with + | None -> None + | Some (D.TypedFieldInt32 i) + | Some (D.TypedFieldUInt32 i) -> Some (Int64.of_int32 i) + | Some (D.TypedFieldInt64 i) + | Some (D.TypedFieldUInt64 i) -> Some i + | _ -> default + in + + let dom = D.lookup_by_uuid conn uuid in + let id = D.get_id dom in + let name = D.get_name dom in + let state = get_param_int "state.state" None in + + if state = Some 5 (* VIR_DOMAIN_SHUTOFF *) then + (name, Inactive) + else ( + (* Active domain. *) + + (* Synthesize a D.info struct out of the data we have + * from virConnectGetAllDomainStats. Doing this is an + * artifact from the old APIs we used to use to fetch + * stats, we could simplify here, and also return the + * RSS memory. XXX + *) + let state = + match state with + | None | Some 0 -> D.InfoNoState + | Some 1 -> D.InfoRunning + | Some 2 -> D.InfoBlocked + | Some 3 -> D.InfoPaused + | Some 4 -> D.InfoShutdown + | Some 5 -> D.InfoShutoff + | Some 6 -> D.InfoCrashed + | Some 7 -> D.InfoPaused (* XXX really VIR_DOMAIN_PMSUSPENDED *) + | _ -> D.InfoNoState in + let memory = + match get_param_int64 "balloon.current" None with + | None -> 0_L + | Some m -> m in + let nr_virt_cpu = + match get_param_int "vcpu.current" None with + | None -> 1 + | Some v -> v in + let cpu_time = + (* NB: libvirt does not return cpu.time for non-root domains. *) + match get_param_int64 "cpu.time" None with + | None -> 0_L + | Some ns -> ns in + let info = { + D.state = state; + max_mem = -1_L; (* not used anywhere in virt-top *) + memory = memory; + nr_virt_cpu = nr_virt_cpu; + cpu_time = cpu_time + } in + + let nr_block_devs = + match get_param_int "block.count" None with + | None -> 0 + | Some i -> i in + let block_stats = + List.map ( + fun i -> + let dev = + match get_param (sprintf "block.%d.name" i) with + | None -> sprintf "blk%d" i + | Some (D.TypedFieldString s) -> s + | _ -> assert false in + dev, { + D.rd_req = + (let n = sprintf "block.%d.rd.reqs" i in + match get_param_int64 n None + with None -> 0_L | Some v -> v); + rd_bytes = + (let n = sprintf "block.%d.rd.bytes" i in + match get_param_int64 n None + with None -> 0_L | Some v -> v); + wr_req = + (let n = sprintf "block.%d.wr.reqs" i in + match get_param_int64 n None + with None -> 0_L | Some v -> v); + wr_bytes = + (let n = sprintf "block.%d.wr.bytes" i in + match get_param_int64 n None + with None -> 0_L | Some v -> v); + errs = 0_L + } + ) (range 0 (nr_block_devs-1)) in + + let nr_interface_devs = + match get_param_int "net.count" None with + | None -> 0 + | Some i -> i in + let interface_stats = + List.map ( + fun i -> + let dev = + match get_param (sprintf "net.%d.name" i) with + | None -> sprintf "net%d" i + | Some (D.TypedFieldString s) -> s + | _ -> assert false in + dev, { + D.rx_bytes = + (match get_param_int64 (sprintf "net.%d.rx.bytes" i) None + with None -> 0_L | Some v -> v); + rx_packets = + (match get_param_int64 (sprintf "net.%d.rx.pkts" i) None + with None -> 0_L | Some v -> v); + rx_errs = + (match get_param_int64 (sprintf "net.%d.rx.errs" i) None + with None -> 0_L | Some v -> v); + rx_drop = + (match get_param_int64 (sprintf "net.%d.rx.drop" i) None + with None -> 0_L | Some v -> v); + tx_bytes = + (match get_param_int64 (sprintf "net.%d.tx.bytes" i) None + with None -> 0_L | Some v -> v); + tx_packets = + (match get_param_int64 (sprintf "net.%d.tx.pkts" i) None + with None -> 0_L | Some v -> v); + tx_errs = + (match get_param_int64 (sprintf "net.%d.tx.errs" i) None + with None -> 0_L | Some v -> v); + tx_drop = + (match get_param_int64 (sprintf "net.%d.tx.drop" i) None + with None -> 0_L | Some v -> v); + } + ) (range 0 (nr_interface_devs-1)) in + + let prev_info, prev_block_stats, prev_interface_stats = + try + let prev_info, prev_block_stats, prev_interface_stats = + Hashtbl.find last_info uuid in + Some prev_info, prev_block_stats, prev_interface_stats + with Not_found -> None, [], [] in + + (name, + Active { + rd_domid = id; rd_domuuid = uuid; rd_dom = dom; + rd_info = info; + rd_block_stats = block_stats; + rd_interface_stats = interface_stats; + rd_prev_info = prev_info; + rd_prev_block_stats = prev_block_stats; + rd_prev_interface_stats = prev_interface_stats; + rd_cpu_time = 0.; rd_percent_cpu = 0.; + rd_mem_bytes = 0L; rd_mem_percent = 0L; + rd_block_rd_reqs = None; rd_block_wr_reqs = None; + rd_block_rd_bytes = None; rd_block_wr_bytes = None; + rd_net_rx_bytes = None; rd_net_tx_bytes = None; + }) + ) + with + Libvirt.Virterror _ -> + (* this can happen if a domain goes away while we + * are reading it, just report an inactive domain + *) + ("", Inactive) ) doms in (* Calculate the CPU time (ns) and %CPU used by each domain. *) -- 1.8.3.1 From 6a45c04e27b942555e79f96f52e452e56d1aca97 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 3 Nov 2021 20:20:53 +0000 Subject: [PATCH 13/16] Version 1.1.1. --- configure.ac | 2 +- po/POTFILES-ml | 1 - po/virt-top.pot | 152 +++++++++++++++++++++++++++----------------------------- 3 files changed, 73 insertions(+), 82 deletions(-) diff --git a/configure.ac b/configure.ac index d31d042..840eba2 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([virt-top],[1.1.0]) +AC_INIT([virt-top],[1.1.1]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/po/POTFILES-ml b/po/POTFILES-ml index 249c66b..cec31b5 100644 --- a/po/POTFILES-ml +++ b/po/POTFILES-ml @@ -2,7 +2,6 @@ ./src/csv_output.ml ./src/main.ml ./src/opt_calendar.ml -./src/opt_csv.ml ./src/opt_gettext.ml ./src/redraw.ml ./src/screen.ml diff --git a/po/virt-top.pot b/po/virt-top.pot index 09cd370..0b3a28e 100644 --- a/po/virt-top.pot +++ b/po/virt-top.pot @@ -6,10 +6,10 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: virt-top 1.0.9\n" +"Project-Id-Version: virt-top 1.1.1\n" "Report-Msgid-Bugs-To: https://bugzilla.redhat.com/enter_bug.cgi?" "component=libguestfs&product=Virtualization+Tools\n" -"POT-Creation-Date: 2021-10-01 16:15+0100\n" +"POT-Creation-Date: 2021-11-03 20:20+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,23 +18,23 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -#: src/top.ml:588 +#: src/top.ml:581 msgid "# %s virt-top configuration file\n" msgstr "" -#: src/top.ml:606 +#: src/top.ml:599 msgid "# Enable CSV output to the named file\n" msgstr "" -#: src/top.ml:609 +#: src/top.ml:602 msgid "# To protect this file from being overwritten, uncomment next line\n" msgstr "" -#: src/top.ml:603 +#: src/top.ml:596 msgid "# To send debug and error messages to a file, uncomment next line\n" msgstr "" -#: src/top.ml:589 +#: src/top.ml:582 msgid "# generated on %s by %s\n" msgstr "" @@ -46,21 +46,21 @@ msgstr "" msgid "%MEM" msgstr "" -#: src/redraw.ml:481 +#: src/redraw.ml:480 msgid "" "%d domains, %d active, %d running, %d sleeping, %d paused, %d inactive D:%d " "O:%d X:%d" msgstr "" -#: src/top.ml:177 +#: src/top.ml:170 msgid "%s: could not parse '%s' in init file: expecting %s" msgstr "" -#: src/top.ml:172 +#: src/top.ml:165 msgid "%s: could not parse '%s' in init file: expecting a number" msgstr "" -#: src/top.ml:167 +#: src/top.ml:160 msgid "%s: could not parse '%s' in init file: expecting an integer" msgstr "" @@ -72,21 +72,21 @@ msgstr "" msgid "%s: sort order should be: %s" msgstr "" -#: src/top.ml:149 +#: src/top.ml:142 msgid "%s: unknown parameter" msgstr "" -#: src/top.ml:201 +#: src/top.ml:194 msgid "" "%s:%d: configuration item ``%s'' ignored\n" "%!" msgstr "" -#: src/top.ml:79 +#: src/top.ml:72 msgid "-d: cannot set a negative delay" msgstr "" -#: src/top.ml:105 +#: src/top.ml:98 msgid "Batch mode" msgstr "" @@ -98,59 +98,59 @@ msgstr "" msgid "Block write reqs" msgstr "" -#: src/redraw.ml:488 +#: src/redraw.ml:487 msgid "CPU: %2.1f%% Mem: %Ld MB (%Ld MB by guests)" msgstr "" -#: src/top.ml:411 +#: src/top.ml:404 msgid "Change delay from %.1f to: " msgstr "" -#: src/top.ml:109 src/top.ml:107 +#: src/top.ml:102 src/top.ml:100 msgid "Connect to libvirt URI" msgstr "" -#: src/top.ml:662 +#: src/top.ml:655 msgid "Connect: %s; Hostname: %s" msgstr "" -#: src/top.ml:701 +#: src/top.ml:694 msgid "DISPLAY MODES" msgstr "" -#: src/top.ml:418 +#: src/top.ml:411 msgid "Delay must be > 0" msgstr "" -#: src/top.ml:121 +#: src/top.ml:114 msgid "Delay time interval (seconds)" msgstr "" -#: src/top.ml:655 +#: src/top.ml:648 msgid "Delay: %.1f secs; Batch: %s; Secure: %s; Sort: %s" msgstr "" -#: src/top.ml:113 +#: src/top.ml:106 msgid "Disable CPU stats in CSV" msgstr "" -#: src/top.ml:117 +#: src/top.ml:110 msgid "Disable block device stats in CSV" msgstr "" -#: src/top.ml:115 +#: src/top.ml:108 msgid "Disable memory stats in CSV" msgstr "" -#: src/top.ml:119 +#: src/top.ml:112 msgid "Disable net stats in CSV" msgstr "" -#: src/top.ml:146 +#: src/top.ml:139 msgid "Display version number and exit" msgstr "" -#: src/top.ml:131 +#: src/top.ml:124 msgid "Do not read init file" msgstr "" @@ -162,39 +162,39 @@ msgstr "" msgid "Domain name" msgstr "" -#: src/top.ml:715 +#: src/top.ml:708 msgid "Domains display" msgstr "" -#: src/top.ml:629 src/top.ml:626 src/main.ml:69 src/main.ml:44 +#: src/top.ml:622 src/top.ml:619 src/main.ml:69 src/main.ml:44 msgid "Error" msgstr "" -#: src/top.ml:125 +#: src/top.ml:118 msgid "Exit at given time" msgstr "" -#: src/top.ml:684 +#: src/top.ml:677 msgid "Help" msgstr "" -#: src/top.ml:127 +#: src/top.ml:120 msgid "Historical CPU delay" msgstr "" -#: src/top.ml:111 +#: src/top.ml:104 msgid "Log statistics to CSV file" msgstr "" -#: src/top.ml:667 +#: src/top.ml:660 msgid "MAIN KEYS" msgstr "" -#: src/top.ml:722 +#: src/top.ml:715 msgid "More help in virt-top(1) man page. Press any key to return." msgstr "" -#: src/top.ml:226 +#: src/top.ml:219 msgid "" "NB: If you want to monitor a local hypervisor, you usually need to be root" msgstr "" @@ -207,87 +207,87 @@ msgstr "" msgid "Net TX bytes" msgstr "" -#: src/top.ml:424 +#: src/top.ml:417 msgid "Not a valid number" msgstr "" -#: src/top.ml:133 +#: src/top.ml:126 msgid "Number of iterations to run" msgstr "" -#: src/top.ml:658 src/top.ml:657 +#: src/top.ml:651 src/top.ml:650 msgid "Off" msgstr "" -#: src/top.ml:658 src/top.ml:657 +#: src/top.ml:651 src/top.ml:650 msgid "On" msgstr "" -#: src/top.ml:682 +#: src/top.ml:675 msgid "Quit" msgstr "" -#: src/top.ml:140 +#: src/top.ml:133 msgid "Run from a script (no user interface)" msgstr "" -#: src/top.ml:689 +#: src/top.ml:682 msgid "SORTING" msgstr "" -#: src/top.ml:138 +#: src/top.ml:131 msgid "Secure (\"kiosk\") mode" msgstr "" -#: src/top.ml:698 +#: src/top.ml:691 msgid "Select sort field" msgstr "" -#: src/top.ml:123 +#: src/top.ml:116 msgid "Send debug messages to file" msgstr "" -#: src/top.ml:129 +#: src/top.ml:122 msgid "Set name of init file" msgstr "" -#: src/top.ml:135 +#: src/top.ml:128 msgid "Set sort order (%s)" msgstr "" -#: src/top.ml:432 +#: src/top.ml:425 msgid "Set sort order for main display" msgstr "" -#: src/top.ml:683 +#: src/top.ml:676 msgid "Set update interval" msgstr "" -#: src/top.ml:694 +#: src/top.ml:687 msgid "Sort by %CPU" msgstr "" -#: src/top.ml:695 +#: src/top.ml:688 msgid "Sort by %MEM" msgstr "" -#: src/top.ml:697 +#: src/top.ml:690 msgid "Sort by ID" msgstr "" -#: src/top.ml:696 +#: src/top.ml:689 msgid "Sort by TIME" msgstr "" -#: src/top.ml:103 +#: src/top.ml:96 msgid "Start by displaying block devices" msgstr "" -#: src/top.ml:101 +#: src/top.ml:94 msgid "Start by displaying network interfaces" msgstr "" -#: src/top.ml:99 +#: src/top.ml:92 msgid "Start by displaying pCPUs (default: tasks)" msgstr "" @@ -295,59 +295,55 @@ msgstr "" msgid "TIME (CPU time)" msgstr "" -#: src/top.ml:718 +#: src/top.ml:711 msgid "Toggle block devices" msgstr "" -#: src/top.ml:717 +#: src/top.ml:710 msgid "Toggle network interfaces" msgstr "" -#: src/top.ml:716 +#: src/top.ml:709 msgid "Toggle physical CPUs" msgstr "" -#: src/top.ml:433 +#: src/top.ml:426 msgid "Type key or use up and down cursor keys." msgstr "" -#: src/top.ml:727 +#: src/top.ml:720 msgid "Unknown command - try 'h' for help" msgstr "" -#: src/top.ml:681 +#: src/top.ml:674 msgid "Update display" msgstr "" -#: src/top.ml:621 +#: src/top.ml:614 msgid "Wrote settings to %s" msgstr "" -#: src/top.ml:663 +#: src/top.ml:656 msgid "default" msgstr "" -#: src/top.ml:142 +#: src/top.ml:135 msgid "dump output to stdout (no userinterface)" msgstr "" -#: src/opt_xml.ml:46 -msgid "get_xml_desc didn't return " -msgstr "" - -#: src/top.ml:144 +#: src/top.ml:137 msgid "show block device load in bytes rather than reqs" msgstr "" -#: src/top.ml:685 +#: src/top.ml:678 msgid "toggle block info req/bytes" msgstr "" -#: src/top.ml:643 +#: src/top.ml:636 msgid "virt-top %s ocaml-libvirt %s libvirt %d.%d.%d by Red Hat" msgstr "" -#: src/top.ml:150 +#: src/top.ml:143 msgid "" "virt-top : a 'top'-like utility for virtualization\n" "\n" @@ -358,9 +354,5 @@ msgid "" msgstr "" #: src/top.ml:39 -msgid "virt-top was compiled without support for CSV files" -msgstr "" - -#: src/top.ml:46 msgid "virt-top was compiled without support for dates and times" msgstr "" -- 1.8.3.1 From 4b15ee2440b0e70e3c1eb5e164ded493e2d8f0c8 Mon Sep 17 00:00:00 2001 From: Yuya Higashi Date: Tue, 15 Nov 2022 13:56:21 +0900 Subject: [PATCH 14/16] virt-top: fix to explicitly disconnect from libvirtd To prevent libvirtd from printing virNetSocketReadWire I/O errors when the virt-top command exits, explicitly disconnect from libvirtd. Signed-off-by: Yuya Higashi --- src/top.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/top.ml b/src/top.ml index 75fbcb9..cbe655a 100644 --- a/src/top.ml +++ b/src/top.ml @@ -306,7 +306,7 @@ let get_string maxlen = ) (* Main loop. *) -let rec main_loop ((_, batch_mode, script_mode, csv_enabled, stream_mode, _, _, _) +let rec main_loop ((conn, batch_mode, script_mode, csv_enabled, stream_mode, _, _, _) as setup) = let csv_flags = !csv_cpu, !csv_mem, !csv_block, !csv_net in @@ -372,7 +372,8 @@ let rec main_loop ((_, batch_mode, script_mode, csv_enabled, stream_mode, _, _, if not !quit || !end_time <> None then millisleep delay ) - done + done; + C.close conn and get_key_press setup delay = (* Read the next key, waiting up to 'delay' milliseconds. *) -- 1.8.3.1 From 1d04fdfce6edea685596fbb18920799c70f1d7fa Mon Sep 17 00:00:00 2001 From: Yuya Higashi Date: Mon, 26 Dec 2022 09:18:15 +0900 Subject: [PATCH 15/16] virt-top: fix to parse init-file correctly This fixes the following runtime error when parsing init-file. $ virt-top --init-file <(echo "sort id") Error: Invalid_argument("String.sub / Bytes.sub") Raised at Stdlib.invalid_arg in file "stdlib.ml", line 30, characters 20-45 Called from Stdlib__String.sub in file "string.ml" (inlined), line 50, characters 2-23 Called from Utils.split in file "utils.ml", line 82, characters 24-68 Called from Utils.read_config_file.(fun) in file "utils.ml", line 114, characters 23-37 Called from Stdlib__List.map in file "list.ml", line 92, characters 20-23 Called from Top.start_up.try_to_read_init_file in file "top.ml", line 153, characters 17-42 Called from Main.script_mode in file "main.ml", line 37, characters 6-17 Signed-off-by: Yuya Higashi --- src/utils.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ml b/src/utils.ml index 1f00803..8dfb255 100644 --- a/src/utils.ml +++ b/src/utils.ml @@ -79,7 +79,7 @@ let trim ?(test = isspace) str = let split str sep = try let i = String.index str sep in - String.sub str 0 i, String.sub str (i+1) (String.length str - 1) + String.sub str 0 i, String.sub str (i+1) (String.length str - i - 1) with Not_found -> str, "" -- 1.8.3.1 From dd205eeae9fb06ac113884e4c9e9f3a90eef7554 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 27 Nov 2023 14:09:04 +0000 Subject: [PATCH 16/16] src: Include MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit libxml2 2.12.1 failed with this error: xml-c.c:92:9: warning: implicit declaration of function ‘xmlReadMemory’; did you mean ‘xmlInitMemory’? [-Wimplicit-function-declaration] 92 | doc = xmlReadMemory (String_val (xmlv), caml_string_length (xmlv), | ^~~~~~~~~~~~~ | xmlInitMemory --- src/xml-c.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/xml-c.c b/src/xml-c.c index 72042bf..6c546b9 100644 --- a/src/xml-c.c +++ b/src/xml-c.c @@ -28,6 +28,7 @@ #include #include +#include #include #include -- 1.8.3.1