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

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging



Block layer patches:

- iotests: Fix output of qemu-io related tests
- Don't ignore bdrv_set_aio_context() for nodes with bs->drv = NUL
- vmdk: Set vmdk parent backing_format to vmdk
- qcow2: Preallocation fixes (especially for external data files)
- Add linear-buffer-based APIs (as wrappers around qiov-based ones)
- Various code cleanups and small corner case fixes

# gpg: Signature made Tue 30 Apr 2019 16:35:09 BST
# gpg:                using RSA key 7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* remotes/kevin/tags/for-upstream: (27 commits)
  block/qed: add missed coroutine_fn markers
  iotests: Check that images are in read-only mode after block-commit
  commit: Make base read-only if there is an early failure
  qemu-img: use buffer-based io
  block/stream: use buffer-based io
  block/commit: use buffer-based io
  block/backup: use buffer-based io
  block/parallels: use buffer-based io
  block/qed: use buffer-based io
  block/qcow: use buffer-based io
  block/qcow2: use buffer-based io
  block: introduce byte-based io helpers
  qcow2: Fix error handling in the compression code
  qcow2: Fix qcow2_make_empty() with external data file
  qemu-img: Make create hint at protocol options
  iotests: Perform the correct test in 082
  qcow2: Fix full preallocation with external data file
  qcow2: Add errp to preallocate_co()
  qcow2: Avoid COW during metadata preallocation
  qemu-img: Saner printing of large file sizes
  ...

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents c4bfdd59 54277a2a
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -5672,10 +5672,6 @@ void bdrv_detach_aio_context(BlockDriverState *bs)
    BdrvAioNotifier *baf, *baf_tmp;
    BdrvChild *child;

    if (!bs->drv) {
        return;
    }

    assert(!bs->walking_aio_notifiers);
    bs->walking_aio_notifiers = true;
    QLIST_FOREACH_SAFE(baf, &bs->aio_notifiers, list, baf_tmp) {
@@ -5690,7 +5686,7 @@ void bdrv_detach_aio_context(BlockDriverState *bs)
     */
    bs->walking_aio_notifiers = false;

    if (bs->drv->bdrv_detach_aio_context) {
    if (bs->drv && bs->drv->bdrv_detach_aio_context) {
        bs->drv->bdrv_detach_aio_context(bs);
    }
    QLIST_FOREACH(child, &bs->children, next) {
@@ -5709,10 +5705,6 @@ void bdrv_attach_aio_context(BlockDriverState *bs,
    BdrvAioNotifier *ban, *ban_tmp;
    BdrvChild *child;

    if (!bs->drv) {
        return;
    }

    if (bs->quiesce_counter) {
        aio_disable_external(new_context);
    }
@@ -5722,7 +5714,7 @@ void bdrv_attach_aio_context(BlockDriverState *bs,
    QLIST_FOREACH(child, &bs->children, next) {
        bdrv_attach_aio_context(child->bs, new_context);
    }
    if (bs->drv->bdrv_attach_aio_context) {
    if (bs->drv && bs->drv->bdrv_attach_aio_context) {
        bs->drv->bdrv_attach_aio_context(bs, new_context);
    }

+6 −8
Original line number Diff line number Diff line
@@ -107,7 +107,6 @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,
                                                      void **bounce_buffer)
{
    int ret;
    QEMUIOVector qiov;
    BlockBackend *blk = job->common.blk;
    int nbytes;
    int read_flags = is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0;
@@ -118,9 +117,8 @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,
    if (!*bounce_buffer) {
        *bounce_buffer = blk_blockalign(blk, job->cluster_size);
    }
    qemu_iovec_init_buf(&qiov, *bounce_buffer, nbytes);

    ret = blk_co_preadv(blk, start, qiov.size, &qiov, read_flags);
    ret = blk_co_pread(blk, start, nbytes, *bounce_buffer, read_flags);
    if (ret < 0) {
        trace_backup_do_cow_read_fail(job, start, ret);
        if (error_is_read) {
@@ -129,12 +127,12 @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,
        goto fail;
    }

    if (qemu_iovec_is_zero(&qiov)) {
    if (buffer_is_zero(*bounce_buffer, nbytes)) {
        ret = blk_co_pwrite_zeroes(job->target, start,
                                   qiov.size, write_flags | BDRV_REQ_MAY_UNMAP);
                                   nbytes, write_flags | BDRV_REQ_MAY_UNMAP);
    } else {
        ret = blk_co_pwritev(job->target, start,
                             qiov.size, &qiov, write_flags |
        ret = blk_co_pwrite(job->target, start,
                            nbytes, *bounce_buffer, write_flags |
                            (job->compress ? BDRV_REQ_WRITE_COMPRESSED : 0));
    }
    if (ret < 0) {
+5 −3
Original line number Diff line number Diff line
@@ -48,16 +48,15 @@ static int coroutine_fn commit_populate(BlockBackend *bs, BlockBackend *base,
                                        void *buf)
{
    int ret = 0;
    QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);

    assert(bytes < SIZE_MAX);

    ret = blk_co_preadv(bs, offset, qiov.size, &qiov, 0);
    ret = blk_co_pread(bs, offset, bytes, buf, 0);
    if (ret < 0) {
        return ret;
    }

    ret = blk_co_pwritev(base, offset, qiov.size, &qiov, 0);
    ret = blk_co_pwrite(base, offset, bytes, buf, 0);
    if (ret < 0) {
        return ret;
    }
@@ -384,6 +383,9 @@ fail:
    if (s->top) {
        blk_unref(s->top);
    }
    if (s->base_read_only) {
        bdrv_reopen_set_read_only(base, true, NULL);
    }
    job_early_fail(&s->common.job);
    /* commit_top_bs has to be replaced after deleting the block job,
     * otherwise this would fail because of lack of permissions. */
+6 −8
Original line number Diff line number Diff line
@@ -220,20 +220,18 @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num,
    if (bs->backing) {
        int64_t nb_cow_sectors = to_allocate * s->tracks;
        int64_t nb_cow_bytes = nb_cow_sectors << BDRV_SECTOR_BITS;
        QEMUIOVector qiov =
            QEMU_IOVEC_INIT_BUF(qiov, qemu_blockalign(bs, nb_cow_bytes),
                                nb_cow_bytes);
        void *buf = qemu_blockalign(bs, nb_cow_bytes);

        ret = bdrv_co_preadv(bs->backing, idx * s->tracks * BDRV_SECTOR_SIZE,
                             nb_cow_bytes, &qiov, 0);
        ret = bdrv_co_pread(bs->backing, idx * s->tracks * BDRV_SECTOR_SIZE,
                            nb_cow_bytes, buf, 0);
        if (ret < 0) {
            qemu_vfree(qemu_iovec_buf(&qiov));
            qemu_vfree(buf);
            return ret;
        }

        ret = bdrv_co_pwritev(bs->file, s->data_end * BDRV_SECTOR_SIZE,
                              nb_cow_bytes, &qiov, 0);
        qemu_vfree(qemu_iovec_buf(&qiov));
                              nb_cow_bytes, buf, 0);
        qemu_vfree(buf);
        if (ret < 0) {
            return ret;
        }
+11 −38
Original line number Diff line number Diff line
@@ -631,42 +631,13 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
    return head;
}

#define NB_SUFFIXES 4

static char *get_human_readable_size(char *buf, int buf_size, int64_t size)
{
    static const char suffixes[NB_SUFFIXES] = {'K', 'M', 'G', 'T'};
    int64_t base;
    int i;

    if (size <= 999) {
        snprintf(buf, buf_size, "%" PRId64, size);
    } else {
        base = 1024;
        for (i = 0; i < NB_SUFFIXES; i++) {
            if (size < (10 * base)) {
                snprintf(buf, buf_size, "%0.1f%c",
                         (double)size / base,
                         suffixes[i]);
                break;
            } else if (size < (1000 * base) || i == (NB_SUFFIXES - 1)) {
                snprintf(buf, buf_size, "%" PRId64 "%c",
                         ((size + (base >> 1)) / base),
                         suffixes[i]);
                break;
            }
            base = base * 1024;
        }
    }
    return buf;
}

void bdrv_snapshot_dump(QEMUSnapshotInfo *sn)
{
    char buf1[128], date_buf[128], clock_buf[128];
    char date_buf[128], clock_buf[128];
    struct tm tm;
    time_t ti;
    int64_t secs;
    char *sizing = NULL;

    if (!sn) {
        qemu_printf("%-10s%-20s%7s%20s%15s",
@@ -683,13 +654,14 @@ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn)
                 (int)((secs / 60) % 60),
                 (int)(secs % 60),
                 (int)((sn->vm_clock_nsec / 1000000) % 1000));
        sizing = size_to_str(sn->vm_state_size);
        qemu_printf("%-10s%-20s%7s%20s%15s",
                    sn->id_str, sn->name,
                    get_human_readable_size(buf1, sizeof(buf1),
                                            sn->vm_state_size),
                    sizing,
                    date_buf,
                    clock_buf);
    }
    g_free(sizing);
}

static void dump_qdict(int indentation, QDict *dict);
@@ -787,14 +759,13 @@ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec)

void bdrv_image_info_dump(ImageInfo *info)
{
    char size_buf[128], dsize_buf[128];
    char *size_buf, *dsize_buf;
    if (!info->has_actual_size) {
        snprintf(dsize_buf, sizeof(dsize_buf), "unavailable");
        dsize_buf = g_strdup("unavailable");
    } else {
        get_human_readable_size(dsize_buf, sizeof(dsize_buf),
                                info->actual_size);
        dsize_buf = size_to_str(info->actual_size);
    }
    get_human_readable_size(size_buf, sizeof(size_buf), info->virtual_size);
    size_buf = size_to_str(info->virtual_size);
    qemu_printf("image: %s\n"
                "file format: %s\n"
                "virtual size: %s (%" PRId64 " bytes)\n"
@@ -802,6 +773,8 @@ void bdrv_image_info_dump(ImageInfo *info)
                info->filename, info->format, size_buf,
                info->virtual_size,
                dsize_buf);
    g_free(size_buf);
    g_free(dsize_buf);

    if (info->has_encrypted && info->encrypted) {
        qemu_printf("encrypted: yes\n");
Loading