static int raw_open_common(BlockDriverState *bs, QDict *options,

                           int bdrv_flags, int open_flags, Error **errp)

{

    BDRVRawState *s = bs->opaque;

    QemuOpts *opts;

    Error *local_err = NULL;

    const char *filename;

    int fd, ret;



    opts = qemu_opts_create_nofail(&raw_runtime_opts);

    qemu_opts_absorb_qdict(opts, options, &local_err);

    if (error_is_set(&local_err)) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    filename = qemu_opt_get(opts, "filename");



    ret = raw_normalize_devicepath(&filename);

    if (ret != 0) {

        error_setg_errno(errp, -ret, "Could not normalize device path");

        goto fail;

    }



    s->open_flags = open_flags;

    raw_parse_flags(bdrv_flags, &s->open_flags);



    s->fd = -1;

    fd = qemu_open(filename, s->open_flags, 0644);

    if (fd < 0) {

        ret = -errno;

        if (ret == -EROFS) {

            ret = -EACCES;

        }

        goto fail;

    }

    s->fd = fd;



#ifdef CONFIG_LINUX_AIO

    if (raw_set_aio(&s->aio_ctx, &s->use_aio, bdrv_flags)) {

        qemu_close(fd);

        ret = -errno;

        error_setg_errno(errp, -ret, "Could not set AIO state");

        goto fail;

    }

#endif



    s->has_discard = 1;

#ifdef CONFIG_XFS

    if (platform_test_xfs_fd(s->fd)) {

        s->is_xfs = 1;

    }

#endif



    ret = 0;

fail:

    qemu_opts_del(opts);

    return ret;

}

static int raw_open_common(BlockDriverState *bs, QDict *options,

                           int bdrv_flags, int open_flags, Error **errp)

{

    BDRVRawState *s = bs->opaque;

    QemuOpts *opts;

    Error *local_err = NULL;

    const char *filename;

    int fd, ret;



    opts = qemu_opts_create_nofail(&raw_runtime_opts);

    qemu_opts_absorb_qdict(opts, options, &local_err);

    if (error_is_set(&local_err)) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    filename = qemu_opt_get(opts, "filename");



    ret = raw_normalize_devicepath(&filename);

    if (ret != 0) {

        error_setg_errno(errp, -ret, "Could not normalize device path");

        goto fail;

    }



    s->open_flags = open_flags;

    raw_parse_flags(bdrv_flags, &s->open_flags);



    s->fd = -1;

    fd = qemu_open(filename, s->open_flags, 0644);

    if (fd < 0) {

        ret = -errno;

        if (ret == -EROFS) {

            ret = -EACCES;

        }

        goto fail;

    }

    s->fd = fd;



#ifdef CONFIG_LINUX_AIO

    if (raw_set_aio(&s->aio_ctx, &s->use_aio, bdrv_flags)) {

        qemu_close(fd);

        ret = -errno;

        error_setg_errno(errp, -ret, "Could not set AIO state");

        goto fail;

    }

#endif



    s->has_discard = 1;

#ifdef CONFIG_XFS

    if (platform_test_xfs_fd(s->fd)) {

        s->is_xfs = 1;

    }

#endif



    ret = 0;

fail:

    qemu_opts_del(opts);

    return ret;

}

static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1,

                           int VAR_2, int VAR_3, Error **VAR_4)

{

    BDRVRawState *s = VAR_0->opaque;

    QemuOpts *opts;

    Error *local_err = NULL;

    const char *VAR_5;

    int VAR_6, VAR_7;



    opts = qemu_opts_create_nofail(&raw_runtime_opts);

    qemu_opts_absorb_qdict(opts, VAR_1, &local_err);

    if (error_is_set(&local_err)) {

        error_propagate(VAR_4, local_err);

        VAR_7 = -EINVAL;

        goto fail;

    }



    VAR_5 = qemu_opt_get(opts, "VAR_5");



    VAR_7 = raw_normalize_devicepath(&VAR_5);

    if (VAR_7 != 0) {

        error_setg_errno(VAR_4, -VAR_7, "Could not normalize device path");

        goto fail;

    }



    s->VAR_3 = VAR_3;

    raw_parse_flags(VAR_2, &s->VAR_3);



    s->VAR_6 = -1;

    VAR_6 = qemu_open(VAR_5, s->VAR_3, 0644);

    if (VAR_6 < 0) {

        VAR_7 = -errno;

        if (VAR_7 == -EROFS) {

            VAR_7 = -EACCES;

        }

        goto fail;

    }

    s->VAR_6 = VAR_6;



#ifdef CONFIG_LINUX_AIO

    if (raw_set_aio(&s->aio_ctx, &s->use_aio, VAR_2)) {

        qemu_close(VAR_6);

        VAR_7 = -errno;

        error_setg_errno(VAR_4, -VAR_7, "Could not set AIO state");

        goto fail;

    }

#endif



    s->has_discard = 1;

#ifdef CONFIG_XFS

    if (platform_test_xfs_fd(s->VAR_6)) {

        s->is_xfs = 1;

    }

#endif



    VAR_7 = 0;

fail:

    qemu_opts_del(opts);

    return VAR_7;

}

static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1,
int VAR_2, int VAR_3, Error **VAR_4)
{ BDRVRawState *s = VAR_0->opaque; QemuOpts *opts; Error *local_err = NULL; const char *VAR_5; int VAR_6, VAR_7; opts = qemu_opts_create_nofail(&raw_runtime_opts); qemu_opts_absorb_qdict(opts, VAR_1, &local_err); if (error_is_set(&local_err)) { error_propagate(VAR_4, local_err); VAR_7 = -EINVAL; goto fail; } VAR_5 = qemu_opt_get(opts, "VAR_5"); VAR_7 = raw_normalize_devicepath(&VAR_5); if (VAR_7 != 0) { error_setg_errno(VAR_4, -VAR_7, "Could not normalize device path"); goto fail; } s->VAR_3 = VAR_3; raw_parse_flags(VAR_2, &s->VAR_3); s->VAR_6 = -1; VAR_6 = qemu_open(VAR_5, s->VAR_3, 0644); if (VAR_6 < 0) { VAR_7 = -errno; if (VAR_7 == -EROFS) { VAR_7 = -EACCES; } goto fail; } s->VAR_6 = VAR_6; #ifdef CONFIG_LINUX_AIO
if (raw_set_aio(&s->aio_ctx, &s->use_aio, VAR_2)) { qemu_close(VAR_6); VAR_7 = -errno; error_setg_errno(VAR_4, -VAR_7, "Could not set AIO state"); goto fail; } #endif
s->has_discard = 1; #ifdef CONFIG_XFS
if (platform_test_xfs_fd(s->VAR_6)) { s->is_xfs = 1; } #endif
VAR_7 = 0; fail:
qemu_opts_del(opts); return VAR_7; }