mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-02 15:02:02 -06:00
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
This commit is contained in:
parent
cd33feecb3
commit
838ab728bf
1 changed files with 5 additions and 7 deletions
12
qemu-io.c
12
qemu-io.c
|
@ -794,6 +794,7 @@ alloc_f(int argc, char **argv)
|
||||||
char s1[64];
|
char s1[64];
|
||||||
int num;
|
int num;
|
||||||
int ret;
|
int ret;
|
||||||
|
const char *retstr;
|
||||||
|
|
||||||
offset = cvtnum(argv[1]);
|
offset = cvtnum(argv[1]);
|
||||||
if (offset & 0x1ff) {
|
if (offset & 0x1ff) {
|
||||||
|
@ -808,18 +809,15 @@ alloc_f(int argc, char **argv)
|
||||||
nb_sectors = 1;
|
nb_sectors = 1;
|
||||||
|
|
||||||
ret = bdrv_is_allocated(bs, offset >> 9, nb_sectors, &num);
|
ret = bdrv_is_allocated(bs, offset >> 9, nb_sectors, &num);
|
||||||
if (ret) {
|
|
||||||
printf("is_allocated: %s", strerror(ret));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cvtstr(offset, s1, sizeof(s1));
|
cvtstr(offset, s1, sizeof(s1));
|
||||||
|
|
||||||
|
retstr = ret ? "allocated" : "not allocated";
|
||||||
if (nb_sectors == 1)
|
if (nb_sectors == 1)
|
||||||
printf("sector allocated at offset %s\n", s1);
|
printf("sector %s at offset %s\n", retstr, s1);
|
||||||
else
|
else
|
||||||
printf("%d/%d sectors allocated at offset %s\n",
|
printf("%d/%d sectors %s at offset %s\n",
|
||||||
num, nb_sectors, s1);
|
num, nb_sectors, retstr, s1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue