[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 4/8] s390x: Dump storage keys qmp command
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v3 4/8] s390x: Dump storage keys qmp command |
Date: |
Mon, 31 Aug 2015 08:48:03 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 |
On 08/31/2015 05:00 AM, Cornelia Huck wrote:
> From: "Jason J. Herne" <address@hidden>
>
> Provide a dump-skeys qmp command to allow the end user to dump storage
> keys. This is useful for debugging problems with guest storage key support
> within Qemu and for guest operating system developers.
>
> Reviewed-by: Thomas Huth <address@hidden>
> Reviewed-by: David Hildenbrand <address@hidden>
> Signed-off-by: Jason J. Herne <address@hidden>
> Signed-off-by: Cornelia Huck <address@hidden>
> ---
> hw/s390x/s390-skeys.c | 90
> +++++++++++++++++++++++++++++++++++++++++++++++++--
> monitor.c | 7 ++++
> qapi-schema.json | 14 ++++++++
> qmp-commands.hx | 25 ++++++++++++++
> 4 files changed, 134 insertions(+), 2 deletions(-)
>
> +static void write_keys(QEMUFile *f, uint8_t *keys, uint64_t startgfn,
> + uint64_t count, Error **errp)
> +{
> + uint64_t curpage = startgfn;
> + uint64_t maxpage = curpage + count - 1;
> + const char *fmt = "page=%03" PRIx64 ": key(%d) => ACC=%X, FP=%d, REF=%d,"
> + " ch=%d, reserved=%d\n";
> + char buf[128];
> + int len;
> +
> + for (; curpage <= maxpage; curpage++) {
> + uint8_t acc = (*keys & 0xF0) >> 4;
> + int fp = (*keys & 0x08);
> + int ref = (*keys & 0x04);
> + int ch = (*keys & 0x02);
> + int res = (*keys & 0x01);
> +
> + len = snprintf(buf, sizeof(buf), fmt, curpage,
> + *keys, acc, fp, ref, ch, res);
> + qemu_put_buffer(f, (uint8_t *)buf, len);
While I can overlook the use of snprintf(), I still think you ought to
at least have assert(len < sizeof(buf)) here before the
qemu_put_buffer(), to ensure that future changes to fmt don't attempt to
print beyond the end of the fixed-width buffer.
With an assert added,
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v3 0/8] s390x: storage key migration, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH v3 6/8] s390x: Info skeys sub-command, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH v3 4/8] s390x: Dump storage keys qmp command, Cornelia Huck, 2015/08/31
- Re: [Qemu-devel] [PATCH v3 4/8] s390x: Dump storage keys qmp command,
Eric Blake <=
- [Qemu-devel] [PATCH v3 5/8] s390x: Dump-skeys hmp support, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH v3 8/8] s390x: Disable storage key migration on old machine type, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH v3 2/8] s390x: Create QOM device for s390 storage keys, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH v3 7/8] s390x: Migrate guest storage keys (initial memory only), Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH v3 1/8] s390x: add 2.5 compat s390-ccw-virtio machine, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH v3 3/8] s390x: Enable new s390-storage-keys device, Cornelia Huck, 2015/08/31