Files
xen/docs/man/xentop.1.pod
Matthias Goergens 292fb23a92 tools/xentop: reject invalid --delay and --iterations arguments
xentop parses -d/--delay and -i/--iterations with atoi(), so invalid
input is silently accepted with surprising results: a fractional delay
such as "-d 2.5" is truncated to 2; "-d abc" parses as 0, which in
batch mode turns the output loop into a busy loop; "-d -1" wraps to an
effective delay of about 136 years; and "-i 0" (or any unparsable
iterations count) decrements an unsigned counter from zero, running
for about 2^32 iterations.  atoi() also has undefined behaviour on
out-of-range input.

Parse both options with strtoull() instead, and reject anything that
is not a plain decimal integer in range: a sign, a fractional part,
trailing junk or overflow now produce an error and exit rather than a
silently wrong value.

Compatibility considerations: "--delay 0" remains accepted, since
updating as fast as possible is a plausible deliberate choice and
works today; "--iterations 0" is rejected, since running the loop
2^32 times cannot be what the caller meant.  The interactive 'D'
prompt already validates its input and is unchanged.  The only
previously useful invocation this breaks is a fractional delay, which
now fails loudly instead of silently rounding down - which is the
point of the change.

A patch documenting the --delay truncation was posted in 2010 but
never applied:
Link: https://lore.kernel.org/xen-devel/01ea26d2420e3562eb30.1292604768@chilopoda.uk.xensource.com/

Signed-off-by: Matthias Goergens <matthias.goergens@gmail.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
2026-10-12 17:31:39 +02:00

121 lines
2.1 KiB
INI

=head1 NAME
xentop - displays real-time information about a Xen system and domains
=head1 SYNOPSIS
B<xentop> [B<-h>] [B<-V>] [B<-d>SECONDS] [B<-n>] [B<-r>] [B<-v>] [B<-f>]
[B<-b>] [B<-i>ITERATIONS] [B<-z>] [B<-p>]
=head1 DESCRIPTION
B<xentop> displays information about the Xen system and domains, in a
continually-updating manner. Command-line options and interactive commands
can change the detail and format of the information displayed by B<xentop>.
=head1 OPTIONS
=over 4
=item B<-h>, B<--help>
display help and exit
=item B<-V>, B<--version>
output version information and exit
=item B<-d>, B<--delay>=I<SECONDS>
seconds between updates (default 3); must be a non-negative integer
=item B<-n>, B<--networks>
output network information
=item B<-x>, B<--vbds>
output vbd block device data
=item B<-r>, B<--repeat-header>
repeat table header before each domain
=item B<-v>, B<--vcpus>
output VCPU data
=item B<-f>, B<--full-name>
output the full domain name (not truncated)
=item B<-b>, B<--batch>
output data in batch mode (to stdout)
=item B<-i>, B<--iterations>=I<ITERATIONS>
maximum number of iterations xentop should produce before ending; must
be a positive integer
=item B<-z>, B<--dom0-first>
display dom0 first, ignoring interactive sorting
=item B<-p>, B<--pcpus>
display physical CPU utilization metrics
=back
=head1 INTERACTIVE COMMANDS
All interactive commands are case-insensitive.
=over 4
=item B<D>
set delay between updates
=item B<N>
toggle display of network information
=item B<Q>, B<Esc>
quit
=item B<R>
toggle table header before each domain
=item B<S>
cycle sort order
=item B<V>
toggle display of VCPU information
=item B<Arrows>
scroll domain display
=back
=head1 AUTHORS
Written by Judy Fischbach, David Hendricks, and Josh Triplett
=head1 REPORTING BUGS
Report bugs to <xen-devel@lists.xenproject.org>.
=head1 COPYRIGHT
Copyright 2005 International Business Machines Corp
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.