From: Stefan Hajnoczi <stefanha@gmail.com>
To: Patrick Jackson <patricksjackson@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 08/11] Goldfish: Added the memory logger device.
Date: Mon, 22 Aug 2011 12:59:41 +0100 [thread overview]
Message-ID: <CAJSP0QX3xnD1ZZjWO07XphvwtwMyC8bF8eNJ=2DoYoPTnWhR6A@mail.gmail.com> (raw)
In-Reply-To: <CAKspZ_sLrHKBg7VCAoikeFR+kRygYd1wWchBO4Bow2Sq5Ng6rw@mail.gmail.com>
On Mon, Aug 22, 2011 at 10:39 AM, Patrick Jackson
<patricksjackson@gmail.com> wrote:
> +static void memlog_write(void *opaque, target_phys_addr_t offset, uint32_t
> val)
> +{
> + static unsigned info[8];
The size should be 2, not 8.
Using a static variable is a bit lazy here. We're already accessing
GoldfishMemlogDevice so we might as well use a proper per-device
info[] array.
> + char buf[128];
> + GoldfishMemlogDevice *s = (GoldfishMemlogDevice *)opaque;
> + int ret;
> +
> + (void)s->dev;
> +
> + if (offset < 8*4)
> + info[offset / 4] = val;
> +
> + if (offset == 0) {
> + /* write PID and VADDR to logfile */
> + snprintf(buf, sizeof buf, "%08x %08x\n", info[0], info[1]);
> + do {
> + ret = write(s->fd, buf, strlen(buf));
> + } while (ret < 0 && errno == EINTR);
> + }
> +}
> +
> +
> +static CPUReadMemoryFunc *memlog_readfn[] = {
> + memlog_read,
> + memlog_read,
> + memlog_read
> +};
Do you really need memlog_read? I would just use NULL read functions.
> +static GoldfishDeviceInfo goldfish_memlog_info = {
> + .init = goldfish_memlog_init,
> + .readfn = memlog_readfn,
> + .writefn = memlog_writefn,
> + .qdev.name = "goldfish_memlog",
> + .qdev.size = sizeof(GoldfishMemlogDevice),
> + .qdev.props = (Property[]) {
> + DEFINE_PROP_UINT32("base", GoldfishDevice, base, 0),
> + DEFINE_PROP_UINT32("id", GoldfishDevice, id, 0),
> + DEFINE_PROP_UINT32("size", GoldfishDevice, size, 0x1000),
> + DEFINE_PROP_UINT32("irq", GoldfishDevice, irq, 0),
> + DEFINE_PROP_UINT32("irq_count", GoldfishDevice, irq_count, 0),
> + DEFINE_PROP_STRING("name", GoldfishDevice, name),
> + DEFINE_PROP_INT32("fd", GoldfishMemlogDevice, fd, -1),
I'm not sure these fields all need to be defined here. Why make fd a
qdev property?
Stefan
next prev parent reply other threads:[~2011-08-22 11:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-22 9:39 [Qemu-devel] [PATCH 08/11] Goldfish: Added the memory logger device Patrick Jackson
2011-08-22 11:59 ` Stefan Hajnoczi [this message]
2011-08-22 14:15 ` Paolo Bonzini
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='CAJSP0QX3xnD1ZZjWO07XphvwtwMyC8bF8eNJ=2DoYoPTnWhR6A@mail.gmail.com' \
--to=stefanha@gmail.com \
--cc=patricksjackson@gmail.com \
--cc=qemu-devel@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).