Revision 3b5276b5 blockdev.c

b/blockdev.c
503 503

  
504 504
static int eject_device(Monitor *mon, BlockDriverState *bs, int force)
505 505
{
506
    if (bdrv_is_inserted(bs)) {
507
        if (!force) {
508
            if (!bdrv_is_removable(bs)) {
509
                qerror_report(QERR_DEVICE_NOT_REMOVABLE,
510
                               bdrv_get_device_name(bs));
511
                return -1;
512
            }
513
            if (bdrv_is_locked(bs)) {
514
                qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs));
515
                return -1;
516
            }
506
    if (!force) {
507
        if (!bdrv_is_removable(bs)) {
508
            qerror_report(QERR_DEVICE_NOT_REMOVABLE,
509
                           bdrv_get_device_name(bs));
510
            return -1;
511
        }
512
        if (bdrv_is_locked(bs)) {
513
            qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs));
514
            return -1;
517 515
        }
518
        bdrv_close(bs);
519 516
    }
517
    bdrv_close(bs);
520 518
    return 0;
521 519
}
522 520

  

Also available in: Unified diff