Fix qemu_driver to build with QEMU 2.x (previously it was only correct for QEMU 2.0)
parent
404e07d365
commit
a1488f7217
|
@ -19,6 +19,10 @@
|
||||||
#include "qemu/units.h"
|
#include "qemu/units.h"
|
||||||
#include "block/qdict.h"
|
#include "block/qdict.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
|
#elif QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 10
|
||||||
|
#include "qemu/cutils.h"
|
||||||
|
#include "qapi/qmp/qstring.h"
|
||||||
|
#include "qapi/qmp/qjson.h"
|
||||||
#else
|
#else
|
||||||
#include "qapi/qmp/qint.h"
|
#include "qapi/qmp/qint.h"
|
||||||
#define qdict_put_int(options, name, num_val) qdict_put_obj(options, name, QOBJECT(qint_from_int(num_val)))
|
#define qdict_put_int(options, name, num_val) qdict_put_obj(options, name, QOBJECT(qint_from_int(num_val)))
|
||||||
|
@ -290,7 +294,7 @@ static void vitastor_close(BlockDriverState *bs)
|
||||||
g_free(client->image);
|
g_free(client->image);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QEMU_VERSION_MAJOR >= 3
|
#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 2
|
||||||
static int vitastor_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
|
static int vitastor_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
|
||||||
{
|
{
|
||||||
bsz->phys = 4096;
|
bsz->phys = 4096;
|
||||||
|
@ -299,6 +303,7 @@ static int vitastor_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if QEMU_VERSION_MAJOR >= 3
|
||||||
static int coroutine_fn vitastor_co_create_opts(
|
static int coroutine_fn vitastor_co_create_opts(
|
||||||
#if QEMU_VERSION_MAJOR >= 4
|
#if QEMU_VERSION_MAJOR >= 4
|
||||||
BlockDriver *drv,
|
BlockDriver *drv,
|
||||||
|
@ -323,6 +328,7 @@ out:
|
||||||
qobject_unref(options);
|
qobject_unref(options);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if QEMU_VERSION_MAJOR >= 3
|
#if QEMU_VERSION_MAJOR >= 3
|
||||||
static int coroutine_fn vitastor_co_truncate(BlockDriverState *bs, int64_t offset,
|
static int coroutine_fn vitastor_co_truncate(BlockDriverState *bs, int64_t offset,
|
||||||
|
@ -362,20 +368,18 @@ static int64_t vitastor_getlength(BlockDriverState *bs)
|
||||||
return client->size;
|
return client->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QEMU_VERSION_MAJOR >= 3
|
#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 0
|
||||||
static void vitastor_refresh_limits(BlockDriverState *bs, Error **errp)
|
static void vitastor_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||||
#else
|
#else
|
||||||
static int vitastor_refresh_limits(BlockDriverState *bs)
|
static int vitastor_refresh_limits(BlockDriverState *bs)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if QEMU_VERSION_MAJOR >= 4
|
|
||||||
bs->bl.request_alignment = 4096;
|
bs->bl.request_alignment = 4096;
|
||||||
|
#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 3
|
||||||
bs->bl.min_mem_alignment = 4096;
|
bs->bl.min_mem_alignment = 4096;
|
||||||
#else
|
|
||||||
bs->bl.request_alignment = 4096;
|
|
||||||
#endif
|
#endif
|
||||||
bs->bl.opt_mem_alignment = 4096;
|
bs->bl.opt_mem_alignment = 4096;
|
||||||
#if QEMU_VERSION_MAJOR < 3
|
#if QEMU_VERSION_MAJOR < 2 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR == 0
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -400,7 +404,7 @@ static void vitastor_co_generic_bh_cb(void *opaque, long retval)
|
||||||
task->complete = 1;
|
task->complete = 1;
|
||||||
if (qemu_coroutine_self() != task->co)
|
if (qemu_coroutine_self() != task->co)
|
||||||
{
|
{
|
||||||
#if QEMU_VERSION_MAJOR >= 3
|
#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 8
|
||||||
aio_co_wake(task->co);
|
aio_co_wake(task->co);
|
||||||
#else
|
#else
|
||||||
qemu_coroutine_enter(task->co, NULL);
|
qemu_coroutine_enter(task->co, NULL);
|
||||||
|
@ -484,7 +488,7 @@ static int coroutine_fn vitastor_co_flush(BlockDriverState *bs)
|
||||||
return task.ret;
|
return task.ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QEMU_VERSION_MAJOR >= 3
|
#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 0
|
||||||
static QemuOptsList vitastor_create_opts = {
|
static QemuOptsList vitastor_create_opts = {
|
||||||
.name = "vitastor-create-opts",
|
.name = "vitastor-create-opts",
|
||||||
.head = QTAILQ_HEAD_INITIALIZER(vitastor_create_opts.head),
|
.head = QTAILQ_HEAD_INITIALIZER(vitastor_create_opts.head),
|
||||||
|
@ -528,7 +532,7 @@ static BlockDriver bdrv_vitastor = {
|
||||||
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
||||||
.bdrv_get_info = vitastor_get_info,
|
.bdrv_get_info = vitastor_get_info,
|
||||||
.bdrv_getlength = vitastor_getlength,
|
.bdrv_getlength = vitastor_getlength,
|
||||||
#if QEMU_VERSION_MAJOR >= 3
|
#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 2
|
||||||
.bdrv_probe_blocksizes = vitastor_probe_blocksizes,
|
.bdrv_probe_blocksizes = vitastor_probe_blocksizes,
|
||||||
#endif
|
#endif
|
||||||
.bdrv_refresh_limits = vitastor_refresh_limits,
|
.bdrv_refresh_limits = vitastor_refresh_limits,
|
||||||
|
@ -540,7 +544,7 @@ static BlockDriver bdrv_vitastor = {
|
||||||
.bdrv_close = vitastor_close,
|
.bdrv_close = vitastor_close,
|
||||||
|
|
||||||
// Option list for the create operation
|
// Option list for the create operation
|
||||||
#if QEMU_VERSION_MAJOR >= 3
|
#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 0
|
||||||
.create_opts = &vitastor_create_opts,
|
.create_opts = &vitastor_create_opts,
|
||||||
#else
|
#else
|
||||||
.create_options = vitastor_create_opts,
|
.create_options = vitastor_create_opts,
|
||||||
|
|
Loading…
Reference in New Issue