net/rocker: Convert to realize()
commit0c8f86ea98945678622c6e4b070c4218a53a0d19
authorMao Zhongyi <maozy.fnst@cn.fujitsu.com>
Mon, 14 Aug 2017 03:33:09 +0000 (14 11:33 +0800)
committerJason Wang <jasowang@redhat.com>
Fri, 8 Sep 2017 00:17:37 +0000 (8 08:17 +0800)
tree4c4ebca03ea7900347d42aab7447b455ac888ccc
parent1343a107e46feed8b901bf08ad8485bd5f302912
net/rocker: Convert to realize()

The rocker device still implements the old PCIDeviceClass .init()
instead of the new .realize(). All devices need to be converted to
.realize().

.init() reports errors with fprintf() and return 0 on success, negative
number on failure. Meanwhile, when -device rocker fails, it first report
a specific error, then a generic one, like this:

    $ x86_64-softmmu/qemu-system-x86_64 -device rocker,name=qemu-rocker
    rocker: name too long; please shorten to at most 9 chars
    qemu-system-x86_64: -device rocker,name=qemu-rocker: Device initialization failed

Now, convert it to .realize() that passes errors to its callers via its
errp argument. Also avoid the superfluous second error message. After
the patch, effect like this:

    $ x86_64-softmmu/qemu-system-x86_64 -device rocker,name=qemu-rocker
    qemu-system-x86_64: -device rocker,name=qemu-rocker: name too long; please shorten to at most 9 chars

Cc: jasowang@redhat.com
Cc: jiri@resnulli.us
Cc: armbru@redhat.com
Cc: f4bug@amsat.org
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hw/net/rocker/rocker.c