void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,

                       int64_t speed, BlockDriverCompletionFunc *cb,

                       void *opaque, Error **errp)

{

    BlockJob *job;



    if (bs->job || bdrv_in_use(bs)) {

        error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));

        return NULL;

    }

    bdrv_ref(bs);

    bdrv_set_in_use(bs, 1);



    job = g_malloc0(driver->instance_size);

    job->driver        = driver;

    job->bs            = bs;

    job->cb            = cb;

    job->opaque        = opaque;

    job->busy          = true;

    bs->job = job;



    /* Only set speed when necessary to avoid NotSupported error */

    if (speed != 0) {

        Error *local_err = NULL;



        block_job_set_speed(job, speed, &local_err);

        if (local_err) {

            bs->job = NULL;

            g_free(job);

            bdrv_set_in_use(bs, 0);

            error_propagate(errp, local_err);

            return NULL;

        }

    }

    return job;

}

void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,

                       int64_t speed, BlockDriverCompletionFunc *cb,

                       void *opaque, Error **errp)

{

    BlockJob *job;



    if (bs->job || bdrv_in_use(bs)) {

        error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));

        return NULL;

    }

    bdrv_ref(bs);

    bdrv_set_in_use(bs, 1);



    job = g_malloc0(driver->instance_size);

    job->driver        = driver;

    job->bs            = bs;

    job->cb            = cb;

    job->opaque        = opaque;

    job->busy          = true;

    bs->job = job;



    

    if (speed != 0) {

        Error *local_err = NULL;



        block_job_set_speed(job, speed, &local_err);

        if (local_err) {

            bs->job = NULL;

            g_free(job);

            bdrv_set_in_use(bs, 0);

            error_propagate(errp, local_err);

            return NULL;

        }

    }

    return job;

}

void *FUNC_0(const BlockJobDriver *VAR_0, BlockDriverState *VAR_1,

                       int64_t VAR_2, BlockDriverCompletionFunc *VAR_3,

                       void *VAR_4, Error **VAR_5)

{

    BlockJob *job;



    if (VAR_1->job || bdrv_in_use(VAR_1)) {

        error_set(VAR_5, QERR_DEVICE_IN_USE, bdrv_get_device_name(VAR_1));

        return NULL;

    }

    bdrv_ref(VAR_1);

    bdrv_set_in_use(VAR_1, 1);



    job = g_malloc0(VAR_0->instance_size);

    job->VAR_0        = VAR_0;

    job->VAR_1            = VAR_1;

    job->VAR_3            = VAR_3;

    job->VAR_4        = VAR_4;

    job->busy          = true;

    VAR_1->job = job;



    

    if (VAR_2 != 0) {

        Error *local_err = NULL;



        block_job_set_speed(job, VAR_2, &local_err);

        if (local_err) {

            VAR_1->job = NULL;

            g_free(job);

            bdrv_set_in_use(VAR_1, 0);

            error_propagate(VAR_5, local_err);

            return NULL;

        }

    }

    return job;

}

void *FUNC_0(const BlockJobDriver *VAR_0, BlockDriverState *VAR_1,
int64_t VAR_2, BlockDriverCompletionFunc *VAR_3,
void *VAR_4, Error **VAR_5)
{ BlockJob *job; if (VAR_1->job || bdrv_in_use(VAR_1)) { error_set(VAR_5, QERR_DEVICE_IN_USE, bdrv_get_device_name(VAR_1)); return NULL; } bdrv_ref(VAR_1); bdrv_set_in_use(VAR_1, 1); job = g_malloc0(VAR_0->instance_size); job->VAR_0        = VAR_0; job->VAR_1            = VAR_1; job->VAR_3            = VAR_3; job->VAR_4        = VAR_4; job->busy          = true; VAR_1->job = job; if (VAR_2 != 0) { Error *local_err = NULL; block_job_set_speed(job, VAR_2, &local_err); if (local_err) { VAR_1->job = NULL; g_free(job); bdrv_set_in_use(VAR_1, 0); error_propagate(VAR_5, local_err); return NULL; } } return job; }