--- qemu-kvm.spec.orig	2021-12-01 22:10:58.967935539 +0000
+++ qemu-kvm.spec	2021-12-01 22:14:38.530117175 +0000
@@ -57,6 +57,7 @@ Requires: %{name}-block-gluster = %{epoc
 %endif                                                           \
 Requires: %{name}-block-iscsi = %{epoch}:%{version}-%{release}   \
 Requires: %{name}-block-rbd = %{epoch}:%{version}-%{release}     \
+Requires: %{name}-block-vitastor = %{epoch}:%{version}-%{release}\
 Requires: %{name}-block-ssh = %{epoch}:%{version}-%{release}
 
 # Macro to properly setup RHEL/RHEV conflict handling
@@ -67,7 +68,7 @@ Obsoletes: %1-rhev
 Summary: QEMU is a machine emulator and virtualizer
 Name: qemu-kvm
 Version: 4.2.0
-Release: 29%{?dist}.6
+Release: 33.vitastor%{?dist}.6
 # Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped
 Epoch: 15
 License: GPLv2 and GPLv2+ and CC-BY
@@ -102,6 +103,7 @@ Source33: qemu-pr-helper.socket
 Source34: 81-kvm-rhel.rules
 Source35: udev-kvm-check.c
 Source36: README.tests
+Source37: qemu-vitastor.c
 
 
 Patch0005: 0005-Initial-redhat-build.patch
@@ -825,6 +827,7 @@ Patch331: kvm-Drop-bogus-IPv6-messages.p
 Patch333: kvm-virtiofsd-Whitelist-fchmod.patch
 # For bz#1883869 - virtiofsd core dump in KATA Container [rhel-8.2.1.z]
 Patch334: kvm-virtiofsd-avoid-proc-self-fd-tempdir.patch
+Patch335: qemu-4.2-vitastor.patch
 
 BuildRequires: wget
 BuildRequires: rpm-build
@@ -861,6 +864,7 @@ BuildRequires: libcurl-devel
 BuildRequires: libssh-devel
 BuildRequires: librados-devel
 BuildRequires: librbd-devel
+BuildRequires: vitastor-client-devel
 %if %{have_gluster}
 # For gluster block driver
 BuildRequires: glusterfs-api-devel
@@ -1095,6 +1099,14 @@ Install this package if you want to acce
 using the rbd protocol.
 
 
+%package  block-vitastor
+Summary: QEMU Vitastor block driver
+Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release}
+
+%description block-vitastor
+This package provides the additional Vitastor block driver for QEMU.
+
+
 %package  block-ssh
 Summary: QEMU SSH block driver
 Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release}
@@ -1109,6 +1121,7 @@ the Secure Shell (SSH) protocol.
 %prep
 %setup -n qemu-%{version}
 %autopatch -p1
+cp %{SOURCE37} ./block/vitastor.c
 
 %build
 %global buildarch %{kvm_target}-softmmu
@@ -1116,7 +1129,7 @@ the Secure Shell (SSH) protocol.
 # --build-id option is used for giving info to the debug packages.
 buildldflags="VL_LDFLAGS=-Wl,--build-id"
 
-%global block_drivers_list qcow2,raw,file,host_device,nbd,iscsi,rbd,blkdebug,luks,null-co,nvme,copy-on-read,throttle
+%global block_drivers_list qcow2,raw,file,host_device,nbd,iscsi,rbd,vitastor,blkdebug,luks,null-co,nvme,copy-on-read,throttle
 
 %if 0%{have_gluster}
     %global block_drivers_list %{block_drivers_list},gluster
@@ -1131,7 +1144,7 @@ buildldflags="VL_LDFLAGS=-Wl,--build-id"
  --docdir="%{qemudocdir}" \
  --libexecdir="%{_libexecdir}" \
  --extra-ldflags="-Wl,--build-id -Wl,-z,relro -Wl,-z,now" \
- --extra-cflags="%{optflags}" \
+ --extra-cflags="%{optflags} -DRHEL_BDRV_CO_TRUNCATE_FLAGS" \
  --with-pkgversion="%{name}-%{version}-%{release}" \
  --with-confsuffix=/"%{name}" \
  --firmwarepath=%{_prefix}/share/qemu-firmware \
@@ -1152,6 +1165,7 @@ buildldflags="VL_LDFLAGS=-Wl,--build-id"
   --disable-numa \
 %endif
   --enable-rbd \
+  --enable-vitastor \
 %if 0%{have_librdma}
   --enable-rdma \
 %else
@@ -1192,9 +1206,7 @@ buildldflags="VL_LDFLAGS=-Wl,--build-id"
 %endif
   --python=%{__python3} \
   --target-list="%{buildarch}" \
-  --block-drv-rw-whitelist=%{block_drivers_list} \
   --audio-drv-list= \
-  --block-drv-ro-whitelist=vmdk,vhdx,vpc,https,ssh \
   --with-coroutine=ucontext \
   --tls-priority=NORMAL \
   --disable-bluez \
@@ -1750,6 +1762,9 @@ useradd -r -u 107 -g qemu -G kvm -d / -s
 %files block-rbd
 %{_libdir}/qemu-kvm/block-rbd.so
 
+%files block-vitastor
+%{_libdir}/qemu-kvm/block-vitastor.so
+
 %files block-ssh
 %{_libdir}/qemu-kvm/block-ssh.so
 
