Revision 9c5a8433cee3f03ecd67de0046c41ed9b01d1993 authored by Eric Blake on 11 June 2018, 21:39:26 UTC, committed by Michael Roth on 21 June 2018, 01:45:07 UTC
Commit a290f085 exposed a latent bug in qemu-img map introduced
during the conversion of block status to be byte-based.  Earlier in
commit 5e344dd8, the internal interface get_block_status() switched
to take byte-based parameters, but still called a sector-based
block layer function; as such, rounding was added in the lone
caller to obey the contract.  However, commit 237d78f8 changed
get_block_status() to truly be byte-based, at which point rounding
to sector boundaries can result in calling bdrv_block_status() with
'bytes == 0' (a coding error) when the boundary between data and a
hole falls mid-sector (true for the past-EOF implicit hole present
in POSIX files).  Fix things by removing the rounding that is now
no longer necessary.

See also https://bugzilla.redhat.com/1589738

Fixes: 237d78f8
Reported-by: Dan Kenigsberg <danken@redhat.com>
Reported-by: Nir Soffer <nsoffer@redhat.com>
Reported-by: Maor Lipchuk <mlipchuk@redhat.com>
CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit e0b371ed5e2db079051139136fd0478728b6a58f)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
1 parent d8a919f
Raw File
replication.c
/*
 * Replication filter
 *
 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
 * Copyright (c) 2016 Intel Corporation
 * Copyright (c) 2016 FUJITSU LIMITED
 *
 * Author:
 *   Changlong Xie <xiecl.fnst@cn.fujitsu.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 */

#include "qemu/osdep.h"
#include "qapi/error.h"
#include "replication.h"

static QLIST_HEAD(, ReplicationState) replication_states;

ReplicationState *replication_new(void *opaque, ReplicationOps *ops)
{
    ReplicationState *rs;

    assert(ops != NULL);
    rs = g_new0(ReplicationState, 1);
    rs->opaque = opaque;
    rs->ops = ops;
    QLIST_INSERT_HEAD(&replication_states, rs, node);

    return rs;
}

void replication_remove(ReplicationState *rs)
{
    if (rs) {
        QLIST_REMOVE(rs, node);
        g_free(rs);
    }
}

/*
 * The caller of the function MUST make sure vm stopped
 */
void replication_start_all(ReplicationMode mode, Error **errp)
{
    ReplicationState *rs, *next;
    Error *local_err = NULL;

    QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
        if (rs->ops && rs->ops->start) {
            rs->ops->start(rs, mode, &local_err);
        }
        if (local_err) {
            error_propagate(errp, local_err);
            return;
        }
    }
}

void replication_do_checkpoint_all(Error **errp)
{
    ReplicationState *rs, *next;
    Error *local_err = NULL;

    QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
        if (rs->ops && rs->ops->checkpoint) {
            rs->ops->checkpoint(rs, &local_err);
        }
        if (local_err) {
            error_propagate(errp, local_err);
            return;
        }
    }
}

void replication_get_error_all(Error **errp)
{
    ReplicationState *rs, *next;
    Error *local_err = NULL;

    QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
        if (rs->ops && rs->ops->get_error) {
            rs->ops->get_error(rs, &local_err);
        }
        if (local_err) {
            error_propagate(errp, local_err);
            return;
        }
    }
}

void replication_stop_all(bool failover, Error **errp)
{
    ReplicationState *rs, *next;
    Error *local_err = NULL;

    QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
        if (rs->ops && rs->ops->stop) {
            rs->ops->stop(rs, failover, &local_err);
        }
        if (local_err) {
            error_propagate(errp, local_err);
            return;
        }
    }
}
back to top