* qemu-kvm: testdev: add monitor device parameter
@ 2010-09-02 23:45 Marcelo Tosatti
0 siblings, 0 replies; only message in thread
From: Marcelo Tosatti @ 2010-09-02 23:45 UTC (permalink / raw)
To: kvm; +Cc: Avi Kivity
So we can connect this chardev to a monitor, for example using a socket.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
diff --git a/hw/testdev.c b/hw/testdev.c
index a8c49a3..2017798 100644
--- a/hw/testdev.c
+++ b/hw/testdev.c
@@ -5,6 +5,7 @@
struct testdev {
ISADevice dev;
CharDriverState *chr;
+ CharDriverState *mon;
};
static void test_device_serial_write(void *opaque, uint32_t addr, uint32_t data)
@@ -17,6 +18,16 @@ static void test_device_serial_write(void *opaque, uint32_t addr, uint32_t data)
}
}
+static void test_device_mon_write(void *opaque, uint32_t addr, uint32_t data)
+{
+ struct testdev *dev = opaque;
+ uint8_t buf[1] = { data };
+
+ if (dev->mon) {
+ qemu_chr_write(dev->mon, buf, 1);
+ }
+}
+
static void test_device_exit(void *opaque, uint32_t addr, uint32_t data)
{
exit(data);
@@ -96,6 +107,7 @@ static int init_test_device(ISADevice *isa)
int iomem;
register_ioport_write(0xf1, 1, 1, test_device_serial_write, dev);
+ register_ioport_write(0xf2, 1, 1, test_device_mon_write, dev);
register_ioport_write(0xf4, 1, 4, test_device_exit, dev);
register_ioport_read(0xd1, 1, 4, test_device_memsize_read, dev);
register_ioport_read(0xe0, 1, 1, test_device_ioport_read, dev);
@@ -117,6 +129,7 @@ static ISADeviceInfo testdev_info = {
.init = init_test_device,
.qdev.props = (Property[]) {
DEFINE_PROP_CHR("chardev", struct testdev, chr),
+ DEFINE_PROP_CHR("mon", struct testdev, mon),
DEFINE_PROP_END_OF_LIST(),
},
};
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-09-03 17:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-02 23:45 qemu-kvm: testdev: add monitor device parameter Marcelo Tosatti
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).