Example #1
0
static void do_multiwrite(BlockDriverState *bs, BlockRequest *blkreq,
    int num_writes)
{
    int i, ret;
    ret = bdrv_aio_multiwrite(bs, blkreq, num_writes);

    if (ret != 0) {
        for (i = 0; i < num_writes; i++) {
            if (blkreq[i].error) {
                virtio_blk_rw_complete(blkreq[i].opaque, -EIO);
            }
        }
    }
}
Example #2
0
static int do_aio_multiwrite(BlockRequest* reqs, int num_reqs, int *total)
{
    int i, ret;
    struct multiwrite_async_ret async_ret = {
        .num_done = 0,
        .error = 0,
    };

    *total = 0;
    for (i = 0; i < num_reqs; i++) {
        reqs[i].cb = multiwrite_cb;
        reqs[i].opaque = &async_ret;
        *total += reqs[i].qiov->size;
    }

    ret = bdrv_aio_multiwrite(bs, reqs, num_reqs);
    if (ret < 0) {
        return ret;
    }

    while (async_ret.num_done < num_reqs) {
        qemu_aio_wait();
    }

    return async_ret.error < 0 ? async_ret.error : 1;
}

static void
read_help(void)
{
    printf(
        "\n"
        " reads a range of bytes from the given offset\n"
        "\n"
        " Example:\n"
        " 'read -v 512 1k' - dumps 1 kilobyte read from 512 bytes into the file\n"
        "\n"
        " Reads a segment of the currently open file, optionally dumping it to the\n"
        " standard output stream (with -v option) for subsequent inspection.\n"
        " -b, -- read from the VM state rather than the virtual disk\n"
        " -C, -- report statistics in a machine parsable format\n"
        " -l, -- length for pattern verification (only with -P)\n"
        " -p, -- use bdrv_pread to read the file\n"
        " -P, -- use a pattern to verify read data\n"
        " -q, -- quite mode, do not show I/O statistics\n"
        " -s, -- start offset for pattern verification (only with -P)\n"
        " -v, -- dump buffer to standard output\n"
        "\n");
}
Example #3
0
static void virtio_submit_multiwrite(BlockDriverState *bs, MultiReqBuffer *mrb)
{
    int i, ret;

    if (!mrb->num_writes) {
        return;
    }

    ret = bdrv_aio_multiwrite(bs, mrb->blkreq, mrb->num_writes);
    if (ret != 0) {
        for (i = 0; i < mrb->num_writes; i++) {
            if (mrb->blkreq[i].error) {
                virtio_blk_rw_complete(mrb->blkreq[i].opaque, -EIO);
            }
        }
    }

    mrb->num_writes = 0;
}