Commit 2e40134b authored by Max Reitz's avatar Max Reitz Committed by Kevin Wolf
Browse files

block: Make bdrv_file_open() static



Add the bdrv_open() option BDRV_O_PROTOCOL which results in passing the
call to bdrv_file_open(). Additionally, make bdrv_file_open() static and
therefore bdrv_open() the only way to call it.

Consequently, all existing calls to bdrv_file_open() have to be adjusted
to use bdrv_open() with the BDRV_O_PROTOCOL flag instead.

Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
Reviewed-by: default avatarBenoit Canet <benoit@irqsave.net>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent ddf5636d
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -960,7 +960,7 @@ free_and_fail:
 * after the call (even on failure), so if the caller intends to reuse the
 * dictionary, it needs to use QINCREF() before calling bdrv_file_open.
 */
int bdrv_file_open(BlockDriverState **pbs, const char *filename,
static int bdrv_file_open(BlockDriverState **pbs, const char *filename,
                          const char *reference, QDict *options, int flags,
                          Error **errp)
{
@@ -1208,8 +1208,8 @@ int bdrv_open_image(BlockDriverState **pbs, const char *filename,

        ret = bdrv_open(pbs, filename, NULL, image_options, flags, NULL, errp);
    } else {
        ret = bdrv_file_open(pbs, filename, reference, image_options, flags,
                             errp);
        ret = bdrv_open(pbs, filename, reference, image_options,
                        flags | BDRV_O_PROTOCOL, NULL, errp);
    }

done:
@@ -1245,6 +1245,12 @@ int bdrv_open(BlockDriverState **pbs, const char *filename,

    assert(pbs);

    if (flags & BDRV_O_PROTOCOL) {
        assert(!drv);
        return bdrv_file_open(pbs, filename, reference, options,
                              flags & ~BDRV_O_PROTOCOL, errp);
    }

    if (reference) {
        bool options_non_empty = options ? qdict_size(options) : false;
        QDECREF(options);
+3 −2
Original line number Diff line number Diff line
@@ -351,8 +351,9 @@ static int cow_create(const char *filename, QEMUOptionParameter *options,
        return ret;
    }

    ret = bdrv_file_open(&cow_bs, filename, NULL, NULL, BDRV_O_RDWR,
                         &local_err);
    cow_bs = NULL;
    ret = bdrv_open(&cow_bs, filename, NULL, NULL,
                    BDRV_O_RDWR | BDRV_O_PROTOCOL, NULL, &local_err);
    if (ret < 0) {
        qerror_report_err(local_err);
        error_free(local_err);
+3 −2
Original line number Diff line number Diff line
@@ -691,8 +691,9 @@ static int qcow_create(const char *filename, QEMUOptionParameter *options,
        return ret;
    }

    ret = bdrv_file_open(&qcow_bs, filename, NULL, NULL, BDRV_O_RDWR,
                         &local_err);
    qcow_bs = NULL;
    ret = bdrv_open(&qcow_bs, filename, NULL, NULL,
                    BDRV_O_RDWR | BDRV_O_PROTOCOL, NULL, &local_err);
    if (ret < 0) {
        qerror_report_err(local_err);
        error_free(local_err);
+3 −1
Original line number Diff line number Diff line
@@ -1493,7 +1493,9 @@ static int qcow2_create2(const char *filename, int64_t total_size,
        return ret;
    }

    ret = bdrv_file_open(&bs, filename, NULL, NULL, BDRV_O_RDWR, &local_err);
    bs = NULL;
    ret = bdrv_open(&bs, filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL,
                    NULL, &local_err);
    if (ret < 0) {
        error_propagate(errp, local_err);
        return ret;
+5 −3
Original line number Diff line number Diff line
@@ -562,7 +562,7 @@ static int qed_create(const char *filename, uint32_t cluster_size,
    size_t l1_size = header.cluster_size * header.table_size;
    Error *local_err = NULL;
    int ret = 0;
    BlockDriverState *bs = NULL;
    BlockDriverState *bs;

    ret = bdrv_create_file(filename, NULL, &local_err);
    if (ret < 0) {
@@ -571,8 +571,10 @@ static int qed_create(const char *filename, uint32_t cluster_size,
        return ret;
    }

    ret = bdrv_file_open(&bs, filename, NULL, NULL,
                         BDRV_O_RDWR | BDRV_O_CACHE_WB, &local_err);
    bs = NULL;
    ret = bdrv_open(&bs, filename, NULL, NULL,
                    BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL, NULL,
                    &local_err);
    if (ret < 0) {
        qerror_report_err(local_err);
        error_free(local_err);
Loading