qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Markus Armbruster" <armbru@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org,
	Michael Roth <mdroth@linux.vnet.ibm.com>,
	Bruce Rogers <brogers@suse.com>, Lin Ma <lma@suse.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/7] string-input-visitor: Fix uint64 parsing
Date: Wed, 30 Sep 2015 07:47:05 -0600	[thread overview]
Message-ID: <560BE7D9.9000006@redhat.com> (raw)
In-Reply-To: <878u7o2gfm.fsf@blackfin.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 3103 bytes --]

On 09/30/2015 07:19 AM, Markus Armbruster wrote:

> 
> The (essentially undocumented) Visitor abstraction has the following
> methods for integers:

I proposed documentation at:
https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg05434.html

> 
> * Mandatory: type_int()
> 
>   Interface uses int64_t for the value.  The implementation should
>   ensure it fits into int64_t.
> 
> * Optional: type_int{8,16,32}()
> 
>   These use int{8,16,32}_t for the value.
> 
>   If present, it should ensure the value fits into the data type.
> 
>   If missing, the core falls back to type_int() plus appropriate range
>   checking.

No one implements them.  In fact, as part of preparing my documentation,
I actually proposed simplifying the visitor callback interface to drop them:
https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg05432.html

> 
> * Optional: type_int64()
> 
>   Same interface as type_int().
> 
>   If present, it should ensure the value fits into int64_t.
> 
>   If missing, the core falls back to type_int().
> 
>   Aside: setting type_int64() would be useful only when you want to
>   distinguish QAPI types int and int64.  So far, nobody does.  In fact,
>   nobody uses QAPI type int64!  I'm tempted to define QAPI type int as a
>   mere alias for int64 and drop the redundant stuff.

Already part of my proposal.

> 
> * Optional: type_uint{8,16,32}()
> 
>   These use uint{8,16,32}_t for the value.
> 
>   If present, it should ensure the value fits into the data type.
> 
>   If missing, the core falls back to type_int() plus appropriate range
>   checking.

Also unused, and simplified above.

> 
> * Optional: type_uint64()
> 
>   Now it gets interesting.  Interface uses uint64_t for the value.
> 
>   If present, it should ensure the value fits into uint64_t.
> 
>   If missing, the core falls back to type_int().  No range checking.  If
>   type_int() performs range checking as it should, then uint64_t values
>   not representable in int64_t get rejected (wrong), and negative values
>   representable in int64_t get cast to uint64_t (also wrong).
> 
>   I think we need to make type_uint64() mandatory, and drop the
>   fallback.

Probably a good idea, although not done in my proposed patches.

> 
> * Optional: type_size()
> 
>   Same interface as type_uint64().
> 
>   If present, it should ensure the value fits into uint64_t.
> 
>   If missing, the core first tries falling back to type_uint64() and
>   then to type_int().  Falling back to type_int() is as wrong here as it
>   is in type_uint64().

Provided by the QemuOpts parser to allow '1k' to mean 1024, and so on.

> 
>> As a bug fix, ignore warnings about preference of qemu_strto[u]ll().
> 
> I'm not sure I get this sentence.
> 
>> Cc: qemu-stable@nongnu.org
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
> 
> On the actual patch, I have nothing to add over Eric's review right now.
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  parent reply	other threads:[~2015-09-30 13:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-25 12:39 [Qemu-devel] [PATCH 0/7] visitor: Fix uint64 parsing for scsi-disk wwn Andreas Färber
2015-09-25 12:39 ` [Qemu-devel] [PATCH 1/7] string-input-visitor: Fix uint64 parsing Andreas Färber
2015-09-25 14:49   ` Eric Blake
2015-11-11 19:26     ` Andreas Färber
2015-09-30 13:19   ` Markus Armbruster
2015-09-30 13:23     ` Andreas Färber
2015-09-30 13:48       ` Eric Blake
2015-09-30 13:47     ` Eric Blake [this message]
2015-09-25 12:39 ` [Qemu-devel] [PATCH 2/7] test-string-input-visitor: Add int test case Andreas Färber
2015-09-25 14:50   ` Eric Blake
2015-09-25 12:39 ` [Qemu-devel] [PATCH 3/7] test-string-input-visitor: Add uint64 test Andreas Färber
2015-09-25 14:55   ` Eric Blake
2015-09-25 12:39 ` [Qemu-devel] [PATCH 4/7] tests: Add QOM property unit tests Andreas Färber
2015-09-25 14:58   ` Eric Blake
2015-09-25 15:01   ` Daniel P. Berrange
2015-11-11 19:52     ` Andreas Färber
2015-09-25 12:39 ` [Qemu-devel] [PATCH 5/7] tests: Add scsi-disk test Andreas Färber
2015-09-25 12:39 ` [Qemu-devel] [PATCH 6/7] cutils: Normalize qemu_strto[u]ll() signature Andreas Färber
2015-09-25 12:42   ` Paolo Bonzini
2015-09-25 12:44     ` Andreas Färber
2015-09-25 12:56       ` Paolo Bonzini
2015-09-25 13:27         ` Andreas Färber
2015-09-25 13:47           ` Paolo Bonzini
2015-09-25 14:59   ` Eric Blake
2015-09-25 12:39 ` [Qemu-devel] [PATCH 7/7] string-input-visitor: Use qemu_strto[u]ll() Andreas Färber

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=560BE7D9.9000006@redhat.com \
    --to=eblake@redhat.com \
    --cc=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=brogers@suse.com \
    --cc=lma@suse.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).