Skip to contentSkip to conversation

sheepdog: fix 'qemu-img map'

PATCH Applied Liu Yuan 2 participants 2 messages Jan 21, 2014 – Jan 22, 2014 Block layer

lore
Share & tools
lore

Liu Yuan

author
#0 lore raw

PATCH 1/1 sheepdog: fix 'qemu-img map'

It was muted in the previous commit 4bc74be9. Let's revive it since nothing prevents us to do it.

With this patch, following command will work as other formats:

$ qemu-img map sheepdog:image
---
 block/sheepdog.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
block/sheepdog.c +3 -2
index b94ab6e..61aead0 100644
@@ -2442,11 +2442,12 @@ sd_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
 {
     BDRVSheepdogState *s = bs->opaque;
     SheepdogInode *inode = &s->inode;
-    unsigned long start = sector_num * BDRV_SECTOR_SIZE / SD_DATA_OBJ_SIZE,
+    uint64_t offset = sector_num * BDRV_SECTOR_SIZE;
+    unsigned long start = offset / SD_DATA_OBJ_SIZE,
                   end = DIV_ROUND_UP((sector_num + nb_sectors) *
                                      BDRV_SECTOR_SIZE, SD_DATA_OBJ_SIZE);
     unsigned long idx;
-    int64_t ret = BDRV_BLOCK_DATA;
+    int64_t ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset;
 
     for (idx = start; idx < end; idx++) {
         if (inode->data_vdi_id[idx] == 0) {
Signature · 1 line
1.8.1.2