qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/7] console: add qemu_console_lookup_by_device_name
@ 2016-01-12 12:29 Gerd Hoffmann
  2016-01-12 12:29 ` [Qemu-devel] [PATCH 2/7] console: use qemu_console_lookup_by_device_name in qemu_input_handler_bind Gerd Hoffmann
                   ` (7 more replies)
  0 siblings, 8 replies; 22+ messages in thread
From: Gerd Hoffmann @ 2016-01-12 12:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcelo Tosatti, Markus Armbruster, Gerd Hoffmann

We have two places needing this, and a third one will come shortly.
So create a helper function for that so we don't diplicate code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  2 ++
 ui/console.c         | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/ui/console.h b/include/ui/console.h
index adac36d..bbc3b7c 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -377,6 +377,8 @@ void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
 
 QemuConsole *qemu_console_lookup_by_index(unsigned int index);
 QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head);
+QemuConsole *qemu_console_lookup_by_device_name(const char *device_id,
+                                                uint32_t head, Error **errp);
 bool qemu_console_is_visible(QemuConsole *con);
 bool qemu_console_is_graphic(QemuConsole *con);
 bool qemu_console_is_fixedsize(QemuConsole *con);
diff --git a/ui/console.c b/ui/console.c
index 4b65c34..ddaa165 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1779,6 +1779,29 @@ QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head)
     return NULL;
 }
 
+QemuConsole *qemu_console_lookup_by_device_name(const char *device_id,
+                                                uint32_t head, Error **errp)
+{
+    DeviceState *dev;
+    QemuConsole *con;
+
+    dev = qdev_find_recursive(sysbus_get_default(), device_id);
+    if (dev == NULL) {
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", device_id);
+        return NULL;
+    }
+
+    con = qemu_console_lookup_by_device(dev, head);
+    if (con == NULL) {
+        error_setg(errp, "Device %s (head %d) is not bound to a QemuConsole",
+                   device_id, head);
+        return NULL;
+    }
+
+    return con;
+}
+
 bool qemu_console_is_visible(QemuConsole *con)
 {
     return (con == active_console) || (con->dcls > 0);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2016-01-15 16:58 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-12 12:29 [Qemu-devel] [PATCH 1/7] console: add qemu_console_lookup_by_device_name Gerd Hoffmann
2016-01-12 12:29 ` [Qemu-devel] [PATCH 2/7] console: use qemu_console_lookup_by_device_name in qemu_input_handler_bind Gerd Hoffmann
2016-01-12 12:43   ` Daniel P. Berrange
2016-01-12 12:29 ` [Qemu-devel] [PATCH 3/7] console: use qemu_console_lookup_by_device_name in vnc_display_open Gerd Hoffmann
2016-01-12 12:43   ` Daniel P. Berrange
2016-01-12 12:29 ` [Qemu-devel] [PATCH 4/7] qapi: switch x-input-send-event from console to device+head Gerd Hoffmann
2016-01-12 12:47   ` Daniel P. Berrange
2016-01-15 16:25   ` Markus Armbruster
2016-01-12 12:29 ` [Qemu-devel] [PATCH 5/7] qapi: rename input buttons Gerd Hoffmann
2016-01-12 12:49   ` Daniel P. Berrange
2016-01-15 16:50   ` Markus Armbruster
2016-01-12 12:29 ` [Qemu-devel] [PATCH 6/7] qapi: rename input axises Gerd Hoffmann
2016-01-12 12:50   ` Daniel P. Berrange
2016-01-15 16:51   ` Markus Armbruster
2016-01-12 12:29 ` [Qemu-devel] [PATCH 7/7] qapi: promote input-send-event to stable Gerd Hoffmann
2016-01-12 12:53   ` Daniel P. Berrange
2016-01-12 13:04     ` Gerd Hoffmann
2016-01-15 16:58       ` Markus Armbruster
2016-01-12 12:42 ` [Qemu-devel] [PATCH 1/7] console: add qemu_console_lookup_by_device_name Daniel P. Berrange
2016-01-15 16:22 ` Markus Armbruster
2016-01-15 16:41   ` Markus Armbruster
2016-01-15 16:45     ` Markus Armbruster

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).