Compare commits
195 Commits
v6.2.0-11-
...
v9.0.2-5
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f55fd376da | ||
![]() |
9b31b9a603 | ||
![]() |
3f36e3b77c | ||
![]() |
d1386d3f15 | ||
![]() |
4bc8223ac9 | ||
![]() |
fd53092e9b | ||
![]() |
7446610389 | ||
![]() |
903a63402e | ||
![]() |
441072fc57 | ||
![]() |
582fd47901 | ||
![]() |
356bc2483a | ||
![]() |
9efd9cea96 | ||
![]() |
4154eea6e6 | ||
![]() |
cf40e92996 | ||
![]() |
14afbdd55f | ||
![]() |
54d1666680 | ||
![]() |
49125e1708 | ||
![]() |
b242e7f196 | ||
![]() |
c2abb73df7 | ||
![]() |
5bdf1bebba | ||
![]() |
99c80e7492 | ||
![]() |
9664f5a132 | ||
![]() |
b37841aa1a | ||
![]() |
822c99f3c3 | ||
![]() |
51df4937bf | ||
![]() |
bb80c7f323 | ||
![]() |
c1cd6a6221 | ||
![]() |
16b7dfe03b | ||
![]() |
f06b222ece | ||
![]() |
db293008ee | ||
![]() |
51232e2e40 | ||
![]() |
e62423e615 | ||
![]() |
c93a5bfd4f | ||
![]() |
2cd560e0d2 | ||
![]() |
4fbd50e2f9 | ||
![]() |
766c61f1b6 | ||
![]() |
c19617bf9b | ||
![]() |
f1eed34ac7 | ||
![]() |
2e71c17f5b | ||
![]() |
f76e07f370 | ||
![]() |
71dd2d48f9 | ||
![]() |
59ab88deb6 | ||
![]() |
20209d8d73 | ||
![]() |
47bdd04244 | ||
![]() |
8dd76cc52d | ||
![]() |
cd7676f3e6 | ||
![]() |
862b46e3e0 | ||
![]() |
061e9ceb36 | ||
![]() |
0d4462207b | ||
![]() |
ed159bc32a | ||
![]() |
86460aef76 | ||
![]() |
676adda3c6 | ||
![]() |
4ff04bdfa5 | ||
![]() |
12b69ed9c5 | ||
![]() |
5e8903f875 | ||
![]() |
4b7975e75d | ||
![]() |
f366bb97ae | ||
![]() |
2a49e667ba | ||
![]() |
c6eb05a799 | ||
![]() |
dfac4f3593 | ||
![]() |
6b7c1815e1 | ||
![]() |
24d732ac0f | ||
![]() |
df2cc786ee | ||
![]() |
38726d3473 | ||
![]() |
89b46e17ec | ||
![]() |
33b22c3fe0 | ||
![]() |
c38e337f5d | ||
![]() |
763949965f | ||
![]() |
1807330a6f | ||
![]() |
a31ab74058 | ||
![]() |
b39f726f31 | ||
![]() |
a36bda146c | ||
![]() |
03ff63aa61 | ||
![]() |
10e1093325 | ||
![]() |
0d9c737d61 | ||
![]() |
a6ddea7ef7 | ||
![]() |
89520c1cd0 | ||
![]() |
eca4daeeed | ||
![]() |
816077299c | ||
![]() |
ef3308db71 | ||
![]() |
0ff45eb23e | ||
![]() |
6c5563e30b | ||
![]() |
9e0186f289 | ||
![]() |
0cffb504e7 | ||
![]() |
f7eed6caa1 | ||
![]() |
0cff91a000 | ||
![]() |
6cadf3677d | ||
![]() |
5f9cb29c3a | ||
![]() |
c36e3f9d17 | ||
![]() |
b8b4ce0480 | ||
![]() |
df47146afe | ||
![]() |
d9cbfafeeb | ||
![]() |
5919ec1446 | ||
![]() |
409db0cd7b | ||
![]() |
ea7662074d | ||
![]() |
d847446186 | ||
![]() |
3aaa855e5c | ||
![]() |
99f9ce2cd2 | ||
![]() |
a816d2969e | ||
![]() |
0e9a7bfda2 | ||
![]() |
a39364b9d1 | ||
![]() |
0f693c2cab | ||
![]() |
88b1550dfb | ||
![]() |
bd3c1fa525 | ||
![]() |
de2dde2da9 | ||
![]() |
04e0262e2e | ||
![]() |
d3c2ae9683 | ||
![]() |
d0603efa38 | ||
![]() |
db5d2a4b77 | ||
![]() |
b64c4dec1c | ||
![]() |
53b56ca781 | ||
![]() |
bf251437e9 | ||
![]() |
fb818ea5b9 | ||
![]() |
3c995a426d | ||
![]() |
be7ce325c7 | ||
![]() |
19b4b4c50f | ||
![]() |
590adba81a | ||
![]() |
abb04bb627 | ||
![]() |
6facdf3a08 | ||
![]() |
cb2b3190a4 | ||
![]() |
2e416ad9d5 | ||
![]() |
d80ca49db8 | ||
![]() |
d65b507d3f | ||
![]() |
98fd8612cb | ||
![]() |
4f56d29218 | ||
![]() |
cd148033f3 | ||
![]() |
92c6d84f6a | ||
![]() |
b8af8dd4fa | ||
![]() |
6eb3e31968 | ||
![]() |
c913853be7 | ||
![]() |
4fc4b533b5 | ||
![]() |
023b916380 | ||
![]() |
19a11f24a5 | ||
![]() |
030fa1db4b | ||
![]() |
2d17b4b4d9 | ||
![]() |
280d157f1c | ||
![]() |
f6be0ca51a | ||
![]() |
93d558c1ee | ||
![]() |
e752bbe5e2 | ||
![]() |
018ef788b3 | ||
![]() |
72fc94c0c6 | ||
![]() |
09186f4b6e | ||
![]() |
ffda59f626 | ||
![]() |
3c4f941ac7 | ||
![]() |
3a94e1a186 | ||
![]() |
67cae45f41 | ||
![]() |
58659169de | ||
![]() |
10691e04e9 | ||
![]() |
09723b9298 | ||
![]() |
00e2507aac | ||
![]() |
e7e5f63573 | ||
![]() |
1688b43738 | ||
![]() |
eee064d954 | ||
![]() |
8051a24b5f | ||
![]() |
ade9f50160 | ||
![]() |
0fde60fd10 | ||
![]() |
d82c5eb632 | ||
![]() |
d5f6ef56f0 | ||
![]() |
658cba46ee | ||
![]() |
a02081501a | ||
![]() |
baf4e3132d | ||
![]() |
48c307550a | ||
![]() |
89fdfe8975 | ||
![]() |
f64132208a | ||
![]() |
271ac0a8a7 | ||
![]() |
f4ed54ec37 | ||
![]() |
2277182712 | ||
![]() |
0906461df0 | ||
![]() |
29bee92c59 | ||
![]() |
82640bb859 | ||
![]() |
d03e1b3ce3 | ||
![]() |
55e33a045e | ||
![]() |
8a38e1da9e | ||
![]() |
3b3d5516ee | ||
![]() |
509409fb64 | ||
![]() |
bf03cd367f | ||
![]() |
0af826b448 | ||
![]() |
ed23707ed7 | ||
![]() |
4e1935c2c9 | ||
![]() |
a262e9642b | ||
![]() |
73912aee39 | ||
![]() |
5b15e2ecaf | ||
![]() |
2775b2e378 | ||
![]() |
ed01236593 | ||
![]() |
2b259b70ec | ||
![]() |
a186335be5 | ||
![]() |
1976ca4607 | ||
![]() |
563c592898 | ||
![]() |
1de53d8a45 | ||
![]() |
0e88ec19db | ||
![]() |
9ee866b2e9 | ||
![]() |
14ed554660 | ||
![]() |
eba403aafc | ||
![]() |
b2685aee04 | ||
![]() |
dc9827a6a4 |
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/*.build
|
||||
/*.buildinfo
|
||||
/*.changes
|
||||
/*.deb
|
||||
/*.dsc
|
||||
/*.tar*
|
||||
/pve-qemu-kvm-*.*/
|
82
Makefile
82
Makefile
@@ -1,60 +1,90 @@
|
||||
include /usr/share/dpkg/pkg-info.mk
|
||||
include /usr/share/dpkg/architecture.mk
|
||||
include /usr/share/dpkg/default.mk
|
||||
|
||||
PACKAGE = pve-qemu-kvm
|
||||
|
||||
SRCDIR := qemu
|
||||
BUILDDIR ?= ${PACKAGE}-${DEB_VERSION_UPSTREAM}
|
||||
BUILDDIR ?= $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
|
||||
ORIG_SRC_TAR=$(PACKAGE)_$(DEB_VERSION_UPSTREAM).orig.tar.gz
|
||||
|
||||
GITVERSION := $(shell git rev-parse HEAD)
|
||||
|
||||
DEB = ${PACKAGE}_${DEB_VERSION_UPSTREAM_REVISION}_${DEB_BUILD_ARCH}.deb
|
||||
DEB_DBG = ${PACKAGE}-dbg_${DEB_VERSION_UPSTREAM_REVISION}_${DEB_BUILD_ARCH}.deb
|
||||
DSC=$(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION).dsc
|
||||
DEB = $(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION)_$(DEB_BUILD_ARCH).deb
|
||||
DEB_DBG = $(PACKAGE)-dbgsym_$(DEB_VERSION_UPSTREAM_REVISION)_$(DEB_BUILD_ARCH).deb
|
||||
DEBS = $(DEB) $(DEB_DBG)
|
||||
|
||||
all: $(DEBS)
|
||||
|
||||
.PHONY: submodule
|
||||
submodule:
|
||||
test -f "${SRCDIR}/configure" || git submodule update --init --recursive
|
||||
ifeq ($(shell test -f "$(SRCDIR)/configure" && echo 1 || echo 0), 0)
|
||||
git submodule update --init --recursive
|
||||
cd $(SRCDIR); meson subprojects download
|
||||
endif
|
||||
|
||||
$(BUILDDIR): keycodemapdb | submodule
|
||||
PC_BIOS_FW_PURGE_LIST_IN = \
|
||||
hppa-firmware.img \
|
||||
hppa-firmware64.img \
|
||||
openbios-ppc \
|
||||
openbios-sparc32 \
|
||||
openbios-sparc64 \
|
||||
palcode-clipper \
|
||||
s390-ccw.img \
|
||||
s390-netboot.img \
|
||||
u-boot.e500 \
|
||||
.*[a-zA-Z0-9]\.dtb \
|
||||
.*[a-zA-Z0-9]\.dts \
|
||||
qemu_vga.ndrv \
|
||||
slof.bin \
|
||||
opensbi-riscv.*-generic-fw_dynamic.bin \
|
||||
|
||||
BLOB_PURGE_SED_CMDS = $(foreach FILE,$(PC_BIOS_FW_PURGE_LIST_IN),-e "/$(FILE)/d")
|
||||
BLOB_PURGE_FILTER = $(foreach FILE,$(PC_BIOS_FW_PURGE_LIST_IN),-e "$(FILE)")
|
||||
|
||||
$(BUILDDIR): submodule
|
||||
# check if qemu/ was used for a build
|
||||
# if so, please run 'make distclean' in the submodule and try again
|
||||
test ! -f $(SRCDIR)/build/config.status
|
||||
rm -rf $(BUILDDIR)
|
||||
cp -a $(SRCDIR) $(BUILDDIR)
|
||||
cp -a debian $(BUILDDIR)/debian
|
||||
rm -rf $(BUILDDIR)/ui/keycodemapdb
|
||||
cp -a keycodemapdb $(BUILDDIR)/ui/
|
||||
echo "git clone git://git.proxmox.com/git/pve-qemu.git\\ngit checkout $(GITVERSION)" > $(BUILDDIR)/debian/SOURCE
|
||||
rm -rf $@.tmp $@
|
||||
cp -a $(SRCDIR) $@.tmp
|
||||
cp -a debian $@.tmp/debian
|
||||
rm -rf $@.tmp/roms/edk2 # packaged separately
|
||||
find $@.tmp/pc-bios -type f | grep $(BLOB_PURGE_FILTER) | xargs rm -f
|
||||
sed -i $(BLOB_PURGE_SED_CMDS) $@.tmp/pc-bios/meson.build
|
||||
echo "git clone git://git.proxmox.com/git/pve-qemu.git\\ngit checkout $(GITVERSION)" > $@.tmp/debian/SOURCE
|
||||
mv $@.tmp $@
|
||||
|
||||
.PHONY: deb kvm
|
||||
deb kvm: $(DEBS)
|
||||
$(DEB_DBG): $(DEB)
|
||||
$(DEB): $(BUILDDIR)
|
||||
cd $(BUILDDIR); dpkg-buildpackage -b -us -uc -j
|
||||
cd $(BUILDDIR); dpkg-buildpackage -b -us -uc
|
||||
lintian $(DEBS)
|
||||
|
||||
.PHONY: update
|
||||
update:
|
||||
cd $(SRCDIR) && git submodule deinit ui/keycodemapdb || true
|
||||
rm -rf $(SRCDIR)/ui/keycodemapdb
|
||||
mkdir $(SRCDIR)/ui/keycodemapdb
|
||||
cd $(SRCDIR) && git submodule update --init ui/keycodemapdb
|
||||
rm -rf keycodemapdb
|
||||
mkdir keycodemapdb
|
||||
cp -R $(SRCDIR)/ui/keycodemapdb/* keycodemapdb/
|
||||
git add keycodemapdb
|
||||
sbuild: $(DSC)
|
||||
sbuild $(DSC)
|
||||
|
||||
$(ORIG_SRC_TAR): $(BUILDDIR)
|
||||
tar czf $(ORIG_SRC_TAR) --exclude="$(BUILDDIR)/debian" $(BUILDDIR)
|
||||
|
||||
.PHONY: dsc
|
||||
dsc:
|
||||
rm -rf *.dsc $(BUILDDIR)
|
||||
$(MAKE) $(DSC)
|
||||
lintian $(DSC)
|
||||
|
||||
$(DSC): $(ORIG_SRC_TAR) $(BUILDDIR)
|
||||
cd $(BUILDDIR); dpkg-buildpackage -S -us -uc -d
|
||||
|
||||
.PHONY: upload
|
||||
upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
|
||||
upload: $(DEBS)
|
||||
tar cf - ${DEBS} | ssh repoman@repo.proxmox.com upload --product pve --dist bullseye
|
||||
tar cf - $(DEBS) | ssh repoman@repo.proxmox.com upload --product pve --dist $(UPLOAD_DIST)
|
||||
|
||||
.PHONY: distclean clean
|
||||
distclean: clean
|
||||
clean:
|
||||
rm -rf $(BUILDDIR) $(PACKAGE)*.deb *.buildinfo *.changes
|
||||
rm -rf $(PACKAGE)-[0-9]*/ $(PACKAGE)*.tar* *.deb *.dsc *.build *.buildinfo *.changes
|
||||
|
||||
.PHONY: dinstall
|
||||
dinstall: $(DEBS)
|
||||
|
442
debian/changelog
vendored
442
debian/changelog
vendored
@@ -1,8 +1,444 @@
|
||||
pve-qemu-kvm (6.2.0-11+vitastor1) bullseye; urgency=medium
|
||||
pve-qemu-kvm (9.0.2-5) bookworm; urgency=medium
|
||||
|
||||
* Add Vitastor support
|
||||
* async snapshot: explicitly specify raw format when loading the VM state
|
||||
file
|
||||
|
||||
-- Vitaliy Filippov <vitalif@yourcmc.ru> Thu, 14 Dec 2022 18:13:59 +0300
|
||||
* vma create: rework CLI parameters for passing disk to a more structured
|
||||
style and use that to allow explicitly specifying the format
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 24 Jan 2025 14:59:17 +0100
|
||||
|
||||
pve-qemu-kvm (9.0.2-4) bookworm; urgency=medium
|
||||
|
||||
* async snapshot: ensure any dynamic vCPU-throttling applied for
|
||||
auto-converge gets always disabled again after finishing the snapshot.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Sun, 10 Nov 2024 11:23:09 +0100
|
||||
|
||||
pve-qemu-kvm (9.0.2-3) bookworm; urgency=medium
|
||||
|
||||
* pick up fix for VirtIO PCI regressions
|
||||
|
||||
* pick up stable fixes for 9.0, including fixes for VirtIO-net, ARM and
|
||||
x86(_64) emulation, CVEs to harden NBD server against malicious clients,
|
||||
as well as a few others (VNC, physmem, Intel IOMMU, ...).
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 06 Sep 2024 16:21:42 +0200
|
||||
|
||||
pve-qemu-kvm (9.0.2-2) bookworm; urgency=medium
|
||||
|
||||
* actually update submodule to QEMU 9.0.2. The previous release was still
|
||||
based on 9.0.0 by mistake.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 07 Aug 2024 10:16:01 +0200
|
||||
|
||||
pve-qemu-kvm (9.0.2-1) bookworm; urgency=medium
|
||||
|
||||
* update submodule and patches to QEMU 9.0.2. While our version had most
|
||||
stable fixes included already, there are new fixes for VirtIO and VGA
|
||||
display screen blanking (#4786)
|
||||
|
||||
* backport fix for a regression with the LSI-53c895a controller and one for
|
||||
the boot order getting ignored for USB storage
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 29 Jul 2024 18:59:40 +0200
|
||||
|
||||
pve-qemu-kvm (9.0.0-6) bookworm; urgency=medium
|
||||
|
||||
* fix a regression in the zeroinit block driver that prevented importing and
|
||||
cloning disks to RBD storages which are not using the krbd setting
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 08 Jul 2024 16:11:15 +0200
|
||||
|
||||
pve-qemu-kvm (9.0.0-5) bookworm; urgency=medium
|
||||
|
||||
* backport fix for CVE-2024-4467 to prevent malicious qcow2 image files from
|
||||
already causing bad effects if being queried via 'qemu-img info'. For
|
||||
Proxmox VE, this is an additional safe guard, as currently it directly
|
||||
creates and manages the qcow2 images used by VMs and does not allow
|
||||
unprivileged users to import them
|
||||
|
||||
* fix #4726: code cleanup: avoid superfluous check in vma backup code
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 03 Jul 2024 13:13:35 +0200
|
||||
|
||||
pve-qemu-kvm (9.0.0-4) bookworm; urgency=medium
|
||||
|
||||
* fix crash after saving a snapshot without including VM state when a VirtIO
|
||||
block device with iothread is configured.
|
||||
|
||||
* fix edge case in error handling when opening a block device from PBS fails
|
||||
|
||||
* minor code cleanup in backup code
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 01 Jul 2024 11:26:11 +0200
|
||||
|
||||
pve-qemu-kvm (9.0.0-3) bookworm; urgency=medium
|
||||
|
||||
* fix crash when doing resize after hotplugging a disk using io_uring
|
||||
|
||||
* fix some minor issues in software CPU emulation (i.e. non-KVM) for ARM and
|
||||
x86(_64)
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 29 May 2024 15:55:44 +0200
|
||||
|
||||
pve-qemu-kvm (9.0.0-2) bookworm; urgency=medium
|
||||
|
||||
* fix #5409: backup: fix copy-before-write timeout
|
||||
|
||||
* backup: improve error when copy-before-write fails for fleecing
|
||||
|
||||
* fix forwards and backwards migration with VirtIO-GPU display
|
||||
|
||||
* fix a regression in pflash device introduced in 8.2
|
||||
|
||||
* revert a commit for VirtIO PCI devices that turned out to cause more
|
||||
potential security issues than what it fixed
|
||||
|
||||
* move compatibility flags for a new VirtIO-net feature to the correct
|
||||
machine type. The feature was introduced in QEMU 8.2, but the
|
||||
compatibility flags got added to machine version 8.0 instead of 8.1. This
|
||||
breaks backwards migration with machine version 8.1 from a 8.2/9.0 binary
|
||||
to an 8.1 binary, in cases where the guest kernel enables the feature
|
||||
(e.g. Ubuntu 23.10).
|
||||
While that breaks migration with machine version 8.1 from an unpatched to
|
||||
a patched binary, Proxmox VE only ever had 8.2 on the test repository and
|
||||
9.0 not yet in any public repository.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 17 May 2024 17:04:52 +0200
|
||||
|
||||
pve-qemu-kvm (8.1.5-6) bookworm; urgency=medium
|
||||
|
||||
* fix #5409: backup: fix copy-before-write timeout
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 29 Apr 2024 16:39:38 +0200
|
||||
|
||||
pve-qemu-kvm (9.0.0-1) bookworm; urgency=medium
|
||||
|
||||
* update submodule and patches to QEMU 9.0.0
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 29 Apr 2024 10:51:37 +0200
|
||||
|
||||
pve-qemu-kvm (8.2.2-1) bookworm; urgency=medium
|
||||
|
||||
* update submodule and patches to QEMU 8.2.2
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Sat, 27 Apr 2024 12:44:30 +0200
|
||||
|
||||
pve-qemu-kvm (8.1.5-5) bookworm; urgency=medium
|
||||
|
||||
* implement support for backup fleecing
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 11 Apr 2024 17:46:48 +0200
|
||||
|
||||
pve-qemu-kvm (8.1.5-4) bookworm; urgency=medium
|
||||
|
||||
* fix live-import for certain kinds of VMDK images that rely on padding
|
||||
|
||||
* backup: avoid bubbling up first error if it's an ECANCELED one, as those
|
||||
are often a result of cancling the job due to running into an actual
|
||||
issue.
|
||||
|
||||
* backup: factor out & clean up gathering device info into helper
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 12 Mar 2024 14:08:40 +0100
|
||||
|
||||
pve-qemu-kvm (8.1.5-3) bookworm; urgency=medium
|
||||
|
||||
* backport fix for potential deadlock during QMP stop command if the VM has
|
||||
disks attached through VirtIO-Block and IO-Thread enabled
|
||||
|
||||
* fix #4507: add patch to automatically increase NOFILE soft limit
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 21 Feb 2024 20:11:23 +0100
|
||||
|
||||
pve-qemu-kvm (8.1.5-2) bookworm; urgency=medium
|
||||
|
||||
* work around for a situation where guest IO might get stuck, if the VM is
|
||||
configure with iothread and VirtIO block/SCSI
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 02 Feb 2024 19:41:27 +0100
|
||||
|
||||
pve-qemu-kvm (8.1.5-1) bookworm; urgency=medium
|
||||
|
||||
* update to 8.1.5 stable release, including more relevant fixes like:
|
||||
- virtio-net: correctly copy vnet header when flushing TX
|
||||
- hw/pflash: implement update buffer for block writes
|
||||
- Fixes to i386 emulation and ARM emulation.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 02 Feb 2024 19:08:13 +0100
|
||||
|
||||
pve-qemu-kvm (8.1.2-6) bookworm; urgency=medium
|
||||
|
||||
* revert attempted fix to avoid rare issue with stuck guest IO when using
|
||||
iothread, because it caused a much more common issue with iothreads
|
||||
consuming too much CPU
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 15 Dec 2023 14:22:06 +0100
|
||||
|
||||
pve-qemu-kvm (8.1.2-5) bookworm; urgency=medium
|
||||
|
||||
* backport workaround for stuck guest IO with iothread and VirtIO block/SCSI
|
||||
in some rare edge cases
|
||||
|
||||
* backport fix for potential deadlock when issuing the "resize" QMP command
|
||||
for a disk that is using iothread
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 11 Dec 2023 16:58:27 +0100
|
||||
|
||||
pve-qemu-kvm (8.1.2-4) bookworm; urgency=medium
|
||||
|
||||
* fix vnc clipboard in the host to guest direction
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 22 Nov 2023 14:28:21 +0100
|
||||
|
||||
pve-qemu-kvm (8.1.2-3) bookworm; urgency=medium
|
||||
|
||||
* fix #5054: backport fix for software reset with SATA, avoiding breakage
|
||||
with, e.g., some FreeBSD VMs
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 20 Nov 2023 10:24:50 +0100
|
||||
|
||||
pve-qemu-kvm (8.1.2-2) bookworm; urgency=medium
|
||||
|
||||
* revert "x86: acpi: workaround Windows not handling name references in
|
||||
Package properly" as that seems to have broken networking (and possibly
|
||||
other things) one some localized variants of Windows (e.g., the German
|
||||
versions).
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 17 Nov 2023 11:55:23 +0100
|
||||
|
||||
pve-qemu-kvm (8.1.2-1) bookworm; urgency=medium
|
||||
|
||||
* update submodule and patches to QEMU 8.1.2
|
||||
|
||||
* use QEMU's keycode-map-db again instead of our static copy from QEMU 6.0
|
||||
|
||||
* disable graph locking, newly introduced in the 8.1 release, as it has
|
||||
still various deadlock issuess, e.g., during canceling backup jobs.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 24 Oct 2023 13:42:45 +0200
|
||||
|
||||
pve-qemu-kvm (8.0.2-7) bookworm; urgency=medium
|
||||
|
||||
* fix #2874: SATA: avoid unsolicited write to sector 0 during reset
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 04 Oct 2023 08:33:35 +0200
|
||||
|
||||
pve-qemu-kvm (8.0.2-6) bookworm; urgency=medium
|
||||
|
||||
* fix #1534: vma: add extract-filter for disk images allowing users to pass
|
||||
a comma separated list of the disks they want to extract from an archive.
|
||||
|
||||
* backup: create jobs in a drained section to avoid subtle bugs where
|
||||
something interferes with the block-copy-state bitmap on initialization
|
||||
|
||||
* backup: drop experimental, and since a while also fully broken, directory
|
||||
backup format (BACKUP_FORMAT_DIR). This format was never exposed via the
|
||||
Proxmox VE API, but only available via QMP, as its broken since QEMU 8 and
|
||||
we got zero reports about that, it's safe to assume that there are no
|
||||
public users, so just remove it completely.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 06 Sep 2023 17:03:59 +0200
|
||||
|
||||
pve-qemu-kvm (8.0.2-5) bookworm; urgency=medium
|
||||
|
||||
* improve memory footprint after backup by not keeping as much memory
|
||||
resident.
|
||||
|
||||
* fix file descriptor leak for vhost (used by default by vNICs).
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 16 Aug 2023 11:52:24 +0200
|
||||
|
||||
pve-qemu-kvm (8.0.2-4) bookworm; urgency=medium
|
||||
|
||||
* fix resume for snapshot and hibernate in combination with iothread and
|
||||
dirty bitmap
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 28 Jul 2023 12:58:22 +0200
|
||||
|
||||
pve-qemu-kvm (8.0.2-3) bookworm; urgency=medium
|
||||
|
||||
* fix regression in QEMU 8.0 for drive mirror with bitmap
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 15 Jun 2023 13:57:46 +0200
|
||||
|
||||
pve-qemu-kvm (8.0.2-2) bookworm; urgency=medium
|
||||
|
||||
* drop custom get_link_status QMP command, was never really used.
|
||||
|
||||
* drop custom & deprecated drive snapshot QMP commands, we use a better
|
||||
alternative since a while.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 09 Jun 2023 07:57:56 +0200
|
||||
|
||||
pve-qemu-kvm (8.0.2-1) bookworm; urgency=medium
|
||||
|
||||
* update to QEMU stable release 8.0.2
|
||||
|
||||
* update patches for avoiding issues with DMA reentrancy to current,
|
||||
slightly optimized version.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 06 Jun 2023 16:34:50 +0200
|
||||
|
||||
pve-qemu-kvm (8.0.0-1) bookworm; urgency=medium
|
||||
|
||||
* update to QEMU stable release 8.0.0
|
||||
|
||||
* re-build for Proxmox VE 8 / Debian 12 Bookworm
|
||||
|
||||
* adapt to the local virtiofsd C variant being dropped, it has been
|
||||
rewritten in Rust and is now hosted in a separate source repository.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 22 May 2023 13:45:49 +0200
|
||||
|
||||
pve-qemu-kvm (7.2.0-8) bullseye; urgency=medium
|
||||
|
||||
* backport fix for ACPI CPU hotplug issue with TCG
|
||||
|
||||
* cherry-pick TCG-related stable fixes for 7.2 for users that turned off KVM
|
||||
HW acceleration
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 17 Mar 2023 15:47:08 +0100
|
||||
|
||||
pve-qemu-kvm (7.2.0-7) bullseye; urgency=medium
|
||||
|
||||
* improve fix for potential deadlock with trim for IDE/SATA and draining
|
||||
|
||||
* backport stable fixes:
|
||||
- hw/nvme: fix missing endian conversions for doorbell buffers
|
||||
- hw/smbios: fix field corruption in type 4 table
|
||||
- virtio-rng-pci: fix transitional migration compat for vectors
|
||||
- hw/timer/hpet: Fix expiration time overflow
|
||||
- vhost/vdpa: stop all svq on device deletion
|
||||
- vhost: avoid a potential use of an uninitialized variable in the call to
|
||||
vhost_svq_poll
|
||||
- chardev/char-socket: set s->listener = NULL in char_socket_finalize to
|
||||
fix a potential crash after live-migration
|
||||
- intel-iommu: fail MAP notifier without caching mode
|
||||
- intel-iommu: fail DEVIOTLB_UNMAP without dt mode
|
||||
|
||||
* fix a regression for when the LSI SCSI controller is used
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 13 Mar 2023 17:42:49 +0100
|
||||
|
||||
pve-qemu-kvm (7.2.0-6) bullseye; urgency=medium
|
||||
|
||||
* fix 7.2 regression for Linux boot failures with megasas SCSI
|
||||
|
||||
* fix 7.0 regression for a potential deadlock with trim for IDE/SATA and
|
||||
draining
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 08 Mar 2023 14:32:17 +0100
|
||||
|
||||
pve-qemu-kvm (7.2.0-5) bullseye; urgency=medium
|
||||
|
||||
* fix #4476: savevm-async: avoid looping without progress
|
||||
|
||||
* savevm-async: decrease the boundary for free space for (memory) state left
|
||||
on target from 30 MiB to 100 MiB, improving the heuristic for when to
|
||||
enter the final "pause and sync" stage.
|
||||
|
||||
* QMP backup: use correct error number when getting blockdrive length fails
|
||||
|
||||
* backport fix for some DMA reentrancy issues, better protecting against
|
||||
malicious guests
|
||||
|
||||
* backport fix for iSCSI double free issue leading to crashes
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 21 Feb 2023 13:49:43 +0100
|
||||
|
||||
pve-qemu-kvm (7.2.0-4) bullseye; urgency=medium
|
||||
|
||||
* backport fix for a 7.2 regression when using VirtIO disk with
|
||||
detect-zeroes=unmap
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 27 Jan 2023 09:37:49 +0100
|
||||
|
||||
pve-qemu-kvm (7.2.0-3) bullseye; urgency=medium
|
||||
|
||||
* add fix for live-migration with virtio-rng devices, which regressed in
|
||||
QEMU 7.2.0.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 12 Jan 2023 13:13:14 +0100
|
||||
|
||||
pve-qemu-kvm (7.2.0-2) bullseye; urgency=medium
|
||||
|
||||
* enable slirp again for now, as in qemu-server, user networking is
|
||||
supported (via CLI/API) when no bridge is set on a virtual NIC
|
||||
|
||||
* cherry-pick stable fixes for 7.2. Two for virtio-mem and one for vIOMMU.
|
||||
Both features are not yet exposed in PVE's qemu-server, but there's work
|
||||
going on to change that.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 10 Jan 2023 15:47:48 +0100
|
||||
|
||||
pve-qemu-kvm (7.2.0-1) bullseye; urgency=medium
|
||||
|
||||
* update to QEMU stable release 7.2.0
|
||||
|
||||
* drop 'slirp' networking
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 16 Dec 2022 13:18:21 +0100
|
||||
|
||||
pve-qemu-kvm (7.1.0-4) bullseye; urgency=medium
|
||||
|
||||
* cherry-pick "block/block-backend: blk_set_enable_write_cache is IO_CODE"
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 22 Nov 2022 09:21:06 +0100
|
||||
|
||||
pve-qemu-kvm (7.1.0-3) bullseye; urgency=medium
|
||||
|
||||
* init: daemonize: defuse PID file resolve error to a warning at max, fixing
|
||||
some usecases that regressed with 7.1, like tracking start up in our
|
||||
file-restore VM.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 28 Oct 2022 10:27:49 +0200
|
||||
|
||||
pve-qemu-kvm (7.1.0-2) bullseye; urgency=medium
|
||||
|
||||
* fix an issue with error handling in async backup code
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 18 Oct 2022 15:33:44 +0200
|
||||
|
||||
pve-qemu-kvm (7.1.0-1) bullseye; urgency=medium
|
||||
|
||||
* update to QEMU stable release 7.1.0
|
||||
|
||||
* add fix for io_uring_register_ring_fd from upstream
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 14 Oct 2022 14:54:09 +0200
|
||||
|
||||
pve-qemu-kvm (7.0.0-4) bullseye; urgency=medium
|
||||
|
||||
* add revision to version output
|
||||
|
||||
* PVE Backup: allow passing max-workers performance setting
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 10 Oct 2022 11:55:37 +0200
|
||||
|
||||
pve-qemu-kvm (7.0.0-3) bullseye; urgency=medium
|
||||
|
||||
* savevm-async: avoid segfault when aborting snapshot creation task
|
||||
|
||||
* savevm-async: set SAVE_STATE_DONE when closing state file was successful
|
||||
allowing one to start a new snapshot task after aborting one.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 30 Aug 2022 12:54:03 +0200
|
||||
|
||||
pve-qemu-kvm (7.0.0-2) bullseye; urgency=medium
|
||||
|
||||
* backport "io_uring: fix short read slow path"
|
||||
|
||||
* backport "e1000: set RX descriptor status in a separate operation"
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 20 Jul 2022 09:17:07 +0200
|
||||
|
||||
pve-qemu-kvm (7.0.0-1) bullseye; urgency=medium
|
||||
|
||||
* update to QEMU stable release 7.0.0
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 30 Jun 2022 11:07:37 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-11) bullseye; urgency=medium
|
||||
|
||||
|
1
debian/compat
vendored
1
debian/compat
vendored
@@ -1 +0,0 @@
|
||||
10
|
28
debian/control
vendored
28
debian/control
vendored
@@ -2,9 +2,8 @@ Source: pve-qemu-kvm
|
||||
Section: admin
|
||||
Priority: optional
|
||||
Maintainer: Proxmox Support Team <support@proxmox.com>
|
||||
Build-Depends: autotools-dev,
|
||||
Build-Depends: debhelper-compat (= 13),
|
||||
check,
|
||||
debhelper (>= 9),
|
||||
libacl1-dev,
|
||||
libaio-dev,
|
||||
libattr1-dev,
|
||||
@@ -16,21 +15,21 @@ Build-Depends: autotools-dev,
|
||||
libglusterfs-dev (>= 5.2-2),
|
||||
libgnutls28-dev,
|
||||
libiscsi-dev (>= 1.12.0),
|
||||
libjemalloc-dev,
|
||||
libjpeg-dev,
|
||||
libjson-perl,
|
||||
libnuma-dev,
|
||||
libpci-dev,
|
||||
libpixman-1-dev,
|
||||
libproxmox-backup-qemu0-dev (>= 1.3.0-1),
|
||||
libproxmox-backup-qemu0-dev (>= 1.3.0),
|
||||
librbd-dev (>= 0.48),
|
||||
libsdl1.2-dev,
|
||||
libseccomp-dev,
|
||||
libslirp-dev,
|
||||
libspice-protocol-dev (>= 0.12.14~),
|
||||
libspice-server-dev (>= 0.14.0~),
|
||||
libsystemd-dev,
|
||||
liburing-dev,
|
||||
libusb-1.0-0-dev (>= 1.0.17-1),
|
||||
libusb-1.0-0-dev (>= 1.0.17),
|
||||
libusbredirparser-dev (>= 0.6-2),
|
||||
libvirglrenderer-dev,
|
||||
libzstd-dev,
|
||||
@@ -38,9 +37,8 @@ Build-Depends: autotools-dev,
|
||||
python3-minimal,
|
||||
python3-sphinx,
|
||||
python3-sphinx-rtd-theme,
|
||||
python3-venv,
|
||||
quilt,
|
||||
texi2html,
|
||||
texinfo,
|
||||
uuid-dev,
|
||||
xfslibs-dev,
|
||||
Standards-Version: 3.7.2
|
||||
@@ -57,7 +55,6 @@ Depends: ceph-common (>= 0.48),
|
||||
libglusterfs-dev | glusterfs-common (>= 5.6),
|
||||
libglusterfs0 | glusterfs-common (>= 5.6),
|
||||
libiscsi4 (>= 1.12.0) | libiscsi7,
|
||||
libjemalloc2,
|
||||
libjpeg62-turbo,
|
||||
libspice-server1 (>= 0.14.0~),
|
||||
libusb-1.0-0 (>= 1.0.17-1),
|
||||
@@ -65,8 +62,8 @@ Depends: ceph-common (>= 0.48),
|
||||
libuuid1,
|
||||
${misc:Depends},
|
||||
${shlibs:Depends},
|
||||
Recommends: numactl
|
||||
Suggests: libgl1
|
||||
Recommends: numactl,
|
||||
Suggests: libgl1,
|
||||
Conflicts: kvm,
|
||||
pve-kvm,
|
||||
pve-qemu-kvm-2.6.18,
|
||||
@@ -74,22 +71,17 @@ Conflicts: kvm,
|
||||
qemu-kvm,
|
||||
qemu-system-arm,
|
||||
qemu-system-common,
|
||||
qemu-system-data,
|
||||
qemu-system-x86,
|
||||
qemu-utils,
|
||||
Provides: qemu-system-arm, qemu-system-x86, qemu-utils
|
||||
Provides: qemu-system-arm, qemu-system-x86, qemu-utils,
|
||||
Replaces: pve-kvm,
|
||||
pve-qemu-kvm-2.6.18,
|
||||
qemu-system-arm,
|
||||
qemu-system-x86,
|
||||
qemu-utils,
|
||||
Breaks: qemu-server (<= 8.0.6)
|
||||
Description: Full virtualization on x86 hardware
|
||||
Using KVM, one can run multiple virtual PCs, each running unmodified Linux or
|
||||
Windows images. Each virtual machine has private virtualized hardware: a
|
||||
network card, disk, graphics adapter, etc.
|
||||
|
||||
Package: pve-qemu-kvm-dbg
|
||||
Architecture: any
|
||||
Section: debug
|
||||
Depends: pve-qemu-kvm (= ${binary:Version})
|
||||
Description: pve qemu debugging symbols
|
||||
This package contains the debugging symbols for pve-qemu-kvm.
|
||||
|
3
debian/parse-machines.pl
vendored
3
debian/parse-machines.pl
vendored
@@ -24,4 +24,5 @@ while (<STDIN>) {
|
||||
|
||||
die "no QEMU machine types detected from STDIN input" if scalar (@$machines) <= 0;
|
||||
|
||||
print to_json($machines, { utf8 => 1 }) or die "$!\n";
|
||||
print to_json($machines, { utf8 => 1, canonical => 1 })
|
||||
or die "failed to encode detected machines as JSON - $!\n";
|
||||
|
@@ -27,19 +27,21 @@ Signed-off-by: Ma Haocong <mahaocong@didichuxing.com>
|
||||
Signed-off-by: John Snow <jsnow@redhat.com>
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: rebased for 8.2.2]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/mirror.c | 98 +++++++++++++++++++++++++-------
|
||||
blockdev.c | 39 ++++++++++++-
|
||||
include/block/block_int.h | 4 +-
|
||||
qapi/block-core.json | 29 ++++++++--
|
||||
tests/unit/test-block-iothread.c | 4 +-
|
||||
5 files changed, 145 insertions(+), 29 deletions(-)
|
||||
block/mirror.c | 99 ++++++++++++++++++++------
|
||||
blockdev.c | 38 +++++++++-
|
||||
include/block/block_int-global-state.h | 4 +-
|
||||
qapi/block-core.json | 25 ++++++-
|
||||
tests/unit/test-block-iothread.c | 4 +-
|
||||
5 files changed, 142 insertions(+), 28 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index efec2c7674..f7804638f9 100644
|
||||
index 1bdce3b657..0c5c72df2e 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -50,7 +50,7 @@ typedef struct MirrorBlockJob {
|
||||
@@ -51,7 +51,7 @@ typedef struct MirrorBlockJob {
|
||||
BlockDriverState *to_replace;
|
||||
/* Used to block operations on the drive-mirror-replace target */
|
||||
Error *replace_blocker;
|
||||
@@ -48,7 +50,7 @@ index efec2c7674..f7804638f9 100644
|
||||
BlockMirrorBackingMode backing_mode;
|
||||
/* Whether the target image requires explicit zero-initialization */
|
||||
bool zero_target;
|
||||
@@ -64,6 +64,8 @@ typedef struct MirrorBlockJob {
|
||||
@@ -73,6 +73,8 @@ typedef struct MirrorBlockJob {
|
||||
size_t buf_size;
|
||||
int64_t bdev_length;
|
||||
unsigned long *cow_bitmap;
|
||||
@@ -57,9 +59,9 @@ index efec2c7674..f7804638f9 100644
|
||||
BdrvDirtyBitmap *dirty_bitmap;
|
||||
BdrvDirtyBitmapIter *dbi;
|
||||
uint8_t *buf;
|
||||
@@ -695,7 +697,8 @@ static int mirror_exit_common(Job *job)
|
||||
bdrv_child_refresh_perms(mirror_top_bs, mirror_top_bs->backing,
|
||||
@@ -722,7 +724,8 @@ static int mirror_exit_common(Job *job)
|
||||
&error_abort);
|
||||
|
||||
if (!abort && s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) {
|
||||
- BlockDriverState *backing = s->is_none_mode ? src : s->base;
|
||||
+ BlockDriverState *backing;
|
||||
@@ -67,7 +69,7 @@ index efec2c7674..f7804638f9 100644
|
||||
BlockDriverState *unfiltered_target = bdrv_skip_filters(target_bs);
|
||||
|
||||
if (bdrv_cow_bs(unfiltered_target) != backing) {
|
||||
@@ -800,6 +803,16 @@ static void mirror_abort(Job *job)
|
||||
@@ -819,6 +822,16 @@ static void mirror_abort(Job *job)
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
@@ -84,7 +86,7 @@ index efec2c7674..f7804638f9 100644
|
||||
static void coroutine_fn mirror_throttle(MirrorBlockJob *s)
|
||||
{
|
||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
||||
@@ -979,7 +992,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
|
||||
@@ -1015,7 +1028,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
|
||||
mirror_free_init(s);
|
||||
|
||||
s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
||||
@@ -94,7 +96,7 @@ index efec2c7674..f7804638f9 100644
|
||||
ret = mirror_dirty_init(s);
|
||||
if (ret < 0 || job_is_cancelled(&s->common.job)) {
|
||||
goto immediate_exit;
|
||||
@@ -1221,6 +1235,7 @@ static const BlockJobDriver mirror_job_driver = {
|
||||
@@ -1304,6 +1318,7 @@ static const BlockJobDriver mirror_job_driver = {
|
||||
.run = mirror_run,
|
||||
.prepare = mirror_prepare,
|
||||
.abort = mirror_abort,
|
||||
@@ -102,7 +104,7 @@ index efec2c7674..f7804638f9 100644
|
||||
.pause = mirror_pause,
|
||||
.complete = mirror_complete,
|
||||
.cancel = mirror_cancel,
|
||||
@@ -1237,6 +1252,7 @@ static const BlockJobDriver commit_active_job_driver = {
|
||||
@@ -1322,6 +1337,7 @@ static const BlockJobDriver commit_active_job_driver = {
|
||||
.run = mirror_run,
|
||||
.prepare = mirror_prepare,
|
||||
.abort = mirror_abort,
|
||||
@@ -110,7 +112,7 @@ index efec2c7674..f7804638f9 100644
|
||||
.pause = mirror_pause,
|
||||
.complete = mirror_complete,
|
||||
.cancel = commit_active_cancel,
|
||||
@@ -1602,7 +1618,10 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1714,7 +1730,10 @@ static BlockJob *mirror_start_job(
|
||||
BlockCompletionFunc *cb,
|
||||
void *opaque,
|
||||
const BlockJobDriver *driver,
|
||||
@@ -122,11 +124,12 @@ index efec2c7674..f7804638f9 100644
|
||||
bool auto_complete, const char *filter_node_name,
|
||||
bool is_mirror, MirrorCopyMode copy_mode,
|
||||
Error **errp)
|
||||
@@ -1614,10 +1633,39 @@ static BlockJob *mirror_start_job(
|
||||
uint64_t target_perms, target_shared_perms;
|
||||
int ret;
|
||||
@@ -1728,10 +1747,39 @@ static BlockJob *mirror_start_job(
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
- if (granularity == 0) {
|
||||
- granularity = bdrv_get_default_bitmap_granularity(target);
|
||||
+ if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
|
||||
+ error_setg(errp, "Sync mode '%s' not supported",
|
||||
+ MirrorSyncMode_str(sync_mode));
|
||||
@@ -147,8 +150,8 @@ index efec2c7674..f7804638f9 100644
|
||||
+ "sync mode '%s' is not compatible with bitmaps",
|
||||
+ MirrorSyncMode_str(sync_mode));
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ if (bitmap) {
|
||||
+ if (granularity) {
|
||||
+ error_setg(errp, "granularity (%d)"
|
||||
@@ -158,13 +161,12 @@ index efec2c7674..f7804638f9 100644
|
||||
+ }
|
||||
+ granularity = bdrv_dirty_bitmap_granularity(bitmap);
|
||||
+ } else if (granularity == 0) {
|
||||
granularity = bdrv_get_default_bitmap_granularity(target);
|
||||
}
|
||||
-
|
||||
+ granularity = bdrv_get_default_bitmap_granularity(target);
|
||||
+ }
|
||||
assert(is_power_of_2(granularity));
|
||||
|
||||
if (buf_size < 0) {
|
||||
@@ -1755,7 +1803,9 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1871,7 +1919,9 @@ static BlockJob *mirror_start_job(
|
||||
s->replaces = g_strdup(replaces);
|
||||
s->on_source_error = on_source_error;
|
||||
s->on_target_error = on_target_error;
|
||||
@@ -174,10 +176,10 @@ index efec2c7674..f7804638f9 100644
|
||||
+ s->bitmap_mode = bitmap_mode;
|
||||
s->backing_mode = backing_mode;
|
||||
s->zero_target = zero_target;
|
||||
s->copy_mode = copy_mode;
|
||||
@@ -1776,6 +1826,18 @@ static BlockJob *mirror_start_job(
|
||||
bdrv_disable_dirty_bitmap(s->dirty_bitmap);
|
||||
}
|
||||
qatomic_set(&s->copy_mode, copy_mode);
|
||||
@@ -1897,6 +1947,18 @@ static BlockJob *mirror_start_job(
|
||||
*/
|
||||
bdrv_disable_dirty_bitmap(s->dirty_bitmap);
|
||||
|
||||
+ if (s->sync_bitmap) {
|
||||
+ bdrv_dirty_bitmap_set_busy(s->sync_bitmap, true);
|
||||
@@ -191,10 +193,10 @@ index efec2c7674..f7804638f9 100644
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
bdrv_graph_wrlock();
|
||||
ret = block_job_add_bdrv(&s->common, "source", bs, 0,
|
||||
BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE |
|
||||
BLK_PERM_CONSISTENT_READ,
|
||||
@@ -1853,6 +1915,9 @@ fail:
|
||||
@@ -1979,6 +2041,9 @@ fail:
|
||||
if (s->dirty_bitmap) {
|
||||
bdrv_release_dirty_bitmap(s->dirty_bitmap);
|
||||
}
|
||||
@@ -204,7 +206,7 @@ index efec2c7674..f7804638f9 100644
|
||||
job_early_fail(&s->common.job);
|
||||
}
|
||||
|
||||
@@ -1870,29 +1935,23 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2001,35 +2066,28 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
|
||||
BlockDriverState *target, const char *replaces,
|
||||
int creation_flags, int64_t speed,
|
||||
uint32_t granularity, int64_t buf_size,
|
||||
@@ -221,14 +223,20 @@ index efec2c7674..f7804638f9 100644
|
||||
- bool is_none_mode;
|
||||
BlockDriverState *base;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
- if ((mode == MIRROR_SYNC_MODE_INCREMENTAL) ||
|
||||
- (mode == MIRROR_SYNC_MODE_BITMAP)) {
|
||||
- error_setg(errp, "Sync mode '%s' not supported",
|
||||
- MirrorSyncMode_str(mode));
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
bdrv_graph_rdlock_main_loop();
|
||||
- is_none_mode = mode == MIRROR_SYNC_MODE_NONE;
|
||||
base = mode == MIRROR_SYNC_MODE_TOP ? bdrv_backing_chain_next(bs) : NULL;
|
||||
bdrv_graph_rdunlock_main_loop();
|
||||
|
||||
mirror_start_job(job_id, bs, creation_flags, target, replaces,
|
||||
speed, granularity, buf_size, backing_mode, zero_target,
|
||||
on_source_error, on_target_error, unmap, NULL, NULL,
|
||||
@@ -239,7 +247,7 @@ index efec2c7674..f7804638f9 100644
|
||||
}
|
||||
|
||||
BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
|
||||
@@ -1917,7 +1976,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2056,7 +2114,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
|
||||
job_id, bs, creation_flags, base, NULL, speed, 0, 0,
|
||||
MIRROR_LEAVE_BACKING_CHAIN, false,
|
||||
on_error, on_error, true, cb, opaque,
|
||||
@@ -250,33 +258,32 @@ index efec2c7674..f7804638f9 100644
|
||||
errp);
|
||||
if (!job) {
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index b35072644e..9940116fe0 100644
|
||||
index 4c33c3f5f0..f3e508a6a7 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -2956,6 +2956,10 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2776,6 +2776,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
BlockDriverState *target,
|
||||
bool has_replaces, const char *replaces,
|
||||
const char *replaces,
|
||||
enum MirrorSyncMode sync,
|
||||
+ bool has_bitmap,
|
||||
+ const char *bitmap_name,
|
||||
+ bool has_bitmap_mode,
|
||||
+ BitmapSyncMode bitmap_mode,
|
||||
BlockMirrorBackingMode backing_mode,
|
||||
bool zero_target,
|
||||
bool has_speed, int64_t speed,
|
||||
@@ -2975,6 +2979,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2794,6 +2797,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
{
|
||||
BlockDriverState *unfiltered_bs;
|
||||
int job_flags = JOB_DEFAULT;
|
||||
+ BdrvDirtyBitmap *bitmap = NULL;
|
||||
|
||||
if (!has_speed) {
|
||||
speed = 0;
|
||||
@@ -3029,6 +3034,29 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
GLOBAL_STATE_CODE();
|
||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||
@@ -2848,6 +2852,29 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
sync = MIRROR_SYNC_MODE_FULL;
|
||||
}
|
||||
|
||||
+ if (has_bitmap) {
|
||||
+ if (bitmap_name) {
|
||||
+ if (granularity) {
|
||||
+ error_setg(errp, "Granularity and bitmap cannot both be set");
|
||||
+ return;
|
||||
@@ -299,53 +306,53 @@ index b35072644e..9940116fe0 100644
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (!has_replaces) {
|
||||
if (!replaces) {
|
||||
/* We want to mirror from @bs, but keep implicit filters on top */
|
||||
unfiltered_bs = bdrv_skip_implicit_filters(bs);
|
||||
@@ -3075,8 +3103,8 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2889,8 +2916,8 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
* and will allow to check whether the node still exist at mirror completion
|
||||
*/
|
||||
mirror_start(job_id, bs, target,
|
||||
- has_replaces ? replaces : NULL, job_flags,
|
||||
- replaces, job_flags,
|
||||
- speed, granularity, buf_size, sync, backing_mode, zero_target,
|
||||
+ has_replaces ? replaces : NULL, job_flags, speed, granularity,
|
||||
+ buf_size, sync, bitmap, bitmap_mode, backing_mode, zero_target,
|
||||
+ replaces, job_flags, speed, granularity, buf_size, sync,
|
||||
+ bitmap, bitmap_mode, backing_mode, zero_target,
|
||||
on_source_error, on_target_error, unmap, filter_node_name,
|
||||
copy_mode, errp);
|
||||
}
|
||||
@@ -3221,6 +3249,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
||||
@@ -3034,6 +3061,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
||||
|
||||
blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, target_bs,
|
||||
arg->has_replaces, arg->replaces, arg->sync,
|
||||
+ arg->has_bitmap, arg->bitmap,
|
||||
blockdev_mirror_common(arg->job_id, bs, target_bs,
|
||||
arg->replaces, arg->sync,
|
||||
+ arg->bitmap,
|
||||
+ arg->has_bitmap_mode, arg->bitmap_mode,
|
||||
backing_mode, zero_target,
|
||||
arg->has_speed, arg->speed,
|
||||
arg->has_granularity, arg->granularity,
|
||||
@@ -3242,6 +3272,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
|
||||
@@ -3053,6 +3082,8 @@ void qmp_blockdev_mirror(const char *job_id,
|
||||
const char *device, const char *target,
|
||||
bool has_replaces, const char *replaces,
|
||||
const char *replaces,
|
||||
MirrorSyncMode sync,
|
||||
+ bool has_bitmap, const char *bitmap,
|
||||
+ const char *bitmap,
|
||||
+ bool has_bitmap_mode, BitmapSyncMode bitmap_mode,
|
||||
bool has_speed, int64_t speed,
|
||||
bool has_granularity, uint32_t granularity,
|
||||
bool has_buf_size, int64_t buf_size,
|
||||
@@ -3291,7 +3323,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
|
||||
@@ -3093,7 +3124,8 @@ void qmp_blockdev_mirror(const char *job_id,
|
||||
}
|
||||
|
||||
blockdev_mirror_common(has_job_id ? job_id : NULL, bs, target_bs,
|
||||
- has_replaces, replaces, sync, backing_mode,
|
||||
+ has_replaces, replaces, sync, has_bitmap,
|
||||
blockdev_mirror_common(job_id, bs, target_bs,
|
||||
- replaces, sync, backing_mode,
|
||||
+ replaces, sync,
|
||||
+ bitmap, has_bitmap_mode, bitmap_mode, backing_mode,
|
||||
zero_target, has_speed, speed,
|
||||
has_granularity, granularity,
|
||||
has_buf_size, buf_size,
|
||||
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
||||
index f4c75e8ba9..ee0aeb1414 100644
|
||||
--- a/include/block/block_int.h
|
||||
+++ b/include/block/block_int.h
|
||||
@@ -1287,7 +1287,9 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
|
||||
diff --git a/include/block/block_int-global-state.h b/include/block/block_int-global-state.h
|
||||
index eb2d92a226..f0c642b194 100644
|
||||
--- a/include/block/block_int-global-state.h
|
||||
+++ b/include/block/block_int-global-state.h
|
||||
@@ -158,7 +158,9 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
|
||||
BlockDriverState *target, const char *replaces,
|
||||
int creation_flags, int64_t speed,
|
||||
uint32_t granularity, int64_t buf_size,
|
||||
@@ -357,31 +364,26 @@ index f4c75e8ba9..ee0aeb1414 100644
|
||||
BlockdevOnError on_source_error,
|
||||
BlockdevOnError on_target_error,
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 1d3dd9cb48..da5dca1e3b 100644
|
||||
index b179d65520..905da8be72 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -1995,10 +1995,19 @@
|
||||
# (all the disk, only the sectors allocated in the topmost image, or
|
||||
# only new I/O).
|
||||
@@ -2174,6 +2174,15 @@
|
||||
# destination (all the disk, only the sectors allocated in the
|
||||
# topmost image, or only new I/O).
|
||||
#
|
||||
+# @bitmap: The name of a bitmap to use for sync=bitmap mode. This argument must
|
||||
+# be present for bitmap mode and absent otherwise. The bitmap's
|
||||
+# granularity is used instead of @granularity (since 4.1).
|
||||
+# @bitmap: The name of a bitmap to use for sync=bitmap mode. This
|
||||
+# argument must be present for bitmap mode and absent otherwise.
|
||||
+# The bitmap's granularity is used instead of @granularity (Since
|
||||
+# 4.1).
|
||||
+#
|
||||
+# @bitmap-mode: Specifies the type of data the bitmap should contain after
|
||||
+# the operation concludes. Must be present if sync is "bitmap".
|
||||
+# Must NOT be present otherwise. (Since 4.1)
|
||||
+# @bitmap-mode: Specifies the type of data the bitmap should contain
|
||||
+# after the operation concludes. Must be present if sync is
|
||||
+# "bitmap". Must NOT be present otherwise. (Since 4.1)
|
||||
+#
|
||||
# @granularity: granularity of the dirty bitmap, default is 64K
|
||||
# if the image format doesn't have clusters, 4K if the clusters
|
||||
# are smaller than that, else the cluster size. Must be a
|
||||
-# power of 2 between 512 and 64M (since 1.4).
|
||||
+# power of 2 between 512 and 64M. Must not be specified if
|
||||
+# @bitmap is present (since 1.4).
|
||||
#
|
||||
# @buf-size: maximum amount of data in flight from source to
|
||||
# target (since 1.4).
|
||||
@@ -2036,7 +2045,9 @@
|
||||
# @granularity: granularity of the dirty bitmap, default is 64K if the
|
||||
# image format doesn't have clusters, 4K if the clusters are
|
||||
# smaller than that, else the cluster size. Must be a power of 2
|
||||
@@ -2216,7 +2225,9 @@
|
||||
{ 'struct': 'DriveMirror',
|
||||
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
|
||||
'*format': 'str', '*node-name': 'str', '*replaces': 'str',
|
||||
@@ -392,28 +394,23 @@ index 1d3dd9cb48..da5dca1e3b 100644
|
||||
'*speed': 'int', '*granularity': 'uint32',
|
||||
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
|
||||
'*on-target-error': 'BlockdevOnError',
|
||||
@@ -2308,10 +2319,19 @@
|
||||
# (all the disk, only the sectors allocated in the topmost image, or
|
||||
# only new I/O).
|
||||
@@ -2496,6 +2507,15 @@
|
||||
# destination (all the disk, only the sectors allocated in the
|
||||
# topmost image, or only new I/O).
|
||||
#
|
||||
+# @bitmap: The name of a bitmap to use for sync=bitmap mode. This argument must
|
||||
+# be present for bitmap mode and absent otherwise. The bitmap's
|
||||
+# granularity is used instead of @granularity (since 4.1).
|
||||
+# @bitmap: The name of a bitmap to use for sync=bitmap mode. This
|
||||
+# argument must be present for bitmap mode and absent otherwise.
|
||||
+# The bitmap's granularity is used instead of @granularity (since
|
||||
+# 4.1).
|
||||
+#
|
||||
+# @bitmap-mode: Specifies the type of data the bitmap should contain after
|
||||
+# the operation concludes. Must be present if sync is "bitmap".
|
||||
+# Must NOT be present otherwise. (Since 4.1)
|
||||
+# @bitmap-mode: Specifies the type of data the bitmap should contain
|
||||
+# after the operation concludes. Must be present if sync is
|
||||
+# "bitmap". Must NOT be present otherwise. (Since 4.1)
|
||||
+#
|
||||
# @granularity: granularity of the dirty bitmap, default is 64K
|
||||
# if the image format doesn't have clusters, 4K if the clusters
|
||||
# are smaller than that, else the cluster size. Must be a
|
||||
-# power of 2 between 512 and 64M
|
||||
+# power of 2 between 512 and 64M . Must not be specified if
|
||||
+# @bitmap is present.
|
||||
#
|
||||
# @buf-size: maximum amount of data in flight from source to
|
||||
# target
|
||||
@@ -2360,7 +2380,8 @@
|
||||
# @granularity: granularity of the dirty bitmap, default is 64K if the
|
||||
# image format doesn't have clusters, 4K if the clusters are
|
||||
# smaller than that, else the cluster size. Must be a power of 2
|
||||
@@ -2544,7 +2564,8 @@
|
||||
{ 'command': 'blockdev-mirror',
|
||||
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
|
||||
'*replaces': 'str',
|
||||
@@ -424,10 +421,10 @@ index 1d3dd9cb48..da5dca1e3b 100644
|
||||
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
|
||||
'*on-target-error': 'BlockdevOnError',
|
||||
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
|
||||
index aea660aeed..22b9770a3e 100644
|
||||
index 3766d5de6b..afa44cbd34 100644
|
||||
--- a/tests/unit/test-block-iothread.c
|
||||
+++ b/tests/unit/test-block-iothread.c
|
||||
@@ -626,8 +626,8 @@ static void test_propagate_mirror(void)
|
||||
@@ -755,8 +755,8 @@ static void test_propagate_mirror(void)
|
||||
|
||||
/* Start a mirror job */
|
||||
mirror_start("job0", src, target, NULL, JOB_DEFAULT, 0, 0, 0,
|
||||
@@ -437,4 +434,4 @@ index aea660aeed..22b9770a3e 100644
|
||||
+ false, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
false, "filter_node", MIRROR_COPY_MODE_BACKGROUND,
|
||||
&error_abort);
|
||||
job = job_get("job0");
|
||||
|
||||
|
@@ -24,10 +24,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 18 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index f7804638f9..4f5f74e2cf 100644
|
||||
index 0c5c72df2e..37fee3fa25 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -672,8 +672,6 @@ static int mirror_exit_common(Job *job)
|
||||
@@ -693,8 +693,6 @@ static int mirror_exit_common(Job *job)
|
||||
bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ index f7804638f9..4f5f74e2cf 100644
|
||||
/* Make sure that the source BDS doesn't go away during bdrv_replace_node,
|
||||
* before we can call bdrv_drained_end */
|
||||
bdrv_ref(src);
|
||||
@@ -781,6 +779,18 @@ static int mirror_exit_common(Job *job)
|
||||
blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort);
|
||||
blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort);
|
||||
@@ -800,6 +798,18 @@ static int mirror_exit_common(Job *job)
|
||||
bdrv_drained_end(target_bs);
|
||||
bdrv_unref(target_bs);
|
||||
|
||||
+ if (s->sync_bitmap) {
|
||||
+ if (s->bitmap_mode == BITMAP_SYNC_MODE_ALWAYS ||
|
||||
@@ -55,7 +55,7 @@ index f7804638f9..4f5f74e2cf 100644
|
||||
bs_opaque->job = NULL;
|
||||
|
||||
bdrv_drained_end(src);
|
||||
@@ -1643,10 +1653,6 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1757,10 +1767,6 @@ static BlockJob *mirror_start_job(
|
||||
" sync mode",
|
||||
MirrorSyncMode_str(sync_mode));
|
||||
return NULL;
|
||||
@@ -66,7 +66,7 @@ index f7804638f9..4f5f74e2cf 100644
|
||||
}
|
||||
} else if (bitmap) {
|
||||
error_setg(errp,
|
||||
@@ -1663,6 +1669,12 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1777,6 +1783,12 @@ static BlockJob *mirror_start_job(
|
||||
return NULL;
|
||||
}
|
||||
granularity = bdrv_dirty_bitmap_granularity(bitmap);
|
||||
|
@@ -16,10 +16,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index 9940116fe0..b113e57d68 100644
|
||||
index f3e508a6a7..37b8437f3e 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -3055,6 +3055,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2873,6 +2873,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) {
|
||||
return;
|
||||
}
|
||||
@@ -28,4 +28,4 @@ index 9940116fe0..b113e57d68 100644
|
||||
+ return;
|
||||
}
|
||||
|
||||
if (!has_replaces) {
|
||||
if (!replaces) {
|
||||
|
@@ -16,10 +16,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 4 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index 4f5f74e2cf..7024f3bbf0 100644
|
||||
index 37fee3fa25..6b3cce1007 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -785,8 +785,8 @@ static int mirror_exit_common(Job *job)
|
||||
@@ -804,8 +804,8 @@ static int mirror_exit_common(Job *job)
|
||||
job->ret == 0 && ret == 0)) {
|
||||
/* Success; synchronize copy back to sync. */
|
||||
bdrv_clear_dirty_bitmap(s->sync_bitmap, NULL);
|
||||
@@ -30,7 +30,7 @@ index 4f5f74e2cf..7024f3bbf0 100644
|
||||
}
|
||||
}
|
||||
bdrv_release_dirty_bitmap(s->dirty_bitmap);
|
||||
@@ -1843,11 +1843,8 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1964,11 +1964,8 @@ static BlockJob *mirror_start_job(
|
||||
}
|
||||
|
||||
if (s->sync_mode == MIRROR_SYNC_MODE_BITMAP) {
|
||||
@@ -43,4 +43,4 @@ index 4f5f74e2cf..7024f3bbf0 100644
|
||||
+ NULL, true);
|
||||
}
|
||||
|
||||
ret = block_job_add_bdrv(&s->common, "source", bs, 0,
|
||||
bdrv_graph_wrlock();
|
||||
|
@@ -12,6 +12,8 @@ uniform w.r.t. backup block jobs.
|
||||
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: rebase for 8.2.2]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/mirror.c | 28 +++------------
|
||||
blockdev.c | 29 +++++++++++++++
|
||||
@@ -19,12 +21,12 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
3 files changed, 70 insertions(+), 59 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index 7024f3bbf0..6211ff22fc 100644
|
||||
index 6b3cce1007..2f1223852b 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -1643,31 +1643,13 @@ static BlockJob *mirror_start_job(
|
||||
uint64_t target_perms, target_shared_perms;
|
||||
int ret;
|
||||
@@ -1757,31 +1757,13 @@ static BlockJob *mirror_start_job(
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
- if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
|
||||
- error_setg(errp, "Sync mode '%s' not supported",
|
||||
@@ -60,17 +62,17 @@ index 7024f3bbf0..6211ff22fc 100644
|
||||
|
||||
if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index b113e57d68..4be0863050 100644
|
||||
index 37b8437f3e..ed8198f351 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -3034,7 +3034,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2852,7 +2852,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
sync = MIRROR_SYNC_MODE_FULL;
|
||||
}
|
||||
|
||||
+ if ((sync == MIRROR_SYNC_MODE_BITMAP) ||
|
||||
+ (sync == MIRROR_SYNC_MODE_INCREMENTAL)) {
|
||||
+ /* done before desugaring 'incremental' to print the right message */
|
||||
+ if (!has_bitmap) {
|
||||
+ if (!bitmap_name) {
|
||||
+ error_setg(errp, "Must provide a valid bitmap name for "
|
||||
+ "'%s' sync mode", MirrorSyncMode_str(sync));
|
||||
+ return;
|
||||
@@ -91,7 +93,7 @@ index b113e57d68..4be0863050 100644
|
||||
+ bitmap_mode = BITMAP_SYNC_MODE_ON_SUCCESS;
|
||||
+ }
|
||||
+
|
||||
if (has_bitmap) {
|
||||
if (bitmap_name) {
|
||||
+ if (sync != MIRROR_SYNC_MODE_BITMAP) {
|
||||
+ error_setg(errp, "Sync mode '%s' not supported with bitmap.",
|
||||
+ MirrorSyncMode_str(sync));
|
||||
|
@@ -48,7 +48,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
6 files changed, 59 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
|
||||
index 12d395d62d..b182943324 100644
|
||||
index 965f5d5450..e04bd059b6 100644
|
||||
--- a/include/monitor/monitor.h
|
||||
+++ b/include/monitor/monitor.h
|
||||
@@ -16,6 +16,7 @@ extern QemuOptsList qemu_mon_opts;
|
||||
@@ -60,7 +60,7 @@ index 12d395d62d..b182943324 100644
|
||||
void monitor_init_globals(void);
|
||||
void monitor_init_globals_core(void);
|
||||
diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
|
||||
index 3da3f86c6a..9953e0cd2d 100644
|
||||
index 252de85681..8db28f9272 100644
|
||||
--- a/monitor/monitor-internal.h
|
||||
+++ b/monitor/monitor-internal.h
|
||||
@@ -151,6 +151,13 @@ typedef struct {
|
||||
@@ -78,10 +78,10 @@ index 3da3f86c6a..9953e0cd2d 100644
|
||||
|
||||
/**
|
||||
diff --git a/monitor/monitor.c b/monitor/monitor.c
|
||||
index 21c7a68758..ad9813567a 100644
|
||||
index 01ede1babd..5681bca346 100644
|
||||
--- a/monitor/monitor.c
|
||||
+++ b/monitor/monitor.c
|
||||
@@ -135,6 +135,21 @@ bool monitor_cur_is_qmp(void)
|
||||
@@ -117,6 +117,21 @@ bool monitor_cur_is_qmp(void)
|
||||
return cur_mon && monitor_is_qmp(cur_mon);
|
||||
}
|
||||
|
||||
@@ -104,10 +104,10 @@ index 21c7a68758..ad9813567a 100644
|
||||
* Is @mon is using readline?
|
||||
* Note: not all HMP monitors use readline, e.g., gdbserver has a
|
||||
diff --git a/monitor/qmp.c b/monitor/qmp.c
|
||||
index 092c527b6f..6b8cfcf6d8 100644
|
||||
index a239945e8d..589c9524f8 100644
|
||||
--- a/monitor/qmp.c
|
||||
+++ b/monitor/qmp.c
|
||||
@@ -141,6 +141,8 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
@@ -165,6 +165,8 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
QDict *rsp;
|
||||
QDict *error;
|
||||
|
||||
@@ -116,7 +116,7 @@ index 092c527b6f..6b8cfcf6d8 100644
|
||||
rsp = qmp_dispatch(mon->commands, req, qmp_oob_enabled(mon),
|
||||
&mon->common);
|
||||
|
||||
@@ -156,7 +158,17 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
@@ -180,7 +182,17 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ index 092c527b6f..6b8cfcf6d8 100644
|
||||
qobject_unref(rsp);
|
||||
}
|
||||
|
||||
@@ -444,6 +456,7 @@ static void monitor_qmp_event(void *opaque, QEMUChrEvent event)
|
||||
@@ -461,6 +473,7 @@ static void monitor_qmp_event(void *opaque, QEMUChrEvent event)
|
||||
|
||||
switch (event) {
|
||||
case CHR_EVENT_OPENED:
|
||||
@@ -144,10 +144,10 @@ index 092c527b6f..6b8cfcf6d8 100644
|
||||
monitor_qmp_caps_reset(mon);
|
||||
data = qmp_greeting(mon);
|
||||
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
|
||||
index d378bccac7..fb8936e7cd 100644
|
||||
index 176b549473..790bb7d1da 100644
|
||||
--- a/qapi/qmp-dispatch.c
|
||||
+++ b/qapi/qmp-dispatch.c
|
||||
@@ -118,16 +118,28 @@ typedef struct QmpDispatchBH {
|
||||
@@ -117,16 +117,28 @@ typedef struct QmpDispatchBH {
|
||||
QObject **ret;
|
||||
Error **errp;
|
||||
Coroutine *co;
|
||||
@@ -180,19 +180,19 @@ index d378bccac7..fb8936e7cd 100644
|
||||
aio_co_wake(data->co);
|
||||
}
|
||||
|
||||
@@ -232,6 +244,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
|
||||
@@ -253,6 +265,7 @@ QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *requ
|
||||
.ret = &ret,
|
||||
.errp = &err,
|
||||
.co = qemu_coroutine_self(),
|
||||
+ .conn_nr = monitor_get_connection_nr(cur_mon),
|
||||
};
|
||||
aio_bh_schedule_oneshot(qemu_get_aio_context(), do_qmp_dispatch_bh,
|
||||
aio_bh_schedule_oneshot(iohandler_get_aio_context(), do_qmp_dispatch_bh,
|
||||
&data);
|
||||
diff --git a/stubs/monitor-core.c b/stubs/monitor-core.c
|
||||
index d058a2a00d..3290b58120 100644
|
||||
index afa477aae6..d3ff124bf3 100644
|
||||
--- a/stubs/monitor-core.c
|
||||
+++ b/stubs/monitor-core.c
|
||||
@@ -13,6 +13,11 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)
|
||||
@@ -12,6 +12,11 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -1,55 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Wed, 1 Sep 2021 16:51:04 +0200
|
||||
Subject: [PATCH] monitor/hmp: add support for flag argument with value
|
||||
|
||||
Adds support for the "-xS" parameter type, where "-x" denotes a flag
|
||||
name and the "S" suffix indicates that this flag is supposed to take an
|
||||
arbitrary string parameter.
|
||||
|
||||
These parameters are always optional, the entry in the qdict will be
|
||||
omitted if the flag is not given.
|
||||
|
||||
Reviewed-by: Eric Blake <eblake@redhat.com>
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
monitor/hmp.c | 17 ++++++++++++++++-
|
||||
1 file changed, 16 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/monitor/hmp.c b/monitor/hmp.c
|
||||
index b20737e63c..b29dbb1833 100644
|
||||
--- a/monitor/hmp.c
|
||||
+++ b/monitor/hmp.c
|
||||
@@ -981,6 +981,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
|
||||
{
|
||||
const char *tmp = p;
|
||||
int skip_key = 0;
|
||||
+ int ret;
|
||||
/* option */
|
||||
|
||||
c = *typestr++;
|
||||
@@ -1003,8 +1004,22 @@ static QDict *monitor_parse_arguments(Monitor *mon,
|
||||
}
|
||||
if (skip_key) {
|
||||
p = tmp;
|
||||
+ } else if (*typestr == 'S') {
|
||||
+ /* has option with string value */
|
||||
+ typestr++;
|
||||
+ tmp = p++;
|
||||
+ while (qemu_isspace(*p)) {
|
||||
+ p++;
|
||||
+ }
|
||||
+ ret = get_str(buf, sizeof(buf), &p);
|
||||
+ if (ret < 0) {
|
||||
+ monitor_printf(mon, "%s: value expected for -%c\n",
|
||||
+ cmd->name, *tmp);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+ qdict_put_str(qdict, key, buf);
|
||||
} else {
|
||||
- /* has option */
|
||||
+ /* has boolean option */
|
||||
p++;
|
||||
qdict_put_bool(qdict, key, true);
|
||||
}
|
69
debian/patches/extra/0002-scsi-megasas-Internal-cdbs-have-16-byte-length.patch
vendored
Normal file
69
debian/patches/extra/0002-scsi-megasas-Internal-cdbs-have-16-byte-length.patch
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Guenter Roeck <linux@roeck-us.net>
|
||||
Date: Tue, 28 Feb 2023 09:11:29 -0800
|
||||
Subject: [PATCH] scsi: megasas: Internal cdbs have 16-byte length
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Host drivers do not necessarily set cdb_len in megasas io commands.
|
||||
With commits 6d1511cea0 ("scsi: Reject commands if the CDB length
|
||||
exceeds buf_len") and fe9d8927e2 ("scsi: Add buf_len parameter to
|
||||
scsi_req_new()"), this results in failures to boot Linux from affected
|
||||
SCSI drives because cdb_len is set to 0 by the host driver.
|
||||
Set the cdb length to its actual size to solve the problem.
|
||||
|
||||
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
|
||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
(picked-up from https://lists.nongnu.org/archive/html/qemu-devel/2023-02/msg08653.html)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/scsi/megasas.c | 14 ++------------
|
||||
1 file changed, 2 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
|
||||
index 2d0c607177..97e51733af 100644
|
||||
--- a/hw/scsi/megasas.c
|
||||
+++ b/hw/scsi/megasas.c
|
||||
@@ -1781,7 +1781,7 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
|
||||
uint8_t cdb[16];
|
||||
int len;
|
||||
struct SCSIDevice *sdev = NULL;
|
||||
- int target_id, lun_id, cdb_len;
|
||||
+ int target_id, lun_id;
|
||||
|
||||
lba_count = le32_to_cpu(cmd->frame->io.header.data_len);
|
||||
lba_start_lo = le32_to_cpu(cmd->frame->io.lba_lo);
|
||||
@@ -1790,7 +1790,6 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
|
||||
|
||||
target_id = cmd->frame->header.target_id;
|
||||
lun_id = cmd->frame->header.lun_id;
|
||||
- cdb_len = cmd->frame->header.cdb_len;
|
||||
|
||||
if (target_id < MFI_MAX_LD && lun_id == 0) {
|
||||
sdev = scsi_device_find(&s->bus, 0, target_id, lun_id);
|
||||
@@ -1805,15 +1804,6 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
|
||||
return MFI_STAT_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
- if (cdb_len > 16) {
|
||||
- trace_megasas_scsi_invalid_cdb_len(
|
||||
- mfi_frame_desc(frame_cmd), 1, target_id, lun_id, cdb_len);
|
||||
- megasas_write_sense(cmd, SENSE_CODE(INVALID_OPCODE));
|
||||
- cmd->frame->header.scsi_status = CHECK_CONDITION;
|
||||
- s->event_count++;
|
||||
- return MFI_STAT_SCSI_DONE_WITH_ERROR;
|
||||
- }
|
||||
-
|
||||
cmd->iov_size = lba_count * sdev->blocksize;
|
||||
if (megasas_map_sgl(s, cmd, &cmd->frame->io.sgl)) {
|
||||
megasas_write_sense(cmd, SENSE_CODE(TARGET_FAILURE));
|
||||
@@ -1824,7 +1814,7 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
|
||||
|
||||
megasas_encode_lba(cdb, lba_start, lba_count, is_write);
|
||||
cmd->req = scsi_req_new(sdev, cmd->index,
|
||||
- lun_id, cdb, cdb_len, cmd);
|
||||
+ lun_id, cdb, sizeof(cdb), cmd);
|
||||
if (!cmd->req) {
|
||||
trace_megasas_scsi_req_alloc_failed(
|
||||
mfi_frame_desc(frame_cmd), target_id, lun_id);
|
100
debian/patches/extra/0003-ide-avoid-potential-deadlock-when-draining-during-tr.patch
vendored
Normal file
100
debian/patches/extra/0003-ide-avoid-potential-deadlock-when-draining-during-tr.patch
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Tue, 7 Mar 2023 15:03:02 +0100
|
||||
Subject: [PATCH] ide: avoid potential deadlock when draining during trim
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The deadlock can happen as follows:
|
||||
1. ide_issue_trim is called, and increments the in_flight counter.
|
||||
2. ide_issue_trim_cb calls blk_aio_pdiscard.
|
||||
3. Somebody else starts draining (e.g. backup to insert the cbw node).
|
||||
4. ide_issue_trim_cb is called as the completion callback for
|
||||
blk_aio_pdiscard.
|
||||
5. ide_issue_trim_cb issues yet another blk_aio_pdiscard request.
|
||||
6. The request is added to the wait queue via blk_wait_while_drained,
|
||||
because draining has been started.
|
||||
7. Nobody ever decrements the in_flight counter and draining can't
|
||||
finish. This would be done by ide_trim_bh_cb, which is called after
|
||||
ide_issue_trim_cb has issued its last request, but
|
||||
ide_issue_trim_cb is not called anymore, because it's the
|
||||
completion callback of blk_aio_pdiscard, which waits on draining.
|
||||
|
||||
Quoting Hanna Czenczek:
|
||||
> The point of 7e5cdb345f was that we need any in-flight count to
|
||||
> accompany a set s->bus->dma->aiocb. While blk_aio_pdiscard() is
|
||||
> happening, we don’t necessarily need another count. But we do need
|
||||
> it while there is no blk_aio_pdiscard().
|
||||
> ide_issue_trim_cb() returns in two cases (and, recursively through
|
||||
> its callers, leaves s->bus->dma->aiocb set):
|
||||
> 1. After calling blk_aio_pdiscard(), which will keep an in-flight
|
||||
> count,
|
||||
> 2. After calling replay_bh_schedule_event() (i.e.
|
||||
> qemu_bh_schedule()), which does not keep an in-flight count.
|
||||
|
||||
Thus, even after moving the blk_inc_in_flight to above the
|
||||
replay_bh_schedule_event call, the invariant "ide_issue_trim_cb
|
||||
returns with an accompanying in-flight count" is still satisfied.
|
||||
|
||||
However, the issue 7e5cdb345f fixed for canceling resurfaces, because
|
||||
ide_cancel_dma_sync assumes that it just needs to drain once. But now
|
||||
the in_flight count is not consistently > 0 during the trim operation.
|
||||
So, change it to drain until !s->bus->dma->aiocb, which means that the
|
||||
operation finished (s->bus->dma->aiocb is cleared by ide_set_inactive
|
||||
via the ide_dma_cb when the end of the transfer is reached).
|
||||
|
||||
Discussion here:
|
||||
https://lists.nongnu.org/archive/html/qemu-devel/2023-03/msg02506.html
|
||||
|
||||
Fixes: 7e5cdb345f ("ide: Increment BB in-flight counter for TRIM BH")
|
||||
Suggested-by: Hanna Czenczek <hreitz@redhat.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/ide/core.c | 12 ++++++------
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/hw/ide/core.c b/hw/ide/core.c
|
||||
index e8cb2dac92..3b21acf651 100644
|
||||
--- a/hw/ide/core.c
|
||||
+++ b/hw/ide/core.c
|
||||
@@ -456,7 +456,7 @@ static void ide_trim_bh_cb(void *opaque)
|
||||
iocb->bh = NULL;
|
||||
qemu_aio_unref(iocb);
|
||||
|
||||
- /* Paired with an increment in ide_issue_trim() */
|
||||
+ /* Paired with an increment in ide_issue_trim_cb() */
|
||||
blk_dec_in_flight(blk);
|
||||
}
|
||||
|
||||
@@ -516,6 +516,8 @@ static void ide_issue_trim_cb(void *opaque, int ret)
|
||||
done:
|
||||
iocb->aiocb = NULL;
|
||||
if (iocb->bh) {
|
||||
+ /* Paired with a decrement in ide_trim_bh_cb() */
|
||||
+ blk_inc_in_flight(s->blk);
|
||||
replay_bh_schedule_event(iocb->bh);
|
||||
}
|
||||
}
|
||||
@@ -528,9 +530,6 @@ BlockAIOCB *ide_issue_trim(
|
||||
IDEDevice *dev = s->unit ? s->bus->slave : s->bus->master;
|
||||
TrimAIOCB *iocb;
|
||||
|
||||
- /* Paired with a decrement in ide_trim_bh_cb() */
|
||||
- blk_inc_in_flight(s->blk);
|
||||
-
|
||||
iocb = blk_aio_get(&trim_aiocb_info, s->blk, cb, cb_opaque);
|
||||
iocb->s = s;
|
||||
iocb->bh = qemu_bh_new_guarded(ide_trim_bh_cb, iocb,
|
||||
@@ -754,8 +753,9 @@ void ide_cancel_dma_sync(IDEState *s)
|
||||
*/
|
||||
if (s->bus->dma->aiocb) {
|
||||
trace_ide_cancel_dma_sync_remaining();
|
||||
- blk_drain(s->blk);
|
||||
- assert(s->bus->dma->aiocb == NULL);
|
||||
+ while (s->bus->dma->aiocb) {
|
||||
+ blk_drain(s->blk);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
@@ -1,477 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Wed, 25 Aug 2021 11:14:13 +0200
|
||||
Subject: [PATCH] monitor: refactor set/expire_password and allow VNC display
|
||||
id
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
It is possible to specify more than one VNC server on the command line,
|
||||
either with an explicit ID or the auto-generated ones à la "default",
|
||||
"vnc2", "vnc3", ...
|
||||
|
||||
It is not possible to change the password on one of these extra VNC
|
||||
displays though. Fix this by adding a "display" parameter to the
|
||||
"set_password" and "expire_password" QMP and HMP commands.
|
||||
|
||||
For HMP, the display is specified using the "-d" value flag.
|
||||
|
||||
For QMP, the schema is updated to explicitly express the supported
|
||||
variants of the commands with protocol-discriminated unions.
|
||||
|
||||
Suggested-by: Eric Blake <eblake@redhat.com>
|
||||
Suggested-by: Markus Armbruster <armbru@redhat.com>
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hmp-commands.hx | 24 ++++---
|
||||
monitor/hmp-cmds.c | 57 +++++++++++++++-
|
||||
monitor/qmp-cmds.c | 62 ++++++-----------
|
||||
qapi/ui.json | 165 ++++++++++++++++++++++++++++++++++++++-------
|
||||
4 files changed, 231 insertions(+), 77 deletions(-)
|
||||
|
||||
diff --git a/hmp-commands.hx b/hmp-commands.hx
|
||||
index 70a9136ac2..5efb47fc32 100644
|
||||
--- a/hmp-commands.hx
|
||||
+++ b/hmp-commands.hx
|
||||
@@ -1514,33 +1514,35 @@ ERST
|
||||
|
||||
{
|
||||
.name = "set_password",
|
||||
- .args_type = "protocol:s,password:s,connected:s?",
|
||||
- .params = "protocol password action-if-connected",
|
||||
+ .args_type = "protocol:s,password:s,display:-dS,connected:s?",
|
||||
+ .params = "protocol password [-d display] [action-if-connected]",
|
||||
.help = "set spice/vnc password",
|
||||
.cmd = hmp_set_password,
|
||||
},
|
||||
|
||||
SRST
|
||||
-``set_password [ vnc | spice ] password [ action-if-connected ]``
|
||||
- Change spice/vnc password. *action-if-connected* specifies what
|
||||
- should happen in case a connection is established: *fail* makes the
|
||||
- password change fail. *disconnect* changes the password and
|
||||
+``set_password [ vnc | spice ] password [ -d display ] [ action-if-connected ]``
|
||||
+ Change spice/vnc password. *display* can be used with 'vnc' to specify
|
||||
+ which display to set the password on. *action-if-connected* specifies
|
||||
+ what should happen in case a connection is established: *fail* makes
|
||||
+ the password change fail. *disconnect* changes the password and
|
||||
disconnects the client. *keep* changes the password and keeps the
|
||||
connection up. *keep* is the default.
|
||||
ERST
|
||||
|
||||
{
|
||||
.name = "expire_password",
|
||||
- .args_type = "protocol:s,time:s",
|
||||
- .params = "protocol time",
|
||||
+ .args_type = "protocol:s,time:s,display:-dS",
|
||||
+ .params = "protocol time [-d display]",
|
||||
.help = "set spice/vnc password expire-time",
|
||||
.cmd = hmp_expire_password,
|
||||
},
|
||||
|
||||
SRST
|
||||
-``expire_password [ vnc | spice ]`` *expire-time*
|
||||
- Specify when a password for spice/vnc becomes
|
||||
- invalid. *expire-time* accepts:
|
||||
+``expire_password [ vnc | spice ] expire-time [ -d display ]``
|
||||
+ Specify when a password for spice/vnc becomes invalid.
|
||||
+ *display* behaves the same as in ``set_password``.
|
||||
+ *expire-time* accepts:
|
||||
|
||||
``now``
|
||||
Invalidate password instantly.
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index 9c91bf93e9..2e91ccb738 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -1384,10 +1384,41 @@ void hmp_set_password(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *protocol = qdict_get_str(qdict, "protocol");
|
||||
const char *password = qdict_get_str(qdict, "password");
|
||||
+ const char *display = qdict_get_try_str(qdict, "display");
|
||||
const char *connected = qdict_get_try_str(qdict, "connected");
|
||||
Error *err = NULL;
|
||||
+ DisplayProtocol proto;
|
||||
|
||||
- qmp_set_password(protocol, password, !!connected, connected, &err);
|
||||
+ SetPasswordOptions opts = {
|
||||
+ .password = g_strdup(password),
|
||||
+ .u.vnc.display = NULL,
|
||||
+ };
|
||||
+
|
||||
+ proto = qapi_enum_parse(&DisplayProtocol_lookup, protocol,
|
||||
+ DISPLAY_PROTOCOL_VNC, &err);
|
||||
+ if (err) {
|
||||
+ hmp_handle_error(mon, err);
|
||||
+ return;
|
||||
+ }
|
||||
+ opts.protocol = proto;
|
||||
+
|
||||
+ if (proto == DISPLAY_PROTOCOL_VNC) {
|
||||
+ opts.u.vnc.has_display = !!display;
|
||||
+ opts.u.vnc.display = g_strdup(display);
|
||||
+ } else if (proto == DISPLAY_PROTOCOL_SPICE) {
|
||||
+ opts.u.spice.has_connected = !!connected;
|
||||
+ opts.u.spice.connected =
|
||||
+ qapi_enum_parse(&SetPasswordAction_lookup, connected,
|
||||
+ SET_PASSWORD_ACTION_KEEP, &err);
|
||||
+ if (err) {
|
||||
+ hmp_handle_error(mon, err);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ qmp_set_password(&opts, &err);
|
||||
+ g_free(opts.password);
|
||||
+ g_free(opts.u.vnc.display);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
@@ -1395,9 +1426,31 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *protocol = qdict_get_str(qdict, "protocol");
|
||||
const char *whenstr = qdict_get_str(qdict, "time");
|
||||
+ const char *display = qdict_get_try_str(qdict, "display");
|
||||
Error *err = NULL;
|
||||
+ DisplayProtocol proto;
|
||||
|
||||
- qmp_expire_password(protocol, whenstr, &err);
|
||||
+ ExpirePasswordOptions opts = {
|
||||
+ .time = g_strdup(whenstr),
|
||||
+ .u.vnc.display = NULL,
|
||||
+ };
|
||||
+
|
||||
+ proto = qapi_enum_parse(&DisplayProtocol_lookup, protocol,
|
||||
+ DISPLAY_PROTOCOL_VNC, &err);
|
||||
+ if (err) {
|
||||
+ hmp_handle_error(mon, err);
|
||||
+ return;
|
||||
+ }
|
||||
+ opts.protocol = proto;
|
||||
+
|
||||
+ if (proto == DISPLAY_PROTOCOL_VNC) {
|
||||
+ opts.u.vnc.has_display = !!display;
|
||||
+ opts.u.vnc.display = g_strdup(display);
|
||||
+ }
|
||||
+
|
||||
+ qmp_expire_password(&opts, &err);
|
||||
+ g_free(opts.time);
|
||||
+ g_free(opts.u.vnc.display);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
|
||||
index 343353e27a..729ca7cceb 100644
|
||||
--- a/monitor/qmp-cmds.c
|
||||
+++ b/monitor/qmp-cmds.c
|
||||
@@ -167,45 +167,30 @@ void qmp_system_wakeup(Error **errp)
|
||||
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, errp);
|
||||
}
|
||||
|
||||
-void qmp_set_password(const char *protocol, const char *password,
|
||||
- bool has_connected, const char *connected, Error **errp)
|
||||
+void qmp_set_password(SetPasswordOptions *opts, Error **errp)
|
||||
{
|
||||
- int disconnect_if_connected = 0;
|
||||
- int fail_if_connected = 0;
|
||||
- int rc;
|
||||
+ bool disconnect_if_connected = false;
|
||||
+ bool fail_if_connected = false;
|
||||
+ int rc = 0;
|
||||
|
||||
- if (has_connected) {
|
||||
- if (strcmp(connected, "fail") == 0) {
|
||||
- fail_if_connected = 1;
|
||||
- } else if (strcmp(connected, "disconnect") == 0) {
|
||||
- disconnect_if_connected = 1;
|
||||
- } else if (strcmp(connected, "keep") == 0) {
|
||||
- /* nothing */
|
||||
- } else {
|
||||
- error_setg(errp, QERR_INVALID_PARAMETER, "connected");
|
||||
- return;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (strcmp(protocol, "spice") == 0) {
|
||||
+ if (opts->protocol == DISPLAY_PROTOCOL_SPICE) {
|
||||
if (!qemu_using_spice(errp)) {
|
||||
return;
|
||||
}
|
||||
- rc = qemu_spice.set_passwd(password, fail_if_connected,
|
||||
+ if (opts->u.spice.has_connected) {
|
||||
+ fail_if_connected =
|
||||
+ opts->u.spice.connected == SET_PASSWORD_ACTION_FAIL;
|
||||
+ disconnect_if_connected =
|
||||
+ opts->u.spice.connected == SET_PASSWORD_ACTION_DISCONNECT;
|
||||
+ }
|
||||
+ rc = qemu_spice.set_passwd(opts->password, fail_if_connected,
|
||||
disconnect_if_connected);
|
||||
- } else if (strcmp(protocol, "vnc") == 0) {
|
||||
- if (fail_if_connected || disconnect_if_connected) {
|
||||
- /* vnc supports "connected=keep" only */
|
||||
- error_setg(errp, QERR_INVALID_PARAMETER, "connected");
|
||||
- return;
|
||||
- }
|
||||
+ } else if (opts->protocol == DISPLAY_PROTOCOL_VNC) {
|
||||
/* Note that setting an empty password will not disable login through
|
||||
* this interface. */
|
||||
- rc = vnc_display_password(NULL, password);
|
||||
- } else {
|
||||
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol",
|
||||
- "'vnc' or 'spice'");
|
||||
- return;
|
||||
+ rc = vnc_display_password(
|
||||
+ opts->u.vnc.has_display ? opts->u.vnc.display : NULL,
|
||||
+ opts->password);
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
@@ -213,11 +198,11 @@ void qmp_set_password(const char *protocol, const char *password,
|
||||
}
|
||||
}
|
||||
|
||||
-void qmp_expire_password(const char *protocol, const char *whenstr,
|
||||
- Error **errp)
|
||||
+void qmp_expire_password(ExpirePasswordOptions *opts, Error **errp)
|
||||
{
|
||||
time_t when;
|
||||
int rc;
|
||||
+ const char* whenstr = opts->time;
|
||||
|
||||
if (strcmp(whenstr, "now") == 0) {
|
||||
when = 0;
|
||||
@@ -229,17 +214,14 @@ void qmp_expire_password(const char *protocol, const char *whenstr,
|
||||
when = strtoull(whenstr, NULL, 10);
|
||||
}
|
||||
|
||||
- if (strcmp(protocol, "spice") == 0) {
|
||||
+ if (opts->protocol == DISPLAY_PROTOCOL_SPICE) {
|
||||
if (!qemu_using_spice(errp)) {
|
||||
return;
|
||||
}
|
||||
rc = qemu_spice.set_pw_expire(when);
|
||||
- } else if (strcmp(protocol, "vnc") == 0) {
|
||||
- rc = vnc_display_pw_expire(NULL, when);
|
||||
- } else {
|
||||
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol",
|
||||
- "'vnc' or 'spice'");
|
||||
- return;
|
||||
+ } else if (opts->protocol == DISPLAY_PROTOCOL_VNC) {
|
||||
+ rc = vnc_display_pw_expire(
|
||||
+ opts->u.vnc.has_display ? opts->u.vnc.display : NULL, when);
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
diff --git a/qapi/ui.json b/qapi/ui.json
|
||||
index d7567ac866..4244c62c30 100644
|
||||
--- a/qapi/ui.json
|
||||
+++ b/qapi/ui.json
|
||||
@@ -9,22 +9,23 @@
|
||||
{ 'include': 'common.json' }
|
||||
{ 'include': 'sockets.json' }
|
||||
|
||||
+##
|
||||
+# @DisplayProtocol:
|
||||
+#
|
||||
+# Display protocols which support changing password options.
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'enum': 'DisplayProtocol',
|
||||
+ 'data': [ { 'name': 'vnc', 'if': 'CONFIG_VNC' },
|
||||
+ { 'name': 'spice', 'if': 'CONFIG_SPICE' } ] }
|
||||
+
|
||||
##
|
||||
# @set_password:
|
||||
#
|
||||
# Sets the password of a remote display session.
|
||||
#
|
||||
-# @protocol: - 'vnc' to modify the VNC server password
|
||||
-# - 'spice' to modify the Spice server password
|
||||
-#
|
||||
-# @password: the new password
|
||||
-#
|
||||
-# @connected: how to handle existing clients when changing the
|
||||
-# password. If nothing is specified, defaults to 'keep'
|
||||
-# 'fail' to fail the command if clients are connected
|
||||
-# 'disconnect' to disconnect existing clients
|
||||
-# 'keep' to maintain existing clients
|
||||
-#
|
||||
# Returns: - Nothing on success
|
||||
# - If Spice is not enabled, DeviceNotFound
|
||||
#
|
||||
@@ -37,16 +38,123 @@
|
||||
# <- { "return": {} }
|
||||
#
|
||||
##
|
||||
-{ 'command': 'set_password',
|
||||
- 'data': {'protocol': 'str', 'password': 'str', '*connected': 'str'} }
|
||||
+{ 'command': 'set_password', 'boxed': true, 'data': 'SetPasswordOptions' }
|
||||
+
|
||||
+##
|
||||
+# @SetPasswordOptions:
|
||||
+#
|
||||
+# Data required to set a new password on a display server protocol.
|
||||
+#
|
||||
+# @protocol: - 'vnc' to modify the VNC server password
|
||||
+# - 'spice' to modify the Spice server password
|
||||
+#
|
||||
+# @password: the new password
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'union': 'SetPasswordOptions',
|
||||
+ 'base': { 'protocol': 'DisplayProtocol',
|
||||
+ 'password': 'str' },
|
||||
+ 'discriminator': 'protocol',
|
||||
+ 'data': { 'vnc': 'SetPasswordOptionsVnc',
|
||||
+ 'spice': 'SetPasswordOptionsSpice' } }
|
||||
+
|
||||
+##
|
||||
+# @SetPasswordAction:
|
||||
+#
|
||||
+# An action to take on changing a password on a connection with active clients.
|
||||
+#
|
||||
+# @fail: fail the command if clients are connected
|
||||
+#
|
||||
+# @disconnect: disconnect existing clients
|
||||
+#
|
||||
+# @keep: maintain existing clients
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'enum': 'SetPasswordAction',
|
||||
+ 'data': [ 'fail', 'disconnect', 'keep' ] }
|
||||
+
|
||||
+##
|
||||
+# @SetPasswordActionVnc:
|
||||
+#
|
||||
+# See @SetPasswordAction. VNC only supports the keep action. 'connection'
|
||||
+# should just be omitted for VNC, this is kept for backwards compatibility.
|
||||
+#
|
||||
+# @keep: maintain existing clients
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'enum': 'SetPasswordActionVnc',
|
||||
+ 'data': [ 'keep' ] }
|
||||
+
|
||||
+##
|
||||
+# @SetPasswordOptionsSpice:
|
||||
+#
|
||||
+# Options for set_password specific to the VNC procotol.
|
||||
+#
|
||||
+# @connected: How to handle existing clients when changing the
|
||||
+# password. If nothing is specified, defaults to 'keep'.
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'SetPasswordOptionsSpice',
|
||||
+ 'data': { '*connected': 'SetPasswordAction' } }
|
||||
+
|
||||
+##
|
||||
+# @SetPasswordOptionsVnc:
|
||||
+#
|
||||
+# Options for set_password specific to the VNC procotol.
|
||||
+#
|
||||
+# @display: The id of the display where the password should be changed.
|
||||
+# Defaults to the first.
|
||||
+#
|
||||
+# @connected: How to handle existing clients when changing the
|
||||
+# password.
|
||||
+#
|
||||
+# Features:
|
||||
+# @deprecated: For VNC, @connected will always be 'keep', parameter should be
|
||||
+# omitted.
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'SetPasswordOptionsVnc',
|
||||
+ 'data': { '*display': 'str',
|
||||
+ '*connected': { 'type': 'SetPasswordActionVnc',
|
||||
+ 'features': ['deprecated'] } } }
|
||||
|
||||
##
|
||||
# @expire_password:
|
||||
#
|
||||
# Expire the password of a remote display server.
|
||||
#
|
||||
-# @protocol: the name of the remote display protocol 'vnc' or 'spice'
|
||||
+# Returns: - Nothing on success
|
||||
+# - If @protocol is 'spice' and Spice is not active, DeviceNotFound
|
||||
#
|
||||
+# Since: 0.14
|
||||
+#
|
||||
+# Example:
|
||||
+#
|
||||
+# -> { "execute": "expire_password", "arguments": { "protocol": "vnc",
|
||||
+# "time": "+60" } }
|
||||
+# <- { "return": {} }
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'expire_password', 'boxed': true, 'data': 'ExpirePasswordOptions' }
|
||||
+
|
||||
+##
|
||||
+# @ExpirePasswordOptions:
|
||||
+#
|
||||
+# Data required to set password expiration on a display server protocol.
|
||||
+#
|
||||
+# @protocol: - 'vnc' to modify the VNC server expiration
|
||||
+# - 'spice' to modify the Spice server expiration
|
||||
+
|
||||
# @time: when to expire the password.
|
||||
#
|
||||
# - 'now' to expire the password immediately
|
||||
@@ -54,24 +162,33 @@
|
||||
# - '+INT' where INT is the number of seconds from now (integer)
|
||||
# - 'INT' where INT is the absolute time in seconds
|
||||
#
|
||||
-# Returns: - Nothing on success
|
||||
-# - If @protocol is 'spice' and Spice is not active, DeviceNotFound
|
||||
-#
|
||||
-# Since: 0.14
|
||||
-#
|
||||
# Notes: Time is relative to the server and currently there is no way to
|
||||
# coordinate server time with client time. It is not recommended to
|
||||
# use the absolute time version of the @time parameter unless you're
|
||||
# sure you are on the same machine as the QEMU instance.
|
||||
#
|
||||
-# Example:
|
||||
+# Since: 6.2
|
||||
#
|
||||
-# -> { "execute": "expire_password", "arguments": { "protocol": "vnc",
|
||||
-# "time": "+60" } }
|
||||
-# <- { "return": {} }
|
||||
+##
|
||||
+{ 'union': 'ExpirePasswordOptions',
|
||||
+ 'base': { 'protocol': 'DisplayProtocol',
|
||||
+ 'time': 'str' },
|
||||
+ 'discriminator': 'protocol',
|
||||
+ 'data': { 'vnc': 'ExpirePasswordOptionsVnc' } }
|
||||
+
|
||||
+##
|
||||
+# @ExpirePasswordOptionsVnc:
|
||||
+#
|
||||
+# Options for expire_password specific to the VNC procotol.
|
||||
+#
|
||||
+# @display: The id of the display where the expiration should be changed.
|
||||
+# Defaults to the first.
|
||||
+#
|
||||
+# Since: 6.2
|
||||
#
|
||||
##
|
||||
-{ 'command': 'expire_password', 'data': {'protocol': 'str', 'time': 'str'} }
|
||||
+{ 'struct': 'ExpirePasswordOptionsVnc',
|
||||
+ 'data': { '*display': 'str' } }
|
||||
|
||||
##
|
||||
# @screendump:
|
45
debian/patches/extra/0004-Revert-x86-acpi-workaround-Windows-not-handling-name.patch
vendored
Normal file
45
debian/patches/extra/0004-Revert-x86-acpi-workaround-Windows-not-handling-name.patch
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Fri, 17 Nov 2023 11:18:06 +0100
|
||||
Subject: [PATCH] Revert "x86: acpi: workaround Windows not handling name
|
||||
references in Package properly"
|
||||
|
||||
This reverts commit 44d975ef340e2f21f236f9520c53e1b30d2213a4.
|
||||
|
||||
As reported in the community forum [0] and reproduced locally this
|
||||
breaks VirtIO network adapters in (at least) the German ISO of Windows
|
||||
Server 2022. The fix itself was for
|
||||
|
||||
> Issue is not fatal but as result acpi-index/"PCI Label ID" property
|
||||
> is either not shown in device details page or shows incorrect value.
|
||||
|
||||
so revert and tolerate that as a stop-gap, rather than have the
|
||||
devices not working at all.
|
||||
|
||||
[0]: https://forum.proxmox.com/threads/92094/post-605684
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/i386/acpi-build.c | 8 ++------
|
||||
1 file changed, 2 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
|
||||
index 53f804ac16..9b1b9f0412 100644
|
||||
--- a/hw/i386/acpi-build.c
|
||||
+++ b/hw/i386/acpi-build.c
|
||||
@@ -347,13 +347,9 @@ Aml *aml_pci_device_dsm(void)
|
||||
{
|
||||
Aml *params = aml_local(0);
|
||||
Aml *pkg = aml_package(2);
|
||||
- aml_append(pkg, aml_int(0));
|
||||
- aml_append(pkg, aml_int(0));
|
||||
+ aml_append(pkg, aml_name("BSEL"));
|
||||
+ aml_append(pkg, aml_name("ASUN"));
|
||||
aml_append(method, aml_store(pkg, params));
|
||||
- aml_append(method,
|
||||
- aml_store(aml_name("BSEL"), aml_index(params, aml_int(0))));
|
||||
- aml_append(method,
|
||||
- aml_store(aml_name("ASUN"), aml_index(params, aml_int(1))));
|
||||
aml_append(method,
|
||||
aml_return(aml_call5("PDSM", aml_arg(0), aml_arg(1),
|
||||
aml_arg(2), aml_arg(3), params))
|
35
debian/patches/extra/0005-block-copy-before-write-use-uint64_t-for-timeout-in-.patch
vendored
Normal file
35
debian/patches/extra/0005-block-copy-before-write-use-uint64_t-for-timeout-in-.patch
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Mon, 29 Apr 2024 15:41:11 +0200
|
||||
Subject: [PATCH] block/copy-before-write: use uint64_t for timeout in
|
||||
nanoseconds
|
||||
|
||||
rather than the uint32_t for which the maximum is slightly more than 4
|
||||
seconds and larger values would overflow. The QAPI interface allows
|
||||
specifying the number of seconds, so only values 0 to 4 are safe right
|
||||
now, other values lead to a much lower timeout than a user expects.
|
||||
|
||||
The block_copy() call where this is used already takes a uint64_t for
|
||||
the timeout, so no change required there.
|
||||
|
||||
Fixes: 6db7fd1ca9 ("block/copy-before-write: implement cbw-timeout option")
|
||||
Reported-by: Friedrich Weber <f.weber@proxmox.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Tested-by: Friedrich Weber <f.weber@proxmox.com>
|
||||
---
|
||||
block/copy-before-write.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
|
||||
index 8aba27a71d..026fa9840f 100644
|
||||
--- a/block/copy-before-write.c
|
||||
+++ b/block/copy-before-write.c
|
||||
@@ -43,7 +43,7 @@ typedef struct BDRVCopyBeforeWriteState {
|
||||
BlockCopyState *bcs;
|
||||
BdrvChild *target;
|
||||
OnCbwError on_cbw_error;
|
||||
- uint32_t cbw_timeout_ns;
|
||||
+ uint64_t cbw_timeout_ns;
|
||||
|
||||
/*
|
||||
* @lock: protects access to @access_bitmap, @done_bitmap and
|
55
debian/patches/extra/0006-block-copy-before-write-fix-permission.patch
vendored
Normal file
55
debian/patches/extra/0006-block-copy-before-write-fix-permission.patch
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
Date: Thu, 11 Apr 2024 11:29:22 +0200
|
||||
Subject: [PATCH] block/copy-before-write: fix permission
|
||||
|
||||
In case when source node does not have any parents, the condition still
|
||||
works as required: backup job do create the parent by
|
||||
|
||||
block_job_create -> block_job_add_bdrv -> bdrv_root_attach_child
|
||||
|
||||
Still, in this case checking @perm variable doesn't work, as backup job
|
||||
creates the root blk with empty permissions (as it rely on CBW filter
|
||||
to require correct permissions and don't want to create extra
|
||||
conflicts).
|
||||
|
||||
So, we should not check @perm.
|
||||
|
||||
The hack may be dropped entirely when transactional insertion of
|
||||
filter (when we don't try to recalculate permissions in intermediate
|
||||
state, when filter does conflict with original parent of the source
|
||||
node) merged (old big series
|
||||
"[PATCH v5 00/45] Transactional block-graph modifying API"[1] and it's
|
||||
current in-flight part is "[PATCH v8 0/7] blockdev-replace"[2])
|
||||
|
||||
[1] https://patchew.org/QEMU/20220330212902.590099-1-vsementsov@openvz.org/
|
||||
[2] https://patchew.org/QEMU/20231017184444.932733-1-vsementsov@yandex-team.ru/
|
||||
|
||||
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/copy-before-write.c | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
|
||||
index 026fa9840f..5a9456d426 100644
|
||||
--- a/block/copy-before-write.c
|
||||
+++ b/block/copy-before-write.c
|
||||
@@ -364,9 +364,13 @@ cbw_child_perm(BlockDriverState *bs, BdrvChild *c, BdrvChildRole role,
|
||||
perm, shared, nperm, nshared);
|
||||
|
||||
if (!QLIST_EMPTY(&bs->parents)) {
|
||||
- if (perm & BLK_PERM_WRITE) {
|
||||
- *nperm = *nperm | BLK_PERM_CONSISTENT_READ;
|
||||
- }
|
||||
+ /*
|
||||
+ * Note, that source child may be shared with backup job. Backup job
|
||||
+ * does create own blk parent on copy-before-write node, so this
|
||||
+ * works even if source node does not have any parents before backup
|
||||
+ * start
|
||||
+ */
|
||||
+ *nperm = *nperm | BLK_PERM_CONSISTENT_READ;
|
||||
*nshared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
|
||||
}
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hanna Reitz <hreitz@redhat.com>
|
||||
Date: Tue, 18 Jan 2022 17:59:59 +0100
|
||||
Subject: [PATCH] block/io: Update BSC only if want_zero is true
|
||||
|
||||
We update the block-status cache whenever we get new information from a
|
||||
bdrv_co_block_status() call to the block driver. However, if we have
|
||||
passed want_zero=false to that call, it may flag areas containing zeroes
|
||||
as data, and so we would update the block-status cache with wrong
|
||||
information.
|
||||
|
||||
Therefore, we should not update the cache with want_zero=false.
|
||||
|
||||
Reported-by: Nir Soffer <nsoffer@redhat.com>
|
||||
Fixes: 0bc329fbb00 ("block: block-status cache for data regions")
|
||||
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
||||
Message-Id: <20220118170000.49423-2-hreitz@redhat.com>
|
||||
Reviewed-by: Eric Blake <eblake@redhat.com>
|
||||
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||||
---
|
||||
block/io.c | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block/io.c b/block/io.c
|
||||
index bb0a254def..4e4cb556c5 100644
|
||||
--- a/block/io.c
|
||||
+++ b/block/io.c
|
||||
@@ -2497,8 +2497,12 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
|
||||
* non-protocol nodes, and then it is never used. However, filling
|
||||
* the cache requires an RCU update, so double check here to avoid
|
||||
* such an update if possible.
|
||||
+ *
|
||||
+ * Check want_zero, because we only want to update the cache when we
|
||||
+ * have accurate information about what is zero and what is data.
|
||||
*/
|
||||
- if (ret == (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) &&
|
||||
+ if (want_zero &&
|
||||
+ ret == (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) &&
|
||||
QLIST_EMPTY(&bs->children))
|
||||
{
|
||||
/*
|
48
debian/patches/extra/0007-block-copy-before-write-support-unligned-snapshot-di.patch
vendored
Normal file
48
debian/patches/extra/0007-block-copy-before-write-support-unligned-snapshot-di.patch
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
Date: Thu, 11 Apr 2024 11:29:23 +0200
|
||||
Subject: [PATCH] block/copy-before-write: support unligned snapshot-discard
|
||||
|
||||
First thing that crashes on unligned access here is
|
||||
bdrv_reset_dirty_bitmap(). Correct way is to align-down the
|
||||
snapshot-discard request.
|
||||
|
||||
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/copy-before-write.c | 16 +++++++++++++---
|
||||
1 file changed, 13 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
|
||||
index 5a9456d426..c0e70669a2 100644
|
||||
--- a/block/copy-before-write.c
|
||||
+++ b/block/copy-before-write.c
|
||||
@@ -325,14 +325,24 @@ static int coroutine_fn GRAPH_RDLOCK
|
||||
cbw_co_pdiscard_snapshot(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
{
|
||||
BDRVCopyBeforeWriteState *s = bs->opaque;
|
||||
+ uint32_t cluster_size = block_copy_cluster_size(s->bcs);
|
||||
+ int64_t aligned_offset = QEMU_ALIGN_UP(offset, cluster_size);
|
||||
+ int64_t aligned_end = QEMU_ALIGN_DOWN(offset + bytes, cluster_size);
|
||||
+ int64_t aligned_bytes;
|
||||
+
|
||||
+ if (aligned_end <= aligned_offset) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ aligned_bytes = aligned_end - aligned_offset;
|
||||
|
||||
WITH_QEMU_LOCK_GUARD(&s->lock) {
|
||||
- bdrv_reset_dirty_bitmap(s->access_bitmap, offset, bytes);
|
||||
+ bdrv_reset_dirty_bitmap(s->access_bitmap, aligned_offset,
|
||||
+ aligned_bytes);
|
||||
}
|
||||
|
||||
- block_copy_reset(s->bcs, offset, bytes);
|
||||
+ block_copy_reset(s->bcs, aligned_offset, aligned_bytes);
|
||||
|
||||
- return bdrv_co_pdiscard(s->target, offset, bytes);
|
||||
+ return bdrv_co_pdiscard(s->target, aligned_offset, aligned_bytes);
|
||||
}
|
||||
|
||||
static void GRAPH_RDLOCK cbw_refresh_filename(BlockDriverState *bs)
|
@@ -1,40 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hanna Reitz <hreitz@redhat.com>
|
||||
Date: Wed, 9 Feb 2022 15:02:52 +0100
|
||||
Subject: [PATCH] block/nbd: Delete reconnect delay timer when done
|
||||
|
||||
We start the reconnect delay timer to cancel the reconnection attempt
|
||||
after a while. Once nbd_co_do_establish_connection() has returned, this
|
||||
attempt is over, and we no longer need the timer.
|
||||
|
||||
Delete it before returning from nbd_reconnect_attempt(), so that it does
|
||||
not persist beyond the I/O request that was paused for reconnecting; we
|
||||
do not want it to fire in a drained section, because all sort of things
|
||||
can happen in such a section (e.g. the AioContext might be changed, and
|
||||
we do not want the timer to fire in the wrong context; or the BDS might
|
||||
even be deleted, and so the timer CB would access already-freed data).
|
||||
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
||||
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
||||
---
|
||||
block/nbd.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/block/nbd.c b/block/nbd.c
|
||||
index 5ef462db1b..b8e5a9b4cc 100644
|
||||
--- a/block/nbd.c
|
||||
+++ b/block/nbd.c
|
||||
@@ -353,6 +353,13 @@ static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s)
|
||||
}
|
||||
|
||||
nbd_co_do_establish_connection(s->bs, NULL);
|
||||
+
|
||||
+ /*
|
||||
+ * The reconnect attempt is done (maybe successfully, maybe not), so
|
||||
+ * we no longer need this timer. Delete it so it will not outlive
|
||||
+ * this I/O request (so draining removes all timers).
|
||||
+ */
|
||||
+ reconnect_delay_timer_del(s);
|
||||
}
|
||||
|
||||
static coroutine_fn int nbd_receive_replies(BDRVNBDState *s, uint64_t handle)
|
373
debian/patches/extra/0008-block-copy-before-write-create-block_copy-bitmap-in-.patch
vendored
Normal file
373
debian/patches/extra/0008-block-copy-before-write-create-block_copy-bitmap-in-.patch
vendored
Normal file
@@ -0,0 +1,373 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
Date: Thu, 11 Apr 2024 11:29:24 +0200
|
||||
Subject: [PATCH] block/copy-before-write: create block_copy bitmap in filter
|
||||
node
|
||||
|
||||
Currently block_copy creates copy_bitmap in source node. But that is in
|
||||
bad relation with .independent_close=true of copy-before-write filter:
|
||||
source node may be detached and removed before .bdrv_close() handler
|
||||
called, which should call block_copy_state_free(), which in turn should
|
||||
remove copy_bitmap.
|
||||
|
||||
That's all not ideal: it would be better if internal bitmap of
|
||||
block-copy object is not attached to any node. But that is not possible
|
||||
now.
|
||||
|
||||
The simplest solution is just create copy_bitmap in filter node, where
|
||||
anyway two other bitmaps are created.
|
||||
|
||||
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/block-copy.c | 3 +-
|
||||
block/copy-before-write.c | 2 +-
|
||||
include/block/block-copy.h | 1 +
|
||||
tests/qemu-iotests/257.out | 112 ++++++++++++++++++-------------------
|
||||
4 files changed, 60 insertions(+), 58 deletions(-)
|
||||
|
||||
diff --git a/block/block-copy.c b/block/block-copy.c
|
||||
index 9ee3dd7ef5..8fca2c3698 100644
|
||||
--- a/block/block-copy.c
|
||||
+++ b/block/block-copy.c
|
||||
@@ -351,6 +351,7 @@ static int64_t block_copy_calculate_cluster_size(BlockDriverState *target,
|
||||
}
|
||||
|
||||
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
|
||||
+ BlockDriverState *copy_bitmap_bs,
|
||||
const BdrvDirtyBitmap *bitmap,
|
||||
Error **errp)
|
||||
{
|
||||
@@ -367,7 +368,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- copy_bitmap = bdrv_create_dirty_bitmap(source->bs, cluster_size, NULL,
|
||||
+ copy_bitmap = bdrv_create_dirty_bitmap(copy_bitmap_bs, cluster_size, NULL,
|
||||
errp);
|
||||
if (!copy_bitmap) {
|
||||
return NULL;
|
||||
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
|
||||
index c0e70669a2..94db31512d 100644
|
||||
--- a/block/copy-before-write.c
|
||||
+++ b/block/copy-before-write.c
|
||||
@@ -468,7 +468,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) &
|
||||
bs->file->bs->supported_zero_flags);
|
||||
|
||||
- s->bcs = block_copy_state_new(bs->file, s->target, bitmap, errp);
|
||||
+ s->bcs = block_copy_state_new(bs->file, s->target, bs, bitmap, errp);
|
||||
if (!s->bcs) {
|
||||
error_prepend(errp, "Cannot create block-copy-state: ");
|
||||
return -EINVAL;
|
||||
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
|
||||
index 0700953ab8..8b41643bfa 100644
|
||||
--- a/include/block/block-copy.h
|
||||
+++ b/include/block/block-copy.h
|
||||
@@ -25,6 +25,7 @@ typedef struct BlockCopyState BlockCopyState;
|
||||
typedef struct BlockCopyCallState BlockCopyCallState;
|
||||
|
||||
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
|
||||
+ BlockDriverState *copy_bitmap_bs,
|
||||
const BdrvDirtyBitmap *bitmap,
|
||||
Error **errp);
|
||||
|
||||
diff --git a/tests/qemu-iotests/257.out b/tests/qemu-iotests/257.out
|
||||
index aa76131ca9..c33dd7f3a9 100644
|
||||
--- a/tests/qemu-iotests/257.out
|
||||
+++ b/tests/qemu-iotests/257.out
|
||||
@@ -120,16 +120,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -596,16 +596,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -865,16 +865,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -1341,16 +1341,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -1610,16 +1610,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -2086,16 +2086,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -2355,16 +2355,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -2831,16 +2831,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -3100,16 +3100,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -3576,16 +3576,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -3845,16 +3845,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -4321,16 +4321,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -4590,16 +4590,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
||||
@@ -5066,16 +5066,16 @@ write -P0x67 0x3fe0000 0x20000
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- }
|
||||
- ],
|
||||
- "drive0": [
|
||||
+ },
|
||||
{
|
||||
"busy": false,
|
||||
"count": 0,
|
||||
"granularity": 65536,
|
||||
"persistent": false,
|
||||
"recording": false
|
||||
- },
|
||||
+ }
|
||||
+ ],
|
||||
+ "drive0": [
|
||||
{
|
||||
"busy": false,
|
||||
"count": 458752,
|
@@ -1,34 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hanna Reitz <hreitz@redhat.com>
|
||||
Date: Wed, 9 Feb 2022 15:02:54 +0100
|
||||
Subject: [PATCH] block/nbd: Assert there are no timers when closed
|
||||
|
||||
Our two timers must not remain armed beyond nbd_clear_bdrvstate(), or
|
||||
they will access freed data when they fire.
|
||||
|
||||
This patch is separate from the patches that actually fix the issue
|
||||
(HEAD^^ and HEAD^) so that you can run the associated regression iotest
|
||||
(281) on a configuration that reproducibly exposes the bug.
|
||||
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
||||
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
||||
[FE: backport (open_timer doesn't exist yet in 6.2.0)]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/nbd.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/block/nbd.c b/block/nbd.c
|
||||
index b8e5a9b4cc..aab20125d8 100644
|
||||
--- a/block/nbd.c
|
||||
+++ b/block/nbd.c
|
||||
@@ -108,6 +108,9 @@ static void nbd_clear_bdrvstate(BlockDriverState *bs)
|
||||
|
||||
yank_unregister_instance(BLOCKDEV_YANK_INSTANCE(bs->node_name));
|
||||
|
||||
+ /* Must not leave timers behind that would access freed data */
|
||||
+ assert(!s->reconnect_delay_timer);
|
||||
+
|
||||
object_unref(OBJECT(s->tlscreds));
|
||||
qapi_free_SocketAddress(s->saddr);
|
||||
s->saddr = NULL;
|
@@ -1,90 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hanna Reitz <hreitz@redhat.com>
|
||||
Date: Wed, 9 Feb 2022 15:02:57 +0100
|
||||
Subject: [PATCH] block/nbd: Move s->ioc on AioContext change
|
||||
|
||||
s->ioc must always be attached to the NBD node's AioContext. If that
|
||||
context changes, s->ioc must be attached to the new context.
|
||||
|
||||
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2033626
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
||||
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
||||
[FE: backport (open_timer doesn't exist yet in 6.2.0)]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/nbd.c | 41 +++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 41 insertions(+)
|
||||
|
||||
diff --git a/block/nbd.c b/block/nbd.c
|
||||
index aab20125d8..a3896c7f5f 100644
|
||||
--- a/block/nbd.c
|
||||
+++ b/block/nbd.c
|
||||
@@ -2003,6 +2003,38 @@ static void nbd_cancel_in_flight(BlockDriverState *bs)
|
||||
nbd_co_establish_connection_cancel(s->conn);
|
||||
}
|
||||
|
||||
+static void nbd_attach_aio_context(BlockDriverState *bs,
|
||||
+ AioContext *new_context)
|
||||
+{
|
||||
+ BDRVNBDState *s = bs->opaque;
|
||||
+
|
||||
+ /*
|
||||
+ * The reconnect_delay_timer is scheduled in I/O paths when the
|
||||
+ * connection is lost, to cancel the reconnection attempt after a
|
||||
+ * given time. Once this attempt is done (successfully or not),
|
||||
+ * nbd_reconnect_attempt() ensures the timer is deleted before the
|
||||
+ * respective I/O request is resumed.
|
||||
+ * Since the AioContext can only be changed when a node is drained,
|
||||
+ * the reconnect_delay_timer cannot be active here.
|
||||
+ */
|
||||
+ assert(!s->reconnect_delay_timer);
|
||||
+
|
||||
+ if (s->ioc) {
|
||||
+ qio_channel_attach_aio_context(s->ioc, new_context);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void nbd_detach_aio_context(BlockDriverState *bs)
|
||||
+{
|
||||
+ BDRVNBDState *s = bs->opaque;
|
||||
+
|
||||
+ assert(!s->reconnect_delay_timer);
|
||||
+
|
||||
+ if (s->ioc) {
|
||||
+ qio_channel_detach_aio_context(s->ioc);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static BlockDriver bdrv_nbd = {
|
||||
.format_name = "nbd",
|
||||
.protocol_name = "nbd",
|
||||
@@ -2026,6 +2058,9 @@ static BlockDriver bdrv_nbd = {
|
||||
.bdrv_dirname = nbd_dirname,
|
||||
.strong_runtime_opts = nbd_strong_runtime_opts,
|
||||
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
|
||||
+
|
||||
+ .bdrv_attach_aio_context = nbd_attach_aio_context,
|
||||
+ .bdrv_detach_aio_context = nbd_detach_aio_context,
|
||||
};
|
||||
|
||||
static BlockDriver bdrv_nbd_tcp = {
|
||||
@@ -2051,6 +2086,9 @@ static BlockDriver bdrv_nbd_tcp = {
|
||||
.bdrv_dirname = nbd_dirname,
|
||||
.strong_runtime_opts = nbd_strong_runtime_opts,
|
||||
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
|
||||
+
|
||||
+ .bdrv_attach_aio_context = nbd_attach_aio_context,
|
||||
+ .bdrv_detach_aio_context = nbd_detach_aio_context,
|
||||
};
|
||||
|
||||
static BlockDriver bdrv_nbd_unix = {
|
||||
@@ -2076,6 +2114,9 @@ static BlockDriver bdrv_nbd_unix = {
|
||||
.bdrv_dirname = nbd_dirname,
|
||||
.strong_runtime_opts = nbd_strong_runtime_opts,
|
||||
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
|
||||
+
|
||||
+ .bdrv_attach_aio_context = nbd_attach_aio_context,
|
||||
+ .bdrv_detach_aio_context = nbd_detach_aio_context,
|
||||
};
|
||||
|
||||
static void bdrv_nbd_init(void)
|
277
debian/patches/extra/0009-qapi-blockdev-backup-add-discard-source-parameter.patch
vendored
Normal file
277
debian/patches/extra/0009-qapi-blockdev-backup-add-discard-source-parameter.patch
vendored
Normal file
@@ -0,0 +1,277 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
Date: Thu, 11 Apr 2024 11:29:25 +0200
|
||||
Subject: [PATCH] qapi: blockdev-backup: add discard-source parameter
|
||||
|
||||
Add a parameter that enables discard-after-copy. That is mostly useful
|
||||
in "push backup with fleecing" scheme, when source is snapshot-access
|
||||
format driver node, based on copy-before-write filter snapshot-access
|
||||
API:
|
||||
|
||||
[guest] [snapshot-access] ~~ blockdev-backup ~~> [backup target]
|
||||
| |
|
||||
| root | file
|
||||
v v
|
||||
[copy-before-write]
|
||||
| |
|
||||
| file | target
|
||||
v v
|
||||
[active disk] [temp.img]
|
||||
|
||||
In this case discard-after-copy does two things:
|
||||
|
||||
- discard data in temp.img to save disk space
|
||||
- avoid further copy-before-write operation in discarded area
|
||||
|
||||
Note that we have to declare WRITE permission on source in
|
||||
copy-before-write filter, for discard to work. Still we can't take it
|
||||
unconditionally, as it will break normal backup from RO source. So, we
|
||||
have to add a parameter and pass it thorough bdrv_open flags.
|
||||
|
||||
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/backup.c | 5 +++--
|
||||
block/block-copy.c | 9 +++++++++
|
||||
block/copy-before-write.c | 15 +++++++++++++--
|
||||
block/copy-before-write.h | 1 +
|
||||
block/replication.c | 4 ++--
|
||||
blockdev.c | 2 +-
|
||||
include/block/block-common.h | 2 ++
|
||||
include/block/block-copy.h | 1 +
|
||||
include/block/block_int-global-state.h | 2 +-
|
||||
qapi/block-core.json | 4 ++++
|
||||
10 files changed, 37 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/block/backup.c b/block/backup.c
|
||||
index ec29d6b810..3dd2e229d2 100644
|
||||
--- a/block/backup.c
|
||||
+++ b/block/backup.c
|
||||
@@ -356,7 +356,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
BlockDriverState *target, int64_t speed,
|
||||
MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap,
|
||||
BitmapSyncMode bitmap_mode,
|
||||
- bool compress,
|
||||
+ bool compress, bool discard_source,
|
||||
const char *filter_node_name,
|
||||
BackupPerf *perf,
|
||||
BlockdevOnError on_source_error,
|
||||
@@ -457,7 +457,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
goto error;
|
||||
}
|
||||
|
||||
- cbw = bdrv_cbw_append(bs, target, filter_node_name, &bcs, errp);
|
||||
+ cbw = bdrv_cbw_append(bs, target, filter_node_name, discard_source,
|
||||
+ &bcs, errp);
|
||||
if (!cbw) {
|
||||
goto error;
|
||||
}
|
||||
diff --git a/block/block-copy.c b/block/block-copy.c
|
||||
index 8fca2c3698..7e3b378528 100644
|
||||
--- a/block/block-copy.c
|
||||
+++ b/block/block-copy.c
|
||||
@@ -137,6 +137,7 @@ typedef struct BlockCopyState {
|
||||
CoMutex lock;
|
||||
int64_t in_flight_bytes;
|
||||
BlockCopyMethod method;
|
||||
+ bool discard_source;
|
||||
BlockReqList reqs;
|
||||
QLIST_HEAD(, BlockCopyCallState) calls;
|
||||
/*
|
||||
@@ -353,6 +354,7 @@ static int64_t block_copy_calculate_cluster_size(BlockDriverState *target,
|
||||
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
|
||||
BlockDriverState *copy_bitmap_bs,
|
||||
const BdrvDirtyBitmap *bitmap,
|
||||
+ bool discard_source,
|
||||
Error **errp)
|
||||
{
|
||||
ERRP_GUARD();
|
||||
@@ -418,6 +420,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
|
||||
cluster_size),
|
||||
};
|
||||
|
||||
+ s->discard_source = discard_source;
|
||||
block_copy_set_copy_opts(s, false, false);
|
||||
|
||||
ratelimit_init(&s->rate_limit);
|
||||
@@ -589,6 +592,12 @@ static coroutine_fn int block_copy_task_entry(AioTask *task)
|
||||
co_put_to_shres(s->mem, t->req.bytes);
|
||||
block_copy_task_end(t, ret);
|
||||
|
||||
+ if (s->discard_source && ret == 0) {
|
||||
+ int64_t nbytes =
|
||||
+ MIN(t->req.offset + t->req.bytes, s->len) - t->req.offset;
|
||||
+ bdrv_co_pdiscard(s->source, t->req.offset, nbytes);
|
||||
+ }
|
||||
+
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
|
||||
index 94db31512d..853e01a1eb 100644
|
||||
--- a/block/copy-before-write.c
|
||||
+++ b/block/copy-before-write.c
|
||||
@@ -44,6 +44,7 @@ typedef struct BDRVCopyBeforeWriteState {
|
||||
BdrvChild *target;
|
||||
OnCbwError on_cbw_error;
|
||||
uint64_t cbw_timeout_ns;
|
||||
+ bool discard_source;
|
||||
|
||||
/*
|
||||
* @lock: protects access to @access_bitmap, @done_bitmap and
|
||||
@@ -357,6 +358,8 @@ cbw_child_perm(BlockDriverState *bs, BdrvChild *c, BdrvChildRole role,
|
||||
uint64_t perm, uint64_t shared,
|
||||
uint64_t *nperm, uint64_t *nshared)
|
||||
{
|
||||
+ BDRVCopyBeforeWriteState *s = bs->opaque;
|
||||
+
|
||||
if (!(role & BDRV_CHILD_FILTERED)) {
|
||||
/*
|
||||
* Target child
|
||||
@@ -381,6 +384,10 @@ cbw_child_perm(BlockDriverState *bs, BdrvChild *c, BdrvChildRole role,
|
||||
* start
|
||||
*/
|
||||
*nperm = *nperm | BLK_PERM_CONSISTENT_READ;
|
||||
+ if (s->discard_source) {
|
||||
+ *nperm = *nperm | BLK_PERM_WRITE;
|
||||
+ }
|
||||
+
|
||||
*nshared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
|
||||
}
|
||||
}
|
||||
@@ -468,7 +475,9 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) &
|
||||
bs->file->bs->supported_zero_flags);
|
||||
|
||||
- s->bcs = block_copy_state_new(bs->file, s->target, bs, bitmap, errp);
|
||||
+ s->discard_source = flags & BDRV_O_CBW_DISCARD_SOURCE;
|
||||
+ s->bcs = block_copy_state_new(bs->file, s->target, bs, bitmap,
|
||||
+ flags & BDRV_O_CBW_DISCARD_SOURCE, errp);
|
||||
if (!s->bcs) {
|
||||
error_prepend(errp, "Cannot create block-copy-state: ");
|
||||
return -EINVAL;
|
||||
@@ -535,12 +544,14 @@ static BlockDriver bdrv_cbw_filter = {
|
||||
BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
|
||||
BlockDriverState *target,
|
||||
const char *filter_node_name,
|
||||
+ bool discard_source,
|
||||
BlockCopyState **bcs,
|
||||
Error **errp)
|
||||
{
|
||||
BDRVCopyBeforeWriteState *state;
|
||||
BlockDriverState *top;
|
||||
QDict *opts;
|
||||
+ int flags = BDRV_O_RDWR | (discard_source ? BDRV_O_CBW_DISCARD_SOURCE : 0);
|
||||
|
||||
assert(source->total_sectors == target->total_sectors);
|
||||
GLOBAL_STATE_CODE();
|
||||
@@ -553,7 +564,7 @@ BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
|
||||
qdict_put_str(opts, "file", bdrv_get_node_name(source));
|
||||
qdict_put_str(opts, "target", bdrv_get_node_name(target));
|
||||
|
||||
- top = bdrv_insert_node(source, opts, BDRV_O_RDWR, errp);
|
||||
+ top = bdrv_insert_node(source, opts, flags, errp);
|
||||
if (!top) {
|
||||
return NULL;
|
||||
}
|
||||
diff --git a/block/copy-before-write.h b/block/copy-before-write.h
|
||||
index 6e72bb25e9..01af0cd3c4 100644
|
||||
--- a/block/copy-before-write.h
|
||||
+++ b/block/copy-before-write.h
|
||||
@@ -39,6 +39,7 @@
|
||||
BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
|
||||
BlockDriverState *target,
|
||||
const char *filter_node_name,
|
||||
+ bool discard_source,
|
||||
BlockCopyState **bcs,
|
||||
Error **errp);
|
||||
void bdrv_cbw_drop(BlockDriverState *bs);
|
||||
diff --git a/block/replication.c b/block/replication.c
|
||||
index ca6bd0a720..0415a5e8b7 100644
|
||||
--- a/block/replication.c
|
||||
+++ b/block/replication.c
|
||||
@@ -582,8 +582,8 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
|
||||
|
||||
s->backup_job = backup_job_create(
|
||||
NULL, s->secondary_disk->bs, s->hidden_disk->bs,
|
||||
- 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false, NULL,
|
||||
- &perf,
|
||||
+ 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false, false,
|
||||
+ NULL, &perf,
|
||||
BLOCKDEV_ON_ERROR_REPORT,
|
||||
BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL,
|
||||
backup_job_completed, bs, NULL, &local_err);
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index 057601dcf0..4c33c3f5f0 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -2726,7 +2726,7 @@ static BlockJob *do_backup_common(BackupCommon *backup,
|
||||
|
||||
job = backup_job_create(backup->job_id, bs, target_bs, backup->speed,
|
||||
backup->sync, bmap, backup->bitmap_mode,
|
||||
- backup->compress,
|
||||
+ backup->compress, backup->discard_source,
|
||||
backup->filter_node_name,
|
||||
&perf,
|
||||
backup->on_source_error,
|
||||
diff --git a/include/block/block-common.h b/include/block/block-common.h
|
||||
index a846023a09..338fe5ff7a 100644
|
||||
--- a/include/block/block-common.h
|
||||
+++ b/include/block/block-common.h
|
||||
@@ -243,6 +243,8 @@ typedef enum {
|
||||
read-write fails */
|
||||
#define BDRV_O_IO_URING 0x40000 /* use io_uring instead of the thread pool */
|
||||
|
||||
+#define BDRV_O_CBW_DISCARD_SOURCE 0x80000 /* for copy-before-write filter */
|
||||
+
|
||||
#define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH)
|
||||
|
||||
|
||||
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
|
||||
index 8b41643bfa..bdc703bacd 100644
|
||||
--- a/include/block/block-copy.h
|
||||
+++ b/include/block/block-copy.h
|
||||
@@ -27,6 +27,7 @@ typedef struct BlockCopyCallState BlockCopyCallState;
|
||||
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
|
||||
BlockDriverState *copy_bitmap_bs,
|
||||
const BdrvDirtyBitmap *bitmap,
|
||||
+ bool discard_source,
|
||||
Error **errp);
|
||||
|
||||
/* Function should be called prior any actual copy request */
|
||||
diff --git a/include/block/block_int-global-state.h b/include/block/block_int-global-state.h
|
||||
index d2201e27f4..eb2d92a226 100644
|
||||
--- a/include/block/block_int-global-state.h
|
||||
+++ b/include/block/block_int-global-state.h
|
||||
@@ -193,7 +193,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
MirrorSyncMode sync_mode,
|
||||
BdrvDirtyBitmap *sync_bitmap,
|
||||
BitmapSyncMode bitmap_mode,
|
||||
- bool compress,
|
||||
+ bool compress, bool discard_source,
|
||||
const char *filter_node_name,
|
||||
BackupPerf *perf,
|
||||
BlockdevOnError on_source_error,
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 4b18e01b85..b179d65520 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -1610,6 +1610,9 @@
|
||||
# node specified by @drive. If this option is not given, a node
|
||||
# name is autogenerated. (Since: 4.2)
|
||||
#
|
||||
+# @discard-source: Discard blocks on source which are already copied
|
||||
+# to the target. (Since 9.0)
|
||||
+#
|
||||
# @x-perf: Performance options. (Since 6.0)
|
||||
#
|
||||
# Features:
|
||||
@@ -1631,6 +1634,7 @@
|
||||
'*on-target-error': 'BlockdevOnError',
|
||||
'*auto-finalize': 'bool', '*auto-dismiss': 'bool',
|
||||
'*filter-node-name': 'str',
|
||||
+ '*discard-source': 'bool',
|
||||
'*x-perf': { 'type': 'BackupPerf',
|
||||
'features': [ 'unstable' ] } } }
|
||||
|
@@ -1,89 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Igor Mammedov <imammedo@redhat.com>
|
||||
Date: Mon, 27 Dec 2021 14:31:17 -0500
|
||||
Subject: [PATCH] acpi: fix QEMU crash when started with SLIC table
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
if QEMU is started with used provided SLIC table blob,
|
||||
|
||||
-acpitable sig=SLIC,oem_id='CRASH ',oem_table_id="ME",oem_rev=00002210,asl_compiler_id="",asl_compiler_rev=00000000,data=/dev/null
|
||||
it will assert with:
|
||||
|
||||
hw/acpi/aml-build.c:61:build_append_padded_str: assertion failed: (len <= maxlen)
|
||||
|
||||
and following backtrace:
|
||||
|
||||
...
|
||||
build_append_padded_str (array=0x555556afe320, str=0x555556afdb2e "CRASH ME", maxlen=0x6, pad=0x20) at hw/acpi/aml-build.c:61
|
||||
acpi_table_begin (desc=0x7fffffffd1b0, array=0x555556afe320) at hw/acpi/aml-build.c:1727
|
||||
build_fadt (tbl=0x555556afe320, linker=0x555557ca3830, f=0x7fffffffd318, oem_id=0x555556afdb2e "CRASH ME", oem_table_id=0x555556afdb34 "ME") at hw/acpi/aml-build.c:2064
|
||||
...
|
||||
|
||||
which happens due to acpi_table_begin() expecting NULL terminated
|
||||
oem_id and oem_table_id strings, which is normally the case, but
|
||||
in case of user provided SLIC table, oem_id points to table's blob
|
||||
directly and as result oem_id became longer than expected.
|
||||
|
||||
Fix issue by handling oem_id consistently and make acpi_get_slic_oem()
|
||||
return NULL terminated strings.
|
||||
|
||||
PS:
|
||||
After [1] refactoring, oem_id semantics became inconsistent, where
|
||||
NULL terminated string was coming from machine and old way pointer
|
||||
into byte array coming from -acpitable option. That used to work
|
||||
since build_header() wasn't expecting NULL terminated string and
|
||||
blindly copied the 1st 6 bytes only.
|
||||
|
||||
However commit [2] broke that by replacing build_header() with
|
||||
acpi_table_begin(), which was expecting NULL terminated string
|
||||
and was checking oem_id size.
|
||||
|
||||
1) 602b45820 ("acpi: Permit OEM ID and OEM table ID fields to be changed")
|
||||
2)
|
||||
Fixes: 4b56e1e4eb08 ("acpi: build_fadt: use acpi_table_begin()/acpi_table_end() instead of build_header()")
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/786
|
||||
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
||||
Message-Id: <20211227193120.1084176-2-imammedo@redhat.com>
|
||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
||||
Tested-by: Denis Lisov <dennis.lissov@gmail.com>
|
||||
Tested-by: Alexander Tsoy <alexander@tsoy.me>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit 8cdb99af45365727ac17f45239a9b8c1d5155c6d)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/acpi/core.c | 4 ++--
|
||||
hw/i386/acpi-build.c | 2 ++
|
||||
2 files changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
|
||||
index 1e004d0078..3e811bf03c 100644
|
||||
--- a/hw/acpi/core.c
|
||||
+++ b/hw/acpi/core.c
|
||||
@@ -345,8 +345,8 @@ int acpi_get_slic_oem(AcpiSlicOem *oem)
|
||||
struct acpi_table_header *hdr = (void *)(u - sizeof(hdr->_length));
|
||||
|
||||
if (memcmp(hdr->sig, "SLIC", 4) == 0) {
|
||||
- oem->id = hdr->oem_id;
|
||||
- oem->table_id = hdr->oem_table_id;
|
||||
+ oem->id = g_strndup(hdr->oem_id, 6);
|
||||
+ oem->table_id = g_strndup(hdr->oem_table_id, 8);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
|
||||
index a99c6e4fe3..570f82997b 100644
|
||||
--- a/hw/i386/acpi-build.c
|
||||
+++ b/hw/i386/acpi-build.c
|
||||
@@ -2721,6 +2721,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
||||
|
||||
/* Cleanup memory that's no longer used. */
|
||||
g_array_free(table_offsets, true);
|
||||
+ g_free(slic_oem.id);
|
||||
+ g_free(slic_oem.table_id);
|
||||
}
|
||||
|
||||
static void acpi_ram_update(MemoryRegion *mr, GArray *data)
|
92
debian/patches/extra/0010-hw-virtio-Fix-the-de-initialization-of-vhost-user-de.patch
vendored
Normal file
92
debian/patches/extra/0010-hw-virtio-Fix-the-de-initialization-of-vhost-user-de.patch
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Tue, 18 Jun 2024 14:19:58 +0200
|
||||
Subject: [PATCH] hw/virtio: Fix the de-initialization of vhost-user devices
|
||||
|
||||
The unrealize functions of the various vhost-user devices are
|
||||
calling the corresponding vhost_*_set_status() functions with a
|
||||
status of 0 to shut down the device correctly.
|
||||
|
||||
Now these vhost_*_set_status() functions all follow this scheme:
|
||||
|
||||
bool should_start = virtio_device_should_start(vdev, status);
|
||||
|
||||
if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (should_start) {
|
||||
/* ... do the initialization stuff ... */
|
||||
} else {
|
||||
/* ... do the cleanup stuff ... */
|
||||
}
|
||||
|
||||
The problem here is virtio_device_should_start(vdev, 0) currently
|
||||
always returns "true" since it internally only looks at vdev->started
|
||||
instead of looking at the "status" parameter. Thus once the device
|
||||
got started once, virtio_device_should_start() always returns true
|
||||
and thus the vhost_*_set_status() functions return early, without
|
||||
ever doing any clean-up when being called with status == 0. This
|
||||
causes e.g. problems when trying to hot-plug and hot-unplug a vhost
|
||||
user devices multiple times since the de-initialization step is
|
||||
completely skipped during the unplug operation.
|
||||
|
||||
This bug has been introduced in commit 9f6bcfd99f ("hw/virtio: move
|
||||
vm_running check to virtio_device_started") which replaced
|
||||
|
||||
should_start = status & VIRTIO_CONFIG_S_DRIVER_OK;
|
||||
|
||||
with
|
||||
|
||||
should_start = virtio_device_started(vdev, status);
|
||||
|
||||
which later got replaced by virtio_device_should_start(). This blocked
|
||||
the possibility to set should_start to false in case the status flag
|
||||
VIRTIO_CONFIG_S_DRIVER_OK was not set.
|
||||
|
||||
Fix it by adjusting the virtio_device_should_start() function to
|
||||
only consider the status flag instead of vdev->started. Since this
|
||||
function is only used in the various vhost_*_set_status() functions
|
||||
for exactly the same purpose, it should be fine to fix it in this
|
||||
central place there without any risk to change the behavior of other
|
||||
code.
|
||||
|
||||
Fixes: 9f6bcfd99f ("hw/virtio: move vm_running check to virtio_device_started")
|
||||
Buglink: https://issues.redhat.com/browse/RHEL-40708
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
Message-Id: <20240618121958.88673-1-thuth@redhat.com>
|
||||
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit d72479b11797c28893e1e3fc565497a9cae5ca16)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
include/hw/virtio/virtio.h | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
|
||||
index 7d5ffdc145..2eafad17b8 100644
|
||||
--- a/include/hw/virtio/virtio.h
|
||||
+++ b/include/hw/virtio/virtio.h
|
||||
@@ -470,9 +470,9 @@ static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status)
|
||||
* @vdev - the VirtIO device
|
||||
* @status - the devices status bits
|
||||
*
|
||||
- * This is similar to virtio_device_started() but also encapsulates a
|
||||
- * check on the VM status which would prevent a device starting
|
||||
- * anyway.
|
||||
+ * This is similar to virtio_device_started() but ignores vdev->started
|
||||
+ * and also encapsulates a check on the VM status which would prevent a
|
||||
+ * device from starting anyway.
|
||||
*/
|
||||
static inline bool virtio_device_should_start(VirtIODevice *vdev, uint8_t status)
|
||||
{
|
||||
@@ -480,7 +480,7 @@ static inline bool virtio_device_should_start(VirtIODevice *vdev, uint8_t status
|
||||
return false;
|
||||
}
|
||||
|
||||
- return virtio_device_started(vdev, status);
|
||||
+ return status & VIRTIO_CONFIG_S_DRIVER_OK;
|
||||
}
|
||||
|
||||
static inline void virtio_set_started(VirtIODevice *vdev, bool started)
|
43
debian/patches/extra/0011-target-arm-Use-float_status-copy-in-sme_fmopa_s.patch
vendored
Normal file
43
debian/patches/extra/0011-target-arm-Use-float_status-copy-in-sme_fmopa_s.patch
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Daniyal Khan <danikhan632@gmail.com>
|
||||
Date: Wed, 17 Jul 2024 16:01:47 +1000
|
||||
Subject: [PATCH] target/arm: Use float_status copy in sme_fmopa_s
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
We made a copy above because the fp exception flags
|
||||
are not propagated back to the FPST register, but
|
||||
then failed to use the copy.
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: 558e956c719 ("target/arm: Implement FMOPA, FMOPS (non-widening)")
|
||||
Signed-off-by: Daniyal Khan <danikhan632@gmail.com>
|
||||
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
|
||||
Message-id: 20240717060149.204788-2-richard.henderson@linaro.org
|
||||
[rth: Split from a larger patch]
|
||||
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
|
||||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
(cherry picked from commit 31d93fedf41c24b0badb38cd9317590d1ef74e37)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
target/arm/tcg/sme_helper.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c
|
||||
index e2e0575039..5a6dd76489 100644
|
||||
--- a/target/arm/tcg/sme_helper.c
|
||||
+++ b/target/arm/tcg/sme_helper.c
|
||||
@@ -916,7 +916,7 @@ void HELPER(sme_fmopa_s)(void *vza, void *vzn, void *vzm, void *vpn,
|
||||
if (pb & 1) {
|
||||
uint32_t *a = vza_row + H1_4(col);
|
||||
uint32_t *m = vzm + H1_4(col);
|
||||
- *a = float32_muladd(n, *m, *a, 0, vst);
|
||||
+ *a = float32_muladd(n, *m, *a, 0, &fpst);
|
||||
}
|
||||
col += 4;
|
||||
pb >>= 4;
|
@@ -1,38 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Wang <jasowang@redhat.com>
|
||||
Date: Tue, 8 Mar 2022 10:42:51 +0800
|
||||
Subject: [PATCH] virtio-net: fix map leaking on error during receive
|
||||
|
||||
Commit bedd7e93d0196 ("virtio-net: fix use after unmap/free for sg")
|
||||
tries to fix the use after free of the sg by caching the virtqueue
|
||||
elements in an array and unmap them at once after receiving the
|
||||
packets, But it forgot to unmap the cached elements on error which
|
||||
will lead to leaking of mapping and other unexpected results.
|
||||
|
||||
Fixing this by detaching the cached elements on error. This addresses
|
||||
CVE-2022-26353.
|
||||
|
||||
Reported-by: Victor Tom <vv474172261@gmail.com>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: CVE-2022-26353
|
||||
Fixes: bedd7e93d0196 ("virtio-net: fix use after unmap/free for sg")
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
||||
(cherry picked from commit abe300d9d894f7138e1af7c8e9c88c04bfe98b37)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/net/virtio-net.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
|
||||
index f2014d5ea0..e1f4748831 100644
|
||||
--- a/hw/net/virtio-net.c
|
||||
+++ b/hw/net/virtio-net.c
|
||||
@@ -1862,6 +1862,7 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
|
||||
|
||||
err:
|
||||
for (j = 0; j < i; j++) {
|
||||
+ virtqueue_detach_element(q->rx_vq, elems[j], lens[j]);
|
||||
g_free(elems[j]);
|
||||
}
|
||||
|
@@ -1,86 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Xu <peterx@redhat.com>
|
||||
Date: Tue, 30 Nov 2021 16:00:28 +0800
|
||||
Subject: [PATCH] memory: Fix incorrect calls of log_global_start/stop
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
We should only call the log_global_start/stop when the global dirty track
|
||||
bitmask changes from zero<->non-zero.
|
||||
|
||||
No real issue reported for this yet probably because no immediate user to
|
||||
enable both dirty rate measurement and migration at the same time. However
|
||||
it'll be good to be prepared for it.
|
||||
|
||||
Fixes: 63b41db4bc ("memory: make global_dirty_tracking a bitmask")
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Cc: Hyman Huang <huangy81@chinatelecom.cn>
|
||||
Cc: Paolo Bonzini <pbonzini@redhat.com>
|
||||
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
Cc: Juan Quintela <quintela@redhat.com>
|
||||
Cc: David Hildenbrand <david@redhat.com>
|
||||
Signed-off-by: Peter Xu <peterx@redhat.com>
|
||||
Reviewed-by: David Hildenbrand <david@redhat.com>
|
||||
Message-Id: <20211130080028.6474-1-peterx@redhat.com>
|
||||
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
(cherry picked from commit 7b0538ed3a22ce30817f818449d10701fb0821f9)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
softmmu/memory.c | 27 ++++++++++++++-------------
|
||||
1 file changed, 14 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/softmmu/memory.c b/softmmu/memory.c
|
||||
index 7340e19ff5..81d4bf1454 100644
|
||||
--- a/softmmu/memory.c
|
||||
+++ b/softmmu/memory.c
|
||||
@@ -2773,6 +2773,8 @@ static VMChangeStateEntry *vmstate_change;
|
||||
|
||||
void memory_global_dirty_log_start(unsigned int flags)
|
||||
{
|
||||
+ unsigned int old_flags = global_dirty_tracking;
|
||||
+
|
||||
if (vmstate_change) {
|
||||
qemu_del_vm_change_state_handler(vmstate_change);
|
||||
vmstate_change = NULL;
|
||||
@@ -2781,15 +2783,14 @@ void memory_global_dirty_log_start(unsigned int flags)
|
||||
assert(flags && !(flags & (~GLOBAL_DIRTY_MASK)));
|
||||
assert(!(global_dirty_tracking & flags));
|
||||
global_dirty_tracking |= flags;
|
||||
-
|
||||
trace_global_dirty_changed(global_dirty_tracking);
|
||||
|
||||
- MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
|
||||
-
|
||||
- /* Refresh DIRTY_MEMORY_MIGRATION bit. */
|
||||
- memory_region_transaction_begin();
|
||||
- memory_region_update_pending = true;
|
||||
- memory_region_transaction_commit();
|
||||
+ if (!old_flags) {
|
||||
+ MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
|
||||
+ memory_region_transaction_begin();
|
||||
+ memory_region_update_pending = true;
|
||||
+ memory_region_transaction_commit();
|
||||
+ }
|
||||
}
|
||||
|
||||
static void memory_global_dirty_log_do_stop(unsigned int flags)
|
||||
@@ -2800,12 +2801,12 @@ static void memory_global_dirty_log_do_stop(unsigned int flags)
|
||||
|
||||
trace_global_dirty_changed(global_dirty_tracking);
|
||||
|
||||
- /* Refresh DIRTY_MEMORY_MIGRATION bit. */
|
||||
- memory_region_transaction_begin();
|
||||
- memory_region_update_pending = true;
|
||||
- memory_region_transaction_commit();
|
||||
-
|
||||
- MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
|
||||
+ if (!global_dirty_tracking) {
|
||||
+ memory_region_transaction_begin();
|
||||
+ memory_region_update_pending = true;
|
||||
+ memory_region_transaction_commit();
|
||||
+ MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
|
||||
+ }
|
||||
}
|
||||
|
||||
static void memory_vm_change_state_handler(void *opaque, bool running,
|
62
debian/patches/extra/0012-target-arm-Use-FPST_F16-for-SME-FMOPA-widening.patch
vendored
Normal file
62
debian/patches/extra/0012-target-arm-Use-FPST_F16-for-SME-FMOPA-widening.patch
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Richard Henderson <richard.henderson@linaro.org>
|
||||
Date: Wed, 17 Jul 2024 16:01:48 +1000
|
||||
Subject: [PATCH] target/arm: Use FPST_F16 for SME FMOPA (widening)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This operation has float16 inputs and thus must use
|
||||
the FZ16 control not the FZ control.
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: 3916841ac75 ("target/arm: Implement FMOPA, FMOPS (widening)")
|
||||
Reported-by: Daniyal Khan <danikhan632@gmail.com>
|
||||
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||||
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
|
||||
Message-id: 20240717060149.204788-3-richard.henderson@linaro.org
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2374
|
||||
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||||
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
|
||||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
(cherry picked from commit 207d30b5fdb5b45a36f26eefcf52fe2c1714dd4f)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
target/arm/tcg/translate-sme.c | 12 ++++++++----
|
||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c
|
||||
index 46c7fce8b4..185a8a917b 100644
|
||||
--- a/target/arm/tcg/translate-sme.c
|
||||
+++ b/target/arm/tcg/translate-sme.c
|
||||
@@ -304,6 +304,7 @@ static bool do_outprod(DisasContext *s, arg_op *a, MemOp esz,
|
||||
}
|
||||
|
||||
static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz,
|
||||
+ ARMFPStatusFlavour e_fpst,
|
||||
gen_helper_gvec_5_ptr *fn)
|
||||
{
|
||||
int svl = streaming_vec_reg_size(s);
|
||||
@@ -319,15 +320,18 @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz,
|
||||
zm = vec_full_reg_ptr(s, a->zm);
|
||||
pn = pred_full_reg_ptr(s, a->pn);
|
||||
pm = pred_full_reg_ptr(s, a->pm);
|
||||
- fpst = fpstatus_ptr(FPST_FPCR);
|
||||
+ fpst = fpstatus_ptr(e_fpst);
|
||||
|
||||
fn(za, zn, zm, pn, pm, fpst, tcg_constant_i32(desc));
|
||||
return true;
|
||||
}
|
||||
|
||||
-TRANS_FEAT(FMOPA_h, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_h)
|
||||
-TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_s)
|
||||
-TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, MO_64, gen_helper_sme_fmopa_d)
|
||||
+TRANS_FEAT(FMOPA_h, aa64_sme, do_outprod_fpst, a,
|
||||
+ MO_32, FPST_FPCR_F16, gen_helper_sme_fmopa_h)
|
||||
+TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a,
|
||||
+ MO_32, FPST_FPCR, gen_helper_sme_fmopa_s)
|
||||
+TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a,
|
||||
+ MO_64, FPST_FPCR, gen_helper_sme_fmopa_d)
|
||||
|
||||
/* TODO: FEAT_EBF16 */
|
||||
TRANS_FEAT(BFMOPA, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_bfmopa)
|
@@ -1,59 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Igor Mammedov <imammedo@redhat.com>
|
||||
Date: Wed, 12 Jan 2022 08:03:31 -0500
|
||||
Subject: [PATCH] acpi: fix OEM ID/OEM Table ID padding
|
||||
|
||||
Commit [2] broke original '\0' padding of OEM ID and OEM Table ID
|
||||
fields in headers of ACPI tables. While it doesn't have impact on
|
||||
default values since QEMU uses 6 and 8 characters long values
|
||||
respectively, it broke usecase where IDs are provided on QEMU CLI.
|
||||
It shouldn't affect guest (but may cause licensing verification
|
||||
issues in guest OS).
|
||||
One of the broken usecases is user supplied SLIC table with IDs
|
||||
shorter than max possible length, where [2] mangles IDs with extra
|
||||
spaces in RSDT and FADT tables whereas guest OS expects those to
|
||||
mirror the respective values of the used SLIC table.
|
||||
|
||||
Fix it by replacing whitespace padding with '\0' padding in
|
||||
accordance with [1] and expectations of guest OS
|
||||
|
||||
1) ACPI spec, v2.0b
|
||||
17.2 AML Grammar Definition
|
||||
...
|
||||
//OEM ID of up to 6 characters. If the OEM ID is
|
||||
//shorter than 6 characters, it can be terminated
|
||||
//with a NULL character.
|
||||
|
||||
2)
|
||||
Fixes: 602b458201 ("acpi: Permit OEM ID and OEM table ID fields to be changed")
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/707
|
||||
Reported-by: Dmitry V. Orekhov <dima.orekhov@gmail.com>
|
||||
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Message-Id: <20220112130332.1648664-4-imammedo@redhat.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Reviewed-by: Ani Sinha <ani@anisinha.ca>
|
||||
Tested-by: Dmitry V. Orekhov dima.orekhov@gmail.com
|
||||
(cherry picked from commit 748c030f360a940fe0c9382c8ca1649096c3a80d)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/acpi/aml-build.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
|
||||
index b3b3310df3..65148d5b9d 100644
|
||||
--- a/hw/acpi/aml-build.c
|
||||
+++ b/hw/acpi/aml-build.c
|
||||
@@ -1724,9 +1724,9 @@ void acpi_table_begin(AcpiTable *desc, GArray *array)
|
||||
build_append_int_noprefix(array, 0, 4); /* Length */
|
||||
build_append_int_noprefix(array, desc->rev, 1); /* Revision */
|
||||
build_append_int_noprefix(array, 0, 1); /* Checksum */
|
||||
- build_append_padded_str(array, desc->oem_id, 6, ' '); /* OEMID */
|
||||
+ build_append_padded_str(array, desc->oem_id, 6, '\0'); /* OEMID */
|
||||
/* OEM Table ID */
|
||||
- build_append_padded_str(array, desc->oem_table_id, 8, ' ');
|
||||
+ build_append_padded_str(array, desc->oem_table_id, 8, '\0');
|
||||
build_append_int_noprefix(array, 1, 4); /* OEM Revision */
|
||||
g_array_append_vals(array, ACPI_BUILD_APPNAME8, 4); /* Creator ID */
|
||||
build_append_int_noprefix(array, 1, 4); /* Creator Revision */
|
60
debian/patches/extra/0013-scsi-fix-regression-and-honor-bootindex-again-for-le.patch
vendored
Normal file
60
debian/patches/extra/0013-scsi-fix-regression-and-honor-bootindex-again-for-le.patch
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 10 Jul 2024 17:25:29 +0200
|
||||
Subject: [PATCH] scsi: fix regression and honor bootindex again for legacy
|
||||
drives
|
||||
|
||||
Commit 3089637461 ("scsi: Don't ignore most usb-storage properties")
|
||||
removed the call to object_property_set_int() and thus the 'set'
|
||||
method for the bootindex property was also not called anymore. Here
|
||||
that method is device_set_bootindex() (as configured by
|
||||
scsi_dev_instance_init() -> device_add_bootindex_property()) which as
|
||||
a side effect registers the device via add_boot_device_path().
|
||||
|
||||
As reported by a downstream user [0], the bootindex property did not
|
||||
have the desired effect anymore for legacy drives. Fix the regression
|
||||
by explicitly calling the add_boot_device_path() function after
|
||||
checking that the bootindex is not yet used (to avoid
|
||||
add_boot_device_path() calling exit()).
|
||||
|
||||
[0]: https://forum.proxmox.com/threads/149772/post-679433
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: 3089637461 ("scsi: Don't ignore most usb-storage properties")
|
||||
Suggested-by: Kevin Wolf <kwolf@redhat.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Link: https://lore.kernel.org/r/20240710152529.1737407-1-f.ebner@proxmox.com
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
(cherry picked from commit 57a8a80d1a5b28797b21d30bfc60601945820e51)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/scsi/scsi-bus.c | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
|
||||
index 9e40b0c920..53eff5dd3d 100644
|
||||
--- a/hw/scsi/scsi-bus.c
|
||||
+++ b/hw/scsi/scsi-bus.c
|
||||
@@ -384,6 +384,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
|
||||
DeviceState *dev;
|
||||
SCSIDevice *s;
|
||||
DriveInfo *dinfo;
|
||||
+ Error *local_err = NULL;
|
||||
|
||||
if (blk_is_sg(blk)) {
|
||||
driver = "scsi-generic";
|
||||
@@ -403,6 +404,14 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
|
||||
s = SCSI_DEVICE(dev);
|
||||
s->conf = *conf;
|
||||
|
||||
+ check_boot_index(conf->bootindex, &local_err);
|
||||
+ if (local_err) {
|
||||
+ object_unparent(OBJECT(dev));
|
||||
+ error_propagate(errp, local_err);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ add_boot_device_path(conf->bootindex, dev, NULL);
|
||||
+
|
||||
qdev_prop_set_uint32(dev, "scsi-id", unit);
|
||||
if (object_property_find(OBJECT(dev), "removable")) {
|
||||
qdev_prop_set_bit(dev, "removable", removable);
|
35
debian/patches/extra/0014-block-copy-before-write-use-uint64_t-for-timeout-in-.patch
vendored
Normal file
35
debian/patches/extra/0014-block-copy-before-write-use-uint64_t-for-timeout-in-.patch
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Mon, 29 Apr 2024 15:41:11 +0200
|
||||
Subject: [PATCH] block/copy-before-write: use uint64_t for timeout in
|
||||
nanoseconds
|
||||
|
||||
rather than the uint32_t for which the maximum is slightly more than 4
|
||||
seconds and larger values would overflow. The QAPI interface allows
|
||||
specifying the number of seconds, so only values 0 to 4 are safe right
|
||||
now, other values lead to a much lower timeout than a user expects.
|
||||
|
||||
The block_copy() call where this is used already takes a uint64_t for
|
||||
the timeout, so no change required there.
|
||||
|
||||
Fixes: 6db7fd1ca9 ("block/copy-before-write: implement cbw-timeout option")
|
||||
Reported-by: Friedrich Weber <f.weber@proxmox.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Tested-by: Friedrich Weber <f.weber@proxmox.com>
|
||||
---
|
||||
block/copy-before-write.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
|
||||
index b866e42271..3ee95c0e7a 100644
|
||||
--- a/block/copy-before-write.c
|
||||
+++ b/block/copy-before-write.c
|
||||
@@ -43,7 +43,7 @@ typedef struct BDRVCopyBeforeWriteState {
|
||||
BlockCopyState *bcs;
|
||||
BdrvChild *target;
|
||||
OnCbwError on_cbw_error;
|
||||
- uint32_t cbw_timeout_ns;
|
||||
+ uint64_t cbw_timeout_ns;
|
||||
|
||||
/*
|
||||
* @lock: protects access to @access_bitmap, @done_bitmap and
|
48
debian/patches/extra/0014-hw-scsi-lsi53c895a-bump-instruction-limit-in-scripts.patch
vendored
Normal file
48
debian/patches/extra/0014-hw-scsi-lsi53c895a-bump-instruction-limit-in-scripts.patch
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Mon, 15 Jul 2024 15:14:03 +0200
|
||||
Subject: [PATCH] hw/scsi/lsi53c895a: bump instruction limit in scripts
|
||||
processing to fix regression
|
||||
|
||||
Commit 9876359990 ("hw/scsi/lsi53c895a: add timer to scripts
|
||||
processing") reduced the maximum allowed instruction count by
|
||||
a factor of 100 all the way down to 100.
|
||||
|
||||
This causes the "Check Point R81.20 Gaia" appliance [0] to fail to
|
||||
boot after fully finishing the installation via the appliance's web
|
||||
interface (there is already one reboot before that).
|
||||
|
||||
With a limit of 150, the appliance still fails to boot, while with a
|
||||
limit of 200, it works. Bump to 500 to fix the regression and be on
|
||||
the safe side.
|
||||
|
||||
Originally reported in the Proxmox community forum[1].
|
||||
|
||||
[0]: https://support.checkpoint.com/results/download/124397
|
||||
[1]: https://forum.proxmox.com/threads/149772/post-683459
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: 9876359990 ("hw/scsi/lsi53c895a: add timer to scripts processing")
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Acked-by: Sven Schnelle <svens@stackframe.org>
|
||||
Link: https://lore.kernel.org/r/20240715131403.223239-1-f.ebner@proxmox.com
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
(cherry picked from commit a4975023fb13cf229bd59c9ceec1b8cbdc5b9a20)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/scsi/lsi53c895a.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
|
||||
index eb9828dd5e..f1935e5328 100644
|
||||
--- a/hw/scsi/lsi53c895a.c
|
||||
+++ b/hw/scsi/lsi53c895a.c
|
||||
@@ -188,7 +188,7 @@ static const char *names[] = {
|
||||
#define LSI_TAG_VALID (1 << 16)
|
||||
|
||||
/* Maximum instructions to process. */
|
||||
-#define LSI_MAX_INSN 100
|
||||
+#define LSI_MAX_INSN 500
|
||||
|
||||
typedef struct lsi_request {
|
||||
SCSIRequest *req;
|
@@ -1,55 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefano Garzarella <sgarzare@redhat.com>
|
||||
Date: Mon, 28 Feb 2022 10:50:58 +0100
|
||||
Subject: [PATCH] vhost-vsock: detach the virqueue element in case of error
|
||||
|
||||
In vhost_vsock_common_send_transport_reset(), if an element popped from
|
||||
the virtqueue is invalid, we should call virtqueue_detach_element() to
|
||||
detach it from the virtqueue before freeing its memory.
|
||||
|
||||
Fixes: fc0b9b0e1c ("vhost-vsock: add virtio sockets device")
|
||||
Fixes: CVE-2022-26354
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Reported-by: VictorV <vv474172261@gmail.com>
|
||||
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
|
||||
Message-Id: <20220228095058.27899-1-sgarzare@redhat.com>
|
||||
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit 8d1b247f3748ac4078524130c6d7ae42b6140aaf)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/virtio/vhost-vsock-common.c | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
|
||||
index 3f3771274e..ed706681ac 100644
|
||||
--- a/hw/virtio/vhost-vsock-common.c
|
||||
+++ b/hw/virtio/vhost-vsock-common.c
|
||||
@@ -153,19 +153,23 @@ static void vhost_vsock_common_send_transport_reset(VHostVSockCommon *vvc)
|
||||
if (elem->out_num) {
|
||||
error_report("invalid vhost-vsock event virtqueue element with "
|
||||
"out buffers");
|
||||
- goto out;
|
||||
+ goto err;
|
||||
}
|
||||
|
||||
if (iov_from_buf(elem->in_sg, elem->in_num, 0,
|
||||
&event, sizeof(event)) != sizeof(event)) {
|
||||
error_report("vhost-vsock event virtqueue element is too short");
|
||||
- goto out;
|
||||
+ goto err;
|
||||
}
|
||||
|
||||
virtqueue_push(vq, elem, sizeof(event));
|
||||
virtio_notify(VIRTIO_DEVICE(vvc), vq);
|
||||
|
||||
-out:
|
||||
+ g_free(elem);
|
||||
+ return;
|
||||
+
|
||||
+err:
|
||||
+ virtqueue_detach_element(vq, elem, 0);
|
||||
g_free(elem);
|
||||
}
|
||||
|
38
debian/patches/extra/0015-block-copy-Fix-missing-graph-lock.patch
vendored
Normal file
38
debian/patches/extra/0015-block-copy-Fix-missing-graph-lock.patch
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Wolf <kwolf@redhat.com>
|
||||
Date: Thu, 27 Jun 2024 20:12:44 +0200
|
||||
Subject: [PATCH] block-copy: Fix missing graph lock
|
||||
|
||||
The graph lock needs to be held when calling bdrv_co_pdiscard(). Fix
|
||||
block_copy_task_entry() to take it for the call.
|
||||
|
||||
WITH_GRAPH_RDLOCK_GUARD() was implemented in a weak way because of
|
||||
limitations in clang's Thread Safety Analysis at the time, so that it
|
||||
only asserts that the lock is held (which allows calling functions that
|
||||
require the lock), but we never deal with the unlocking (so even after
|
||||
the scope of the guard, the compiler assumes that the lock is still
|
||||
held). This is why the compiler didn't catch this locking error.
|
||||
|
||||
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||||
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
(picked from https://lore.kernel.org/qemu-devel/20240627181245.281403-2-kwolf@redhat.com/)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/block-copy.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block/block-copy.c b/block/block-copy.c
|
||||
index 7e3b378528..cc618e4561 100644
|
||||
--- a/block/block-copy.c
|
||||
+++ b/block/block-copy.c
|
||||
@@ -595,7 +595,9 @@ static coroutine_fn int block_copy_task_entry(AioTask *task)
|
||||
if (s->discard_source && ret == 0) {
|
||||
int64_t nbytes =
|
||||
MIN(t->req.offset + t->req.bytes, s->len) - t->req.offset;
|
||||
- bdrv_co_pdiscard(s->source, t->req.offset, nbytes);
|
||||
+ WITH_GRAPH_RDLOCK_GUARD() {
|
||||
+ bdrv_co_pdiscard(s->source, t->req.offset, nbytes);
|
||||
+ }
|
||||
}
|
||||
|
||||
return ret;
|
@@ -1,98 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Xueming Li <xuemingl@nvidia.com>
|
||||
Date: Mon, 7 Feb 2022 15:19:28 +0800
|
||||
Subject: [PATCH] vhost-user: remove VirtQ notifier restore
|
||||
|
||||
Notifier set when vhost-user backend asks qemu to mmap an FD and
|
||||
offset. When vhost-user backend restart or getting killed, VQ notifier
|
||||
FD and mmap addresses become invalid. After backend restart, MR contains
|
||||
the invalid address will be restored and fail on notifier access.
|
||||
|
||||
On the other hand, qemu should munmap the notifier, release underlying
|
||||
hardware resources to enable backend restart and allocate hardware
|
||||
notifier resources correctly.
|
||||
|
||||
Qemu shouldn't reference and use resources of disconnected backend.
|
||||
|
||||
This patch removes VQ notifier restore, uses the default vhost-user
|
||||
notifier to avoid invalid address access.
|
||||
|
||||
After backend restart, the backend should ask qemu to install a hardware
|
||||
notifier if needed.
|
||||
|
||||
Fixes: 44866521bd6e ("vhost-user: support registering external host notifiers")
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
|
||||
Message-Id: <20220207071929.527149-2-xuemingl@nvidia.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit e867144b73b3c5009266b6df07d5ff44acfb82c3)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/virtio/vhost-user.c | 19 +------------------
|
||||
include/hw/virtio/vhost-user.h | 1 -
|
||||
2 files changed, 1 insertion(+), 19 deletions(-)
|
||||
|
||||
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
|
||||
index bf6e50223c..c671719e9b 100644
|
||||
--- a/hw/virtio/vhost-user.c
|
||||
+++ b/hw/virtio/vhost-user.c
|
||||
@@ -1143,19 +1143,6 @@ static int vhost_user_set_vring_num(struct vhost_dev *dev,
|
||||
return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring);
|
||||
}
|
||||
|
||||
-static void vhost_user_host_notifier_restore(struct vhost_dev *dev,
|
||||
- int queue_idx)
|
||||
-{
|
||||
- struct vhost_user *u = dev->opaque;
|
||||
- VhostUserHostNotifier *n = &u->user->notifier[queue_idx];
|
||||
- VirtIODevice *vdev = dev->vdev;
|
||||
-
|
||||
- if (n->addr && !n->set) {
|
||||
- virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true);
|
||||
- n->set = true;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
static void vhost_user_host_notifier_remove(struct vhost_dev *dev,
|
||||
int queue_idx)
|
||||
{
|
||||
@@ -1163,17 +1150,14 @@ static void vhost_user_host_notifier_remove(struct vhost_dev *dev,
|
||||
VhostUserHostNotifier *n = &u->user->notifier[queue_idx];
|
||||
VirtIODevice *vdev = dev->vdev;
|
||||
|
||||
- if (n->addr && n->set) {
|
||||
+ if (n->addr) {
|
||||
virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
|
||||
- n->set = false;
|
||||
}
|
||||
}
|
||||
|
||||
static int vhost_user_set_vring_base(struct vhost_dev *dev,
|
||||
struct vhost_vring_state *ring)
|
||||
{
|
||||
- vhost_user_host_notifier_restore(dev, ring->index);
|
||||
-
|
||||
return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring);
|
||||
}
|
||||
|
||||
@@ -1538,7 +1522,6 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
|
||||
}
|
||||
|
||||
n->addr = addr;
|
||||
- n->set = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h
|
||||
index a9abca3288..f6012b2078 100644
|
||||
--- a/include/hw/virtio/vhost-user.h
|
||||
+++ b/include/hw/virtio/vhost-user.h
|
||||
@@ -14,7 +14,6 @@
|
||||
typedef struct VhostUserHostNotifier {
|
||||
MemoryRegion mr;
|
||||
void *addr;
|
||||
- bool set;
|
||||
} VhostUserHostNotifier;
|
||||
|
||||
typedef struct VhostUserState {
|
93
debian/patches/extra/0016-Revert-qemu-char-do-not-operate-on-sources-from-fina.patch
vendored
Normal file
93
debian/patches/extra/0016-Revert-qemu-char-do-not-operate-on-sources-from-fina.patch
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Dyasli <sergey.dyasli@nutanix.com>
|
||||
Date: Fri, 12 Jul 2024 09:26:59 +0000
|
||||
Subject: [PATCH] Revert "qemu-char: do not operate on sources from finalize
|
||||
callbacks"
|
||||
|
||||
This reverts commit 2b316774f60291f57ca9ecb6a9f0712c532cae34.
|
||||
|
||||
After 038b4217884c ("Revert "chardev: use a child source for qio input
|
||||
source"") we've been observing the "iwp->src == NULL" assertion
|
||||
triggering periodically during the initial capabilities querying by
|
||||
libvirtd. One of possible backtraces:
|
||||
|
||||
Thread 1 (Thread 0x7f16cd4f0700 (LWP 43858)):
|
||||
0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
|
||||
1 0x00007f16c6c21e65 in __GI_abort () at abort.c:79
|
||||
2 0x00007f16c6c21d39 in __assert_fail_base at assert.c:92
|
||||
3 0x00007f16c6c46e86 in __GI___assert_fail (assertion=assertion@entry=0x562e9bcdaadd "iwp->src == NULL", file=file@entry=0x562e9bcdaac8 "../chardev/char-io.c", line=line@entry=99, function=function@entry=0x562e9bcdab10 <__PRETTY_FUNCTION__.20549> "io_watch_poll_finalize") at assert.c:101
|
||||
4 0x0000562e9ba20c2c in io_watch_poll_finalize (source=<optimized out>) at ../chardev/char-io.c:99
|
||||
5 io_watch_poll_finalize (source=<optimized out>) at ../chardev/char-io.c:88
|
||||
6 0x00007f16c904aae0 in g_source_unref_internal () from /lib64/libglib-2.0.so.0
|
||||
7 0x00007f16c904baf9 in g_source_destroy_internal () from /lib64/libglib-2.0.so.0
|
||||
8 0x0000562e9ba20db0 in io_remove_watch_poll (source=0x562e9d6720b0) at ../chardev/char-io.c:147
|
||||
9 remove_fd_in_watch (chr=chr@entry=0x562e9d5f3800) at ../chardev/char-io.c:153
|
||||
10 0x0000562e9ba23ffb in update_ioc_handlers (s=0x562e9d5f3800) at ../chardev/char-socket.c:592
|
||||
11 0x0000562e9ba2072f in qemu_chr_fe_set_handlers_full at ../chardev/char-fe.c:279
|
||||
12 0x0000562e9ba207a9 in qemu_chr_fe_set_handlers at ../chardev/char-fe.c:304
|
||||
13 0x0000562e9ba2ca75 in monitor_qmp_setup_handlers_bh (opaque=0x562e9d4c2c60) at ../monitor/qmp.c:509
|
||||
14 0x0000562e9bb6222e in aio_bh_poll (ctx=ctx@entry=0x562e9d4c2f20) at ../util/async.c:216
|
||||
15 0x0000562e9bb4de0a in aio_poll (ctx=0x562e9d4c2f20, blocking=blocking@entry=true) at ../util/aio-posix.c:722
|
||||
16 0x0000562e9b99dfaa in iothread_run (opaque=0x562e9d4c26f0) at ../iothread.c:63
|
||||
17 0x0000562e9bb505a4 in qemu_thread_start (args=0x562e9d4c7ea0) at ../util/qemu-thread-posix.c:543
|
||||
18 0x00007f16c70081ca in start_thread (arg=<optimized out>) at pthread_create.c:479
|
||||
19 0x00007f16c6c398d3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
|
||||
|
||||
io_remove_watch_poll(), which makes sure that iwp->src is NULL, calls
|
||||
g_source_destroy() which finds that iwp->src is not NULL in the finalize
|
||||
callback. This can only happen if another thread has managed to trigger
|
||||
io_watch_poll_prepare() callback in the meantime.
|
||||
|
||||
Move iwp->src destruction back to the finalize callback to prevent the
|
||||
described race, and also remove the stale comment. The deadlock glib bug
|
||||
was fixed back in 2010 by b35820285668 ("gmain: move finalization of
|
||||
GSource outside of context lock").
|
||||
|
||||
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
Signed-off-by: Sergey Dyasli <sergey.dyasli@nutanix.com>
|
||||
Link: https://lore.kernel.org/r/20240712092659.216206-1-sergey.dyasli@nutanix.com
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
(cherry picked from commit e0bf95443ee9326d44031373420cf9f3513ee255)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
chardev/char-io.c | 19 +++++--------------
|
||||
1 file changed, 5 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/chardev/char-io.c b/chardev/char-io.c
|
||||
index dab77b112e..3be17b51ca 100644
|
||||
--- a/chardev/char-io.c
|
||||
+++ b/chardev/char-io.c
|
||||
@@ -87,16 +87,12 @@ static gboolean io_watch_poll_dispatch(GSource *source, GSourceFunc callback,
|
||||
|
||||
static void io_watch_poll_finalize(GSource *source)
|
||||
{
|
||||
- /*
|
||||
- * Due to a glib bug, removing the last reference to a source
|
||||
- * inside a finalize callback causes recursive locking (and a
|
||||
- * deadlock). This is not a problem inside other callbacks,
|
||||
- * including dispatch callbacks, so we call io_remove_watch_poll
|
||||
- * to remove this source. At this point, iwp->src must
|
||||
- * be NULL, or we would leak it.
|
||||
- */
|
||||
IOWatchPoll *iwp = io_watch_poll_from_source(source);
|
||||
- assert(iwp->src == NULL);
|
||||
+ if (iwp->src) {
|
||||
+ g_source_destroy(iwp->src);
|
||||
+ g_source_unref(iwp->src);
|
||||
+ iwp->src = NULL;
|
||||
+ }
|
||||
}
|
||||
|
||||
static GSourceFuncs io_watch_poll_funcs = {
|
||||
@@ -139,11 +135,6 @@ static void io_remove_watch_poll(GSource *source)
|
||||
IOWatchPoll *iwp;
|
||||
|
||||
iwp = io_watch_poll_from_source(source);
|
||||
- if (iwp->src) {
|
||||
- g_source_destroy(iwp->src);
|
||||
- g_source_unref(iwp->src);
|
||||
- iwp->src = NULL;
|
||||
- }
|
||||
g_source_destroy(&iwp->parent);
|
||||
}
|
||||
|
@@ -1,149 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Xueming Li <xuemingl@nvidia.com>
|
||||
Date: Mon, 7 Feb 2022 15:19:29 +0800
|
||||
Subject: [PATCH] vhost-user: fix VirtQ notifier cleanup
|
||||
|
||||
When vhost-user device cleanup, remove notifier MR and munmaps notifier
|
||||
address in the event-handling thread, VM CPU thread writing the notifier
|
||||
in concurrent fails with an error of accessing invalid address. It
|
||||
happens because MR is still being referenced and accessed in another
|
||||
thread while the underlying notifier mmap address is being freed and
|
||||
becomes invalid.
|
||||
|
||||
This patch calls RCU and munmap notifiers in the callback after the
|
||||
memory flatview update finish.
|
||||
|
||||
Fixes: 44866521bd6e ("vhost-user: support registering external host notifiers")
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
|
||||
Message-Id: <20220207071929.527149-3-xuemingl@nvidia.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit 0b0af4d62f7002b31cd7b2762b26d2fcb76bb2ba)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/virtio/vhost-user.c | 48 ++++++++++++++++++++--------------
|
||||
include/hw/virtio/vhost-user.h | 2 ++
|
||||
2 files changed, 31 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
|
||||
index c671719e9b..ed5f9a5471 100644
|
||||
--- a/hw/virtio/vhost-user.c
|
||||
+++ b/hw/virtio/vhost-user.c
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "migration/migration.h"
|
||||
#include "migration/postcopy-ram.h"
|
||||
#include "trace.h"
|
||||
+#include "exec/ramblock.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -1143,15 +1144,26 @@ static int vhost_user_set_vring_num(struct vhost_dev *dev,
|
||||
return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring);
|
||||
}
|
||||
|
||||
-static void vhost_user_host_notifier_remove(struct vhost_dev *dev,
|
||||
- int queue_idx)
|
||||
+static void vhost_user_host_notifier_free(VhostUserHostNotifier *n)
|
||||
{
|
||||
- struct vhost_user *u = dev->opaque;
|
||||
- VhostUserHostNotifier *n = &u->user->notifier[queue_idx];
|
||||
- VirtIODevice *vdev = dev->vdev;
|
||||
+ assert(n && n->unmap_addr);
|
||||
+ munmap(n->unmap_addr, qemu_real_host_page_size);
|
||||
+ n->unmap_addr = NULL;
|
||||
+}
|
||||
+
|
||||
+static void vhost_user_host_notifier_remove(VhostUserState *user,
|
||||
+ VirtIODevice *vdev, int queue_idx)
|
||||
+{
|
||||
+ VhostUserHostNotifier *n = &user->notifier[queue_idx];
|
||||
|
||||
if (n->addr) {
|
||||
- virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
|
||||
+ if (vdev) {
|
||||
+ virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
|
||||
+ }
|
||||
+ assert(!n->unmap_addr);
|
||||
+ n->unmap_addr = n->addr;
|
||||
+ n->addr = NULL;
|
||||
+ call_rcu(n, vhost_user_host_notifier_free, rcu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1190,8 +1202,9 @@ static int vhost_user_get_vring_base(struct vhost_dev *dev,
|
||||
.payload.state = *ring,
|
||||
.hdr.size = sizeof(msg.payload.state),
|
||||
};
|
||||
+ struct vhost_user *u = dev->opaque;
|
||||
|
||||
- vhost_user_host_notifier_remove(dev, ring->index);
|
||||
+ vhost_user_host_notifier_remove(u->user, dev->vdev, ring->index);
|
||||
|
||||
if (vhost_user_write(dev, &msg, NULL, 0) < 0) {
|
||||
return -1;
|
||||
@@ -1486,12 +1499,7 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
|
||||
|
||||
n = &user->notifier[queue_idx];
|
||||
|
||||
- if (n->addr) {
|
||||
- virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
|
||||
- object_unparent(OBJECT(&n->mr));
|
||||
- munmap(n->addr, page_size);
|
||||
- n->addr = NULL;
|
||||
- }
|
||||
+ vhost_user_host_notifier_remove(user, vdev, queue_idx);
|
||||
|
||||
if (area->u64 & VHOST_USER_VRING_NOFD_MASK) {
|
||||
return 0;
|
||||
@@ -1510,9 +1518,12 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
|
||||
|
||||
name = g_strdup_printf("vhost-user/host-notifier@%p mmaps[%d]",
|
||||
user, queue_idx);
|
||||
- if (!n->mr.ram) /* Don't init again after suspend. */
|
||||
+ if (!n->mr.ram) { /* Don't init again after suspend. */
|
||||
memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name,
|
||||
page_size, addr);
|
||||
+ } else {
|
||||
+ n->mr.ram_block->host = addr;
|
||||
+ }
|
||||
g_free(name);
|
||||
|
||||
if (virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true)) {
|
||||
@@ -2460,17 +2471,16 @@ bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp)
|
||||
void vhost_user_cleanup(VhostUserState *user)
|
||||
{
|
||||
int i;
|
||||
+ VhostUserHostNotifier *n;
|
||||
|
||||
if (!user->chr) {
|
||||
return;
|
||||
}
|
||||
memory_region_transaction_begin();
|
||||
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
|
||||
- if (user->notifier[i].addr) {
|
||||
- object_unparent(OBJECT(&user->notifier[i].mr));
|
||||
- munmap(user->notifier[i].addr, qemu_real_host_page_size);
|
||||
- user->notifier[i].addr = NULL;
|
||||
- }
|
||||
+ n = &user->notifier[i];
|
||||
+ vhost_user_host_notifier_remove(user, NULL, i);
|
||||
+ object_unparent(OBJECT(&n->mr));
|
||||
}
|
||||
memory_region_transaction_commit();
|
||||
user->chr = NULL;
|
||||
diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h
|
||||
index f6012b2078..e44a41bb70 100644
|
||||
--- a/include/hw/virtio/vhost-user.h
|
||||
+++ b/include/hw/virtio/vhost-user.h
|
||||
@@ -12,8 +12,10 @@
|
||||
#include "hw/virtio/virtio.h"
|
||||
|
||||
typedef struct VhostUserHostNotifier {
|
||||
+ struct rcu_head rcu;
|
||||
MemoryRegion mr;
|
||||
void *addr;
|
||||
+ void *unmap_addr;
|
||||
} VhostUserHostNotifier;
|
||||
|
||||
typedef struct VhostUserState {
|
@@ -1,101 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Halil Pasic <pasic@linux.ibm.com>
|
||||
Date: Mon, 7 Feb 2022 12:28:57 +0100
|
||||
Subject: [PATCH] virtio: fix the condition for iommu_platform not supported
|
||||
|
||||
The commit 04ceb61a40 ("virtio: Fail if iommu_platform is requested, but
|
||||
unsupported") claims to fail the device hotplug when iommu_platform
|
||||
is requested, but not supported by the (vhost) device. On the first
|
||||
glance the condition for detecting that situation looks perfect, but
|
||||
because a certain peculiarity of virtio_platform it ain't.
|
||||
|
||||
In fact the aforementioned commit introduces a regression. It breaks
|
||||
virtio-fs support for Secure Execution, and most likely also for AMD SEV
|
||||
or any other confidential guest scenario that relies encrypted guest
|
||||
memory. The same also applies to any other vhost device that does not
|
||||
support _F_ACCESS_PLATFORM.
|
||||
|
||||
The peculiarity is that iommu_platform and _F_ACCESS_PLATFORM collates
|
||||
"device can not access all of the guest RAM" and "iova != gpa, thus
|
||||
device needs to translate iova".
|
||||
|
||||
Confidential guest technologies currently rely on the device/hypervisor
|
||||
offering _F_ACCESS_PLATFORM, so that, after the feature has been
|
||||
negotiated, the guest grants access to the portions of memory the
|
||||
device needs to see. So in for confidential guests, generally,
|
||||
_F_ACCESS_PLATFORM is about the restricted access to memory, but not
|
||||
about the addresses used being something else than guest physical
|
||||
addresses.
|
||||
|
||||
This is the very reason for which commit f7ef7e6e3b ("vhost: correctly
|
||||
turn on VIRTIO_F_IOMMU_PLATFORM") fences _F_ACCESS_PLATFORM from the
|
||||
vhost device that does not need it, because on the vhost interface it
|
||||
only means "I/O address translation is needed".
|
||||
|
||||
This patch takes inspiration from f7ef7e6e3b ("vhost: correctly turn on
|
||||
VIRTIO_F_IOMMU_PLATFORM"), and uses the same condition for detecting the
|
||||
situation when _F_ACCESS_PLATFORM is requested, but no I/O translation
|
||||
by the device, and thus no device capability is needed. In this
|
||||
situation claiming that the device does not support iommu_plattform=on
|
||||
is counter-productive. So let us stop doing that!
|
||||
|
||||
Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
|
||||
Reported-by: Jakob Naucke <Jakob.Naucke@ibm.com>
|
||||
Fixes: 04ceb61a40 ("virtio: Fail if iommu_platform is requested, but
|
||||
unsupported")
|
||||
Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
|
||||
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
|
||||
Cc: Kevin Wolf <kwolf@redhat.com>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
|
||||
Message-Id: <20220207112857.607829-1-pasic@linux.ibm.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Acked-by: Jason Wang <jasowang@redhat.com>
|
||||
(cherry picked from commit e65902a913bf31ba79a83a3bd3621108b85cf645)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/virtio/virtio-bus.c | 12 +++++++-----
|
||||
1 file changed, 7 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
|
||||
index d23db98c56..0f69d1c742 100644
|
||||
--- a/hw/virtio/virtio-bus.c
|
||||
+++ b/hw/virtio/virtio-bus.c
|
||||
@@ -48,6 +48,7 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
|
||||
VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
|
||||
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
|
||||
bool has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
|
||||
+ bool vdev_has_iommu;
|
||||
Error *local_err = NULL;
|
||||
|
||||
DPRINTF("%s: plug device.\n", qbus->name);
|
||||
@@ -69,11 +70,6 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
- if (has_iommu && !virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) {
|
||||
- error_setg(errp, "iommu_platform=true is not supported by the device");
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
if (klass->device_plugged != NULL) {
|
||||
klass->device_plugged(qbus->parent, &local_err);
|
||||
}
|
||||
@@ -82,9 +78,15 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
+ vdev_has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
|
||||
if (klass->get_dma_as != NULL && has_iommu) {
|
||||
virtio_add_feature(&vdev->host_features, VIRTIO_F_IOMMU_PLATFORM);
|
||||
vdev->dma_as = klass->get_dma_as(qbus->parent);
|
||||
+ if (!vdev_has_iommu && vdev->dma_as != &address_space_memory) {
|
||||
+ error_setg(errp,
|
||||
+ "iommu_platform=true is not supported by the device");
|
||||
+ return;
|
||||
+ }
|
||||
} else {
|
||||
vdev->dma_as = &address_space_memory;
|
||||
}
|
77
debian/patches/extra/0017-virtio-pci-Fix-the-use-of-an-uninitialized-irqfd.patch
vendored
Normal file
77
debian/patches/extra/0017-virtio-pci-Fix-the-use-of-an-uninitialized-irqfd.patch
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Cindy Lu <lulu@redhat.com>
|
||||
Date: Tue, 6 Aug 2024 17:37:12 +0800
|
||||
Subject: [PATCH] virtio-pci: Fix the use of an uninitialized irqfd
|
||||
|
||||
The crash was reported in MAC OS and NixOS, here is the link for this bug
|
||||
https://gitlab.com/qemu-project/qemu/-/issues/2334
|
||||
https://gitlab.com/qemu-project/qemu/-/issues/2321
|
||||
|
||||
In this bug, they are using the virtio_input device. The guest notifier was
|
||||
not supported for this device, The function virtio_pci_set_guest_notifiers()
|
||||
was not called, and the vector_irqfd was not initialized.
|
||||
|
||||
So the fix is adding the check for vector_irqfd in virtio_pci_get_notifier()
|
||||
|
||||
The function virtio_pci_get_notifier() can be used in various devices.
|
||||
It could also be called when VIRTIO_CONFIG_S_DRIVER_OK is not set. In this situation,
|
||||
the vector_irqfd being NULL is acceptable. We can allow the device continue to boot
|
||||
|
||||
If the vector_irqfd still hasn't been initialized after VIRTIO_CONFIG_S_DRIVER_OK
|
||||
is set, it means that the function set_guest_notifiers was not called before the
|
||||
driver started. This indicates that the device is not using the notifier.
|
||||
At this point, we will let the check fail.
|
||||
|
||||
This fix is verified in vyatta,MacOS,NixOS,fedora system.
|
||||
|
||||
The bt tree for this bug is:
|
||||
Thread 6 "CPU 0/KVM" received signal SIGSEGV, Segmentation fault.
|
||||
[Switching to Thread 0x7c817be006c0 (LWP 1269146)]
|
||||
kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
|
||||
817 if (irqfd->users == 0) {
|
||||
(gdb) thread apply all bt
|
||||
...
|
||||
Thread 6 (Thread 0x7c817be006c0 (LWP 1269146) "CPU 0/KVM"):
|
||||
0 kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817
|
||||
1 kvm_virtio_pci_vector_use_one () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:893
|
||||
2 0x00005983657045e2 in memory_region_write_accessor () at ../qemu-9.0.0/system/memory.c:497
|
||||
3 0x0000598365704ba6 in access_with_adjusted_size () at ../qemu-9.0.0/system/memory.c:573
|
||||
4 0x0000598365705059 in memory_region_dispatch_write () at ../qemu-9.0.0/system/memory.c:1528
|
||||
5 0x00005983659b8e1f in flatview_write_continue_step.isra.0 () at ../qemu-9.0.0/system/physmem.c:2713
|
||||
6 0x000059836570ba7d in flatview_write_continue () at ../qemu-9.0.0/system/physmem.c:2743
|
||||
7 flatview_write () at ../qemu-9.0.0/system/physmem.c:2774
|
||||
8 0x000059836570bb76 in address_space_write () at ../qemu-9.0.0/system/physmem.c:2894
|
||||
9 0x0000598365763afe in address_space_rw () at ../qemu-9.0.0/system/physmem.c:2904
|
||||
10 kvm_cpu_exec () at ../qemu-9.0.0/accel/kvm/kvm-all.c:2917
|
||||
11 0x000059836576656e in kvm_vcpu_thread_fn () at ../qemu-9.0.0/accel/kvm/kvm-accel-ops.c:50
|
||||
12 0x0000598365926ca8 in qemu_thread_start () at ../qemu-9.0.0/util/qemu-thread-posix.c:541
|
||||
13 0x00007c8185bcd1cf in ??? () at /usr/lib/libc.so.6
|
||||
14 0x00007c8185c4e504 in clone () at /usr/lib/libc.so.6
|
||||
|
||||
Fixes: 2ce6cff94d ("virtio-pci: fix use of a released vector")
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Cindy Lu <lulu@redhat.com>
|
||||
Message-Id: <20240806093715.65105-1-lulu@redhat.com>
|
||||
Acked-by: Jason Wang <jasowang@redhat.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit a8e63ff289d137197ad7a701a587cc432872d798)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/virtio/virtio-pci.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
|
||||
index e04218a9fb..389bab003f 100644
|
||||
--- a/hw/virtio/virtio-pci.c
|
||||
+++ b/hw/virtio/virtio-pci.c
|
||||
@@ -860,6 +860,9 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no,
|
||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
||||
VirtQueue *vq;
|
||||
|
||||
+ if (!proxy->vector_irqfd && vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)
|
||||
+ return -1;
|
||||
+
|
||||
if (queue_no == VIRTIO_CONFIG_IRQ_IDX) {
|
||||
*n = virtio_config_get_guest_notifier(vdev);
|
||||
*vector = vdev->config_vector;
|
@@ -1,38 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Fri, 6 May 2022 14:38:35 +0200
|
||||
Subject: [PATCH] block/gluster: correctly set max_pdiscard which is int64_t
|
||||
|
||||
Previously, max_pdiscard would be zero in the following assertion:
|
||||
qemu-system-x86_64: ../block/io.c:3166: bdrv_co_pdiscard: Assertion
|
||||
`max_pdiscard >= bs->bl.request_alignment' failed.
|
||||
|
||||
Fixes: 0c8022876f ("block: use int64_t instead of int in driver discard handlers")
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/gluster.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/block/gluster.c b/block/gluster.c
|
||||
index 398976bc66..592e71b22a 100644
|
||||
--- a/block/gluster.c
|
||||
+++ b/block/gluster.c
|
||||
@@ -891,7 +891,7 @@ out:
|
||||
static void qemu_gluster_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
{
|
||||
bs->bl.max_transfer = GLUSTER_MAX_TRANSFER;
|
||||
- bs->bl.max_pdiscard = SIZE_MAX;
|
||||
+ bs->bl.max_pdiscard = INT64_MAX;
|
||||
}
|
||||
|
||||
static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
|
||||
@@ -1304,7 +1304,7 @@ static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs,
|
||||
GlusterAIOCB acb;
|
||||
BDRVGlusterState *s = bs->opaque;
|
||||
|
||||
- assert(bytes <= SIZE_MAX); /* rely on max_pdiscard */
|
||||
+ assert(bytes <= INT64_MAX); /* rely on max_pdiscard */
|
||||
|
||||
acb.size = 0;
|
||||
acb.ret = 0;
|
35
debian/patches/extra/0018-virtio-net-Ensure-queue-index-fits-with-RSS.patch
vendored
Normal file
35
debian/patches/extra/0018-virtio-net-Ensure-queue-index-fits-with-RSS.patch
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Akihiko Odaki <akihiko.odaki@daynix.com>
|
||||
Date: Mon, 1 Jul 2024 20:58:04 +0900
|
||||
Subject: [PATCH] virtio-net: Ensure queue index fits with RSS
|
||||
|
||||
Ensure the queue index points to a valid queue when software RSS
|
||||
enabled. The new calculation matches with the behavior of Linux's TAP
|
||||
device with the RSS eBPF program.
|
||||
|
||||
Fixes: 4474e37a5b3a ("virtio-net: implement RX RSS processing")
|
||||
Reported-by: Zhibin Hu <huzhibin5@huawei.com>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
||||
(cherry picked from commit f1595ceb9aad36a6c1da95bcb77ab9509b38822d)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/net/virtio-net.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
|
||||
index 3644bfd91b..f48588638d 100644
|
||||
--- a/hw/net/virtio-net.c
|
||||
+++ b/hw/net/virtio-net.c
|
||||
@@ -1949,7 +1949,8 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
|
||||
if (!no_rss && n->rss_data.enabled && n->rss_data.enabled_software_rss) {
|
||||
int index = virtio_net_process_rss(nc, buf, size);
|
||||
if (index >= 0) {
|
||||
- NetClientState *nc2 = qemu_get_subqueue(n->nic, index);
|
||||
+ NetClientState *nc2 =
|
||||
+ qemu_get_subqueue(n->nic, index % n->curr_queue_pairs);
|
||||
return virtio_net_receive_rcu(nc2, buf, size, true);
|
||||
}
|
||||
}
|
@@ -1,72 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Rao Lei <lei.rao@intel.com>
|
||||
Date: Fri, 6 May 2022 14:38:36 +0200
|
||||
Subject: [PATCH] ui/vnc.c: Fixed a deadlock bug.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The GDB statck is as follows:
|
||||
(gdb) bt
|
||||
0 __lll_lock_wait (futex=futex@entry=0x56211df20360, private=0) at lowlevellock.c:52
|
||||
1 0x00007f263caf20a3 in __GI___pthread_mutex_lock (mutex=0x56211df20360) at ../nptl/pthread_mutex_lock.c:80
|
||||
2 0x000056211a757364 in qemu_mutex_lock_impl (mutex=0x56211df20360, file=0x56211a804857 "../ui/vnc-jobs.h", line=60)
|
||||
at ../util/qemu-thread-posix.c:80
|
||||
3 0x000056211a0ef8c7 in vnc_lock_output (vs=0x56211df14200) at ../ui/vnc-jobs.h:60
|
||||
4 0x000056211a0efcb7 in vnc_clipboard_send (vs=0x56211df14200, count=1, dwords=0x7ffdf1701338) at ../ui/vnc-clipboard.c:138
|
||||
5 0x000056211a0f0129 in vnc_clipboard_notify (notifier=0x56211df244c8, data=0x56211dd1bbf0) at ../ui/vnc-clipboard.c:209
|
||||
6 0x000056211a75dde8 in notifier_list_notify (list=0x56211afa17d0 <clipboard_notifiers>, data=0x56211dd1bbf0) at ../util/notify.c:39
|
||||
7 0x000056211a0bf0e6 in qemu_clipboard_update (info=0x56211dd1bbf0) at ../ui/clipboard.c:50
|
||||
8 0x000056211a0bf05d in qemu_clipboard_peer_release (peer=0x56211df244c0, selection=QEMU_CLIPBOARD_SELECTION_CLIPBOARD)
|
||||
at ../ui/clipboard.c:41
|
||||
9 0x000056211a0bef9b in qemu_clipboard_peer_unregister (peer=0x56211df244c0) at ../ui/clipboard.c:19
|
||||
10 0x000056211a0d45f3 in vnc_disconnect_finish (vs=0x56211df14200) at ../ui/vnc.c:1358
|
||||
11 0x000056211a0d4c9d in vnc_client_read (vs=0x56211df14200) at ../ui/vnc.c:1611
|
||||
12 0x000056211a0d4df8 in vnc_client_io (ioc=0x56211ce70690, condition=G_IO_IN, opaque=0x56211df14200) at ../ui/vnc.c:1649
|
||||
13 0x000056211a5b976c in qio_channel_fd_source_dispatch
|
||||
(source=0x56211ce50a00, callback=0x56211a0d4d71 <vnc_client_io>, user_data=0x56211df14200) at ../io/channel-watch.c:84
|
||||
14 0x00007f263ccede8e in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
|
||||
15 0x000056211a77d4a1 in glib_pollfds_poll () at ../util/main-loop.c:232
|
||||
16 0x000056211a77d51f in os_host_main_loop_wait (timeout=958545) at ../util/main-loop.c:255
|
||||
17 0x000056211a77d630 in main_loop_wait (nonblocking=0) at ../util/main-loop.c:531
|
||||
18 0x000056211a45bc8e in qemu_main_loop () at ../softmmu/runstate.c:726
|
||||
19 0x000056211a0b45fa in main (argc=69, argv=0x7ffdf1701778, envp=0x7ffdf17019a8) at ../softmmu/main.c:50
|
||||
|
||||
From the call trace, we can see it is a deadlock bug.
|
||||
vnc_disconnect_finish will acquire the output_mutex.
|
||||
But, the output_mutex will be acquired again in vnc_clipboard_send.
|
||||
Repeated locking will cause deadlock. So, I move
|
||||
qemu_clipboard_peer_unregister() behind vnc_unlock_output();
|
||||
|
||||
Fixes: 0bf41cab93e ("ui/vnc: clipboard support")
|
||||
Signed-off-by: Lei Rao <lei.rao@intel.com>
|
||||
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
Message-Id: <20220105020808.597325-1-lei.rao@intel.com>
|
||||
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
||||
(cherry-picked from commit 1dbbe6f172810026c51dc84ed927a3cc23017949)
|
||||
[FE: trivial backport for 6.2]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
ui/vnc.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/ui/vnc.c b/ui/vnc.c
|
||||
index af02522e84..b253e85c65 100644
|
||||
--- a/ui/vnc.c
|
||||
+++ b/ui/vnc.c
|
||||
@@ -1354,12 +1354,12 @@ void vnc_disconnect_finish(VncState *vs)
|
||||
/* last client gone */
|
||||
vnc_update_server_surface(vs->vd);
|
||||
}
|
||||
+ vnc_unlock_output(vs);
|
||||
+
|
||||
if (vs->cbpeer.update.notify) {
|
||||
qemu_clipboard_peer_unregister(&vs->cbpeer);
|
||||
}
|
||||
|
||||
- vnc_unlock_output(vs);
|
||||
-
|
||||
qemu_mutex_destroy(&vs->output_mutex);
|
||||
if (vs->bh != NULL) {
|
||||
qemu_bh_delete(vs->bh);
|
338
debian/patches/extra/0019-virtio-net-Fix-network-stall-at-the-host-side-waitin.patch
vendored
Normal file
338
debian/patches/extra/0019-virtio-net-Fix-network-stall-at-the-host-side-waitin.patch
vendored
Normal file
@@ -0,0 +1,338 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: thomas <east.moutain.yang@gmail.com>
|
||||
Date: Fri, 12 Jul 2024 11:10:53 +0800
|
||||
Subject: [PATCH] virtio-net: Fix network stall at the host side waiting for
|
||||
kick
|
||||
|
||||
Patch 06b12970174 ("virtio-net: fix network stall under load")
|
||||
added double-check to test whether the available buffer size
|
||||
can satisfy the request or not, in case the guest has added
|
||||
some buffers to the avail ring simultaneously after the first
|
||||
check. It will be lucky if the available buffer size becomes
|
||||
okay after the double-check, then the host can send the packet
|
||||
to the guest. If the buffer size still can't satisfy the request,
|
||||
even if the guest has added some buffers, viritio-net would
|
||||
stall at the host side forever.
|
||||
|
||||
The patch enables notification and checks whether the guest has
|
||||
added some buffers since last check of available buffers when
|
||||
the available buffers are insufficient. If no buffer is added,
|
||||
return false, else recheck the available buffers in the loop.
|
||||
If the available buffers are sufficient, disable notification
|
||||
and return true.
|
||||
|
||||
Changes:
|
||||
1. Change the return type of virtqueue_get_avail_bytes() from void
|
||||
to int, it returns an opaque that represents the shadow_avail_idx
|
||||
of the virtqueue on success, else -1 on error.
|
||||
2. Add a new API: virtio_queue_enable_notification_and_check(),
|
||||
it takes an opaque as input arg which is returned from
|
||||
virtqueue_get_avail_bytes(). It enables notification firstly,
|
||||
then checks whether the guest has added some buffers since
|
||||
last check of available buffers or not by virtio_queue_poll(),
|
||||
return ture if yes.
|
||||
|
||||
The patch also reverts patch "06b12970174".
|
||||
|
||||
The case below can reproduce the stall.
|
||||
|
||||
Guest 0
|
||||
+--------+
|
||||
| iperf |
|
||||
---------------> | server |
|
||||
Host | +--------+
|
||||
+--------+ | ...
|
||||
| iperf |----
|
||||
| client |---- Guest n
|
||||
+--------+ | +--------+
|
||||
| | iperf |
|
||||
---------------> | server |
|
||||
+--------+
|
||||
|
||||
Boot many guests from qemu with virtio network:
|
||||
qemu ... -netdev tap,id=net_x \
|
||||
-device virtio-net-pci-non-transitional,\
|
||||
iommu_platform=on,mac=xx:xx:xx:xx:xx:xx,netdev=net_x
|
||||
|
||||
Each guest acts as iperf server with commands below:
|
||||
iperf3 -s -D -i 10 -p 8001
|
||||
iperf3 -s -D -i 10 -p 8002
|
||||
|
||||
The host as iperf client:
|
||||
iperf3 -c guest_IP -p 8001 -i 30 -w 256k -P 20 -t 40000
|
||||
iperf3 -c guest_IP -p 8002 -i 30 -w 256k -P 20 -t 40000
|
||||
|
||||
After some time, the host loses connection to the guest,
|
||||
the guest can send packet to the host, but can't receive
|
||||
packet from the host.
|
||||
|
||||
It's more likely to happen if SWIOTLB is enabled in the guest,
|
||||
allocating and freeing bounce buffer takes some CPU ticks,
|
||||
copying from/to bounce buffer takes more CPU ticks, compared
|
||||
with that there is no bounce buffer in the guest.
|
||||
Once the rate of producing packets from the host approximates
|
||||
the rate of receiveing packets in the guest, the guest would
|
||||
loop in NAPI.
|
||||
|
||||
receive packets ---
|
||||
| |
|
||||
v |
|
||||
free buf virtnet_poll
|
||||
| |
|
||||
v |
|
||||
add buf to avail ring ---
|
||||
|
|
||||
| need kick the host?
|
||||
| NAPI continues
|
||||
v
|
||||
receive packets ---
|
||||
| |
|
||||
v |
|
||||
free buf virtnet_poll
|
||||
| |
|
||||
v |
|
||||
add buf to avail ring ---
|
||||
|
|
||||
v
|
||||
... ...
|
||||
|
||||
On the other hand, the host fetches free buf from avail
|
||||
ring, if the buf in the avail ring is not enough, the
|
||||
host notifies the guest the event by writing the avail
|
||||
idx read from avail ring to the event idx of used ring,
|
||||
then the host goes to sleep, waiting for the kick signal
|
||||
from the guest.
|
||||
|
||||
Once the guest finds the host is waiting for kick singal
|
||||
(in virtqueue_kick_prepare_split()), it kicks the host.
|
||||
|
||||
The host may stall forever at the sequences below:
|
||||
|
||||
Host Guest
|
||||
------------ -----------
|
||||
fetch buf, send packet receive packet ---
|
||||
... ... |
|
||||
fetch buf, send packet add buf |
|
||||
... add buf virtnet_poll
|
||||
buf not enough avail idx-> add buf |
|
||||
read avail idx add buf |
|
||||
add buf ---
|
||||
receive packet ---
|
||||
write event idx ... |
|
||||
wait for kick add buf virtnet_poll
|
||||
... |
|
||||
---
|
||||
no more packet, exit NAPI
|
||||
|
||||
In the first loop of NAPI above, indicated in the range of
|
||||
virtnet_poll above, the host is sending packets while the
|
||||
guest is receiving packets and adding buffers.
|
||||
step 1: The buf is not enough, for example, a big packet
|
||||
needs 5 buf, but the available buf count is 3.
|
||||
The host read current avail idx.
|
||||
step 2: The guest adds some buf, then checks whether the
|
||||
host is waiting for kick signal, not at this time.
|
||||
The used ring is not empty, the guest continues
|
||||
the second loop of NAPI.
|
||||
step 3: The host writes the avail idx read from avail
|
||||
ring to used ring as event idx via
|
||||
virtio_queue_set_notification(q->rx_vq, 1).
|
||||
step 4: At the end of the second loop of NAPI, recheck
|
||||
whether kick is needed, as the event idx in the
|
||||
used ring written by the host is beyound the
|
||||
range of kick condition, the guest will not
|
||||
send kick signal to the host.
|
||||
|
||||
Fixes: 06b12970174 ("virtio-net: fix network stall under load")
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Wencheng Yang <east.moutain.yang@gmail.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
||||
(cherry picked from commit f937309fbdbb48c354220a3e7110c202ae4aa7fa)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/net/virtio-net.c | 28 ++++++++++-------
|
||||
hw/virtio/virtio.c | 64 +++++++++++++++++++++++++++++++++++---
|
||||
include/hw/virtio/virtio.h | 21 +++++++++++--
|
||||
3 files changed, 94 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
|
||||
index f48588638d..d4b979d343 100644
|
||||
--- a/hw/net/virtio-net.c
|
||||
+++ b/hw/net/virtio-net.c
|
||||
@@ -1680,24 +1680,28 @@ static bool virtio_net_can_receive(NetClientState *nc)
|
||||
|
||||
static int virtio_net_has_buffers(VirtIONetQueue *q, int bufsize)
|
||||
{
|
||||
+ int opaque;
|
||||
+ unsigned int in_bytes;
|
||||
VirtIONet *n = q->n;
|
||||
- if (virtio_queue_empty(q->rx_vq) ||
|
||||
- (n->mergeable_rx_bufs &&
|
||||
- !virtqueue_avail_bytes(q->rx_vq, bufsize, 0))) {
|
||||
- virtio_queue_set_notification(q->rx_vq, 1);
|
||||
-
|
||||
- /* To avoid a race condition where the guest has made some buffers
|
||||
- * available after the above check but before notification was
|
||||
- * enabled, check for available buffers again.
|
||||
- */
|
||||
- if (virtio_queue_empty(q->rx_vq) ||
|
||||
- (n->mergeable_rx_bufs &&
|
||||
- !virtqueue_avail_bytes(q->rx_vq, bufsize, 0))) {
|
||||
+
|
||||
+ while (virtio_queue_empty(q->rx_vq) || n->mergeable_rx_bufs) {
|
||||
+ opaque = virtqueue_get_avail_bytes(q->rx_vq, &in_bytes, NULL,
|
||||
+ bufsize, 0);
|
||||
+ /* Buffer is enough, disable notifiaction */
|
||||
+ if (bufsize <= in_bytes) {
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (virtio_queue_enable_notification_and_check(q->rx_vq, opaque)) {
|
||||
+ /* Guest has added some buffers, try again */
|
||||
+ continue;
|
||||
+ } else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
virtio_queue_set_notification(q->rx_vq, 0);
|
||||
+
|
||||
return 1;
|
||||
}
|
||||
|
||||
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
|
||||
index fd2dfe3a6b..08fba6b2d8 100644
|
||||
--- a/hw/virtio/virtio.c
|
||||
+++ b/hw/virtio/virtio.c
|
||||
@@ -743,6 +743,60 @@ int virtio_queue_empty(VirtQueue *vq)
|
||||
}
|
||||
}
|
||||
|
||||
+static bool virtio_queue_split_poll(VirtQueue *vq, unsigned shadow_idx)
|
||||
+{
|
||||
+ if (unlikely(!vq->vring.avail)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return (uint16_t)shadow_idx != vring_avail_idx(vq);
|
||||
+}
|
||||
+
|
||||
+static bool virtio_queue_packed_poll(VirtQueue *vq, unsigned shadow_idx)
|
||||
+{
|
||||
+ VRingPackedDesc desc;
|
||||
+ VRingMemoryRegionCaches *caches;
|
||||
+
|
||||
+ if (unlikely(!vq->vring.desc)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ caches = vring_get_region_caches(vq);
|
||||
+ if (!caches) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ vring_packed_desc_read(vq->vdev, &desc, &caches->desc,
|
||||
+ shadow_idx, true);
|
||||
+
|
||||
+ return is_desc_avail(desc.flags, vq->shadow_avail_wrap_counter);
|
||||
+}
|
||||
+
|
||||
+static bool virtio_queue_poll(VirtQueue *vq, unsigned shadow_idx)
|
||||
+{
|
||||
+ if (virtio_device_disabled(vq->vdev)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) {
|
||||
+ return virtio_queue_packed_poll(vq, shadow_idx);
|
||||
+ } else {
|
||||
+ return virtio_queue_split_poll(vq, shadow_idx);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+bool virtio_queue_enable_notification_and_check(VirtQueue *vq,
|
||||
+ int opaque)
|
||||
+{
|
||||
+ virtio_queue_set_notification(vq, 1);
|
||||
+
|
||||
+ if (opaque >= 0) {
|
||||
+ return virtio_queue_poll(vq, (unsigned)opaque);
|
||||
+ } else {
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem,
|
||||
unsigned int len)
|
||||
{
|
||||
@@ -1330,9 +1384,9 @@ err:
|
||||
goto done;
|
||||
}
|
||||
|
||||
-void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
|
||||
- unsigned int *out_bytes,
|
||||
- unsigned max_in_bytes, unsigned max_out_bytes)
|
||||
+int virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
|
||||
+ unsigned int *out_bytes, unsigned max_in_bytes,
|
||||
+ unsigned max_out_bytes)
|
||||
{
|
||||
uint16_t desc_size;
|
||||
VRingMemoryRegionCaches *caches;
|
||||
@@ -1365,7 +1419,7 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
|
||||
caches);
|
||||
}
|
||||
|
||||
- return;
|
||||
+ return (int)vq->shadow_avail_idx;
|
||||
err:
|
||||
if (in_bytes) {
|
||||
*in_bytes = 0;
|
||||
@@ -1373,6 +1427,8 @@ err:
|
||||
if (out_bytes) {
|
||||
*out_bytes = 0;
|
||||
}
|
||||
+
|
||||
+ return -1;
|
||||
}
|
||||
|
||||
int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes,
|
||||
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
|
||||
index 2eafad17b8..8b4da92889 100644
|
||||
--- a/include/hw/virtio/virtio.h
|
||||
+++ b/include/hw/virtio/virtio.h
|
||||
@@ -271,9 +271,13 @@ void qemu_put_virtqueue_element(VirtIODevice *vdev, QEMUFile *f,
|
||||
VirtQueueElement *elem);
|
||||
int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes,
|
||||
unsigned int out_bytes);
|
||||
-void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
|
||||
- unsigned int *out_bytes,
|
||||
- unsigned max_in_bytes, unsigned max_out_bytes);
|
||||
+/**
|
||||
+ * Return <0 on error or an opaque >=0 to pass to
|
||||
+ * virtio_queue_enable_notification_and_check on success.
|
||||
+ */
|
||||
+int virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
|
||||
+ unsigned int *out_bytes, unsigned max_in_bytes,
|
||||
+ unsigned max_out_bytes);
|
||||
|
||||
void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq);
|
||||
void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);
|
||||
@@ -307,6 +311,17 @@ int virtio_queue_ready(VirtQueue *vq);
|
||||
|
||||
int virtio_queue_empty(VirtQueue *vq);
|
||||
|
||||
+/**
|
||||
+ * Enable notification and check whether guest has added some
|
||||
+ * buffers since last call to virtqueue_get_avail_bytes.
|
||||
+ *
|
||||
+ * @opaque: value returned from virtqueue_get_avail_bytes
|
||||
+ */
|
||||
+bool virtio_queue_enable_notification_and_check(VirtQueue *vq,
|
||||
+ int opaque);
|
||||
+
|
||||
+void virtio_queue_set_shadow_avail_idx(VirtQueue *vq, uint16_t idx);
|
||||
+
|
||||
/* Host binding interface. */
|
||||
|
||||
uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr);
|
@@ -1,37 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mauro Matteo Cascella <mcascell@redhat.com>
|
||||
Date: Thu, 7 Apr 2022 10:11:06 +0200
|
||||
Subject: [PATCH] display/qxl-render: fix race condition in qxl_cursor
|
||||
(CVE-2021-4207)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Avoid fetching 'width' and 'height' a second time to prevent possible
|
||||
race condition. Refer to security advisory
|
||||
https://starlabs.sg/advisories/22-4207/ for more information.
|
||||
|
||||
Fixes: CVE-2021-4207
|
||||
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
|
||||
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
Message-Id: <20220407081106.343235-1-mcascell@redhat.com>
|
||||
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
||||
(cherry picked from commit 9569f5cb5b4bffa9d3ebc8ba7da1e03830a9a895)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/display/qxl-render.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c
|
||||
index d28849b121..237ed293ba 100644
|
||||
--- a/hw/display/qxl-render.c
|
||||
+++ b/hw/display/qxl-render.c
|
||||
@@ -266,7 +266,7 @@ static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor,
|
||||
}
|
||||
break;
|
||||
case SPICE_CURSOR_TYPE_ALPHA:
|
||||
- size = sizeof(uint32_t) * cursor->header.width * cursor->header.height;
|
||||
+ size = sizeof(uint32_t) * c->width * c->height;
|
||||
qxl_unpack_chunks(c->data, size, qxl, &cursor->chunk, group_id);
|
||||
if (qxl->debug > 2) {
|
||||
cursor_print_ascii_art(c, "qxl/alpha");
|
70
debian/patches/extra/0020-net-Reinstate-net-nic-model-help-output-as-documente.patch
vendored
Normal file
70
debian/patches/extra/0020-net-Reinstate-net-nic-model-help-output-as-documente.patch
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: David Woodhouse <dwmw@amazon.co.uk>
|
||||
Date: Tue, 9 Jul 2024 13:34:44 +0100
|
||||
Subject: [PATCH] net: Reinstate '-net nic, model=help' output as documented in
|
||||
man page
|
||||
|
||||
While refactoring the NIC initialization code, I broke '-net nic,model=help'
|
||||
which no longer outputs a list of available NIC models.
|
||||
|
||||
Fixes: 2cdeca04adab ("net: report list of available models according to platform")
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
|
||||
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
|
||||
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
||||
(cherry picked from commit 64f75f57f9d2c8c12ac6d9355fa5d3a2af5879ca)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
net/net.c | 25 ++++++++++++++++++++++---
|
||||
1 file changed, 22 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/net/net.c b/net/net.c
|
||||
index a2f0c828bb..e6ca2529bb 100644
|
||||
--- a/net/net.c
|
||||
+++ b/net/net.c
|
||||
@@ -1150,6 +1150,21 @@ NICInfo *qemu_find_nic_info(const char *typename, bool match_default,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+static bool is_nic_model_help_option(const char *model)
|
||||
+{
|
||||
+ if (model && is_help_option(model)) {
|
||||
+ /*
|
||||
+ * Trigger the help output by instantiating the hash table which
|
||||
+ * will gather tha available models as they get registered.
|
||||
+ */
|
||||
+ if (!nic_model_help) {
|
||||
+ nic_model_help = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||
+ g_free, NULL);
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
|
||||
/* "I have created a device. Please configure it if you can" */
|
||||
bool qemu_configure_nic_device(DeviceState *dev, bool match_default,
|
||||
@@ -1733,6 +1748,12 @@ void net_check_clients(void)
|
||||
|
||||
static int net_init_client(void *dummy, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
+ const char *model = qemu_opt_get_del(opts, "model");
|
||||
+
|
||||
+ if (is_nic_model_help_option(model)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
return net_client_init(opts, false, errp);
|
||||
}
|
||||
|
||||
@@ -1789,9 +1810,7 @@ static int net_param_nic(void *dummy, QemuOpts *opts, Error **errp)
|
||||
memset(ni, 0, sizeof(*ni));
|
||||
ni->model = qemu_opt_get_del(opts, "model");
|
||||
|
||||
- if (!nic_model_help && !g_strcmp0(ni->model, "help")) {
|
||||
- nic_model_help = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||
- g_free, NULL);
|
||||
+ if (is_nic_model_help_option(ni->model)) {
|
||||
return 0;
|
||||
}
|
||||
|
32
debian/patches/extra/0021-net-Fix-net-nic-model-for-non-help-arguments.patch
vendored
Normal file
32
debian/patches/extra/0021-net-Fix-net-nic-model-for-non-help-arguments.patch
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: David Woodhouse <dwmw@amazon.co.uk>
|
||||
Date: Tue, 6 Aug 2024 18:21:37 +0100
|
||||
Subject: [PATCH] net: Fix '-net nic,model=' for non-help arguments
|
||||
|
||||
Oops, don't *delete* the model option when checking for 'help'.
|
||||
|
||||
Fixes: 64f75f57f9d2 ("net: Reinstate '-net nic, model=help' output as documented in man page")
|
||||
Reported-by: Hans <sungdgdhtryrt@gmail.com>
|
||||
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
|
||||
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
||||
(cherry picked from commit fa62cb989a9146c82f8f172715042852f5d36200)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
net/net.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/net/net.c b/net/net.c
|
||||
index e6ca2529bb..897bb936cf 100644
|
||||
--- a/net/net.c
|
||||
+++ b/net/net.c
|
||||
@@ -1748,7 +1748,7 @@ void net_check_clients(void)
|
||||
|
||||
static int net_init_client(void *dummy, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
- const char *model = qemu_opt_get_del(opts, "model");
|
||||
+ const char *model = qemu_opt_get(opts, "model");
|
||||
|
||||
if (is_nic_model_help_option(model)) {
|
||||
return 0;
|
@@ -1,83 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mauro Matteo Cascella <mcascell@redhat.com>
|
||||
Date: Thu, 7 Apr 2022 10:17:12 +0200
|
||||
Subject: [PATCH] ui/cursor: fix integer overflow in cursor_alloc
|
||||
(CVE-2021-4206)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Prevent potential integer overflow by limiting 'width' and 'height' to
|
||||
512x512. Also change 'datasize' type to size_t. Refer to security
|
||||
advisory https://starlabs.sg/advisories/22-4206/ for more information.
|
||||
|
||||
Fixes: CVE-2021-4206
|
||||
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
|
||||
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
Message-Id: <20220407081712.345609-1-mcascell@redhat.com>
|
||||
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
||||
(cherry picked from commit fa892e9abb728e76afcf27323ab29c57fb0fe7aa)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/display/qxl-render.c | 7 +++++++
|
||||
hw/display/vmware_vga.c | 2 ++
|
||||
ui/cursor.c | 8 +++++++-
|
||||
3 files changed, 16 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c
|
||||
index 237ed293ba..ca217004bf 100644
|
||||
--- a/hw/display/qxl-render.c
|
||||
+++ b/hw/display/qxl-render.c
|
||||
@@ -247,6 +247,13 @@ static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor,
|
||||
size_t size;
|
||||
|
||||
c = cursor_alloc(cursor->header.width, cursor->header.height);
|
||||
+
|
||||
+ if (!c) {
|
||||
+ qxl_set_guest_bug(qxl, "%s: cursor %ux%u alloc error", __func__,
|
||||
+ cursor->header.width, cursor->header.height);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
c->hot_x = cursor->header.hot_spot_x;
|
||||
c->hot_y = cursor->header.hot_spot_y;
|
||||
switch (cursor->header.type) {
|
||||
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
|
||||
index e2969a6c81..2b81d6122f 100644
|
||||
--- a/hw/display/vmware_vga.c
|
||||
+++ b/hw/display/vmware_vga.c
|
||||
@@ -509,6 +509,8 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
|
||||
int i, pixels;
|
||||
|
||||
qc = cursor_alloc(c->width, c->height);
|
||||
+ assert(qc != NULL);
|
||||
+
|
||||
qc->hot_x = c->hot_x;
|
||||
qc->hot_y = c->hot_y;
|
||||
switch (c->bpp) {
|
||||
diff --git a/ui/cursor.c b/ui/cursor.c
|
||||
index 1d62ddd4d0..835f0802f9 100644
|
||||
--- a/ui/cursor.c
|
||||
+++ b/ui/cursor.c
|
||||
@@ -46,6 +46,8 @@ static QEMUCursor *cursor_parse_xpm(const char *xpm[])
|
||||
|
||||
/* parse pixel data */
|
||||
c = cursor_alloc(width, height);
|
||||
+ assert(c != NULL);
|
||||
+
|
||||
for (pixel = 0, y = 0; y < height; y++, line++) {
|
||||
for (x = 0; x < height; x++, pixel++) {
|
||||
idx = xpm[line][x];
|
||||
@@ -91,7 +93,11 @@ QEMUCursor *cursor_builtin_left_ptr(void)
|
||||
QEMUCursor *cursor_alloc(int width, int height)
|
||||
{
|
||||
QEMUCursor *c;
|
||||
- int datasize = width * height * sizeof(uint32_t);
|
||||
+ size_t datasize = width * height * sizeof(uint32_t);
|
||||
+
|
||||
+ if (width > 512 || height > 512) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
|
||||
c = g_malloc0(sizeof(QEMUCursor) + datasize);
|
||||
c->width = width;
|
57
debian/patches/extra/0022-target-arm-Don-t-assert-for-128-bit-tile-accesses-wh.patch
vendored
Normal file
57
debian/patches/extra/0022-target-arm-Don-t-assert-for-128-bit-tile-accesses-wh.patch
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Maydell <peter.maydell@linaro.org>
|
||||
Date: Mon, 22 Jul 2024 18:29:54 +0100
|
||||
Subject: [PATCH] target/arm: Don't assert for 128-bit tile accesses when SVL
|
||||
is 128
|
||||
|
||||
For an instruction which accesses a 128-bit element tile when
|
||||
the SVL is also 128 (for example MOV z0.Q, p0/M, ZA0H.Q[w0,0]),
|
||||
we will assert in get_tile_rowcol():
|
||||
|
||||
qemu-system-aarch64: ../../tcg/tcg-op.c:926: tcg_gen_deposit_z_i32: Assertion `len > 0' failed.
|
||||
|
||||
This happens because we calculate
|
||||
len = ctz32(streaming_vec_reg_size(s)) - esz;$
|
||||
but if the SVL and the element size are the same len is 0, and
|
||||
the deposit operation asserts.
|
||||
|
||||
In this case the ZA storage contains exactly one 128 bit
|
||||
element ZA tile, and the horizontal or vertical slice is just
|
||||
that tile. This means that regardless of the index value in
|
||||
the Ws register, we always access that tile. (In pseudocode terms,
|
||||
we calculate (index + offset) MOD 1, which is 0.)
|
||||
|
||||
Special case the len == 0 case to avoid hitting the assertion
|
||||
in tcg_gen_deposit_z_i32().
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
|
||||
Message-id: 20240722172957.1041231-2-peter.maydell@linaro.org
|
||||
(cherry picked from commit 56f1c0db928aae0b83fd91c89ddb226b137e2b21)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
target/arm/tcg/translate-sme.c | 10 +++++++++-
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c
|
||||
index 185a8a917b..a50a419af2 100644
|
||||
--- a/target/arm/tcg/translate-sme.c
|
||||
+++ b/target/arm/tcg/translate-sme.c
|
||||
@@ -49,7 +49,15 @@ static TCGv_ptr get_tile_rowcol(DisasContext *s, int esz, int rs,
|
||||
/* Prepare a power-of-two modulo via extraction of @len bits. */
|
||||
len = ctz32(streaming_vec_reg_size(s)) - esz;
|
||||
|
||||
- if (vertical) {
|
||||
+ if (!len) {
|
||||
+ /*
|
||||
+ * SVL is 128 and the element size is 128. There is exactly
|
||||
+ * one 128x128 tile in the ZA storage, and so we calculate
|
||||
+ * (Rs + imm) MOD 1, which is always 0. We need to special case
|
||||
+ * this because TCG doesn't allow deposit ops with len 0.
|
||||
+ */
|
||||
+ tcg_gen_movi_i32(tmp, 0);
|
||||
+ } else if (vertical) {
|
||||
/*
|
||||
* Compute the byte offset of the index within the tile:
|
||||
* (index % (svl / size)) * size
|
59
debian/patches/extra/0023-target-arm-Fix-UMOPA-UMOPS-of-16-bit-values.patch
vendored
Normal file
59
debian/patches/extra/0023-target-arm-Fix-UMOPA-UMOPS-of-16-bit-values.patch
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Maydell <peter.maydell@linaro.org>
|
||||
Date: Mon, 22 Jul 2024 18:29:55 +0100
|
||||
Subject: [PATCH] target/arm: Fix UMOPA/UMOPS of 16-bit values
|
||||
|
||||
The UMOPA/UMOPS instructions are supposed to multiply unsigned 8 or
|
||||
16 bit elements and accumulate the products into a 64-bit element.
|
||||
In the Arm ARM pseudocode, this is done with the usual
|
||||
infinite-precision signed arithmetic. However our implementation
|
||||
doesn't quite get it right, because in the DEF_IMOP_64() macro we do:
|
||||
sum += (NTYPE)(n >> 0) * (MTYPE)(m >> 0);
|
||||
|
||||
where NTYPE and MTYPE are uint16_t or int16_t. In the uint16_t case,
|
||||
the C usual arithmetic conversions mean the values are converted to
|
||||
"int" type and the multiply is done as a 32-bit multiply. This means
|
||||
that if the inputs are, for example, 0xffff and 0xffff then the
|
||||
result is 0xFFFE0001 as an int, which is then promoted to uint64_t
|
||||
for the accumulation into sum; this promotion incorrectly sign
|
||||
extends the multiply.
|
||||
|
||||
Avoid the incorrect sign extension by casting to int64_t before
|
||||
the multiply, so we do the multiply as 64-bit signed arithmetic,
|
||||
which is a type large enough that the multiply can never
|
||||
overflow into the sign bit.
|
||||
|
||||
(The equivalent 8-bit operations in DEF_IMOP_32() are fine, because
|
||||
the 8-bit multiplies can never overflow into the sign bit of a
|
||||
32-bit integer.)
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2372
|
||||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
|
||||
Message-id: 20240722172957.1041231-3-peter.maydell@linaro.org
|
||||
(cherry picked from commit ea3f5a90f036734522e9af3bffd77e69e9f47355)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
target/arm/tcg/sme_helper.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c
|
||||
index 5a6dd76489..f9001f5213 100644
|
||||
--- a/target/arm/tcg/sme_helper.c
|
||||
+++ b/target/arm/tcg/sme_helper.c
|
||||
@@ -1146,10 +1146,10 @@ static uint64_t NAME(uint64_t n, uint64_t m, uint64_t a, uint8_t p, bool neg) \
|
||||
uint64_t sum = 0; \
|
||||
/* Apply P to N as a mask, making the inactive elements 0. */ \
|
||||
n &= expand_pred_h(p); \
|
||||
- sum += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \
|
||||
- sum += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \
|
||||
- sum += (NTYPE)(n >> 32) * (MTYPE)(m >> 32); \
|
||||
- sum += (NTYPE)(n >> 48) * (MTYPE)(m >> 48); \
|
||||
+ sum += (int64_t)(NTYPE)(n >> 0) * (MTYPE)(m >> 0); \
|
||||
+ sum += (int64_t)(NTYPE)(n >> 16) * (MTYPE)(m >> 16); \
|
||||
+ sum += (int64_t)(NTYPE)(n >> 32) * (MTYPE)(m >> 32); \
|
||||
+ sum += (int64_t)(NTYPE)(n >> 48) * (MTYPE)(m >> 48); \
|
||||
return neg ? a - sum : a + sum; \
|
||||
}
|
||||
|
62
debian/patches/extra/0024-target-arm-Avoid-shifts-by-1-in-tszimm_shr-and-tszim.patch
vendored
Normal file
62
debian/patches/extra/0024-target-arm-Avoid-shifts-by-1-in-tszimm_shr-and-tszim.patch
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Maydell <peter.maydell@linaro.org>
|
||||
Date: Mon, 22 Jul 2024 18:29:56 +0100
|
||||
Subject: [PATCH] target/arm: Avoid shifts by -1 in tszimm_shr() and
|
||||
tszimm_shl()
|
||||
|
||||
The function tszimm_esz() returns a shift amount, or possibly -1 in
|
||||
certain cases that correspond to unallocated encodings in the
|
||||
instruction set. We catch these later in the trans_ functions
|
||||
(generally with an "a-esz < 0" check), but before we do the
|
||||
decodetree-generated code will also call tszimm_shr() or tszimm_sl(),
|
||||
which will use the tszimm_esz() return value as a shift count without
|
||||
checking that it is not negative, which is undefined behaviour.
|
||||
|
||||
Avoid the UB by checking the return value in tszimm_shr() and
|
||||
tszimm_shl().
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Resolves: Coverity CID 1547617, 1547694
|
||||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
|
||||
Message-id: 20240722172957.1041231-4-peter.maydell@linaro.org
|
||||
(cherry picked from commit 76916dfa89e8900639c1055c07a295c06628a0bc)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
target/arm/tcg/translate-sve.c | 18 ++++++++++++++++--
|
||||
1 file changed, 16 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c
|
||||
index ada05aa530..466a19c25a 100644
|
||||
--- a/target/arm/tcg/translate-sve.c
|
||||
+++ b/target/arm/tcg/translate-sve.c
|
||||
@@ -50,13 +50,27 @@ static int tszimm_esz(DisasContext *s, int x)
|
||||
|
||||
static int tszimm_shr(DisasContext *s, int x)
|
||||
{
|
||||
- return (16 << tszimm_esz(s, x)) - x;
|
||||
+ /*
|
||||
+ * We won't use the tszimm_shr() value if tszimm_esz() returns -1 (the
|
||||
+ * trans function will check for esz < 0), so we can return any
|
||||
+ * value we like from here in that case as long as we avoid UB.
|
||||
+ */
|
||||
+ int esz = tszimm_esz(s, x);
|
||||
+ if (esz < 0) {
|
||||
+ return esz;
|
||||
+ }
|
||||
+ return (16 << esz) - x;
|
||||
}
|
||||
|
||||
/* See e.g. LSL (immediate, predicated). */
|
||||
static int tszimm_shl(DisasContext *s, int x)
|
||||
{
|
||||
- return x - (8 << tszimm_esz(s, x));
|
||||
+ /* As with tszimm_shr(), value will be unused if esz < 0 */
|
||||
+ int esz = tszimm_esz(s, x);
|
||||
+ if (esz < 0) {
|
||||
+ return esz;
|
||||
+ }
|
||||
+ return x - (8 << esz);
|
||||
}
|
||||
|
||||
/* The SH bit is in bit 8. Extract the low 8 and shift. */
|
41
debian/patches/extra/0025-target-arm-Ignore-SMCR_EL2.LEN-and-SVCR_EL2.LEN-if-E.patch
vendored
Normal file
41
debian/patches/extra/0025-target-arm-Ignore-SMCR_EL2.LEN-and-SVCR_EL2.LEN-if-E.patch
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Maydell <peter.maydell@linaro.org>
|
||||
Date: Mon, 22 Jul 2024 18:29:57 +0100
|
||||
Subject: [PATCH] target/arm: Ignore SMCR_EL2.LEN and SVCR_EL2.LEN if EL2 is
|
||||
not enabled
|
||||
|
||||
When determining the current vector length, the SMCR_EL2.LEN and
|
||||
SVCR_EL2.LEN settings should only be considered if EL2 is enabled
|
||||
(compare the pseudocode CurrentSVL and CurrentNSVL which call
|
||||
EL2Enabled()).
|
||||
|
||||
We were checking against ARM_FEATURE_EL2 rather than calling
|
||||
arm_is_el2_enabled(), which meant that we would look at
|
||||
SMCR_EL2/SVCR_EL2 when in Secure EL1 or Secure EL0 even if Secure EL2
|
||||
was not enabled.
|
||||
|
||||
Use the correct check in sve_vqm1_for_el_sm().
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
|
||||
Message-id: 20240722172957.1041231-5-peter.maydell@linaro.org
|
||||
(cherry picked from commit f573ac059ed060234fcef4299fae9e500d357c33)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
target/arm/helper.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/target/arm/helper.c b/target/arm/helper.c
|
||||
index a620481d7c..42044ae14b 100644
|
||||
--- a/target/arm/helper.c
|
||||
+++ b/target/arm/helper.c
|
||||
@@ -7191,7 +7191,7 @@ uint32_t sve_vqm1_for_el_sm(CPUARMState *env, int el, bool sm)
|
||||
if (el <= 1 && !el_is_in_host(env, el)) {
|
||||
len = MIN(len, 0xf & (uint32_t)cr[1]);
|
||||
}
|
||||
- if (el <= 2 && arm_feature(env, ARM_FEATURE_EL2)) {
|
||||
+ if (el <= 2 && arm_is_el2_enabled(env)) {
|
||||
len = MIN(len, 0xf & (uint32_t)cr[2]);
|
||||
}
|
||||
if (arm_feature(env, ARM_FEATURE_EL3)) {
|
164
debian/patches/extra/0026-target-arm-Handle-denormals-correctly-for-FMOPA-wide.patch
vendored
Normal file
164
debian/patches/extra/0026-target-arm-Handle-denormals-correctly-for-FMOPA-wide.patch
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Maydell <peter.maydell@linaro.org>
|
||||
Date: Thu, 1 Aug 2024 10:15:03 +0100
|
||||
Subject: [PATCH] target/arm: Handle denormals correctly for FMOPA (widening)
|
||||
|
||||
The FMOPA (widening) SME instruction takes pairs of half-precision
|
||||
floating point values, widens them to single-precision, does a
|
||||
two-way dot product and accumulates the results into a
|
||||
single-precision destination. We don't quite correctly handle the
|
||||
FPCR bits FZ and FZ16 which control flushing of denormal inputs and
|
||||
outputs. This is because at the moment we pass a single float_status
|
||||
value to the helper function, which then uses that configuration for
|
||||
all the fp operations it does. However, because the inputs to this
|
||||
operation are float16 and the outputs are float32 we need to use the
|
||||
fp_status_f16 for the float16 input widening but the normal fp_status
|
||||
for everything else. Otherwise we will apply the flushing control
|
||||
FPCR.FZ16 to the 32-bit output rather than the FPCR.FZ control, and
|
||||
incorrectly flush a denormal output to zero when we should not (or
|
||||
vice-versa).
|
||||
|
||||
(In commit 207d30b5fdb5b we tried to fix the FZ handling but
|
||||
didn't get it right, switching from "use FPCR.FZ for everything" to
|
||||
"use FPCR.FZ16 for everything".)
|
||||
|
||||
Pass the CPU env to the sme_fmopa_h helper instead of an fp_status
|
||||
pointer, and have the helper pass an extra fp_status into the
|
||||
f16_dotadd() function so that we can use the right status for the
|
||||
right parts of this operation.
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: 207d30b5fdb5 ("target/arm: Use FPST_F16 for SME FMOPA (widening)")
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2373
|
||||
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
|
||||
(cherry picked from commit 55f9f4ee018c5ccea81d8c8c586756d7711ae46f)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
target/arm/tcg/helper-sme.h | 2 +-
|
||||
target/arm/tcg/sme_helper.c | 39 +++++++++++++++++++++++-----------
|
||||
target/arm/tcg/translate-sme.c | 25 ++++++++++++++++++++--
|
||||
3 files changed, 51 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/target/arm/tcg/helper-sme.h b/target/arm/tcg/helper-sme.h
|
||||
index 27eef49a11..d22bf9d21b 100644
|
||||
--- a/target/arm/tcg/helper-sme.h
|
||||
+++ b/target/arm/tcg/helper-sme.h
|
||||
@@ -121,7 +121,7 @@ DEF_HELPER_FLAGS_5(sme_addha_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
|
||||
DEF_HELPER_FLAGS_5(sme_addva_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
|
||||
|
||||
DEF_HELPER_FLAGS_7(sme_fmopa_h, TCG_CALL_NO_RWG,
|
||||
- void, ptr, ptr, ptr, ptr, ptr, ptr, i32)
|
||||
+ void, ptr, ptr, ptr, ptr, ptr, env, i32)
|
||||
DEF_HELPER_FLAGS_7(sme_fmopa_s, TCG_CALL_NO_RWG,
|
||||
void, ptr, ptr, ptr, ptr, ptr, ptr, i32)
|
||||
DEF_HELPER_FLAGS_7(sme_fmopa_d, TCG_CALL_NO_RWG,
|
||||
diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c
|
||||
index f9001f5213..3906bb51c0 100644
|
||||
--- a/target/arm/tcg/sme_helper.c
|
||||
+++ b/target/arm/tcg/sme_helper.c
|
||||
@@ -976,12 +976,23 @@ static inline uint32_t f16mop_adj_pair(uint32_t pair, uint32_t pg, uint32_t neg)
|
||||
}
|
||||
|
||||
static float32 f16_dotadd(float32 sum, uint32_t e1, uint32_t e2,
|
||||
- float_status *s_std, float_status *s_odd)
|
||||
+ float_status *s_f16, float_status *s_std,
|
||||
+ float_status *s_odd)
|
||||
{
|
||||
- float64 e1r = float16_to_float64(e1 & 0xffff, true, s_std);
|
||||
- float64 e1c = float16_to_float64(e1 >> 16, true, s_std);
|
||||
- float64 e2r = float16_to_float64(e2 & 0xffff, true, s_std);
|
||||
- float64 e2c = float16_to_float64(e2 >> 16, true, s_std);
|
||||
+ /*
|
||||
+ * We need three different float_status for different parts of this
|
||||
+ * operation:
|
||||
+ * - the input conversion of the float16 values must use the
|
||||
+ * f16-specific float_status, so that the FPCR.FZ16 control is applied
|
||||
+ * - operations on float32 including the final accumulation must use
|
||||
+ * the normal float_status, so that FPCR.FZ is applied
|
||||
+ * - we have pre-set-up copy of s_std which is set to round-to-odd,
|
||||
+ * for the multiply (see below)
|
||||
+ */
|
||||
+ float64 e1r = float16_to_float64(e1 & 0xffff, true, s_f16);
|
||||
+ float64 e1c = float16_to_float64(e1 >> 16, true, s_f16);
|
||||
+ float64 e2r = float16_to_float64(e2 & 0xffff, true, s_f16);
|
||||
+ float64 e2c = float16_to_float64(e2 >> 16, true, s_f16);
|
||||
float64 t64;
|
||||
float32 t32;
|
||||
|
||||
@@ -1003,20 +1014,23 @@ static float32 f16_dotadd(float32 sum, uint32_t e1, uint32_t e2,
|
||||
}
|
||||
|
||||
void HELPER(sme_fmopa_h)(void *vza, void *vzn, void *vzm, void *vpn,
|
||||
- void *vpm, void *vst, uint32_t desc)
|
||||
+ void *vpm, CPUARMState *env, uint32_t desc)
|
||||
{
|
||||
intptr_t row, col, oprsz = simd_maxsz(desc);
|
||||
uint32_t neg = simd_data(desc) * 0x80008000u;
|
||||
uint16_t *pn = vpn, *pm = vpm;
|
||||
- float_status fpst_odd, fpst_std;
|
||||
+ float_status fpst_odd, fpst_std, fpst_f16;
|
||||
|
||||
/*
|
||||
- * Make a copy of float_status because this operation does not
|
||||
- * update the cumulative fp exception status. It also produces
|
||||
- * default nans. Make a second copy with round-to-odd -- see above.
|
||||
+ * Make copies of fp_status and fp_status_f16, because this operation
|
||||
+ * does not update the cumulative fp exception status. It also
|
||||
+ * produces default NaNs. We also need a second copy of fp_status with
|
||||
+ * round-to-odd -- see above.
|
||||
*/
|
||||
- fpst_std = *(float_status *)vst;
|
||||
+ fpst_f16 = env->vfp.fp_status_f16;
|
||||
+ fpst_std = env->vfp.fp_status;
|
||||
set_default_nan_mode(true, &fpst_std);
|
||||
+ set_default_nan_mode(true, &fpst_f16);
|
||||
fpst_odd = fpst_std;
|
||||
set_float_rounding_mode(float_round_to_odd, &fpst_odd);
|
||||
|
||||
@@ -1036,7 +1050,8 @@ void HELPER(sme_fmopa_h)(void *vza, void *vzn, void *vzm, void *vpn,
|
||||
uint32_t m = *(uint32_t *)(vzm + H1_4(col));
|
||||
|
||||
m = f16mop_adj_pair(m, pcol, 0);
|
||||
- *a = f16_dotadd(*a, n, m, &fpst_std, &fpst_odd);
|
||||
+ *a = f16_dotadd(*a, n, m,
|
||||
+ &fpst_f16, &fpst_std, &fpst_odd);
|
||||
}
|
||||
col += 4;
|
||||
pcol >>= 4;
|
||||
diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c
|
||||
index a50a419af2..ae42ddef7b 100644
|
||||
--- a/target/arm/tcg/translate-sme.c
|
||||
+++ b/target/arm/tcg/translate-sme.c
|
||||
@@ -334,8 +334,29 @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz,
|
||||
return true;
|
||||
}
|
||||
|
||||
-TRANS_FEAT(FMOPA_h, aa64_sme, do_outprod_fpst, a,
|
||||
- MO_32, FPST_FPCR_F16, gen_helper_sme_fmopa_h)
|
||||
+static bool do_outprod_env(DisasContext *s, arg_op *a, MemOp esz,
|
||||
+ gen_helper_gvec_5_ptr *fn)
|
||||
+{
|
||||
+ int svl = streaming_vec_reg_size(s);
|
||||
+ uint32_t desc = simd_desc(svl, svl, a->sub);
|
||||
+ TCGv_ptr za, zn, zm, pn, pm;
|
||||
+
|
||||
+ if (!sme_smza_enabled_check(s)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ za = get_tile(s, esz, a->zad);
|
||||
+ zn = vec_full_reg_ptr(s, a->zn);
|
||||
+ zm = vec_full_reg_ptr(s, a->zm);
|
||||
+ pn = pred_full_reg_ptr(s, a->pn);
|
||||
+ pm = pred_full_reg_ptr(s, a->pm);
|
||||
+
|
||||
+ fn(za, zn, zm, pn, pm, tcg_env, tcg_constant_i32(desc));
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+TRANS_FEAT(FMOPA_h, aa64_sme, do_outprod_env, a,
|
||||
+ MO_32, gen_helper_sme_fmopa_h)
|
||||
TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a,
|
||||
MO_32, FPST_FPCR, gen_helper_sme_fmopa_s)
|
||||
TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a,
|
39
debian/patches/extra/0027-intel_iommu-fix-FRCD-construction-macro.patch
vendored
Normal file
39
debian/patches/extra/0027-intel_iommu-fix-FRCD-construction-macro.patch
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Cl=C3=A9ment=20Mathieu--Drif?=
|
||||
<clement.mathieu--drif@eviden.com>
|
||||
Date: Tue, 9 Jul 2024 14:26:08 +0000
|
||||
Subject: [PATCH] intel_iommu: fix FRCD construction macro
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The constant must be unsigned, otherwise the two's complement
|
||||
overrides the other fields when a PASID is present.
|
||||
|
||||
Fixes: 1b2b12376c8a ("intel-iommu: PASID support")
|
||||
Signed-off-by: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com>
|
||||
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
|
||||
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||||
Reviewed-by: Minwoo Im <minwoo.im@samsung.com>
|
||||
Message-Id: <20240709142557.317271-2-clement.mathieu--drif@eviden.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit a3c8d7e38550c3d5a46e6fa94ffadfa625a4861d)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/i386/intel_iommu_internal.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h
|
||||
index f8cf99bddf..cbc4030031 100644
|
||||
--- a/hw/i386/intel_iommu_internal.h
|
||||
+++ b/hw/i386/intel_iommu_internal.h
|
||||
@@ -267,7 +267,7 @@
|
||||
/* For the low 64-bit of 128-bit */
|
||||
#define VTD_FRCD_FI(val) ((val) & ~0xfffULL)
|
||||
#define VTD_FRCD_PV(val) (((val) & 0xffffULL) << 40)
|
||||
-#define VTD_FRCD_PP(val) (((val) & 0x1) << 31)
|
||||
+#define VTD_FRCD_PP(val) (((val) & 0x1ULL) << 31)
|
||||
#define VTD_FRCD_IR_IDX(val) (((val) & 0xffffULL) << 48)
|
||||
|
||||
/* DMA Remapping Fault Conditions */
|
33
debian/patches/extra/0028-target-i386-Do-not-apply-REX-to-MMX-operands.patch
vendored
Normal file
33
debian/patches/extra/0028-target-i386-Do-not-apply-REX-to-MMX-operands.patch
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Richard Henderson <richard.henderson@linaro.org>
|
||||
Date: Mon, 12 Aug 2024 12:58:42 +1000
|
||||
Subject: [PATCH] target/i386: Do not apply REX to MMX operands
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: b3e22b2318a ("target/i386: add core of new i386 decoder")
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2495
|
||||
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20240812025844.58956-2-richard.henderson@linaro.org
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
(cherry picked from commit 416f2b16c02c618c0f233372ebfe343f9ee667d4)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
target/i386/tcg/decode-new.c.inc | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
|
||||
index 4209d59ca8..09b8d2314a 100644
|
||||
--- a/target/i386/tcg/decode-new.c.inc
|
||||
+++ b/target/i386/tcg/decode-new.c.inc
|
||||
@@ -1271,7 +1271,10 @@ static bool decode_op(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode,
|
||||
op->unit = X86_OP_SSE;
|
||||
}
|
||||
get_reg:
|
||||
- op->n = ((get_modrm(s, env) >> 3) & 7) | REX_R(s);
|
||||
+ op->n = ((get_modrm(s, env) >> 3) & 7);
|
||||
+ if (op->unit != X86_OP_MMX) {
|
||||
+ op->n |= REX_R(s);
|
||||
+ }
|
||||
break;
|
||||
|
||||
case X86_TYPE_E: /* ALU modrm operand */
|
42
debian/patches/extra/0029-module-Prevent-crash-by-resetting-local_err-in-modul.patch
vendored
Normal file
42
debian/patches/extra/0029-module-Prevent-crash-by-resetting-local_err-in-modul.patch
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
|
||||
Date: Fri, 9 Aug 2024 14:13:40 +0200
|
||||
Subject: [PATCH] module: Prevent crash by resetting local_err in
|
||||
module_load_qom_all()
|
||||
|
||||
Set local_err to NULL after it has been freed in error_report_err(). This
|
||||
avoids triggering assert(*errp == NULL) failure in error_setv() when
|
||||
local_err is reused in the loop.
|
||||
|
||||
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
|
||||
Reviewed-by: Claudio Fontana <cfontana@suse.de>
|
||||
Reviewed-by: Denis V. Lunev <den@openvz.org>
|
||||
Link: https://lore.kernel.org/r/20240809121340.992049-2-alexander.ivanov@virtuozzo.com
|
||||
[Do the same by moving the declaration instead. - Paolo]
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
(cherry picked from commit 940d802b24e63650e0eacad3714e2ce171cba17c)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
util/module.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/util/module.c b/util/module.c
|
||||
index 32e263163c..3eb0f06df1 100644
|
||||
--- a/util/module.c
|
||||
+++ b/util/module.c
|
||||
@@ -354,13 +354,13 @@ int module_load_qom(const char *type, Error **errp)
|
||||
void module_load_qom_all(void)
|
||||
{
|
||||
const QemuModinfo *modinfo;
|
||||
- Error *local_err = NULL;
|
||||
|
||||
if (module_loaded_qom_all) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (modinfo = module_info; modinfo->name != NULL; modinfo++) {
|
||||
+ Error *local_err = NULL;
|
||||
if (!modinfo->objs) {
|
||||
continue;
|
||||
}
|
164
debian/patches/extra/0030-nbd-server-Plumb-in-new-args-to-nbd_client_add.patch
vendored
Normal file
164
debian/patches/extra/0030-nbd-server-Plumb-in-new-args-to-nbd_client_add.patch
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Blake <eblake@redhat.com>
|
||||
Date: Wed, 7 Aug 2024 08:50:01 -0500
|
||||
Subject: [PATCH] nbd/server: Plumb in new args to nbd_client_add()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Upcoming patches to fix a CVE need to track an opaque pointer passed
|
||||
in by the owner of a client object, as well as request for a time
|
||||
limit on how fast negotiation must complete. Prepare for that by
|
||||
changing the signature of nbd_client_new() and adding an accessor to
|
||||
get at the opaque pointer, although for now the two servers
|
||||
(qemu-nbd.c and blockdev-nbd.c) do not change behavior even though
|
||||
they pass in a new default timeout value.
|
||||
|
||||
Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||||
Message-ID: <20240807174943.771624-11-eblake@redhat.com>
|
||||
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
[eblake: s/LIMIT/MAX_SECS/ as suggested by Dan]
|
||||
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||||
(cherry picked from commit fb1c2aaa981e0a2fa6362c9985f1296b74f055ac)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
blockdev-nbd.c | 6 ++++--
|
||||
include/block/nbd.h | 11 ++++++++++-
|
||||
nbd/server.c | 20 +++++++++++++++++---
|
||||
qemu-nbd.c | 4 +++-
|
||||
4 files changed, 34 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
|
||||
index 213012435f..267a1de903 100644
|
||||
--- a/blockdev-nbd.c
|
||||
+++ b/blockdev-nbd.c
|
||||
@@ -64,8 +64,10 @@ static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc,
|
||||
nbd_update_server_watch(nbd_server);
|
||||
|
||||
qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
|
||||
- nbd_client_new(cioc, nbd_server->tlscreds, nbd_server->tlsauthz,
|
||||
- nbd_blockdev_client_closed);
|
||||
+ /* TODO - expose handshake timeout as QMP option */
|
||||
+ nbd_client_new(cioc, NBD_DEFAULT_HANDSHAKE_MAX_SECS,
|
||||
+ nbd_server->tlscreds, nbd_server->tlsauthz,
|
||||
+ nbd_blockdev_client_closed, NULL);
|
||||
}
|
||||
|
||||
static void nbd_update_server_watch(NBDServerData *s)
|
||||
diff --git a/include/block/nbd.h b/include/block/nbd.h
|
||||
index 4e7bd6342f..1d4d65922d 100644
|
||||
--- a/include/block/nbd.h
|
||||
+++ b/include/block/nbd.h
|
||||
@@ -33,6 +33,12 @@ typedef struct NBDMetaContexts NBDMetaContexts;
|
||||
|
||||
extern const BlockExportDriver blk_exp_nbd;
|
||||
|
||||
+/*
|
||||
+ * NBD_DEFAULT_HANDSHAKE_MAX_SECS: Number of seconds in which client must
|
||||
+ * succeed at NBD_OPT_GO before being forcefully dropped as too slow.
|
||||
+ */
|
||||
+#define NBD_DEFAULT_HANDSHAKE_MAX_SECS 10
|
||||
+
|
||||
/* Handshake phase structs - this struct is passed on the wire */
|
||||
|
||||
typedef struct NBDOption {
|
||||
@@ -403,9 +409,12 @@ AioContext *nbd_export_aio_context(NBDExport *exp);
|
||||
NBDExport *nbd_export_find(const char *name);
|
||||
|
||||
void nbd_client_new(QIOChannelSocket *sioc,
|
||||
+ uint32_t handshake_max_secs,
|
||||
QCryptoTLSCreds *tlscreds,
|
||||
const char *tlsauthz,
|
||||
- void (*close_fn)(NBDClient *, bool));
|
||||
+ void (*close_fn)(NBDClient *, bool),
|
||||
+ void *owner);
|
||||
+void *nbd_client_owner(NBDClient *client);
|
||||
void nbd_client_get(NBDClient *client);
|
||||
void nbd_client_put(NBDClient *client);
|
||||
|
||||
diff --git a/nbd/server.c b/nbd/server.c
|
||||
index 892797bb11..e50012499f 100644
|
||||
--- a/nbd/server.c
|
||||
+++ b/nbd/server.c
|
||||
@@ -124,12 +124,14 @@ struct NBDMetaContexts {
|
||||
struct NBDClient {
|
||||
int refcount; /* atomic */
|
||||
void (*close_fn)(NBDClient *client, bool negotiated);
|
||||
+ void *owner;
|
||||
|
||||
QemuMutex lock;
|
||||
|
||||
NBDExport *exp;
|
||||
QCryptoTLSCreds *tlscreds;
|
||||
char *tlsauthz;
|
||||
+ uint32_t handshake_max_secs;
|
||||
QIOChannelSocket *sioc; /* The underlying data channel */
|
||||
QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */
|
||||
|
||||
@@ -3191,6 +3193,7 @@ static coroutine_fn void nbd_co_client_start(void *opaque)
|
||||
|
||||
qemu_co_mutex_init(&client->send_lock);
|
||||
|
||||
+ /* TODO - utilize client->handshake_max_secs */
|
||||
if (nbd_negotiate(client, &local_err)) {
|
||||
if (local_err) {
|
||||
error_report_err(local_err);
|
||||
@@ -3205,14 +3208,17 @@ static coroutine_fn void nbd_co_client_start(void *opaque)
|
||||
}
|
||||
|
||||
/*
|
||||
- * Create a new client listener using the given channel @sioc.
|
||||
+ * Create a new client listener using the given channel @sioc and @owner.
|
||||
* Begin servicing it in a coroutine. When the connection closes, call
|
||||
- * @close_fn with an indication of whether the client completed negotiation.
|
||||
+ * @close_fn with an indication of whether the client completed negotiation
|
||||
+ * within @handshake_max_secs seconds (0 for unbounded).
|
||||
*/
|
||||
void nbd_client_new(QIOChannelSocket *sioc,
|
||||
+ uint32_t handshake_max_secs,
|
||||
QCryptoTLSCreds *tlscreds,
|
||||
const char *tlsauthz,
|
||||
- void (*close_fn)(NBDClient *, bool))
|
||||
+ void (*close_fn)(NBDClient *, bool),
|
||||
+ void *owner)
|
||||
{
|
||||
NBDClient *client;
|
||||
Coroutine *co;
|
||||
@@ -3225,13 +3231,21 @@ void nbd_client_new(QIOChannelSocket *sioc,
|
||||
object_ref(OBJECT(client->tlscreds));
|
||||
}
|
||||
client->tlsauthz = g_strdup(tlsauthz);
|
||||
+ client->handshake_max_secs = handshake_max_secs;
|
||||
client->sioc = sioc;
|
||||
qio_channel_set_delay(QIO_CHANNEL(sioc), false);
|
||||
object_ref(OBJECT(client->sioc));
|
||||
client->ioc = QIO_CHANNEL(sioc);
|
||||
object_ref(OBJECT(client->ioc));
|
||||
client->close_fn = close_fn;
|
||||
+ client->owner = owner;
|
||||
|
||||
co = qemu_coroutine_create(nbd_co_client_start, client);
|
||||
qemu_coroutine_enter(co);
|
||||
}
|
||||
+
|
||||
+void *
|
||||
+nbd_client_owner(NBDClient *client)
|
||||
+{
|
||||
+ return client->owner;
|
||||
+}
|
||||
diff --git a/qemu-nbd.c b/qemu-nbd.c
|
||||
index d7b3ccab21..48e2fa5858 100644
|
||||
--- a/qemu-nbd.c
|
||||
+++ b/qemu-nbd.c
|
||||
@@ -390,7 +390,9 @@ static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc,
|
||||
|
||||
nb_fds++;
|
||||
nbd_update_server_watch();
|
||||
- nbd_client_new(cioc, tlscreds, tlsauthz, nbd_client_closed);
|
||||
+ /* TODO - expose handshake timeout as command line option */
|
||||
+ nbd_client_new(cioc, NBD_DEFAULT_HANDSHAKE_MAX_SECS,
|
||||
+ tlscreds, tlsauthz, nbd_client_closed, NULL);
|
||||
}
|
||||
|
||||
static void nbd_update_server_watch(void)
|
172
debian/patches/extra/0031-nbd-server-CVE-2024-7409-Cap-default-max-connections.patch
vendored
Normal file
172
debian/patches/extra/0031-nbd-server-CVE-2024-7409-Cap-default-max-connections.patch
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Blake <eblake@redhat.com>
|
||||
Date: Tue, 6 Aug 2024 13:53:00 -0500
|
||||
Subject: [PATCH] nbd/server: CVE-2024-7409: Cap default max-connections to 100
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Allowing an unlimited number of clients to any web service is a recipe
|
||||
for a rudimentary denial of service attack: the client merely needs to
|
||||
open lots of sockets without closing them, until qemu no longer has
|
||||
any more fds available to allocate.
|
||||
|
||||
For qemu-nbd, we default to allowing only 1 connection unless more are
|
||||
explicitly asked for (-e or --shared); this was historically picked as
|
||||
a nice default (without an explicit -t, a non-persistent qemu-nbd goes
|
||||
away after a client disconnects, without needing any additional
|
||||
follow-up commands), and we are not going to change that interface now
|
||||
(besides, someday we want to point people towards qemu-storage-daemon
|
||||
instead of qemu-nbd).
|
||||
|
||||
But for qemu proper, and the newer qemu-storage-daemon, the QMP
|
||||
nbd-server-start command has historically had a default of unlimited
|
||||
number of connections, in part because unlike qemu-nbd it is
|
||||
inherently persistent until nbd-server-stop. Allowing multiple client
|
||||
sockets is particularly useful for clients that can take advantage of
|
||||
MULTI_CONN (creating parallel sockets to increase throughput),
|
||||
although known clients that do so (such as libnbd's nbdcopy) typically
|
||||
use only 8 or 16 connections (the benefits of scaling diminish once
|
||||
more sockets are competing for kernel attention). Picking a number
|
||||
large enough for typical use cases, but not unlimited, makes it
|
||||
slightly harder for a malicious client to perform a denial of service
|
||||
merely by opening lots of connections withot progressing through the
|
||||
handshake.
|
||||
|
||||
This change does not eliminate CVE-2024-7409 on its own, but reduces
|
||||
the chance for fd exhaustion or unlimited memory usage as an attack
|
||||
surface. On the other hand, by itself, it makes it more obvious that
|
||||
with a finite limit, we have the problem of an unauthenticated client
|
||||
holding 100 fds opened as a way to block out a legitimate client from
|
||||
being able to connect; thus, later patches will further add timeouts
|
||||
to reject clients that are not making progress.
|
||||
|
||||
This is an INTENTIONAL change in behavior, and will break any client
|
||||
of nbd-server-start that was not passing an explicit max-connections
|
||||
parameter, yet expects more than 100 simultaneous connections. We are
|
||||
not aware of any such client (as stated above, most clients aware of
|
||||
MULTI_CONN get by just fine on 8 or 16 connections, and probably cope
|
||||
with later connections failing by relying on the earlier connections;
|
||||
libvirt has not yet been passing max-connections, but generally
|
||||
creates NBD servers with the intent for a single client for the sake
|
||||
of live storage migration; meanwhile, the KubeSAN project anticipates
|
||||
a large cluster sharing multiple clients [up to 8 per node, and up to
|
||||
100 nodes in a cluster], but it currently uses qemu-nbd with an
|
||||
explicit --shared=0 rather than qemu-storage-daemon with
|
||||
nbd-server-start).
|
||||
|
||||
We considered using a deprecation period (declare that omitting
|
||||
max-parameters is deprecated, and make it mandatory in 3 releases -
|
||||
then we don't need to pick an arbitrary default); that has zero risk
|
||||
of breaking any apps that accidentally depended on more than 100
|
||||
connections, and where such breakage might not be noticed under unit
|
||||
testing but only under the larger loads of production usage. But it
|
||||
does not close the denial-of-service hole until far into the future,
|
||||
and requires all apps to change to add the parameter even if 100 was
|
||||
good enough. It also has a drawback that any app (like libvirt) that
|
||||
is accidentally relying on an unlimited default should seriously
|
||||
consider their own CVE now, at which point they are going to change to
|
||||
pass explicit max-connections sooner than waiting for 3 qemu releases.
|
||||
Finally, if our changed default breaks an app, that app can always
|
||||
pass in an explicit max-parameters with a larger value.
|
||||
|
||||
It is also intentional that the HMP interface to nbd-server-start is
|
||||
not changed to expose max-connections (any client needing to fine-tune
|
||||
things should be using QMP).
|
||||
|
||||
Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||||
Message-ID: <20240807174943.771624-12-eblake@redhat.com>
|
||||
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
[ericb: Expand commit message to summarize Dan's argument for why we
|
||||
break corner-case back-compat behavior without a deprecation period]
|
||||
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||||
(cherry picked from commit c8a76dbd90c2f48df89b75bef74917f90a59b623)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/monitor/block-hmp-cmds.c | 3 ++-
|
||||
blockdev-nbd.c | 8 ++++++++
|
||||
include/block/nbd.h | 7 +++++++
|
||||
qapi/block-export.json | 4 ++--
|
||||
4 files changed, 19 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index d954bec6f1..bdf2eb50b6 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -402,7 +402,8 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
- nbd_server_start(addr, NULL, NULL, 0, &local_err);
|
||||
+ nbd_server_start(addr, NULL, NULL, NBD_DEFAULT_MAX_CONNECTIONS,
|
||||
+ &local_err);
|
||||
qapi_free_SocketAddress(addr);
|
||||
if (local_err != NULL) {
|
||||
goto exit;
|
||||
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
|
||||
index 267a1de903..24ba5382db 100644
|
||||
--- a/blockdev-nbd.c
|
||||
+++ b/blockdev-nbd.c
|
||||
@@ -170,6 +170,10 @@ void nbd_server_start(SocketAddress *addr, const char *tls_creds,
|
||||
|
||||
void nbd_server_start_options(NbdServerOptions *arg, Error **errp)
|
||||
{
|
||||
+ if (!arg->has_max_connections) {
|
||||
+ arg->max_connections = NBD_DEFAULT_MAX_CONNECTIONS;
|
||||
+ }
|
||||
+
|
||||
nbd_server_start(arg->addr, arg->tls_creds, arg->tls_authz,
|
||||
arg->max_connections, errp);
|
||||
}
|
||||
@@ -182,6 +186,10 @@ void qmp_nbd_server_start(SocketAddressLegacy *addr,
|
||||
{
|
||||
SocketAddress *addr_flat = socket_address_flatten(addr);
|
||||
|
||||
+ if (!has_max_connections) {
|
||||
+ max_connections = NBD_DEFAULT_MAX_CONNECTIONS;
|
||||
+ }
|
||||
+
|
||||
nbd_server_start(addr_flat, tls_creds, tls_authz, max_connections, errp);
|
||||
qapi_free_SocketAddress(addr_flat);
|
||||
}
|
||||
diff --git a/include/block/nbd.h b/include/block/nbd.h
|
||||
index 1d4d65922d..d4f8b21aec 100644
|
||||
--- a/include/block/nbd.h
|
||||
+++ b/include/block/nbd.h
|
||||
@@ -39,6 +39,13 @@ extern const BlockExportDriver blk_exp_nbd;
|
||||
*/
|
||||
#define NBD_DEFAULT_HANDSHAKE_MAX_SECS 10
|
||||
|
||||
+/*
|
||||
+ * NBD_DEFAULT_MAX_CONNECTIONS: Number of client sockets to allow at
|
||||
+ * once; must be large enough to allow a MULTI_CONN-aware client like
|
||||
+ * nbdcopy to create its typical number of 8-16 sockets.
|
||||
+ */
|
||||
+#define NBD_DEFAULT_MAX_CONNECTIONS 100
|
||||
+
|
||||
/* Handshake phase structs - this struct is passed on the wire */
|
||||
|
||||
typedef struct NBDOption {
|
||||
diff --git a/qapi/block-export.json b/qapi/block-export.json
|
||||
index 3919a2d5b9..f45e4fd481 100644
|
||||
--- a/qapi/block-export.json
|
||||
+++ b/qapi/block-export.json
|
||||
@@ -28,7 +28,7 @@
|
||||
# @max-connections: The maximum number of connections to allow at the
|
||||
# same time, 0 for unlimited. Setting this to 1 also stops the
|
||||
# server from advertising multiple client support (since 5.2;
|
||||
-# default: 0)
|
||||
+# default: 100)
|
||||
#
|
||||
# Since: 4.2
|
||||
##
|
||||
@@ -63,7 +63,7 @@
|
||||
# @max-connections: The maximum number of connections to allow at the
|
||||
# same time, 0 for unlimited. Setting this to 1 also stops the
|
||||
# server from advertising multiple client support (since 5.2;
|
||||
-# default: 0).
|
||||
+# default: 100).
|
||||
#
|
||||
# Errors:
|
||||
# - if the server is already running
|
123
debian/patches/extra/0032-nbd-server-CVE-2024-7409-Drop-non-negotiating-client.patch
vendored
Normal file
123
debian/patches/extra/0032-nbd-server-CVE-2024-7409-Drop-non-negotiating-client.patch
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Blake <eblake@redhat.com>
|
||||
Date: Thu, 8 Aug 2024 16:05:08 -0500
|
||||
Subject: [PATCH] nbd/server: CVE-2024-7409: Drop non-negotiating clients
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
A client that opens a socket but does not negotiate is merely hogging
|
||||
qemu's resources (an open fd and a small amount of memory); and a
|
||||
malicious client that can access the port where NBD is listening can
|
||||
attempt a denial of service attack by intentionally opening and
|
||||
abandoning lots of unfinished connections. The previous patch put a
|
||||
default bound on the number of such ongoing connections, but once that
|
||||
limit is hit, no more clients can connect (including legitimate ones).
|
||||
The solution is to insist that clients complete handshake within a
|
||||
reasonable time limit, defaulting to 10 seconds. A client that has
|
||||
not successfully completed NBD_OPT_GO by then (including the case of
|
||||
where the client didn't know TLS credentials to even reach the point
|
||||
of NBD_OPT_GO) is wasting our time and does not deserve to stay
|
||||
connected. Later patches will allow fine-tuning the limit away from
|
||||
the default value (including disabling it for doing integration
|
||||
testing of the handshake process itself).
|
||||
|
||||
Note that this patch in isolation actually makes it more likely to see
|
||||
qemu SEGV after nbd-server-stop, as any client socket still connected
|
||||
when the server shuts down will now be closed after 10 seconds rather
|
||||
than at the client's whims. That will be addressed in the next patch.
|
||||
|
||||
For a demo of this patch in action:
|
||||
$ qemu-nbd -f raw -r -t -e 10 file &
|
||||
$ nbdsh --opt-mode -c '
|
||||
H = list()
|
||||
for i in range(20):
|
||||
print(i)
|
||||
H.insert(i, nbd.NBD())
|
||||
H[i].set_opt_mode(True)
|
||||
H[i].connect_uri("nbd://localhost")
|
||||
'
|
||||
$ kill $!
|
||||
|
||||
where later connections get to start progressing once earlier ones are
|
||||
forcefully dropped for taking too long, rather than hanging.
|
||||
|
||||
Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||||
Message-ID: <20240807174943.771624-13-eblake@redhat.com>
|
||||
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
[eblake: rebase to changes earlier in series, reduce scope of timer]
|
||||
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||||
(cherry picked from commit b9b72cb3ce15b693148bd09cef7e50110566d8a0)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
nbd/server.c | 28 +++++++++++++++++++++++++++-
|
||||
nbd/trace-events | 1 +
|
||||
2 files changed, 28 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/nbd/server.c b/nbd/server.c
|
||||
index e50012499f..39285cc971 100644
|
||||
--- a/nbd/server.c
|
||||
+++ b/nbd/server.c
|
||||
@@ -3186,22 +3186,48 @@ static void nbd_client_receive_next_request(NBDClient *client)
|
||||
}
|
||||
}
|
||||
|
||||
+static void nbd_handshake_timer_cb(void *opaque)
|
||||
+{
|
||||
+ QIOChannel *ioc = opaque;
|
||||
+
|
||||
+ trace_nbd_handshake_timer_cb();
|
||||
+ qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);
|
||||
+}
|
||||
+
|
||||
static coroutine_fn void nbd_co_client_start(void *opaque)
|
||||
{
|
||||
NBDClient *client = opaque;
|
||||
Error *local_err = NULL;
|
||||
+ QEMUTimer *handshake_timer = NULL;
|
||||
|
||||
qemu_co_mutex_init(&client->send_lock);
|
||||
|
||||
- /* TODO - utilize client->handshake_max_secs */
|
||||
+ /*
|
||||
+ * Create a timer to bound the time spent in negotiation. If the
|
||||
+ * timer expires, it is likely nbd_negotiate will fail because the
|
||||
+ * socket was shutdown.
|
||||
+ */
|
||||
+ if (client->handshake_max_secs > 0) {
|
||||
+ handshake_timer = aio_timer_new(qemu_get_aio_context(),
|
||||
+ QEMU_CLOCK_REALTIME,
|
||||
+ SCALE_NS,
|
||||
+ nbd_handshake_timer_cb,
|
||||
+ client->sioc);
|
||||
+ timer_mod(handshake_timer,
|
||||
+ qemu_clock_get_ns(QEMU_CLOCK_REALTIME) +
|
||||
+ client->handshake_max_secs * NANOSECONDS_PER_SECOND);
|
||||
+ }
|
||||
+
|
||||
if (nbd_negotiate(client, &local_err)) {
|
||||
if (local_err) {
|
||||
error_report_err(local_err);
|
||||
}
|
||||
+ timer_free(handshake_timer);
|
||||
client_close(client, false);
|
||||
return;
|
||||
}
|
||||
|
||||
+ timer_free(handshake_timer);
|
||||
WITH_QEMU_LOCK_GUARD(&client->lock) {
|
||||
nbd_client_receive_next_request(client);
|
||||
}
|
||||
diff --git a/nbd/trace-events b/nbd/trace-events
|
||||
index 00ae3216a1..cbd0a4ab7e 100644
|
||||
--- a/nbd/trace-events
|
||||
+++ b/nbd/trace-events
|
||||
@@ -76,6 +76,7 @@ nbd_co_receive_request_payload_received(uint64_t cookie, uint64_t len) "Payload
|
||||
nbd_co_receive_ext_payload_compliance(uint64_t from, uint64_t len) "client sent non-compliant write without payload flag: from=0x%" PRIx64 ", len=0x%" PRIx64
|
||||
nbd_co_receive_align_compliance(const char *op, uint64_t from, uint64_t len, uint32_t align) "client sent non-compliant unaligned %s request: from=0x%" PRIx64 ", len=0x%" PRIx64 ", align=0x%" PRIx32
|
||||
nbd_trip(void) "Reading request"
|
||||
+nbd_handshake_timer_cb(void) "client took too long to negotiate"
|
||||
|
||||
# client-connection.c
|
||||
nbd_connect_thread_sleep(uint64_t timeout) "timeout %" PRIu64
|
161
debian/patches/extra/0033-nbd-server-CVE-2024-7409-Close-stray-clients-at-serv.patch
vendored
Normal file
161
debian/patches/extra/0033-nbd-server-CVE-2024-7409-Close-stray-clients-at-serv.patch
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Blake <eblake@redhat.com>
|
||||
Date: Wed, 7 Aug 2024 12:23:13 -0500
|
||||
Subject: [PATCH] nbd/server: CVE-2024-7409: Close stray clients at server-stop
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
A malicious client can attempt to connect to an NBD server, and then
|
||||
intentionally delay progress in the handshake, including if it does
|
||||
not know the TLS secrets. Although the previous two patches reduce
|
||||
this behavior by capping the default max-connections parameter and
|
||||
killing slow clients, they did not eliminate the possibility of a
|
||||
client waiting to close the socket until after the QMP nbd-server-stop
|
||||
command is executed, at which point qemu would SEGV when trying to
|
||||
dereference the NULL nbd_server global which is no longer present.
|
||||
This amounts to a denial of service attack. Worse, if another NBD
|
||||
server is started before the malicious client disconnects, I cannot
|
||||
rule out additional adverse effects when the old client interferes
|
||||
with the connection count of the new server (although the most likely
|
||||
is a crash due to an assertion failure when checking
|
||||
nbd_server->connections > 0).
|
||||
|
||||
For environments without this patch, the CVE can be mitigated by
|
||||
ensuring (such as via a firewall) that only trusted clients can
|
||||
connect to an NBD server. Note that using frameworks like libvirt
|
||||
that ensure that TLS is used and that nbd-server-stop is not executed
|
||||
while any trusted clients are still connected will only help if there
|
||||
is also no possibility for an untrusted client to open a connection
|
||||
but then stall on the NBD handshake.
|
||||
|
||||
Given the previous patches, it would be possible to guarantee that no
|
||||
clients remain connected by having nbd-server-stop sleep for longer
|
||||
than the default handshake deadline before finally freeing the global
|
||||
nbd_server object, but that could make QMP non-responsive for a long
|
||||
time. So intead, this patch fixes the problem by tracking all client
|
||||
sockets opened while the server is running, and forcefully closing any
|
||||
such sockets remaining without a completed handshake at the time of
|
||||
nbd-server-stop, then waiting until the coroutines servicing those
|
||||
sockets notice the state change. nbd-server-stop now has a second
|
||||
AIO_WAIT_WHILE_UNLOCKED (the first is indirectly through the
|
||||
blk_exp_close_all_type() that disconnects all clients that completed
|
||||
handshakes), but forced socket shutdown is enough to progress the
|
||||
coroutines and quickly tear down all clients before the server is
|
||||
freed, thus finally fixing the CVE.
|
||||
|
||||
This patch relies heavily on the fact that nbd/server.c guarantees
|
||||
that it only calls nbd_blockdev_client_closed() from the main loop
|
||||
(see the assertion in nbd_client_put() and the hoops used in
|
||||
nbd_client_put_nonzero() to achieve that); if we did not have that
|
||||
guarantee, we would also need a mutex protecting our accesses of the
|
||||
list of connections to survive re-entrancy from independent iothreads.
|
||||
|
||||
Although I did not actually try to test old builds, it looks like this
|
||||
problem has existed since at least commit 862172f45c (v2.12.0, 2017) -
|
||||
even back when that patch started using a QIONetListener to handle
|
||||
listening on multiple sockets, nbd_server_free() was already unaware
|
||||
that the nbd_blockdev_client_closed callback can be reached later by a
|
||||
client thread that has not completed handshakes (and therefore the
|
||||
client's socket never got added to the list closed in
|
||||
nbd_export_close_all), despite that patch intentionally tearing down
|
||||
the QIONetListener to prevent new clients.
|
||||
|
||||
Reported-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
|
||||
Fixes: CVE-2024-7409
|
||||
CC: qemu-stable@nongnu.org
|
||||
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||||
Message-ID: <20240807174943.771624-14-eblake@redhat.com>
|
||||
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
(cherry picked from commit 3e7ef738c8462c45043a1d39f702a0990406a3b3)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
blockdev-nbd.c | 35 ++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 34 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
|
||||
index 24ba5382db..f73409ae49 100644
|
||||
--- a/blockdev-nbd.c
|
||||
+++ b/blockdev-nbd.c
|
||||
@@ -21,12 +21,18 @@
|
||||
#include "io/channel-socket.h"
|
||||
#include "io/net-listener.h"
|
||||
|
||||
+typedef struct NBDConn {
|
||||
+ QIOChannelSocket *cioc;
|
||||
+ QLIST_ENTRY(NBDConn) next;
|
||||
+} NBDConn;
|
||||
+
|
||||
typedef struct NBDServerData {
|
||||
QIONetListener *listener;
|
||||
QCryptoTLSCreds *tlscreds;
|
||||
char *tlsauthz;
|
||||
uint32_t max_connections;
|
||||
uint32_t connections;
|
||||
+ QLIST_HEAD(, NBDConn) conns;
|
||||
} NBDServerData;
|
||||
|
||||
static NBDServerData *nbd_server;
|
||||
@@ -51,6 +57,14 @@ int nbd_server_max_connections(void)
|
||||
|
||||
static void nbd_blockdev_client_closed(NBDClient *client, bool ignored)
|
||||
{
|
||||
+ NBDConn *conn = nbd_client_owner(client);
|
||||
+
|
||||
+ assert(qemu_in_main_thread() && nbd_server);
|
||||
+
|
||||
+ object_unref(OBJECT(conn->cioc));
|
||||
+ QLIST_REMOVE(conn, next);
|
||||
+ g_free(conn);
|
||||
+
|
||||
nbd_client_put(client);
|
||||
assert(nbd_server->connections > 0);
|
||||
nbd_server->connections--;
|
||||
@@ -60,14 +74,20 @@ static void nbd_blockdev_client_closed(NBDClient *client, bool ignored)
|
||||
static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc,
|
||||
gpointer opaque)
|
||||
{
|
||||
+ NBDConn *conn = g_new0(NBDConn, 1);
|
||||
+
|
||||
+ assert(qemu_in_main_thread() && nbd_server);
|
||||
nbd_server->connections++;
|
||||
+ object_ref(OBJECT(cioc));
|
||||
+ conn->cioc = cioc;
|
||||
+ QLIST_INSERT_HEAD(&nbd_server->conns, conn, next);
|
||||
nbd_update_server_watch(nbd_server);
|
||||
|
||||
qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
|
||||
/* TODO - expose handshake timeout as QMP option */
|
||||
nbd_client_new(cioc, NBD_DEFAULT_HANDSHAKE_MAX_SECS,
|
||||
nbd_server->tlscreds, nbd_server->tlsauthz,
|
||||
- nbd_blockdev_client_closed, NULL);
|
||||
+ nbd_blockdev_client_closed, conn);
|
||||
}
|
||||
|
||||
static void nbd_update_server_watch(NBDServerData *s)
|
||||
@@ -81,12 +101,25 @@ static void nbd_update_server_watch(NBDServerData *s)
|
||||
|
||||
static void nbd_server_free(NBDServerData *server)
|
||||
{
|
||||
+ NBDConn *conn, *tmp;
|
||||
+
|
||||
if (!server) {
|
||||
return;
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ * Forcefully close the listener socket, and any clients that have
|
||||
+ * not yet disconnected on their own.
|
||||
+ */
|
||||
qio_net_listener_disconnect(server->listener);
|
||||
object_unref(OBJECT(server->listener));
|
||||
+ QLIST_FOREACH_SAFE(conn, &server->conns, next, tmp) {
|
||||
+ qio_channel_shutdown(QIO_CHANNEL(conn->cioc), QIO_CHANNEL_SHUTDOWN_BOTH,
|
||||
+ NULL);
|
||||
+ }
|
||||
+
|
||||
+ AIO_WAIT_WHILE_UNLOCKED(NULL, server->connections > 0);
|
||||
+
|
||||
if (server->tlscreds) {
|
||||
object_unref(OBJECT(server->tlscreds));
|
||||
}
|
47
debian/patches/extra/0034-vnc-fix-crash-when-no-console-attached.patch
vendored
Normal file
47
debian/patches/extra/0034-vnc-fix-crash-when-no-console-attached.patch
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
||||
Date: Tue, 20 Aug 2024 17:11:12 +0400
|
||||
Subject: [PATCH] vnc: fix crash when no console attached
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Since commit e99441a3793b5 ("ui/curses: Do not use console_select()")
|
||||
qemu_text_console_put_keysym() no longer checks for NULL console
|
||||
argument, which leads to a later crash:
|
||||
|
||||
Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
|
||||
0x00005555559ee186 in qemu_text_console_handle_keysym (s=0x0, keysym=31) at ../ui/console-vc.c:332
|
||||
332 } else if (s->echo && (keysym == '\r' || keysym == '\n')) {
|
||||
(gdb) bt
|
||||
#0 0x00005555559ee186 in qemu_text_console_handle_keysym (s=0x0, keysym=31) at ../ui/console-vc.c:332
|
||||
#1 0x00005555559e18e5 in qemu_text_console_put_keysym (s=<optimized out>, keysym=<optimized out>) at ../ui/console.c:303
|
||||
#2 0x00005555559f2e88 in do_key_event (vs=vs@entry=0x5555579045c0, down=down@entry=1, keycode=keycode@entry=60, sym=sym@entry=65471) at ../ui/vnc.c:2034
|
||||
#3 0x00005555559f845c in ext_key_event (vs=0x5555579045c0, down=1, sym=65471, keycode=<optimized out>) at ../ui/vnc.c:2070
|
||||
#4 protocol_client_msg (vs=0x5555579045c0, data=<optimized out>, len=<optimized out>) at ../ui/vnc.c:2514
|
||||
#5 0x00005555559f515c in vnc_client_read (vs=0x5555579045c0) at ../ui/vnc.c:1607
|
||||
|
||||
Fixes: e99441a3793b5 ("ui/curses: Do not use console_select()")
|
||||
Fixes: https://issues.redhat.com/browse/RHEL-50529
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
|
||||
(picked from https://lore.kernel.org/qemu-devel/20240820131112.1267954-1-marcandre.lureau@redhat.com/)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
ui/vnc.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ui/vnc.c b/ui/vnc.c
|
||||
index b3fd78022b..953ea38318 100644
|
||||
--- a/ui/vnc.c
|
||||
+++ b/ui/vnc.c
|
||||
@@ -1935,7 +1935,7 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)
|
||||
}
|
||||
|
||||
qkbd_state_key_event(vs->vd->kbd, qcode, down);
|
||||
- if (!qemu_console_is_graphic(vs->vd->dcl.con)) {
|
||||
+ if (QEMU_IS_TEXT_CONSOLE(vs->vd->dcl.con)) {
|
||||
QemuTextConsole *con = QEMU_TEXT_CONSOLE(vs->vd->dcl.con);
|
||||
bool numlock = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_NUMLOCK);
|
||||
bool control = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_CTRL);
|
89
debian/patches/extra/0035-nbd-server-CVE-2024-7409-Avoid-use-after-free-when-c.patch
vendored
Normal file
89
debian/patches/extra/0035-nbd-server-CVE-2024-7409-Avoid-use-after-free-when-c.patch
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Blake <eblake@redhat.com>
|
||||
Date: Thu, 22 Aug 2024 09:35:29 -0500
|
||||
Subject: [PATCH] nbd/server: CVE-2024-7409: Avoid use-after-free when closing
|
||||
server
|
||||
|
||||
Commit 3e7ef738 plugged the use-after-free of the global nbd_server
|
||||
object, but overlooked a use-after-free of nbd_server->listener.
|
||||
Although this race is harder to hit, notice that our shutdown path
|
||||
first drops the reference count of nbd_server->listener, then triggers
|
||||
actions that can result in a pending client reaching the
|
||||
nbd_blockdev_client_closed() callback, which in turn calls
|
||||
qio_net_listener_set_client_func on a potentially stale object.
|
||||
|
||||
If we know we don't want any more clients to connect, and have already
|
||||
told the listener socket to shut down, then we should not be trying to
|
||||
update the listener socket's associated function.
|
||||
|
||||
Reproducer:
|
||||
|
||||
> #!/usr/bin/python3
|
||||
>
|
||||
> import os
|
||||
> from threading import Thread
|
||||
>
|
||||
> def start_stop():
|
||||
> while 1:
|
||||
> os.system('virsh qemu-monitor-command VM \'{"execute": "nbd-server-start",
|
||||
+"arguments":{"addr":{"type":"unix","data":{"path":"/tmp/nbd-sock"}}}}\'')
|
||||
> os.system('virsh qemu-monitor-command VM \'{"execute": "nbd-server-stop"}\'')
|
||||
>
|
||||
> def nbd_list():
|
||||
> while 1:
|
||||
> os.system('/path/to/build/qemu-nbd -L -k /tmp/nbd-sock')
|
||||
>
|
||||
> def test():
|
||||
> sst = Thread(target=start_stop)
|
||||
> sst.start()
|
||||
> nlt = Thread(target=nbd_list)
|
||||
> nlt.start()
|
||||
>
|
||||
> sst.join()
|
||||
> nlt.join()
|
||||
>
|
||||
> test()
|
||||
|
||||
Fixes: CVE-2024-7409
|
||||
Fixes: 3e7ef738c8 ("nbd/server: CVE-2024-7409: Close stray clients at server-stop")
|
||||
CC: qemu-stable@nongnu.org
|
||||
Reported-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
|
||||
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||||
Message-ID: <20240822143617.800419-2-eblake@redhat.com>
|
||||
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
(cherry picked from commit 3874f5f73c441c52f1c699c848d463b0eda01e4c)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
blockdev-nbd.c | 12 ++++++++----
|
||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
|
||||
index f73409ae49..b36f41b7c5 100644
|
||||
--- a/blockdev-nbd.c
|
||||
+++ b/blockdev-nbd.c
|
||||
@@ -92,10 +92,13 @@ static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc,
|
||||
|
||||
static void nbd_update_server_watch(NBDServerData *s)
|
||||
{
|
||||
- if (!s->max_connections || s->connections < s->max_connections) {
|
||||
- qio_net_listener_set_client_func(s->listener, nbd_accept, NULL, NULL);
|
||||
- } else {
|
||||
- qio_net_listener_set_client_func(s->listener, NULL, NULL, NULL);
|
||||
+ if (s->listener) {
|
||||
+ if (!s->max_connections || s->connections < s->max_connections) {
|
||||
+ qio_net_listener_set_client_func(s->listener, nbd_accept, NULL,
|
||||
+ NULL);
|
||||
+ } else {
|
||||
+ qio_net_listener_set_client_func(s->listener, NULL, NULL, NULL);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +116,7 @@ static void nbd_server_free(NBDServerData *server)
|
||||
*/
|
||||
qio_net_listener_disconnect(server->listener);
|
||||
object_unref(OBJECT(server->listener));
|
||||
+ server->listener = NULL;
|
||||
QLIST_FOREACH_SAFE(conn, &server->conns, next, tmp) {
|
||||
qio_channel_shutdown(QIO_CHANNEL(conn->cioc), QIO_CHANNEL_SHUTDOWN_BOTH,
|
||||
NULL);
|
134
debian/patches/extra/0036-softmmu-physmem-fix-memory-leak-in-dirty_memory_exte.patch
vendored
Normal file
134
debian/patches/extra/0036-softmmu-physmem-fix-memory-leak-in-dirty_memory_exte.patch
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: David Hildenbrand <david@redhat.com>
|
||||
Date: Wed, 28 Aug 2024 11:07:43 +0200
|
||||
Subject: [PATCH] softmmu/physmem: fix memory leak in dirty_memory_extend()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
As reported by Peter, we might be leaking memory when removing the
|
||||
highest RAMBlock (in the weird ram_addr_t space), and adding a new one.
|
||||
|
||||
We will fail to realize that we already allocated bitmaps for more
|
||||
dirty memory blocks, and effectively discard the pointers to them.
|
||||
|
||||
Fix it by getting rid of last_ram_page() and by remembering the number
|
||||
of dirty memory blocks that have been allocated already.
|
||||
|
||||
While at it, let's use "unsigned int" for the number of blocks, which
|
||||
should be sufficient until we reach ~32 exabytes.
|
||||
|
||||
Looks like this leak was introduced as we switched from using a single
|
||||
bitmap_zero_extend() to allocating multiple bitmaps:
|
||||
bitmap_zero_extend() relies on g_renew() which should have taken care of
|
||||
this.
|
||||
|
||||
Resolves: https://lkml.kernel.org/r/CAFEAcA-k7a+VObGAfCFNygQNfCKL=AfX6A4kScq=VSSK0peqPg@mail.gmail.com
|
||||
Reported-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Fixes: 5b82b703b69a ("memory: RCU ram_list.dirty_memory[] for safe RAM hotplug")
|
||||
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Reviewed-by: Peter Xu <peterx@redhat.com>
|
||||
Tested-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Cc: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Cc: Paolo Bonzini <pbonzini@redhat.com>
|
||||
Cc: Peter Xu <peterx@redhat.com>
|
||||
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
|
||||
Signed-off-by: David Hildenbrand <david@redhat.com>
|
||||
(picked from https://lore.kernel.org/qemu-devel/20240828090743.128647-1-david@redhat.com/)
|
||||
[FE: backport - remove not-yet-existing variable in context of hunk touching ram_block_add()]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
include/exec/ramlist.h | 1 +
|
||||
system/physmem.c | 35 +++++++++--------------------------
|
||||
2 files changed, 10 insertions(+), 26 deletions(-)
|
||||
|
||||
diff --git a/include/exec/ramlist.h b/include/exec/ramlist.h
|
||||
index 2ad2a81acc..d9cfe530be 100644
|
||||
--- a/include/exec/ramlist.h
|
||||
+++ b/include/exec/ramlist.h
|
||||
@@ -50,6 +50,7 @@ typedef struct RAMList {
|
||||
/* RCU-enabled, writes protected by the ramlist lock. */
|
||||
QLIST_HEAD(, RAMBlock) blocks;
|
||||
DirtyMemoryBlocks *dirty_memory[DIRTY_MEMORY_NUM];
|
||||
+ unsigned int num_dirty_blocks;
|
||||
uint32_t version;
|
||||
QLIST_HEAD(, RAMBlockNotifier) ramblock_notifiers;
|
||||
} RAMList;
|
||||
diff --git a/system/physmem.c b/system/physmem.c
|
||||
index a4fe3d2bf8..78f7db1121 100644
|
||||
--- a/system/physmem.c
|
||||
+++ b/system/physmem.c
|
||||
@@ -1497,18 +1497,6 @@ static ram_addr_t find_ram_offset(ram_addr_t size)
|
||||
return offset;
|
||||
}
|
||||
|
||||
-static unsigned long last_ram_page(void)
|
||||
-{
|
||||
- RAMBlock *block;
|
||||
- ram_addr_t last = 0;
|
||||
-
|
||||
- RCU_READ_LOCK_GUARD();
|
||||
- RAMBLOCK_FOREACH(block) {
|
||||
- last = MAX(last, block->offset + block->max_length);
|
||||
- }
|
||||
- return last >> TARGET_PAGE_BITS;
|
||||
-}
|
||||
-
|
||||
static void qemu_ram_setup_dump(void *addr, ram_addr_t size)
|
||||
{
|
||||
int ret;
|
||||
@@ -1762,13 +1750,11 @@ void qemu_ram_msync(RAMBlock *block, ram_addr_t start, ram_addr_t length)
|
||||
}
|
||||
|
||||
/* Called with ram_list.mutex held */
|
||||
-static void dirty_memory_extend(ram_addr_t old_ram_size,
|
||||
- ram_addr_t new_ram_size)
|
||||
+static void dirty_memory_extend(ram_addr_t new_ram_size)
|
||||
{
|
||||
- ram_addr_t old_num_blocks = DIV_ROUND_UP(old_ram_size,
|
||||
- DIRTY_MEMORY_BLOCK_SIZE);
|
||||
- ram_addr_t new_num_blocks = DIV_ROUND_UP(new_ram_size,
|
||||
- DIRTY_MEMORY_BLOCK_SIZE);
|
||||
+ unsigned int old_num_blocks = ram_list.num_dirty_blocks;
|
||||
+ unsigned int new_num_blocks = DIV_ROUND_UP(new_ram_size,
|
||||
+ DIRTY_MEMORY_BLOCK_SIZE);
|
||||
int i;
|
||||
|
||||
/* Only need to extend if block count increased */
|
||||
@@ -1800,6 +1786,8 @@ static void dirty_memory_extend(ram_addr_t old_ram_size,
|
||||
g_free_rcu(old_blocks, rcu);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ ram_list.num_dirty_blocks = new_num_blocks;
|
||||
}
|
||||
|
||||
static void ram_block_add(RAMBlock *new_block, Error **errp)
|
||||
@@ -1808,11 +1796,9 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)
|
||||
const bool shared = qemu_ram_is_shared(new_block);
|
||||
RAMBlock *block;
|
||||
RAMBlock *last_block = NULL;
|
||||
- ram_addr_t old_ram_size, new_ram_size;
|
||||
+ ram_addr_t ram_size;
|
||||
Error *err = NULL;
|
||||
|
||||
- old_ram_size = last_ram_page();
|
||||
-
|
||||
qemu_mutex_lock_ramlist();
|
||||
new_block->offset = find_ram_offset(new_block->max_length);
|
||||
|
||||
@@ -1840,11 +1826,8 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
- new_ram_size = MAX(old_ram_size,
|
||||
- (new_block->offset + new_block->max_length) >> TARGET_PAGE_BITS);
|
||||
- if (new_ram_size > old_ram_size) {
|
||||
- dirty_memory_extend(old_ram_size, new_ram_size);
|
||||
- }
|
||||
+ ram_size = (new_block->offset + new_block->max_length) >> TARGET_PAGE_BITS;
|
||||
+ dirty_memory_extend(ram_size);
|
||||
/* Keep the list sorted from biggest to smallest block. Unlike QTAILQ,
|
||||
* QLIST (which has an RCU-friendly variant) does not have insertion at
|
||||
* tail, so save the last element in last_block.
|
772
debian/patches/pve-qemu-6.2-vitastor.patch
vendored
772
debian/patches/pve-qemu-6.2-vitastor.patch
vendored
@@ -1,772 +0,0 @@
|
||||
Index: qemu/block/meson.build
|
||||
===================================================================
|
||||
--- qemu.orig/block/meson.build
|
||||
+++ qemu/block/meson.build
|
||||
@@ -91,6 +91,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/meson.build
|
||||
===================================================================
|
||||
--- qemu.orig/meson.build
|
||||
+++ qemu/meson.build
|
||||
@@ -838,6 +838,26 @@ if not get_option('rbd').auto() or have_
|
||||
endif
|
||||
endif
|
||||
|
||||
+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 <vitastor_c.h>
|
||||
+ 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
|
||||
@@ -1459,6 +1479,7 @@ config_host_data.set('CONFIG_LINUX_AIO',
|
||||
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())
|
||||
@@ -3424,6 +3445,7 @@ if spice_protocol.found()
|
||||
summary_info += {' spice server support': spice}
|
||||
endif
|
||||
summary_info += {'rbd support': rbd}
|
||||
+summary_info += {'vitastor support': vitastor}
|
||||
summary_info += {'xfsctl support': config_host.has_key('CONFIG_XFS')}
|
||||
summary_info += {'smartcard support': cacard}
|
||||
summary_info += {'U2F support': u2f}
|
||||
Index: qemu/meson_options.txt
|
||||
===================================================================
|
||||
--- qemu.orig/meson_options.txt
|
||||
+++ qemu/meson_options.txt
|
||||
@@ -121,6 +121,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',
|
||||
Index: qemu/qapi/block-core.json
|
||||
===================================================================
|
||||
--- qemu.orig/qapi/block-core.json
|
||||
+++ qemu/qapi/block-core.json
|
||||
@@ -3179,7 +3179,7 @@
|
||||
'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
|
||||
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
|
||||
'pbs',
|
||||
- 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
|
||||
+ 'ssh', 'throttle', 'vdi', 'vhdx', 'vitastor', 'vmdk', 'vpc', 'vvfat' ] }
|
||||
|
||||
##
|
||||
# @BlockdevOptionsFile:
|
||||
@@ -4125,6 +4125,28 @@
|
||||
'*server': ['InetSocketAddressBase'] } }
|
||||
|
||||
##
|
||||
+# @BlockdevOptionsVitastor:
|
||||
+#
|
||||
+# Driver specific block device options for vitastor
|
||||
+#
|
||||
+# @image: Image name
|
||||
+# @inode: Inode number
|
||||
+# @pool: Pool ID
|
||||
+# @size: Desired image size in bytes
|
||||
+# @config-path: Path to Vitastor configuration
|
||||
+# @etcd-host: etcd connection address(es)
|
||||
+# @etcd-prefix: etcd key/value prefix
|
||||
+##
|
||||
+{ 'struct': 'BlockdevOptionsVitastor',
|
||||
+ 'data': { '*inode': 'uint64',
|
||||
+ '*pool': 'uint64',
|
||||
+ '*size': 'uint64',
|
||||
+ '*image': 'str',
|
||||
+ '*config-path': 'str',
|
||||
+ '*etcd-host': 'str',
|
||||
+ '*etcd-prefix': 'str' } }
|
||||
+
|
||||
+##
|
||||
# @ReplicationMode:
|
||||
#
|
||||
# An enumeration of replication modes.
|
||||
@@ -4520,6 +4542,7 @@
|
||||
'throttle': 'BlockdevOptionsThrottle',
|
||||
'vdi': 'BlockdevOptionsGenericFormat',
|
||||
'vhdx': 'BlockdevOptionsGenericFormat',
|
||||
+ 'vitastor': 'BlockdevOptionsVitastor',
|
||||
'vmdk': 'BlockdevOptionsGenericCOWFormat',
|
||||
'vpc': 'BlockdevOptionsGenericFormat',
|
||||
'vvfat': 'BlockdevOptionsVVFAT'
|
||||
@@ -4910,6 +4933,17 @@
|
||||
'*encrypt' : 'RbdEncryptionCreateOptions' } }
|
||||
|
||||
##
|
||||
+# @BlockdevCreateOptionsVitastor:
|
||||
+#
|
||||
+# Driver specific image creation options for Vitastor.
|
||||
+#
|
||||
+# @size: Size of the virtual disk in bytes
|
||||
+##
|
||||
+{ 'struct': 'BlockdevCreateOptionsVitastor',
|
||||
+ 'data': { 'location': 'BlockdevOptionsVitastor',
|
||||
+ 'size': 'size' } }
|
||||
+
|
||||
+##
|
||||
# @BlockdevVmdkSubformat:
|
||||
#
|
||||
# Subformat options for VMDK images
|
||||
@@ -5108,6 +5142,7 @@
|
||||
'ssh': 'BlockdevCreateOptionsSsh',
|
||||
'vdi': 'BlockdevCreateOptionsVdi',
|
||||
'vhdx': 'BlockdevCreateOptionsVhdx',
|
||||
+ 'vitastor': 'BlockdevCreateOptionsVitastor',
|
||||
'vmdk': 'BlockdevCreateOptionsVmdk',
|
||||
'vpc': 'BlockdevCreateOptionsVpc'
|
||||
} }
|
||||
Index: qemu/scripts/ci/org.centos/stream/8/x86_64/configure
|
||||
===================================================================
|
||||
--- qemu.orig/scripts/ci/org.centos/stream/8/x86_64/configure
|
||||
+++ qemu/scripts/ci/org.centos/stream/8/x86_64/configure
|
||||
@@ -31,7 +31,7 @@
|
||||
--with-git=meson \
|
||||
--with-git-submodules=update \
|
||||
--target-list="x86_64-softmmu" \
|
||||
---block-drv-rw-whitelist="qcow2,raw,file,host_device,nbd,iscsi,rbd,blkdebug,luks,null-co,nvme,copy-on-read,throttle,gluster" \
|
||||
+--block-drv-rw-whitelist="qcow2,raw,file,host_device,nbd,iscsi,rbd,vitastor,blkdebug,luks,null-co,nvme,copy-on-read,throttle,gluster" \
|
||||
--audio-drv-list="" \
|
||||
--block-drv-ro-whitelist="vmdk,vhdx,vpc,https,ssh" \
|
||||
--with-coroutine=ucontext \
|
||||
@@ -183,6 +183,7 @@
|
||||
--enable-opengl \
|
||||
--enable-pie \
|
||||
--enable-rbd \
|
||||
+--enable-vitastor \
|
||||
--enable-rdma \
|
||||
--enable-seccomp \
|
||||
--enable-snappy \
|
||||
Index: qemu/block/vitastor.c
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ qemu/block/vitastor.c
|
||||
@@ -0,0 +1,598 @@
|
||||
+// Copyright (c) Vitaliy Filippov, 2019+
|
||||
+// License: VNPL-1.1 or GNU GPL-2.0+ (see README.md for details)
|
||||
+
|
||||
+// QEMU block driver
|
||||
+
|
||||
+#ifdef VITASTOR_SOURCE_TREE
|
||||
+#define BUILD_DSO
|
||||
+#define _GNU_SOURCE
|
||||
+#endif
|
||||
+#include "qemu/osdep.h"
|
||||
+#include "qemu/main-loop.h"
|
||||
+#include "block/block_int.h"
|
||||
+#include "qapi/error.h"
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
+#include "qapi/qmp/qerror.h"
|
||||
+#include "qemu/uri.h"
|
||||
+#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"
|
||||
+#elif QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 10
|
||||
+#include "qemu/cutils.h"
|
||||
+#include "qapi/qmp/qstring.h"
|
||||
+#include "qapi/qmp/qjson.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 "vitastor_c.h"
|
||||
+
|
||||
+#ifdef VITASTOR_SOURCE_TREE
|
||||
+void qemu_module_dummy(void)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+void DSO_STAMP_FUN(void)
|
||||
+{
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+typedef struct VitastorClient
|
||||
+{
|
||||
+ void *proxy;
|
||||
+ void *watch;
|
||||
+ char *config_path;
|
||||
+ char *etcd_host;
|
||||
+ char *etcd_prefix;
|
||||
+ char *image;
|
||||
+ uint64_t inode;
|
||||
+ uint64_t pool;
|
||||
+ uint64_t size;
|
||||
+ long readonly;
|
||||
+ int use_rdma;
|
||||
+ char *rdma_device;
|
||||
+ int rdma_port_num;
|
||||
+ int rdma_gid_index;
|
||||
+ int rdma_mtu;
|
||||
+ QemuMutex mutex;
|
||||
+} VitastorClient;
|
||||
+
|
||||
+typedef struct VitastorRPC
|
||||
+{
|
||||
+ BlockDriverState *bs;
|
||||
+ Coroutine *co;
|
||||
+ QEMUIOVector *iov;
|
||||
+ long ret;
|
||||
+ int complete;
|
||||
+} VitastorRPC;
|
||||
+
|
||||
+static void vitastor_co_init_task(BlockDriverState *bs, VitastorRPC *task);
|
||||
+static void vitastor_co_generic_bh_cb(void *opaque, long retval);
|
||||
+static void vitastor_co_read_cb(void *opaque, long retval, uint64_t version);
|
||||
+static void vitastor_close(BlockDriverState *bs);
|
||||
+
|
||||
+static char *qemu_vitastor_next_tok(char *src, char delim, char **p)
|
||||
+{
|
||||
+ char *end;
|
||||
+ *p = NULL;
|
||||
+ for (end = src; *end; ++end)
|
||||
+ {
|
||||
+ if (*end == delim)
|
||||
+ break;
|
||||
+ if (*end == '\\' && end[1] != '\0')
|
||||
+ end++;
|
||||
+ }
|
||||
+ if (*end == delim)
|
||||
+ {
|
||||
+ *p = end + 1;
|
||||
+ *end = '\0';
|
||||
+ }
|
||||
+ return src;
|
||||
+}
|
||||
+
|
||||
+static void qemu_vitastor_unescape(char *src)
|
||||
+{
|
||||
+ char *p;
|
||||
+ for (p = src; *src; ++src, ++p)
|
||||
+ {
|
||||
+ if (*src == '\\' && src[1] != '\0')
|
||||
+ src++;
|
||||
+ *p = *src;
|
||||
+ }
|
||||
+ *p = '\0';
|
||||
+}
|
||||
+
|
||||
+// vitastor[:key=value]*
|
||||
+// vitastor[:etcd_host=127.0.0.1]:inode=1:pool=1[:rdma_gid_index=3]
|
||||
+// vitastor:config_path=/etc/vitastor/vitastor.conf:image=testimg
|
||||
+static void vitastor_parse_filename(const char *filename, QDict *options, Error **errp)
|
||||
+{
|
||||
+ const char *start;
|
||||
+ char *p, *buf;
|
||||
+
|
||||
+ if (!strstart(filename, "vitastor:", &start))
|
||||
+ {
|
||||
+ error_setg(errp, "File name must start with 'vitastor:'");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ buf = g_strdup(start);
|
||||
+ p = buf;
|
||||
+
|
||||
+ // The following are all key/value pairs
|
||||
+ while (p)
|
||||
+ {
|
||||
+ int i;
|
||||
+ char *name, *value;
|
||||
+ name = qemu_vitastor_next_tok(p, '=', &p);
|
||||
+ if (!p)
|
||||
+ {
|
||||
+ error_setg(errp, "conf option %s has no value", name);
|
||||
+ break;
|
||||
+ }
|
||||
+ for (i = 0; i < strlen(name); i++)
|
||||
+ if (name[i] == '_')
|
||||
+ name[i] = '-';
|
||||
+ qemu_vitastor_unescape(name);
|
||||
+ value = qemu_vitastor_next_tok(p, ':', &p);
|
||||
+ qemu_vitastor_unescape(value);
|
||||
+ if (!strcmp(name, "inode") ||
|
||||
+ !strcmp(name, "pool") ||
|
||||
+ !strcmp(name, "size") ||
|
||||
+ !strcmp(name, "use-rdma") ||
|
||||
+ !strcmp(name, "rdma-port_num") ||
|
||||
+ !strcmp(name, "rdma-gid-index") ||
|
||||
+ !strcmp(name, "rdma-mtu"))
|
||||
+ {
|
||||
+ unsigned long long num_val;
|
||||
+ if (parse_uint_full(value, &num_val, 0))
|
||||
+ {
|
||||
+ error_setg(errp, "Illegal %s: %s", name, value);
|
||||
+ goto out;
|
||||
+ }
|
||||
+ qdict_put_int(options, name, num_val);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ qdict_put_str(options, name, value);
|
||||
+ }
|
||||
+ }
|
||||
+ if (!qdict_get_try_str(options, "image"))
|
||||
+ {
|
||||
+ if (!qdict_get_try_int(options, "inode", 0))
|
||||
+ {
|
||||
+ error_setg(errp, "one of image (name) and inode (number) must be specified");
|
||||
+ goto out;
|
||||
+ }
|
||||
+ if (!(qdict_get_try_int(options, "inode", 0) >> (64-POOL_ID_BITS)) &&
|
||||
+ !qdict_get_try_int(options, "pool", 0))
|
||||
+ {
|
||||
+ error_setg(errp, "pool number must be specified or included in the inode number");
|
||||
+ goto out;
|
||||
+ }
|
||||
+ if (!qdict_get_try_int(options, "size", 0))
|
||||
+ {
|
||||
+ error_setg(errp, "size must be specified when inode number is used instead of image name");
|
||||
+ goto out;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+out:
|
||||
+ g_free(buf);
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static void coroutine_fn vitastor_co_get_metadata(VitastorRPC *task)
|
||||
+{
|
||||
+ BlockDriverState *bs = task->bs;
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ task->co = qemu_coroutine_self();
|
||||
+
|
||||
+ qemu_mutex_lock(&client->mutex);
|
||||
+ vitastor_c_watch_inode(client->proxy, client->image, vitastor_co_generic_bh_cb, task);
|
||||
+ qemu_mutex_unlock(&client->mutex);
|
||||
+
|
||||
+ while (!task->complete)
|
||||
+ {
|
||||
+ qemu_coroutine_yield();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int vitastor_file_open(BlockDriverState *bs, QDict *options, int flags, Error **errp)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ int64_t ret = 0;
|
||||
+ qemu_mutex_init(&client->mutex);
|
||||
+ client->config_path = g_strdup(qdict_get_try_str(options, "config-path"));
|
||||
+ // FIXME: Rename to etcd_address
|
||||
+ client->etcd_host = g_strdup(qdict_get_try_str(options, "etcd-host"));
|
||||
+ client->etcd_prefix = g_strdup(qdict_get_try_str(options, "etcd-prefix"));
|
||||
+ client->use_rdma = qdict_get_try_int(options, "use-rdma", -1);
|
||||
+ client->rdma_device = g_strdup(qdict_get_try_str(options, "rdma-device"));
|
||||
+ client->rdma_port_num = qdict_get_try_int(options, "rdma-port-num", 0);
|
||||
+ client->rdma_gid_index = qdict_get_try_int(options, "rdma-gid-index", 0);
|
||||
+ client->rdma_mtu = qdict_get_try_int(options, "rdma-mtu", 0);
|
||||
+ client->proxy = vitastor_c_create_qemu(
|
||||
+ (QEMUSetFDHandler*)aio_set_fd_handler, bdrv_get_aio_context(bs), client->config_path, client->etcd_host, client->etcd_prefix,
|
||||
+ client->use_rdma, client->rdma_device, client->rdma_port_num, client->rdma_gid_index, client->rdma_mtu, 0
|
||||
+ );
|
||||
+ client->image = g_strdup(qdict_get_try_str(options, "image"));
|
||||
+ client->readonly = (flags & BDRV_O_RDWR) ? 1 : 0;
|
||||
+ if (client->image)
|
||||
+ {
|
||||
+ // Get image metadata (size and readonly flag)
|
||||
+ VitastorRPC task;
|
||||
+ task.complete = 0;
|
||||
+ task.bs = bs;
|
||||
+ if (qemu_in_coroutine())
|
||||
+ {
|
||||
+ vitastor_co_get_metadata(&task);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ qemu_coroutine_enter(qemu_coroutine_create((void(*)(void*))vitastor_co_get_metadata, &task));
|
||||
+ }
|
||||
+ BDRV_POLL_WHILE(bs, !task.complete);
|
||||
+ client->watch = (void*)task.ret;
|
||||
+ client->readonly = client->readonly || vitastor_c_inode_get_readonly(client->watch);
|
||||
+ client->size = vitastor_c_inode_get_size(client->watch);
|
||||
+ if (!vitastor_c_inode_get_num(client->watch))
|
||||
+ {
|
||||
+ error_setg(errp, "image does not exist");
|
||||
+ vitastor_close(bs);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if (!client->size)
|
||||
+ {
|
||||
+ client->size = qdict_get_try_int(options, "size", 0);
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ client->watch = NULL;
|
||||
+ client->inode = qdict_get_try_int(options, "inode", 0);
|
||||
+ client->pool = qdict_get_try_int(options, "pool", 0);
|
||||
+ if (client->pool)
|
||||
+ {
|
||||
+ client->inode = (client->inode & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1)) | (client->pool << (64-POOL_ID_BITS));
|
||||
+ }
|
||||
+ client->size = qdict_get_try_int(options, "size", 0);
|
||||
+ }
|
||||
+ if (!client->size)
|
||||
+ {
|
||||
+ error_setg(errp, "image size not specified");
|
||||
+ vitastor_close(bs);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bs->total_sectors = client->size / BDRV_SECTOR_SIZE;
|
||||
+ //client->aio_context = bdrv_get_aio_context(bs);
|
||||
+ qdict_del(options, "use-rdma");
|
||||
+ qdict_del(options, "rdma-mtu");
|
||||
+ qdict_del(options, "rdma-gid-index");
|
||||
+ qdict_del(options, "rdma-port-num");
|
||||
+ qdict_del(options, "rdma-device");
|
||||
+ qdict_del(options, "config-path");
|
||||
+ qdict_del(options, "etcd-host");
|
||||
+ qdict_del(options, "etcd-prefix");
|
||||
+ qdict_del(options, "image");
|
||||
+ qdict_del(options, "inode");
|
||||
+ qdict_del(options, "pool");
|
||||
+ qdict_del(options, "size");
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void vitastor_close(BlockDriverState *bs)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ vitastor_c_destroy(client->proxy);
|
||||
+ qemu_mutex_destroy(&client->mutex);
|
||||
+ if (client->config_path)
|
||||
+ g_free(client->config_path);
|
||||
+ if (client->etcd_host)
|
||||
+ g_free(client->etcd_host);
|
||||
+ if (client->etcd_prefix)
|
||||
+ g_free(client->etcd_prefix);
|
||||
+ if (client->image)
|
||||
+ g_free(client->image);
|
||||
+}
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 2
|
||||
+static int vitastor_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
|
||||
+{
|
||||
+ bsz->phys = 4096;
|
||||
+ bsz->log = 512;
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 12
|
||||
+static int coroutine_fn vitastor_co_create_opts(
|
||||
+#if QEMU_VERSION_MAJOR >= 4
|
||||
+ BlockDriver *drv,
|
||||
+#endif
|
||||
+ const char *url, QemuOpts *opts, Error **errp)
|
||||
+{
|
||||
+ QDict *options;
|
||||
+ int ret;
|
||||
+
|
||||
+ options = qdict_new();
|
||||
+ vitastor_parse_filename(url, options, errp);
|
||||
+ if (*errp)
|
||||
+ {
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ // inodes don't require creation in Vitastor. FIXME: They will when there will be some metadata
|
||||
+
|
||||
+ ret = 0;
|
||||
+out:
|
||||
+ qobject_unref(options);
|
||||
+ return ret;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3
|
||||
+static int coroutine_fn vitastor_co_truncate(BlockDriverState *bs, int64_t offset,
|
||||
+#if QEMU_VERSION_MAJOR >= 4
|
||||
+ bool exact,
|
||||
+#endif
|
||||
+ PreallocMode prealloc,
|
||||
+#if QEMU_VERSION_MAJOR >= 5 && QEMU_VERSION_MINOR >= 1 || QEMU_VERSION_MAJOR > 5 || defined RHEL_BDRV_CO_TRUNCATE_FLAGS
|
||||
+ BdrvRequestFlags flags,
|
||||
+#endif
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+
|
||||
+ if (prealloc != PREALLOC_MODE_OFF)
|
||||
+ {
|
||||
+ error_setg(errp, "Unsupported preallocation mode '%s'", PreallocMode_str(prealloc));
|
||||
+ return -ENOTSUP;
|
||||
+ }
|
||||
+
|
||||
+ // TODO: Resize inode to <offset> bytes
|
||||
+ client->size = offset / BDRV_SECTOR_SIZE;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static int vitastor_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
|
||||
+{
|
||||
+ bdi->cluster_size = 4096;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int64_t vitastor_getlength(BlockDriverState *bs)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ return client->size;
|
||||
+}
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 0
|
||||
+static void vitastor_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
+#else
|
||||
+static int vitastor_refresh_limits(BlockDriverState *bs)
|
||||
+#endif
|
||||
+{
|
||||
+ bs->bl.request_alignment = 4096;
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 3
|
||||
+ bs->bl.min_mem_alignment = 4096;
|
||||
+#endif
|
||||
+ bs->bl.opt_mem_alignment = 4096;
|
||||
+#if QEMU_VERSION_MAJOR < 2 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR == 0
|
||||
+ return 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+//static int64_t vitastor_get_allocated_file_size(BlockDriverState *bs)
|
||||
+//{
|
||||
+// return 0;
|
||||
+//}
|
||||
+
|
||||
+static void vitastor_co_init_task(BlockDriverState *bs, VitastorRPC *task)
|
||||
+{
|
||||
+ *task = (VitastorRPC) {
|
||||
+ .co = qemu_coroutine_self(),
|
||||
+ .bs = bs,
|
||||
+ };
|
||||
+}
|
||||
+
|
||||
+static void vitastor_co_generic_bh_cb(void *opaque, long retval)
|
||||
+{
|
||||
+ VitastorRPC *task = opaque;
|
||||
+ task->ret = retval;
|
||||
+ task->complete = 1;
|
||||
+ if (qemu_coroutine_self() != task->co)
|
||||
+ {
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 8
|
||||
+ aio_co_wake(task->co);
|
||||
+#else
|
||||
+ qemu_coroutine_enter(task->co, NULL);
|
||||
+ qemu_aio_release(task);
|
||||
+#endif
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void vitastor_co_read_cb(void *opaque, long retval, uint64_t version)
|
||||
+{
|
||||
+ vitastor_co_generic_bh_cb(opaque, retval);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn vitastor_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *iov, int flags)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ VitastorRPC task;
|
||||
+ vitastor_co_init_task(bs, &task);
|
||||
+ task.iov = iov;
|
||||
+
|
||||
+ uint64_t inode = client->watch ? vitastor_c_inode_get_num(client->watch) : client->inode;
|
||||
+ qemu_mutex_lock(&client->mutex);
|
||||
+ vitastor_c_read(client->proxy, inode, offset, bytes, iov->iov, iov->niov, vitastor_co_read_cb, &task);
|
||||
+ qemu_mutex_unlock(&client->mutex);
|
||||
+
|
||||
+ while (!task.complete)
|
||||
+ {
|
||||
+ qemu_coroutine_yield();
|
||||
+ }
|
||||
+
|
||||
+ return task.ret;
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn vitastor_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *iov, int flags)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ VitastorRPC task;
|
||||
+ vitastor_co_init_task(bs, &task);
|
||||
+ task.iov = iov;
|
||||
+
|
||||
+ uint64_t inode = client->watch ? vitastor_c_inode_get_num(client->watch) : client->inode;
|
||||
+ qemu_mutex_lock(&client->mutex);
|
||||
+ vitastor_c_write(client->proxy, inode, offset, bytes, 0, iov->iov, iov->niov, vitastor_co_generic_bh_cb, &task);
|
||||
+ qemu_mutex_unlock(&client->mutex);
|
||||
+
|
||||
+ while (!task.complete)
|
||||
+ {
|
||||
+ qemu_coroutine_yield();
|
||||
+ }
|
||||
+
|
||||
+ return task.ret;
|
||||
+}
|
||||
+
|
||||
+#if !( QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 7 )
|
||||
+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;
|
||||
+ VitastorRPC task;
|
||||
+ vitastor_co_init_task(bs, &task);
|
||||
+
|
||||
+ qemu_mutex_lock(&client->mutex);
|
||||
+ vitastor_c_sync(client->proxy, vitastor_co_generic_bh_cb, &task);
|
||||
+ qemu_mutex_unlock(&client->mutex);
|
||||
+
|
||||
+ while (!task.complete)
|
||||
+ {
|
||||
+ qemu_coroutine_yield();
|
||||
+ }
|
||||
+
|
||||
+ return task.ret;
|
||||
+}
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 0
|
||||
+static QemuOptsList vitastor_create_opts = {
|
||||
+ .name = "vitastor-create-opts",
|
||||
+ .head = QTAILQ_HEAD_INITIALIZER(vitastor_create_opts.head),
|
||||
+ .desc = {
|
||||
+ {
|
||||
+ .name = BLOCK_OPT_SIZE,
|
||||
+ .type = QEMU_OPT_SIZE,
|
||||
+ .help = "Virtual disk size"
|
||||
+ },
|
||||
+ { /* end of list */ }
|
||||
+ }
|
||||
+};
|
||||
+#else
|
||||
+static QEMUOptionParameter vitastor_create_opts[] = {
|
||||
+ {
|
||||
+ .name = BLOCK_OPT_SIZE,
|
||||
+ .type = OPT_SIZE,
|
||||
+ .help = "Virtual disk size"
|
||||
+ },
|
||||
+ { NULL }
|
||||
+};
|
||||
+#endif
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 4
|
||||
+static const char *vitastor_strong_runtime_opts[] = {
|
||||
+ "inode",
|
||||
+ "pool",
|
||||
+ "config-path",
|
||||
+ "etcd-host",
|
||||
+ "etcd-prefix",
|
||||
+
|
||||
+ NULL
|
||||
+};
|
||||
+#endif
|
||||
+
|
||||
+static BlockDriver bdrv_vitastor = {
|
||||
+ .format_name = "vitastor",
|
||||
+ .protocol_name = "vitastor",
|
||||
+
|
||||
+ .instance_size = sizeof(VitastorClient),
|
||||
+ .bdrv_parse_filename = vitastor_parse_filename,
|
||||
+
|
||||
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
||||
+ .bdrv_get_info = vitastor_get_info,
|
||||
+ .bdrv_getlength = vitastor_getlength,
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 2
|
||||
+ .bdrv_probe_blocksizes = vitastor_probe_blocksizes,
|
||||
+#endif
|
||||
+ .bdrv_refresh_limits = vitastor_refresh_limits,
|
||||
+
|
||||
+ // FIXME: Implement it along with per-inode statistics
|
||||
+ //.bdrv_get_allocated_file_size = vitastor_get_allocated_file_size,
|
||||
+
|
||||
+ .bdrv_file_open = vitastor_file_open,
|
||||
+ .bdrv_close = vitastor_close,
|
||||
+
|
||||
+ // Option list for the create operation
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 0
|
||||
+ .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 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 12
|
||||
+ // For bdrv_create(), used by qemu-img
|
||||
+ .bdrv_co_create_opts = vitastor_co_create_opts,
|
||||
+#endif
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3
|
||||
+ .bdrv_co_truncate = vitastor_co_truncate,
|
||||
+#endif
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 7
|
||||
+ .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
|
||||
+ .strong_runtime_opts = vitastor_strong_runtime_opts,
|
||||
+#endif
|
||||
+};
|
||||
+
|
||||
+static void vitastor_block_init(void)
|
||||
+{
|
||||
+ bdrv_register(&bdrv_vitastor);
|
||||
+}
|
||||
+
|
||||
+block_init(vitastor_block_init);
|
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/block/file-posix.c b/block/file-posix.c
|
||||
index b283093e5b..821405fd02 100644
|
||||
index 35684f7e21..43bc0bd520 100644
|
||||
--- a/block/file-posix.c
|
||||
+++ b/block/file-posix.c
|
||||
@@ -552,7 +552,7 @@ static QemuOptsList raw_runtime_opts = {
|
||||
@@ -563,7 +563,7 @@ static QemuOptsList raw_runtime_opts = {
|
||||
{
|
||||
.name = "locking",
|
||||
.type = QEMU_OPT_STRING,
|
||||
@@ -26,7 +26,7 @@ index b283093e5b..821405fd02 100644
|
||||
},
|
||||
{
|
||||
.name = "pr-manager",
|
||||
@@ -652,7 +652,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
@@ -663,7 +663,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
s->use_lock = false;
|
||||
break;
|
||||
case ON_OFF_AUTO_AUTO:
|
||||
|
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/include/net/net.h b/include/net/net.h
|
||||
index 523136c7ac..c27859b4f6 100644
|
||||
index b1f9b35fcc..096c0d52e4 100644
|
||||
--- a/include/net/net.h
|
||||
+++ b/include/net/net.h
|
||||
@@ -226,8 +226,8 @@ void netdev_add(QemuOpts *opts, Error **errp);
|
||||
@@ -317,8 +317,8 @@ void netdev_add(QemuOpts *opts, Error **errp);
|
||||
int net_hub_id_for_client(NetClientState *nc, int *id);
|
||||
NetClientState *net_hub_port_find(int hub_id);
|
||||
|
||||
|
@@ -10,10 +10,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
|
||||
index 04f2b790c9..19fdbb981c 100644
|
||||
index 6b05738079..d82869900a 100644
|
||||
--- a/target/i386/cpu.h
|
||||
+++ b/target/i386/cpu.h
|
||||
@@ -2039,9 +2039,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
|
||||
@@ -2291,9 +2291,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
|
||||
#define CPU_RESOLVING_TYPE TYPE_X86_CPU
|
||||
|
||||
#ifdef TARGET_X86_64
|
||||
|
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 9 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/ui/spice-core.c b/ui/spice-core.c
|
||||
index 31974b8d6c..a3acdbd682 100644
|
||||
index 15be640286..ea20e6153c 100644
|
||||
--- a/ui/spice-core.c
|
||||
+++ b/ui/spice-core.c
|
||||
@@ -689,32 +689,35 @@ static void qemu_spice_init(void)
|
||||
@@ -690,32 +690,35 @@ static void qemu_spice_init(void)
|
||||
|
||||
if (tls_port) {
|
||||
x509_dir = qemu_opt_get(opts, "x509-dir");
|
||||
|
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 11 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/block/gluster.c b/block/gluster.c
|
||||
index 592e71b22a..aebfece6eb 100644
|
||||
index cc74af06dc..3ba9bbfa5e 100644
|
||||
--- a/block/gluster.c
|
||||
+++ b/block/gluster.c
|
||||
@@ -42,7 +42,7 @@
|
||||
@@ -43,7 +43,7 @@
|
||||
#define GLUSTER_DEBUG_DEFAULT 4
|
||||
#define GLUSTER_DEBUG_MAX 9
|
||||
#define GLUSTER_OPT_LOGFILE "logfile"
|
||||
@@ -21,15 +21,15 @@ index 592e71b22a..aebfece6eb 100644
|
||||
/*
|
||||
* Several versions of GlusterFS (3.12? -> 6.0.1) fail when the transfer size
|
||||
* is greater or equal to 1024 MiB, so we are limiting the transfer size to 512
|
||||
@@ -424,6 +424,7 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
|
||||
@@ -425,6 +425,7 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
|
||||
int old_errno;
|
||||
SocketAddressList *server;
|
||||
unsigned long long port;
|
||||
uint64_t port;
|
||||
+ const char *logfile;
|
||||
|
||||
glfs = glfs_find_preopened(gconf->volume);
|
||||
if (glfs) {
|
||||
@@ -466,9 +467,15 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
|
||||
@@ -467,9 +468,15 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,10 +18,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/block/rbd.c b/block/rbd.c
|
||||
index def96292e0..a4b8fb482c 100644
|
||||
index 84bb2fa5d7..63f60d41be 100644
|
||||
--- a/block/rbd.c
|
||||
+++ b/block/rbd.c
|
||||
@@ -820,6 +820,8 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
||||
@@ -963,6 +963,8 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
||||
rados_conf_set(*cluster, "rbd_cache", "false");
|
||||
}
|
||||
|
||||
|
@@ -16,10 +16,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block/gluster.c b/block/gluster.c
|
||||
index aebfece6eb..3b7ee2f649 100644
|
||||
index 3ba9bbfa5e..34936eb855 100644
|
||||
--- a/block/gluster.c
|
||||
+++ b/block/gluster.c
|
||||
@@ -57,6 +57,7 @@ typedef struct GlusterAIOCB {
|
||||
@@ -58,6 +58,7 @@ typedef struct GlusterAIOCB {
|
||||
int ret;
|
||||
Coroutine *coroutine;
|
||||
AioContext *aio_context;
|
||||
@@ -27,7 +27,7 @@ index aebfece6eb..3b7ee2f649 100644
|
||||
} GlusterAIOCB;
|
||||
|
||||
typedef struct BDRVGlusterState {
|
||||
@@ -752,8 +753,10 @@ static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret,
|
||||
@@ -753,8 +754,10 @@ static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret,
|
||||
acb->ret = 0; /* Success */
|
||||
} else if (ret < 0) {
|
||||
acb->ret = -errno; /* Read/Write failed */
|
||||
@@ -39,7 +39,7 @@ index aebfece6eb..3b7ee2f649 100644
|
||||
}
|
||||
|
||||
aio_co_schedule(acb->aio_context, acb->coroutine);
|
||||
@@ -1022,6 +1025,7 @@ static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
@@ -1023,6 +1026,7 @@ static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
acb.ret = 0;
|
||||
acb.coroutine = qemu_coroutine_self();
|
||||
acb.aio_context = bdrv_get_aio_context(bs);
|
||||
@@ -59,7 +59,7 @@ index aebfece6eb..3b7ee2f649 100644
|
||||
ret = glfs_preadv_async(s->fd, qiov->iov, qiov->niov, offset, 0,
|
||||
gluster_finish_aiocb, &acb);
|
||||
}
|
||||
@@ -1269,6 +1275,7 @@ static coroutine_fn int qemu_gluster_co_flush_to_disk(BlockDriverState *bs)
|
||||
@@ -1268,6 +1274,7 @@ static coroutine_fn int qemu_gluster_co_flush_to_disk(BlockDriverState *bs)
|
||||
acb.ret = 0;
|
||||
acb.coroutine = qemu_coroutine_self();
|
||||
acb.aio_context = bdrv_get_aio_context(bs);
|
||||
@@ -67,7 +67,7 @@ index aebfece6eb..3b7ee2f649 100644
|
||||
|
||||
ret = glfs_fsync_async(s->fd, gluster_finish_aiocb, &acb);
|
||||
if (ret < 0) {
|
||||
@@ -1317,6 +1324,7 @@ static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs,
|
||||
@@ -1316,6 +1323,7 @@ static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs,
|
||||
acb.ret = 0;
|
||||
acb.coroutine = qemu_coroutine_self();
|
||||
acb.aio_context = bdrv_get_aio_context(bs);
|
@@ -1,88 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Date: Mon, 6 Apr 2020 12:16:37 +0200
|
||||
Subject: [PATCH] PVE: [Up] qmp: add get_link_status
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
net/net.c | 27 +++++++++++++++++++++++++++
|
||||
qapi/net.json | 15 +++++++++++++++
|
||||
qapi/pragma.json | 1 +
|
||||
3 files changed, 43 insertions(+)
|
||||
|
||||
diff --git a/net/net.c b/net/net.c
|
||||
index f0d14dbfc1..6d476c47ef 100644
|
||||
--- a/net/net.c
|
||||
+++ b/net/net.c
|
||||
@@ -1334,6 +1334,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
|
||||
}
|
||||
}
|
||||
|
||||
+int64_t qmp_get_link_status(const char *name, Error **errp)
|
||||
+{
|
||||
+ NetClientState *ncs[MAX_QUEUE_NUM];
|
||||
+ NetClientState *nc;
|
||||
+ int queues;
|
||||
+ bool ret;
|
||||
+
|
||||
+ queues = qemu_find_net_clients_except(name, ncs,
|
||||
+ NET_CLIENT_DRIVER__MAX,
|
||||
+ MAX_QUEUE_NUM);
|
||||
+
|
||||
+ if (queues == 0) {
|
||||
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
+ "Device '%s' not found", name);
|
||||
+ return (int64_t) -1;
|
||||
+ }
|
||||
+
|
||||
+ nc = ncs[0];
|
||||
+ ret = ncs[0]->link_down;
|
||||
+
|
||||
+ if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
|
||||
+ ret = ncs[0]->peer->link_down;
|
||||
+ }
|
||||
+
|
||||
+ return (int64_t) ret ? 0 : 1;
|
||||
+}
|
||||
+
|
||||
void colo_notify_filters_event(int event, Error **errp)
|
||||
{
|
||||
NetClientState *nc;
|
||||
diff --git a/qapi/net.json b/qapi/net.json
|
||||
index 7fab2e7cd8..74c9a6109e 100644
|
||||
--- a/qapi/net.json
|
||||
+++ b/qapi/net.json
|
||||
@@ -35,6 +35,21 @@
|
||||
##
|
||||
{ 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
|
||||
|
||||
+##
|
||||
+# @get_link_status:
|
||||
+#
|
||||
+# Get the current link state of the nics or nic.
|
||||
+#
|
||||
+# @name: name of the nic you get the state of
|
||||
+#
|
||||
+# Return: If link is up 1
|
||||
+# If link is down 0
|
||||
+# If an error occure an empty string.
|
||||
+#
|
||||
+# Notes: this is an Proxmox VE extension and not offical part of Qemu.
|
||||
+##
|
||||
+{ 'command': 'get_link_status', 'data': {'name': 'str'} , 'returns': 'int' }
|
||||
+
|
||||
##
|
||||
# @netdev_add:
|
||||
#
|
||||
diff --git a/qapi/pragma.json b/qapi/pragma.json
|
||||
index 3bc0335d1f..7c91ea3685 100644
|
||||
--- a/qapi/pragma.json
|
||||
+++ b/qapi/pragma.json
|
||||
@@ -22,6 +22,7 @@
|
||||
'system_reset',
|
||||
'system_wakeup' ],
|
||||
'command-returns-exceptions': [
|
||||
+ 'get_link_status',
|
||||
'human-monitor-command',
|
||||
'qom-get',
|
||||
'query-tpm-models',
|
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index f036a1d428..080ad9bca7 100644
|
||||
index 7668f86769..2575e97b43 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -2989,7 +2989,8 @@ static int img_info(int argc, char **argv)
|
||||
@@ -3075,7 +3075,8 @@ static int img_info(int argc, char **argv)
|
||||
list = collect_image_info_list(image_opts, filename, fmt, chain,
|
||||
force_share);
|
||||
if (!list) {
|
@@ -31,16 +31,17 @@ override the output file's size.
|
||||
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
qemu-img-cmds.hx | 4 +-
|
||||
qemu-img.c | 187 +++++++++++++++++++++++++++++------------------
|
||||
2 files changed, 119 insertions(+), 72 deletions(-)
|
||||
qemu-img.c | 202 ++++++++++++++++++++++++++++++-----------------
|
||||
2 files changed, 133 insertions(+), 73 deletions(-)
|
||||
|
||||
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
||||
index 72bcdcfbfa..0b2999f3ab 100644
|
||||
index c9dd70a892..048788b23d 100644
|
||||
--- a/qemu-img-cmds.hx
|
||||
+++ b/qemu-img-cmds.hx
|
||||
@@ -58,9 +58,9 @@ SRST
|
||||
@@ -60,9 +60,9 @@ SRST
|
||||
ERST
|
||||
|
||||
DEF("dd", img_dd,
|
||||
@@ -53,10 +54,10 @@ index 72bcdcfbfa..0b2999f3ab 100644
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 080ad9bca7..1f457d9e80 100644
|
||||
index 2575e97b43..8ec68b346f 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4805,10 +4805,12 @@ static int img_bitmap(int argc, char **argv)
|
||||
@@ -4993,10 +4993,12 @@ static int img_bitmap(int argc, char **argv)
|
||||
#define C_IF 04
|
||||
#define C_OF 010
|
||||
#define C_SKIP 020
|
||||
@@ -69,7 +70,7 @@ index 080ad9bca7..1f457d9e80 100644
|
||||
};
|
||||
|
||||
struct DdIo {
|
||||
@@ -4884,6 +4886,19 @@ static int img_dd_skip(const char *arg,
|
||||
@@ -5072,6 +5074,19 @@ static int img_dd_skip(const char *arg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ index 080ad9bca7..1f457d9e80 100644
|
||||
static int img_dd(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -4924,6 +4939,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5112,6 +5127,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ "if", img_dd_if, C_IF },
|
||||
{ "of", img_dd_of, C_OF },
|
||||
{ "skip", img_dd_skip, C_SKIP },
|
||||
@@ -97,7 +98,7 @@ index 080ad9bca7..1f457d9e80 100644
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
const struct option long_options[] = {
|
||||
@@ -4999,91 +5015,112 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5187,91 +5203,112 @@ static int img_dd(int argc, char **argv)
|
||||
arg = NULL;
|
||||
}
|
||||
|
||||
@@ -153,9 +154,9 @@ index 080ad9bca7..1f457d9e80 100644
|
||||
}
|
||||
- create_opts = qemu_opts_append(create_opts, drv->create_opts);
|
||||
- create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
|
||||
|
||||
- opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
|
||||
-
|
||||
- opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
|
||||
|
||||
- size = blk_getlength(blk1);
|
||||
- if (size < 0) {
|
||||
- error_report("Failed to get size for '%s'", in.filename);
|
||||
@@ -274,41 +275,54 @@ index 080ad9bca7..1f457d9e80 100644
|
||||
}
|
||||
|
||||
if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
|
||||
@@ -5101,11 +5138,17 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5288,20 +5325,43 @@ static int img_dd(int argc, char **argv)
|
||||
in.buf = g_new(uint8_t, in.bsz);
|
||||
|
||||
for (out_pos = 0; in_pos < size; block_count++) {
|
||||
int in_ret, out_ret;
|
||||
for (out_pos = 0; in_pos < size; ) {
|
||||
+ int in_ret, out_ret;
|
||||
int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz;
|
||||
-
|
||||
- if (in_pos + in.bsz > size) {
|
||||
- in_ret = blk_pread(blk1, in_pos, in.buf, size - in_pos);
|
||||
+ size_t in_bsz = in_pos + in.bsz > size ? size - in_pos : in.bsz;
|
||||
- ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
|
||||
- if (ret < 0) {
|
||||
+ if (blk1) {
|
||||
+ in_ret = blk_pread(blk1, in_pos, in.buf, in_bsz);
|
||||
} else {
|
||||
- in_ret = blk_pread(blk1, in_pos, in.buf, in.bsz);
|
||||
+ in_ret = read(STDIN_FILENO, in.buf, in_bsz);
|
||||
+ in_ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
|
||||
+ if (in_ret == 0) {
|
||||
+ in_ret = bytes;
|
||||
+ }
|
||||
+ } else {
|
||||
+ in_ret = read(STDIN_FILENO, in.buf, bytes);
|
||||
+ if (in_ret == 0) {
|
||||
+ /* early EOF is considered an error */
|
||||
+ error_report("Input ended unexpectedly");
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
if (in_ret < 0) {
|
||||
+ }
|
||||
+ if (in_ret < 0) {
|
||||
error_report("error while reading from input image file: %s",
|
||||
@@ -5115,9 +5158,13 @@ static int img_dd(int argc, char **argv)
|
||||
- strerror(-ret));
|
||||
+ strerror(-in_ret));
|
||||
+ ret = -1;
|
||||
goto out;
|
||||
}
|
||||
in_pos += in_ret;
|
||||
in_pos += bytes;
|
||||
|
||||
- out_ret = blk_pwrite(blk2, out_pos, in.buf, in_ret, 0);
|
||||
- ret = blk_pwrite(blk2, out_pos, bytes, in.buf, 0);
|
||||
- if (ret < 0) {
|
||||
+ if (blk2) {
|
||||
+ out_ret = blk_pwrite(blk2, out_pos, in.buf, in_ret, 0);
|
||||
+ out_ret = blk_pwrite(blk2, out_pos, in_ret, in.buf, 0);
|
||||
+ if (out_ret == 0) {
|
||||
+ out_ret = in_ret;
|
||||
+ }
|
||||
+ } else {
|
||||
+ out_ret = write(STDOUT_FILENO, in.buf, in_ret);
|
||||
+ }
|
||||
|
||||
- if (out_ret < 0) {
|
||||
+
|
||||
+ if (out_ret != in_ret) {
|
||||
error_report("error while writing to output image file: %s",
|
||||
strerror(-out_ret));
|
||||
ret = -1;
|
||||
- strerror(-ret));
|
||||
+ strerror(-out_ret));
|
||||
+ ret = -1;
|
||||
goto out;
|
||||
}
|
||||
out_pos += bytes;
|
@@ -10,15 +10,16 @@ an expected end of input.
|
||||
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
qemu-img.c | 28 +++++++++++++++++++++++++---
|
||||
1 file changed, 25 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 1f457d9e80..d9e8a8c4d4 100644
|
||||
index 8ec68b346f..b98184bba1 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4806,11 +4806,13 @@ static int img_bitmap(int argc, char **argv)
|
||||
@@ -4994,11 +4994,13 @@ static int img_bitmap(int argc, char **argv)
|
||||
#define C_OF 010
|
||||
#define C_SKIP 020
|
||||
#define C_OSIZE 040
|
||||
@@ -32,7 +33,7 @@ index 1f457d9e80..d9e8a8c4d4 100644
|
||||
};
|
||||
|
||||
struct DdIo {
|
||||
@@ -4899,6 +4901,19 @@ static int img_dd_osize(const char *arg,
|
||||
@@ -5087,6 +5089,19 @@ static int img_dd_osize(const char *arg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -52,13 +53,13 @@ index 1f457d9e80..d9e8a8c4d4 100644
|
||||
static int img_dd(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -4913,12 +4928,14 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5101,12 +5116,14 @@ static int img_dd(int argc, char **argv)
|
||||
int c, i;
|
||||
const char *out_fmt = "raw";
|
||||
const char *fmt = NULL;
|
||||
- int64_t size = 0;
|
||||
+ int64_t size = 0, readsize = 0;
|
||||
int64_t block_count = 0, out_pos, in_pos;
|
||||
int64_t out_pos, in_pos;
|
||||
bool force_share = false;
|
||||
struct DdInfo dd = {
|
||||
.flags = 0,
|
||||
@@ -68,7 +69,7 @@ index 1f457d9e80..d9e8a8c4d4 100644
|
||||
};
|
||||
struct DdIo in = {
|
||||
.bsz = 512, /* Block size is by default 512 bytes */
|
||||
@@ -4940,6 +4957,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5128,6 +5145,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ "of", img_dd_of, C_OF },
|
||||
{ "skip", img_dd_skip, C_SKIP },
|
||||
{ "osize", img_dd_osize, C_OSIZE },
|
||||
@@ -76,20 +77,22 @@ index 1f457d9e80..d9e8a8c4d4 100644
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
const struct option long_options[] = {
|
||||
@@ -5136,14 +5154,18 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5324,9 +5342,10 @@ static int img_dd(int argc, char **argv)
|
||||
|
||||
in.buf = g_new(uint8_t, in.bsz);
|
||||
|
||||
- for (out_pos = 0; in_pos < size; block_count++) {
|
||||
- for (out_pos = 0; in_pos < size; ) {
|
||||
+ readsize = (dd.isize > 0) ? dd.isize : size;
|
||||
+ for (out_pos = 0; in_pos < readsize; block_count++) {
|
||||
+ for (out_pos = 0; in_pos < readsize; ) {
|
||||
int in_ret, out_ret;
|
||||
- size_t in_bsz = in_pos + in.bsz > size ? size - in_pos : in.bsz;
|
||||
+ size_t in_bsz = in_pos + in.bsz > readsize ? readsize - in_pos : in.bsz;
|
||||
- int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz;
|
||||
+ int bytes = (in_pos + in.bsz > readsize) ? readsize - in_pos : in.bsz;
|
||||
if (blk1) {
|
||||
in_ret = blk_pread(blk1, in_pos, in.buf, in_bsz);
|
||||
in_ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
|
||||
if (in_ret == 0) {
|
||||
@@ -5335,6 +5354,9 @@ static int img_dd(int argc, char **argv)
|
||||
} else {
|
||||
in_ret = read(STDIN_FILENO, in.buf, in_bsz);
|
||||
in_ret = read(STDIN_FILENO, in.buf, bytes);
|
||||
if (in_ret == 0) {
|
||||
+ if (dd.isize == 0) {
|
||||
+ goto out;
|
@@ -5,7 +5,7 @@ Subject: [PATCH] PVE: [Up] qemu-img dd: add -n skip_create
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: fix getopt-string + add documentation]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
docs/tools/qemu-img.rst | 11 ++++++++++-
|
||||
qemu-img-cmds.hx | 4 ++--
|
||||
@@ -13,10 +13,10 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
3 files changed, 26 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
|
||||
index d663dd92bd..a49badb158 100644
|
||||
index 3653adb963..d83e8fb3c0 100644
|
||||
--- a/docs/tools/qemu-img.rst
|
||||
+++ b/docs/tools/qemu-img.rst
|
||||
@@ -208,6 +208,10 @@ Parameters to convert subcommand:
|
||||
@@ -212,6 +212,10 @@ Parameters to convert subcommand:
|
||||
|
||||
Parameters to dd subcommand:
|
||||
|
||||
@@ -27,7 +27,7 @@ index d663dd92bd..a49badb158 100644
|
||||
.. program:: qemu-img-dd
|
||||
|
||||
.. option:: bs=BLOCK_SIZE
|
||||
@@ -488,7 +492,7 @@ Command description:
|
||||
@@ -492,7 +496,7 @@ Command description:
|
||||
it doesn't need to be specified separately in this case.
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ index d663dd92bd..a49badb158 100644
|
||||
|
||||
dd copies from *INPUT* file to *OUTPUT* file converting it from
|
||||
*FMT* format to *OUTPUT_FMT* format.
|
||||
@@ -499,6 +503,11 @@ Command description:
|
||||
@@ -503,6 +507,11 @@ Command description:
|
||||
|
||||
The size syntax is similar to :manpage:`dd(1)`'s size syntax.
|
||||
|
||||
@@ -49,10 +49,10 @@ index d663dd92bd..a49badb158 100644
|
||||
|
||||
Give information about the disk image *FILENAME*. Use it in
|
||||
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
||||
index 0b2999f3ab..f3b2b1b4de 100644
|
||||
index 048788b23d..0b29a67a06 100644
|
||||
--- a/qemu-img-cmds.hx
|
||||
+++ b/qemu-img-cmds.hx
|
||||
@@ -58,9 +58,9 @@ SRST
|
||||
@@ -60,9 +60,9 @@ SRST
|
||||
ERST
|
||||
|
||||
DEF("dd", img_dd,
|
||||
@@ -65,19 +65,19 @@ index 0b2999f3ab..f3b2b1b4de 100644
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index d9e8a8c4d4..015d6d2ce4 100644
|
||||
index b98184bba1..6fc8384f64 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4930,7 +4930,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5118,7 +5118,7 @@ static int img_dd(int argc, char **argv)
|
||||
const char *fmt = NULL;
|
||||
int64_t size = 0, readsize = 0;
|
||||
int64_t block_count = 0, out_pos, in_pos;
|
||||
int64_t out_pos, in_pos;
|
||||
- bool force_share = false;
|
||||
+ bool force_share = false, skip_create = false;
|
||||
struct DdInfo dd = {
|
||||
.flags = 0,
|
||||
.count = 0,
|
||||
@@ -4968,7 +4968,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5156,7 +5156,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
@@ -86,7 +86,7 @@ index d9e8a8c4d4..015d6d2ce4 100644
|
||||
if (c == EOF) {
|
||||
break;
|
||||
}
|
||||
@@ -4988,6 +4988,9 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5176,6 +5176,9 @@ static int img_dd(int argc, char **argv)
|
||||
case 'h':
|
||||
help();
|
||||
break;
|
||||
@@ -96,7 +96,7 @@ index d9e8a8c4d4..015d6d2ce4 100644
|
||||
case 'U':
|
||||
force_share = true;
|
||||
break;
|
||||
@@ -5118,13 +5121,15 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5306,13 +5309,15 @@ static int img_dd(int argc, char **argv)
|
||||
size - in.bsz * in.offset, &error_abort);
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Mon, 7 Feb 2022 14:21:01 +0100
|
||||
Subject: [PATCH] qemu-img: dd: add -l option for loading a snapshot
|
||||
Subject: [PATCH] qemu-img dd: add -l option for loading a snapshot
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
docs/tools/qemu-img.rst | 6 +++---
|
||||
@@ -12,10 +12,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
3 files changed, 36 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
|
||||
index a49badb158..1039aec01c 100644
|
||||
index d83e8fb3c0..61c6b21859 100644
|
||||
--- a/docs/tools/qemu-img.rst
|
||||
+++ b/docs/tools/qemu-img.rst
|
||||
@@ -492,10 +492,10 @@ Command description:
|
||||
@@ -496,10 +496,10 @@ Command description:
|
||||
it doesn't need to be specified separately in this case.
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ index a49badb158..1039aec01c 100644
|
||||
The data is by default read and written using blocks of 512 bytes but can be
|
||||
modified by specifying *BLOCK_SIZE*. If count=\ *BLOCKS* is specified
|
||||
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
||||
index f3b2b1b4de..e77ed9347f 100644
|
||||
index 0b29a67a06..758f397232 100644
|
||||
--- a/qemu-img-cmds.hx
|
||||
+++ b/qemu-img-cmds.hx
|
||||
@@ -58,9 +58,9 @@ SRST
|
||||
@@ -60,9 +60,9 @@ SRST
|
||||
ERST
|
||||
|
||||
DEF("dd", img_dd,
|
||||
@@ -46,10 +46,10 @@ index f3b2b1b4de..e77ed9347f 100644
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 015d6d2ce4..7031195e32 100644
|
||||
index 6fc8384f64..a6c88e0860 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4922,6 +4922,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5110,6 +5110,7 @@ static int img_dd(int argc, char **argv)
|
||||
BlockDriver *drv = NULL, *proto_drv = NULL;
|
||||
BlockBackend *blk1 = NULL, *blk2 = NULL;
|
||||
QemuOpts *opts = NULL;
|
||||
@@ -57,15 +57,15 @@ index 015d6d2ce4..7031195e32 100644
|
||||
QemuOptsList *create_opts = NULL;
|
||||
Error *local_err = NULL;
|
||||
bool image_opts = false;
|
||||
@@ -4931,6 +4932,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5119,6 +5120,7 @@ static int img_dd(int argc, char **argv)
|
||||
int64_t size = 0, readsize = 0;
|
||||
int64_t block_count = 0, out_pos, in_pos;
|
||||
int64_t out_pos, in_pos;
|
||||
bool force_share = false, skip_create = false;
|
||||
+ const char *snapshot_name = NULL;
|
||||
struct DdInfo dd = {
|
||||
.flags = 0,
|
||||
.count = 0,
|
||||
@@ -4968,7 +4970,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5156,7 +5158,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ index 015d6d2ce4..7031195e32 100644
|
||||
if (c == EOF) {
|
||||
break;
|
||||
}
|
||||
@@ -4991,6 +4993,19 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5179,6 +5181,19 @@ static int img_dd(int argc, char **argv)
|
||||
case 'n':
|
||||
skip_create = true;
|
||||
break;
|
||||
@@ -94,7 +94,7 @@ index 015d6d2ce4..7031195e32 100644
|
||||
case 'U':
|
||||
force_share = true;
|
||||
break;
|
||||
@@ -5050,11 +5065,24 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5238,11 +5253,24 @@ static int img_dd(int argc, char **argv)
|
||||
if (dd.flags & C_IF) {
|
||||
blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
|
||||
force_share);
|
||||
@@ -120,7 +120,7 @@ index 015d6d2ce4..7031195e32 100644
|
||||
}
|
||||
|
||||
if (dd.flags & C_OSIZE) {
|
||||
@@ -5203,6 +5231,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5397,6 +5425,7 @@ static int img_dd(int argc, char **argv)
|
||||
out:
|
||||
g_free(arg);
|
||||
qemu_opts_del(opts);
|
@@ -7,17 +7,62 @@ Actually provide memory information via the query-balloon
|
||||
command.
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: add BalloonInfo to member name exceptions list
|
||||
rebase for 8.0 - moved to hw/core/machine-hmp-cmds.c]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/core/machine-hmp-cmds.c | 30 +++++++++++++++++++++++++++++-
|
||||
hw/virtio/virtio-balloon.c | 33 +++++++++++++++++++++++++++++++--
|
||||
monitor/hmp-cmds.c | 30 +++++++++++++++++++++++++++++-
|
||||
qapi/machine.json | 22 +++++++++++++++++++++-
|
||||
3 files changed, 81 insertions(+), 4 deletions(-)
|
||||
qapi/pragma.json | 1 +
|
||||
4 files changed, 82 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
|
||||
index a6ff6a4875..e7f74d1c63 100644
|
||||
--- a/hw/core/machine-hmp-cmds.c
|
||||
+++ b/hw/core/machine-hmp-cmds.c
|
||||
@@ -175,7 +175,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
|
||||
return;
|
||||
}
|
||||
|
||||
- monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
|
||||
+ monitor_printf(mon, "balloon: actual=%" PRId64, info->actual >> 20);
|
||||
+ monitor_printf(mon, " max_mem=%" PRId64, info->max_mem >> 20);
|
||||
+ if (info->has_total_mem) {
|
||||
+ monitor_printf(mon, " total_mem=%" PRId64, info->total_mem >> 20);
|
||||
+ }
|
||||
+ if (info->has_free_mem) {
|
||||
+ monitor_printf(mon, " free_mem=%" PRId64, info->free_mem >> 20);
|
||||
+ }
|
||||
+
|
||||
+ if (info->has_mem_swapped_in) {
|
||||
+ monitor_printf(mon, " mem_swapped_in=%" PRId64, info->mem_swapped_in);
|
||||
+ }
|
||||
+ if (info->has_mem_swapped_out) {
|
||||
+ monitor_printf(mon, " mem_swapped_out=%" PRId64, info->mem_swapped_out);
|
||||
+ }
|
||||
+ if (info->has_major_page_faults) {
|
||||
+ monitor_printf(mon, " major_page_faults=%" PRId64,
|
||||
+ info->major_page_faults);
|
||||
+ }
|
||||
+ if (info->has_minor_page_faults) {
|
||||
+ monitor_printf(mon, " minor_page_faults=%" PRId64,
|
||||
+ info->minor_page_faults);
|
||||
+ }
|
||||
+ if (info->has_last_update) {
|
||||
+ monitor_printf(mon, " last_update=%" PRId64,
|
||||
+ info->last_update);
|
||||
+ }
|
||||
+
|
||||
+ monitor_printf(mon, "\n");
|
||||
|
||||
qapi_free_BalloonInfo(info);
|
||||
}
|
||||
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
|
||||
index 9a4f491b54..1faa16234e 100644
|
||||
index 609e39a821..8cb6dfcac3 100644
|
||||
--- a/hw/virtio/virtio-balloon.c
|
||||
+++ b/hw/virtio/virtio-balloon.c
|
||||
@@ -812,8 +812,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
|
||||
@@ -781,8 +781,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
|
||||
static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
|
||||
{
|
||||
VirtIOBalloon *dev = opaque;
|
||||
@@ -57,54 +102,13 @@ index 9a4f491b54..1faa16234e 100644
|
||||
}
|
||||
|
||||
static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index 2e91ccb738..e9fa9af6bd 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -696,7 +696,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
|
||||
return;
|
||||
}
|
||||
|
||||
- monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
|
||||
+ monitor_printf(mon, "balloon: actual=%" PRId64, info->actual >> 20);
|
||||
+ monitor_printf(mon, " max_mem=%" PRId64, info->max_mem >> 20);
|
||||
+ if (info->has_total_mem) {
|
||||
+ monitor_printf(mon, " total_mem=%" PRId64, info->total_mem >> 20);
|
||||
+ }
|
||||
+ if (info->has_free_mem) {
|
||||
+ monitor_printf(mon, " free_mem=%" PRId64, info->free_mem >> 20);
|
||||
+ }
|
||||
+
|
||||
+ if (info->has_mem_swapped_in) {
|
||||
+ monitor_printf(mon, " mem_swapped_in=%" PRId64, info->mem_swapped_in);
|
||||
+ }
|
||||
+ if (info->has_mem_swapped_out) {
|
||||
+ monitor_printf(mon, " mem_swapped_out=%" PRId64, info->mem_swapped_out);
|
||||
+ }
|
||||
+ if (info->has_major_page_faults) {
|
||||
+ monitor_printf(mon, " major_page_faults=%" PRId64,
|
||||
+ info->major_page_faults);
|
||||
+ }
|
||||
+ if (info->has_minor_page_faults) {
|
||||
+ monitor_printf(mon, " minor_page_faults=%" PRId64,
|
||||
+ info->minor_page_faults);
|
||||
+ }
|
||||
+ if (info->has_last_update) {
|
||||
+ monitor_printf(mon, " last_update=%" PRId64,
|
||||
+ info->last_update);
|
||||
+ }
|
||||
+
|
||||
+ monitor_printf(mon, "\n");
|
||||
|
||||
qapi_free_BalloonInfo(info);
|
||||
}
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 067e3f5378..91f3be6f44 100644
|
||||
index e8b60641f2..2054cdc70d 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -1018,10 +1018,30 @@
|
||||
# @actual: the logical size of the VM in bytes
|
||||
# Formula used: logical_vm_size = vm_ram_size - balloon_size
|
||||
@@ -1079,9 +1079,29 @@
|
||||
# @actual: the logical size of the VM in bytes Formula used:
|
||||
# logical_vm_size = vm_ram_size - balloon_size
|
||||
#
|
||||
+# @last_update: time when stats got updated from guest
|
||||
+#
|
||||
@@ -123,7 +127,6 @@ index 067e3f5378..91f3be6f44 100644
|
||||
+# @max_mem: amount of memory (in bytes) assigned to the guest
|
||||
+#
|
||||
# Since: 0.14
|
||||
#
|
||||
##
|
||||
-{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
|
||||
+{ 'struct': 'BalloonInfo',
|
||||
@@ -134,3 +137,15 @@ index 067e3f5378..91f3be6f44 100644
|
||||
|
||||
##
|
||||
# @query-balloon:
|
||||
diff --git a/qapi/pragma.json b/qapi/pragma.json
|
||||
index 59fbe74b8c..be8fa304c5 100644
|
||||
--- a/qapi/pragma.json
|
||||
+++ b/qapi/pragma.json
|
||||
@@ -90,6 +90,7 @@
|
||||
'member-name-exceptions': [ # visible in:
|
||||
'ACPISlotType', # query-acpi-ospm-status
|
||||
'AcpiTableOptions', # -acpitable
|
||||
+ 'BalloonInfo', # query-balloon
|
||||
'BlkdebugEvent', # blockdev-add, -blockdev
|
||||
'BlkdebugSetStateOptions', # blockdev-add, -blockdev
|
||||
'BlockDeviceInfo', # query-block
|
||||
|
@@ -13,13 +13,13 @@ Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
|
||||
2 files changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
|
||||
index 4f4ab30f8c..76fff60a6b 100644
|
||||
index 4b72009cd3..314351cdff 100644
|
||||
--- a/hw/core/machine-qmp-cmds.c
|
||||
+++ b/hw/core/machine-qmp-cmds.c
|
||||
@@ -99,6 +99,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
||||
info->hotpluggable_cpus = mc->has_hotpluggable_cpus;
|
||||
@@ -90,6 +90,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
||||
info->numa_mem_supported = mc->numa_mem_supported;
|
||||
info->deprecated = !!mc->deprecation_reason;
|
||||
info->acpi = !!object_class_property_find(OBJECT_CLASS(mc), "acpi");
|
||||
+
|
||||
+ if (strcmp(mc->name, MACHINE_GET_CLASS(current_machine)->name) == 0) {
|
||||
+ info->has_is_current = true;
|
||||
@@ -28,21 +28,21 @@ index 4f4ab30f8c..76fff60a6b 100644
|
||||
+
|
||||
if (mc->default_cpu_type) {
|
||||
info->default_cpu_type = g_strdup(mc->default_cpu_type);
|
||||
info->has_default_cpu_type = true;
|
||||
}
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 91f3be6f44..0905618e25 100644
|
||||
index 2054cdc70d..a024d5b05d 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -141,6 +141,8 @@
|
||||
@@ -146,6 +146,8 @@
|
||||
#
|
||||
# @is-default: whether the machine is default
|
||||
#
|
||||
+# @is-current: whether this machine is currently used
|
||||
+#
|
||||
# @cpu-max: maximum number of CPUs supported by the machine type
|
||||
# (since 1.5)
|
||||
# (since 1.5)
|
||||
#
|
||||
@@ -162,7 +164,7 @@
|
||||
@@ -170,7 +172,7 @@
|
||||
##
|
||||
{ 'struct': 'MachineInfo',
|
||||
'data': { 'name': 'str', '*alias': 'str',
|
||||
@@ -50,4 +50,4 @@ index 91f3be6f44..0905618e25 100644
|
||||
+ '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
|
||||
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
|
||||
'deprecated': 'bool', '*default-cpu-type': 'str',
|
||||
'*default-ram-id': 'str' } }
|
||||
'*default-ram-id': 'str', 'acpi': 'bool' } }
|
||||
|
@@ -6,16 +6,18 @@ Subject: [PATCH] PVE: qapi: modify spice query
|
||||
Provide the last ticket in the SpiceInfo struct optionally.
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: adapt to QAPI change]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
qapi/ui.json | 3 +++
|
||||
ui/spice-core.c | 5 +++++
|
||||
2 files changed, 8 insertions(+)
|
||||
ui/spice-core.c | 4 ++++
|
||||
2 files changed, 7 insertions(+)
|
||||
|
||||
diff --git a/qapi/ui.json b/qapi/ui.json
|
||||
index 4244c62c30..f946fbd8c1 100644
|
||||
index f610bce118..6ea26a9acb 100644
|
||||
--- a/qapi/ui.json
|
||||
+++ b/qapi/ui.json
|
||||
@@ -333,11 +333,14 @@
|
||||
@@ -314,11 +314,14 @@
|
||||
#
|
||||
# @channels: a list of @SpiceChannel for each active spice channel
|
||||
#
|
||||
@@ -31,15 +33,14 @@ index 4244c62c30..f946fbd8c1 100644
|
||||
'if': 'CONFIG_SPICE' }
|
||||
|
||||
diff --git a/ui/spice-core.c b/ui/spice-core.c
|
||||
index a3acdbd682..756776778d 100644
|
||||
index ea20e6153c..55a15fba8b 100644
|
||||
--- a/ui/spice-core.c
|
||||
+++ b/ui/spice-core.c
|
||||
@@ -534,6 +534,11 @@ static SpiceInfo *qmp_query_spice_real(Error **errp)
|
||||
@@ -548,6 +548,10 @@ static SpiceInfo *qmp_query_spice_real(Error **errp)
|
||||
micro = SPICE_SERVER_VERSION & 0xff;
|
||||
info->compiled_version = g_strdup_printf("%d.%d.%d", major, minor, micro);
|
||||
|
||||
+ if (auth_passwd) {
|
||||
+ info->has_ticket = true;
|
||||
+ info->ticket = g_strdup(auth_passwd);
|
||||
+ }
|
||||
+
|
||||
|
284
debian/patches/pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch
vendored
Normal file
284
debian/patches/pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch
vendored
Normal file
@@ -0,0 +1,284 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 13 Oct 2022 11:33:50 +0200
|
||||
Subject: [PATCH] PVE: add IOChannel implementation for savevm-async
|
||||
|
||||
based on migration/channel-block.c and the implementation that was
|
||||
present in migration/savevm-async.c before QEMU 7.1.
|
||||
|
||||
Passes along read/write requests to the given BlockBackend, while
|
||||
ensuring that a read request going beyond the end results in a
|
||||
graceful short read.
|
||||
|
||||
Additionally, allows tracking the current position from the outside
|
||||
(intended to be used for progress tracking).
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
migration/channel-savevm-async.c | 184 +++++++++++++++++++++++++++++++
|
||||
migration/channel-savevm-async.h | 51 +++++++++
|
||||
migration/meson.build | 1 +
|
||||
3 files changed, 236 insertions(+)
|
||||
create mode 100644 migration/channel-savevm-async.c
|
||||
create mode 100644 migration/channel-savevm-async.h
|
||||
|
||||
diff --git a/migration/channel-savevm-async.c b/migration/channel-savevm-async.c
|
||||
new file mode 100644
|
||||
index 0000000000..081a192f49
|
||||
--- /dev/null
|
||||
+++ b/migration/channel-savevm-async.c
|
||||
@@ -0,0 +1,184 @@
|
||||
+/*
|
||||
+ * QIO Channel implementation to be used by savevm-async QMP calls
|
||||
+ */
|
||||
+#include "qemu/osdep.h"
|
||||
+#include "migration/channel-savevm-async.h"
|
||||
+#include "qapi/error.h"
|
||||
+#include "sysemu/block-backend.h"
|
||||
+#include "trace.h"
|
||||
+
|
||||
+QIOChannelSavevmAsync *
|
||||
+qio_channel_savevm_async_new(BlockBackend *be, size_t *bs_pos)
|
||||
+{
|
||||
+ QIOChannelSavevmAsync *ioc;
|
||||
+
|
||||
+ ioc = QIO_CHANNEL_SAVEVM_ASYNC(object_new(TYPE_QIO_CHANNEL_SAVEVM_ASYNC));
|
||||
+
|
||||
+ bdrv_ref(blk_bs(be));
|
||||
+ ioc->be = be;
|
||||
+ ioc->bs_pos = bs_pos;
|
||||
+
|
||||
+ return ioc;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void
|
||||
+qio_channel_savevm_async_finalize(Object *obj)
|
||||
+{
|
||||
+ QIOChannelSavevmAsync *ioc = QIO_CHANNEL_SAVEVM_ASYNC(obj);
|
||||
+
|
||||
+ if (ioc->be) {
|
||||
+ bdrv_unref(blk_bs(ioc->be));
|
||||
+ ioc->be = NULL;
|
||||
+ }
|
||||
+ ioc->bs_pos = NULL;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static ssize_t
|
||||
+qio_channel_savevm_async_readv(QIOChannel *ioc,
|
||||
+ const struct iovec *iov,
|
||||
+ size_t niov,
|
||||
+ int **fds,
|
||||
+ size_t *nfds,
|
||||
+ int flags,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ QIOChannelSavevmAsync *saioc = QIO_CHANNEL_SAVEVM_ASYNC(ioc);
|
||||
+ BlockBackend *be = saioc->be;
|
||||
+ int64_t maxlen = blk_getlength(be);
|
||||
+ QEMUIOVector qiov;
|
||||
+ size_t size;
|
||||
+ int ret;
|
||||
+
|
||||
+ qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
|
||||
+
|
||||
+ if (*saioc->bs_pos >= maxlen) {
|
||||
+ error_setg(errp, "cannot read beyond maxlen");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (maxlen - *saioc->bs_pos < qiov.size) {
|
||||
+ size = maxlen - *saioc->bs_pos;
|
||||
+ } else {
|
||||
+ size = qiov.size;
|
||||
+ }
|
||||
+
|
||||
+ // returns 0 on success
|
||||
+ ret = blk_preadv(be, *saioc->bs_pos, size, &qiov, 0);
|
||||
+ if (ret < 0) {
|
||||
+ error_setg_errno(errp, -ret, "blk_preadv failed");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ *saioc->bs_pos += size;
|
||||
+ return size;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static ssize_t
|
||||
+qio_channel_savevm_async_writev(QIOChannel *ioc,
|
||||
+ const struct iovec *iov,
|
||||
+ size_t niov,
|
||||
+ int *fds,
|
||||
+ size_t nfds,
|
||||
+ int flags,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ QIOChannelSavevmAsync *saioc = QIO_CHANNEL_SAVEVM_ASYNC(ioc);
|
||||
+ BlockBackend *be = saioc->be;
|
||||
+ QEMUIOVector qiov;
|
||||
+ int ret;
|
||||
+
|
||||
+ qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
|
||||
+
|
||||
+ if (qemu_in_coroutine()) {
|
||||
+ ret = blk_co_pwritev(be, *saioc->bs_pos, qiov.size, &qiov, 0);
|
||||
+ aio_wait_kick();
|
||||
+ } else {
|
||||
+ ret = blk_pwritev(be, *saioc->bs_pos, qiov.size, &qiov, 0);
|
||||
+ }
|
||||
+
|
||||
+ if (ret < 0) {
|
||||
+ error_setg_errno(errp, -ret, "blk(_co)_pwritev failed");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ *saioc->bs_pos += qiov.size;
|
||||
+ return qiov.size;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int
|
||||
+qio_channel_savevm_async_set_blocking(QIOChannel *ioc,
|
||||
+ bool enabled,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ if (!enabled) {
|
||||
+ error_setg(errp, "Non-blocking mode not supported for savevm-async");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int
|
||||
+qio_channel_savevm_async_close(QIOChannel *ioc,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ QIOChannelSavevmAsync *saioc = QIO_CHANNEL_SAVEVM_ASYNC(ioc);
|
||||
+ int rv = bdrv_flush(blk_bs(saioc->be));
|
||||
+
|
||||
+ if (rv < 0) {
|
||||
+ error_setg_errno(errp, -rv, "Unable to flush VMState");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ bdrv_unref(blk_bs(saioc->be));
|
||||
+ saioc->be = NULL;
|
||||
+ saioc->bs_pos = NULL;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void
|
||||
+qio_channel_savevm_async_set_aio_fd_handler(QIOChannel *ioc,
|
||||
+ AioContext *read_ctx,
|
||||
+ IOHandler *io_read,
|
||||
+ AioContext *write_ctx,
|
||||
+ IOHandler *io_write,
|
||||
+ void *opaque)
|
||||
+{
|
||||
+ // if channel-block starts doing something, check if this needs adaptation
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void
|
||||
+qio_channel_savevm_async_class_init(ObjectClass *klass,
|
||||
+ void *class_data G_GNUC_UNUSED)
|
||||
+{
|
||||
+ QIOChannelClass *ioc_klass = QIO_CHANNEL_CLASS(klass);
|
||||
+
|
||||
+ ioc_klass->io_writev = qio_channel_savevm_async_writev;
|
||||
+ ioc_klass->io_readv = qio_channel_savevm_async_readv;
|
||||
+ ioc_klass->io_set_blocking = qio_channel_savevm_async_set_blocking;
|
||||
+ ioc_klass->io_close = qio_channel_savevm_async_close;
|
||||
+ ioc_klass->io_set_aio_fd_handler = qio_channel_savevm_async_set_aio_fd_handler;
|
||||
+}
|
||||
+
|
||||
+static const TypeInfo qio_channel_savevm_async_info = {
|
||||
+ .parent = TYPE_QIO_CHANNEL,
|
||||
+ .name = TYPE_QIO_CHANNEL_SAVEVM_ASYNC,
|
||||
+ .instance_size = sizeof(QIOChannelSavevmAsync),
|
||||
+ .instance_finalize = qio_channel_savevm_async_finalize,
|
||||
+ .class_init = qio_channel_savevm_async_class_init,
|
||||
+};
|
||||
+
|
||||
+static void
|
||||
+qio_channel_savevm_async_register_types(void)
|
||||
+{
|
||||
+ type_register_static(&qio_channel_savevm_async_info);
|
||||
+}
|
||||
+
|
||||
+type_init(qio_channel_savevm_async_register_types);
|
||||
diff --git a/migration/channel-savevm-async.h b/migration/channel-savevm-async.h
|
||||
new file mode 100644
|
||||
index 0000000000..17ae2cb261
|
||||
--- /dev/null
|
||||
+++ b/migration/channel-savevm-async.h
|
||||
@@ -0,0 +1,51 @@
|
||||
+/*
|
||||
+ * QEMU I/O channels driver for savevm-async.c
|
||||
+ *
|
||||
+ * Copyright (c) 2022 Proxmox Server Solutions
|
||||
+ *
|
||||
+ * Authors:
|
||||
+ * Fiona Ebner (f.ebner@proxmox.com)
|
||||
+ *
|
||||
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
+ * See the COPYING file in the top-level directory.
|
||||
+ */
|
||||
+
|
||||
+#ifndef QIO_CHANNEL_SAVEVM_ASYNC_H
|
||||
+#define QIO_CHANNEL_SAVEVM_ASYNC_H
|
||||
+
|
||||
+#include "io/channel.h"
|
||||
+#include "qom/object.h"
|
||||
+
|
||||
+#define TYPE_QIO_CHANNEL_SAVEVM_ASYNC "qio-channel-savevm-async"
|
||||
+OBJECT_DECLARE_SIMPLE_TYPE(QIOChannelSavevmAsync, QIO_CHANNEL_SAVEVM_ASYNC)
|
||||
+
|
||||
+
|
||||
+/**
|
||||
+ * QIOChannelSavevmAsync:
|
||||
+ *
|
||||
+ * The QIOChannelBlock object provides a channel implementation that is able to
|
||||
+ * perform I/O on any BlockBackend whose BlockDriverState directly contains a
|
||||
+ * VMState (as opposed to indirectly, like qcow2). It allows tracking the
|
||||
+ * current position from the outside.
|
||||
+ */
|
||||
+struct QIOChannelSavevmAsync {
|
||||
+ QIOChannel parent;
|
||||
+ BlockBackend *be;
|
||||
+ size_t *bs_pos;
|
||||
+};
|
||||
+
|
||||
+
|
||||
+/**
|
||||
+ * qio_channel_savevm_async_new:
|
||||
+ * @be: the block backend
|
||||
+ * @bs_pos: used to keep track of the IOChannels current position
|
||||
+ *
|
||||
+ * Create a new IO channel object that can perform I/O on a BlockBackend object
|
||||
+ * whose BlockDriverState directly contains a VMState.
|
||||
+ *
|
||||
+ * Returns: the new channel object
|
||||
+ */
|
||||
+QIOChannelSavevmAsync *
|
||||
+qio_channel_savevm_async_new(BlockBackend *be, size_t *bs_pos);
|
||||
+
|
||||
+#endif /* QIO_CHANNEL_SAVEVM_ASYNC_H */
|
||||
diff --git a/migration/meson.build b/migration/meson.build
|
||||
index 1eeb915ff6..95d1cf2250 100644
|
||||
--- a/migration/meson.build
|
||||
+++ b/migration/meson.build
|
||||
@@ -13,6 +13,7 @@ system_ss.add(files(
|
||||
'block-dirty-bitmap.c',
|
||||
'channel.c',
|
||||
'channel-block.c',
|
||||
+ 'channel-savevm-async.c',
|
||||
'dirtyrate.c',
|
||||
'exec.c',
|
||||
'fd.c',
|
@@ -1,188 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Date: Mon, 4 May 2020 11:05:08 +0200
|
||||
Subject: [PATCH] PVE: add optional buffer size to QEMUFile
|
||||
|
||||
So we can use a 4M buffer for savevm-async which should
|
||||
increase performance storing the state onto ceph.
|
||||
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
[increase max IOV count in QEMUFile to actually write more data]
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
migration/qemu-file.c | 38 +++++++++++++++++++++++++-------------
|
||||
migration/qemu-file.h | 1 +
|
||||
migration/savevm-async.c | 4 ++--
|
||||
3 files changed, 28 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
|
||||
index 6338d8e2ff..6697a93a7e 100644
|
||||
--- a/migration/qemu-file.c
|
||||
+++ b/migration/qemu-file.c
|
||||
@@ -30,8 +30,8 @@
|
||||
#include "trace.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
-#define IO_BUF_SIZE 32768
|
||||
-#define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 64)
|
||||
+#define DEFAULT_IO_BUF_SIZE 32768
|
||||
+#define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 256)
|
||||
|
||||
struct QEMUFile {
|
||||
const QEMUFileOps *ops;
|
||||
@@ -45,7 +45,8 @@ struct QEMUFile {
|
||||
when reading */
|
||||
int buf_index;
|
||||
int buf_size; /* 0 when writing */
|
||||
- uint8_t buf[IO_BUF_SIZE];
|
||||
+ size_t buf_allocated_size;
|
||||
+ uint8_t *buf;
|
||||
|
||||
DECLARE_BITMAP(may_free, MAX_IOV_SIZE);
|
||||
struct iovec iov[MAX_IOV_SIZE];
|
||||
@@ -103,7 +104,7 @@ bool qemu_file_mode_is_not_valid(const char *mode)
|
||||
return false;
|
||||
}
|
||||
|
||||
-QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
|
||||
+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, bool has_ioc, size_t buffer_size)
|
||||
{
|
||||
QEMUFile *f;
|
||||
|
||||
@@ -112,9 +113,17 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
|
||||
f->opaque = opaque;
|
||||
f->ops = ops;
|
||||
f->has_ioc = has_ioc;
|
||||
+ f->buf_allocated_size = buffer_size;
|
||||
+ f->buf = malloc(buffer_size);
|
||||
+
|
||||
return f;
|
||||
}
|
||||
|
||||
+QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
|
||||
+{
|
||||
+ return qemu_fopen_ops_sized(opaque, ops, has_ioc, DEFAULT_IO_BUF_SIZE);
|
||||
+}
|
||||
+
|
||||
|
||||
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks)
|
||||
{
|
||||
@@ -349,7 +358,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
|
||||
}
|
||||
|
||||
len = f->ops->get_buffer(f->opaque, f->buf + pending, f->pos,
|
||||
- IO_BUF_SIZE - pending, &local_error);
|
||||
+ f->buf_allocated_size - pending, &local_error);
|
||||
if (len > 0) {
|
||||
f->buf_size += len;
|
||||
f->pos += len;
|
||||
@@ -389,6 +398,9 @@ int qemu_fclose(QEMUFile *f)
|
||||
ret = ret2;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ free(f->buf);
|
||||
+
|
||||
/* If any error was spotted before closing, we should report it
|
||||
* instead of the close() return value.
|
||||
*/
|
||||
@@ -443,7 +455,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
|
||||
{
|
||||
if (!add_to_iovec(f, f->buf + f->buf_index, len, false)) {
|
||||
f->buf_index += len;
|
||||
- if (f->buf_index == IO_BUF_SIZE) {
|
||||
+ if (f->buf_index == f->buf_allocated_size) {
|
||||
qemu_fflush(f);
|
||||
}
|
||||
}
|
||||
@@ -469,7 +481,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
|
||||
}
|
||||
|
||||
while (size > 0) {
|
||||
- l = IO_BUF_SIZE - f->buf_index;
|
||||
+ l = f->buf_allocated_size - f->buf_index;
|
||||
if (l > size) {
|
||||
l = size;
|
||||
}
|
||||
@@ -516,8 +528,8 @@ size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset)
|
||||
size_t index;
|
||||
|
||||
assert(!qemu_file_is_writable(f));
|
||||
- assert(offset < IO_BUF_SIZE);
|
||||
- assert(size <= IO_BUF_SIZE - offset);
|
||||
+ assert(offset < f->buf_allocated_size);
|
||||
+ assert(size <= f->buf_allocated_size - offset);
|
||||
|
||||
/* The 1st byte to read from */
|
||||
index = f->buf_index + offset;
|
||||
@@ -567,7 +579,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
|
||||
size_t res;
|
||||
uint8_t *src;
|
||||
|
||||
- res = qemu_peek_buffer(f, &src, MIN(pending, IO_BUF_SIZE), 0);
|
||||
+ res = qemu_peek_buffer(f, &src, MIN(pending, f->buf_allocated_size), 0);
|
||||
if (res == 0) {
|
||||
return done;
|
||||
}
|
||||
@@ -601,7 +613,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
|
||||
*/
|
||||
size_t qemu_get_buffer_in_place(QEMUFile *f, uint8_t **buf, size_t size)
|
||||
{
|
||||
- if (size < IO_BUF_SIZE) {
|
||||
+ if (size < f->buf_allocated_size) {
|
||||
size_t res;
|
||||
uint8_t *src = NULL;
|
||||
|
||||
@@ -626,7 +638,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
|
||||
int index = f->buf_index + offset;
|
||||
|
||||
assert(!qemu_file_is_writable(f));
|
||||
- assert(offset < IO_BUF_SIZE);
|
||||
+ assert(offset < f->buf_allocated_size);
|
||||
|
||||
if (index >= f->buf_size) {
|
||||
qemu_fill_buffer(f);
|
||||
@@ -778,7 +790,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
|
||||
ssize_t qemu_put_compression_data(QEMUFile *f, z_stream *stream,
|
||||
const uint8_t *p, size_t size)
|
||||
{
|
||||
- ssize_t blen = IO_BUF_SIZE - f->buf_index - sizeof(int32_t);
|
||||
+ ssize_t blen = f->buf_allocated_size - f->buf_index - sizeof(int32_t);
|
||||
|
||||
if (blen < compressBound(size)) {
|
||||
return -1;
|
||||
diff --git a/migration/qemu-file.h b/migration/qemu-file.h
|
||||
index 3f36d4dc8c..67501fd9cf 100644
|
||||
--- a/migration/qemu-file.h
|
||||
+++ b/migration/qemu-file.h
|
||||
@@ -121,6 +121,7 @@ typedef struct QEMUFileHooks {
|
||||
} QEMUFileHooks;
|
||||
|
||||
QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc);
|
||||
+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, bool has_ioc, size_t buffer_size);
|
||||
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks);
|
||||
int qemu_get_fd(QEMUFile *f);
|
||||
int qemu_fclose(QEMUFile *f);
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index 79a0cda906..970ee3b3fc 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -418,7 +418,7 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp)
|
||||
goto restart;
|
||||
}
|
||||
|
||||
- snap_state.file = qemu_fopen_ops(&snap_state, &block_file_ops);
|
||||
+ snap_state.file = qemu_fopen_ops_sized(&snap_state, &block_file_ops, false, 4 * 1024 * 1024);
|
||||
|
||||
if (!snap_state.file) {
|
||||
error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
|
||||
@@ -567,7 +567,7 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
|
||||
blk_op_block_all(be, blocker);
|
||||
|
||||
/* restore the VM state */
|
||||
- f = qemu_fopen_ops(be, &loadstate_file_ops);
|
||||
+ f = qemu_fopen_ops_sized(be, &loadstate_file_ops, false, 4 * 1024 * 1024);
|
||||
if (!f) {
|
||||
error_setg(errp, "Could not open VM state file");
|
||||
goto the_end;
|
@@ -21,28 +21,37 @@ still opened by QEMU.
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
[improve aborting]
|
||||
[SR: improve aborting
|
||||
register yank before migration_incoming_state_destroy]
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
[FE: further improve aborting
|
||||
adapt to removal of QEMUFileOps
|
||||
improve condition for entering final stage
|
||||
adapt to QAPI and other changes for 8.2
|
||||
make sure to not call vm_start() from coroutine
|
||||
stop CPU throttling after finishing
|
||||
force raw format when loading state as suggested by Friedrich Weber]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hmp-commands-info.hx | 13 +
|
||||
hmp-commands.hx | 33 ++
|
||||
hmp-commands.hx | 17 ++
|
||||
include/migration/snapshot.h | 2 +
|
||||
include/monitor/hmp.h | 5 +
|
||||
include/monitor/hmp.h | 3 +
|
||||
migration/meson.build | 1 +
|
||||
migration/savevm-async.c | 598 +++++++++++++++++++++++++++++++++++
|
||||
monitor/hmp-cmds.c | 57 ++++
|
||||
qapi/migration.json | 34 ++
|
||||
qapi/misc.json | 32 ++
|
||||
migration/savevm-async.c | 549 +++++++++++++++++++++++++++++++++++
|
||||
monitor/hmp-cmds.c | 38 +++
|
||||
qapi/migration.json | 34 +++
|
||||
qapi/misc.json | 18 ++
|
||||
qemu-options.hx | 12 +
|
||||
softmmu/vl.c | 10 +
|
||||
11 files changed, 797 insertions(+)
|
||||
system/vl.c | 10 +
|
||||
11 files changed, 697 insertions(+)
|
||||
create mode 100644 migration/savevm-async.c
|
||||
|
||||
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
|
||||
index 407a1da800..245f8acc55 100644
|
||||
index ad1b1306e3..d5ab880492 100644
|
||||
--- a/hmp-commands-info.hx
|
||||
+++ b/hmp-commands-info.hx
|
||||
@@ -536,6 +536,19 @@ SRST
|
||||
@@ -525,6 +525,19 @@ SRST
|
||||
Show current migration parameters.
|
||||
ERST
|
||||
|
||||
@@ -63,13 +72,13 @@ index 407a1da800..245f8acc55 100644
|
||||
.name = "balloon",
|
||||
.args_type = "",
|
||||
diff --git a/hmp-commands.hx b/hmp-commands.hx
|
||||
index 5efb47fc32..1ad13b668b 100644
|
||||
index 2e2a3bcf98..7506de251c 100644
|
||||
--- a/hmp-commands.hx
|
||||
+++ b/hmp-commands.hx
|
||||
@@ -1746,3 +1746,36 @@ ERST
|
||||
"\n\t\t\t -b to specify dirty bitmap as method of calculation)",
|
||||
.cmd = hmp_calc_dirty_rate,
|
||||
},
|
||||
@@ -1862,3 +1862,20 @@ SRST
|
||||
List event channels in the guest
|
||||
ERST
|
||||
#endif
|
||||
+
|
||||
+ {
|
||||
+ .name = "savevm-start",
|
||||
@@ -80,22 +89,6 @@ index 5efb47fc32..1ad13b668b 100644
|
||||
+ },
|
||||
+
|
||||
+ {
|
||||
+ .name = "snapshot-drive",
|
||||
+ .args_type = "device:s,name:s",
|
||||
+ .params = "device name",
|
||||
+ .help = "Create internal snapshot.",
|
||||
+ .cmd = hmp_snapshot_drive,
|
||||
+ },
|
||||
+
|
||||
+ {
|
||||
+ .name = "delete-drive-snapshot",
|
||||
+ .args_type = "device:s,name:s",
|
||||
+ .params = "device name",
|
||||
+ .help = "Delete internal snapshot.",
|
||||
+ .cmd = hmp_delete_drive_snapshot,
|
||||
+ },
|
||||
+
|
||||
+ {
|
||||
+ .name = "savevm-end",
|
||||
+ .args_type = "",
|
||||
+ .params = "",
|
||||
@@ -104,21 +97,21 @@ index 5efb47fc32..1ad13b668b 100644
|
||||
+ .coroutine = true,
|
||||
+ },
|
||||
diff --git a/include/migration/snapshot.h b/include/migration/snapshot.h
|
||||
index e72083b117..c846d37806 100644
|
||||
index 9e4dcaaa75..2581730d74 100644
|
||||
--- a/include/migration/snapshot.h
|
||||
+++ b/include/migration/snapshot.h
|
||||
@@ -61,4 +61,6 @@ bool delete_snapshot(const char *name,
|
||||
bool has_devices, strList *devices,
|
||||
Error **errp);
|
||||
@@ -68,4 +68,6 @@ bool delete_snapshot(const char *name,
|
||||
*/
|
||||
void load_snapshot_resume(RunState state);
|
||||
|
||||
+int load_snapshot_from_blockdev(const char *filename, Error **errp);
|
||||
+
|
||||
#endif
|
||||
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
|
||||
index 96d014826a..3a39ba41b5 100644
|
||||
index 13f9a2dedb..7a7def7530 100644
|
||||
--- a/include/monitor/hmp.h
|
||||
+++ b/include/monitor/hmp.h
|
||||
@@ -26,6 +26,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
|
||||
@@ -28,6 +28,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_uuid(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_chardev(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_mice(Monitor *mon, const QDict *qdict);
|
||||
@@ -126,42 +119,44 @@ index 96d014826a..3a39ba41b5 100644
|
||||
void hmp_info_migrate(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict);
|
||||
@@ -80,6 +81,10 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict);
|
||||
void hmp_netdev_del(Monitor *mon, const QDict *qdict);
|
||||
void hmp_getfd(Monitor *mon, const QDict *qdict);
|
||||
void hmp_closefd(Monitor *mon, const QDict *qdict);
|
||||
@@ -94,6 +95,8 @@ void hmp_closefd(Monitor *mon, const QDict *qdict);
|
||||
void hmp_mouse_move(Monitor *mon, const QDict *qdict);
|
||||
void hmp_mouse_button(Monitor *mon, const QDict *qdict);
|
||||
void hmp_mouse_set(Monitor *mon, const QDict *qdict);
|
||||
+void hmp_savevm_start(Monitor *mon, const QDict *qdict);
|
||||
+void hmp_snapshot_drive(Monitor *mon, const QDict *qdict);
|
||||
+void hmp_delete_drive_snapshot(Monitor *mon, const QDict *qdict);
|
||||
+void hmp_savevm_end(Monitor *mon, const QDict *qdict);
|
||||
void hmp_sendkey(Monitor *mon, const QDict *qdict);
|
||||
void hmp_screendump(Monitor *mon, const QDict *qdict);
|
||||
void coroutine_fn hmp_screendump(Monitor *mon, const QDict *qdict);
|
||||
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
|
||||
diff --git a/migration/meson.build b/migration/meson.build
|
||||
index f8714dcb15..ea9aedeefc 100644
|
||||
index 95d1cf2250..800f12a60d 100644
|
||||
--- a/migration/meson.build
|
||||
+++ b/migration/meson.build
|
||||
@@ -23,6 +23,7 @@ softmmu_ss.add(files(
|
||||
'multifd-zlib.c',
|
||||
@@ -28,6 +28,7 @@ system_ss.add(files(
|
||||
'options.c',
|
||||
'postcopy-ram.c',
|
||||
'savevm.c',
|
||||
+ 'savevm-async.c',
|
||||
'socket.c',
|
||||
'tls.c',
|
||||
), gnutls)
|
||||
'threadinfo.c',
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
new file mode 100644
|
||||
index 0000000000..79a0cda906
|
||||
index 0000000000..ae7ed68651
|
||||
--- /dev/null
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -0,0 +1,598 @@
|
||||
@@ -0,0 +1,549 @@
|
||||
+#include "qemu/osdep.h"
|
||||
+#include "migration/channel-savevm-async.h"
|
||||
+#include "migration/migration.h"
|
||||
+#include "migration/migration-stats.h"
|
||||
+#include "migration/options.h"
|
||||
+#include "migration/savevm.h"
|
||||
+#include "migration/snapshot.h"
|
||||
+#include "migration/global_state.h"
|
||||
+#include "migration/ram.h"
|
||||
+#include "migration/qemu-file.h"
|
||||
+#include "sysemu/cpu-throttle.h"
|
||||
+#include "sysemu/sysemu.h"
|
||||
+#include "sysemu/runstate.h"
|
||||
+#include "block/block.h"
|
||||
@@ -176,12 +171,10 @@ index 0000000000..79a0cda906
|
||||
+#include "qemu/timer.h"
|
||||
+#include "qemu/main-loop.h"
|
||||
+#include "qemu/rcu.h"
|
||||
+#include "qemu/yank.h"
|
||||
+
|
||||
+/* #define DEBUG_SAVEVM_STATE */
|
||||
+
|
||||
+/* used while emulated sync operation in progress */
|
||||
+#define NOT_DONE -EINPROGRESS
|
||||
+
|
||||
+#ifdef DEBUG_SAVEVM_STATE
|
||||
+#define DPRINTF(fmt, ...) \
|
||||
+ do { printf("savevm-async: " fmt, ## __VA_ARGS__); } while (0)
|
||||
@@ -210,7 +203,7 @@ index 0000000000..79a0cda906
|
||||
+ int64_t total_time;
|
||||
+ QEMUBH *finalize_bh;
|
||||
+ Coroutine *co;
|
||||
+ QemuCoSleep *target_close_wait;
|
||||
+ QemuCoSleep target_close_wait;
|
||||
+} snap_state;
|
||||
+
|
||||
+static bool savevm_aborted(void)
|
||||
@@ -229,24 +222,20 @@ index 0000000000..79a0cda906
|
||||
+ info->bytes = s->bs_pos;
|
||||
+ switch (s->state) {
|
||||
+ case SAVE_STATE_ERROR:
|
||||
+ info->has_status = true;
|
||||
+ info->status = g_strdup("failed");
|
||||
+ info->has_total_time = true;
|
||||
+ info->total_time = s->total_time;
|
||||
+ if (s->error) {
|
||||
+ info->has_error = true;
|
||||
+ info->error = g_strdup(error_get_pretty(s->error));
|
||||
+ }
|
||||
+ break;
|
||||
+ case SAVE_STATE_ACTIVE:
|
||||
+ info->has_status = true;
|
||||
+ info->status = g_strdup("active");
|
||||
+ info->has_total_time = true;
|
||||
+ info->total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME)
|
||||
+ - s->total_time;
|
||||
+ break;
|
||||
+ case SAVE_STATE_COMPLETED:
|
||||
+ info->has_status = true;
|
||||
+ info->status = g_strdup("completed");
|
||||
+ info->has_total_time = true;
|
||||
+ info->total_time = s->total_time;
|
||||
@@ -268,6 +257,7 @@ index 0000000000..79a0cda906
|
||||
+
|
||||
+ if (snap_state.file) {
|
||||
+ ret = qemu_fclose(snap_state.file);
|
||||
+ snap_state.file = NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (snap_state.target) {
|
||||
@@ -285,15 +275,13 @@ index 0000000000..79a0cda906
|
||||
+ blk_unref(snap_state.target);
|
||||
+ snap_state.target = NULL;
|
||||
+
|
||||
+ if (snap_state.target_close_wait) {
|
||||
+ qemu_co_sleep_wake(snap_state.target_close_wait);
|
||||
+ }
|
||||
+ qemu_co_sleep_wake(&snap_state.target_close_wait);
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void save_snapshot_error(const char *fmt, ...)
|
||||
+static void G_GNUC_PRINTF(1, 2) save_snapshot_error(const char *fmt, ...)
|
||||
+{
|
||||
+ va_list ap;
|
||||
+ char *msg;
|
||||
@@ -313,64 +301,9 @@ index 0000000000..79a0cda906
|
||||
+ snap_state.state = SAVE_STATE_ERROR;
|
||||
+}
|
||||
+
|
||||
+static int block_state_close(void *opaque, Error **errp)
|
||||
+{
|
||||
+ snap_state.file = NULL;
|
||||
+ return blk_flush(snap_state.target);
|
||||
+}
|
||||
+
|
||||
+typedef struct BlkRwCo {
|
||||
+ int64_t offset;
|
||||
+ QEMUIOVector *qiov;
|
||||
+ ssize_t ret;
|
||||
+} BlkRwCo;
|
||||
+
|
||||
+static void coroutine_fn block_state_write_entry(void *opaque) {
|
||||
+ BlkRwCo *rwco = opaque;
|
||||
+ rwco->ret = blk_co_pwritev(snap_state.target, rwco->offset, rwco->qiov->size,
|
||||
+ rwco->qiov, 0);
|
||||
+ aio_wait_kick();
|
||||
+}
|
||||
+
|
||||
+static ssize_t block_state_writev_buffer(void *opaque, struct iovec *iov,
|
||||
+ int iovcnt, int64_t pos, Error **errp)
|
||||
+{
|
||||
+ QEMUIOVector qiov;
|
||||
+ BlkRwCo rwco;
|
||||
+
|
||||
+ assert(pos == snap_state.bs_pos);
|
||||
+ rwco = (BlkRwCo) {
|
||||
+ .offset = pos,
|
||||
+ .qiov = &qiov,
|
||||
+ .ret = NOT_DONE,
|
||||
+ };
|
||||
+
|
||||
+ qemu_iovec_init_external(&qiov, iov, iovcnt);
|
||||
+
|
||||
+ if (qemu_in_coroutine()) {
|
||||
+ block_state_write_entry(&rwco);
|
||||
+ } else {
|
||||
+ Coroutine *co = qemu_coroutine_create(&block_state_write_entry, &rwco);
|
||||
+ bdrv_coroutine_enter(blk_bs(snap_state.target), co);
|
||||
+ BDRV_POLL_WHILE(blk_bs(snap_state.target), rwco.ret == NOT_DONE);
|
||||
+ }
|
||||
+ if (rwco.ret < 0) {
|
||||
+ return rwco.ret;
|
||||
+ }
|
||||
+
|
||||
+ snap_state.bs_pos += qiov.size;
|
||||
+ return qiov.size;
|
||||
+}
|
||||
+
|
||||
+static const QEMUFileOps block_file_ops = {
|
||||
+ .writev_buffer = block_state_writev_buffer,
|
||||
+ .close = block_state_close,
|
||||
+};
|
||||
+
|
||||
+static void process_savevm_finalize(void *opaque)
|
||||
+{
|
||||
+ int ret;
|
||||
+ AioContext *iohandler_ctx = iohandler_get_aio_context();
|
||||
+ MigrationState *ms = migrate_get_current();
|
||||
+
|
||||
+ bool aborted = savevm_aborted();
|
||||
@@ -387,9 +320,7 @@ index 0000000000..79a0cda906
|
||||
+ * so move it back. It can stay in the main context and live out its live
|
||||
+ * there, since we're done with it after this method ends anyway.
|
||||
+ */
|
||||
+ aio_context_acquire(iohandler_ctx);
|
||||
+ blk_set_aio_context(snap_state.target, qemu_get_aio_context(), NULL);
|
||||
+ aio_context_release(iohandler_ctx);
|
||||
+
|
||||
+ ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
|
||||
+ if (ret < 0) {
|
||||
@@ -401,7 +332,7 @@ index 0000000000..79a0cda906
|
||||
+ (void)qemu_savevm_state_complete_precopy(snap_state.file, false, false);
|
||||
+ ret = qemu_file_get_error(snap_state.file);
|
||||
+ if (ret < 0) {
|
||||
+ save_snapshot_error("qemu_savevm_state_iterate error %d", ret);
|
||||
+ save_snapshot_error("qemu_savevm_state_complete_precopy error %d", ret);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -414,6 +345,12 @@ index 0000000000..79a0cda906
|
||||
+ ret || aborted ? MIGRATION_STATUS_FAILED : MIGRATION_STATUS_COMPLETED);
|
||||
+ ms->to_dst_file = NULL;
|
||||
+
|
||||
+ /*
|
||||
+ * Same as in migration_iteration_finish(): saving RAM might've turned on CPU throttling for
|
||||
+ * auto-converge, make sure to disable it.
|
||||
+ */
|
||||
+ cpu_throttle_stop();
|
||||
+
|
||||
+ qemu_savevm_state_cleanup();
|
||||
+
|
||||
+ ret = save_snapshot_cleanup();
|
||||
@@ -422,8 +359,11 @@ index 0000000000..79a0cda906
|
||||
+ } else if (snap_state.state == SAVE_STATE_ACTIVE) {
|
||||
+ snap_state.state = SAVE_STATE_COMPLETED;
|
||||
+ } else if (aborted) {
|
||||
+ save_snapshot_error("process_savevm_cleanup: found aborted state: %d",
|
||||
+ snap_state.state);
|
||||
+ /*
|
||||
+ * If there was an error, there's no need to set a new one here.
|
||||
+ * If the snapshot was canceled, leave setting the state to
|
||||
+ * qmp_savevm_end(), which is waked by save_snapshot_cleanup().
|
||||
+ */
|
||||
+ } else {
|
||||
+ save_snapshot_error("process_savevm_cleanup: invalid state: %d",
|
||||
+ snap_state.state);
|
||||
@@ -455,18 +395,32 @@ index 0000000000..79a0cda906
|
||||
+ }
|
||||
+
|
||||
+ while (snap_state.state == SAVE_STATE_ACTIVE) {
|
||||
+ uint64_t pending_size, pend_precopy, pend_compatible, pend_postcopy;
|
||||
+ uint64_t pending_size, pend_precopy, pend_postcopy;
|
||||
+ uint64_t threshold = 400 * 1000;
|
||||
+
|
||||
+ /* pending is expected to be called without iothread lock */
|
||||
+ qemu_mutex_unlock_iothread();
|
||||
+ qemu_savevm_state_pending(snap_state.file, 0, &pend_precopy, &pend_compatible, &pend_postcopy);
|
||||
+ qemu_mutex_lock_iothread();
|
||||
+ /*
|
||||
+ * pending_{estimate,exact} are expected to be called without iothread
|
||||
+ * lock. Similar to what is done in migration.c, call the exact variant
|
||||
+ * only once pend_precopy in the estimate is below the threshold.
|
||||
+ */
|
||||
+ bql_unlock();
|
||||
+ qemu_savevm_state_pending_estimate(&pend_precopy, &pend_postcopy);
|
||||
+ if (pend_precopy <= threshold) {
|
||||
+ qemu_savevm_state_pending_exact(&pend_precopy, &pend_postcopy);
|
||||
+ }
|
||||
+ bql_lock();
|
||||
+ pending_size = pend_precopy + pend_postcopy;
|
||||
+
|
||||
+ pending_size = pend_precopy + pend_compatible + pend_postcopy;
|
||||
+ /*
|
||||
+ * A guest reaching this cutoff is dirtying lots of RAM. It should be
|
||||
+ * large enough so that the guest can't dirty this much between the
|
||||
+ * check and the guest actually being stopped, but it should be small
|
||||
+ * enough to avoid long downtimes for non-hibernation snapshots.
|
||||
+ */
|
||||
+ maxlen = blk_getlength(snap_state.target) - 100*1024*1024;
|
||||
+
|
||||
+ maxlen = blk_getlength(snap_state.target) - 30*1024*1024;
|
||||
+
|
||||
+ if (pending_size > 400000 && snap_state.bs_pos + pending_size < maxlen) {
|
||||
+ /* Note that there is no progress for pend_postcopy when iterating */
|
||||
+ if (pend_precopy > threshold && snap_state.bs_pos + pending_size < maxlen) {
|
||||
+ ret = qemu_savevm_state_iterate(snap_state.file, false);
|
||||
+ if (ret < 0) {
|
||||
+ save_snapshot_error("qemu_savevm_state_iterate error %d", ret);
|
||||
@@ -475,11 +429,7 @@ index 0000000000..79a0cda906
|
||||
+ DPRINTF("savevm iterate pending size %lu ret %d\n", pending_size, ret);
|
||||
+ } else {
|
||||
+ qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
|
||||
+ ret = global_state_store();
|
||||
+ if (ret) {
|
||||
+ save_snapshot_error("global_state_store error %d", ret);
|
||||
+ break;
|
||||
+ }
|
||||
+ global_state_store();
|
||||
+
|
||||
+ DPRINTF("savevm iterate complete\n");
|
||||
+ break;
|
||||
@@ -498,19 +448,25 @@ index 0000000000..79a0cda906
|
||||
+ * so move there now and after every flush.
|
||||
+ */
|
||||
+ aio_co_reschedule_self(qemu_get_aio_context());
|
||||
+ for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ bs = bdrv_first(&it);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ while (bs) {
|
||||
+ /* target has BDRV_O_NO_FLUSH, no sense calling bdrv_flush on it */
|
||||
+ if (bs == blk_bs(snap_state.target)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ AioContext *bs_ctx = bdrv_get_aio_context(bs);
|
||||
+ if (bs_ctx != qemu_get_aio_context()) {
|
||||
+ DPRINTF("savevm: async flushing drive %s\n", bs->filename);
|
||||
+ aio_co_reschedule_self(bs_ctx);
|
||||
+ bdrv_flush(bs);
|
||||
+ aio_co_reschedule_self(qemu_get_aio_context());
|
||||
+ if (bs != blk_bs(snap_state.target)) {
|
||||
+ AioContext *bs_ctx = bdrv_get_aio_context(bs);
|
||||
+ if (bs_ctx != qemu_get_aio_context()) {
|
||||
+ DPRINTF("savevm: async flushing drive %s\n", bs->filename);
|
||||
+ aio_co_reschedule_self(bs_ctx);
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ bdrv_flush(bs);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ aio_co_reschedule_self(qemu_get_aio_context());
|
||||
+ }
|
||||
+ }
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ bs = bdrv_next(&it);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ }
|
||||
+
|
||||
+ DPRINTF("timing: async flushing took %ld ms\n",
|
||||
@@ -519,7 +475,7 @@ index 0000000000..79a0cda906
|
||||
+ qemu_bh_schedule(snap_state.finalize_bh);
|
||||
+}
|
||||
+
|
||||
+void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp)
|
||||
+void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
+{
|
||||
+ Error *local_err = NULL;
|
||||
+ MigrationState *ms = migrate_get_current();
|
||||
@@ -533,12 +489,12 @@ index 0000000000..79a0cda906
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (migration_is_running(ms->state)) {
|
||||
+ if (migration_is_running()) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, QERR_MIGRATION_ACTIVE);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (migrate_use_block()) {
|
||||
+ if (migrate_block()) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
+ "Block migration and snapshots are incompatible");
|
||||
+ return;
|
||||
@@ -549,13 +505,14 @@ index 0000000000..79a0cda906
|
||||
+ snap_state.bs_pos = 0;
|
||||
+ snap_state.total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
|
||||
+ snap_state.blocker = NULL;
|
||||
+ snap_state.target_close_wait = (QemuCoSleep){ .to_wake = NULL };
|
||||
+
|
||||
+ if (snap_state.error) {
|
||||
+ error_free(snap_state.error);
|
||||
+ snap_state.error = NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (!has_statefile) {
|
||||
+ if (!statefile) {
|
||||
+ vm_stop(RUN_STATE_SAVE_VM);
|
||||
+ snap_state.state = SAVE_STATE_COMPLETED;
|
||||
+ return;
|
||||
@@ -575,7 +532,9 @@ index 0000000000..79a0cda906
|
||||
+ goto restart;
|
||||
+ }
|
||||
+
|
||||
+ snap_state.file = qemu_fopen_ops(&snap_state, &block_file_ops);
|
||||
+ QIOChannel *ioc = QIO_CHANNEL(qio_channel_savevm_async_new(snap_state.target,
|
||||
+ &snap_state.bs_pos));
|
||||
+ snap_state.file = qemu_file_new_output(ioc);
|
||||
+
|
||||
+ if (!snap_state.file) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
|
||||
@@ -587,8 +546,10 @@ index 0000000000..79a0cda906
|
||||
+ * State is cleared in process_savevm_co, but has to be initialized
|
||||
+ * here (blocking main thread, from QMP) to avoid race conditions.
|
||||
+ */
|
||||
+ migrate_init(ms);
|
||||
+ memset(&ram_counters, 0, sizeof(ram_counters));
|
||||
+ if (migrate_init(ms, errp)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ memset(&mig_stats, 0, sizeof(mig_stats));
|
||||
+ ms->to_dst_file = snap_state.file;
|
||||
+
|
||||
+ error_setg(&snap_state.blocker, "block device is in use by savevm");
|
||||
@@ -597,10 +558,8 @@ index 0000000000..79a0cda906
|
||||
+ snap_state.state = SAVE_STATE_ACTIVE;
|
||||
+ snap_state.finalize_bh = qemu_bh_new(process_savevm_finalize, &snap_state);
|
||||
+ snap_state.co = qemu_coroutine_create(&process_savevm_co, NULL);
|
||||
+ qemu_mutex_unlock_iothread();
|
||||
+ qemu_savevm_state_header(snap_state.file);
|
||||
+ qemu_savevm_state_setup(snap_state.file);
|
||||
+ qemu_mutex_lock_iothread();
|
||||
+
|
||||
+ /* Async processing from here on out happens in iohandler context, so let
|
||||
+ * the target bdrv have its home there.
|
||||
@@ -621,29 +580,10 @@ index 0000000000..79a0cda906
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void coroutine_fn qmp_savevm_end(Error **errp)
|
||||
+static void coroutine_fn wait_for_close_co(void *opaque)
|
||||
+{
|
||||
+ int64_t timeout;
|
||||
+
|
||||
+ if (snap_state.state == SAVE_STATE_DONE) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
+ "VM snapshot not started\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (snap_state.state == SAVE_STATE_ACTIVE) {
|
||||
+ snap_state.state = SAVE_STATE_CANCELLED;
|
||||
+ goto wait_for_close;
|
||||
+ }
|
||||
+
|
||||
+ if (snap_state.saved_vm_running) {
|
||||
+ vm_start();
|
||||
+ snap_state.saved_vm_running = false;
|
||||
+ }
|
||||
+
|
||||
+ snap_state.state = SAVE_STATE_DONE;
|
||||
+
|
||||
+wait_for_close:
|
||||
+ if (!snap_state.target) {
|
||||
+ DPRINTF("savevm-end: no target file open\n");
|
||||
+ return;
|
||||
@@ -653,9 +593,8 @@ index 0000000000..79a0cda906
|
||||
+ * call exits the statefile will be closed and can be removed immediately */
|
||||
+ DPRINTF("savevm-end: waiting for cleanup\n");
|
||||
+ timeout = 30L * 1000 * 1000 * 1000;
|
||||
+ qemu_co_sleep_ns_wakeable(snap_state.target_close_wait,
|
||||
+ qemu_co_sleep_ns_wakeable(&snap_state.target_close_wait,
|
||||
+ QEMU_CLOCK_REALTIME, timeout);
|
||||
+ snap_state.target_close_wait = NULL;
|
||||
+ if (snap_state.target) {
|
||||
+ save_snapshot_error("timeout waiting for target file close in "
|
||||
+ "qmp_savevm_end");
|
||||
@@ -664,56 +603,55 @@ index 0000000000..79a0cda906
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // File closed and no other error, so ensure next snapshot can be started.
|
||||
+ if (snap_state.state != SAVE_STATE_ERROR) {
|
||||
+ snap_state.state = SAVE_STATE_DONE;
|
||||
+ }
|
||||
+
|
||||
+ DPRINTF("savevm-end: cleanup done\n");
|
||||
+}
|
||||
+
|
||||
+// FIXME: Deprecated
|
||||
+void qmp_snapshot_drive(const char *device, const char *name, Error **errp)
|
||||
+void qmp_savevm_end(Error **errp)
|
||||
+{
|
||||
+ // Compatibility to older qemu-server.
|
||||
+ qmp_blockdev_snapshot_internal_sync(device, name, errp);
|
||||
+}
|
||||
+
|
||||
+// FIXME: Deprecated
|
||||
+void qmp_delete_drive_snapshot(const char *device, const char *name,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ // Compatibility to older qemu-server.
|
||||
+ (void)qmp_blockdev_snapshot_delete_internal_sync(device, false, NULL,
|
||||
+ true, name, errp);
|
||||
+}
|
||||
+
|
||||
+static ssize_t loadstate_get_buffer(void *opaque, uint8_t *buf, int64_t pos,
|
||||
+ size_t size, Error **errp)
|
||||
+{
|
||||
+ BlockBackend *be = opaque;
|
||||
+ int64_t maxlen = blk_getlength(be);
|
||||
+ if (pos > maxlen) {
|
||||
+ return -EIO;
|
||||
+ if (snap_state.state == SAVE_STATE_DONE) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
+ "VM snapshot not started\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ if ((pos + size) > maxlen) {
|
||||
+ size = maxlen - pos - 1;
|
||||
+ }
|
||||
+ if (size == 0) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ return blk_pread(be, pos, buf, size);
|
||||
+}
|
||||
+
|
||||
+static const QEMUFileOps loadstate_file_ops = {
|
||||
+ .get_buffer = loadstate_get_buffer,
|
||||
+};
|
||||
+ Coroutine *wait_for_close = qemu_coroutine_create(wait_for_close_co, NULL);
|
||||
+
|
||||
+ if (snap_state.state == SAVE_STATE_ACTIVE) {
|
||||
+ snap_state.state = SAVE_STATE_CANCELLED;
|
||||
+ qemu_coroutine_enter(wait_for_close);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (snap_state.saved_vm_running) {
|
||||
+ vm_start();
|
||||
+ snap_state.saved_vm_running = false;
|
||||
+ }
|
||||
+
|
||||
+ snap_state.state = SAVE_STATE_DONE;
|
||||
+
|
||||
+ qemu_coroutine_enter(wait_for_close);
|
||||
+}
|
||||
+
|
||||
+int load_snapshot_from_blockdev(const char *filename, Error **errp)
|
||||
+{
|
||||
+ BlockBackend *be;
|
||||
+ Error *local_err = NULL;
|
||||
+ Error *blocker = NULL;
|
||||
+ QDict *options;
|
||||
+
|
||||
+ QEMUFile *f;
|
||||
+ size_t bs_pos = 0;
|
||||
+ int ret = -EINVAL;
|
||||
+
|
||||
+ be = blk_new_open(filename, NULL, NULL, 0, &local_err);
|
||||
+ options = qdict_new();
|
||||
+ qdict_put_str(options, "driver", "raw");
|
||||
+
|
||||
+ be = blk_new_open(filename, NULL, options, 0, &local_err);
|
||||
+
|
||||
+ if (!be) {
|
||||
+ error_setg(errp, "Could not open VM state file");
|
||||
@@ -724,7 +662,7 @@ index 0000000000..79a0cda906
|
||||
+ blk_op_block_all(be, blocker);
|
||||
+
|
||||
+ /* restore the VM state */
|
||||
+ f = qemu_fopen_ops(be, &loadstate_file_ops);
|
||||
+ f = qemu_file_new_input(QIO_CHANNEL(qio_channel_savevm_async_new(be, &bs_pos)));
|
||||
+ if (!f) {
|
||||
+ error_setg(errp, "Could not open VM state file");
|
||||
+ goto the_end;
|
||||
@@ -737,6 +675,10 @@ index 0000000000..79a0cda906
|
||||
+ dirty_bitmap_mig_before_vm_start();
|
||||
+
|
||||
+ qemu_fclose(f);
|
||||
+
|
||||
+ /* state_destroy assumes a real migration which would have added a yank */
|
||||
+ yank_register_instance(MIGRATION_YANK_INSTANCE, &error_abort);
|
||||
+
|
||||
+ migration_incoming_state_destroy();
|
||||
+ if (ret < 0) {
|
||||
+ error_setg_errno(errp, -ret, "Error while loading VM state");
|
||||
@@ -754,39 +696,28 @@ index 0000000000..79a0cda906
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index e9fa9af6bd..5000ce39d1 100644
|
||||
index 871898ac46..ef4634e5c1 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -1903,6 +1903,63 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "monitor/monitor-internal.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-commands-control.h"
|
||||
+#include "qapi/qapi-commands-migration.h"
|
||||
#include "qapi/qapi-commands-misc.h"
|
||||
#include "qapi/qmp/qdict.h"
|
||||
#include "qemu/cutils.h"
|
||||
@@ -443,3 +444,40 @@ void hmp_info_mtree(Monitor *mon, const QDict *qdict)
|
||||
|
||||
mtree_info(flatview, dispatch_tree, owner, disabled);
|
||||
}
|
||||
+
|
||||
+void hmp_savevm_start(Monitor *mon, const QDict *qdict)
|
||||
+{
|
||||
+ Error *errp = NULL;
|
||||
+ const char *statefile = qdict_get_try_str(qdict, "statefile");
|
||||
+
|
||||
+ qmp_savevm_start(statefile != NULL, statefile, &errp);
|
||||
+ hmp_handle_error(mon, errp);
|
||||
+}
|
||||
+
|
||||
+void hmp_snapshot_drive(Monitor *mon, const QDict *qdict)
|
||||
+{
|
||||
+ Error *errp = NULL;
|
||||
+ const char *name = qdict_get_str(qdict, "name");
|
||||
+ const char *device = qdict_get_str(qdict, "device");
|
||||
+
|
||||
+ qmp_snapshot_drive(device, name, &errp);
|
||||
+ hmp_handle_error(mon, errp);
|
||||
+}
|
||||
+
|
||||
+void hmp_delete_drive_snapshot(Monitor *mon, const QDict *qdict)
|
||||
+{
|
||||
+ Error *errp = NULL;
|
||||
+ const char *name = qdict_get_str(qdict, "name");
|
||||
+ const char *device = qdict_get_str(qdict, "device");
|
||||
+
|
||||
+ qmp_delete_drive_snapshot(device, name, &errp);
|
||||
+ qmp_savevm_start(statefile, &errp);
|
||||
+ hmp_handle_error(mon, errp);
|
||||
+}
|
||||
+
|
||||
@@ -803,7 +734,7 @@ index e9fa9af6bd..5000ce39d1 100644
|
||||
+ SaveVMInfo *info;
|
||||
+ info = qmp_query_savevm(NULL);
|
||||
+
|
||||
+ if (info->has_status) {
|
||||
+ if (info->status) {
|
||||
+ monitor_printf(mon, "savevm status: %s\n", info->status);
|
||||
+ monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n",
|
||||
+ info->total_time);
|
||||
@@ -813,21 +744,17 @@ index e9fa9af6bd..5000ce39d1 100644
|
||||
+ if (info->has_bytes) {
|
||||
+ monitor_printf(mon, "Bytes saved: %"PRIu64"\n", info->bytes);
|
||||
+ }
|
||||
+ if (info->has_error) {
|
||||
+ if (info->error) {
|
||||
+ monitor_printf(mon, "Error: %s\n", info->error);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
|
||||
diff --git a/qapi/migration.json b/qapi/migration.json
|
||||
index bbfd48cf0b..45686390a2 100644
|
||||
index 8c65b90328..ed20d066cd 100644
|
||||
--- a/qapi/migration.json
|
||||
+++ b/qapi/migration.json
|
||||
@@ -247,6 +247,40 @@
|
||||
'*compression': 'CompressionStats',
|
||||
'*socket-address': ['SocketAddress'] } }
|
||||
@@ -297,6 +297,40 @@
|
||||
'*dirty-limit-throttle-time-per-round': 'uint64',
|
||||
'*dirty-limit-ring-full-time': 'uint64'} }
|
||||
|
||||
+##
|
||||
+# @SaveVMInfo:
|
||||
@@ -867,10 +794,10 @@ index bbfd48cf0b..45686390a2 100644
|
||||
# @query-migrate:
|
||||
#
|
||||
diff --git a/qapi/misc.json b/qapi/misc.json
|
||||
index 358548abe1..25b3febc52 100644
|
||||
index ec30e5c570..3c68633f68 100644
|
||||
--- a/qapi/misc.json
|
||||
+++ b/qapi/misc.json
|
||||
@@ -435,6 +435,38 @@
|
||||
@@ -454,6 +454,24 @@
|
||||
##
|
||||
{ 'command': 'query-fdsets', 'returns': ['FdsetInfo'] }
|
||||
|
||||
@@ -879,41 +806,27 @@ index 358548abe1..25b3febc52 100644
|
||||
+#
|
||||
+# Prepare for snapshot and halt VM. Save VM state to statefile.
|
||||
+#
|
||||
+# @statefile: target file that state should be written to.
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'savevm-start', 'data': { '*statefile': 'str' } }
|
||||
+
|
||||
+##
|
||||
+# @snapshot-drive:
|
||||
+#
|
||||
+# Create an internal drive snapshot.
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'snapshot-drive', 'data': { 'device': 'str', 'name': 'str' } }
|
||||
+
|
||||
+##
|
||||
+# @delete-drive-snapshot:
|
||||
+#
|
||||
+# Delete a drive snapshot.
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'delete-drive-snapshot', 'data': { 'device': 'str', 'name': 'str' } }
|
||||
+
|
||||
+##
|
||||
+# @savevm-end:
|
||||
+#
|
||||
+# Resume VM after a snapshot.
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'savevm-end', 'coroutine': true }
|
||||
+{ 'command': 'savevm-end' }
|
||||
+
|
||||
##
|
||||
# @CommandLineParameterType:
|
||||
#
|
||||
diff --git a/qemu-options.hx b/qemu-options.hx
|
||||
index ae2c6dbbfc..423144abeb 100644
|
||||
index 8ce85d4559..511ab9415e 100644
|
||||
--- a/qemu-options.hx
|
||||
+++ b/qemu-options.hx
|
||||
@@ -4171,6 +4171,18 @@ SRST
|
||||
@@ -4610,6 +4610,18 @@ SRST
|
||||
Start right away with a saved state (``loadvm`` in monitor)
|
||||
ERST
|
||||
|
||||
@@ -932,22 +845,22 @@ index ae2c6dbbfc..423144abeb 100644
|
||||
#ifndef _WIN32
|
||||
DEF("daemonize", 0, QEMU_OPTION_daemonize, \
|
||||
"-daemonize daemonize QEMU after initializing\n", QEMU_ARCH_ALL)
|
||||
diff --git a/softmmu/vl.c b/softmmu/vl.c
|
||||
index 620a1f1367..fd82efb8b3 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -156,6 +156,7 @@ static const char *incoming;
|
||||
static const char *loadvm;
|
||||
static const char *accelerators;
|
||||
diff --git a/system/vl.c b/system/vl.c
|
||||
index c644222982..2738ab7c91 100644
|
||||
--- a/system/vl.c
|
||||
+++ b/system/vl.c
|
||||
@@ -163,6 +163,7 @@ static const char *accelerators;
|
||||
static bool have_custom_ram_size;
|
||||
static const char *ram_memdev_id;
|
||||
static QDict *machine_opts_dict;
|
||||
+static const char *loadstate;
|
||||
static QTAILQ_HEAD(, ObjectOption) object_opts = QTAILQ_HEAD_INITIALIZER(object_opts);
|
||||
static QTAILQ_HEAD(, DeviceOption) device_opts = QTAILQ_HEAD_INITIALIZER(device_opts);
|
||||
static ram_addr_t maxram_size;
|
||||
@@ -2743,6 +2744,12 @@ void qmp_x_exit_preconfig(Error **errp)
|
||||
|
||||
if (loadvm) {
|
||||
static int display_remote;
|
||||
@@ -2712,6 +2713,12 @@ void qmp_x_exit_preconfig(Error **errp)
|
||||
RunState state = autostart ? RUN_STATE_RUNNING : runstate_get();
|
||||
load_snapshot(loadvm, NULL, false, NULL, &error_fatal);
|
||||
load_snapshot_resume(state);
|
||||
+ } else if (loadstate) {
|
||||
+ Error *local_err = NULL;
|
||||
+ if (load_snapshot_from_blockdev(loadstate, &local_err) < 0) {
|
||||
@@ -957,7 +870,7 @@ index 620a1f1367..fd82efb8b3 100644
|
||||
}
|
||||
if (replay_mode != REPLAY_MODE_NONE) {
|
||||
replay_vmstate_init();
|
||||
@@ -3284,6 +3291,9 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
@@ -3259,6 +3266,9 @@ void qemu_init(int argc, char **argv)
|
||||
case QEMU_OPTION_loadvm:
|
||||
loadvm = optarg;
|
||||
break;
|
217
debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
vendored
Normal file
217
debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Date: Mon, 4 May 2020 11:05:08 +0200
|
||||
Subject: [PATCH] PVE: add optional buffer size to QEMUFile
|
||||
|
||||
So we can use a 4M buffer for savevm-async which should
|
||||
increase performance storing the state onto ceph.
|
||||
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
[increase max IOV count in QEMUFile to actually write more data]
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: adapt to removal of QEMUFileOps]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
migration/qemu-file.c | 50 +++++++++++++++++++++++++++-------------
|
||||
migration/qemu-file.h | 2 ++
|
||||
migration/savevm-async.c | 5 ++--
|
||||
3 files changed, 39 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
|
||||
index a10882d47f..19c1de0472 100644
|
||||
--- a/migration/qemu-file.c
|
||||
+++ b/migration/qemu-file.c
|
||||
@@ -35,8 +35,8 @@
|
||||
#include "rdma.h"
|
||||
#include "io/channel-file.h"
|
||||
|
||||
-#define IO_BUF_SIZE 32768
|
||||
-#define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 64)
|
||||
+#define DEFAULT_IO_BUF_SIZE 32768
|
||||
+#define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 256)
|
||||
|
||||
struct QEMUFile {
|
||||
QIOChannel *ioc;
|
||||
@@ -44,7 +44,8 @@ struct QEMUFile {
|
||||
|
||||
int buf_index;
|
||||
int buf_size; /* 0 when writing */
|
||||
- uint8_t buf[IO_BUF_SIZE];
|
||||
+ size_t buf_allocated_size;
|
||||
+ uint8_t *buf;
|
||||
|
||||
DECLARE_BITMAP(may_free, MAX_IOV_SIZE);
|
||||
struct iovec iov[MAX_IOV_SIZE];
|
||||
@@ -101,7 +102,9 @@ int qemu_file_shutdown(QEMUFile *f)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
|
||||
+static QEMUFile *qemu_file_new_impl(QIOChannel *ioc,
|
||||
+ bool is_writable,
|
||||
+ size_t buffer_size)
|
||||
{
|
||||
QEMUFile *f;
|
||||
|
||||
@@ -110,6 +113,8 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
|
||||
object_ref(ioc);
|
||||
f->ioc = ioc;
|
||||
f->is_writable = is_writable;
|
||||
+ f->buf_allocated_size = buffer_size;
|
||||
+ f->buf = malloc(buffer_size);
|
||||
|
||||
return f;
|
||||
}
|
||||
@@ -120,17 +125,27 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
|
||||
*/
|
||||
QEMUFile *qemu_file_get_return_path(QEMUFile *f)
|
||||
{
|
||||
- return qemu_file_new_impl(f->ioc, !f->is_writable);
|
||||
+ return qemu_file_new_impl(f->ioc, !f->is_writable, DEFAULT_IO_BUF_SIZE);
|
||||
}
|
||||
|
||||
QEMUFile *qemu_file_new_output(QIOChannel *ioc)
|
||||
{
|
||||
- return qemu_file_new_impl(ioc, true);
|
||||
+ return qemu_file_new_impl(ioc, true, DEFAULT_IO_BUF_SIZE);
|
||||
+}
|
||||
+
|
||||
+QEMUFile *qemu_file_new_output_sized(QIOChannel *ioc, size_t buffer_size)
|
||||
+{
|
||||
+ return qemu_file_new_impl(ioc, true, buffer_size);
|
||||
}
|
||||
|
||||
QEMUFile *qemu_file_new_input(QIOChannel *ioc)
|
||||
{
|
||||
- return qemu_file_new_impl(ioc, false);
|
||||
+ return qemu_file_new_impl(ioc, false, DEFAULT_IO_BUF_SIZE);
|
||||
+}
|
||||
+
|
||||
+QEMUFile *qemu_file_new_input_sized(QIOChannel *ioc, size_t buffer_size)
|
||||
+{
|
||||
+ return qemu_file_new_impl(ioc, false, buffer_size);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -328,7 +343,7 @@ static ssize_t coroutine_mixed_fn qemu_fill_buffer(QEMUFile *f)
|
||||
do {
|
||||
len = qio_channel_read(f->ioc,
|
||||
(char *)f->buf + pending,
|
||||
- IO_BUF_SIZE - pending,
|
||||
+ f->buf_allocated_size - pending,
|
||||
&local_error);
|
||||
if (len == QIO_CHANNEL_ERR_BLOCK) {
|
||||
if (qemu_in_coroutine()) {
|
||||
@@ -368,6 +383,9 @@ int qemu_fclose(QEMUFile *f)
|
||||
ret = ret2;
|
||||
}
|
||||
g_clear_pointer(&f->ioc, object_unref);
|
||||
+
|
||||
+ free(f->buf);
|
||||
+
|
||||
error_free(f->last_error_obj);
|
||||
g_free(f);
|
||||
trace_qemu_file_fclose();
|
||||
@@ -416,7 +434,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
|
||||
{
|
||||
if (!add_to_iovec(f, f->buf + f->buf_index, len, false)) {
|
||||
f->buf_index += len;
|
||||
- if (f->buf_index == IO_BUF_SIZE) {
|
||||
+ if (f->buf_index == f->buf_allocated_size) {
|
||||
qemu_fflush(f);
|
||||
}
|
||||
}
|
||||
@@ -441,7 +459,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
|
||||
}
|
||||
|
||||
while (size > 0) {
|
||||
- l = IO_BUF_SIZE - f->buf_index;
|
||||
+ l = f->buf_allocated_size - f->buf_index;
|
||||
if (l > size) {
|
||||
l = size;
|
||||
}
|
||||
@@ -587,8 +605,8 @@ size_t coroutine_mixed_fn qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t si
|
||||
size_t index;
|
||||
|
||||
assert(!qemu_file_is_writable(f));
|
||||
- assert(offset < IO_BUF_SIZE);
|
||||
- assert(size <= IO_BUF_SIZE - offset);
|
||||
+ assert(offset < f->buf_allocated_size);
|
||||
+ assert(size <= f->buf_allocated_size - offset);
|
||||
|
||||
/* The 1st byte to read from */
|
||||
index = f->buf_index + offset;
|
||||
@@ -638,7 +656,7 @@ size_t coroutine_mixed_fn qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size
|
||||
size_t res;
|
||||
uint8_t *src;
|
||||
|
||||
- res = qemu_peek_buffer(f, &src, MIN(pending, IO_BUF_SIZE), 0);
|
||||
+ res = qemu_peek_buffer(f, &src, MIN(pending, f->buf_allocated_size), 0);
|
||||
if (res == 0) {
|
||||
return done;
|
||||
}
|
||||
@@ -672,7 +690,7 @@ size_t coroutine_mixed_fn qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size
|
||||
*/
|
||||
size_t coroutine_mixed_fn qemu_get_buffer_in_place(QEMUFile *f, uint8_t **buf, size_t size)
|
||||
{
|
||||
- if (size < IO_BUF_SIZE) {
|
||||
+ if (size < f->buf_allocated_size) {
|
||||
size_t res;
|
||||
uint8_t *src = NULL;
|
||||
|
||||
@@ -697,7 +715,7 @@ int coroutine_mixed_fn qemu_peek_byte(QEMUFile *f, int offset)
|
||||
int index = f->buf_index + offset;
|
||||
|
||||
assert(!qemu_file_is_writable(f));
|
||||
- assert(offset < IO_BUF_SIZE);
|
||||
+ assert(offset < f->buf_allocated_size);
|
||||
|
||||
if (index >= f->buf_size) {
|
||||
qemu_fill_buffer(f);
|
||||
@@ -811,7 +829,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
|
||||
ssize_t qemu_put_compression_data(QEMUFile *f, z_stream *stream,
|
||||
const uint8_t *p, size_t size)
|
||||
{
|
||||
- ssize_t blen = IO_BUF_SIZE - f->buf_index - sizeof(int32_t);
|
||||
+ ssize_t blen = f->buf_allocated_size - f->buf_index - sizeof(int32_t);
|
||||
|
||||
if (blen < compressBound(size)) {
|
||||
return -1;
|
||||
diff --git a/migration/qemu-file.h b/migration/qemu-file.h
|
||||
index 32fd4a34fd..36a0cd8cc8 100644
|
||||
--- a/migration/qemu-file.h
|
||||
+++ b/migration/qemu-file.h
|
||||
@@ -30,7 +30,9 @@
|
||||
#include "io/channel.h"
|
||||
|
||||
QEMUFile *qemu_file_new_input(QIOChannel *ioc);
|
||||
+QEMUFile *qemu_file_new_input_sized(QIOChannel *ioc, size_t buffer_size);
|
||||
QEMUFile *qemu_file_new_output(QIOChannel *ioc);
|
||||
+QEMUFile *qemu_file_new_output_sized(QIOChannel *ioc, size_t buffer_size);
|
||||
int qemu_fclose(QEMUFile *f);
|
||||
|
||||
/*
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index ae7ed68651..cdd5ea6288 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -386,7 +386,7 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
|
||||
QIOChannel *ioc = QIO_CHANNEL(qio_channel_savevm_async_new(snap_state.target,
|
||||
&snap_state.bs_pos));
|
||||
- snap_state.file = qemu_file_new_output(ioc);
|
||||
+ snap_state.file = qemu_file_new_output_sized(ioc, 4 * 1024 * 1024);
|
||||
|
||||
if (!snap_state.file) {
|
||||
error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
|
||||
@@ -514,7 +514,8 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
|
||||
blk_op_block_all(be, blocker);
|
||||
|
||||
/* restore the VM state */
|
||||
- f = qemu_file_new_input(QIO_CHANNEL(qio_channel_savevm_async_new(be, &bs_pos)));
|
||||
+ f = qemu_file_new_input_sized(QIO_CHANNEL(qio_channel_savevm_async_new(be, &bs_pos)),
|
||||
+ 4 * 1024 * 1024);
|
||||
if (!f) {
|
||||
error_setg(errp, "Could not open VM state file");
|
||||
goto the_end;
|
@@ -4,32 +4,34 @@ Date: Mon, 6 Apr 2020 12:16:47 +0200
|
||||
Subject: [PATCH] PVE: block: add the zeroinit block driver filter
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[adapt to changed function signatures]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
[FE: adapt to changed function signatures
|
||||
adhere to block graph lock requirements
|
||||
use dedicated function to open file child]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/meson.build | 1 +
|
||||
block/zeroinit.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 197 insertions(+)
|
||||
block/zeroinit.c | 207 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 208 insertions(+)
|
||||
create mode 100644 block/zeroinit.c
|
||||
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index deb73ca389..c9d1fdca7d 100644
|
||||
index e1f03fd773..b530e117b5 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -41,6 +41,7 @@ block_ss.add(files(
|
||||
'vmdk.c',
|
||||
'vpc.c',
|
||||
@@ -39,6 +39,7 @@ block_ss.add(files(
|
||||
'throttle.c',
|
||||
'throttle-groups.c',
|
||||
'write-threshold.c',
|
||||
+ 'zeroinit.c',
|
||||
), zstd, zlib, gnutls)
|
||||
|
||||
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
system_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
diff --git a/block/zeroinit.c b/block/zeroinit.c
|
||||
new file mode 100644
|
||||
index 0000000000..20ee611f22
|
||||
index 0000000000..7998c9332d
|
||||
--- /dev/null
|
||||
+++ b/block/zeroinit.c
|
||||
@@ -0,0 +1,196 @@
|
||||
@@ -0,0 +1,207 @@
|
||||
+/*
|
||||
+ * Filter to fake a zero-initialized block device.
|
||||
+ *
|
||||
@@ -43,6 +45,8 @@ index 0000000000..20ee611f22
|
||||
+#include "qemu/osdep.h"
|
||||
+#include "qapi/error.h"
|
||||
+#include "block/block_int.h"
|
||||
+#include "block/block-io.h"
|
||||
+#include "block/graph-lock.h"
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
+#include "qapi/qmp/qstring.h"
|
||||
+#include "qemu/cutils.h"
|
||||
@@ -108,10 +112,9 @@ index 0000000000..20ee611f22
|
||||
+ }
|
||||
+
|
||||
+ /* Open the raw file */
|
||||
+ bs->file = bdrv_open_child(qemu_opt_get(opts, "x-next"), options, "next",
|
||||
+ bs, &child_of_bds, BDRV_CHILD_FILTERED, false, &local_err);
|
||||
+ if (local_err) {
|
||||
+ ret = -EINVAL;
|
||||
+ ret = bdrv_open_file_child(qemu_opt_get(opts, "x-next"), options, "next",
|
||||
+ bs, &local_err);
|
||||
+ if (ret < 0) {
|
||||
+ error_propagate(errp, local_err);
|
||||
+ goto fail;
|
||||
+ }
|
||||
@@ -122,7 +125,9 @@ index 0000000000..20ee611f22
|
||||
+ ret = 0;
|
||||
+fail:
|
||||
+ if (ret < 0) {
|
||||
+ bdrv_graph_wrlock();
|
||||
+ bdrv_unref_child(bs, bs->file);
|
||||
+ bdrv_graph_wrunlock();
|
||||
+ }
|
||||
+ qemu_opts_del(opts);
|
||||
+ return ret;
|
||||
@@ -134,19 +139,22 @@ index 0000000000..20ee611f22
|
||||
+ (void)s;
|
||||
+}
|
||||
+
|
||||
+static int64_t zeroinit_getlength(BlockDriverState *bs)
|
||||
+static coroutine_fn int64_t GRAPH_RDLOCK
|
||||
+zeroinit_co_getlength(BlockDriverState *bs)
|
||||
+{
|
||||
+ return bdrv_getlength(bs->file->bs);
|
||||
+ return bdrv_co_getlength(bs->file->bs);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_preadv(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+zeroinit_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
+ QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
||||
+ int64_t bytes, BdrvRequestFlags flags)
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+zeroinit_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
+ BdrvRequestFlags flags)
|
||||
+{
|
||||
+ BDRVZeroinitState *s = bs->opaque;
|
||||
+ if (offset >= s->extents)
|
||||
@@ -154,8 +162,9 @@ index 0000000000..20ee611f22
|
||||
+ return bdrv_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_pwritev(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+zeroinit_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
+ QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ BDRVZeroinitState *s = bs->opaque;
|
||||
+ int64_t extents = offset + bytes;
|
||||
@@ -164,33 +173,37 @@ index 0000000000..20ee611f22
|
||||
+ return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int zeroinit_co_flush(BlockDriverState *bs)
|
||||
+static coroutine_fn int GRAPH_RDLOCK
|
||||
+zeroinit_co_flush(BlockDriverState *bs)
|
||||
+{
|
||||
+ return bdrv_co_flush(bs->file->bs);
|
||||
+}
|
||||
+
|
||||
+static int zeroinit_has_zero_init(BlockDriverState *bs)
|
||||
+static int GRAPH_RDLOCK
|
||||
+zeroinit_has_zero_init(BlockDriverState *bs)
|
||||
+{
|
||||
+ BDRVZeroinitState *s = bs->opaque;
|
||||
+ return s->has_zero_init;
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_pdiscard(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes)
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+zeroinit_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
+{
|
||||
+ return bdrv_co_pdiscard(bs->file, offset, bytes);
|
||||
+}
|
||||
+
|
||||
+static int zeroinit_co_truncate(BlockDriverState *bs, int64_t offset,
|
||||
+ _Bool exact, PreallocMode prealloc,
|
||||
+ BdrvRequestFlags req_flags, Error **errp)
|
||||
+static int GRAPH_RDLOCK
|
||||
+zeroinit_co_truncate(BlockDriverState *bs, int64_t offset, _Bool exact,
|
||||
+ PreallocMode prealloc, BdrvRequestFlags req_flags,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ return bdrv_co_truncate(bs->file, offset, exact, prealloc, req_flags, errp);
|
||||
+}
|
||||
+
|
||||
+static int zeroinit_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
|
||||
+static coroutine_fn int GRAPH_RDLOCK
|
||||
+zeroinit_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
|
||||
+{
|
||||
+ return bdrv_get_info(bs->file->bs, bdi);
|
||||
+ return bdrv_co_get_info(bs->file->bs, bdi);
|
||||
+}
|
||||
+
|
||||
+static BlockDriver bdrv_zeroinit = {
|
||||
@@ -201,7 +214,7 @@ index 0000000000..20ee611f22
|
||||
+ .bdrv_parse_filename = zeroinit_parse_filename,
|
||||
+ .bdrv_file_open = zeroinit_open,
|
||||
+ .bdrv_close = zeroinit_close,
|
||||
+ .bdrv_getlength = zeroinit_getlength,
|
||||
+ .bdrv_co_getlength = zeroinit_co_getlength,
|
||||
+ .bdrv_child_perm = bdrv_default_perms,
|
||||
+ .bdrv_co_flush_to_disk = zeroinit_co_flush,
|
||||
+
|
||||
@@ -217,7 +230,7 @@ index 0000000000..20ee611f22
|
||||
+ .bdrv_co_pdiscard = zeroinit_co_pdiscard,
|
||||
+
|
||||
+ .bdrv_co_truncate = zeroinit_co_truncate,
|
||||
+ .bdrv_get_info = zeroinit_get_info,
|
||||
+ .bdrv_co_get_info = zeroinit_co_get_info,
|
||||
+};
|
||||
+
|
||||
+static void bdrv_zeroinit_init(void)
|
@@ -10,16 +10,16 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
qemu-options.hx | 3 +++
|
||||
softmmu/vl.c | 8 ++++++++
|
||||
system/vl.c | 8 ++++++++
|
||||
2 files changed, 11 insertions(+)
|
||||
|
||||
diff --git a/qemu-options.hx b/qemu-options.hx
|
||||
index 423144abeb..4879471aeb 100644
|
||||
index 511ab9415e..92e301d545 100644
|
||||
--- a/qemu-options.hx
|
||||
+++ b/qemu-options.hx
|
||||
@@ -1019,6 +1019,9 @@ DEFHEADING()
|
||||
@@ -1237,6 +1237,9 @@ legacy PC, they are not recommended for modern configurations.
|
||||
|
||||
DEFHEADING(Block device options:)
|
||||
ERST
|
||||
|
||||
+DEF("id", HAS_ARG, QEMU_OPTION_id,
|
||||
+ "-id n set the VMID", QEMU_ARCH_ALL)
|
||||
@@ -27,11 +27,11 @@ index 423144abeb..4879471aeb 100644
|
||||
DEF("fda", HAS_ARG, QEMU_OPTION_fda,
|
||||
"-fda/-fdb file use 'file' as floppy disk 0/1 image\n", QEMU_ARCH_ALL)
|
||||
DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "", QEMU_ARCH_ALL)
|
||||
diff --git a/softmmu/vl.c b/softmmu/vl.c
|
||||
index fd82efb8b3..eb05e5a000 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -2779,6 +2779,7 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
diff --git a/system/vl.c b/system/vl.c
|
||||
index 2738ab7c91..20ebf2c920 100644
|
||||
--- a/system/vl.c
|
||||
+++ b/system/vl.c
|
||||
@@ -2748,6 +2748,7 @@ void qemu_init(int argc, char **argv)
|
||||
MachineClass *machine_class;
|
||||
bool userconfig = true;
|
||||
FILE *vmstate_dump_file = NULL;
|
||||
@@ -39,7 +39,7 @@ index fd82efb8b3..eb05e5a000 100644
|
||||
|
||||
qemu_add_opts(&qemu_drive_opts);
|
||||
qemu_add_drive_opts(&qemu_legacy_drive_opts);
|
||||
@@ -3421,6 +3422,13 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
@@ -3371,6 +3372,13 @@ void qemu_init(int argc, char **argv)
|
||||
machine_parse_property_opt(qemu_find_opts("smp-opts"),
|
||||
"smp", optarg);
|
||||
break;
|
||||
@@ -50,6 +50,6 @@ index fd82efb8b3..eb05e5a000 100644
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ break;
|
||||
#ifdef CONFIG_VNC
|
||||
case QEMU_OPTION_vnc:
|
||||
vnc_parse(optarg);
|
||||
break;
|
@@ -11,10 +11,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
|
||||
index 2a20982066..7968ad5a93 100644
|
||||
index d8fc1e2815..789694b8b3 100644
|
||||
--- a/hw/intc/apic_common.c
|
||||
+++ b/hw/intc/apic_common.c
|
||||
@@ -278,6 +278,15 @@ static void apic_reset_common(DeviceState *dev)
|
||||
@@ -263,6 +263,15 @@ static void apic_reset_common(DeviceState *dev)
|
||||
info->vapic_base_update(s);
|
||||
|
||||
apic_init_reset(dev);
|
@@ -9,14 +9,14 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/file-posix.c | 59 ++++++++++++++++++++++++++++++--------------
|
||||
qapi/block-core.json | 3 ++-
|
||||
2 files changed, 42 insertions(+), 20 deletions(-)
|
||||
qapi/block-core.json | 7 +++++-
|
||||
2 files changed, 46 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/block/file-posix.c b/block/file-posix.c
|
||||
index 821405fd02..e3b6c3c524 100644
|
||||
index 43bc0bd520..60e98c87f1 100644
|
||||
--- a/block/file-posix.c
|
||||
+++ b/block/file-posix.c
|
||||
@@ -2465,6 +2465,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -2876,6 +2876,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
int fd;
|
||||
uint64_t perm, shared;
|
||||
int result = 0;
|
||||
@@ -24,7 +24,7 @@ index 821405fd02..e3b6c3c524 100644
|
||||
|
||||
/* Validate options and set default values */
|
||||
assert(options->driver == BLOCKDEV_DRIVER_FILE);
|
||||
@@ -2505,19 +2506,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -2916,19 +2917,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
perm = BLK_PERM_WRITE | BLK_PERM_RESIZE;
|
||||
shared = BLK_PERM_ALL & ~BLK_PERM_RESIZE;
|
||||
|
||||
@@ -59,7 +59,7 @@ index 821405fd02..e3b6c3c524 100644
|
||||
}
|
||||
|
||||
/* Clear the file by truncating it to 0 */
|
||||
@@ -2571,13 +2575,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -2982,13 +2986,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
}
|
||||
|
||||
out_unlock:
|
||||
@@ -82,7 +82,7 @@ index 821405fd02..e3b6c3c524 100644
|
||||
}
|
||||
|
||||
out_close:
|
||||
@@ -2602,6 +2608,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
@@ -3012,6 +3018,7 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
PreallocMode prealloc;
|
||||
char *buf = NULL;
|
||||
Error *local_err = NULL;
|
||||
@@ -90,7 +90,7 @@ index 821405fd02..e3b6c3c524 100644
|
||||
|
||||
/* Skip file: protocol prefix */
|
||||
strstart(filename, "file:", &filename);
|
||||
@@ -2624,6 +2631,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
@@ -3034,6 +3041,18 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ index 821405fd02..e3b6c3c524 100644
|
||||
options = (BlockdevCreateOptions) {
|
||||
.driver = BLOCKDEV_DRIVER_FILE,
|
||||
.u.file = {
|
||||
@@ -2635,6 +2654,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
@@ -3045,6 +3064,8 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
.nocow = nocow,
|
||||
.has_extent_size_hint = has_extent_size_hint,
|
||||
.extent_size_hint = extent_size_hint,
|
||||
@@ -119,10 +119,21 @@ index 821405fd02..e3b6c3c524 100644
|
||||
};
|
||||
return raw_co_create(&options, errp);
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 1d3dd9cb48..3f81d6a5c0 100644
|
||||
index 905da8be72..3db587a6e4 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -4445,7 +4445,8 @@
|
||||
@@ -4956,6 +4956,10 @@
|
||||
# @extent-size-hint: Extent size hint to add to the image file; 0 for
|
||||
# not adding an extent size hint (default: 1 MB, since 5.1)
|
||||
#
|
||||
+# @locking: whether to enable file locking. If set to 'auto', only
|
||||
+# enable when Open File Descriptor (OFD) locking API is available
|
||||
+# (default: auto).
|
||||
+#
|
||||
# Since: 2.12
|
||||
##
|
||||
{ 'struct': 'BlockdevCreateOptionsFile',
|
||||
@@ -4963,7 +4967,8 @@
|
||||
'size': 'size',
|
||||
'*preallocation': 'PreallocMode',
|
||||
'*nocow': 'bool',
|
@@ -18,10 +18,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/monitor/qmp.c b/monitor/qmp.c
|
||||
index 6b8cfcf6d8..3ec67e32d3 100644
|
||||
index 589c9524f8..2505dd658a 100644
|
||||
--- a/monitor/qmp.c
|
||||
+++ b/monitor/qmp.c
|
||||
@@ -519,8 +519,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
|
||||
@@ -536,8 +536,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
|
||||
qemu_chr_fe_set_echo(&mon->common.chr, true);
|
||||
|
||||
/* Note: we run QMP monitor in I/O thread when @chr supports that */
|
@@ -26,10 +26,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/core/machine.c b/hw/core/machine.c
|
||||
index 53a99abc56..ad2cb2592e 100644
|
||||
index 4273de16a0..83f1fc0293 100644
|
||||
--- a/hw/core/machine.c
|
||||
+++ b/hw/core/machine.c
|
||||
@@ -113,7 +113,8 @@ GlobalProperty hw_compat_4_0[] = {
|
||||
@@ -162,7 +162,8 @@ GlobalProperty hw_compat_4_0[] = {
|
||||
{ "virtio-vga", "edid", "false" },
|
||||
{ "virtio-gpu-device", "edid", "false" },
|
||||
{ "virtio-device", "use-started", "false" },
|
@@ -11,78 +11,79 @@ and only if 'is-current').
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: adapt to QAPI changes]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/core/machine-qmp-cmds.c | 6 ++++++
|
||||
hw/core/machine-qmp-cmds.c | 5 +++++
|
||||
include/hw/boards.h | 2 ++
|
||||
qapi/machine.json | 4 +++-
|
||||
softmmu/vl.c | 25 +++++++++++++++++++++++++
|
||||
4 files changed, 36 insertions(+), 1 deletion(-)
|
||||
system/vl.c | 25 +++++++++++++++++++++++++
|
||||
4 files changed, 35 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
|
||||
index 76fff60a6b..ec9201fb9a 100644
|
||||
index 314351cdff..628a3537c5 100644
|
||||
--- a/hw/core/machine-qmp-cmds.c
|
||||
+++ b/hw/core/machine-qmp-cmds.c
|
||||
@@ -103,6 +103,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
||||
@@ -94,6 +94,11 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
||||
if (strcmp(mc->name, MACHINE_GET_CLASS(current_machine)->name) == 0) {
|
||||
info->has_is_current = true;
|
||||
info->is_current = true;
|
||||
+
|
||||
+ // PVE version string only exists for current machine
|
||||
+ if (mc->pve_version) {
|
||||
+ info->has_pve_version = true;
|
||||
+ info->pve_version = g_strdup(mc->pve_version);
|
||||
+ }
|
||||
}
|
||||
|
||||
if (mc->default_cpu_type) {
|
||||
diff --git a/include/hw/boards.h b/include/hw/boards.h
|
||||
index 9c1c190104..51e04bde62 100644
|
||||
index 8b8f6d5c00..dd6d0a1447 100644
|
||||
--- a/include/hw/boards.h
|
||||
+++ b/include/hw/boards.h
|
||||
@@ -227,6 +227,8 @@ struct MachineClass {
|
||||
@@ -246,6 +246,8 @@ struct MachineClass {
|
||||
const char *desc;
|
||||
const char *deprecation_reason;
|
||||
|
||||
+ const char *pve_version;
|
||||
+
|
||||
void (*init)(MachineState *state);
|
||||
void (*reset)(MachineState *state);
|
||||
void (*reset)(MachineState *state, ShutdownCause reason);
|
||||
void (*wakeup)(MachineState *state);
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 0905618e25..a05c46e253 100644
|
||||
index a024d5b05d..1d69bffaa0 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -160,6 +160,8 @@
|
||||
@@ -168,6 +168,8 @@
|
||||
#
|
||||
# @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
|
||||
# @acpi: machine type supports ACPI (since 8.0)
|
||||
#
|
||||
+# @pve-version: custom PVE version suffix specified as 'machine+pveN'
|
||||
+#
|
||||
# Since: 1.2
|
||||
##
|
||||
{ 'struct': 'MachineInfo',
|
||||
@@ -167,7 +169,7 @@
|
||||
@@ -175,7 +177,7 @@
|
||||
'*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
|
||||
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
|
||||
'deprecated': 'bool', '*default-cpu-type': 'str',
|
||||
- '*default-ram-id': 'str' } }
|
||||
+ '*default-ram-id': 'str', '*pve-version': 'str' } }
|
||||
- '*default-ram-id': 'str', 'acpi': 'bool' } }
|
||||
+ '*default-ram-id': 'str', 'acpi': 'bool', '*pve-version': 'str' } }
|
||||
|
||||
##
|
||||
# @query-machines:
|
||||
diff --git a/softmmu/vl.c b/softmmu/vl.c
|
||||
index eb05e5a000..f306d21d63 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -1655,6 +1655,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
|
||||
diff --git a/system/vl.c b/system/vl.c
|
||||
index 20ebf2c920..4d39e32097 100644
|
||||
--- a/system/vl.c
|
||||
+++ b/system/vl.c
|
||||
@@ -1659,6 +1659,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
|
||||
static MachineClass *select_machine(QDict *qdict, Error **errp)
|
||||
{
|
||||
const char *optarg = qdict_get_try_str(qdict, "type");
|
||||
const char *machine_type = qdict_get_try_str(qdict, "type");
|
||||
+ const char *pvever = qdict_get_try_str(qdict, "pvever");
|
||||
GSList *machines = object_class_get_list(TYPE_MACHINE, false);
|
||||
MachineClass *machine_class;
|
||||
Error *local_err = NULL;
|
||||
@@ -1672,6 +1673,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
|
||||
@@ -1676,6 +1677,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ index eb05e5a000..f306d21d63 100644
|
||||
g_slist_free(machines);
|
||||
if (local_err) {
|
||||
error_append_hint(&local_err, "Use -machine help to list supported machines\n");
|
||||
@@ -3363,12 +3369,31 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
@@ -3313,12 +3319,31 @@ void qemu_init(int argc, char **argv)
|
||||
case QEMU_OPTION_machine:
|
||||
{
|
||||
bool help;
|
@@ -25,11 +25,11 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/block/backup.c b/block/backup.c
|
||||
index 21d5983779..47e218857d 100644
|
||||
index 3dd2e229d2..eba5b11493 100644
|
||||
--- a/block/backup.c
|
||||
+++ b/block/backup.c
|
||||
@@ -239,8 +239,8 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
|
||||
assert(ret);
|
||||
@@ -237,8 +237,8 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
|
||||
true);
|
||||
} else if (job->sync_mode == MIRROR_SYNC_MODE_TOP) {
|
||||
/*
|
||||
- * We can't hog the coroutine to initialize this thoroughly.
|
||||
@@ -39,7 +39,7 @@ index 21d5983779..47e218857d 100644
|
||||
*/
|
||||
block_copy_set_skip_unallocated(job->bcs, true);
|
||||
}
|
||||
@@ -254,8 +254,6 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
|
||||
@@ -252,8 +252,6 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
|
||||
BackupBlockJob *s = container_of(job, BackupBlockJob, common.job);
|
||||
int ret;
|
||||
|
||||
@@ -48,9 +48,9 @@ index 21d5983779..47e218857d 100644
|
||||
if (s->sync_mode == MIRROR_SYNC_MODE_TOP) {
|
||||
int64_t offset = 0;
|
||||
int64_t count;
|
||||
@@ -493,6 +491,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL,
|
||||
@@ -502,6 +500,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
&error_abort);
|
||||
bdrv_graph_wrunlock();
|
||||
|
||||
+ backup_init_bcs_bitmap(job);
|
||||
+
|
@@ -3,40 +3,47 @@ From: Dietmar Maurer <dietmar@proxmox.com>
|
||||
Date: Mon, 6 Apr 2020 12:16:57 +0200
|
||||
Subject: [PATCH] PVE-Backup: add vma backup format code
|
||||
|
||||
Notes about partial restoring: skipping a certain drive is done via a
|
||||
map line of the form skip=drive-scsi0. Since in PVE, most archives are
|
||||
compressed and piped to vma for restore, it's not easily possible to
|
||||
skip reads.
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: create: register all streams before entering coroutines]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
[FE: improvements during create
|
||||
allow partial restore
|
||||
allow specifying disk formats for create operation]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/meson.build | 2 +
|
||||
meson.build | 5 +
|
||||
vma-reader.c | 860 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma-writer.c | 790 ++++++++++++++++++++++++++++++++++++++++++
|
||||
vma.c | 849 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma-reader.c | 870 ++++++++++++++++++++++++++++++++++++++++++
|
||||
vma-writer.c | 817 ++++++++++++++++++++++++++++++++++++++++
|
||||
vma.c | 941 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma.h | 150 ++++++++
|
||||
6 files changed, 2656 insertions(+)
|
||||
6 files changed, 2785 insertions(+)
|
||||
create mode 100644 vma-reader.c
|
||||
create mode 100644 vma-writer.c
|
||||
create mode 100644 vma.c
|
||||
create mode 100644 vma.h
|
||||
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index c9d1fdca7d..72081a9974 100644
|
||||
index b530e117b5..b245daa98e 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -44,6 +44,8 @@ block_ss.add(files(
|
||||
@@ -42,6 +42,8 @@ block_ss.add(files(
|
||||
'zeroinit.c',
|
||||
), zstd, zlib, gnutls)
|
||||
|
||||
+block_ss.add(files('../vma-writer.c'), libuuid)
|
||||
+
|
||||
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
system_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
system_ss.add(files('block-ram-registrar.c'))
|
||||
|
||||
block_ss.add(when: 'CONFIG_QCOW1', if_true: files('qcow.c'))
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 96de1a6ef9..54c23b9567 100644
|
||||
index 91a0aa64c6..620cc594b2 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -1202,6 +1202,8 @@ keyutils = dependency('libkeyutils', required: false,
|
||||
@@ -1922,6 +1922,8 @@ endif
|
||||
|
||||
has_gettid = cc.has_function('gettid')
|
||||
|
||||
@@ -45,7 +52,7 @@ index 96de1a6ef9..54c23b9567 100644
|
||||
# libselinux
|
||||
selinux = dependency('libselinux',
|
||||
required: get_option('selinux'),
|
||||
@@ -3070,6 +3072,9 @@ if have_tools
|
||||
@@ -4023,6 +4025,9 @@ if have_tools
|
||||
dependencies: [blockdev, qemuutil, gnutls, selinux],
|
||||
install: true)
|
||||
|
||||
@@ -53,14 +60,14 @@ index 96de1a6ef9..54c23b9567 100644
|
||||
+ dependencies: [authz, block, crypto, io, qom], install: true)
|
||||
+
|
||||
subdir('storage-daemon')
|
||||
subdir('contrib/rdmacm-mux')
|
||||
subdir('contrib/elf2dmp')
|
||||
|
||||
foreach exe: [ 'qemu-img', 'qemu-io', 'qemu-nbd', 'qemu-storage-daemon']
|
||||
diff --git a/vma-reader.c b/vma-reader.c
|
||||
new file mode 100644
|
||||
index 0000000000..4f4ee2b47b
|
||||
index 0000000000..d0b6721812
|
||||
--- /dev/null
|
||||
+++ b/vma-reader.c
|
||||
@@ -0,0 +1,860 @@
|
||||
@@ -0,0 +1,870 @@
|
||||
+/*
|
||||
+ * VMA: Virtual Machine Archive
|
||||
+ *
|
||||
@@ -78,11 +85,11 @@ index 0000000000..4f4ee2b47b
|
||||
+#include <glib.h>
|
||||
+#include <uuid/uuid.h>
|
||||
+
|
||||
+#include "qemu-common.h"
|
||||
+#include "qemu/timer.h"
|
||||
+#include "qemu/ratelimit.h"
|
||||
+#include "vma.h"
|
||||
+#include "block/block.h"
|
||||
+#include "block/graph-lock.h"
|
||||
+#include "sysemu/block-backend.h"
|
||||
+
|
||||
+static unsigned char zero_vma_block[VMA_BLOCK_SIZE];
|
||||
@@ -92,6 +99,7 @@ index 0000000000..4f4ee2b47b
|
||||
+ bool write_zeroes;
|
||||
+ unsigned long *bitmap;
|
||||
+ int bitmap_size;
|
||||
+ bool skip;
|
||||
+} VmaRestoreState;
|
||||
+
|
||||
+struct VmaReader {
|
||||
@@ -489,13 +497,14 @@ index 0000000000..4f4ee2b47b
|
||||
+}
|
||||
+
|
||||
+static void allocate_rstate(VmaReader *vmar, guint8 dev_id,
|
||||
+ BlockBackend *target, bool write_zeroes)
|
||||
+ BlockBackend *target, bool write_zeroes, bool skip)
|
||||
+{
|
||||
+ assert(vmar);
|
||||
+ assert(dev_id);
|
||||
+
|
||||
+ vmar->rstate[dev_id].target = target;
|
||||
+ vmar->rstate[dev_id].write_zeroes = write_zeroes;
|
||||
+ vmar->rstate[dev_id].skip = skip;
|
||||
+
|
||||
+ int64_t size = vmar->devinfo[dev_id].size;
|
||||
+
|
||||
@@ -510,28 +519,30 @@ index 0000000000..4f4ee2b47b
|
||||
+}
|
||||
+
|
||||
+int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id, BlockBackend *target,
|
||||
+ bool write_zeroes, Error **errp)
|
||||
+ bool write_zeroes, bool skip, Error **errp)
|
||||
+{
|
||||
+ assert(vmar);
|
||||
+ assert(target != NULL);
|
||||
+ assert(target != NULL || skip);
|
||||
+ assert(dev_id);
|
||||
+ assert(vmar->rstate[dev_id].target == NULL);
|
||||
+ assert(vmar->rstate[dev_id].target == NULL && !vmar->rstate[dev_id].skip);
|
||||
+
|
||||
+ int64_t size = blk_getlength(target);
|
||||
+ int64_t size_diff = size - vmar->devinfo[dev_id].size;
|
||||
+ if (target != NULL) {
|
||||
+ int64_t size = blk_getlength(target);
|
||||
+ int64_t size_diff = size - vmar->devinfo[dev_id].size;
|
||||
+
|
||||
+ /* storage types can have different size restrictions, so it
|
||||
+ * is not always possible to create an image with exact size.
|
||||
+ * So we tolerate a size difference up to 4MB.
|
||||
+ */
|
||||
+ if ((size_diff < 0) || (size_diff > 4*1024*1024)) {
|
||||
+ error_setg(errp, "vma_reader_register_bs for stream %s failed - "
|
||||
+ "unexpected size %zd != %zd", vmar->devinfo[dev_id].devname,
|
||||
+ size, vmar->devinfo[dev_id].size);
|
||||
+ return -1;
|
||||
+ /* storage types can have different size restrictions, so it
|
||||
+ * is not always possible to create an image with exact size.
|
||||
+ * So we tolerate a size difference up to 4MB.
|
||||
+ */
|
||||
+ if ((size_diff < 0) || (size_diff > 4*1024*1024)) {
|
||||
+ error_setg(errp, "vma_reader_register_bs for stream %s failed - "
|
||||
+ "unexpected size %zd != %zd", vmar->devinfo[dev_id].devname,
|
||||
+ size, vmar->devinfo[dev_id].size);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ allocate_rstate(vmar, dev_id, target, write_zeroes);
|
||||
+ allocate_rstate(vmar, dev_id, target, write_zeroes, skip);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
@@ -589,10 +600,12 @@ index 0000000000..4f4ee2b47b
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ int res = blk_pwrite(target, sector_num * BDRV_SECTOR_SIZE, buf, nb_sectors * BDRV_SECTOR_SIZE, 0);
|
||||
+ int res = blk_pwrite(target, sector_num * BDRV_SECTOR_SIZE, nb_sectors * BDRV_SECTOR_SIZE, buf, 0);
|
||||
+ if (res < 0) {
|
||||
+ bdrv_graph_rdlock_main_loop();
|
||||
+ error_setg(errp, "blk_pwrite to %s failed (%d)",
|
||||
+ bdrv_get_device_name(blk_bs(target)), res);
|
||||
+ bdrv_graph_rdunlock_main_loop();
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
@@ -624,19 +637,23 @@ index 0000000000..4f4ee2b47b
|
||||
+ VmaRestoreState *rstate = &vmar->rstate[dev_id];
|
||||
+ BlockBackend *target = NULL;
|
||||
+
|
||||
+ bool skip = rstate->skip;
|
||||
+
|
||||
+ if (dev_id != vmar->vmstate_stream) {
|
||||
+ target = rstate->target;
|
||||
+ if (!verify && !target) {
|
||||
+ if (!verify && !target && !skip) {
|
||||
+ error_setg(errp, "got wrong dev id %d", dev_id);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (vma_reader_get_bitmap(rstate, cluster_num)) {
|
||||
+ error_setg(errp, "found duplicated cluster %zd for stream %s",
|
||||
+ cluster_num, vmar->devinfo[dev_id].devname);
|
||||
+ return -1;
|
||||
+ if (!skip) {
|
||||
+ if (vma_reader_get_bitmap(rstate, cluster_num)) {
|
||||
+ error_setg(errp, "found duplicated cluster %zd for stream %s",
|
||||
+ cluster_num, vmar->devinfo[dev_id].devname);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ vma_reader_set_bitmap(rstate, cluster_num, 1);
|
||||
+ }
|
||||
+ vma_reader_set_bitmap(rstate, cluster_num, 1);
|
||||
+
|
||||
+ max_sector = vmar->devinfo[dev_id].size/BDRV_SECTOR_SIZE;
|
||||
+ } else {
|
||||
@@ -682,7 +699,7 @@ index 0000000000..4f4ee2b47b
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (!verify) {
|
||||
+ if (!verify && !skip) {
|
||||
+ int nb_sectors = end_sector - sector_num;
|
||||
+ if (restore_write_data(vmar, dev_id, target, vmstate_fd,
|
||||
+ buf + start, sector_num, nb_sectors,
|
||||
@@ -718,7 +735,7 @@ index 0000000000..4f4ee2b47b
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (!verify) {
|
||||
+ if (!verify && !skip) {
|
||||
+ int nb_sectors = end_sector - sector_num;
|
||||
+ if (restore_write_data(vmar, dev_id, target, vmstate_fd,
|
||||
+ buf + start, sector_num,
|
||||
@@ -743,7 +760,7 @@ index 0000000000..4f4ee2b47b
|
||||
+ vmar->partial_zero_cluster_data += zero_size;
|
||||
+ }
|
||||
+
|
||||
+ if (rstate->write_zeroes && !verify) {
|
||||
+ if (rstate->write_zeroes && !verify && !skip) {
|
||||
+ if (restore_write_data(vmar, dev_id, target, vmstate_fd,
|
||||
+ zero_vma_block, sector_num,
|
||||
+ nb_sectors, errp) < 0) {
|
||||
@@ -914,7 +931,7 @@ index 0000000000..4f4ee2b47b
|
||||
+
|
||||
+ for (dev_id = 1; dev_id < 255; dev_id++) {
|
||||
+ if (vma_reader_get_device_info(vmar, dev_id)) {
|
||||
+ allocate_rstate(vmar, dev_id, NULL, false);
|
||||
+ allocate_rstate(vmar, dev_id, NULL, false, false);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -923,10 +940,10 @@ index 0000000000..4f4ee2b47b
|
||||
+
|
||||
diff --git a/vma-writer.c b/vma-writer.c
|
||||
new file mode 100644
|
||||
index 0000000000..11d8321ffd
|
||||
index 0000000000..a466652a5d
|
||||
--- /dev/null
|
||||
+++ b/vma-writer.c
|
||||
@@ -0,0 +1,790 @@
|
||||
@@ -0,0 +1,817 @@
|
||||
+/*
|
||||
+ * VMA: Virtual Machine Archive
|
||||
+ *
|
||||
@@ -942,6 +959,8 @@ index 0000000000..11d8321ffd
|
||||
+
|
||||
+#include "qemu/osdep.h"
|
||||
+#include <glib.h>
|
||||
+#include <linux/magic.h>
|
||||
+#include <sys/vfs.h>
|
||||
+#include <uuid/uuid.h>
|
||||
+
|
||||
+#include "vma.h"
|
||||
@@ -950,6 +969,8 @@ index 0000000000..11d8321ffd
|
||||
+#include "qemu/main-loop.h"
|
||||
+#include "qemu/coroutine.h"
|
||||
+#include "qemu/cutils.h"
|
||||
+#include "qemu/error-report.h"
|
||||
+#include "qemu/memalign.h"
|
||||
+
|
||||
+#define DEBUG_VMA 0
|
||||
+
|
||||
@@ -1132,10 +1153,10 @@ index 0000000000..11d8321ffd
|
||||
+{
|
||||
+ assert(qemu_in_coroutine());
|
||||
+ AioContext *ctx = qemu_get_current_aio_context();
|
||||
+ aio_set_fd_handler(ctx, fd, false, NULL, (IOHandler *)qemu_coroutine_enter,
|
||||
+ aio_set_fd_handler(ctx, fd, NULL, (IOHandler *)qemu_coroutine_enter, NULL,
|
||||
+ NULL, qemu_coroutine_self());
|
||||
+ qemu_coroutine_yield();
|
||||
+ aio_set_fd_handler(ctx, fd, false, NULL, NULL, NULL, NULL);
|
||||
+ aio_set_fd_handler(ctx, fd, NULL, NULL, NULL, NULL, NULL);
|
||||
+}
|
||||
+
|
||||
+static ssize_t coroutine_fn
|
||||
@@ -1184,6 +1205,23 @@ index 0000000000..11d8321ffd
|
||||
+ return (done == bytes) ? bytes : -1;
|
||||
+}
|
||||
+
|
||||
+static bool is_path_tmpfs(const char *path) {
|
||||
+ struct statfs fs;
|
||||
+ int ret;
|
||||
+
|
||||
+ do {
|
||||
+ ret = statfs(path, &fs);
|
||||
+ } while (ret != 0 && errno == EINTR);
|
||||
+
|
||||
+ if (ret != 0) {
|
||||
+ warn_report("statfs call for %s failed, assuming not tmpfs - %s\n",
|
||||
+ path, strerror(errno));
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return fs.f_type == TMPFS_MAGIC;
|
||||
+}
|
||||
+
|
||||
+VmaWriter *vma_writer_create(const char *filename, uuid_t uuid, Error **errp)
|
||||
+{
|
||||
+ const char *p;
|
||||
@@ -1233,12 +1271,19 @@ index 0000000000..11d8321ffd
|
||||
+ }
|
||||
+ /* try to use O_NONBLOCK */
|
||||
+ fcntl(vmaw->fd, F_SETFL, fcntl(vmaw->fd, F_GETFL)|O_NONBLOCK);
|
||||
+ } else {
|
||||
+ oflags = O_NONBLOCK|O_DIRECT|O_WRONLY|O_EXCL;
|
||||
+ } else {
|
||||
+ gchar *dirname = g_path_get_dirname(filename);
|
||||
+ oflags = O_NONBLOCK|O_WRONLY|O_EXCL;
|
||||
+ if (!is_path_tmpfs(dirname)) {
|
||||
+ oflags |= O_DIRECT;
|
||||
+ }
|
||||
+ g_free(dirname);
|
||||
+ vmaw->fd = qemu_create(filename, oflags, 0644, errp);
|
||||
+ }
|
||||
+
|
||||
+ if (vmaw->fd < 0) {
|
||||
+ error_free(*errp);
|
||||
+ *errp = NULL;
|
||||
+ error_setg(errp, "can't open file %s - %s\n", filename,
|
||||
+ g_strerror(errno));
|
||||
+ goto err;
|
||||
@@ -1473,17 +1518,16 @@ index 0000000000..11d8321ffd
|
||||
+ int i;
|
||||
+
|
||||
+ g_assert(vmaw != NULL);
|
||||
+ g_assert(status != NULL);
|
||||
+
|
||||
+ if (status) {
|
||||
+ status->status = vmaw->status;
|
||||
+ g_strlcpy(status->errmsg, vmaw->errmsg, sizeof(status->errmsg));
|
||||
+ for (i = 0; i <= 255; i++) {
|
||||
+ status->stream_info[i] = vmaw->stream_info[i];
|
||||
+ }
|
||||
+
|
||||
+ uuid_unparse_lower(vmaw->uuid, status->uuid_str);
|
||||
+ status->status = vmaw->status;
|
||||
+ g_strlcpy(status->errmsg, vmaw->errmsg, sizeof(status->errmsg));
|
||||
+ for (i = 0; i <= 255; i++) {
|
||||
+ status->stream_info[i] = vmaw->stream_info[i];
|
||||
+ }
|
||||
+
|
||||
+ uuid_unparse_lower(vmaw->uuid, status->uuid_str);
|
||||
+
|
||||
+ status->closed = vmaw->closed;
|
||||
+
|
||||
+ return vmaw->status;
|
||||
@@ -1719,10 +1763,10 @@ index 0000000000..11d8321ffd
|
||||
+}
|
||||
diff --git a/vma.c b/vma.c
|
||||
new file mode 100644
|
||||
index 0000000000..89440733b1
|
||||
index 0000000000..8d4b4be414
|
||||
--- /dev/null
|
||||
+++ b/vma.c
|
||||
@@ -0,0 +1,849 @@
|
||||
@@ -0,0 +1,941 @@
|
||||
+/*
|
||||
+ * VMA: Virtual Machine Archive
|
||||
+ *
|
||||
@@ -1740,11 +1784,11 @@ index 0000000000..89440733b1
|
||||
+#include <glib.h>
|
||||
+
|
||||
+#include "vma.h"
|
||||
+#include "qemu-common.h"
|
||||
+#include "qemu/module.h"
|
||||
+#include "qemu/error-report.h"
|
||||
+#include "qemu/main-loop.h"
|
||||
+#include "qemu/cutils.h"
|
||||
+#include "qemu/memalign.h"
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
+#include "sysemu/block-backend.h"
|
||||
+
|
||||
@@ -1754,9 +1798,9 @@ index 0000000000..89440733b1
|
||||
+ "usage: vma command [command options]\n"
|
||||
+ "\n"
|
||||
+ "vma list <filename>\n"
|
||||
+ "vma config <filename> [-c config]\n"
|
||||
+ "vma create <filename> [-c config] pathname ...\n"
|
||||
+ "vma extract <filename> [-r <fifo>] <targetdir>\n"
|
||||
+ "vma config <filename> [-c <config>]\n"
|
||||
+ "vma create <filename> [-c <config>] [-d format=<format>:<device name>=<path> [-d ...]]\n"
|
||||
+ "vma extract <filename> [-d <drive-list>] [-r <fifo>] <targetdir>\n"
|
||||
+ "vma verify <filename> [-v]\n"
|
||||
+ ;
|
||||
+
|
||||
@@ -1863,6 +1907,7 @@ index 0000000000..89440733b1
|
||||
+ char *throttling_group;
|
||||
+ char *cache;
|
||||
+ bool write_zero;
|
||||
+ bool skip;
|
||||
+} RestoreMap;
|
||||
+
|
||||
+static bool try_parse_option(char **line, const char *optname, char **out, const char *inbuf) {
|
||||
@@ -1900,9 +1945,10 @@ index 0000000000..89440733b1
|
||||
+ const char *filename;
|
||||
+ const char *dirname;
|
||||
+ const char *readmap = NULL;
|
||||
+ gchar **drive_list = NULL;
|
||||
+
|
||||
+ for (;;) {
|
||||
+ c = getopt(argc, argv, "hvr:");
|
||||
+ c = getopt(argc, argv, "hvd:r:");
|
||||
+ if (c == -1) {
|
||||
+ break;
|
||||
+ }
|
||||
@@ -1911,6 +1957,9 @@ index 0000000000..89440733b1
|
||||
+ case 'h':
|
||||
+ help();
|
||||
+ break;
|
||||
+ case 'd':
|
||||
+ drive_list = g_strsplit(optarg, ",", 254);
|
||||
+ break;
|
||||
+ case 'r':
|
||||
+ readmap = optarg;
|
||||
+ break;
|
||||
@@ -1970,74 +2019,89 @@ index 0000000000..89440733b1
|
||||
+ char *bps = NULL;
|
||||
+ char *group = NULL;
|
||||
+ char *cache = NULL;
|
||||
+ char *devname = NULL;
|
||||
+ bool skip = false;
|
||||
+ uint64_t bps_value = 0;
|
||||
+ const char *path = NULL;
|
||||
+ bool write_zero = true;
|
||||
+
|
||||
+ if (!line || line[0] == '\0' || !strcmp(line, "done\n")) {
|
||||
+ break;
|
||||
+ }
|
||||
+ int len = strlen(line);
|
||||
+ if (line[len - 1] == '\n') {
|
||||
+ line[len - 1] = '\0';
|
||||
+ if (len == 1) {
|
||||
+ len = len - 1;
|
||||
+ if (len == 0) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ while (1) {
|
||||
+ if (!try_parse_option(&line, "format", &format, inbuf) &&
|
||||
+ !try_parse_option(&line, "throttling.bps", &bps, inbuf) &&
|
||||
+ !try_parse_option(&line, "throttling.group", &group, inbuf) &&
|
||||
+ !try_parse_option(&line, "cache", &cache, inbuf))
|
||||
+ {
|
||||
+ break;
|
||||
+ if (strncmp(line, "skip", 4) == 0) {
|
||||
+ if (len < 6 || line[4] != '=') {
|
||||
+ g_error("read map failed - option 'skip' has no value ('%s')",
|
||||
+ inbuf);
|
||||
+ } else {
|
||||
+ devname = line + 5;
|
||||
+ skip = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ uint64_t bps_value = 0;
|
||||
+ if (bps) {
|
||||
+ bps_value = verify_u64(bps);
|
||||
+ g_free(bps);
|
||||
+ }
|
||||
+
|
||||
+ const char *path;
|
||||
+ bool write_zero;
|
||||
+ if (line[0] == '0' && line[1] == ':') {
|
||||
+ path = line + 2;
|
||||
+ write_zero = false;
|
||||
+ } else if (line[0] == '1' && line[1] == ':') {
|
||||
+ path = line + 2;
|
||||
+ write_zero = true;
|
||||
+ } else {
|
||||
+ g_error("read map failed - parse error ('%s')", inbuf);
|
||||
+ while (1) {
|
||||
+ if (!try_parse_option(&line, "format", &format, inbuf) &&
|
||||
+ !try_parse_option(&line, "throttling.bps", &bps, inbuf) &&
|
||||
+ !try_parse_option(&line, "throttling.group", &group, inbuf) &&
|
||||
+ !try_parse_option(&line, "cache", &cache, inbuf))
|
||||
+ {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (bps) {
|
||||
+ bps_value = verify_u64(bps);
|
||||
+ g_free(bps);
|
||||
+ }
|
||||
+
|
||||
+ if (line[0] == '0' && line[1] == ':') {
|
||||
+ path = line + 2;
|
||||
+ write_zero = false;
|
||||
+ } else if (line[0] == '1' && line[1] == ':') {
|
||||
+ path = line + 2;
|
||||
+ write_zero = true;
|
||||
+ } else {
|
||||
+ g_error("read map failed - parse error ('%s')", inbuf);
|
||||
+ }
|
||||
+
|
||||
+ path = extract_devname(path, &devname, -1);
|
||||
+ }
|
||||
+
|
||||
+ char *devname = NULL;
|
||||
+ path = extract_devname(path, &devname, -1);
|
||||
+ if (!devname) {
|
||||
+ g_error("read map failed - no dev name specified ('%s')",
|
||||
+ inbuf);
|
||||
+ }
|
||||
+
|
||||
+ RestoreMap *map = g_new0(RestoreMap, 1);
|
||||
+ map->devname = g_strdup(devname);
|
||||
+ map->path = g_strdup(path);
|
||||
+ map->format = format;
|
||||
+ map->throttling_bps = bps_value;
|
||||
+ map->throttling_group = group;
|
||||
+ map->cache = cache;
|
||||
+ map->write_zero = write_zero;
|
||||
+ RestoreMap *restore_map = g_new0(RestoreMap, 1);
|
||||
+ restore_map->devname = g_strdup(devname);
|
||||
+ restore_map->path = g_strdup(path);
|
||||
+ restore_map->format = format;
|
||||
+ restore_map->throttling_bps = bps_value;
|
||||
+ restore_map->throttling_group = group;
|
||||
+ restore_map->cache = cache;
|
||||
+ restore_map->write_zero = write_zero;
|
||||
+ restore_map->skip = skip;
|
||||
+
|
||||
+ g_hash_table_insert(devmap, map->devname, map);
|
||||
+ g_hash_table_insert(devmap, restore_map->devname, restore_map);
|
||||
+
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ int i;
|
||||
+ int vmstate_fd = -1;
|
||||
+ guint8 vmstate_stream = 0;
|
||||
+ bool drive_rename_bitmap[255];
|
||||
+ memset(drive_rename_bitmap, 0, sizeof(drive_rename_bitmap));
|
||||
+
|
||||
+ for (i = 1; i < 255; i++) {
|
||||
+ VmaDeviceInfo *di = vma_reader_get_device_info(vmar, i);
|
||||
+ if (di && (strcmp(di->devname, "vmstate") == 0)) {
|
||||
+ vmstate_stream = i;
|
||||
+ char *statefn = g_strdup_printf("%s/vmstate.bin", dirname);
|
||||
+ vmstate_fd = open(statefn, O_WRONLY|O_CREAT|O_EXCL, 0644);
|
||||
+ if (vmstate_fd < 0) {
|
||||
@@ -2053,10 +2117,25 @@ index 0000000000..89440733b1
|
||||
+ const char *cache = NULL;
|
||||
+ int flags = BDRV_O_RDWR;
|
||||
+ bool write_zero = true;
|
||||
+ bool skip = false;
|
||||
+
|
||||
+ BlockBackend *blk = NULL;
|
||||
+
|
||||
+ if (readmap) {
|
||||
+ if (drive_list) {
|
||||
+ skip = true;
|
||||
+ int j;
|
||||
+ for (j = 0; drive_list[j]; j++) {
|
||||
+ if (strcmp(drive_list[j], di->devname) == 0) {
|
||||
+ skip = false;
|
||||
+ drive_rename_bitmap[i] = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ drive_rename_bitmap[i] = true;
|
||||
+ }
|
||||
+
|
||||
+ if (!skip && readmap) {
|
||||
+ RestoreMap *map;
|
||||
+ map = (RestoreMap *)g_hash_table_lookup(devmap, di->devname);
|
||||
+ if (map == NULL) {
|
||||
@@ -2068,7 +2147,8 @@ index 0000000000..89440733b1
|
||||
+ throttling_group = map->throttling_group;
|
||||
+ cache = map->cache;
|
||||
+ write_zero = map->write_zero;
|
||||
+ } else {
|
||||
+ skip = map->skip;
|
||||
+ } else if (!skip) {
|
||||
+ devfn = g_strdup_printf("%s/tmp-disk-%s.raw",
|
||||
+ dirname, di->devname);
|
||||
+ printf("DEVINFO %s %zd\n", devfn, di->size);
|
||||
@@ -2086,57 +2166,60 @@ index 0000000000..89440733b1
|
||||
+ write_zero = false;
|
||||
+ }
|
||||
+
|
||||
+ size_t devlen = strlen(devfn);
|
||||
+ QDict *options = NULL;
|
||||
+ bool writethrough;
|
||||
+ if (format) {
|
||||
+ /* explicit format from commandline */
|
||||
+ options = qdict_new();
|
||||
+ qdict_put_str(options, "driver", format);
|
||||
+ } else if ((devlen > 4 && strcmp(devfn+devlen-4, ".raw") == 0) ||
|
||||
+ strncmp(devfn, "/dev/", 5) == 0)
|
||||
+ {
|
||||
+ /* This part is now deprecated for PVE as well (just as qemu
|
||||
+ * deprecated not specifying an explicit raw format, too.
|
||||
+ */
|
||||
+ /* explicit raw format */
|
||||
+ options = qdict_new();
|
||||
+ qdict_put_str(options, "driver", "raw");
|
||||
+ }
|
||||
+ if (cache && bdrv_parse_cache_mode(cache, &flags, &writethrough)) {
|
||||
+ g_error("invalid cache option: %s\n", cache);
|
||||
+ }
|
||||
+
|
||||
+ if (errp || !(blk = blk_new_open(devfn, NULL, options, flags, &errp))) {
|
||||
+ g_error("can't open file %s - %s", devfn,
|
||||
+ error_get_pretty(errp));
|
||||
+ }
|
||||
+
|
||||
+ if (cache) {
|
||||
+ blk_set_enable_write_cache(blk, !writethrough);
|
||||
+ }
|
||||
+
|
||||
+ if (throttling_group) {
|
||||
+ blk_io_limits_enable(blk, throttling_group);
|
||||
+ }
|
||||
+
|
||||
+ if (throttling_bps) {
|
||||
+ if (!throttling_group) {
|
||||
+ blk_io_limits_enable(blk, devfn);
|
||||
+ if (!skip) {
|
||||
+ size_t devlen = strlen(devfn);
|
||||
+ QDict *options = NULL;
|
||||
+ bool writethrough;
|
||||
+ if (format) {
|
||||
+ /* explicit format from commandline */
|
||||
+ options = qdict_new();
|
||||
+ qdict_put_str(options, "driver", format);
|
||||
+ } else if ((devlen > 4 && strcmp(devfn+devlen-4, ".raw") == 0) ||
|
||||
+ strncmp(devfn, "/dev/", 5) == 0)
|
||||
+ {
|
||||
+ /* This part is now deprecated for PVE as well (just as qemu
|
||||
+ * deprecated not specifying an explicit raw format, too.
|
||||
+ */
|
||||
+ /* explicit raw format */
|
||||
+ options = qdict_new();
|
||||
+ qdict_put_str(options, "driver", "raw");
|
||||
+ }
|
||||
+
|
||||
+ ThrottleConfig cfg;
|
||||
+ throttle_config_init(&cfg);
|
||||
+ cfg.buckets[THROTTLE_BPS_WRITE].avg = throttling_bps;
|
||||
+ Error *err = NULL;
|
||||
+ if (!throttle_is_valid(&cfg, &err)) {
|
||||
+ error_report_err(err);
|
||||
+ g_error("failed to apply throttling");
|
||||
+ if (cache && bdrv_parse_cache_mode(cache, &flags, &writethrough)) {
|
||||
+ g_error("invalid cache option: %s\n", cache);
|
||||
+ }
|
||||
+
|
||||
+ if (errp || !(blk = blk_new_open(devfn, NULL, options, flags, &errp))) {
|
||||
+ g_error("can't open file %s - %s", devfn,
|
||||
+ error_get_pretty(errp));
|
||||
+ }
|
||||
+
|
||||
+ if (cache) {
|
||||
+ blk_set_enable_write_cache(blk, !writethrough);
|
||||
+ }
|
||||
+
|
||||
+ if (throttling_group) {
|
||||
+ blk_io_limits_enable(blk, throttling_group);
|
||||
+ }
|
||||
+
|
||||
+ if (throttling_bps) {
|
||||
+ if (!throttling_group) {
|
||||
+ blk_io_limits_enable(blk, devfn);
|
||||
+ }
|
||||
+
|
||||
+ ThrottleConfig cfg;
|
||||
+ throttle_config_init(&cfg);
|
||||
+ cfg.buckets[THROTTLE_BPS_WRITE].avg = throttling_bps;
|
||||
+ Error *err = NULL;
|
||||
+ if (!throttle_is_valid(&cfg, &err)) {
|
||||
+ error_report_err(err);
|
||||
+ g_error("failed to apply throttling");
|
||||
+ }
|
||||
+ blk_set_io_limits(blk, &cfg);
|
||||
+ }
|
||||
+ blk_set_io_limits(blk, &cfg);
|
||||
+ }
|
||||
+
|
||||
+ if (vma_reader_register_bs(vmar, i, blk, write_zero, &errp) < 0) {
|
||||
+ if (vma_reader_register_bs(vmar, i, blk, write_zero, skip, &errp) < 0) {
|
||||
+ g_error("%s", error_get_pretty(errp));
|
||||
+ }
|
||||
+
|
||||
@@ -2146,6 +2229,10 @@ index 0000000000..89440733b1
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (drive_list) {
|
||||
+ g_strfreev(drive_list);
|
||||
+ }
|
||||
+
|
||||
+ if (vma_reader_restore(vmar, vmstate_fd, verbose, &errp) < 0) {
|
||||
+ g_error("restore failed - %s", error_get_pretty(errp));
|
||||
+ }
|
||||
@@ -2153,7 +2240,7 @@ index 0000000000..89440733b1
|
||||
+ if (!readmap) {
|
||||
+ for (i = 1; i < 255; i++) {
|
||||
+ VmaDeviceInfo *di = vma_reader_get_device_info(vmar, i);
|
||||
+ if (di && (i != vmstate_stream)) {
|
||||
+ if (di && drive_rename_bitmap[i]) {
|
||||
+ char *tmpfn = g_strdup_printf("%s/tmp-disk-%s.raw",
|
||||
+ dirname, di->devname);
|
||||
+ char *fn = g_strdup_printf("%s/disk-%s.raw",
|
||||
@@ -2252,7 +2339,7 @@ index 0000000000..89440733b1
|
||||
+ struct iovec iov;
|
||||
+ QEMUIOVector qiov;
|
||||
+
|
||||
+ int64_t start, end;
|
||||
+ int64_t start, end, readlen;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ unsigned char *buf = blk_blockalign(job->target, VMA_CLUSTER_SIZE);
|
||||
@@ -2266,16 +2353,24 @@ index 0000000000..89440733b1
|
||||
+ iov.iov_len = VMA_CLUSTER_SIZE;
|
||||
+ qemu_iovec_init_external(&qiov, &iov, 1);
|
||||
+
|
||||
+ if (start + 1 == end) {
|
||||
+ memset(buf, 0, VMA_CLUSTER_SIZE);
|
||||
+ readlen = job->len - start * VMA_CLUSTER_SIZE;
|
||||
+ assert(readlen > 0 && readlen <= VMA_CLUSTER_SIZE);
|
||||
+ } else {
|
||||
+ readlen = VMA_CLUSTER_SIZE;
|
||||
+ }
|
||||
+
|
||||
+ ret = blk_co_preadv(job->target, start * VMA_CLUSTER_SIZE,
|
||||
+ VMA_CLUSTER_SIZE, &qiov, 0);
|
||||
+ readlen, &qiov, 0);
|
||||
+ if (ret < 0) {
|
||||
+ vma_writer_set_error(job->vmaw, "read error", -1);
|
||||
+ vma_writer_set_error(job->vmaw, "read error");
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ size_t zb = 0;
|
||||
+ if (vma_writer_write(job->vmaw, job->dev_id, start, buf, &zb) < 0) {
|
||||
+ vma_writer_set_error(job->vmaw, "backup_dump_cb vma_writer_write failed", -1);
|
||||
+ vma_writer_set_error(job->vmaw, "backup_dump_cb vma_writer_write failed");
|
||||
+ goto out;
|
||||
+ }
|
||||
+ }
|
||||
@@ -2293,14 +2388,16 @@ index 0000000000..89440733b1
|
||||
+
|
||||
+static int create_archive(int argc, char **argv)
|
||||
+{
|
||||
+ int i, c;
|
||||
+ int c;
|
||||
+ int verbose = 0;
|
||||
+ bool expect_format = true;
|
||||
+ const char *archivename;
|
||||
+ GList *backup_coroutines = NULL;
|
||||
+ GList *config_files = NULL;
|
||||
+ GList *disk_infos = NULL;
|
||||
+
|
||||
+ for (;;) {
|
||||
+ c = getopt(argc, argv, "hvc:");
|
||||
+ c = getopt(argc, argv, "hvc:d:");
|
||||
+ if (c == -1) {
|
||||
+ break;
|
||||
+ }
|
||||
@@ -2312,6 +2409,9 @@ index 0000000000..89440733b1
|
||||
+ case 'c':
|
||||
+ config_files = g_list_append(config_files, optarg);
|
||||
+ break;
|
||||
+ case 'd':
|
||||
+ disk_infos = g_list_append(disk_infos, optarg);
|
||||
+ break;
|
||||
+ case 'v':
|
||||
+ verbose = 1;
|
||||
+ break;
|
||||
@@ -2357,16 +2457,48 @@ index 0000000000..89440733b1
|
||||
+ l = g_list_next(l);
|
||||
+ }
|
||||
+
|
||||
+ int devcount = 0;
|
||||
+ /*
|
||||
+ * Don't allow mixing new and old way to specifiy disks.
|
||||
+ * TODO PVE 9 drop old way and always require format.
|
||||
+ */
|
||||
+ if (optind < argc && g_list_first(disk_infos)) {
|
||||
+ unlink(archivename);
|
||||
+ g_error("Unexpected extra argument - specify all devices via '-d'");
|
||||
+ }
|
||||
+
|
||||
+ while (optind < argc) {
|
||||
+ const char *path = argv[optind++];
|
||||
+ expect_format = false;
|
||||
+ disk_infos = g_list_append(disk_infos, argv[optind++]);
|
||||
+ }
|
||||
+
|
||||
+ int devcount = 0;
|
||||
+ GList *disk_l = disk_infos;
|
||||
+ while (disk_l && disk_l->data) {
|
||||
+ char *disk_info = disk_l->data;
|
||||
+ const char *path = NULL;
|
||||
+ char *devname = NULL;
|
||||
+ path = extract_devname(path, &devname, devcount++);
|
||||
+ char *format = NULL;
|
||||
+ QDict *options = qdict_new();
|
||||
+
|
||||
+ if (try_parse_option(&disk_info, "format", &format, disk_info)) {
|
||||
+ qdict_put_str(options, "driver", format);
|
||||
+ } else {
|
||||
+ if (expect_format) {
|
||||
+ unlink(archivename);
|
||||
+ g_error("No format specified for device: '%s'", disk_info);
|
||||
+ } else {
|
||||
+ g_warning("Specifying a device without a format is deprecated"
|
||||
+ " - use '-d format=<format>:%s'",
|
||||
+ disk_info);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ path = extract_devname(disk_info, &devname, devcount++);
|
||||
+
|
||||
+ Error *errp = NULL;
|
||||
+ BlockBackend *target;
|
||||
+
|
||||
+ target = blk_new_open(path, NULL, NULL, 0, &errp);
|
||||
+ target = blk_new_open(path, NULL, options, 0, &errp);
|
||||
+ if (!target) {
|
||||
+ unlink(archivename);
|
||||
+ g_error("bdrv_open '%s' failed - %s", path, error_get_pretty(errp));
|
||||
@@ -2388,6 +2520,8 @@ index 0000000000..89440733b1
|
||||
+ // Don't enter coroutine yet, because it might write the header before
|
||||
+ // all streams can be registered.
|
||||
+ backup_coroutines = g_list_append(backup_coroutines, co);
|
||||
+
|
||||
+ disk_l = g_list_next(disk_l);
|
||||
+ }
|
||||
+
|
||||
+ VmaStatus vmastat;
|
||||
@@ -2451,6 +2585,7 @@ index 0000000000..89440733b1
|
||||
+ vma_writer_get_status(vmaw, &vmastat);
|
||||
+
|
||||
+ if (verbose) {
|
||||
+ int i;
|
||||
+ for (i = 0; i < 256; i++) {
|
||||
+ VmaStreamInfo *si = &vmastat.stream_info[i];
|
||||
+ if (si->size) {
|
||||
@@ -2468,6 +2603,7 @@ index 0000000000..89440733b1
|
||||
+
|
||||
+ g_list_free(backup_coroutines);
|
||||
+ g_list_free(config_files);
|
||||
+ g_list_free(disk_infos);
|
||||
+ vma_writer_destroy(vmaw);
|
||||
+ return 0;
|
||||
+}
|
||||
@@ -2574,7 +2710,7 @@ index 0000000000..89440733b1
|
||||
+}
|
||||
diff --git a/vma.h b/vma.h
|
||||
new file mode 100644
|
||||
index 0000000000..c895c97f6d
|
||||
index 0000000000..86d2873aa5
|
||||
--- /dev/null
|
||||
+++ b/vma.h
|
||||
@@ -0,0 +1,150 @@
|
||||
@@ -2712,7 +2848,7 @@ index 0000000000..c895c97f6d
|
||||
+int coroutine_fn vma_writer_flush_output(VmaWriter *vmaw);
|
||||
+
|
||||
+int vma_writer_get_status(VmaWriter *vmaw, VmaStatus *status);
|
||||
+void vma_writer_set_error(VmaWriter *vmaw, const char *fmt, ...);
|
||||
+void vma_writer_set_error(VmaWriter *vmaw, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
|
||||
+
|
||||
+
|
||||
+VmaReader *vma_reader_create(const char *filename, Error **errp);
|
||||
@@ -2722,7 +2858,7 @@ index 0000000000..c895c97f6d
|
||||
+VmaDeviceInfo *vma_reader_get_device_info(VmaReader *vmar, guint8 dev_id);
|
||||
+int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id,
|
||||
+ BlockBackend *target, bool write_zeroes,
|
||||
+ Error **errp);
|
||||
+ bool skip, Error **errp);
|
||||
+int vma_reader_restore(VmaReader *vmar, int vmstate_fd, bool verbose,
|
||||
+ Error **errp);
|
||||
+int vma_reader_verify(VmaReader *vmar, bool verbose, Error **errp);
|
@@ -9,21 +9,23 @@ Subject: [PATCH] PVE-Backup: add backup-dump block driver
|
||||
- job.c: make job_should_pause non-static
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: adapt to coroutine changes]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/backup-dump.c | 168 ++++++++++++++++++++++++++++++++++++++
|
||||
block/backup.c | 30 ++-----
|
||||
block/meson.build | 1 +
|
||||
include/block/block_int.h | 35 ++++++++
|
||||
job.c | 3 +-
|
||||
5 files changed, 214 insertions(+), 23 deletions(-)
|
||||
block/backup-dump.c | 172 +++++++++++++++++++++++++++++++
|
||||
block/backup.c | 30 ++----
|
||||
block/meson.build | 1 +
|
||||
include/block/block_int-common.h | 35 +++++++
|
||||
job.c | 3 +-
|
||||
5 files changed, 218 insertions(+), 23 deletions(-)
|
||||
create mode 100644 block/backup-dump.c
|
||||
|
||||
diff --git a/block/backup-dump.c b/block/backup-dump.c
|
||||
new file mode 100644
|
||||
index 0000000000..93d7f46950
|
||||
index 0000000000..e46abf1070
|
||||
--- /dev/null
|
||||
+++ b/block/backup-dump.c
|
||||
@@ -0,0 +1,168 @@
|
||||
@@ -0,0 +1,172 @@
|
||||
+/*
|
||||
+ * BlockDriver to send backup data stream to a callback function
|
||||
+ *
|
||||
@@ -35,7 +37,8 @@ index 0000000000..93d7f46950
|
||||
+ */
|
||||
+
|
||||
+#include "qemu/osdep.h"
|
||||
+#include "qemu-common.h"
|
||||
+
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
+#include "qom/object_interfaces.h"
|
||||
+#include "block/block_int.h"
|
||||
+
|
||||
@@ -46,7 +49,8 @@ index 0000000000..93d7f46950
|
||||
+ void *dump_cb_data;
|
||||
+} BDRVBackupDumpState;
|
||||
+
|
||||
+static int qemu_backup_dump_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
|
||||
+static coroutine_fn int qemu_backup_dump_co_get_info(BlockDriverState *bs,
|
||||
+ BlockDriverInfo *bdi)
|
||||
+{
|
||||
+ BDRVBackupDumpState *s = bs->opaque;
|
||||
+
|
||||
@@ -87,7 +91,7 @@ index 0000000000..93d7f46950
|
||||
+ /* Nothing to do. */
|
||||
+}
|
||||
+
|
||||
+static int64_t qemu_backup_dump_getlength(BlockDriverState *bs)
|
||||
+static coroutine_fn int64_t qemu_backup_dump_co_getlength(BlockDriverState *bs)
|
||||
+{
|
||||
+ BDRVBackupDumpState *s = bs->opaque;
|
||||
+
|
||||
@@ -147,8 +151,8 @@ index 0000000000..93d7f46950
|
||||
+
|
||||
+ .bdrv_close = qemu_backup_dump_close,
|
||||
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
||||
+ .bdrv_getlength = qemu_backup_dump_getlength,
|
||||
+ .bdrv_get_info = qemu_backup_dump_get_info,
|
||||
+ .bdrv_co_getlength = qemu_backup_dump_co_getlength,
|
||||
+ .bdrv_co_get_info = qemu_backup_dump_co_get_info,
|
||||
+
|
||||
+ .bdrv_co_writev = qemu_backup_dump_co_writev,
|
||||
+
|
||||
@@ -167,7 +171,7 @@ index 0000000000..93d7f46950
|
||||
+block_init(bdrv_backup_dump_init);
|
||||
+
|
||||
+
|
||||
+BlockDriverState *bdrv_backup_dump_create(
|
||||
+BlockDriverState *coroutine_fn bdrv_co_backup_dump_create(
|
||||
+ int dump_cb_block_size,
|
||||
+ uint64_t byte_size,
|
||||
+ BackupDumpFunc *dump_cb,
|
||||
@@ -175,9 +179,11 @@ index 0000000000..93d7f46950
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ BDRVBackupDumpState *state;
|
||||
+ BlockDriverState *bs = bdrv_new_open_driver(
|
||||
+ &bdrv_backup_dump_drive, NULL, BDRV_O_RDWR, errp);
|
||||
+
|
||||
+ QDict *options = qdict_new();
|
||||
+ qdict_put_str(options, "driver", "backup-dump-drive");
|
||||
+
|
||||
+ BlockDriverState *bs = bdrv_co_open(NULL, NULL, options, BDRV_O_RDWR, errp);
|
||||
+ if (!bs) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
@@ -193,7 +199,7 @@ index 0000000000..93d7f46950
|
||||
+ return bs;
|
||||
+}
|
||||
diff --git a/block/backup.c b/block/backup.c
|
||||
index 47e218857d..4d8fad70c4 100644
|
||||
index eba5b11493..1963e47ab9 100644
|
||||
--- a/block/backup.c
|
||||
+++ b/block/backup.c
|
||||
@@ -29,28 +29,6 @@
|
||||
@@ -225,7 +231,7 @@ index 47e218857d..4d8fad70c4 100644
|
||||
static const BlockJobDriver backup_job_driver;
|
||||
|
||||
static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret)
|
||||
@@ -455,6 +433,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
@@ -462,6 +440,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
}
|
||||
|
||||
cluster_size = block_copy_cluster_size(bcs);
|
||||
@@ -241,7 +247,7 @@ index 47e218857d..4d8fad70c4 100644
|
||||
if (perf->max_chunk && perf->max_chunk < cluster_size) {
|
||||
error_setg(errp, "Required max-chunk (%" PRIi64 ") is less than backup "
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index 72081a9974..7883df047c 100644
|
||||
index b245daa98e..e99914eaa4 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -4,6 +4,7 @@ block_ss.add(files(
|
||||
@@ -249,28 +255,28 @@ index 72081a9974..7883df047c 100644
|
||||
'amend.c',
|
||||
'backup.c',
|
||||
+ 'backup-dump.c',
|
||||
'copy-before-write.c',
|
||||
'blkdebug.c',
|
||||
'blklogwrites.c',
|
||||
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
||||
index f4c75e8ba9..169dc43d59 100644
|
||||
--- a/include/block/block_int.h
|
||||
+++ b/include/block/block_int.h
|
||||
'blkverify.c',
|
||||
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
|
||||
index 761276127e..b3e6697613 100644
|
||||
--- a/include/block/block_int-common.h
|
||||
+++ b/include/block/block_int-common.h
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "block/accounting.h"
|
||||
#include "block/block.h"
|
||||
#include "block/aio.h"
|
||||
#include "block/block-common.h"
|
||||
+#include "block/block-copy.h"
|
||||
#include "block/aio-wait.h"
|
||||
#include "qemu/queue.h"
|
||||
#include "qemu/coroutine.h"
|
||||
@@ -64,6 +65,40 @@
|
||||
#include "block/block-global-state.h"
|
||||
#include "block/snapshot.h"
|
||||
#include "qemu/iov.h"
|
||||
@@ -60,6 +61,40 @@
|
||||
|
||||
#define BLOCK_PROBE_BUF_SIZE 512
|
||||
|
||||
+typedef int BackupDumpFunc(void *opaque, uint64_t offset, uint64_t bytes, const void *buf);
|
||||
+
|
||||
+BlockDriverState *bdrv_backuo_dump_create(
|
||||
+BlockDriverState *coroutine_fn bdrv_co_backup_dump_create(
|
||||
+ int dump_cb_block_size,
|
||||
+ uint64_t byte_size,
|
||||
+ BackupDumpFunc *dump_cb,
|
||||
@@ -306,16 +312,16 @@ index f4c75e8ba9..169dc43d59 100644
|
||||
BDRV_TRACKED_READ,
|
||||
BDRV_TRACKED_WRITE,
|
||||
diff --git a/job.c b/job.c
|
||||
index dbfa67bb0a..af25dd5b98 100644
|
||||
index 660ce22c56..baf54c8d60 100644
|
||||
--- a/job.c
|
||||
+++ b/job.c
|
||||
@@ -276,7 +276,8 @@ static bool job_started(Job *job)
|
||||
return job->co;
|
||||
@@ -331,7 +331,8 @@ static bool job_started_locked(Job *job)
|
||||
}
|
||||
|
||||
-static bool job_should_pause(Job *job)
|
||||
+bool job_should_pause(Job *job);
|
||||
+bool job_should_pause(Job *job)
|
||||
/* Called with job_mutex held. */
|
||||
-static bool job_should_pause_locked(Job *job)
|
||||
+bool job_should_pause_locked(Job *job);
|
||||
+bool job_should_pause_locked(Job *job)
|
||||
{
|
||||
return job->pause_count > 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -7,14 +7,14 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
include/qemu/job.h | 12 ++++++++++++
|
||||
job.c | 31 +++++++++++++++++++++++++++++++
|
||||
2 files changed, 43 insertions(+)
|
||||
job.c | 34 ++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 46 insertions(+)
|
||||
|
||||
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
||||
index 6e67b6977f..60376c99ee 100644
|
||||
index 2b873f2576..528cd6acb9 100644
|
||||
--- a/include/qemu/job.h
|
||||
+++ b/include/qemu/job.h
|
||||
@@ -294,6 +294,18 @@ typedef enum JobCreateFlags {
|
||||
@@ -362,6 +362,18 @@ void job_unlock(void);
|
||||
*/
|
||||
JobTxn *job_txn_new(void);
|
||||
|
||||
@@ -34,10 +34,10 @@ index 6e67b6977f..60376c99ee 100644
|
||||
* Release a reference that was previously acquired with job_txn_add_job or
|
||||
* job_txn_new. If it's the last reference to the object, it will be freed.
|
||||
diff --git a/job.c b/job.c
|
||||
index af25dd5b98..d0d152e697 100644
|
||||
index baf54c8d60..3ac5e5cde2 100644
|
||||
--- a/job.c
|
||||
+++ b/job.c
|
||||
@@ -72,6 +72,8 @@ struct JobTxn {
|
||||
@@ -94,6 +94,8 @@ struct JobTxn {
|
||||
|
||||
/* Reference count */
|
||||
int refcnt;
|
||||
@@ -45,8 +45,8 @@ index af25dd5b98..d0d152e697 100644
|
||||
+ bool sequential;
|
||||
};
|
||||
|
||||
/* Right now, this mutex is only needed to synchronize accesses to job->busy
|
||||
@@ -102,6 +104,25 @@ JobTxn *job_txn_new(void)
|
||||
void job_lock(void)
|
||||
@@ -119,6 +121,25 @@ JobTxn *job_txn_new(void)
|
||||
return txn;
|
||||
}
|
||||
|
||||
@@ -69,20 +69,23 @@ index af25dd5b98..d0d152e697 100644
|
||||
+ job_start(first);
|
||||
+}
|
||||
+
|
||||
static void job_txn_ref(JobTxn *txn)
|
||||
/* Called with job_mutex held. */
|
||||
static void job_txn_ref_locked(JobTxn *txn)
|
||||
{
|
||||
txn->refcnt++;
|
||||
@@ -888,6 +909,9 @@ static void job_completed_txn_success(Job *job)
|
||||
@@ -1042,6 +1063,12 @@ static void job_completed_txn_success_locked(Job *job)
|
||||
*/
|
||||
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
|
||||
if (!job_is_completed(other_job)) {
|
||||
if (!job_is_completed_locked(other_job)) {
|
||||
+ if (txn->sequential) {
|
||||
+ job_unlock();
|
||||
+ /* Needs to be called without holding the job lock */
|
||||
+ job_start(other_job);
|
||||
+ job_lock();
|
||||
+ }
|
||||
return;
|
||||
}
|
||||
assert(other_job->ret == 0);
|
||||
@@ -1082,6 +1106,13 @@ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
|
||||
@@ -1253,6 +1280,13 @@ int job_finish_sync_locked(Job *job,
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
@@ -90,9 +93,9 @@ index af25dd5b98..d0d152e697 100644
|
||||
+ * of cancelling, these have not begun work so job_enter won't do anything,
|
||||
+ * let's ensure they are marked as ABORTING if required */
|
||||
+ if (job->status == JOB_STATUS_CREATED && job->txn->sequential) {
|
||||
+ job_update_rc(job);
|
||||
+ job_update_rc_locked(job);
|
||||
+ }
|
||||
+
|
||||
AIO_WAIT_WHILE(job->aio_context,
|
||||
(job_enter(job), !job_is_completed(job)));
|
||||
|
||||
job_unlock();
|
||||
AIO_WAIT_WHILE_UNLOCKED(job->aio_context,
|
||||
(job_enter(job), !job_is_completed(job)));
|
@@ -1,452 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Mon, 29 Jun 2020 11:06:03 +0200
|
||||
Subject: [PATCH] PVE-Backup: Add dirty-bitmap tracking for incremental backups
|
||||
|
||||
Uses QEMU's existing MIRROR_SYNC_MODE_BITMAP and a dirty-bitmap on top
|
||||
of all backed-up drives. This will only execute the data-write callback
|
||||
for any changed chunks, the PBS rust code will reuse chunks from the
|
||||
previous index for everything it doesn't receive if reuse_index is true.
|
||||
|
||||
On error or cancellation, remove all dirty bitmaps to ensure
|
||||
consistency.
|
||||
|
||||
Add PBS/incremental specific information to query backup info QMP and
|
||||
HMP commands.
|
||||
|
||||
Only supported for PBS backups.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/monitor/block-hmp-cmds.c | 1 +
|
||||
monitor/hmp-cmds.c | 45 ++++++++++----
|
||||
proxmox-backup-client.c | 3 +-
|
||||
proxmox-backup-client.h | 1 +
|
||||
pve-backup.c | 103 ++++++++++++++++++++++++++++++---
|
||||
qapi/block-core.json | 12 +++-
|
||||
6 files changed, 142 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index f6668ab01d..3c06734e6d 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1042,6 +1042,7 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
|
||||
false, NULL, // PBS fingerprint
|
||||
false, NULL, // PBS backup-id
|
||||
false, 0, // PBS backup-time
|
||||
+ false, false, // PBS incremental
|
||||
true, dir ? BACKUP_FORMAT_DIR : BACKUP_FORMAT_VMA,
|
||||
false, NULL, false, NULL, !!devlist,
|
||||
devlist, qdict_haskey(qdict, "speed"), speed, &error);
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index b2687eae3a..cfd7a60f32 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -221,19 +221,42 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
|
||||
monitor_printf(mon, "End time: %s", ctime(&info->end_time));
|
||||
}
|
||||
|
||||
- int per = (info->has_total && info->total &&
|
||||
- info->has_transferred && info->transferred) ?
|
||||
- (info->transferred * 100)/info->total : 0;
|
||||
- int zero_per = (info->has_total && info->total &&
|
||||
- info->has_zero_bytes && info->zero_bytes) ?
|
||||
- (info->zero_bytes * 100)/info->total : 0;
|
||||
monitor_printf(mon, "Backup file: %s\n", info->backup_file);
|
||||
monitor_printf(mon, "Backup uuid: %s\n", info->uuid);
|
||||
- monitor_printf(mon, "Total size: %zd\n", info->total);
|
||||
- monitor_printf(mon, "Transferred bytes: %zd (%d%%)\n",
|
||||
- info->transferred, per);
|
||||
- monitor_printf(mon, "Zero bytes: %zd (%d%%)\n",
|
||||
- info->zero_bytes, zero_per);
|
||||
+
|
||||
+ if (!(info->has_total && info->total)) {
|
||||
+ // this should not happen normally
|
||||
+ monitor_printf(mon, "Total size: %d\n", 0);
|
||||
+ } else {
|
||||
+ bool incremental = false;
|
||||
+ size_t total_or_dirty = info->total;
|
||||
+ if (info->has_transferred) {
|
||||
+ if (info->has_dirty && info->dirty) {
|
||||
+ if (info->dirty < info->total) {
|
||||
+ total_or_dirty = info->dirty;
|
||||
+ incremental = true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ int per = (info->transferred * 100)/total_or_dirty;
|
||||
+
|
||||
+ monitor_printf(mon, "Backup mode: %s\n", incremental ? "incremental" : "full");
|
||||
+
|
||||
+ int zero_per = (info->has_zero_bytes && info->zero_bytes) ?
|
||||
+ (info->zero_bytes * 100)/info->total : 0;
|
||||
+ monitor_printf(mon, "Total size: %zd\n", info->total);
|
||||
+ monitor_printf(mon, "Transferred bytes: %zd (%d%%)\n",
|
||||
+ info->transferred, per);
|
||||
+ monitor_printf(mon, "Zero bytes: %zd (%d%%)\n",
|
||||
+ info->zero_bytes, zero_per);
|
||||
+
|
||||
+ if (info->has_reused) {
|
||||
+ int reused_per = (info->reused * 100)/total_or_dirty;
|
||||
+ monitor_printf(mon, "Reused bytes: %zd (%d%%)\n",
|
||||
+ info->reused, reused_per);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
qapi_free_BackupStatus(info);
|
||||
diff --git a/proxmox-backup-client.c b/proxmox-backup-client.c
|
||||
index a8f6653a81..4ce7bc0b5e 100644
|
||||
--- a/proxmox-backup-client.c
|
||||
+++ b/proxmox-backup-client.c
|
||||
@@ -89,6 +89,7 @@ proxmox_backup_co_register_image(
|
||||
ProxmoxBackupHandle *pbs,
|
||||
const char *device_name,
|
||||
uint64_t size,
|
||||
+ bool incremental,
|
||||
Error **errp)
|
||||
{
|
||||
Coroutine *co = qemu_coroutine_self();
|
||||
@@ -98,7 +99,7 @@ proxmox_backup_co_register_image(
|
||||
int pbs_res = -1;
|
||||
|
||||
proxmox_backup_register_image_async(
|
||||
- pbs, device_name, size ,proxmox_backup_schedule_wake, &waker, &pbs_res, &pbs_err);
|
||||
+ pbs, device_name, size, incremental, proxmox_backup_schedule_wake, &waker, &pbs_res, &pbs_err);
|
||||
qemu_coroutine_yield();
|
||||
if (pbs_res < 0) {
|
||||
if (errp) error_setg(errp, "backup register image failed: %s", pbs_err ? pbs_err : "unknown error");
|
||||
diff --git a/proxmox-backup-client.h b/proxmox-backup-client.h
|
||||
index 1dda8b7d8f..8cbf645b2c 100644
|
||||
--- a/proxmox-backup-client.h
|
||||
+++ b/proxmox-backup-client.h
|
||||
@@ -32,6 +32,7 @@ proxmox_backup_co_register_image(
|
||||
ProxmoxBackupHandle *pbs,
|
||||
const char *device_name,
|
||||
uint64_t size,
|
||||
+ bool incremental,
|
||||
Error **errp);
|
||||
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 88f5ee133f..1c49cd178d 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -28,6 +28,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
+const char *PBS_BITMAP_NAME = "pbs-incremental-dirty-bitmap";
|
||||
+
|
||||
static struct PVEBackupState {
|
||||
struct {
|
||||
// Everithing accessed from qmp_backup_query command is protected using lock
|
||||
@@ -39,7 +41,9 @@ static struct PVEBackupState {
|
||||
uuid_t uuid;
|
||||
char uuid_str[37];
|
||||
size_t total;
|
||||
+ size_t dirty;
|
||||
size_t transferred;
|
||||
+ size_t reused;
|
||||
size_t zero_bytes;
|
||||
} stat;
|
||||
int64_t speed;
|
||||
@@ -66,6 +70,7 @@ typedef struct PVEBackupDevInfo {
|
||||
uint8_t dev_id;
|
||||
bool completed;
|
||||
char targetfile[PATH_MAX];
|
||||
+ BdrvDirtyBitmap *bitmap;
|
||||
BlockDriverState *target;
|
||||
} PVEBackupDevInfo;
|
||||
|
||||
@@ -105,11 +110,12 @@ static bool pvebackup_error_or_canceled(void)
|
||||
return error_or_canceled;
|
||||
}
|
||||
|
||||
-static void pvebackup_add_transfered_bytes(size_t transferred, size_t zero_bytes)
|
||||
+static void pvebackup_add_transfered_bytes(size_t transferred, size_t zero_bytes, size_t reused)
|
||||
{
|
||||
qemu_mutex_lock(&backup_state.stat.lock);
|
||||
backup_state.stat.zero_bytes += zero_bytes;
|
||||
backup_state.stat.transferred += transferred;
|
||||
+ backup_state.stat.reused += reused;
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
}
|
||||
|
||||
@@ -148,7 +154,8 @@ pvebackup_co_dump_pbs_cb(
|
||||
pvebackup_propagate_error(local_err);
|
||||
return pbs_res;
|
||||
} else {
|
||||
- pvebackup_add_transfered_bytes(size, !buf ? size : 0);
|
||||
+ size_t reused = (pbs_res == 0) ? size : 0;
|
||||
+ pvebackup_add_transfered_bytes(size, !buf ? size : 0, reused);
|
||||
}
|
||||
|
||||
return size;
|
||||
@@ -208,11 +215,11 @@ pvebackup_co_dump_vma_cb(
|
||||
} else {
|
||||
if (remaining >= VMA_CLUSTER_SIZE) {
|
||||
assert(ret == VMA_CLUSTER_SIZE);
|
||||
- pvebackup_add_transfered_bytes(VMA_CLUSTER_SIZE, zero_bytes);
|
||||
+ pvebackup_add_transfered_bytes(VMA_CLUSTER_SIZE, zero_bytes, 0);
|
||||
remaining -= VMA_CLUSTER_SIZE;
|
||||
} else {
|
||||
assert(ret == remaining);
|
||||
- pvebackup_add_transfered_bytes(remaining, zero_bytes);
|
||||
+ pvebackup_add_transfered_bytes(remaining, zero_bytes, 0);
|
||||
remaining = 0;
|
||||
}
|
||||
}
|
||||
@@ -248,6 +255,18 @@ static void coroutine_fn pvebackup_co_cleanup(void *unused)
|
||||
if (local_err != NULL) {
|
||||
pvebackup_propagate_error(local_err);
|
||||
}
|
||||
+ } else {
|
||||
+ // on error or cancel we cannot ensure synchronization of dirty
|
||||
+ // bitmaps with backup server, so remove all and do full backup next
|
||||
+ GList *l = backup_state.di_list;
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ if (di->bitmap) {
|
||||
+ bdrv_release_dirty_bitmap(di->bitmap);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
proxmox_backup_disconnect(backup_state.pbs);
|
||||
@@ -303,6 +322,12 @@ static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
// remove self from job queue
|
||||
backup_state.di_list = g_list_remove(backup_state.di_list, di);
|
||||
|
||||
+ if (di->bitmap && ret < 0) {
|
||||
+ // on error or cancel we cannot ensure synchronization of dirty
|
||||
+ // bitmaps with backup server, so remove all and do full backup next
|
||||
+ bdrv_release_dirty_bitmap(di->bitmap);
|
||||
+ }
|
||||
+
|
||||
g_free(di);
|
||||
|
||||
qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
@@ -472,12 +497,18 @@ static bool create_backup_jobs(void) {
|
||||
|
||||
assert(di->target != NULL);
|
||||
|
||||
+ MirrorSyncMode sync_mode = MIRROR_SYNC_MODE_FULL;
|
||||
+ BitmapSyncMode bitmap_mode = BITMAP_SYNC_MODE_NEVER;
|
||||
+ if (di->bitmap) {
|
||||
+ sync_mode = MIRROR_SYNC_MODE_BITMAP;
|
||||
+ bitmap_mode = BITMAP_SYNC_MODE_ON_SUCCESS;
|
||||
+ }
|
||||
AioContext *aio_context = bdrv_get_aio_context(di->bs);
|
||||
aio_context_acquire(aio_context);
|
||||
|
||||
BlockJob *job = backup_job_create(
|
||||
- NULL, di->bs, di->target, backup_state.speed, MIRROR_SYNC_MODE_FULL, NULL,
|
||||
- BITMAP_SYNC_MODE_NEVER, false, NULL, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
+ NULL, di->bs, di->target, backup_state.speed, sync_mode, di->bitmap,
|
||||
+ bitmap_mode, false, NULL, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
JOB_DEFAULT, pvebackup_complete_cb, di, NULL, &local_err);
|
||||
|
||||
aio_context_release(aio_context);
|
||||
@@ -528,6 +559,8 @@ typedef struct QmpBackupTask {
|
||||
const char *fingerprint;
|
||||
bool has_fingerprint;
|
||||
int64_t backup_time;
|
||||
+ bool has_use_dirty_bitmap;
|
||||
+ bool use_dirty_bitmap;
|
||||
bool has_format;
|
||||
BackupFormat format;
|
||||
bool has_config_file;
|
||||
@@ -619,6 +652,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
|
||||
size_t total = 0;
|
||||
+ size_t dirty = 0;
|
||||
|
||||
l = di_list;
|
||||
while (l) {
|
||||
@@ -656,6 +690,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
int dump_cb_block_size = PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE; // Hardcoded (4M)
|
||||
firewall_name = "fw.conf";
|
||||
|
||||
+ bool use_dirty_bitmap = task->has_use_dirty_bitmap && task->use_dirty_bitmap;
|
||||
+
|
||||
char *pbs_err = NULL;
|
||||
pbs = proxmox_backup_new(
|
||||
task->backup_file,
|
||||
@@ -675,7 +711,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
goto err;
|
||||
}
|
||||
|
||||
- if (proxmox_backup_co_connect(pbs, task->errp) < 0)
|
||||
+ int connect_result = proxmox_backup_co_connect(pbs, task->errp);
|
||||
+ if (connect_result < 0)
|
||||
goto err;
|
||||
|
||||
/* register all devices */
|
||||
@@ -686,9 +723,40 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
|
||||
const char *devname = bdrv_get_device_name(di->bs);
|
||||
|
||||
- int dev_id = proxmox_backup_co_register_image(pbs, devname, di->size, task->errp);
|
||||
- if (dev_id < 0)
|
||||
+ BdrvDirtyBitmap *bitmap = bdrv_find_dirty_bitmap(di->bs, PBS_BITMAP_NAME);
|
||||
+ bool expect_only_dirty = false;
|
||||
+
|
||||
+ if (use_dirty_bitmap) {
|
||||
+ if (bitmap == NULL) {
|
||||
+ bitmap = bdrv_create_dirty_bitmap(di->bs, dump_cb_block_size, PBS_BITMAP_NAME, task->errp);
|
||||
+ if (!bitmap) {
|
||||
+ goto err;
|
||||
+ }
|
||||
+ } else {
|
||||
+ expect_only_dirty = proxmox_backup_check_incremental(pbs, devname, di->size) != 0;
|
||||
+ }
|
||||
+
|
||||
+ if (expect_only_dirty) {
|
||||
+ dirty += bdrv_get_dirty_count(bitmap);
|
||||
+ } else {
|
||||
+ /* mark entire bitmap as dirty to make full backup */
|
||||
+ bdrv_set_dirty_bitmap(bitmap, 0, di->size);
|
||||
+ dirty += di->size;
|
||||
+ }
|
||||
+ di->bitmap = bitmap;
|
||||
+ } else {
|
||||
+ dirty += di->size;
|
||||
+
|
||||
+ /* after a full backup the old dirty bitmap is invalid anyway */
|
||||
+ if (bitmap != NULL) {
|
||||
+ bdrv_release_dirty_bitmap(bitmap);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ int dev_id = proxmox_backup_co_register_image(pbs, devname, di->size, expect_only_dirty, task->errp);
|
||||
+ if (dev_id < 0) {
|
||||
goto err;
|
||||
+ }
|
||||
|
||||
if (!(di->target = bdrv_backup_dump_create(dump_cb_block_size, di->size, pvebackup_co_dump_pbs_cb, di, task->errp))) {
|
||||
goto err;
|
||||
@@ -697,6 +765,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
di->dev_id = dev_id;
|
||||
}
|
||||
} else if (format == BACKUP_FORMAT_VMA) {
|
||||
+ dirty = total;
|
||||
+
|
||||
vmaw = vma_writer_create(task->backup_file, uuid, &local_err);
|
||||
if (!vmaw) {
|
||||
if (local_err) {
|
||||
@@ -724,6 +794,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
}
|
||||
} else if (format == BACKUP_FORMAT_DIR) {
|
||||
+ dirty = total;
|
||||
+
|
||||
if (mkdir(task->backup_file, 0640) != 0) {
|
||||
error_setg_errno(task->errp, errno, "can't create directory '%s'\n",
|
||||
task->backup_file);
|
||||
@@ -796,8 +868,10 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
char *uuid_str = g_strdup(backup_state.stat.uuid_str);
|
||||
|
||||
backup_state.stat.total = total;
|
||||
+ backup_state.stat.dirty = dirty;
|
||||
backup_state.stat.transferred = 0;
|
||||
backup_state.stat.zero_bytes = 0;
|
||||
+ backup_state.stat.reused = format == BACKUP_FORMAT_PBS && dirty >= total ? 0 : total - dirty;
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
@@ -821,6 +895,10 @@ err:
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
l = g_list_next(l);
|
||||
|
||||
+ if (di->bitmap) {
|
||||
+ bdrv_release_dirty_bitmap(di->bitmap);
|
||||
+ }
|
||||
+
|
||||
if (di->target) {
|
||||
bdrv_unref(di->target);
|
||||
}
|
||||
@@ -862,6 +940,7 @@ UuidInfo *qmp_backup(
|
||||
bool has_fingerprint, const char *fingerprint,
|
||||
bool has_backup_id, const char *backup_id,
|
||||
bool has_backup_time, int64_t backup_time,
|
||||
+ bool has_use_dirty_bitmap, bool use_dirty_bitmap,
|
||||
bool has_format, BackupFormat format,
|
||||
bool has_config_file, const char *config_file,
|
||||
bool has_firewall_file, const char *firewall_file,
|
||||
@@ -880,6 +959,8 @@ UuidInfo *qmp_backup(
|
||||
.backup_id = backup_id,
|
||||
.has_backup_time = has_backup_time,
|
||||
.backup_time = backup_time,
|
||||
+ .has_use_dirty_bitmap = has_use_dirty_bitmap,
|
||||
+ .use_dirty_bitmap = use_dirty_bitmap,
|
||||
.has_format = has_format,
|
||||
.format = format,
|
||||
.has_config_file = has_config_file,
|
||||
@@ -948,10 +1029,14 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
|
||||
info->has_total = true;
|
||||
info->total = backup_state.stat.total;
|
||||
+ info->has_dirty = true;
|
||||
+ info->dirty = backup_state.stat.dirty;
|
||||
info->has_zero_bytes = true;
|
||||
info->zero_bytes = backup_state.stat.zero_bytes;
|
||||
info->has_transferred = true;
|
||||
info->transferred = backup_state.stat.transferred;
|
||||
+ info->has_reused = true;
|
||||
+ info->reused = backup_state.stat.reused;
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 551ee28275..b9d6f52f0c 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -757,8 +757,13 @@
|
||||
#
|
||||
# @total: total amount of bytes involved in the backup process
|
||||
#
|
||||
+# @dirty: with incremental mode (PBS) this is the amount of bytes involved
|
||||
+# in the backup process which are marked dirty.
|
||||
+#
|
||||
# @transferred: amount of bytes already backed up.
|
||||
#
|
||||
+# @reused: amount of bytes reused due to deduplication.
|
||||
+#
|
||||
# @zero-bytes: amount of 'zero' bytes detected.
|
||||
#
|
||||
# @start-time: time (epoch) when backup job started.
|
||||
@@ -771,8 +776,8 @@
|
||||
#
|
||||
##
|
||||
{ 'struct': 'BackupStatus',
|
||||
- 'data': {'*status': 'str', '*errmsg': 'str', '*total': 'int',
|
||||
- '*transferred': 'int', '*zero-bytes': 'int',
|
||||
+ 'data': {'*status': 'str', '*errmsg': 'str', '*total': 'int', '*dirty': 'int',
|
||||
+ '*transferred': 'int', '*zero-bytes': 'int', '*reused': 'int',
|
||||
'*start-time': 'int', '*end-time': 'int',
|
||||
'*backup-file': 'str', '*uuid': 'str' } }
|
||||
|
||||
@@ -815,6 +820,8 @@
|
||||
#
|
||||
# @backup-time: backup timestamp (Unix epoch, required for format 'pbs')
|
||||
#
|
||||
+# @use-dirty-bitmap: use dirty bitmap to detect incremental changes since last job (optional for format 'pbs')
|
||||
+#
|
||||
# Returns: the uuid of the backup job
|
||||
#
|
||||
##
|
||||
@@ -825,6 +832,7 @@
|
||||
'*fingerprint': 'str',
|
||||
'*backup-id': 'str',
|
||||
'*backup-time': 'int',
|
||||
+ '*use-dirty-bitmap': 'bool',
|
||||
'*format': 'BackupFormat',
|
||||
'*config-file': 'str',
|
||||
'*firewall-file': 'str',
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user