qemu-sockets: add Error ** to all functions

This lets me adjust the clients to do proper error propagation, and
avoid temporary regressions in the quality of the error messages.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hmp: rename MigrationStatus to MigrationStatusData

The name MigrationStatus will be taken by an enum.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
migration: use enum for MigrationInfo.status

libvirt is actually using it as an enum, make it clear that we cannot
change it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
migration: add Error information to query-migrate

Before:

    (qemu) migrate unix:/vvvv
    migrate: An undefined error has occurred
    (qemu) info migrate
    capabilities: xbzrle: off
    Migration status: failed
    total time: 0 milliseconds

After:

    (qemu) migrate unix:/vvvv
    migrate: Failed to connect to socket: No such file or directory
    (qemu) info migrate
    capabilities: xbzrle: off
    Migration status: failed (Failed to connect to socket: No such file or directory)
    total time: 0 milliseconds

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
migration: store connection errors in s->error

Also call migrate_fd_error appropriately for fd and exec protocols.
This is incomplete for TCP, because no Error is passed to the connection
handler.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qemu-char: ask and print error information from qemu-sockets

Before:

    $ qemu-system-x86_64 -monitor tcp:localhost:6000
    (starts despite error)

    $ qemu-system-x86_64 -monitor tcp:foo.bar:12345
    getaddrinfo(foo.bar,12345): Name or service not known
    chardev: opening backend "socket" failed

    $ qemu-system-x86_64 -monitor tcp:localhost:443,server=on
    inet_listen_opts: bind(ipv4,127.0.0.1,443): Permission denied
    inet_listen_opts: FAILED
    chardev: opening backend "socket" failed

After:

    $ x86_64-softmmu/qemu-system-x86_64 -monitor tcp:localhost:6000
    x86_64-softmmu/qemu-system-x86_64: -monitor tcp:localhost:6000: Failed to connect to socket: Connection refused
    chardev: opening backend "socket" failed

    $ x86_64-softmmu/qemu-system-x86_64 -monitor tcp:foo.bar:12345
    qemu-system-x86_64: -monitor tcp:foo.bar:12345: address resolution failed for foo.bar:12345: Name or service not known
    chardev: opening backend "socket" failed

    $ x86_64-softmmu/qemu-system-x86_64 -monitor tcp:localhost:443,server=on
    qemu-system-x86_64: -monitor tcp:localhost:443,server=on: Failed to bind socket: Permission denied
    chardev: opening backend "socket" failed

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
nbd: ask and print error information from qemu-sockets

Before:

    $ qemu-system-x86_64 nbd:localhost:12345
    inet_connect_opts: connect(ipv4,yakj.usersys.redhat.com,127.0.0.1,12345): Connection refused
    qemu-system-x86_64: could not open disk image nbd:localhost:12345: Connection refused

After:

    $ x86_64-softmmu/qemu-system-x86_64 nbd:localhost:12345
    qemu-system-x86_64: Failed to connect to socket: Connection refused
    qemu-system-x86_64: could not open disk image nbd:localhost:12345: Connection refused

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qemu-ga: ask and print error information from qemu-sockets

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
vnc: add error propagation to vnc_display_open

Before:

    $ qemu-system-x86_64 -vnc foo.bar:12345
    getaddrinfo(foo.bar,18245): Name or service not known
    Failed to start VNC server on `foo.bar:12345'

    $ qemu-system-x86_64 -vnc localhost:12345,reverse=on
    inet_connect_opts: connect(ipv4,yakj.usersys.redhat.com,127.0.0.1,12345): Connection refused
    Failed to start VNC server on `localhost:12345,reverse=on'

After:

    $ x86_64-softmmu/qemu-system-x86_64 -vnc foo.bar:12345
    qemu-system-x86_64: address resolution failed for foo.bar:18245: Name or service not known
    Failed to start VNC server on `foo.bar:12345'

    $ x86_64-softmmu/qemu-system-x86_64 -vnc localhost:12345,reverse=on
    qemu-system-x86_64: Failed to connect to socket: Connection refused
    Failed to start VNC server on `localhost:12345,reverse=on'

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qemu-sockets: include strerror or gai_strerror output in error messages

Among others, before:

    $ qemu-system-x86_64 -chardev socket,port=12345,id=char
    inet_connect: host and/or port not specified
    chardev: opening backend "socket" failed

After:

    $ x86_64-softmmu/qemu-system-x86_64 -chardev socket,port=12345,id=char
    qemu-system-x86_64: -chardev socket,port=12345,id=char: host and/or port not specified
    chardev: opening backend "socket" failed

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qemu-sockets: add error propagation to inet_connect_addr

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qemu-sockets: add error propagation to inet_dgram_opts

Before:

    $ qemu-system-x86_64 -monitor udp:localhost:631@localhost:631
    inet_dgram_opts: bind(ipv4,127.0.0.1,631): OK
    inet_dgram_opts failed
    chardev: opening backend "udp" failed

After:

    $ x86_64-softmmu/qemu-system-x86_64 -monitor udp:localhost:631@localhost:631
    qemu-system-x86_64: -monitor udp:localhost:631@localhost:631: Failed to bind socket: Address already in use
    chardev: opening backend "udp" failed

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qemu-sockets: add error propagation to inet_parse

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qemu-sockets: add error propagation to Unix socket functions

This patch starts harmonizing unix_* and inet_* functions.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>