aboutsummaryrefslogtreecommitdiff
path: root/qemu-nbd.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2015-02-25 13:08:21 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2015-03-18 12:06:50 +0100
commit98f44bbe70bb803e7be2421b7cc92a1c179afb87 (patch)
treef257e066f4dd5d13044315941367b47d6336e017 /qemu-nbd.c
parent892f5a5270f9f3cae4f384dffbf70679fa2a57b6 (diff)
nbd: Handle blk_getlength() failure
Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <1424887718-10800-9-git-send-email-mreitz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qemu-nbd.c')
-rw-r--r--qemu-nbd.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/qemu-nbd.c b/qemu-nbd.c
index d8daf1d3a6..0cb0e4e29a 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -717,6 +717,10 @@ int main(int argc, char **argv)
bs->detect_zeroes = detect_zeroes;
fd_size = blk_getlength(blk);
+ if (fd_size < 0) {
+ errx(EXIT_FAILURE, "Failed to determine the image length: %s",
+ strerror(-fd_size));
+ }
if (partition != -1) {
ret = find_partition(blk, partition, &dev_offset, &fd_size);
@@ -726,7 +730,11 @@ int main(int argc, char **argv)
}
}
- exp = nbd_export_new(blk, dev_offset, fd_size, nbdflags, nbd_export_closed);
+ exp = nbd_export_new(blk, dev_offset, fd_size, nbdflags, nbd_export_closed,
+ &local_err);
+ if (!exp) {
+ errx(EXIT_FAILURE, "%s", error_get_pretty(local_err));
+ }
if (sockpath) {
fd = unix_socket_incoming(sockpath);