X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Ftmpdisk.c;h=0be279fc739cb9b77ca100f7cacc31ba67875082;hb=45d9da21cb9fcff297b690cc9f12c9a7c7a6ecb5;hp=450de5304b4b65e00c9ea851f30685a4fb762477;hpb=e2964f7234daa3429275c039769a313f0870c212;p=palacios.releases.git diff --git a/palacios/src/devices/tmpdisk.c b/palacios/src/devices/tmpdisk.c index 450de53..0be279f 100644 --- a/palacios/src/devices/tmpdisk.c +++ b/palacios/src/devices/tmpdisk.c @@ -73,8 +73,11 @@ static int blk_write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * pr } -static int blk_free(struct vm_device * dev) { - return -1; +static int blk_free(struct blk_state * blk) { + V3_FreePages((void *)blk->blk_base_addr, blk->capacity / 4096); + + V3_Free(blk); + return 0; } @@ -87,7 +90,7 @@ static struct v3_dev_blk_ops blk_ops = { static struct v3_device_ops dev_ops = { - .free = blk_free, + .free = (int (*)(void *))blk_free, }; @@ -117,10 +120,11 @@ static int blk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { memset(blk->blk_space, 0, capacity); - struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, blk); + struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, blk); - if (v3_attach_device(vm, dev) == -1) { + if (dev == NULL) { PrintError("Could not attach device %s\n", dev_id); + V3_Free(blk); return -1; } @@ -128,6 +132,7 @@ static int blk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { &blk_ops, frontend_cfg, blk) == -1) { PrintError("Could not connect %s to frontend %s\n", dev_id, v3_cfg_val(frontend_cfg, "tag")); + v3_remove_device(dev); return -1; }