diff options
author | Markus Armbruster <armbru@redhat.com> | 2015-02-27 11:52:17 +0100 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2015-03-09 15:00:07 +0100 |
commit | 28b07e737eb58f299b066c1c6b3740bb055a2cf9 (patch) | |
tree | 1098375236abebb68267a1e41724b9238ab33533 /hw/char/spapr_vty.c | |
parent | e5f6e7327a95bf4c7e9354cd00e03d7ffaf25f8e (diff) |
spapr_vio: Convert to realize()
Bonus fix: always set an error on failure. Some failures were silent
before, except for the generic error set by device_realize().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'hw/char/spapr_vty.c')
-rw-r--r-- | hw/char/spapr_vty.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c index 0adf096ae0..4e464bd15a 100644 --- a/hw/char/spapr_vty.c +++ b/hw/char/spapr_vty.c @@ -60,19 +60,17 @@ void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len) qemu_chr_fe_write(dev->chardev, buf, len); } -static int spapr_vty_init(VIOsPAPRDevice *sdev) +static void spapr_vty_realize(VIOsPAPRDevice *sdev, Error **errp) { VIOsPAPRVTYDevice *dev = VIO_SPAPR_VTY_DEVICE(sdev); if (!dev->chardev) { - fprintf(stderr, "spapr-vty: Can't create vty without a chardev!\n"); - exit(1); + error_setg(errp, "chardev property not set"); + return; } qemu_chr_add_handlers(dev->chardev, vty_can_receive, vty_receive, NULL, dev); - - return 0; } /* Forward declaration */ @@ -163,7 +161,7 @@ static void spapr_vty_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); VIOsPAPRDeviceClass *k = VIO_SPAPR_DEVICE_CLASS(klass); - k->init = spapr_vty_init; + k->realize = spapr_vty_realize; k->dt_name = "vty"; k->dt_type = "serial"; k->dt_compatible = "hvterm1"; |