From 92362027a87bfe68bbd7c7873c775e0f1c6815b5 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Mon, 29 Nov 2021 01:40:59 +0300 Subject: [PATCH] Build vitastor driver as part of the QEMU package by default Old behaviour can be restored with cmake var WITH_QEMU=true --- debian/control | 8 +-- debian/patched-qemu.Dockerfile | 14 +++- debian/vitastor-qemu.install | 1 - patches/qemu-6.1-vitastor.patch | 120 +++++++++++++++++++++++++++++--- src/CMakeLists.txt | 3 +- src/qemu_driver.c | 4 ++ 6 files changed, 129 insertions(+), 21 deletions(-) delete mode 100644 debian/vitastor-qemu.install diff --git a/debian/control b/debian/control index 8216e123..136f192f 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,7 @@ Rules-Requires-Root: no Package: vitastor Architecture: amd64 -Depends: vitastor-osd, vitastor-mon, vitastor-client, vitastor-client-dev, vitastor-fio, vitastor-qemu +Depends: vitastor-osd, vitastor-mon, vitastor-client, vitastor-client-dev, vitastor-fio Description: Vitastor, a fast software-defined clustered block storage Vitastor is a small, simple and fast clustered block storage (storage for VM drives), architecturally similar to Ceph which means strong consistency, primary-replication, @@ -47,9 +47,3 @@ Architecture: amd64 Depends: ${shlibs:Depends}, ${misc:Depends}, vitastor-client (= ${binary:Version}), fio (= ${dep:fio}) Description: Vitastor, a fast software-defined clustered block storage - fio drivers Vitastor fio drivers for benchmarking. - -Package: vitastor-qemu -Architecture: amd64 -Depends: ${shlibs:Depends}, ${misc:Depends}, vitastor-client (= ${binary:Version}), qemu (= ${dep:qemu}) -Description: Vitastor, a fast software-defined clustered block storage - QEMU driver - Vitastor QEMU block device driver. diff --git a/debian/patched-qemu.Dockerfile b/debian/patched-qemu.Dockerfile index cfc9709f..0e66b921 100644 --- a/debian/patched-qemu.Dockerfile +++ b/debian/patched-qemu.Dockerfile @@ -27,8 +27,14 @@ RUN apt-get -y build-dep fio RUN apt-get --download-only source qemu RUN apt-get --download-only source fio -ADD patches/qemu-5.0-vitastor.patch patches/qemu-5.1-vitastor.patch patches/qemu-6.1-vitastor.patch /root/vitastor/patches/ +ADD patches/qemu-5.0-vitastor.patch patches/qemu-5.1-vitastor.patch patches/qemu-6.1-vitastor.patch src/qemu_driver.c /root/vitastor/patches/ RUN set -e; \ + apt-get install -y wget; \ + wget -q -O /etc/apt/trusted.gpg.d/vitastor.gpg https://vitastor.io/debian/pubkey.gpg; \ + (echo deb http://vitastor.io/debian bullseye main > /etc/apt/sources.list.d/vitastor.list); \ + (echo "APT::Install-Recommends false;" > /etc/apt/apt.conf) && \ + apt-get update; \ + apt-get install -y vitastor-client-dev quilt; \ mkdir -p /root/packages/qemu-$REL; \ rm -rf /root/packages/qemu-$REL/*; \ cd /root/packages/qemu-$REL; \ @@ -47,7 +53,11 @@ RUN set -e; \ echo qemu-5.1-vitastor.patch >> $P/series; \ fi; \ cd /root/packages/qemu-$REL/qemu-*/; \ + quilt push -a; \ + quilt add block/vitastor.c; \ + cp /root/vitastor/patches/qemu_driver.c block/vitastor.c; \ + quilt refresh; \ V=$(head -n1 debian/changelog | perl -pe 's/^.*\((.*?)(~bpo[\d\+]*)?\).*$/$1/')+vitastor1; \ - DEBFULLNAME="Vitaliy Filippov " dch -D $REL -v $V 'Plug Vitastor block driver'; \ + DEBEMAIL="Vitaliy Filippov " dch -D $REL -v $V 'Plug Vitastor block driver'; \ DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage --jobs=auto -sa; \ rm -rf /root/packages/qemu-$REL/qemu-*/ diff --git a/debian/vitastor-qemu.install b/debian/vitastor-qemu.install deleted file mode 100644 index f36972d6..00000000 --- a/debian/vitastor-qemu.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/*/qemu/* diff --git a/patches/qemu-6.1-vitastor.patch b/patches/qemu-6.1-vitastor.patch index ea528e45..61bafe52 100644 --- a/patches/qemu-6.1-vitastor.patch +++ b/patches/qemu-6.1-vitastor.patch @@ -74,15 +74,115 @@ Index: qemu-6.1+dfsg/qapi/block-core.json 'vmdk': 'BlockdevCreateOptionsVmdk', 'vpc': 'BlockdevCreateOptionsVpc' } } -Index: qemu-6.1+dfsg/scripts/modules/module_block.py +Index: qemu-6.1+dfsg/block/meson.build =================================================================== ---- qemu-6.1+dfsg.orig/scripts/modules/module_block.py -+++ qemu-6.1+dfsg/scripts/modules/module_block.py -@@ -86,6 +86,7 @@ if __name__ == '__main__': - output_file = sys.argv[1] - with open(output_file, 'w') as fheader: - print_top(fheader) -+ add_module(fheader, "vitastor", "vitastor", "vitastor") +--- qemu-6.1+dfsg.orig/block/meson.build ++++ qemu-6.1+dfsg/block/meson.build +@@ -78,6 +78,7 @@ foreach m : [ + [libnfs, 'nfs', files('nfs.c')], + [libssh, 'ssh', files('ssh.c')], + [rbd, 'rbd', files('rbd.c')], ++ [vitastor, 'vitastor', files('vitastor.c')], + ] + if m[0].found() + module_ss = ss.source_set() +Index: qemu-6.1+dfsg/configure +=================================================================== +--- qemu-6.1+dfsg.orig/configure ++++ qemu-6.1+dfsg/configure +@@ -375,6 +375,7 @@ trace_file="trace" + spice="$default_feature" + spice_protocol="auto" + rbd="auto" ++vitastor="auto" + smartcard="auto" + u2f="auto" + libusb="auto" +@@ -1292,6 +1293,10 @@ for opt do + ;; + --enable-rbd) rbd="enabled" + ;; ++ --disable-vitastor) vitastor="disabled" ++ ;; ++ --enable-vitastor) vitastor="enabled" ++ ;; + --disable-xfsctl) xfs="no" + ;; + --enable-xfsctl) xfs="yes" +@@ -1916,6 +1921,7 @@ disabled with --disable-FEATURE, default + spice spice + spice-protocol spice-protocol + rbd rados block device (rbd) ++ vitastor vitastor block device + libiscsi iscsi support + libnfs nfs support + smartcard smartcard support (libcacard) +@@ -5202,7 +5208,7 @@ if test "$skip_meson" = no; then + -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \ + -Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \ + -Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\ +- -Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse -Dlibxml2=$libxml2 \ ++ -Drbd=$rbd -Dvitastor=$vitastor -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse -Dlibxml2=$libxml2 \ + -Dlibdaxctl=$libdaxctl -Dlibpmem=$libpmem -Dlinux_io_uring=$linux_io_uring \ + -Dgnutls=$gnutls -Dnettle=$nettle -Dgcrypt=$gcrypt -Dauth_pam=$auth_pam \ + -Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \ +Index: qemu-6.1+dfsg/meson.build +=================================================================== +--- qemu-6.1+dfsg.orig/meson.build ++++ qemu-6.1+dfsg/meson.build +@@ -729,6 +729,26 @@ if not get_option('rbd').auto() or have_ + endif + endif - for filename in sys.argv[2:]: - if os.path.isfile(filename): ++vitastor = not_found ++if not get_option('vitastor').auto() or have_block ++ libvitastor_client = cc.find_library('vitastor_client', has_headers: ['vitastor_c.h'], ++ required: get_option('vitastor'), kwargs: static_kwargs) ++ if libvitastor_client.found() ++ if cc.links(''' ++ #include ++ int main(void) { ++ vitastor_c_create_qemu(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); ++ return 0; ++ }''', dependencies: libvitastor_client) ++ vitastor = declare_dependency(dependencies: libvitastor_client) ++ elif get_option('vitastor').enabled() ++ error('could not link libvitastor_client') ++ else ++ warning('could not link libvitastor_client, disabling') ++ endif ++ endif ++endif ++ + glusterfs = not_found + glusterfs_ftruncate_has_stat = false + glusterfs_iocb_has_stat = false +@@ -1264,6 +1284,7 @@ config_host_data.set('CONFIG_LIBNFS', li + config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found()) + config_host_data.set('CONFIG_LIBPMEM', libpmem.found()) + config_host_data.set('CONFIG_RBD', rbd.found()) ++config_host_data.set('CONFIG_VITASTOR', vitastor.found()) + config_host_data.set('CONFIG_SDL', sdl.found()) + config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found()) + config_host_data.set('CONFIG_SECCOMP', seccomp.found()) +@@ -3075,6 +3096,7 @@ summary_info += {'bpf support': libbpf.f + # TODO: add back protocol and server version + summary_info += {'spice support': config_host.has_key('CONFIG_SPICE')} + summary_info += {'rbd support': rbd.found()} ++summary_info += {'vitastor support': vitastor.found()} + summary_info += {'xfsctl support': config_host.has_key('CONFIG_XFS')} + summary_info += {'smartcard support': cacard.found()} + summary_info += {'U2F support': u2f.found()} +Index: qemu-6.1+dfsg/meson_options.txt +=================================================================== +--- qemu-6.1+dfsg.orig/meson_options.txt ++++ qemu-6.1+dfsg/meson_options.txt +@@ -102,6 +102,8 @@ option('lzo', type : 'feature', value : + description: 'lzo compression support') + option('rbd', type : 'feature', value : 'auto', + description: 'Ceph block device driver') ++option('vitastor', type : 'feature', value : 'auto', ++ description: 'Vitastor block device driver') + option('gtk', type : 'feature', value : 'auto', + description: 'GTK+ user interface') + option('sdl', type : 'feature', value : 'auto', diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 635e6259..8a790ff5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,7 +4,7 @@ project(vitastor) include(GNUInstallDirs) -set(WITH_QEMU true CACHE BOOL "Build QEMU driver") +set(WITH_QEMU false CACHE BOOL "Build QEMU driver inside Vitastor source tree") set(WITH_FIO true CACHE BOOL "Build FIO driver") set(QEMU_PLUGINDIR qemu CACHE STRING "QEMU plugin directory suffix (qemu-kvm on RHEL)") set(WITH_ASAN false CACHE BOOL "Build with AddressSanitizer") @@ -171,6 +171,7 @@ if (${WITH_QEMU}) add_library(qemu_vitastor SHARED qemu_driver.c ) + target_compile_options(qemu_vitastor PUBLIC -DVITASTOR_SOURCE_TREE) target_include_directories(qemu_vitastor PUBLIC ../qemu/b/qemu ../qemu/include diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 3989b9af..b94192f0 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -3,8 +3,10 @@ // QEMU block driver +#ifdef VITASTOR_SOURCE_TREE #define BUILD_DSO #define _GNU_SOURCE +#endif #include "qemu/osdep.h" #include "block/block_int.h" #include "qapi/error.h" @@ -32,6 +34,7 @@ #include "vitastor_c.h" +#ifdef VITASTOR_SOURCE_TREE void qemu_module_dummy(void) { } @@ -39,6 +42,7 @@ void qemu_module_dummy(void) void DSO_STAMP_FUN(void) { } +#endif typedef struct VitastorClient {