Commit d6e9098e authored by Kevin Wolf's avatar Kevin Wolf
Browse files

Replace calls of old bdrv_open



What is known today as bdrv_open2 becomes the new bdrv_open. All remaining
callers of the old function are converted to the new one. In some places they
even know the right format, so they should have used bdrv_open2 from the
beginning.

Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent 4768fa90
Loading
Loading
Loading
Loading
+9 −15
Original line number Diff line number Diff line
@@ -338,7 +338,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags)
    int ret;

    bs = bdrv_new("");
    ret = bdrv_open2(bs, filename, flags | BDRV_O_FILE, NULL);
    ret = bdrv_open(bs, filename, flags | BDRV_O_FILE, NULL);
    if (ret < 0) {
        bdrv_delete(bs);
        return ret;
@@ -348,12 +348,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags)
    return 0;
}

int bdrv_open(BlockDriverState *bs, const char *filename, int flags)
{
    return bdrv_open2(bs, filename, flags, NULL);
}

int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
              BlockDriver *drv)
{
    int ret, open_flags;
@@ -379,7 +374,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,

        /* if there is a backing file, use it */
        bs1 = bdrv_new("");
        ret = bdrv_open2(bs1, filename, 0, drv);
        ret = bdrv_open(bs1, filename, 0, drv);
        if (ret < 0) {
            bdrv_delete(bs1);
            return ret;
@@ -492,8 +487,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
        /* backing files always opened read-only */
        open_flags &= ~BDRV_O_RDWR;

        ret = bdrv_open2(bs->backing_hd, backing_filename, open_flags,
                         back_drv);
        ret = bdrv_open(bs->backing_hd, backing_filename, open_flags, back_drv);
        if (ret < 0) {
            bdrv_close(bs);
            return ret;
@@ -605,12 +599,12 @@ int bdrv_commit(BlockDriverState *bs)
        bdrv_delete(bs->backing_hd);
        bs->backing_hd = NULL;
        bs_rw = bdrv_new("");
        rw_ret = bdrv_open2(bs_rw, filename, open_flags | BDRV_O_RDWR, NULL);
        rw_ret = bdrv_open(bs_rw, filename, open_flags | BDRV_O_RDWR, NULL);
        if (rw_ret < 0) {
            bdrv_delete(bs_rw);
            /* try to re-open read-only */
            bs_ro = bdrv_new("");
            ret = bdrv_open2(bs_ro, filename, open_flags & ~BDRV_O_RDWR, NULL);
            ret = bdrv_open(bs_ro, filename, open_flags & ~BDRV_O_RDWR, NULL);
            if (ret < 0) {
                bdrv_delete(bs_ro);
                /* drive not functional anymore */
@@ -662,7 +656,7 @@ ro_cleanup:
        bdrv_delete(bs->backing_hd);
        bs->backing_hd = NULL;
        bs_ro = bdrv_new("");
        ret = bdrv_open2(bs_ro, filename, open_flags & ~BDRV_O_RDWR, NULL);
        ret = bdrv_open(bs_ro, filename, open_flags & ~BDRV_O_RDWR, NULL);
        if (ret < 0) {
            bdrv_delete(bs_ro);
            /* drive not functional anymore */
+2 −3
Original line number Diff line number Diff line
@@ -68,8 +68,7 @@ int bdrv_create2(BlockDriver *drv,
BlockDriverState *bdrv_new(const char *device_name);
void bdrv_delete(BlockDriverState *bs);
int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags);
int bdrv_open(BlockDriverState *bs, const char *filename, int flags);
int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
              BlockDriver *drv);
void bdrv_close(BlockDriverState *bs);
int bdrv_check(BlockDriverState *bs);
+2 −2
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ typedef struct {
#define  QCOW_EXT_MAGIC_END 0
#define  QCOW_EXT_MAGIC_BACKING_FORMAT 0xE2792ACA


static BlockDriver bdrv_qcow2;

static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
{
@@ -1033,7 +1033,7 @@ exit:
    if (ret == 0 && prealloc) {
        BlockDriverState *bs;
        bs = bdrv_new("");
        bdrv_open(bs, filename, BDRV_O_CACHE_WB | BDRV_O_RDWR);
        bdrv_open(bs, filename, BDRV_O_CACHE_WB | BDRV_O_RDWR, &bdrv_qcow2);
        preallocate(bs);
        bdrv_close(bs);
    }
+1 −1
Original line number Diff line number Diff line
@@ -390,7 +390,7 @@ static int vmdk_parent_open(BlockDriverState *bs, const char * filename)
            return -1;
        }
        parent_open = 1;
        if (bdrv_open(bs->backing_hd, parent_img_name, 0) < 0)
        if (bdrv_open(bs->backing_hd, parent_img_name, 0, NULL) < 0)
            goto failure;
        parent_open = 0;
    }
+4 −1
Original line number Diff line number Diff line
@@ -2795,8 +2795,11 @@ static int enable_write_target(BDRVVVFATState *s)
    if (bdrv_create(bdrv_qcow, s->qcow_filename, options) < 0)
	return -1;
    s->qcow = bdrv_new("");
    if (s->qcow == NULL || bdrv_open(s->qcow, s->qcow_filename, BDRV_O_RDWR) < 0)
    if (s->qcow == NULL ||
        bdrv_open(s->qcow, s->qcow_filename, BDRV_O_RDWR, bdrv_qcow) < 0)
    {
	return -1;
    }

#ifndef _WIN32
    unlink(s->qcow_filename);
Loading