Revision 4f8a066b

b/blockdev.c
528 528
    if (media == MEDIA_CDROM) {
529 529
        /* CDROM is fine for any interface, don't check.  */
530 530
        ro = 1;
531
    } else if (ro == 1) {
532
        if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY &&
533
            type != IF_NONE && type != IF_PFLASH) {
534
            error_report("read-only not supported by this bus type");
535
            goto err;
536
        }
537 531
    }
538 532

  
539 533
    bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
b/hw/block/m25p80.c
624 624
    if (dinfo && dinfo->bdrv) {
625 625
        DB_PRINT_L(0, "Binding to IF_MTD drive\n");
626 626
        s->bdrv = dinfo->bdrv;
627
        if (bdrv_is_read_only(s->bdrv)) {
628
            fprintf(stderr, "Can't use a read-only drive");
629
            return 1;
630
        }
631

  
627 632
        /* FIXME: Move to late init */
628 633
        if (bdrv_read(s->bdrv, 0, s->storage, DIV_ROUND_UP(s->size,
629 634
                                                    BDRV_SECTOR_SIZE))) {
b/hw/block/xen_disk.c
830 830
        /* setup via qemu cmdline -> already setup for us */
831 831
        xen_be_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n");
832 832
        blkdev->bs = blkdev->dinfo->bdrv;
833
        if (bdrv_is_read_only(blkdev->bs) && !readonly) {
834
            xen_be_printf(&blkdev->xendev, 0, "Unexpected read-only drive");
835
            blkdev->bs = NULL;
836
            return -1;
837
        }
833 838
        /* blkdev->bs is not create by us, we get a reference
834 839
         * so we can bdrv_unref() unconditionally */
835 840
        bdrv_ref(blkdev->bs);
b/hw/sd/milkymist-memcard.c
255 255

  
256 256
    dinfo = drive_get_next(IF_SD);
257 257
    s->card = sd_init(dinfo ? dinfo->bdrv : NULL, false);
258
    if (s->card == NULL) {
259
        return -1;
260
    }
261

  
258 262
    s->enabled = dinfo ? bdrv_is_inserted(dinfo->bdrv) : 0;
259 263

  
260 264
    memory_region_init_io(&s->regs_region, OBJECT(s), &memcard_mmio_ops, s,
b/hw/sd/omap_mmc.c
593 593

  
594 594
    /* Instantiate the storage */
595 595
    s->card = sd_init(bd, false);
596
    if (s->card == NULL) {
597
        exit(1);
598
    }
596 599

  
597 600
    return s;
598 601
}
......
618 621

  
619 622
    /* Instantiate the storage */
620 623
    s->card = sd_init(bd, false);
624
    if (s->card == NULL) {
625
        exit(1);
626
    }
621 627

  
622 628
    s->cdet = qemu_allocate_irqs(omap_mmc_cover_cb, s, 1)[0];
623 629
    sd_set_cb(s->card, NULL, s->cdet);
b/hw/sd/pl181.c
491 491
    qdev_init_gpio_out(dev, s->cardstatus, 2);
492 492
    dinfo = drive_get_next(IF_SD);
493 493
    s->card = sd_init(dinfo ? dinfo->bdrv : NULL, false);
494
    if (s->card == NULL) {
495
        return -1;
496
    }
497

  
494 498
    return 0;
495 499
}
496 500

  
b/hw/sd/pxa2xx_mmci.c
539 539

  
540 540
    /* Instantiate the actual storage */
541 541
    s->card = sd_init(bd, false);
542
    if (s->card == NULL) {
543
        exit(1);
544
    }
542 545

  
543 546
    register_savevm(NULL, "pxa2xx_mmci", 0, 0,
544 547
                    pxa2xx_mmci_save, pxa2xx_mmci_load, s);
b/hw/sd/sd.c
494 494
{
495 495
    SDState *sd;
496 496

  
497
    if (bdrv_is_read_only(bs)) {
498
        fprintf(stderr, "sd_init: Cannot use read-only drive\n");
499
        return NULL;
500
    }
501

  
497 502
    sd = (SDState *) g_malloc0(sizeof(SDState));
498 503
    sd->buf = qemu_blockalign(bs, 512);
499 504
    sd->spi = is_spi;
b/hw/sd/sdhci.c
1166 1166

  
1167 1167
    di = drive_get_next(IF_SD);
1168 1168
    s->card = sd_init(di ? di->bdrv : NULL, false);
1169
    if (s->card == NULL) {
1170
        exit(1);
1171
    }
1169 1172
    s->eject_cb = qemu_allocate_irqs(sdhci_insert_eject_cb, s, 1)[0];
1170 1173
    s->ro_cb = qemu_allocate_irqs(sdhci_card_readonly_cb, s, 1)[0];
1171 1174
    sd_set_cb(s->card, s->ro_cb, s->eject_cb);
b/hw/sd/ssi-sd.c
246 246
    s->mode = SSI_SD_CMD;
247 247
    dinfo = drive_get_next(IF_SD);
248 248
    s->sd = sd_init(dinfo ? dinfo->bdrv : NULL, true);
249
    if (s->sd == NULL) {
250
        return -1;
251
    }
249 252
    register_savevm(&dev->qdev, "ssi_sd", -1, 1, ssi_sd_save, ssi_sd_load, s);
250 253
    return 0;
251 254
}
b/tests/qemu-iotests/051.out
139 139
(qemu) qququiquit
140 140

  
141 141
Testing: -drive file=TEST_DIR/t.qcow2,if=ide,readonly=on
142
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=ide,readonly=on: read-only not supported by this bus type
142
QEMU X.Y.Z monitor - type 'help' for more information
143
(qemu) QEMU_PROG: Can't use a read-only drive
144
QEMU_PROG: Device initialization failed.
145
QEMU_PROG: Initialization of device ide-hd failed
143 146

  
144 147
Testing: -drive file=TEST_DIR/t.qcow2,if=virtio,readonly=on
145 148
QEMU X.Y.Z monitor - type 'help' for more information

Also available in: Unified diff