summaryrefslogtreecommitdiff
path: root/ui/console.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2013-04-18 07:30:40 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2013-04-25 14:45:46 -0500
commit14a936490bf90df32ab83d13563efe4b4c768c3c (patch)
treeb484130f56c1b1d1a2ae2a105e2bd1caed3ae60e /ui/console.c
parentaa2beaa1f57ca329cfceece08cc19d52368e6a8f (diff)
downloadqemu-14a936490bf90df32ab83d13563efe4b4c768c3c.tar.gz
qemu-14a936490bf90df32ab83d13563efe4b4c768c3c.tar.bz2
qemu-14a936490bf90df32ab83d13563efe4b4c768c3c.zip
console: add qemu_console_lookup_by_device
Look up the QemuConsole for a given device, using the new link. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/console.c')
-rw-r--r--ui/console.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/ui/console.c b/ui/console.c
index 4102e8c697..e3ab9853ec 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1596,6 +1596,25 @@ QemuConsole *qemu_console_lookup_by_index(unsigned int index)
return consoles[index];
}
+QemuConsole *qemu_console_lookup_by_device(DeviceState *dev)
+{
+ Error *local_err = NULL;
+ Object *obj;
+ int i;
+
+ for (i = 0; i < nb_consoles; i++) {
+ if (!consoles[i]) {
+ continue;
+ }
+ obj = object_property_get_link(OBJECT(consoles[i]),
+ "device", &local_err);
+ if (DEVICE(obj) == dev) {
+ return consoles[i];
+ }
+ }
+ return NULL;
+}
+
bool qemu_console_is_visible(QemuConsole *con)
{
return (con == active_console) || (con->dcls > 0);