From: Markus Armbruster <armbru@redhat.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org,
quintela@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org,
mreitz@redhat.com, pbonzini@redhat.com,
marcandre.lureau@redhat.com, jsnow@redhat.com
Subject: Re: [Qemu-devel] [RFC PATCH 03/56] monitor: Rewrite comment describing HMP .args_type
Date: Wed, 09 Aug 2017 08:00:26 +0200 [thread overview]
Message-ID: <871sol1ds5.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20170808161022.GO2081@work-vm> (David Alan Gilbert's message of "Tue, 8 Aug 2017 17:10:22 +0100")
"Dr. David Alan Gilbert" <dgilbert@redhat.com> writes:
> * Markus Armbruster (armbru@redhat.com) wrote:
>> "Dr. David Alan Gilbert" <dgilbert@redhat.com> writes:
>>
>> > * Markus Armbruster (armbru@redhat.com) wrote:
>> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> >> ---
>> >> monitor.c | 75 +++++++++++++++++++++++++++++++++++++++------------------------
>> >> 1 file changed, 47 insertions(+), 28 deletions(-)
>> >>
>> >> diff --git a/monitor.c b/monitor.c
>> >> index e0f8801..8b54ba1 100644
>> >> --- a/monitor.c
>> >> +++ b/monitor.c
>> >> @@ -85,37 +85,56 @@
>> >> #endif
>> >>
>> >> /*
>> >> - * Supported types:
>> >> + * Command handlers (mon_cmd_t member @cmd) receive actual arguments
>> >> + * in a QDict, which is built by the HMP core according to mon_cmd_t
>> >> + * member @args_type. It's a list of NAME:TYPE separated by comma.
>> >> *
>> >> - * 'F' filename
>> >> - * 'B' block device name
>> >> - * 's' string (accept optional quote)
>> >> - * 'S' it just appends the rest of the string (accept optional quote)
>> >> - * 'O' option string of the form NAME=VALUE,...
>> >> - * parsed according to QemuOptsList given by its name
>> >> - * Example: 'device:O' uses qemu_device_opts.
>> >> - * Restriction: only lists with empty desc are supported
>> >> - * TODO lift the restriction
>> >> - * 'i' 32 bit integer
>> >> - * 'l' target long (32 or 64 bit)
>> >> - * 'M' Non-negative target long (32 or 64 bit), in user mode the
>> >> - * value is multiplied by 2^20 (think Mebibyte)
>> >> - * 'o' octets (aka bytes)
>> >> - * user mode accepts an optional E, e, P, p, T, t, G, g, M, m,
>> >> - * K, k suffix, which multiplies the value by 2^60 for suffixes E
>> >> - * and e, 2^50 for suffixes P and p, 2^40 for suffixes T and t,
>> >> - * 2^30 for suffixes G and g, 2^20 for M and m, 2^10 for K and k
>> >> - * 'T' double
>> >> - * user mode accepts an optional ms, us, ns suffix,
>> >> - * which divides the value by 1e3, 1e6, 1e9, respectively
>> >> - * '/' optional gdb-like print format (like "/10x")
>> >> + * TYPEs that put a string value with key NAME into the QDict:
>> >> + * 's' Argument is enclosed in '"' or delimited by whitespace. In
>> >> + * the former case, escapes \n \r \\ \' and \" are recognized.
>> >> + * 'F' File name, like 's' except for completion.
>> >> + * 'B' BlockBackend name, like 's' except for completion.
>> >> + * 'S' Argument is the remainder of the line, less leading
>> >> + * whitespace.
>> >> +
>> >> *
>> >> - * '?' optional type (for all types, except '/')
>> >> - * '.' other form of optional type (for 'i' and 'l')
>> >> - * 'b' boolean
>> >> - * user mode accepts "on" or "off"
>> >> - * '-' optional parameter (eg. '-f')
>> >> + * TYPEs that put an int64_t value with key NAME:
>> >> + * 'l' Argument is an expression (QEMU pocket calculator).
>> >> + * 'i' Like 'l' except value must fit into 32 bit unsigned.
>> >> + * 'M' Like 'l' except value must not be negative and is multiplied
>> >> + * by 2^20 (think "mebibyte").
>> >> *
>> >> + * TYPEs that put an uint64_t value with key NAME:
>> >> + * 'o' Argument is a size (think "octets"). Without suffix the
>> >> + * value is multiplied by 2^20 (mebibytes), with suffix E or e
>> >> + * by 2^60 (exbibytes), with P or p by 2^50 (pebibytes), with T
>> >> + * or t by 2^40 (tebibytes), with G or g by 2^30 (gibibytes),
>> >> + * with M or m by 2^10 (mebibytes), with K or k by 2^10
>> >> + * (kibibytes).
>> >
>> > 'o' is messy. It using qemu_strtosz_MiB which uses a 'double' intermediate
>> > so I fear it can round.
>>
>> It does, but only when you have more than 53 significant bits.
>>
>> > It also has a note it can't take all f's due to
>> > an overflow from the conversion.
>>
>> Correct, because values between 0xfffffffffffffc00 and 2^64-1 round up
>> to 2^64.
>
> Right, so these bother me not for normal sizes, but if we were to start
> to use them for hex values with meanings, like addresses for example.
> (Although I guess that's unlikely with the default assumption of MB)
Yes, 'o' is convenient in some cases, inconvenient in others, and
incapable when you need more than 53 significant bits.
>> If it bothers you, feel free to explore the following: feed the string
>> both to strtod() and to strtoll(). Whichever eats more characters wins.
>
> Is the reason we're using strtod because we actively want users to be
> able to say 3.5G ? I guess that's a reason to keep it.
Early (and flawed) version(s) of the patch introducing strtosz() used
strtoll(). Jes decided to switch to strtod() precisely to support
things like 3.5G.
>> This patch is of course just about better documenting what we have. I
>> was starting to type something like "repeating the (complex) contract of
>> qemu_strtosz_MiB() here isn't so hot, let's include it by reference
>> instead", but then I looked it up. Pffft.
>>
>> > Two things not mentioned are that
>> > it also takes hex (as explicit 0x) and that it also does 'b' as a suffix
>> > to multiply by 1. Those two combine in bad ways - i.e. 0x1b is 27MB,
>> > 1b is 1 byte (same for 'e'). These are probably OK except if you were
>> > to start replacing 'l' by 'o' because you really wanted 64bit addresses
>> > say.
>>
>> I guess the sanest solution is not to recognize suffixes when the number
>> is hexadecimal.
>>
>> > (I also wouldn't bother expanding the size names and powers).
>>
>> I erred on the side of tedious clarity. Feel free to suggest something
>> you like better.
>
> I think something like:
> The optional suffix's b/k/m/g/t/p/e are accepted (upper or lower case)
> to denote bytes, kibibytes, mebibytes etc. With no suffix, values
> are interpreted as MiB.
I like it. I'll fix "suffix's" to "suffixes", and list the suffixes in
their "officially correct" case "b/k/M/G/T/P/E".
>> >> + *
>> >> + * TYPEs that put a double value with key NAME:
>> >> + * 'T' Argument is a time in seconds. With optional ms, us, ns
>> >> + * suffix, the value divided by 1e3, 1e6, 1e9 respectively.
>> >> + *
>> >> + * TYPEs that put a bool value with key NAME:
>> >> + * 'b' Argument is either "on" (true) or "off" (false).
>> >> + * '-' CHAR
>> >> + * Argument is either "-CHAR" (true) or absent (false).
>> >
>> > I found the previous description clearer.
>>
>> What I don't like about the previous description: it defines by example.
>> Examples are great, but they are for illustrating a definition, they
>> can't really replace one.
>
> I'm less fussy if it's clear; how about
> '-' CHAR
> True if optional single character argument (e.g. -f) is present
> else absent.
>
> since you've got the '-' CHAR you have the definition.
Sold.
>> >> + * TYPEs that put multiple values:
>> >> + * 'O' Option string of the form NAME=VALUE,... parsed according to
>> >> + * the QemuOptsList given by its name.
>> >> + * Example: 'device:O' uses qemu_device_opts.
>> >> + * Restriction: only lists with empty desc are supported.
>> >> + * Puts all the NAME=VALUE.
>> >> + * '/' Gdb-like print format (like "/10x"), always optional.
>> >> + * Puts keys "count", "format", "size", all int.
>> >> + *
>> >> + * Modifier character following the type string:
>> >> + * '?' Argument is optional, nothing is put when it is absent
>> >> + * (all types except 'O', '/', 'b').
>> >> + * '.' Argument is optional, must be preceded by '.' if present
>> >> + * (only types 'i', 'l', 'M')
>> >
>> > That's obscure; I can only see one use of it in ioport_read and that's
>> > extra-special!
>>
>> Extra-special baroque! Took me a while to figure out WTF it does :)
>
> Should we avoid a lot of the 'o' pain by adding a new type; something
> like:
> '6'
> A 64bit unsigned value. Decimal or hex integers are accepted;
> optional suffixes of k/m/g/t/p/e are accepted to denote kibibytes
> etc. With no suffix values are interpreted as bytes.
>
> then that would be suffix_mul() * qemu_strtou64()
Feels like a good idea. Of course you need to find a few uses for it.
Might even want to discourage new uses of 'o' then.
>
> Dave
>
>> >> */
>> >>
>> >> typedef struct mon_cmd_t {
>> >> --
>> >> 2.7.5
>>
>> Thanks!
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2017-08-09 6:00 UTC|newest]
Thread overview: 105+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 14:45 [Qemu-devel] [RFC PATCH 00/56] qapi: Use 'size' for byte counts & offsets Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 01/56] qobject: Touch up comments to say @param instead of 'param' Markus Armbruster
2017-08-09 14:39 ` Eric Blake
2017-08-10 8:20 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 02/56] qdict: New helpers to put and get unsigned integers Markus Armbruster
2017-08-22 11:27 ` Marc-André Lureau
2017-08-22 12:49 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 03/56] monitor: Rewrite comment describing HMP .args_type Markus Armbruster
2017-08-08 11:20 ` Dr. David Alan Gilbert
2017-08-08 14:22 ` Paolo Bonzini
2017-08-08 14:46 ` Dr. David Alan Gilbert
2017-08-08 15:36 ` Markus Armbruster
2017-08-08 16:10 ` Dr. David Alan Gilbert
2017-08-09 6:00 ` Markus Armbruster [this message]
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 04/56] char: Make ringbuf-read size unsigned in QAPI/QMP Markus Armbruster
2017-08-22 11:32 ` Marc-André Lureau
2017-08-22 13:00 ` Markus Armbruster
2017-08-22 15:54 ` Marc-André Lureau
2017-08-22 16:22 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 05/56] char: Make ringbuf size unsigned in QAPI Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 06/56] char: Don't truncate -chardev and HMP chardev-add ringbuf size Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 07/56] cpus: Make memsave, pmemsave sizes, addresses unsigned in QAPI/QMP Markus Armbruster
2017-08-08 14:31 ` Dr. David Alan Gilbert
2017-08-08 15:37 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 08/56] dump: Make sizes and " Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 09/56] balloon: Make balloon size " Markus Armbruster
2017-08-08 14:58 ` Dr. David Alan Gilbert
2017-08-09 6:04 ` Markus Armbruster
2017-08-09 10:47 ` Dr. David Alan Gilbert
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 10/56] hmp: Make balloon's argument unsigned Markus Armbruster
2017-08-08 15:10 ` Dr. David Alan Gilbert
2017-08-09 6:05 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 11/56] monitor: Drop unused HMP .args_type 'M' Markus Armbruster
2017-08-08 15:23 ` Dr. David Alan Gilbert
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 12/56] pc-dimm: Make size and address unsigned in QAPI/QMP Markus Armbruster
2017-08-22 12:55 ` Igor Mammedov
2017-08-22 13:50 ` Markus Armbruster
2017-08-22 15:45 ` Igor Mammedov
2017-08-22 16:38 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 13/56] pci: Make PCI addresses and sizes " Markus Armbruster
2017-08-22 14:03 ` Marcel Apfelbaum
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 14/56] migration: Fix migrate-set-cache-size error reporting Markus Armbruster
2017-08-07 16:07 ` Juan Quintela
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 15/56] migration: Make XBZRLE cache size unsigned in QAPI/QMP Markus Armbruster
2017-08-07 16:10 ` Juan Quintela
2017-08-08 15:57 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 16/56] migration: Make XBZRLE transferred " Markus Armbruster
2017-08-07 16:47 ` Juan Quintela
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 17/56] migration: Make MigrationStats sizes " Markus Armbruster
2017-08-07 16:48 ` Juan Quintela
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 18/56] migration: Make parameter max-bandwidth " Markus Armbruster
2017-08-07 16:50 ` Juan Quintela
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 19/56] block: Make snapshot VM state size " Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 20/56] block: Make ImageInfo sizes " Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 21/56] block: Clean up get_human_readable_size() Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 22/56] block: Mix up signed and unsigned less in bdrv_img_create() Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 23/56] option: Fix type of qemu_opt_set_number() parameter @val Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 24/56] block/qcow2: Change align_offset() to operate on uint64_t Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 25/56] block/qcow2: Change qcow2_calc_prealloc_size() to uint64_t Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 26/56] block: Make BlockMeasureInfo sizes unsigned in QAPI Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 27/56] block/dirty-bitmap: Clean up signed vs. unsigned dirty counts Markus Armbruster
2017-08-08 1:50 ` John Snow
2017-08-08 14:53 ` Eric Blake
2017-08-09 6:06 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 28/56] block: Widen dirty bitmap granularity to uint64_t for safety Markus Armbruster
2017-08-08 1:55 ` John Snow
2017-08-08 14:55 ` Eric Blake
2017-08-08 15:58 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 29/56] block: Make BlockDirtyInfo byte count unsigned in QAPI/QMP Markus Armbruster
2017-08-08 1:56 ` John Snow
2017-08-08 15:58 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 30/56] block: Make write thresholds " Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 31/56] block: Make throttle byte rates and sizes " Markus Armbruster
2017-08-23 13:42 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-08-24 7:24 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 32/56] hmp: Make block_set_io_throttle's arguments unsigned Markus Armbruster
2017-08-08 15:34 ` Dr. David Alan Gilbert
2017-08-09 6:10 ` Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 33/56] block: Make block_resize size unsigned in QAPI/QMP Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 34/56] block: Make BlockDeviceStats sizes, offsets " Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 35/56] blockjob: Lift speed sign conversion into block_job_set_speed() Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 36/56] blockjob: Drop unused parameter @errp of method set_speed() Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 37/56] blockjob: Make BlockJobInfo and event speed unsigned in QAPI/QMP Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 38/56] blockjob: Lift speed sign conversion out of block_job_set_speed() Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 39/56] blockjob: Lift speed sign conversion out of block_job_create() Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 40/56] blockjob: Lift speed sign conversion out of backup_job_create() Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 41/56] blockjob: Lift speed sign conversion out of mirror_start_job() Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 42/56] blockjob: Lift speed sign conversion out of stream_start() Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 43/56] blockjob: Lift speed sign conversion out of mirror_start() Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 44/56] blockjob: Lift speed sign conversion out of blockdev_mirror_common() Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 45/56] blockjob: Lift speed sign conversion out of commit_start() etc Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 46/56] blockjob: Make job commands' speed parameter unsigned in QAPI/QMP Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 47/56] blockjob: Make BlockJobInfo and event offsets " Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 48/56] block: Make mirror buffer size " Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 49/56] block: Make ImageCheck file offset unsigned in QAPI Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 50/56] block: Make BLOCK_IMAGE_CORRUPTED offset, size unsigned in QAPI/QMP Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 51/56] block/nfs: Fix for readahead-size, page-cache-size > INT64_MAX Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 52/56] block/nfs: Reject negative readahead-size, page-cache-size Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 53/56] block: Make blockdev-add byte counts unsigned in QAPI/QMP Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 54/56] qemu-img: blk_getlength() can fail, fix img_map() to check Markus Armbruster
2017-08-07 14:45 ` [Qemu-devel] [RFC PATCH 55/56] block: Make MapEntry offsets and size unsigned in QAPI Markus Armbruster
2017-08-07 14:46 ` [Qemu-devel] [RFC PATCH 56/56] crypto: Make QCryptoBlockInfoLUKS offsets unsigned in QAPI/QMP Markus Armbruster
2017-08-07 15:10 ` Daniel P. Berrange
2017-09-06 15:32 ` [Qemu-devel] [RFC PATCH 00/56] qapi: Use 'size' for byte counts & offsets Kevin Wolf
2017-09-06 17:58 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871sol1ds5.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.