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;
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,
- BlockDriver *drv)
+int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
+ BlockDriver *drv)
{
int ret, open_flags;
char tmp_filename[PATH_MAX];
/* 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;
/* 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;
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 */
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 */
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,
- BlockDriver *drv);
+int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
+ BlockDriver *drv);
void bdrv_close(BlockDriverState *bs);
int bdrv_check(BlockDriverState *bs);
int bdrv_read(BlockDriverState *bs, int64_t sector_num,
#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)
{
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);
}
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;
}
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);
xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
blkdev->bs = bdrv_new(blkdev->dev);
if (blkdev->bs) {
- if (bdrv_open2(blkdev->bs, blkdev->filename, qflags,
+ if (bdrv_open(blkdev->bs, blkdev->filename, qflags,
bdrv_find_whitelisted_format(blkdev->fileproto))
!= 0) {
bdrv_delete(blkdev->bs);
if (eject_device(mon, bs, 0) < 0) {
return -1;
}
- if (bdrv_open2(bs, filename, BDRV_O_RDWR, drv) < 0) {
+ if (bdrv_open(bs, filename, BDRV_O_RDWR, drv) < 0) {
qerror_report(QERR_OPEN_FILE_FAILED, filename);
return -1;
}
if (!readonly) {
flags |= BDRV_O_RDWR;
}
- if (bdrv_open2(bs, filename, flags, drv) < 0) {
+ if (bdrv_open(bs, filename, flags, drv) < 0) {
error("Could not open '%s'", filename);
}
if (bdrv_is_encrypted(bs)) {
} else {
drv = NULL;
}
- if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) {
+ if (bdrv_open(bs, filename, BRDV_O_FLAGS, drv) < 0) {
error("Could not open '%s'", filename);
}
ret = bdrv_check(bs);
} else {
drv = NULL;
}
- if (bdrv_open2(bs, filename, BRDV_O_FLAGS | BDRV_O_RDWR, drv) < 0) {
+ if (bdrv_open(bs, filename, BRDV_O_FLAGS | BDRV_O_RDWR, drv) < 0) {
error("Could not open '%s'", filename);
}
ret = bdrv_commit(bs);
} else {
drv = NULL;
}
- if (bdrv_open2(bs, filename, BRDV_O_FLAGS | BDRV_O_NO_BACKING, drv) < 0) {
+ if (bdrv_open(bs, filename, BRDV_O_FLAGS | BDRV_O_NO_BACKING, drv) < 0) {
error("Could not open '%s'", filename);
}
bdrv_get_format(bs, fmt_name, sizeof(fmt_name));
if (!bs)
error("Not enough memory");
- if (bdrv_open2(bs, filename, bdrv_oflags, NULL) < 0) {
+ if (bdrv_open(bs, filename, bdrv_oflags, NULL) < 0) {
error("Could not open '%s'", filename);
}
}
flags = BRDV_O_FLAGS | BDRV_O_RDWR | (unsafe ? BDRV_O_NO_BACKING : 0);
- if (bdrv_open2(bs, filename, flags, drv) < 0) {
+ if (bdrv_open(bs, filename, flags, drv) < 0) {
error("Could not open '%s'", filename);
}
bs_old_backing = bdrv_new("old_backing");
bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name));
- if (bdrv_open2(bs_old_backing, backing_name, BRDV_O_FLAGS,
+ if (bdrv_open(bs_old_backing, backing_name, BRDV_O_FLAGS,
old_backing_drv))
{
error("Could not open old backing file '%s'", backing_name);
}
bs_new_backing = bdrv_new("new_backing");
- if (bdrv_open2(bs_new_backing, out_baseimg, BRDV_O_FLAGS | BDRV_O_RDWR,
+ if (bdrv_open(bs_new_backing, out_baseimg, BRDV_O_FLAGS | BDRV_O_RDWR,
new_backing_drv))
{
error("Could not open new backing file '%s'", out_baseimg);
flags |= BDRV_O_FILE;
}
- if (bdrv_open(bs, name, flags) < 0) {
+ if (bdrv_open(bs, name, flags, NULL) < 0) {
fprintf(stderr, "%s: can't open device %s\n", progname, name);
bs = NULL;
return 1;
if (bs == NULL)
return 1;
- if (bdrv_open(bs, argv[optind], flags) < 0)
+ if (bdrv_open(bs, argv[optind], flags, NULL) < 0)
return 1;
fd_size = bs->total_sectors * 512;
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
- if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
+ if (bdrv_open(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
fprintf(stderr, "qemu: could not open disk image %s: %s\n",
file, strerror(errno));
return NULL;