aboutsummaryrefslogtreecommitdiff
path: root/block/export/vduse-blk.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/export/vduse-blk.c')
-rw-r--r--block/export/vduse-blk.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/block/export/vduse-blk.c b/block/export/vduse-blk.c
index cab1904..251d73c 100644
--- a/block/export/vduse-blk.c
+++ b/block/export/vduse-blk.c
@@ -30,6 +30,7 @@ typedef struct VduseBlkExport {
VirtioBlkHandler handler;
VduseDev *dev;
uint16_t num_queues;
+ char *recon_file;
unsigned int inflight;
} VduseBlkExport;
@@ -125,6 +126,8 @@ static void vduse_blk_enable_queue(VduseDev *dev, VduseVirtq *vq)
aio_set_fd_handler(vblk_exp->export.ctx, vduse_queue_get_fd(vq),
true, on_vduse_vq_kick, NULL, NULL, NULL, vq);
+ /* Make sure we don't miss any kick afer reconnecting */
+ eventfd_write(vduse_queue_get_fd(vq), 1);
}
static void vduse_blk_disable_queue(VduseDev *dev, VduseVirtq *vq)
@@ -306,6 +309,15 @@ static int vduse_blk_exp_create(BlockExport *exp, BlockExportOptions *opts,
return -ENOMEM;
}
+ vblk_exp->recon_file = g_strdup_printf("%s/vduse-blk-%s",
+ g_get_tmp_dir(), exp->id);
+ if (vduse_set_reconnect_log_file(vblk_exp->dev, vblk_exp->recon_file)) {
+ error_setg(errp, "failed to set reconnect log file");
+ vduse_dev_destroy(vblk_exp->dev);
+ g_free(vblk_exp->recon_file);
+ return -EINVAL;
+ }
+
for (i = 0; i < num_queues; i++) {
vduse_dev_setup_queue(vblk_exp->dev, i, queue_size);
}
@@ -324,11 +336,16 @@ static int vduse_blk_exp_create(BlockExport *exp, BlockExportOptions *opts,
static void vduse_blk_exp_delete(BlockExport *exp)
{
VduseBlkExport *vblk_exp = container_of(exp, VduseBlkExport, export);
+ int ret;
blk_remove_aio_context_notifier(exp->blk, blk_aio_attached, blk_aio_detach,
vblk_exp);
blk_set_dev_ops(exp->blk, NULL, NULL);
- vduse_dev_destroy(vblk_exp->dev);
+ ret = vduse_dev_destroy(vblk_exp->dev);
+ if (ret != -EBUSY) {
+ unlink(vblk_exp->recon_file);
+ }
+ g_free(vblk_exp->recon_file);
}
static void vduse_blk_exp_request_shutdown(BlockExport *exp)