Commit d9c1647d authored by Peter Maydell's avatar Peter Maydell
Browse files

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: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 910f66fc 2bd3bce8
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -3626,10 +3626,27 @@ void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action,
                       bool is_read, int error)
{
    assert(error >= 0);
    bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read);

    if (action == BDRV_ACTION_STOP) {
        vm_stop(RUN_STATE_IO_ERROR);
        /* First set the iostatus, so that "info block" returns an iostatus
         * that matches the events raised so far (an additional error iostatus
         * is fine, but not a lost one).
         */
        bdrv_iostatus_set_err(bs, error);

        /* Then raise the request to stop the VM and the event.
         * qemu_system_vmstop_request_prepare has two effects.  First,
         * it ensures that the STOP event always comes after the
         * BLOCK_IO_ERROR event.  Second, it ensures that even if management
         * can observe the STOP event and do a "cont" before the STOP
         * event is issued, the VM will not stop.  In this case, vm_start()
         * also ensures that the STOP/RESUME pair of events is emitted.
         */
        qemu_system_vmstop_request_prepare();
        bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read);
        qemu_system_vmstop_request(RUN_STATE_IO_ERROR);
    } else {
        bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read);
    }
}

+1 −0
Original line number Diff line number Diff line
@@ -1756,6 +1756,7 @@ static int sd_create(const char *filename, QemuOpts *opts,
        bdrv_unref(bs);
    }

    s->aio_context = qemu_get_aio_context();
    ret = do_sd_create(s, &vid, 0, errp);
    if (ret) {
        goto out;
+1 −0
Original line number Diff line number Diff line
@@ -1206,6 +1206,7 @@ void cpu_stop_current(void)
int vm_stop(RunState state)
{
    if (qemu_in_vcpu_thread()) {
        qemu_system_vmstop_request_prepare();
        qemu_system_vmstop_request(state);
        /*
         * FIXME: should not return to device code in case
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ Data:
- "action": action that has been taken, it's one of the following (json-string):
    "ignore": error has been ignored
    "report": error has been reported to the device
    "stop": error caused VM to be stopped
    "stop": the VM is going to stop because of the error

Example:

+14 −16
Original line number Diff line number Diff line
@@ -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;

    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);
    }
    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,
Loading