--- qemu-kvm-6.2.spec.orig	2023-07-18 13:52:57.636625440 +0000
+++ qemu-kvm-6.2.spec	2023-07-18 13:52:19.011683886 +0000
@@ -73,6 +73,7 @@ Requires: %{name}-hw-usbredir = %{epoch}
 %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
@@ -83,7 +84,7 @@ Obsoletes: %1-rhev <= %{epoch}:%{version
 Summary: QEMU is a machine emulator and virtualizer
 Name: qemu-kvm
 Version: 6.2.0
-Release: 32%{?rcrel}%{?dist}
+Release: 32.vitastor%{?rcrel}%{?dist}
 # 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
@@ -122,6 +123,7 @@ Source37: tests_data_acpi_pc_SSDT.dimmpx
 Source38: tests_data_acpi_q35_FACP.slic
 Source39: tests_data_acpi_q35_SSDT.dimmpxm
 Source40: tests_data_acpi_virt_SSDT.memhp
+Source41: qemu-vitastor.c
 
 Patch0001: 0001-redhat-Adding-slirp-to-the-exploded-tree.patch
 Patch0005: 0005-Initial-redhat-build.patch
@@ -652,6 +654,7 @@ Patch255: kvm-scsi-protect-req-aiocb-wit
 Patch256: kvm-dma-helpers-prevent-dma_blk_cb-vs-dma_aio_cancel-rac.patch
 # For bz#2090990 - qemu crash with error scsi_req_unref(SCSIRequest *): Assertion `req->refcount > 0' failed or scsi_dma_complete(void *, int): Assertion `r->req.aiocb != NULL' failed [8.7.0]
 Patch257: kvm-virtio-scsi-reset-SCSI-devices-from-main-loop-thread.patch
+Patch258: qemu-6.2-vitastor.patch
 
 BuildRequires: wget
 BuildRequires: rpm-build
@@ -689,6 +692,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
@@ -926,6 +930,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}
@@ -979,6 +991,7 @@ This package provides usbredir support.
 rm -fr slirp
 mkdir slirp
 %autopatch -p1
+cp %{SOURCE41} ./block/vitastor.c
 
 %global qemu_kvm_build qemu_kvm_build
 mkdir -p %{qemu_kvm_build}
@@ -994,7 +1007,7 @@ cp -f %{SOURCE40} tests/data/acpi/virt/S
 # --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
@@ -1149,9 +1162,7 @@ pushd %{qemu_kvm_build}
   --firmwarepath=%{_prefix}/share/qemu-firmware \
   --meson="git" \
   --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 \
   --with-git=git \
   --tls-priority=@QEMU,SYSTEM \
@@ -1197,6 +1208,7 @@ pushd %{qemu_kvm_build}
 %endif
   --enable-pie \
   --enable-rbd \
+  --enable-vitastor \
 %if 0%{have_librdma}
   --enable-rdma \
 %endif
@@ -1794,6 +1806,9 @@ sh %{_sysconfdir}/sysconfig/modules/kvm.
 %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
 
