Fix parse error using --init-file option

resolves: rhbz#2159549
This commit is contained in:
Richard W.M. Jones 2023-01-10 09:20:41 +00:00
parent df3c34e373
commit 6c178b22ce
3 changed files with 47 additions and 2 deletions

View File

@ -1,7 +1,7 @@
From 4b15ee2440b0e70e3c1eb5e164ded493e2d8f0c8 Mon Sep 17 00:00:00 2001 From 4b15ee2440b0e70e3c1eb5e164ded493e2d8f0c8 Mon Sep 17 00:00:00 2001
From: Yuya Higashi <higashi.yuya@fujitsu.com> From: Yuya Higashi <higashi.yuya@fujitsu.com>
Date: Tue, 15 Nov 2022 13:56:21 +0900 Date: Tue, 15 Nov 2022 13:56:21 +0900
Subject: [PATCH] virt-top: fix to explicitly disconnect from libvirtd Subject: [PATCH 1/2] virt-top: fix to explicitly disconnect from libvirtd
To prevent libvirtd from printing virNetSocketReadWire I/O errors when To prevent libvirtd from printing virNetSocketReadWire I/O errors when
the virt-top command exits, explicitly disconnect from libvirtd. the virt-top command exits, explicitly disconnect from libvirtd.

View File

@ -0,0 +1,38 @@
From 1d04fdfce6edea685596fbb18920799c70f1d7fa Mon Sep 17 00:00:00 2001
From: Yuya Higashi <higashi.yuya@fujitsu.com>
Date: Mon, 26 Dec 2022 09:18:15 +0900
Subject: [PATCH 2/2] 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 <higashi.yuya@fujitsu.com>
---
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, ""
--
2.31.1

View File

@ -1,7 +1,7 @@
%undefine _package_note_flags %undefine _package_note_flags
Name: virt-top Name: virt-top
Version: 1.1.1 Version: 1.1.1
Release: 7%{?dist} Release: 8%{?dist}
Summary: Utility like top(1) for displaying virtualization stats Summary: Utility like top(1) for displaying virtualization stats
License: GPLv2+ License: GPLv2+
@ -28,6 +28,9 @@ Patch1: virt-top-1.0.9-processcsv-documentation.patch
# Fix "Input/output error" in journal (RHBZ#2148798) # Fix "Input/output error" in journal (RHBZ#2148798)
Patch2: 0001-virt-top-fix-to-explicitly-disconnect-from-libvirtd.patch Patch2: 0001-virt-top-fix-to-explicitly-disconnect-from-libvirtd.patch
# Fix parse error using --init-file option (RHBZ#2159549)
Patch3: 0002-virt-top-fix-to-parse-init-file-correctly.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: make BuildRequires: make
BuildRequires: ocaml >= 3.10.2 BuildRequires: ocaml >= 3.10.2
@ -116,6 +119,10 @@ install -m 0644 processcsv.py.1 $RPM_BUILD_ROOT%{_mandir}/man1/
%changelog %changelog
* Tue Jan 10 2023 Richard W.M. Jones <rjones@redhat.com> - 1.1.1-8
- Fix parse error using --init-file option
resolves: rhbz#2159549
* Mon Nov 28 2022 Richard W.M. Jones <rjones@redhat.com> - 1.1.1-7 * Mon Nov 28 2022 Richard W.M. Jones <rjones@redhat.com> - 1.1.1-7
- Fix "Input/output error" in journal - Fix "Input/output error" in journal
resolves: rhbz#2148798 resolves: rhbz#2148798