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
check-qlit.c
/*
* QLit unit-tests.
*
* Copyright (C) 2017 Red Hat Inc.
*
* 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/qmp/qbool.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qlit.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
static QLitObject qlit = QLIT_QDICT(((QLitDictEntry[]) {
{ "foo", QLIT_QNUM(42) },
{ "bar", QLIT_QSTR("hello world") },
{ "baz", QLIT_QNULL },
{ "bee", QLIT_QLIST(((QLitObject[]) {
QLIT_QNUM(43),
QLIT_QNUM(44),
QLIT_QBOOL(true),
{ },
}))},
{ },
}));
static QLitObject qlit_foo = QLIT_QDICT(((QLitDictEntry[]) {
{ "foo", QLIT_QNUM(42) },
{ },
}));
static QObject *make_qobject(void)
{
QDict *qdict = qdict_new();
QList *list = qlist_new();
qdict_put_int(qdict, "foo", 42);
qdict_put_str(qdict, "bar", "hello world");
qdict_put_null(qdict, "baz");
qlist_append_int(list, 43);
qlist_append_int(list, 44);
qlist_append_bool(list, true);
qdict_put(qdict, "bee", list);
return QOBJECT(qdict);
}
static void qlit_equal_qobject_test(void)
{
QObject *qobj = make_qobject();
g_assert(qlit_equal_qobject(&qlit, qobj));
g_assert(!qlit_equal_qobject(&qlit_foo, qobj));
qdict_put(qobject_to_qdict(qobj), "bee", qlist_new());
g_assert(!qlit_equal_qobject(&qlit, qobj));
qobject_decref(qobj);
}
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
g_test_add_func("/qlit/equal_qobject", qlit_equal_qobject_test);
return g_test_run();
}
Computing file changes ...