qemu-kvm: testdev: add monitor device parameter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So we can connect this chardev to a monitor, for example using a socket.

Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>

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(),
     },
 };
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux