Skip to content

Commit

Permalink
console: add qemu_console_lookup_by_device
Browse files Browse the repository at this point in the history
Look up the QemuConsole for a given device, using the new link.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
kraxel authored and Anthony Liguori committed Apr 25, 2013
1 parent aa2beaa commit 14a9364
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/ui/console.h
Expand Up @@ -287,6 +287,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);
Expand Down
19 changes: 19 additions & 0 deletions ui/console.c
Expand Up @@ -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);
Expand Down

0 comments on commit 14a9364

Please sign in to comment.