From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVH2U-0001cM-AE for qemu-devel@nongnu.org; Thu, 25 Apr 2013 03:56:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVH2P-0007HP-NB for qemu-devel@nongnu.org; Thu, 25 Apr 2013 03:56:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVH2P-0007H5-ER for qemu-devel@nongnu.org; Thu, 25 Apr 2013 03:56:17 -0400 From: Gerd Hoffmann Date: Thu, 25 Apr 2013 09:56:12 +0200 Message-Id: <1366876575-23958-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1366876575-23958-1-git-send-email-kraxel@redhat.com> References: <1366876575-23958-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 3/6] console: add qemu_console_lookup_by_device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Gerd Hoffmann Look up the QemuConsole for a given device, using the new link. Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 1 + ui/console.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index 22670d8..c74e791 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -300,6 +300,7 @@ void graphic_hw_invalidate(QemuConsole *con); 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); 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 4102e8c..e3ab985 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); -- 1.7.9.7