On Wed, May 23, 2018 at 19:09:59 +0200, Andrea Bolognani wrote:
> On Wed, 2018-05-23 at 18:40 +0200, Peter Krempa wrote:
> > On Wed, May 23, 2018 at 18:18:02 +0200, Andrea Bolognani wrote:
> > > + /* QEMU expects the argument to be a number of left shifts:
> > > + * for example, if you wanted to limit the guest to 4 KiB
pages,
> > > + * since 4096 == 1 << 12, you would need to add
cap-hpt-mps=12
> > > + * to the command line.
> >
> > So basically you need to pass the exponent of a power of 2 that yields
> > this number. The number of left shifts may be slightly confusing ...
>
> I guess it depends on the reader; the two definitions are
> equivalent anyway, so no harm in having both in the comment :)
Using both are fine, but without mentioning that it is in fact a power of
two-only thing I was thinking that the interface is off by one or
something:
4096 == 1 << 12 == 2 << 11
> In general, I'd say it's not the most user-friendly interface on
> QEMU's side, but I believe it's dictated by hardware / emulator
> details, given how it ends up being used: see
>
>
http://lists.nongnu.org/archive/html/qemu-devel/2018-04/msg02822.html
>
> To be fair, it would perhaps make sense to perform the conversion
> directly inside QEMU, in order to make it more convenient not only
> for libvirt but for for people driving it directly as well.
If strictly only powers of two make sense for this knob then this gives
you input validation for free. On the other hand, specifying a big
number can overflow internally if it is ever used in the non-exponent
form. I think the format does not matter much, since libvirt's job is to
shield users from such weirdness.
Yeah, the above is basically my reasoning for using the exponent, not
the final page size.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!