Compare commits
323 Commits
v5.1.0-8+v
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
839b53bab8 | ||
![]() |
c8dd2db54c | ||
![]() |
5e0c823f82 | ||
![]() |
4f0e2dfce4 | ||
![]() |
8e6de66a76 | ||
![]() |
1e351bfe19 | ||
![]() |
4397bd351d | ||
![]() |
6e581a8033 | ||
![]() |
7891f050c6 | ||
![]() |
bd931f0f04 | ||
![]() |
b73923535f | ||
![]() |
50717bf6df | ||
![]() |
e0969989ac | ||
![]() |
b30e898392 | ||
![]() |
053f68a7ac | ||
![]() |
cb662eb2c1 | ||
![]() |
a6ee093f1c | ||
![]() |
76dd2fb90b | ||
![]() |
3da02409af | ||
![]() |
f7be446ebe | ||
![]() |
dc45786e06 | ||
![]() |
f6dc6b54ba | ||
![]() |
4f4fca78f7 | ||
![]() |
e247b46563 | ||
![]() |
670aa8ecdf | ||
![]() |
dfac8d424d | ||
![]() |
b7ad4dc467 | ||
![]() |
1d777d7fe6 | ||
![]() |
6390972c7b | ||
![]() |
acd551f801 | ||
![]() |
f42ba1f272 | ||
![]() |
c4efa30b30 | ||
![]() |
0b40610f61 | ||
![]() |
28ad83b492 | ||
![]() |
5fff8d91c7 | ||
![]() |
7882afe30d | ||
![]() |
05089ab57d | ||
![]() |
9e8ef15831 | ||
![]() |
531db7df01 | ||
![]() |
d14bffa8c0 | ||
![]() |
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 | ||
![]() |
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 | ||
![]() |
4e4b9ab13f | ||
![]() |
39e84ba82d | ||
![]() |
4fd0fa7fb3 | ||
![]() |
539e333eaa | ||
![]() |
68569ea2ff | ||
![]() |
41aedfb6db | ||
![]() |
7bd4d8645a | ||
![]() |
ed3b5b8ab8 | ||
![]() |
7f4326d1dc | ||
![]() |
53bff441c5 | ||
![]() |
f9a4b1cea7 | ||
![]() |
dc265df350 | ||
![]() |
e0076597c6 | ||
![]() |
ee99c1f813 | ||
![]() |
58a5492e9c | ||
![]() |
e67b8b5bd9 | ||
![]() |
309b5c1694 | ||
![]() |
4ce5937f89 | ||
![]() |
f87d0523df | ||
![]() |
2fd4ea2813 | ||
![]() |
2653a5f029 | ||
![]() |
664ecf59a9 | ||
![]() |
4de9440f87 | ||
![]() |
9b348f8c6d | ||
![]() |
799cf8c5a3 | ||
![]() |
b02e62dba0 | ||
![]() |
fc03e1b6bf | ||
![]() |
c8ba14bed0 | ||
![]() |
daea534caa | ||
![]() |
27199bd753 | ||
![]() |
e050683663 | ||
![]() |
13184117e4 | ||
![]() |
aa4b14ea10 | ||
![]() |
3aa5b7598d | ||
![]() |
13d3e10aa6 | ||
![]() |
58c3533a58 | ||
![]() |
fe0542bed9 | ||
![]() |
f6d40bfdf4 | ||
![]() |
107132becc | ||
![]() |
4567474e95 | ||
![]() |
33a2d3a826 | ||
![]() |
2bf61c3eb6 | ||
![]() |
c07b2203b3 | ||
![]() |
ddbf7a872d | ||
![]() |
95c7156d1e | ||
![]() |
570d4ad51d | ||
![]() |
c5e8e7c998 | ||
![]() |
7cf6b60926 | ||
![]() |
50999525c6 | ||
![]() |
edbcc10a69 | ||
![]() |
cc707c362e | ||
![]() |
af64ed13eb | ||
![]() |
f376b2b9e2 | ||
![]() |
89fa943ef9 | ||
![]() |
26eee146bc | ||
![]() |
277d33454f | ||
![]() |
611b692181 | ||
![]() |
0114d3cd02 | ||
![]() |
bb3e494bdc | ||
![]() |
403f23a0c3 | ||
![]() |
db687e3cac | ||
![]() |
8893def37c | ||
![]() |
263fef5b4c | ||
![]() |
eb96e850ac | ||
![]() |
8dca018b68 | ||
![]() |
1cbf147251 | ||
![]() |
9e4cba3943 | ||
![]() |
ebcd9ada10 | ||
![]() |
0a88214b72 | ||
![]() |
76e464784e | ||
![]() |
b36e8acc31 | ||
![]() |
aa42ea267e | ||
![]() |
6d6894394c | ||
![]() |
e79be6c6c4 | ||
![]() |
0be2cab670 | ||
![]() |
bb751cab32 | ||
![]() |
154a7c0f8d | ||
![]() |
677d0d169f | ||
![]() |
e9b36665c7 | ||
![]() |
970196fc93 | ||
![]() |
6503e6e08d | ||
![]() |
40e6b6e5a5 | ||
![]() |
a6ede89808 | ||
![]() |
2413972b46 | ||
![]() |
0c893fd820 | ||
![]() |
25b9156448 | ||
![]() |
4194124719 | ||
![]() |
42a90c4e1c | ||
![]() |
448136958e | ||
![]() |
8e231fbe8d | ||
![]() |
00fae7cdbe | ||
![]() |
0b8da68824 | ||
![]() |
817b7667e8 | ||
![]() |
a16eaaffd3 |
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/*.build
|
||||
/*.buildinfo
|
||||
/*.changes
|
||||
/*.deb
|
||||
/*.dsc
|
||||
/*.tar*
|
||||
/pve-qemu-kvm-*.*/
|
88
Makefile
88
Makefile
@@ -1,57 +1,89 @@
|
||||
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
|
||||
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
|
||||
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 $@.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
|
||||
$(DEBS) &: $(BUILDDIR)
|
||||
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 buster
|
||||
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)
|
||||
|
743
debian/changelog
vendored
743
debian/changelog
vendored
@@ -1,3 +1,746 @@
|
||||
pve-qemu-kvm (10.0.2-4) trixie; urgency=medium
|
||||
|
||||
* savevm-async: reuse migration blocker check for snapshots/hibernation to
|
||||
avoid crashing a VM when on these actions if its configuration does not
|
||||
support them.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 17 Jul 2025 23:08:46 +0200
|
||||
|
||||
pve-qemu-kvm (10.0.2-3) trixie; urgency=medium
|
||||
|
||||
* add backup/zeroinit/track-alloc blockdev patches
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 03 Jul 2025 12:02:03 +0200
|
||||
|
||||
pve-qemu-kvm (10.0.2-2) trixie; urgency=medium
|
||||
|
||||
* drop support for accessing Gluster based storage directly due to its
|
||||
effective end of support and maintenance. The last upstream release
|
||||
happened over 2.5 years ago and there's currently no one providing
|
||||
enterprise support or security updates. Further, upstream QEMU will remove
|
||||
the integration in one of the next releases, so use the upcomming PVE 9
|
||||
major release to provide a clean cut.
|
||||
User can either stay on Proxmox VE 8 until its end-of-life (probably end
|
||||
of June 2026), or mount GlusterFS "manually" (e.g., /etc/fstab) and add it
|
||||
as directory storage to Proxmox VE.
|
||||
We recommend moving to other actively maintained storage technology
|
||||
altogether though.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 25 Jun 2025 19:23:30 +0200
|
||||
|
||||
pve-qemu-kvm (10.0.2-1) trixie; urgency=medium
|
||||
|
||||
* update QEMU and downstream patches for 10.0.2 release.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 17 Jun 2025 08:38:51 +0200
|
||||
|
||||
pve-qemu-kvm (9.2.0-5) bookworm; urgency=medium
|
||||
|
||||
* pve backup: backup-access api: simplify bitmap logic
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 04 Apr 2025 16:15:58 +0200
|
||||
|
||||
pve-qemu-kvm (9.2.0-4) bookworm; urgency=medium
|
||||
|
||||
* various async snapshot improvements, inclduing using a dedicated IO thread
|
||||
for the state file when doing a live snapshot. That should reduce load on
|
||||
the main thread and for it to get stuck on IO, i.e. same benefits as using
|
||||
a dedicated IO thread for regular drives. This is particularly interesting
|
||||
when the VM state storage is a network storage like NFS. It should also
|
||||
address #6262.
|
||||
|
||||
* pve backup: implement basic features and API in preperation for external
|
||||
backup provider storage plugins.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 03 Apr 2025 17:00:34 +0200
|
||||
|
||||
pve-qemu-kvm (9.2.0-3) bookworm; urgency=medium
|
||||
|
||||
* revert changes to the High Precision Event Timer (HPET) to fix performance
|
||||
regression
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 26 Mar 2025 09:56:01 +0100
|
||||
|
||||
pve-qemu-kvm (9.2.0-2) bookworm; urgency=medium
|
||||
|
||||
* fix assertion failure when migrating a VM with multiple disks on a
|
||||
replicated ZFS.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 24 Feb 2025 17:33:34 +0100
|
||||
|
||||
pve-qemu-kvm (9.2.0-1) bookworm; urgency=medium
|
||||
|
||||
* update submodule and patches to QEMU 9.2.0
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 04 Feb 2025 08:49:20 +0100
|
||||
|
||||
pve-qemu-kvm (9.1.2-3) bookworm; urgency=medium
|
||||
|
||||
* async snapshot: explicitly specify raw format when loading the VM state
|
||||
file
|
||||
|
||||
* 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 16:12:34 +0100
|
||||
|
||||
pve-qemu-kvm (9.1.2-2) bookworm; urgency=medium
|
||||
|
||||
* adapt machine version deprecation for Proxmox VE release and support
|
||||
cycle.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 17 Jan 2025 16:34:06 +0100
|
||||
|
||||
pve-qemu-kvm (9.1.2-1) bookworm; urgency=medium
|
||||
|
||||
* update submodule and patches to QEMU 9.1.2
|
||||
|
||||
* improve error handling and edge cases with fleecing backups.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 11 Dec 2024 16:47:21 +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 (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
|
||||
|
||||
* add 'namespace' to BlockdevOptionsPbs for live-restore support
|
||||
|
||||
* vma: create: support 64KiB-unaligned input images like to improve backing
|
||||
up some VM templates
|
||||
|
||||
* block: alloc-track: avoid unlikely, but possible premature break
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 22 Jun 2022 15:54:54 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-10) bullseye; urgency=medium
|
||||
|
||||
* fix #4101: fix backup cancellation bug with iothreads
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 9 Jun 2022 16:35:51 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-9) bullseye; urgency=medium
|
||||
|
||||
* fix possible race conditions during cancellation of a PBS backup
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 08 Jun 2022 14:03:22 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-8) bullseye; urgency=medium
|
||||
|
||||
* revert "block/rbd: implement bdrv_co_block_status" to work around
|
||||
performance regression when backing up large RBD disk
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 19 May 2022 09:24:45 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-7) bullseye; urgency=medium
|
||||
|
||||
* Proxmox Backup Server namespace support
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 12 May 2022 16:05:56 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-6) bullseye; urgency=medium
|
||||
|
||||
* block/gluster: correctly set max_pdiscard which is int64_t to avoid
|
||||
triggering assertion
|
||||
|
||||
* ui/vnc.c: Fixed a deadlock bug
|
||||
|
||||
* display/qxl-render: fix race condition in qxl_cursor (CVE-2021-4207) and
|
||||
integer overflow in cursor_alloc (CVE-2021-4206)
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 11 May 2022 10:42:53 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-5) bullseye; urgency=medium
|
||||
|
||||
* vma: allow partial restore by skipping some disk
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 25 Apr 2022 10:13:46 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-4) bullseye; urgency=medium
|
||||
|
||||
* d/control: add libgbm to build dependencies
|
||||
|
||||
* d/control: add suggest dependency-hint for libgl1
|
||||
|
||||
* various stable backports:
|
||||
+ virtio-net: fix map leaking on error during receive
|
||||
+ memory: Fix incorrect calls of log_global_start/stop
|
||||
+ acpi: fix OEM ID/OEM Table ID padding
|
||||
+ vhost-vsock: detach the virqueue element in case of error
|
||||
+ vhost-user: remove VirtQ notifier restore
|
||||
+ vhost-user: fix VirtQ notifier cleanup
|
||||
+ virtio: fix the condition for iommu_platform not supported
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 22 Apr 2022 11:52:30 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-3) bullseye; urgency=medium
|
||||
|
||||
* cherry-pick fix for some manually added ACPI table SLIC entries via the
|
||||
custom args flag.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 15 Apr 2022 09:09:37 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-2) bullseye; urgency=medium
|
||||
|
||||
* compile in virgl support
|
||||
|
||||
* enable zstd support
|
||||
|
||||
* drop sdl dependency (it was disabled at compile time already)
|
||||
|
||||
* recommend 'numactl'
|
||||
|
||||
* fix an issue with multi-disk backups where chunks would be written
|
||||
multiple times
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 03 Mar 2022 12:03:44 +0100
|
||||
|
||||
pve-qemu-kvm (6.2.0-1) bullseye; urgency=medium
|
||||
|
||||
* update to QEMU stable release 6.2.0
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 17 Feb 2022 06:23:14 +0100
|
||||
|
||||
pve-qemu-kvm (6.1.1-2) bullseye; urgency=medium
|
||||
|
||||
* vma: create: register all streams before entering coroutines to avoid that
|
||||
an early stream starts to write already before all got registered.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 14 Feb 2022 15:53:15 +0100
|
||||
|
||||
pve-qemu-kvm (6.1.1-1) bullseye; urgency=medium
|
||||
|
||||
* update to 6.1.1 stable release
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 13 Jan 2022 10:57:43 +0100
|
||||
|
||||
pve-qemu-kvm (6.1.0-3) bullseye; urgency=medium
|
||||
|
||||
* fix #3738: cherry-pick "block: introduce max_hw_iov for use in scsi-
|
||||
generic
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 01 Dec 2021 15:35:43 +0100
|
||||
|
||||
pve-qemu-kvm (6.1.0-2) bullseye; urgency=medium
|
||||
|
||||
* avoid a possible segmentation fault during block (disk) mirror
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 16 Nov 2021 09:38:10 +0100
|
||||
|
||||
pve-qemu-kvm (6.1.0-1) bullseye; urgency=medium
|
||||
|
||||
* update to QEMU stable release 6.1.0
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 11 Oct 2021 15:15:19 +0200
|
||||
|
||||
pve-qemu-kvm (6.0.0-4) bullseye; urgency=medium
|
||||
|
||||
* drop the ancient workaround that force disabled SMM due to observing VM
|
||||
hangs on old kernel versions.
|
||||
|
||||
* monitor/qmp: fix race with clients disconnecting early resulting in other
|
||||
clients receiving a message with the (now wrong) ID of the former
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 06 Sep 2021 07:30:00 +0200
|
||||
|
||||
pve-qemu-kvm (6.0.0-3) bullseye; urgency=medium
|
||||
|
||||
* io_uring: resubmit when result is -EAGAIN
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 3 Aug 2021 15:01:31 +0200
|
||||
|
||||
pve-qemu-kvm (6.0.0-2) bullseye; urgency=medium
|
||||
|
||||
* enable io-uring support in QEMU builds
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 23 Jun 2021 11:03:54 +0200
|
||||
|
||||
pve-qemu-kvm (6.0.0-1) bullseye; urgency=medium
|
||||
|
||||
* update to QEMU stable release 6.0.0
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 28 May 2021 11:30:50 +0200
|
||||
|
||||
pve-qemu-kvm (5.2.0-11) bullseye; urgency=medium
|
||||
|
||||
* re-build for Proxmox VE 7 / Debian Bullseye
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 13 May 2021 14:03:00 +0200
|
||||
|
||||
pve-qemu-kvm (5.2.0-6) pve; urgency=medium
|
||||
|
||||
* improve the alloc-track and Proxmox Backup Server special block driver when
|
||||
used with IO-threads for the new live-restore feature
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 15 Apr 2021 16:29:48 +0200
|
||||
|
||||
pve-qemu-kvm (5.2.0-5) pve; urgency=medium
|
||||
|
||||
* cherry-pick fixes for a possible deadlock when resizing a disk while using
|
||||
IO-threads
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 30 Mar 2021 18:18:18 +0200
|
||||
|
||||
pve-qemu-kvm (5.2.0-4) pve; urgency=medium
|
||||
|
||||
* monitor/qmp: fix race on CHR_EVENT_CLOSED without OOB
|
||||
|
||||
* improve saving and loading dirty bitmaps in live-snapshots
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 23 Mar 2021 15:41:26 +0100
|
||||
|
||||
pve-qemu-kvm (5.2.0-3) pve; urgency=medium
|
||||
|
||||
* backport "i386/acpi: restore device paths for pre-5.1 vms" patch
|
||||
|
||||
* ship list of 'i440fx' and 'q35' machine versions this QEMU version supports
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 05 Mar 2021 16:23:06 +0100
|
||||
|
||||
pve-qemu-kvm (5.2.0-2) pve; urgency=medium
|
||||
|
||||
* Proxmox Backup restore: ensure all caches are flushed for userspace
|
||||
attached storages (for example, Ceph when librbd and not KRBD is used)
|
||||
|
||||
* ship VirtIOFSd daemon
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 24 Feb 2021 18:25:14 +0100
|
||||
|
||||
pve-qemu-kvm (5.2.0-1) pve; urgency=medium
|
||||
|
||||
* update to QEMU stable release 5.2.0
|
||||
|
||||
* fix #3084: fall back to open-iscsi initiatorname
|
||||
|
||||
* fix snapshot abort and improve performance in some edge cases
|
||||
|
||||
* add basis for Proxmox Backup Server master key support
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 12 Feb 2021 12:09:59 +0100
|
||||
|
||||
pve-qemu-kvm (5.1.0-8) pve; urgency=medium
|
||||
|
||||
* disable jemalloc, as it does not play nice with our library written in
|
||||
|
1
debian/compat
vendored
1
debian/compat
vendored
@@ -1 +0,0 @@
|
||||
10
|
47
debian/control
vendored
47
debian/control
vendored
@@ -2,37 +2,42 @@ 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,
|
||||
libcap-ng-dev,
|
||||
libcurl4-gnutls-dev,
|
||||
libepoxy-dev,
|
||||
libfdt-dev,
|
||||
libglusterfs-dev (>= 5.2-2),
|
||||
libgbm-dev,
|
||||
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.0.2-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,
|
||||
libusb-1.0-0-dev (>= 1.0.17-1),
|
||||
liburing-dev,
|
||||
libusb-1.0-0-dev (>= 1.0.17),
|
||||
libusbredirparser-dev (>= 0.6-2),
|
||||
libvirglrenderer-dev,
|
||||
libzstd-dev,
|
||||
meson,
|
||||
python3-minimal,
|
||||
python3-sphinx,
|
||||
python3-sphinx-rtd-theme,
|
||||
python3-venv,
|
||||
quilt,
|
||||
texi2html,
|
||||
texinfo,
|
||||
uuid-dev,
|
||||
xfslibs-dev,
|
||||
Standards-Version: 3.7.2
|
||||
@@ -41,27 +46,16 @@ Package: pve-qemu-kvm
|
||||
Architecture: any
|
||||
Depends: ceph-common (>= 0.48),
|
||||
iproute2,
|
||||
libaio1,
|
||||
libgfapi0 | glusterfs-common (>= 5.6),
|
||||
libgfchangelog0 | glusterfs-common (>= 5.6),
|
||||
libgfdb0 | glusterfs-common (>= 5.6),
|
||||
libgfrpc0 | glusterfs-common (>= 5.6),
|
||||
libgfxdr0 | glusterfs-common (>= 5.6),
|
||||
libglusterfs-dev | glusterfs-common (>= 5.6),
|
||||
libglusterfs0 | glusterfs-common (>= 5.6),
|
||||
libiscsi4 (>= 1.12.0) | libiscsi7,
|
||||
libjemalloc2,
|
||||
libjpeg62-turbo,
|
||||
libproxmox-backup-qemu0 (>= 1.0.2-1),
|
||||
libsdl1.2debian,
|
||||
libspice-server1 (>= 0.14.0~),
|
||||
libusb-1.0-0 (>= 1.0.17-1),
|
||||
libusbredirparser1 (>= 0.6-2),
|
||||
libuuid1,
|
||||
numactl,
|
||||
python,
|
||||
${misc:Depends},
|
||||
${shlibs:Depends},
|
||||
Recommends: numactl,
|
||||
Suggests: libgl1,
|
||||
Conflicts: kvm,
|
||||
pve-kvm,
|
||||
pve-qemu-kvm-2.6.18,
|
||||
@@ -69,22 +63,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.
|
||||
|
2
debian/copyright
vendored
2
debian/copyright
vendored
@@ -25,7 +25,7 @@ License:
|
||||
|
||||
In particular, the QEMU virtual CPU core library (libqemu.a) is
|
||||
released under the GNU Lesser General Public License version 2 or later.
|
||||
On Debian systems, the complete text of the GNU Lesser General Public
|
||||
On Debian systems, the complete text of the GNU Lesser General Public
|
||||
License can be found in the file /usr/share/common-licenses/LGPL.
|
||||
|
||||
Some hardware device emulation sources and other QEMU functionality are
|
||||
|
28
debian/parse-machines.pl
vendored
Executable file
28
debian/parse-machines.pl
vendored
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use JSON;
|
||||
|
||||
my $machines = [];
|
||||
|
||||
while (<STDIN>) {
|
||||
if (/^\s*Supported machines are:/) {
|
||||
next;
|
||||
}
|
||||
|
||||
s/^\s+//;
|
||||
my @machine = split(/\s+/);
|
||||
next if $machine[0] !~ m/^pc-(i440fx|q35)-(.+)$/;
|
||||
push @$machines, {
|
||||
'id' => $machine[0],
|
||||
'type' => $1,
|
||||
'version' => $2,
|
||||
};
|
||||
}
|
||||
|
||||
die "no QEMU machine types detected from STDIN input" if scalar (@$machines) <= 0;
|
||||
|
||||
print to_json($machines, { utf8 => 1, canonical => 1 })
|
||||
or die "failed to encode detected machines as JSON - $!\n";
|
@@ -26,19 +26,22 @@ Suggested-by: Ma Haocong <mahaocong@didichuxing.com>
|
||||
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 9.1.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/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 e8e8844afc..100e828639 100644
|
||||
index a53582f17b..fafca1360e 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -49,7 +49,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;
|
||||
@@ -47,7 +50,7 @@ index e8e8844afc..100e828639 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;
|
||||
@@ -56,17 +59,17 @@ index e8e8844afc..100e828639 100644
|
||||
BdrvDirtyBitmap *dirty_bitmap;
|
||||
BdrvDirtyBitmapIter *dbi;
|
||||
uint8_t *buf;
|
||||
@@ -676,7 +678,8 @@ static int mirror_exit_common(Job *job)
|
||||
bdrv_child_refresh_perms(mirror_top_bs, mirror_top_bs->backing,
|
||||
@@ -723,7 +725,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;
|
||||
+ backing = s->sync_mode == MIRROR_SYNC_MODE_NONE ? src : s->base;
|
||||
if (backing_bs(target_bs) != backing) {
|
||||
bdrv_set_backing_hd(target_bs, backing, &local_err);
|
||||
if (local_err) {
|
||||
@@ -771,6 +774,16 @@ static void mirror_abort(Job *job)
|
||||
BlockDriverState *unfiltered_target = bdrv_skip_filters(target_bs);
|
||||
|
||||
if (bdrv_cow_bs(unfiltered_target) != backing) {
|
||||
@@ -824,6 +827,16 @@ static void mirror_abort(Job *job)
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
@@ -83,7 +86,7 @@ index e8e8844afc..100e828639 100644
|
||||
static void coroutine_fn mirror_throttle(MirrorBlockJob *s)
|
||||
{
|
||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
||||
@@ -952,7 +965,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
|
||||
@@ -1020,7 +1033,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);
|
||||
@@ -93,23 +96,23 @@ index e8e8844afc..100e828639 100644
|
||||
ret = mirror_dirty_init(s);
|
||||
if (ret < 0 || job_is_cancelled(&s->common.job)) {
|
||||
goto immediate_exit;
|
||||
@@ -1184,6 +1198,7 @@ static const BlockJobDriver mirror_job_driver = {
|
||||
@@ -1309,6 +1323,7 @@ static const BlockJobDriver mirror_job_driver = {
|
||||
.run = mirror_run,
|
||||
.prepare = mirror_prepare,
|
||||
.abort = mirror_abort,
|
||||
+ .clean = mirror_clean,
|
||||
.pause = mirror_pause,
|
||||
.complete = mirror_complete,
|
||||
},
|
||||
@@ -1199,6 +1214,7 @@ static const BlockJobDriver commit_active_job_driver = {
|
||||
.cancel = mirror_cancel,
|
||||
@@ -1327,6 +1342,7 @@ static const BlockJobDriver commit_active_job_driver = {
|
||||
.run = mirror_run,
|
||||
.prepare = mirror_prepare,
|
||||
.abort = mirror_abort,
|
||||
+ .clean = mirror_clean,
|
||||
.pause = mirror_pause,
|
||||
.complete = mirror_complete,
|
||||
},
|
||||
@@ -1547,7 +1563,10 @@ static BlockJob *mirror_start_job(
|
||||
.cancel = commit_active_cancel,
|
||||
@@ -1719,7 +1735,10 @@ static BlockJob *mirror_start_job(
|
||||
BlockCompletionFunc *cb,
|
||||
void *opaque,
|
||||
const BlockJobDriver *driver,
|
||||
@@ -120,10 +123,10 @@ index e8e8844afc..100e828639 100644
|
||||
+ BlockDriverState *base,
|
||||
bool auto_complete, const char *filter_node_name,
|
||||
bool is_mirror, MirrorCopyMode copy_mode,
|
||||
Error **errp)
|
||||
@@ -1560,10 +1579,39 @@ static BlockJob *mirror_start_job(
|
||||
Error *local_err = NULL;
|
||||
int ret;
|
||||
bool base_ro,
|
||||
@@ -1734,10 +1753,39 @@ static BlockJob *mirror_start_job(
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
- if (granularity == 0) {
|
||||
- granularity = bdrv_get_default_bitmap_granularity(target);
|
||||
@@ -163,7 +166,7 @@ index e8e8844afc..100e828639 100644
|
||||
assert(is_power_of_2(granularity));
|
||||
|
||||
if (buf_size < 0) {
|
||||
@@ -1667,7 +1715,9 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1878,7 +1926,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;
|
||||
@@ -173,10 +176,10 @@ index e8e8844afc..100e828639 100644
|
||||
+ s->bitmap_mode = bitmap_mode;
|
||||
s->backing_mode = backing_mode;
|
||||
s->zero_target = zero_target;
|
||||
s->copy_mode = copy_mode;
|
||||
@@ -1687,6 +1737,18 @@ static BlockJob *mirror_start_job(
|
||||
bdrv_disable_dirty_bitmap(s->dirty_bitmap);
|
||||
}
|
||||
qatomic_set(&s->copy_mode, copy_mode);
|
||||
@@ -1904,6 +1954,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);
|
||||
@@ -190,10 +193,10 @@ index e8e8844afc..100e828639 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,
|
||||
@@ -1740,6 +1802,9 @@ fail:
|
||||
@@ -1986,6 +2048,9 @@ fail:
|
||||
if (s->dirty_bitmap) {
|
||||
bdrv_release_dirty_bitmap(s->dirty_bitmap);
|
||||
}
|
||||
@@ -203,7 +206,7 @@ index e8e8844afc..100e828639 100644
|
||||
job_early_fail(&s->common.job);
|
||||
}
|
||||
|
||||
@@ -1757,29 +1822,23 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2008,35 +2073,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,
|
||||
@@ -220,25 +223,31 @@ index e8e8844afc..100e828639 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 ? backing_bs(bs) : NULL;
|
||||
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,
|
||||
- &mirror_job_driver, is_none_mode, base, false,
|
||||
- filter_node_name, true, copy_mode, errp);
|
||||
- filter_node_name, true, copy_mode, false, errp);
|
||||
+ &mirror_job_driver, mode, bitmap, bitmap_mode, base,
|
||||
+ false, filter_node_name, true, copy_mode, errp);
|
||||
+ false, filter_node_name, true, copy_mode, false, errp);
|
||||
}
|
||||
|
||||
BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
|
||||
@@ -1805,7 +1864,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2063,7 +2121,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,
|
||||
@@ -246,36 +255,35 @@ index e8e8844afc..100e828639 100644
|
||||
+ &commit_active_job_driver, MIRROR_SYNC_MODE_FULL,
|
||||
+ NULL, 0, base, auto_complete,
|
||||
filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND,
|
||||
&local_err);
|
||||
if (local_err) {
|
||||
base_read_only, errp);
|
||||
if (!job) {
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index 681da7c8b6..02d58e7645 100644
|
||||
index 1d1f27cfff..ec45bbaa52 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -2876,6 +2876,10 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2797,6 +2797,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,
|
||||
@@ -2894,6 +2898,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
Error **errp)
|
||||
@@ -2815,6 +2818,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;
|
||||
@@ -2948,6 +2953,29 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
GLOBAL_STATE_CODE();
|
||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||
@@ -2869,6 +2873,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;
|
||||
@@ -298,53 +306,53 @@ index 681da7c8b6..02d58e7645 100644
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (has_replaces) {
|
||||
BlockDriverState *to_replace_bs;
|
||||
AioContext *replace_aio_context;
|
||||
@@ -2985,8 +3013,8 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
if (!replaces) {
|
||||
/* We want to mirror from @bs, but keep implicit filters on top */
|
||||
unfiltered_bs = bdrv_skip_implicit_filters(bs);
|
||||
@@ -2910,8 +2937,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);
|
||||
}
|
||||
@@ -3127,6 +3155,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
||||
@@ -3055,6 +3082,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,
|
||||
@@ -3148,6 +3178,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
|
||||
@@ -3074,6 +3103,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,
|
||||
@@ -3197,7 +3229,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
|
||||
@@ -3114,7 +3145,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 8dda6f769d..279bd4ab61 100644
|
||||
--- a/include/block/block_int.h
|
||||
+++ b/include/block/block_int.h
|
||||
@@ -1245,7 +1245,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,
|
||||
@@ -356,31 +364,26 @@ index 8dda6f769d..279bd4ab61 100644
|
||||
BlockdevOnError on_source_error,
|
||||
BlockdevOnError on_target_error,
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 69db270b1a..9db8e26517 100644
|
||||
index b1937780e1..0e5f148d30 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -2064,10 +2064,19 @@
|
||||
# (all the disk, only the sectors allocated in the topmost image, or
|
||||
# only new I/O).
|
||||
@@ -2182,6 +2182,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).
|
||||
@@ -2105,7 +2114,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
|
||||
@@ -2224,7 +2233,9 @@
|
||||
{ 'struct': 'DriveMirror',
|
||||
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
|
||||
'*format': 'str', '*node-name': 'str', '*replaces': 'str',
|
||||
@@ -391,28 +394,23 @@ index 69db270b1a..9db8e26517 100644
|
||||
'*speed': 'int', '*granularity': 'uint32',
|
||||
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
|
||||
'*on-target-error': 'BlockdevOnError',
|
||||
@@ -2372,10 +2383,19 @@
|
||||
# (all the disk, only the sectors allocated in the topmost image, or
|
||||
# only new I/O).
|
||||
@@ -2503,6 +2514,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
|
||||
@@ -2424,7 +2444,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
|
||||
@@ -2551,7 +2571,8 @@
|
||||
{ 'command': 'blockdev-mirror',
|
||||
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
|
||||
'*replaces': 'str',
|
||||
@@ -422,11 +420,11 @@ index 69db270b1a..9db8e26517 100644
|
||||
'*speed': 'int', '*granularity': 'uint32',
|
||||
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
|
||||
'*on-target-error': 'BlockdevOnError',
|
||||
diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c
|
||||
index 3f866a35c6..500ede71c8 100644
|
||||
--- a/tests/test-block-iothread.c
|
||||
+++ b/tests/test-block-iothread.c
|
||||
@@ -623,8 +623,8 @@ static void test_propagate_mirror(void)
|
||||
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
|
||||
index 2b358eaaa8..2a149fe021 100644
|
||||
--- a/tests/unit/test-block-iothread.c
|
||||
+++ b/tests/unit/test-block-iothread.c
|
||||
@@ -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,
|
||||
@@ -436,4 +434,4 @@ index 3f866a35c6..500ede71c8 100644
|
||||
+ false, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
false, "filter_node", MIRROR_COPY_MODE_BACKGROUND,
|
||||
&error_abort);
|
||||
job = job_get("job0");
|
||||
|
@@ -18,15 +18,16 @@ incremental backup modes; we can use this bitmap to later refresh a
|
||||
successfully created mirror.
|
||||
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/mirror.c | 24 ++++++++++++++++++------
|
||||
1 file changed, 18 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index 100e828639..7d3c3252f3 100644
|
||||
index fafca1360e..05e738bcce 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -653,8 +653,6 @@ static int mirror_exit_common(Job *job)
|
||||
@@ -694,8 +694,6 @@ static int mirror_exit_common(Job *job)
|
||||
bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs);
|
||||
}
|
||||
|
||||
@@ -35,9 +36,9 @@ index 100e828639..7d3c3252f3 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);
|
||||
@@ -752,6 +750,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);
|
||||
@@ -805,6 +803,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 ||
|
||||
@@ -54,7 +55,7 @@ index 100e828639..7d3c3252f3 100644
|
||||
bs_opaque->job = NULL;
|
||||
|
||||
bdrv_drained_end(src);
|
||||
@@ -1589,10 +1599,6 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1763,10 +1773,6 @@ static BlockJob *mirror_start_job(
|
||||
" sync mode",
|
||||
MirrorSyncMode_str(sync_mode));
|
||||
return NULL;
|
||||
@@ -65,7 +66,7 @@ index 100e828639..7d3c3252f3 100644
|
||||
}
|
||||
} else if (bitmap) {
|
||||
error_setg(errp,
|
||||
@@ -1609,6 +1615,12 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1783,6 +1789,12 @@ static BlockJob *mirror_start_job(
|
||||
return NULL;
|
||||
}
|
||||
granularity = bdrv_dirty_bitmap_granularity(bitmap);
|
@@ -10,15 +10,16 @@ as one without the other does not make much sense with the current set
|
||||
of modes.
|
||||
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
blockdev.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index 02d58e7645..0d480f02c7 100644
|
||||
index ec45bbaa52..9fab7ec554 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -2974,6 +2974,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2894,6 +2894,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) {
|
||||
return;
|
||||
}
|
||||
@@ -27,4 +28,4 @@ index 02d58e7645..0d480f02c7 100644
|
||||
+ return;
|
||||
}
|
||||
|
||||
if (has_replaces) {
|
||||
if (!replaces) {
|
@@ -10,15 +10,16 @@ since sync_bitmap is busy at the point of merging, and we checked access
|
||||
beforehand.
|
||||
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/mirror.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
block/mirror.c | 11 ++++-------
|
||||
1 file changed, 4 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index 7d3c3252f3..fb12ccb932 100644
|
||||
index 05e738bcce..2a2a227f3b 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -756,8 +756,8 @@ static int mirror_exit_common(Job *job)
|
||||
@@ -809,8 +809,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);
|
||||
@@ -29,14 +30,17 @@ index 7d3c3252f3..fb12ccb932 100644
|
||||
}
|
||||
}
|
||||
bdrv_release_dirty_bitmap(s->dirty_bitmap);
|
||||
@@ -1754,8 +1754,8 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1971,11 +1971,8 @@ static BlockJob *mirror_start_job(
|
||||
}
|
||||
|
||||
if (s->sync_mode == MIRROR_SYNC_MODE_BITMAP) {
|
||||
- bdrv_merge_dirty_bitmap(s->dirty_bitmap, s->sync_bitmap,
|
||||
- NULL, &local_err);
|
||||
- if (local_err) {
|
||||
- goto fail;
|
||||
- }
|
||||
+ bdrv_dirty_bitmap_merge_internal(s->dirty_bitmap, s->sync_bitmap,
|
||||
+ NULL, true);
|
||||
if (local_err) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
bdrv_graph_wrlock();
|
@@ -20,11 +20,11 @@ intentionally keeping copyright and ownership of original test case to
|
||||
honor provenance.
|
||||
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
tests/qemu-iotests/384 | 547 +++++++
|
||||
tests/qemu-iotests/384.out | 2846 ++++++++++++++++++++++++++++++++++++
|
||||
tests/qemu-iotests/group | 1 +
|
||||
3 files changed, 3394 insertions(+)
|
||||
2 files changed, 3393 insertions(+)
|
||||
create mode 100755 tests/qemu-iotests/384
|
||||
create mode 100644 tests/qemu-iotests/384.out
|
||||
|
||||
@@ -3433,15 +3433,3 @@ index 0000000000..9b7408b6d6
|
||||
+{"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
|
||||
+{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
|
||||
+
|
||||
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
|
||||
index 025ed5238d..bee527c012 100644
|
||||
--- a/tests/qemu-iotests/group
|
||||
+++ b/tests/qemu-iotests/group
|
||||
@@ -270,6 +270,7 @@
|
||||
253 rw quick
|
||||
254 rw backing quick
|
||||
255 rw quick
|
||||
+384 rw
|
||||
256 rw auto quick
|
||||
257 rw
|
||||
258 rw quick
|
@@ -11,6 +11,9 @@ mode was never available for drive-mirror, it makes the interface more
|
||||
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 +++++++++++++++
|
||||
@@ -18,12 +21,12 @@ Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
3 files changed, 70 insertions(+), 59 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index fb12ccb932..dfce442e97 100644
|
||||
index 2a2a227f3b..87c0856979 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -1589,31 +1589,13 @@ static BlockJob *mirror_start_job(
|
||||
Error *local_err = NULL;
|
||||
int ret;
|
||||
@@ -1763,31 +1763,13 @@ static BlockJob *mirror_start_job(
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
- if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
|
||||
- error_setg(errp, "Sync mode '%s' not supported",
|
||||
@@ -59,17 +62,17 @@ index fb12ccb932..dfce442e97 100644
|
||||
|
||||
if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index 0d480f02c7..be87d65c02 100644
|
||||
index 9fab7ec554..158ac9314b 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -2953,7 +2953,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2873,7 +2873,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;
|
||||
@@ -90,7 +93,7 @@ index 0d480f02c7..be87d65c02 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));
|
@@ -1,34 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Thu, 6 Aug 2020 15:43:58 +0200
|
||||
Subject: [PATCH] block/block-copy: always align copied region to cluster size
|
||||
|
||||
Since commit 42ac214406e0 (block/block-copy: refactor task creation)
|
||||
block_copy_task_create calculates the area to be copied via
|
||||
bdrv_dirty_bitmap_next_dirty_area, but that can return an unaligned byte
|
||||
count if the image's last cluster end is not aligned to the bitmap's
|
||||
granularity.
|
||||
|
||||
Always ALIGN_UP the resulting bytes value to satisfy block_copy_do_copy,
|
||||
which requires the 'bytes' parameter to be aligned to cluster size.
|
||||
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
block/block-copy.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/block/block-copy.c b/block/block-copy.c
|
||||
index f7428a7c08..a30b9097ef 100644
|
||||
--- a/block/block-copy.c
|
||||
+++ b/block/block-copy.c
|
||||
@@ -142,6 +142,9 @@ static BlockCopyTask *block_copy_task_create(BlockCopyState *s,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+ assert(QEMU_IS_ALIGNED(offset, s->cluster_size));
|
||||
+ bytes = QEMU_ALIGN_UP(bytes, s->cluster_size);
|
||||
+
|
||||
/* region is dirty, so no existent tasks possible in it */
|
||||
assert(!find_conflicting_task(s, offset, bytes));
|
||||
|
206
debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
vendored
Normal file
206
debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Mon, 23 Aug 2021 11:28:32 +0200
|
||||
Subject: [PATCH] monitor/qmp: fix race with clients disconnecting early
|
||||
|
||||
The following sequence can produce a race condition that results in
|
||||
responses meant for different clients being sent to the wrong one:
|
||||
|
||||
(QMP, no OOB)
|
||||
1) client A connects
|
||||
2) client A sends 'qmp_capabilities'
|
||||
3) 'qmp_dispatch' runs in coroutine, schedules out to
|
||||
'do_qmp_dispatch_bh' and yields
|
||||
4) client A disconnects (i.e. aborts, crashes, etc...)
|
||||
5) client B connects
|
||||
6) 'do_qmp_dispatch_bh' runs 'qmp_capabilities' and wakes calling coroutine
|
||||
7) capabilities are now set and 'mon->commands' is set to '&qmp_commands'
|
||||
8) 'qmp_dispatch' returns to 'monitor_qmp_dispatch'
|
||||
9) success message is sent to client B *without it ever having sent
|
||||
'qmp_capabilities' itself*
|
||||
9a) even if client B ignores it, it will now presumably send it's own
|
||||
greeting, which will error because caps are already set
|
||||
|
||||
The fix proposed here uses an atomic, sequential connection number
|
||||
stored in the MonitorQMP struct, which is incremented everytime a new
|
||||
client connects. Since it is not changed on CHR_EVENT_CLOSED, the
|
||||
behaviour of allowing a client to disconnect only one side of the
|
||||
connection is retained.
|
||||
|
||||
The connection_nr needs to be exposed outside of the monitor subsystem,
|
||||
since qmp_dispatch lives in qapi code. It needs to be checked twice,
|
||||
once for actually running the command in the BH (fixes 7), and once for
|
||||
sending back a response (fixes 9).
|
||||
|
||||
This satisfies my local reproducer - using multiple clients constantly
|
||||
looping to open a connection, send the greeting, then exiting no longer
|
||||
crashes other, normally behaving clients with unrelated responses.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
include/monitor/monitor.h | 1 +
|
||||
monitor/monitor-internal.h | 7 +++++++
|
||||
monitor/monitor.c | 15 +++++++++++++++
|
||||
monitor/qmp.c | 15 ++++++++++++++-
|
||||
qapi/qmp-dispatch.c | 21 +++++++++++++++++----
|
||||
stubs/monitor-core.c | 5 +++++
|
||||
6 files changed, 59 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
|
||||
index c3740ec616..7f38ce6b8b 100644
|
||||
--- a/include/monitor/monitor.h
|
||||
+++ b/include/monitor/monitor.h
|
||||
@@ -16,6 +16,7 @@ extern QemuOptsList qemu_mon_opts;
|
||||
Monitor *monitor_cur(void);
|
||||
Monitor *monitor_set_cur(Coroutine *co, Monitor *mon);
|
||||
bool monitor_cur_is_qmp(void);
|
||||
+int monitor_get_connection_nr(const Monitor *mon);
|
||||
|
||||
void monitor_init_globals(void);
|
||||
void monitor_init_globals_core(void);
|
||||
diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
|
||||
index 5676eb334e..4c452a6aeb 100644
|
||||
--- a/monitor/monitor-internal.h
|
||||
+++ b/monitor/monitor-internal.h
|
||||
@@ -151,6 +151,13 @@ typedef struct {
|
||||
QemuMutex qmp_queue_lock;
|
||||
/* Input queue that holds all the parsed QMP requests */
|
||||
GQueue *qmp_requests;
|
||||
+
|
||||
+ /*
|
||||
+ * A sequential number that gets incremented on every new CHR_EVENT_OPENED.
|
||||
+ * Used to avoid leftover responses in BHs from being sent to the wrong
|
||||
+ * client. Access with atomics.
|
||||
+ */
|
||||
+ int connection_nr;
|
||||
} MonitorQMP;
|
||||
|
||||
/**
|
||||
diff --git a/monitor/monitor.c b/monitor/monitor.c
|
||||
index c5a5d30877..07775784d4 100644
|
||||
--- a/monitor/monitor.c
|
||||
+++ b/monitor/monitor.c
|
||||
@@ -116,6 +116,21 @@ bool monitor_cur_is_qmp(void)
|
||||
return cur_mon && monitor_is_qmp(cur_mon);
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * If @mon is a QMP monitor, return the connection_nr, otherwise -1.
|
||||
+ */
|
||||
+int monitor_get_connection_nr(const Monitor *mon)
|
||||
+{
|
||||
+ MonitorQMP *qmp_mon;
|
||||
+
|
||||
+ if (!monitor_is_qmp(mon)) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ qmp_mon = container_of(mon, MonitorQMP, common);
|
||||
+ return qatomic_read(&qmp_mon->connection_nr);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* 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 2f46cf9e49..f093e256e9 100644
|
||||
--- a/monitor/qmp.c
|
||||
+++ b/monitor/qmp.c
|
||||
@@ -165,6 +165,8 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
QDict *rsp;
|
||||
QDict *error;
|
||||
|
||||
+ int conn_nr_before = qatomic_read(&mon->connection_nr);
|
||||
+
|
||||
rsp = qmp_dispatch(mon->commands, req, qmp_oob_enabled(mon),
|
||||
&mon->common);
|
||||
|
||||
@@ -180,7 +182,17 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
}
|
||||
}
|
||||
|
||||
- monitor_qmp_respond(mon, rsp);
|
||||
+ /*
|
||||
+ * qmp_dispatch might have yielded and waited for a BH, in which case there
|
||||
+ * is a chance a new client connected in the meantime - if this happened,
|
||||
+ * the command will not have been executed, but we also need to ensure that
|
||||
+ * we don't send back a corresponding response on a line that no longer
|
||||
+ * belongs to this request.
|
||||
+ */
|
||||
+ if (conn_nr_before == qatomic_read(&mon->connection_nr)) {
|
||||
+ monitor_qmp_respond(mon, rsp);
|
||||
+ }
|
||||
+
|
||||
qobject_unref(rsp);
|
||||
}
|
||||
|
||||
@@ -461,6 +473,7 @@ static void monitor_qmp_event(void *opaque, QEMUChrEvent event)
|
||||
|
||||
switch (event) {
|
||||
case CHR_EVENT_OPENED:
|
||||
+ qatomic_inc_fetch(&mon->connection_nr);
|
||||
mon->commands = &qmp_cap_negotiation_commands;
|
||||
monitor_qmp_caps_reset(mon);
|
||||
data = qmp_greeting(mon);
|
||||
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
|
||||
index e569224eae..eb03782e91 100644
|
||||
--- a/qapi/qmp-dispatch.c
|
||||
+++ b/qapi/qmp-dispatch.c
|
||||
@@ -117,16 +117,28 @@ typedef struct QmpDispatchBH {
|
||||
QObject **ret;
|
||||
Error **errp;
|
||||
Coroutine *co;
|
||||
+ int conn_nr;
|
||||
} QmpDispatchBH;
|
||||
|
||||
static void do_qmp_dispatch_bh(void *opaque)
|
||||
{
|
||||
QmpDispatchBH *data = opaque;
|
||||
|
||||
- assert(monitor_cur() == NULL);
|
||||
- monitor_set_cur(qemu_coroutine_self(), data->cur_mon);
|
||||
- data->cmd->fn(data->args, data->ret, data->errp);
|
||||
- monitor_set_cur(qemu_coroutine_self(), NULL);
|
||||
+ /*
|
||||
+ * A QMP monitor tracks it's client with a connection number, if this
|
||||
+ * changes during the scheduling delay of this BH, we must not execute the
|
||||
+ * command. Otherwise a badly placed 'qmp_capabilities' might affect the
|
||||
+ * connection state of a client it was never meant for.
|
||||
+ */
|
||||
+ if (data->conn_nr == monitor_get_connection_nr(data->cur_mon)) {
|
||||
+ assert(monitor_cur() == NULL);
|
||||
+ monitor_set_cur(qemu_coroutine_self(), data->cur_mon);
|
||||
+ data->cmd->fn(data->args, data->ret, data->errp);
|
||||
+ monitor_set_cur(qemu_coroutine_self(), NULL);
|
||||
+ } else {
|
||||
+ error_setg(data->errp, "active monitor connection changed");
|
||||
+ }
|
||||
+
|
||||
aio_co_wake(data->co);
|
||||
}
|
||||
|
||||
@@ -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(iohandler_get_aio_context(), do_qmp_dispatch_bh,
|
||||
&data);
|
||||
diff --git a/stubs/monitor-core.c b/stubs/monitor-core.c
|
||||
index 1894cdfe1f..d74d0459f0 100644
|
||||
--- a/stubs/monitor-core.c
|
||||
+++ b/stubs/monitor-core.c
|
||||
@@ -12,6 +12,11 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+int monitor_get_connection_nr(const Monitor *mon)
|
||||
+{
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
void qapi_event_emit(QAPIEvent event, QDict *qdict)
|
||||
{
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
Date: Mon, 14 Sep 2020 19:32:21 +0200
|
||||
Subject: [PATCH] Revert "qemu-img convert: Don't pre-zero images"
|
||||
|
||||
This reverts commit edafc70c0c8510862f2f213a3acf7067113bcd08.
|
||||
|
||||
As it correlates with causing issues on LVM allocation
|
||||
https://bugzilla.proxmox.com/show_bug.cgi?id=3002
|
||||
---
|
||||
qemu-img.c | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 9635e9c001..c7884d248a 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -2079,6 +2079,15 @@ static int convert_do_copy(ImgConvertState *s)
|
||||
s->has_zero_init = bdrv_has_zero_init(blk_bs(s->target));
|
||||
}
|
||||
|
||||
+ if (!s->has_zero_init && !s->target_has_backing &&
|
||||
+ bdrv_can_write_zeroes_with_unmap(blk_bs(s->target)))
|
||||
+ {
|
||||
+ ret = blk_make_zero(s->target, BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK);
|
||||
+ if (ret == 0) {
|
||||
+ s->has_zero_init = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/* Allocate buffer for copied data. For compressed images, only one cluster
|
||||
* can be copied at a time. */
|
||||
if (s->compressed) {
|
100
debian/patches/extra/0002-ide-avoid-potential-deadlock-when-draining-during-tr.patch
vendored
Normal file
100
debian/patches/extra/0002-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 b14983ec54..41c543e627 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,87 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Gerd Hoffmann <kraxel@redhat.com>
|
||||
Date: Tue, 25 Aug 2020 07:36:36 +0200
|
||||
Subject: [PATCH] usb: fix setup_len init (CVE-2020-14364)
|
||||
|
||||
Store calculated setup_len in a local variable, verify it, and only
|
||||
write it to the struct (USBDevice->setup_len) in case it passed the
|
||||
sanity checks.
|
||||
|
||||
This prevents other code (do_token_{in,out} functions specifically)
|
||||
from working with invalid USBDevice->setup_len values and overrunning
|
||||
the USBDevice->setup_buf[] buffer.
|
||||
|
||||
Fixes: CVE-2020-14364
|
||||
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
||||
Tested-by: Gonglei <arei.gonglei@huawei.com>
|
||||
Reviewed-by: Li Qiang <liq3ea@gmail.com>
|
||||
Message-id: 20200825053636.29648-1-kraxel@redhat.com
|
||||
(cherry picked from commit b946434f2659a182afc17e155be6791ebfb302eb)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/usb/core.c | 16 ++++++++++------
|
||||
1 file changed, 10 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/hw/usb/core.c b/hw/usb/core.c
|
||||
index 5abd128b6b..5234dcc73f 100644
|
||||
--- a/hw/usb/core.c
|
||||
+++ b/hw/usb/core.c
|
||||
@@ -129,6 +129,7 @@ void usb_wakeup(USBEndpoint *ep, unsigned int stream)
|
||||
static void do_token_setup(USBDevice *s, USBPacket *p)
|
||||
{
|
||||
int request, value, index;
|
||||
+ unsigned int setup_len;
|
||||
|
||||
if (p->iov.size != 8) {
|
||||
p->status = USB_RET_STALL;
|
||||
@@ -138,14 +139,15 @@ static void do_token_setup(USBDevice *s, USBPacket *p)
|
||||
usb_packet_copy(p, s->setup_buf, p->iov.size);
|
||||
s->setup_index = 0;
|
||||
p->actual_length = 0;
|
||||
- s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
||||
- if (s->setup_len > sizeof(s->data_buf)) {
|
||||
+ setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
||||
+ if (setup_len > sizeof(s->data_buf)) {
|
||||
fprintf(stderr,
|
||||
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
|
||||
- s->setup_len, sizeof(s->data_buf));
|
||||
+ setup_len, sizeof(s->data_buf));
|
||||
p->status = USB_RET_STALL;
|
||||
return;
|
||||
}
|
||||
+ s->setup_len = setup_len;
|
||||
|
||||
request = (s->setup_buf[0] << 8) | s->setup_buf[1];
|
||||
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
|
||||
@@ -259,26 +261,28 @@ static void do_token_out(USBDevice *s, USBPacket *p)
|
||||
static void do_parameter(USBDevice *s, USBPacket *p)
|
||||
{
|
||||
int i, request, value, index;
|
||||
+ unsigned int setup_len;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
s->setup_buf[i] = p->parameter >> (i*8);
|
||||
}
|
||||
|
||||
s->setup_state = SETUP_STATE_PARAM;
|
||||
- s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
||||
s->setup_index = 0;
|
||||
|
||||
request = (s->setup_buf[0] << 8) | s->setup_buf[1];
|
||||
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
|
||||
index = (s->setup_buf[5] << 8) | s->setup_buf[4];
|
||||
|
||||
- if (s->setup_len > sizeof(s->data_buf)) {
|
||||
+ setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
||||
+ if (setup_len > sizeof(s->data_buf)) {
|
||||
fprintf(stderr,
|
||||
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
|
||||
- s->setup_len, sizeof(s->data_buf));
|
||||
+ setup_len, sizeof(s->data_buf));
|
||||
p->status = USB_RET_STALL;
|
||||
return;
|
||||
}
|
||||
+ s->setup_len = setup_len;
|
||||
|
||||
if (p->pid == USB_TOKEN_OUT) {
|
||||
usb_packet_copy(p, s->data_buf, s->setup_len);
|
@@ -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 9a00d4190a..bb72e1e5ca 100644
|
||||
index 56d1972d15..cfa0b832ba 100644
|
||||
--- a/block/file-posix.c
|
||||
+++ b/block/file-posix.c
|
||||
@@ -508,7 +508,7 @@ static QemuOptsList raw_runtime_opts = {
|
||||
@@ -565,7 +565,7 @@ static QemuOptsList raw_runtime_opts = {
|
||||
{
|
||||
.name = "locking",
|
||||
.type = QEMU_OPT_STRING,
|
||||
@@ -26,7 +26,7 @@ index 9a00d4190a..bb72e1e5ca 100644
|
||||
},
|
||||
{
|
||||
.name = "pr-manager",
|
||||
@@ -606,7 +606,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
@@ -665,7 +665,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
s->use_lock = false;
|
||||
break;
|
||||
case ON_OFF_AUTO_AUTO:
|
||||
|
@@ -5,22 +5,21 @@ Subject: [PATCH] PVE: [Config] Adjust network script path to /etc/kvm/
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
include/net/net.h | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
include/net/net.h | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/include/net/net.h b/include/net/net.h
|
||||
index e7ef42d62b..4fd1144e58 100644
|
||||
index cdd5b109b0..653a37e9d1 100644
|
||||
--- a/include/net/net.h
|
||||
+++ b/include/net/net.h
|
||||
@@ -209,8 +209,9 @@ 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);
|
||||
@@ -305,8 +305,8 @@ void netdev_add(QemuOpts *opts, Error **errp);
|
||||
|
||||
-#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
|
||||
-#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
|
||||
+#define DEFAULT_NETWORK_SCRIPT "/etc/kvm/kvm-ifup"
|
||||
+#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/kvm/kvm-ifdown"
|
||||
+
|
||||
int net_hub_id_for_client(NetClientState *nc, int *id);
|
||||
|
||||
-#define DEFAULT_NETWORK_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifup"
|
||||
-#define DEFAULT_NETWORK_DOWN_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifdown"
|
||||
+#define DEFAULT_NETWORK_SCRIPT CONFIG_SYSCONFDIR "/kvm/kvm-ifup"
|
||||
+#define DEFAULT_NETWORK_DOWN_SCRIPT CONFIG_SYSCONFDIR "/kvm/kvm-ifdown"
|
||||
#define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
|
||||
#define DEFAULT_BRIDGE_INTERFACE "br0"
|
||||
|
||||
|
@@ -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 e1a5c174dc..8973d3160f 100644
|
||||
index 76f24446a5..2a47d79b49 100644
|
||||
--- a/target/i386/cpu.h
|
||||
+++ b/target/i386/cpu.h
|
||||
@@ -1975,9 +1975,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
|
||||
@@ -2556,9 +2556,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
|
||||
#define CPU_RESOLVING_TYPE TYPE_X86_CPU
|
||||
|
||||
#ifdef TARGET_X86_64
|
||||
@@ -24,4 +24,4 @@ index e1a5c174dc..8973d3160f 100644
|
||||
+#define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("kvm32")
|
||||
#endif
|
||||
|
||||
#define cpu_signal_handler cpu_x86_signal_handler
|
||||
#define cpu_list x86_cpu_list
|
||||
|
@@ -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 ecc2ec2c55..ca04965ead 100644
|
||||
index 0326c63bec..d523d00200 100644
|
||||
--- a/ui/spice-core.c
|
||||
+++ b/ui/spice-core.c
|
||||
@@ -668,32 +668,35 @@ 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,7 +9,7 @@ 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 4f1448e2bc..715f06394c 100644
|
||||
index c6d25ae733..ccca125c3a 100644
|
||||
--- a/block/gluster.c
|
||||
+++ b/block/gluster.c
|
||||
@@ -42,7 +42,7 @@
|
||||
@@ -21,15 +21,15 @@ index 4f1448e2bc..715f06394c 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,
|
||||
@@ -421,6 +421,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,
|
||||
@@ -463,9 +464,15 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
|
||||
}
|
||||
}
|
||||
|
@@ -1,24 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Derumier <aderumier@odiso.com>
|
||||
Date: Mon, 6 Apr 2020 12:16:34 +0200
|
||||
Subject: [PATCH] PVE: [Config] smm_available = false
|
||||
|
||||
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/i386/x86.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
|
||||
index 67bee1bcb8..d954bf77b9 100644
|
||||
--- a/hw/i386/x86.c
|
||||
+++ b/hw/i386/x86.c
|
||||
@@ -856,7 +856,7 @@ bool x86_machine_is_smm_enabled(X86MachineState *x86ms)
|
||||
if (tcg_enabled() || qtest_enabled()) {
|
||||
smm_available = true;
|
||||
} else if (kvm_enabled()) {
|
||||
- smm_available = kvm_has_smm();
|
||||
+ smm_available = false;
|
||||
}
|
||||
|
||||
if (smm_available) {
|
@@ -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 688074c64b..8ae39abb46 100644
|
||||
index af984fb7db..bf143fac00 100644
|
||||
--- a/block/rbd.c
|
||||
+++ b/block/rbd.c
|
||||
@@ -651,6 +651,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,7 +16,7 @@ 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 715f06394c..6d02170d9b 100644
|
||||
index ccca125c3a..301a653ea7 100644
|
||||
--- a/block/gluster.c
|
||||
+++ b/block/gluster.c
|
||||
@@ -57,6 +57,7 @@ typedef struct GlusterAIOCB {
|
||||
@@ -27,7 +27,7 @@ index 715f06394c..6d02170d9b 100644
|
||||
} GlusterAIOCB;
|
||||
|
||||
typedef struct BDRVGlusterState {
|
||||
@@ -759,8 +760,10 @@ static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret,
|
||||
@@ -746,8 +747,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,15 +39,15 @@ index 715f06394c..6d02170d9b 100644
|
||||
}
|
||||
|
||||
aio_co_schedule(acb->aio_context, acb->coroutine);
|
||||
@@ -1028,6 +1031,7 @@ static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
@@ -1018,6 +1021,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);
|
||||
+ acb.is_write = true;
|
||||
|
||||
ret = glfs_zerofill_async(s->fd, offset, size, gluster_finish_aiocb, &acb);
|
||||
ret = glfs_zerofill_async(s->fd, offset, bytes, gluster_finish_aiocb, &acb);
|
||||
if (ret < 0) {
|
||||
@@ -1209,9 +1213,11 @@ static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs,
|
||||
@@ -1198,9 +1202,11 @@ static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs,
|
||||
acb.aio_context = bdrv_get_aio_context(bs);
|
||||
|
||||
if (write) {
|
||||
@@ -59,7 +59,7 @@ index 715f06394c..6d02170d9b 100644
|
||||
ret = glfs_preadv_async(s->fd, qiov->iov, qiov->niov, offset, 0,
|
||||
gluster_finish_aiocb, &acb);
|
||||
}
|
||||
@@ -1275,6 +1281,7 @@ static coroutine_fn int qemu_gluster_co_flush_to_disk(BlockDriverState *bs)
|
||||
@@ -1263,6 +1269,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,11 +67,11 @@ index 715f06394c..6d02170d9b 100644
|
||||
|
||||
ret = glfs_fsync_async(s->fd, gluster_finish_aiocb, &acb);
|
||||
if (ret < 0) {
|
||||
@@ -1321,6 +1328,7 @@ static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs,
|
||||
@@ -1311,6 +1318,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);
|
||||
+ acb.is_write = true;
|
||||
|
||||
ret = glfs_discard_async(s->fd, offset, size, gluster_finish_aiocb, &acb);
|
||||
ret = glfs_discard_async(s->fd, offset, bytes, gluster_finish_aiocb, &acb);
|
||||
if (ret < 0) {
|
@@ -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 5308773811..45aa024acc 100644
|
||||
index 2044c22a4c..4c8b5412c6 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -2955,7 +2955,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) {
|
@@ -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 bbaedb3c7a..9de23ec834 100644
|
||||
--- a/net/net.c
|
||||
+++ b/net/net.c
|
||||
@@ -1276,6 +1276,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 ddb113e5e5..eb3b785984 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 cffae27666..5a3e3de95f 100644
|
||||
--- a/qapi/pragma.json
|
||||
+++ b/qapi/pragma.json
|
||||
@@ -5,6 +5,7 @@
|
||||
{ 'pragma': {
|
||||
# Commands allowed to return a non-dictionary:
|
||||
'returns-whitelist': [
|
||||
+ 'get_link_status',
|
||||
'human-monitor-command',
|
||||
'qom-get',
|
||||
'query-migrate-cache-size',
|
@@ -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 | 191 +++++++++++++++++++++++++++++------------------
|
||||
2 files changed, 121 insertions(+), 74 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 b89c019b76..91d18a4819 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 b89c019b76..91d18a4819 100644
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 45aa024acc..af54d0896e 100644
|
||||
index 4c8b5412c6..d5fa89a204 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4819,10 +4819,12 @@ static int img_bitmap(int argc, char **argv)
|
||||
@@ -4997,10 +4997,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 45aa024acc..af54d0896e 100644
|
||||
};
|
||||
|
||||
struct DdIo {
|
||||
@@ -4898,6 +4900,19 @@ static int img_dd_skip(const char *arg,
|
||||
@@ -5076,6 +5078,19 @@ static int img_dd_skip(const char *arg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ index 45aa024acc..af54d0896e 100644
|
||||
static int img_dd(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -4938,6 +4953,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5116,6 +5131,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 45aa024acc..af54d0896e 100644
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
const struct option long_options[] = {
|
||||
@@ -5016,8 +5032,13 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5191,91 +5207,112 @@ static int img_dd(int argc, char **argv)
|
||||
arg = NULL;
|
||||
}
|
||||
|
||||
@@ -105,53 +106,30 @@ index 45aa024acc..af54d0896e 100644
|
||||
- error_report("Must specify both input and output files");
|
||||
+ if (!(dd.flags & C_IF) && (!fmt || strcmp(fmt, "raw") != 0)) {
|
||||
+ error_report("Input format must be raw when readin from stdin");
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
-
|
||||
- blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
|
||||
- force_share);
|
||||
-
|
||||
- if (!blk1) {
|
||||
+ if (!(dd.flags & C_OF) && strcmp(out_fmt, "raw") != 0) {
|
||||
+ error_report("Output format must be raw when writing to stdout");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
@@ -5029,85 +5050,101 @@ static int img_dd(int argc, char **argv)
|
||||
goto out;
|
||||
}
|
||||
|
||||
- blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
|
||||
- force_share);
|
||||
+ if (dd.flags & C_IF) {
|
||||
+ blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
|
||||
+ force_share);
|
||||
|
||||
- if (!blk1) {
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+ if (!blk1) {
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
|
||||
- drv = bdrv_find_format(out_fmt);
|
||||
- if (!drv) {
|
||||
- error_report("Unknown file format");
|
||||
+ if (dd.flags & C_OSIZE) {
|
||||
+ size = dd.osize;
|
||||
+ } else if (dd.flags & C_IF) {
|
||||
+ size = blk_getlength(blk1);
|
||||
+ if (size < 0) {
|
||||
+ error_report("Failed to get size for '%s'", in.filename);
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ } else if (dd.flags & C_COUNT) {
|
||||
+ size = dd.count * in.bsz;
|
||||
+ } else {
|
||||
+ error_report("Output size must be known when reading from stdin");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
- }
|
||||
- proto_drv = bdrv_find_protocol(out.filename, true, &local_err);
|
||||
+ if (dd.flags & C_IF) {
|
||||
+ blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
|
||||
+ force_share);
|
||||
|
||||
- if (!proto_drv) {
|
||||
- error_report_err(local_err);
|
||||
@@ -169,14 +147,50 @@ index 45aa024acc..af54d0896e 100644
|
||||
- proto_drv->format_name);
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+ if (!(dd.flags & C_OSIZE) && dd.flags & C_COUNT && dd.count <= INT64_MAX / in.bsz &&
|
||||
+ dd.count * in.bsz < size) {
|
||||
+ size = dd.count * in.bsz;
|
||||
+ if (!blk1) {
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
- 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);
|
||||
|
||||
- size = blk_getlength(blk1);
|
||||
- if (size < 0) {
|
||||
- error_report("Failed to get size for '%s'", in.filename);
|
||||
+ if (dd.flags & C_OSIZE) {
|
||||
+ size = dd.osize;
|
||||
+ } else if (dd.flags & C_IF) {
|
||||
+ size = blk_getlength(blk1);
|
||||
+ if (size < 0) {
|
||||
+ error_report("Failed to get size for '%s'", in.filename);
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ } else if (dd.flags & C_COUNT) {
|
||||
+ size = dd.count * in.bsz;
|
||||
+ } else {
|
||||
+ error_report("Output size must be known when reading from stdin");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
- if (dd.flags & C_COUNT && dd.count <= INT64_MAX / in.bsz &&
|
||||
+ if (!(dd.flags & C_OSIZE) && dd.flags & C_COUNT && dd.count <= INT64_MAX / in.bsz &&
|
||||
dd.count * in.bsz < size) {
|
||||
size = dd.count * in.bsz;
|
||||
}
|
||||
|
||||
- /* Overflow means the specified offset is beyond input image's size */
|
||||
- if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
|
||||
- size < in.bsz * in.offset)) {
|
||||
- qemu_opt_set_number(opts, BLOCK_OPT_SIZE, 0, &error_abort);
|
||||
- } else {
|
||||
- qemu_opt_set_number(opts, BLOCK_OPT_SIZE,
|
||||
- size - in.bsz * in.offset, &error_abort);
|
||||
- }
|
||||
+ if (dd.flags & C_OF) {
|
||||
+ drv = bdrv_find_format(out_fmt);
|
||||
+ if (!drv) {
|
||||
@@ -186,9 +200,11 @@ index 45aa024acc..af54d0896e 100644
|
||||
+ }
|
||||
+ proto_drv = bdrv_find_protocol(out.filename, true, &local_err);
|
||||
|
||||
- size = blk_getlength(blk1);
|
||||
- if (size < 0) {
|
||||
- error_report("Failed to get size for '%s'", in.filename);
|
||||
- ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
- if (ret < 0) {
|
||||
- error_reportf_err(local_err,
|
||||
- "%s: error while creating output image: ",
|
||||
- out.filename);
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
- }
|
||||
@@ -212,20 +228,18 @@ index 45aa024acc..af54d0896e 100644
|
||||
+ create_opts = qemu_opts_append(create_opts, drv->create_opts);
|
||||
+ create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
|
||||
|
||||
- if (dd.flags & C_COUNT && dd.count <= INT64_MAX / in.bsz &&
|
||||
- dd.count * in.bsz < size) {
|
||||
- size = dd.count * in.bsz;
|
||||
- }
|
||||
- /* TODO, we can't honour --image-opts for the target,
|
||||
- * since it needs to be given in a format compatible
|
||||
- * with the bdrv_create() call above which does not
|
||||
- * support image-opts style.
|
||||
- */
|
||||
- blk2 = img_open_file(out.filename, NULL, out_fmt, BDRV_O_RDWR,
|
||||
- false, false, false);
|
||||
+ opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
|
||||
|
||||
- /* Overflow means the specified offset is beyond input image's size */
|
||||
- if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
|
||||
- size < in.bsz * in.offset)) {
|
||||
- qemu_opt_set_number(opts, BLOCK_OPT_SIZE, 0, &error_abort);
|
||||
- } else {
|
||||
- qemu_opt_set_number(opts, BLOCK_OPT_SIZE,
|
||||
- size - in.bsz * in.offset, &error_abort);
|
||||
- }
|
||||
- if (!blk2) {
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+ /* Overflow means the specified offset is beyond input image's size */
|
||||
+ if (dd.flags & C_OSIZE) {
|
||||
+ qemu_opt_set_number(opts, BLOCK_OPT_SIZE, size, &error_abort);
|
||||
@@ -236,15 +250,7 @@ index 45aa024acc..af54d0896e 100644
|
||||
+ qemu_opt_set_number(opts, BLOCK_OPT_SIZE,
|
||||
+ size - in.bsz * in.offset, &error_abort);
|
||||
+ }
|
||||
|
||||
- ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
- if (ret < 0) {
|
||||
- error_reportf_err(local_err,
|
||||
- "%s: error while creating output image: ",
|
||||
- out.filename);
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
- }
|
||||
+
|
||||
+ ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
+ if (ret < 0) {
|
||||
+ error_reportf_err(local_err,
|
||||
@@ -253,14 +259,7 @@ index 45aa024acc..af54d0896e 100644
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
- /* TODO, we can't honour --image-opts for the target,
|
||||
- * since it needs to be given in a format compatible
|
||||
- * with the bdrv_create() call above which does not
|
||||
- * support image-opts style.
|
||||
- */
|
||||
- blk2 = img_open_file(out.filename, NULL, out_fmt, BDRV_O_RDWR,
|
||||
- false, false, false);
|
||||
+
|
||||
+ /* TODO, we can't honour --image-opts for the target,
|
||||
+ * since it needs to be given in a format compatible
|
||||
+ * with the bdrv_create() call above which does not
|
||||
@@ -268,10 +267,7 @@ index 45aa024acc..af54d0896e 100644
|
||||
+ */
|
||||
+ blk2 = img_open_file(out.filename, NULL, out_fmt, BDRV_O_RDWR,
|
||||
+ false, false, false);
|
||||
|
||||
- if (!blk2) {
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+
|
||||
+ if (!blk2) {
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
@@ -279,41 +275,54 @@ index 45aa024acc..af54d0896e 100644
|
||||
}
|
||||
|
||||
if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
|
||||
@@ -5125,11 +5162,17 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5292,20 +5329,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",
|
||||
@@ -5139,9 +5182,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 af54d0896e..0f1d464392 100644
|
||||
index d5fa89a204..d458e85af2 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4820,11 +4820,13 @@ static int img_bitmap(int argc, char **argv)
|
||||
@@ -4998,11 +4998,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 af54d0896e..0f1d464392 100644
|
||||
};
|
||||
|
||||
struct DdIo {
|
||||
@@ -4913,6 +4915,19 @@ static int img_dd_osize(const char *arg,
|
||||
@@ -5091,6 +5093,19 @@ static int img_dd_osize(const char *arg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -52,13 +53,13 @@ index af54d0896e..0f1d464392 100644
|
||||
static int img_dd(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -4927,12 +4942,14 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5105,12 +5120,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 af54d0896e..0f1d464392 100644
|
||||
};
|
||||
struct DdIo in = {
|
||||
.bsz = 512, /* Block size is by default 512 bytes */
|
||||
@@ -4954,6 +4971,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5132,6 +5149,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 af54d0896e..0f1d464392 100644
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
const struct option long_options[] = {
|
||||
@@ -5160,14 +5178,18 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5328,9 +5346,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) {
|
||||
@@ -5339,6 +5358,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;
|
121
debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-n-skip_create.patch
vendored
Normal file
121
debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-n-skip_create.patch
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Derumier <aderumier@odiso.com>
|
||||
Date: Mon, 6 Apr 2020 12:16:42 +0200
|
||||
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: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
docs/tools/qemu-img.rst | 11 ++++++++++-
|
||||
qemu-img-cmds.hx | 4 ++--
|
||||
qemu-img.c | 23 ++++++++++++++---------
|
||||
3 files changed, 26 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
|
||||
index 3653adb963..d83e8fb3c0 100644
|
||||
--- a/docs/tools/qemu-img.rst
|
||||
+++ b/docs/tools/qemu-img.rst
|
||||
@@ -212,6 +212,10 @@ Parameters to convert subcommand:
|
||||
|
||||
Parameters to dd subcommand:
|
||||
|
||||
+.. option:: -n
|
||||
+
|
||||
+ Skip the creation of the target volume
|
||||
+
|
||||
.. program:: qemu-img-dd
|
||||
|
||||
.. option:: bs=BLOCK_SIZE
|
||||
@@ -492,7 +496,7 @@ Command description:
|
||||
it doesn't need to be specified separately in this case.
|
||||
|
||||
|
||||
-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
|
||||
+.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
|
||||
|
||||
dd copies from *INPUT* file to *OUTPUT* file converting it from
|
||||
*FMT* format to *OUTPUT_FMT* format.
|
||||
@@ -503,6 +507,11 @@ Command description:
|
||||
|
||||
The size syntax is similar to :manpage:`dd(1)`'s size syntax.
|
||||
|
||||
+ If the ``-n`` option is specified, the target volume creation will be
|
||||
+ skipped. This is useful for formats such as ``rbd`` if the target
|
||||
+ volume has already been created with site specific options that cannot
|
||||
+ be supplied through ``qemu-img``.
|
||||
+
|
||||
.. option:: info [--object OBJECTDEF] [--image-opts] [-f FMT] [--output=OFMT] [--backing-chain] [-U] FILENAME
|
||||
|
||||
Give information about the disk image *FILENAME*. Use it in
|
||||
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
||||
index 048788b23d..0b29a67a06 100644
|
||||
--- a/qemu-img-cmds.hx
|
||||
+++ b/qemu-img-cmds.hx
|
||||
@@ -60,9 +60,9 @@ SRST
|
||||
ERST
|
||||
|
||||
DEF("dd", img_dd,
|
||||
- "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
|
||||
+ "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [-n] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
|
||||
SRST
|
||||
-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT
|
||||
+.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT
|
||||
ERST
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index d458e85af2..dc13efba8b 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -5122,7 +5122,7 @@ static int img_dd(int argc, char **argv)
|
||||
const char *fmt = NULL;
|
||||
int64_t size = 0, readsize = 0;
|
||||
int64_t out_pos, in_pos;
|
||||
- bool force_share = false;
|
||||
+ bool force_share = false, skip_create = false;
|
||||
struct DdInfo dd = {
|
||||
.flags = 0,
|
||||
.count = 0,
|
||||
@@ -5160,7 +5160,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
- while ((c = getopt_long(argc, argv, ":hf:O:U", long_options, NULL))) {
|
||||
+ while ((c = getopt_long(argc, argv, ":hf:O:Un", long_options, NULL))) {
|
||||
if (c == EOF) {
|
||||
break;
|
||||
}
|
||||
@@ -5180,6 +5180,9 @@ static int img_dd(int argc, char **argv)
|
||||
case 'h':
|
||||
help();
|
||||
break;
|
||||
+ case 'n':
|
||||
+ skip_create = true;
|
||||
+ break;
|
||||
case 'U':
|
||||
force_share = true;
|
||||
break;
|
||||
@@ -5310,13 +5313,15 @@ static int img_dd(int argc, char **argv)
|
||||
size - in.bsz * in.offset, &error_abort);
|
||||
}
|
||||
|
||||
- ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
- if (ret < 0) {
|
||||
- error_reportf_err(local_err,
|
||||
- "%s: error while creating output image: ",
|
||||
- out.filename);
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+ if (!skip_create) {
|
||||
+ ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
+ if (ret < 0) {
|
||||
+ error_reportf_err(local_err,
|
||||
+ "%s: error while creating output image: ",
|
||||
+ out.filename);
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* TODO, we can't honour --image-opts for the target,
|
130
debian/patches/pve/0012-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
vendored
Normal file
130
debian/patches/pve/0012-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
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
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
docs/tools/qemu-img.rst | 6 +++---
|
||||
qemu-img-cmds.hx | 4 ++--
|
||||
qemu-img.c | 33 +++++++++++++++++++++++++++++++--
|
||||
3 files changed, 36 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
|
||||
index d83e8fb3c0..61c6b21859 100644
|
||||
--- a/docs/tools/qemu-img.rst
|
||||
+++ b/docs/tools/qemu-img.rst
|
||||
@@ -496,10 +496,10 @@ Command description:
|
||||
it doesn't need to be specified separately in this case.
|
||||
|
||||
|
||||
-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
|
||||
+.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [-l SNAPSHOT_PARAM] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
|
||||
|
||||
- dd copies from *INPUT* file to *OUTPUT* file converting it from
|
||||
- *FMT* format to *OUTPUT_FMT* format.
|
||||
+ dd copies from *INPUT* file or snapshot *SNAPSHOT_PARAM* to *OUTPUT* file
|
||||
+ converting it from *FMT* format to *OUTPUT_FMT* format.
|
||||
|
||||
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 0b29a67a06..758f397232 100644
|
||||
--- a/qemu-img-cmds.hx
|
||||
+++ b/qemu-img-cmds.hx
|
||||
@@ -60,9 +60,9 @@ SRST
|
||||
ERST
|
||||
|
||||
DEF("dd", img_dd,
|
||||
- "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [-n] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
|
||||
+ "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [-n] [-l snapshot_param] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
|
||||
SRST
|
||||
-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT
|
||||
+.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [-l SNAPSHOT_PARAM] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT
|
||||
ERST
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index dc13efba8b..02f2e0aa45 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -5114,6 +5114,7 @@ static int img_dd(int argc, char **argv)
|
||||
BlockDriver *drv = NULL, *proto_drv = NULL;
|
||||
BlockBackend *blk1 = NULL, *blk2 = NULL;
|
||||
QemuOpts *opts = NULL;
|
||||
+ QemuOpts *sn_opts = NULL;
|
||||
QemuOptsList *create_opts = NULL;
|
||||
Error *local_err = NULL;
|
||||
bool image_opts = false;
|
||||
@@ -5123,6 +5124,7 @@ static int img_dd(int argc, char **argv)
|
||||
int64_t size = 0, readsize = 0;
|
||||
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,
|
||||
@@ -5160,7 +5162,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
- while ((c = getopt_long(argc, argv, ":hf:O:Un", long_options, NULL))) {
|
||||
+ while ((c = getopt_long(argc, argv, ":hf:O:l:Un", long_options, NULL))) {
|
||||
if (c == EOF) {
|
||||
break;
|
||||
}
|
||||
@@ -5183,6 +5185,19 @@ static int img_dd(int argc, char **argv)
|
||||
case 'n':
|
||||
skip_create = true;
|
||||
break;
|
||||
+ case 'l':
|
||||
+ if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
|
||||
+ sn_opts = qemu_opts_parse_noisily(&internal_snapshot_opts,
|
||||
+ optarg, false);
|
||||
+ if (!sn_opts) {
|
||||
+ error_report("Failed in parsing snapshot param '%s'",
|
||||
+ optarg);
|
||||
+ goto out;
|
||||
+ }
|
||||
+ } else {
|
||||
+ snapshot_name = optarg;
|
||||
+ }
|
||||
+ break;
|
||||
case 'U':
|
||||
force_share = true;
|
||||
break;
|
||||
@@ -5242,11 +5257,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);
|
||||
-
|
||||
if (!blk1) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
+ if (sn_opts) {
|
||||
+ bdrv_snapshot_load_tmp(blk_bs(blk1),
|
||||
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID),
|
||||
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME),
|
||||
+ &local_err);
|
||||
+ } else if (snapshot_name != NULL) {
|
||||
+ bdrv_snapshot_load_tmp_by_id_or_name(blk_bs(blk1), snapshot_name,
|
||||
+ &local_err);
|
||||
+ }
|
||||
+ if (local_err) {
|
||||
+ error_reportf_err(local_err, "Failed to load snapshot: ");
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
|
||||
if (dd.flags & C_OSIZE) {
|
||||
@@ -5401,6 +5429,7 @@ static int img_dd(int argc, char **argv)
|
||||
out:
|
||||
g_free(arg);
|
||||
qemu_opts_del(opts);
|
||||
+ qemu_opts_del(sn_opts);
|
||||
qemu_opts_free(create_opts);
|
||||
blk_unref(blk1);
|
||||
blk_unref(blk2);
|
@@ -1,65 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Derumier <aderumier@odiso.com>
|
||||
Date: Mon, 6 Apr 2020 12:16:42 +0200
|
||||
Subject: [PATCH] PVE: [Up] qemu-img dd: add -n skip_create
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
qemu-img.c | 23 ++++++++++++++---------
|
||||
1 file changed, 14 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 0f1d464392..9635e9c001 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4944,7 +4944,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;
|
||||
- bool force_share = false;
|
||||
+ bool force_share = false, skip_create = false;
|
||||
struct DdInfo dd = {
|
||||
.flags = 0,
|
||||
.count = 0,
|
||||
@@ -4982,7 +4982,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
- while ((c = getopt_long(argc, argv, ":hf:O:U", long_options, NULL))) {
|
||||
+ while ((c = getopt_long(argc, argv, ":hf:O:U:n", long_options, NULL))) {
|
||||
if (c == EOF) {
|
||||
break;
|
||||
}
|
||||
@@ -5002,6 +5002,9 @@ static int img_dd(int argc, char **argv)
|
||||
case 'h':
|
||||
help();
|
||||
break;
|
||||
+ case 'n':
|
||||
+ skip_create = true;
|
||||
+ break;
|
||||
case 'U':
|
||||
force_share = true;
|
||||
break;
|
||||
@@ -5142,13 +5145,15 @@ static int img_dd(int argc, char **argv)
|
||||
size - in.bsz * in.offset, &error_abort);
|
||||
}
|
||||
|
||||
- ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
- if (ret < 0) {
|
||||
- error_reportf_err(local_err,
|
||||
- "%s: error while creating output image: ",
|
||||
- out.filename);
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+ if (!skip_create) {
|
||||
+ ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
+ if (ret < 0) {
|
||||
+ error_reportf_err(local_err,
|
||||
+ "%s: error while creating output image: ",
|
||||
+ out.filename);
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* TODO, we can't honour --image-opts for the target,
|
@@ -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/misc.json | 22 +++++++++++++++++++++-
|
||||
3 files changed, 81 insertions(+), 4 deletions(-)
|
||||
qapi/machine.json | 22 +++++++++++++++++++++-
|
||||
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 c6325cdcaa..7f817d622d 100644
|
||||
--- a/hw/core/machine-hmp-cmds.c
|
||||
+++ b/hw/core/machine-hmp-cmds.c
|
||||
@@ -179,7 +179,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 22cb5df717..6513adb0a6 100644
|
||||
index 2eb5a14fa2..aa2fd6c32f 100644
|
||||
--- a/hw/virtio/virtio-balloon.c
|
||||
+++ b/hw/virtio/virtio-balloon.c
|
||||
@@ -805,8 +805,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
|
||||
@@ -795,8 +795,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 22cb5df717..6513adb0a6 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 ae4b6a4246..6e26ea2cd0 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -660,7 +660,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/misc.json b/qapi/misc.json
|
||||
index 9d32820dc1..44b1fb6fa7 100644
|
||||
--- a/qapi/misc.json
|
||||
+++ b/qapi/misc.json
|
||||
@@ -226,10 +226,30 @@
|
||||
#
|
||||
# @actual: the number of bytes the balloon currently contains
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index a6b8795b09..9f7ed0eaa0 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -1163,9 +1163,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
|
||||
+#
|
||||
@@ -122,8 +126,7 @@ index 9d32820dc1..44b1fb6fa7 100644
|
||||
+#
|
||||
+# @max_mem: amount of memory (in bytes) assigned to the guest
|
||||
+#
|
||||
# Since: 0.14.0
|
||||
#
|
||||
# Since: 0.14
|
||||
##
|
||||
-{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
|
||||
+{ 'struct': 'BalloonInfo',
|
||||
@@ -134,3 +137,15 @@ index 9d32820dc1..44b1fb6fa7 100644
|
||||
|
||||
##
|
||||
# @query-balloon:
|
||||
diff --git a/qapi/pragma.json b/qapi/pragma.json
|
||||
index 023a2ef7bc..6aaa9cb975 100644
|
||||
--- a/qapi/pragma.json
|
||||
+++ b/qapi/pragma.json
|
||||
@@ -81,6 +81,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,41 +13,41 @@ 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 963088b798..32f630549e 100644
|
||||
index 1bc21b84a4..93fb4bc24a 100644
|
||||
--- a/hw/core/machine-qmp-cmds.c
|
||||
+++ b/hw/core/machine-qmp-cmds.c
|
||||
@@ -234,6 +234,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
||||
info->hotpluggable_cpus = mc->has_hotpluggable_cpus;
|
||||
@@ -91,6 +91,12 @@ MachineInfoList *qmp_query_machines(bool has_compat_props, bool compat_props,
|
||||
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;
|
||||
+ info->is_current = true;
|
||||
+ }
|
||||
+
|
||||
if (mc->default_cpu_type) {
|
||||
info->default_cpu_type = g_strdup(mc->default_cpu_type);
|
||||
info->has_default_cpu_type = true;
|
||||
if (default_cpu_type) {
|
||||
info->default_cpu_type = g_strdup(default_cpu_type);
|
||||
}
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 481b1f07ec..268044a34b 100644
|
||||
index 9f7ed0eaa0..16366b774a 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -342,6 +342,8 @@
|
||||
@@ -167,6 +167,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.0)
|
||||
# (since 1.5)
|
||||
#
|
||||
@@ -361,7 +363,7 @@
|
||||
@@ -199,7 +201,7 @@
|
||||
##
|
||||
{ 'struct': 'MachineInfo',
|
||||
'data': { 'name': 'str', '*alias': 'str',
|
||||
- '*is-default': 'bool', 'cpu-max': 'int',
|
||||
+ '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
|
||||
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
|
||||
'deprecated': 'bool', '*default-cpu-type': 'str' } }
|
||||
|
||||
'deprecated': 'bool', '*default-cpu-type': 'str',
|
||||
'*default-ram-id': 'str', 'acpi': 'bool',
|
@@ -6,40 +6,41 @@ 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 9d6721037f..af87b18db9 100644
|
||||
index c536d4e524..c2df48959b 100644
|
||||
--- a/qapi/ui.json
|
||||
+++ b/qapi/ui.json
|
||||
@@ -214,11 +214,14 @@
|
||||
@@ -312,11 +312,14 @@
|
||||
#
|
||||
# @channels: a list of @SpiceChannel for each active spice channel
|
||||
#
|
||||
+# @ticket: The last ticket set with set_password
|
||||
+#
|
||||
# Since: 0.14.0
|
||||
# Since: 0.14
|
||||
##
|
||||
{ 'struct': 'SpiceInfo',
|
||||
'data': {'enabled': 'bool', 'migrated': 'bool', '*host': 'str', '*port': 'int',
|
||||
'*tls-port': 'int', '*auth': 'str', '*compiled-version': 'str',
|
||||
+ '*ticket': 'str',
|
||||
'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChannel']},
|
||||
'if': 'defined(CONFIG_SPICE)' }
|
||||
'if': 'CONFIG_SPICE' }
|
||||
|
||||
diff --git a/ui/spice-core.c b/ui/spice-core.c
|
||||
index ca04965ead..243466c13d 100644
|
||||
index d523d00200..c76c224706 100644
|
||||
--- a/ui/spice-core.c
|
||||
+++ b/ui/spice-core.c
|
||||
@@ -539,6 +539,11 @@ SpiceInfo *qmp_query_spice(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..e57ab2ae40
|
||||
--- /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 "system/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 9aa48b290e..cf66c78681 100644
|
||||
--- a/migration/meson.build
|
||||
+++ b/migration/meson.build
|
||||
@@ -14,6 +14,7 @@ system_ss.add(files(
|
||||
'block-active.c',
|
||||
'channel.c',
|
||||
'channel-block.c',
|
||||
+ 'channel-savevm-async.c',
|
||||
'cpr.c',
|
||||
'cpr-transfer.c',
|
||||
'cpu-throttle.c',
|
File diff suppressed because it is too large
Load Diff
208
debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
vendored
Normal file
208
debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
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 | 48 +++++++++++++++++++++++++++-------------
|
||||
migration/qemu-file.h | 2 ++
|
||||
migration/savevm-async.c | 5 +++--
|
||||
3 files changed, 38 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
|
||||
index 1303a5bf58..6e2d58d5c0 100644
|
||||
--- a/migration/qemu-file.c
|
||||
+++ b/migration/qemu-file.c
|
||||
@@ -34,8 +34,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)
|
||||
|
||||
typedef struct FdEntry {
|
||||
QTAILQ_ENTRY(FdEntry) entry;
|
||||
@@ -48,7 +48,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];
|
||||
@@ -108,7 +109,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;
|
||||
|
||||
@@ -119,6 +122,8 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
|
||||
f->is_writable = is_writable;
|
||||
f->can_pass_fd = qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_FD_PASS);
|
||||
QTAILQ_INIT(&f->fds);
|
||||
+ f->buf_allocated_size = buffer_size;
|
||||
+ f->buf = malloc(buffer_size);
|
||||
|
||||
return f;
|
||||
}
|
||||
@@ -129,17 +134,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);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -339,7 +354,7 @@ static ssize_t coroutine_mixed_fn qemu_fill_buffer(QEMUFile *f)
|
||||
}
|
||||
|
||||
do {
|
||||
- struct iovec iov = { f->buf + pending, IO_BUF_SIZE - pending };
|
||||
+ struct iovec iov = { f->buf + pending, f->buf_allocated_size - pending };
|
||||
len = qio_channel_readv_full(f->ioc, &iov, 1, pfds, pnfd, 0,
|
||||
&local_error);
|
||||
if (len == QIO_CHANNEL_ERR_BLOCK) {
|
||||
@@ -443,6 +458,9 @@ int qemu_fclose(QEMUFile *f)
|
||||
g_free(fde);
|
||||
}
|
||||
g_clear_pointer(&f->ioc, object_unref);
|
||||
+
|
||||
+ free(f->buf);
|
||||
+
|
||||
error_free(f->last_error_obj);
|
||||
g_free(f);
|
||||
trace_qemu_file_fclose();
|
||||
@@ -491,7 +509,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);
|
||||
}
|
||||
}
|
||||
@@ -516,7 +534,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;
|
||||
}
|
||||
@@ -662,8 +680,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;
|
||||
@@ -713,7 +731,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;
|
||||
}
|
||||
@@ -747,7 +765,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;
|
||||
|
||||
@@ -772,7 +790,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);
|
||||
diff --git a/migration/qemu-file.h b/migration/qemu-file.h
|
||||
index f5b9f430e0..0179b90698 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);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(QEMUFile, qemu_fclose)
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index 56e0fa6c69..730b815494 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -409,7 +409,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_setg(errp, "failed to open '%s'", statefile);
|
||||
@@ -544,7 +544,8 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
|
||||
bdrv_op_block_all(bs, 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;
|
@@ -1,183 +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] 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>
|
||||
---
|
||||
migration/qemu-file.c | 36 ++++++++++++++++++++++++------------
|
||||
migration/qemu-file.h | 1 +
|
||||
savevm-async.c | 4 ++--
|
||||
3 files changed, 27 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
|
||||
index be21518c57..a4d2e2c8ff 100644
|
||||
--- a/migration/qemu-file.c
|
||||
+++ b/migration/qemu-file.c
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "trace.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
-#define IO_BUF_SIZE 32768
|
||||
+#define DEFAULT_IO_BUF_SIZE 32768
|
||||
#define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 64)
|
||||
|
||||
struct QEMUFile {
|
||||
@@ -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];
|
||||
@@ -101,7 +102,7 @@ bool qemu_file_mode_is_not_valid(const char *mode)
|
||||
return false;
|
||||
}
|
||||
|
||||
-QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
|
||||
+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, size_t buffer_size)
|
||||
{
|
||||
QEMUFile *f;
|
||||
|
||||
@@ -109,9 +110,17 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
|
||||
|
||||
f->opaque = opaque;
|
||||
f->ops = ops;
|
||||
+ f->buf_allocated_size = buffer_size;
|
||||
+ f->buf = malloc(buffer_size);
|
||||
+
|
||||
return f;
|
||||
}
|
||||
|
||||
+QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
|
||||
+{
|
||||
+ return qemu_fopen_ops_sized(opaque, ops, DEFAULT_IO_BUF_SIZE);
|
||||
+}
|
||||
+
|
||||
|
||||
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks)
|
||||
{
|
||||
@@ -346,7 +355,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;
|
||||
@@ -386,6 +395,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.
|
||||
*/
|
||||
@@ -435,7 +447,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);
|
||||
}
|
||||
}
|
||||
@@ -461,7 +473,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;
|
||||
}
|
||||
@@ -508,8 +520,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;
|
||||
@@ -559,7 +571,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;
|
||||
}
|
||||
@@ -593,7 +605,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;
|
||||
|
||||
@@ -618,7 +630,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);
|
||||
@@ -770,7 +782,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 a9b6d6ccb7..8752d27c74 100644
|
||||
--- a/migration/qemu-file.h
|
||||
+++ b/migration/qemu-file.h
|
||||
@@ -120,6 +120,7 @@ typedef struct QEMUFileHooks {
|
||||
} QEMUFileHooks;
|
||||
|
||||
QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops);
|
||||
+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, 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/savevm-async.c b/savevm-async.c
|
||||
index f918e18dce..156b7a030e 100644
|
||||
--- a/savevm-async.c
|
||||
+++ b/savevm-async.c
|
||||
@@ -392,7 +392,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, 4 * 1024 * 1024);
|
||||
|
||||
if (!snap_state.file) {
|
||||
error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
|
||||
@@ -514,7 +514,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, 4 * 1024 * 1024);
|
||||
if (!f) {
|
||||
error_setg(errp, "Could not open VM state file");
|
||||
goto the_end;
|
@@ -4,30 +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>
|
||||
[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/Makefile.objs | 1 +
|
||||
block/zeroinit.c | 198 ++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 199 insertions(+)
|
||||
block/meson.build | 1 +
|
||||
block/zeroinit.c | 207 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 208 insertions(+)
|
||||
create mode 100644 block/zeroinit.c
|
||||
|
||||
diff --git a/block/Makefile.objs b/block/Makefile.objs
|
||||
index 19c6f371c9..d1a9227b8f 100644
|
||||
--- a/block/Makefile.objs
|
||||
+++ b/block/Makefile.objs
|
||||
@@ -11,6 +11,7 @@ block-obj-$(CONFIG_QED) += qed.o qed-l2-cache.o qed-table.o qed-cluster.o
|
||||
block-obj-$(CONFIG_QED) += qed-check.o
|
||||
block-obj-y += vhdx.o vhdx-endian.o vhdx-log.o
|
||||
block-obj-y += quorum.o
|
||||
+block-obj-y += zeroinit.o
|
||||
block-obj-y += blkdebug.o blkverify.o blkreplay.o
|
||||
block-obj-$(CONFIG_PARALLELS) += parallels.o
|
||||
block-obj-y += blklogwrites.o
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index 34b1b2a306..a21d9a5411 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -39,6 +39,7 @@ block_ss.add(files(
|
||||
'throttle.c',
|
||||
'throttle-groups.c',
|
||||
'write-threshold.c',
|
||||
+ 'zeroinit.c',
|
||||
), zstd, zlib)
|
||||
|
||||
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..4fbb80eab0
|
||||
index 0000000000..f9d513db15
|
||||
--- /dev/null
|
||||
+++ b/block/zeroinit.c
|
||||
@@ -0,0 +1,198 @@
|
||||
@@ -0,0 +1,207 @@
|
||||
+/*
|
||||
+ * Filter to fake a zero-initialized block device.
|
||||
+ *
|
||||
@@ -41,8 +45,10 @@ index 0000000000..4fbb80eab0
|
||||
+#include "qemu/osdep.h"
|
||||
+#include "qapi/error.h"
|
||||
+#include "block/block_int.h"
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
+#include "qapi/qmp/qstring.h"
|
||||
+#include "block/block-io.h"
|
||||
+#include "block/graph-lock.h"
|
||||
+#include "qobject/qdict.h"
|
||||
+#include "qobject/qstring.h"
|
||||
+#include "qemu/cutils.h"
|
||||
+#include "qemu/option.h"
|
||||
+#include "qemu/module.h"
|
||||
@@ -106,10 +112,9 @@ index 0000000000..4fbb80eab0
|
||||
+ }
|
||||
+
|
||||
+ /* 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;
|
||||
+ }
|
||||
@@ -120,7 +125,9 @@ index 0000000000..4fbb80eab0
|
||||
+ ret = 0;
|
||||
+fail:
|
||||
+ if (ret < 0) {
|
||||
+ bdrv_graph_wrlock();
|
||||
+ bdrv_unref_child(bs, bs->file);
|
||||
+ bdrv_graph_wrunlock();
|
||||
+ }
|
||||
+ qemu_opts_del(opts);
|
||||
+ return ret;
|
||||
@@ -132,28 +139,32 @@ index 0000000000..4fbb80eab0
|
||||
+ (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,
|
||||
+ uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int 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,
|
||||
+ int count, 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)
|
||||
+ return 0;
|
||||
+ return bdrv_pwrite_zeroes(bs->file, offset, count, flags);
|
||||
+ return bdrv_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_pwritev(BlockDriverState *bs,
|
||||
+ uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int 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;
|
||||
@@ -162,33 +173,37 @@ index 0000000000..4fbb80eab0
|
||||
+ 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, int count)
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+zeroinit_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
+{
|
||||
+ return bdrv_co_pdiscard(bs->file, offset, count);
|
||||
+ 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 = {
|
||||
@@ -197,9 +212,9 @@ index 0000000000..4fbb80eab0
|
||||
+ .instance_size = sizeof(BDRVZeroinitState),
|
||||
+
|
||||
+ .bdrv_parse_filename = zeroinit_parse_filename,
|
||||
+ .bdrv_file_open = zeroinit_open,
|
||||
+ .bdrv_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,
|
||||
+
|
||||
@@ -212,12 +227,10 @@ index 0000000000..4fbb80eab0
|
||||
+
|
||||
+ .bdrv_has_zero_init = zeroinit_has_zero_init,
|
||||
+
|
||||
+ .bdrv_co_block_status = bdrv_co_block_status_from_file,
|
||||
+
|
||||
+ .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 d32995cc50..abfde19ce0 100644
|
||||
index defee0c06a..fb980a05cf 100644
|
||||
--- a/qemu-options.hx
|
||||
+++ b/qemu-options.hx
|
||||
@@ -914,6 +914,9 @@ DEFHEADING()
|
||||
@@ -1280,6 +1280,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,21 +27,21 @@ index d32995cc50..abfde19ce0 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 670b7e427c..366e30e594 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -2832,6 +2832,7 @@ static void create_default_memdev(MachineState *ms, const char *path)
|
||||
void qemu_init(int argc, char **argv, char **envp)
|
||||
{
|
||||
int i;
|
||||
diff --git a/system/vl.c b/system/vl.c
|
||||
index 9b36ace6b4..452742ab58 100644
|
||||
--- a/system/vl.c
|
||||
+++ b/system/vl.c
|
||||
@@ -2854,6 +2854,7 @@ void qemu_init(int argc, char **argv)
|
||||
MachineClass *machine_class;
|
||||
bool userconfig = true;
|
||||
FILE *vmstate_dump_file = NULL;
|
||||
+ long vm_id;
|
||||
int snapshot, linux_boot;
|
||||
const char *initrd_filename;
|
||||
const char *kernel_filename, *kernel_cmdline;
|
||||
@@ -3530,6 +3531,13 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
qemu_add_opts(&qemu_drive_opts);
|
||||
qemu_add_drive_opts(&qemu_legacy_drive_opts);
|
||||
@@ -3472,6 +3473,13 @@ void qemu_init(int argc, char **argv)
|
||||
machine_parse_property_opt(qemu_find_opts("smp-opts"),
|
||||
"smp", optarg);
|
||||
break;
|
||||
+ case QEMU_OPTION_id:
|
||||
+ vm_id = strtol(optarg, (char **)&optarg, 10);
|
||||
@@ -50,6 +50,6 @@ index 670b7e427c..366e30e594 100644
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ break;
|
||||
#ifdef CONFIG_VNC
|
||||
case QEMU_OPTION_vnc:
|
||||
vnc_parse(optarg, &error_fatal);
|
||||
break;
|
||||
vnc_parse(optarg);
|
||||
|
@@ -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 81addd6390..c2026b07c5 100644
|
||||
index 2a3e878c4d..efbed1aea3 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);
|
||||
|
@@ -8,15 +8,15 @@ Otherwise creating images on nfs/cifs can be problematic.
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/file-posix.c | 61 +++++++++++++++++++++++++++++---------------
|
||||
qapi/block-core.json | 3 ++-
|
||||
2 files changed, 43 insertions(+), 21 deletions(-)
|
||||
block/file-posix.c | 59 ++++++++++++++++++++++++++++++--------------
|
||||
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 bb72e1e5ca..914bd1f367 100644
|
||||
index cfa0b832ba..d5c28cccc9 100644
|
||||
--- a/block/file-posix.c
|
||||
+++ b/block/file-posix.c
|
||||
@@ -2390,6 +2390,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -2897,6 +2897,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
int fd;
|
||||
uint64_t perm, shared;
|
||||
int result = 0;
|
||||
@@ -24,7 +24,7 @@ index bb72e1e5ca..914bd1f367 100644
|
||||
|
||||
/* Validate options and set default values */
|
||||
assert(options->driver == BLOCKDEV_DRIVER_FILE);
|
||||
@@ -2431,19 +2432,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -2937,19 +2938,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 bb72e1e5ca..914bd1f367 100644
|
||||
}
|
||||
|
||||
/* Clear the file by truncating it to 0 */
|
||||
@@ -2497,13 +2501,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -3003,13 +3007,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
}
|
||||
|
||||
out_unlock:
|
||||
@@ -82,7 +82,7 @@ index bb72e1e5ca..914bd1f367 100644
|
||||
}
|
||||
|
||||
out_close:
|
||||
@@ -2528,6 +2534,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
@@ -3033,6 +3039,7 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
PreallocMode prealloc;
|
||||
char *buf = NULL;
|
||||
Error *local_err = NULL;
|
||||
@@ -90,7 +90,7 @@ index bb72e1e5ca..914bd1f367 100644
|
||||
|
||||
/* Skip file: protocol prefix */
|
||||
strstart(filename, "file:", &filename);
|
||||
@@ -2550,6 +2557,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
@@ -3055,6 +3062,18 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ index bb72e1e5ca..914bd1f367 100644
|
||||
options = (BlockdevCreateOptions) {
|
||||
.driver = BLOCKDEV_DRIVER_FILE,
|
||||
.u.file = {
|
||||
@@ -2561,6 +2580,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
@@ -3066,6 +3085,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,
|
||||
@@ -118,20 +118,22 @@ index bb72e1e5ca..914bd1f367 100644
|
||||
},
|
||||
};
|
||||
return raw_co_create(&options, errp);
|
||||
@@ -3107,7 +3128,7 @@ static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared,
|
||||
}
|
||||
|
||||
/* Copy locks to the new fd */
|
||||
- if (s->perm_change_fd) {
|
||||
+ if (s->use_lock && s->perm_change_fd) {
|
||||
ret = raw_apply_lock_bytes(NULL, s->perm_change_fd, perm, ~shared,
|
||||
false, errp);
|
||||
if (ret < 0) {
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 197bdc1c36..ea5fae22ae 100644
|
||||
index 0e5f148d30..1c05413916 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -4178,7 +4178,8 @@
|
||||
@@ -5016,6 +5016,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',
|
||||
@@ -5023,7 +5027,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 d433ceae5b..a16cf3532d 100644
|
||||
index f093e256e9..78f1c8e3c8 100644
|
||||
--- a/monitor/qmp.c
|
||||
+++ b/monitor/qmp.c
|
||||
@@ -409,8 +409,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
|
||||
@@ -534,8 +534,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 8d1a90c6cf..413902777e 100644
|
||||
index 63c6ef93d2..9a34017e5a 100644
|
||||
--- a/hw/core/machine.c
|
||||
+++ b/hw/core/machine.c
|
||||
@@ -66,7 +66,8 @@ GlobalProperty hw_compat_4_0[] = {
|
||||
@@ -193,7 +193,8 @@ GlobalProperty hw_compat_4_0[] = {
|
||||
{ "virtio-vga", "edid", "false" },
|
||||
{ "virtio-gpu-device", "edid", "false" },
|
||||
{ "virtio-device", "use-started", "false" },
|
||||
|
@@ -10,92 +10,119 @@ Version is made available as 'pve-version' in query-machines (same as,
|
||||
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 | 3 ++-
|
||||
softmmu/vl.c | 15 ++++++++++++++-
|
||||
4 files changed, 24 insertions(+), 2 deletions(-)
|
||||
qapi/machine.json | 3 +++
|
||||
system/vl.c | 24 ++++++++++++++++++++++++
|
||||
4 files changed, 34 insertions(+)
|
||||
|
||||
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
|
||||
index 32f630549e..71e19db4e1 100644
|
||||
index 93fb4bc24a..b9999423b4 100644
|
||||
--- a/hw/core/machine-qmp-cmds.c
|
||||
+++ b/hw/core/machine-qmp-cmds.c
|
||||
@@ -238,6 +238,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
||||
@@ -95,6 +95,11 @@ MachineInfoList *qmp_query_machines(bool has_compat_props, bool compat_props,
|
||||
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) {
|
||||
if (default_cpu_type) {
|
||||
diff --git a/include/hw/boards.h b/include/hw/boards.h
|
||||
index 426ce5f625..3bce25a25f 100644
|
||||
index f22b2e7fc7..8ada4d5832 100644
|
||||
--- a/include/hw/boards.h
|
||||
+++ b/include/hw/boards.h
|
||||
@@ -170,6 +170,8 @@ struct MachineClass {
|
||||
@@ -271,6 +271,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, ResetType type);
|
||||
void (*wakeup)(MachineState *state);
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 268044a34b..7a811a5860 100644
|
||||
index 16366b774a..12cfd3f260 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -365,7 +365,8 @@
|
||||
'data': { 'name': 'str', '*alias': 'str',
|
||||
'*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
|
||||
@@ -189,6 +189,8 @@
|
||||
#
|
||||
# @acpi: machine type supports ACPI (since 8.0)
|
||||
#
|
||||
+# @pve-version: custom PVE version suffix specified as 'machine+pveN'
|
||||
+#
|
||||
# @compat-props: The machine type's compatibility properties. Only
|
||||
# present when query-machines argument @compat-props is true.
|
||||
# (since 9.1)
|
||||
@@ -205,6 +207,7 @@
|
||||
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
|
||||
- 'deprecated': 'bool', '*default-cpu-type': 'str' } }
|
||||
+ 'deprecated': 'bool', '*default-cpu-type': 'str',
|
||||
+ '*pve-version': 'str' } }
|
||||
'deprecated': 'bool', '*default-cpu-type': 'str',
|
||||
'*default-ram-id': 'str', 'acpi': 'bool',
|
||||
+ '*pve-version': 'str',
|
||||
'*compat-props': { 'type': ['CompatProperty'],
|
||||
'features': ['unstable'] } } }
|
||||
|
||||
##
|
||||
# @query-machines:
|
||||
diff --git a/softmmu/vl.c b/softmmu/vl.c
|
||||
index 366e30e594..16aa2186b0 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -2322,6 +2322,8 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
|
||||
diff --git a/system/vl.c b/system/vl.c
|
||||
index 452742ab58..c3707b2412 100644
|
||||
--- a/system/vl.c
|
||||
+++ b/system/vl.c
|
||||
@@ -1674,6 +1674,7 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
|
||||
{
|
||||
MachineClass *mc;
|
||||
GSList *el;
|
||||
+ size_t pvever_index = 0;
|
||||
+ gchar *name_clean;
|
||||
ERRP_GUARD();
|
||||
const char *machine_type = qdict_get_try_str(qdict, "type");
|
||||
+ const char *pvever = qdict_get_try_str(qdict, "pvever");
|
||||
g_autoptr(GSList) machines = object_class_get_list(TYPE_MACHINE, false);
|
||||
MachineClass *machine_class = NULL;
|
||||
|
||||
if (is_help_option(name)) {
|
||||
printf("Supported machines are:\n");
|
||||
@@ -2338,12 +2340,23 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
- mc = find_machine(name, machines);
|
||||
+ // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
|
||||
+ pvever_index = strcspn(name, "+");
|
||||
+
|
||||
+ name_clean = g_strndup(name, pvever_index);
|
||||
+ mc = find_machine(name_clean, machines);
|
||||
+ g_free(name_clean);
|
||||
+
|
||||
if (!mc) {
|
||||
error_report("unsupported machine type");
|
||||
error_printf("Use -machine help to list supported machines\n");
|
||||
exit(1);
|
||||
@@ -1693,7 +1694,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
|
||||
if (!machine_class) {
|
||||
error_append_hint(errp,
|
||||
"Use -machine help to list supported machines\n");
|
||||
+ } else {
|
||||
+ machine_class->pve_version = g_strdup(pvever);
|
||||
+ qdict_del(qdict, "pvever");
|
||||
}
|
||||
+
|
||||
+ if (pvever_index < strlen(name)) {
|
||||
+ mc->pve_version = &name[pvever_index+1];
|
||||
+ }
|
||||
+
|
||||
return mc;
|
||||
return machine_class;
|
||||
}
|
||||
|
||||
@@ -3414,12 +3419,31 @@ void qemu_init(int argc, char **argv)
|
||||
case QEMU_OPTION_machine:
|
||||
{
|
||||
bool help;
|
||||
+ size_t pvever_index, name_len;
|
||||
+ const gchar *name;
|
||||
+ gchar *name_clean, *pvever;
|
||||
|
||||
keyval_parse_into(machine_opts_dict, optarg, "type", &help, &error_fatal);
|
||||
if (help) {
|
||||
machine_help_func(machine_opts_dict);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
+
|
||||
+ // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
|
||||
+ name = qdict_get_try_str(machine_opts_dict, "type");
|
||||
+ if (name != NULL) {
|
||||
+ name_len = strlen(name);
|
||||
+ pvever_index = strcspn(name, "+");
|
||||
+ if (pvever_index < name_len) {
|
||||
+ name_clean = g_strndup(name, pvever_index);
|
||||
+ pvever = g_strndup(name + pvever_index + 1, name_len - pvever_index - 1);
|
||||
+ qdict_put_str(machine_opts_dict, "pvever", pvever);
|
||||
+ qdict_put_str(machine_opts_dict, "type", name_clean);
|
||||
+ g_free(name_clean);
|
||||
+ g_free(pvever);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
break;
|
||||
}
|
||||
case QEMU_OPTION_accel:
|
||||
|
59
debian/patches/pve/0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
vendored
Normal file
59
debian/patches/pve/0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 2 Mar 2022 08:35:05 +0100
|
||||
Subject: [PATCH] block/backup: move bcs bitmap initialization to job creation
|
||||
|
||||
For backing up the state of multiple disks from the same time, a job
|
||||
for each disk has to be created. It's convenient if the jobs don't
|
||||
have to be started at the same time and if operation of the VM can be
|
||||
resumed after job creation. This would lead to a window between job
|
||||
creation and running the job, where writes can happen. But no writes
|
||||
should happen between setting up the copy-before-write filter and
|
||||
setting up the block copy state bitmap, because then new writes would
|
||||
just pass through.
|
||||
|
||||
Commit 06e0a9c16405c0a4c1eca33cf286cc04c42066a2 moved initalization of
|
||||
the bitmap to setting up the copy-before-write filter when sync_mode
|
||||
is not MIRROR_SYNC_MODE_BITMAP. Ensure that the bitmap is initialized
|
||||
upon job creation for the remaining case too, by moving the
|
||||
backup_init_bcs_bitmap call to backup_job_create.
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/backup.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/block/backup.c b/block/backup.c
|
||||
index 79652bf57b..cc747e9163 100644
|
||||
--- a/block/backup.c
|
||||
+++ b/block/backup.c
|
||||
@@ -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.
|
||||
- * Set a flag and resume work when we are able to yield safely.
|
||||
+ * Initialization is costly here. Simply set a flag and let the
|
||||
+ * backup_run coroutine resume work once it can yield safely.
|
||||
*/
|
||||
block_copy_set_skip_unallocated(job->bcs, true);
|
||||
}
|
||||
@@ -252,8 +252,6 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
|
||||
BackupBlockJob *s = container_of(job, BackupBlockJob, common.job);
|
||||
int ret;
|
||||
|
||||
- backup_init_bcs_bitmap(s);
|
||||
-
|
||||
if (s->sync_mode == MIRROR_SYNC_MODE_TOP) {
|
||||
int64_t offset = 0;
|
||||
int64_t count;
|
||||
@@ -502,6 +500,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
&error_abort);
|
||||
bdrv_graph_wrunlock();
|
||||
|
||||
+ backup_init_bcs_bitmap(job);
|
||||
+
|
||||
return &job->common;
|
||||
|
||||
error:
|
@@ -3,58 +3,71 @@ 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: improvements during create
|
||||
allow partial restore
|
||||
allow specifying disk formats for create operation]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
Makefile | 3 +-
|
||||
Makefile.objs | 1 +
|
||||
vma-reader.c | 857 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma-writer.c | 790 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma.c | 839 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma.h | 150 +++++++++
|
||||
6 files changed, 2639 insertions(+), 1 deletion(-)
|
||||
block/meson.build | 2 +
|
||||
meson.build | 5 +
|
||||
vma-reader.c | 867 ++++++++++++++++++++++++++++++++++++++++++
|
||||
vma-writer.c | 816 ++++++++++++++++++++++++++++++++++++++++
|
||||
vma.c | 941 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma.h | 150 ++++++++
|
||||
6 files changed, 2781 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/Makefile b/Makefile
|
||||
index 13dd708c4a..7b8c17ce2d 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -479,7 +479,7 @@ dummy := $(call unnest-vars,, \
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index a21d9a5411..1373612c10 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -42,6 +42,8 @@ block_ss.add(files(
|
||||
'zeroinit.c',
|
||||
), zstd, zlib)
|
||||
|
||||
include $(SRC_PATH)/tests/Makefile.include
|
||||
+block_ss.add(files('../vma-writer.c'), libuuid)
|
||||
+
|
||||
system_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
system_ss.add(files('block-ram-registrar.c'))
|
||||
|
||||
-all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
|
||||
+all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) vma$(EXESUF) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 8ec796d835..680ab48b9b 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -2161,6 +2161,8 @@ endif
|
||||
|
||||
qemu-version.h: FORCE
|
||||
$(call quiet-command, \
|
||||
@@ -602,6 +602,7 @@ qemu-img$(EXESUF): qemu-img.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io
|
||||
qemu-nbd$(EXESUF): qemu-nbd.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
|
||||
qemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
|
||||
qemu-storage-daemon$(EXESUF): qemu-storage-daemon.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(chardev-obj-y) $(io-obj-y) $(qom-obj-y) $(storage-daemon-obj-y) $(COMMON_LDADDS)
|
||||
+vma$(EXESUF): vma.o vma-reader.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
|
||||
has_gettid = cc.has_function('gettid')
|
||||
|
||||
qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
|
||||
+libuuid = cc.find_library('uuid', required: true)
|
||||
+
|
||||
# libselinux
|
||||
selinux = dependency('libselinux',
|
||||
required: get_option('selinux'),
|
||||
@@ -4367,6 +4369,9 @@ if have_tools
|
||||
dependencies: [blockdev, qemuutil, selinux],
|
||||
install: true)
|
||||
|
||||
diff --git a/Makefile.objs b/Makefile.objs
|
||||
index a1307c12a8..ade7b17a69 100644
|
||||
--- a/Makefile.objs
|
||||
+++ b/Makefile.objs
|
||||
@@ -17,6 +17,7 @@ block-obj-y = block/ nbd/ scsi/
|
||||
block-obj-y += block.o blockjob.o job.o
|
||||
block-obj-y += qemu-io-cmds.o
|
||||
block-obj-$(CONFIG_REPLICATION) += replication.o
|
||||
+block-obj-y += vma-writer.o
|
||||
|
||||
block-obj-m = block/
|
||||
+ vma = executable('vma', files('vma.c', 'vma-reader.c') + genh,
|
||||
+ dependencies: [authz, block, crypto, io, qemuutil, qom], install: true)
|
||||
+
|
||||
subdir('storage-daemon')
|
||||
|
||||
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..2b1d1cdab3
|
||||
index 0000000000..1888b21851
|
||||
--- /dev/null
|
||||
+++ b/vma-reader.c
|
||||
@@ -0,0 +1,857 @@
|
||||
@@ -0,0 +1,867 @@
|
||||
+/*
|
||||
+ * VMA: Virtual Machine Archive
|
||||
+ *
|
||||
@@ -72,12 +85,12 @@ index 0000000000..2b1d1cdab3
|
||||
+#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 "sysemu/block-backend.h"
|
||||
+#include "block/graph-lock.h"
|
||||
+#include "system/block-backend.h"
|
||||
+
|
||||
+static unsigned char zero_vma_block[VMA_BLOCK_SIZE];
|
||||
+
|
||||
@@ -86,6 +99,7 @@ index 0000000000..2b1d1cdab3
|
||||
+ bool write_zeroes;
|
||||
+ unsigned long *bitmap;
|
||||
+ int bitmap_size;
|
||||
+ bool skip;
|
||||
+} VmaRestoreState;
|
||||
+
|
||||
+struct VmaReader {
|
||||
@@ -249,6 +263,9 @@ index 0000000000..2b1d1cdab3
|
||||
+ if (vmar->rstate[i].bitmap) {
|
||||
+ g_free(vmar->rstate[i].bitmap);
|
||||
+ }
|
||||
+ if (vmar->rstate[i].target) {
|
||||
+ blk_unref(vmar->rstate[i].target);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (vmar->md5csum) {
|
||||
@@ -365,7 +382,6 @@ index 0000000000..2b1d1cdab3
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ int count = 0;
|
||||
+ for (i = 1; i < 256; i++) {
|
||||
+ VmaDeviceInfoHeader *dih = &h->dev_info[i];
|
||||
+ uint32_t devname_ptr = GUINT32_FROM_BE(dih->devname_ptr);
|
||||
@@ -373,7 +389,6 @@ index 0000000000..2b1d1cdab3
|
||||
+ const char *devname = get_header_str(vmar, devname_ptr);
|
||||
+
|
||||
+ if (size && devname) {
|
||||
+ count++;
|
||||
+ vmar->devinfo[i].size = size;
|
||||
+ vmar->devinfo[i].devname = devname;
|
||||
+
|
||||
@@ -480,13 +495,14 @@ index 0000000000..2b1d1cdab3
|
||||
+}
|
||||
+
|
||||
+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;
|
||||
+
|
||||
@@ -501,28 +517,30 @@ index 0000000000..2b1d1cdab3
|
||||
+}
|
||||
+
|
||||
+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;
|
||||
+}
|
||||
@@ -580,10 +598,12 @@ index 0000000000..2b1d1cdab3
|
||||
+ }
|
||||
+ }
|
||||
+ } 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;
|
||||
+ }
|
||||
+ }
|
||||
@@ -615,19 +635,23 @@ index 0000000000..2b1d1cdab3
|
||||
+ 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 {
|
||||
@@ -673,7 +697,7 @@ index 0000000000..2b1d1cdab3
|
||||
+ 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,
|
||||
@@ -709,7 +733,7 @@ index 0000000000..2b1d1cdab3
|
||||
+ 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,
|
||||
@@ -734,7 +758,7 @@ index 0000000000..2b1d1cdab3
|
||||
+ 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) {
|
||||
@@ -859,8 +883,7 @@ index 0000000000..2b1d1cdab3
|
||||
+
|
||||
+ int64_t cluster_num, end;
|
||||
+
|
||||
+ end = (vmar->devinfo[i].size + VMA_CLUSTER_SIZE - 1) /
|
||||
+ VMA_CLUSTER_SIZE;
|
||||
+ end = DIV_ROUND_UP(vmar->devinfo[i].size, VMA_CLUSTER_SIZE);
|
||||
+
|
||||
+ for (cluster_num = 0; cluster_num < end; cluster_num++) {
|
||||
+ if (!vma_reader_get_bitmap(rstate, cluster_num)) {
|
||||
@@ -905,7 +928,7 @@ index 0000000000..2b1d1cdab3
|
||||
+
|
||||
+ 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);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -914,10 +937,10 @@ index 0000000000..2b1d1cdab3
|
||||
+
|
||||
diff --git a/vma-writer.c b/vma-writer.c
|
||||
new file mode 100644
|
||||
index 0000000000..f5d2c5d23c
|
||||
index 0000000000..3f489092df
|
||||
--- /dev/null
|
||||
+++ b/vma-writer.c
|
||||
@@ -0,0 +1,790 @@
|
||||
@@ -0,0 +1,816 @@
|
||||
+/*
|
||||
+ * VMA: Virtual Machine Archive
|
||||
+ *
|
||||
@@ -933,6 +956,8 @@ index 0000000000..f5d2c5d23c
|
||||
+
|
||||
+#include "qemu/osdep.h"
|
||||
+#include <glib.h>
|
||||
+#include <linux/magic.h>
|
||||
+#include <sys/vfs.h>
|
||||
+#include <uuid/uuid.h>
|
||||
+
|
||||
+#include "vma.h"
|
||||
@@ -941,6 +966,8 @@ index 0000000000..f5d2c5d23c
|
||||
+#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
|
||||
+
|
||||
@@ -1107,8 +1134,7 @@ index 0000000000..f5d2c5d23c
|
||||
+ vmaw->stream_info[n].devname = g_strdup(devname);
|
||||
+ vmaw->stream_info[n].size = size;
|
||||
+
|
||||
+ vmaw->stream_info[n].cluster_count = (size + VMA_CLUSTER_SIZE - 1) /
|
||||
+ VMA_CLUSTER_SIZE;
|
||||
+ vmaw->stream_info[n].cluster_count = DIV_ROUND_UP(size, VMA_CLUSTER_SIZE);
|
||||
+
|
||||
+ vmaw->stream_count = n;
|
||||
+
|
||||
@@ -1123,10 +1149,10 @@ index 0000000000..f5d2c5d23c
|
||||
+{
|
||||
+ 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
|
||||
@@ -1175,6 +1201,23 @@ index 0000000000..f5d2c5d23c
|
||||
+ 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;
|
||||
@@ -1213,23 +1256,30 @@ index 0000000000..f5d2c5d23c
|
||||
+
|
||||
+ if ((stat(filename, &st) == 0) && S_ISFIFO(st.st_mode)) {
|
||||
+ oflags = O_NONBLOCK|O_WRONLY;
|
||||
+ vmaw->fd = qemu_open(filename, oflags, 0644);
|
||||
+ vmaw->fd = qemu_open(filename, oflags, errp);
|
||||
+ } else if (strstart(filename, "/dev/fdset/", &tmp_id_str)) {
|
||||
+ oflags = O_NONBLOCK|O_WRONLY;
|
||||
+ vmaw->fd = qemu_open(filename, oflags, 0644);
|
||||
+ vmaw->fd = qemu_open(filename, oflags, errp);
|
||||
+ } else if (strstart(filename, "/dev/fdname/", &tmp_id_str)) {
|
||||
+ vmaw->fd = monitor_get_fd(cur_mon, tmp_id_str, errp);
|
||||
+ vmaw->fd = monitor_get_fd(monitor_cur(), tmp_id_str, errp);
|
||||
+ if (vmaw->fd < 0) {
|
||||
+ goto err;
|
||||
+ }
|
||||
+ /* 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_CREAT|O_EXCL;
|
||||
+ vmaw->fd = qemu_open(filename, oflags, 0644);
|
||||
+ } 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;
|
||||
@@ -1464,17 +1514,16 @@ index 0000000000..f5d2c5d23c
|
||||
+ 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;
|
||||
@@ -1710,10 +1759,10 @@ index 0000000000..f5d2c5d23c
|
||||
+}
|
||||
diff --git a/vma.c b/vma.c
|
||||
new file mode 100644
|
||||
index 0000000000..2eea2fc281
|
||||
index 0000000000..0e990b5e30
|
||||
--- /dev/null
|
||||
+++ b/vma.c
|
||||
@@ -0,0 +1,839 @@
|
||||
@@ -0,0 +1,941 @@
|
||||
+/*
|
||||
+ * VMA: Virtual Machine Archive
|
||||
+ *
|
||||
@@ -1731,13 +1780,13 @@ index 0000000000..2eea2fc281
|
||||
+#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 "qapi/qmp/qdict.h"
|
||||
+#include "sysemu/block-backend.h"
|
||||
+#include "qemu/memalign.h"
|
||||
+#include "qobject/qdict.h"
|
||||
+#include "system/block-backend.h"
|
||||
+
|
||||
+static void help(void)
|
||||
+{
|
||||
@@ -1745,9 +1794,9 @@ index 0000000000..2eea2fc281
|
||||
+ "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"
|
||||
+ ;
|
||||
+
|
||||
@@ -1854,6 +1903,7 @@ index 0000000000..2eea2fc281
|
||||
+ 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) {
|
||||
@@ -1891,9 +1941,10 @@ index 0000000000..2eea2fc281
|
||||
+ 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;
|
||||
+ }
|
||||
@@ -1902,6 +1953,9 @@ index 0000000000..2eea2fc281
|
||||
+ case 'h':
|
||||
+ help();
|
||||
+ break;
|
||||
+ case 'd':
|
||||
+ drive_list = g_strsplit(optarg, ",", 254);
|
||||
+ break;
|
||||
+ case 'r':
|
||||
+ readmap = optarg;
|
||||
+ break;
|
||||
@@ -1961,76 +2015,89 @@ index 0000000000..2eea2fc281
|
||||
+ 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;
|
||||
+
|
||||
+ BlockBackend *blk = NULL;
|
||||
+ 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) {
|
||||
@@ -2046,8 +2113,25 @@ index 0000000000..2eea2fc281
|
||||
+ const char *cache = NULL;
|
||||
+ int flags = BDRV_O_RDWR;
|
||||
+ bool write_zero = true;
|
||||
+ bool skip = false;
|
||||
+
|
||||
+ if (readmap) {
|
||||
+ BlockBackend *blk = NULL;
|
||||
+
|
||||
+ 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) {
|
||||
@@ -2059,7 +2143,8 @@ index 0000000000..2eea2fc281
|
||||
+ 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);
|
||||
@@ -2077,57 +2162,60 @@ index 0000000000..2eea2fc281
|
||||
+ 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));
|
||||
+ }
|
||||
+
|
||||
@@ -2137,6 +2225,10 @@ index 0000000000..2eea2fc281
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ 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));
|
||||
+ }
|
||||
@@ -2144,7 +2236,7 @@ index 0000000000..2eea2fc281
|
||||
+ 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",
|
||||
@@ -2159,8 +2251,6 @@ index 0000000000..2eea2fc281
|
||||
+
|
||||
+ vma_reader_destroy(vmar);
|
||||
+
|
||||
+ blk_unref(blk);
|
||||
+
|
||||
+ bdrv_close_all();
|
||||
+
|
||||
+ return ret;
|
||||
@@ -2245,7 +2335,7 @@ index 0000000000..2eea2fc281
|
||||
+ 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);
|
||||
@@ -2259,16 +2349,24 @@ index 0000000000..2eea2fc281
|
||||
+ 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;
|
||||
+ }
|
||||
+ }
|
||||
@@ -2286,13 +2384,16 @@ index 0000000000..2eea2fc281
|
||||
+
|
||||
+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;
|
||||
+ }
|
||||
@@ -2304,6 +2405,9 @@ index 0000000000..2eea2fc281
|
||||
+ 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;
|
||||
@@ -2349,16 +2453,48 @@ index 0000000000..2eea2fc281
|
||||
+ 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));
|
||||
@@ -2377,7 +2513,11 @@ index 0000000000..2eea2fc281
|
||||
+ job->dev_id = dev_id;
|
||||
+
|
||||
+ Coroutine *co = qemu_coroutine_create(backup_run, job);
|
||||
+ qemu_coroutine_enter(co);
|
||||
+ // 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;
|
||||
@@ -2385,6 +2525,13 @@ index 0000000000..2eea2fc281
|
||||
+ int last_percent = -1;
|
||||
+
|
||||
+ if (devcount) {
|
||||
+ GList *entry = backup_coroutines;
|
||||
+ while (entry && entry->data) {
|
||||
+ Coroutine *co = entry->data;
|
||||
+ qemu_coroutine_enter(co);
|
||||
+ entry = g_list_next(entry);
|
||||
+ }
|
||||
+
|
||||
+ while (1) {
|
||||
+ main_loop_wait(false);
|
||||
+ vma_writer_get_status(vmaw, &vmastat);
|
||||
@@ -2434,6 +2581,7 @@ index 0000000000..2eea2fc281
|
||||
+ 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) {
|
||||
@@ -2449,6 +2597,9 @@ index 0000000000..2eea2fc281
|
||||
+ g_error("creating vma archive failed");
|
||||
+ }
|
||||
+
|
||||
+ g_list_free(backup_coroutines);
|
||||
+ g_list_free(config_files);
|
||||
+ g_list_free(disk_infos);
|
||||
+ vma_writer_destroy(vmaw);
|
||||
+ return 0;
|
||||
+}
|
||||
@@ -2555,7 +2706,7 @@ index 0000000000..2eea2fc281
|
||||
+}
|
||||
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 @@
|
||||
@@ -2693,7 +2844,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);
|
||||
@@ -2703,7 +2854,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);
|
@@ -7,33 +7,25 @@ Subject: [PATCH] PVE-Backup: add backup-dump block driver
|
||||
- move BackupBlockJob declaration from block/backup.c to include/block/block_int.h
|
||||
- block/backup.c - backup-job-create: also consider source cluster size
|
||||
- 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/Makefile.objs | 1 +
|
||||
block/backup-dump.c | 168 ++++++++++++++++++++++++++++++++++++++
|
||||
block/backup.c | 23 ++----
|
||||
include/block/block_int.h | 30 +++++++
|
||||
job.c | 3 +-
|
||||
5 files changed, 206 insertions(+), 19 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/Makefile.objs b/block/Makefile.objs
|
||||
index d1a9227b8f..9ea0477d0b 100644
|
||||
--- a/block/Makefile.objs
|
||||
+++ b/block/Makefile.objs
|
||||
@@ -33,6 +33,7 @@ block-obj-$(CONFIG_CURL) += curl.o
|
||||
block-obj-$(CONFIG_RBD) += rbd.o
|
||||
block-obj-$(CONFIG_GLUSTERFS) += gluster.o
|
||||
block-obj-$(CONFIG_LIBSSH) += ssh.o
|
||||
+block-obj-y += backup-dump.o
|
||||
block-obj-y += accounting.o dirty-bitmap.o
|
||||
block-obj-y += write-threshold.o
|
||||
block-obj-y += backup.o
|
||||
diff --git a/block/backup-dump.c b/block/backup-dump.c
|
||||
new file mode 100644
|
||||
index 0000000000..93d7f46950
|
||||
index 0000000000..354593bc10
|
||||
--- /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
|
||||
+ *
|
||||
@@ -45,7 +37,8 @@ index 0000000000..93d7f46950
|
||||
+ */
|
||||
+
|
||||
+#include "qemu/osdep.h"
|
||||
+#include "qemu-common.h"
|
||||
+
|
||||
+#include "qobject/qdict.h"
|
||||
+#include "qom/object_interfaces.h"
|
||||
+#include "block/block_int.h"
|
||||
+
|
||||
@@ -56,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;
|
||||
+
|
||||
@@ -97,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;
|
||||
+
|
||||
@@ -157,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,
|
||||
+
|
||||
@@ -177,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,
|
||||
@@ -185,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;
|
||||
+ }
|
||||
@@ -203,17 +199,18 @@ index 0000000000..93d7f46950
|
||||
+ return bs;
|
||||
+}
|
||||
diff --git a/block/backup.c b/block/backup.c
|
||||
index 4f13bb20a5..cd42236b79 100644
|
||||
index cc747e9163..6f7c45f922 100644
|
||||
--- a/block/backup.c
|
||||
+++ b/block/backup.c
|
||||
@@ -32,24 +32,6 @@
|
||||
@@ -29,28 +29,6 @@
|
||||
|
||||
#define BACKUP_CLUSTER_SIZE_DEFAULT (1 << 16)
|
||||
#include "block/copy-before-write.h"
|
||||
|
||||
-typedef struct BackupBlockJob {
|
||||
- BlockJob common;
|
||||
- BlockDriverState *backup_top;
|
||||
- BlockDriverState *cbw;
|
||||
- BlockDriverState *source_bs;
|
||||
- BlockDriverState *target_bs;
|
||||
-
|
||||
- BdrvDirtyBitmap *sync_bitmap;
|
||||
-
|
||||
@@ -222,38 +219,64 @@ index 4f13bb20a5..cd42236b79 100644
|
||||
- BlockdevOnError on_source_error;
|
||||
- BlockdevOnError on_target_error;
|
||||
- uint64_t len;
|
||||
- uint64_t bytes_read;
|
||||
- int64_t cluster_size;
|
||||
- BackupPerf perf;
|
||||
-
|
||||
- BlockCopyState *bcs;
|
||||
-
|
||||
- bool wait;
|
||||
- BlockCopyCallState *bg_bcs_call;
|
||||
-} BackupBlockJob;
|
||||
-
|
||||
static const BlockJobDriver backup_job_driver;
|
||||
|
||||
static void backup_progress_bytes_callback(int64_t bytes, void *opaque)
|
||||
@@ -422,6 +404,11 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
goto error;
|
||||
static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret)
|
||||
@@ -462,6 +440,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
}
|
||||
|
||||
cluster_size = block_copy_cluster_size(bcs);
|
||||
+ if (cluster_size < 0) {
|
||||
+ goto error;
|
||||
+ }
|
||||
+
|
||||
+ BlockDriverInfo bdi;
|
||||
+ if (bdrv_get_info(bs, &bdi) == 0) {
|
||||
+ cluster_size = MAX(cluster_size, bdi.cluster_size);
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* If source is in backing chain of target assume that target is going to be
|
||||
* used for "image fleecing", i.e. it should represent a kind of snapshot of
|
||||
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
||||
index 38dec0275b..1efb1f527c 100644
|
||||
--- a/include/block/block_int.h
|
||||
+++ b/include/block/block_int.h
|
||||
@@ -62,6 +62,36 @@
|
||||
|
||||
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 1373612c10..6278c4af0f 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -4,6 +4,7 @@ block_ss.add(files(
|
||||
'aio_task.c',
|
||||
'amend.c',
|
||||
'backup.c',
|
||||
+ 'backup-dump.c',
|
||||
'blkdebug.c',
|
||||
'blklogwrites.c',
|
||||
'blkverify.c',
|
||||
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
|
||||
index ebb4e56a50..e717a74e5f 100644
|
||||
--- a/include/block/block_int-common.h
|
||||
+++ b/include/block/block_int-common.h
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "block/aio.h"
|
||||
#include "block/block-common.h"
|
||||
+#include "block/block-copy.h"
|
||||
#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,
|
||||
@@ -265,8 +288,9 @@ index 38dec0275b..1efb1f527c 100644
|
||||
+typedef struct BlockCopyState BlockCopyState;
|
||||
+typedef struct BackupBlockJob {
|
||||
+ BlockJob common;
|
||||
+ BlockDriverState *backup_top;
|
||||
+ BlockDriverState *cbw;
|
||||
+ BlockDriverState *source_bs;
|
||||
+ BlockDriverState *target_bs;
|
||||
+
|
||||
+ BdrvDirtyBitmap *sync_bitmap;
|
||||
+
|
||||
@@ -275,26 +299,29 @@ index 38dec0275b..1efb1f527c 100644
|
||||
+ BlockdevOnError on_source_error;
|
||||
+ BlockdevOnError on_target_error;
|
||||
+ uint64_t len;
|
||||
+ uint64_t bytes_read;
|
||||
+ int64_t cluster_size;
|
||||
+ BackupPerf perf;
|
||||
+
|
||||
+ BlockCopyState *bcs;
|
||||
+
|
||||
+ bool wait;
|
||||
+ BlockCopyCallState *bg_bcs_call;
|
||||
+} BackupBlockJob;
|
||||
+
|
||||
enum BdrvTrackedRequestType {
|
||||
BDRV_TRACKED_READ,
|
||||
BDRV_TRACKED_WRITE,
|
||||
diff --git a/job.c b/job.c
|
||||
index 53be57a3a0..b8139c80a4 100644
|
||||
index 0653bc2ba6..b981070ee8 100644
|
||||
--- a/job.c
|
||||
+++ b/job.c
|
||||
@@ -269,7 +269,8 @@ static bool job_started(Job *job)
|
||||
return job->co;
|
||||
@@ -337,7 +337,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
@@ -4,16 +4,17 @@ Date: Thu, 20 Aug 2020 14:31:59 +0200
|
||||
Subject: [PATCH] PVE: Add sequential job transaction support
|
||||
|
||||
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 | 24 ++++++++++++++++++++++++
|
||||
2 files changed, 36 insertions(+)
|
||||
job.c | 34 ++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 46 insertions(+)
|
||||
|
||||
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
||||
index 32aabb1c60..f7a6a0926a 100644
|
||||
index a5a04155ea..562cc7eaec 100644
|
||||
--- a/include/qemu/job.h
|
||||
+++ b/include/qemu/job.h
|
||||
@@ -280,6 +280,18 @@ typedef enum JobCreateFlags {
|
||||
@@ -362,6 +362,18 @@ void job_unlock(void);
|
||||
*/
|
||||
JobTxn *job_txn_new(void);
|
||||
|
||||
@@ -33,10 +34,10 @@ index 32aabb1c60..f7a6a0926a 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 b8139c80a4..97ee97a192 100644
|
||||
index b981070ee8..f4646866ec 100644
|
||||
--- a/job.c
|
||||
+++ b/job.c
|
||||
@@ -72,6 +72,8 @@ struct JobTxn {
|
||||
@@ -94,6 +94,8 @@ struct JobTxn {
|
||||
|
||||
/* Reference count */
|
||||
int refcnt;
|
||||
@@ -44,8 +45,8 @@ index b8139c80a4..97ee97a192 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;
|
||||
}
|
||||
|
||||
@@ -68,16 +69,33 @@ index b8139c80a4..97ee97a192 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++;
|
||||
@@ -841,6 +862,9 @@ static void job_completed_txn_success(Job *job)
|
||||
@@ -1048,6 +1069,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);
|
||||
@@ -1259,6 +1286,13 @@ int job_finish_sync_locked(Job *job,
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
+ /* in a sequential transaction jobs with status CREATED can appear at time
|
||||
+ * 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_locked(job);
|
||||
+ }
|
||||
+
|
||||
job_unlock();
|
||||
AIO_WAIT_WHILE_UNLOCKED(job->aio_context,
|
||||
(job_enter(job), !job_is_completed(job)));
|
1988
debian/patches/pve/0030-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
vendored
Normal file
1988
debian/patches/pve/0030-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,914 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dietmar Maurer <dietmar@proxmox.com>
|
||||
Date: Mon, 6 Apr 2020 12:17:00 +0200
|
||||
Subject: [PATCH] PVE-Backup: avoid coroutines to fix AIO freeze, cleanups
|
||||
|
||||
We observed various AIO pool loop freezes, so we decided to avoid
|
||||
coroutines and restrict ourselfes using similar code as upstream
|
||||
(see blockdev.c: do_backup_common).
|
||||
|
||||
* avoid coroutine for job related code (causes hangs with iothreads)
|
||||
- We then acquire/release all mutexes outside coroutines now, so we can now
|
||||
correctly use a normal mutex.
|
||||
|
||||
* split pvebackup_co_dump_cb into:
|
||||
- pvebackup_co_dump_pbs_cb and
|
||||
- pvebackup_co_dump_pbs_cb
|
||||
|
||||
* new helper functions
|
||||
- pvebackup_propagate_error
|
||||
- pvebackup_error_or_canceled
|
||||
- pvebackup_add_transfered_bytes
|
||||
|
||||
* avoid cancel flag (not needed)
|
||||
|
||||
* simplify backup_cancel logic
|
||||
|
||||
There is progress on upstream to support running qmp commands inside
|
||||
coroutines, see:
|
||||
https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg04852.html
|
||||
|
||||
We should consider using that when it is available in upstream qemu.
|
||||
|
||||
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 638 ++++++++++++++++++++++++++-------------------------
|
||||
1 file changed, 320 insertions(+), 318 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 55441eb9d1..d40f3f2fd6 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -11,11 +11,27 @@
|
||||
|
||||
/* PVE backup state and related function */
|
||||
|
||||
+/*
|
||||
+ * Note: A resume from a qemu_coroutine_yield can happen in a different thread,
|
||||
+ * so you may not use normal mutexes within coroutines:
|
||||
+ *
|
||||
+ * ---bad-example---
|
||||
+ * qemu_rec_mutex_lock(lock)
|
||||
+ * ...
|
||||
+ * qemu_coroutine_yield() // wait for something
|
||||
+ * // we are now inside a different thread
|
||||
+ * qemu_rec_mutex_unlock(lock) // Crash - wrong thread!!
|
||||
+ * ---end-bad-example--
|
||||
+ *
|
||||
+ * ==> Always use CoMutext inside coroutines.
|
||||
+ * ==> Never acquire/release AioContext withing coroutines (because that use QemuRecMutex)
|
||||
+ *
|
||||
+ */
|
||||
|
||||
static struct PVEBackupState {
|
||||
struct {
|
||||
- // Everithing accessed from qmp command, protected using rwlock
|
||||
- CoRwlock rwlock;
|
||||
+ // Everithing accessed from qmp_backup_query command is protected using lock
|
||||
+ QemuMutex lock;
|
||||
Error *error;
|
||||
time_t start_time;
|
||||
time_t end_time;
|
||||
@@ -25,19 +41,20 @@ static struct PVEBackupState {
|
||||
size_t total;
|
||||
size_t transferred;
|
||||
size_t zero_bytes;
|
||||
- bool cancel;
|
||||
} stat;
|
||||
int64_t speed;
|
||||
VmaWriter *vmaw;
|
||||
ProxmoxBackupHandle *pbs;
|
||||
GList *di_list;
|
||||
- CoMutex backup_mutex;
|
||||
+ QemuMutex backup_mutex;
|
||||
+ CoMutex dump_callback_mutex;
|
||||
} backup_state;
|
||||
|
||||
static void pvebackup_init(void)
|
||||
{
|
||||
- qemu_co_rwlock_init(&backup_state.stat.rwlock);
|
||||
- qemu_co_mutex_init(&backup_state.backup_mutex);
|
||||
+ qemu_mutex_init(&backup_state.stat.lock);
|
||||
+ qemu_mutex_init(&backup_state.backup_mutex);
|
||||
+ qemu_co_mutex_init(&backup_state.dump_callback_mutex);
|
||||
}
|
||||
|
||||
// initialize PVEBackupState at startup
|
||||
@@ -52,10 +69,54 @@ typedef struct PVEBackupDevInfo {
|
||||
BlockDriverState *target;
|
||||
} PVEBackupDevInfo;
|
||||
|
||||
-static void pvebackup_co_run_next_job(void);
|
||||
+static void pvebackup_run_next_job(void);
|
||||
|
||||
+static BlockJob *
|
||||
+lookup_active_block_job(PVEBackupDevInfo *di)
|
||||
+{
|
||||
+ if (!di->completed && di->bs) {
|
||||
+ for (BlockJob *job = block_job_next(NULL); job; job = block_job_next(job)) {
|
||||
+ if (job->job.driver->job_type != JOB_TYPE_BACKUP) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ BackupBlockJob *bjob = container_of(job, BackupBlockJob, common);
|
||||
+ if (bjob && bjob->source_bs == di->bs) {
|
||||
+ return job;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static void pvebackup_propagate_error(Error *err)
|
||||
+{
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+ error_propagate(&backup_state.stat.error, err);
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+}
|
||||
+
|
||||
+static bool pvebackup_error_or_canceled(void)
|
||||
+{
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+ bool error_or_canceled = !!backup_state.stat.error;
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+
|
||||
+ return error_or_canceled;
|
||||
+}
|
||||
+
|
||||
+static void pvebackup_add_transfered_bytes(size_t transferred, size_t zero_bytes)
|
||||
+{
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+ backup_state.stat.zero_bytes += zero_bytes;
|
||||
+ backup_state.stat.transferred += transferred;
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+}
|
||||
+
|
||||
+// This may get called from multiple coroutines in multiple io-threads
|
||||
+// Note1: this may get called after job_cancel()
|
||||
static int coroutine_fn
|
||||
-pvebackup_co_dump_cb(
|
||||
+pvebackup_co_dump_pbs_cb(
|
||||
void *opaque,
|
||||
uint64_t start,
|
||||
uint64_t bytes,
|
||||
@@ -67,137 +128,127 @@ pvebackup_co_dump_cb(
|
||||
const unsigned char *buf = pbuf;
|
||||
PVEBackupDevInfo *di = opaque;
|
||||
|
||||
- qemu_co_rwlock_rdlock(&backup_state.stat.rwlock);
|
||||
- bool cancel = backup_state.stat.cancel;
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
+ assert(backup_state.pbs);
|
||||
+
|
||||
+ Error *local_err = NULL;
|
||||
+ int pbs_res = -1;
|
||||
+
|
||||
+ qemu_co_mutex_lock(&backup_state.dump_callback_mutex);
|
||||
|
||||
- if (cancel) {
|
||||
- return size; // return success
|
||||
+ // avoid deadlock if job is cancelled
|
||||
+ if (pvebackup_error_or_canceled()) {
|
||||
+ qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
|
||||
+ return -1;
|
||||
}
|
||||
|
||||
- qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
+ pbs_res = proxmox_backup_co_write_data(backup_state.pbs, di->dev_id, buf, start, size, &local_err);
|
||||
+ qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
|
||||
|
||||
- int ret = -1;
|
||||
+ if (pbs_res < 0) {
|
||||
+ pvebackup_propagate_error(local_err);
|
||||
+ return pbs_res;
|
||||
+ } else {
|
||||
+ pvebackup_add_transfered_bytes(size, !buf ? size : 0);
|
||||
+ }
|
||||
|
||||
- if (backup_state.vmaw) {
|
||||
- size_t zero_bytes = 0;
|
||||
- uint64_t remaining = size;
|
||||
-
|
||||
- uint64_t cluster_num = start / VMA_CLUSTER_SIZE;
|
||||
- if ((cluster_num * VMA_CLUSTER_SIZE) != start) {
|
||||
- qemu_co_rwlock_rdlock(&backup_state.stat.rwlock);
|
||||
- if (!backup_state.stat.error) {
|
||||
- qemu_co_rwlock_upgrade(&backup_state.stat.rwlock);
|
||||
- error_setg(&backup_state.stat.error,
|
||||
- "got unaligned write inside backup dump "
|
||||
- "callback (sector %ld)", start);
|
||||
- }
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
- return -1; // not aligned to cluster size
|
||||
- }
|
||||
+ return size;
|
||||
+}
|
||||
|
||||
- while (remaining > 0) {
|
||||
- ret = vma_writer_write(backup_state.vmaw, di->dev_id, cluster_num,
|
||||
- buf, &zero_bytes);
|
||||
- ++cluster_num;
|
||||
- if (buf) {
|
||||
- buf += VMA_CLUSTER_SIZE;
|
||||
- }
|
||||
- if (ret < 0) {
|
||||
- qemu_co_rwlock_rdlock(&backup_state.stat.rwlock);
|
||||
- if (!backup_state.stat.error) {
|
||||
- qemu_co_rwlock_upgrade(&backup_state.stat.rwlock);
|
||||
- vma_writer_error_propagate(backup_state.vmaw, &backup_state.stat.error);
|
||||
- }
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
+// This may get called from multiple coroutines in multiple io-threads
|
||||
+static int coroutine_fn
|
||||
+pvebackup_co_dump_vma_cb(
|
||||
+ void *opaque,
|
||||
+ uint64_t start,
|
||||
+ uint64_t bytes,
|
||||
+ const void *pbuf)
|
||||
+{
|
||||
+ assert(qemu_in_coroutine());
|
||||
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
- return ret;
|
||||
- } else {
|
||||
- qemu_co_rwlock_wrlock(&backup_state.stat.rwlock);
|
||||
- backup_state.stat.zero_bytes += zero_bytes;
|
||||
- if (remaining >= VMA_CLUSTER_SIZE) {
|
||||
- backup_state.stat.transferred += VMA_CLUSTER_SIZE;
|
||||
- remaining -= VMA_CLUSTER_SIZE;
|
||||
- } else {
|
||||
- backup_state.stat.transferred += remaining;
|
||||
- remaining = 0;
|
||||
- }
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
- }
|
||||
- }
|
||||
- } else if (backup_state.pbs) {
|
||||
- Error *local_err = NULL;
|
||||
- int pbs_res = -1;
|
||||
+ const uint64_t size = bytes;
|
||||
+ const unsigned char *buf = pbuf;
|
||||
+ PVEBackupDevInfo *di = opaque;
|
||||
|
||||
- pbs_res = proxmox_backup_co_write_data(backup_state.pbs, di->dev_id, buf, start, size, &local_err);
|
||||
+ int ret = -1;
|
||||
|
||||
- qemu_co_rwlock_wrlock(&backup_state.stat.rwlock);
|
||||
+ assert(backup_state.vmaw);
|
||||
|
||||
- if (pbs_res < 0) {
|
||||
- error_propagate(&backup_state.stat.error, local_err);
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
- return pbs_res;
|
||||
- } else {
|
||||
- if (!buf) {
|
||||
- backup_state.stat.zero_bytes += size;
|
||||
- }
|
||||
- backup_state.stat.transferred += size;
|
||||
+ uint64_t remaining = size;
|
||||
+
|
||||
+ uint64_t cluster_num = start / VMA_CLUSTER_SIZE;
|
||||
+ if ((cluster_num * VMA_CLUSTER_SIZE) != start) {
|
||||
+ Error *local_err = NULL;
|
||||
+ error_setg(&local_err,
|
||||
+ "got unaligned write inside backup dump "
|
||||
+ "callback (sector %ld)", start);
|
||||
+ pvebackup_propagate_error(local_err);
|
||||
+ return -1; // not aligned to cluster size
|
||||
+ }
|
||||
+
|
||||
+ while (remaining > 0) {
|
||||
+ qemu_co_mutex_lock(&backup_state.dump_callback_mutex);
|
||||
+ // avoid deadlock if job is cancelled
|
||||
+ if (pvebackup_error_or_canceled()) {
|
||||
+ qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
|
||||
+ return -1;
|
||||
}
|
||||
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
+ size_t zero_bytes = 0;
|
||||
+ ret = vma_writer_write(backup_state.vmaw, di->dev_id, cluster_num, buf, &zero_bytes);
|
||||
+ qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
|
||||
|
||||
- } else {
|
||||
- qemu_co_rwlock_wrlock(&backup_state.stat.rwlock);
|
||||
- if (!buf) {
|
||||
- backup_state.stat.zero_bytes += size;
|
||||
+ ++cluster_num;
|
||||
+ if (buf) {
|
||||
+ buf += VMA_CLUSTER_SIZE;
|
||||
+ }
|
||||
+ if (ret < 0) {
|
||||
+ Error *local_err = NULL;
|
||||
+ vma_writer_error_propagate(backup_state.vmaw, &local_err);
|
||||
+ pvebackup_propagate_error(local_err);
|
||||
+ return ret;
|
||||
+ } else {
|
||||
+ if (remaining >= VMA_CLUSTER_SIZE) {
|
||||
+ assert(ret == VMA_CLUSTER_SIZE);
|
||||
+ pvebackup_add_transfered_bytes(VMA_CLUSTER_SIZE, zero_bytes);
|
||||
+ remaining -= VMA_CLUSTER_SIZE;
|
||||
+ } else {
|
||||
+ assert(ret == remaining);
|
||||
+ pvebackup_add_transfered_bytes(remaining, zero_bytes);
|
||||
+ remaining = 0;
|
||||
+ }
|
||||
}
|
||||
- backup_state.stat.transferred += size;
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
}
|
||||
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
-
|
||||
return size;
|
||||
}
|
||||
|
||||
-static void coroutine_fn pvebackup_co_cleanup(void)
|
||||
+// assumes the caller holds backup_mutex
|
||||
+static void coroutine_fn pvebackup_co_cleanup(void *unused)
|
||||
{
|
||||
assert(qemu_in_coroutine());
|
||||
|
||||
- qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
-
|
||||
- qemu_co_rwlock_wrlock(&backup_state.stat.rwlock);
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
backup_state.stat.end_time = time(NULL);
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
if (backup_state.vmaw) {
|
||||
Error *local_err = NULL;
|
||||
vma_writer_close(backup_state.vmaw, &local_err);
|
||||
|
||||
if (local_err != NULL) {
|
||||
- qemu_co_rwlock_wrlock(&backup_state.stat.rwlock);
|
||||
- error_propagate(&backup_state.stat.error, local_err);
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
- }
|
||||
+ pvebackup_propagate_error(local_err);
|
||||
+ }
|
||||
|
||||
backup_state.vmaw = NULL;
|
||||
}
|
||||
|
||||
if (backup_state.pbs) {
|
||||
- qemu_co_rwlock_rdlock(&backup_state.stat.rwlock);
|
||||
- bool error_or_canceled = backup_state.stat.error || backup_state.stat.cancel;
|
||||
- if (!error_or_canceled) {
|
||||
+ if (!pvebackup_error_or_canceled()) {
|
||||
Error *local_err = NULL;
|
||||
proxmox_backup_co_finish(backup_state.pbs, &local_err);
|
||||
if (local_err != NULL) {
|
||||
- qemu_co_rwlock_upgrade(&backup_state.stat.rwlock);
|
||||
- error_propagate(&backup_state.stat.error, local_err);
|
||||
- }
|
||||
+ pvebackup_propagate_error(local_err);
|
||||
+ }
|
||||
}
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
|
||||
proxmox_backup_disconnect(backup_state.pbs);
|
||||
backup_state.pbs = NULL;
|
||||
@@ -205,43 +256,14 @@ static void coroutine_fn pvebackup_co_cleanup(void)
|
||||
|
||||
g_list_free(backup_state.di_list);
|
||||
backup_state.di_list = NULL;
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
}
|
||||
|
||||
-typedef struct PVEBackupCompeteCallbackData {
|
||||
- PVEBackupDevInfo *di;
|
||||
- int result;
|
||||
-} PVEBackupCompeteCallbackData;
|
||||
-
|
||||
-static void coroutine_fn pvebackup_co_complete_cb(void *opaque)
|
||||
+// assumes the caller holds backup_mutex
|
||||
+static void coroutine_fn pvebackup_complete_stream(void *opaque)
|
||||
{
|
||||
- assert(qemu_in_coroutine());
|
||||
-
|
||||
- PVEBackupCompeteCallbackData *cb_data = opaque;
|
||||
-
|
||||
- qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
-
|
||||
- PVEBackupDevInfo *di = cb_data->di;
|
||||
- int ret = cb_data->result;
|
||||
-
|
||||
- di->completed = true;
|
||||
-
|
||||
- qemu_co_rwlock_rdlock(&backup_state.stat.rwlock);
|
||||
- bool error_or_canceled = backup_state.stat.error || backup_state.stat.cancel;
|
||||
-
|
||||
- if (ret < 0 && !backup_state.stat.error) {
|
||||
- qemu_co_rwlock_upgrade(&backup_state.stat.rwlock);
|
||||
- error_setg(&backup_state.stat.error, "job failed with err %d - %s",
|
||||
- ret, strerror(-ret));
|
||||
- }
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
-
|
||||
- di->bs = NULL;
|
||||
+ PVEBackupDevInfo *di = opaque;
|
||||
|
||||
- if (di->target) {
|
||||
- bdrv_unref(di->target);
|
||||
- di->target = NULL;
|
||||
- }
|
||||
+ bool error_or_canceled = pvebackup_error_or_canceled();
|
||||
|
||||
if (backup_state.vmaw) {
|
||||
vma_writer_close_stream(backup_state.vmaw, di->dev_id);
|
||||
@@ -251,110 +273,101 @@ static void coroutine_fn pvebackup_co_complete_cb(void *opaque)
|
||||
Error *local_err = NULL;
|
||||
proxmox_backup_co_close_image(backup_state.pbs, di->dev_id, &local_err);
|
||||
if (local_err != NULL) {
|
||||
- qemu_co_rwlock_wrlock(&backup_state.stat.rwlock);
|
||||
- error_propagate(&backup_state.stat.error, local_err);
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
+ pvebackup_propagate_error(local_err);
|
||||
}
|
||||
}
|
||||
+}
|
||||
|
||||
- // remove self from job queue
|
||||
- backup_state.di_list = g_list_remove(backup_state.di_list, di);
|
||||
- g_free(di);
|
||||
+static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
+{
|
||||
+ assert(!qemu_in_coroutine());
|
||||
|
||||
- int pending_jobs = g_list_length(backup_state.di_list);
|
||||
+ PVEBackupDevInfo *di = opaque;
|
||||
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ qemu_mutex_lock(&backup_state.backup_mutex);
|
||||
|
||||
- if (pending_jobs > 0) {
|
||||
- pvebackup_co_run_next_job();
|
||||
- } else {
|
||||
- pvebackup_co_cleanup();
|
||||
+ di->completed = true;
|
||||
+
|
||||
+ if (ret < 0) {
|
||||
+ Error *local_err = NULL;
|
||||
+ error_setg(&local_err, "job failed with err %d - %s", ret, strerror(-ret));
|
||||
+ pvebackup_propagate_error(local_err);
|
||||
}
|
||||
-}
|
||||
|
||||
-static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
-{
|
||||
- // This can be called from the main loop, or from a coroutine
|
||||
- PVEBackupCompeteCallbackData cb_data = {
|
||||
- .di = opaque,
|
||||
- .result = ret,
|
||||
- };
|
||||
+ di->bs = NULL;
|
||||
|
||||
- if (qemu_in_coroutine()) {
|
||||
- pvebackup_co_complete_cb(&cb_data);
|
||||
- } else {
|
||||
- block_on_coroutine_fn(pvebackup_co_complete_cb, &cb_data);
|
||||
- }
|
||||
-}
|
||||
+ assert(di->target == NULL);
|
||||
|
||||
-static void coroutine_fn pvebackup_co_cancel(void *opaque)
|
||||
-{
|
||||
- assert(qemu_in_coroutine());
|
||||
+ block_on_coroutine_fn(pvebackup_complete_stream, di);
|
||||
|
||||
- qemu_co_rwlock_wrlock(&backup_state.stat.rwlock);
|
||||
- backup_state.stat.cancel = true;
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
+ // remove self from job queue
|
||||
+ backup_state.di_list = g_list_remove(backup_state.di_list, di);
|
||||
|
||||
- qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
+ g_free(di);
|
||||
|
||||
- // Avoid race between block jobs and backup-cancel command:
|
||||
- if (!(backup_state.vmaw || backup_state.pbs)) {
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
- return;
|
||||
- }
|
||||
+ qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
|
||||
- qemu_co_rwlock_rdlock(&backup_state.stat.rwlock);
|
||||
- if (!backup_state.stat.error) {
|
||||
- qemu_co_rwlock_upgrade(&backup_state.stat.rwlock);
|
||||
- error_setg(&backup_state.stat.error, "backup cancelled");
|
||||
- }
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
+ pvebackup_run_next_job();
|
||||
+}
|
||||
+
|
||||
+static void pvebackup_cancel(void)
|
||||
+{
|
||||
+ assert(!qemu_in_coroutine());
|
||||
+
|
||||
+ Error *cancel_err = NULL;
|
||||
+ error_setg(&cancel_err, "backup canceled");
|
||||
+ pvebackup_propagate_error(cancel_err);
|
||||
+
|
||||
+ qemu_mutex_lock(&backup_state.backup_mutex);
|
||||
|
||||
if (backup_state.vmaw) {
|
||||
/* make sure vma writer does not block anymore */
|
||||
- vma_writer_set_error(backup_state.vmaw, "backup cancelled");
|
||||
+ vma_writer_set_error(backup_state.vmaw, "backup canceled");
|
||||
}
|
||||
|
||||
if (backup_state.pbs) {
|
||||
- proxmox_backup_abort(backup_state.pbs, "backup cancelled");
|
||||
+ proxmox_backup_abort(backup_state.pbs, "backup canceled");
|
||||
}
|
||||
|
||||
- bool running_jobs = 0;
|
||||
- GList *l = backup_state.di_list;
|
||||
- while (l) {
|
||||
- PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
- l = g_list_next(l);
|
||||
- if (!di->completed && di->bs) {
|
||||
- for (BlockJob *job = block_job_next(NULL); job; job = block_job_next(job)) {
|
||||
- if (job->job.driver->job_type != JOB_TYPE_BACKUP) {
|
||||
- continue;
|
||||
- }
|
||||
+ qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
|
||||
- BackupBlockJob *bjob = container_of(job, BackupBlockJob, common);
|
||||
- if (bjob && bjob->source_bs == di->bs) {
|
||||
- AioContext *aio_context = job->job.aio_context;
|
||||
- aio_context_acquire(aio_context);
|
||||
+ for(;;) {
|
||||
|
||||
- if (!di->completed) {
|
||||
- running_jobs += 1;
|
||||
- job_cancel(&job->job, false);
|
||||
- }
|
||||
- aio_context_release(aio_context);
|
||||
- }
|
||||
+ BlockJob *next_job = NULL;
|
||||
+
|
||||
+ qemu_mutex_lock(&backup_state.backup_mutex);
|
||||
+
|
||||
+ GList *l = backup_state.di_list;
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ BlockJob *job = lookup_active_block_job(di);
|
||||
+ if (job != NULL) {
|
||||
+ next_job = job;
|
||||
+ break;
|
||||
}
|
||||
}
|
||||
- }
|
||||
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
|
||||
- if (running_jobs == 0) pvebackup_co_cleanup(); // else job will call completion handler
|
||||
+ if (next_job) {
|
||||
+ AioContext *aio_context = next_job->job.aio_context;
|
||||
+ aio_context_acquire(aio_context);
|
||||
+ job_cancel_sync(&next_job->job);
|
||||
+ aio_context_release(aio_context);
|
||||
+ } else {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
void qmp_backup_cancel(Error **errp)
|
||||
{
|
||||
- block_on_coroutine_fn(pvebackup_co_cancel, NULL);
|
||||
+ pvebackup_cancel();
|
||||
}
|
||||
|
||||
+// assumes the caller holds backup_mutex
|
||||
static int coroutine_fn pvebackup_co_add_config(
|
||||
const char *file,
|
||||
const char *name,
|
||||
@@ -406,46 +419,97 @@ static int coroutine_fn pvebackup_co_add_config(
|
||||
|
||||
bool job_should_pause(Job *job);
|
||||
|
||||
-static void coroutine_fn pvebackup_co_run_next_job(void)
|
||||
+static void pvebackup_run_next_job(void)
|
||||
{
|
||||
- assert(qemu_in_coroutine());
|
||||
+ assert(!qemu_in_coroutine());
|
||||
|
||||
- qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
+ qemu_mutex_lock(&backup_state.backup_mutex);
|
||||
|
||||
GList *l = backup_state.di_list;
|
||||
while (l) {
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
l = g_list_next(l);
|
||||
- if (!di->completed && di->bs) {
|
||||
- for (BlockJob *job = block_job_next(NULL); job; job = block_job_next(job)) {
|
||||
- if (job->job.driver->job_type != JOB_TYPE_BACKUP) {
|
||||
- continue;
|
||||
- }
|
||||
|
||||
- BackupBlockJob *bjob = container_of(job, BackupBlockJob, common);
|
||||
- if (bjob && bjob->source_bs == di->bs) {
|
||||
- AioContext *aio_context = job->job.aio_context;
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
- aio_context_acquire(aio_context);
|
||||
-
|
||||
- if (job_should_pause(&job->job)) {
|
||||
- qemu_co_rwlock_rdlock(&backup_state.stat.rwlock);
|
||||
- bool error_or_canceled = backup_state.stat.error || backup_state.stat.cancel;
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
-
|
||||
- if (error_or_canceled) {
|
||||
- job_cancel(&job->job, false);
|
||||
- } else {
|
||||
- job_resume(&job->job);
|
||||
- }
|
||||
- }
|
||||
- aio_context_release(aio_context);
|
||||
- return;
|
||||
+ BlockJob *job = lookup_active_block_job(di);
|
||||
+
|
||||
+ if (job) {
|
||||
+ qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
+
|
||||
+ AioContext *aio_context = job->job.aio_context;
|
||||
+ aio_context_acquire(aio_context);
|
||||
+
|
||||
+ if (job_should_pause(&job->job)) {
|
||||
+ bool error_or_canceled = pvebackup_error_or_canceled();
|
||||
+ if (error_or_canceled) {
|
||||
+ job_cancel_sync(&job->job);
|
||||
+ } else {
|
||||
+ job_resume(&job->job);
|
||||
}
|
||||
}
|
||||
+ aio_context_release(aio_context);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ block_on_coroutine_fn(pvebackup_co_cleanup, NULL); // no more jobs, run cleanup
|
||||
+
|
||||
+ qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
+}
|
||||
+
|
||||
+static bool create_backup_jobs(void) {
|
||||
+
|
||||
+ assert(!qemu_in_coroutine());
|
||||
+
|
||||
+ Error *local_err = NULL;
|
||||
+
|
||||
+ /* create and start all jobs (paused state) */
|
||||
+ GList *l = backup_state.di_list;
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ assert(di->target != NULL);
|
||||
+
|
||||
+ 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, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
+ JOB_DEFAULT, pvebackup_complete_cb, di, 1, NULL, &local_err);
|
||||
+
|
||||
+ aio_context_release(aio_context);
|
||||
+
|
||||
+ if (!job || local_err != NULL) {
|
||||
+ Error *create_job_err = NULL;
|
||||
+ error_setg(&create_job_err, "backup_job_create failed: %s",
|
||||
+ local_err ? error_get_pretty(local_err) : "null");
|
||||
+
|
||||
+ pvebackup_propagate_error(create_job_err);
|
||||
+ break;
|
||||
+ }
|
||||
+ job_start(&job->job);
|
||||
+
|
||||
+ bdrv_unref(di->target);
|
||||
+ di->target = NULL;
|
||||
+ }
|
||||
+
|
||||
+ bool errors = pvebackup_error_or_canceled();
|
||||
+
|
||||
+ if (errors) {
|
||||
+ l = backup_state.di_list;
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ if (di->target) {
|
||||
+ bdrv_unref(di->target);
|
||||
+ di->target = NULL;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+
|
||||
+ return errors;
|
||||
}
|
||||
|
||||
typedef struct QmpBackupTask {
|
||||
@@ -476,7 +540,8 @@ typedef struct QmpBackupTask {
|
||||
UuidInfo *result;
|
||||
} QmpBackupTask;
|
||||
|
||||
-static void coroutine_fn pvebackup_co_start(void *opaque)
|
||||
+// assumes the caller holds backup_mutex
|
||||
+static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
{
|
||||
assert(qemu_in_coroutine());
|
||||
|
||||
@@ -495,16 +560,12 @@ static void coroutine_fn pvebackup_co_start(void *opaque)
|
||||
GList *di_list = NULL;
|
||||
GList *l;
|
||||
UuidInfo *uuid_info;
|
||||
- BlockJob *job;
|
||||
|
||||
const char *config_name = "qemu-server.conf";
|
||||
const char *firewall_name = "qemu-server.fw";
|
||||
|
||||
- qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
-
|
||||
if (backup_state.di_list) {
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
- error_set(task->errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
+ error_set(task->errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
"previous backup not finished");
|
||||
return;
|
||||
}
|
||||
@@ -627,7 +688,7 @@ static void coroutine_fn pvebackup_co_start(void *opaque)
|
||||
if (dev_id < 0)
|
||||
goto err;
|
||||
|
||||
- if (!(di->target = bdrv_backup_dump_create(dump_cb_block_size, di->size, pvebackup_co_dump_cb, di, task->errp))) {
|
||||
+ if (!(di->target = bdrv_backup_dump_create(dump_cb_block_size, di->size, pvebackup_co_dump_pbs_cb, di, task->errp))) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -648,7 +709,7 @@ static void coroutine_fn pvebackup_co_start(void *opaque)
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
l = g_list_next(l);
|
||||
|
||||
- if (!(di->target = bdrv_backup_dump_create(VMA_CLUSTER_SIZE, di->size, pvebackup_co_dump_cb, di, task->errp))) {
|
||||
+ if (!(di->target = bdrv_backup_dump_create(VMA_CLUSTER_SIZE, di->size, pvebackup_co_dump_vma_cb, di, task->errp))) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -713,9 +774,7 @@ static void coroutine_fn pvebackup_co_start(void *opaque)
|
||||
}
|
||||
/* initialize global backup_state now */
|
||||
|
||||
- qemu_co_rwlock_wrlock(&backup_state.stat.rwlock);
|
||||
-
|
||||
- backup_state.stat.cancel = false;
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
|
||||
if (backup_state.stat.error) {
|
||||
error_free(backup_state.stat.error);
|
||||
@@ -738,7 +797,7 @@ static void coroutine_fn pvebackup_co_start(void *opaque)
|
||||
backup_state.stat.transferred = 0;
|
||||
backup_state.stat.zero_bytes = 0;
|
||||
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
backup_state.speed = (task->has_speed && task->speed > 0) ? task->speed : 0;
|
||||
|
||||
@@ -747,48 +806,6 @@ static void coroutine_fn pvebackup_co_start(void *opaque)
|
||||
|
||||
backup_state.di_list = di_list;
|
||||
|
||||
- /* start all jobs (paused state) */
|
||||
- l = di_list;
|
||||
- while (l) {
|
||||
- PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
- l = g_list_next(l);
|
||||
-
|
||||
- // make sure target runs in same aoi_context as source
|
||||
- AioContext *aio_context = bdrv_get_aio_context(di->bs);
|
||||
- aio_context_acquire(aio_context);
|
||||
- GSList *ignore = NULL;
|
||||
- bdrv_set_aio_context_ignore(di->target, aio_context, &ignore);
|
||||
- g_slist_free(ignore);
|
||||
- aio_context_release(aio_context);
|
||||
-
|
||||
- job = backup_job_create(NULL, di->bs, di->target, backup_state.speed, MIRROR_SYNC_MODE_FULL, NULL,
|
||||
- BITMAP_SYNC_MODE_NEVER, false, NULL, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
- JOB_DEFAULT, pvebackup_complete_cb, di, 1, NULL, &local_err);
|
||||
- if (!job || local_err != NULL) {
|
||||
- qemu_co_rwlock_wrlock(&backup_state.stat.rwlock);
|
||||
- error_setg(&backup_state.stat.error, "backup_job_create failed");
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
- break;
|
||||
- }
|
||||
- job_start(&job->job);
|
||||
- if (di->target) {
|
||||
- bdrv_unref(di->target);
|
||||
- di->target = NULL;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
-
|
||||
- qemu_co_rwlock_rdlock(&backup_state.stat.rwlock);
|
||||
- bool no_errors = !backup_state.stat.error;
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
-
|
||||
- if (no_errors) {
|
||||
- pvebackup_co_run_next_job(); // run one job
|
||||
- } else {
|
||||
- pvebackup_co_cancel(NULL);
|
||||
- }
|
||||
-
|
||||
uuid_info = g_malloc0(sizeof(*uuid_info));
|
||||
uuid_info->UUID = uuid_str;
|
||||
|
||||
@@ -831,8 +848,6 @@ err:
|
||||
rmdir(backup_dir);
|
||||
}
|
||||
|
||||
- qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
-
|
||||
task->result = NULL;
|
||||
return;
|
||||
}
|
||||
@@ -876,32 +891,31 @@ UuidInfo *qmp_backup(
|
||||
.errp = errp,
|
||||
};
|
||||
|
||||
- block_on_coroutine_fn(pvebackup_co_start, &task);
|
||||
+ qemu_mutex_lock(&backup_state.backup_mutex);
|
||||
|
||||
- return task.result;
|
||||
-}
|
||||
+ block_on_coroutine_fn(pvebackup_co_prepare, &task);
|
||||
|
||||
+ if (*errp == NULL) {
|
||||
+ create_backup_jobs();
|
||||
+ qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ pvebackup_run_next_job();
|
||||
+ } else {
|
||||
+ qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ }
|
||||
|
||||
-typedef struct QmpQueryBackupTask {
|
||||
- Error **errp;
|
||||
- BackupStatus *result;
|
||||
-} QmpQueryBackupTask;
|
||||
+ return task.result;
|
||||
+}
|
||||
|
||||
-static void coroutine_fn pvebackup_co_query(void *opaque)
|
||||
+BackupStatus *qmp_query_backup(Error **errp)
|
||||
{
|
||||
- assert(qemu_in_coroutine());
|
||||
-
|
||||
- QmpQueryBackupTask *task = opaque;
|
||||
-
|
||||
BackupStatus *info = g_malloc0(sizeof(*info));
|
||||
|
||||
- qemu_co_rwlock_rdlock(&backup_state.stat.rwlock);
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
|
||||
if (!backup_state.stat.start_time) {
|
||||
/* not started, return {} */
|
||||
- task->result = info;
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
- return;
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+ return info;
|
||||
}
|
||||
|
||||
info->has_status = true;
|
||||
@@ -937,19 +951,7 @@ static void coroutine_fn pvebackup_co_query(void *opaque)
|
||||
info->has_transferred = true;
|
||||
info->transferred = backup_state.stat.transferred;
|
||||
|
||||
- task->result = info;
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
- qemu_co_rwlock_unlock(&backup_state.stat.rwlock);
|
||||
-}
|
||||
-
|
||||
-BackupStatus *qmp_query_backup(Error **errp)
|
||||
-{
|
||||
- QmpQueryBackupTask task = {
|
||||
- .errp = errp,
|
||||
- .result = NULL,
|
||||
- };
|
||||
-
|
||||
- block_on_coroutine_fn(pvebackup_co_query, &task);
|
||||
-
|
||||
- return task.result;
|
||||
+ return info;
|
||||
}
|
@@ -5,40 +5,35 @@ Subject: [PATCH] PVE-Backup: pbs-restore - new command to restore from proxmox
|
||||
backup server
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[WB: add namespace support]
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
Makefile | 4 +-
|
||||
pbs-restore.c | 217 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 220 insertions(+), 1 deletion(-)
|
||||
meson.build | 4 +
|
||||
pbs-restore.c | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 240 insertions(+)
|
||||
create mode 100644 pbs-restore.c
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index aec216968d..b73da29f24 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -479,7 +479,7 @@ dummy := $(call unnest-vars,, \
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 1f74de1d93..8508aab9c9 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -4373,6 +4373,10 @@ if have_tools
|
||||
vma = executable('vma', files('vma.c', 'vma-reader.c') + genh,
|
||||
dependencies: [authz, block, crypto, io, qemuutil, qom], install: true)
|
||||
|
||||
include $(SRC_PATH)/tests/Makefile.include
|
||||
|
||||
-all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) vma$(EXESUF) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
|
||||
+all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) vma$(EXESUF) pbs-restore$(EXESUF) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
|
||||
|
||||
qemu-version.h: FORCE
|
||||
$(call quiet-command, \
|
||||
@@ -604,6 +604,8 @@ qemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-o
|
||||
qemu-storage-daemon$(EXESUF): qemu-storage-daemon.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(chardev-obj-y) $(io-obj-y) $(qom-obj-y) $(storage-daemon-obj-y) $(COMMON_LDADDS)
|
||||
qemu-storage-daemon$(EXESUF): LIBS += -lproxmox_backup_qemu
|
||||
vma$(EXESUF): vma.o vma-reader.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
|
||||
+pbs-restore$(EXESUF): pbs-restore.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
|
||||
+pbs-restore$(EXESUF): LIBS += -lproxmox_backup_qemu
|
||||
|
||||
qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
|
||||
+ pbs_restore = executable('pbs-restore', files('pbs-restore.c') + genh,
|
||||
+ dependencies: [authz, block, crypto, io, qemuutil, qom,
|
||||
+ libproxmox_backup_qemu], install: true)
|
||||
+
|
||||
subdir('storage-daemon')
|
||||
|
||||
foreach exe: [ 'qemu-img', 'qemu-io', 'qemu-nbd', 'qemu-storage-daemon']
|
||||
diff --git a/pbs-restore.c b/pbs-restore.c
|
||||
new file mode 100644
|
||||
index 0000000000..4bf37ef1fa
|
||||
index 0000000000..f165f418af
|
||||
--- /dev/null
|
||||
+++ b/pbs-restore.c
|
||||
@@ -0,0 +1,217 @@
|
||||
@@ -0,0 +1,236 @@
|
||||
+/*
|
||||
+ * Qemu image restore helper for Proxmox Backup
|
||||
+ *
|
||||
@@ -57,21 +52,20 @@ index 0000000000..4bf37ef1fa
|
||||
+#include <getopt.h>
|
||||
+#include <string.h>
|
||||
+
|
||||
+#include "qemu-common.h"
|
||||
+#include "qemu/module.h"
|
||||
+#include "qemu/error-report.h"
|
||||
+#include "qemu/main-loop.h"
|
||||
+#include "qemu/cutils.h"
|
||||
+#include "qapi/error.h"
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
+#include "sysemu/block-backend.h"
|
||||
+#include "qobject/qdict.h"
|
||||
+#include "system/block-backend.h"
|
||||
+
|
||||
+#include <proxmox-backup-qemu.h>
|
||||
+
|
||||
+static void help(void)
|
||||
+{
|
||||
+ const char *help_msg =
|
||||
+ "usage: pbs-restore [--repository <repo>] snapshot archive-name target [command options]\n"
|
||||
+ "usage: pbs-restore [--repository <repo>] [--ns namespace] snapshot archive-name target [command options]\n"
|
||||
+ ;
|
||||
+
|
||||
+ printf("%s", help_msg);
|
||||
@@ -103,7 +97,7 @@ index 0000000000..4bf37ef1fa
|
||||
+ }
|
||||
+ res = blk_pwrite_zeroes(callback_data->target, offset, data_len, 0);
|
||||
+ } else {
|
||||
+ res = blk_pwrite(callback_data->target, offset, data, data_len, 0);
|
||||
+ res = blk_pwrite(callback_data->target, offset, data_len, data, 0);
|
||||
+ }
|
||||
+
|
||||
+ if (res < 0) {
|
||||
@@ -119,6 +113,7 @@ index 0000000000..4bf37ef1fa
|
||||
+ Error *main_loop_err = NULL;
|
||||
+ const char *format = "raw";
|
||||
+ const char *repository = NULL;
|
||||
+ const char *backup_ns = NULL;
|
||||
+ const char *keyfile = NULL;
|
||||
+ int verbose = false;
|
||||
+ bool skip_zero = false;
|
||||
@@ -132,6 +127,7 @@ index 0000000000..4bf37ef1fa
|
||||
+ {"verbose", no_argument, 0, 'v'},
|
||||
+ {"format", required_argument, 0, 'f'},
|
||||
+ {"repository", required_argument, 0, 'r'},
|
||||
+ {"ns", required_argument, 0, 'n'},
|
||||
+ {"keyfile", required_argument, 0, 'k'},
|
||||
+ {0, 0, 0, 0}
|
||||
+ };
|
||||
@@ -152,6 +148,9 @@ index 0000000000..4bf37ef1fa
|
||||
+ case 'r':
|
||||
+ repository = g_strdup(argv[optind - 1]);
|
||||
+ break;
|
||||
+ case 'n':
|
||||
+ backup_ns = g_strdup(argv[optind - 1]);
|
||||
+ break;
|
||||
+ case 'k':
|
||||
+ keyfile = g_strdup(argv[optind - 1]);
|
||||
+ break;
|
||||
@@ -202,13 +201,27 @@ index 0000000000..4bf37ef1fa
|
||||
+ fprintf(stderr, "connecting to repository '%s'\n", repository);
|
||||
+ }
|
||||
+ char *pbs_error = NULL;
|
||||
+ ProxmoxRestoreHandle *conn = proxmox_restore_connect(
|
||||
+ repository, snapshot, password, keyfile, key_password, fingerprint, &pbs_error);
|
||||
+ ProxmoxRestoreHandle *conn = proxmox_restore_new_ns(
|
||||
+ repository,
|
||||
+ snapshot,
|
||||
+ backup_ns,
|
||||
+ password,
|
||||
+ keyfile,
|
||||
+ key_password,
|
||||
+ fingerprint,
|
||||
+ &pbs_error
|
||||
+ );
|
||||
+ if (conn == NULL) {
|
||||
+ fprintf(stderr, "restore failed: %s\n", pbs_error);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ int res = proxmox_restore_connect(conn, &pbs_error);
|
||||
+ if (res < 0 || pbs_error) {
|
||||
+ fprintf(stderr, "restore failed (connection error): %s\n", pbs_error);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ QDict *options = qdict_new();
|
||||
+
|
||||
+ if (format) {
|
||||
@@ -239,7 +252,7 @@ index 0000000000..4bf37ef1fa
|
||||
+ fprintf(stderr, "starting to restore snapshot '%s'\n", snapshot);
|
||||
+ fflush(stderr); // ensure we do not get printed after the progress log
|
||||
+ }
|
||||
+ int res = proxmox_restore_image(
|
||||
+ res = proxmox_restore_image(
|
||||
+ conn,
|
||||
+ archive_name,
|
||||
+ write_callback,
|
||||
@@ -248,6 +261,7 @@ index 0000000000..4bf37ef1fa
|
||||
+ verbose);
|
||||
+
|
||||
+ proxmox_restore_disconnect(conn);
|
||||
+ blk_unref(blk);
|
||||
+
|
||||
+ if (res < 0) {
|
||||
+ fprintf(stderr, "restore failed: %s\n", pbs_error);
|
@@ -6,53 +6,59 @@ Subject: [PATCH] PVE: Add PBS block driver to map backup archives into VMs
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
[error cleanups, file_open implementation]
|
||||
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[WB: add namespace support]
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
[FE: adapt to changed function signatures
|
||||
make pbs_co_preadv return values consistent with QEMU
|
||||
getlength is now a coroutine function]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/Makefile.objs | 2 +
|
||||
block/pbs.c | 271 +++++++++++++++++++++++++++++++++++++++++++
|
||||
configure | 10 ++
|
||||
qapi/block-core.json | 14 ++-
|
||||
4 files changed, 296 insertions(+), 1 deletion(-)
|
||||
block/meson.build | 2 +
|
||||
block/pbs.c | 306 +++++++++++++++++++++++++++++++++++++++++++
|
||||
meson.build | 2 +-
|
||||
qapi/block-core.json | 29 ++++
|
||||
qapi/pragma.json | 1 +
|
||||
5 files changed, 339 insertions(+), 1 deletion(-)
|
||||
create mode 100644 block/pbs.c
|
||||
|
||||
diff --git a/block/Makefile.objs b/block/Makefile.objs
|
||||
index 9ea0477d0b..28fb3b7f7c 100644
|
||||
--- a/block/Makefile.objs
|
||||
+++ b/block/Makefile.objs
|
||||
@@ -5,6 +5,7 @@ block-obj-$(CONFIG_CLOOP) += cloop.o
|
||||
block-obj-$(CONFIG_BOCHS) += bochs.o
|
||||
block-obj-$(CONFIG_VVFAT) += vvfat.o
|
||||
block-obj-$(CONFIG_DMG) += dmg.o
|
||||
+block-obj-$(CONFIG_PBS_BDRV) += pbs.o
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index d1b16e40e9..d243372c41 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -49,6 +49,8 @@ block_ss.add(files(
|
||||
'../pve-backup.c',
|
||||
), libproxmox_backup_qemu)
|
||||
|
||||
block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-cache.o qcow2-bitmap.o qcow2-threads.o
|
||||
block-obj-$(CONFIG_QED) += qed.o qed-l2-cache.o qed-table.o qed-cluster.o
|
||||
@@ -75,3 +76,4 @@ io_uring.o-cflags := $(LINUX_IO_URING_CFLAGS)
|
||||
io_uring.o-libs := $(LINUX_IO_URING_LIBS)
|
||||
parallels.o-cflags := $(LIBXML2_CFLAGS)
|
||||
parallels.o-libs := $(LIBXML2_LIBS)
|
||||
+pbs.o-libs := -lproxmox_backup_qemu
|
||||
+block_ss.add(files('pbs.c'), libproxmox_backup_qemu)
|
||||
+
|
||||
|
||||
system_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
system_ss.add(files('block-ram-registrar.c'))
|
||||
diff --git a/block/pbs.c b/block/pbs.c
|
||||
new file mode 100644
|
||||
index 0000000000..1481a2bfd1
|
||||
index 0000000000..3e41421716
|
||||
--- /dev/null
|
||||
+++ b/block/pbs.c
|
||||
@@ -0,0 +1,271 @@
|
||||
@@ -0,0 +1,306 @@
|
||||
+/*
|
||||
+ * Proxmox Backup Server read-only block driver
|
||||
+ */
|
||||
+
|
||||
+#include "qemu/osdep.h"
|
||||
+#include "qapi/error.h"
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
+#include "qapi/qmp/qstring.h"
|
||||
+#include "qobject/qdict.h"
|
||||
+#include "qobject/qstring.h"
|
||||
+#include "qemu/module.h"
|
||||
+#include "qemu/option.h"
|
||||
+#include "qemu/cutils.h"
|
||||
+#include "block/block_int.h"
|
||||
+#include "block/block-io.h"
|
||||
+
|
||||
+#include <proxmox-backup-qemu.h>
|
||||
+
|
||||
+#define PBS_OPT_REPOSITORY "repository"
|
||||
+#define PBS_OPT_NAMESPACE "namespace"
|
||||
+#define PBS_OPT_SNAPSHOT "snapshot"
|
||||
+#define PBS_OPT_ARCHIVE "archive"
|
||||
+#define PBS_OPT_KEYFILE "keyfile"
|
||||
@@ -62,10 +68,11 @@ index 0000000000..1481a2bfd1
|
||||
+
|
||||
+typedef struct {
|
||||
+ ProxmoxRestoreHandle *conn;
|
||||
+ char aid;
|
||||
+ uint8_t aid;
|
||||
+ int64_t length;
|
||||
+
|
||||
+ char *repository;
|
||||
+ char *namespace;
|
||||
+ char *snapshot;
|
||||
+ char *archive;
|
||||
+} BDRVPBSState;
|
||||
@@ -80,6 +87,11 @@ index 0000000000..1481a2bfd1
|
||||
+ .help = "The server address and repository to connect to.",
|
||||
+ },
|
||||
+ {
|
||||
+ .name = PBS_OPT_NAMESPACE,
|
||||
+ .type = QEMU_OPT_STRING,
|
||||
+ .help = "Optional: The snapshot's namespace.",
|
||||
+ },
|
||||
+ {
|
||||
+ .name = PBS_OPT_SNAPSHOT,
|
||||
+ .type = QEMU_OPT_STRING,
|
||||
+ .help = "The snapshot to read.",
|
||||
@@ -115,7 +127,7 @@ index 0000000000..1481a2bfd1
|
||||
+
|
||||
+
|
||||
+// filename format:
|
||||
+// pbs:repository=<repo>,snapshot=<snap>,password=<pw>,key_password=<kpw>,fingerprint=<fp>,archive=<archive>
|
||||
+// pbs:repository=<repo>,namespace=<ns>,snapshot=<snap>,password=<pw>,key_password=<kpw>,fingerprint=<fp>,archive=<archive>
|
||||
+static void pbs_parse_filename(const char *filename, QDict *options,
|
||||
+ Error **errp)
|
||||
+{
|
||||
@@ -151,6 +163,7 @@ index 0000000000..1481a2bfd1
|
||||
+ s->archive = g_strdup(qemu_opt_get(opts, PBS_OPT_ARCHIVE));
|
||||
+ const char *keyfile = qemu_opt_get(opts, PBS_OPT_KEYFILE);
|
||||
+ const char *password = qemu_opt_get(opts, PBS_OPT_PASSWORD);
|
||||
+ const char *namespace = qemu_opt_get(opts, PBS_OPT_NAMESPACE);
|
||||
+ const char *fingerprint = qemu_opt_get(opts, PBS_OPT_FINGERPRINT);
|
||||
+ const char *key_password = qemu_opt_get(opts, PBS_OPT_ENCRYPTION_PASSWORD);
|
||||
+
|
||||
@@ -163,9 +176,12 @@ index 0000000000..1481a2bfd1
|
||||
+ if (!key_password) {
|
||||
+ key_password = getenv("PBS_ENCRYPTION_PASSWORD");
|
||||
+ }
|
||||
+ if (namespace) {
|
||||
+ s->namespace = g_strdup(namespace);
|
||||
+ }
|
||||
+
|
||||
+ /* connect to PBS server in read mode */
|
||||
+ s->conn = proxmox_restore_new(s->repository, s->snapshot, password,
|
||||
+ s->conn = proxmox_restore_new_ns(s->repository, s->snapshot, s->namespace, password,
|
||||
+ keyfile, key_password, fingerprint, &pbs_error);
|
||||
+
|
||||
+ /* invalidates qemu_opt_get char pointers from above */
|
||||
@@ -185,12 +201,18 @@ index 0000000000..1481a2bfd1
|
||||
+ }
|
||||
+
|
||||
+ /* acquire handle and length */
|
||||
+ s->aid = proxmox_restore_open_image(s->conn, s->archive, &pbs_error);
|
||||
+ if (s->aid < 0) {
|
||||
+ ret = proxmox_restore_open_image(s->conn, s->archive, &pbs_error);
|
||||
+ if (ret < 0) {
|
||||
+ if (pbs_error && errp) error_setg(errp, "PBS open_image failed: %s", pbs_error);
|
||||
+ if (pbs_error) proxmox_backup_free_error(pbs_error);
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+ if (ret > UINT8_MAX) {
|
||||
+ error_setg(errp, "PBS open_image returned an ID larger than %u", UINT8_MAX);
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+ s->aid = ret;
|
||||
+
|
||||
+ s->length = proxmox_restore_get_image_length(s->conn, s->aid, &pbs_error);
|
||||
+ if (s->length < 0) {
|
||||
+ if (pbs_error && errp) error_setg(errp, "PBS get_image_length failed: %s", pbs_error);
|
||||
@@ -201,21 +223,17 @@ index 0000000000..1481a2bfd1
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int pbs_file_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ return pbs_open(bs, options, flags, errp);
|
||||
+}
|
||||
+
|
||||
+static void pbs_close(BlockDriverState *bs) {
|
||||
+ BDRVPBSState *s = bs->opaque;
|
||||
+ g_free(s->repository);
|
||||
+ g_free(s->namespace);
|
||||
+ g_free(s->snapshot);
|
||||
+ g_free(s->archive);
|
||||
+ proxmox_restore_disconnect(s->conn);
|
||||
+}
|
||||
+
|
||||
+static int64_t pbs_getlength(BlockDriverState *bs)
|
||||
+static coroutine_fn int64_t GRAPH_RDLOCK
|
||||
+pbs_co_getlength(BlockDriverState *bs)
|
||||
+{
|
||||
+ BDRVPBSState *s = bs->opaque;
|
||||
+ return s->length;
|
||||
@@ -232,21 +250,35 @@ index 0000000000..1481a2bfd1
|
||||
+ aio_co_schedule(rcb->ctx, rcb->co);
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int pbs_co_preadv(BlockDriverState *bs,
|
||||
+ uint64_t offset, uint64_t bytes,
|
||||
+ QEMUIOVector *qiov, int flags)
|
||||
+static coroutine_fn int GRAPH_RDLOCK
|
||||
+pbs_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
+ QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ BDRVPBSState *s = bs->opaque;
|
||||
+ int ret;
|
||||
+ char *pbs_error = NULL;
|
||||
+ uint8_t *buf = malloc(bytes);
|
||||
+ uint8_t *buf;
|
||||
+ bool inline_buf = true;
|
||||
+
|
||||
+ /* for single-buffer IO vectors we can fast-path the write directly to it */
|
||||
+ if (qiov->niov == 1 && qiov->iov->iov_len >= bytes) {
|
||||
+ buf = qiov->iov->iov_base;
|
||||
+ } else {
|
||||
+ inline_buf = false;
|
||||
+ buf = g_malloc(bytes);
|
||||
+ }
|
||||
+
|
||||
+ if (offset < 0 || bytes < 0) {
|
||||
+ fprintf(stderr, "unexpected negative 'offset' or 'bytes' value!\n");
|
||||
+ return -EIO;
|
||||
+ }
|
||||
+
|
||||
+ ReadCallbackData rcb = {
|
||||
+ .co = qemu_coroutine_self(),
|
||||
+ .ctx = qemu_get_current_aio_context(),
|
||||
+ .ctx = bdrv_get_aio_context(bs),
|
||||
+ };
|
||||
+
|
||||
+ proxmox_restore_read_image_at_async(s->conn, s->aid, buf, offset, bytes,
|
||||
+ proxmox_restore_read_image_at_async(s->conn, s->aid, buf, (uint64_t)offset, (uint64_t)bytes,
|
||||
+ read_callback, (void *) &rcb, &ret, &pbs_error);
|
||||
+
|
||||
+ qemu_coroutine_yield();
|
||||
@@ -257,26 +289,34 @@ index 0000000000..1481a2bfd1
|
||||
+ return -EIO;
|
||||
+ }
|
||||
+
|
||||
+ qemu_iovec_from_buf(qiov, 0, buf, bytes);
|
||||
+ free(buf);
|
||||
+ if (!inline_buf) {
|
||||
+ qemu_iovec_from_buf(qiov, 0, buf, bytes);
|
||||
+ g_free(buf);
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int pbs_co_pwritev(BlockDriverState *bs,
|
||||
+ uint64_t offset, uint64_t bytes,
|
||||
+ QEMUIOVector *qiov, int flags)
|
||||
+static coroutine_fn int GRAPH_RDLOCK
|
||||
+pbs_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
+ QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ fprintf(stderr, "pbs-bdrv: cannot write to backup file, make sure "
|
||||
+ "any attached disk devices are set to read-only!\n");
|
||||
+ return -EPERM;
|
||||
+}
|
||||
+
|
||||
+static void pbs_refresh_filename(BlockDriverState *bs)
|
||||
+static void GRAPH_RDLOCK
|
||||
+pbs_refresh_filename(BlockDriverState *bs)
|
||||
+{
|
||||
+ BDRVPBSState *s = bs->opaque;
|
||||
+ snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s/%s(%s)",
|
||||
+ s->repository, s->snapshot, s->archive);
|
||||
+ if (s->namespace) {
|
||||
+ snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s/%s:%s(%s)",
|
||||
+ s->repository, s->namespace, s->snapshot, s->archive);
|
||||
+ } else {
|
||||
+ snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s/%s(%s)",
|
||||
+ s->repository, s->snapshot, s->archive);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static const char *const pbs_strong_runtime_opts[] = {
|
||||
@@ -290,10 +330,9 @@ index 0000000000..1481a2bfd1
|
||||
+
|
||||
+ .bdrv_parse_filename = pbs_parse_filename,
|
||||
+
|
||||
+ .bdrv_file_open = pbs_file_open,
|
||||
+ .bdrv_open = pbs_open,
|
||||
+ .bdrv_close = pbs_close,
|
||||
+ .bdrv_getlength = pbs_getlength,
|
||||
+ .bdrv_co_getlength = pbs_co_getlength,
|
||||
+
|
||||
+ .bdrv_co_preadv = pbs_co_preadv,
|
||||
+ .bdrv_co_pwritev = pbs_co_pwritev,
|
||||
@@ -308,69 +347,32 @@ index 0000000000..1481a2bfd1
|
||||
+}
|
||||
+
|
||||
+block_init(bdrv_pbs_init);
|
||||
diff --git a/configure b/configure
|
||||
index 2acc4d1465..3fc80d0c2c 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -510,6 +510,7 @@ vvfat="yes"
|
||||
qed="yes"
|
||||
parallels="yes"
|
||||
sheepdog="yes"
|
||||
+pbs_bdrv="yes"
|
||||
libxml2=""
|
||||
debug_mutex="no"
|
||||
libpmem=""
|
||||
@@ -1576,6 +1577,10 @@ for opt do
|
||||
;;
|
||||
--enable-sheepdog) sheepdog="yes"
|
||||
;;
|
||||
+ --disable-pbs-bdrv) pbs_bdrv="no"
|
||||
+ ;;
|
||||
+ --enable-pbs-bdrv) pbs_bdrv="yes"
|
||||
+ ;;
|
||||
--disable-vhost-user) vhost_user="no"
|
||||
;;
|
||||
--enable-vhost-user) vhost_user="yes"
|
||||
@@ -1936,6 +1941,7 @@ disabled with --disable-FEATURE, default is enabled if available:
|
||||
qed qed image format support
|
||||
parallels parallels image format support
|
||||
sheepdog sheepdog block driver support
|
||||
+ pbs-bdrv Proxmox backup server read-only block driver support
|
||||
crypto-afalg Linux AF_ALG crypto backend driver
|
||||
capstone capstone disassembler support
|
||||
debug-mutex mutex debugging support
|
||||
@@ -7009,6 +7015,7 @@ echo "vvfat support $vvfat"
|
||||
echo "qed support $qed"
|
||||
echo "parallels support $parallels"
|
||||
echo "sheepdog support $sheepdog"
|
||||
+echo "pbs-bdrv support $pbs_bdrv"
|
||||
echo "capstone $capstone"
|
||||
echo "libpmem support $libpmem"
|
||||
echo "libdaxctl support $libdaxctl"
|
||||
@@ -7885,6 +7892,9 @@ fi
|
||||
if test "$sheepdog" = "yes" ; then
|
||||
echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
|
||||
fi
|
||||
+if test "$pbs_bdrv" = "yes" ; then
|
||||
+ echo "CONFIG_PBS_BDRV=y" >> $config_host_mak
|
||||
+fi
|
||||
if test "$pty_h" = "yes" ; then
|
||||
echo "HAVE_PTY_H=y" >> $config_host_mak
|
||||
fi
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 8508aab9c9..9c39f54f86 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -4838,7 +4838,7 @@ summary_info += {'Query Processing Library support': qpl}
|
||||
summary_info += {'UADK Library support': uadk}
|
||||
summary_info += {'qatzip support': qatzip}
|
||||
summary_info += {'NUMA host support': numa}
|
||||
-summary_info += {'capstone': capstone}
|
||||
+summary_info += {'PBS bdrv support': config_host.has_key('CONFIG_PBS_BDRV')}
|
||||
summary_info += {'libpmem support': libpmem}
|
||||
summary_info += {'libdaxctl support': libdaxctl}
|
||||
summary_info += {'libcbor support': libcbor}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index a177fea6cd..f782c2cf96 100644
|
||||
index dd98e03bf1..0c3ebfa74e 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -2951,7 +2951,7 @@
|
||||
'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
|
||||
'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
|
||||
{ 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' },
|
||||
- 'sheepdog',
|
||||
+ 'sheepdog', 'pbs',
|
||||
'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
|
||||
|
||||
##
|
||||
@@ -3015,6 +3015,17 @@
|
||||
@@ -3470,6 +3470,7 @@
|
||||
'parallels', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum',
|
||||
'raw', 'rbd',
|
||||
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
|
||||
+ 'pbs',
|
||||
'ssh', 'throttle', 'vdi', 'vhdx',
|
||||
{ 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
|
||||
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
|
||||
@@ -3556,6 +3557,33 @@
|
||||
{ 'struct': 'BlockdevOptionsNull',
|
||||
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
|
||||
|
||||
@@ -379,20 +381,48 @@ index a177fea6cd..f782c2cf96 100644
|
||||
+#
|
||||
+# Driver specific block device options for the PBS backend.
|
||||
+#
|
||||
+# @repository: Proxmox Backup Server repository.
|
||||
+#
|
||||
+# @snapshot: backup snapshots ID.
|
||||
+#
|
||||
+# @archive: archive name.
|
||||
+#
|
||||
+# @keyfile: keyfile to use for encryption.
|
||||
+#
|
||||
+# @password: password to use for connection.
|
||||
+#
|
||||
+# @fingerprint: backup server fingerprint.
|
||||
+#
|
||||
+# @key_password: password to unlock key.
|
||||
+#
|
||||
+# @namespace: namespace where backup snapshot lives.
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'BlockdevOptionsPbs',
|
||||
+ 'data': { 'repository': 'str', 'snapshot': 'str', 'archive': 'str',
|
||||
+ '*keyfile': 'str', '*password': 'str', '*fingerprint': 'str',
|
||||
+ '*key_password': 'str' } }
|
||||
+ '*key_password': 'str', '*namespace': 'str' } }
|
||||
+
|
||||
##
|
||||
# @BlockdevOptionsNVMe:
|
||||
#
|
||||
@@ -4121,6 +4132,7 @@
|
||||
@@ -5003,6 +5031,7 @@
|
||||
'nfs': 'BlockdevOptionsNfs',
|
||||
'null-aio': 'BlockdevOptionsNull',
|
||||
'null-co': 'BlockdevOptionsNull',
|
||||
+ 'pbs': 'BlockdevOptionsPbs',
|
||||
'nvme': 'BlockdevOptionsNVMe',
|
||||
'parallels': 'BlockdevOptionsGenericFormat',
|
||||
'qcow2': 'BlockdevOptionsQcow2',
|
||||
'nvme-io_uring': { 'type': 'BlockdevOptionsNvmeIoUring',
|
||||
'if': 'CONFIG_BLKIO' },
|
||||
diff --git a/qapi/pragma.json b/qapi/pragma.json
|
||||
index 6aaa9cb975..e9c595c4ba 100644
|
||||
--- a/qapi/pragma.json
|
||||
+++ b/qapi/pragma.json
|
||||
@@ -91,6 +91,7 @@
|
||||
'BlockInfo', # query-block
|
||||
'BlockdevAioOptions', # blockdev-add, -blockdev
|
||||
'BlockdevDriver', # blockdev-add, query-blockstats, ...
|
||||
+ 'BlockdevOptionsPbs', # for PBS backwards compat
|
||||
'BlockdevVmdkAdapterType', # blockdev-create (to match VMDK spec)
|
||||
'BlockdevVmdkSubformat', # blockdev-create (to match VMDK spec)
|
||||
'ColoCompareProperties', # object_add, -object
|
62
debian/patches/pve/0033-PVE-redirect-stderr-to-journal-when-daemonized.patch
vendored
Normal file
62
debian/patches/pve/0033-PVE-redirect-stderr-to-journal-when-daemonized.patch
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Tue, 12 Jan 2021 14:12:20 +0100
|
||||
Subject: [PATCH] PVE: redirect stderr to journal when daemonized
|
||||
|
||||
QEMU uses the logging for error messages usually, so LOG_ERR is most
|
||||
fitting.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
meson.build | 3 ++-
|
||||
os-posix.c | 7 +++++--
|
||||
2 files changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 9c39f54f86..60af7fa723 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -2162,6 +2162,7 @@ endif
|
||||
has_gettid = cc.has_function('gettid')
|
||||
|
||||
libuuid = cc.find_library('uuid', required: true)
|
||||
+libsystemd = cc.find_library('systemd', required: true)
|
||||
libproxmox_backup_qemu = cc.find_library('proxmox_backup_qemu', required: true)
|
||||
|
||||
# libselinux
|
||||
@@ -3766,7 +3767,7 @@ if have_block
|
||||
if host_os == 'windows'
|
||||
system_ss.add(files('os-win32.c'))
|
||||
else
|
||||
- blockdev_ss.add(files('os-posix.c'))
|
||||
+ blockdev_ss.add(files('os-posix.c'), libsystemd)
|
||||
endif
|
||||
endif
|
||||
|
||||
diff --git a/os-posix.c b/os-posix.c
|
||||
index 52925c23d3..84b96d3da9 100644
|
||||
--- a/os-posix.c
|
||||
+++ b/os-posix.c
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <libgen.h>
|
||||
+#include <systemd/sd-journal.h>
|
||||
+#include <syslog.h>
|
||||
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/log.h"
|
||||
@@ -306,9 +308,10 @@ void os_setup_post(void)
|
||||
|
||||
dup2(fd, 0);
|
||||
dup2(fd, 1);
|
||||
- /* In case -D is given do not redirect stderr to /dev/null */
|
||||
+ /* In case -D is given do not redirect stderr to journal */
|
||||
if (!qemu_log_enabled()) {
|
||||
- dup2(fd, 2);
|
||||
+ int journal_fd = sd_journal_stream_fd("QEMU", LOG_ERR, 0);
|
||||
+ dup2(journal_fd, 2);
|
||||
}
|
||||
|
||||
close(fd);
|
@@ -12,46 +12,69 @@ Also add a flag to query-proxmox-support so qemu-server can determine if
|
||||
safe migration is possible and makes sense.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: split up state_pending for 8.0]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
include/migration/misc.h | 3 ++
|
||||
migration/Makefile.objs | 1 +
|
||||
migration/pbs-state.c | 106 +++++++++++++++++++++++++++++++++++++++
|
||||
migration/meson.build | 2 +
|
||||
migration/migration.c | 1 +
|
||||
migration/pbs-state.c | 104 +++++++++++++++++++++++++++++++++++++++
|
||||
pve-backup.c | 1 +
|
||||
qapi/block-core.json | 6 +++
|
||||
softmmu/vl.c | 1 +
|
||||
6 files changed, 118 insertions(+)
|
||||
6 files changed, 117 insertions(+)
|
||||
create mode 100644 migration/pbs-state.c
|
||||
|
||||
diff --git a/include/migration/misc.h b/include/migration/misc.h
|
||||
index 34e7d75713..f83816dd3c 100644
|
||||
index 8fd36eba1d..e963e93e71 100644
|
||||
--- a/include/migration/misc.h
|
||||
+++ b/include/migration/misc.h
|
||||
@@ -75,4 +75,7 @@ bool migration_in_incoming_postcopy(void);
|
||||
/* migration/block-dirty-bitmap.c */
|
||||
void dirty_bitmap_mig_init(void);
|
||||
@@ -140,4 +140,7 @@ bool multifd_device_state_save_thread_should_exit(void);
|
||||
void multifd_abort_device_state_save_threads(void);
|
||||
bool multifd_join_device_state_save_threads(void);
|
||||
|
||||
+/* migration/pbs-state.c */
|
||||
+void pbs_state_mig_init(void);
|
||||
+
|
||||
#endif
|
||||
diff --git a/migration/Makefile.objs b/migration/Makefile.objs
|
||||
index 0fc619e380..20b3792599 100644
|
||||
--- a/migration/Makefile.objs
|
||||
+++ b/migration/Makefile.objs
|
||||
@@ -9,6 +9,7 @@ common-obj-y += qjson.o
|
||||
common-obj-y += block-dirty-bitmap.o
|
||||
common-obj-y += multifd.o
|
||||
common-obj-y += multifd-zlib.o
|
||||
+common-obj-y += pbs-state.o
|
||||
common-obj-$(CONFIG_ZSTD) += multifd-zstd.o
|
||||
diff --git a/migration/meson.build b/migration/meson.build
|
||||
index 46e92249a1..fb3fd7d7d0 100644
|
||||
--- a/migration/meson.build
|
||||
+++ b/migration/meson.build
|
||||
@@ -8,6 +8,7 @@ migration_files = files(
|
||||
'qemu-file.c',
|
||||
'yank_functions.c',
|
||||
)
|
||||
+system_ss.add(libproxmox_backup_qemu)
|
||||
|
||||
common-obj-$(CONFIG_RDMA) += rdma.o
|
||||
system_ss.add(files(
|
||||
'block-dirty-bitmap.c',
|
||||
@@ -31,6 +32,7 @@ system_ss.add(files(
|
||||
'multifd-zlib.c',
|
||||
'multifd-zero-page.c',
|
||||
'options.c',
|
||||
+ 'pbs-state.c',
|
||||
'postcopy-ram.c',
|
||||
'savevm.c',
|
||||
'savevm-async.c',
|
||||
diff --git a/migration/migration.c b/migration/migration.c
|
||||
index d46e776e24..2f3430f440 100644
|
||||
--- a/migration/migration.c
|
||||
+++ b/migration/migration.c
|
||||
@@ -319,6 +319,7 @@ void migration_object_init(void)
|
||||
|
||||
/* Initialize cpu throttle timers */
|
||||
cpu_throttle_init();
|
||||
+ pbs_state_mig_init();
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
diff --git a/migration/pbs-state.c b/migration/pbs-state.c
|
||||
new file mode 100644
|
||||
index 0000000000..29f2b3860d
|
||||
index 0000000000..a97187e4d7
|
||||
--- /dev/null
|
||||
+++ b/migration/pbs-state.c
|
||||
@@ -0,0 +1,106 @@
|
||||
@@ -0,0 +1,104 @@
|
||||
+/*
|
||||
+ * PBS (dirty-bitmap) state migration
|
||||
+ */
|
||||
@@ -70,11 +93,8 @@ index 0000000000..29f2b3860d
|
||||
+/* state is accessed via this static variable directly, 'opaque' is NULL */
|
||||
+static PBSState pbs_state;
|
||||
+
|
||||
+static void pbs_state_save_pending(QEMUFile *f, void *opaque,
|
||||
+ uint64_t max_size,
|
||||
+ uint64_t *res_precopy_only,
|
||||
+ uint64_t *res_compatible,
|
||||
+ uint64_t *res_postcopy_only)
|
||||
+static void pbs_state_pending(void *opaque, uint64_t *must_precopy,
|
||||
+ uint64_t *can_postcopy)
|
||||
+{
|
||||
+ /* we send everything in save_setup, so nothing is ever pending */
|
||||
+}
|
||||
@@ -100,7 +120,7 @@ index 0000000000..29f2b3860d
|
||||
+}
|
||||
+
|
||||
+/* serialize PBS state and send to target via f, called on source */
|
||||
+static int pbs_state_save_setup(QEMUFile *f, void *opaque)
|
||||
+static int pbs_state_save_setup(QEMUFile *f, void *opaque, Error **errp)
|
||||
+{
|
||||
+ size_t buf_size;
|
||||
+ uint8_t *buf = proxmox_export_state(&buf_size);
|
||||
@@ -144,7 +164,8 @@ index 0000000000..29f2b3860d
|
||||
+static SaveVMHandlers savevm_pbs_state_handlers = {
|
||||
+ .save_setup = pbs_state_save_setup,
|
||||
+ .has_postcopy = pbs_state_has_postcopy,
|
||||
+ .save_live_pending = pbs_state_save_pending,
|
||||
+ .state_pending_exact = pbs_state_pending,
|
||||
+ .state_pending_estimate = pbs_state_pending,
|
||||
+ .is_active_iterate = pbs_state_is_active_iterate,
|
||||
+ .load_state = pbs_state_load,
|
||||
+ .is_active = pbs_state_is_active,
|
||||
@@ -159,48 +180,38 @@ index 0000000000..29f2b3860d
|
||||
+ NULL);
|
||||
+}
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index c7cde0fb0e..f65f1dda26 100644
|
||||
index e931cb9203..366b015589 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -1130,5 +1130,6 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
@@ -1089,6 +1089,7 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
ret->pbs_library_version = g_strdup(proxmox_backup_qemu_version());
|
||||
ret->pbs_dirty_bitmap = true;
|
||||
ret->query_bitmap_info = true;
|
||||
ret->pbs_dirty_bitmap_savevm = true;
|
||||
+ ret->pbs_dirty_bitmap_migration = true;
|
||||
return ret;
|
||||
}
|
||||
ret->query_bitmap_info = true;
|
||||
ret->pbs_masterkey = true;
|
||||
ret->backup_max_workers = true;
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 29650896e2..0da4b35028 100644
|
||||
index 0c3ebfa74e..6838187607 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -890,12 +890,18 @@
|
||||
#
|
||||
# @query-bitmap-info: True if the 'query-pbs-bitmap-info' QMP call is supported.
|
||||
@@ -1008,6 +1008,11 @@
|
||||
# @pbs-dirty-bitmap-savevm: True if 'dirty-bitmaps' migration capability can
|
||||
# safely be set for savevm-async.
|
||||
#
|
||||
+# @pbs-dirty-bitmap-migration: True if safe migration of dirty-bitmaps including
|
||||
+# PBS state is supported. Enabling 'dirty-bitmaps'
|
||||
+# migration cap if this is false/unset may lead
|
||||
+# to crashes on migration!
|
||||
+#
|
||||
# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
|
||||
# @pbs-masterkey: True if the QMP backup call supports the 'master_keyfile'
|
||||
# parameter.
|
||||
#
|
||||
##
|
||||
{ 'struct': 'ProxmoxSupportStatus',
|
||||
@@ -1021,6 +1026,7 @@
|
||||
'data': { 'pbs-dirty-bitmap': 'bool',
|
||||
'query-bitmap-info': 'bool',
|
||||
'pbs-dirty-bitmap-savevm': 'bool',
|
||||
+ 'pbs-dirty-bitmap-migration': 'bool',
|
||||
'pbs-library-version': 'str' } }
|
||||
|
||||
##
|
||||
diff --git a/softmmu/vl.c b/softmmu/vl.c
|
||||
index 16aa2186b0..88b13871fd 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -4288,6 +4288,7 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
blk_mig_init();
|
||||
ram_mig_init();
|
||||
dirty_bitmap_mig_init();
|
||||
+ pbs_state_mig_init();
|
||||
|
||||
qemu_opts_foreach(qemu_find_opts("mon"),
|
||||
mon_init_func, NULL, &error_fatal);
|
||||
'pbs-masterkey': 'bool',
|
||||
'pbs-library-version': 'str',
|
||||
'backup-max-workers': 'bool' } }
|
@@ -13,20 +13,25 @@ that are obviously marked as "busy", which would cause none at all to be
|
||||
transferred.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
migration/block-dirty-bitmap.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
migration/block-dirty-bitmap.c | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
|
||||
index 5bf0d9fbc6..1070c19181 100644
|
||||
index f2c352d4a7..931a8481e9 100644
|
||||
--- a/migration/block-dirty-bitmap.c
|
||||
+++ b/migration/block-dirty-bitmap.c
|
||||
@@ -323,7 +323,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
|
||||
@@ -539,7 +539,11 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
|
||||
}
|
||||
|
||||
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, &local_err)) {
|
||||
error_report_err(local_err);
|
||||
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) {
|
||||
- return -1;
|
||||
+ if (errp != NULL) {
|
||||
+ error_report_err(*errp);
|
||||
+ *errp = NULL;
|
||||
+ }
|
||||
+ continue;
|
||||
}
|
||||
|
||||
bdrv_ref(bs);
|
||||
if (bitmap_aliases) {
|
69
debian/patches/pve/0036-PVE-fall-back-to-open-iscsi-initiatorname.patch
vendored
Normal file
69
debian/patches/pve/0036-PVE-fall-back-to-open-iscsi-initiatorname.patch
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Tue, 17 Nov 2020 10:51:05 +0100
|
||||
Subject: [PATCH] PVE: fall back to open-iscsi initiatorname
|
||||
|
||||
When no explicit option is given, try reading the initiator name from
|
||||
/etc/iscsi/initiatorname.iscsi and only use the generic fallback, i.e.
|
||||
iqn.2008-11.org.linux-kvmXXX, as a third alternative.
|
||||
|
||||
This avoids the need to add an explicit option for vma and to explicitly set it
|
||||
for each call to qemu that deals with iSCSI disks, while still allowing to set
|
||||
the option if a different name is needed.
|
||||
|
||||
According to RFC 3720, an initiator name is at most 223 bytes long, so the
|
||||
4 KiB buffer is big enough, even if many whitespaces are used.
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/iscsi.c | 30 ++++++++++++++++++++++++++++++
|
||||
1 file changed, 30 insertions(+)
|
||||
|
||||
diff --git a/block/iscsi.c b/block/iscsi.c
|
||||
index 2f0f4dac09..b523137cff 100644
|
||||
--- a/block/iscsi.c
|
||||
+++ b/block/iscsi.c
|
||||
@@ -1392,12 +1392,42 @@ static char *get_initiator_name(QemuOpts *opts)
|
||||
const char *name;
|
||||
char *iscsi_name;
|
||||
UuidInfo *uuid_info;
|
||||
+ FILE *name_fh;
|
||||
|
||||
name = qemu_opt_get(opts, "initiator-name");
|
||||
if (name) {
|
||||
return g_strdup(name);
|
||||
}
|
||||
|
||||
+ name_fh = fopen("/etc/iscsi/initiatorname.iscsi", "r");
|
||||
+ if (name_fh) {
|
||||
+ const char *key = "InitiatorName";
|
||||
+ char buffer[4096];
|
||||
+ char *line;
|
||||
+
|
||||
+ while ((line = fgets(buffer, sizeof(buffer), name_fh))) {
|
||||
+ line = g_strstrip(line);
|
||||
+ if (!strncmp(line, key, strlen(key))) {
|
||||
+ line = strchr(line, '=');
|
||||
+ if (!line || strlen(line) == 1) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ line++;
|
||||
+ g_strstrip(line);
|
||||
+ if (!strlen(line)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ name = line;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ fclose(name_fh);
|
||||
+
|
||||
+ if (name) {
|
||||
+ return g_strdup(name);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
uuid_info = qmp_query_uuid(NULL);
|
||||
if (strcmp(uuid_info->UUID, UUID_NONE) == 0) {
|
||||
name = qemu_get_vm_name();
|
@@ -1,444 +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 | 95 ++++++++++++++++++++++++++++++----
|
||||
qapi/block-core.json | 12 ++++-
|
||||
6 files changed, 134 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index d485c3ac79..fdc85a5c0e 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1038,6 +1038,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 0e2d166552..3ff014d32a 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -218,19 +218,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 d40f3f2fd6..d50f03a050 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);
|
||||
@@ -470,12 +495,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, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
+ NULL, di->bs, di->target, backup_state.speed, sync_mode, di->bitmap,
|
||||
+ bitmap_mode, false, NULL, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
JOB_DEFAULT, pvebackup_complete_cb, di, 1, NULL, &local_err);
|
||||
|
||||
aio_context_release(aio_context);
|
||||
@@ -526,6 +557,8 @@ typedef struct QmpBackupTask {
|
||||
const char *fingerprint;
|
||||
bool has_fingerprint;
|
||||
int64_t backup_time;
|
||||
+ bool has_incremental;
|
||||
+ bool incremental;
|
||||
bool has_format;
|
||||
BackupFormat format;
|
||||
bool has_config_file;
|
||||
@@ -617,6 +650,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
|
||||
size_t total = 0;
|
||||
+ size_t dirty = 0;
|
||||
|
||||
l = di_list;
|
||||
while (l) {
|
||||
@@ -654,6 +688,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 incremental = task->has_incremental && task->incremental;
|
||||
+
|
||||
char *pbs_err = NULL;
|
||||
pbs = proxmox_backup_new(
|
||||
task->backup_file,
|
||||
@@ -673,7 +709,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 */
|
||||
@@ -684,9 +721,32 @@ 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 use_incremental = false;
|
||||
+ if (incremental) {
|
||||
+ if (bitmap == NULL) {
|
||||
+ bitmap = bdrv_create_dirty_bitmap(di->bs, dump_cb_block_size, PBS_BITMAP_NAME, task->errp);
|
||||
+ if (!bitmap) {
|
||||
+ goto err;
|
||||
+ }
|
||||
+ /* mark entire bitmap as dirty to make full backup first */
|
||||
+ bdrv_set_dirty_bitmap(bitmap, 0, di->size);
|
||||
+ dirty += di->size;
|
||||
+ } else {
|
||||
+ use_incremental = true;
|
||||
+ dirty += bdrv_get_dirty_count(bitmap);
|
||||
+ }
|
||||
+ di->bitmap = bitmap;
|
||||
+ } else if (bitmap != NULL) {
|
||||
+ dirty += di->size;
|
||||
+ bdrv_release_dirty_bitmap(bitmap);
|
||||
+ }
|
||||
+
|
||||
+ int dev_id = proxmox_backup_co_register_image(pbs, devname, di->size, use_incremental, 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;
|
||||
@@ -695,6 +755,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) {
|
||||
@@ -722,6 +784,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);
|
||||
@@ -794,8 +858,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 = dirty >= total ? 0 : total - dirty;
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
@@ -819,6 +885,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);
|
||||
}
|
||||
@@ -860,6 +930,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_incremental, bool incremental,
|
||||
bool has_format, BackupFormat format,
|
||||
bool has_config_file, const char *config_file,
|
||||
bool has_firewall_file, const char *firewall_file,
|
||||
@@ -878,6 +949,8 @@ UuidInfo *qmp_backup(
|
||||
.backup_id = backup_id,
|
||||
.has_backup_time = has_backup_time,
|
||||
.backup_time = backup_time,
|
||||
+ .has_incremental = has_incremental,
|
||||
+ .incremental = incremental,
|
||||
.has_format = has_format,
|
||||
.format = format,
|
||||
.has_config_file = has_config_file,
|
||||
@@ -946,10 +1019,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 9db8e26517..6cad1e0e38 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -767,8 +767,13 @@
|
||||
#
|
||||
# @total: total amount of bytes involved in the backup process
|
||||
#
|
||||
+# @dirty: with incremental mode, 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.
|
||||
@@ -781,8 +786,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' } }
|
||||
|
||||
@@ -825,6 +830,8 @@
|
||||
#
|
||||
# @backup-time: backup timestamp (Unix epoch, required for format 'pbs')
|
||||
#
|
||||
+# @incremental: sync incremental changes since last job (optional for format 'pbs')
|
||||
+#
|
||||
# Returns: the uuid of the backup job
|
||||
#
|
||||
##
|
||||
@@ -835,6 +842,7 @@
|
||||
'*fingerprint': 'str',
|
||||
'*backup-id': 'str',
|
||||
'*backup-time': 'int',
|
||||
+ '*incremental': 'bool',
|
||||
'*format': 'BackupFormat',
|
||||
'*config-file': 'str',
|
||||
'*firewall-file': 'str',
|
25
debian/patches/pve/0037-PVE-block-stream-increase-chunk-size.patch
vendored
Normal file
25
debian/patches/pve/0037-PVE-block-stream-increase-chunk-size.patch
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Tue, 2 Mar 2021 16:34:28 +0100
|
||||
Subject: [PATCH] PVE: block/stream: increase chunk size
|
||||
|
||||
Ceph favors bigger chunks, so increase to 4M.
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/stream.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block/stream.c b/block/stream.c
|
||||
index 999d9e56d4..e187cd1262 100644
|
||||
--- a/block/stream.c
|
||||
+++ b/block/stream.c
|
||||
@@ -27,7 +27,7 @@ enum {
|
||||
* large enough to process multiple clusters in a single call, so
|
||||
* that populating contiguous regions of the image is efficient.
|
||||
*/
|
||||
- STREAM_CHUNK = 512 * 1024, /* in bytes */
|
||||
+ STREAM_CHUNK = 4 * 1024 * 1024, /* in bytes */
|
||||
};
|
||||
|
||||
typedef struct StreamBlockJob {
|
@@ -1,126 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
Date: Mon, 6 Jul 2020 20:05:16 +0200
|
||||
Subject: [PATCH] PVE backup: rename incremental to use-dirty-bitmap
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 22 +++++++++++-----------
|
||||
qapi/block-core.json | 6 +++---
|
||||
2 files changed, 14 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index d50f03a050..7bf54b4c5d 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -557,8 +557,8 @@ typedef struct QmpBackupTask {
|
||||
const char *fingerprint;
|
||||
bool has_fingerprint;
|
||||
int64_t backup_time;
|
||||
- bool has_incremental;
|
||||
- bool incremental;
|
||||
+ bool has_use_dirty_bitmap;
|
||||
+ bool use_dirty_bitmap;
|
||||
bool has_format;
|
||||
BackupFormat format;
|
||||
bool has_config_file;
|
||||
@@ -688,7 +688,7 @@ 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 incremental = task->has_incremental && task->incremental;
|
||||
+ bool use_dirty_bitmap = task->has_use_dirty_bitmap && task->use_dirty_bitmap;
|
||||
|
||||
char *pbs_err = NULL;
|
||||
pbs = proxmox_backup_new(
|
||||
@@ -722,9 +722,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
const char *devname = bdrv_get_device_name(di->bs);
|
||||
|
||||
BdrvDirtyBitmap *bitmap = bdrv_find_dirty_bitmap(di->bs, PBS_BITMAP_NAME);
|
||||
+ bool expect_only_dirty = false;
|
||||
|
||||
- bool use_incremental = false;
|
||||
- if (incremental) {
|
||||
+ 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) {
|
||||
@@ -734,7 +734,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
bdrv_set_dirty_bitmap(bitmap, 0, di->size);
|
||||
dirty += di->size;
|
||||
} else {
|
||||
- use_incremental = true;
|
||||
+ expect_only_dirty = true;
|
||||
dirty += bdrv_get_dirty_count(bitmap);
|
||||
}
|
||||
di->bitmap = bitmap;
|
||||
@@ -743,7 +743,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
bdrv_release_dirty_bitmap(bitmap);
|
||||
}
|
||||
|
||||
- int dev_id = proxmox_backup_co_register_image(pbs, devname, di->size, use_incremental, task->errp);
|
||||
+ int dev_id = proxmox_backup_co_register_image(pbs, devname, di->size, expect_only_dirty, task->errp);
|
||||
if (dev_id < 0) {
|
||||
goto err;
|
||||
}
|
||||
@@ -861,7 +861,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
backup_state.stat.dirty = dirty;
|
||||
backup_state.stat.transferred = 0;
|
||||
backup_state.stat.zero_bytes = 0;
|
||||
- backup_state.stat.reused = dirty >= total ? 0 : total - dirty;
|
||||
+ backup_state.stat.reused = format == BACKUP_FORMAT_PBS && dirty >= total ? 0 : total - dirty;
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
@@ -930,7 +930,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_incremental, bool incremental,
|
||||
+ 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,
|
||||
@@ -949,8 +949,8 @@ UuidInfo *qmp_backup(
|
||||
.backup_id = backup_id,
|
||||
.has_backup_time = has_backup_time,
|
||||
.backup_time = backup_time,
|
||||
- .has_incremental = has_incremental,
|
||||
- .incremental = incremental,
|
||||
+ .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,
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 6cad1e0e38..e00e577c6c 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -767,7 +767,7 @@
|
||||
#
|
||||
# @total: total amount of bytes involved in the backup process
|
||||
#
|
||||
-# @dirty: with incremental mode, this is the amount of bytes involved
|
||||
+# @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.
|
||||
@@ -830,7 +830,7 @@
|
||||
#
|
||||
# @backup-time: backup timestamp (Unix epoch, required for format 'pbs')
|
||||
#
|
||||
-# @incremental: sync incremental changes since last job (optional 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
|
||||
#
|
||||
@@ -842,7 +842,7 @@
|
||||
'*fingerprint': 'str',
|
||||
'*backup-id': 'str',
|
||||
'*backup-time': 'int',
|
||||
- '*incremental': 'bool',
|
||||
+ '*use-dirty-bitmap': 'bool',
|
||||
'*format': 'BackupFormat',
|
||||
'*config-file': 'str',
|
||||
'*firewall-file': 'str',
|
449
debian/patches/pve/0038-block-add-alloc-track-driver.patch
vendored
Normal file
449
debian/patches/pve/0038-block-add-alloc-track-driver.patch
vendored
Normal file
@@ -0,0 +1,449 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Mon, 7 Dec 2020 15:21:03 +0100
|
||||
Subject: [PATCH] block: add alloc-track driver
|
||||
|
||||
Add a new filter node 'alloc-track', which seperates reads and writes to
|
||||
different children, thus allowing to put a backing image behind any
|
||||
blockdev (regardless of driver support). Since we can't detect any
|
||||
pre-allocated blocks, we can only track new writes, hence the write
|
||||
target ('file') for this node must always be empty.
|
||||
|
||||
Intended use case is for live restoring, i.e. add a backup image as a
|
||||
block device into a VM, then put an alloc-track on the restore target
|
||||
and set the backup as backing. With this, one can use a regular
|
||||
'block-stream' to restore the image, while the VM can already run in the
|
||||
background. Copy-on-read will help make progress as the VM reads as
|
||||
well.
|
||||
|
||||
This only worked if the target supports backing images, so up until now
|
||||
only for qcow2, with alloc-track any driver for the target can be used.
|
||||
|
||||
Replacing the node cannot be done in the
|
||||
track_co_change_backing_file() callback, because replacing a node
|
||||
cannot happen in a coroutine and requires the block graph lock
|
||||
exclusively. Could either become a special option for the stream job,
|
||||
or maybe the upcoming blockdev-replace QMP command can be used in the
|
||||
future.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: adapt to changed function signatures
|
||||
make error return value consistent with QEMU
|
||||
avoid premature break during read
|
||||
adhere to block graph lock requirements
|
||||
avoid superfluous child permission update]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/alloc-track.c | 343 ++++++++++++++++++++++++++++++++++++++++++++
|
||||
block/meson.build | 1 +
|
||||
block/stream.c | 34 +++++
|
||||
3 files changed, 378 insertions(+)
|
||||
create mode 100644 block/alloc-track.c
|
||||
|
||||
diff --git a/block/alloc-track.c b/block/alloc-track.c
|
||||
new file mode 100644
|
||||
index 0000000000..718aaabf2a
|
||||
--- /dev/null
|
||||
+++ b/block/alloc-track.c
|
||||
@@ -0,0 +1,343 @@
|
||||
+/*
|
||||
+ * Node to allow backing images to be applied to any node. Assumes a blank
|
||||
+ * image to begin with, only new writes are tracked as allocated, thus this
|
||||
+ * must never be put on a node that already contains data.
|
||||
+ *
|
||||
+ * Copyright (c) 2020 Proxmox Server Solutions GmbH
|
||||
+ * Copyright (c) 2020 Stefan Reiter <s.reiter@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.
|
||||
+ */
|
||||
+
|
||||
+#include "qemu/osdep.h"
|
||||
+#include "qapi/error.h"
|
||||
+#include "block/block_int.h"
|
||||
+#include "block/dirty-bitmap.h"
|
||||
+#include "block/graph-lock.h"
|
||||
+#include "qobject/qdict.h"
|
||||
+#include "qobject/qstring.h"
|
||||
+#include "qemu/cutils.h"
|
||||
+#include "qemu/error-report.h"
|
||||
+#include "qemu/option.h"
|
||||
+#include "qemu/module.h"
|
||||
+#include "system/block-backend.h"
|
||||
+
|
||||
+#define TRACK_OPT_AUTO_REMOVE "auto-remove"
|
||||
+
|
||||
+typedef struct {
|
||||
+ BdrvDirtyBitmap *bitmap;
|
||||
+ uint64_t granularity;
|
||||
+} BDRVAllocTrackState;
|
||||
+
|
||||
+static QemuOptsList runtime_opts = {
|
||||
+ .name = "alloc-track",
|
||||
+ .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
|
||||
+ .desc = {
|
||||
+ {
|
||||
+ .name = TRACK_OPT_AUTO_REMOVE,
|
||||
+ .type = QEMU_OPT_BOOL,
|
||||
+ .help = "automatically replace this node with 'file' when 'backing'"
|
||||
+ "is detached",
|
||||
+ },
|
||||
+ { /* end of list */ }
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static void GRAPH_RDLOCK
|
||||
+track_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
+{
|
||||
+ BDRVAllocTrackState *s = bs->opaque;
|
||||
+
|
||||
+ if (!bs->file) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Always use alignment from underlying write device so RMW cycle for
|
||||
+ * bdrv_pwritev reads data from our backing via track_co_preadv. Also use at
|
||||
+ * least the bitmap granularity.
|
||||
+ */
|
||||
+ bs->bl.request_alignment = MAX(bs->file->bs->bl.request_alignment,
|
||||
+ s->granularity);
|
||||
+}
|
||||
+
|
||||
+static int track_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ BDRVAllocTrackState *s = bs->opaque;
|
||||
+ BdrvChild *file = NULL;
|
||||
+ QemuOpts *opts;
|
||||
+ Error *local_err = NULL;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
|
||||
+ qemu_opts_absorb_qdict(opts, options, &local_err);
|
||||
+ if (local_err) {
|
||||
+ error_propagate(errp, local_err);
|
||||
+ ret = -EINVAL;
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ if (!qemu_opt_get_bool(opts, TRACK_OPT_AUTO_REMOVE, false)) {
|
||||
+ error_setg(errp, "alloc-track: requires auto-remove option to be set to on");
|
||||
+ ret = -EINVAL;
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ /* open the target (write) node, backing will be attached by block layer */
|
||||
+ file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
|
||||
+ BDRV_CHILD_DATA | BDRV_CHILD_METADATA, false,
|
||||
+ &local_err);
|
||||
+ bdrv_graph_wrlock();
|
||||
+ bs->file = file;
|
||||
+ bdrv_graph_wrunlock();
|
||||
+ if (local_err) {
|
||||
+ ret = -EINVAL;
|
||||
+ error_propagate(errp, local_err);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ bdrv_graph_rdlock_main_loop();
|
||||
+ BlockDriverInfo bdi = {0};
|
||||
+ ret = bdrv_get_info(bs->file->bs, &bdi);
|
||||
+ if (ret < 0) {
|
||||
+ /*
|
||||
+ * Not a hard failure. Worst that can happen is partial cluster
|
||||
+ * allocation in the write target. However, the driver here returns its
|
||||
+ * allocation status based on the dirty bitmap, so any other data that
|
||||
+ * maps to such a cluster will still be copied later by a stream job (or
|
||||
+ * during writes to that cluster).
|
||||
+ */
|
||||
+ warn_report("alloc-track: unable to query cluster size for write target: %s",
|
||||
+ strerror(ret));
|
||||
+ }
|
||||
+ ret = 0;
|
||||
+ /*
|
||||
+ * Always consider alignment from underlying write device so RMW cycle for
|
||||
+ * bdrv_pwritev reads data from our backing via track_co_preadv. Also try to
|
||||
+ * avoid partial cluster allocation in the write target by considering the
|
||||
+ * cluster size.
|
||||
+ */
|
||||
+ s->granularity = MAX(bs->file->bs->bl.request_alignment,
|
||||
+ MAX(bdi.cluster_size, BDRV_SECTOR_SIZE));
|
||||
+ track_refresh_limits(bs, errp);
|
||||
+ s->bitmap = bdrv_create_dirty_bitmap(bs->file->bs, s->granularity, NULL,
|
||||
+ &local_err);
|
||||
+ bdrv_graph_rdunlock_main_loop();
|
||||
+ if (local_err) {
|
||||
+ ret = -EIO;
|
||||
+ error_propagate(errp, local_err);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+fail:
|
||||
+ if (ret < 0) {
|
||||
+ bdrv_graph_wrlock();
|
||||
+ bdrv_unref_child(bs, bs->file);
|
||||
+ bdrv_graph_wrunlock();
|
||||
+ if (s->bitmap) {
|
||||
+ bdrv_release_dirty_bitmap(s->bitmap);
|
||||
+ }
|
||||
+ }
|
||||
+ qemu_opts_del(opts);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void track_close(BlockDriverState *bs)
|
||||
+{
|
||||
+ BDRVAllocTrackState *s = bs->opaque;
|
||||
+ if (s->bitmap) {
|
||||
+ bdrv_release_dirty_bitmap(s->bitmap);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int64_t GRAPH_RDLOCK
|
||||
+track_co_getlength(BlockDriverState *bs)
|
||||
+{
|
||||
+ return bdrv_co_getlength(bs->file->bs);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+track_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
+ QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ BDRVAllocTrackState *s = bs->opaque;
|
||||
+ QEMUIOVector local_qiov;
|
||||
+ int ret;
|
||||
+
|
||||
+ /* 'cur_offset' is relative to 'offset', 'local_offset' to image start */
|
||||
+ uint64_t cur_offset, local_offset;
|
||||
+ int64_t local_bytes;
|
||||
+ bool alloc;
|
||||
+
|
||||
+ if (offset < 0 || bytes < 0) {
|
||||
+ fprintf(stderr, "unexpected negative 'offset' or 'bytes' value!\n");
|
||||
+ return -EIO;
|
||||
+ }
|
||||
+
|
||||
+ /* a read request can span multiple granularity-sized chunks, and can thus
|
||||
+ * contain blocks with different allocation status - we could just iterate
|
||||
+ * granularity-wise, but for better performance use bdrv_dirty_bitmap_next_X
|
||||
+ * to find the next flip and consider everything up to that in one go */
|
||||
+ for (cur_offset = 0; cur_offset < bytes; cur_offset += local_bytes) {
|
||||
+ local_offset = offset + cur_offset;
|
||||
+ alloc = bdrv_dirty_bitmap_get(s->bitmap, local_offset);
|
||||
+ if (alloc) {
|
||||
+ local_bytes = bdrv_dirty_bitmap_next_zero(s->bitmap, local_offset,
|
||||
+ bytes - cur_offset);
|
||||
+ } else {
|
||||
+ local_bytes = bdrv_dirty_bitmap_next_dirty(s->bitmap, local_offset,
|
||||
+ bytes - cur_offset);
|
||||
+ }
|
||||
+
|
||||
+ /* _bitmap_next_X return is -1 if no end found within limit, otherwise
|
||||
+ * offset of next flip (to start of image) */
|
||||
+ local_bytes = local_bytes < 0 ?
|
||||
+ bytes - cur_offset :
|
||||
+ local_bytes - local_offset;
|
||||
+
|
||||
+ qemu_iovec_init_slice(&local_qiov, qiov, cur_offset, local_bytes);
|
||||
+
|
||||
+ if (alloc) {
|
||||
+ ret = bdrv_co_preadv(bs->file, local_offset, local_bytes,
|
||||
+ &local_qiov, flags);
|
||||
+ } else if (bs->backing) {
|
||||
+ ret = bdrv_co_preadv(bs->backing, local_offset, local_bytes,
|
||||
+ &local_qiov, flags);
|
||||
+ } else {
|
||||
+ qemu_iovec_memset(&local_qiov, cur_offset, 0, local_bytes);
|
||||
+ ret = 0;
|
||||
+ }
|
||||
+
|
||||
+ if (ret != 0) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+track_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
+ QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+track_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
+ BdrvRequestFlags flags)
|
||||
+{
|
||||
+ return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+track_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
+{
|
||||
+ return bdrv_co_pdiscard(bs->file, offset, bytes);
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int GRAPH_RDLOCK
|
||||
+track_co_flush(BlockDriverState *bs)
|
||||
+{
|
||||
+ return bdrv_co_flush(bs->file->bs);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+track_co_block_status(BlockDriverState *bs, bool want_zero,
|
||||
+ int64_t offset,
|
||||
+ int64_t bytes,
|
||||
+ int64_t *pnum,
|
||||
+ int64_t *map,
|
||||
+ BlockDriverState **file)
|
||||
+{
|
||||
+ BDRVAllocTrackState *s = bs->opaque;
|
||||
+
|
||||
+ bool alloc = bdrv_dirty_bitmap_get(s->bitmap, offset);
|
||||
+ int64_t next_flipped;
|
||||
+ if (alloc) {
|
||||
+ next_flipped = bdrv_dirty_bitmap_next_zero(s->bitmap, offset, bytes);
|
||||
+ } else {
|
||||
+ next_flipped = bdrv_dirty_bitmap_next_dirty(s->bitmap, offset, bytes);
|
||||
+ }
|
||||
+
|
||||
+ /* in case not the entire region has the same state, we need to set pnum to
|
||||
+ * indicate for how many bytes our result is valid */
|
||||
+ *pnum = next_flipped == -1 ? bytes : next_flipped - offset;
|
||||
+ *map = offset;
|
||||
+
|
||||
+ if (alloc) {
|
||||
+ *file = bs->file->bs;
|
||||
+ return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID;
|
||||
+ } else if (bs->backing) {
|
||||
+ *file = bs->backing->bs;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void GRAPH_RDLOCK
|
||||
+track_child_perm(BlockDriverState *bs, BdrvChild *c, BdrvChildRole role,
|
||||
+ BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared,
|
||||
+ uint64_t *nperm, uint64_t *nshared)
|
||||
+{
|
||||
+ *nshared = BLK_PERM_ALL;
|
||||
+
|
||||
+ if (role & BDRV_CHILD_DATA) {
|
||||
+ *nperm = perm & DEFAULT_PERM_PASSTHROUGH;
|
||||
+ } else {
|
||||
+ /* 'backing' is also a child of our BDS, but we don't expect it to be
|
||||
+ * writeable, so we only forward 'consistent read' */
|
||||
+ *nperm = perm & BLK_PERM_CONSISTENT_READ;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+track_co_change_backing_file(BlockDriverState *bs, const char *backing_file,
|
||||
+ const char *backing_fmt)
|
||||
+{
|
||||
+ /*
|
||||
+ * Note that the actual backing file graph change is already done in the
|
||||
+ * stream job itself with bdrv_set_backing_hd_drained(), so no need to
|
||||
+ * actually do anything here. But still needs to be implemented, to make
|
||||
+ * our caller (i.e. bdrv_co_change_backing_file() do the right thing).
|
||||
+ *
|
||||
+ * FIXME
|
||||
+ * We'd like to auto-remove ourselves from the block graph, but it cannot
|
||||
+ * be done from a coroutine. Currently done in the stream job, where it
|
||||
+ * kinda fits better, but in the long-term, a special parameter would be
|
||||
+ * nice (or done via qemu-server via upcoming blockdev-replace QMP command).
|
||||
+ */
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static BlockDriver bdrv_alloc_track = {
|
||||
+ .format_name = "alloc-track",
|
||||
+ .instance_size = sizeof(BDRVAllocTrackState),
|
||||
+
|
||||
+ .bdrv_open = track_open,
|
||||
+ .bdrv_close = track_close,
|
||||
+ .bdrv_co_getlength = track_co_getlength,
|
||||
+ .bdrv_child_perm = track_child_perm,
|
||||
+ .bdrv_refresh_limits = track_refresh_limits,
|
||||
+
|
||||
+ .bdrv_co_pwrite_zeroes = track_co_pwrite_zeroes,
|
||||
+ .bdrv_co_pwritev = track_co_pwritev,
|
||||
+ .bdrv_co_preadv = track_co_preadv,
|
||||
+ .bdrv_co_pdiscard = track_co_pdiscard,
|
||||
+
|
||||
+ .bdrv_co_flush = track_co_flush,
|
||||
+ .bdrv_co_flush_to_disk = track_co_flush,
|
||||
+
|
||||
+ .supports_backing = true,
|
||||
+
|
||||
+ .bdrv_co_block_status = track_co_block_status,
|
||||
+ .bdrv_co_change_backing_file = track_co_change_backing_file,
|
||||
+};
|
||||
+
|
||||
+static void bdrv_alloc_track_init(void)
|
||||
+{
|
||||
+ bdrv_register(&bdrv_alloc_track);
|
||||
+}
|
||||
+
|
||||
+block_init(bdrv_alloc_track_init);
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index d243372c41..9b45b5256d 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -2,6 +2,7 @@ block_ss.add(genh)
|
||||
block_ss.add(files(
|
||||
'accounting.c',
|
||||
'aio_task.c',
|
||||
+ 'alloc-track.c',
|
||||
'amend.c',
|
||||
'backup.c',
|
||||
'backup-dump.c',
|
||||
diff --git a/block/stream.c b/block/stream.c
|
||||
index e187cd1262..0b61029399 100644
|
||||
--- a/block/stream.c
|
||||
+++ b/block/stream.c
|
||||
@@ -120,6 +120,40 @@ static int stream_prepare(Job *job)
|
||||
ret = -EPERM;
|
||||
goto out;
|
||||
}
|
||||
+
|
||||
+ /*
|
||||
+ * This cannot be done in the co_change_backing_file callback, because
|
||||
+ * bdrv_replace_node() cannot be done in a coroutine. The latter also
|
||||
+ * requires the graph lock exclusively. Only required for the
|
||||
+ * alloc-track driver.
|
||||
+ *
|
||||
+ * The long-term plan is to either have an explicit parameter for the
|
||||
+ * stream job or use the upcoming blockdev-replace QMP command.
|
||||
+ */
|
||||
+ if (base_id == NULL && strcmp(unfiltered_bs->drv->format_name, "alloc-track") == 0) {
|
||||
+ BlockDriverState *file_bs;
|
||||
+
|
||||
+ bdrv_graph_rdlock_main_loop();
|
||||
+ file_bs = unfiltered_bs->file->bs;
|
||||
+ bdrv_graph_rdunlock_main_loop();
|
||||
+
|
||||
+ bdrv_ref(unfiltered_bs); // unrefed by bdrv_replace_node()
|
||||
+ bdrv_drained_begin(file_bs);
|
||||
+ bdrv_graph_wrlock();
|
||||
+
|
||||
+ bdrv_replace_node(unfiltered_bs, file_bs, &local_err);
|
||||
+
|
||||
+ bdrv_graph_wrunlock();
|
||||
+ bdrv_drained_end(file_bs);
|
||||
+ bdrv_unref(unfiltered_bs);
|
||||
+
|
||||
+ if (local_err) {
|
||||
+ error_prepend(&local_err, "failed to replace alloc-track node: ");
|
||||
+ error_report_err(local_err);
|
||||
+ ret = -EPERM;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
out:
|
@@ -1,44 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Mon, 6 Jul 2020 14:40:12 +0200
|
||||
Subject: [PATCH] PVE: fixup pbs-restore API
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
pbs-restore.c | 10 ++++++++--
|
||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/pbs-restore.c b/pbs-restore.c
|
||||
index 4bf37ef1fa..ff3fc38e8a 100644
|
||||
--- a/pbs-restore.c
|
||||
+++ b/pbs-restore.c
|
||||
@@ -161,13 +161,19 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "connecting to repository '%s'\n", repository);
|
||||
}
|
||||
char *pbs_error = NULL;
|
||||
- ProxmoxRestoreHandle *conn = proxmox_restore_connect(
|
||||
+ ProxmoxRestoreHandle *conn = proxmox_restore_new(
|
||||
repository, snapshot, password, keyfile, key_password, fingerprint, &pbs_error);
|
||||
if (conn == NULL) {
|
||||
fprintf(stderr, "restore failed: %s\n", pbs_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ int res = proxmox_restore_connect(conn, &pbs_error);
|
||||
+ if (res < 0 || pbs_error) {
|
||||
+ fprintf(stderr, "restore failed (connection error): %s\n", pbs_error);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
QDict *options = qdict_new();
|
||||
|
||||
if (format) {
|
||||
@@ -198,7 +204,7 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "starting to restore snapshot '%s'\n", snapshot);
|
||||
fflush(stderr); // ensure we do not get printed after the progress log
|
||||
}
|
||||
- int res = proxmox_restore_image(
|
||||
+ res = proxmox_restore_image(
|
||||
conn,
|
||||
archive_name,
|
||||
write_callback,
|
81
debian/patches/pve/0039-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
vendored
Normal file
81
debian/patches/pve/0039-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 23 Jun 2022 14:00:05 +0200
|
||||
Subject: [PATCH] Revert "block/rbd: workaround for ceph issue #53784"
|
||||
|
||||
This reverts commit fc176116cdea816ceb8dd969080b2b95f58edbc0 in
|
||||
preparation to revert 0347a8fd4c3faaedf119be04c197804be40a384b.
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/rbd.c | 42 ++----------------------------------------
|
||||
1 file changed, 2 insertions(+), 40 deletions(-)
|
||||
|
||||
diff --git a/block/rbd.c b/block/rbd.c
|
||||
index bf143fac00..70d92966f7 100644
|
||||
--- a/block/rbd.c
|
||||
+++ b/block/rbd.c
|
||||
@@ -1515,7 +1515,6 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
||||
int status, r;
|
||||
RBDDiffIterateReq req = { .offs = offset };
|
||||
uint64_t features, flags;
|
||||
- uint64_t head = 0;
|
||||
|
||||
assert(offset + bytes <= s->image_size);
|
||||
|
||||
@@ -1543,43 +1542,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
||||
return status;
|
||||
}
|
||||
|
||||
-#if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 17, 0)
|
||||
- /*
|
||||
- * librbd had a bug until early 2022 that affected all versions of ceph that
|
||||
- * supported fast-diff. This bug results in reporting of incorrect offsets
|
||||
- * if the offset parameter to rbd_diff_iterate2 is not object aligned.
|
||||
- * Work around this bug by rounding down the offset to object boundaries.
|
||||
- * This is OK because we call rbd_diff_iterate2 with whole_object = true.
|
||||
- * However, this workaround only works for non cloned images with default
|
||||
- * striping.
|
||||
- *
|
||||
- * See: https://tracker.ceph.com/issues/53784
|
||||
- */
|
||||
-
|
||||
- /* check if RBD image has non-default striping enabled */
|
||||
- if (features & RBD_FEATURE_STRIPINGV2) {
|
||||
- return status;
|
||||
- }
|
||||
-
|
||||
-#pragma GCC diagnostic push
|
||||
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
- /*
|
||||
- * check if RBD image is a clone (= has a parent).
|
||||
- *
|
||||
- * rbd_get_parent_info is deprecated from Nautilus onwards, but the
|
||||
- * replacement rbd_get_parent is not present in Luminous and Mimic.
|
||||
- */
|
||||
- if (rbd_get_parent_info(s->image, NULL, 0, NULL, 0, NULL, 0) != -ENOENT) {
|
||||
- return status;
|
||||
- }
|
||||
-#pragma GCC diagnostic pop
|
||||
-
|
||||
- head = req.offs & (s->object_size - 1);
|
||||
- req.offs -= head;
|
||||
- bytes += head;
|
||||
-#endif
|
||||
-
|
||||
- r = rbd_diff_iterate2(s->image, NULL, req.offs, bytes, true, true,
|
||||
+ r = rbd_diff_iterate2(s->image, NULL, offset, bytes, true, true,
|
||||
qemu_rbd_diff_iterate_cb, &req);
|
||||
if (r < 0 && r != QEMU_RBD_EXIT_DIFF_ITERATE2) {
|
||||
return status;
|
||||
@@ -1598,8 +1561,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
||||
status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
|
||||
}
|
||||
|
||||
- assert(req.bytes > head);
|
||||
- *pnum = req.bytes - head;
|
||||
+ *pnum = req.bytes;
|
||||
return status;
|
||||
}
|
||||
|
@@ -1,30 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Mon, 6 Jul 2020 14:40:13 +0200
|
||||
Subject: [PATCH] PVE: always set dirty counter for non-incremental backups
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 8 ++++++--
|
||||
1 file changed, 6 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 7bf54b4c5d..1f2a0bbe8c 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -738,9 +738,13 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
dirty += bdrv_get_dirty_count(bitmap);
|
||||
}
|
||||
di->bitmap = bitmap;
|
||||
- } else if (bitmap != NULL) {
|
||||
+ } else {
|
||||
dirty += di->size;
|
||||
- bdrv_release_dirty_bitmap(bitmap);
|
||||
+
|
||||
+ /* 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);
|
36
debian/patches/pve/0040-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
vendored
Normal file
36
debian/patches/pve/0040-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 23 Jun 2022 14:00:07 +0200
|
||||
Subject: [PATCH] Revert "block/rbd: fix handling of holes in
|
||||
.bdrv_co_block_status"
|
||||
|
||||
This reverts commit 9e302f64bb407a9bb097b626da97228c2654cfee in
|
||||
preparation to revert 0347a8fd4c3faaedf119be04c197804be40a384b.
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/rbd.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/block/rbd.c b/block/rbd.c
|
||||
index 70d92966f7..931b513828 100644
|
||||
--- a/block/rbd.c
|
||||
+++ b/block/rbd.c
|
||||
@@ -1474,11 +1474,11 @@ static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
|
||||
RBDDiffIterateReq *req = opaque;
|
||||
|
||||
assert(req->offs + req->bytes <= offs);
|
||||
-
|
||||
- /* treat a hole like an unallocated area and bail out */
|
||||
- if (!exists) {
|
||||
- return 0;
|
||||
- }
|
||||
+ /*
|
||||
+ * we do not diff against a snapshot so we should never receive a callback
|
||||
+ * for a hole.
|
||||
+ */
|
||||
+ assert(exists);
|
||||
|
||||
if (!req->exists && offs > req->offs) {
|
||||
/*
|
@@ -1,36 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Mon, 6 Jul 2020 14:40:14 +0200
|
||||
Subject: [PATCH] PVE: use proxmox_backup_check_incremental
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 12 ++++++++----
|
||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 1f2a0bbe8c..1cd9d31d7c 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -730,12 +730,16 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
if (!bitmap) {
|
||||
goto err;
|
||||
}
|
||||
- /* mark entire bitmap as dirty to make full backup first */
|
||||
- bdrv_set_dirty_bitmap(bitmap, 0, di->size);
|
||||
- dirty += di->size;
|
||||
} else {
|
||||
- expect_only_dirty = true;
|
||||
+ 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 {
|
162
debian/patches/pve/0041-Revert-block-rbd-implement-bdrv_co_block_status.patch
vendored
Normal file
162
debian/patches/pve/0041-Revert-block-rbd-implement-bdrv_co_block_status.patch
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Tue, 17 May 2022 09:46:02 +0200
|
||||
Subject: [PATCH] Revert "block/rbd: implement bdrv_co_block_status"
|
||||
|
||||
During backup, bdrv_co_block_status is called for each block copy
|
||||
chunk. When RBD is used, the current implementation with
|
||||
rbd_diff_iterate2() using whole_object=true takes about linearly more
|
||||
time, depending on the image size. Since there are linearly more
|
||||
chunks, the slowdown is quadratic, becoming unacceptable for large
|
||||
images (starting somewhere between 500-1000 GiB in my testing).
|
||||
|
||||
This reverts commit 0347a8fd4c3faaedf119be04c197804be40a384b as a
|
||||
stop-gap measure, until it's clear how to make the implemenation
|
||||
more efficient.
|
||||
|
||||
Upstream bug report:
|
||||
https://gitlab.com/qemu-project/qemu/-/issues/1026
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/rbd.c | 112 ----------------------------------------------------
|
||||
1 file changed, 112 deletions(-)
|
||||
|
||||
diff --git a/block/rbd.c b/block/rbd.c
|
||||
index 931b513828..4ab9bb5e02 100644
|
||||
--- a/block/rbd.c
|
||||
+++ b/block/rbd.c
|
||||
@@ -108,12 +108,6 @@ typedef struct RBDTask {
|
||||
int64_t ret;
|
||||
} RBDTask;
|
||||
|
||||
-typedef struct RBDDiffIterateReq {
|
||||
- uint64_t offs;
|
||||
- uint64_t bytes;
|
||||
- bool exists;
|
||||
-} RBDDiffIterateReq;
|
||||
-
|
||||
static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
||||
BlockdevOptionsRbd *opts, bool cache,
|
||||
const char *keypairs, const char *secretid,
|
||||
@@ -1460,111 +1454,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
|
||||
return spec_info;
|
||||
}
|
||||
|
||||
-/*
|
||||
- * rbd_diff_iterate2 allows to interrupt the exection by returning a negative
|
||||
- * value in the callback routine. Choose a value that does not conflict with
|
||||
- * an existing exitcode and return it if we want to prematurely stop the
|
||||
- * execution because we detected a change in the allocation status.
|
||||
- */
|
||||
-#define QEMU_RBD_EXIT_DIFF_ITERATE2 -9000
|
||||
-
|
||||
-static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
|
||||
- int exists, void *opaque)
|
||||
-{
|
||||
- RBDDiffIterateReq *req = opaque;
|
||||
-
|
||||
- assert(req->offs + req->bytes <= offs);
|
||||
- /*
|
||||
- * we do not diff against a snapshot so we should never receive a callback
|
||||
- * for a hole.
|
||||
- */
|
||||
- assert(exists);
|
||||
-
|
||||
- if (!req->exists && offs > req->offs) {
|
||||
- /*
|
||||
- * we started in an unallocated area and hit the first allocated
|
||||
- * block. req->bytes must be set to the length of the unallocated area
|
||||
- * before the allocated area. stop further processing.
|
||||
- */
|
||||
- req->bytes = offs - req->offs;
|
||||
- return QEMU_RBD_EXIT_DIFF_ITERATE2;
|
||||
- }
|
||||
-
|
||||
- if (req->exists && offs > req->offs + req->bytes) {
|
||||
- /*
|
||||
- * we started in an allocated area and jumped over an unallocated area,
|
||||
- * req->bytes contains the length of the allocated area before the
|
||||
- * unallocated area. stop further processing.
|
||||
- */
|
||||
- return QEMU_RBD_EXIT_DIFF_ITERATE2;
|
||||
- }
|
||||
-
|
||||
- req->bytes += len;
|
||||
- req->exists = true;
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
||||
- bool want_zero, int64_t offset,
|
||||
- int64_t bytes, int64_t *pnum,
|
||||
- int64_t *map,
|
||||
- BlockDriverState **file)
|
||||
-{
|
||||
- BDRVRBDState *s = bs->opaque;
|
||||
- int status, r;
|
||||
- RBDDiffIterateReq req = { .offs = offset };
|
||||
- uint64_t features, flags;
|
||||
-
|
||||
- assert(offset + bytes <= s->image_size);
|
||||
-
|
||||
- /* default to all sectors allocated */
|
||||
- status = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID;
|
||||
- *map = offset;
|
||||
- *file = bs;
|
||||
- *pnum = bytes;
|
||||
-
|
||||
- /* check if RBD image supports fast-diff */
|
||||
- r = rbd_get_features(s->image, &features);
|
||||
- if (r < 0) {
|
||||
- return status;
|
||||
- }
|
||||
- if (!(features & RBD_FEATURE_FAST_DIFF)) {
|
||||
- return status;
|
||||
- }
|
||||
-
|
||||
- /* check if RBD fast-diff result is valid */
|
||||
- r = rbd_get_flags(s->image, &flags);
|
||||
- if (r < 0) {
|
||||
- return status;
|
||||
- }
|
||||
- if (flags & RBD_FLAG_FAST_DIFF_INVALID) {
|
||||
- return status;
|
||||
- }
|
||||
-
|
||||
- r = rbd_diff_iterate2(s->image, NULL, offset, bytes, true, true,
|
||||
- qemu_rbd_diff_iterate_cb, &req);
|
||||
- if (r < 0 && r != QEMU_RBD_EXIT_DIFF_ITERATE2) {
|
||||
- return status;
|
||||
- }
|
||||
- assert(req.bytes <= bytes);
|
||||
- if (!req.exists) {
|
||||
- if (r == 0) {
|
||||
- /*
|
||||
- * rbd_diff_iterate2 does not invoke callbacks for unallocated
|
||||
- * areas. This here catches the case where no callback was
|
||||
- * invoked at all (req.bytes == 0).
|
||||
- */
|
||||
- assert(req.bytes == 0);
|
||||
- req.bytes = bytes;
|
||||
- }
|
||||
- status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
|
||||
- }
|
||||
-
|
||||
- *pnum = req.bytes;
|
||||
- return status;
|
||||
-}
|
||||
-
|
||||
static int64_t coroutine_fn qemu_rbd_co_getlength(BlockDriverState *bs)
|
||||
{
|
||||
BDRVRBDState *s = bs->opaque;
|
||||
@@ -1801,7 +1690,6 @@ static BlockDriver bdrv_rbd = {
|
||||
#ifdef LIBRBD_SUPPORTS_WRITE_ZEROES
|
||||
.bdrv_co_pwrite_zeroes = qemu_rbd_co_pwrite_zeroes,
|
||||
#endif
|
||||
- .bdrv_co_block_status = qemu_rbd_co_block_status,
|
||||
|
||||
.bdrv_snapshot_create = qemu_rbd_snap_create,
|
||||
.bdrv_snapshot_delete = qemu_rbd_snap_remove,
|
472
debian/patches/pve/0042-PVE-backup-add-fleecing-option.patch
vendored
Normal file
472
debian/patches/pve/0042-PVE-backup-add-fleecing-option.patch
vendored
Normal file
@@ -0,0 +1,472 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 11 Apr 2024 11:29:28 +0200
|
||||
Subject: [PATCH] PVE backup: add fleecing option
|
||||
|
||||
When a fleecing option is given, it is expected that each device has
|
||||
a corresponding "-fleecing" block device already attached, except for
|
||||
EFI disk and TPM state, where fleecing is never used.
|
||||
|
||||
The following graph was adapted from [0] which also contains more
|
||||
details about fleecing.
|
||||
|
||||
[guest]
|
||||
|
|
||||
| root
|
||||
v file
|
||||
[copy-before-write]<------[snapshot-access]
|
||||
| |
|
||||
| file | target
|
||||
v v
|
||||
[source] [fleecing]
|
||||
|
||||
For fleecing, a copy-before-write filter is inserted on top of the
|
||||
source node, as well as a snapshot-access node pointing to the filter
|
||||
node which allows to read the consistent state of the image at the
|
||||
time it was inserted. New guest writes are passed through the
|
||||
copy-before-write filter which will first copy over old data to the
|
||||
fleecing image in case that old data is still needed by the
|
||||
snapshot-access node.
|
||||
|
||||
The backup process will sequentially read from the snapshot access,
|
||||
which has a bitmap and knows whether to read from the original image
|
||||
or the fleecing image to get the "snapshot" state, i.e. data from the
|
||||
source image at the time when the copy-before-write filter was
|
||||
inserted. After reading, the copied sections are discarded from the
|
||||
fleecing image to reduce space usage.
|
||||
|
||||
All of this can be restricted by an initial dirty bitmap to parts of
|
||||
the source image that are required for an incremental backup.
|
||||
|
||||
For discard to work, it is necessary that the fleecing image does not
|
||||
have a larger cluster size than the backup job granularity. Since
|
||||
querying that size does not always work, e.g. for RBD with krbd, the
|
||||
cluster size will not be reported, a minimum of 4 MiB is used. A job
|
||||
with PBS target already has at least this granularity, so it's just
|
||||
relevant for other targets. I.e. edge cases where this minimum is not
|
||||
enough should be very rare in practice. If ever necessary in the
|
||||
future, can still add a passed-in value for the backup QMP command to
|
||||
override.
|
||||
|
||||
Additionally, the cbw-timeout and on-cbw-error=break-snapshot options
|
||||
are set when installing the copy-before-write filter and
|
||||
snapshot-access. When an error or timeout occurs, the problematic (and
|
||||
each further) snapshot operation will fail and thus cancel the backup
|
||||
instead of breaking the guest write.
|
||||
|
||||
Note that job_id cannot be inferred from the snapshot-access bs because
|
||||
it has no parent, so just pass the one from the original bs.
|
||||
|
||||
[0]: https://www.mail-archive.com/qemu-devel@nongnu.org/msg876056.html
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: improve error when cbw fails as reported by Friedrich Weber]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/copy-before-write.c | 18 ++--
|
||||
block/copy-before-write.h | 1 +
|
||||
block/monitor/block-hmp-cmds.c | 1 +
|
||||
pve-backup.c | 175 ++++++++++++++++++++++++++++++++-
|
||||
qapi/block-core.json | 10 +-
|
||||
5 files changed, 195 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
|
||||
index fd470f5f92..5c23b578ef 100644
|
||||
--- a/block/copy-before-write.c
|
||||
+++ b/block/copy-before-write.c
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "qobject/qjson.h"
|
||||
|
||||
#include "system/block-backend.h"
|
||||
+#include "qemu/atomic.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "qapi/error.h"
|
||||
#include "block/block_int.h"
|
||||
@@ -75,7 +76,8 @@ typedef struct BDRVCopyBeforeWriteState {
|
||||
* @snapshot_error is normally zero. But on first copy-before-write failure
|
||||
* when @on_cbw_error == ON_CBW_ERROR_BREAK_SNAPSHOT, @snapshot_error takes
|
||||
* value of this error (<0). After that all in-flight and further
|
||||
- * snapshot-API requests will fail with that error.
|
||||
+ * snapshot-API requests will fail with that error. To be accessed with
|
||||
+ * atomics.
|
||||
*/
|
||||
int snapshot_error;
|
||||
} BDRVCopyBeforeWriteState;
|
||||
@@ -115,7 +117,7 @@ static coroutine_fn int cbw_do_copy_before_write(BlockDriverState *bs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
- if (s->snapshot_error) {
|
||||
+ if (qatomic_read(&s->snapshot_error)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -139,9 +141,7 @@ static coroutine_fn int cbw_do_copy_before_write(BlockDriverState *bs,
|
||||
WITH_QEMU_LOCK_GUARD(&s->lock) {
|
||||
if (ret < 0) {
|
||||
assert(s->on_cbw_error == ON_CBW_ERROR_BREAK_SNAPSHOT);
|
||||
- if (!s->snapshot_error) {
|
||||
- s->snapshot_error = ret;
|
||||
- }
|
||||
+ qatomic_cmpxchg(&s->snapshot_error, 0, ret);
|
||||
} else {
|
||||
bdrv_set_dirty_bitmap(s->done_bitmap, off, end - off);
|
||||
}
|
||||
@@ -215,7 +215,7 @@ cbw_snapshot_read_lock(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
|
||||
QEMU_LOCK_GUARD(&s->lock);
|
||||
|
||||
- if (s->snapshot_error) {
|
||||
+ if (qatomic_read(&s->snapshot_error)) {
|
||||
g_free(req);
|
||||
return NULL;
|
||||
}
|
||||
@@ -595,6 +595,12 @@ void bdrv_cbw_drop(BlockDriverState *bs)
|
||||
bdrv_unref(bs);
|
||||
}
|
||||
|
||||
+int bdrv_cbw_snapshot_error(BlockDriverState *bs)
|
||||
+{
|
||||
+ BDRVCopyBeforeWriteState *s = bs->opaque;
|
||||
+ return qatomic_read(&s->snapshot_error);
|
||||
+}
|
||||
+
|
||||
static void cbw_init(void)
|
||||
{
|
||||
bdrv_register(&bdrv_cbw_filter);
|
||||
diff --git a/block/copy-before-write.h b/block/copy-before-write.h
|
||||
index 2a5d4ba693..969da3620f 100644
|
||||
--- a/block/copy-before-write.h
|
||||
+++ b/block/copy-before-write.h
|
||||
@@ -44,5 +44,6 @@ BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
|
||||
BlockCopyState **bcs,
|
||||
Error **errp);
|
||||
void bdrv_cbw_drop(BlockDriverState *bs);
|
||||
+int bdrv_cbw_snapshot_error(BlockDriverState *bs);
|
||||
|
||||
#endif /* COPY_BEFORE_WRITE_H */
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index 4f30f99644..66d16d342f 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1045,6 +1045,7 @@ void coroutine_fn hmp_backup(Monitor *mon, const QDict *qdict)
|
||||
NULL, NULL,
|
||||
devlist, qdict_haskey(qdict, "speed"), speed,
|
||||
false, 0, // BackupPerf max-workers
|
||||
+ false, false, // fleecing
|
||||
&error);
|
||||
|
||||
hmp_handle_error(mon, error);
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 366b015589..9b66788ab5 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "system/blockdev.h"
|
||||
#include "block/block_int-global-state.h"
|
||||
#include "block/blockjob.h"
|
||||
+#include "block/copy-before-write.h"
|
||||
#include "block/dirty-bitmap.h"
|
||||
#include "block/graph-lock.h"
|
||||
#include "qapi/qapi-commands-block.h"
|
||||
@@ -81,8 +82,15 @@ static void pvebackup_init(void)
|
||||
// initialize PVEBackupState at startup
|
||||
opts_init(pvebackup_init);
|
||||
|
||||
+typedef struct PVEBackupFleecingInfo {
|
||||
+ BlockDriverState *bs;
|
||||
+ BlockDriverState *cbw;
|
||||
+ BlockDriverState *snapshot_access;
|
||||
+} PVEBackupFleecingInfo;
|
||||
+
|
||||
typedef struct PVEBackupDevInfo {
|
||||
BlockDriverState *bs;
|
||||
+ PVEBackupFleecingInfo fleecing;
|
||||
size_t size;
|
||||
uint64_t block_size;
|
||||
uint8_t dev_id;
|
||||
@@ -352,11 +360,44 @@ static void coroutine_fn pvebackup_co_complete_stream(void *opaque)
|
||||
qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
}
|
||||
|
||||
+static void cleanup_snapshot_access(PVEBackupDevInfo *di)
|
||||
+{
|
||||
+ if (di->fleecing.snapshot_access) {
|
||||
+ bdrv_unref(di->fleecing.snapshot_access);
|
||||
+ di->fleecing.snapshot_access = NULL;
|
||||
+ }
|
||||
+ if (di->fleecing.cbw) {
|
||||
+ bdrv_cbw_drop(di->fleecing.cbw);
|
||||
+ di->fleecing.cbw = NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
{
|
||||
PVEBackupDevInfo *di = opaque;
|
||||
di->completed_ret = ret;
|
||||
|
||||
+ if (di->fleecing.cbw) {
|
||||
+ /*
|
||||
+ * With fleecing, failure for cbw does not fail the guest write, but only sets the snapshot
|
||||
+ * error, making further requests to the snapshot fail with EACCES, which then also fail the
|
||||
+ * job. But that code is not the root cause and just confusing, so update it.
|
||||
+ */
|
||||
+ int snapshot_error = bdrv_cbw_snapshot_error(di->fleecing.cbw);
|
||||
+ if (di->completed_ret == -EACCES && snapshot_error) {
|
||||
+ di->completed_ret = snapshot_error;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Handle block-graph specific cleanup (for fleecing) outside of the coroutine, because the work
|
||||
+ * won't be done as a coroutine anyways:
|
||||
+ * - For snapshot_access, allows doing bdrv_unref() directly. Doing it via bdrv_co_unref() would
|
||||
+ * just spawn a BH calling bdrv_unref().
|
||||
+ * - For cbw, draining would need to spawn a BH.
|
||||
+ */
|
||||
+ cleanup_snapshot_access(di);
|
||||
+
|
||||
/*
|
||||
* Needs to happen outside of coroutine, because it takes the graph write lock.
|
||||
*/
|
||||
@@ -487,6 +528,65 @@ static int coroutine_fn pvebackup_co_add_config(
|
||||
goto out;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Setup a snapshot-access block node for a device with associated fleecing image.
|
||||
+ */
|
||||
+static int setup_snapshot_access(PVEBackupDevInfo *di, Error **errp)
|
||||
+{
|
||||
+ Error *local_err = NULL;
|
||||
+
|
||||
+ if (!di->fleecing.bs) {
|
||||
+ error_setg(errp, "no associated fleecing image");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ QDict *cbw_opts = qdict_new();
|
||||
+ qdict_put_str(cbw_opts, "driver", "copy-before-write");
|
||||
+ qdict_put_str(cbw_opts, "file", bdrv_get_node_name(di->bs));
|
||||
+ qdict_put_str(cbw_opts, "target", bdrv_get_node_name(di->fleecing.bs));
|
||||
+
|
||||
+ if (di->bitmap) {
|
||||
+ /*
|
||||
+ * Only guest writes to parts relevant for the backup need to be intercepted with
|
||||
+ * old data being copied to the fleecing image.
|
||||
+ */
|
||||
+ qdict_put_str(cbw_opts, "bitmap.node", bdrv_get_node_name(di->bs));
|
||||
+ qdict_put_str(cbw_opts, "bitmap.name", bdrv_dirty_bitmap_name(di->bitmap));
|
||||
+ }
|
||||
+ /*
|
||||
+ * Fleecing storage is supposed to be fast and it's better to break backup than guest
|
||||
+ * writes. Certain guest drivers like VirtIO-win have 60 seconds timeout by default, so
|
||||
+ * abort a bit before that.
|
||||
+ */
|
||||
+ qdict_put_str(cbw_opts, "on-cbw-error", "break-snapshot");
|
||||
+ qdict_put_int(cbw_opts, "cbw-timeout", 45);
|
||||
+
|
||||
+ di->fleecing.cbw = bdrv_insert_node(di->bs, cbw_opts, BDRV_O_RDWR, &local_err);
|
||||
+
|
||||
+ if (!di->fleecing.cbw) {
|
||||
+ error_setg(errp, "appending cbw node for fleecing failed: %s",
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ QDict *snapshot_access_opts = qdict_new();
|
||||
+ qdict_put_str(snapshot_access_opts, "driver", "snapshot-access");
|
||||
+ qdict_put_str(snapshot_access_opts, "file", bdrv_get_node_name(di->fleecing.cbw));
|
||||
+
|
||||
+ di->fleecing.snapshot_access =
|
||||
+ bdrv_open(NULL, NULL, snapshot_access_opts, BDRV_O_RDWR | BDRV_O_UNMAP, &local_err);
|
||||
+ if (!di->fleecing.snapshot_access) {
|
||||
+ bdrv_cbw_drop(di->fleecing.cbw);
|
||||
+ di->fleecing.cbw = NULL;
|
||||
+
|
||||
+ error_setg(errp, "setting up snapshot access for fleecing failed: %s",
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* backup_job_create can *not* be run from a coroutine, so this can't either.
|
||||
* The caller is responsible that backup_mutex is held nonetheless.
|
||||
@@ -523,9 +623,42 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
}
|
||||
bdrv_drained_begin(di->bs);
|
||||
|
||||
+ BackupPerf perf = (BackupPerf){ .max_workers = backup_state.perf.max_workers };
|
||||
+
|
||||
+ BlockDriverState *source_bs = di->bs;
|
||||
+ bool discard_source = false;
|
||||
+ if (di->fleecing.bs) {
|
||||
+ if (setup_snapshot_access(di, &local_err) < 0) {
|
||||
+ error_setg(errp, "%s - setting up snapshot access for fleecing failed: %s",
|
||||
+ di->device_name,
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ bdrv_drained_end(di->bs);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ source_bs = di->fleecing.snapshot_access;
|
||||
+ discard_source = true;
|
||||
+
|
||||
+ /*
|
||||
+ * bdrv_get_info() just retuns 0 (= doesn't matter) for RBD when using krbd. But discard
|
||||
+ * on the fleecing image won't work if the backup job's granularity is less than the RBD
|
||||
+ * object size (default 4 MiB), so it does matter. Always use at least 4 MiB. With a PBS
|
||||
+ * target, the backup job granularity would already be at least this much.
|
||||
+ */
|
||||
+ perf.min_cluster_size = 4 * 1024 * 1024;
|
||||
+ /*
|
||||
+ * For discard to work, cluster size for the backup job must be at least the same as for
|
||||
+ * the fleecing image.
|
||||
+ */
|
||||
+ BlockDriverInfo bdi;
|
||||
+ if (bdrv_get_info(di->fleecing.bs, &bdi) >= 0) {
|
||||
+ perf.min_cluster_size = MAX(perf.min_cluster_size, bdi.cluster_size);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
BlockJob *job = backup_job_create(
|
||||
- NULL, di->bs, di->target, backup_state.speed, sync_mode, di->bitmap,
|
||||
- bitmap_mode, false, NULL, &backup_state.perf, BLOCKDEV_ON_ERROR_REPORT,
|
||||
+ di->device_name, source_bs, di->target, backup_state.speed, sync_mode, di->bitmap,
|
||||
+ bitmap_mode, false, discard_source, NULL, &perf, BLOCKDEV_ON_ERROR_REPORT,
|
||||
BLOCKDEV_ON_ERROR_REPORT, JOB_DEFAULT, pvebackup_complete_cb, di, backup_state.txn,
|
||||
&local_err);
|
||||
|
||||
@@ -539,6 +672,7 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
}
|
||||
|
||||
if (!job || local_err) {
|
||||
+ cleanup_snapshot_access(di);
|
||||
error_setg(errp, "backup_job_create failed: %s",
|
||||
local_err ? error_get_pretty(local_err) : "null");
|
||||
break;
|
||||
@@ -581,6 +715,14 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
aio_co_enter(data->ctx, data->co);
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * EFI disk and TPM state are small and it's just not worth setting up fleecing for them.
|
||||
+ */
|
||||
+static bool device_uses_fleecing(const char *device_id)
|
||||
+{
|
||||
+ return strncmp(device_id, "drive-efidisk", 13) && strncmp(device_id, "drive-tpmstate", 14);
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Returns a list of device infos, which needs to be freed by the caller. In
|
||||
* case of an error, errp will be set, but the returned value might still be a
|
||||
@@ -588,6 +730,7 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
*/
|
||||
static GList coroutine_fn GRAPH_RDLOCK *get_device_info(
|
||||
const char *devlist,
|
||||
+ bool fleecing,
|
||||
Error **errp)
|
||||
{
|
||||
gchar **devs = NULL;
|
||||
@@ -613,6 +756,30 @@ static GList coroutine_fn GRAPH_RDLOCK *get_device_info(
|
||||
di->bs = bs;
|
||||
di->device_name = g_strdup(bdrv_get_device_name(bs));
|
||||
|
||||
+ if (fleecing && device_uses_fleecing(*d)) {
|
||||
+ g_autofree gchar *fleecing_devid = g_strconcat(*d, "-fleecing", NULL);
|
||||
+ BlockBackend *fleecing_blk = blk_by_name(fleecing_devid);
|
||||
+ if (!fleecing_blk) {
|
||||
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
+ "Device '%s' not found", fleecing_devid);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ BlockDriverState *fleecing_bs = blk_bs(fleecing_blk);
|
||||
+ if (!bdrv_co_is_inserted(fleecing_bs)) {
|
||||
+ error_setg(errp, "Device '%s' has no medium", fleecing_devid);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ /*
|
||||
+ * Fleecing image needs to be the same size to act as a cbw target.
|
||||
+ */
|
||||
+ if (bs->total_sectors != fleecing_bs->total_sectors) {
|
||||
+ error_setg(errp, "Size mismatch for '%s' - sector count %ld != %ld",
|
||||
+ fleecing_devid, fleecing_bs->total_sectors, bs->total_sectors);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ di->fleecing.bs = fleecing_bs;
|
||||
+ }
|
||||
+
|
||||
di_list = g_list_append(di_list, di);
|
||||
d++;
|
||||
}
|
||||
@@ -663,6 +830,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
const char *devlist,
|
||||
bool has_speed, int64_t speed,
|
||||
bool has_max_workers, int64_t max_workers,
|
||||
+ bool has_fleecing, bool fleecing,
|
||||
Error **errp)
|
||||
{
|
||||
assert(qemu_in_coroutine());
|
||||
@@ -691,7 +859,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
format = has_format ? format : BACKUP_FORMAT_VMA;
|
||||
|
||||
bdrv_graph_co_rdlock();
|
||||
- di_list = get_device_info(devlist, &local_err);
|
||||
+ di_list = get_device_info(devlist, has_fleecing && fleecing, &local_err);
|
||||
bdrv_graph_co_rdunlock();
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
@@ -1093,5 +1261,6 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
ret->query_bitmap_info = true;
|
||||
ret->pbs_masterkey = true;
|
||||
ret->backup_max_workers = true;
|
||||
+ ret->backup_fleecing = true;
|
||||
return ret;
|
||||
}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 6838187607..9bdcfa31ea 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -952,6 +952,10 @@
|
||||
#
|
||||
# @max-workers: see @BackupPerf for details. Default 16.
|
||||
#
|
||||
+# @fleecing: perform a backup with fleecing. For each device in @devlist, a
|
||||
+# corresponing '-fleecing' device with the same size already needs to
|
||||
+# be present.
|
||||
+#
|
||||
# Returns: the uuid of the backup job
|
||||
#
|
||||
##
|
||||
@@ -972,7 +976,8 @@
|
||||
'*firewall-file': 'str',
|
||||
'*devlist': 'str',
|
||||
'*speed': 'int',
|
||||
- '*max-workers': 'int' },
|
||||
+ '*max-workers': 'int',
|
||||
+ '*fleecing': 'bool' },
|
||||
'returns': 'UuidInfo', 'coroutine': true }
|
||||
|
||||
##
|
||||
@@ -1018,6 +1023,8 @@
|
||||
#
|
||||
# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
|
||||
#
|
||||
+# @backup-fleecing: Whether backup fleecing is supported or not.
|
||||
+#
|
||||
# @backup-max-workers: Whether the 'max-workers' @BackupPerf setting is
|
||||
# supported or not.
|
||||
#
|
||||
@@ -1029,6 +1036,7 @@
|
||||
'pbs-dirty-bitmap-migration': 'bool',
|
||||
'pbs-masterkey': 'bool',
|
||||
'pbs-library-version': 'str',
|
||||
+ 'backup-fleecing': 'bool',
|
||||
'backup-max-workers': 'bool' } }
|
||||
|
||||
##
|
@@ -1,103 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dietmar Maurer <dietmar@proxmox.com>
|
||||
Date: Thu, 9 Jul 2020 12:53:08 +0200
|
||||
Subject: [PATCH] PVE: fixup pbs backup, add compress and encrypt options
|
||||
|
||||
---
|
||||
block/monitor/block-hmp-cmds.c | 4 +++-
|
||||
pve-backup.c | 13 ++++++++++++-
|
||||
qapi/block-core.json | 6 ++++++
|
||||
3 files changed, 21 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index fdc85a5c0e..43aa87487b 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1038,7 +1038,9 @@ 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
|
||||
+ false, false, // PBS use-dirty-bitmap
|
||||
+ false, false, // PBS compress
|
||||
+ false, false, // PBS encrypt
|
||||
true, dir ? BACKUP_FORMAT_DIR : BACKUP_FORMAT_VMA,
|
||||
false, NULL, false, NULL, !!devlist,
|
||||
devlist, qdict_haskey(qdict, "speed"), speed, &error);
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 1cd9d31d7c..bfb648d6b5 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -567,6 +567,10 @@ typedef struct QmpBackupTask {
|
||||
const char *firewall_file;
|
||||
bool has_devlist;
|
||||
const char *devlist;
|
||||
+ bool has_compress;
|
||||
+ bool compress;
|
||||
+ bool has_encrypt;
|
||||
+ bool encrypt;
|
||||
bool has_speed;
|
||||
int64_t speed;
|
||||
Error **errp;
|
||||
@@ -690,6 +694,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
|
||||
bool use_dirty_bitmap = task->has_use_dirty_bitmap && task->use_dirty_bitmap;
|
||||
|
||||
+
|
||||
char *pbs_err = NULL;
|
||||
pbs = proxmox_backup_new(
|
||||
task->backup_file,
|
||||
@@ -699,8 +704,10 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
task->has_password ? task->password : NULL,
|
||||
task->has_keyfile ? task->keyfile : NULL,
|
||||
task->has_key_password ? task->key_password : NULL,
|
||||
+ task->has_compress ? task->compress : true,
|
||||
+ task->has_encrypt ? task->encrypt : task->has_keyfile,
|
||||
task->has_fingerprint ? task->fingerprint : NULL,
|
||||
- &pbs_err);
|
||||
+ &pbs_err);
|
||||
|
||||
if (!pbs) {
|
||||
error_set(task->errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
@@ -939,6 +946,8 @@ UuidInfo *qmp_backup(
|
||||
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_compress, bool compress,
|
||||
+ bool has_encrypt, bool encrypt,
|
||||
bool has_format, BackupFormat format,
|
||||
bool has_config_file, const char *config_file,
|
||||
bool has_firewall_file, const char *firewall_file,
|
||||
@@ -967,6 +976,8 @@ UuidInfo *qmp_backup(
|
||||
.firewall_file = firewall_file,
|
||||
.has_devlist = has_devlist,
|
||||
.devlist = devlist,
|
||||
+ .has_compress = has_compress,
|
||||
+ .has_encrypt = has_encrypt,
|
||||
.has_speed = has_speed,
|
||||
.speed = speed,
|
||||
.errp = errp,
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index e00e577c6c..a177fea6cd 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -832,6 +832,10 @@
|
||||
#
|
||||
# @use-dirty-bitmap: use dirty bitmap to detect incremental changes since last job (optional for format 'pbs')
|
||||
#
|
||||
+# @compress: use compression (optional for format 'pbs', defaults to true)
|
||||
+#
|
||||
+# @encrypt: use encryption ((optional for format 'pbs', defaults to true if there is a keyfile)
|
||||
+#
|
||||
# Returns: the uuid of the backup job
|
||||
#
|
||||
##
|
||||
@@ -843,6 +847,8 @@
|
||||
'*backup-id': 'str',
|
||||
'*backup-time': 'int',
|
||||
'*use-dirty-bitmap': 'bool',
|
||||
+ '*compress': 'bool',
|
||||
+ '*encrypt': 'bool',
|
||||
'*format': 'BackupFormat',
|
||||
'*config-file': 'str',
|
||||
'*firewall-file': 'str',
|
137
debian/patches/pve/0043-adapt-machine-version-deprecation-for-Proxmox-VE.patch
vendored
Normal file
137
debian/patches/pve/0043-adapt-machine-version-deprecation-for-Proxmox-VE.patch
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Fri, 3 Jan 2025 14:03:12 +0100
|
||||
Subject: [PATCH] adapt machine version deprecation for Proxmox VE
|
||||
|
||||
In commit a35f8577a0 ("include/hw: add macros for deprecation &
|
||||
removal of versioned machines"), a new machine version deprecation and
|
||||
removal policy was introduced. After only 3 years a machine version
|
||||
will be deprecated while being removed after 6 years.
|
||||
|
||||
The deprecation is a bit early considering major PVE releases are
|
||||
approximately every 2 years. This means that a deprecation warning can
|
||||
already happen for a machine version that was introduced during the
|
||||
previous major release. This would scare users for no good reason, so
|
||||
avoid deprecating machine versions in PVE too early and define a
|
||||
baseline of machine versions that will be supported throughout a
|
||||
single major PVE release.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
include/hw/boards.h | 78 +++++++++++++++++++++++++++++----------------
|
||||
1 file changed, 51 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/include/hw/boards.h b/include/hw/boards.h
|
||||
index 8ada4d5832..f9f3b75284 100644
|
||||
--- a/include/hw/boards.h
|
||||
+++ b/include/hw/boards.h
|
||||
@@ -636,42 +636,66 @@ struct MachineState {
|
||||
|
||||
|
||||
/*
|
||||
- * How many years/major releases for each phase
|
||||
- * of the life cycle. Assumes use of versioning
|
||||
- * scheme where major is bumped each year
|
||||
+ * Baseline of machine versions that are still considered supported throughout
|
||||
+ * current major Proxmox VE release. Machine versions older than this are
|
||||
+ * considered to be deprecated in Proxmox VE.
|
||||
+ *
|
||||
+ * Machine versions older than 6 years are removed just like in upstream QEMU.
|
||||
+ * (policy takes effect with QEMU 10.1). Assumes yearly major QEMU release.
|
||||
+ *
|
||||
+ * QEMU release cylce N.0 in ~April, N.1 in ~August, N.2 in ~December
|
||||
+ * Debian/PVE release cylce ~every two years in summer
|
||||
+ *
|
||||
+ * PVE - last QEMU - machine versions dropped - baseline
|
||||
+ * 8 9.2 2.3 and older 2.4
|
||||
+ * 9 11.2 5.2 and older 6.0
|
||||
+ * 10 13.2 7.2 and older 8.0
|
||||
+ */
|
||||
+#define MACHINE_VER_BASELINE_PVE_MAJOR 2
|
||||
+#define MACHINE_VER_BASELINE_PVE_MINOR 4
|
||||
+#define MACHINE_VER_DELETION_MAJOR (QEMU_VERSION_MAJOR - 6)
|
||||
+#define MACHINE_VER_DELETION_MINOR QEMU_VERSION_MINOR
|
||||
+
|
||||
+/*
|
||||
+ * Proxmox VE needs to support the baseline throughout a major PVE release. So
|
||||
+ * a QEMU release where the baseline is already deleted cannot be used.
|
||||
+ * Removal policy after 6 years takes effect with QEMU 10.1.
|
||||
*/
|
||||
-#define MACHINE_VER_DELETION_MAJOR 6
|
||||
-#define MACHINE_VER_DEPRECATION_MAJOR 3
|
||||
+#if ((QEMU_VERSION_MAJOR > 10) || ((QEMU_VERSION_MAJOR == 10) && (QEMU_VERSION_MINOR >= 1)))
|
||||
+#if ((MACHINE_VER_BASELINE_PVE_MAJOR < MACHINE_VER_DELETION_MAJOR) || \
|
||||
+ ((MACHINE_VER_BASELINE_PVE_MAJOR == MACHINE_VER_DELETION_MAJOR) && \
|
||||
+ (MACHINE_VER_BASELINE_PVE_MINOR < MACHINE_VER_DELETION_MINOR)))
|
||||
+#error "Baseline machine version needed by Proxmox VE not supported anymore by this QEMU release"
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
/*
|
||||
* Expands to a static string containing a deprecation
|
||||
* message for a versioned machine type
|
||||
*/
|
||||
#define MACHINE_VER_DEPRECATION_MSG \
|
||||
- "machines more than " stringify(MACHINE_VER_DEPRECATION_MAJOR) \
|
||||
- " years old are subject to deletion after " \
|
||||
- stringify(MACHINE_VER_DELETION_MAJOR) " years"
|
||||
-
|
||||
-#define _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor) \
|
||||
- (((QEMU_VERSION_MAJOR - major) > cutoff) || \
|
||||
- (((QEMU_VERSION_MAJOR - major) == cutoff) && \
|
||||
- (QEMU_VERSION_MINOR - minor) >= 0))
|
||||
-
|
||||
-#define _MACHINE_VER_IS_EXPIRED2(cutoff, major, minor) \
|
||||
- _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor)
|
||||
-#define _MACHINE_VER_IS_EXPIRED3(cutoff, major, minor, micro) \
|
||||
- _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor)
|
||||
-#define _MACHINE_VER_IS_EXPIRED4(cutoff, major, minor, _unused, tag) \
|
||||
- _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor)
|
||||
-#define _MACHINE_VER_IS_EXPIRED5(cutoff, major, minor, micro, _unused, tag) \
|
||||
- _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor)
|
||||
-
|
||||
-#define _MACHINE_IS_EXPIRED(cutoff, ...) \
|
||||
+ "old machine version is subject to deletion during current major Proxmox VE release"
|
||||
+
|
||||
+#define _MACHINE_VER_IS_EXPIRED_IMPL(baseline_major, baseline_minor, major, minor) \
|
||||
+ ((major < baseline_major) || \
|
||||
+ ((major == baseline_major) && \
|
||||
+ (minor < baseline_minor)))
|
||||
+
|
||||
+#define _MACHINE_VER_IS_EXPIRED2(baseline_major, baseline_minor, major, minor) \
|
||||
+ _MACHINE_VER_IS_EXPIRED_IMPL(baseline_major, baseline_minor, major, minor)
|
||||
+#define _MACHINE_VER_IS_EXPIRED3(baseline_major, baseline_minor, major, minor, micro) \
|
||||
+ _MACHINE_VER_IS_EXPIRED_IMPL(baseline_major, baseline_minor, major, minor)
|
||||
+#define _MACHINE_VER_IS_EXPIRED4(baseline_major, baseline_minor, major, minor, _unused, tag) \
|
||||
+ _MACHINE_VER_IS_EXPIRED_IMPL(baseline_major, baseline_minor, major, minor)
|
||||
+#define _MACHINE_VER_IS_EXPIRED5(baseline_major, baseline_minor, major, minor, micro, _unused, tag) \
|
||||
+ _MACHINE_VER_IS_EXPIRED_IMPL(baseline_major, baseline_minor, major, minor)
|
||||
+
|
||||
+#define _MACHINE_IS_EXPIRED(baseline_major, baseline_minor, ...) \
|
||||
_MACHINE_VER_PICK(__VA_ARGS__, \
|
||||
_MACHINE_VER_IS_EXPIRED5, \
|
||||
_MACHINE_VER_IS_EXPIRED4, \
|
||||
_MACHINE_VER_IS_EXPIRED3, \
|
||||
- _MACHINE_VER_IS_EXPIRED2) (cutoff, __VA_ARGS__)
|
||||
+ _MACHINE_VER_IS_EXPIRED2) (baseline_major, baseline_minor, __VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Evaluates true when a machine type with (major, minor)
|
||||
@@ -680,7 +704,7 @@ struct MachineState {
|
||||
* lifecycle rules
|
||||
*/
|
||||
#define MACHINE_VER_IS_DEPRECATED(...) \
|
||||
- _MACHINE_IS_EXPIRED(MACHINE_VER_DEPRECATION_MAJOR, __VA_ARGS__)
|
||||
+ _MACHINE_IS_EXPIRED(MACHINE_VER_BASELINE_PVE_MAJOR, MACHINE_VER_BASELINE_PVE_MINOR, __VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Evaluates true when a machine type with (major, minor)
|
||||
@@ -689,7 +713,7 @@ struct MachineState {
|
||||
* lifecycle rules
|
||||
*/
|
||||
#define MACHINE_VER_SHOULD_DELETE(...) \
|
||||
- _MACHINE_IS_EXPIRED(MACHINE_VER_DELETION_MAJOR, __VA_ARGS__)
|
||||
+ _MACHINE_IS_EXPIRED(MACHINE_VER_DELETION_MAJOR, MACHINE_VER_DELETION_MINOR, __VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Sets the deprecation reason for a versioned machine based
|
@@ -1,69 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Wed, 8 Jul 2020 11:57:53 +0200
|
||||
Subject: [PATCH] PVE: add query_proxmox_support QMP command
|
||||
|
||||
Generic interface for future use, currently used for PBS dirty-bitmap
|
||||
backup support.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[PVE: query-proxmox-support: include library version]
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 8 ++++++++
|
||||
qapi/block-core.json | 25 +++++++++++++++++++++++++
|
||||
2 files changed, 33 insertions(+)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index bfb648d6b5..6bf138cfc6 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -1051,3 +1051,11 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
|
||||
return info;
|
||||
}
|
||||
+
|
||||
+ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
+{
|
||||
+ ProxmoxSupportStatus *ret = g_malloc0(sizeof(*ret));
|
||||
+ ret->pbs_library_version = g_strdup(proxmox_backup_qemu_version());
|
||||
+ ret->pbs_dirty_bitmap = true;
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index f782c2cf96..1ed5987c88 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -877,6 +877,31 @@
|
||||
##
|
||||
{ 'command': 'backup-cancel' }
|
||||
|
||||
+##
|
||||
+# @ProxmoxSupportStatus:
|
||||
+#
|
||||
+# Contains info about supported features added by Proxmox.
|
||||
+#
|
||||
+# @pbs-dirty-bitmap: True if dirty-bitmap-incremental backups to PBS are
|
||||
+# supported.
|
||||
+#
|
||||
+# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'ProxmoxSupportStatus',
|
||||
+ 'data': { 'pbs-dirty-bitmap': 'bool',
|
||||
+ 'pbs-library-version': 'str' } }
|
||||
+
|
||||
+##
|
||||
+# @query-proxmox-support:
|
||||
+#
|
||||
+# Returns information about supported features added by Proxmox.
|
||||
+#
|
||||
+# Returns: @ProxmoxSupportStatus
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'query-proxmox-support', 'returns': 'ProxmoxSupportStatus' }
|
||||
+
|
||||
##
|
||||
# @BlockDeviceTimedStats:
|
||||
#
|
50
debian/patches/pve/0044-Revert-hpet-avoid-timer-storms-on-periodic-timers.patch
vendored
Normal file
50
debian/patches/pve/0044-Revert-hpet-avoid-timer-storms-on-periodic-timers.patch
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 19 Mar 2025 17:31:05 +0100
|
||||
Subject: [PATCH] Revert "hpet: avoid timer storms on periodic timers"
|
||||
|
||||
This reverts commit 7c912ffb59e8137091894d767433e65c3df8b0bf.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/timer/hpet.c | 13 ++-----------
|
||||
1 file changed, 2 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
|
||||
index ccb97b6806..0f45af8bbe 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -61,7 +61,6 @@ typedef struct HPETTimer { /* timers */
|
||||
uint8_t wrap_flag; /* timer pop will indicate wrap for one-shot 32-bit
|
||||
* mode. Next pop will be actual timer expiration.
|
||||
*/
|
||||
- uint64_t last; /* last value armed, to avoid timer storms */
|
||||
} HPETTimer;
|
||||
|
||||
struct HPETState {
|
||||
@@ -262,7 +261,6 @@ static int hpet_post_load(void *opaque, int version_id)
|
||||
for (i = 0; i < s->num_timers; i++) {
|
||||
HPETTimer *t = &s->timer[i];
|
||||
t->cmp64 = hpet_calculate_cmp64(t, s->hpet_counter, t->cmp);
|
||||
- t->last = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - NANOSECONDS_PER_SECOND;
|
||||
}
|
||||
/* Recalculate the offset between the main counter and guest time */
|
||||
if (!s->hpet_offset_saved) {
|
||||
@@ -350,15 +348,8 @@ static const VMStateDescription vmstate_hpet = {
|
||||
|
||||
static void hpet_arm(HPETTimer *t, uint64_t tick)
|
||||
{
|
||||
- uint64_t ns = hpet_get_ns(t->state, tick);
|
||||
-
|
||||
- /* Clamp period to reasonable min value (1 us) */
|
||||
- if (timer_is_periodic(t) && ns - t->last < 1000) {
|
||||
- ns = t->last + 1000;
|
||||
- }
|
||||
-
|
||||
- t->last = ns;
|
||||
- timer_mod(t->qemu_timer, ns);
|
||||
+ /* FIXME: Clamp period to reasonable min value? */
|
||||
+ timer_mod(t->qemu_timer, hpet_get_ns(t->state, tick));
|
||||
}
|
||||
|
||||
/*
|
202
debian/patches/pve/0045-Revert-hpet-store-full-64-bit-target-value-of-the-co.patch
vendored
Normal file
202
debian/patches/pve/0045-Revert-hpet-store-full-64-bit-target-value-of-the-co.patch
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 19 Mar 2025 17:31:08 +0100
|
||||
Subject: [PATCH] Revert "hpet: store full 64-bit target value of the counter"
|
||||
|
||||
This reverts commit 242d665396407f83a6acbffc804882eeb21cfdad.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/timer/hpet.c | 109 +++++++++++++++++++++++++++---------------------
|
||||
1 file changed, 61 insertions(+), 48 deletions(-)
|
||||
|
||||
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
|
||||
index 0f45af8bbe..635a060d38 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -56,7 +56,6 @@ typedef struct HPETTimer { /* timers */
|
||||
uint64_t cmp; /* comparator */
|
||||
uint64_t fsb; /* FSB route */
|
||||
/* Hidden register state */
|
||||
- uint64_t cmp64; /* comparator (extended to counter width) */
|
||||
uint64_t period; /* Last value written to comparator */
|
||||
uint8_t wrap_flag; /* timer pop will indicate wrap for one-shot 32-bit
|
||||
* mode. Next pop will be actual timer expiration.
|
||||
@@ -119,6 +118,11 @@ static uint32_t timer_enabled(HPETTimer *t)
|
||||
}
|
||||
|
||||
static uint32_t hpet_time_after(uint64_t a, uint64_t b)
|
||||
+{
|
||||
+ return ((int32_t)(b - a) < 0);
|
||||
+}
|
||||
+
|
||||
+static uint32_t hpet_time_after64(uint64_t a, uint64_t b)
|
||||
{
|
||||
return ((int64_t)(b - a) < 0);
|
||||
}
|
||||
@@ -155,32 +159,27 @@ static uint64_t hpet_get_ticks(HPETState *s)
|
||||
return ns_to_ticks(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->hpet_offset);
|
||||
}
|
||||
|
||||
-static uint64_t hpet_get_ns(HPETState *s, uint64_t tick)
|
||||
-{
|
||||
- return ticks_to_ns(tick) - s->hpet_offset;
|
||||
-}
|
||||
-
|
||||
/*
|
||||
- * calculate next value of the general counter that matches the
|
||||
- * target (either entirely, or the low 32-bit only depending on
|
||||
- * the timer mode).
|
||||
+ * calculate diff between comparator value and current ticks
|
||||
*/
|
||||
-static uint64_t hpet_calculate_cmp64(HPETTimer *t, uint64_t cur_tick, uint64_t target)
|
||||
+static inline uint64_t hpet_calculate_diff(HPETTimer *t, uint64_t current)
|
||||
{
|
||||
+
|
||||
if (t->config & HPET_TN_32BIT) {
|
||||
- uint64_t result = deposit64(cur_tick, 0, 32, target);
|
||||
- if (result < cur_tick) {
|
||||
- result += 0x100000000ULL;
|
||||
- }
|
||||
- return result;
|
||||
+ uint32_t diff, cmp;
|
||||
+
|
||||
+ cmp = (uint32_t)t->cmp;
|
||||
+ diff = cmp - (uint32_t)current;
|
||||
+ diff = (int32_t)diff > 0 ? diff : (uint32_t)1;
|
||||
+ return (uint64_t)diff;
|
||||
} else {
|
||||
- return target;
|
||||
- }
|
||||
-}
|
||||
+ uint64_t diff, cmp;
|
||||
|
||||
-static uint64_t hpet_next_wrap(uint64_t cur_tick)
|
||||
-{
|
||||
- return (cur_tick | 0xffffffffU) + 1;
|
||||
+ cmp = t->cmp;
|
||||
+ diff = cmp - current;
|
||||
+ diff = (int64_t)diff > 0 ? diff : (uint64_t)1;
|
||||
+ return diff;
|
||||
+ }
|
||||
}
|
||||
|
||||
static void update_irq(struct HPETTimer *timer, int set)
|
||||
@@ -256,12 +255,7 @@ static bool hpet_validate_num_timers(void *opaque, int version_id)
|
||||
static int hpet_post_load(void *opaque, int version_id)
|
||||
{
|
||||
HPETState *s = opaque;
|
||||
- int i;
|
||||
|
||||
- for (i = 0; i < s->num_timers; i++) {
|
||||
- HPETTimer *t = &s->timer[i];
|
||||
- t->cmp64 = hpet_calculate_cmp64(t, s->hpet_counter, t->cmp);
|
||||
- }
|
||||
/* Recalculate the offset between the main counter and guest time */
|
||||
if (!s->hpet_offset_saved) {
|
||||
s->hpet_offset = ticks_to_ns(s->hpet_counter)
|
||||
@@ -346,10 +340,14 @@ static const VMStateDescription vmstate_hpet = {
|
||||
}
|
||||
};
|
||||
|
||||
-static void hpet_arm(HPETTimer *t, uint64_t tick)
|
||||
+static void hpet_arm(HPETTimer *t, uint64_t ticks)
|
||||
{
|
||||
- /* FIXME: Clamp period to reasonable min value? */
|
||||
- timer_mod(t->qemu_timer, hpet_get_ns(t->state, tick));
|
||||
+ if (ticks < ns_to_ticks(INT64_MAX / 2)) {
|
||||
+ timer_mod(t->qemu_timer,
|
||||
+ qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ticks_to_ns(ticks));
|
||||
+ } else {
|
||||
+ timer_del(t->qemu_timer);
|
||||
+ }
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -358,44 +356,54 @@ static void hpet_arm(HPETTimer *t, uint64_t tick)
|
||||
static void hpet_timer(void *opaque)
|
||||
{
|
||||
HPETTimer *t = opaque;
|
||||
+ uint64_t diff;
|
||||
+
|
||||
uint64_t period = t->period;
|
||||
uint64_t cur_tick = hpet_get_ticks(t->state);
|
||||
|
||||
if (timer_is_periodic(t) && period != 0) {
|
||||
- while (hpet_time_after(cur_tick, t->cmp64)) {
|
||||
- t->cmp64 += period;
|
||||
- }
|
||||
if (t->config & HPET_TN_32BIT) {
|
||||
- t->cmp = (uint32_t)t->cmp64;
|
||||
+ while (hpet_time_after(cur_tick, t->cmp)) {
|
||||
+ t->cmp = (uint32_t)(t->cmp + t->period);
|
||||
+ }
|
||||
} else {
|
||||
- t->cmp = t->cmp64;
|
||||
+ while (hpet_time_after64(cur_tick, t->cmp)) {
|
||||
+ t->cmp += period;
|
||||
+ }
|
||||
+ }
|
||||
+ diff = hpet_calculate_diff(t, cur_tick);
|
||||
+ hpet_arm(t, diff);
|
||||
+ } else if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {
|
||||
+ if (t->wrap_flag) {
|
||||
+ diff = hpet_calculate_diff(t, cur_tick);
|
||||
+ hpet_arm(t, diff);
|
||||
+ t->wrap_flag = 0;
|
||||
}
|
||||
- hpet_arm(t, t->cmp64);
|
||||
- } else if (t->wrap_flag) {
|
||||
- t->wrap_flag = 0;
|
||||
- hpet_arm(t, t->cmp64);
|
||||
}
|
||||
update_irq(t, 1);
|
||||
}
|
||||
|
||||
static void hpet_set_timer(HPETTimer *t)
|
||||
{
|
||||
+ uint64_t diff;
|
||||
+ uint32_t wrap_diff; /* how many ticks until we wrap? */
|
||||
uint64_t cur_tick = hpet_get_ticks(t->state);
|
||||
|
||||
+ /* whenever new timer is being set up, make sure wrap_flag is 0 */
|
||||
t->wrap_flag = 0;
|
||||
- t->cmp64 = hpet_calculate_cmp64(t, cur_tick, t->cmp);
|
||||
- if (t->config & HPET_TN_32BIT) {
|
||||
+ diff = hpet_calculate_diff(t, cur_tick);
|
||||
|
||||
- /* hpet spec says in one-shot 32-bit mode, generate an interrupt when
|
||||
- * counter wraps in addition to an interrupt with comparator match.
|
||||
- */
|
||||
- if (!timer_is_periodic(t) && t->cmp64 > hpet_next_wrap(cur_tick)) {
|
||||
+ /* hpet spec says in one-shot 32-bit mode, generate an interrupt when
|
||||
+ * counter wraps in addition to an interrupt with comparator match.
|
||||
+ */
|
||||
+ if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {
|
||||
+ wrap_diff = 0xffffffff - (uint32_t)cur_tick;
|
||||
+ if (wrap_diff < (uint32_t)diff) {
|
||||
+ diff = wrap_diff;
|
||||
t->wrap_flag = 1;
|
||||
- hpet_arm(t, hpet_next_wrap(cur_tick));
|
||||
- return;
|
||||
}
|
||||
}
|
||||
- hpet_arm(t, t->cmp64);
|
||||
+ hpet_arm(t, diff);
|
||||
}
|
||||
|
||||
static void hpet_del_timer(HPETTimer *t)
|
||||
@@ -526,7 +534,12 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
timer->cmp = deposit64(timer->cmp, shift, len, value);
|
||||
}
|
||||
if (timer_is_periodic(timer)) {
|
||||
- timer->period = deposit64(timer->period, shift, len, value);
|
||||
+ /*
|
||||
+ * FIXME: Clamp period to reasonable min value?
|
||||
+ * Clamp period to reasonable max value
|
||||
+ */
|
||||
+ new_val = deposit64(timer->period, shift, len, value);
|
||||
+ timer->period = MIN(new_val, (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1);
|
||||
}
|
||||
timer->config &= ~HPET_TN_SETVAL;
|
||||
if (hpet_enabled(s)) {
|
@@ -1,43 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Date: Fri, 10 Jul 2020 13:22:35 +0200
|
||||
Subject: [PATCH] pbs: fix missing crypt and compress parameters
|
||||
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 8 ++++++--
|
||||
1 file changed, 6 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 6bf138cfc6..cd3a132d8b 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -958,6 +958,8 @@ UuidInfo *qmp_backup(
|
||||
.backup_file = backup_file,
|
||||
.has_password = has_password,
|
||||
.password = password,
|
||||
+ .has_keyfile = has_keyfile,
|
||||
+ .keyfile = keyfile,
|
||||
.has_key_password = has_key_password,
|
||||
.key_password = key_password,
|
||||
.has_fingerprint = has_fingerprint,
|
||||
@@ -968,6 +970,10 @@ UuidInfo *qmp_backup(
|
||||
.backup_time = backup_time,
|
||||
.has_use_dirty_bitmap = has_use_dirty_bitmap,
|
||||
.use_dirty_bitmap = use_dirty_bitmap,
|
||||
+ .has_compress = has_compress,
|
||||
+ .compress = compress,
|
||||
+ .has_encrypt = has_encrypt,
|
||||
+ .encrypt = encrypt,
|
||||
.has_format = has_format,
|
||||
.format = format,
|
||||
.has_config_file = has_config_file,
|
||||
@@ -976,8 +982,6 @@ UuidInfo *qmp_backup(
|
||||
.firewall_file = firewall_file,
|
||||
.has_devlist = has_devlist,
|
||||
.devlist = devlist,
|
||||
- .has_compress = has_compress,
|
||||
- .has_encrypt = has_encrypt,
|
||||
.has_speed = has_speed,
|
||||
.speed = speed,
|
||||
.errp = errp,
|
@@ -1,76 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Wed, 19 Aug 2020 12:33:17 +0200
|
||||
Subject: [PATCH] PVE: handle PBS write callback with big blocks correctly
|
||||
|
||||
Under certain conditions QEMU will push more than the given blocksize
|
||||
into the callback at once. Handle it like VMA does, by iterating the
|
||||
data until all is written.
|
||||
|
||||
The block size is stored per backup device to be used in the callback.
|
||||
This avoids relying on PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE, in case it is
|
||||
made configurable in the future.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 30 ++++++++++++++++++++++--------
|
||||
1 file changed, 22 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index cd3a132d8b..f14273645a 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -67,6 +67,7 @@ opts_init(pvebackup_init);
|
||||
typedef struct PVEBackupDevInfo {
|
||||
BlockDriverState *bs;
|
||||
size_t size;
|
||||
+ uint64_t block_size;
|
||||
uint8_t dev_id;
|
||||
bool completed;
|
||||
char targetfile[PATH_MAX];
|
||||
@@ -147,17 +148,28 @@ pvebackup_co_dump_pbs_cb(
|
||||
return -1;
|
||||
}
|
||||
|
||||
- pbs_res = proxmox_backup_co_write_data(backup_state.pbs, di->dev_id, buf, start, size, &local_err);
|
||||
- qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
|
||||
+ uint64_t transferred = 0;
|
||||
+ uint64_t reused = 0;
|
||||
+ while (transferred < size) {
|
||||
+ uint64_t left = size - transferred;
|
||||
+ uint64_t to_transfer = left < di->block_size ? left : di->block_size;
|
||||
|
||||
- if (pbs_res < 0) {
|
||||
- pvebackup_propagate_error(local_err);
|
||||
- return pbs_res;
|
||||
- } else {
|
||||
- size_t reused = (pbs_res == 0) ? size : 0;
|
||||
- pvebackup_add_transfered_bytes(size, !buf ? size : 0, reused);
|
||||
+ pbs_res = proxmox_backup_co_write_data(backup_state.pbs, di->dev_id,
|
||||
+ buf ? buf + transferred : NULL, start + transferred, to_transfer, &local_err);
|
||||
+ transferred += to_transfer;
|
||||
+
|
||||
+ if (pbs_res < 0) {
|
||||
+ pvebackup_propagate_error(local_err);
|
||||
+ qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
|
||||
+ return pbs_res;
|
||||
+ }
|
||||
+
|
||||
+ reused += pbs_res == 0 ? to_transfer : 0;
|
||||
}
|
||||
|
||||
+ qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
|
||||
+ pvebackup_add_transfered_bytes(size, !buf ? size : 0, reused);
|
||||
+
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -726,6 +738,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
l = g_list_next(l);
|
||||
|
||||
+ di->block_size = dump_cb_block_size;
|
||||
+
|
||||
const char *devname = bdrv_get_device_name(di->bs);
|
||||
|
||||
BdrvDirtyBitmap *bitmap = bdrv_find_dirty_bitmap(di->bs, PBS_BITMAP_NAME);
|
281
debian/patches/pve/0046-Revert-hpet-accept-64-bit-reads-and-writes.patch
vendored
Normal file
281
debian/patches/pve/0046-Revert-hpet-accept-64-bit-reads-and-writes.patch
vendored
Normal file
@@ -0,0 +1,281 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 19 Mar 2025 17:31:09 +0100
|
||||
Subject: [PATCH] Revert "hpet: accept 64-bit reads and writes"
|
||||
|
||||
This reverts commit c2366567378dd8fb89329816003801f54e30e6f3.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/timer/hpet.c | 137 +++++++++++++++++++++++++++++-------------
|
||||
hw/timer/trace-events | 3 +-
|
||||
2 files changed, 96 insertions(+), 44 deletions(-)
|
||||
|
||||
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
|
||||
index 635a060d38..5f4bb5667d 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -421,7 +421,6 @@ static uint64_t hpet_ram_read(void *opaque, hwaddr addr,
|
||||
unsigned size)
|
||||
{
|
||||
HPETState *s = opaque;
|
||||
- int shift = (addr & 4) * 8;
|
||||
uint64_t cur_tick;
|
||||
|
||||
trace_hpet_ram_read(addr);
|
||||
@@ -436,33 +435,52 @@ static uint64_t hpet_ram_read(void *opaque, hwaddr addr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
- switch (addr & 0x18) {
|
||||
- case HPET_TN_CFG: // including interrupt capabilities
|
||||
- return timer->config >> shift;
|
||||
+ switch ((addr - 0x100) % 0x20) {
|
||||
+ case HPET_TN_CFG:
|
||||
+ return timer->config;
|
||||
+ case HPET_TN_CFG + 4: // Interrupt capabilities
|
||||
+ return timer->config >> 32;
|
||||
case HPET_TN_CMP: // comparator register
|
||||
- return timer->cmp >> shift;
|
||||
+ return timer->cmp;
|
||||
+ case HPET_TN_CMP + 4:
|
||||
+ return timer->cmp >> 32;
|
||||
case HPET_TN_ROUTE:
|
||||
- return timer->fsb >> shift;
|
||||
+ return timer->fsb;
|
||||
+ case HPET_TN_ROUTE + 4:
|
||||
+ return timer->fsb >> 32;
|
||||
default:
|
||||
trace_hpet_ram_read_invalid();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
- switch (addr & ~4) {
|
||||
- case HPET_ID: // including HPET_PERIOD
|
||||
- return s->capability >> shift;
|
||||
+ switch (addr) {
|
||||
+ case HPET_ID:
|
||||
+ return s->capability;
|
||||
+ case HPET_PERIOD:
|
||||
+ return s->capability >> 32;
|
||||
case HPET_CFG:
|
||||
- return s->config >> shift;
|
||||
+ return s->config;
|
||||
+ case HPET_CFG + 4:
|
||||
+ trace_hpet_invalid_hpet_cfg(4);
|
||||
+ return 0;
|
||||
case HPET_COUNTER:
|
||||
if (hpet_enabled(s)) {
|
||||
cur_tick = hpet_get_ticks(s);
|
||||
} else {
|
||||
cur_tick = s->hpet_counter;
|
||||
}
|
||||
- trace_hpet_ram_read_reading_counter(addr & 4, cur_tick);
|
||||
- return cur_tick >> shift;
|
||||
+ trace_hpet_ram_read_reading_counter(0, cur_tick);
|
||||
+ return cur_tick;
|
||||
+ case HPET_COUNTER + 4:
|
||||
+ if (hpet_enabled(s)) {
|
||||
+ cur_tick = hpet_get_ticks(s);
|
||||
+ } else {
|
||||
+ cur_tick = s->hpet_counter;
|
||||
+ }
|
||||
+ trace_hpet_ram_read_reading_counter(4, cur_tick);
|
||||
+ return cur_tick >> 32;
|
||||
case HPET_STATUS:
|
||||
- return s->isr >> shift;
|
||||
+ return s->isr;
|
||||
default:
|
||||
trace_hpet_ram_read_invalid();
|
||||
break;
|
||||
@@ -476,11 +494,11 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
{
|
||||
int i;
|
||||
HPETState *s = opaque;
|
||||
- int shift = (addr & 4) * 8;
|
||||
- int len = MIN(size * 8, 64 - shift);
|
||||
uint64_t old_val, new_val, cleared;
|
||||
|
||||
trace_hpet_ram_write(addr, value);
|
||||
+ old_val = hpet_ram_read(opaque, addr, 4);
|
||||
+ new_val = value;
|
||||
|
||||
/*address range of all TN regs*/
|
||||
if (addr >= 0x100 && addr <= 0x3ff) {
|
||||
@@ -492,12 +510,9 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
trace_hpet_timer_id_out_of_range(timer_id);
|
||||
return;
|
||||
}
|
||||
- switch (addr & 0x18) {
|
||||
+ switch ((addr - 0x100) % 0x20) {
|
||||
case HPET_TN_CFG:
|
||||
- trace_hpet_ram_write_tn_cfg(addr & 4);
|
||||
- old_val = timer->config;
|
||||
- new_val = deposit64(old_val, shift, len, value);
|
||||
- new_val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK);
|
||||
+ trace_hpet_ram_write_tn_cfg();
|
||||
if (deactivating_bit(old_val, new_val, HPET_TN_TYPE_LEVEL)) {
|
||||
/*
|
||||
* Do this before changing timer->config; otherwise, if
|
||||
@@ -505,7 +520,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
*/
|
||||
update_irq(timer, 0);
|
||||
}
|
||||
- timer->config = new_val;
|
||||
+ new_val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK);
|
||||
+ timer->config = (timer->config & 0xffffffff00000000ULL) | new_val;
|
||||
if (activating_bit(old_val, new_val, HPET_TN_ENABLE)
|
||||
&& (s->isr & (1 << timer_id))) {
|
||||
update_irq(timer, 1);
|
||||
@@ -518,28 +534,56 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
hpet_set_timer(timer);
|
||||
}
|
||||
break;
|
||||
+ case HPET_TN_CFG + 4: // Interrupt capabilities
|
||||
+ trace_hpet_ram_write_invalid_tn_cfg(4);
|
||||
+ break;
|
||||
case HPET_TN_CMP: // comparator register
|
||||
+ trace_hpet_ram_write_tn_cmp(0);
|
||||
if (timer->config & HPET_TN_32BIT) {
|
||||
- /* High 32-bits are zero, leave them untouched. */
|
||||
- if (shift) {
|
||||
- trace_hpet_ram_write_invalid_tn_cmp();
|
||||
- break;
|
||||
+ new_val = (uint32_t)new_val;
|
||||
+ }
|
||||
+ if (!timer_is_periodic(timer)
|
||||
+ || (timer->config & HPET_TN_SETVAL)) {
|
||||
+ timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val;
|
||||
+ }
|
||||
+ if (timer_is_periodic(timer)) {
|
||||
+ /*
|
||||
+ * FIXME: Clamp period to reasonable min value?
|
||||
+ * Clamp period to reasonable max value
|
||||
+ */
|
||||
+ if (timer->config & HPET_TN_32BIT) {
|
||||
+ new_val = MIN(new_val, ~0u >> 1);
|
||||
}
|
||||
- len = 64;
|
||||
- value = (uint32_t) value;
|
||||
+ timer->period =
|
||||
+ (timer->period & 0xffffffff00000000ULL) | new_val;
|
||||
+ }
|
||||
+ /*
|
||||
+ * FIXME: on a 64-bit write, HPET_TN_SETVAL should apply to the
|
||||
+ * high bits part as well.
|
||||
+ */
|
||||
+ timer->config &= ~HPET_TN_SETVAL;
|
||||
+ if (hpet_enabled(s)) {
|
||||
+ hpet_set_timer(timer);
|
||||
}
|
||||
- trace_hpet_ram_write_tn_cmp(addr & 4);
|
||||
+ break;
|
||||
+ case HPET_TN_CMP + 4: // comparator register high order
|
||||
+ if (timer->config & HPET_TN_32BIT) {
|
||||
+ trace_hpet_ram_write_invalid_tn_cmp();
|
||||
+ break;
|
||||
+ }
|
||||
+ trace_hpet_ram_write_tn_cmp(4);
|
||||
if (!timer_is_periodic(timer)
|
||||
|| (timer->config & HPET_TN_SETVAL)) {
|
||||
- timer->cmp = deposit64(timer->cmp, shift, len, value);
|
||||
+ timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32;
|
||||
}
|
||||
if (timer_is_periodic(timer)) {
|
||||
/*
|
||||
* FIXME: Clamp period to reasonable min value?
|
||||
* Clamp period to reasonable max value
|
||||
*/
|
||||
- new_val = deposit64(timer->period, shift, len, value);
|
||||
- timer->period = MIN(new_val, (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1);
|
||||
+ new_val = MIN(new_val, ~0u >> 1);
|
||||
+ timer->period =
|
||||
+ (timer->period & 0xffffffffULL) | new_val << 32;
|
||||
}
|
||||
timer->config &= ~HPET_TN_SETVAL;
|
||||
if (hpet_enabled(s)) {
|
||||
@@ -547,7 +591,10 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
}
|
||||
break;
|
||||
case HPET_TN_ROUTE:
|
||||
- timer->fsb = deposit64(timer->fsb, shift, len, value);
|
||||
+ timer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val;
|
||||
+ break;
|
||||
+ case HPET_TN_ROUTE + 4:
|
||||
+ timer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff);
|
||||
break;
|
||||
default:
|
||||
trace_hpet_ram_write_invalid();
|
||||
@@ -555,14 +602,12 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
- switch (addr & ~4) {
|
||||
+ switch (addr) {
|
||||
case HPET_ID:
|
||||
return;
|
||||
case HPET_CFG:
|
||||
- old_val = s->config;
|
||||
- new_val = deposit64(old_val, shift, len, value);
|
||||
new_val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK);
|
||||
- s->config = new_val;
|
||||
+ s->config = (s->config & 0xffffffff00000000ULL) | new_val;
|
||||
if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) {
|
||||
/* Enable main counter and interrupt generation. */
|
||||
s->hpet_offset =
|
||||
@@ -592,8 +637,10 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level);
|
||||
}
|
||||
break;
|
||||
+ case HPET_CFG + 4:
|
||||
+ trace_hpet_invalid_hpet_cfg(4);
|
||||
+ break;
|
||||
case HPET_STATUS:
|
||||
- new_val = value << shift;
|
||||
cleared = new_val & s->isr;
|
||||
for (i = 0; i < s->num_timers; i++) {
|
||||
if (cleared & (1 << i)) {
|
||||
@@ -605,7 +652,15 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
if (hpet_enabled(s)) {
|
||||
trace_hpet_ram_write_counter_write_while_enabled();
|
||||
}
|
||||
- s->hpet_counter = deposit64(s->hpet_counter, shift, len, value);
|
||||
+ s->hpet_counter =
|
||||
+ (s->hpet_counter & 0xffffffff00000000ULL) | value;
|
||||
+ trace_hpet_ram_write_counter_written(0, value, s->hpet_counter);
|
||||
+ break;
|
||||
+ case HPET_COUNTER + 4:
|
||||
+ trace_hpet_ram_write_counter_write_while_enabled();
|
||||
+ s->hpet_counter =
|
||||
+ (s->hpet_counter & 0xffffffffULL) | (((uint64_t)value) << 32);
|
||||
+ trace_hpet_ram_write_counter_written(4, value, s->hpet_counter);
|
||||
break;
|
||||
default:
|
||||
trace_hpet_ram_write_invalid();
|
||||
@@ -619,11 +674,7 @@ static const MemoryRegionOps hpet_ram_ops = {
|
||||
.write = hpet_ram_write,
|
||||
.valid = {
|
||||
.min_access_size = 4,
|
||||
- .max_access_size = 8,
|
||||
- },
|
||||
- .impl = {
|
||||
- .min_access_size = 4,
|
||||
- .max_access_size = 8,
|
||||
+ .max_access_size = 4,
|
||||
},
|
||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
};
|
||||
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
|
||||
index c5b6db49f5..dd8a53c690 100644
|
||||
--- a/hw/timer/trace-events
|
||||
+++ b/hw/timer/trace-events
|
||||
@@ -114,7 +114,8 @@ hpet_ram_read_reading_counter(uint8_t reg_off, uint64_t cur_tick) "reading count
|
||||
hpet_ram_read_invalid(void) "invalid hpet_ram_readl"
|
||||
hpet_ram_write(uint64_t addr, uint64_t value) "enter hpet_ram_writel at 0x%" PRIx64 " = 0x%" PRIx64
|
||||
hpet_ram_write_timer_id(uint64_t timer_id) "hpet_ram_writel timer_id = 0x%" PRIx64
|
||||
-hpet_ram_write_tn_cfg(uint8_t reg_off) "hpet_ram_writel HPET_TN_CFG + %" PRIu8
|
||||
+hpet_ram_write_tn_cfg(void) "hpet_ram_writel HPET_TN_CFG"
|
||||
+hpet_ram_write_invalid_tn_cfg(uint8_t reg_off) "invalid HPET_TN_CFG + %" PRIu8 " write"
|
||||
hpet_ram_write_tn_cmp(uint8_t reg_off) "hpet_ram_writel HPET_TN_CMP + %" PRIu8
|
||||
hpet_ram_write_invalid_tn_cmp(void) "invalid HPET_TN_CMP + 4 write"
|
||||
hpet_ram_write_invalid(void) "invalid hpet_ram_writel"
|
@@ -1,85 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Thu, 13 Aug 2020 13:50:27 +0200
|
||||
Subject: [PATCH] PVE: add zero block handling to PBS dump callback
|
||||
|
||||
Both the PBS and VMA dump callbacks assume that a NULL pointer can be
|
||||
passed as *pbuf, but that never happens, as backup-dump.c calls this
|
||||
function with contents of an iovec.
|
||||
|
||||
So first, remove that assumption and add an 'assert' to verify.
|
||||
|
||||
Secondly, while the vma-writer already does the buffer_is_zero check
|
||||
internally, for PBS we relied on that non-existant behaviour for zero
|
||||
chunks, so do the buffer_is_zero check manually and pass NULL to the
|
||||
rust lib in case it is true.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 14 +++++++++-----
|
||||
1 file changed, 9 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index f14273645a..bd802c6205 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "block/blockjob.h"
|
||||
#include "qapi/qapi-commands-block.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
+#include "qemu/cutils.h"
|
||||
|
||||
/* PVE backup state and related function */
|
||||
|
||||
@@ -136,10 +137,13 @@ pvebackup_co_dump_pbs_cb(
|
||||
PVEBackupDevInfo *di = opaque;
|
||||
|
||||
assert(backup_state.pbs);
|
||||
+ assert(buf);
|
||||
|
||||
Error *local_err = NULL;
|
||||
int pbs_res = -1;
|
||||
|
||||
+ bool is_zero_block = size == di->block_size && buffer_is_zero(buf, size);
|
||||
+
|
||||
qemu_co_mutex_lock(&backup_state.dump_callback_mutex);
|
||||
|
||||
// avoid deadlock if job is cancelled
|
||||
@@ -155,7 +159,8 @@ pvebackup_co_dump_pbs_cb(
|
||||
uint64_t to_transfer = left < di->block_size ? left : di->block_size;
|
||||
|
||||
pbs_res = proxmox_backup_co_write_data(backup_state.pbs, di->dev_id,
|
||||
- buf ? buf + transferred : NULL, start + transferred, to_transfer, &local_err);
|
||||
+ is_zero_block ? NULL : buf + transferred, start + transferred,
|
||||
+ to_transfer, &local_err);
|
||||
transferred += to_transfer;
|
||||
|
||||
if (pbs_res < 0) {
|
||||
@@ -168,7 +173,7 @@ pvebackup_co_dump_pbs_cb(
|
||||
}
|
||||
|
||||
qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
|
||||
- pvebackup_add_transfered_bytes(size, !buf ? size : 0, reused);
|
||||
+ pvebackup_add_transfered_bytes(size, is_zero_block ? size : 0, reused);
|
||||
|
||||
return size;
|
||||
}
|
||||
@@ -190,6 +195,7 @@ pvebackup_co_dump_vma_cb(
|
||||
int ret = -1;
|
||||
|
||||
assert(backup_state.vmaw);
|
||||
+ assert(buf);
|
||||
|
||||
uint64_t remaining = size;
|
||||
|
||||
@@ -216,9 +222,7 @@ pvebackup_co_dump_vma_cb(
|
||||
qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
|
||||
|
||||
++cluster_num;
|
||||
- if (buf) {
|
||||
- buf += VMA_CLUSTER_SIZE;
|
||||
- }
|
||||
+ buf += VMA_CLUSTER_SIZE;
|
||||
if (ret < 0) {
|
||||
Error *local_err = NULL;
|
||||
vma_writer_error_propagate(backup_state.vmaw, &local_err);
|
64
debian/patches/pve/0047-Revert-hpet-place-read-only-bits-directly-in-new_val.patch
vendored
Normal file
64
debian/patches/pve/0047-Revert-hpet-place-read-only-bits-directly-in-new_val.patch
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 19 Mar 2025 17:31:10 +0100
|
||||
Subject: [PATCH] Revert "hpet: place read-only bits directly in "new_val""
|
||||
|
||||
This reverts commit ba88935b0fac2588b0a739f810b58dfabf7f92c8.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/timer/hpet.c | 15 ++++++++-------
|
||||
1 file changed, 8 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
|
||||
index 5f4bb5667d..5e3bf1f153 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -494,7 +494,7 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
{
|
||||
int i;
|
||||
HPETState *s = opaque;
|
||||
- uint64_t old_val, new_val, cleared;
|
||||
+ uint64_t old_val, new_val, val;
|
||||
|
||||
trace_hpet_ram_write(addr, value);
|
||||
old_val = hpet_ram_read(opaque, addr, 4);
|
||||
@@ -520,12 +520,13 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
*/
|
||||
update_irq(timer, 0);
|
||||
}
|
||||
- new_val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK);
|
||||
- timer->config = (timer->config & 0xffffffff00000000ULL) | new_val;
|
||||
+ val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK);
|
||||
+ timer->config = (timer->config & 0xffffffff00000000ULL) | val;
|
||||
if (activating_bit(old_val, new_val, HPET_TN_ENABLE)
|
||||
&& (s->isr & (1 << timer_id))) {
|
||||
update_irq(timer, 1);
|
||||
}
|
||||
+
|
||||
if (new_val & HPET_TN_32BIT) {
|
||||
timer->cmp = (uint32_t)timer->cmp;
|
||||
timer->period = (uint32_t)timer->period;
|
||||
@@ -606,8 +607,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
case HPET_ID:
|
||||
return;
|
||||
case HPET_CFG:
|
||||
- new_val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK);
|
||||
- s->config = (s->config & 0xffffffff00000000ULL) | new_val;
|
||||
+ val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK);
|
||||
+ s->config = (s->config & 0xffffffff00000000ULL) | val;
|
||||
if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) {
|
||||
/* Enable main counter and interrupt generation. */
|
||||
s->hpet_offset =
|
||||
@@ -641,9 +642,9 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
trace_hpet_invalid_hpet_cfg(4);
|
||||
break;
|
||||
case HPET_STATUS:
|
||||
- cleared = new_val & s->isr;
|
||||
+ val = new_val & s->isr;
|
||||
for (i = 0; i < s->num_timers; i++) {
|
||||
- if (cleared & (1 << i)) {
|
||||
+ if (val & (1 << i)) {
|
||||
update_irq(&s->timer[i], 0);
|
||||
}
|
||||
}
|
@@ -1,437 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Wed, 19 Aug 2020 17:02:00 +0200
|
||||
Subject: [PATCH] PVE: add query-pbs-bitmap-info QMP call
|
||||
|
||||
Returns advanced information about dirty bitmaps used (or not used) for
|
||||
the latest PBS backup.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
monitor/hmp-cmds.c | 28 ++++++-----
|
||||
pve-backup.c | 117 ++++++++++++++++++++++++++++++++-----------
|
||||
qapi/block-core.json | 56 +++++++++++++++++++++
|
||||
3 files changed, 159 insertions(+), 42 deletions(-)
|
||||
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index 3ff014d32a..c3227a1498 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -195,6 +195,7 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
|
||||
void hmp_info_backup(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
BackupStatus *info;
|
||||
+ PBSBitmapInfoList *bitmap_info;
|
||||
|
||||
info = qmp_query_backup(NULL);
|
||||
|
||||
@@ -225,26 +226,29 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
|
||||
// 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;
|
||||
- }
|
||||
- }
|
||||
+ bitmap_info = qmp_query_pbs_bitmap_info(NULL);
|
||||
+
|
||||
+ while (bitmap_info) {
|
||||
+ monitor_printf(mon, "Drive %s:\n",
|
||||
+ bitmap_info->value->drive);
|
||||
+ monitor_printf(mon, " bitmap action: %s\n",
|
||||
+ PBSBitmapAction_str(bitmap_info->value->action));
|
||||
+ monitor_printf(mon, " size: %zd\n",
|
||||
+ bitmap_info->value->size);
|
||||
+ monitor_printf(mon, " dirty: %zd\n",
|
||||
+ bitmap_info->value->dirty);
|
||||
+ bitmap_info = bitmap_info->next;
|
||||
}
|
||||
|
||||
- int per = (info->transferred * 100)/total_or_dirty;
|
||||
-
|
||||
- monitor_printf(mon, "Backup mode: %s\n", incremental ? "incremental" : "full");
|
||||
+ qapi_free_PBSBitmapInfoList(bitmap_info);
|
||||
|
||||
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);
|
||||
+ int trans_per = (info->transferred * 100)/total_or_dirty;
|
||||
monitor_printf(mon, "Transferred bytes: %zd (%d%%)\n",
|
||||
- info->transferred, per);
|
||||
+ info->transferred, trans_per);
|
||||
monitor_printf(mon, "Zero bytes: %zd (%d%%)\n",
|
||||
info->zero_bytes, zero_per);
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index bd802c6205..2db4a62580 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -46,6 +46,7 @@ static struct PVEBackupState {
|
||||
size_t transferred;
|
||||
size_t reused;
|
||||
size_t zero_bytes;
|
||||
+ GList *bitmap_list;
|
||||
} stat;
|
||||
int64_t speed;
|
||||
VmaWriter *vmaw;
|
||||
@@ -670,7 +671,6 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
|
||||
size_t total = 0;
|
||||
- size_t dirty = 0;
|
||||
|
||||
l = di_list;
|
||||
while (l) {
|
||||
@@ -691,18 +691,33 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
|
||||
uuid_generate(uuid);
|
||||
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+ backup_state.stat.reused = 0;
|
||||
+
|
||||
+ /* clear previous backup's bitmap_list */
|
||||
+ if (backup_state.stat.bitmap_list) {
|
||||
+ GList *bl = backup_state.stat.bitmap_list;
|
||||
+ while (bl) {
|
||||
+ g_free(((PBSBitmapInfo *)bl->data)->drive);
|
||||
+ g_free(bl->data);
|
||||
+ bl = g_list_next(bl);
|
||||
+ }
|
||||
+ g_list_free(backup_state.stat.bitmap_list);
|
||||
+ backup_state.stat.bitmap_list = NULL;
|
||||
+ }
|
||||
+
|
||||
if (format == BACKUP_FORMAT_PBS) {
|
||||
if (!task->has_password) {
|
||||
error_set(task->errp, ERROR_CLASS_GENERIC_ERROR, "missing parameter 'password'");
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
if (!task->has_backup_id) {
|
||||
error_set(task->errp, ERROR_CLASS_GENERIC_ERROR, "missing parameter 'backup-id'");
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
if (!task->has_backup_time) {
|
||||
error_set(task->errp, ERROR_CLASS_GENERIC_ERROR, "missing parameter 'backup-time'");
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
|
||||
int dump_cb_block_size = PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE; // Hardcoded (4M)
|
||||
@@ -729,12 +744,12 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
error_set(task->errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
"proxmox_backup_new failed: %s", pbs_err);
|
||||
proxmox_backup_free_error(pbs_err);
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
|
||||
int connect_result = proxmox_backup_co_connect(pbs, task->errp);
|
||||
if (connect_result < 0)
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
|
||||
/* register all devices */
|
||||
l = di_list;
|
||||
@@ -745,6 +760,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
di->block_size = dump_cb_block_size;
|
||||
|
||||
const char *devname = bdrv_get_device_name(di->bs);
|
||||
+ PBSBitmapAction action = PBS_BITMAP_ACTION_NOT_USED;
|
||||
+ size_t dirty = di->size;
|
||||
|
||||
BdrvDirtyBitmap *bitmap = bdrv_find_dirty_bitmap(di->bs, PBS_BITMAP_NAME);
|
||||
bool expect_only_dirty = false;
|
||||
@@ -753,49 +770,59 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
if (bitmap == NULL) {
|
||||
bitmap = bdrv_create_dirty_bitmap(di->bs, dump_cb_block_size, PBS_BITMAP_NAME, task->errp);
|
||||
if (!bitmap) {
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
+ action = PBS_BITMAP_ACTION_NEW;
|
||||
} else {
|
||||
expect_only_dirty = proxmox_backup_check_incremental(pbs, devname, di->size) != 0;
|
||||
}
|
||||
|
||||
if (expect_only_dirty) {
|
||||
- dirty += bdrv_get_dirty_count(bitmap);
|
||||
+ /* track clean chunks as reused */
|
||||
+ dirty = MIN(bdrv_get_dirty_count(bitmap), di->size);
|
||||
+ backup_state.stat.reused += di->size - dirty;
|
||||
+ action = PBS_BITMAP_ACTION_USED;
|
||||
} else {
|
||||
/* mark entire bitmap as dirty to make full backup */
|
||||
bdrv_set_dirty_bitmap(bitmap, 0, di->size);
|
||||
- dirty += di->size;
|
||||
+ if (action != PBS_BITMAP_ACTION_NEW) {
|
||||
+ action = PBS_BITMAP_ACTION_INVALID;
|
||||
+ }
|
||||
}
|
||||
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);
|
||||
+ action = PBS_BITMAP_ACTION_NOT_USED_REMOVED;
|
||||
}
|
||||
}
|
||||
|
||||
int dev_id = proxmox_backup_co_register_image(pbs, devname, di->size, expect_only_dirty, task->errp);
|
||||
if (dev_id < 0) {
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
|
||||
if (!(di->target = bdrv_backup_dump_create(dump_cb_block_size, di->size, pvebackup_co_dump_pbs_cb, di, task->errp))) {
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
|
||||
di->dev_id = dev_id;
|
||||
+
|
||||
+ PBSBitmapInfo *info = g_malloc(sizeof(*info));
|
||||
+ info->drive = g_strdup(devname);
|
||||
+ info->action = action;
|
||||
+ info->size = di->size;
|
||||
+ info->dirty = dirty;
|
||||
+ backup_state.stat.bitmap_list = g_list_append(backup_state.stat.bitmap_list, info);
|
||||
}
|
||||
} else if (format == BACKUP_FORMAT_VMA) {
|
||||
- dirty = total;
|
||||
-
|
||||
vmaw = vma_writer_create(task->backup_file, uuid, &local_err);
|
||||
if (!vmaw) {
|
||||
if (local_err) {
|
||||
error_propagate(task->errp, local_err);
|
||||
}
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
|
||||
/* register all devices for vma writer */
|
||||
@@ -805,7 +832,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
l = g_list_next(l);
|
||||
|
||||
if (!(di->target = bdrv_backup_dump_create(VMA_CLUSTER_SIZE, di->size, pvebackup_co_dump_vma_cb, di, task->errp))) {
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
|
||||
const char *devname = bdrv_get_device_name(di->bs);
|
||||
@@ -813,16 +840,14 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
if (di->dev_id <= 0) {
|
||||
error_set(task->errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
"register_stream failed");
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
backup_dir = task->backup_file;
|
||||
|
||||
@@ -839,18 +864,18 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
di->size, flags, false, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(task->errp, local_err);
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
|
||||
di->target = bdrv_open(di->targetfile, NULL, NULL, flags, &local_err);
|
||||
if (!di->target) {
|
||||
error_propagate(task->errp, local_err);
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error_set(task->errp, ERROR_CLASS_GENERIC_ERROR, "unknown backup format");
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
|
||||
|
||||
@@ -858,7 +883,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
if (task->has_config_file) {
|
||||
if (pvebackup_co_add_config(task->config_file, config_name, format, backup_dir,
|
||||
vmaw, pbs, task->errp) != 0) {
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -866,12 +891,11 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
if (task->has_firewall_file) {
|
||||
if (pvebackup_co_add_config(task->firewall_file, firewall_name, format, backup_dir,
|
||||
vmaw, pbs, task->errp) != 0) {
|
||||
- goto err;
|
||||
+ goto err_mutex;
|
||||
}
|
||||
}
|
||||
/* initialize global backup_state now */
|
||||
-
|
||||
- qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+ /* note: 'reused' and 'bitmap_list' are initialized earlier */
|
||||
|
||||
if (backup_state.stat.error) {
|
||||
error_free(backup_state.stat.error);
|
||||
@@ -891,10 +915,9 @@ 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.dirty = total - backup_state.stat.reused;
|
||||
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);
|
||||
|
||||
@@ -911,6 +934,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
task->result = uuid_info;
|
||||
return;
|
||||
|
||||
+err_mutex:
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+
|
||||
err:
|
||||
|
||||
l = di_list;
|
||||
@@ -1074,10 +1100,41 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
return info;
|
||||
}
|
||||
|
||||
+PBSBitmapInfoList *qmp_query_pbs_bitmap_info(Error **errp)
|
||||
+{
|
||||
+ PBSBitmapInfoList *head = NULL, **p_next = &head;
|
||||
+
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+
|
||||
+ GList *l = backup_state.stat.bitmap_list;
|
||||
+ while (l) {
|
||||
+ PBSBitmapInfo *info = (PBSBitmapInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ /* clone bitmap info to avoid auto free after QMP marshalling */
|
||||
+ PBSBitmapInfo *info_ret = g_malloc0(sizeof(*info_ret));
|
||||
+ info_ret->drive = g_strdup(info->drive);
|
||||
+ info_ret->action = info->action;
|
||||
+ info_ret->size = info->size;
|
||||
+ info_ret->dirty = info->dirty;
|
||||
+
|
||||
+ PBSBitmapInfoList *info_list = g_malloc0(sizeof(*info_list));
|
||||
+ info_list->value = info_ret;
|
||||
+
|
||||
+ *p_next = info_list;
|
||||
+ p_next = &info_list->next;
|
||||
+ }
|
||||
+
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+
|
||||
+ return head;
|
||||
+}
|
||||
+
|
||||
ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
{
|
||||
ProxmoxSupportStatus *ret = g_malloc0(sizeof(*ret));
|
||||
ret->pbs_library_version = g_strdup(proxmox_backup_qemu_version());
|
||||
ret->pbs_dirty_bitmap = true;
|
||||
+ ret->query_bitmap_info = true;
|
||||
return ret;
|
||||
}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 1ed5987c88..03fc0af99b 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -885,11 +885,14 @@
|
||||
# @pbs-dirty-bitmap: True if dirty-bitmap-incremental backups to PBS are
|
||||
# supported.
|
||||
#
|
||||
+# @query-bitmap-info: True if the 'query-pbs-bitmap-info' QMP call is supported.
|
||||
+#
|
||||
# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
|
||||
#
|
||||
##
|
||||
{ 'struct': 'ProxmoxSupportStatus',
|
||||
'data': { 'pbs-dirty-bitmap': 'bool',
|
||||
+ 'query-bitmap-info': 'bool',
|
||||
'pbs-library-version': 'str' } }
|
||||
|
||||
##
|
||||
@@ -902,6 +905,59 @@
|
||||
##
|
||||
{ 'command': 'query-proxmox-support', 'returns': 'ProxmoxSupportStatus' }
|
||||
|
||||
+##
|
||||
+# @PBSBitmapAction:
|
||||
+#
|
||||
+# An action taken on a dirty-bitmap when a backup job was started.
|
||||
+#
|
||||
+# @not-used: Bitmap mode was not enabled.
|
||||
+#
|
||||
+# @not-used-removed: Bitmap mode was not enabled, but a bitmap from a
|
||||
+# previous backup still existed and was removed.
|
||||
+#
|
||||
+# @new: A new bitmap was attached to the drive for this backup.
|
||||
+#
|
||||
+# @used: An existing bitmap will be used to only backup changed data.
|
||||
+#
|
||||
+# @invalid: A bitmap existed, but had to be cleared since it's associated
|
||||
+# base snapshot did not match the base given for the current job or
|
||||
+# the crypt mode has changed.
|
||||
+#
|
||||
+##
|
||||
+{ 'enum': 'PBSBitmapAction',
|
||||
+ 'data': ['not-used', 'not-used-removed', 'new', 'used', 'invalid'] }
|
||||
+
|
||||
+##
|
||||
+# @PBSBitmapInfo:
|
||||
+#
|
||||
+# Contains information about dirty bitmaps used for each drive in a PBS backup.
|
||||
+#
|
||||
+# @drive: The underlying drive.
|
||||
+#
|
||||
+# @action: The action that was taken when the backup started.
|
||||
+#
|
||||
+# @size: The total size of the drive.
|
||||
+#
|
||||
+# @dirty: How much of the drive is considered dirty and will be backed up,
|
||||
+# or 'size' if everything will be.
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'PBSBitmapInfo',
|
||||
+ 'data': { 'drive': 'str', 'action': 'PBSBitmapAction', 'size': 'int',
|
||||
+ 'dirty': 'int' } }
|
||||
+
|
||||
+##
|
||||
+# @query-pbs-bitmap-info:
|
||||
+#
|
||||
+# Returns information about dirty bitmaps used on the most recently started
|
||||
+# backup. Returns nothing when the last backup was not using PBS or if no
|
||||
+# backup occured in this session.
|
||||
+#
|
||||
+# Returns: @PBSBitmapInfo
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'query-pbs-bitmap-info', 'returns': ['PBSBitmapInfo'] }
|
||||
+
|
||||
##
|
||||
# @BlockDeviceTimedStats:
|
||||
#
|
68
debian/patches/pve/0048-Revert-hpet-remove-unnecessary-variable-index.patch
vendored
Normal file
68
debian/patches/pve/0048-Revert-hpet-remove-unnecessary-variable-index.patch
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 19 Mar 2025 17:31:11 +0100
|
||||
Subject: [PATCH] Revert "hpet: remove unnecessary variable "index""
|
||||
|
||||
This reverts commit 5895879aca252f4ebb2d1078eaf836c61ec54e9b.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/timer/hpet.c | 15 ++++++++-------
|
||||
1 file changed, 8 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
|
||||
index 5e3bf1f153..daef12c8cf 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -421,12 +421,12 @@ static uint64_t hpet_ram_read(void *opaque, hwaddr addr,
|
||||
unsigned size)
|
||||
{
|
||||
HPETState *s = opaque;
|
||||
- uint64_t cur_tick;
|
||||
+ uint64_t cur_tick, index;
|
||||
|
||||
trace_hpet_ram_read(addr);
|
||||
-
|
||||
+ index = addr;
|
||||
/*address range of all TN regs*/
|
||||
- if (addr >= 0x100 && addr <= 0x3ff) {
|
||||
+ if (index >= 0x100 && index <= 0x3ff) {
|
||||
uint8_t timer_id = (addr - 0x100) / 0x20;
|
||||
HPETTimer *timer = &s->timer[timer_id];
|
||||
|
||||
@@ -453,7 +453,7 @@ static uint64_t hpet_ram_read(void *opaque, hwaddr addr,
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
- switch (addr) {
|
||||
+ switch (index) {
|
||||
case HPET_ID:
|
||||
return s->capability;
|
||||
case HPET_PERIOD:
|
||||
@@ -494,14 +494,15 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
{
|
||||
int i;
|
||||
HPETState *s = opaque;
|
||||
- uint64_t old_val, new_val, val;
|
||||
+ uint64_t old_val, new_val, val, index;
|
||||
|
||||
trace_hpet_ram_write(addr, value);
|
||||
+ index = addr;
|
||||
old_val = hpet_ram_read(opaque, addr, 4);
|
||||
new_val = value;
|
||||
|
||||
/*address range of all TN regs*/
|
||||
- if (addr >= 0x100 && addr <= 0x3ff) {
|
||||
+ if (index >= 0x100 && index <= 0x3ff) {
|
||||
uint8_t timer_id = (addr - 0x100) / 0x20;
|
||||
HPETTimer *timer = &s->timer[timer_id];
|
||||
|
||||
@@ -603,7 +604,7 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
- switch (addr) {
|
||||
+ switch (index) {
|
||||
case HPET_ID:
|
||||
return;
|
||||
case HPET_CFG:
|
@@ -1,52 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Tue, 30 Jun 2020 13:10:10 +0200
|
||||
Subject: [PATCH] PVE: redirect stderr to journal when daemonized
|
||||
|
||||
QEMU uses the logging for error messages usually, so LOG_ERR is most
|
||||
fitting.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
Makefile.objs | 1 +
|
||||
os-posix.c | 7 +++++--
|
||||
2 files changed, 6 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Makefile.objs b/Makefile.objs
|
||||
index 240eb503f2..c7ba4e11e7 100644
|
||||
--- a/Makefile.objs
|
||||
+++ b/Makefile.objs
|
||||
@@ -54,6 +54,7 @@ common-obj-y += net/
|
||||
common-obj-y += qdev-monitor.o
|
||||
common-obj-$(CONFIG_WIN32) += os-win32.o
|
||||
common-obj-$(CONFIG_POSIX) += os-posix.o
|
||||
+os-posix.o-libs := -lsystemd
|
||||
|
||||
common-obj-$(CONFIG_LINUX) += fsdev/
|
||||
|
||||
diff --git a/os-posix.c b/os-posix.c
|
||||
index 3572db3f44..b45dde63ac 100644
|
||||
--- a/os-posix.c
|
||||
+++ b/os-posix.c
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <libgen.h>
|
||||
+#include <systemd/sd-journal.h>
|
||||
+#include <syslog.h>
|
||||
|
||||
#include "qemu-common.h"
|
||||
/* Needed early for CONFIG_BSD etc. */
|
||||
@@ -312,9 +314,10 @@ void os_setup_post(void)
|
||||
|
||||
dup2(fd, 0);
|
||||
dup2(fd, 1);
|
||||
- /* In case -D is given do not redirect stderr to /dev/null */
|
||||
+ /* In case -D is given do not redirect stderr to journal */
|
||||
if (!qemu_logfile) {
|
||||
- dup2(fd, 2);
|
||||
+ int journal_fd = sd_journal_stream_fd("QEMU", LOG_ERR, 0);
|
||||
+ dup2(journal_fd, 2);
|
||||
}
|
||||
|
||||
close(fd);
|
40
debian/patches/pve/0049-Revert-hpet-ignore-high-bits-of-comparator-in-32-bit.patch
vendored
Normal file
40
debian/patches/pve/0049-Revert-hpet-ignore-high-bits-of-comparator-in-32-bit.patch
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 19 Mar 2025 17:31:12 +0100
|
||||
Subject: [PATCH] Revert "hpet: ignore high bits of comparator in 32-bit mode"
|
||||
|
||||
This reverts commit 9eb7fad3546a89ee7cf0e90f5b1daccf89725cea.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/timer/hpet.c | 4 ----
|
||||
hw/timer/trace-events | 1 -
|
||||
2 files changed, 5 deletions(-)
|
||||
|
||||
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
|
||||
index daef12c8cf..927263e2ff 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -569,10 +569,6 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
}
|
||||
break;
|
||||
case HPET_TN_CMP + 4: // comparator register high order
|
||||
- if (timer->config & HPET_TN_32BIT) {
|
||||
- trace_hpet_ram_write_invalid_tn_cmp();
|
||||
- break;
|
||||
- }
|
||||
trace_hpet_ram_write_tn_cmp(4);
|
||||
if (!timer_is_periodic(timer)
|
||||
|| (timer->config & HPET_TN_SETVAL)) {
|
||||
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
|
||||
index dd8a53c690..2b81ee0812 100644
|
||||
--- a/hw/timer/trace-events
|
||||
+++ b/hw/timer/trace-events
|
||||
@@ -117,7 +117,6 @@ hpet_ram_write_timer_id(uint64_t timer_id) "hpet_ram_writel timer_id = 0x%" PRIx
|
||||
hpet_ram_write_tn_cfg(void) "hpet_ram_writel HPET_TN_CFG"
|
||||
hpet_ram_write_invalid_tn_cfg(uint8_t reg_off) "invalid HPET_TN_CFG + %" PRIu8 " write"
|
||||
hpet_ram_write_tn_cmp(uint8_t reg_off) "hpet_ram_writel HPET_TN_CMP + %" PRIu8
|
||||
-hpet_ram_write_invalid_tn_cmp(void) "invalid HPET_TN_CMP + 4 write"
|
||||
hpet_ram_write_invalid(void) "invalid hpet_ram_writel"
|
||||
hpet_ram_write_counter_write_while_enabled(void) "Writing counter while HPET enabled!"
|
||||
hpet_ram_write_counter_written(uint8_t reg_off, uint64_t value, uint64_t counter) "HPET counter + %" PRIu8 "written. crt = 0x%" PRIx64 " -> 0x%" PRIx64
|
120
debian/patches/pve/0050-Revert-hpet-fix-and-cleanup-persistence-of-interrupt.patch
vendored
Normal file
120
debian/patches/pve/0050-Revert-hpet-fix-and-cleanup-persistence-of-interrupt.patch
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 19 Mar 2025 17:31:13 +0100
|
||||
Subject: [PATCH] Revert "hpet: fix and cleanup persistence of interrupt
|
||||
status"
|
||||
|
||||
This reverts commit f0ccf770789e48b7a73497b465fdc892d28c1339.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/timer/hpet.c | 60 ++++++++++++++++---------------------------------
|
||||
1 file changed, 19 insertions(+), 41 deletions(-)
|
||||
|
||||
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
|
||||
index 927263e2ff..5aae09f166 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -199,31 +199,21 @@ static void update_irq(struct HPETTimer *timer, int set)
|
||||
}
|
||||
s = timer->state;
|
||||
mask = 1 << timer->tn;
|
||||
-
|
||||
- if (set && (timer->config & HPET_TN_TYPE_LEVEL)) {
|
||||
- /*
|
||||
- * If HPET_TN_ENABLE bit is 0, "the timer will still operate and
|
||||
- * generate appropriate status bits, but will not cause an interrupt"
|
||||
- */
|
||||
- s->isr |= mask;
|
||||
- } else {
|
||||
+ if (!set || !timer_enabled(timer) || !hpet_enabled(timer->state)) {
|
||||
s->isr &= ~mask;
|
||||
- }
|
||||
-
|
||||
- if (set && timer_enabled(timer) && hpet_enabled(s)) {
|
||||
- if (timer_fsb_route(timer)) {
|
||||
- address_space_stl_le(&address_space_memory, timer->fsb >> 32,
|
||||
- timer->fsb & 0xffffffff, MEMTXATTRS_UNSPECIFIED,
|
||||
- NULL);
|
||||
- } else if (timer->config & HPET_TN_TYPE_LEVEL) {
|
||||
- qemu_irq_raise(s->irqs[route]);
|
||||
- } else {
|
||||
- qemu_irq_pulse(s->irqs[route]);
|
||||
- }
|
||||
- } else {
|
||||
if (!timer_fsb_route(timer)) {
|
||||
qemu_irq_lower(s->irqs[route]);
|
||||
}
|
||||
+ } else if (timer_fsb_route(timer)) {
|
||||
+ address_space_stl_le(&address_space_memory, timer->fsb >> 32,
|
||||
+ timer->fsb & 0xffffffff, MEMTXATTRS_UNSPECIFIED,
|
||||
+ NULL);
|
||||
+ } else if (timer->config & HPET_TN_TYPE_LEVEL) {
|
||||
+ s->isr |= mask;
|
||||
+ qemu_irq_raise(s->irqs[route]);
|
||||
+ } else {
|
||||
+ s->isr &= ~mask;
|
||||
+ qemu_irq_pulse(s->irqs[route]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,13 +398,8 @@ static void hpet_set_timer(HPETTimer *t)
|
||||
|
||||
static void hpet_del_timer(HPETTimer *t)
|
||||
{
|
||||
- HPETState *s = t->state;
|
||||
timer_del(t->qemu_timer);
|
||||
-
|
||||
- if (s->isr & (1 << t->tn)) {
|
||||
- /* For level-triggered interrupt, this leaves ISR set but lowers irq. */
|
||||
- update_irq(t, 1);
|
||||
- }
|
||||
+ update_irq(t, 0);
|
||||
}
|
||||
|
||||
static uint64_t hpet_ram_read(void *opaque, hwaddr addr,
|
||||
@@ -514,26 +499,20 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
switch ((addr - 0x100) % 0x20) {
|
||||
case HPET_TN_CFG:
|
||||
trace_hpet_ram_write_tn_cfg();
|
||||
- if (deactivating_bit(old_val, new_val, HPET_TN_TYPE_LEVEL)) {
|
||||
- /*
|
||||
- * Do this before changing timer->config; otherwise, if
|
||||
- * HPET_TN_FSB is set, update_irq will not lower the qemu_irq.
|
||||
- */
|
||||
+ if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) {
|
||||
update_irq(timer, 0);
|
||||
}
|
||||
val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK);
|
||||
timer->config = (timer->config & 0xffffffff00000000ULL) | val;
|
||||
- if (activating_bit(old_val, new_val, HPET_TN_ENABLE)
|
||||
- && (s->isr & (1 << timer_id))) {
|
||||
- update_irq(timer, 1);
|
||||
- }
|
||||
-
|
||||
if (new_val & HPET_TN_32BIT) {
|
||||
timer->cmp = (uint32_t)timer->cmp;
|
||||
timer->period = (uint32_t)timer->period;
|
||||
}
|
||||
- if (hpet_enabled(s)) {
|
||||
+ if (activating_bit(old_val, new_val, HPET_TN_ENABLE) &&
|
||||
+ hpet_enabled(s)) {
|
||||
hpet_set_timer(timer);
|
||||
+ } else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) {
|
||||
+ hpet_del_timer(timer);
|
||||
}
|
||||
break;
|
||||
case HPET_TN_CFG + 4: // Interrupt capabilities
|
||||
@@ -611,10 +590,9 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
s->hpet_offset =
|
||||
ticks_to_ns(s->hpet_counter) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
for (i = 0; i < s->num_timers; i++) {
|
||||
- if (timer_enabled(&s->timer[i]) && (s->isr & (1 << i))) {
|
||||
- update_irq(&s->timer[i], 1);
|
||||
+ if ((&s->timer[i])->cmp != ~0ULL) {
|
||||
+ hpet_set_timer(&s->timer[i]);
|
||||
}
|
||||
- hpet_set_timer(&s->timer[i]);
|
||||
}
|
||||
} else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) {
|
||||
/* Halt main counter and disable interrupt generation. */
|
@@ -1,292 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Thu, 20 Aug 2020 14:25:00 +0200
|
||||
Subject: [PATCH] PVE-Backup: Use a transaction to synchronize job states
|
||||
|
||||
By using a JobTxn, we can sync dirty bitmaps only when *all* jobs were
|
||||
successful - meaning we don't need to remove them when the backup fails,
|
||||
since QEMU's BITMAP_SYNC_MODE_ON_SUCCESS will now handle that for us.
|
||||
|
||||
To keep the rate-limiting and IO impact from before, we use a sequential
|
||||
transaction, so drives will still be backed up one after the other.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 167 +++++++++++++++------------------------------------
|
||||
1 file changed, 49 insertions(+), 118 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 2db4a62580..b52f4a9364 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -52,6 +52,7 @@ static struct PVEBackupState {
|
||||
VmaWriter *vmaw;
|
||||
ProxmoxBackupHandle *pbs;
|
||||
GList *di_list;
|
||||
+ JobTxn *txn;
|
||||
QemuMutex backup_mutex;
|
||||
CoMutex dump_callback_mutex;
|
||||
} backup_state;
|
||||
@@ -71,32 +72,12 @@ typedef struct PVEBackupDevInfo {
|
||||
size_t size;
|
||||
uint64_t block_size;
|
||||
uint8_t dev_id;
|
||||
- bool completed;
|
||||
char targetfile[PATH_MAX];
|
||||
BdrvDirtyBitmap *bitmap;
|
||||
BlockDriverState *target;
|
||||
+ BlockJob *job;
|
||||
} PVEBackupDevInfo;
|
||||
|
||||
-static void pvebackup_run_next_job(void);
|
||||
-
|
||||
-static BlockJob *
|
||||
-lookup_active_block_job(PVEBackupDevInfo *di)
|
||||
-{
|
||||
- if (!di->completed && di->bs) {
|
||||
- for (BlockJob *job = block_job_next(NULL); job; job = block_job_next(job)) {
|
||||
- if (job->job.driver->job_type != JOB_TYPE_BACKUP) {
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- BackupBlockJob *bjob = container_of(job, BackupBlockJob, common);
|
||||
- if (bjob && bjob->source_bs == di->bs) {
|
||||
- return job;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- return NULL;
|
||||
-}
|
||||
-
|
||||
static void pvebackup_propagate_error(Error *err)
|
||||
{
|
||||
qemu_mutex_lock(&backup_state.stat.lock);
|
||||
@@ -272,18 +253,6 @@ 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);
|
||||
@@ -322,8 +291,6 @@ static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
|
||||
qemu_mutex_lock(&backup_state.backup_mutex);
|
||||
|
||||
- di->completed = true;
|
||||
-
|
||||
if (ret < 0) {
|
||||
Error *local_err = NULL;
|
||||
error_setg(&local_err, "job failed with err %d - %s", ret, strerror(-ret));
|
||||
@@ -336,20 +303,17 @@ static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
|
||||
block_on_coroutine_fn(pvebackup_complete_stream, di);
|
||||
|
||||
- // remove self from job queue
|
||||
+ // remove self from job list
|
||||
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);
|
||||
+ /* call cleanup if we're the last job */
|
||||
+ if (!g_list_first(backup_state.di_list)) {
|
||||
+ block_on_coroutine_fn(pvebackup_co_cleanup, NULL);
|
||||
+ }
|
||||
|
||||
- pvebackup_run_next_job();
|
||||
+ qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
}
|
||||
|
||||
static void pvebackup_cancel(void)
|
||||
@@ -371,36 +335,28 @@ static void pvebackup_cancel(void)
|
||||
proxmox_backup_abort(backup_state.pbs, "backup canceled");
|
||||
}
|
||||
|
||||
- qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
-
|
||||
- for(;;) {
|
||||
-
|
||||
- BlockJob *next_job = NULL;
|
||||
-
|
||||
- qemu_mutex_lock(&backup_state.backup_mutex);
|
||||
-
|
||||
- GList *l = backup_state.di_list;
|
||||
- while (l) {
|
||||
- PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
- l = g_list_next(l);
|
||||
+ /* it's enough to cancel one job in the transaction, the rest will follow
|
||||
+ * automatically */
|
||||
+ GList *bdi = g_list_first(backup_state.di_list);
|
||||
+ BlockJob *cancel_job = bdi && bdi->data ?
|
||||
+ ((PVEBackupDevInfo *)bdi->data)->job :
|
||||
+ NULL;
|
||||
|
||||
- BlockJob *job = lookup_active_block_job(di);
|
||||
- if (job != NULL) {
|
||||
- next_job = job;
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ /* ref the job before releasing the mutex, just to be safe */
|
||||
+ if (cancel_job) {
|
||||
+ job_ref(&cancel_job->job);
|
||||
+ }
|
||||
|
||||
- qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ /* job_cancel_sync may enter the job, so we need to release the
|
||||
+ * backup_mutex to avoid deadlock */
|
||||
+ qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
|
||||
- if (next_job) {
|
||||
- AioContext *aio_context = next_job->job.aio_context;
|
||||
- aio_context_acquire(aio_context);
|
||||
- job_cancel_sync(&next_job->job);
|
||||
- aio_context_release(aio_context);
|
||||
- } else {
|
||||
- break;
|
||||
- }
|
||||
+ if (cancel_job) {
|
||||
+ AioContext *aio_context = cancel_job->job.aio_context;
|
||||
+ aio_context_acquire(aio_context);
|
||||
+ job_cancel_sync(&cancel_job->job);
|
||||
+ job_unref(&cancel_job->job);
|
||||
+ aio_context_release(aio_context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,51 +415,19 @@ static int coroutine_fn pvebackup_co_add_config(
|
||||
goto out;
|
||||
}
|
||||
|
||||
-bool job_should_pause(Job *job);
|
||||
-
|
||||
-static void pvebackup_run_next_job(void)
|
||||
-{
|
||||
- assert(!qemu_in_coroutine());
|
||||
-
|
||||
- qemu_mutex_lock(&backup_state.backup_mutex);
|
||||
-
|
||||
- GList *l = backup_state.di_list;
|
||||
- while (l) {
|
||||
- PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
- l = g_list_next(l);
|
||||
-
|
||||
- BlockJob *job = lookup_active_block_job(di);
|
||||
-
|
||||
- if (job) {
|
||||
- qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
-
|
||||
- AioContext *aio_context = job->job.aio_context;
|
||||
- aio_context_acquire(aio_context);
|
||||
-
|
||||
- if (job_should_pause(&job->job)) {
|
||||
- bool error_or_canceled = pvebackup_error_or_canceled();
|
||||
- if (error_or_canceled) {
|
||||
- job_cancel_sync(&job->job);
|
||||
- } else {
|
||||
- job_resume(&job->job);
|
||||
- }
|
||||
- }
|
||||
- aio_context_release(aio_context);
|
||||
- return;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- block_on_coroutine_fn(pvebackup_co_cleanup, NULL); // no more jobs, run cleanup
|
||||
-
|
||||
- qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
-}
|
||||
-
|
||||
static bool create_backup_jobs(void) {
|
||||
|
||||
assert(!qemu_in_coroutine());
|
||||
|
||||
Error *local_err = NULL;
|
||||
|
||||
+ /* create job transaction to synchronize bitmap commit and cancel all
|
||||
+ * jobs in case one errors */
|
||||
+ if (backup_state.txn) {
|
||||
+ job_txn_unref(backup_state.txn);
|
||||
+ }
|
||||
+ backup_state.txn = job_txn_new_seq();
|
||||
+
|
||||
/* create and start all jobs (paused state) */
|
||||
GList *l = backup_state.di_list;
|
||||
while (l) {
|
||||
@@ -524,7 +448,7 @@ static bool create_backup_jobs(void) {
|
||||
BlockJob *job = backup_job_create(
|
||||
NULL, di->bs, di->target, backup_state.speed, sync_mode, di->bitmap,
|
||||
bitmap_mode, false, NULL, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
- JOB_DEFAULT, pvebackup_complete_cb, di, 1, NULL, &local_err);
|
||||
+ JOB_DEFAULT, pvebackup_complete_cb, di, backup_state.txn, &local_err);
|
||||
|
||||
aio_context_release(aio_context);
|
||||
|
||||
@@ -536,7 +460,8 @@ static bool create_backup_jobs(void) {
|
||||
pvebackup_propagate_error(create_job_err);
|
||||
break;
|
||||
}
|
||||
- job_start(&job->job);
|
||||
+
|
||||
+ di->job = job;
|
||||
|
||||
bdrv_unref(di->target);
|
||||
di->target = NULL;
|
||||
@@ -554,6 +479,10 @@ static bool create_backup_jobs(void) {
|
||||
bdrv_unref(di->target);
|
||||
di->target = NULL;
|
||||
}
|
||||
+
|
||||
+ if (di->job) {
|
||||
+ job_unref(&di->job->job);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -944,10 +873,6 @@ 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);
|
||||
}
|
||||
@@ -1036,9 +961,15 @@ UuidInfo *qmp_backup(
|
||||
block_on_coroutine_fn(pvebackup_co_prepare, &task);
|
||||
|
||||
if (*errp == NULL) {
|
||||
- create_backup_jobs();
|
||||
+ bool errors = create_backup_jobs();
|
||||
qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
- pvebackup_run_next_job();
|
||||
+
|
||||
+ if (!errors) {
|
||||
+ /* start the first job in the transaction
|
||||
+ * note: this might directly enter the job, so we need to do this
|
||||
+ * after unlocking the backup_mutex */
|
||||
+ job_txn_start_seq(backup_state.txn);
|
||||
+ }
|
||||
} else {
|
||||
qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
}
|
59
debian/patches/pve/0051-PVE-backup-factor-out-helper-to-clear-backup-state-s.patch
vendored
Normal file
59
debian/patches/pve/0051-PVE-backup-factor-out-helper-to-clear-backup-state-s.patch
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 3 Apr 2025 14:30:42 +0200
|
||||
Subject: [PATCH] PVE backup: factor out helper to clear backup state's bitmap
|
||||
list
|
||||
|
||||
Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 28 ++++++++++++++++++----------
|
||||
1 file changed, 18 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 9b66788ab5..588ee98ffc 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -811,6 +811,23 @@ err:
|
||||
return di_list;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * To be called with the backup_state.stat mutex held.
|
||||
+ */
|
||||
+static void clear_backup_state_bitmap_list(void) {
|
||||
+
|
||||
+ if (backup_state.stat.bitmap_list) {
|
||||
+ GList *bl = backup_state.stat.bitmap_list;
|
||||
+ while (bl) {
|
||||
+ g_free(((PBSBitmapInfo *)bl->data)->drive);
|
||||
+ g_free(bl->data);
|
||||
+ bl = g_list_next(bl);
|
||||
+ }
|
||||
+ g_list_free(backup_state.stat.bitmap_list);
|
||||
+ backup_state.stat.bitmap_list = NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
UuidInfo coroutine_fn *qmp_backup(
|
||||
const char *backup_file,
|
||||
const char *password,
|
||||
@@ -898,16 +915,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
backup_state.stat.reused = 0;
|
||||
|
||||
/* clear previous backup's bitmap_list */
|
||||
- if (backup_state.stat.bitmap_list) {
|
||||
- GList *bl = backup_state.stat.bitmap_list;
|
||||
- while (bl) {
|
||||
- g_free(((PBSBitmapInfo *)bl->data)->drive);
|
||||
- g_free(bl->data);
|
||||
- bl = g_list_next(bl);
|
||||
- }
|
||||
- g_list_free(backup_state.stat.bitmap_list);
|
||||
- backup_state.stat.bitmap_list = NULL;
|
||||
- }
|
||||
+ clear_backup_state_bitmap_list();
|
||||
|
||||
if (format == BACKUP_FORMAT_PBS) {
|
||||
if (!password) {
|
@@ -1,381 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Mon, 28 Sep 2020 13:40:51 +0200
|
||||
Subject: [PATCH] PVE-Backup: Use more coroutines and don't block on finishing
|
||||
|
||||
proxmox_backup_co_finish is already async, but previously we would wait
|
||||
for the coroutine using block_on_coroutine_fn(). Avoid this by
|
||||
scheduling pvebackup_co_complete_stream (and thus pvebackup_co_cleanup)
|
||||
as a real coroutine when calling from pvebackup_complete_cb. This is ok,
|
||||
since complete_stream uses the backup_mutex internally to synchronize,
|
||||
and other streams can happily continue writing in the meantime anyway.
|
||||
|
||||
To accomodate, backup_mutex is converted to a CoMutex. This means
|
||||
converting every user to a coroutine. This is not just useful here, but
|
||||
will come in handy once this series[0] is merged, and QMP calls can be
|
||||
yield-able coroutines too. Then we can also finally get rid of
|
||||
block_on_coroutine_fn.
|
||||
|
||||
Cases of aio_context_acquire/release from within what is now a coroutine
|
||||
are changed to aio_co_reschedule_self, which works since a running
|
||||
coroutine always holds the aio lock for the context it is running in.
|
||||
|
||||
job_cancel_sync is called from a BH since it can't be run from a
|
||||
coroutine (uses AIO_WAIT_WHILE internally).
|
||||
|
||||
Same thing for create_backup_jobs, which is converted to a BH too.
|
||||
|
||||
To communicate the finishing state, a new property is introduced to
|
||||
query-backup: 'finishing'. A new state is explicitly not used, since
|
||||
that would break compatibility with older qemu-server versions.
|
||||
|
||||
[0] https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg03515.html
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 148 ++++++++++++++++++++++++++-----------------
|
||||
qapi/block-core.json | 5 +-
|
||||
2 files changed, 95 insertions(+), 58 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index b52f4a9364..4402c0cb17 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -33,7 +33,9 @@ const char *PBS_BITMAP_NAME = "pbs-incremental-dirty-bitmap";
|
||||
|
||||
static struct PVEBackupState {
|
||||
struct {
|
||||
- // Everithing accessed from qmp_backup_query command is protected using lock
|
||||
+ // Everything accessed from qmp_backup_query command is protected using
|
||||
+ // this lock. Do NOT hold this lock for long times, as it is sometimes
|
||||
+ // acquired from coroutines, and thus any wait time may block the guest.
|
||||
QemuMutex lock;
|
||||
Error *error;
|
||||
time_t start_time;
|
||||
@@ -47,20 +49,21 @@ static struct PVEBackupState {
|
||||
size_t reused;
|
||||
size_t zero_bytes;
|
||||
GList *bitmap_list;
|
||||
+ bool finishing;
|
||||
} stat;
|
||||
int64_t speed;
|
||||
VmaWriter *vmaw;
|
||||
ProxmoxBackupHandle *pbs;
|
||||
GList *di_list;
|
||||
JobTxn *txn;
|
||||
- QemuMutex backup_mutex;
|
||||
+ CoMutex backup_mutex;
|
||||
CoMutex dump_callback_mutex;
|
||||
} backup_state;
|
||||
|
||||
static void pvebackup_init(void)
|
||||
{
|
||||
qemu_mutex_init(&backup_state.stat.lock);
|
||||
- qemu_mutex_init(&backup_state.backup_mutex);
|
||||
+ qemu_co_mutex_init(&backup_state.backup_mutex);
|
||||
qemu_co_mutex_init(&backup_state.dump_callback_mutex);
|
||||
}
|
||||
|
||||
@@ -72,6 +75,7 @@ typedef struct PVEBackupDevInfo {
|
||||
size_t size;
|
||||
uint64_t block_size;
|
||||
uint8_t dev_id;
|
||||
+ int completed_ret; // INT_MAX if not completed
|
||||
char targetfile[PATH_MAX];
|
||||
BdrvDirtyBitmap *bitmap;
|
||||
BlockDriverState *target;
|
||||
@@ -227,12 +231,12 @@ pvebackup_co_dump_vma_cb(
|
||||
}
|
||||
|
||||
// assumes the caller holds backup_mutex
|
||||
-static void coroutine_fn pvebackup_co_cleanup(void *unused)
|
||||
+static void coroutine_fn pvebackup_co_cleanup(void)
|
||||
{
|
||||
assert(qemu_in_coroutine());
|
||||
|
||||
qemu_mutex_lock(&backup_state.stat.lock);
|
||||
- backup_state.stat.end_time = time(NULL);
|
||||
+ backup_state.stat.finishing = true;
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
if (backup_state.vmaw) {
|
||||
@@ -261,12 +265,29 @@ static void coroutine_fn pvebackup_co_cleanup(void *unused)
|
||||
|
||||
g_list_free(backup_state.di_list);
|
||||
backup_state.di_list = NULL;
|
||||
+
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+ backup_state.stat.end_time = time(NULL);
|
||||
+ backup_state.stat.finishing = false;
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
}
|
||||
|
||||
-// assumes the caller holds backup_mutex
|
||||
-static void coroutine_fn pvebackup_complete_stream(void *opaque)
|
||||
+static void coroutine_fn pvebackup_co_complete_stream(void *opaque)
|
||||
{
|
||||
PVEBackupDevInfo *di = opaque;
|
||||
+ int ret = di->completed_ret;
|
||||
+
|
||||
+ qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
+
|
||||
+ if (ret < 0) {
|
||||
+ Error *local_err = NULL;
|
||||
+ error_setg(&local_err, "job failed with err %d - %s", ret, strerror(-ret));
|
||||
+ pvebackup_propagate_error(local_err);
|
||||
+ }
|
||||
+
|
||||
+ di->bs = NULL;
|
||||
+
|
||||
+ assert(di->target == NULL);
|
||||
|
||||
bool error_or_canceled = pvebackup_error_or_canceled();
|
||||
|
||||
@@ -281,27 +302,6 @@ static void coroutine_fn pvebackup_complete_stream(void *opaque)
|
||||
pvebackup_propagate_error(local_err);
|
||||
}
|
||||
}
|
||||
-}
|
||||
-
|
||||
-static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
-{
|
||||
- assert(!qemu_in_coroutine());
|
||||
-
|
||||
- PVEBackupDevInfo *di = opaque;
|
||||
-
|
||||
- qemu_mutex_lock(&backup_state.backup_mutex);
|
||||
-
|
||||
- if (ret < 0) {
|
||||
- Error *local_err = NULL;
|
||||
- error_setg(&local_err, "job failed with err %d - %s", ret, strerror(-ret));
|
||||
- pvebackup_propagate_error(local_err);
|
||||
- }
|
||||
-
|
||||
- di->bs = NULL;
|
||||
-
|
||||
- assert(di->target == NULL);
|
||||
-
|
||||
- block_on_coroutine_fn(pvebackup_complete_stream, di);
|
||||
|
||||
// remove self from job list
|
||||
backup_state.di_list = g_list_remove(backup_state.di_list, di);
|
||||
@@ -310,21 +310,49 @@ static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
|
||||
/* call cleanup if we're the last job */
|
||||
if (!g_list_first(backup_state.di_list)) {
|
||||
- block_on_coroutine_fn(pvebackup_co_cleanup, NULL);
|
||||
+ pvebackup_co_cleanup();
|
||||
}
|
||||
|
||||
- qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
}
|
||||
|
||||
-static void pvebackup_cancel(void)
|
||||
+static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
{
|
||||
- assert(!qemu_in_coroutine());
|
||||
+ PVEBackupDevInfo *di = opaque;
|
||||
+ di->completed_ret = ret;
|
||||
+
|
||||
+ /*
|
||||
+ * Schedule stream cleanup in async coroutine. close_image and finish might
|
||||
+ * take a while, so we can't block on them here. This way it also doesn't
|
||||
+ * matter if we're already running in a coroutine or not.
|
||||
+ * Note: di is a pointer to an entry in the global backup_state struct, so
|
||||
+ * it stays valid.
|
||||
+ */
|
||||
+ Coroutine *co = qemu_coroutine_create(pvebackup_co_complete_stream, di);
|
||||
+ aio_co_enter(qemu_get_aio_context(), co);
|
||||
+}
|
||||
|
||||
+/*
|
||||
+ * job_cancel(_sync) does not like to be called from coroutines, so defer to
|
||||
+ * main loop processing via a bottom half.
|
||||
+ */
|
||||
+static void job_cancel_bh(void *opaque) {
|
||||
+ CoCtxData *data = (CoCtxData*)opaque;
|
||||
+ Job *job = (Job*)data->data;
|
||||
+ AioContext *job_ctx = job->aio_context;
|
||||
+ aio_context_acquire(job_ctx);
|
||||
+ job_cancel_sync(job);
|
||||
+ aio_context_release(job_ctx);
|
||||
+ aio_co_enter(data->ctx, data->co);
|
||||
+}
|
||||
+
|
||||
+static void coroutine_fn pvebackup_co_cancel(void *opaque)
|
||||
+{
|
||||
Error *cancel_err = NULL;
|
||||
error_setg(&cancel_err, "backup canceled");
|
||||
pvebackup_propagate_error(cancel_err);
|
||||
|
||||
- qemu_mutex_lock(&backup_state.backup_mutex);
|
||||
+ qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
|
||||
if (backup_state.vmaw) {
|
||||
/* make sure vma writer does not block anymore */
|
||||
@@ -342,27 +370,22 @@ static void pvebackup_cancel(void)
|
||||
((PVEBackupDevInfo *)bdi->data)->job :
|
||||
NULL;
|
||||
|
||||
- /* ref the job before releasing the mutex, just to be safe */
|
||||
if (cancel_job) {
|
||||
- job_ref(&cancel_job->job);
|
||||
+ CoCtxData data = {
|
||||
+ .ctx = qemu_get_current_aio_context(),
|
||||
+ .co = qemu_coroutine_self(),
|
||||
+ .data = &cancel_job->job,
|
||||
+ };
|
||||
+ aio_bh_schedule_oneshot(data.ctx, job_cancel_bh, &data);
|
||||
+ qemu_coroutine_yield();
|
||||
}
|
||||
|
||||
- /* job_cancel_sync may enter the job, so we need to release the
|
||||
- * backup_mutex to avoid deadlock */
|
||||
- qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
-
|
||||
- if (cancel_job) {
|
||||
- AioContext *aio_context = cancel_job->job.aio_context;
|
||||
- aio_context_acquire(aio_context);
|
||||
- job_cancel_sync(&cancel_job->job);
|
||||
- job_unref(&cancel_job->job);
|
||||
- aio_context_release(aio_context);
|
||||
- }
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
}
|
||||
|
||||
void qmp_backup_cancel(Error **errp)
|
||||
{
|
||||
- pvebackup_cancel();
|
||||
+ block_on_coroutine_fn(pvebackup_co_cancel, NULL);
|
||||
}
|
||||
|
||||
// assumes the caller holds backup_mutex
|
||||
@@ -415,6 +438,14 @@ static int coroutine_fn pvebackup_co_add_config(
|
||||
goto out;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * backup_job_create can *not* be run from a coroutine (and requires an
|
||||
+ * acquired AioContext), so this can't either.
|
||||
+ * This does imply that this function cannot run with backup_mutex acquired.
|
||||
+ * That is ok because it is only ever called between setting up the backup_state
|
||||
+ * struct and starting the jobs, and from within a QMP call. This means that no
|
||||
+ * other QMP call can interrupt, and no background job is running yet.
|
||||
+ */
|
||||
static bool create_backup_jobs(void) {
|
||||
|
||||
assert(!qemu_in_coroutine());
|
||||
@@ -523,11 +554,12 @@ typedef struct QmpBackupTask {
|
||||
UuidInfo *result;
|
||||
} QmpBackupTask;
|
||||
|
||||
-// assumes the caller holds backup_mutex
|
||||
static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
{
|
||||
assert(qemu_in_coroutine());
|
||||
|
||||
+ qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
+
|
||||
QmpBackupTask *task = opaque;
|
||||
|
||||
task->result = NULL; // just to be sure
|
||||
@@ -548,8 +580,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
const char *firewall_name = "qemu-server.fw";
|
||||
|
||||
if (backup_state.di_list) {
|
||||
- error_set(task->errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
+ error_set(task->errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
"previous backup not finished");
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -616,6 +649,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
di->size = size;
|
||||
total += size;
|
||||
+
|
||||
+ di->completed_ret = INT_MAX;
|
||||
}
|
||||
|
||||
uuid_generate(uuid);
|
||||
@@ -847,6 +882,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
backup_state.stat.dirty = total - backup_state.stat.reused;
|
||||
backup_state.stat.transferred = 0;
|
||||
backup_state.stat.zero_bytes = 0;
|
||||
+ backup_state.stat.finishing = false;
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
@@ -861,6 +897,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
uuid_info->UUID = uuid_str;
|
||||
|
||||
task->result = uuid_info;
|
||||
+
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
return;
|
||||
|
||||
err_mutex:
|
||||
@@ -903,6 +941,8 @@ err:
|
||||
}
|
||||
|
||||
task->result = NULL;
|
||||
+
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -956,22 +996,15 @@ UuidInfo *qmp_backup(
|
||||
.errp = errp,
|
||||
};
|
||||
|
||||
- qemu_mutex_lock(&backup_state.backup_mutex);
|
||||
-
|
||||
block_on_coroutine_fn(pvebackup_co_prepare, &task);
|
||||
|
||||
if (*errp == NULL) {
|
||||
bool errors = create_backup_jobs();
|
||||
- qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
|
||||
if (!errors) {
|
||||
- /* start the first job in the transaction
|
||||
- * note: this might directly enter the job, so we need to do this
|
||||
- * after unlocking the backup_mutex */
|
||||
+ // start the first job in the transaction
|
||||
job_txn_start_seq(backup_state.txn);
|
||||
}
|
||||
- } else {
|
||||
- qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
}
|
||||
|
||||
return task.result;
|
||||
@@ -1025,6 +1058,7 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
info->transferred = backup_state.stat.transferred;
|
||||
info->has_reused = true;
|
||||
info->reused = backup_state.stat.reused;
|
||||
+ info->finishing = backup_state.stat.finishing;
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 03fc0af99b..29650896e2 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -784,12 +784,15 @@
|
||||
#
|
||||
# @uuid: uuid for this backup job
|
||||
#
|
||||
+# @finishing: if status='active' and finishing=true, then the backup process is
|
||||
+# waiting for the target to finish.
|
||||
+#
|
||||
##
|
||||
{ 'struct': 'BackupStatus',
|
||||
'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' } }
|
||||
+ '*backup-file': 'str', '*uuid': 'str', 'finishing': 'bool' } }
|
||||
|
||||
##
|
||||
# @BackupFormat:
|
95
debian/patches/pve/0052-PVE-backup-factor-out-helper-to-initialize-backup-st.patch
vendored
Normal file
95
debian/patches/pve/0052-PVE-backup-factor-out-helper-to-initialize-backup-st.patch
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 3 Apr 2025 14:30:43 +0200
|
||||
Subject: [PATCH] PVE backup: factor out helper to initialize backup state stat
|
||||
struct
|
||||
|
||||
Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 62 ++++++++++++++++++++++++++++++++--------------------
|
||||
1 file changed, 38 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 588ee98ffc..3be9930ad3 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -828,6 +828,43 @@ static void clear_backup_state_bitmap_list(void) {
|
||||
}
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Initializes most of the backup state 'stat' struct. Note that 'reused' and
|
||||
+ * 'bitmap_list' are not changed by this function and need to be handled by
|
||||
+ * the caller. In particular, 'reused' needs to be set before calling this
|
||||
+ * function.
|
||||
+ *
|
||||
+ * To be called with the backup_state.stat mutex held.
|
||||
+ */
|
||||
+static void initialize_backup_state_stat(
|
||||
+ const char *backup_file,
|
||||
+ uuid_t uuid,
|
||||
+ size_t total)
|
||||
+{
|
||||
+ if (backup_state.stat.error) {
|
||||
+ error_free(backup_state.stat.error);
|
||||
+ backup_state.stat.error = NULL;
|
||||
+ }
|
||||
+
|
||||
+ backup_state.stat.start_time = time(NULL);
|
||||
+ backup_state.stat.end_time = 0;
|
||||
+
|
||||
+ if (backup_state.stat.backup_file) {
|
||||
+ g_free(backup_state.stat.backup_file);
|
||||
+ }
|
||||
+ backup_state.stat.backup_file = g_strdup(backup_file);
|
||||
+
|
||||
+ uuid_copy(backup_state.stat.uuid, uuid);
|
||||
+ uuid_unparse_lower(uuid, backup_state.stat.uuid_str);
|
||||
+
|
||||
+ backup_state.stat.total = total;
|
||||
+ backup_state.stat.dirty = total - backup_state.stat.reused;
|
||||
+ backup_state.stat.transferred = 0;
|
||||
+ backup_state.stat.zero_bytes = 0;
|
||||
+ backup_state.stat.finishing = false;
|
||||
+ backup_state.stat.starting = true;
|
||||
+}
|
||||
+
|
||||
UuidInfo coroutine_fn *qmp_backup(
|
||||
const char *backup_file,
|
||||
const char *password,
|
||||
@@ -1070,32 +1107,9 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
}
|
||||
}
|
||||
/* initialize global backup_state now */
|
||||
- /* note: 'reused' and 'bitmap_list' are initialized earlier */
|
||||
-
|
||||
- if (backup_state.stat.error) {
|
||||
- error_free(backup_state.stat.error);
|
||||
- backup_state.stat.error = NULL;
|
||||
- }
|
||||
-
|
||||
- backup_state.stat.start_time = time(NULL);
|
||||
- backup_state.stat.end_time = 0;
|
||||
-
|
||||
- if (backup_state.stat.backup_file) {
|
||||
- g_free(backup_state.stat.backup_file);
|
||||
- }
|
||||
- backup_state.stat.backup_file = g_strdup(backup_file);
|
||||
-
|
||||
- uuid_copy(backup_state.stat.uuid, uuid);
|
||||
- uuid_unparse_lower(uuid, backup_state.stat.uuid_str);
|
||||
+ initialize_backup_state_stat(backup_file, uuid, total);
|
||||
char *uuid_str = g_strdup(backup_state.stat.uuid_str);
|
||||
|
||||
- backup_state.stat.total = total;
|
||||
- backup_state.stat.dirty = total - backup_state.stat.reused;
|
||||
- backup_state.stat.transferred = 0;
|
||||
- backup_state.stat.zero_bytes = 0;
|
||||
- backup_state.stat.finishing = false;
|
||||
- backup_state.stat.starting = true;
|
||||
-
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
backup_state.speed = (has_speed && speed > 0) ? speed : 0;
|
63
debian/patches/pve/0053-PVE-backup-add-target-ID-in-backup-state.patch
vendored
Normal file
63
debian/patches/pve/0053-PVE-backup-add-target-ID-in-backup-state.patch
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 3 Apr 2025 14:30:44 +0200
|
||||
Subject: [PATCH] PVE backup: add target ID in backup state
|
||||
|
||||
In preparation for allowing multiple backup providers and potentially
|
||||
multiple targets for a given provider. Each backup target can then
|
||||
have its own dirty bitmap and there can be additional checks that the
|
||||
current backup state is actually associated to the expected target.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 15 ++++++++++++++-
|
||||
1 file changed, 14 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 3be9930ad3..87778f7e76 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -70,6 +70,7 @@ static struct PVEBackupState {
|
||||
JobTxn *txn;
|
||||
CoMutex backup_mutex;
|
||||
CoMutex dump_callback_mutex;
|
||||
+ char *target_id;
|
||||
} backup_state;
|
||||
|
||||
static void pvebackup_init(void)
|
||||
@@ -865,6 +866,16 @@ static void initialize_backup_state_stat(
|
||||
backup_state.stat.starting = true;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * To be called with the backup_state mutex held.
|
||||
+ */
|
||||
+static void backup_state_set_target_id(const char *target_id) {
|
||||
+ if (backup_state.target_id) {
|
||||
+ g_free(backup_state.target_id);
|
||||
+ }
|
||||
+ backup_state.target_id = g_strdup(target_id);
|
||||
+}
|
||||
+
|
||||
UuidInfo coroutine_fn *qmp_backup(
|
||||
const char *backup_file,
|
||||
const char *password,
|
||||
@@ -904,7 +915,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
|
||||
if (backup_state.di_list) {
|
||||
error_set(errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
- "previous backup not finished");
|
||||
+ "previous backup for target '%s' not finished", backup_state.target_id);
|
||||
qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1122,6 +1133,8 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
backup_state.vmaw = vmaw;
|
||||
backup_state.pbs = pbs;
|
||||
|
||||
+ backup_state_set_target_id("Proxmox");
|
||||
+
|
||||
backup_state.di_list = di_list;
|
||||
|
||||
uuid_info = g_malloc0(sizeof(*uuid_info));
|
@@ -1,187 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Thu, 22 Oct 2020 17:01:07 +0200
|
||||
Subject: [PATCH] PVE: fix and clean up error handling for create_backup_jobs
|
||||
|
||||
No more weird bool returns, just the standard "errp" format used
|
||||
everywhere else too. With this, if backup_job_create fails, the error
|
||||
message is actually returned over QMP and can be shown to the user.
|
||||
|
||||
To facilitate correct cleanup on such an error, we call
|
||||
create_backup_jobs as a bottom half directly from pvebackup_co_prepare.
|
||||
This additionally allows us to actually hold the backup_mutex during
|
||||
operation.
|
||||
|
||||
Also add a job_cancel_sync before job_unref, since a job must be in
|
||||
STATUS_NULL to be deleted by unref, which could trigger an assert
|
||||
before.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 79 +++++++++++++++++++++++++++++++++++-----------------
|
||||
1 file changed, 54 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 4402c0cb17..c7cde0fb0e 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -50,6 +50,7 @@ static struct PVEBackupState {
|
||||
size_t zero_bytes;
|
||||
GList *bitmap_list;
|
||||
bool finishing;
|
||||
+ bool starting;
|
||||
} stat;
|
||||
int64_t speed;
|
||||
VmaWriter *vmaw;
|
||||
@@ -277,6 +278,16 @@ static void coroutine_fn pvebackup_co_complete_stream(void *opaque)
|
||||
PVEBackupDevInfo *di = opaque;
|
||||
int ret = di->completed_ret;
|
||||
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+ bool starting = backup_state.stat.starting;
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+ if (starting) {
|
||||
+ /* in 'starting' state, no tasks have been run yet, meaning we can (and
|
||||
+ * must) skip all cleanup, as we don't know what has and hasn't been
|
||||
+ * initialized yet. */
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
|
||||
if (ret < 0) {
|
||||
@@ -441,15 +452,15 @@ static int coroutine_fn pvebackup_co_add_config(
|
||||
/*
|
||||
* backup_job_create can *not* be run from a coroutine (and requires an
|
||||
* acquired AioContext), so this can't either.
|
||||
- * This does imply that this function cannot run with backup_mutex acquired.
|
||||
- * That is ok because it is only ever called between setting up the backup_state
|
||||
- * struct and starting the jobs, and from within a QMP call. This means that no
|
||||
- * other QMP call can interrupt, and no background job is running yet.
|
||||
+ * The caller is responsible that backup_mutex is held nonetheless.
|
||||
*/
|
||||
-static bool create_backup_jobs(void) {
|
||||
+static void create_backup_jobs_bh(void *opaque) {
|
||||
|
||||
assert(!qemu_in_coroutine());
|
||||
|
||||
+ CoCtxData *data = (CoCtxData*)opaque;
|
||||
+ Error **errp = (Error**)data->data;
|
||||
+
|
||||
Error *local_err = NULL;
|
||||
|
||||
/* create job transaction to synchronize bitmap commit and cancel all
|
||||
@@ -483,24 +494,19 @@ static bool create_backup_jobs(void) {
|
||||
|
||||
aio_context_release(aio_context);
|
||||
|
||||
- if (!job || local_err != NULL) {
|
||||
- Error *create_job_err = NULL;
|
||||
- error_setg(&create_job_err, "backup_job_create failed: %s",
|
||||
- local_err ? error_get_pretty(local_err) : "null");
|
||||
+ di->job = job;
|
||||
|
||||
- pvebackup_propagate_error(create_job_err);
|
||||
+ if (!job || local_err) {
|
||||
+ error_setg(errp, "backup_job_create failed: %s",
|
||||
+ local_err ? error_get_pretty(local_err) : "null");
|
||||
break;
|
||||
}
|
||||
|
||||
- di->job = job;
|
||||
-
|
||||
bdrv_unref(di->target);
|
||||
di->target = NULL;
|
||||
}
|
||||
|
||||
- bool errors = pvebackup_error_or_canceled();
|
||||
-
|
||||
- if (errors) {
|
||||
+ if (*errp) {
|
||||
l = backup_state.di_list;
|
||||
while (l) {
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
@@ -512,12 +518,17 @@ static bool create_backup_jobs(void) {
|
||||
}
|
||||
|
||||
if (di->job) {
|
||||
+ AioContext *ctx = di->job->job.aio_context;
|
||||
+ aio_context_acquire(ctx);
|
||||
+ job_cancel_sync(&di->job->job);
|
||||
job_unref(&di->job->job);
|
||||
+ aio_context_release(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- return errors;
|
||||
+ /* return */
|
||||
+ aio_co_enter(data->ctx, data->co);
|
||||
}
|
||||
|
||||
typedef struct QmpBackupTask {
|
||||
@@ -883,6 +894,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
backup_state.stat.transferred = 0;
|
||||
backup_state.stat.zero_bytes = 0;
|
||||
backup_state.stat.finishing = false;
|
||||
+ backup_state.stat.starting = true;
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
@@ -898,7 +910,32 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
|
||||
task->result = uuid_info;
|
||||
|
||||
+ /* Run create_backup_jobs_bh outside of coroutine (in BH) but keep
|
||||
+ * backup_mutex locked. This is fine, a CoMutex can be held across yield
|
||||
+ * points, and we'll release it as soon as the BH reschedules us.
|
||||
+ */
|
||||
+ CoCtxData waker = {
|
||||
+ .co = qemu_coroutine_self(),
|
||||
+ .ctx = qemu_get_current_aio_context(),
|
||||
+ .data = &local_err,
|
||||
+ };
|
||||
+ aio_bh_schedule_oneshot(waker.ctx, create_backup_jobs_bh, &waker);
|
||||
+ qemu_coroutine_yield();
|
||||
+
|
||||
+ if (local_err) {
|
||||
+ error_propagate(task->errp, local_err);
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+ backup_state.stat.starting = false;
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+
|
||||
+ /* start the first job in the transaction */
|
||||
+ job_txn_start_seq(backup_state.txn);
|
||||
+
|
||||
return;
|
||||
|
||||
err_mutex:
|
||||
@@ -921,6 +958,7 @@ err:
|
||||
g_free(di);
|
||||
}
|
||||
g_list_free(di_list);
|
||||
+ backup_state.di_list = NULL;
|
||||
|
||||
if (devs) {
|
||||
g_strfreev(devs);
|
||||
@@ -998,15 +1036,6 @@ UuidInfo *qmp_backup(
|
||||
|
||||
block_on_coroutine_fn(pvebackup_co_prepare, &task);
|
||||
|
||||
- if (*errp == NULL) {
|
||||
- bool errors = create_backup_jobs();
|
||||
-
|
||||
- if (!errors) {
|
||||
- // start the first job in the transaction
|
||||
- job_txn_start_seq(backup_state.txn);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
return task.result;
|
||||
}
|
||||
|
57
debian/patches/pve/0054-PVE-backup-get-device-info-allow-caller-to-specify-f.patch
vendored
Normal file
57
debian/patches/pve/0054-PVE-backup-get-device-info-allow-caller-to-specify-f.patch
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 3 Apr 2025 14:30:45 +0200
|
||||
Subject: [PATCH] PVE backup: get device info: allow caller to specify filter
|
||||
for which devices use fleecing
|
||||
|
||||
For providing snapshot-access to external backup providers, EFI and
|
||||
TPM also need an associated fleecing image. The new caller will thus
|
||||
need a different filter.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 9 +++++----
|
||||
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 87778f7e76..bd81621d51 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -719,7 +719,7 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
/*
|
||||
* EFI disk and TPM state are small and it's just not worth setting up fleecing for them.
|
||||
*/
|
||||
-static bool device_uses_fleecing(const char *device_id)
|
||||
+static bool fleecing_no_efi_tpm(const char *device_id)
|
||||
{
|
||||
return strncmp(device_id, "drive-efidisk", 13) && strncmp(device_id, "drive-tpmstate", 14);
|
||||
}
|
||||
@@ -731,7 +731,7 @@ static bool device_uses_fleecing(const char *device_id)
|
||||
*/
|
||||
static GList coroutine_fn GRAPH_RDLOCK *get_device_info(
|
||||
const char *devlist,
|
||||
- bool fleecing,
|
||||
+ bool (*device_uses_fleecing)(const char*),
|
||||
Error **errp)
|
||||
{
|
||||
gchar **devs = NULL;
|
||||
@@ -757,7 +757,7 @@ static GList coroutine_fn GRAPH_RDLOCK *get_device_info(
|
||||
di->bs = bs;
|
||||
di->device_name = g_strdup(bdrv_get_device_name(bs));
|
||||
|
||||
- if (fleecing && device_uses_fleecing(*d)) {
|
||||
+ if (device_uses_fleecing && device_uses_fleecing(*d)) {
|
||||
g_autofree gchar *fleecing_devid = g_strconcat(*d, "-fleecing", NULL);
|
||||
BlockBackend *fleecing_blk = blk_by_name(fleecing_devid);
|
||||
if (!fleecing_blk) {
|
||||
@@ -924,7 +924,8 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
format = has_format ? format : BACKUP_FORMAT_VMA;
|
||||
|
||||
bdrv_graph_co_rdlock();
|
||||
- di_list = get_device_info(devlist, has_fleecing && fleecing, &local_err);
|
||||
+ di_list = get_device_info(devlist, (has_fleecing && fleecing) ? fleecing_no_efi_tpm : NULL,
|
||||
+ &local_err);
|
||||
bdrv_graph_co_rdunlock();
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
@@ -1,33 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Thu, 22 Oct 2020 17:34:17 +0200
|
||||
Subject: [PATCH] migration/block-dirty-bitmap: fix larger granularity bitmaps
|
||||
|
||||
sectors_per_chunk is a 64 bit integer, but the calculation would be done
|
||||
in 32 bits, leading to an overflow for coarse bitmap granularities.
|
||||
|
||||
If that results in the value 0, it leads to a hang where no progress is
|
||||
made but send_bitmap_bits is constantly called with nr_sectors being 0.
|
||||
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
||||
Reviewed-by: Eric Blake <eblake@redhat.com>
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
migration/block-dirty-bitmap.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
|
||||
index 784330ebe1..5bf0d9fbc6 100644
|
||||
--- a/migration/block-dirty-bitmap.c
|
||||
+++ b/migration/block-dirty-bitmap.c
|
||||
@@ -334,8 +334,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
|
||||
dbms->node_name = bs_name;
|
||||
dbms->bitmap = bitmap;
|
||||
dbms->total_sectors = bdrv_nb_sectors(bs);
|
||||
- dbms->sectors_per_chunk = CHUNK_SIZE * 8 *
|
||||
+ dbms->sectors_per_chunk = CHUNK_SIZE * 8LLU *
|
||||
bdrv_dirty_bitmap_granularity(bitmap) >> BDRV_SECTOR_BITS;
|
||||
+ assert(dbms->sectors_per_chunk != 0);
|
||||
if (bdrv_dirty_bitmap_enabled(bitmap)) {
|
||||
dbms->flags |= DIRTY_BITMAP_MIG_START_FLAG_ENABLED;
|
||||
}
|
898
debian/patches/pve/0055-PVE-backup-implement-backup-access-setup-and-teardow.patch
vendored
Normal file
898
debian/patches/pve/0055-PVE-backup-implement-backup-access-setup-and-teardow.patch
vendored
Normal file
@@ -0,0 +1,898 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 3 Apr 2025 14:30:46 +0200
|
||||
Subject: [PATCH] PVE backup: implement backup access setup and teardown API
|
||||
for external providers
|
||||
|
||||
For external backup providers, the state of the VM's disk images at
|
||||
the time the backup is started is preserved via a snapshot-access
|
||||
block node. Old data is moved to the fleecing image when new guest
|
||||
writes come in. The snapshot-access block node, as well as the
|
||||
associated bitmap in case of incremental backup, will be exported via
|
||||
NBD to the external provider. The NBD export will be done by the
|
||||
management layer, the missing functionality is setting up and tearing
|
||||
down the snapshot-access block nodes, which this patch adds.
|
||||
|
||||
It is necessary to also set up fleecing for EFI and TPM disks, so that
|
||||
old data can be moved out of the way when a new guest write comes in.
|
||||
|
||||
There can only be one regular backup or one active backup access at
|
||||
a time, because both require replacing the original block node of the
|
||||
drive. Thus the backup state is re-used, and checks are added to
|
||||
prohibit regular backup while snapshot access is active and vice
|
||||
versa.
|
||||
|
||||
The block nodes added by the backup-access-setup QMP call are not
|
||||
tracked anywhere else (there is no job they are associated to like for
|
||||
regular backup). This requires adding a callback for teardown when
|
||||
QEMU exits, i.e. in qemu_cleanup(). Otherwise, there will be an
|
||||
assertion failure that the block graph is not empty when QEMU exits
|
||||
before the backup-access-teardown QMP command is called.
|
||||
|
||||
The code for the qmp_backup_access_setup() was based on the existing
|
||||
qmp_backup() routine.
|
||||
|
||||
The return value for the setup QMP command contains information about
|
||||
the snapshot-access block nodes that can be used by the management
|
||||
layer to set up the NBD exports.
|
||||
|
||||
There can be one dirty bitmap for each backup target ID for each
|
||||
device (which are tracked in the backup_access_bitmaps hash table).
|
||||
The QMP user can specify the ID of the bitmap it likes to use. This ID
|
||||
is then compared to the current one for the given target and device.
|
||||
If they match, the bitmap is re-used (should it still exist on the
|
||||
drive, otherwise re-created). If there is a mismatch, the old bitmap
|
||||
is removed and a new one is created.
|
||||
|
||||
The return value of the QMP command includes information about what
|
||||
bitmap action was taken. Similar to what the query-backup QMP command
|
||||
returns for regular backup. It also includes the bitmap name and
|
||||
associated block node, so the management layer can then set up an NBD
|
||||
export with the bitmap.
|
||||
|
||||
While the backup access is active, a background bitmap is also
|
||||
required. This is necessary to implement bitmap handling according to
|
||||
the original reference [0]. In particular:
|
||||
|
||||
- in the error case, new writes since the backup access was set up are
|
||||
in the background bitmap. Because of failure, the previously tracked
|
||||
writes from the backup access bitmap are still required too. Thus,
|
||||
the bitmap is merged with the background bitmap to get all new
|
||||
writes since the last backup.
|
||||
|
||||
- in the success case, continue tracking for the next incremental
|
||||
backup in the backup access bitmap. New writes since the backup
|
||||
access was set up are in the background bitmap. Because the backup
|
||||
was successfully, clear the backup access bitmap and merge back the
|
||||
background bitmap to get only the new writes.
|
||||
|
||||
Since QEMU cannot know if the backup was successful or not (except if
|
||||
failure already happens during the setup QMP command), the management
|
||||
layer needs to tell it via the teardown QMP command.
|
||||
|
||||
The bitmap action is also recorded in the device info now.
|
||||
|
||||
The backup-access api keeps track of what bitmap names got used for
|
||||
which devices and thus knows when a bitmap went missing. Propagate
|
||||
this information to the QMP user with a new 'missing-recreated'
|
||||
variant for the taken bitmap action.
|
||||
|
||||
[0]: https://lore.kernel.org/qemu-devel/b68833dd-8864-4d72-7c61-c134a9835036@ya.ru/
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 519 +++++++++++++++++++++++++++++++++++++++----
|
||||
pve-backup.h | 16 ++
|
||||
qapi/block-core.json | 99 ++++++++-
|
||||
system/runstate.c | 6 +
|
||||
4 files changed, 596 insertions(+), 44 deletions(-)
|
||||
create mode 100644 pve-backup.h
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index bd81621d51..0450303017 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "proxmox-backup-client.h"
|
||||
+#include "pve-backup.h"
|
||||
#include "vma.h"
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
@@ -14,6 +15,7 @@
|
||||
#include "qobject/qdict.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qemu/cutils.h"
|
||||
+#include "qemu/error-report.h"
|
||||
|
||||
#if defined(CONFIG_MALLOC_TRIM)
|
||||
#include <malloc.h>
|
||||
@@ -40,6 +42,7 @@
|
||||
*/
|
||||
|
||||
const char *PBS_BITMAP_NAME = "pbs-incremental-dirty-bitmap";
|
||||
+const char *BACKGROUND_BITMAP_NAME = "backup-access-background-bitmap";
|
||||
|
||||
static struct PVEBackupState {
|
||||
struct {
|
||||
@@ -98,8 +101,11 @@ typedef struct PVEBackupDevInfo {
|
||||
char* device_name;
|
||||
int completed_ret; // INT_MAX if not completed
|
||||
BdrvDirtyBitmap *bitmap;
|
||||
+ BdrvDirtyBitmap *background_bitmap; // used for external backup access
|
||||
+ PBSBitmapAction bitmap_action;
|
||||
BlockDriverState *target;
|
||||
BlockJob *job;
|
||||
+ BackupAccessSetupBitmapMode requested_bitmap_mode;
|
||||
} PVEBackupDevInfo;
|
||||
|
||||
static void pvebackup_propagate_error(Error *err)
|
||||
@@ -361,6 +367,67 @@ static void coroutine_fn pvebackup_co_complete_stream(void *opaque)
|
||||
qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * New writes since the backup access was set up are in the background bitmap. Because of failure,
|
||||
+ * the previously tracked writes in di->bitmap are still required too. Thus, merge with the
|
||||
+ * background bitmap to get all new writes since the last backup.
|
||||
+ */
|
||||
+static void handle_backup_access_bitmaps_in_error_case(PVEBackupDevInfo *di)
|
||||
+{
|
||||
+ Error *local_err = NULL;
|
||||
+
|
||||
+ if (di->bs && di->background_bitmap) {
|
||||
+ bdrv_drained_begin(di->bs);
|
||||
+ if (di->bitmap) {
|
||||
+ bdrv_enable_dirty_bitmap(di->bitmap);
|
||||
+ if (!bdrv_merge_dirty_bitmap(di->bitmap, di->background_bitmap, NULL, &local_err)) {
|
||||
+ warn_report("backup access: %s - could not merge bitmaps in error path - %s",
|
||||
+ di->device_name,
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ /*
|
||||
+ * Could not merge, drop original bitmap too.
|
||||
+ */
|
||||
+ bdrv_release_dirty_bitmap(di->bitmap);
|
||||
+ }
|
||||
+ } else {
|
||||
+ warn_report("backup access: %s - expected bitmap not present", di->device_name);
|
||||
+ }
|
||||
+ bdrv_release_dirty_bitmap(di->background_bitmap);
|
||||
+ bdrv_drained_end(di->bs);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Continue tracking for next incremental backup in di->bitmap. New writes since the backup access
|
||||
+ * was set up are in the background bitmap. Because the backup was successful, clear di->bitmap and
|
||||
+ * merge back the background bitmap to get only the new writes.
|
||||
+ */
|
||||
+static void handle_backup_access_bitmaps_after_success(PVEBackupDevInfo *di)
|
||||
+{
|
||||
+ Error *local_err = NULL;
|
||||
+
|
||||
+ if (di->bs && di->background_bitmap) {
|
||||
+ bdrv_drained_begin(di->bs);
|
||||
+ if (di->bitmap) {
|
||||
+ bdrv_enable_dirty_bitmap(di->bitmap);
|
||||
+ bdrv_clear_dirty_bitmap(di->bitmap, NULL);
|
||||
+ if (!bdrv_merge_dirty_bitmap(di->bitmap, di->background_bitmap, NULL, &local_err)) {
|
||||
+ warn_report("backup access: %s - could not merge bitmaps after backup - %s",
|
||||
+ di->device_name,
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ /*
|
||||
+ * Could not merge, drop original bitmap too.
|
||||
+ */
|
||||
+ bdrv_release_dirty_bitmap(di->bitmap);
|
||||
+ }
|
||||
+ } else {
|
||||
+ warn_report("backup access: %s - expected bitmap not present", di->device_name);
|
||||
+ }
|
||||
+ bdrv_release_dirty_bitmap(di->background_bitmap);
|
||||
+ bdrv_drained_end(di->bs);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void cleanup_snapshot_access(PVEBackupDevInfo *di)
|
||||
{
|
||||
if (di->fleecing.snapshot_access) {
|
||||
@@ -588,6 +655,51 @@ static int setup_snapshot_access(PVEBackupDevInfo *di, Error **errp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void setup_all_snapshot_access_bh(void *opaque)
|
||||
+{
|
||||
+ assert(!qemu_in_coroutine());
|
||||
+
|
||||
+ CoCtxData *data = (CoCtxData*)opaque;
|
||||
+ Error **errp = (Error**)data->data;
|
||||
+
|
||||
+ Error *local_err = NULL;
|
||||
+
|
||||
+ GList *l = backup_state.di_list;
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ bdrv_drained_begin(di->bs);
|
||||
+
|
||||
+ if (di->bitmap) {
|
||||
+ BdrvDirtyBitmap *background_bitmap =
|
||||
+ bdrv_create_dirty_bitmap(di->bs, PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE,
|
||||
+ BACKGROUND_BITMAP_NAME, &local_err);
|
||||
+ if (!background_bitmap) {
|
||||
+ error_setg(errp, "%s - creating background bitmap for backup access failed: %s",
|
||||
+ di->device_name,
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ bdrv_drained_end(di->bs);
|
||||
+ break;
|
||||
+ }
|
||||
+ di->background_bitmap = background_bitmap;
|
||||
+ bdrv_disable_dirty_bitmap(di->bitmap);
|
||||
+ }
|
||||
+
|
||||
+ if (setup_snapshot_access(di, &local_err) < 0) {
|
||||
+ bdrv_drained_end(di->bs);
|
||||
+ error_setg(errp, "%s - setting up snapshot access failed: %s", di->device_name,
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ bdrv_drained_end(di->bs);
|
||||
+ }
|
||||
+
|
||||
+ /* return */
|
||||
+ aio_co_enter(data->ctx, data->co);
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* backup_job_create can *not* be run from a coroutine, so this can't either.
|
||||
* The caller is responsible that backup_mutex is held nonetheless.
|
||||
@@ -724,6 +836,62 @@ static bool fleecing_no_efi_tpm(const char *device_id)
|
||||
return strncmp(device_id, "drive-efidisk", 13) && strncmp(device_id, "drive-tpmstate", 14);
|
||||
}
|
||||
|
||||
+static bool fleecing_all(const char *device_id)
|
||||
+{
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+static PVEBackupDevInfo coroutine_fn GRAPH_RDLOCK *get_single_device_info(
|
||||
+ const char *device,
|
||||
+ bool (*device_uses_fleecing)(const char*),
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ BlockBackend *blk = blk_by_name(device);
|
||||
+ if (!blk) {
|
||||
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
+ "Device '%s' not found", device);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ BlockDriverState *bs = blk_bs(blk);
|
||||
+ if (!bdrv_co_is_inserted(bs)) {
|
||||
+ error_setg(errp, "Device '%s' has no medium", device);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
+ di->bs = bs;
|
||||
+ di->device_name = g_strdup(bdrv_get_device_name(bs));
|
||||
+
|
||||
+ if (device_uses_fleecing && device_uses_fleecing(device)) {
|
||||
+ g_autofree gchar *fleecing_devid = g_strconcat(device, "-fleecing", NULL);
|
||||
+ BlockBackend *fleecing_blk = blk_by_name(fleecing_devid);
|
||||
+ if (!fleecing_blk) {
|
||||
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
+ "Device '%s' not found", fleecing_devid);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+ BlockDriverState *fleecing_bs = blk_bs(fleecing_blk);
|
||||
+ if (!bdrv_co_is_inserted(fleecing_bs)) {
|
||||
+ error_setg(errp, "Device '%s' has no medium", fleecing_devid);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+ /*
|
||||
+ * Fleecing image needs to be the same size to act as a cbw target.
|
||||
+ */
|
||||
+ if (bs->total_sectors != fleecing_bs->total_sectors) {
|
||||
+ error_setg(errp, "Size mismatch for '%s' - sector count %ld != %ld",
|
||||
+ fleecing_devid, fleecing_bs->total_sectors, bs->total_sectors);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+ di->fleecing.bs = fleecing_bs;
|
||||
+ }
|
||||
+
|
||||
+ return di;
|
||||
+fail:
|
||||
+ g_free(di->device_name);
|
||||
+ g_free(di);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Returns a list of device infos, which needs to be freed by the caller. In
|
||||
* case of an error, errp will be set, but the returned value might still be a
|
||||
@@ -742,45 +910,10 @@ static GList coroutine_fn GRAPH_RDLOCK *get_device_info(
|
||||
|
||||
gchar **d = devs;
|
||||
while (d && *d) {
|
||||
- BlockBackend *blk = blk_by_name(*d);
|
||||
- if (!blk) {
|
||||
- error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
- "Device '%s' not found", *d);
|
||||
- goto err;
|
||||
- }
|
||||
- BlockDriverState *bs = blk_bs(blk);
|
||||
- if (!bdrv_co_is_inserted(bs)) {
|
||||
- error_setg(errp, "Device '%s' has no medium", *d);
|
||||
+ PVEBackupDevInfo *di = get_single_device_info(*d, device_uses_fleecing, errp);
|
||||
+ if (!di) {
|
||||
goto err;
|
||||
}
|
||||
- PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
- di->bs = bs;
|
||||
- di->device_name = g_strdup(bdrv_get_device_name(bs));
|
||||
-
|
||||
- if (device_uses_fleecing && device_uses_fleecing(*d)) {
|
||||
- g_autofree gchar *fleecing_devid = g_strconcat(*d, "-fleecing", NULL);
|
||||
- BlockBackend *fleecing_blk = blk_by_name(fleecing_devid);
|
||||
- if (!fleecing_blk) {
|
||||
- error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
- "Device '%s' not found", fleecing_devid);
|
||||
- goto err;
|
||||
- }
|
||||
- BlockDriverState *fleecing_bs = blk_bs(fleecing_blk);
|
||||
- if (!bdrv_co_is_inserted(fleecing_bs)) {
|
||||
- error_setg(errp, "Device '%s' has no medium", fleecing_devid);
|
||||
- goto err;
|
||||
- }
|
||||
- /*
|
||||
- * Fleecing image needs to be the same size to act as a cbw target.
|
||||
- */
|
||||
- if (bs->total_sectors != fleecing_bs->total_sectors) {
|
||||
- error_setg(errp, "Size mismatch for '%s' - sector count %ld != %ld",
|
||||
- fleecing_devid, fleecing_bs->total_sectors, bs->total_sectors);
|
||||
- goto err;
|
||||
- }
|
||||
- di->fleecing.bs = fleecing_bs;
|
||||
- }
|
||||
-
|
||||
di_list = g_list_append(di_list, di);
|
||||
d++;
|
||||
}
|
||||
@@ -839,8 +972,9 @@ static void clear_backup_state_bitmap_list(void) {
|
||||
*/
|
||||
static void initialize_backup_state_stat(
|
||||
const char *backup_file,
|
||||
- uuid_t uuid,
|
||||
- size_t total)
|
||||
+ uuid_t *uuid,
|
||||
+ size_t total,
|
||||
+ bool starting)
|
||||
{
|
||||
if (backup_state.stat.error) {
|
||||
error_free(backup_state.stat.error);
|
||||
@@ -855,15 +989,19 @@ static void initialize_backup_state_stat(
|
||||
}
|
||||
backup_state.stat.backup_file = g_strdup(backup_file);
|
||||
|
||||
- uuid_copy(backup_state.stat.uuid, uuid);
|
||||
- uuid_unparse_lower(uuid, backup_state.stat.uuid_str);
|
||||
+ if (uuid) {
|
||||
+ uuid_copy(backup_state.stat.uuid, *uuid);
|
||||
+ uuid_unparse_lower(*uuid, backup_state.stat.uuid_str);
|
||||
+ } else {
|
||||
+ backup_state.stat.uuid_str[0] = '\0';
|
||||
+ }
|
||||
|
||||
backup_state.stat.total = total;
|
||||
backup_state.stat.dirty = total - backup_state.stat.reused;
|
||||
backup_state.stat.transferred = 0;
|
||||
backup_state.stat.zero_bytes = 0;
|
||||
backup_state.stat.finishing = false;
|
||||
- backup_state.stat.starting = true;
|
||||
+ backup_state.stat.starting = starting;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -876,6 +1014,299 @@ static void backup_state_set_target_id(const char *target_id) {
|
||||
backup_state.target_id = g_strdup(target_id);
|
||||
}
|
||||
|
||||
+BackupAccessInfoList *coroutine_fn qmp_backup_access_setup(
|
||||
+ const char *target_id,
|
||||
+ BackupAccessSourceDeviceList *devices,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ assert(qemu_in_coroutine());
|
||||
+
|
||||
+ qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
+
|
||||
+ Error *local_err = NULL;
|
||||
+ GList *di_list = NULL;
|
||||
+ GList *l;
|
||||
+
|
||||
+ if (backup_state.di_list) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
+ "previous backup for target '%s' not finished", backup_state.target_id);
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ for (BackupAccessSourceDeviceList *it = devices; it; it = it->next) {
|
||||
+ PVEBackupDevInfo *di = get_single_device_info(it->value->device, fleecing_all, &local_err);
|
||||
+ if (!di) {
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ error_propagate(errp, local_err);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ di->requested_bitmap_mode = it->value->bitmap_mode;
|
||||
+ di_list = g_list_append(di_list, di);
|
||||
+ }
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ assert(di_list);
|
||||
+
|
||||
+ size_t total = 0;
|
||||
+
|
||||
+ l = di_list;
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ ssize_t size = bdrv_getlength(di->bs);
|
||||
+ if (size < 0) {
|
||||
+ error_setg_errno(errp, -size, "bdrv_getlength failed");
|
||||
+ goto err;
|
||||
+ }
|
||||
+ di->size = size;
|
||||
+ total += size;
|
||||
+
|
||||
+ di->completed_ret = INT_MAX;
|
||||
+ }
|
||||
+
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+ backup_state.stat.reused = 0;
|
||||
+
|
||||
+ /* clear previous backup's bitmap_list */
|
||||
+ clear_backup_state_bitmap_list();
|
||||
+
|
||||
+ const char *bitmap_name = target_id;
|
||||
+
|
||||
+ /* create bitmaps if requested */
|
||||
+ l = di_list;
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ di->block_size = PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE;
|
||||
+
|
||||
+ PBSBitmapAction action = PBS_BITMAP_ACTION_NOT_USED;
|
||||
+ size_t dirty = di->size;
|
||||
+
|
||||
+ if (di->requested_bitmap_mode == BACKUP_ACCESS_SETUP_BITMAP_MODE_NONE ||
|
||||
+ di->requested_bitmap_mode == BACKUP_ACCESS_SETUP_BITMAP_MODE_NEW) {
|
||||
+ BdrvDirtyBitmap *old_bitmap = bdrv_find_dirty_bitmap(di->bs, bitmap_name);
|
||||
+ if (old_bitmap) {
|
||||
+ bdrv_release_dirty_bitmap(old_bitmap);
|
||||
+ action = PBS_BITMAP_ACTION_NOT_USED_REMOVED; // set below for new
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ BdrvDirtyBitmap *bitmap = NULL;
|
||||
+ if (di->requested_bitmap_mode == BACKUP_ACCESS_SETUP_BITMAP_MODE_NEW ||
|
||||
+ di->requested_bitmap_mode == BACKUP_ACCESS_SETUP_BITMAP_MODE_USE) {
|
||||
+ bitmap = bdrv_find_dirty_bitmap(di->bs, bitmap_name);
|
||||
+ if (!bitmap) {
|
||||
+ bitmap = bdrv_create_dirty_bitmap(di->bs, PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE,
|
||||
+ bitmap_name, errp);
|
||||
+ if (!bitmap) {
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ bdrv_set_dirty_bitmap(bitmap, 0, di->size);
|
||||
+ if (di->requested_bitmap_mode == BACKUP_ACCESS_SETUP_BITMAP_MODE_USE) {
|
||||
+ action = PBS_BITMAP_ACTION_MISSING_RECREATED;
|
||||
+ } else {
|
||||
+ action = PBS_BITMAP_ACTION_NEW;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (di->requested_bitmap_mode == BACKUP_ACCESS_SETUP_BITMAP_MODE_NEW) {
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+ error_setg(errp, "internal error - removed old bitmap still present");
|
||||
+ goto err;
|
||||
+ }
|
||||
+ /* track clean chunks as reused */
|
||||
+ dirty = MIN(bdrv_get_dirty_count(bitmap), di->size);
|
||||
+ backup_state.stat.reused += di->size - dirty;
|
||||
+ action = PBS_BITMAP_ACTION_USED;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ PBSBitmapInfo *info = g_malloc(sizeof(*info));
|
||||
+ info->drive = g_strdup(di->device_name);
|
||||
+ info->action = action;
|
||||
+ info->size = di->size;
|
||||
+ info->dirty = dirty;
|
||||
+ backup_state.stat.bitmap_list = g_list_append(backup_state.stat.bitmap_list, info);
|
||||
+
|
||||
+ di->bitmap = bitmap;
|
||||
+ di->bitmap_action = action;
|
||||
+ }
|
||||
+
|
||||
+ /* starting=false, because there is no associated QEMU job */
|
||||
+ initialize_backup_state_stat(NULL, NULL, total, false);
|
||||
+
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+
|
||||
+ backup_state_set_target_id(target_id);
|
||||
+
|
||||
+ backup_state.vmaw = NULL;
|
||||
+ backup_state.pbs = NULL;
|
||||
+
|
||||
+ backup_state.di_list = di_list;
|
||||
+
|
||||
+ /* Run setup_all_snapshot_access_bh outside of coroutine (in BH) but keep
|
||||
+ * backup_mutex locked. This is fine, a CoMutex can be held across yield
|
||||
+ * points, and we'll release it as soon as the BH reschedules us.
|
||||
+ */
|
||||
+ CoCtxData waker = {
|
||||
+ .co = qemu_coroutine_self(),
|
||||
+ .ctx = qemu_get_current_aio_context(),
|
||||
+ .data = &local_err,
|
||||
+ };
|
||||
+ aio_bh_schedule_oneshot(waker.ctx, setup_all_snapshot_access_bh, &waker);
|
||||
+ qemu_coroutine_yield();
|
||||
+
|
||||
+ if (local_err) {
|
||||
+ error_propagate(errp, local_err);
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+
|
||||
+ BackupAccessInfoList *bai_head = NULL, **p_bai_next = &bai_head;
|
||||
+
|
||||
+ l = di_list;
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ BackupAccessInfoList *info = g_malloc0(sizeof(*info));
|
||||
+ info->value = g_malloc0(sizeof(*info->value));
|
||||
+ info->value->node_name = g_strdup(bdrv_get_node_name(di->fleecing.snapshot_access));
|
||||
+ info->value->device = g_strdup(di->device_name);
|
||||
+ info->value->size = di->size;
|
||||
+ if (di->bitmap) {
|
||||
+ info->value->bitmap_node_name = g_strdup(bdrv_get_node_name(di->bs));
|
||||
+ info->value->bitmap_name = g_strdup(bitmap_name);
|
||||
+ info->value->bitmap_action = di->bitmap_action;
|
||||
+ info->value->has_bitmap_action = true;
|
||||
+ }
|
||||
+
|
||||
+ *p_bai_next = info;
|
||||
+ p_bai_next = &info->next;
|
||||
+ }
|
||||
+
|
||||
+ return bai_head;
|
||||
+
|
||||
+err:
|
||||
+
|
||||
+ l = di_list;
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ handle_backup_access_bitmaps_in_error_case(di);
|
||||
+
|
||||
+ g_free(di->device_name);
|
||||
+ di->device_name = NULL;
|
||||
+
|
||||
+ g_free(di);
|
||||
+ }
|
||||
+ g_list_free(di_list);
|
||||
+ backup_state.di_list = NULL;
|
||||
+
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Caller needs to hold the backup mutex or the BQL.
|
||||
+ */
|
||||
+void backup_access_teardown(bool success)
|
||||
+{
|
||||
+ GList *l = backup_state.di_list;
|
||||
+
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+ backup_state.stat.finishing = true;
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ if (di->fleecing.snapshot_access) {
|
||||
+ bdrv_unref(di->fleecing.snapshot_access);
|
||||
+ di->fleecing.snapshot_access = NULL;
|
||||
+ }
|
||||
+ if (di->fleecing.cbw) {
|
||||
+ bdrv_cbw_drop(di->fleecing.cbw);
|
||||
+ di->fleecing.cbw = NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (success) {
|
||||
+ handle_backup_access_bitmaps_after_success(di);
|
||||
+ } else {
|
||||
+ handle_backup_access_bitmaps_in_error_case(di);
|
||||
+ }
|
||||
+
|
||||
+ g_free(di->device_name);
|
||||
+ di->device_name = NULL;
|
||||
+
|
||||
+ g_free(di);
|
||||
+ }
|
||||
+ g_list_free(backup_state.di_list);
|
||||
+ backup_state.di_list = NULL;
|
||||
+
|
||||
+ qemu_mutex_lock(&backup_state.stat.lock);
|
||||
+ backup_state.stat.end_time = time(NULL);
|
||||
+ backup_state.stat.finishing = false;
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+}
|
||||
+
|
||||
+// Not done in a coroutine, because bdrv_co_unref() and cbw_drop() would just spawn BHs anyways.
|
||||
+// Caller needs to hold the backup_state.backup_mutex lock
|
||||
+static void backup_access_teardown_bh(void *opaque)
|
||||
+{
|
||||
+ CoCtxData *data = (CoCtxData*)opaque;
|
||||
+
|
||||
+ backup_access_teardown(*((bool*)data->data));
|
||||
+
|
||||
+ /* return */
|
||||
+ aio_co_enter(data->ctx, data->co);
|
||||
+}
|
||||
+
|
||||
+void coroutine_fn qmp_backup_access_teardown(const char *target_id, bool success, Error **errp)
|
||||
+{
|
||||
+ assert(qemu_in_coroutine());
|
||||
+
|
||||
+ qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
+
|
||||
+ if (!backup_state.target_id) { // nothing to do
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Continue with target_id == NULL, used by the callback registered for qemu_cleanup()
|
||||
+ */
|
||||
+ if (target_id && strcmp(backup_state.target_id, target_id)) {
|
||||
+ error_setg(errp, "cannot teardown backup access - got target %s instead of %s",
|
||||
+ target_id, backup_state.target_id);
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (!strcmp(backup_state.target_id, "Proxmox VE")) {
|
||||
+ error_setg(errp, "cannot teardown backup access for PVE - use backup-cancel instead");
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ CoCtxData waker = {
|
||||
+ .co = qemu_coroutine_self(),
|
||||
+ .ctx = qemu_get_current_aio_context(),
|
||||
+ .data = &success,
|
||||
+ };
|
||||
+ aio_bh_schedule_oneshot(waker.ctx, backup_access_teardown_bh, &waker);
|
||||
+ qemu_coroutine_yield();
|
||||
+
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
UuidInfo coroutine_fn *qmp_backup(
|
||||
const char *backup_file,
|
||||
const char *password,
|
||||
@@ -1068,6 +1499,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
}
|
||||
|
||||
di->dev_id = dev_id;
|
||||
+ di->bitmap_action = action;
|
||||
|
||||
PBSBitmapInfo *info = g_malloc(sizeof(*info));
|
||||
info->drive = g_strdup(di->device_name);
|
||||
@@ -1119,7 +1551,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
}
|
||||
}
|
||||
/* initialize global backup_state now */
|
||||
- initialize_backup_state_stat(backup_file, uuid, total);
|
||||
+ initialize_backup_state_stat(backup_file, &uuid, total, true);
|
||||
char *uuid_str = g_strdup(backup_state.stat.uuid_str);
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
@@ -1298,5 +1730,6 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
ret->pbs_masterkey = true;
|
||||
ret->backup_max_workers = true;
|
||||
ret->backup_fleecing = true;
|
||||
+ ret->backup_access_api = true;
|
||||
return ret;
|
||||
}
|
||||
diff --git a/pve-backup.h b/pve-backup.h
|
||||
new file mode 100644
|
||||
index 0000000000..9ebeef7c8f
|
||||
--- /dev/null
|
||||
+++ b/pve-backup.h
|
||||
@@ -0,0 +1,16 @@
|
||||
+/*
|
||||
+ * Bacup code used by Proxmox VE
|
||||
+ *
|
||||
+ * Copyright (C) Proxmox Server Solutions
|
||||
+ *
|
||||
+ * 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 PVE_BACKUP_H
|
||||
+#define PVE_BACKUP_H
|
||||
+
|
||||
+void backup_access_teardown(bool success);
|
||||
+
|
||||
+#endif /* PVE_BACKUP_H */
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 9bdcfa31ea..2fb51215f2 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -1023,6 +1023,9 @@
|
||||
#
|
||||
# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
|
||||
#
|
||||
+# @backup-access-api: Whether backup access API for external providers is
|
||||
+# supported or not.
|
||||
+#
|
||||
# @backup-fleecing: Whether backup fleecing is supported or not.
|
||||
#
|
||||
# @backup-max-workers: Whether the 'max-workers' @BackupPerf setting is
|
||||
@@ -1036,6 +1039,7 @@
|
||||
'pbs-dirty-bitmap-migration': 'bool',
|
||||
'pbs-masterkey': 'bool',
|
||||
'pbs-library-version': 'str',
|
||||
+ 'backup-access-api': 'bool',
|
||||
'backup-fleecing': 'bool',
|
||||
'backup-max-workers': 'bool' } }
|
||||
|
||||
@@ -1067,9 +1071,16 @@
|
||||
# base snapshot did not match the base given for the current job or
|
||||
# the crypt mode has changed.
|
||||
#
|
||||
+# @missing-recreated: A bitmap for incremental backup was expected to be
|
||||
+# present, but was missing and thus got recreated. For example, this can
|
||||
+# happen if the drive was re-attached or if the bitmap was deleted for some
|
||||
+# other reason. PBS does not currently keep track of this; the backup-access
|
||||
+# mechanism does.
|
||||
+#
|
||||
##
|
||||
{ 'enum': 'PBSBitmapAction',
|
||||
- 'data': ['not-used', 'not-used-removed', 'new', 'used', 'invalid'] }
|
||||
+ 'data': ['not-used', 'not-used-removed', 'new', 'used', 'invalid',
|
||||
+ 'missing-recreated'] }
|
||||
|
||||
##
|
||||
# @PBSBitmapInfo:
|
||||
@@ -1102,6 +1113,92 @@
|
||||
##
|
||||
{ 'command': 'query-pbs-bitmap-info', 'returns': ['PBSBitmapInfo'] }
|
||||
|
||||
+##
|
||||
+# @BackupAccessInfo:
|
||||
+#
|
||||
+# Info associated to a snapshot access for backup. For more information about
|
||||
+# the bitmap see @BackupAccessBitmapMode.
|
||||
+#
|
||||
+# @node-name: the block node name of the snapshot-access node.
|
||||
+#
|
||||
+# @device: the device on top of which the snapshot access was created.
|
||||
+#
|
||||
+# @size: the size of the block device in bytes.
|
||||
+#
|
||||
+# @bitmap-node-name: the block node name the dirty bitmap is associated to.
|
||||
+#
|
||||
+# @bitmap-name: the name of the dirty bitmap associated to the backup access.
|
||||
+#
|
||||
+# @bitmap-action: the action taken on the dirty bitmap.
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'BackupAccessInfo',
|
||||
+ 'data': { 'node-name': 'str', 'device': 'str', 'size': 'size',
|
||||
+ '*bitmap-node-name': 'str', '*bitmap-name': 'str',
|
||||
+ '*bitmap-action': 'PBSBitmapAction' } }
|
||||
+
|
||||
+##
|
||||
+# @BackupAccessSourceDevice:
|
||||
+#
|
||||
+# Source block device information for creating a backup access.
|
||||
+#
|
||||
+# @device: the block device name.
|
||||
+#
|
||||
+# @bitmap-mode: used to control whether the bitmap should be reused or
|
||||
+# recreated or not used. Default is not using a bitmap.
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'BackupAccessSourceDevice',
|
||||
+ 'data': { 'device': 'str', '*bitmap-mode': 'BackupAccessSetupBitmapMode' } }
|
||||
+
|
||||
+##
|
||||
+# @BackupAccessSetupBitmapMode:
|
||||
+#
|
||||
+# How to setup a bitmap for a device for @backup-access-setup.
|
||||
+#
|
||||
+# @none: do not use a bitmap. Removes an existing bitmap if present.
|
||||
+#
|
||||
+# @new: create and use a new bitmap.
|
||||
+#
|
||||
+# @use: try to re-use an existing bitmap. Create a new one if it doesn't exist.
|
||||
+##
|
||||
+{ 'enum': 'BackupAccessSetupBitmapMode',
|
||||
+ 'data': ['none', 'new', 'use' ] }
|
||||
+
|
||||
+##
|
||||
+# @backup-access-setup:
|
||||
+#
|
||||
+# Set up snapshot access to VM drives for an external backup provider. No other
|
||||
+# backup or backup access can be done before tearing down the backup access.
|
||||
+#
|
||||
+# @target-id: the unique ID of the backup target.
|
||||
+#
|
||||
+# @devices: list of devices for which to create the backup access. Also
|
||||
+# controls whether to use/create a bitmap for the device. Check the
|
||||
+# @bitmap-action in the result to see what action was actually taken for the
|
||||
+# bitmap. Each target controls its own bitmaps.
|
||||
+#
|
||||
+# Returns: a list of @BackupAccessInfo, one for each device.
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'backup-access-setup',
|
||||
+ 'data': { 'target-id': 'str', 'devices': [ 'BackupAccessSourceDevice' ] },
|
||||
+ 'returns': [ 'BackupAccessInfo' ], 'coroutine': true }
|
||||
+
|
||||
+##
|
||||
+# @backup-access-teardown:
|
||||
+#
|
||||
+# Tear down previously setup snapshot access for the same target.
|
||||
+#
|
||||
+# @target-id: the ID of the backup target.
|
||||
+#
|
||||
+# @success: whether the backup done by the external provider was successful.
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'backup-access-teardown',
|
||||
+ 'data': { 'target-id': 'str', 'success': 'bool' },
|
||||
+ 'coroutine': true }
|
||||
+
|
||||
##
|
||||
# @BlockDeviceTimedStats:
|
||||
#
|
||||
diff --git a/system/runstate.c b/system/runstate.c
|
||||
index 272801d307..cf775213bd 100644
|
||||
--- a/system/runstate.c
|
||||
+++ b/system/runstate.c
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "system/system.h"
|
||||
#include "system/tpm.h"
|
||||
#include "trace.h"
|
||||
+#include "pve-backup.h"
|
||||
|
||||
static NotifierList exit_notifiers =
|
||||
NOTIFIER_LIST_INITIALIZER(exit_notifiers);
|
||||
@@ -921,6 +922,11 @@ void qemu_cleanup(int status)
|
||||
* requests happening from here on anyway.
|
||||
*/
|
||||
bdrv_drain_all_begin();
|
||||
+ /*
|
||||
+ * The backup access is set up by a QMP command, but is neither owned by a monitor nor
|
||||
+ * associated to a BlockBackend. Need to tear it down manually here.
|
||||
+ */
|
||||
+ backup_access_teardown(false);
|
||||
job_cancel_sync_all();
|
||||
bdrv_close_all();
|
||||
|
106
debian/patches/pve/0056-PVE-backup-prepare-for-the-switch-to-using-blockdev-.patch
vendored
Normal file
106
debian/patches/pve/0056-PVE-backup-prepare-for-the-switch-to-using-blockdev-.patch
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
From 5a8cf9e98ba1668a6a20c2fcda1704de4103ff58 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 2 Jul 2025 18:27:34 +0200
|
||||
Subject: [PATCH 56/59] PVE backup: prepare for the switch to using blockdev
|
||||
rather than drive
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Also allow finding block nodes by their node name rather than just via
|
||||
an associated block backend, which might not exist for block nodes.
|
||||
|
||||
For regular drives, it is essential to not use the throttle group,
|
||||
because otherwise the limits intended only for the guest would also
|
||||
apply to the backup job.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 51 +++++++++++++++++++++++++++++++++++++++------------
|
||||
1 file changed, 39 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 0450303017..457fcb7e5c 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -847,29 +847,56 @@ static PVEBackupDevInfo coroutine_fn GRAPH_RDLOCK *get_single_device_info(
|
||||
Error **errp)
|
||||
{
|
||||
BlockBackend *blk = blk_by_name(device);
|
||||
- if (!blk) {
|
||||
- error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
- "Device '%s' not found", device);
|
||||
- return NULL;
|
||||
+ BlockDriverState *root_bs, *bs;
|
||||
+
|
||||
+ if (blk) {
|
||||
+ root_bs = bs = blk_bs(blk);
|
||||
+ } else {
|
||||
+ /* TODO PVE 10 - fleecing will always be attached without blk */
|
||||
+ root_bs = bs = bdrv_find_node(device);
|
||||
+ if (!bs) {
|
||||
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
+ "Device '%s' not found", device);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ /* For TPM, bs is already correct, otherwise need the file child. */
|
||||
+ if (!strncmp(bs->drv->format_name, "throttle", 8)) {
|
||||
+ if (!bs->file || !bs->file->bs) {
|
||||
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
+ "Device '%s' not found (no file child)", device);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ bs = bs->file->bs;
|
||||
+ }
|
||||
}
|
||||
- BlockDriverState *bs = blk_bs(blk);
|
||||
+
|
||||
if (!bdrv_co_is_inserted(bs)) {
|
||||
error_setg(errp, "Device '%s' has no medium", device);
|
||||
return NULL;
|
||||
}
|
||||
+
|
||||
PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
di->bs = bs;
|
||||
- di->device_name = g_strdup(bdrv_get_device_name(bs));
|
||||
+ /* Need the name of the root node, e.g. drive-scsi0 */
|
||||
+ di->device_name = g_strdup(bdrv_get_device_or_node_name(root_bs));
|
||||
|
||||
if (device_uses_fleecing && device_uses_fleecing(device)) {
|
||||
g_autofree gchar *fleecing_devid = g_strconcat(device, "-fleecing", NULL);
|
||||
+ BlockDriverState *fleecing_bs;
|
||||
+
|
||||
BlockBackend *fleecing_blk = blk_by_name(fleecing_devid);
|
||||
- if (!fleecing_blk) {
|
||||
- error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
- "Device '%s' not found", fleecing_devid);
|
||||
- goto fail;
|
||||
+ if (fleecing_blk) {
|
||||
+ fleecing_bs = blk_bs(fleecing_blk);
|
||||
+ } else {
|
||||
+ /* TODO PVE 10 - fleecing will always be attached without blk */
|
||||
+ fleecing_bs = bdrv_find_node(fleecing_devid);
|
||||
+ if (!fleecing_bs) {
|
||||
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
+ "Device '%s' not found", fleecing_devid);
|
||||
+ goto fail;
|
||||
+ }
|
||||
}
|
||||
- BlockDriverState *fleecing_bs = blk_bs(fleecing_blk);
|
||||
+
|
||||
if (!bdrv_co_is_inserted(fleecing_bs)) {
|
||||
error_setg(errp, "Device '%s' has no medium", fleecing_devid);
|
||||
goto fail;
|
||||
@@ -927,7 +954,7 @@ static GList coroutine_fn GRAPH_RDLOCK *get_device_info(
|
||||
|
||||
PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
di->bs = bs;
|
||||
- di->device_name = g_strdup(bdrv_get_device_name(bs));
|
||||
+ di->device_name = g_strdup(bdrv_get_device_or_node_name(bs));
|
||||
di_list = g_list_append(di_list, di);
|
||||
}
|
||||
}
|
||||
--
|
||||
2.39.5
|
||||
|
@@ -1,39 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Mon, 4 Jan 2021 14:49:14 +0100
|
||||
Subject: [PATCH] PVE: fix aborting multiple 'CREATED' jobs in sequential
|
||||
transaction
|
||||
|
||||
Deadlocks could occur in the AIO_WAIT_WHILE loop in job_finish_sync,
|
||||
which would wait for CREATED but not running jobs to complete, even
|
||||
though job_enter is a no-op in that scenario. Mark offending jobs as
|
||||
ABORTING immediately via job_update_rc if required.
|
||||
|
||||
Manifested itself in cancelling or failing backups with more than 2
|
||||
drives.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Tested-by: Mira Limbeck <m.limbeck@proxmox.com>
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
job.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/job.c b/job.c
|
||||
index 97ee97a192..51984e557c 100644
|
||||
--- a/job.c
|
||||
+++ b/job.c
|
||||
@@ -1035,6 +1035,13 @@ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
+ /* in a sequential transaction jobs with status CREATED can appear at time
|
||||
+ * 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);
|
||||
+ }
|
||||
+
|
||||
AIO_WAIT_WHILE(job->aio_context,
|
||||
(job_enter(job), !job_is_completed(job)));
|
||||
|
71
debian/patches/pve/0057-block-zeroinit-support-using-as-blockdev-driver.patch
vendored
Normal file
71
debian/patches/pve/0057-block-zeroinit-support-using-as-blockdev-driver.patch
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
From 5beb1f48555d74f468b6c0ca657d3be44c8ea8e3 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 2 Jul 2025 18:27:35 +0200
|
||||
Subject: [PATCH 57/59] block/zeroinit: support using as blockdev driver
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
---
|
||||
block/zeroinit.c | 12 +++++++++---
|
||||
qapi/block-core.json | 5 +++--
|
||||
2 files changed, 12 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/block/zeroinit.c b/block/zeroinit.c
|
||||
index f9d513db15..036edb17f5 100644
|
||||
--- a/block/zeroinit.c
|
||||
+++ b/block/zeroinit.c
|
||||
@@ -66,6 +66,7 @@ static int zeroinit_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
QemuOpts *opts;
|
||||
Error *local_err = NULL;
|
||||
int ret;
|
||||
+ const char *next = NULL;
|
||||
|
||||
s->extents = 0;
|
||||
|
||||
@@ -77,9 +78,14 @@ static int zeroinit_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- /* Open the raw file */
|
||||
- ret = bdrv_open_file_child(qemu_opt_get(opts, "x-next"), options, "next",
|
||||
- bs, &local_err);
|
||||
+
|
||||
+ next = qemu_opt_get(opts, "x-next");
|
||||
+
|
||||
+ if (next) {
|
||||
+ ret = bdrv_open_file_child(next, options, "next", bs, &local_err);
|
||||
+ } else { /* when opened as a blockdev, there is no 'next' option */
|
||||
+ ret = bdrv_open_file_child(NULL, options, "file", bs, &local_err);
|
||||
+ }
|
||||
if (ret < 0) {
|
||||
error_propagate(errp, local_err);
|
||||
goto fail;
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 2fb51215f2..f8ed564cf0 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -3586,7 +3586,7 @@
|
||||
{ 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
|
||||
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
|
||||
{ 'name': 'virtio-blk-vhost-vdpa', 'if': 'CONFIG_BLKIO' },
|
||||
- 'vmdk', 'vpc', 'vvfat' ] }
|
||||
+ 'vmdk', 'vpc', 'vvfat', 'zeroinit' ] }
|
||||
|
||||
##
|
||||
# @BlockdevOptionsFile:
|
||||
@@ -5172,7 +5172,8 @@
|
||||
'if': 'CONFIG_BLKIO' },
|
||||
'vmdk': 'BlockdevOptionsGenericCOWFormat',
|
||||
'vpc': 'BlockdevOptionsGenericFormat',
|
||||
- 'vvfat': 'BlockdevOptionsVVFAT'
|
||||
+ 'vvfat': 'BlockdevOptionsVVFAT',
|
||||
+ 'zeroinit': 'BlockdevOptionsGenericFormat'
|
||||
} }
|
||||
|
||||
##
|
||||
--
|
||||
2.39.5
|
||||
|
61
debian/patches/pve/0058-block-alloc-track-support-using-as-blockdev-driver.patch
vendored
Normal file
61
debian/patches/pve/0058-block-alloc-track-support-using-as-blockdev-driver.patch
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
From d180b059731818ae34e43e11495c8ac081ab89b9 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 2 Jul 2025 18:27:36 +0200
|
||||
Subject: [PATCH 58/59] block/alloc-track: support using as blockdev driver
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
---
|
||||
qapi/block-core.json | 19 ++++++++++++++++++-
|
||||
1 file changed, 18 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index f8ed564cf0..07c5773717 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -3567,7 +3567,8 @@
|
||||
# Since: 2.9
|
||||
##
|
||||
{ 'enum': 'BlockdevDriver',
|
||||
- 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs',
|
||||
+ 'data': [ 'alloc-track',
|
||||
+ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs',
|
||||
'cloop', 'compress', 'copy-before-write', 'copy-on-read', 'dmg',
|
||||
'file', 'snapshot-access', 'ftp', 'ftps',
|
||||
{'name': 'gluster', 'features': [ 'deprecated' ] },
|
||||
@@ -3668,6 +3669,21 @@
|
||||
{ 'struct': 'BlockdevOptionsNull',
|
||||
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
|
||||
|
||||
+##
|
||||
+# @BlockdevOptionsAllocTrack:
|
||||
+#
|
||||
+# Driver specific block device options for the alloc-track backend.
|
||||
+#
|
||||
+# @backing: backing file with the data.
|
||||
+#
|
||||
+# @auto-remove: whether the alloc-track driver should drop itself
|
||||
+# after completing the stream.
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'BlockdevOptionsAllocTrack',
|
||||
+ 'base': 'BlockdevOptionsGenericFormat',
|
||||
+ 'data': { 'auto-remove': 'bool', 'backing': 'BlockdevRefOrNull' } }
|
||||
+
|
||||
##
|
||||
# @BlockdevOptionsPbs:
|
||||
#
|
||||
@@ -5114,6 +5130,7 @@
|
||||
'*detect-zeroes': 'BlockdevDetectZeroesOptions' },
|
||||
'discriminator': 'driver',
|
||||
'data': {
|
||||
+ 'alloc-track':'BlockdevOptionsAllocTrack',
|
||||
'blkdebug': 'BlockdevOptionsBlkdebug',
|
||||
'blklogwrites':'BlockdevOptionsBlklogwrites',
|
||||
'blkverify': 'BlockdevOptionsBlkverify',
|
||||
--
|
||||
2.39.5
|
||||
|
137
debian/patches/pve/0059-block-qapi-include-child-references-in-block-device-.patch
vendored
Normal file
137
debian/patches/pve/0059-block-qapi-include-child-references-in-block-device-.patch
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
From 76442f3eafa8cbe647fe2d39e78e817ec681143c Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 2 Jul 2025 18:27:37 +0200
|
||||
Subject: [PATCH 59/59] block/qapi: include child references in block device
|
||||
info
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
In combination with using a throttle filter to enforce IO limits for
|
||||
a guest device, knowing the 'file' child of a block device can be
|
||||
useful. If the throttle filter is only intended for guest IO, block
|
||||
jobs should not also be limited by the throttle filter, so the
|
||||
block operations need to be done with the 'file' child of the top
|
||||
throttle node as the target. In combination with mirroring, the name
|
||||
of that child is not fixed.
|
||||
|
||||
Another scenario is when unplugging a guest device after mirroring
|
||||
below a top throttle node, where the mirror target is added explicitly
|
||||
via blockdev-add. After mirroring, the target becomes the new 'file'
|
||||
child of the throttle node. For unplugging, both the top throttle node
|
||||
and the mirror target need to be deleted, because only implicitly
|
||||
added child nodes are deleted automatically, and the current 'file'
|
||||
child of the throttle node was explicitly added (as the mirror
|
||||
target).
|
||||
|
||||
In other scenarios, it could be useful to follow the backing chain.
|
||||
|
||||
Note that iotests 191 and 273 use _filter_img_info, so the 'children'
|
||||
information is filtered out there.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
---
|
||||
block/qapi.c | 10 ++++++++++
|
||||
qapi/block-core.json | 16 ++++++++++++++++
|
||||
tests/qemu-iotests/184.out | 8 ++++++++
|
||||
3 files changed, 34 insertions(+)
|
||||
|
||||
diff --git a/block/qapi.c b/block/qapi.c
|
||||
index 2c50a6bf3b..e08a1e970f 100644
|
||||
--- a/block/qapi.c
|
||||
+++ b/block/qapi.c
|
||||
@@ -51,6 +51,8 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
|
||||
ImageInfo *backing_info;
|
||||
BlockDriverState *backing;
|
||||
BlockDeviceInfo *info;
|
||||
+ BlockdevChildList **children_list_tail;
|
||||
+ BdrvChild *child;
|
||||
|
||||
if (!bs->drv) {
|
||||
error_setg(errp, "Block device %s is ejected", bs->node_name);
|
||||
@@ -77,6 +79,14 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
|
||||
info->node_name = g_strdup(bs->node_name);
|
||||
}
|
||||
|
||||
+ children_list_tail = &info->children;
|
||||
+ QLIST_FOREACH(child, &bs->children, next) {
|
||||
+ BlockdevChild *child_ref = g_new0(BlockdevChild, 1);
|
||||
+ child_ref->child = g_strdup(child->name);
|
||||
+ child_ref->node_name = g_strdup(child->bs->node_name);
|
||||
+ QAPI_LIST_APPEND(children_list_tail, child_ref);
|
||||
+ }
|
||||
+
|
||||
backing = bdrv_cow_bs(bs);
|
||||
if (backing) {
|
||||
info->backing_file = g_strdup(backing->filename);
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 07c5773717..4db27f5819 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -461,6 +461,19 @@
|
||||
'direct': 'bool',
|
||||
'no-flush': 'bool' } }
|
||||
|
||||
+##
|
||||
+# @BlockdevChild:
|
||||
+#
|
||||
+# @child: The name of the child, for example 'file' or 'backing'.
|
||||
+#
|
||||
+# @node-name: The name of the child's block driver node.
|
||||
+#
|
||||
+# Since: 10.1
|
||||
+##
|
||||
+{ 'struct': 'BlockdevChild',
|
||||
+ 'data': { 'child': 'str',
|
||||
+ 'node-name': 'str' } }
|
||||
+
|
||||
##
|
||||
# @BlockDeviceInfo:
|
||||
#
|
||||
@@ -486,6 +499,8 @@
|
||||
# @backing_file_depth: number of files in the backing file chain
|
||||
# (since: 1.2)
|
||||
#
|
||||
+# @children: Information about child block nodes. (since: 10.1)
|
||||
+#
|
||||
# @active: true if the backend is active; typical cases for inactive backends
|
||||
# are on the migration source instance after migration completes and on the
|
||||
# destination before it completes. (since: 10.0)
|
||||
@@ -560,6 +575,7 @@
|
||||
{ 'struct': 'BlockDeviceInfo',
|
||||
'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
|
||||
'*backing_file': 'str', 'backing_file_depth': 'int',
|
||||
+ 'children': ['BlockdevChild'],
|
||||
'active': 'bool', 'encrypted': 'bool',
|
||||
'detect_zeroes': 'BlockdevDetectZeroesOptions',
|
||||
'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
|
||||
diff --git a/tests/qemu-iotests/184.out b/tests/qemu-iotests/184.out
|
||||
index 52692b6b3b..ef99bb2e9a 100644
|
||||
--- a/tests/qemu-iotests/184.out
|
||||
+++ b/tests/qemu-iotests/184.out
|
||||
@@ -41,6 +41,12 @@ Testing:
|
||||
},
|
||||
"iops_wr": 0,
|
||||
"ro": false,
|
||||
+ "children": [
|
||||
+ {
|
||||
+ "node-name": "disk0",
|
||||
+ "child": "file"
|
||||
+ }
|
||||
+ ],
|
||||
"node-name": "throttle0",
|
||||
"backing_file_depth": 1,
|
||||
"drv": "throttle",
|
||||
@@ -69,6 +75,8 @@ Testing:
|
||||
},
|
||||
"iops_wr": 0,
|
||||
"ro": false,
|
||||
+ "children": [
|
||||
+ ],
|
||||
"node-name": "disk0",
|
||||
"backing_file_depth": 0,
|
||||
"drv": "null-co",
|
||||
--
|
||||
2.39.5
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user