Received: from eggs.gnu.org ([208.118.235.92]:57053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USkie-0004t6-Ap for qemu-devel@nongnu.org; Thu, 18 Apr 2013 05:01:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USkiY-0007iX-Sg for qemu-devel@nongnu.org; Thu, 18 Apr 2013 05:01:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51145) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USkiY-0007hB-FO for qemu-devel@nongnu.org; Thu, 18 Apr 2013 05:01:22 -0400 From: Gerd Hoffmann Date: Thu, 18 Apr 2013 11:01:18 +0200 Message-Id: <1366275680-15416-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1366275680-15416-1-git-send-email-kraxel@redhat.com> References: <1366275680-15416-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 4/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 , lcapitulino@redhat.com 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 21f762b..7c3f2f9 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1606,6 +1606,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