diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-06-23 12:55:22 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-06-23 12:55:22 +0100 |
commit | d9c1647d896d3192cba9dbf98fb7efab876edde5 (patch) | |
tree | a18d31b5578e0267be6ed052c6ab5096f1d127d0 /hw | |
parent | 910f66fcda2d410249697d959dcbdf8c82d77844 (diff) | |
parent | 2bd3bce8efebe86b031beab5c0e3b9bbaec0b502 (diff) | |
download | hqemu-d9c1647d896d3192cba9dbf98fb7efab876edde5.zip hqemu-d9c1647d896d3192cba9dbf98fb7efab876edde5.tar.gz |
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Block pull request
# gpg: Signature made Mon 23 Jun 2014 09:53:49 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>"
* remotes/stefanha/tags/block-pull-request:
block: asynchronously stop the VM on I/O errors
vl: allow other threads to do qemu_system_vmstop_request
sheepdog: fix NULL dereference in sd_create
QemuOpts: check NULL opts in qemu_opt_get functions
block: m25p80: Support read only bdrvs.
block: m25p80: sync_page(): Deindent function body.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/block/m25p80.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 4076114..5893773 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -288,18 +288,20 @@ static void bdrv_sync_complete(void *opaque, int ret) static void flash_sync_page(Flash *s, int page) { - if (s->bdrv) { - int bdrv_sector, nb_sectors; - QEMUIOVector iov; - - bdrv_sector = (page * s->pi->page_size) / BDRV_SECTOR_SIZE; - nb_sectors = DIV_ROUND_UP(s->pi->page_size, BDRV_SECTOR_SIZE); - qemu_iovec_init(&iov, 1); - qemu_iovec_add(&iov, s->storage + bdrv_sector * BDRV_SECTOR_SIZE, - nb_sectors * BDRV_SECTOR_SIZE); - bdrv_aio_writev(s->bdrv, bdrv_sector, &iov, nb_sectors, - bdrv_sync_complete, NULL); + int bdrv_sector, nb_sectors; + QEMUIOVector iov; + + if (!s->bdrv || bdrv_is_read_only(s->bdrv)) { + return; } + + bdrv_sector = (page * s->pi->page_size) / BDRV_SECTOR_SIZE; + nb_sectors = DIV_ROUND_UP(s->pi->page_size, BDRV_SECTOR_SIZE); + qemu_iovec_init(&iov, 1); + qemu_iovec_add(&iov, s->storage + bdrv_sector * BDRV_SECTOR_SIZE, + nb_sectors * BDRV_SECTOR_SIZE); + bdrv_aio_writev(s->bdrv, bdrv_sector, &iov, nb_sectors, bdrv_sync_complete, + NULL); } static inline void flash_sync_area(Flash *s, int64_t off, int64_t len) @@ -307,7 +309,7 @@ static inline void flash_sync_area(Flash *s, int64_t off, int64_t len) int64_t start, end, nb_sectors; QEMUIOVector iov; - if (!s->bdrv) { + if (!s->bdrv || bdrv_is_read_only(s->bdrv)) { return; } @@ -625,10 +627,6 @@ static int m25p80_init(SSISlave *ss) if (dinfo && dinfo->bdrv) { DB_PRINT_L(0, "Binding to IF_MTD drive\n"); s->bdrv = dinfo->bdrv; - if (bdrv_is_read_only(s->bdrv)) { - fprintf(stderr, "Can't use a read-only drive"); - return 1; - } /* FIXME: Move to late init */ if (bdrv_read(s->bdrv, 0, s->storage, DIV_ROUND_UP(s->size, |