Revision 14bafc54 blockdev.c

b/blockdev.c
17 17

  
18 18
static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
19 19

  
20
/*
21
 * We automatically delete the drive when a device using it gets
22
 * unplugged.  Questionable feature, but we can't just drop it.
23
 * Device models call blockdev_mark_auto_del() to schedule the
24
 * automatic deletion, and generic qdev code calls blockdev_auto_del()
25
 * when deletion is actually safe.
26
 */
27
void blockdev_mark_auto_del(BlockDriverState *bs)
28
{
29
    DriveInfo *dinfo = drive_get_by_blockdev(bs);
30

  
31
    dinfo->auto_del = 1;
32
}
33

  
34
void blockdev_auto_del(BlockDriverState *bs)
35
{
36
    DriveInfo *dinfo = drive_get_by_blockdev(bs);
37

  
38
    if (dinfo->auto_del) {
39
        drive_uninit(dinfo);
40
    }
41
}
42

  
20 43
QemuOpts *drive_add(const char *file, const char *fmt, ...)
21 44
{
22 45
    va_list ap;

Also available in: Unified diff