blockdev: Make eject fail for non-removable drives even with -f
Ejecting hard disk platters can only end in tears. If you need to revoke access to an image, use drive_del, not eject -f. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
		
							parent
							
								
									927d721777
								
							
						
					
					
						commit
						ea8f942fe4
					
				@ -646,17 +646,14 @@ out:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static int eject_device(Monitor *mon, BlockDriverState *bs, int force)
 | 
					static int eject_device(Monitor *mon, BlockDriverState *bs, int force)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!force) {
 | 
					 | 
				
			||||||
    if (!bdrv_is_removable(bs)) {
 | 
					    if (!bdrv_is_removable(bs)) {
 | 
				
			||||||
            qerror_report(QERR_DEVICE_NOT_REMOVABLE,
 | 
					        qerror_report(QERR_DEVICE_NOT_REMOVABLE, bdrv_get_device_name(bs));
 | 
				
			||||||
                           bdrv_get_device_name(bs));
 | 
					 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
        if (bdrv_is_locked(bs)) {
 | 
					    if (!force && bdrv_is_locked(bs)) {
 | 
				
			||||||
        qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs));
 | 
					        qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs));
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    bdrv_close(bs);
 | 
					    bdrv_close(bs);
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user