Make it build with QEMU 2.0, too
Also begin to work on rpms
父節點
0c43ff9daf
當前提交
3be7bc29d8
|
@ -293,7 +293,7 @@ Vitastor with single-thread NBD on the same hardware:
|
|||
- Install node.js 12 or newer.
|
||||
- Install gcc and g++ 9.x or later.
|
||||
- Clone https://yourcmc.ru/git/vitalif/vitastor/ with submodules.
|
||||
- Install QEMU 4.x or 5.x, get its source, begin to build it, stop the build and copy headers:
|
||||
- Install QEMU 2.0+, get its source, begin to build it, stop the build and copy headers:
|
||||
- `<qemu>/include` → `<vitastor>/qemu/include`
|
||||
- Debian:
|
||||
* Use qemu packages from the main repository
|
||||
|
@ -303,9 +303,10 @@ Vitastor with single-thread NBD on the same hardware:
|
|||
* Use qemu packages from the Advanced-Virtualization repository. To enable it, run
|
||||
`yum install centos-release-advanced-virtualization.noarch` and then `yum install qemu`
|
||||
* `<qemu>/config-host.h` → `<vitastor>/qemu/b/qemu/config-host.h`
|
||||
* `<qemu>/qapi` → `<vitastor>/qemu/b/qemu/qapi`
|
||||
* For QEMU 3.0+: `<qemu>/qapi` → `<vitastor>/qemu/b/qemu/qapi`
|
||||
* For QEMU 2.0+: `<qemu>/qapi-types.h` → `<vitastor>/qemu/b/qemu/qapi-types.h`
|
||||
- `config-host.h` and `qapi` are required because they contain generated headers
|
||||
- Install fio 3.16 or later, get its source and symlink it into `<vitastor>/fio`.
|
||||
- Install fio 3.7 or later, get its source and symlink it into `<vitastor>/fio`.
|
||||
- Build Vitastor with `make -j8`.
|
||||
- Copy binaries somewhere.
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
#include "epoll_manager.h"
|
||||
#include "cluster_client.h"
|
||||
|
||||
#ifndef MSG_ZEROCOPY
|
||||
#define MSG_ZEROCOPY 0
|
||||
#endif
|
||||
|
||||
const char *exe_name = NULL;
|
||||
|
||||
class nbd_proxy
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
#define BUILD_DSO
|
||||
#define _GNU_SOURCE
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/units.h"
|
||||
#include "block/block_int.h"
|
||||
#include "block/qdict.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qmp/qdict.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
|
@ -16,7 +14,17 @@
|
|||
#include "qemu/error-report.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/option.h"
|
||||
|
||||
#if QEMU_VERSION_MAJOR >= 3
|
||||
#include "qemu/units.h"
|
||||
#include "block/qdict.h"
|
||||
#include "qemu/cutils.h"
|
||||
#else
|
||||
#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_str(options, name, value) qdict_put_obj(options, name, QOBJECT(qstring_from_str(value)))
|
||||
#define qobject_unref QDECREF
|
||||
#endif
|
||||
|
||||
#include "qemu_proxy.h"
|
||||
|
||||
|
@ -185,12 +193,14 @@ static void vitastor_close(BlockDriverState *bs)
|
|||
g_free(client->etcd_prefix);
|
||||
}
|
||||
|
||||
#if QEMU_VERSION_MAJOR >= 3
|
||||
static int vitastor_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
|
||||
{
|
||||
bsz->phys = 4096;
|
||||
bsz->log = 4096;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int coroutine_fn vitastor_co_create_opts(
|
||||
#if QEMU_VERSION_MAJOR >= 4
|
||||
|
@ -217,6 +227,7 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
#if QEMU_VERSION_MAJOR >= 3
|
||||
static int coroutine_fn vitastor_co_truncate(BlockDriverState *bs, int64_t offset,
|
||||
#if QEMU_VERSION_MAJOR >= 4
|
||||
bool exact,
|
||||
|
@ -240,6 +251,7 @@ static int coroutine_fn vitastor_co_truncate(BlockDriverState *bs, int64_t offse
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int vitastor_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
|
||||
{
|
||||
|
@ -253,11 +265,22 @@ static int64_t vitastor_getlength(BlockDriverState *bs)
|
|||
return client->size;
|
||||
}
|
||||
|
||||
#if QEMU_VERSION_MAJOR >= 3
|
||||
static void vitastor_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
#else
|
||||
static int vitastor_refresh_limits(BlockDriverState *bs)
|
||||
#endif
|
||||
{
|
||||
#if QEMU_VERSION_MAJOR >= 4
|
||||
bs->bl.request_alignment = 4096;
|
||||
bs->bl.min_mem_alignment = 4096;
|
||||
#else
|
||||
bs->request_alignment = 4096;
|
||||
#endif
|
||||
bs->bl.opt_mem_alignment = 4096;
|
||||
#if QEMU_VERSION_MAJOR < 3
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int64_t vitastor_get_allocated_file_size(BlockDriverState *bs)
|
||||
|
@ -280,7 +303,12 @@ static void vitastor_co_generic_bh_cb(int retval, void *opaque)
|
|||
task->complete = 1;
|
||||
if (qemu_coroutine_self() != task->co)
|
||||
{
|
||||
#if QEMU_VERSION_MAJOR >= 3
|
||||
aio_co_wake(task->co);
|
||||
#else
|
||||
qemu_coroutine_enter(task->co, NULL);
|
||||
qemu_aio_release(task);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,6 +350,18 @@ static int coroutine_fn vitastor_co_pwritev(BlockDriverState *bs, uint64_t offse
|
|||
return task.ret;
|
||||
}
|
||||
|
||||
#if QEMU_VERSION_MAJOR < 3
|
||||
static int coroutine_fn vitastor_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov)
|
||||
{
|
||||
return vitastor_co_preadv(bs, sector_num*BDRV_SECTOR_SIZE, nb_sectors*BDRV_SECTOR_SIZE, iov, 0);
|
||||
}
|
||||
|
||||
static int coroutine_fn vitastor_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov)
|
||||
{
|
||||
return vitastor_co_pwritev(bs, sector_num*BDRV_SECTOR_SIZE, nb_sectors*BDRV_SECTOR_SIZE, iov, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int coroutine_fn vitastor_co_flush(BlockDriverState *bs)
|
||||
{
|
||||
VitastorClient *client = bs->opaque;
|
||||
|
@ -340,6 +380,7 @@ static int coroutine_fn vitastor_co_flush(BlockDriverState *bs)
|
|||
return task.ret;
|
||||
}
|
||||
|
||||
#if QEMU_VERSION_MAJOR >= 3
|
||||
static QemuOptsList vitastor_create_opts = {
|
||||
.name = "vitastor-create-opts",
|
||||
.head = QTAILQ_HEAD_INITIALIZER(vitastor_create_opts.head),
|
||||
|
@ -352,6 +393,16 @@ static QemuOptsList vitastor_create_opts = {
|
|||
{ /* end of list */ }
|
||||
}
|
||||
};
|
||||
#else
|
||||
static QEMUOptionParameter vitastor_create_opts[] = {
|
||||
{
|
||||
.name = BLOCK_OPT_SIZE,
|
||||
.type = OPT_SIZE,
|
||||
.help = "Virtual disk size"
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
#endif
|
||||
|
||||
static const char *vitastor_strong_runtime_opts[] = {
|
||||
"inode",
|
||||
|
@ -372,7 +423,9 @@ static BlockDriver bdrv_vitastor = {
|
|||
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
||||
.bdrv_get_info = vitastor_get_info,
|
||||
.bdrv_getlength = vitastor_getlength,
|
||||
#if QEMU_VERSION_MAJOR >= 3
|
||||
.bdrv_probe_blocksizes = vitastor_probe_blocksizes,
|
||||
#endif
|
||||
.bdrv_refresh_limits = vitastor_refresh_limits,
|
||||
|
||||
// FIXME: Implement it along with per-inode statistics
|
||||
|
@ -382,12 +435,17 @@ static BlockDriver bdrv_vitastor = {
|
|||
.bdrv_close = vitastor_close,
|
||||
|
||||
// Option list for the create operation
|
||||
#if QEMU_VERSION_MAJOR >= 3
|
||||
.create_opts = &vitastor_create_opts,
|
||||
#else
|
||||
.create_options = vitastor_create_opts,
|
||||
#endif
|
||||
|
||||
// For qmp_blockdev_create(), used by the qemu monitor / QAPI
|
||||
// Requires patching QAPI IDL, thus unimplemented
|
||||
//.bdrv_co_create = vitastor_co_create,
|
||||
|
||||
#if QEMU_VERSION_MAJOR >= 3
|
||||
// For bdrv_create(), used by qemu-img
|
||||
.bdrv_co_create_opts = vitastor_co_create_opts,
|
||||
|
||||
|
@ -395,6 +453,11 @@ static BlockDriver bdrv_vitastor = {
|
|||
|
||||
.bdrv_co_preadv = vitastor_co_preadv,
|
||||
.bdrv_co_pwritev = vitastor_co_pwritev,
|
||||
#else
|
||||
.bdrv_co_readv = vitastor_co_readv,
|
||||
.bdrv_co_writev = vitastor_co_writev,
|
||||
#endif
|
||||
|
||||
.bdrv_co_flush_to_disk = vitastor_co_flush,
|
||||
|
||||
#if QEMU_VERSION_MAJOR >= 4
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Cheatsheet for CentOS 7 packaging (not a build script)
|
||||
|
||||
set -e
|
||||
rm -f /etc/yum.repos.d/CentOS-Media.repo
|
||||
yum -y --enablerepo=extras install centos-release-scl epel-release
|
||||
yum -y --enablerepo='*' install devtoolset-9-gcc-c++ devtoolset-9-libatomic-devel gperftools-devel
|
||||
yumdownloader --source qemu
|
||||
yumdownloader --source fio
|
||||
yum-builddep -y --enablerepo='*' qemu
|
||||
yum -y install rpm-build
|
||||
. /opt/rh/devtoolset-9/enable
|
||||
rpm --nomd5 -i qemu*.src.rpm
|
||||
rpm --nomd5 -i fio*.src.rpm
|
||||
cd ~/rpmbuild/SPECS
|
||||
rpmbuild -bp fio.spec
|
||||
perl -i -pe 's/^make V=1/exit 1; make V=1/' qemu.spec
|
||||
rpmbuild -bc qemu.spec
|
||||
perl -i -pe 's/^exit 1; make V=1/make V=1/' qemu.spec
|
||||
cd ~/rpmbuild/BUILD/qemu*/
|
||||
make qapi-types.h
|
||||
mkdir -p ~/vitastor/qemu/b/qemu
|
||||
cp config-host.h ~/vitastor/qemu/b/qemu
|
||||
cp qapi-types.h ~/vitastor/qemu/b/qemu
|
||||
cp -r include ~/vitastor/qemu
|
||||
cd ~/vitastor
|
||||
sh copy-qemu-includes.sh
|
||||
mv qemu qemu-old
|
||||
mv qemu-copy qemu
|
||||
ln -s ~/rpmbuild/BUILD/fio*/ fio
|
||||
sh copy-fio-includes.sh
|
||||
rm fio
|
||||
mv fio-copy fio
|
Loading…
Reference in New Issue