X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Flnx_virtio_blk.c;h=a129c7f1ba49eff99a9448673e2772ac68d5f7f0;hp=7bc41a63209e28f73a0242bf5aa02f5c9f0daf0a;hb=46eb34d1853799f1ad729b7713ec093c5c24a00f;hpb=2c707e0bcd8b8ea972b935801424fcd196203fed diff --git a/palacios/src/devices/lnx_virtio_blk.c b/palacios/src/devices/lnx_virtio_blk.c index 7bc41a6..a129c7f 100644 --- a/palacios/src/devices/lnx_virtio_blk.c +++ b/palacios/src/devices/lnx_virtio_blk.c @@ -32,6 +32,8 @@ #endif +#define SECTOR_SIZE 512 + #define BLK_CAPACITY_PORT 20 #define BLK_MAX_SIZE_PORT 28 #define BLK_MAX_SEG_PORT 32 @@ -136,8 +138,8 @@ static int handle_read_op(struct virtio_blk_state * blk_state, uint8_t * buf, ui int ret = -1; PrintDebug("Reading Disk\n"); - ret = blk_state->ops->read(buf, *sector, len, (void *)(blk_state->backend_data)); - *sector += len; + ret = blk_state->ops->read(buf, (*sector) * SECTOR_SIZE, len, (void *)(blk_state->backend_data)); + *sector += (len / SECTOR_SIZE); return ret; } @@ -147,8 +149,8 @@ static int handle_write_op(struct virtio_blk_state * blk_state, uint8_t * buf, u int ret = -1; PrintDebug("Writing Disk\n"); - ret = blk_state->ops->write(buf, *sector, len, (void *)(blk_state->backend_data)); - *sector += len; + ret = blk_state->ops->write(buf, (*sector) * SECTOR_SIZE, len, (void *)(blk_state->backend_data)); + *sector += (len / SECTOR_SIZE); return ret; } @@ -593,10 +595,10 @@ static int connect_fn(struct guest_info * info, blk_state->ops = ops; blk_state->backend_data = private_data; - blk_state->block_cfg.capacity = ops->get_capacity(private_data); + blk_state->block_cfg.capacity = ops->get_capacity(private_data) / SECTOR_SIZE; - PrintDebug("Virtio Capacity = %d -- 0x%p\n", (int)(virtio->block_cfg.capacity), - (void *)(addr_t)(virtio->block_cfg.capacity)); + PrintDebug("Virtio Capacity = %d -- 0x%p\n", (int)(blk_state->block_cfg.capacity), + (void *)(addr_t)(blk_state->block_cfg.capacity)); return 0; }