Commit a77beb0f authored by Stefan Hajnoczi's avatar Stefan Hajnoczi
Browse files

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



Block layer patches for 2.8.0-rc0

# gpg: Signature made Fri 11 Nov 2016 03:46:12 PM GMT
# gpg:                using RSA key 0x7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* kwolf/tags/for-upstream:
  raw-posix: Rename 'raw_s' to 'rs'
  iotests: Always use -machine accel=qtest
  iotests: Skip test 162 if there is no SSH support
  block: Emit modules in bdrv_iterate_format()
  block: Fix bdrv_iterate_format() sorting
  nfs: Fix memory leak in nfs_file_create()
  qcow2: Remove stale FIXME comment
  raw_bsd: don't check size alignment when only offset is set
  raw_bsd: move check to prevent overflow
  hmp: Make block_stream set an explicit job ID
  block/ssh: Code cleanup for unused parameter
  block/nbd: Fix the leaked visitor

Message-id: 1478883311-24052-1-git-send-email-kwolf@redhat.com
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parents 736986fa ff569b94
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -2796,7 +2796,7 @@ const char *bdrv_get_format_name(BlockDriverState *bs)

static int qsort_strcmp(const void *a, const void *b)
{
    return strcmp(a, b);
    return strcmp(*(char *const *)a, *(char *const *)b);
}

void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
@@ -2822,6 +2822,24 @@ void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
        }
    }

    for (i = 0; i < (int)ARRAY_SIZE(block_driver_modules); i++) {
        const char *format_name = block_driver_modules[i].format_name;

        if (format_name) {
            bool found = false;
            int j = count;

            while (formats && j && !found) {
                found = !strcmp(formats[--j], format_name);
            }

            if (!found) {
                formats = g_renew(const char *, formats, count + 1);
                formats[count++] = format_name;
            }
        }
    }

    qsort(formats, count, sizeof(formats[0]), qsort_strcmp);

    for (i = 0; i < count; i++) {
+1 −0
Original line number Diff line number Diff line
@@ -536,6 +536,7 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)
    ov = qobject_output_visitor_new(&saddr_qdict);
    visit_type_SocketAddress(ov, NULL, &s->saddr, &error_abort);
    visit_complete(ov, &saddr_qdict);
    visit_free(ov);
    assert(qobject_type(saddr_qdict) == QTYPE_QDICT);

    qdict_put_obj(opts, "server", saddr_qdict);
+1 −0
Original line number Diff line number Diff line
@@ -676,6 +676,7 @@ static int nfs_file_create(const char *url, QemuOpts *opts, Error **errp)
    ret = nfs_ftruncate(client->context, client->fh, total_size);
    nfs_client_close(client);
out:
    QDECREF(options);
    g_free(client);
    return ret;
}
+0 −2
Original line number Diff line number Diff line
@@ -473,8 +473,6 @@ static inline uint64_t refcount_diff(uint64_t r1, uint64_t r2)
    return r1 > r2 ? r1 - r2 : r2 - r1;
}

// FIXME Need qcow2_ prefix to global functions

/* qcow2.c functions */
int qcow2_backing_read1(BlockDriverState *bs, QEMUIOVector *qiov,
                  int64_t sector_num, int nb_sectors);
