Revision 7d0d6950

b/block.c
1299 1299
    return is_read ? bs->on_read_error : bs->on_write_error;
1300 1300
}
1301 1301

  
1302
void bdrv_set_removable(BlockDriverState *bs, int removable)
1303
{
1304
    bs->removable = removable;
1305
    if (removable && bs == bs_snapshots) {
1306
        bs_snapshots = NULL;
1307
    }
1308
}
1309

  
1302 1310
int bdrv_is_removable(BlockDriverState *bs)
1303 1311
{
1304 1312
    return bs->removable;
b/block.h
162 162
void bdrv_set_on_error(BlockDriverState *bs, BlockErrorAction on_read_error,
163 163
                       BlockErrorAction on_write_error);
164 164
BlockErrorAction bdrv_get_on_error(BlockDriverState *bs, int is_read);
165
void bdrv_set_removable(BlockDriverState *bs, int removable);
165 166
int bdrv_is_removable(BlockDriverState *bs);
166 167
int bdrv_is_read_only(BlockDriverState *bs);
167 168
int bdrv_is_sg(BlockDriverState *bs);
b/hw/fdc.c
1847 1847
static void fdctrl_connect_drives(FDCtrl *fdctrl)
1848 1848
{
1849 1849
    unsigned int i;
1850
    FDrive *drive;
1850 1851

  
1851 1852
    for (i = 0; i < MAX_FD; i++) {
1852
        fd_init(&fdctrl->drives[i]);
1853
        fd_revalidate(&fdctrl->drives[i]);
1853
        drive = &fdctrl->drives[i];
1854

  
1855
        fd_init(drive);
1856
        fd_revalidate(drive);
1857
        if (drive->bs) {
1858
            bdrv_set_removable(drive->bs, 1);
1859
        }
1854 1860
    }
1855 1861
}
1856 1862

  
b/hw/ide/core.c
2629 2629
        pstrcpy(s->version, sizeof(s->version), QEMU_VERSION);
2630 2630
    }
2631 2631
    ide_reset(s);
2632
    bdrv_set_removable(bs, s->is_cdrom);
2632 2633
}
2633 2634

  
2634 2635
static void ide_init1(IDEBus *bus, int unit)
b/hw/scsi-disk.c
1049 1049
static int scsi_disk_initfn(SCSIDevice *dev)
1050 1050
{
1051 1051
    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
1052
    int is_cd;
1052 1053
    DriveInfo *dinfo;
1053 1054

  
1054 1055
    if (!s->qdev.conf.bs) {
......
1056 1057
        return -1;
1057 1058
    }
1058 1059
    s->bs = s->qdev.conf.bs;
1060
    is_cd = bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM;
1059 1061

  
1060 1062
    if (!s->serial) {
1061 1063
        /* try to fall back to value set with legacy -drive serial=... */
......
1072 1074
        return -1;
1073 1075
    }
1074 1076

  
1075
    if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) {
1077
    if (is_cd) {
1076 1078
        s->qdev.blocksize = 2048;
1077 1079
    } else {
1078 1080
        s->qdev.blocksize = s->qdev.conf.logical_block_size;
......
1081 1083

  
1082 1084
    s->qdev.type = TYPE_DISK;
1083 1085
    qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);
1086
    bdrv_set_removable(s->bs, is_cd);
1084 1087
    return 0;
1085 1088
}
1086 1089

  
b/hw/scsi-generic.c
509 509
    DPRINTF("block size %d\n", s->qdev.blocksize);
510 510
    s->driver_status = 0;
511 511
    memset(s->sensebuf, 0, sizeof(s->sensebuf));
512
    bdrv_set_removable(s->bs, 0);
512 513
    return 0;
513 514
}
514 515

  
b/hw/virtio-blk.c
500 500
    qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s);
501 501
    register_savevm("virtio-blk", virtio_blk_id++, 2,
502 502
                    virtio_blk_save, virtio_blk_load, s);
503
    bdrv_set_removable(s->bs, 0);
503 504

  
504 505
    return &s->vdev;
505 506
}

Also available in: Unified diff