static void eject_device(BlockDriverState *bs, int force, Error **errp)

{

    if (bdrv_in_use(bs)) {

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

        return;

    }

    if (!bdrv_dev_has_removable_media(bs)) {

        error_setg(errp, "Device '%s' is not removable",

                   bdrv_get_device_name(bs));

        return;

    }



    if (bdrv_dev_is_medium_locked(bs) && !bdrv_dev_is_tray_open(bs)) {

        bdrv_dev_eject_request(bs, force);

        if (!force) {

            error_setg(errp, "Device '%s' is locked",

                       bdrv_get_device_name(bs));

            return;

        }

    }



    bdrv_close(bs);

}

static void eject_device(BlockDriverState *bs, int force, Error **errp)

{

    if (bdrv_in_use(bs)) {

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

        return;

    }

    if (!bdrv_dev_has_removable_media(bs)) {

        error_setg(errp, "Device '%s' is not removable",

                   bdrv_get_device_name(bs));

        return;

    }



    if (bdrv_dev_is_medium_locked(bs) && !bdrv_dev_is_tray_open(bs)) {

        bdrv_dev_eject_request(bs, force);

        if (!force) {

            error_setg(errp, "Device '%s' is locked",

                       bdrv_get_device_name(bs));

            return;

        }

    }



    bdrv_close(bs);

}

static void FUNC_0(BlockDriverState *VAR_0, int VAR_1, Error **VAR_2)

{

    if (bdrv_in_use(VAR_0)) {

        error_set(VAR_2, QERR_DEVICE_IN_USE, bdrv_get_device_name(VAR_0));

        return;

    }

    if (!bdrv_dev_has_removable_media(VAR_0)) {

        error_setg(VAR_2, "Device '%s' is not removable",

                   bdrv_get_device_name(VAR_0));

        return;

    }



    if (bdrv_dev_is_medium_locked(VAR_0) && !bdrv_dev_is_tray_open(VAR_0)) {

        bdrv_dev_eject_request(VAR_0, VAR_1);

        if (!VAR_1) {

            error_setg(VAR_2, "Device '%s' is locked",

                       bdrv_get_device_name(VAR_0));

            return;

        }

    }



    bdrv_close(VAR_0);

}

static void FUNC_0(BlockDriverState *VAR_0, int VAR_1, Error **VAR_2)
{ if (bdrv_in_use(VAR_0)) { error_set(VAR_2, QERR_DEVICE_IN_USE, bdrv_get_device_name(VAR_0)); return; } if (!bdrv_dev_has_removable_media(VAR_0)) { error_setg(VAR_2, "Device '%s' is not removable",
bdrv_get_device_name(VAR_0)); return; } if (bdrv_dev_is_medium_locked(VAR_0) && !bdrv_dev_is_tray_open(VAR_0)) { bdrv_dev_eject_request(VAR_0, VAR_1); if (!VAR_1) { error_setg(VAR_2, "Device '%s' is locked",
bdrv_get_device_name(VAR_0)); return; } } bdrv_close(VAR_0); }