+28 −28
Original line number Diff line number Diff line
@@ -542,7 +542,7 @@ static int raw_reopen_prepare(BDRVReopenState *state,
                              BlockReopenQueue *queue, Error **errp)
{
    BDRVRawState *s;
    BDRVRawReopenState *raw_s;
    BDRVRawReopenState *rs;
    int ret = 0;
    Error *local_err = NULL;

@@ -552,15 +552,15 @@ static int raw_reopen_prepare(BDRVReopenState *state,
    s = state->bs->opaque;

    state->opaque = g_new0(BDRVRawReopenState, 1);
    raw_s = state->opaque;
    rs = state->opaque;

    if (s->type == FTYPE_CD) {
        raw_s->open_flags |= O_NONBLOCK;
        rs->open_flags |= O_NONBLOCK;
    }

    raw_parse_flags(state->flags, &raw_s->open_flags);
    raw_parse_flags(state->flags, &rs->open_flags);

    raw_s->fd = -1;
    rs->fd = -1;

    int fcntl_flags = O_APPEND | O_NONBLOCK;
#ifdef O_NOATIME
@@ -569,35 +569,35 @@ static int raw_reopen_prepare(BDRVReopenState *state,

#ifdef O_ASYNC
    /* Not all operating systems have O_ASYNC, and those that don't
     * will not let us track the state into raw_s->open_flags (typically
     * will not let us track the state into rs->open_flags (typically
     * you achieve the same effect with an ioctl, for example I_SETSIG
     * on Solaris). But we do not use O_ASYNC, so that's fine.
     */
    assert((s->open_flags & O_ASYNC) == 0);
#endif

    if ((raw_s->open_flags & ~fcntl_flags) == (s->open_flags & ~fcntl_flags)) {
    if ((rs->open_flags & ~fcntl_flags) == (s->open_flags & ~fcntl_flags)) {
        /* dup the original fd */
        raw_s->fd = qemu_dup(s->fd);
        if (raw_s->fd >= 0) {
            ret = fcntl_setfl(raw_s->fd, raw_s->open_flags);
        rs->fd = qemu_dup(s->fd);
        if (rs->fd >= 0) {
            ret = fcntl_setfl(rs->fd, rs->open_flags);
            if (ret) {
                qemu_close(raw_s->fd);
                raw_s->fd = -1;
                qemu_close(rs->fd);
                rs->fd = -1;
            }
        }
    }

    /* If we cannot use fcntl, or fcntl failed, fall back to qemu_open() */
    if (raw_s->fd == -1) {
    if (rs->fd == -1) {
        const char *normalized_filename = state->bs->filename;
        ret = raw_normalize_devicepath(&normalized_filename);
        if (ret < 0) {
            error_setg_errno(errp, -ret, "Could not normalize device path");
        } else {
            assert(!(raw_s->open_flags & O_CREAT));
            raw_s->fd = qemu_open(normalized_filename, raw_s->open_flags);
            if (raw_s->fd == -1) {
            assert(!(rs->open_flags & O_CREAT));
            rs->fd = qemu_open(normalized_filename, rs->open_flags);
            if (rs->fd == -1) {
                error_setg_errno(errp, errno, "Could not reopen file");
                ret = -1;
            }
@@ -606,11 +606,11 @@ static int raw_reopen_prepare(BDRVReopenState *state,

    /* Fail already reopen_prepare() if we can't get a working O_DIRECT
     * alignment with the new fd. */
    if (raw_s->fd != -1) {
        raw_probe_alignment(state->bs, raw_s->fd, &local_err);
    if (rs->fd != -1) {
        raw_probe_alignment(state->bs, rs->fd, &local_err);
        if (local_err) {
            qemu_close(raw_s->fd);
            raw_s->fd = -1;
            qemu_close(rs->fd);
            rs->fd = -1;
            error_propagate(errp, local_err);
            ret = -EINVAL;
        }
@@ -621,13 +621,13 @@ static int raw_reopen_prepare(BDRVReopenState *state,

static void raw_reopen_commit(BDRVReopenState *state)
{
    BDRVRawReopenState *raw_s = state->opaque;
    BDRVRawReopenState *rs = state->opaque;
    BDRVRawState *s = state->bs->opaque;

    s->open_flags = raw_s->open_flags;
    s->open_flags = rs->open_flags;

    qemu_close(s->fd);
    s->fd = raw_s->fd;
    s->fd = rs->fd;

    g_free(state->opaque);
    state->opaque = NULL;
@@ -636,16 +636,16 @@ static void raw_reopen_commit(BDRVReopenState *state)

static void raw_reopen_abort(BDRVReopenState *state)
{
    BDRVRawReopenState *raw_s = state->opaque;
    BDRVRawReopenState *rs = state->opaque;

     /* nothing to do if NULL, we didn't get far enough */
    if (raw_s == NULL) {
    if (rs == NULL) {
        return;
    }

    if (raw_s->fd >= 0) {
        qemu_close(raw_s->fd);
        raw_s->fd = -1;
    if (rs->fd >= 0) {
        qemu_close(rs->fd);
        rs->fd = -1;
    }
    g_free(state->opaque);
    state->opaque = NULL;
Loading