|
|
9ae3a8 |
From 52d7a3ed9170da1248cadbbc746c32dd7c34c568 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 17 Jan 2014 03:07:48 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 05/34] block: make bdrv_delete() static
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1389928083-8921-4-git-send-email-famz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56765
|
|
|
9ae3a8 |
O-Subject: [RHEL-7 qemu-kvm PATCH 03/18] block: make bdrv_delete() static
|
|
|
9ae3a8 |
Bugzilla: 1041301
|
|
|
9ae3a8 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Manage BlockDriverState lifecycle with refcnt, so bdrv_delete() is no
|
|
|
9ae3a8 |
longer public and should be called by bdrv_unref() if refcnt is
|
|
|
9ae3a8 |
decreased to 0.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This is an identical change because effectively, there's no multiple
|
|
|
9ae3a8 |
reference of BDS now: no caller of bdrv_ref() yet, only bdrv_new() sets
|
|
|
9ae3a8 |
bs->refcnt to 1, so all bdrv_unref() now actually delete the BDS.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 4f6fd3491cf0f768b135ed2e242bd1d1d2a2efec)
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
block/backup.c
|
|
|
9ae3a8 |
block/blkverify.c
|
|
|
9ae3a8 |
block/vvfat.c
|
|
|
9ae3a8 |
blockdev.c
|
|
|
9ae3a8 |
hw/block/xen_disk.c
|
|
|
9ae3a8 |
qemu-io.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
All are contextual conflicts. We are doing a mechanical replacing here,
|
|
|
9ae3a8 |
so simply use the downstream code except replace bdrv_delete with
|
|
|
9ae3a8 |
bdrv_unref.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Several more bdrv_delete's are converted in qemu-img.c, qemu-io.c and
|
|
|
9ae3a8 |
block/vhdx.c.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 23 ++++++++++++-----------
|
|
|
9ae3a8 |
block/blkverify.c | 4 ++--
|
|
|
9ae3a8 |
block/cow.c | 2 +-
|
|
|
9ae3a8 |
block/iscsi.c | 2 +-
|
|
|
9ae3a8 |
block/mirror.c | 2 +-
|
|
|
9ae3a8 |
block/qcow.c | 2 +-
|
|
|
9ae3a8 |
block/qcow2.c | 2 +-
|
|
|
9ae3a8 |
block/qed.c | 2 +-
|
|
|
9ae3a8 |
block/sheepdog.c | 6 +++---
|
|
|
9ae3a8 |
block/snapshot.c | 2 +-
|
|
|
9ae3a8 |
block/stream.c | 2 +-
|
|
|
9ae3a8 |
block/vhdx.c | 2 +-
|
|
|
9ae3a8 |
block/vmdk.c | 10 +++++-----
|
|
|
9ae3a8 |
block/vvfat.c | 4 ++--
|
|
|
9ae3a8 |
blockdev.c | 10 +++++-----
|
|
|
9ae3a8 |
hw/block/xen_disk.c | 4 ++--
|
|
|
9ae3a8 |
include/block/block.h | 1 -
|
|
|
9ae3a8 |
qemu-img.c | 31 +++++++++++++++----------------
|
|
|
9ae3a8 |
qemu-io.c | 6 +++---
|
|
|
9ae3a8 |
19 files changed, 58 insertions(+), 59 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 23 ++++++++++++-----------
|
|
|
9ae3a8 |
block/blkverify.c | 4 ++--
|
|
|
9ae3a8 |
block/cow.c | 2 +-
|
|
|
9ae3a8 |
block/iscsi.c | 2 +-
|
|
|
9ae3a8 |
block/mirror.c | 2 +-
|
|
|
9ae3a8 |
block/qcow.c | 2 +-
|
|
|
9ae3a8 |
block/qcow2.c | 2 +-
|
|
|
9ae3a8 |
block/qed.c | 2 +-
|
|
|
9ae3a8 |
block/sheepdog.c | 6 +++---
|
|
|
9ae3a8 |
block/snapshot.c | 2 +-
|
|
|
9ae3a8 |
block/stream.c | 2 +-
|
|
|
9ae3a8 |
block/vhdx.c | 2 +-
|
|
|
9ae3a8 |
block/vmdk.c | 10 +++++-----
|
|
|
9ae3a8 |
block/vvfat.c | 4 ++--
|
|
|
9ae3a8 |
blockdev.c | 10 +++++-----
|
|
|
9ae3a8 |
hw/block/xen_disk.c | 4 ++--
|
|
|
9ae3a8 |
include/block/block.h | 1 -
|
|
|
9ae3a8 |
qemu-img.c | 31 +++++++++++++++----------------
|
|
|
9ae3a8 |
qemu-io.c | 6 +++---
|
|
|
9ae3a8 |
19 files changed, 58 insertions(+), 59 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block.c b/block.c
|
|
|
9ae3a8 |
index ddf29d0..b4e3ced 100644
|
|
|
9ae3a8 |
--- a/block.c
|
|
|
9ae3a8 |
+++ b/block.c
|
|
|
9ae3a8 |
@@ -918,7 +918,7 @@ fail:
|
|
|
9ae3a8 |
if (!bs->drv) {
|
|
|
9ae3a8 |
QDECREF(bs->options);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -972,7 +972,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
|
|
|
9ae3a8 |
*backing_filename ? backing_filename : NULL, options,
|
|
|
9ae3a8 |
back_flags, back_drv, &local_err);
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
- bdrv_delete(bs->backing_hd);
|
|
|
9ae3a8 |
+ bdrv_unref(bs->backing_hd);
|
|
|
9ae3a8 |
bs->backing_hd = NULL;
|
|
|
9ae3a8 |
bs->open_flags |= BDRV_O_NO_BACKING;
|
|
|
9ae3a8 |
error_propagate(errp, local_err);
|
|
|
9ae3a8 |
@@ -1051,12 +1051,12 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
|
|
|
9ae3a8 |
bs1 = bdrv_new("");
|
|
|
9ae3a8 |
ret = bdrv_open(bs1, filename, NULL, 0, drv, &local_err);
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
- bdrv_delete(bs1);
|
|
|
9ae3a8 |
+ bdrv_unref(bs1);
|
|
|
9ae3a8 |
goto fail;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- bdrv_delete(bs1);
|
|
|
9ae3a8 |
+ bdrv_unref(bs1);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
@@ -1137,7 +1137,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (bs->file != file) {
|
|
|
9ae3a8 |
- bdrv_delete(file);
|
|
|
9ae3a8 |
+ bdrv_unref(file);
|
|
|
9ae3a8 |
file = NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1177,7 +1177,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
unlink_and_fail:
|
|
|
9ae3a8 |
if (file != NULL) {
|
|
|
9ae3a8 |
- bdrv_delete(file);
|
|
|
9ae3a8 |
+ bdrv_unref(file);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (bs->is_temporary) {
|
|
|
9ae3a8 |
unlink(filename);
|
|
|
9ae3a8 |
@@ -1444,7 +1444,7 @@ void bdrv_close(BlockDriverState *bs)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (bs->drv) {
|
|
|
9ae3a8 |
if (bs->backing_hd) {
|
|
|
9ae3a8 |
- bdrv_delete(bs->backing_hd);
|
|
|
9ae3a8 |
+ bdrv_unref(bs->backing_hd);
|
|
|
9ae3a8 |
bs->backing_hd = NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
bs->drv->bdrv_close(bs);
|
|
|
9ae3a8 |
@@ -1469,7 +1469,7 @@ void bdrv_close(BlockDriverState *bs)
|
|
|
9ae3a8 |
bs->options = NULL;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (bs->file != NULL) {
|
|
|
9ae3a8 |
- bdrv_delete(bs->file);
|
|
|
9ae3a8 |
+ bdrv_unref(bs->file);
|
|
|
9ae3a8 |
bs->file = NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1667,11 +1667,12 @@ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top)
|
|
|
9ae3a8 |
bs_new->drv ? bs_new->drv->format_name : "");
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-void bdrv_delete(BlockDriverState *bs)
|
|
|
9ae3a8 |
+static void bdrv_delete(BlockDriverState *bs)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
assert(!bs->dev);
|
|
|
9ae3a8 |
assert(!bs->job);
|
|
|
9ae3a8 |
assert(!bs->in_use);
|
|
|
9ae3a8 |
+ assert(!bs->refcnt);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* remove from list, if necessary */
|
|
|
9ae3a8 |
bdrv_make_anon(bs);
|
|
|
9ae3a8 |
@@ -2247,7 +2248,7 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,
|
|
|
9ae3a8 |
QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry, next) {
|
|
|
9ae3a8 |
/* so that bdrv_close() does not recursively close the chain */
|
|
|
9ae3a8 |
intermediate_state->bs->backing_hd = NULL;
|
|
|
9ae3a8 |
- bdrv_delete(intermediate_state->bs);
|
|
|
9ae3a8 |
+ bdrv_unref(intermediate_state->bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
ret = 0;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -4989,7 +4990,7 @@ out:
|
|
|
9ae3a8 |
free_option_parameters(param);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (bs) {
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (error_is_set(&local_err)) {
|
|
|
9ae3a8 |
error_propagate(errp, local_err);
|
|
|
9ae3a8 |
diff --git a/block/blkverify.c b/block/blkverify.c
|
|
|
9ae3a8 |
index 92a452d..4ff7688 100644
|
|
|
9ae3a8 |
--- a/block/blkverify.c
|
|
|
9ae3a8 |
+++ b/block/blkverify.c
|
|
|
9ae3a8 |
@@ -159,7 +159,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
9ae3a8 |
ret = bdrv_open(s->test_file, filename, NULL, flags, NULL, &local_err);
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
error_propagate(errp, local_err);
|
|
|
9ae3a8 |
- bdrv_delete(s->test_file);
|
|
|
9ae3a8 |
+ bdrv_unref(s->test_file);
|
|
|
9ae3a8 |
s->test_file = NULL;
|
|
|
9ae3a8 |
goto fail;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -173,7 +173,7 @@ static void blkverify_close(BlockDriverState *bs)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BDRVBlkverifyState *s = bs->opaque;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- bdrv_delete(s->test_file);
|
|
|
9ae3a8 |
+ bdrv_unref(s->test_file);
|
|
|
9ae3a8 |
s->test_file = NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/cow.c b/block/cow.c
|
|
|
9ae3a8 |
index cb9a3b0..909c3e7 100644
|
|
|
9ae3a8 |
--- a/block/cow.c
|
|
|
9ae3a8 |
+++ b/block/cow.c
|
|
|
9ae3a8 |
@@ -360,7 +360,7 @@ static int cow_create(const char *filename, QEMUOptionParameter *options,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
exit:
|
|
|
9ae3a8 |
- bdrv_delete(cow_bs);
|
|
|
9ae3a8 |
+ bdrv_unref(cow_bs);
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/iscsi.c b/block/iscsi.c
|
|
|
9ae3a8 |
index fce909b..fa6f7c4 100644
|
|
|
9ae3a8 |
--- a/block/iscsi.c
|
|
|
9ae3a8 |
+++ b/block/iscsi.c
|
|
|
9ae3a8 |
@@ -1576,7 +1576,7 @@ out:
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
g_free(bs->opaque);
|
|
|
9ae3a8 |
bs->opaque = NULL;
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/mirror.c b/block/mirror.c
|
|
|
9ae3a8 |
index 6fa733e..6843e70 100644
|
|
|
9ae3a8 |
--- a/block/mirror.c
|
|
|
9ae3a8 |
+++ b/block/mirror.c
|
|
|
9ae3a8 |
@@ -480,7 +480,7 @@ immediate_exit:
|
|
|
9ae3a8 |
bdrv_swap(s->target, s->common.bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
bdrv_close(s->target);
|
|
|
9ae3a8 |
- bdrv_delete(s->target);
|
|
|
9ae3a8 |
+ bdrv_unref(s->target);
|
|
|
9ae3a8 |
block_job_completed(&s->common, ret);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/qcow.c b/block/qcow.c
|
|
|
9ae3a8 |
index 6bc2358..c470e05 100644
|
|
|
9ae3a8 |
--- a/block/qcow.c
|
|
|
9ae3a8 |
+++ b/block/qcow.c
|
|
|
9ae3a8 |
@@ -765,7 +765,7 @@ static int qcow_create(const char *filename, QEMUOptionParameter *options,
|
|
|
9ae3a8 |
g_free(tmp);
|
|
|
9ae3a8 |
ret = 0;
|
|
|
9ae3a8 |
exit:
|
|
|
9ae3a8 |
- bdrv_delete(qcow_bs);
|
|
|
9ae3a8 |
+ bdrv_unref(qcow_bs);
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
9ae3a8 |
index 3f7fd51..f6307af 100644
|
|
|
9ae3a8 |
--- a/block/qcow2.c
|
|
|
9ae3a8 |
+++ b/block/qcow2.c
|
|
|
9ae3a8 |
@@ -1591,7 +1591,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ret = 0;
|
|
|
9ae3a8 |
out:
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/qed.c b/block/qed.c
|
|
|
9ae3a8 |
index 0805ba3..fb8ccd5 100644
|
|
|
9ae3a8 |
--- a/block/qed.c
|
|
|
9ae3a8 |
+++ b/block/qed.c
|
|
|
9ae3a8 |
@@ -607,7 +607,7 @@ static int qed_create(const char *filename, uint32_t cluster_size,
|
|
|
9ae3a8 |
ret = 0; /* success */
|
|
|
9ae3a8 |
out:
|
|
|
9ae3a8 |
g_free(l1_table);
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/sheepdog.c b/block/sheepdog.c
|
|
|
9ae3a8 |
index 09203ad..b3a2ae8 100644
|
|
|
9ae3a8 |
--- a/block/sheepdog.c
|
|
|
9ae3a8 |
+++ b/block/sheepdog.c
|
|
|
9ae3a8 |
@@ -1451,7 +1451,7 @@ static int sd_prealloc(const char *filename)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
out:
|
|
|
9ae3a8 |
if (bs) {
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
g_free(buf);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1534,13 +1534,13 @@ static int sd_create(const char *filename, QEMUOptionParameter *options,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (!is_snapshot(&s->inode)) {
|
|
|
9ae3a8 |
error_report("cannot clone from a non snapshot vdi");
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
ret = -EINVAL;
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
base_vid = s->inode.vdi_id;
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ret = do_sd_create(s, vdi, vdi_size, base_vid, &vid, 0);
|
|
|
9ae3a8 |
diff --git a/block/snapshot.c b/block/snapshot.c
|
|
|
9ae3a8 |
index 51b4b96..b2d7681 100644
|
|
|
9ae3a8 |
--- a/block/snapshot.c
|
|
|
9ae3a8 |
+++ b/block/snapshot.c
|
|
|
9ae3a8 |
@@ -99,7 +99,7 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
|
|
|
9ae3a8 |
ret = bdrv_snapshot_goto(bs->file, snapshot_id);
|
|
|
9ae3a8 |
open_ret = drv->bdrv_open(bs, NULL, bs->open_flags, NULL);
|
|
|
9ae3a8 |
if (open_ret < 0) {
|
|
|
9ae3a8 |
- bdrv_delete(bs->file);
|
|
|
9ae3a8 |
+ bdrv_unref(bs->file);
|
|
|
9ae3a8 |
bs->drv = NULL;
|
|
|
9ae3a8 |
return open_ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
diff --git a/block/stream.c b/block/stream.c
|
|
|
9ae3a8 |
index cbae815..82fb179 100644
|
|
|
9ae3a8 |
--- a/block/stream.c
|
|
|
9ae3a8 |
+++ b/block/stream.c
|
|
|
9ae3a8 |
@@ -68,7 +68,7 @@ static void close_unused_images(BlockDriverState *top, BlockDriverState *base,
|
|
|
9ae3a8 |
unused = intermediate;
|
|
|
9ae3a8 |
intermediate = intermediate->backing_hd;
|
|
|
9ae3a8 |
unused->backing_hd = NULL;
|
|
|
9ae3a8 |
- bdrv_delete(unused);
|
|
|
9ae3a8 |
+ bdrv_unref(unused);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
top->backing_hd = base;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
diff --git a/block/vhdx.c b/block/vhdx.c
|
|
|
9ae3a8 |
index 8b1a5c9..1995778 100644
|
|
|
9ae3a8 |
--- a/block/vhdx.c
|
|
|
9ae3a8 |
+++ b/block/vhdx.c
|
|
|
9ae3a8 |
@@ -1847,7 +1847,7 @@ static int vhdx_create(const char *filename, QEMUOptionParameter *options,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
delete_and_exit:
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
exit:
|
|
|
9ae3a8 |
g_free(creator);
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
diff --git a/block/vmdk.c b/block/vmdk.c
|
|
|
9ae3a8 |
index 8662016..a1994a4 100644
|
|
|
9ae3a8 |
--- a/block/vmdk.c
|
|
|
9ae3a8 |
+++ b/block/vmdk.c
|
|
|
9ae3a8 |
@@ -219,7 +219,7 @@ static void vmdk_free_extents(BlockDriverState *bs)
|
|
|
9ae3a8 |
g_free(e->l1_backup_table);
|
|
|
9ae3a8 |
g_free(e->type);
|
|
|
9ae3a8 |
if (e->file != bs->file) {
|
|
|
9ae3a8 |
- bdrv_delete(e->file);
|
|
|
9ae3a8 |
+ bdrv_unref(e->file);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
g_free(s->extents);
|
|
|
9ae3a8 |
@@ -784,7 +784,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
|
|
|
9ae3a8 |
/* SPARSE extent and VMFSSPARSE extent are both "COWD" sparse file*/
|
|
|
9ae3a8 |
ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, errp);
|
|
|
9ae3a8 |
if (ret) {
|
|
|
9ae3a8 |
- bdrv_delete(extent_file);
|
|
|
9ae3a8 |
+ bdrv_unref(extent_file);
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
extent = &s->extents[s->num_extents - 1];
|
|
|
9ae3a8 |
@@ -1703,15 +1703,15 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
|
|
|
9ae3a8 |
BlockDriverState *bs = bdrv_new("");
|
|
|
9ae3a8 |
ret = bdrv_open(bs, backing_file, NULL, 0, NULL, errp);
|
|
|
9ae3a8 |
if (ret != 0) {
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (strcmp(bs->drv->format_name, "vmdk")) {
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
return -EINVAL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
parent_cid = vmdk_read_cid(bs, 0);
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
snprintf(parent_desc_line, sizeof(parent_desc_line),
|
|
|
9ae3a8 |
"parentFileNameHint=\"%s\"", backing_file);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
diff --git a/block/vvfat.c b/block/vvfat.c
|
|
|
9ae3a8 |
index 2c7970d..3ddaa0b 100644
|
|
|
9ae3a8 |
--- a/block/vvfat.c
|
|
|
9ae3a8 |
+++ b/block/vvfat.c
|
|
|
9ae3a8 |
@@ -2896,7 +2896,7 @@ static int write_target_commit(BlockDriverState *bs, int64_t sector_num,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void write_target_close(BlockDriverState *bs) {
|
|
|
9ae3a8 |
BDRVVVFATState* s = *((BDRVVVFATState**) bs->opaque);
|
|
|
9ae3a8 |
- bdrv_delete(s->qcow);
|
|
|
9ae3a8 |
+ bdrv_unref(s->qcow);
|
|
|
9ae3a8 |
g_free(s->qcow_filename);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -2943,7 +2943,7 @@ static int enable_write_target(BDRVVVFATState *s)
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
qerror_report_err(local_err);
|
|
|
9ae3a8 |
error_free(local_err);
|
|
|
9ae3a8 |
- bdrv_delete(s->qcow);
|
|
|
9ae3a8 |
+ bdrv_unref(s->qcow);
|
|
|
9ae3a8 |
goto err;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
9ae3a8 |
index 93fb339..564262a 100644
|
|
|
9ae3a8 |
--- a/blockdev.c
|
|
|
9ae3a8 |
+++ b/blockdev.c
|
|
|
9ae3a8 |
@@ -221,7 +221,7 @@ static void drive_uninit(DriveInfo *dinfo)
|
|
|
9ae3a8 |
qemu_opts_del(dinfo->opts);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- bdrv_delete(dinfo->bdrv);
|
|
|
9ae3a8 |
+ bdrv_unref(dinfo->bdrv);
|
|
|
9ae3a8 |
g_free(dinfo->id);
|
|
|
9ae3a8 |
QTAILQ_REMOVE(&drives, dinfo, next);
|
|
|
9ae3a8 |
g_free(dinfo->serial);
|
|
|
9ae3a8 |
@@ -531,7 +531,7 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
|
|
|
9ae3a8 |
return dinfo;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
err:
|
|
|
9ae3a8 |
- bdrv_delete(dinfo->bdrv);
|
|
|
9ae3a8 |
+ bdrv_unref(dinfo->bdrv);
|
|
|
9ae3a8 |
g_free(dinfo->id);
|
|
|
9ae3a8 |
QTAILQ_REMOVE(&drives, dinfo, next);
|
|
|
9ae3a8 |
g_free(dinfo);
|
|
|
9ae3a8 |
@@ -1086,7 +1086,7 @@ static void external_snapshot_abort(BlkTransactionStates *common)
|
|
|
9ae3a8 |
ExternalSnapshotStates *states =
|
|
|
9ae3a8 |
DO_UPCAST(ExternalSnapshotStates, common, common);
|
|
|
9ae3a8 |
if (states->new_bs) {
|
|
|
9ae3a8 |
- bdrv_delete(states->new_bs);
|
|
|
9ae3a8 |
+ bdrv_unref(states->new_bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1645,7 +1645,7 @@ void qmp_drive_mirror(const char *device, const char *target,
|
|
|
9ae3a8 |
ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv,
|
|
|
9ae3a8 |
&local_err);
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
- bdrv_delete(target_bs);
|
|
|
9ae3a8 |
+ bdrv_unref(target_bs);
|
|
|
9ae3a8 |
error_propagate(errp, local_err);
|
|
|
9ae3a8 |
return;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1654,7 +1654,7 @@ void qmp_drive_mirror(const char *device, const char *target,
|
|
|
9ae3a8 |
on_source_error, on_target_error,
|
|
|
9ae3a8 |
block_job_cb, bs, &local_err);
|
|
|
9ae3a8 |
if (local_err != NULL) {
|
|
|
9ae3a8 |
- bdrv_delete(target_bs);
|
|
|
9ae3a8 |
+ bdrv_unref(target_bs);
|
|
|
9ae3a8 |
error_propagate(errp, local_err);
|
|
|
9ae3a8 |
return;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
|
|
|
9ae3a8 |
index 498f2e9..138ab94 100644
|
|
|
9ae3a8 |
--- a/hw/block/xen_disk.c
|
|
|
9ae3a8 |
+++ b/hw/block/xen_disk.c
|
|
|
9ae3a8 |
@@ -806,7 +806,7 @@ static int blk_connect(struct XenDevice *xendev)
|
|
|
9ae3a8 |
xen_be_printf(&blkdev->xendev, 0, "error: %s\n",
|
|
|
9ae3a8 |
error_get_pretty(local_err));
|
|
|
9ae3a8 |
error_free(local_err);
|
|
|
9ae3a8 |
- bdrv_delete(blkdev->bs);
|
|
|
9ae3a8 |
+ bdrv_unref(blkdev->bs);
|
|
|
9ae3a8 |
blkdev->bs = NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -924,7 +924,7 @@ static void blk_disconnect(struct XenDevice *xendev)
|
|
|
9ae3a8 |
/* close/delete only if we created it ourself */
|
|
|
9ae3a8 |
bdrv_close(blkdev->bs);
|
|
|
9ae3a8 |
bdrv_detach_dev(blkdev->bs, blkdev);
|
|
|
9ae3a8 |
- bdrv_delete(blkdev->bs);
|
|
|
9ae3a8 |
+ bdrv_unref(blkdev->bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
blkdev->bs = NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
diff --git a/include/block/block.h b/include/block/block.h
|
|
|
9ae3a8 |
index a3b7395..d20d63e 100644
|
|
|
9ae3a8 |
--- a/include/block/block.h
|
|
|
9ae3a8 |
+++ b/include/block/block.h
|
|
|
9ae3a8 |
@@ -182,7 +182,6 @@ BlockDriverState *bdrv_new(const char *device_name);
|
|
|
9ae3a8 |
void bdrv_make_anon(BlockDriverState *bs);
|
|
|
9ae3a8 |
void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old);
|
|
|
9ae3a8 |
void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top);
|
|
|
9ae3a8 |
-void bdrv_delete(BlockDriverState *bs);
|
|
|
9ae3a8 |
int bdrv_parse_cache_flags(const char *mode, int *flags);
|
|
|
9ae3a8 |
int bdrv_parse_discard_flags(const char *mode, int *flags);
|
|
|
9ae3a8 |
int bdrv_file_open(BlockDriverState **pbs, const char *filename,
|
|
|
9ae3a8 |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
9ae3a8 |
index f0f70e4..bc48dc1 100644
|
|
|
9ae3a8 |
--- a/qemu-img.c
|
|
|
9ae3a8 |
+++ b/qemu-img.c
|
|
|
9ae3a8 |
@@ -305,7 +305,7 @@ static BlockDriverState *bdrv_new_open(const char *filename,
|
|
|
9ae3a8 |
return bs;
|
|
|
9ae3a8 |
fail:
|
|
|
9ae3a8 |
if (bs) {
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
return NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -658,7 +658,7 @@ static int img_check(int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
fail:
|
|
|
9ae3a8 |
qapi_free_ImageCheck(check);
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -728,7 +728,7 @@ static int img_commit(int argc, char **argv)
|
|
|
9ae3a8 |
break;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
if (ret) {
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1110,11 +1110,11 @@ static int img_compare(int argc, char **argv)
|
|
|
9ae3a8 |
ret = 0;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
out:
|
|
|
9ae3a8 |
- bdrv_delete(bs2);
|
|
|
9ae3a8 |
+ bdrv_unref(bs2);
|
|
|
9ae3a8 |
qemu_vfree(buf1);
|
|
|
9ae3a8 |
qemu_vfree(buf2);
|
|
|
9ae3a8 |
out2:
|
|
|
9ae3a8 |
- bdrv_delete(bs1);
|
|
|
9ae3a8 |
+ bdrv_unref(bs1);
|
|
|
9ae3a8 |
out3:
|
|
|
9ae3a8 |
qemu_progress_end();
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
@@ -1595,12 +1595,12 @@ out:
|
|
|
9ae3a8 |
free_option_parameters(param);
|
|
|
9ae3a8 |
qemu_vfree(buf);
|
|
|
9ae3a8 |
if (out_bs) {
|
|
|
9ae3a8 |
- bdrv_delete(out_bs);
|
|
|
9ae3a8 |
+ bdrv_unref(out_bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (bs) {
|
|
|
9ae3a8 |
for (bs_i = 0; bs_i < bs_n; bs_i++) {
|
|
|
9ae3a8 |
if (bs[bs_i]) {
|
|
|
9ae3a8 |
- bdrv_delete(bs[bs_i]);
|
|
|
9ae3a8 |
+ bdrv_unref(bs[bs_i]);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
g_free(bs);
|
|
|
9ae3a8 |
@@ -1738,7 +1738,7 @@ static ImageInfoList *collect_image_info_list(const char *filename,
|
|
|
9ae3a8 |
*last = elem;
|
|
|
9ae3a8 |
last = &elem->next;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
filename = fmt = NULL;
|
|
|
9ae3a8 |
if (chain) {
|
|
|
9ae3a8 |
@@ -2024,8 +2024,7 @@ static int img_map(int argc, char **argv)
|
|
|
9ae3a8 |
dump_map_entry(output_format, &curr, NULL);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
out:
|
|
|
9ae3a8 |
- bdrv_close(bs);
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
return ret < 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -2144,7 +2143,7 @@ static int img_snapshot(int argc, char **argv)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Cleanup */
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
if (ret) {
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -2428,14 +2427,14 @@ out:
|
|
|
9ae3a8 |
/* Cleanup */
|
|
|
9ae3a8 |
if (!unsafe) {
|
|
|
9ae3a8 |
if (bs_old_backing != NULL) {
|
|
|
9ae3a8 |
- bdrv_delete(bs_old_backing);
|
|
|
9ae3a8 |
+ bdrv_unref(bs_old_backing);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (bs_new_backing != NULL) {
|
|
|
9ae3a8 |
- bdrv_delete(bs_new_backing);
|
|
|
9ae3a8 |
+ bdrv_unref(bs_new_backing);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
if (ret) {
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -2558,7 +2557,7 @@ static int img_resize(int argc, char **argv)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
out:
|
|
|
9ae3a8 |
if (bs) {
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (ret) {
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
@@ -2640,7 +2639,7 @@ static int img_amend(int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
out:
|
|
|
9ae3a8 |
if (bs) {
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
free_option_parameters(create_options);
|
|
|
9ae3a8 |
free_option_parameters(options_param);
|
|
|
9ae3a8 |
diff --git a/qemu-io.c b/qemu-io.c
|
|
|
9ae3a8 |
index 64b060c..7e258a5 100644
|
|
|
9ae3a8 |
--- a/qemu-io.c
|
|
|
9ae3a8 |
+++ b/qemu-io.c
|
|
|
9ae3a8 |
@@ -1761,7 +1761,7 @@ static const cmdinfo_t abort_cmd = {
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int close_f(int argc, char **argv)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
bs = NULL;
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1796,7 +1796,7 @@ static int openfile(char *name, int flags, int growable, QDict *opts)
|
|
|
9ae3a8 |
fprintf(stderr, "%s: can't open device %s: %s\n", progname, name,
|
|
|
9ae3a8 |
error_get_pretty(local_err));
|
|
|
9ae3a8 |
error_free(local_err);
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
bs = NULL;
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -2072,7 +2072,7 @@ int main(int argc, char **argv)
|
|
|
9ae3a8 |
bdrv_drain_all();
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (bs) {
|
|
|
9ae3a8 |
- bdrv_delete(bs);
|
|
|
9ae3a8 |
+ bdrv_unref(bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|