X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Ftmpdisk.c;h=bf582e775fd5ef24950ace262b8b38ca04c3c6d8;hb=27eb2f39dd8e616c48f115c67ecca22f1c799b23;hp=fde3cf3327fb8ee191f59214fdc762c39437fdb5;hpb=46eb34d1853799f1ad729b7713ec093c5c24a00f;p=palacios.git diff --git a/palacios/src/devices/tmpdisk.c b/palacios/src/devices/tmpdisk.c index fde3cf3..bf582e7 100644 --- a/palacios/src/devices/tmpdisk.c +++ b/palacios/src/devices/tmpdisk.c @@ -32,7 +32,7 @@ struct blk_state { static uint64_t blk_get_capacity(void * private_data) { struct blk_state * blk = (struct blk_state *)private_data; - PrintDebug("SymBlk: Getting Capacity %d\n", (uint32_t)(blk->capacity)); + // PrintDebug("SymBlk: Getting Capacity %d\n", (uint32_t)(blk->capacity)); return blk->capacity; } @@ -42,6 +42,8 @@ static uint64_t blk_get_capacity(void * private_data) { static int blk_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) { struct blk_state * blk = (struct blk_state *)private_data; + // PrintDebug("TmpDisk Reading %d bytes to %p (lba=%p)\n", (uint32_t)num_bytes, buf, (void *)(addr_t)lba); + if (lba + num_bytes > blk->capacity) { PrintError("TMPDISK Read past end of disk\n"); return -1; @@ -58,6 +60,8 @@ static int blk_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * priv static int blk_write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) { struct blk_state * blk = (struct blk_state *)private_data; + // PrintDebug("TmpDisk Writing %d bytes to %p (lba=%p)\n", (uint32_t)num_bytes, buf, (void *)(addr_t)lba); + if (lba + num_bytes > blk->capacity) { PrintError("TMPDISK Write past end of disk\n"); return -1; @@ -92,10 +96,10 @@ static struct v3_device_ops dev_ops = { -static int blk_init(struct guest_info * vm, v3_cfg_tree_t * cfg) { +static int blk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct blk_state * blk = NULL; v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend"); - char * name = v3_cfg_val(cfg, "name"); + char * dev_id = v3_cfg_val(cfg, "ID"); uint64_t capacity = atoi(v3_cfg_val(cfg, "size")) * 1024 * 1024; if (!frontend_cfg) { @@ -115,17 +119,17 @@ static int blk_init(struct guest_info * vm, v3_cfg_tree_t * cfg) { memset(blk->blk_space, 0, capacity); - struct vm_device * dev = v3_allocate_device(name, &dev_ops, blk); + struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, blk); if (v3_attach_device(vm, dev) == -1) { - PrintError("Could not attach device %s\n", name); + PrintError("Could not attach device %s\n", dev_id); return -1; } if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"), &blk_ops, frontend_cfg, blk) == -1) { PrintError("Could not connect %s to frontend %s\n", - name, v3_cfg_val(frontend_cfg, "tag")); + dev_id, v3_cfg_val(frontend_cfg, "tag")); return -1; }