static int openfile(char *name, int flags, bool writethrough, bool force_share,

                    QDict *opts)

{

    Error *local_err = NULL;

    BlockDriverState *bs;



    if (qemuio_blk) {

        error_report("file open already, try 'help close'");

        QDECREF(opts);

        return 1;

    }



    if (force_share) {

        if (!opts) {

            opts = qdict_new();

        }

        if (qdict_haskey(opts, BDRV_OPT_FORCE_SHARE)

            && !qdict_get_bool(opts, BDRV_OPT_FORCE_SHARE)) {

            error_report("-U conflicts with image options");

            QDECREF(opts);

            return 1;

        }

        qdict_put_bool(opts, BDRV_OPT_FORCE_SHARE, true);

    }

    qemuio_blk = blk_new_open(name, NULL, opts, flags, &local_err);

    if (!qemuio_blk) {

        error_reportf_err(local_err, "can't open%s%s: ",

                          name ? " device " : "", name ?: "");

        return 1;

    }



    bs = blk_bs(qemuio_blk);

    if (bdrv_is_encrypted(bs) && bdrv_key_required(bs)) {

        char password[256];

        printf("Disk image '%s' is encrypted.\n", name);

        if (qemu_read_password(password, sizeof(password)) < 0) {

            error_report("No password given");

            goto error;

        }

        if (bdrv_set_key(bs, password) < 0) {

            error_report("invalid password");

            goto error;

        }

    }



    blk_set_enable_write_cache(qemuio_blk, !writethrough);



    return 0;



 error:

    blk_unref(qemuio_blk);

    qemuio_blk = NULL;

    return 1;

}

static int openfile(char *name, int flags, bool writethrough, bool force_share,

                    QDict *opts)

{

    Error *local_err = NULL;

    BlockDriverState *bs;



    if (qemuio_blk) {

        error_report("file open already, try 'help close'");

        QDECREF(opts);

        return 1;

    }



    if (force_share) {

        if (!opts) {

            opts = qdict_new();

        }

        if (qdict_haskey(opts, BDRV_OPT_FORCE_SHARE)

            && !qdict_get_bool(opts, BDRV_OPT_FORCE_SHARE)) {

            error_report("-U conflicts with image options");

            QDECREF(opts);

            return 1;

        }

        qdict_put_bool(opts, BDRV_OPT_FORCE_SHARE, true);

    }

    qemuio_blk = blk_new_open(name, NULL, opts, flags, &local_err);

    if (!qemuio_blk) {

        error_reportf_err(local_err, "can't open%s%s: ",

                          name ? " device " : "", name ?: "");

        return 1;

    }



    bs = blk_bs(qemuio_blk);

    if (bdrv_is_encrypted(bs) && bdrv_key_required(bs)) {

        char password[256];

        printf("Disk image '%s' is encrypted.\n", name);

        if (qemu_read_password(password, sizeof(password)) < 0) {

            error_report("No password given");

            goto error;

        }

        if (bdrv_set_key(bs, password) < 0) {

            error_report("invalid password");

            goto error;

        }

    }



    blk_set_enable_write_cache(qemuio_blk, !writethrough);



    return 0;



 error:

    blk_unref(qemuio_blk);

    qemuio_blk = NULL;

    return 1;

}

    Error *local_err = NULL;     return 0;     BlockDriverState *bs;         if (qemu_read_password(password, sizeof(password)) < 0) {             error_report("No password given");         if (bdrv_set_key(bs, password) < 0) {             error_report("invalid password");     return 0;     BlockDriverState *bs;     bs = blk_bs(qemuio_blk);     if (bdrv_is_encrypted(bs) && bdrv_key_required(bs)) {         char password[256];         printf("Disk image '%s' is encrypted.\n", name);         if (qemu_read_password(password, sizeof(password)) < 0) {             error_report("No password given");             goto error;         if (bdrv_set_key(bs, password) < 0) {             error_report("invalid password");             goto error;  error:     blk_unref(qemuio_blk);     qemuio_blk = NULL;     return 1;     Error *local_err = NULL;     BlockDriverState *bs;     return 0;
static int FUNC_0(char *VAR_0, int VAR_1, bool VAR_2, bool VAR_3,

                    QDict *VAR_4)

{

    Error *local_err = NULL;

    BlockDriverState *bs;



    if (qemuio_blk) {

        error_report("file open already, try 'help close'");

        QDECREF(VAR_4);

        return 1;

    }



    if (VAR_3) {

        if (!VAR_4) {

            VAR_4 = qdict_new();

        }

        if (qdict_haskey(VAR_4, BDRV_OPT_FORCE_SHARE)

            && !qdict_get_bool(VAR_4, BDRV_OPT_FORCE_SHARE)) {

            error_report("-U conflicts with image options");

            QDECREF(VAR_4);

            return 1;

        }

        qdict_put_bool(VAR_4, BDRV_OPT_FORCE_SHARE, true);

    }

    qemuio_blk = blk_new_open(VAR_0, NULL, VAR_4, VAR_1, &local_err);

    if (!qemuio_blk) {

        error_reportf_err(local_err, "can't open%s%s: ",

                          VAR_0 ? " device " : "", VAR_0 ?: "");

        return 1;

    }



    bs = blk_bs(qemuio_blk);

    if (bdrv_is_encrypted(bs) && bdrv_key_required(bs)) {

        char VAR_5[256];

        printf("Disk image '%s' is encrypted.\n", VAR_0);

        if (qemu_read_password(VAR_5, sizeof(VAR_5)) < 0) {

            error_report("No VAR_5 given");

            goto error;

        }

        if (bdrv_set_key(bs, VAR_5) < 0) {

            error_report("invalid VAR_5");

            goto error;

        }

    }



    blk_set_enable_write_cache(qemuio_blk, !VAR_2);



    return 0;



 error:

    blk_unref(qemuio_blk);

    qemuio_blk = NULL;

    return 1;

}

static int FUNC_0(char *VAR_0, int VAR_1, bool VAR_2, bool VAR_3,
QDict *VAR_4)
{ Error *local_err = NULL; BlockDriverState *bs; if (qemuio_blk) { error_report("file open already, try 'help close'"); QDECREF(VAR_4); return 1; } if (VAR_3) { if (!VAR_4) { VAR_4 = qdict_new(); } if (qdict_haskey(VAR_4, BDRV_OPT_FORCE_SHARE)
&& !qdict_get_bool(VAR_4, BDRV_OPT_FORCE_SHARE)) { error_report("-U conflicts with image options"); QDECREF(VAR_4); return 1; } qdict_put_bool(VAR_4, BDRV_OPT_FORCE_SHARE, true); } qemuio_blk = blk_new_open(VAR_0, NULL, VAR_4, VAR_1, &local_err); if (!qemuio_blk) { error_reportf_err(local_err, "can't open%s%s: ",
VAR_0 ? " device " : "", VAR_0 ?: ""); return 1; } bs = blk_bs(qemuio_blk); if (bdrv_is_encrypted(bs) && bdrv_key_required(bs)) { char VAR_5[256]; printf("Disk image '%s' is encrypted.\n", VAR_0); if (qemu_read_password(VAR_5, sizeof(VAR_5)) < 0) { error_report("No VAR_5 given"); goto error; } if (bdrv_set_key(bs, VAR_5) < 0) { error_report("invalid VAR_5"); goto error; } } blk_set_enable_write_cache(qemuio_blk, !VAR_2); return 0; error:
blk_unref(qemuio_blk); qemuio_blk = NULL; return 1; }