From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUwAQ-0004fa-E5 for qemu-devel@nongnu.org; Wed, 24 Apr 2013 05:39:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUwAL-0002B2-9S for qemu-devel@nongnu.org; Wed, 24 Apr 2013 05:39:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47529) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUw4r-0000Mn-6B for qemu-devel@nongnu.org; Wed, 24 Apr 2013 05:33:25 -0400 From: Gerd Hoffmann Date: Wed, 24 Apr 2013 11:33:20 +0200 Message-Id: <1366796002-30135-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1366796002-30135-1-git-send-email-kraxel@redhat.com> References: <1366796002-30135-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 3/5] 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