mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
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>
This commit is contained in:
parent
892f5a5270
commit
98f44bbe70
4 changed files with 30 additions and 5 deletions
10
qemu-nbd.c
10
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue