On Mon, Aug 22, 2011 at 10:39 AM, Patrick Jackson <patricksjack...@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