Commit 838ab728bfd269593e80ee2f8e98c8138b658e5a
1 parent
cd33feec
qemu-io: Fix handling of bdrv_is_allocated() return value (Kevin Wolf)
bdrv_is_allocated() returns a boolean which indicates if the offset is allocated, not 0 on success and everything else is an error. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7181 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
5 additions
and
7 deletions
qemu-io.c
| @@ -794,6 +794,7 @@ alloc_f(int argc, char **argv) | @@ -794,6 +794,7 @@ alloc_f(int argc, char **argv) | ||
| 794 | char s1[64]; | 794 | char s1[64]; |
| 795 | int num; | 795 | int num; |
| 796 | int ret; | 796 | int ret; |
| 797 | + const char *retstr; | ||
| 797 | 798 | ||
| 798 | offset = cvtnum(argv[1]); | 799 | offset = cvtnum(argv[1]); |
| 799 | if (offset & 0x1ff) { | 800 | if (offset & 0x1ff) { |
| @@ -808,18 +809,15 @@ alloc_f(int argc, char **argv) | @@ -808,18 +809,15 @@ alloc_f(int argc, char **argv) | ||
| 808 | nb_sectors = 1; | 809 | nb_sectors = 1; |
| 809 | 810 | ||
| 810 | ret = bdrv_is_allocated(bs, offset >> 9, nb_sectors, &num); | 811 | ret = bdrv_is_allocated(bs, offset >> 9, nb_sectors, &num); |
| 811 | - if (ret) { | ||
| 812 | - printf("is_allocated: %s", strerror(ret)); | ||
| 813 | - return 0; | ||
| 814 | - } | ||
| 815 | 812 | ||
| 816 | cvtstr(offset, s1, sizeof(s1)); | 813 | cvtstr(offset, s1, sizeof(s1)); |
| 817 | 814 | ||
| 815 | + retstr = ret ? "allocated" : "not allocated"; | ||
| 818 | if (nb_sectors == 1) | 816 | if (nb_sectors == 1) |
| 819 | - printf("sector allocated at offset %s\n", s1); | 817 | + printf("sector %s at offset %s\n", retstr, s1); |
| 820 | else | 818 | else |
| 821 | - printf("%d/%d sectors allocated at offset %s\n", | ||
| 822 | - num, nb_sectors, s1); | 819 | + printf("%d/%d sectors %s at offset %s\n", |
| 820 | + num, nb_sectors, retstr, s1); | ||
| 823 | return 0; | 821 | return 0; |
| 824 | } | 822 | } |
| 825 | 823 |