[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v9 1/3] iov: Factor out hexdumper
From: |
Gerd Hoffmann |
Subject: |
Re: [Qemu-devel] [PATCH v9 1/3] iov: Factor out hexdumper |
Date: |
Wed, 20 Feb 2013 10:04:22 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130108 Thunderbird/10.0.12 |
Hi,
> Done, thanks for the correction. Do you have a lightweight test vector
> that exercises this? The iovec stuff in my areas is all limited to
> single iovec element. Interdiff below.
hw/usb/dev-network.c (with TRAFFC_DEBUG) calls this on usb packets which
could trigger this in theory. Depends on how the guest allocates the
usb packet buffers though, so I'm not fully sure whenever that actually
triggers in practice.
> @@ -202,11 +202,16 @@ void iov_hexdump(const struct iovec *iov, const
> unsigned int iov_cnt,
> FILE *fp, const char *prefix, size_t limit)
> {
> int v;
> - for (v = 0; v < iov_cnt && limit; v++) {
> - int size = limit < iov[v].iov_len ? limit : iov[v].iov_len;
> - hexdump(iov[v].iov_base, fp, prefix, size);
> - limit -= size;
> + size_t size = 0;
> + char *buf;
> +
> + for (v = 0; v < iov_cnt; v++) {
> + size += iov[v].iov_len;
> }
> + size = size > limit ? limit : size;
> + buf = g_malloc(size);
> + iov_to_buf(iov, iov_cnt, 0, buf, size);
You've lost the actual hexdump() call here ;)
> + g_free(buf);
Otherwise it looks fine.
cheers,
Gerd