All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] ivshmem property size should be a size, not a string
@ 2015-11-20 16:07 Markus Armbruster
  2015-11-20 16:23 ` Marc-André Lureau
  2015-11-23 20:57 ` Bruce Rogers
  0 siblings, 2 replies; 27+ messages in thread
From: Markus Armbruster @ 2015-11-20 16:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, Claudio Fontana, Luiz Capitulino

Everybody's favourite device model has "size" property.  It's declared
as *string*

    DEFINE_PROP_STRING("size", IVShmemState, sizearg),

which gets converted to a size manually in the realize method:

    } else if (s->sizearg == NULL) {
        s->ivshmem_size = 4 << 20; /* 4 MB default */
    } else {
        char *end;
        int64_t size = qemu_strtosz(s->sizearg, &end);
        if (size < 0 || *end != '\0' || !is_power_of_2(size)) {
            error_setg(errp, "Invalid size %s", s->sizearg);
            return;
        }
        s->ivshmem_size = size;
    }

This is *wrong*.  Impact, as far as I can tell:

* -device ivshmem,help shows the property as 'str' instead of 'size'.

  Unhelpful, but hardly show-stopper.

* On the command line and in HMP, ivshmem's size is parsed differently
  than other size properties.  In particular, a number without a suffix
  is normally interpreted as bytes, except for ivshmem, where it's
  Mebibytes.

  Ugly inconsistency, but hardly the only one.

* In QMP, the size must be given as JSON string instead of JSON number,
  and size suffixes are accepted.  Example: "size": "512k" instead of
  "size": 524288.

  Right now, this violation of QMP rules is tolerable (barely), because
  device_add breaks some of these rules already.  However, one goal of
  the current work on QAPI is to support a QMP command to plug devices
  that doesn't break QMP rules, and then this violation will stand out.

  Therefore, I want it fixed now, before ivshmem gets used in anger.

  A straight fix of size isn't fully backwards compatible: suffixes no
  longer work in QMP, and you need to use an 'M' suffix to get Mebibytes
  on command line and HMP.

  If that's unacceptable, we'll have to provide a new, fixed property,
  and deprecate size.

  Opinions?

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2015-11-24 15:12 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-20 16:07 [Qemu-devel] ivshmem property size should be a size, not a string Markus Armbruster
2015-11-20 16:23 ` Marc-André Lureau
2015-11-20 16:46   ` Eric Blake
2015-11-20 18:06     ` Markus Armbruster
2015-11-20 18:20       ` Marc-André Lureau
2015-11-20 19:39         ` Markus Armbruster
2015-11-20 20:18           ` Marc-André Lureau
2015-11-23 10:19             ` Markus Armbruster
2015-11-23 12:15               ` Marc-André Lureau
2015-11-23 13:25                 ` Markus Armbruster
2015-11-23 13:48                   ` Marc-André Lureau
2015-11-23 14:08                     ` Markus Armbruster
2015-11-23 14:16                       ` Marc-André Lureau
2015-11-23 14:46                         ` Markus Armbruster
2015-11-23 14:53                           ` Marc-André Lureau
2015-11-23 15:17                             ` Markus Armbruster
2015-11-23 19:52                           ` Eric Blake
2015-11-23 20:19                             ` Marc-André Lureau
2015-11-24  9:56                               ` Markus Armbruster
2015-11-24 12:23                                 ` Marc-André Lureau
2015-11-24 13:50                                   ` Markus Armbruster
2015-11-24 14:23                                     ` Marc-André Lureau
2015-11-24 15:12                                       ` Markus Armbruster
2015-11-23 18:22               ` Markus Armbruster
2015-11-23 23:29             ` Andrew James
2015-11-24  9:52               ` Markus Armbruster
2015-11-23 20:57 ` Bruce Rogers

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.