qemu-img: Gracefully shutdown when map can't finish
commit30065d142443981924786da72828ba683da35e8f
authorEric Blake <eblake@redhat.com>
Tue, 26 Mar 2019 18:40:43 +0000 (26 13:40 -0500)
committerEric Blake <eblake@redhat.com>
Sat, 30 Mar 2019 15:06:08 +0000 (30 10:06 -0500)
treec258cccafabbd13a4cbb93bb34a015bffacdbffb
parentebd82cd872726549d0a55d329d22c731e2e660ff
qemu-img: Gracefully shutdown when map can't finish

Trying 'qemu-img map -f raw nbd://localhost:10809' causes the
NBD server to output a scary message:

qemu-nbd: Disconnect client, due to: Failed to read request: Unexpected end-of-file before all bytes were read

This is because the NBD client, being remote, has no way to expose a
human-readable map (the --output=json data is fine, however). But
because we exit(1) right after the message, causing the client to
bypass all block cleanup, the server sees the abrupt exit and warns,
whereas it would be silent had the client had a chance to send
NBD_CMD_DISC. Other protocols may have similar cleanup issues, where
failure to blk_unref() could cause unintended effects.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190326184043.7544-1-eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
qemu-img.c