qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [PATCH v2 2/5] backup: keep an extra reference to the targe


From: Alberto Garcia
Subject: [Qemu-block] [PATCH v2 2/5] backup: keep an extra reference to the target image during the job
Date: Thu, 22 Oct 2015 18:13:56 +0300

During the 'drive-backup' operation the target image only has the
monitor reference, therefore there's nothing that prevents its
deletion using the 'x-blockdev-del' command before the block job has
finished.

Although the operation itself does not allow the user to set a node
name that can be used to delete the new image, we are auto-generating
them since 15489c769b9a4b3bec5b5848af2960689d7b4bd8.

Signed-off-by: Alberto Garcia <address@hidden>
---
 block/backup.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/block/backup.c b/block/backup.c
index ec01db8..6cbf36e 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -250,6 +250,7 @@ static void backup_complete(BlockJob *job, void *opaque)
     BackupCompleteData *data = opaque;
 
     bdrv_unref(s->target);
+    bdrv_unref(s->target); /* extra reference added in backup_start() */
 
     block_job_completed(job, data->ret);
     g_free(data);
@@ -546,6 +547,10 @@ void backup_start(BlockDriverState *bs, BlockDriverState 
*target,
 
     bdrv_op_block_all(target, job->common.blocker);
 
+    /* We keep an extra reference during the block job so the target
+     * BDS cannot be deleted using x-blockdev-del */
+    bdrv_ref(target);
+
     job->on_source_error = on_source_error;
     job->on_target_error = on_target_error;
     job->target = target;
-- 
2.6.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]