static int do_open_tray(const char *device, bool force, Error **errp)

{

    BlockBackend *blk;

    bool locked;



    blk = blk_by_name(device);

    if (!blk) {

        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,

                  "Device '%s' not found", device);

        return -ENODEV;

    }



    if (!blk_dev_has_removable_media(blk)) {

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

        return -ENOTSUP;

    }



    if (!blk_dev_has_tray(blk)) {

        /* Ignore this command on tray-less devices */

        return ENOSYS;

    }



    if (blk_dev_is_tray_open(blk)) {

        return 0;

    }



    locked = blk_dev_is_medium_locked(blk);

    if (locked) {

        blk_dev_eject_request(blk, force);

    }



    if (!locked || force) {

        blk_dev_change_media_cb(blk, false);

    }



    if (locked && !force) {

        return EINPROGRESS;

    }



    return 0;

}

static int do_open_tray(const char *device, bool force, Error **errp)

{

    BlockBackend *blk;

    bool locked;



    blk = blk_by_name(device);

    if (!blk) {

        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,

                  "Device '%s' not found", device);

        return -ENODEV;

    }



    if (!blk_dev_has_removable_media(blk)) {

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

        return -ENOTSUP;

    }



    if (!blk_dev_has_tray(blk)) {

        

        return ENOSYS;

    }



    if (blk_dev_is_tray_open(blk)) {

        return 0;

    }



    locked = blk_dev_is_medium_locked(blk);

    if (locked) {

        blk_dev_eject_request(blk, force);

    }



    if (!locked || force) {

        blk_dev_change_media_cb(blk, false);

    }



    if (locked && !force) {

        return EINPROGRESS;

    }



    return 0;

}

static int FUNC_0(const char *VAR_0, bool VAR_1, Error **VAR_2)

{

    BlockBackend *blk;

    bool locked;



    blk = blk_by_name(VAR_0);

    if (!blk) {

        error_set(VAR_2, ERROR_CLASS_DEVICE_NOT_FOUND,

                  "Device '%s' not found", VAR_0);

        return -ENODEV;

    }



    if (!blk_dev_has_removable_media(blk)) {

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

        return -ENOTSUP;

    }



    if (!blk_dev_has_tray(blk)) {

        

        return ENOSYS;

    }



    if (blk_dev_is_tray_open(blk)) {

        return 0;

    }



    locked = blk_dev_is_medium_locked(blk);

    if (locked) {

        blk_dev_eject_request(blk, VAR_1);

    }



    if (!locked || VAR_1) {

        blk_dev_change_media_cb(blk, false);

    }



    if (locked && !VAR_1) {

        return EINPROGRESS;

    }



    return 0;

}

static int FUNC_0(const char *VAR_0, bool VAR_1, Error **VAR_2)
{ BlockBackend *blk; bool locked; blk = blk_by_name(VAR_0); if (!blk) { error_set(VAR_2, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", VAR_0); return -ENODEV; } if (!blk_dev_has_removable_media(blk)) { error_setg(VAR_2, "Device '%s' is not removable", VAR_0); return -ENOTSUP; } if (!blk_dev_has_tray(blk)) { return ENOSYS; } if (blk_dev_is_tray_open(blk)) { return 0; } locked = blk_dev_is_medium_locked(blk); if (locked) { blk_dev_eject_request(blk, VAR_1); } if (!locked || VAR_1) { blk_dev_change_media_cb(blk, false); } if (locked && !VAR_1) { return EINPROGRESS; } return 0; }