git: c7dd97ec9968 - main - vmstat: Add root element to libxo output

From: Xin LI <delphij_at_FreeBSD.org>
Date: Tue, 03 Sep 2024 01:22:48 UTC
The branch main has been updated by delphij:

URL: https://cgit.FreeBSD.org/src/commit/?id=c7dd97ec99687996de49ec0b1a23bf007e5199b9

commit c7dd97ec99687996de49ec0b1a23bf007e5199b9
Author:     Bram Ton <bram@cbbg.nl>
AuthorDate: 2024-07-17 07:23:30 +0000
Commit:     Xin LI <delphij@FreeBSD.org>
CommitDate: 2024-09-03 01:22:14 +0000

    vmstat: Add root element to libxo output
    
    Current libxo output does not have a root element. Valid XML requires a single
    root element. This commit adds this root element.
    
    The libxo output version bumped accordingly.
    
    PR:             254635
    MFC after:      1 week
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1330
---
 usr.bin/vmstat/vmstat.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 21068d632a8c..e7790ad6e2f6 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -66,7 +66,7 @@
 #include <libutil.h>
 #include <libxo/xo.h>
 
-#define VMSTAT_XO_VERSION "1"
+#define VMSTAT_XO_VERSION "2"
 
 static char da[] = "da";
 
@@ -282,6 +282,7 @@ main(int argc, char *argv[])
 	argv += optind;
 
 	xo_set_version(VMSTAT_XO_VERSION);
+	xo_open_container("vmstat");
 	if (!hflag)
 		xo_set_options(NULL, "no-humanize");
 	if (todo == 0)
@@ -383,6 +384,7 @@ nlist_ok:
 		dointr(interval, reps);
 	if (todo & VMSTAT)
 		dovmstat(interval, reps);
+	xo_close_container("vmstat");
 	xo_finish();
 	exit(0);
 }