summary refs log tree commit diff stats
path: root/ui/vnc.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2016-01-12 11:45:43 +0100
committerGerd Hoffmann <kraxel@redhat.com>2016-03-01 07:51:34 +0100
commitf2c1d54c186c400ec676ec4d29ea4b8bf440c054 (patch)
tree577d745cad7ac0a433b02a8a964438fa966076ae /ui/vnc.c
parent071608b519adf62bc29c914343a21c5407ab1ac9 (diff)
downloadfocaccia-qemu-f2c1d54c186c400ec676ec4d29ea4b8bf440c054.tar.gz
focaccia-qemu-f2c1d54c186c400ec676ec4d29ea4b8bf440c054.zip
console: add & use qemu_console_lookup_by_device_name
We have two places needing this, and a third one will come shortly.
So factor things out into a helper function to reduce code duplication.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'ui/vnc.c')
-rw-r--r--ui/vnc.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/ui/vnc.c b/ui/vnc.c
index b6bbea5f44..f27df6dbc0 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3732,19 +3732,12 @@ void vnc_display_open(const char *id, Error **errp)
 
     device_id = qemu_opt_get(opts, "display");
     if (device_id) {
-        DeviceState *dev;
         int head = qemu_opt_get_number(opts, "head", 0);
+        Error *err = NULL;
 
-        dev = qdev_find_recursive(sysbus_get_default(), device_id);
-        if (dev == NULL) {
-            error_setg(errp, "Device '%s' not found", device_id);
-            goto fail;
-        }
-
-        con = qemu_console_lookup_by_device(dev, head);
-        if (con == NULL) {
-            error_setg(errp, "Device %s is not bound to a QemuConsole",
-                       device_id);
+        con = qemu_console_lookup_by_device_name(device_id, head, &err);
+        if (err) {
+            error_propagate(errp, err);
             goto fail;
         }
     } else {