Compare commits
115 Commits
v8.0.2-3+v
...
v9.2.0-5
Author | SHA1 | Date | |
---|---|---|---|
![]() |
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 |
26
Makefile
26
Makefile
@@ -17,10 +17,14 @@ 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
|
||||
|
||||
PC_BIOS_FW_PURGE_LIST_IN = \
|
||||
hppa-firmware.img \
|
||||
hppa-firmware64.img \
|
||||
openbios-ppc \
|
||||
openbios-sparc32 \
|
||||
openbios-sparc64 \
|
||||
@@ -28,7 +32,8 @@ PC_BIOS_FW_PURGE_LIST_IN = \
|
||||
s390-ccw.img \
|
||||
s390-netboot.img \
|
||||
u-boot.e500 \
|
||||
.*\.dtb \
|
||||
.*[a-zA-Z0-9]\.dtb \
|
||||
.*[a-zA-Z0-9]\.dts \
|
||||
qemu_vga.ndrv \
|
||||
slof.bin \
|
||||
opensbi-riscv.*-generic-fw_dynamic.bin \
|
||||
@@ -36,16 +41,14 @@ PC_BIOS_FW_PURGE_LIST_IN = \
|
||||
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): keycodemapdb | submodule
|
||||
$(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/ui/keycodemapdb
|
||||
rm -rf $@.tmp/roms/edk2 # packaged separately
|
||||
cp -a keycodemapdb $@.tmp/ui/
|
||||
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
|
||||
@@ -55,7 +58,7 @@ $(BUILDDIR): keycodemapdb | submodule
|
||||
deb kvm: $(DEBS)
|
||||
$(DEB_DBG): $(DEB)
|
||||
$(DEB): $(BUILDDIR)
|
||||
cd $(BUILDDIR); dpkg-buildpackage -b -us -uc -j32
|
||||
cd $(BUILDDIR); dpkg-buildpackage -b -us -uc
|
||||
lintian $(DEBS)
|
||||
|
||||
sbuild: $(DSC)
|
||||
@@ -73,17 +76,6 @@ dsc:
|
||||
$(DSC): $(ORIG_SRC_TAR) $(BUILDDIR)
|
||||
cd $(BUILDDIR); dpkg-buildpackage -S -us -uc -d
|
||||
|
||||
.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
|
||||
|
||||
.PHONY: upload
|
||||
upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
|
||||
upload: $(DEBS)
|
||||
|
309
debian/changelog
vendored
309
debian/changelog
vendored
@@ -1,15 +1,310 @@
|
||||
pve-qemu-kvm (8.0.2-3+vitastor2) bookworm; urgency=medium
|
||||
pve-qemu-kvm (9.2.0-5) bookworm; urgency=medium
|
||||
|
||||
* Improve performance by adding io_uring support
|
||||
* Fix qemu-img deadlocks after iothread fixes
|
||||
* pve backup: backup-access api: simplify bitmap logic
|
||||
|
||||
-- Vitaliy Filippov <vitalif@yourcmc.ru> Tue, 19 Jul 2023 02:07:02 +0300
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 04 Apr 2025 16:15:58 +0200
|
||||
|
||||
pve-qemu-kvm (8.0.2-3+vitastor1) bookworm; urgency=medium
|
||||
pve-qemu-kvm (9.2.0-4) bookworm; urgency=medium
|
||||
|
||||
* Add Vitastor support
|
||||
* 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.
|
||||
|
||||
-- Vitaliy Filippov <vitalif@yourcmc.ru> Sat, 24 Jun 2023 00:50:32 +0300
|
||||
* 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
|
||||
|
||||
|
3
debian/control
vendored
3
debian/control
vendored
@@ -37,6 +37,7 @@ Build-Depends: debhelper-compat (= 13),
|
||||
python3-minimal,
|
||||
python3-sphinx,
|
||||
python3-sphinx-rtd-theme,
|
||||
python3-venv,
|
||||
quilt,
|
||||
uuid-dev,
|
||||
xfslibs-dev,
|
||||
@@ -58,7 +59,6 @@ Depends: ceph-common (>= 0.48),
|
||||
libspice-server1 (>= 0.14.0~),
|
||||
libusb-1.0-0 (>= 1.0.17-1),
|
||||
libusbredirparser1 (>= 0.6-2),
|
||||
vitastor-client (>= 0.9.4),
|
||||
libuuid1,
|
||||
${misc:Depends},
|
||||
${shlibs:Depends},
|
||||
@@ -80,6 +80,7 @@ Replaces: pve-kvm,
|
||||
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
|
||||
|
@@ -27,18 +27,18 @@ Signed-off-by: Ma Haocong <mahaocong@didichuxing.com>
|
||||
Signed-off-by: John Snow <jsnow@redhat.com>
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: rebased for 8.0]
|
||||
[FE: rebased for 9.1.2]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/mirror.c | 98 +++++++++++++++++++++-----
|
||||
block/mirror.c | 99 ++++++++++++++++++++------
|
||||
blockdev.c | 38 +++++++++-
|
||||
include/block/block_int-global-state.h | 4 +-
|
||||
qapi/block-core.json | 29 ++++++--
|
||||
qapi/block-core.json | 25 ++++++-
|
||||
tests/unit/test-block-iothread.c | 4 +-
|
||||
5 files changed, 144 insertions(+), 29 deletions(-)
|
||||
5 files changed, 142 insertions(+), 28 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index 663e2b7002..9099c75992 100644
|
||||
index 2afe700b4d..c3d4be9b15 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -51,7 +51,7 @@ typedef struct MirrorBlockJob {
|
||||
@@ -50,7 +50,7 @@ index 663e2b7002..9099c75992 100644
|
||||
BlockMirrorBackingMode backing_mode;
|
||||
/* Whether the target image requires explicit zero-initialization */
|
||||
bool zero_target;
|
||||
@@ -65,6 +65,8 @@ typedef struct MirrorBlockJob {
|
||||
@@ -73,6 +73,8 @@ typedef struct MirrorBlockJob {
|
||||
size_t buf_size;
|
||||
int64_t bdev_length;
|
||||
unsigned long *cow_bitmap;
|
||||
@@ -59,9 +59,9 @@ index 663e2b7002..9099c75992 100644
|
||||
BdrvDirtyBitmap *dirty_bitmap;
|
||||
BdrvDirtyBitmapIter *dbi;
|
||||
uint8_t *buf;
|
||||
@@ -703,7 +705,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;
|
||||
@@ -69,7 +69,7 @@ index 663e2b7002..9099c75992 100644
|
||||
BlockDriverState *unfiltered_target = bdrv_skip_filters(target_bs);
|
||||
|
||||
if (bdrv_cow_bs(unfiltered_target) != backing) {
|
||||
@@ -801,6 +804,16 @@ static void mirror_abort(Job *job)
|
||||
@@ -824,6 +827,16 @@ static void mirror_abort(Job *job)
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ index 663e2b7002..9099c75992 100644
|
||||
static void coroutine_fn mirror_throttle(MirrorBlockJob *s)
|
||||
{
|
||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
||||
@@ -987,7 +1000,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);
|
||||
@@ -96,7 +96,7 @@ index 663e2b7002..9099c75992 100644
|
||||
ret = mirror_dirty_init(s);
|
||||
if (ret < 0 || job_is_cancelled(&s->common.job)) {
|
||||
goto immediate_exit;
|
||||
@@ -1240,6 +1254,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,
|
||||
@@ -104,7 +104,7 @@ index 663e2b7002..9099c75992 100644
|
||||
.pause = mirror_pause,
|
||||
.complete = mirror_complete,
|
||||
.cancel = mirror_cancel,
|
||||
@@ -1256,6 +1271,7 @@ static const BlockJobDriver commit_active_job_driver = {
|
||||
@@ -1327,6 +1342,7 @@ static const BlockJobDriver commit_active_job_driver = {
|
||||
.run = mirror_run,
|
||||
.prepare = mirror_prepare,
|
||||
.abort = mirror_abort,
|
||||
@@ -112,7 +112,7 @@ index 663e2b7002..9099c75992 100644
|
||||
.pause = mirror_pause,
|
||||
.complete = mirror_complete,
|
||||
.cancel = commit_active_cancel,
|
||||
@@ -1647,7 +1663,10 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1719,7 +1735,10 @@ static BlockJob *mirror_start_job(
|
||||
BlockCompletionFunc *cb,
|
||||
void *opaque,
|
||||
const BlockJobDriver *driver,
|
||||
@@ -123,10 +123,10 @@ index 663e2b7002..9099c75992 100644
|
||||
+ BlockDriverState *base,
|
||||
bool auto_complete, const char *filter_node_name,
|
||||
bool is_mirror, MirrorCopyMode copy_mode,
|
||||
Error **errp)
|
||||
@@ -1659,10 +1678,39 @@ static BlockJob *mirror_start_job(
|
||||
uint64_t target_perms, target_shared_perms;
|
||||
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);
|
||||
@@ -166,7 +166,7 @@ index 663e2b7002..9099c75992 100644
|
||||
assert(is_power_of_2(granularity));
|
||||
|
||||
if (buf_size < 0) {
|
||||
@@ -1793,7 +1841,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;
|
||||
@@ -176,10 +176,10 @@ index 663e2b7002..9099c75992 100644
|
||||
+ s->bitmap_mode = bitmap_mode;
|
||||
s->backing_mode = backing_mode;
|
||||
s->zero_target = zero_target;
|
||||
s->copy_mode = copy_mode;
|
||||
@@ -1814,6 +1864,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);
|
||||
@@ -193,10 +193,10 @@ index 663e2b7002..9099c75992 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,
|
||||
@@ -1891,6 +1953,9 @@ fail:
|
||||
@@ -1986,6 +2048,9 @@ fail:
|
||||
if (s->dirty_bitmap) {
|
||||
bdrv_release_dirty_bitmap(s->dirty_bitmap);
|
||||
}
|
||||
@@ -206,7 +206,7 @@ index 663e2b7002..9099c75992 100644
|
||||
job_early_fail(&s->common.job);
|
||||
}
|
||||
|
||||
@@ -1908,31 +1973,25 @@ 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,
|
||||
@@ -231,19 +231,23 @@ index 663e2b7002..9099c75992 100644
|
||||
- MirrorSyncMode_str(mode));
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
bdrv_graph_rdlock_main_loop();
|
||||
- is_none_mode = mode == MIRROR_SYNC_MODE_NONE;
|
||||
base = mode == MIRROR_SYNC_MODE_TOP ? bdrv_backing_chain_next(bs) : NULL;
|
||||
bdrv_graph_rdunlock_main_loop();
|
||||
|
||||
mirror_start_job(job_id, bs, creation_flags, target, replaces,
|
||||
speed, granularity, buf_size, backing_mode, zero_target,
|
||||
on_source_error, on_target_error, unmap, NULL, NULL,
|
||||
- &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,
|
||||
@@ -1959,7 +2018,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,
|
||||
@@ -251,13 +255,13 @@ index 663e2b7002..9099c75992 100644
|
||||
+ &commit_active_job_driver, MIRROR_SYNC_MODE_FULL,
|
||||
+ NULL, 0, base, auto_complete,
|
||||
filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND,
|
||||
errp);
|
||||
base_read_only, errp);
|
||||
if (!job) {
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index e464daea58..50e4a9c682 100644
|
||||
index 6740663fda..38fa63155c 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -2942,6 +2942,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2781,6 +2781,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
BlockDriverState *target,
|
||||
const char *replaces,
|
||||
enum MirrorSyncMode sync,
|
||||
@@ -267,15 +271,15 @@ index e464daea58..50e4a9c682 100644
|
||||
BlockMirrorBackingMode backing_mode,
|
||||
bool zero_target,
|
||||
bool has_speed, int64_t speed,
|
||||
@@ -2960,6 +2963,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2799,6 +2802,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;
|
||||
@@ -3011,6 +3015,29 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
GLOBAL_STATE_CODE();
|
||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||
@@ -2853,6 +2857,29 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
sync = MIRROR_SYNC_MODE_FULL;
|
||||
}
|
||||
|
||||
@@ -305,7 +309,7 @@ index e464daea58..50e4a9c682 100644
|
||||
if (!replaces) {
|
||||
/* We want to mirror from @bs, but keep implicit filters on top */
|
||||
unfiltered_bs = bdrv_skip_implicit_filters(bs);
|
||||
@@ -3056,8 +3083,8 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2894,8 +2921,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,
|
||||
@@ -316,7 +320,7 @@ index e464daea58..50e4a9c682 100644
|
||||
on_source_error, on_target_error, unmap, filter_node_name,
|
||||
copy_mode, errp);
|
||||
}
|
||||
@@ -3202,6 +3229,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
||||
@@ -3039,6 +3066,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
||||
|
||||
blockdev_mirror_common(arg->job_id, bs, target_bs,
|
||||
arg->replaces, arg->sync,
|
||||
@@ -325,7 +329,7 @@ index e464daea58..50e4a9c682 100644
|
||||
backing_mode, zero_target,
|
||||
arg->has_speed, arg->speed,
|
||||
arg->has_granularity, arg->granularity,
|
||||
@@ -3223,6 +3252,8 @@ void qmp_blockdev_mirror(const char *job_id,
|
||||
@@ -3058,6 +3087,8 @@ void qmp_blockdev_mirror(const char *job_id,
|
||||
const char *device, const char *target,
|
||||
const char *replaces,
|
||||
MirrorSyncMode sync,
|
||||
@@ -334,7 +338,7 @@ index e464daea58..50e4a9c682 100644
|
||||
bool has_speed, int64_t speed,
|
||||
bool has_granularity, uint32_t granularity,
|
||||
bool has_buf_size, int64_t buf_size,
|
||||
@@ -3271,7 +3302,8 @@ void qmp_blockdev_mirror(const char *job_id,
|
||||
@@ -3098,7 +3129,8 @@ void qmp_blockdev_mirror(const char *job_id,
|
||||
}
|
||||
|
||||
blockdev_mirror_common(job_id, bs, target_bs,
|
||||
@@ -345,10 +349,10 @@ index e464daea58..50e4a9c682 100644
|
||||
has_granularity, granularity,
|
||||
has_buf_size, buf_size,
|
||||
diff --git a/include/block/block_int-global-state.h b/include/block/block_int-global-state.h
|
||||
index 902406eb99..d559be928c 100644
|
||||
index eb2d92a226..f0c642b194 100644
|
||||
--- a/include/block/block_int-global-state.h
|
||||
+++ b/include/block/block_int-global-state.h
|
||||
@@ -152,7 +152,9 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
|
||||
@@ -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,
|
||||
@@ -360,31 +364,26 @@ index 902406eb99..d559be928c 100644
|
||||
BlockdevOnError on_source_error,
|
||||
BlockdevOnError on_target_error,
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index c05ad0c07e..3c945c1f93 100644
|
||||
index fd3bcc1c17..48ba32049f 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -2095,10 +2095,19 @@
|
||||
# (all the disk, only the sectors allocated in the topmost image, or
|
||||
# only new I/O).
|
||||
@@ -2178,6 +2178,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).
|
||||
@@ -2138,7 +2147,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
|
||||
@@ -2220,7 +2229,9 @@
|
||||
{ 'struct': 'DriveMirror',
|
||||
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
|
||||
'*format': 'str', '*node-name': 'str', '*replaces': 'str',
|
||||
@@ -395,28 +394,23 @@ index c05ad0c07e..3c945c1f93 100644
|
||||
'*speed': 'int', '*granularity': 'uint32',
|
||||
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
|
||||
'*on-target-error': 'BlockdevOnError',
|
||||
@@ -2417,10 +2428,19 @@
|
||||
# (all the disk, only the sectors allocated in the topmost image, or
|
||||
# only new I/O).
|
||||
@@ -2499,6 +2510,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
|
||||
@@ -2470,7 +2490,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
|
||||
@@ -2547,7 +2567,8 @@
|
||||
{ 'command': 'blockdev-mirror',
|
||||
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
|
||||
'*replaces': 'str',
|
||||
@@ -427,10 +421,10 @@ index c05ad0c07e..3c945c1f93 100644
|
||||
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
|
||||
'*on-target-error': 'BlockdevOnError',
|
||||
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
|
||||
index 3a5e1eb2c4..c1ecc49073 100644
|
||||
index 20ed54f570..4f50a99334 100644
|
||||
--- a/tests/unit/test-block-iothread.c
|
||||
+++ b/tests/unit/test-block-iothread.c
|
||||
@@ -757,8 +757,8 @@ static void test_propagate_mirror(void)
|
||||
@@ -755,8 +755,8 @@ static void test_propagate_mirror(void)
|
||||
|
||||
/* Start a mirror job */
|
||||
mirror_start("job0", src, target, NULL, JOB_DEFAULT, 0, 0, 0,
|
||||
@@ -440,4 +434,4 @@ index 3a5e1eb2c4..c1ecc49073 100644
|
||||
+ false, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
false, "filter_node", MIRROR_COPY_MODE_BACKGROUND,
|
||||
&error_abort);
|
||||
WITH_JOB_LOCK_GUARD() {
|
||||
|
||||
|
@@ -24,10 +24,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 18 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index 9099c75992..e2ff42067b 100644
|
||||
index c3d4be9b15..7b6f7c0068 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -680,8 +680,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);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ index 9099c75992..e2ff42067b 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);
|
||||
@@ -782,6 +780,18 @@ static int mirror_exit_common(Job *job)
|
||||
block_job_remove_all_bdrv(bjob);
|
||||
bdrv_replace_node(mirror_top_bs, mirror_top_bs->backing->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 ||
|
||||
@@ -55,7 +55,7 @@ index 9099c75992..e2ff42067b 100644
|
||||
bs_opaque->job = NULL;
|
||||
|
||||
bdrv_drained_end(src);
|
||||
@@ -1688,10 +1698,6 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1763,10 +1773,6 @@ static BlockJob *mirror_start_job(
|
||||
" sync mode",
|
||||
MirrorSyncMode_str(sync_mode));
|
||||
return NULL;
|
||||
@@ -66,7 +66,7 @@ index 9099c75992..e2ff42067b 100644
|
||||
}
|
||||
} else if (bitmap) {
|
||||
error_setg(errp,
|
||||
@@ -1708,6 +1714,12 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1783,6 +1789,12 @@ static BlockJob *mirror_start_job(
|
||||
return NULL;
|
||||
}
|
||||
granularity = bdrv_dirty_bitmap_granularity(bitmap);
|
||||
|
@@ -16,10 +16,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index 50e4a9c682..e6b2b1e338 100644
|
||||
index 38fa63155c..204cf6fad1 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -3036,6 +3036,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2878,6 +2878,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) {
|
||||
return;
|
||||
}
|
||||
|
@@ -16,10 +16,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 4 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index e2ff42067b..f42953837b 100644
|
||||
index 7b6f7c0068..2b1c07095d 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -786,8 +786,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);
|
||||
@@ -30,7 +30,7 @@ index e2ff42067b..f42953837b 100644
|
||||
}
|
||||
}
|
||||
bdrv_release_dirty_bitmap(s->dirty_bitmap);
|
||||
@@ -1881,11 +1881,8 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1971,11 +1971,8 @@ static BlockJob *mirror_start_job(
|
||||
}
|
||||
|
||||
if (s->sync_mode == MIRROR_SYNC_MODE_BITMAP) {
|
||||
@@ -43,4 +43,4 @@ index e2ff42067b..f42953837b 100644
|
||||
+ NULL, true);
|
||||
}
|
||||
|
||||
ret = block_job_add_bdrv(&s->common, "source", bs, 0,
|
||||
bdrv_graph_wrlock();
|
||||
|
@@ -12,7 +12,7 @@ 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.0]
|
||||
[FE: rebase for 8.2.2]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/mirror.c | 28 +++------------
|
||||
@@ -21,12 +21,12 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
3 files changed, 70 insertions(+), 59 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index f42953837b..8f79efaa87 100644
|
||||
index 2b1c07095d..f5787b380c 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -1688,31 +1688,13 @@ static BlockJob *mirror_start_job(
|
||||
uint64_t target_perms, target_shared_perms;
|
||||
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",
|
||||
@@ -62,10 +62,10 @@ index f42953837b..8f79efaa87 100644
|
||||
|
||||
if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index e6b2b1e338..bdae211a54 100644
|
||||
index 204cf6fad1..79d47b1920 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -3015,7 +3015,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2857,7 +2857,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
sync = MIRROR_SYNC_MODE_FULL;
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
6 files changed, 59 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
|
||||
index 033390f699..ad35d4fea8 100644
|
||||
index c3740ec616..7f38ce6b8b 100644
|
||||
--- a/include/monitor/monitor.h
|
||||
+++ b/include/monitor/monitor.h
|
||||
@@ -16,6 +16,7 @@ extern QemuOptsList qemu_mon_opts;
|
||||
@@ -60,10 +60,10 @@ index 033390f699..ad35d4fea8 100644
|
||||
void monitor_init_globals(void);
|
||||
void monitor_init_globals_core(void);
|
||||
diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
|
||||
index 53e3808054..a19f8cbc2b 100644
|
||||
index cb628f681d..93dbd62fc2 100644
|
||||
--- a/monitor/monitor-internal.h
|
||||
+++ b/monitor/monitor-internal.h
|
||||
@@ -152,6 +152,13 @@ typedef struct {
|
||||
@@ -151,6 +151,13 @@ typedef struct {
|
||||
QemuMutex qmp_queue_lock;
|
||||
/* Input queue that holds all the parsed QMP requests */
|
||||
GQueue *qmp_requests;
|
||||
@@ -78,10 +78,10 @@ index 53e3808054..a19f8cbc2b 100644
|
||||
|
||||
/**
|
||||
diff --git a/monitor/monitor.c b/monitor/monitor.c
|
||||
index 8dc96f6af9..f3c38cb714 100644
|
||||
index 56786c0ccc..30071d0c8a 100644
|
||||
--- a/monitor/monitor.c
|
||||
+++ b/monitor/monitor.c
|
||||
@@ -135,6 +135,21 @@ bool monitor_cur_is_qmp(void)
|
||||
@@ -116,6 +116,21 @@ bool monitor_cur_is_qmp(void)
|
||||
return cur_mon && monitor_is_qmp(cur_mon);
|
||||
}
|
||||
|
||||
@@ -104,10 +104,10 @@ index 8dc96f6af9..f3c38cb714 100644
|
||||
* Is @mon is using readline?
|
||||
* Note: not all HMP monitors use readline, e.g., gdbserver has a
|
||||
diff --git a/monitor/qmp.c b/monitor/qmp.c
|
||||
index 092c527b6f..6b8cfcf6d8 100644
|
||||
index 5e538f34c0..eb181d5979 100644
|
||||
--- a/monitor/qmp.c
|
||||
+++ b/monitor/qmp.c
|
||||
@@ -141,6 +141,8 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
@@ -165,6 +165,8 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
QDict *rsp;
|
||||
QDict *error;
|
||||
|
||||
@@ -116,7 +116,7 @@ index 092c527b6f..6b8cfcf6d8 100644
|
||||
rsp = qmp_dispatch(mon->commands, req, qmp_oob_enabled(mon),
|
||||
&mon->common);
|
||||
|
||||
@@ -156,7 +158,17 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
@@ -180,7 +182,17 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ index 092c527b6f..6b8cfcf6d8 100644
|
||||
qobject_unref(rsp);
|
||||
}
|
||||
|
||||
@@ -444,6 +456,7 @@ static void monitor_qmp_event(void *opaque, QEMUChrEvent event)
|
||||
@@ -461,6 +473,7 @@ static void monitor_qmp_event(void *opaque, QEMUChrEvent event)
|
||||
|
||||
switch (event) {
|
||||
case CHR_EVENT_OPENED:
|
||||
@@ -144,7 +144,7 @@ index 092c527b6f..6b8cfcf6d8 100644
|
||||
monitor_qmp_caps_reset(mon);
|
||||
data = qmp_greeting(mon);
|
||||
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
|
||||
index 0990873ec8..e605003771 100644
|
||||
index 176b549473..790bb7d1da 100644
|
||||
--- a/qapi/qmp-dispatch.c
|
||||
+++ b/qapi/qmp-dispatch.c
|
||||
@@ -117,16 +117,28 @@ typedef struct QmpDispatchBH {
|
||||
@@ -180,16 +180,16 @@ index 0990873ec8..e605003771 100644
|
||||
aio_co_wake(data->co);
|
||||
}
|
||||
|
||||
@@ -231,6 +243,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
|
||||
@@ -253,6 +265,7 @@ QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *requ
|
||||
.ret = &ret,
|
||||
.errp = &err,
|
||||
.co = qemu_coroutine_self(),
|
||||
+ .conn_nr = monitor_get_connection_nr(cur_mon),
|
||||
};
|
||||
aio_bh_schedule_oneshot(qemu_get_aio_context(), do_qmp_dispatch_bh,
|
||||
aio_bh_schedule_oneshot(iohandler_get_aio_context(), do_qmp_dispatch_bh,
|
||||
&data);
|
||||
diff --git a/stubs/monitor-core.c b/stubs/monitor-core.c
|
||||
index afa477aae6..d3ff124bf3 100644
|
||||
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)
|
||||
@@ -201,6 +201,6 @@ index afa477aae6..d3ff124bf3 100644
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
|
||||
void qapi_event_emit(QAPIEvent event, QDict *qdict)
|
||||
{
|
||||
}
|
||||
|
@@ -55,10 +55,10 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/hw/ide/core.c b/hw/ide/core.c
|
||||
index 45d14a25e9..08e1f0c3d7 100644
|
||||
index 08d9218455..20d8c0cf66 100644
|
||||
--- a/hw/ide/core.c
|
||||
+++ b/hw/ide/core.c
|
||||
@@ -444,7 +444,7 @@ static void ide_trim_bh_cb(void *opaque)
|
||||
@@ -456,7 +456,7 @@ static void ide_trim_bh_cb(void *opaque)
|
||||
iocb->bh = NULL;
|
||||
qemu_aio_unref(iocb);
|
||||
|
||||
@@ -67,7 +67,7 @@ index 45d14a25e9..08e1f0c3d7 100644
|
||||
blk_dec_in_flight(blk);
|
||||
}
|
||||
|
||||
@@ -504,6 +504,8 @@ static void ide_issue_trim_cb(void *opaque, int ret)
|
||||
@@ -516,6 +516,8 @@ static void ide_issue_trim_cb(void *opaque, int ret)
|
||||
done:
|
||||
iocb->aiocb = NULL;
|
||||
if (iocb->bh) {
|
||||
@@ -76,8 +76,8 @@ index 45d14a25e9..08e1f0c3d7 100644
|
||||
replay_bh_schedule_event(iocb->bh);
|
||||
}
|
||||
}
|
||||
@@ -515,9 +517,6 @@ BlockAIOCB *ide_issue_trim(
|
||||
IDEState *s = opaque;
|
||||
@@ -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() */
|
||||
@@ -85,8 +85,8 @@ index 45d14a25e9..08e1f0c3d7 100644
|
||||
-
|
||||
iocb = blk_aio_get(&trim_aiocb_info, s->blk, cb, cb_opaque);
|
||||
iocb->s = s;
|
||||
iocb->bh = qemu_bh_new(ide_trim_bh_cb, iocb);
|
||||
@@ -740,8 +739,9 @@ void ide_cancel_dma_sync(IDEState *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();
|
@@ -1,69 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Guenter Roeck <linux@roeck-us.net>
|
||||
Date: Tue, 28 Feb 2023 09:11:29 -0800
|
||||
Subject: [PATCH] scsi: megasas: Internal cdbs have 16-byte length
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Host drivers do not necessarily set cdb_len in megasas io commands.
|
||||
With commits 6d1511cea0 ("scsi: Reject commands if the CDB length
|
||||
exceeds buf_len") and fe9d8927e2 ("scsi: Add buf_len parameter to
|
||||
scsi_req_new()"), this results in failures to boot Linux from affected
|
||||
SCSI drives because cdb_len is set to 0 by the host driver.
|
||||
Set the cdb length to its actual size to solve the problem.
|
||||
|
||||
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
|
||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
(picked-up from https://lists.nongnu.org/archive/html/qemu-devel/2023-02/msg08653.html)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/scsi/megasas.c | 14 ++------------
|
||||
1 file changed, 2 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
|
||||
index 9cbbb16121..d624866bb6 100644
|
||||
--- a/hw/scsi/megasas.c
|
||||
+++ b/hw/scsi/megasas.c
|
||||
@@ -1780,7 +1780,7 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
|
||||
uint8_t cdb[16];
|
||||
int len;
|
||||
struct SCSIDevice *sdev = NULL;
|
||||
- int target_id, lun_id, cdb_len;
|
||||
+ int target_id, lun_id;
|
||||
|
||||
lba_count = le32_to_cpu(cmd->frame->io.header.data_len);
|
||||
lba_start_lo = le32_to_cpu(cmd->frame->io.lba_lo);
|
||||
@@ -1789,7 +1789,6 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
|
||||
|
||||
target_id = cmd->frame->header.target_id;
|
||||
lun_id = cmd->frame->header.lun_id;
|
||||
- cdb_len = cmd->frame->header.cdb_len;
|
||||
|
||||
if (target_id < MFI_MAX_LD && lun_id == 0) {
|
||||
sdev = scsi_device_find(&s->bus, 0, target_id, lun_id);
|
||||
@@ -1804,15 +1803,6 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
|
||||
return MFI_STAT_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
- if (cdb_len > 16) {
|
||||
- trace_megasas_scsi_invalid_cdb_len(
|
||||
- mfi_frame_desc(frame_cmd), 1, target_id, lun_id, cdb_len);
|
||||
- megasas_write_sense(cmd, SENSE_CODE(INVALID_OPCODE));
|
||||
- cmd->frame->header.scsi_status = CHECK_CONDITION;
|
||||
- s->event_count++;
|
||||
- return MFI_STAT_SCSI_DONE_WITH_ERROR;
|
||||
- }
|
||||
-
|
||||
cmd->iov_size = lba_count * sdev->blocksize;
|
||||
if (megasas_map_sgl(s, cmd, &cmd->frame->io.sgl)) {
|
||||
megasas_write_sense(cmd, SENSE_CODE(TARGET_FAILURE));
|
||||
@@ -1823,7 +1813,7 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
|
||||
|
||||
megasas_encode_lba(cdb, lba_start, lba_count, is_write);
|
||||
cmd->req = scsi_req_new(sdev, cmd->index,
|
||||
- lun_id, cdb, cdb_len, cmd);
|
||||
+ lun_id, cdb, sizeof(cdb), cmd);
|
||||
if (!cmd->req) {
|
||||
trace_megasas_scsi_req_alloc_failed(
|
||||
mfi_frame_desc(frame_cmd), target_id, lun_id);
|
82
debian/patches/extra/0003-tcg-Reset-free_temps-before-tcg_optimize.patch
vendored
Normal file
82
debian/patches/extra/0003-tcg-Reset-free_temps-before-tcg_optimize.patch
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Richard Henderson <richard.henderson@linaro.org>
|
||||
Date: Sat, 7 Dec 2024 18:14:45 +0000
|
||||
Subject: [PATCH] tcg: Reset free_temps before tcg_optimize
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
When allocating new temps during tcg_optmize, do not re-use
|
||||
any EBB temps that were used within the TB. We do not have
|
||||
any idea what span of the TB in which the temp was live.
|
||||
|
||||
Introduce tcg_temp_ebb_reset_freed and use before tcg_optimize,
|
||||
as well as replacing the equivalent in plugin_gen_inject and
|
||||
tcg_func_start.
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: fb04ab7ddd8 ("tcg/optimize: Lower TCG_COND_TST{EQ,NE} if unsupported")
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2711
|
||||
Reported-by: wannacu <wannacu2049@gmail.com>
|
||||
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||||
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
|
||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
(cherry picked from commit 04e006ab36a8565b92d4e21dd346367fbade7d74)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
accel/tcg/plugin-gen.c | 2 +-
|
||||
include/tcg/tcg-temp-internal.h | 6 ++++++
|
||||
tcg/tcg.c | 5 ++++-
|
||||
3 files changed, 11 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
|
||||
index 0f47bfbb48..1ef075552c 100644
|
||||
--- a/accel/tcg/plugin-gen.c
|
||||
+++ b/accel/tcg/plugin-gen.c
|
||||
@@ -275,7 +275,7 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb)
|
||||
* that might be live within the existing opcode stream.
|
||||
* The simplest solution is to release them all and create new.
|
||||
*/
|
||||
- memset(tcg_ctx->free_temps, 0, sizeof(tcg_ctx->free_temps));
|
||||
+ tcg_temp_ebb_reset_freed(tcg_ctx);
|
||||
|
||||
QTAILQ_FOREACH_SAFE(op, &tcg_ctx->ops, link, next) {
|
||||
switch (op->opc) {
|
||||
diff --git a/include/tcg/tcg-temp-internal.h b/include/tcg/tcg-temp-internal.h
|
||||
index 44192c55a9..98f91e68b7 100644
|
||||
--- a/include/tcg/tcg-temp-internal.h
|
||||
+++ b/include/tcg/tcg-temp-internal.h
|
||||
@@ -42,4 +42,10 @@ TCGv_i64 tcg_temp_ebb_new_i64(void);
|
||||
TCGv_ptr tcg_temp_ebb_new_ptr(void);
|
||||
TCGv_i128 tcg_temp_ebb_new_i128(void);
|
||||
|
||||
+/* Forget all freed EBB temps, so that new allocations produce new temps. */
|
||||
+static inline void tcg_temp_ebb_reset_freed(TCGContext *s)
|
||||
+{
|
||||
+ memset(s->free_temps, 0, sizeof(s->free_temps));
|
||||
+}
|
||||
+
|
||||
#endif /* TCG_TEMP_FREE_H */
|
||||
diff --git a/tcg/tcg.c b/tcg/tcg.c
|
||||
index 0babae1b88..4578b185be 100644
|
||||
--- a/tcg/tcg.c
|
||||
+++ b/tcg/tcg.c
|
||||
@@ -1489,7 +1489,7 @@ void tcg_func_start(TCGContext *s)
|
||||
s->nb_temps = s->nb_globals;
|
||||
|
||||
/* No temps have been previously allocated for size or locality. */
|
||||
- memset(s->free_temps, 0, sizeof(s->free_temps));
|
||||
+ tcg_temp_ebb_reset_freed(s);
|
||||
|
||||
/* No constant temps have been previously allocated. */
|
||||
for (int i = 0; i < TCG_TYPE_COUNT; ++i) {
|
||||
@@ -6120,6 +6120,9 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, uint64_t pc_start)
|
||||
}
|
||||
#endif
|
||||
|
||||
+ /* Do not reuse any EBB that may be allocated within the TB. */
|
||||
+ tcg_temp_ebb_reset_freed(s);
|
||||
+
|
||||
tcg_optimize(s);
|
||||
|
||||
reachable_code_pass(s);
|
149
debian/patches/extra/0004-target-i386-Reset-TSCs-of-parked-vCPUs-too-on-VM-res.patch
vendored
Normal file
149
debian/patches/extra/0004-target-i386-Reset-TSCs-of-parked-vCPUs-too-on-VM-res.patch
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
|
||||
Date: Thu, 12 Dec 2024 15:51:15 +0100
|
||||
Subject: [PATCH] target/i386: Reset TSCs of parked vCPUs too on VM reset
|
||||
|
||||
Since commit 5286c3662294 ("target/i386: properly reset TSC on reset")
|
||||
QEMU writes the special value of "1" to each online vCPU TSC on VM reset
|
||||
to reset it.
|
||||
|
||||
However parked vCPUs don't get that handling and due to that their TSCs
|
||||
get desynchronized when the VM gets reset.
|
||||
This in turn causes KVM to turn off PVCLOCK_TSC_STABLE_BIT in its exported
|
||||
PV clock.
|
||||
Note that KVM has no understanding of vCPU being currently parked.
|
||||
|
||||
Without PVCLOCK_TSC_STABLE_BIT the sched clock is marked unstable in
|
||||
the guest's kvm_sched_clock_init().
|
||||
This causes a performance regressions to show in some tests.
|
||||
|
||||
Fix this issue by writing the special value of "1" also to TSCs of parked
|
||||
vCPUs on VM reset.
|
||||
|
||||
Reproducing the issue:
|
||||
1) Boot a VM with "-smp 2,maxcpus=3" or similar
|
||||
|
||||
2) device_add host-x86_64-cpu,id=vcpu,node-id=0,socket-id=0,core-id=2,thread-id=0
|
||||
|
||||
3) Wait a few seconds
|
||||
|
||||
4) device_del vcpu
|
||||
|
||||
5) Inside the VM run:
|
||||
# echo "t" >/proc/sysrq-trigger; dmesg | grep sched_clock_stable
|
||||
Observe the sched_clock_stable() value is 1.
|
||||
|
||||
6) Reboot the VM
|
||||
|
||||
7) Once the VM boots once again run inside it:
|
||||
# echo "t" >/proc/sysrq-trigger; dmesg | grep sched_clock_stable
|
||||
Observe the sched_clock_stable() value is now 0.
|
||||
|
||||
Fixes: 5286c3662294 ("target/i386: properly reset TSC on reset")
|
||||
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
|
||||
Link: https://lore.kernel.org/r/5a605a88e9a231386dc803c60f5fed9b48108139.1734014926.git.maciej.szmigiero@oracle.com
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
(cherry picked from commit 3f2a05b31ee9ce2ddb6c75a9bc3f5e7f7af9a76f)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
accel/kvm/kvm-all.c | 11 +++++++++++
|
||||
configs/targets/i386-softmmu.mak | 1 +
|
||||
configs/targets/x86_64-softmmu.mak | 1 +
|
||||
include/sysemu/kvm.h | 8 ++++++++
|
||||
target/i386/kvm/kvm.c | 15 +++++++++++++++
|
||||
5 files changed, 36 insertions(+)
|
||||
|
||||
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
|
||||
index 801cff16a5..dec1d1c16a 100644
|
||||
--- a/accel/kvm/kvm-all.c
|
||||
+++ b/accel/kvm/kvm-all.c
|
||||
@@ -437,6 +437,16 @@ int kvm_unpark_vcpu(KVMState *s, unsigned long vcpu_id)
|
||||
return kvm_fd;
|
||||
}
|
||||
|
||||
+static void kvm_reset_parked_vcpus(void *param)
|
||||
+{
|
||||
+ KVMState *s = param;
|
||||
+ struct KVMParkedVcpu *cpu;
|
||||
+
|
||||
+ QLIST_FOREACH(cpu, &s->kvm_parked_vcpus, node) {
|
||||
+ kvm_arch_reset_parked_vcpu(cpu->vcpu_id, cpu->kvm_fd);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
int kvm_create_vcpu(CPUState *cpu)
|
||||
{
|
||||
unsigned long vcpu_id = kvm_arch_vcpu_id(cpu);
|
||||
@@ -2728,6 +2738,7 @@ static int kvm_init(MachineState *ms)
|
||||
}
|
||||
|
||||
qemu_register_reset(kvm_unpoison_all, NULL);
|
||||
+ qemu_register_reset(kvm_reset_parked_vcpus, s);
|
||||
|
||||
if (s->kernel_irqchip_allowed) {
|
||||
kvm_irqchip_create(s);
|
||||
diff --git a/configs/targets/i386-softmmu.mak b/configs/targets/i386-softmmu.mak
|
||||
index 2ac69d5ba3..2eb0e86250 100644
|
||||
--- a/configs/targets/i386-softmmu.mak
|
||||
+++ b/configs/targets/i386-softmmu.mak
|
||||
@@ -1,4 +1,5 @@
|
||||
TARGET_ARCH=i386
|
||||
TARGET_SUPPORTS_MTTCG=y
|
||||
TARGET_KVM_HAVE_GUEST_DEBUG=y
|
||||
+TARGET_KVM_HAVE_RESET_PARKED_VCPU=y
|
||||
TARGET_XML_FILES= gdb-xml/i386-32bit.xml
|
||||
diff --git a/configs/targets/x86_64-softmmu.mak b/configs/targets/x86_64-softmmu.mak
|
||||
index e12ac3dc59..920e9a4200 100644
|
||||
--- a/configs/targets/x86_64-softmmu.mak
|
||||
+++ b/configs/targets/x86_64-softmmu.mak
|
||||
@@ -2,4 +2,5 @@ TARGET_ARCH=x86_64
|
||||
TARGET_BASE_ARCH=i386
|
||||
TARGET_SUPPORTS_MTTCG=y
|
||||
TARGET_KVM_HAVE_GUEST_DEBUG=y
|
||||
+TARGET_KVM_HAVE_RESET_PARKED_VCPU=y
|
||||
TARGET_XML_FILES= gdb-xml/i386-64bit.xml
|
||||
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
|
||||
index c3a60b2890..ab17c09a55 100644
|
||||
--- a/include/sysemu/kvm.h
|
||||
+++ b/include/sysemu/kvm.h
|
||||
@@ -377,6 +377,14 @@ int kvm_arch_init(MachineState *ms, KVMState *s);
|
||||
int kvm_arch_init_vcpu(CPUState *cpu);
|
||||
int kvm_arch_destroy_vcpu(CPUState *cpu);
|
||||
|
||||
+#ifdef TARGET_KVM_HAVE_RESET_PARKED_VCPU
|
||||
+void kvm_arch_reset_parked_vcpu(unsigned long vcpu_id, int kvm_fd);
|
||||
+#else
|
||||
+static inline void kvm_arch_reset_parked_vcpu(unsigned long vcpu_id, int kvm_fd)
|
||||
+{
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
bool kvm_vcpu_id_is_valid(int vcpu_id);
|
||||
|
||||
/* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */
|
||||
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
|
||||
index 8e17942c3b..2ff618fbf1 100644
|
||||
--- a/target/i386/kvm/kvm.c
|
||||
+++ b/target/i386/kvm/kvm.c
|
||||
@@ -2415,6 +2415,21 @@ void kvm_arch_after_reset_vcpu(X86CPU *cpu)
|
||||
}
|
||||
}
|
||||
|
||||
+void kvm_arch_reset_parked_vcpu(unsigned long vcpu_id, int kvm_fd)
|
||||
+{
|
||||
+ g_autofree struct kvm_msrs *msrs = NULL;
|
||||
+
|
||||
+ msrs = g_malloc0(sizeof(*msrs) + sizeof(msrs->entries[0]));
|
||||
+ msrs->entries[0].index = MSR_IA32_TSC;
|
||||
+ msrs->entries[0].data = 1; /* match the value in x86_cpu_reset() */
|
||||
+ msrs->nmsrs++;
|
||||
+
|
||||
+ if (ioctl(kvm_fd, KVM_SET_MSRS, msrs) != 1) {
|
||||
+ warn_report("parked vCPU %lu TSC reset failed: %d",
|
||||
+ vcpu_id, errno);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void kvm_arch_do_init_vcpu(X86CPU *cpu)
|
||||
{
|
||||
CPUX86State *env = &cpu->env;
|
@@ -1,36 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
||||
Date: Fri, 28 Apr 2023 19:48:06 +0400
|
||||
Subject: [PATCH] ui: return NULL when getting cursor without a console
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
VNC may try to get the current cursor even when there are no consoles
|
||||
and crashes. Simple reproducer is qemu with -nodefaults.
|
||||
|
||||
Fixes: (again)
|
||||
https://gitlab.com/qemu-project/qemu/-/issues/1548
|
||||
|
||||
Fixes: commit 385ac97f8 ("ui: keep current cursor with QemuConsole")
|
||||
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
(picked up from https://lists.nongnu.org/archive/html/qemu-devel/2023-04/msg05598.html)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
ui/console.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ui/console.c b/ui/console.c
|
||||
index e173731e20..7461446e71 100644
|
||||
--- a/ui/console.c
|
||||
+++ b/ui/console.c
|
||||
@@ -2306,7 +2306,7 @@ QEMUCursor *qemu_console_get_cursor(QemuConsole *con)
|
||||
if (con == NULL) {
|
||||
con = active_console;
|
||||
}
|
||||
- return con->cursor;
|
||||
+ return con ? con->cursor : NULL;
|
||||
}
|
||||
|
||||
bool qemu_console_is_visible(QemuConsole *con)
|
41
debian/patches/extra/0005-i386-cpu-Mark-avx10_version-filtered-when-prefix-is-.patch
vendored
Normal file
41
debian/patches/extra/0005-i386-cpu-Mark-avx10_version-filtered-when-prefix-is-.patch
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zhao Liu <zhao1.liu@intel.com>
|
||||
Date: Wed, 6 Nov 2024 11:07:18 +0800
|
||||
Subject: [PATCH] i386/cpu: Mark avx10_version filtered when prefix is NULL
|
||||
|
||||
In x86_cpu_filter_features(), if host doesn't support AVX10, the
|
||||
configured avx10_version should be marked as filtered regardless of
|
||||
whether prefix is NULL or not.
|
||||
|
||||
Check prefix before warn_report() instead of checking for
|
||||
have_filtered_features.
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: commit bccfb846fd52 ("target/i386: add AVX10 feature and AVX10 version property")
|
||||
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
|
||||
Reviewed-by: Tao Su <tao1.su@linux.intel.com>
|
||||
Link: https://lore.kernel.org/r/20241106030728.553238-2-zhao1.liu@intel.com
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
(cherry picked from commit cf4c263551886964c5d58bd7b675b13fd497b402)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
target/i386/cpu.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
||||
index 3725dbbc4b..1981aeaba5 100644
|
||||
--- a/target/i386/cpu.c
|
||||
+++ b/target/i386/cpu.c
|
||||
@@ -7718,8 +7718,10 @@ static bool x86_cpu_filter_features(X86CPU *cpu, bool verbose)
|
||||
env->avx10_version = version;
|
||||
have_filtered_features = true;
|
||||
}
|
||||
- } else if (env->avx10_version && prefix) {
|
||||
- warn_report("%s: avx10.%d.", prefix, env->avx10_version);
|
||||
+ } else if (env->avx10_version) {
|
||||
+ if (prefix) {
|
||||
+ warn_report("%s: avx10.%d.", prefix, env->avx10_version);
|
||||
+ }
|
||||
have_filtered_features = true;
|
||||
}
|
||||
|
@@ -1,130 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Bulekov <alxndr@bu.edu>
|
||||
Date: Thu, 27 Apr 2023 17:10:06 -0400
|
||||
Subject: [PATCH] memory: prevent dma-reentracy issues
|
||||
|
||||
Add a flag to the DeviceState, when a device is engaged in PIO/MMIO/DMA.
|
||||
This flag is set/checked prior to calling a device's MemoryRegion
|
||||
handlers, and set when device code initiates DMA. The purpose of this
|
||||
flag is to prevent two types of DMA-based reentrancy issues:
|
||||
|
||||
1.) mmio -> dma -> mmio case
|
||||
2.) bh -> dma write -> mmio case
|
||||
|
||||
These issues have led to problems such as stack-exhaustion and
|
||||
use-after-frees.
|
||||
|
||||
Summary of the problem from Peter Maydell:
|
||||
https://lore.kernel.org/qemu-devel/CAFEAcA_23vc7hE3iaM-JVA6W38LK4hJoWae5KcknhPRD5fPBZA@mail.gmail.com
|
||||
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/62
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/540
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/541
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/556
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/557
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/827
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1282
|
||||
Resolves: CVE-2023-0330
|
||||
|
||||
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
||||
Message-Id: <20230427211013.2994127-2-alxndr@bu.edu>
|
||||
[thuth: Replace warn_report() with warn_report_once()]
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry-picked from commit a2e1753b8054344f32cf94f31c6399a58794a380)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
include/exec/memory.h | 5 +++++
|
||||
include/hw/qdev-core.h | 7 +++++++
|
||||
softmmu/memory.c | 16 ++++++++++++++++
|
||||
3 files changed, 28 insertions(+)
|
||||
|
||||
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
||||
index 15ade918ba..e45ce6061f 100644
|
||||
--- a/include/exec/memory.h
|
||||
+++ b/include/exec/memory.h
|
||||
@@ -767,6 +767,8 @@ struct MemoryRegion {
|
||||
bool is_iommu;
|
||||
RAMBlock *ram_block;
|
||||
Object *owner;
|
||||
+ /* owner as TYPE_DEVICE. Used for re-entrancy checks in MR access hotpath */
|
||||
+ DeviceState *dev;
|
||||
|
||||
const MemoryRegionOps *ops;
|
||||
void *opaque;
|
||||
@@ -791,6 +793,9 @@ struct MemoryRegion {
|
||||
unsigned ioeventfd_nb;
|
||||
MemoryRegionIoeventfd *ioeventfds;
|
||||
RamDiscardManager *rdm; /* Only for RAM */
|
||||
+
|
||||
+ /* For devices designed to perform re-entrant IO into their own IO MRs */
|
||||
+ bool disable_reentrancy_guard;
|
||||
};
|
||||
|
||||
struct IOMMUMemoryRegion {
|
||||
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
|
||||
index bd50ad5ee1..7623703943 100644
|
||||
--- a/include/hw/qdev-core.h
|
||||
+++ b/include/hw/qdev-core.h
|
||||
@@ -162,6 +162,10 @@ struct NamedClockList {
|
||||
QLIST_ENTRY(NamedClockList) node;
|
||||
};
|
||||
|
||||
+typedef struct {
|
||||
+ bool engaged_in_io;
|
||||
+} MemReentrancyGuard;
|
||||
+
|
||||
/**
|
||||
* DeviceState:
|
||||
* @realized: Indicates whether the device has been fully constructed.
|
||||
@@ -194,6 +198,9 @@ struct DeviceState {
|
||||
int alias_required_for_version;
|
||||
ResettableState reset;
|
||||
GSList *unplug_blockers;
|
||||
+
|
||||
+ /* Is the device currently in mmio/pio/dma? Used to prevent re-entrancy */
|
||||
+ MemReentrancyGuard mem_reentrancy_guard;
|
||||
};
|
||||
|
||||
struct DeviceListener {
|
||||
diff --git a/softmmu/memory.c b/softmmu/memory.c
|
||||
index b1a6cae6f5..b7b3386e9d 100644
|
||||
--- a/softmmu/memory.c
|
||||
+++ b/softmmu/memory.c
|
||||
@@ -542,6 +542,18 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
|
||||
access_size_max = 4;
|
||||
}
|
||||
|
||||
+ /* Do not allow more than one simultaneous access to a device's IO Regions */
|
||||
+ if (mr->dev && !mr->disable_reentrancy_guard &&
|
||||
+ !mr->ram_device && !mr->ram && !mr->rom_device && !mr->readonly) {
|
||||
+ if (mr->dev->mem_reentrancy_guard.engaged_in_io) {
|
||||
+ warn_report_once("Blocked re-entrant IO on MemoryRegion: "
|
||||
+ "%s at addr: 0x%" HWADDR_PRIX,
|
||||
+ memory_region_name(mr), addr);
|
||||
+ return MEMTX_ACCESS_ERROR;
|
||||
+ }
|
||||
+ mr->dev->mem_reentrancy_guard.engaged_in_io = true;
|
||||
+ }
|
||||
+
|
||||
/* FIXME: support unaligned access? */
|
||||
access_size = MAX(MIN(size, access_size_max), access_size_min);
|
||||
access_mask = MAKE_64BIT_MASK(0, access_size * 8);
|
||||
@@ -556,6 +568,9 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
|
||||
access_mask, attrs);
|
||||
}
|
||||
}
|
||||
+ if (mr->dev) {
|
||||
+ mr->dev->mem_reentrancy_guard.engaged_in_io = false;
|
||||
+ }
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -1170,6 +1185,7 @@ static void memory_region_do_init(MemoryRegion *mr,
|
||||
}
|
||||
mr->name = g_strdup(name);
|
||||
mr->owner = owner;
|
||||
+ mr->dev = (DeviceState *) object_dynamic_cast(mr->owner, TYPE_DEVICE);
|
||||
mr->ram_block = NULL;
|
||||
|
||||
if (name) {
|
@@ -1,39 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Bulekov <alxndr@bu.edu>
|
||||
Date: Thu, 27 Apr 2023 17:10:10 -0400
|
||||
Subject: [PATCH] lsi53c895a: disable reentrancy detection for script RAM
|
||||
|
||||
As the code is designed to use the memory APIs to access the script ram,
|
||||
disable reentrancy checks for the pseudo-RAM ram_io MemoryRegion.
|
||||
|
||||
In the future, ram_io may be converted from an IO to a proper RAM MemoryRegion.
|
||||
|
||||
Reported-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
||||
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Message-Id: <20230427211013.2994127-6-alxndr@bu.edu>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry-picked from commit bfd6e7ae6a72b84e2eb9574f56e6ec037f05182c)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/scsi/lsi53c895a.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
|
||||
index bbf32d3f73..17af67935f 100644
|
||||
--- a/hw/scsi/lsi53c895a.c
|
||||
+++ b/hw/scsi/lsi53c895a.c
|
||||
@@ -2313,6 +2313,12 @@ static void lsi_scsi_realize(PCIDevice *dev, Error **errp)
|
||||
memory_region_init_io(&s->io_io, OBJECT(s), &lsi_io_ops, s,
|
||||
"lsi-io", 256);
|
||||
|
||||
+ /*
|
||||
+ * Since we use the address-space API to interact with ram_io, disable the
|
||||
+ * re-entrancy guard.
|
||||
+ */
|
||||
+ s->ram_io.disable_reentrancy_guard = true;
|
||||
+
|
||||
address_space_init(&s->pci_io_as, pci_address_space_io(dev), "lsi-pci-io");
|
||||
qdev_init_gpio_out(d, &s->ext_irq, 1);
|
||||
|
67
debian/patches/extra/0006-net-Fix-announce_self.patch
vendored
Normal file
67
debian/patches/extra/0006-net-Fix-announce_self.patch
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Laurent Vivier <lvivier@redhat.com>
|
||||
Date: Fri, 17 Jan 2025 12:17:08 +0100
|
||||
Subject: [PATCH] net: Fix announce_self
|
||||
|
||||
b9ad513e1876 ("net: Remove receive_raw()") adds an iovec entry
|
||||
in qemu_deliver_packet_iov() to add the virtio-net header
|
||||
in the data when QEMU_NET_PACKET_FLAG_RAW is set but forgets
|
||||
to increase the number of iovec entries in the array, so
|
||||
receive_iov() will only send the first entry (the virtio-net
|
||||
entry, full of 0) and no data. The packet will be discarded.
|
||||
|
||||
The only user of QEMU_NET_PACKET_FLAG_RAW is announce_self.
|
||||
|
||||
We can see the problem with tcpdump:
|
||||
|
||||
- QEMU parameters:
|
||||
|
||||
.. -monitor stdio \
|
||||
-netdev bridge,id=netdev0,br=virbr0 \
|
||||
-device virtio-net,mac=9a:2b:2c:2d:2e:2f,netdev=netdev0 \
|
||||
|
||||
- HMP command:
|
||||
|
||||
(qemu) announce_self
|
||||
|
||||
- TCP dump:
|
||||
|
||||
$ sudo tcpdump -nxi virbr0
|
||||
|
||||
without the fix:
|
||||
|
||||
<nothing>
|
||||
|
||||
with the fix:
|
||||
|
||||
ARP, Reverse Request who-is 9a:2b:2c:2d:2e:2f tell 9a:2b:2c:2d:2e:2f, length 46
|
||||
0x0000: 0001 0800 0604 0003 9a2b 2c2d 2e2f 0000
|
||||
0x0010: 0000 9a2b 2c2d 2e2f 0000 0000 0000 0000
|
||||
0x0020: 0000 0000 0000 0000 0000 0000 0000
|
||||
|
||||
Reported-by: Xiaohui Li <xiaohli@redhat.com>
|
||||
Bug: https://issues.redhat.com/browse/RHEL-73891
|
||||
Fixes: b9ad513e1876 ("net: Remove receive_raw()")
|
||||
Cc: akihiko.odaki@daynix.com
|
||||
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
|
||||
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
|
||||
Acked-by: Jason Wang <jasowang@redhat.com>
|
||||
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
|
||||
(picked from https://lore.kernel.org/qemu-devel/20250117111709.970789-2-lvivier@redhat.com/)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
net/net.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/net/net.c b/net/net.c
|
||||
index 7ef6885876..fefa701bb2 100644
|
||||
--- a/net/net.c
|
||||
+++ b/net/net.c
|
||||
@@ -822,6 +822,7 @@ static ssize_t qemu_deliver_packet_iov(NetClientState *sender,
|
||||
iov_copy[0].iov_len = nc->vnet_hdr_len;
|
||||
memcpy(&iov_copy[1], iov, iovcnt * sizeof(*iov));
|
||||
iov = iov_copy;
|
||||
+ iovcnt++;
|
||||
}
|
||||
|
||||
if (nc->info->receive_iov) {
|
@@ -1,37 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Bulekov <alxndr@bu.edu>
|
||||
Date: Thu, 27 Apr 2023 17:10:11 -0400
|
||||
Subject: [PATCH] bcm2835_property: disable reentrancy detection for iomem
|
||||
|
||||
As the code is designed for re-entrant calls from bcm2835_property to
|
||||
bcm2835_mbox and back into bcm2835_property, mark iomem as
|
||||
reentrancy-safe.
|
||||
|
||||
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
||||
Message-Id: <20230427211013.2994127-7-alxndr@bu.edu>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry-picked from commit 985c4a4e547afb9573b6bd6843d20eb2c3d1d1cd)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/misc/bcm2835_property.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
|
||||
index 890ae7bae5..de056ea2df 100644
|
||||
--- a/hw/misc/bcm2835_property.c
|
||||
+++ b/hw/misc/bcm2835_property.c
|
||||
@@ -382,6 +382,13 @@ static void bcm2835_property_init(Object *obj)
|
||||
|
||||
memory_region_init_io(&s->iomem, OBJECT(s), &bcm2835_property_ops, s,
|
||||
TYPE_BCM2835_PROPERTY, 0x10);
|
||||
+
|
||||
+ /*
|
||||
+ * bcm2835_property_ops call into bcm2835_mbox, which in-turn reads from
|
||||
+ * iomem. As such, mark iomem as re-entracy safe.
|
||||
+ */
|
||||
+ s->iomem.disable_reentrancy_guard = true;
|
||||
+
|
||||
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
|
||||
sysbus_init_irq(SYS_BUS_DEVICE(s), &s->mbox_irq);
|
||||
}
|
67
debian/patches/extra/0007-net-dump-Correctly-compute-Ethernet-packet-offset.patch
vendored
Normal file
67
debian/patches/extra/0007-net-dump-Correctly-compute-Ethernet-packet-offset.patch
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Laurent Vivier <lvivier@redhat.com>
|
||||
Date: Fri, 17 Jan 2025 12:17:09 +0100
|
||||
Subject: [PATCH] net/dump: Correctly compute Ethernet packet offset
|
||||
|
||||
When a packet is sent with QEMU_NET_PACKET_FLAG_RAW by QEMU it
|
||||
never includes virtio-net header even if qemu_get_vnet_hdr_len()
|
||||
is not 0, and filter-dump is not managing this case.
|
||||
|
||||
The only user of QEMU_NET_PACKET_FLAG_RAW is announce_self,
|
||||
we can show the problem using it and tcpddump:
|
||||
|
||||
- QEMU parameters:
|
||||
|
||||
.. -monitor stdio \
|
||||
-netdev bridge,id=netdev0,br=virbr0 \
|
||||
-device virtio-net,mac=9a:2b:2c:2d:2e:2f,netdev=netdev0 \
|
||||
-object filter-dump,netdev=netdev0,file=log.pcap,id=pcap0
|
||||
|
||||
- HMP command:
|
||||
|
||||
(qemu) announce_self
|
||||
|
||||
- TCP dump:
|
||||
|
||||
$ tcpdump -nxr log.pcap
|
||||
|
||||
without the fix:
|
||||
|
||||
08:00:06:04:00:03 > 2e:2f:80:35:00:01, ethertype Unknown (0x9a2b), length 50:
|
||||
0x0000: 2c2d 2e2f 0000 0000 9a2b 2c2d 2e2f 0000
|
||||
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x0020: 0000 0000
|
||||
|
||||
with the fix:
|
||||
|
||||
ARP, Reverse Request who-is 9a:2b:2c:2d:2e:2f tell 9a:2b:2c:2d:2e:2f, length 46
|
||||
0x0000: 0001 0800 0604 0003 9a2b 2c2d 2e2f 0000
|
||||
0x0010: 0000 9a2b 2c2d 2e2f 0000 0000 0000 0000
|
||||
0x0020: 0000 0000 0000 0000 0000 0000 0000
|
||||
|
||||
Fixes: 481c52320a26 ("net: Strip virtio-net header when dumping")
|
||||
Cc: akihiko.odaki@daynix.com
|
||||
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
|
||||
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
|
||||
Acked-by: Jason Wang <jasowang@redhat.com>
|
||||
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
|
||||
(picked from https://lore.kernel.org/qemu-devel/20250117111709.970789-3-lvivier@redhat.com/)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
net/dump.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/net/dump.c b/net/dump.c
|
||||
index 956e34a123..42ab8d7716 100644
|
||||
--- a/net/dump.c
|
||||
+++ b/net/dump.c
|
||||
@@ -155,7 +155,8 @@ static ssize_t filter_dump_receive_iov(NetFilterState *nf, NetClientState *sndr,
|
||||
{
|
||||
NetFilterDumpState *nfds = FILTER_DUMP(nf);
|
||||
|
||||
- dump_receive_iov(&nfds->ds, iov, iovcnt, qemu_get_vnet_hdr_len(nf->netdev));
|
||||
+ dump_receive_iov(&nfds->ds, iov, iovcnt, flags & QEMU_NET_PACKET_FLAG_RAW ?
|
||||
+ 0 : qemu_get_vnet_hdr_len(nf->netdev));
|
||||
return 0;
|
||||
}
|
||||
|
96
debian/patches/extra/0008-pci-acpi-Windows-PCI-Label-Id-bug-workaround.patch
vendored
Normal file
96
debian/patches/extra/0008-pci-acpi-Windows-PCI-Label-Id-bug-workaround.patch
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Igor Mammedov <imammedo@redhat.com>
|
||||
Date: Wed, 15 Jan 2025 13:53:41 +0100
|
||||
Subject: [PATCH] pci: acpi: Windows 'PCI Label Id' bug workaround
|
||||
|
||||
Current versions of Windows call _DSM(func=7) regardless
|
||||
of whether it is supported or not. It leads to NICs having bogus
|
||||
'PCI Label Id = 0', where none should be set at all.
|
||||
|
||||
Also presence of 'PCI Label Id' triggers another Windows bug
|
||||
on localized versions that leads to hangs. The later bug is fixed
|
||||
in latest updates for 'Windows Server' but not in consumer
|
||||
versions of Windows (and there is no plans to fix it
|
||||
as far as I'm aware).
|
||||
|
||||
Given it's easy, implement Microsoft suggested workaround
|
||||
(return invalid Package) so that affected Windows versions
|
||||
could boot on QEMU.
|
||||
This would effectvely remove bogus 'PCI Label Id's on NICs,
|
||||
but MS teem confirmed that flipping 'PCI Label Id' should not
|
||||
change 'Network Connection' ennumeration, so it should be safe
|
||||
for QEMU to change _DSM without any compat code.
|
||||
|
||||
Smoke tested with WinXP and WS2022
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/774
|
||||
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
||||
Message-Id: <20250115125342.3883374-3-imammedo@redhat.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit 0b053391985abcc40b16ac8fc4a7f6588d1d95c1)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/i386/acpi-build.c | 33 +++++++++++++++++++++++----------
|
||||
1 file changed, 23 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
|
||||
index 9fcc2897b8..f7b961e04c 100644
|
||||
--- a/hw/i386/acpi-build.c
|
||||
+++ b/hw/i386/acpi-build.c
|
||||
@@ -654,6 +654,7 @@ static Aml *aml_pci_pdsm(void)
|
||||
Aml *acpi_index = aml_local(2);
|
||||
Aml *zero = aml_int(0);
|
||||
Aml *one = aml_int(1);
|
||||
+ Aml *not_supp = aml_int(0xFFFFFFFF);
|
||||
Aml *func = aml_arg(2);
|
||||
Aml *params = aml_arg(4);
|
||||
Aml *bnum = aml_derefof(aml_index(params, aml_int(0)));
|
||||
@@ -678,7 +679,7 @@ static Aml *aml_pci_pdsm(void)
|
||||
*/
|
||||
ifctx1 = aml_if(aml_lnot(
|
||||
aml_or(aml_equal(acpi_index, zero),
|
||||
- aml_equal(acpi_index, aml_int(0xFFFFFFFF)), NULL)
|
||||
+ aml_equal(acpi_index, not_supp), NULL)
|
||||
));
|
||||
{
|
||||
/* have supported functions */
|
||||
@@ -704,18 +705,30 @@ static Aml *aml_pci_pdsm(void)
|
||||
{
|
||||
Aml *pkg = aml_package(2);
|
||||
|
||||
- aml_append(pkg, zero);
|
||||
- /*
|
||||
- * optional, if not impl. should return null string
|
||||
- */
|
||||
- aml_append(pkg, aml_string("%s", ""));
|
||||
- aml_append(ifctx, aml_store(pkg, ret));
|
||||
-
|
||||
aml_append(ifctx, aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
|
||||
+ aml_append(ifctx, aml_store(pkg, ret));
|
||||
/*
|
||||
- * update acpi-index to actual value
|
||||
+ * Windows calls func=7 without checking if it's available,
|
||||
+ * as workaround Microsoft has suggested to return invalid for func7
|
||||
+ * Package, so return 2 elements package but only initialize elements
|
||||
+ * when acpi_index is supported and leave them uninitialized, which
|
||||
+ * leads elements to being Uninitialized ObjectType and should trip
|
||||
+ * Windows into discarding result as an unexpected and prevent setting
|
||||
+ * bogus 'PCI Label' on the device.
|
||||
*/
|
||||
- aml_append(ifctx, aml_store(acpi_index, aml_index(ret, zero)));
|
||||
+ ifctx1 = aml_if(aml_lnot(aml_lor(
|
||||
+ aml_equal(acpi_index, zero), aml_equal(acpi_index, not_supp)
|
||||
+ )));
|
||||
+ {
|
||||
+ aml_append(ifctx1, aml_store(acpi_index, aml_index(ret, zero)));
|
||||
+ /*
|
||||
+ * optional, if not impl. should return null string
|
||||
+ */
|
||||
+ aml_append(ifctx1, aml_store(aml_string("%s", ""),
|
||||
+ aml_index(ret, one)));
|
||||
+ }
|
||||
+ aml_append(ifctx, ifctx1);
|
||||
+
|
||||
aml_append(ifctx, aml_return(ret));
|
||||
}
|
||||
|
@@ -1,35 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Bulekov <alxndr@bu.edu>
|
||||
Date: Thu, 27 Apr 2023 17:10:12 -0400
|
||||
Subject: [PATCH] raven: disable reentrancy detection for iomem
|
||||
|
||||
As the code is designed for re-entrant calls from raven_io_ops to
|
||||
pci-conf, mark raven_io_ops as reentrancy-safe.
|
||||
|
||||
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Message-Id: <20230427211013.2994127-8-alxndr@bu.edu>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry-picked from commit 6dad5a6810d9c60ca320d01276f6133bbcfa1fc7)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/pci-host/raven.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c
|
||||
index 072ffe3c5e..9a11ac4b2b 100644
|
||||
--- a/hw/pci-host/raven.c
|
||||
+++ b/hw/pci-host/raven.c
|
||||
@@ -294,6 +294,13 @@ static void raven_pcihost_initfn(Object *obj)
|
||||
memory_region_init(&s->pci_memory, obj, "pci-memory", 0x3f000000);
|
||||
address_space_init(&s->pci_io_as, &s->pci_io, "raven-io");
|
||||
|
||||
+ /*
|
||||
+ * Raven's raven_io_ops use the address-space API to access pci-conf-idx
|
||||
+ * (which is also owned by the raven device). As such, mark the
|
||||
+ * pci_io_non_contiguous as re-entrancy safe.
|
||||
+ */
|
||||
+ s->pci_io_non_contiguous.disable_reentrancy_guard = true;
|
||||
+
|
||||
/* CPU address space */
|
||||
memory_region_add_subregion(address_space_mem, PCI_IO_BASE_ADDR,
|
||||
&s->pci_io);
|
@@ -1,36 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Bulekov <alxndr@bu.edu>
|
||||
Date: Thu, 27 Apr 2023 17:10:13 -0400
|
||||
Subject: [PATCH] apic: disable reentrancy detection for apic-msi
|
||||
|
||||
As the code is designed for re-entrant calls to apic-msi, mark apic-msi
|
||||
as reentrancy-safe.
|
||||
|
||||
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Message-Id: <20230427211013.2994127-9-alxndr@bu.edu>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
(cherry-picked from commit 50795ee051a342c681a9b45671c552fbd6274db8)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/intc/apic.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/hw/intc/apic.c b/hw/intc/apic.c
|
||||
index 20b5a94073..ac3d47d231 100644
|
||||
--- a/hw/intc/apic.c
|
||||
+++ b/hw/intc/apic.c
|
||||
@@ -885,6 +885,13 @@ static void apic_realize(DeviceState *dev, Error **errp)
|
||||
memory_region_init_io(&s->io_memory, OBJECT(s), &apic_io_ops, s, "apic-msi",
|
||||
APIC_SPACE_SIZE);
|
||||
|
||||
+ /*
|
||||
+ * apic-msi's apic_mem_write can call into ioapic_eoi_broadcast, which can
|
||||
+ * write back to apic-msi. As such mark the apic-msi region re-entrancy
|
||||
+ * safe.
|
||||
+ */
|
||||
+ s->io_memory.disable_reentrancy_guard = true;
|
||||
+
|
||||
s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, apic_timer, s);
|
||||
local_apics[s->id] = s;
|
||||
|
53
debian/patches/extra/0009-hw-usb-hcd-xhci-pci-Use-modulo-to-select-MSI-vector-.patch
vendored
Normal file
53
debian/patches/extra/0009-hw-usb-hcd-xhci-pci-Use-modulo-to-select-MSI-vector-.patch
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Dennis-Jordan <phil@philjordan.eu>
|
||||
Date: Fri, 13 Dec 2024 17:06:14 +0100
|
||||
Subject: [PATCH] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per
|
||||
spec
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
QEMU would crash with a failed assertion if the XHCI controller
|
||||
attempted to raise the interrupt on an interrupter corresponding
|
||||
to a MSI vector with a higher index than the highest configured
|
||||
for the device by the guest driver.
|
||||
|
||||
This behaviour is correct on the MSI/PCI side: per PCI 3.0 spec,
|
||||
devices must ensure they do not send MSI notifications for
|
||||
vectors beyond the range of those allocated by the system/driver
|
||||
software. Unlike MSI-X, there is no generic way for handling
|
||||
aliasing in the case of fewer allocated vectors than requested,
|
||||
so the specifics are up to device implementors. (Section
|
||||
6.8.3.4. "Sending Messages")
|
||||
|
||||
It turns out the XHCI spec (Implementation Note in section 4.17,
|
||||
"Interrupters") requires that the host controller signal the MSI
|
||||
vector with the number computed by taking the interrupter number
|
||||
modulo the number of enabled MSI vectors.
|
||||
|
||||
This change introduces that modulo calculation, fixing the
|
||||
failed assertion. This makes the device work correctly in MSI mode
|
||||
with macOS's XHCI driver, which only allocates a single vector.
|
||||
|
||||
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
|
||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
Message-ID: <20250112210056.16658-2-phil@philjordan.eu>
|
||||
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
(cherry picked from commit bb5b7fced6b5d3334ab20702fc846e47bb1fb731)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/usb/hcd-xhci-pci.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
|
||||
index a039f5778a..516e6909d2 100644
|
||||
--- a/hw/usb/hcd-xhci-pci.c
|
||||
+++ b/hw/usb/hcd-xhci-pci.c
|
||||
@@ -74,6 +74,7 @@ static bool xhci_pci_intr_raise(XHCIState *xhci, int n, bool level)
|
||||
}
|
||||
|
||||
if (msi_enabled(pci_dev) && level) {
|
||||
+ n %= msi_nr_vectors_allocated(pci_dev);
|
||||
msi_notify(pci_dev, n);
|
||||
return true;
|
||||
}
|
63
debian/patches/extra/0010-pci-ensure-valid-link-status-bits-for-downstream-por.patch
vendored
Normal file
63
debian/patches/extra/0010-pci-ensure-valid-link-status-bits-for-downstream-por.patch
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Ott <sebott@redhat.com>
|
||||
Date: Tue, 3 Dec 2024 13:19:28 +0100
|
||||
Subject: [PATCH] pci: ensure valid link status bits for downstream ports
|
||||
|
||||
PCI hotplug for downstream endpoints on arm fails because Linux'
|
||||
PCIe hotplug driver doesn't like the QEMU provided LNKSTA:
|
||||
|
||||
pcieport 0000:08:01.0: pciehp: Slot(2): Card present
|
||||
pcieport 0000:08:01.0: pciehp: Slot(2): Link Up
|
||||
pcieport 0000:08:01.0: pciehp: Slot(2): Cannot train link: status 0x2000
|
||||
|
||||
There's 2 cases where LNKSTA isn't setup properly:
|
||||
* the downstream device has no express capability
|
||||
* max link width of the bridge is 0
|
||||
|
||||
Move the sanity checks added via 88c869198aa63
|
||||
("pci: Sanity test minimum downstream LNKSTA") outside of the
|
||||
branch to make sure downstream ports always have a valid LNKSTA.
|
||||
|
||||
Signed-off-by: Sebastian Ott <sebott@redhat.com>
|
||||
Tested-by: Zhenyu Zhang <zhenyzha@redhat.com>
|
||||
Message-Id: <20241203121928.14861-1-sebott@redhat.com>
|
||||
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit 694632fd44987cc4618612a38ad151047524a590)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/pci/pcie.c | 12 ++++++++----
|
||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
|
||||
index 0b455c8654..1b12db6fa2 100644
|
||||
--- a/hw/pci/pcie.c
|
||||
+++ b/hw/pci/pcie.c
|
||||
@@ -1113,18 +1113,22 @@ void pcie_sync_bridge_lnk(PCIDevice *bridge_dev)
|
||||
if ((lnksta & PCI_EXP_LNKSTA_NLW) > (lnkcap & PCI_EXP_LNKCAP_MLW)) {
|
||||
lnksta &= ~PCI_EXP_LNKSTA_NLW;
|
||||
lnksta |= lnkcap & PCI_EXP_LNKCAP_MLW;
|
||||
- } else if (!(lnksta & PCI_EXP_LNKSTA_NLW)) {
|
||||
- lnksta |= QEMU_PCI_EXP_LNKSTA_NLW(QEMU_PCI_EXP_LNK_X1);
|
||||
}
|
||||
|
||||
if ((lnksta & PCI_EXP_LNKSTA_CLS) > (lnkcap & PCI_EXP_LNKCAP_SLS)) {
|
||||
lnksta &= ~PCI_EXP_LNKSTA_CLS;
|
||||
lnksta |= lnkcap & PCI_EXP_LNKCAP_SLS;
|
||||
- } else if (!(lnksta & PCI_EXP_LNKSTA_CLS)) {
|
||||
- lnksta |= QEMU_PCI_EXP_LNKSTA_CLS(QEMU_PCI_EXP_LNK_2_5GT);
|
||||
}
|
||||
}
|
||||
|
||||
+ if (!(lnksta & PCI_EXP_LNKSTA_NLW)) {
|
||||
+ lnksta |= QEMU_PCI_EXP_LNKSTA_NLW(QEMU_PCI_EXP_LNK_X1);
|
||||
+ }
|
||||
+
|
||||
+ if (!(lnksta & PCI_EXP_LNKSTA_CLS)) {
|
||||
+ lnksta |= QEMU_PCI_EXP_LNKSTA_CLS(QEMU_PCI_EXP_LNK_2_5GT);
|
||||
+ }
|
||||
+
|
||||
pci_word_test_and_clear_mask(exp_cap + PCI_EXP_LNKSTA,
|
||||
PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW);
|
||||
pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA, lnksta &
|
36
debian/patches/extra/0011-pci-msix-Fix-msix-pba-read-vector-poll-end-calculati.patch
vendored
Normal file
36
debian/patches/extra/0011-pci-msix-Fix-msix-pba-read-vector-poll-end-calculati.patch
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Nicholas Piggin <npiggin@gmail.com>
|
||||
Date: Thu, 12 Dec 2024 22:04:02 +1000
|
||||
Subject: [PATCH] pci/msix: Fix msix pba read vector poll end calculation
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The end vector calculation has a bug that results in polling fewer
|
||||
than required vectors when reading at a non-zero offset in PBA memory.
|
||||
|
||||
Fixes: bbef882cc193 ("msi: add API to get notified about pending bit poll")
|
||||
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
|
||||
Message-Id: <20241212120402.1475053-1-npiggin@gmail.com>
|
||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit 42e2a7a0ab23784e44fcb18369e06067abc89305)
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/pci/msix.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/pci/msix.c b/hw/pci/msix.c
|
||||
index 487e49834e..cc6e79ec67 100644
|
||||
--- a/hw/pci/msix.c
|
||||
+++ b/hw/pci/msix.c
|
||||
@@ -250,7 +250,7 @@ static uint64_t msix_pba_mmio_read(void *opaque, hwaddr addr,
|
||||
PCIDevice *dev = opaque;
|
||||
if (dev->msix_vector_poll_notifier) {
|
||||
unsigned vector_start = addr * 8;
|
||||
- unsigned vector_end = MIN(addr + size * 8, dev->msix_entries_nr);
|
||||
+ unsigned vector_end = MIN((addr + size) * 8, dev->msix_entries_nr);
|
||||
dev->msix_vector_poll_notifier(dev, vector_start, vector_end);
|
||||
}
|
||||
|
1212
debian/patches/pve-qemu-8.0-vitastor.patch
vendored
1212
debian/patches/pve-qemu-8.0-vitastor.patch
vendored
File diff suppressed because it is too large
Load Diff
@@ -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 c2dee3f056..9681bd0434 100644
|
||||
index 90fa54352c..e2ea071315 100644
|
||||
--- a/block/file-posix.c
|
||||
+++ b/block/file-posix.c
|
||||
@@ -553,7 +553,7 @@ static QemuOptsList raw_runtime_opts = {
|
||||
@@ -564,7 +564,7 @@ static QemuOptsList raw_runtime_opts = {
|
||||
{
|
||||
.name = "locking",
|
||||
.type = QEMU_OPT_STRING,
|
||||
@@ -26,7 +26,7 @@ index c2dee3f056..9681bd0434 100644
|
||||
},
|
||||
{
|
||||
.name = "pr-manager",
|
||||
@@ -653,7 +653,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
@@ -664,7 +664,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
s->use_lock = false;
|
||||
break;
|
||||
case ON_OFF_AUTO_AUTO:
|
||||
|
@@ -9,12 +9,12 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/include/net/net.h b/include/net/net.h
|
||||
index 1448d00afb..d1601d32c1 100644
|
||||
index cdd5b109b0..653a37e9d1 100644
|
||||
--- a/include/net/net.h
|
||||
+++ b/include/net/net.h
|
||||
@@ -258,8 +258,8 @@ void netdev_add(QemuOpts *opts, Error **errp);
|
||||
@@ -305,8 +305,8 @@ void netdev_add(QemuOpts *opts, Error **errp);
|
||||
|
||||
int net_hub_id_for_client(NetClientState *nc, int *id);
|
||||
NetClientState *net_hub_port_find(int hub_id);
|
||||
|
||||
-#define DEFAULT_NETWORK_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifup"
|
||||
-#define DEFAULT_NETWORK_DOWN_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifdown"
|
||||
|
@@ -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 d243e290d3..3489b05ec4 100644
|
||||
index 4c239a6970..be09263fb0 100644
|
||||
--- a/target/i386/cpu.h
|
||||
+++ b/target/i386/cpu.h
|
||||
@@ -2203,9 +2203,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
|
||||
@@ -2475,9 +2475,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
|
||||
#define CPU_RESOLVING_TYPE TYPE_X86_CPU
|
||||
|
||||
#ifdef TARGET_X86_64
|
||||
|
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 9 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/ui/spice-core.c b/ui/spice-core.c
|
||||
index 52a59386d7..b20c25aee0 100644
|
||||
index bd9dbe03f1..a7ecaad9c7 100644
|
||||
--- a/ui/spice-core.c
|
||||
+++ b/ui/spice-core.c
|
||||
@@ -691,32 +691,35 @@ static void qemu_spice_init(void)
|
||||
@@ -690,32 +690,35 @@ static void qemu_spice_init(void)
|
||||
|
||||
if (tls_port) {
|
||||
x509_dir = qemu_opt_get(opts, "x509-dir");
|
||||
|
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 11 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/block/gluster.c b/block/gluster.c
|
||||
index 185a83e5e5..f11a40aa9e 100644
|
||||
index e9c038042b..c8457a5014 100644
|
||||
--- a/block/gluster.c
|
||||
+++ b/block/gluster.c
|
||||
@@ -43,7 +43,7 @@
|
||||
@@ -42,7 +42,7 @@
|
||||
#define GLUSTER_DEBUG_DEFAULT 4
|
||||
#define GLUSTER_DEBUG_MAX 9
|
||||
#define GLUSTER_OPT_LOGFILE "logfile"
|
||||
@@ -21,15 +21,15 @@ index 185a83e5e5..f11a40aa9e 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
|
||||
@@ -425,6 +425,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) {
|
||||
@@ -467,9 +468,15 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
|
||||
@@ -463,9 +464,15 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,7 @@ 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 978671411e..a4749f3b1b 100644
|
||||
index 04ed0e242e..728bce3b1e 100644
|
||||
--- a/block/rbd.c
|
||||
+++ b/block/rbd.c
|
||||
@@ -963,6 +963,8 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
||||
|
@@ -16,10 +16,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block/gluster.c b/block/gluster.c
|
||||
index f11a40aa9e..6756e6b886 100644
|
||||
index c8457a5014..c3a9555591 100644
|
||||
--- a/block/gluster.c
|
||||
+++ b/block/gluster.c
|
||||
@@ -58,6 +58,7 @@ typedef struct GlusterAIOCB {
|
||||
@@ -57,6 +57,7 @@ typedef struct GlusterAIOCB {
|
||||
int ret;
|
||||
Coroutine *coroutine;
|
||||
AioContext *aio_context;
|
||||
@@ -27,7 +27,7 @@ index f11a40aa9e..6756e6b886 100644
|
||||
} GlusterAIOCB;
|
||||
|
||||
typedef struct BDRVGlusterState {
|
||||
@@ -753,8 +754,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,7 +39,7 @@ index f11a40aa9e..6756e6b886 100644
|
||||
}
|
||||
|
||||
aio_co_schedule(acb->aio_context, acb->coroutine);
|
||||
@@ -1021,6 +1024,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);
|
||||
@@ -47,7 +47,7 @@ index f11a40aa9e..6756e6b886 100644
|
||||
|
||||
ret = glfs_zerofill_async(s->fd, offset, bytes, gluster_finish_aiocb, &acb);
|
||||
if (ret < 0) {
|
||||
@@ -1201,9 +1205,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 f11a40aa9e..6756e6b886 100644
|
||||
ret = glfs_preadv_async(s->fd, qiov->iov, qiov->niov, offset, 0,
|
||||
gluster_finish_aiocb, &acb);
|
||||
}
|
||||
@@ -1266,6 +1272,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,7 +67,7 @@ index f11a40aa9e..6756e6b886 100644
|
||||
|
||||
ret = glfs_fsync_async(s->fd, gluster_finish_aiocb, &acb);
|
||||
if (ret < 0) {
|
||||
@@ -1314,6 +1321,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);
|
||||
|
@@ -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 9aeac69fa6..0919fac1f1 100644
|
||||
index 7668f86769..2575e97b43 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -3059,7 +3059,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) {
|
||||
|
@@ -38,10 +38,10 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
2 files changed, 133 insertions(+), 73 deletions(-)
|
||||
|
||||
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
||||
index 1b1dab5b17..d1616c045a 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,
|
||||
@@ -54,10 +54,10 @@ index 1b1dab5b17..d1616c045a 100644
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 0919fac1f1..c584de648c 100644
|
||||
index 2575e97b43..8ec68b346f 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4885,10 +4885,12 @@ static int img_bitmap(int argc, char **argv)
|
||||
@@ -4993,10 +4993,12 @@ static int img_bitmap(int argc, char **argv)
|
||||
#define C_IF 04
|
||||
#define C_OF 010
|
||||
#define C_SKIP 020
|
||||
@@ -70,7 +70,7 @@ index 0919fac1f1..c584de648c 100644
|
||||
};
|
||||
|
||||
struct DdIo {
|
||||
@@ -4964,6 +4966,19 @@ static int img_dd_skip(const char *arg,
|
||||
@@ -5072,6 +5074,19 @@ static int img_dd_skip(const char *arg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ index 0919fac1f1..c584de648c 100644
|
||||
static int img_dd(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -5004,6 +5019,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5112,6 +5127,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ "if", img_dd_if, C_IF },
|
||||
{ "of", img_dd_of, C_OF },
|
||||
{ "skip", img_dd_skip, C_SKIP },
|
||||
@@ -98,7 +98,7 @@ index 0919fac1f1..c584de648c 100644
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
const struct option long_options[] = {
|
||||
@@ -5079,91 +5095,112 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5187,91 +5203,112 @@ static int img_dd(int argc, char **argv)
|
||||
arg = NULL;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ index 0919fac1f1..c584de648c 100644
|
||||
}
|
||||
|
||||
if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
|
||||
@@ -5180,20 +5217,43 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5288,20 +5325,43 @@ static int img_dd(int argc, char **argv)
|
||||
in.buf = g_new(uint8_t, in.bsz);
|
||||
|
||||
for (out_pos = 0; in_pos < size; ) {
|
||||
|
@@ -16,10 +16,10 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
1 file changed, 25 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index c584de648c..a57ceeddfe 100644
|
||||
index 8ec68b346f..b98184bba1 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4886,11 +4886,13 @@ static int img_bitmap(int argc, char **argv)
|
||||
@@ -4994,11 +4994,13 @@ static int img_bitmap(int argc, char **argv)
|
||||
#define C_OF 010
|
||||
#define C_SKIP 020
|
||||
#define C_OSIZE 040
|
||||
@@ -33,7 +33,7 @@ index c584de648c..a57ceeddfe 100644
|
||||
};
|
||||
|
||||
struct DdIo {
|
||||
@@ -4979,6 +4981,19 @@ static int img_dd_osize(const char *arg,
|
||||
@@ -5087,6 +5089,19 @@ static int img_dd_osize(const char *arg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ index c584de648c..a57ceeddfe 100644
|
||||
static int img_dd(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -4993,12 +5008,14 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5101,12 +5116,14 @@ static int img_dd(int argc, char **argv)
|
||||
int c, i;
|
||||
const char *out_fmt = "raw";
|
||||
const char *fmt = NULL;
|
||||
@@ -69,7 +69,7 @@ index c584de648c..a57ceeddfe 100644
|
||||
};
|
||||
struct DdIo in = {
|
||||
.bsz = 512, /* Block size is by default 512 bytes */
|
||||
@@ -5020,6 +5037,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5128,6 +5145,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ "of", img_dd_of, C_OF },
|
||||
{ "skip", img_dd_skip, C_SKIP },
|
||||
{ "osize", img_dd_osize, C_OSIZE },
|
||||
@@ -77,7 +77,7 @@ index c584de648c..a57ceeddfe 100644
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
const struct option long_options[] = {
|
||||
@@ -5216,9 +5234,10 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5324,9 +5342,10 @@ static int img_dd(int argc, char **argv)
|
||||
|
||||
in.buf = g_new(uint8_t, in.bsz);
|
||||
|
||||
@@ -90,7 +90,7 @@ index c584de648c..a57ceeddfe 100644
|
||||
if (blk1) {
|
||||
in_ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
|
||||
if (in_ret == 0) {
|
||||
@@ -5227,6 +5246,9 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5335,6 +5354,9 @@ static int img_dd(int argc, char **argv)
|
||||
} else {
|
||||
in_ret = read(STDIN_FILENO, in.buf, bytes);
|
||||
if (in_ret == 0) {
|
||||
|
@@ -13,10 +13,10 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
3 files changed, 26 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
|
||||
index 15aeddc6d8..5e713e231d 100644
|
||||
index 3653adb963..d83e8fb3c0 100644
|
||||
--- a/docs/tools/qemu-img.rst
|
||||
+++ b/docs/tools/qemu-img.rst
|
||||
@@ -208,6 +208,10 @@ Parameters to convert subcommand:
|
||||
@@ -212,6 +212,10 @@ Parameters to convert subcommand:
|
||||
|
||||
Parameters to dd subcommand:
|
||||
|
||||
@@ -27,7 +27,7 @@ index 15aeddc6d8..5e713e231d 100644
|
||||
.. program:: qemu-img-dd
|
||||
|
||||
.. option:: bs=BLOCK_SIZE
|
||||
@@ -488,7 +492,7 @@ Command description:
|
||||
@@ -492,7 +496,7 @@ Command description:
|
||||
it doesn't need to be specified separately in this case.
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ index 15aeddc6d8..5e713e231d 100644
|
||||
|
||||
dd copies from *INPUT* file to *OUTPUT* file converting it from
|
||||
*FMT* format to *OUTPUT_FMT* format.
|
||||
@@ -499,6 +503,11 @@ Command description:
|
||||
@@ -503,6 +507,11 @@ Command description:
|
||||
|
||||
The size syntax is similar to :manpage:`dd(1)`'s size syntax.
|
||||
|
||||
@@ -49,10 +49,10 @@ index 15aeddc6d8..5e713e231d 100644
|
||||
|
||||
Give information about the disk image *FILENAME*. Use it in
|
||||
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
||||
index d1616c045a..b5b0bb4467 100644
|
||||
index 048788b23d..0b29a67a06 100644
|
||||
--- a/qemu-img-cmds.hx
|
||||
+++ b/qemu-img-cmds.hx
|
||||
@@ -58,9 +58,9 @@ SRST
|
||||
@@ -60,9 +60,9 @@ SRST
|
||||
ERST
|
||||
|
||||
DEF("dd", img_dd,
|
||||
@@ -65,10 +65,10 @@ index d1616c045a..b5b0bb4467 100644
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index a57ceeddfe..06d814e39c 100644
|
||||
index b98184bba1..6fc8384f64 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -5010,7 +5010,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5118,7 +5118,7 @@ static int img_dd(int argc, char **argv)
|
||||
const char *fmt = NULL;
|
||||
int64_t size = 0, readsize = 0;
|
||||
int64_t out_pos, in_pos;
|
||||
@@ -77,7 +77,7 @@ index a57ceeddfe..06d814e39c 100644
|
||||
struct DdInfo dd = {
|
||||
.flags = 0,
|
||||
.count = 0,
|
||||
@@ -5048,7 +5048,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5156,7 +5156,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
@@ -86,7 +86,7 @@ index a57ceeddfe..06d814e39c 100644
|
||||
if (c == EOF) {
|
||||
break;
|
||||
}
|
||||
@@ -5068,6 +5068,9 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5176,6 +5176,9 @@ static int img_dd(int argc, char **argv)
|
||||
case 'h':
|
||||
help();
|
||||
break;
|
||||
@@ -96,7 +96,7 @@ index a57ceeddfe..06d814e39c 100644
|
||||
case 'U':
|
||||
force_share = true;
|
||||
break;
|
||||
@@ -5198,13 +5201,15 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5306,13 +5309,15 @@ static int img_dd(int argc, char **argv)
|
||||
size - in.bsz * in.offset, &error_abort);
|
||||
}
|
||||
|
||||
|
@@ -12,10 +12,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
3 files changed, 36 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
|
||||
index 5e713e231d..9390d5e5cf 100644
|
||||
index d83e8fb3c0..61c6b21859 100644
|
||||
--- a/docs/tools/qemu-img.rst
|
||||
+++ b/docs/tools/qemu-img.rst
|
||||
@@ -492,10 +492,10 @@ Command description:
|
||||
@@ -496,10 +496,10 @@ Command description:
|
||||
it doesn't need to be specified separately in this case.
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ index 5e713e231d..9390d5e5cf 100644
|
||||
The data is by default read and written using blocks of 512 bytes but can be
|
||||
modified by specifying *BLOCK_SIZE*. If count=\ *BLOCKS* is specified
|
||||
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
||||
index b5b0bb4467..36f97e1f19 100644
|
||||
index 0b29a67a06..758f397232 100644
|
||||
--- a/qemu-img-cmds.hx
|
||||
+++ b/qemu-img-cmds.hx
|
||||
@@ -58,9 +58,9 @@ SRST
|
||||
@@ -60,9 +60,9 @@ SRST
|
||||
ERST
|
||||
|
||||
DEF("dd", img_dd,
|
||||
@@ -46,10 +46,10 @@ index b5b0bb4467..36f97e1f19 100644
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 06d814e39c..e2c06c496d 100644
|
||||
index 6fc8384f64..a6c88e0860 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -5002,6 +5002,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5110,6 +5110,7 @@ static int img_dd(int argc, char **argv)
|
||||
BlockDriver *drv = NULL, *proto_drv = NULL;
|
||||
BlockBackend *blk1 = NULL, *blk2 = NULL;
|
||||
QemuOpts *opts = NULL;
|
||||
@@ -57,7 +57,7 @@ index 06d814e39c..e2c06c496d 100644
|
||||
QemuOptsList *create_opts = NULL;
|
||||
Error *local_err = NULL;
|
||||
bool image_opts = false;
|
||||
@@ -5011,6 +5012,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5119,6 +5120,7 @@ static int img_dd(int argc, char **argv)
|
||||
int64_t size = 0, readsize = 0;
|
||||
int64_t out_pos, in_pos;
|
||||
bool force_share = false, skip_create = false;
|
||||
@@ -65,7 +65,7 @@ index 06d814e39c..e2c06c496d 100644
|
||||
struct DdInfo dd = {
|
||||
.flags = 0,
|
||||
.count = 0,
|
||||
@@ -5048,7 +5050,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5156,7 +5158,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ index 06d814e39c..e2c06c496d 100644
|
||||
if (c == EOF) {
|
||||
break;
|
||||
}
|
||||
@@ -5071,6 +5073,19 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5179,6 +5181,19 @@ static int img_dd(int argc, char **argv)
|
||||
case 'n':
|
||||
skip_create = true;
|
||||
break;
|
||||
@@ -94,7 +94,7 @@ index 06d814e39c..e2c06c496d 100644
|
||||
case 'U':
|
||||
force_share = true;
|
||||
break;
|
||||
@@ -5130,11 +5145,24 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5238,11 +5253,24 @@ static int img_dd(int argc, char **argv)
|
||||
if (dd.flags & C_IF) {
|
||||
blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
|
||||
force_share);
|
||||
@@ -120,7 +120,7 @@ index 06d814e39c..e2c06c496d 100644
|
||||
}
|
||||
|
||||
if (dd.flags & C_OSIZE) {
|
||||
@@ -5289,6 +5317,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5397,6 +5425,7 @@ static int img_dd(int argc, char **argv)
|
||||
out:
|
||||
g_free(arg);
|
||||
qemu_opts_del(opts);
|
||||
|
@@ -18,10 +18,10 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
4 files changed, 82 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
|
||||
index c3e55ef9e9..0e32e6201f 100644
|
||||
index 8701f00cc7..3b4c5ef403 100644
|
||||
--- a/hw/core/machine-hmp-cmds.c
|
||||
+++ b/hw/core/machine-hmp-cmds.c
|
||||
@@ -169,7 +169,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
|
||||
@@ -179,7 +179,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,10 +59,10 @@ index c3e55ef9e9..0e32e6201f 100644
|
||||
qapi_free_BalloonInfo(info);
|
||||
}
|
||||
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
|
||||
index 746f07c4d2..a41854b902 100644
|
||||
index afd2ad6dd6..c724218c17 100644
|
||||
--- a/hw/virtio/virtio-balloon.c
|
||||
+++ b/hw/virtio/virtio-balloon.c
|
||||
@@ -804,8 +804,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;
|
||||
@@ -103,12 +103,12 @@ index 746f07c4d2..a41854b902 100644
|
||||
|
||||
static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 604b686e59..15f5f86683 100644
|
||||
index a6b8795b09..9f7ed0eaa0 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -1056,9 +1056,29 @@
|
||||
# @actual: the logical size of the VM in bytes
|
||||
# Formula used: logical_vm_size = vm_ram_size - balloon_size
|
||||
@@ -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
|
||||
+#
|
||||
@@ -138,10 +138,10 @@ index 604b686e59..15f5f86683 100644
|
||||
##
|
||||
# @query-balloon:
|
||||
diff --git a/qapi/pragma.json b/qapi/pragma.json
|
||||
index 7f810b0e97..325e684411 100644
|
||||
index 023a2ef7bc..6aaa9cb975 100644
|
||||
--- a/qapi/pragma.json
|
||||
+++ b/qapi/pragma.json
|
||||
@@ -35,6 +35,7 @@
|
||||
@@ -81,6 +81,7 @@
|
||||
'member-name-exceptions': [ # visible in:
|
||||
'ACPISlotType', # query-acpi-ospm-status
|
||||
'AcpiTableOptions', # -acpitable
|
||||
|
@@ -13,10 +13,10 @@ 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 b98ff15089..24595f618c 100644
|
||||
index 130217da8f..52a6d74820 100644
|
||||
--- a/hw/core/machine-qmp-cmds.c
|
||||
+++ b/hw/core/machine-qmp-cmds.c
|
||||
@@ -103,6 +103,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
||||
@@ -90,6 +90,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");
|
||||
@@ -30,19 +30,19 @@ index b98ff15089..24595f618c 100644
|
||||
info->default_cpu_type = g_strdup(mc->default_cpu_type);
|
||||
}
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 15f5f86683..c904280085 100644
|
||||
index 9f7ed0eaa0..16366b774a 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -138,6 +138,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)
|
||||
# (since 1.5)
|
||||
#
|
||||
@@ -161,7 +163,7 @@
|
||||
@@ -199,7 +201,7 @@
|
||||
##
|
||||
{ 'struct': 'MachineInfo',
|
||||
'data': { 'name': 'str', '*alias': 'str',
|
||||
@@ -50,4 +50,4 @@ index 15f5f86683..c904280085 100644
|
||||
+ '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
|
||||
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
|
||||
'deprecated': 'bool', '*default-cpu-type': 'str',
|
||||
'*default-ram-id': 'str', 'acpi': 'bool' } }
|
||||
'*default-ram-id': 'str', 'acpi': 'bool',
|
||||
|
@@ -14,10 +14,10 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
2 files changed, 7 insertions(+)
|
||||
|
||||
diff --git a/qapi/ui.json b/qapi/ui.json
|
||||
index 98322342f7..316d4dc933 100644
|
||||
index 460a26b981..42b911bda3 100644
|
||||
--- a/qapi/ui.json
|
||||
+++ b/qapi/ui.json
|
||||
@@ -310,11 +310,14 @@
|
||||
@@ -312,11 +312,14 @@
|
||||
#
|
||||
# @channels: a list of @SpiceChannel for each active spice channel
|
||||
#
|
||||
@@ -33,7 +33,7 @@ index 98322342f7..316d4dc933 100644
|
||||
'if': 'CONFIG_SPICE' }
|
||||
|
||||
diff --git a/ui/spice-core.c b/ui/spice-core.c
|
||||
index b20c25aee0..26baeb7846 100644
|
||||
index a7ecaad9c7..fecf002d50 100644
|
||||
--- a/ui/spice-core.c
|
||||
+++ b/ui/spice-core.c
|
||||
@@ -548,6 +548,10 @@ static SpiceInfo *qmp_query_spice_real(Error **errp)
|
||||
|
@@ -14,20 +14,21 @@ 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 | 183 +++++++++++++++++++++++++++++++
|
||||
migration/channel-savevm-async.c | 184 +++++++++++++++++++++++++++++++
|
||||
migration/channel-savevm-async.h | 51 +++++++++
|
||||
migration/meson.build | 1 +
|
||||
3 files changed, 235 insertions(+)
|
||||
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..aab081ce07
|
||||
index 0000000000..081a192f49
|
||||
--- /dev/null
|
||||
+++ b/migration/channel-savevm-async.c
|
||||
@@ -0,0 +1,183 @@
|
||||
@@ -0,0 +1,184 @@
|
||||
+/*
|
||||
+ * QIO Channel implementation to be used by savevm-async QMP calls
|
||||
+ */
|
||||
@@ -174,8 +175,9 @@ index 0000000000..aab081ce07
|
||||
+
|
||||
+static void
|
||||
+qio_channel_savevm_async_set_aio_fd_handler(QIOChannel *ioc,
|
||||
+ AioContext *ctx,
|
||||
+ AioContext *read_ctx,
|
||||
+ IOHandler *io_read,
|
||||
+ AioContext *write_ctx,
|
||||
+ IOHandler *io_write,
|
||||
+ void *opaque)
|
||||
+{
|
||||
@@ -269,14 +271,14 @@ index 0000000000..17ae2cb261
|
||||
+
|
||||
+#endif /* QIO_CHANNEL_SAVEVM_ASYNC_H */
|
||||
diff --git a/migration/meson.build b/migration/meson.build
|
||||
index 0d1bb9f96e..8a142fc7a9 100644
|
||||
index d53cf3417a..b00d58064d 100644
|
||||
--- a/migration/meson.build
|
||||
+++ b/migration/meson.build
|
||||
@@ -13,6 +13,7 @@ softmmu_ss.add(files(
|
||||
@@ -13,6 +13,7 @@ system_ss.add(files(
|
||||
'block-dirty-bitmap.c',
|
||||
'channel.c',
|
||||
'channel-block.c',
|
||||
+ 'channel-savevm-async.c',
|
||||
'colo-failover.c',
|
||||
'colo.c',
|
||||
'cpu-throttle.c',
|
||||
'dirtyrate.c',
|
||||
'exec.c',
|
||||
|
@@ -27,7 +27,10 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
[FE: further improve aborting
|
||||
adapt to removal of QEMUFileOps
|
||||
improve condition for entering final stage
|
||||
adapt to QAPI and other changes for 8.0]
|
||||
adapt to QAPI and other changes for 8.2
|
||||
make sure to not call vm_start() from coroutine
|
||||
stop CPU throttling after finishing
|
||||
force raw format when loading state as suggested by Friedrich Weber]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hmp-commands-info.hx | 13 +
|
||||
@@ -35,20 +38,20 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
include/migration/snapshot.h | 2 +
|
||||
include/monitor/hmp.h | 3 +
|
||||
migration/meson.build | 1 +
|
||||
migration/savevm-async.c | 533 +++++++++++++++++++++++++++++++++++
|
||||
migration/savevm-async.c | 571 +++++++++++++++++++++++++++++++++++
|
||||
monitor/hmp-cmds.c | 38 +++
|
||||
qapi/migration.json | 34 +++
|
||||
qapi/misc.json | 16 ++
|
||||
qapi/misc.json | 18 ++
|
||||
qemu-options.hx | 12 +
|
||||
softmmu/vl.c | 10 +
|
||||
11 files changed, 679 insertions(+)
|
||||
system/vl.c | 10 +
|
||||
11 files changed, 719 insertions(+)
|
||||
create mode 100644 migration/savevm-async.c
|
||||
|
||||
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
|
||||
index 47d63d26db..a166bff3d5 100644
|
||||
index c59cd6637b..d1a7b99add 100644
|
||||
--- a/hmp-commands-info.hx
|
||||
+++ b/hmp-commands-info.hx
|
||||
@@ -540,6 +540,19 @@ SRST
|
||||
@@ -512,6 +512,19 @@ SRST
|
||||
Show current migration parameters.
|
||||
ERST
|
||||
|
||||
@@ -69,10 +72,10 @@ index 47d63d26db..a166bff3d5 100644
|
||||
.name = "balloon",
|
||||
.args_type = "",
|
||||
diff --git a/hmp-commands.hx b/hmp-commands.hx
|
||||
index bb85ee1d26..d9f9f42d11 100644
|
||||
index 06746f0afc..0c7c6f2c16 100644
|
||||
--- a/hmp-commands.hx
|
||||
+++ b/hmp-commands.hx
|
||||
@@ -1846,3 +1846,20 @@ SRST
|
||||
@@ -1859,3 +1859,20 @@ SRST
|
||||
List event channels in the guest
|
||||
ERST
|
||||
#endif
|
||||
@@ -94,18 +97,18 @@ index bb85ee1d26..d9f9f42d11 100644
|
||||
+ .coroutine = true,
|
||||
+ },
|
||||
diff --git a/include/migration/snapshot.h b/include/migration/snapshot.h
|
||||
index e72083b117..c846d37806 100644
|
||||
index 9e4dcaaa75..2581730d74 100644
|
||||
--- a/include/migration/snapshot.h
|
||||
+++ b/include/migration/snapshot.h
|
||||
@@ -61,4 +61,6 @@ bool delete_snapshot(const char *name,
|
||||
bool has_devices, strList *devices,
|
||||
Error **errp);
|
||||
@@ -68,4 +68,6 @@ bool delete_snapshot(const char *name,
|
||||
*/
|
||||
void load_snapshot_resume(RunState state);
|
||||
|
||||
+int load_snapshot_from_blockdev(const char *filename, Error **errp);
|
||||
+
|
||||
#endif
|
||||
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
|
||||
index fdb69b7f9c..fdf6b45fb8 100644
|
||||
index ae116d9804..2596cc2426 100644
|
||||
--- a/include/monitor/hmp.h
|
||||
+++ b/include/monitor/hmp.h
|
||||
@@ -28,6 +28,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
|
||||
@@ -116,7 +119,7 @@ index fdb69b7f9c..fdf6b45fb8 100644
|
||||
void hmp_info_migrate(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict);
|
||||
@@ -94,6 +95,8 @@ void hmp_closefd(Monitor *mon, const QDict *qdict);
|
||||
@@ -92,6 +93,8 @@ void hmp_closefd(Monitor *mon, const QDict *qdict);
|
||||
void hmp_mouse_move(Monitor *mon, const QDict *qdict);
|
||||
void hmp_mouse_button(Monitor *mon, const QDict *qdict);
|
||||
void hmp_mouse_set(Monitor *mon, const QDict *qdict);
|
||||
@@ -126,11 +129,11 @@ index fdb69b7f9c..fdf6b45fb8 100644
|
||||
void coroutine_fn hmp_screendump(Monitor *mon, const QDict *qdict);
|
||||
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
|
||||
diff --git a/migration/meson.build b/migration/meson.build
|
||||
index 8a142fc7a9..a7824b5266 100644
|
||||
index b00d58064d..075b013971 100644
|
||||
--- a/migration/meson.build
|
||||
+++ b/migration/meson.build
|
||||
@@ -25,6 +25,7 @@ softmmu_ss.add(files(
|
||||
'multifd-zlib.c',
|
||||
@@ -29,6 +29,7 @@ system_ss.add(files(
|
||||
'options.c',
|
||||
'postcopy-ram.c',
|
||||
'savevm.c',
|
||||
+ 'savevm-async.c',
|
||||
@@ -139,18 +142,21 @@ index 8a142fc7a9..a7824b5266 100644
|
||||
'threadinfo.c',
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
new file mode 100644
|
||||
index 0000000000..ac1fac6378
|
||||
index 0000000000..ee8ef316d0
|
||||
--- /dev/null
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -0,0 +1,533 @@
|
||||
@@ -0,0 +1,571 @@
|
||||
+#include "qemu/osdep.h"
|
||||
+#include "migration/channel-savevm-async.h"
|
||||
+#include "migration/migration.h"
|
||||
+#include "migration/migration-stats.h"
|
||||
+#include "migration/options.h"
|
||||
+#include "migration/savevm.h"
|
||||
+#include "migration/snapshot.h"
|
||||
+#include "migration/global_state.h"
|
||||
+#include "migration/ram.h"
|
||||
+#include "migration/qemu-file.h"
|
||||
+#include "sysemu/cpu-throttle.h"
|
||||
+#include "sysemu/sysemu.h"
|
||||
+#include "sysemu/runstate.h"
|
||||
+#include "block/block.h"
|
||||
@@ -162,6 +168,7 @@ index 0000000000..ac1fac6378
|
||||
+#include "qapi/qapi-commands-misc.h"
|
||||
+#include "qapi/qapi-commands-block.h"
|
||||
+#include "qemu/cutils.h"
|
||||
+#include "qemu/error-report.h"
|
||||
+#include "qemu/timer.h"
|
||||
+#include "qemu/main-loop.h"
|
||||
+#include "qemu/rcu.h"
|
||||
@@ -255,6 +262,7 @@ index 0000000000..ac1fac6378
|
||||
+ }
|
||||
+
|
||||
+ if (snap_state.target) {
|
||||
+ BlockDriverState *target_bs = blk_bs(snap_state.target);
|
||||
+ if (!savevm_aborted()) {
|
||||
+ /* try to truncate, but ignore errors (will fail on block devices).
|
||||
+ * note1: bdrv_read() need whole blocks, so we need to round up
|
||||
@@ -263,7 +271,9 @@ index 0000000000..ac1fac6378
|
||||
+ size_t size = QEMU_ALIGN_UP(snap_state.bs_pos, BDRV_SECTOR_SIZE*2);
|
||||
+ blk_truncate(snap_state.target, size, false, PREALLOC_MODE_OFF, 0, NULL);
|
||||
+ }
|
||||
+ blk_op_unblock_all(snap_state.target, snap_state.blocker);
|
||||
+ if (target_bs) {
|
||||
+ bdrv_op_unblock_all(target_bs, snap_state.blocker);
|
||||
+ }
|
||||
+ error_free(snap_state.blocker);
|
||||
+ snap_state.blocker = NULL;
|
||||
+ blk_unref(snap_state.target);
|
||||
@@ -275,7 +285,7 @@ index 0000000000..ac1fac6378
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void save_snapshot_error(const char *fmt, ...)
|
||||
+static void G_GNUC_PRINTF(1, 2) save_snapshot_error(const char *fmt, ...)
|
||||
+{
|
||||
+ va_list ap;
|
||||
+ char *msg;
|
||||
@@ -287,7 +297,7 @@ index 0000000000..ac1fac6378
|
||||
+ DPRINTF("save_snapshot_error: %s\n", msg);
|
||||
+
|
||||
+ if (!snap_state.error) {
|
||||
+ error_set(&snap_state.error, ERROR_CLASS_GENERIC_ERROR, "%s", msg);
|
||||
+ error_setg(&snap_state.error, "%s", msg);
|
||||
+ }
|
||||
+
|
||||
+ g_free (msg);
|
||||
@@ -298,7 +308,6 @@ index 0000000000..ac1fac6378
|
||||
+static void process_savevm_finalize(void *opaque)
|
||||
+{
|
||||
+ int ret;
|
||||
+ AioContext *iohandler_ctx = iohandler_get_aio_context();
|
||||
+ MigrationState *ms = migrate_get_current();
|
||||
+
|
||||
+ bool aborted = savevm_aborted();
|
||||
@@ -315,9 +324,7 @@ index 0000000000..ac1fac6378
|
||||
+ * so move it back. It can stay in the main context and live out its live
|
||||
+ * there, since we're done with it after this method ends anyway.
|
||||
+ */
|
||||
+ aio_context_acquire(iohandler_ctx);
|
||||
+ blk_set_aio_context(snap_state.target, qemu_get_aio_context(), NULL);
|
||||
+ aio_context_release(iohandler_ctx);
|
||||
+
|
||||
+ ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
|
||||
+ if (ret < 0) {
|
||||
@@ -342,6 +349,12 @@ index 0000000000..ac1fac6378
|
||||
+ ret || aborted ? MIGRATION_STATUS_FAILED : MIGRATION_STATUS_COMPLETED);
|
||||
+ ms->to_dst_file = NULL;
|
||||
+
|
||||
+ /*
|
||||
+ * Same as in migration_iteration_finish(): saving RAM might've turned on CPU throttling for
|
||||
+ * auto-converge, make sure to disable it.
|
||||
+ */
|
||||
+ cpu_throttle_stop();
|
||||
+
|
||||
+ qemu_savevm_state_cleanup();
|
||||
+
|
||||
+ ret = save_snapshot_cleanup();
|
||||
@@ -394,12 +407,12 @@ index 0000000000..ac1fac6378
|
||||
+ * lock. Similar to what is done in migration.c, call the exact variant
|
||||
+ * only once pend_precopy in the estimate is below the threshold.
|
||||
+ */
|
||||
+ qemu_mutex_unlock_iothread();
|
||||
+ bql_unlock();
|
||||
+ qemu_savevm_state_pending_estimate(&pend_precopy, &pend_postcopy);
|
||||
+ if (pend_precopy <= threshold) {
|
||||
+ qemu_savevm_state_pending_exact(&pend_precopy, &pend_postcopy);
|
||||
+ }
|
||||
+ qemu_mutex_lock_iothread();
|
||||
+ bql_lock();
|
||||
+ pending_size = pend_precopy + pend_postcopy;
|
||||
+
|
||||
+ /*
|
||||
@@ -420,11 +433,7 @@ index 0000000000..ac1fac6378
|
||||
+ DPRINTF("savevm iterate pending size %lu ret %d\n", pending_size, ret);
|
||||
+ } else {
|
||||
+ qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
|
||||
+ ret = global_state_store();
|
||||
+ if (ret) {
|
||||
+ save_snapshot_error("global_state_store error %d", ret);
|
||||
+ break;
|
||||
+ }
|
||||
+ global_state_store();
|
||||
+
|
||||
+ DPRINTF("savevm iterate complete\n");
|
||||
+ break;
|
||||
@@ -443,21 +452,25 @@ index 0000000000..ac1fac6378
|
||||
+ * so move there now and after every flush.
|
||||
+ */
|
||||
+ aio_co_reschedule_self(qemu_get_aio_context());
|
||||
+ for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ bs = bdrv_first(&it);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ while (bs) {
|
||||
+ /* target has BDRV_O_NO_FLUSH, no sense calling bdrv_flush on it */
|
||||
+ if (bs == blk_bs(snap_state.target)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ AioContext *bs_ctx = bdrv_get_aio_context(bs);
|
||||
+ if (bs_ctx != qemu_get_aio_context()) {
|
||||
+ DPRINTF("savevm: async flushing drive %s\n", bs->filename);
|
||||
+ aio_co_reschedule_self(bs_ctx);
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ bdrv_flush(bs);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ aio_co_reschedule_self(qemu_get_aio_context());
|
||||
+ if (bs != blk_bs(snap_state.target)) {
|
||||
+ AioContext *bs_ctx = bdrv_get_aio_context(bs);
|
||||
+ if (bs_ctx != qemu_get_aio_context()) {
|
||||
+ DPRINTF("savevm: async flushing drive %s\n", bs->filename);
|
||||
+ aio_co_reschedule_self(bs_ctx);
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ bdrv_flush(bs);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ aio_co_reschedule_self(qemu_get_aio_context());
|
||||
+ }
|
||||
+ }
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ bs = bdrv_next(&it);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ }
|
||||
+
|
||||
+ DPRINTF("timing: async flushing took %ld ms\n",
|
||||
@@ -471,23 +484,18 @@ index 0000000000..ac1fac6378
|
||||
+ Error *local_err = NULL;
|
||||
+ MigrationState *ms = migrate_get_current();
|
||||
+ AioContext *iohandler_ctx = iohandler_get_aio_context();
|
||||
+ BlockDriverState *target_bs = NULL;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ int bdrv_oflags = BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH;
|
||||
+
|
||||
+ if (snap_state.state != SAVE_STATE_DONE) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
+ "VM snapshot already started\n");
|
||||
+ error_setg(errp, "VM snapshot already started\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (migration_is_running(ms->state)) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, QERR_MIGRATION_ACTIVE);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (migrate_use_block()) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
+ "Block migration and snapshots are incompatible");
|
||||
+ if (migration_is_running()) {
|
||||
+ error_setg(errp, "There's a migration process in progress");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@@ -519,7 +527,12 @@ index 0000000000..ac1fac6378
|
||||
+ qdict_put_str(options, "driver", "raw");
|
||||
+ snap_state.target = blk_new_open(statefile, NULL, options, bdrv_oflags, &local_err);
|
||||
+ if (!snap_state.target) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
|
||||
+ error_setg(errp, "failed to open '%s'", statefile);
|
||||
+ goto restart;
|
||||
+ }
|
||||
+ target_bs = blk_bs(snap_state.target);
|
||||
+ if (!target_bs) {
|
||||
+ error_setg(errp, "failed to open '%s' - no block driver state", statefile);
|
||||
+ goto restart;
|
||||
+ }
|
||||
+
|
||||
@@ -528,7 +541,7 @@ index 0000000000..ac1fac6378
|
||||
+ snap_state.file = qemu_file_new_output(ioc);
|
||||
+
|
||||
+ if (!snap_state.file) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
|
||||
+ error_setg(errp, "failed to open '%s'", statefile);
|
||||
+ goto restart;
|
||||
+ }
|
||||
+
|
||||
@@ -537,27 +550,36 @@ index 0000000000..ac1fac6378
|
||||
+ * State is cleared in process_savevm_co, but has to be initialized
|
||||
+ * here (blocking main thread, from QMP) to avoid race conditions.
|
||||
+ */
|
||||
+ migrate_init(ms);
|
||||
+ memset(&ram_counters, 0, sizeof(ram_counters));
|
||||
+ memset(&compression_counters, 0, sizeof(compression_counters));
|
||||
+ if (migrate_init(ms, errp)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ memset(&mig_stats, 0, sizeof(mig_stats));
|
||||
+ ms->to_dst_file = snap_state.file;
|
||||
+
|
||||
+ error_setg(&snap_state.blocker, "block device is in use by savevm");
|
||||
+ blk_op_block_all(snap_state.target, snap_state.blocker);
|
||||
+ bdrv_op_block_all(target_bs, snap_state.blocker);
|
||||
+
|
||||
+ snap_state.state = SAVE_STATE_ACTIVE;
|
||||
+ snap_state.finalize_bh = qemu_bh_new(process_savevm_finalize, &snap_state);
|
||||
+ snap_state.co = qemu_coroutine_create(&process_savevm_co, NULL);
|
||||
+ qemu_mutex_unlock_iothread();
|
||||
+ qemu_savevm_state_header(snap_state.file);
|
||||
+ qemu_savevm_state_setup(snap_state.file);
|
||||
+ qemu_mutex_lock_iothread();
|
||||
+ ret = qemu_savevm_state_setup(snap_state.file, &local_err);
|
||||
+ if (ret != 0) {
|
||||
+ error_setg_errno(errp, -ret, "savevm state setup failed: %s",
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* Async processing from here on out happens in iohandler context, so let
|
||||
+ * the target bdrv have its home there.
|
||||
+ */
|
||||
+ blk_set_aio_context(snap_state.target, iohandler_ctx, &local_err);
|
||||
+ ret = blk_set_aio_context(snap_state.target, iohandler_ctx, &local_err);
|
||||
+ if (ret != 0) {
|
||||
+ warn_report("failed to set iohandler context for VM state target: %s %s",
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error",
|
||||
+ strerror(-ret));
|
||||
+ }
|
||||
+
|
||||
+ snap_state.co = qemu_coroutine_create(&process_savevm_co, NULL);
|
||||
+ aio_co_schedule(iohandler_ctx, snap_state.co);
|
||||
+
|
||||
+ return;
|
||||
@@ -572,29 +594,10 @@ index 0000000000..ac1fac6378
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void coroutine_fn qmp_savevm_end(Error **errp)
|
||||
+static void coroutine_fn wait_for_close_co(void *opaque)
|
||||
+{
|
||||
+ int64_t timeout;
|
||||
+
|
||||
+ if (snap_state.state == SAVE_STATE_DONE) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
+ "VM snapshot not started\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (snap_state.state == SAVE_STATE_ACTIVE) {
|
||||
+ snap_state.state = SAVE_STATE_CANCELLED;
|
||||
+ goto wait_for_close;
|
||||
+ }
|
||||
+
|
||||
+ if (snap_state.saved_vm_running) {
|
||||
+ vm_start();
|
||||
+ snap_state.saved_vm_running = false;
|
||||
+ }
|
||||
+
|
||||
+ snap_state.state = SAVE_STATE_DONE;
|
||||
+
|
||||
+wait_for_close:
|
||||
+ if (!snap_state.target) {
|
||||
+ DPRINTF("savevm-end: no target file open\n");
|
||||
+ return;
|
||||
@@ -622,25 +625,61 @@ index 0000000000..ac1fac6378
|
||||
+ DPRINTF("savevm-end: cleanup done\n");
|
||||
+}
|
||||
+
|
||||
+void qmp_savevm_end(Error **errp)
|
||||
+{
|
||||
+ if (snap_state.state == SAVE_STATE_DONE) {
|
||||
+ error_setg(errp, "VM snapshot not started\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ Coroutine *wait_for_close = qemu_coroutine_create(wait_for_close_co, NULL);
|
||||
+
|
||||
+ if (snap_state.state == SAVE_STATE_ACTIVE) {
|
||||
+ snap_state.state = SAVE_STATE_CANCELLED;
|
||||
+ qemu_coroutine_enter(wait_for_close);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (snap_state.saved_vm_running) {
|
||||
+ vm_start();
|
||||
+ snap_state.saved_vm_running = false;
|
||||
+ }
|
||||
+
|
||||
+ snap_state.state = SAVE_STATE_DONE;
|
||||
+
|
||||
+ qemu_coroutine_enter(wait_for_close);
|
||||
+}
|
||||
+
|
||||
+int load_snapshot_from_blockdev(const char *filename, Error **errp)
|
||||
+{
|
||||
+ BlockBackend *be;
|
||||
+ BlockDriverState *bs = NULL;
|
||||
+ Error *local_err = NULL;
|
||||
+ Error *blocker = NULL;
|
||||
+ QDict *options;
|
||||
+
|
||||
+ QEMUFile *f;
|
||||
+ size_t bs_pos = 0;
|
||||
+ int ret = -EINVAL;
|
||||
+
|
||||
+ be = blk_new_open(filename, NULL, NULL, 0, &local_err);
|
||||
+ options = qdict_new();
|
||||
+ qdict_put_str(options, "driver", "raw");
|
||||
+
|
||||
+ be = blk_new_open(filename, NULL, options, 0, &local_err);
|
||||
+
|
||||
+ if (!be) {
|
||||
+ error_setg(errp, "Could not open VM state file");
|
||||
+ goto the_end;
|
||||
+ }
|
||||
+
|
||||
+ bs = blk_bs(be);
|
||||
+ if (!bs) {
|
||||
+ error_setg(errp, "Could not open VM state file - missing block driver state");
|
||||
+ goto the_end;
|
||||
+ }
|
||||
+
|
||||
+ error_setg(&blocker, "block device is in use by load state");
|
||||
+ blk_op_block_all(be, blocker);
|
||||
+ 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)));
|
||||
@@ -670,28 +709,30 @@ index 0000000000..ac1fac6378
|
||||
+
|
||||
+ the_end:
|
||||
+ if (be) {
|
||||
+ blk_op_unblock_all(be, blocker);
|
||||
+ if (bs) {
|
||||
+ bdrv_op_unblock_all(bs, blocker);
|
||||
+ }
|
||||
+ error_free(blocker);
|
||||
+ blk_unref(be);
|
||||
+ }
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index 6c559b48c8..91be698308 100644
|
||||
index f601d06ab8..874084565f 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "monitor/monitor-internal.h"
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-commands-control.h"
|
||||
#include "qapi/qapi-commands-machine.h"
|
||||
+#include "qapi/qapi-commands-migration.h"
|
||||
#include "qapi/qapi-commands-misc.h"
|
||||
#include "qapi/qmp/qdict.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
@@ -443,3 +444,40 @@ void hmp_info_mtree(Monitor *mon, const QDict *qdict)
|
||||
|
||||
mtree_info(flatview, dispatch_tree, owner, disabled);
|
||||
#include "qemu/cutils.h"
|
||||
@@ -434,3 +435,40 @@ void hmp_dumpdtb(Monitor *mon, const QDict *qdict)
|
||||
monitor_printf(mon, "dtb dumped to %s", filename);
|
||||
}
|
||||
#endif
|
||||
+
|
||||
+void hmp_savevm_start(Monitor *mon, const QDict *qdict)
|
||||
+{
|
||||
@@ -730,12 +771,12 @@ index 6c559b48c8..91be698308 100644
|
||||
+ }
|
||||
+}
|
||||
diff --git a/qapi/migration.json b/qapi/migration.json
|
||||
index c84fa10e86..1702b92553 100644
|
||||
index a605dc26db..927b1e1c7d 100644
|
||||
--- a/qapi/migration.json
|
||||
+++ b/qapi/migration.json
|
||||
@@ -261,6 +261,40 @@
|
||||
'*compression': 'CompressionStats',
|
||||
'*socket-address': ['SocketAddress'] } }
|
||||
@@ -276,6 +276,40 @@
|
||||
'*dirty-limit-throttle-time-per-round': 'uint64',
|
||||
'*dirty-limit-ring-full-time': 'uint64'} }
|
||||
|
||||
+##
|
||||
+# @SaveVMInfo:
|
||||
@@ -775,10 +816,10 @@ index c84fa10e86..1702b92553 100644
|
||||
# @query-migrate:
|
||||
#
|
||||
diff --git a/qapi/misc.json b/qapi/misc.json
|
||||
index 6ddd16ea28..e5681ae8a2 100644
|
||||
index 559b66f201..7959e89c1e 100644
|
||||
--- a/qapi/misc.json
|
||||
+++ b/qapi/misc.json
|
||||
@@ -469,6 +469,22 @@
|
||||
@@ -454,6 +454,24 @@
|
||||
##
|
||||
{ 'command': 'query-fdsets', 'returns': ['FdsetInfo'] }
|
||||
|
||||
@@ -787,6 +828,8 @@ index 6ddd16ea28..e5681ae8a2 100644
|
||||
+#
|
||||
+# Prepare for snapshot and halt VM. Save VM state to statefile.
|
||||
+#
|
||||
+# @statefile: target file that state should be written to.
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'savevm-start', 'data': { '*statefile': 'str' } }
|
||||
+
|
||||
@@ -796,16 +839,16 @@ index 6ddd16ea28..e5681ae8a2 100644
|
||||
+# Resume VM after a snapshot.
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'savevm-end', 'coroutine': true }
|
||||
+{ 'command': 'savevm-end' }
|
||||
+
|
||||
##
|
||||
# @CommandLineParameterType:
|
||||
#
|
||||
diff --git a/qemu-options.hx b/qemu-options.hx
|
||||
index fdddfab6ff..fdd551c2bb 100644
|
||||
index dacc9790a4..c05f411599 100644
|
||||
--- a/qemu-options.hx
|
||||
+++ b/qemu-options.hx
|
||||
@@ -4398,6 +4398,18 @@ SRST
|
||||
@@ -4764,6 +4764,18 @@ SRST
|
||||
Start right away with a saved state (``loadvm`` in monitor)
|
||||
ERST
|
||||
|
||||
@@ -824,10 +867,10 @@ index fdddfab6ff..fdd551c2bb 100644
|
||||
#ifndef _WIN32
|
||||
DEF("daemonize", 0, QEMU_OPTION_daemonize, \
|
||||
"-daemonize daemonize QEMU after initializing\n", QEMU_ARCH_ALL)
|
||||
diff --git a/softmmu/vl.c b/softmmu/vl.c
|
||||
index ea20b23e4c..0eabc71b68 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
diff --git a/system/vl.c b/system/vl.c
|
||||
index 2f855d83fb..39d451bb41 100644
|
||||
--- a/system/vl.c
|
||||
+++ b/system/vl.c
|
||||
@@ -164,6 +164,7 @@ static const char *accelerators;
|
||||
static bool have_custom_ram_size;
|
||||
static const char *ram_memdev_id;
|
||||
@@ -836,10 +879,10 @@ index ea20b23e4c..0eabc71b68 100644
|
||||
static QTAILQ_HEAD(, ObjectOption) object_opts = QTAILQ_HEAD_INITIALIZER(object_opts);
|
||||
static QTAILQ_HEAD(, DeviceOption) device_opts = QTAILQ_HEAD_INITIALIZER(device_opts);
|
||||
static int display_remote;
|
||||
@@ -2612,6 +2613,12 @@ void qmp_x_exit_preconfig(Error **errp)
|
||||
|
||||
if (loadvm) {
|
||||
@@ -2725,6 +2726,12 @@ void qmp_x_exit_preconfig(Error **errp)
|
||||
RunState state = autostart ? RUN_STATE_RUNNING : runstate_get();
|
||||
load_snapshot(loadvm, NULL, false, NULL, &error_fatal);
|
||||
load_snapshot_resume(state);
|
||||
+ } else if (loadstate) {
|
||||
+ Error *local_err = NULL;
|
||||
+ if (load_snapshot_from_blockdev(loadstate, &local_err) < 0) {
|
||||
@@ -849,7 +892,7 @@ index ea20b23e4c..0eabc71b68 100644
|
||||
}
|
||||
if (replay_mode != REPLAY_MODE_NONE) {
|
||||
replay_vmstate_init();
|
||||
@@ -3159,6 +3166,9 @@ void qemu_init(int argc, char **argv)
|
||||
@@ -3262,6 +3269,9 @@ void qemu_init(int argc, char **argv)
|
||||
case QEMU_OPTION_loadvm:
|
||||
loadvm = optarg;
|
||||
break;
|
||||
|
@@ -13,18 +13,18 @@ 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 | 49 +++++++++++++++++++++++++++-------------
|
||||
migration/qemu-file.c | 48 +++++++++++++++++++++++++++-------------
|
||||
migration/qemu-file.h | 2 ++
|
||||
migration/savevm-async.c | 5 ++--
|
||||
3 files changed, 38 insertions(+), 18 deletions(-)
|
||||
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 102ab3b439..5ced17aba4 100644
|
||||
index b6d2f588bd..754dc0b3f7 100644
|
||||
--- a/migration/qemu-file.c
|
||||
+++ b/migration/qemu-file.c
|
||||
@@ -31,8 +31,8 @@
|
||||
#include "trace.h"
|
||||
#include "qapi/error.h"
|
||||
@@ -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)
|
||||
@@ -32,8 +32,8 @@ index 102ab3b439..5ced17aba4 100644
|
||||
+#define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 256)
|
||||
|
||||
struct QEMUFile {
|
||||
const QEMUFileHooks *hooks;
|
||||
@@ -55,7 +55,8 @@ struct QEMUFile {
|
||||
QIOChannel *ioc;
|
||||
@@ -43,7 +43,8 @@ struct QEMUFile {
|
||||
|
||||
int buf_index;
|
||||
int buf_size; /* 0 when writing */
|
||||
@@ -43,8 +43,8 @@ index 102ab3b439..5ced17aba4 100644
|
||||
|
||||
DECLARE_BITMAP(may_free, MAX_IOV_SIZE);
|
||||
struct iovec iov[MAX_IOV_SIZE];
|
||||
@@ -127,7 +128,9 @@ bool qemu_file_mode_is_not_valid(const char *mode)
|
||||
return false;
|
||||
@@ -100,7 +101,9 @@ int qemu_file_shutdown(QEMUFile *f)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
|
||||
@@ -54,7 +54,7 @@ index 102ab3b439..5ced17aba4 100644
|
||||
{
|
||||
QEMUFile *f;
|
||||
|
||||
@@ -136,6 +139,8 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
|
||||
@@ -109,6 +112,8 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
|
||||
object_ref(ioc);
|
||||
f->ioc = ioc;
|
||||
f->is_writable = is_writable;
|
||||
@@ -63,7 +63,7 @@ index 102ab3b439..5ced17aba4 100644
|
||||
|
||||
return f;
|
||||
}
|
||||
@@ -146,17 +151,27 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
|
||||
@@ -119,17 +124,27 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
|
||||
*/
|
||||
QEMUFile *qemu_file_get_return_path(QEMUFile *f)
|
||||
{
|
||||
@@ -93,8 +93,8 @@ index 102ab3b439..5ced17aba4 100644
|
||||
+ return qemu_file_new_impl(ioc, false, buffer_size);
|
||||
}
|
||||
|
||||
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks)
|
||||
@@ -414,7 +429,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
|
||||
/*
|
||||
@@ -327,7 +342,7 @@ static ssize_t coroutine_mixed_fn qemu_fill_buffer(QEMUFile *f)
|
||||
do {
|
||||
len = qio_channel_read(f->ioc,
|
||||
(char *)f->buf + pending,
|
||||
@@ -103,16 +103,17 @@ index 102ab3b439..5ced17aba4 100644
|
||||
&local_error);
|
||||
if (len == QIO_CHANNEL_ERR_BLOCK) {
|
||||
if (qemu_in_coroutine()) {
|
||||
@@ -464,6 +479,8 @@ int qemu_fclose(QEMUFile *f)
|
||||
@@ -367,6 +382,9 @@ int qemu_fclose(QEMUFile *f)
|
||||
ret = ret2;
|
||||
}
|
||||
g_clear_pointer(&f->ioc, object_unref);
|
||||
|
||||
+
|
||||
+ free(f->buf);
|
||||
+
|
||||
/* If any error was spotted before closing, we should report it
|
||||
* instead of the close() return value.
|
||||
*/
|
||||
@@ -518,7 +535,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
|
||||
error_free(f->last_error_obj);
|
||||
g_free(f);
|
||||
trace_qemu_file_fclose();
|
||||
@@ -415,7 +433,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;
|
||||
@@ -121,7 +122,7 @@ index 102ab3b439..5ced17aba4 100644
|
||||
qemu_fflush(f);
|
||||
}
|
||||
}
|
||||
@@ -544,7 +561,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
|
||||
@@ -440,7 +458,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
|
||||
}
|
||||
|
||||
while (size > 0) {
|
||||
@@ -130,7 +131,7 @@ index 102ab3b439..5ced17aba4 100644
|
||||
if (l > size) {
|
||||
l = size;
|
||||
}
|
||||
@@ -591,8 +608,8 @@ size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset)
|
||||
@@ -586,8 +604,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));
|
||||
@@ -141,7 +142,7 @@ index 102ab3b439..5ced17aba4 100644
|
||||
|
||||
/* The 1st byte to read from */
|
||||
index = f->buf_index + offset;
|
||||
@@ -642,7 +659,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
|
||||
@@ -637,7 +655,7 @@ size_t coroutine_mixed_fn qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size
|
||||
size_t res;
|
||||
uint8_t *src;
|
||||
|
||||
@@ -150,16 +151,16 @@ index 102ab3b439..5ced17aba4 100644
|
||||
if (res == 0) {
|
||||
return done;
|
||||
}
|
||||
@@ -676,7 +693,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
|
||||
@@ -671,7 +689,7 @@ size_t coroutine_mixed_fn 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)
|
||||
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;
|
||||
|
||||
@@ -701,7 +718,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
|
||||
@@ -696,7 +714,7 @@ int coroutine_mixed_fn qemu_peek_byte(QEMUFile *f, int offset)
|
||||
int index = f->buf_index + offset;
|
||||
|
||||
assert(!qemu_file_is_writable(f));
|
||||
@@ -168,34 +169,25 @@ index 102ab3b439..5ced17aba4 100644
|
||||
|
||||
if (index >= f->buf_size) {
|
||||
qemu_fill_buffer(f);
|
||||
@@ -853,7 +870,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 9d0155a2a1..cc06240e8d 100644
|
||||
index 11c2120edd..edf3c5d147 100644
|
||||
--- a/migration/qemu-file.h
|
||||
+++ b/migration/qemu-file.h
|
||||
@@ -63,7 +63,9 @@ typedef struct QEMUFileHooks {
|
||||
} QEMUFileHooks;
|
||||
@@ -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);
|
||||
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks);
|
||||
int qemu_fclose(QEMUFile *f);
|
||||
|
||||
/*
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index ac1fac6378..ea3b2f36a6 100644
|
||||
index ee8ef316d0..1e79fce9ba 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -380,7 +380,7 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
@@ -390,7 +390,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));
|
||||
@@ -203,9 +195,9 @@ index ac1fac6378..ea3b2f36a6 100644
|
||||
+ snap_state.file = qemu_file_new_output_sized(ioc, 4 * 1024 * 1024);
|
||||
|
||||
if (!snap_state.file) {
|
||||
error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
|
||||
@@ -498,7 +498,8 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
|
||||
blk_op_block_all(be, blocker);
|
||||
error_setg(errp, "failed to open '%s'", statefile);
|
||||
@@ -534,7 +534,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)));
|
||||
|
@@ -4,32 +4,34 @@ Date: Mon, 6 Apr 2020 12:16:47 +0200
|
||||
Subject: [PATCH] PVE: block: add the zeroinit block driver filter
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: adapt to changed function signatures]
|
||||
[FE: adapt to changed function signatures
|
||||
adhere to block graph lock requirements
|
||||
use dedicated function to open file child]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/meson.build | 1 +
|
||||
block/zeroinit.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 201 insertions(+)
|
||||
block/zeroinit.c | 207 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 208 insertions(+)
|
||||
create mode 100644 block/zeroinit.c
|
||||
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index 382bec0e7d..253fe49fa2 100644
|
||||
index f1262ec2ba..6a60b5d6b9 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -44,6 +44,7 @@ block_ss.add(files(
|
||||
'vmdk.c',
|
||||
'vpc.c',
|
||||
@@ -39,6 +39,7 @@ block_ss.add(files(
|
||||
'throttle.c',
|
||||
'throttle-groups.c',
|
||||
'write-threshold.c',
|
||||
+ 'zeroinit.c',
|
||||
), zstd, zlib, gnutls)
|
||||
), zstd, zlib)
|
||||
|
||||
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
system_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
diff --git a/block/zeroinit.c b/block/zeroinit.c
|
||||
new file mode 100644
|
||||
index 0000000000..1257342724
|
||||
index 0000000000..2b2b194ccf
|
||||
--- /dev/null
|
||||
+++ b/block/zeroinit.c
|
||||
@@ -0,0 +1,200 @@
|
||||
@@ -0,0 +1,207 @@
|
||||
+/*
|
||||
+ * Filter to fake a zero-initialized block device.
|
||||
+ *
|
||||
@@ -44,6 +46,7 @@ index 0000000000..1257342724
|
||||
+#include "qapi/error.h"
|
||||
+#include "block/block_int.h"
|
||||
+#include "block/block-io.h"
|
||||
+#include "block/graph-lock.h"
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
+#include "qapi/qmp/qstring.h"
|
||||
+#include "qemu/cutils.h"
|
||||
@@ -109,12 +112,9 @@ index 0000000000..1257342724
|
||||
+ }
|
||||
+
|
||||
+ /* Open the raw file */
|
||||
+ bs->file = bdrv_open_child(qemu_opt_get(opts, "x-next"), options, "next",
|
||||
+ bs, &child_of_bds,
|
||||
+ BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
|
||||
+ 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;
|
||||
+ }
|
||||
@@ -125,7 +125,9 @@ index 0000000000..1257342724
|
||||
+ ret = 0;
|
||||
+fail:
|
||||
+ if (ret < 0) {
|
||||
+ bdrv_graph_wrlock();
|
||||
+ bdrv_unref_child(bs, bs->file);
|
||||
+ bdrv_graph_wrunlock();
|
||||
+ }
|
||||
+ qemu_opts_del(opts);
|
||||
+ return ret;
|
||||
@@ -137,19 +139,22 @@ index 0000000000..1257342724
|
||||
+ (void)s;
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int64_t zeroinit_co_getlength(BlockDriverState *bs)
|
||||
+static coroutine_fn int64_t GRAPH_RDLOCK
|
||||
+zeroinit_co_getlength(BlockDriverState *bs)
|
||||
+{
|
||||
+ return bdrv_co_getlength(bs->file->bs);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_preadv(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+zeroinit_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
+ QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
||||
+ int64_t bytes, BdrvRequestFlags flags)
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+zeroinit_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
+ BdrvRequestFlags flags)
|
||||
+{
|
||||
+ BDRVZeroinitState *s = bs->opaque;
|
||||
+ if (offset >= s->extents)
|
||||
@@ -157,8 +162,9 @@ index 0000000000..1257342724
|
||||
+ return bdrv_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_pwritev(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+zeroinit_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
+ QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ BDRVZeroinitState *s = bs->opaque;
|
||||
+ int64_t extents = offset + bytes;
|
||||
@@ -167,32 +173,35 @@ index 0000000000..1257342724
|
||||
+ return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int zeroinit_co_flush(BlockDriverState *bs)
|
||||
+static coroutine_fn int GRAPH_RDLOCK
|
||||
+zeroinit_co_flush(BlockDriverState *bs)
|
||||
+{
|
||||
+ return bdrv_co_flush(bs->file->bs);
|
||||
+}
|
||||
+
|
||||
+static int zeroinit_has_zero_init(BlockDriverState *bs)
|
||||
+static int GRAPH_RDLOCK
|
||||
+zeroinit_has_zero_init(BlockDriverState *bs)
|
||||
+{
|
||||
+ BDRVZeroinitState *s = bs->opaque;
|
||||
+ return s->has_zero_init;
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_pdiscard(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes)
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+zeroinit_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
+{
|
||||
+ return bdrv_co_pdiscard(bs->file, offset, bytes);
|
||||
+}
|
||||
+
|
||||
+static int zeroinit_co_truncate(BlockDriverState *bs, int64_t offset,
|
||||
+ _Bool exact, PreallocMode prealloc,
|
||||
+ BdrvRequestFlags req_flags, Error **errp)
|
||||
+static int GRAPH_RDLOCK
|
||||
+zeroinit_co_truncate(BlockDriverState *bs, int64_t offset, _Bool exact,
|
||||
+ PreallocMode prealloc, BdrvRequestFlags req_flags,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ return bdrv_co_truncate(bs->file, offset, exact, prealloc, req_flags, errp);
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int zeroinit_co_get_info(BlockDriverState *bs,
|
||||
+ BlockDriverInfo *bdi)
|
||||
+static coroutine_fn int GRAPH_RDLOCK
|
||||
+zeroinit_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
|
||||
+{
|
||||
+ return bdrv_co_get_info(bs->file->bs, bdi);
|
||||
+}
|
||||
@@ -203,7 +212,7 @@ index 0000000000..1257342724
|
||||
+ .instance_size = sizeof(BDRVZeroinitState),
|
||||
+
|
||||
+ .bdrv_parse_filename = zeroinit_parse_filename,
|
||||
+ .bdrv_file_open = zeroinit_open,
|
||||
+ .bdrv_open = zeroinit_open,
|
||||
+ .bdrv_close = zeroinit_close,
|
||||
+ .bdrv_co_getlength = zeroinit_co_getlength,
|
||||
+ .bdrv_child_perm = bdrv_default_perms,
|
||||
|
@@ -10,14 +10,14 @@ 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 fdd551c2bb..4eb43b7bc5 100644
|
||||
index c05f411599..0732077a0e 100644
|
||||
--- a/qemu-options.hx
|
||||
+++ b/qemu-options.hx
|
||||
@@ -1162,6 +1162,9 @@ legacy PC, they are not recommended for modern configurations.
|
||||
@@ -1239,6 +1239,9 @@ legacy PC, they are not recommended for modern configurations.
|
||||
|
||||
ERST
|
||||
|
||||
@@ -27,11 +27,11 @@ index fdd551c2bb..4eb43b7bc5 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 0eabc71b68..323f6a23d4 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -2648,6 +2648,7 @@ void qemu_init(int argc, char **argv)
|
||||
diff --git a/system/vl.c b/system/vl.c
|
||||
index 39d451bb41..e7cae51f13 100644
|
||||
--- a/system/vl.c
|
||||
+++ b/system/vl.c
|
||||
@@ -2762,6 +2762,7 @@ void qemu_init(int argc, char **argv)
|
||||
MachineClass *machine_class;
|
||||
bool userconfig = true;
|
||||
FILE *vmstate_dump_file = NULL;
|
||||
@@ -39,7 +39,7 @@ index 0eabc71b68..323f6a23d4 100644
|
||||
|
||||
qemu_add_opts(&qemu_drive_opts);
|
||||
qemu_add_drive_opts(&qemu_legacy_drive_opts);
|
||||
@@ -3271,6 +3272,13 @@ void qemu_init(int argc, char **argv)
|
||||
@@ -3374,6 +3375,13 @@ void qemu_init(int argc, char **argv)
|
||||
machine_parse_property_opt(qemu_find_opts("smp-opts"),
|
||||
"smp", optarg);
|
||||
break;
|
||||
@@ -50,6 +50,6 @@ index 0eabc71b68..323f6a23d4 100644
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ break;
|
||||
#ifdef CONFIG_VNC
|
||||
case QEMU_OPTION_vnc:
|
||||
vnc_parse(optarg);
|
||||
break;
|
||||
|
@@ -11,10 +11,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
|
||||
index 4a34f03047..59b917e50c 100644
|
||||
index 62f3bbf203..89e0c7d995 100644
|
||||
--- a/hw/intc/apic_common.c
|
||||
+++ b/hw/intc/apic_common.c
|
||||
@@ -252,6 +252,15 @@ static void apic_reset_common(DeviceState *dev)
|
||||
@@ -263,6 +263,15 @@ static void apic_reset_common(DeviceState *dev)
|
||||
info->vapic_base_update(s);
|
||||
|
||||
apic_init_reset(dev);
|
||||
|
@@ -9,14 +9,14 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/file-posix.c | 59 ++++++++++++++++++++++++++++++--------------
|
||||
qapi/block-core.json | 3 ++-
|
||||
2 files changed, 42 insertions(+), 20 deletions(-)
|
||||
qapi/block-core.json | 7 +++++-
|
||||
2 files changed, 46 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/block/file-posix.c b/block/file-posix.c
|
||||
index 9681bd0434..044890822d 100644
|
||||
index e2ea071315..4c3dc56c8e 100644
|
||||
--- a/block/file-posix.c
|
||||
+++ b/block/file-posix.c
|
||||
@@ -2483,6 +2483,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -2884,6 +2884,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
int fd;
|
||||
uint64_t perm, shared;
|
||||
int result = 0;
|
||||
@@ -24,7 +24,7 @@ index 9681bd0434..044890822d 100644
|
||||
|
||||
/* Validate options and set default values */
|
||||
assert(options->driver == BLOCKDEV_DRIVER_FILE);
|
||||
@@ -2523,19 +2524,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -2924,19 +2925,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 9681bd0434..044890822d 100644
|
||||
}
|
||||
|
||||
/* Clear the file by truncating it to 0 */
|
||||
@@ -2589,13 +2593,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -2990,13 +2994,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
}
|
||||
|
||||
out_unlock:
|
||||
@@ -82,7 +82,7 @@ index 9681bd0434..044890822d 100644
|
||||
}
|
||||
|
||||
out_close:
|
||||
@@ -2619,6 +2625,7 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
@@ -3020,6 +3026,7 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
PreallocMode prealloc;
|
||||
char *buf = NULL;
|
||||
Error *local_err = NULL;
|
||||
@@ -90,7 +90,7 @@ index 9681bd0434..044890822d 100644
|
||||
|
||||
/* Skip file: protocol prefix */
|
||||
strstart(filename, "file:", &filename);
|
||||
@@ -2641,6 +2648,18 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
@@ -3042,6 +3049,18 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ index 9681bd0434..044890822d 100644
|
||||
options = (BlockdevCreateOptions) {
|
||||
.driver = BLOCKDEV_DRIVER_FILE,
|
||||
.u.file = {
|
||||
@@ -2652,6 +2671,8 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
@@ -3053,6 +3072,8 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
.nocow = nocow,
|
||||
.has_extent_size_hint = has_extent_size_hint,
|
||||
.extent_size_hint = extent_size_hint,
|
||||
@@ -119,10 +119,21 @@ index 9681bd0434..044890822d 100644
|
||||
};
|
||||
return raw_co_create(&options, errp);
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 3c945c1f93..542add004b 100644
|
||||
index 48ba32049f..321d1fd0e1 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -4740,7 +4740,8 @@
|
||||
@@ -4974,6 +4974,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',
|
||||
@@ -4981,7 +4985,8 @@
|
||||
'size': 'size',
|
||||
'*preallocation': 'PreallocMode',
|
||||
'*nocow': 'bool',
|
||||
|
@@ -18,10 +18,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/monitor/qmp.c b/monitor/qmp.c
|
||||
index 6b8cfcf6d8..3ec67e32d3 100644
|
||||
index eb181d5979..20fc0d20a6 100644
|
||||
--- a/monitor/qmp.c
|
||||
+++ b/monitor/qmp.c
|
||||
@@ -519,8 +519,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 2f6ccf5623..a5927e92f1 100644
|
||||
index f29fe95964..2c327fc36a 100644
|
||||
--- a/hw/core/machine.c
|
||||
+++ b/hw/core/machine.c
|
||||
@@ -142,7 +142,8 @@ GlobalProperty hw_compat_4_0[] = {
|
||||
@@ -180,7 +180,8 @@ GlobalProperty hw_compat_4_0[] = {
|
||||
{ "virtio-vga", "edid", "false" },
|
||||
{ "virtio-gpu-device", "edid", "false" },
|
||||
{ "virtio-device", "use-started", "false" },
|
||||
|
@@ -16,15 +16,15 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hw/core/machine-qmp-cmds.c | 5 +++++
|
||||
include/hw/boards.h | 2 ++
|
||||
qapi/machine.json | 4 +++-
|
||||
softmmu/vl.c | 25 +++++++++++++++++++++++++
|
||||
4 files changed, 35 insertions(+), 1 deletion(-)
|
||||
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 24595f618c..ee9cb0cd04 100644
|
||||
index 52a6d74820..362128842d 100644
|
||||
--- a/hw/core/machine-qmp-cmds.c
|
||||
+++ b/hw/core/machine-qmp-cmds.c
|
||||
@@ -107,6 +107,11 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
||||
@@ -94,6 +94,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;
|
||||
@@ -37,65 +37,64 @@ index 24595f618c..ee9cb0cd04 100644
|
||||
|
||||
if (mc->default_cpu_type) {
|
||||
diff --git a/include/hw/boards.h b/include/hw/boards.h
|
||||
index 6fbbfd56c8..61a526e97d 100644
|
||||
index 36fbb9b59d..d1741ea121 100644
|
||||
--- a/include/hw/boards.h
|
||||
+++ b/include/hw/boards.h
|
||||
@@ -232,6 +232,8 @@ struct MachineClass {
|
||||
@@ -268,6 +268,8 @@ struct MachineClass {
|
||||
const char *desc;
|
||||
const char *deprecation_reason;
|
||||
|
||||
+ const char *pve_version;
|
||||
+
|
||||
void (*init)(MachineState *state);
|
||||
void (*reset)(MachineState *state, ShutdownCause reason);
|
||||
void (*reset)(MachineState *state, ResetType type);
|
||||
void (*wakeup)(MachineState *state);
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index c904280085..47f3facdb2 100644
|
||||
index 16366b774a..12cfd3f260 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -159,6 +159,8 @@
|
||||
@@ -189,6 +189,8 @@
|
||||
#
|
||||
# @acpi: machine type supports ACPI (since 8.0)
|
||||
#
|
||||
+# @pve-version: custom PVE version suffix specified as 'machine+pveN'
|
||||
+#
|
||||
# Since: 1.2
|
||||
##
|
||||
{ 'struct': 'MachineInfo',
|
||||
@@ -166,7 +168,7 @@
|
||||
'*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
|
||||
# @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',
|
||||
- '*default-ram-id': 'str', 'acpi': 'bool' } }
|
||||
+ '*default-ram-id': 'str', 'acpi': 'bool', '*pve-version': '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 323f6a23d4..25abdc9da7 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -1578,6 +1578,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
|
||||
static MachineClass *select_machine(QDict *qdict, Error **errp)
|
||||
diff --git a/system/vl.c b/system/vl.c
|
||||
index e7cae51f13..3f4916ac5a 100644
|
||||
--- a/system/vl.c
|
||||
+++ b/system/vl.c
|
||||
@@ -1675,6 +1675,7 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
|
||||
{
|
||||
const char *optarg = qdict_get_try_str(qdict, "type");
|
||||
ERRP_GUARD();
|
||||
const char *machine_type = qdict_get_try_str(qdict, "type");
|
||||
+ const char *pvever = qdict_get_try_str(qdict, "pvever");
|
||||
GSList *machines = object_class_get_list(TYPE_MACHINE, false);
|
||||
MachineClass *machine_class;
|
||||
Error *local_err = NULL;
|
||||
@@ -1595,6 +1596,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
|
||||
}
|
||||
}
|
||||
g_autoptr(GSList) machines = object_class_get_list(TYPE_MACHINE, false);
|
||||
MachineClass *machine_class = NULL;
|
||||
|
||||
+ if (machine_class) {
|
||||
@@ -1694,7 +1695,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");
|
||||
+ }
|
||||
}
|
||||
+
|
||||
g_slist_free(machines);
|
||||
if (local_err) {
|
||||
error_append_hint(&local_err, "Use -machine help to list supported machines\n");
|
||||
@@ -3213,12 +3219,31 @@ void qemu_init(int argc, char **argv)
|
||||
return machine_class;
|
||||
}
|
||||
|
||||
@@ -3316,12 +3321,31 @@ void qemu_init(int argc, char **argv)
|
||||
case QEMU_OPTION_machine:
|
||||
{
|
||||
bool help;
|
||||
|
@@ -25,7 +25,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/block/backup.c b/block/backup.c
|
||||
index db3791f4d1..39410dcf8d 100644
|
||||
index a1292c01ec..2e38b30d67 100644
|
||||
--- a/block/backup.c
|
||||
+++ b/block/backup.c
|
||||
@@ -237,8 +237,8 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
|
||||
@@ -48,9 +48,9 @@ index db3791f4d1..39410dcf8d 100644
|
||||
if (s->sync_mode == MIRROR_SYNC_MODE_TOP) {
|
||||
int64_t offset = 0;
|
||||
int64_t count;
|
||||
@@ -495,6 +493,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL,
|
||||
@@ -502,6 +500,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
&error_abort);
|
||||
bdrv_graph_wrunlock();
|
||||
|
||||
+ backup_init_bcs_bitmap(job);
|
||||
+
|
||||
|
@@ -10,39 +10,40 @@ skip reads.
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: improvements during create
|
||||
allow partial restore]
|
||||
allow partial restore
|
||||
allow specifying disk formats for create operation]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/meson.build | 2 +
|
||||
meson.build | 5 +
|
||||
vma-reader.c | 867 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma-writer.c | 793 +++++++++++++++++++++++++++++++++++++++++
|
||||
vma.c | 878 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma-reader.c | 867 ++++++++++++++++++++++++++++++++++++++++++
|
||||
vma-writer.c | 816 ++++++++++++++++++++++++++++++++++++++++
|
||||
vma.c | 941 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma.h | 150 ++++++++
|
||||
6 files changed, 2695 insertions(+)
|
||||
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/block/meson.build b/block/meson.build
|
||||
index 253fe49fa2..744b698a82 100644
|
||||
index 6a60b5d6b9..652c8cbdb7 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -47,6 +47,8 @@ block_ss.add(files(
|
||||
@@ -42,6 +42,8 @@ block_ss.add(files(
|
||||
'zeroinit.c',
|
||||
), zstd, zlib, gnutls)
|
||||
), zstd, zlib)
|
||||
|
||||
+block_ss.add(files('../vma-writer.c'), libuuid)
|
||||
+
|
||||
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
softmmu_ss.add(files('block-ram-registrar.c'))
|
||||
system_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
system_ss.add(files('block-ram-registrar.c'))
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 30447cfaef..38a4e2bcef 100644
|
||||
index 147097c652..b9b673c271 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -1527,6 +1527,8 @@ keyutils = dependency('libkeyutils', required: false,
|
||||
@@ -2129,6 +2129,8 @@ endif
|
||||
|
||||
has_gettid = cc.has_function('gettid')
|
||||
|
||||
@@ -51,19 +52,19 @@ index 30447cfaef..38a4e2bcef 100644
|
||||
# libselinux
|
||||
selinux = dependency('libselinux',
|
||||
required: get_option('selinux'),
|
||||
@@ -3650,6 +3652,9 @@ if have_tools
|
||||
dependencies: [blockdev, qemuutil, gnutls, selinux],
|
||||
@@ -4344,6 +4346,9 @@ if have_tools
|
||||
dependencies: [blockdev, qemuutil, selinux],
|
||||
install: true)
|
||||
|
||||
+ vma = executable('vma', files('vma.c', 'vma-reader.c') + genh,
|
||||
+ dependencies: [authz, block, crypto, io, qom], install: true)
|
||||
+ dependencies: [authz, block, crypto, io, qemuutil, qom], install: true)
|
||||
+
|
||||
subdir('storage-daemon')
|
||||
subdir('contrib/rdmacm-mux')
|
||||
subdir('contrib/elf2dmp')
|
||||
|
||||
foreach exe: [ 'qemu-img', 'qemu-io', 'qemu-nbd', 'qemu-storage-daemon']
|
||||
diff --git a/vma-reader.c b/vma-reader.c
|
||||
new file mode 100644
|
||||
index 0000000000..81a891c6b1
|
||||
index 0000000000..bb65ad313c
|
||||
--- /dev/null
|
||||
+++ b/vma-reader.c
|
||||
@@ -0,0 +1,867 @@
|
||||
@@ -88,6 +89,7 @@ index 0000000000..81a891c6b1
|
||||
+#include "qemu/ratelimit.h"
|
||||
+#include "vma.h"
|
||||
+#include "block/block.h"
|
||||
+#include "block/graph-lock.h"
|
||||
+#include "sysemu/block-backend.h"
|
||||
+
|
||||
+static unsigned char zero_vma_block[VMA_BLOCK_SIZE];
|
||||
@@ -380,7 +382,6 @@ index 0000000000..81a891c6b1
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ 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);
|
||||
@@ -388,7 +389,6 @@ index 0000000000..81a891c6b1
|
||||
+ const char *devname = get_header_str(vmar, devname_ptr);
|
||||
+
|
||||
+ if (size && devname) {
|
||||
+ count++;
|
||||
+ vmar->devinfo[i].size = size;
|
||||
+ vmar->devinfo[i].devname = devname;
|
||||
+
|
||||
@@ -600,8 +600,10 @@ index 0000000000..81a891c6b1
|
||||
+ } else {
|
||||
+ 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;
|
||||
+ }
|
||||
+ }
|
||||
@@ -881,8 +883,7 @@ index 0000000000..81a891c6b1
|
||||
+
|
||||
+ 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)) {
|
||||
@@ -936,10 +937,10 @@ index 0000000000..81a891c6b1
|
||||
+
|
||||
diff --git a/vma-writer.c b/vma-writer.c
|
||||
new file mode 100644
|
||||
index 0000000000..ac7da237d0
|
||||
index 0000000000..3f489092df
|
||||
--- /dev/null
|
||||
+++ b/vma-writer.c
|
||||
@@ -0,0 +1,793 @@
|
||||
@@ -0,0 +1,816 @@
|
||||
+/*
|
||||
+ * VMA: Virtual Machine Archive
|
||||
+ *
|
||||
@@ -955,6 +956,8 @@ index 0000000000..ac7da237d0
|
||||
+
|
||||
+#include "qemu/osdep.h"
|
||||
+#include <glib.h>
|
||||
+#include <linux/magic.h>
|
||||
+#include <sys/vfs.h>
|
||||
+#include <uuid/uuid.h>
|
||||
+
|
||||
+#include "vma.h"
|
||||
@@ -963,6 +966,7 @@ index 0000000000..ac7da237d0
|
||||
+#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
|
||||
@@ -1130,8 +1134,7 @@ index 0000000000..ac7da237d0
|
||||
+ 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;
|
||||
+
|
||||
@@ -1146,10 +1149,10 @@ index 0000000000..ac7da237d0
|
||||
+{
|
||||
+ assert(qemu_in_coroutine());
|
||||
+ AioContext *ctx = qemu_get_current_aio_context();
|
||||
+ aio_set_fd_handler(ctx, fd, false, NULL, (IOHandler *)qemu_coroutine_enter,
|
||||
+ NULL, NULL, qemu_coroutine_self());
|
||||
+ 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, NULL);
|
||||
+ aio_set_fd_handler(ctx, fd, NULL, NULL, NULL, NULL, NULL);
|
||||
+}
|
||||
+
|
||||
+static ssize_t coroutine_fn
|
||||
@@ -1198,6 +1201,23 @@ index 0000000000..ac7da237d0
|
||||
+ 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;
|
||||
@@ -1247,8 +1267,13 @@ index 0000000000..ac7da237d0
|
||||
+ }
|
||||
+ /* try to use O_NONBLOCK */
|
||||
+ fcntl(vmaw->fd, F_SETFL, fcntl(vmaw->fd, F_GETFL)|O_NONBLOCK);
|
||||
+ } else {
|
||||
+ oflags = O_NONBLOCK|O_DIRECT|O_WRONLY|O_EXCL;
|
||||
+ } else {
|
||||
+ gchar *dirname = g_path_get_dirname(filename);
|
||||
+ oflags = O_NONBLOCK|O_WRONLY|O_EXCL;
|
||||
+ if (!is_path_tmpfs(dirname)) {
|
||||
+ oflags |= O_DIRECT;
|
||||
+ }
|
||||
+ g_free(dirname);
|
||||
+ vmaw->fd = qemu_create(filename, oflags, 0644, errp);
|
||||
+ }
|
||||
+
|
||||
@@ -1489,17 +1514,16 @@ index 0000000000..ac7da237d0
|
||||
+ 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;
|
||||
@@ -1735,10 +1759,10 @@ index 0000000000..ac7da237d0
|
||||
+}
|
||||
diff --git a/vma.c b/vma.c
|
||||
new file mode 100644
|
||||
index 0000000000..304f02bc84
|
||||
index 0000000000..8d4b4be414
|
||||
--- /dev/null
|
||||
+++ b/vma.c
|
||||
@@ -0,0 +1,878 @@
|
||||
@@ -0,0 +1,941 @@
|
||||
+/*
|
||||
+ * VMA: Virtual Machine Archive
|
||||
+ *
|
||||
@@ -1770,9 +1794,9 @@ index 0000000000..304f02bc84
|
||||
+ "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"
|
||||
+ ;
|
||||
+
|
||||
@@ -1917,9 +1941,10 @@ index 0000000000..304f02bc84
|
||||
+ 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;
|
||||
+ }
|
||||
@@ -1928,6 +1953,9 @@ index 0000000000..304f02bc84
|
||||
+ case 'h':
|
||||
+ help();
|
||||
+ break;
|
||||
+ case 'd':
|
||||
+ drive_list = g_strsplit(optarg, ",", 254);
|
||||
+ break;
|
||||
+ case 'r':
|
||||
+ readmap = optarg;
|
||||
+ break;
|
||||
@@ -2047,29 +2075,29 @@ index 0000000000..304f02bc84
|
||||
+ 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;
|
||||
+ map->skip = skip;
|
||||
+ RestoreMap *restore_map = g_new0(RestoreMap, 1);
|
||||
+ restore_map->devname = g_strdup(devname);
|
||||
+ restore_map->path = g_strdup(path);
|
||||
+ restore_map->format = format;
|
||||
+ restore_map->throttling_bps = bps_value;
|
||||
+ restore_map->throttling_group = group;
|
||||
+ restore_map->cache = cache;
|
||||
+ restore_map->write_zero = write_zero;
|
||||
+ restore_map->skip = skip;
|
||||
+
|
||||
+ g_hash_table_insert(devmap, map->devname, map);
|
||||
+ g_hash_table_insert(devmap, restore_map->devname, restore_map);
|
||||
+
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ int i;
|
||||
+ int vmstate_fd = -1;
|
||||
+ guint8 vmstate_stream = 0;
|
||||
+ bool drive_rename_bitmap[255];
|
||||
+ memset(drive_rename_bitmap, 0, sizeof(drive_rename_bitmap));
|
||||
+
|
||||
+ for (i = 1; i < 255; i++) {
|
||||
+ VmaDeviceInfo *di = vma_reader_get_device_info(vmar, i);
|
||||
+ if (di && (strcmp(di->devname, "vmstate") == 0)) {
|
||||
+ vmstate_stream = i;
|
||||
+ char *statefn = g_strdup_printf("%s/vmstate.bin", dirname);
|
||||
+ vmstate_fd = open(statefn, O_WRONLY|O_CREAT|O_EXCL, 0644);
|
||||
+ if (vmstate_fd < 0) {
|
||||
@@ -2089,7 +2117,21 @@ index 0000000000..304f02bc84
|
||||
+
|
||||
+ BlockBackend *blk = NULL;
|
||||
+
|
||||
+ if (readmap) {
|
||||
+ if (drive_list) {
|
||||
+ skip = true;
|
||||
+ int j;
|
||||
+ for (j = 0; drive_list[j]; j++) {
|
||||
+ if (strcmp(drive_list[j], di->devname) == 0) {
|
||||
+ skip = false;
|
||||
+ drive_rename_bitmap[i] = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ drive_rename_bitmap[i] = true;
|
||||
+ }
|
||||
+
|
||||
+ if (!skip && readmap) {
|
||||
+ RestoreMap *map;
|
||||
+ map = (RestoreMap *)g_hash_table_lookup(devmap, di->devname);
|
||||
+ if (map == NULL) {
|
||||
@@ -2102,7 +2144,7 @@ index 0000000000..304f02bc84
|
||||
+ cache = map->cache;
|
||||
+ write_zero = map->write_zero;
|
||||
+ skip = map->skip;
|
||||
+ } else {
|
||||
+ } else if (!skip) {
|
||||
+ devfn = g_strdup_printf("%s/tmp-disk-%s.raw",
|
||||
+ dirname, di->devname);
|
||||
+ printf("DEVINFO %s %zd\n", devfn, di->size);
|
||||
@@ -2183,6 +2225,10 @@ index 0000000000..304f02bc84
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ 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));
|
||||
+ }
|
||||
@@ -2190,7 +2236,7 @@ index 0000000000..304f02bc84
|
||||
+ 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",
|
||||
@@ -2314,13 +2360,13 @@ index 0000000000..304f02bc84
|
||||
+ ret = blk_co_preadv(job->target, start * VMA_CLUSTER_SIZE,
|
||||
+ 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;
|
||||
+ }
|
||||
+ }
|
||||
@@ -2338,14 +2384,16 @@ index 0000000000..304f02bc84
|
||||
+
|
||||
+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;
|
||||
+ }
|
||||
@@ -2357,6 +2405,9 @@ index 0000000000..304f02bc84
|
||||
+ 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;
|
||||
@@ -2402,16 +2453,48 @@ index 0000000000..304f02bc84
|
||||
+ 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));
|
||||
@@ -2433,6 +2516,8 @@ index 0000000000..304f02bc84
|
||||
+ // 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;
|
||||
@@ -2496,6 +2581,7 @@ index 0000000000..304f02bc84
|
||||
+ 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) {
|
||||
@@ -2513,6 +2599,7 @@ index 0000000000..304f02bc84
|
||||
+
|
||||
+ g_list_free(backup_coroutines);
|
||||
+ g_list_free(config_files);
|
||||
+ g_list_free(disk_infos);
|
||||
+ vma_writer_destroy(vmaw);
|
||||
+ return 0;
|
||||
+}
|
||||
@@ -2619,7 +2706,7 @@ index 0000000000..304f02bc84
|
||||
+}
|
||||
diff --git a/vma.h b/vma.h
|
||||
new file mode 100644
|
||||
index 0000000000..1b62859165
|
||||
index 0000000000..86d2873aa5
|
||||
--- /dev/null
|
||||
+++ b/vma.h
|
||||
@@ -0,0 +1,150 @@
|
||||
@@ -2757,7 +2844,7 @@ index 0000000000..1b62859165
|
||||
+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);
|
||||
|
@@ -12,20 +12,20 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: adapt to coroutine changes]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/backup-dump.c | 168 +++++++++++++++++++++++++++++++
|
||||
block/backup-dump.c | 172 +++++++++++++++++++++++++++++++
|
||||
block/backup.c | 30 ++----
|
||||
block/meson.build | 1 +
|
||||
include/block/block_int-common.h | 35 +++++++
|
||||
job.c | 3 +-
|
||||
5 files changed, 214 insertions(+), 23 deletions(-)
|
||||
5 files changed, 218 insertions(+), 23 deletions(-)
|
||||
create mode 100644 block/backup-dump.c
|
||||
|
||||
diff --git a/block/backup-dump.c b/block/backup-dump.c
|
||||
new file mode 100644
|
||||
index 0000000000..232a094426
|
||||
index 0000000000..e46abf1070
|
||||
--- /dev/null
|
||||
+++ b/block/backup-dump.c
|
||||
@@ -0,0 +1,168 @@
|
||||
@@ -0,0 +1,172 @@
|
||||
+/*
|
||||
+ * BlockDriver to send backup data stream to a callback function
|
||||
+ *
|
||||
@@ -37,6 +37,8 @@ index 0000000000..232a094426
|
||||
+ */
|
||||
+
|
||||
+#include "qemu/osdep.h"
|
||||
+
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
+#include "qom/object_interfaces.h"
|
||||
+#include "block/block_int.h"
|
||||
+
|
||||
@@ -169,7 +171,7 @@ index 0000000000..232a094426
|
||||
+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,
|
||||
@@ -177,9 +179,11 @@ index 0000000000..232a094426
|
||||
+ 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;
|
||||
+ }
|
||||
@@ -195,7 +199,7 @@ index 0000000000..232a094426
|
||||
+ return bs;
|
||||
+}
|
||||
diff --git a/block/backup.c b/block/backup.c
|
||||
index 39410dcf8d..af87fa6aa9 100644
|
||||
index 2e38b30d67..fe69723ada 100644
|
||||
--- a/block/backup.c
|
||||
+++ b/block/backup.c
|
||||
@@ -29,28 +29,6 @@
|
||||
@@ -227,7 +231,7 @@ index 39410dcf8d..af87fa6aa9 100644
|
||||
static const BlockJobDriver backup_job_driver;
|
||||
|
||||
static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret)
|
||||
@@ -457,6 +435,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
@@ -462,6 +440,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
}
|
||||
|
||||
cluster_size = block_copy_cluster_size(bcs);
|
||||
@@ -243,7 +247,7 @@ index 39410dcf8d..af87fa6aa9 100644
|
||||
if (perf->max_chunk && perf->max_chunk < cluster_size) {
|
||||
error_setg(errp, "Required max-chunk (%" PRIi64 ") is less than backup "
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index 744b698a82..f580f95395 100644
|
||||
index 652c8cbdb7..e1cf5a2e65 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -4,6 +4,7 @@ block_ss.add(files(
|
||||
@@ -251,11 +255,11 @@ index 744b698a82..f580f95395 100644
|
||||
'amend.c',
|
||||
'backup.c',
|
||||
+ 'backup-dump.c',
|
||||
'copy-before-write.c',
|
||||
'blkdebug.c',
|
||||
'blklogwrites.c',
|
||||
'blkverify.c',
|
||||
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
|
||||
index f01bb8b617..d7ffd1826e 100644
|
||||
index ebb4e56a50..e717a74e5f 100644
|
||||
--- a/include/block/block_int-common.h
|
||||
+++ b/include/block/block_int-common.h
|
||||
@@ -26,6 +26,7 @@
|
||||
@@ -272,7 +276,7 @@ index f01bb8b617..d7ffd1826e 100644
|
||||
|
||||
+typedef int BackupDumpFunc(void *opaque, uint64_t offset, uint64_t bytes, const void *buf);
|
||||
+
|
||||
+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,
|
||||
@@ -308,10 +312,10 @@ index f01bb8b617..d7ffd1826e 100644
|
||||
BDRV_TRACKED_READ,
|
||||
BDRV_TRACKED_WRITE,
|
||||
diff --git a/job.c b/job.c
|
||||
index 72d57f0934..93e22d180b 100644
|
||||
index 660ce22c56..baf54c8d60 100644
|
||||
--- a/job.c
|
||||
+++ b/job.c
|
||||
@@ -330,7 +330,8 @@ static bool job_started_locked(Job *job)
|
||||
@@ -331,7 +331,8 @@ static bool job_started_locked(Job *job)
|
||||
}
|
||||
|
||||
/* Called with job_mutex held. */
|
||||
|
@@ -11,10 +11,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
2 files changed, 46 insertions(+)
|
||||
|
||||
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
||||
index e502787dd8..963cf2bef5 100644
|
||||
index 2b873f2576..528cd6acb9 100644
|
||||
--- a/include/qemu/job.h
|
||||
+++ b/include/qemu/job.h
|
||||
@@ -381,6 +381,18 @@ void job_unlock(void);
|
||||
@@ -362,6 +362,18 @@ void job_unlock(void);
|
||||
*/
|
||||
JobTxn *job_txn_new(void);
|
||||
|
||||
@@ -34,10 +34,10 @@ index e502787dd8..963cf2bef5 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 93e22d180b..2b31f1e14f 100644
|
||||
index baf54c8d60..3ac5e5cde2 100644
|
||||
--- a/job.c
|
||||
+++ b/job.c
|
||||
@@ -93,6 +93,8 @@ struct JobTxn {
|
||||
@@ -94,6 +94,8 @@ struct JobTxn {
|
||||
|
||||
/* Reference count */
|
||||
int refcnt;
|
||||
@@ -46,7 +46,7 @@ index 93e22d180b..2b31f1e14f 100644
|
||||
};
|
||||
|
||||
void job_lock(void)
|
||||
@@ -118,6 +120,25 @@ JobTxn *job_txn_new(void)
|
||||
@@ -119,6 +121,25 @@ JobTxn *job_txn_new(void)
|
||||
return txn;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ index 93e22d180b..2b31f1e14f 100644
|
||||
/* Called with job_mutex held. */
|
||||
static void job_txn_ref_locked(JobTxn *txn)
|
||||
{
|
||||
@@ -1057,6 +1078,12 @@ static void job_completed_txn_success_locked(Job *job)
|
||||
@@ -1042,6 +1063,12 @@ static void job_completed_txn_success_locked(Job *job)
|
||||
*/
|
||||
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
|
||||
if (!job_is_completed_locked(other_job)) {
|
||||
@@ -85,7 +85,7 @@ index 93e22d180b..2b31f1e14f 100644
|
||||
return;
|
||||
}
|
||||
assert(other_job->ret == 0);
|
||||
@@ -1268,6 +1295,13 @@ int job_finish_sync_locked(Job *job,
|
||||
@@ -1253,6 +1280,13 @@ int job_finish_sync_locked(Job *job,
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
|
@@ -79,34 +79,36 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
adapt for new job lock mechanism replacing AioContext locks
|
||||
adapt to QAPI changes
|
||||
improve canceling
|
||||
allow passing max-workers setting]
|
||||
allow passing max-workers setting
|
||||
use malloc_trim after backup
|
||||
create jobs in a drained section]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/meson.build | 5 +
|
||||
block/monitor/block-hmp-cmds.c | 40 ++
|
||||
block/monitor/block-hmp-cmds.c | 39 ++
|
||||
blockdev.c | 1 +
|
||||
hmp-commands-info.hx | 14 +
|
||||
hmp-commands.hx | 31 +
|
||||
hmp-commands.hx | 29 +
|
||||
include/monitor/hmp.h | 3 +
|
||||
meson.build | 1 +
|
||||
monitor/hmp-cmds.c | 72 +++
|
||||
proxmox-backup-client.c | 146 +++++
|
||||
proxmox-backup-client.h | 60 ++
|
||||
pve-backup.c | 1097 ++++++++++++++++++++++++++++++++
|
||||
qapi/block-core.json | 226 +++++++
|
||||
qapi/common.json | 13 +
|
||||
qapi/machine.json | 15 +-
|
||||
14 files changed, 1711 insertions(+), 13 deletions(-)
|
||||
pve-backup.c | 1090 ++++++++++++++++++++++++++++++++
|
||||
qapi/block-core.json | 233 +++++++
|
||||
qapi/common.json | 14 +
|
||||
qapi/machine.json | 16 +-
|
||||
14 files changed, 1709 insertions(+), 14 deletions(-)
|
||||
create mode 100644 proxmox-backup-client.c
|
||||
create mode 100644 proxmox-backup-client.h
|
||||
create mode 100644 pve-backup.c
|
||||
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index f580f95395..5bcebb934b 100644
|
||||
index e1cf5a2e65..2367e1ac1b 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -49,6 +49,11 @@ block_ss.add(files(
|
||||
), zstd, zlib, gnutls)
|
||||
@@ -44,6 +44,11 @@ block_ss.add(files(
|
||||
), zstd, zlib)
|
||||
|
||||
block_ss.add(files('../vma-writer.c'), libuuid)
|
||||
+block_ss.add(files(
|
||||
@@ -115,13 +117,13 @@ index f580f95395..5bcebb934b 100644
|
||||
+), libproxmox_backup_qemu)
|
||||
+
|
||||
|
||||
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
softmmu_ss.add(files('block-ram-registrar.c'))
|
||||
system_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
system_ss.add(files('block-ram-registrar.c'))
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index ca2599de44..636509b83e 100644
|
||||
index bdf2eb50b6..439a7a14c8 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1029,3 +1029,43 @@ void hmp_change_medium(Monitor *mon, const char *device, const char *target,
|
||||
@@ -1009,3 +1009,42 @@ void hmp_change_medium(Monitor *mon, const char *device, const char *target,
|
||||
qmp_blockdev_change_medium(device, NULL, target, arg, true, force,
|
||||
!!read_only, read_only_mode, errp);
|
||||
}
|
||||
@@ -139,7 +141,6 @@ index ca2599de44..636509b83e 100644
|
||||
+{
|
||||
+ Error *error = NULL;
|
||||
+
|
||||
+ int dir = qdict_get_try_bool(qdict, "directory", 0);
|
||||
+ const char *backup_file = qdict_get_str(qdict, "backupfile");
|
||||
+ const char *devlist = qdict_get_try_str(qdict, "devlist");
|
||||
+ int64_t speed = qdict_get_try_int(qdict, "speed", 0);
|
||||
@@ -157,7 +158,7 @@ index ca2599de44..636509b83e 100644
|
||||
+ false, false, // PBS use-dirty-bitmap
|
||||
+ false, false, // PBS compress
|
||||
+ false, false, // PBS encrypt
|
||||
+ true, dir ? BACKUP_FORMAT_DIR : BACKUP_FORMAT_VMA,
|
||||
+ true, BACKUP_FORMAT_VMA,
|
||||
+ NULL, NULL,
|
||||
+ devlist, qdict_haskey(qdict, "speed"), speed,
|
||||
+ false, 0, // BackupPerf max-workers
|
||||
@@ -166,7 +167,7 @@ index ca2599de44..636509b83e 100644
|
||||
+ hmp_handle_error(mon, error);
|
||||
+}
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index bdae211a54..315a27fc09 100644
|
||||
index 79d47b1920..3f67eb413d 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -37,6 +37,7 @@
|
||||
@@ -178,10 +179,10 @@ index bdae211a54..315a27fc09 100644
|
||||
#include "monitor/monitor.h"
|
||||
#include "qemu/error-report.h"
|
||||
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
|
||||
index a166bff3d5..4b75966c2e 100644
|
||||
index d1a7b99add..af588145ff 100644
|
||||
--- a/hmp-commands-info.hx
|
||||
+++ b/hmp-commands-info.hx
|
||||
@@ -486,6 +486,20 @@ SRST
|
||||
@@ -458,6 +458,20 @@ SRST
|
||||
Show the current VM UUID.
|
||||
ERST
|
||||
|
||||
@@ -203,10 +204,10 @@ index a166bff3d5..4b75966c2e 100644
|
||||
{
|
||||
.name = "usernet",
|
||||
diff --git a/hmp-commands.hx b/hmp-commands.hx
|
||||
index d9f9f42d11..775518fb09 100644
|
||||
index 0c7c6f2c16..bf8315f226 100644
|
||||
--- a/hmp-commands.hx
|
||||
+++ b/hmp-commands.hx
|
||||
@@ -101,6 +101,37 @@ ERST
|
||||
@@ -101,6 +101,35 @@ ERST
|
||||
SRST
|
||||
``block_stream``
|
||||
Copy data from a backing file into a block device.
|
||||
@@ -214,11 +215,9 @@ index d9f9f42d11..775518fb09 100644
|
||||
+
|
||||
+ {
|
||||
+ .name = "backup",
|
||||
+ .args_type = "directory:-d,backupfile:s,speed:o?,devlist:s?",
|
||||
+ .params = "[-d] backupfile [speed [devlist]]",
|
||||
+ .help = "create a VM Backup."
|
||||
+ "\n\t\t\t Use -d to dump data into a directory instead"
|
||||
+ "\n\t\t\t of using VMA format.",
|
||||
+ .args_type = "backupfile:s,speed:o?,devlist:s?",
|
||||
+ .params = "backupfile [speed [devlist]]",
|
||||
+ .help = "create a VM backup (VMA format).",
|
||||
+ .cmd = hmp_backup,
|
||||
+ .coroutine = true,
|
||||
+ },
|
||||
@@ -245,7 +244,7 @@ index d9f9f42d11..775518fb09 100644
|
||||
|
||||
{
|
||||
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
|
||||
index fdf6b45fb8..e01b2201d8 100644
|
||||
index 2596cc2426..9dda91d65a 100644
|
||||
--- a/include/monitor/hmp.h
|
||||
+++ b/include/monitor/hmp.h
|
||||
@@ -32,6 +32,7 @@ void hmp_info_savevm(Monitor *mon, const QDict *qdict);
|
||||
@@ -256,7 +255,7 @@ index fdf6b45fb8..e01b2201d8 100644
|
||||
void hmp_info_cpus(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_vnc(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_spice(Monitor *mon, const QDict *qdict);
|
||||
@@ -84,6 +85,8 @@ void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
|
||||
@@ -82,6 +83,8 @@ void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
|
||||
void hmp_change_medium(Monitor *mon, const char *device, const char *target,
|
||||
const char *arg, const char *read_only, bool force,
|
||||
Error **errp);
|
||||
@@ -266,10 +265,10 @@ index fdf6b45fb8..e01b2201d8 100644
|
||||
void hmp_device_add(Monitor *mon, const QDict *qdict);
|
||||
void hmp_device_del(Monitor *mon, const QDict *qdict);
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 38a4e2bcef..443b3238f9 100644
|
||||
index b9b673c271..f6fb9b4fd8 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -1528,6 +1528,7 @@ keyutils = dependency('libkeyutils', required: false,
|
||||
@@ -2130,6 +2130,7 @@ endif
|
||||
has_gettid = cc.has_function('gettid')
|
||||
|
||||
libuuid = cc.find_library('uuid', required: true)
|
||||
@@ -278,18 +277,18 @@ index 38a4e2bcef..443b3238f9 100644
|
||||
# libselinux
|
||||
selinux = dependency('libselinux',
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index 91be698308..5b9c231a4c 100644
|
||||
index 874084565f..bedeb81f8c 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -21,6 +21,7 @@
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "qemu/help_option.h"
|
||||
#include "monitor/monitor-internal.h"
|
||||
#include "qapi/error.h"
|
||||
+#include "qapi/qapi-commands-block-core.h"
|
||||
#include "qapi/qapi-commands-control.h"
|
||||
#include "qapi/qapi-commands-machine.h"
|
||||
#include "qapi/qapi-commands-migration.h"
|
||||
#include "qapi/qapi-commands-misc.h"
|
||||
@@ -144,6 +145,77 @@ void hmp_sync_profile(Monitor *mon, const QDict *qdict)
|
||||
@@ -119,6 +120,77 @@ void hmp_sync_profile(Monitor *mon, const QDict *qdict)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,10 +586,10 @@ index 0000000000..8cbf645b2c
|
||||
+#endif /* PROXMOX_BACKUP_CLIENT_H */
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
new file mode 100644
|
||||
index 0000000000..dd72ee0ed6
|
||||
index 0000000000..fea0152de0
|
||||
--- /dev/null
|
||||
+++ b/pve-backup.c
|
||||
@@ -0,0 +1,1097 @@
|
||||
@@ -0,0 +1,1090 @@
|
||||
+#include "proxmox-backup-client.h"
|
||||
+#include "vma.h"
|
||||
+
|
||||
@@ -601,10 +600,15 @@ index 0000000000..dd72ee0ed6
|
||||
+#include "block/block_int-global-state.h"
|
||||
+#include "block/blockjob.h"
|
||||
+#include "block/dirty-bitmap.h"
|
||||
+#include "block/graph-lock.h"
|
||||
+#include "qapi/qapi-commands-block.h"
|
||||
+#include "qapi/qmp/qerror.h"
|
||||
+#include "qemu/cutils.h"
|
||||
+
|
||||
+#if defined(CONFIG_MALLOC_TRIM)
|
||||
+#include <malloc.h>
|
||||
+#endif
|
||||
+
|
||||
+#include <proxmox-backup-qemu.h>
|
||||
+
|
||||
+/* PVE backup state and related function */
|
||||
@@ -622,7 +626,6 @@ index 0000000000..dd72ee0ed6
|
||||
+ * ---end-bad-example--
|
||||
+ *
|
||||
+ * ==> Always use CoMutext inside coroutines.
|
||||
+ * ==> Never acquire/release AioContext withing coroutines (because that use QemuRecMutex)
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
@@ -675,7 +678,6 @@ index 0000000000..dd72ee0ed6
|
||||
+ uint64_t block_size;
|
||||
+ uint8_t dev_id;
|
||||
+ int completed_ret; // INT_MAX if not completed
|
||||
+ char targetfile[PATH_MAX];
|
||||
+ BdrvDirtyBitmap *bitmap;
|
||||
+ BlockDriverState *target;
|
||||
+ BlockJob *job;
|
||||
@@ -697,7 +699,7 @@ index 0000000000..dd72ee0ed6
|
||||
+ return error_or_canceled;
|
||||
+}
|
||||
+
|
||||
+static void pvebackup_add_transfered_bytes(size_t transferred, size_t zero_bytes, size_t reused)
|
||||
+static void pvebackup_add_transferred_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;
|
||||
@@ -758,7 +760,7 @@ index 0000000000..dd72ee0ed6
|
||||
+ }
|
||||
+
|
||||
+ qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
|
||||
+ pvebackup_add_transfered_bytes(size, is_zero_block ? size : 0, reused);
|
||||
+ pvebackup_add_transferred_bytes(size, is_zero_block ? size : 0, reused);
|
||||
+
|
||||
+ return size;
|
||||
+}
|
||||
@@ -816,11 +818,11 @@ index 0000000000..dd72ee0ed6
|
||||
+ } else {
|
||||
+ if (remaining >= VMA_CLUSTER_SIZE) {
|
||||
+ assert(ret == VMA_CLUSTER_SIZE);
|
||||
+ pvebackup_add_transfered_bytes(VMA_CLUSTER_SIZE, zero_bytes, 0);
|
||||
+ pvebackup_add_transferred_bytes(VMA_CLUSTER_SIZE, zero_bytes, 0);
|
||||
+ remaining -= VMA_CLUSTER_SIZE;
|
||||
+ } else {
|
||||
+ assert(ret == remaining);
|
||||
+ pvebackup_add_transfered_bytes(remaining, zero_bytes, 0);
|
||||
+ pvebackup_add_transferred_bytes(remaining, zero_bytes, 0);
|
||||
+ remaining = 0;
|
||||
+ }
|
||||
+ }
|
||||
@@ -869,6 +871,14 @@ index 0000000000..dd72ee0ed6
|
||||
+ backup_state.stat.end_time = time(NULL);
|
||||
+ backup_state.stat.finishing = false;
|
||||
+ qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
+
|
||||
+#if defined(CONFIG_MALLOC_TRIM)
|
||||
+ /*
|
||||
+ * Try to reclaim memory for buffers (and, in case of PBS, Rust futures), etc.
|
||||
+ * Won't happen by default if there is fragmentation.
|
||||
+ */
|
||||
+ malloc_trim(4 * 1024 * 1024);
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+static void coroutine_fn pvebackup_co_complete_stream(void *opaque)
|
||||
@@ -888,7 +898,12 @@ index 0000000000..dd72ee0ed6
|
||||
+
|
||||
+ qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
+
|
||||
+ if (ret < 0) {
|
||||
+ /*
|
||||
+ * All jobs in the transaction will be canceled when one receives an error.
|
||||
+ * The first error wins, so only set it for ECANCELED if it was the last
|
||||
+ * job. This allows more interesting errors from other jobs to win.
|
||||
+ */
|
||||
+ if (ret < 0 && (ret != -ECANCELED || !g_list_nth(backup_state.di_list, 1))) {
|
||||
+ Error *local_err = NULL;
|
||||
+ error_setg(&local_err, "job failed with err %d - %s", ret, strerror(-ret));
|
||||
+ pvebackup_propagate_error(local_err);
|
||||
@@ -912,13 +927,6 @@ index 0000000000..dd72ee0ed6
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (di->job) {
|
||||
+ WITH_JOB_LOCK_GUARD() {
|
||||
+ job_unref_locked(&di->job->job);
|
||||
+ di->job = NULL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // remove self from job list
|
||||
+ backup_state.di_list = g_list_remove(backup_state.di_list, di);
|
||||
+
|
||||
@@ -938,6 +946,16 @@ index 0000000000..dd72ee0ed6
|
||||
+ di->completed_ret = ret;
|
||||
+
|
||||
+ /*
|
||||
+ * Needs to happen outside of coroutine, because it takes the graph write lock.
|
||||
+ */
|
||||
+ if (di->job) {
|
||||
+ WITH_JOB_LOCK_GUARD() {
|
||||
+ job_unref_locked(&di->job->job);
|
||||
+ di->job = NULL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * 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.
|
||||
@@ -1020,7 +1038,6 @@ index 0000000000..dd72ee0ed6
|
||||
+ const char *file,
|
||||
+ const char *name,
|
||||
+ BackupFormat format,
|
||||
+ const char *backup_dir,
|
||||
+ VmaWriter *vmaw,
|
||||
+ ProxmoxBackupHandle *pbs,
|
||||
+ Error **errp)
|
||||
@@ -1046,13 +1063,6 @@ index 0000000000..dd72ee0ed6
|
||||
+ } else if (format == BACKUP_FORMAT_PBS) {
|
||||
+ if (proxmox_backup_co_add_config(pbs, name, (unsigned char *)cdata, clen, errp) < 0)
|
||||
+ goto err;
|
||||
+ } else if (format == BACKUP_FORMAT_DIR) {
|
||||
+ char config_path[PATH_MAX];
|
||||
+ snprintf(config_path, PATH_MAX, "%s/%s", backup_dir, name);
|
||||
+ if (!g_file_set_contents(config_path, cdata, clen, &err)) {
|
||||
+ error_setg(errp, "unable to write config file '%s'", config_path);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ out:
|
||||
@@ -1066,8 +1076,7 @@ index 0000000000..dd72ee0ed6
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * backup_job_create can *not* be run from a coroutine (and requires an
|
||||
+ * acquired AioContext), so this can't either.
|
||||
+ * 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.
|
||||
+ */
|
||||
+static void create_backup_jobs_bh(void *opaque) {
|
||||
@@ -1100,8 +1109,7 @@ index 0000000000..dd72ee0ed6
|
||||
+ 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);
|
||||
+ bdrv_drained_begin(di->bs);
|
||||
+
|
||||
+ BlockJob *job = backup_job_create(
|
||||
+ NULL, di->bs, di->target, backup_state.speed, sync_mode, di->bitmap,
|
||||
@@ -1109,7 +1117,7 @@ index 0000000000..dd72ee0ed6
|
||||
+ BLOCKDEV_ON_ERROR_REPORT, JOB_DEFAULT, pvebackup_complete_cb, di, backup_state.txn,
|
||||
+ &local_err);
|
||||
+
|
||||
+ aio_context_release(aio_context);
|
||||
+ bdrv_drained_end(di->bs);
|
||||
+
|
||||
+ di->job = job;
|
||||
+ if (job) {
|
||||
@@ -1161,6 +1169,66 @@ index 0000000000..dd72ee0ed6
|
||||
+ aio_co_enter(data->ctx, data->co);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * 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
|
||||
+ * list.
|
||||
+ */
|
||||
+static GList coroutine_fn GRAPH_RDLOCK *get_device_info(
|
||||
+ const char *devlist,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ gchar **devs = NULL;
|
||||
+ GList *di_list = NULL;
|
||||
+
|
||||
+ if (devlist) {
|
||||
+ devs = g_strsplit_set(devlist, ",;:", -1);
|
||||
+
|
||||
+ 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);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
+ di->bs = bs;
|
||||
+ di_list = g_list_append(di_list, di);
|
||||
+ d++;
|
||||
+ }
|
||||
+ } else {
|
||||
+ BdrvNextIterator it;
|
||||
+
|
||||
+ for (BlockDriverState *bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
|
||||
+ if (!bdrv_co_is_inserted(bs) || bdrv_is_read_only(bs)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
+ di->bs = bs;
|
||||
+ di_list = g_list_append(di_list, di);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!di_list) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "empty device list");
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
+err:
|
||||
+ if (devs) {
|
||||
+ g_strfreev(devs);
|
||||
+ }
|
||||
+
|
||||
+ return di_list;
|
||||
+}
|
||||
+
|
||||
+UuidInfo coroutine_fn *qmp_backup(
|
||||
+ const char *backup_file,
|
||||
+ const char *password,
|
||||
@@ -1186,14 +1254,10 @@ index 0000000000..dd72ee0ed6
|
||||
+
|
||||
+ qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
+
|
||||
+ BlockBackend *blk;
|
||||
+ BlockDriverState *bs = NULL;
|
||||
+ const char *backup_dir = NULL;
|
||||
+ Error *local_err = NULL;
|
||||
+ uuid_t uuid;
|
||||
+ VmaWriter *vmaw = NULL;
|
||||
+ ProxmoxBackupHandle *pbs = NULL;
|
||||
+ gchar **devs = NULL;
|
||||
+ GList *di_list = NULL;
|
||||
+ GList *l;
|
||||
+ UuidInfo *uuid_info;
|
||||
@@ -1211,48 +1275,14 @@ index 0000000000..dd72ee0ed6
|
||||
+ /* Todo: try to auto-detect format based on file name */
|
||||
+ format = has_format ? format : BACKUP_FORMAT_VMA;
|
||||
+
|
||||
+ if (devlist) {
|
||||
+ devs = g_strsplit_set(devlist, ",;:", -1);
|
||||
+
|
||||
+ gchar **d = devs;
|
||||
+ while (d && *d) {
|
||||
+ blk = blk_by_name(*d);
|
||||
+ if (blk) {
|
||||
+ bs = blk_bs(blk);
|
||||
+ if (!bdrv_co_is_inserted(bs)) {
|
||||
+ error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, *d);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
+ di->bs = bs;
|
||||
+ di_list = g_list_append(di_list, di);
|
||||
+ } else {
|
||||
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
+ "Device '%s' not found", *d);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ d++;
|
||||
+ }
|
||||
+
|
||||
+ } else {
|
||||
+ BdrvNextIterator it;
|
||||
+
|
||||
+ bs = NULL;
|
||||
+ for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
|
||||
+ if (!bdrv_co_is_inserted(bs) || bdrv_is_read_only(bs)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
+ di->bs = bs;
|
||||
+ di_list = g_list_append(di_list, di);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!di_list) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "empty device list");
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ di_list = get_device_info(devlist, &local_err);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ if (local_err) {
|
||||
+ error_propagate(errp, local_err);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ assert(di_list);
|
||||
+
|
||||
+ size_t total = 0;
|
||||
+
|
||||
@@ -1260,7 +1290,11 @@ index 0000000000..dd72ee0ed6
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+ if (bdrv_op_is_blocked(di->bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) {
|
||||
+
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ bool blocked = bdrv_op_is_blocked(di->bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ if (blocked) {
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
@@ -1344,7 +1378,9 @@ index 0000000000..dd72ee0ed6
|
||||
+
|
||||
+ di->block_size = dump_cb_block_size;
|
||||
+
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ const char *devname = bdrv_get_device_name(di->bs);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ PBSBitmapAction action = PBS_BITMAP_ACTION_NOT_USED;
|
||||
+ size_t dirty = di->size;
|
||||
+
|
||||
@@ -1388,7 +1424,7 @@ index 0000000000..dd72ee0ed6
|
||||
+ goto err_mutex;
|
||||
+ }
|
||||
+
|
||||
+ if (!(di->target = bdrv_backup_dump_create(dump_cb_block_size, di->size, pvebackup_co_dump_pbs_cb, di, errp))) {
|
||||
+ if (!(di->target = bdrv_co_backup_dump_create(dump_cb_block_size, di->size, pvebackup_co_dump_pbs_cb, di, errp))) {
|
||||
+ goto err_mutex;
|
||||
+ }
|
||||
+
|
||||
@@ -1404,9 +1440,7 @@ index 0000000000..dd72ee0ed6
|
||||
+ } else if (format == BACKUP_FORMAT_VMA) {
|
||||
+ vmaw = vma_writer_create(backup_file, uuid, &local_err);
|
||||
+ if (!vmaw) {
|
||||
+ if (local_err) {
|
||||
+ error_propagate(errp, local_err);
|
||||
+ }
|
||||
+ error_propagate(errp, local_err);
|
||||
+ goto err_mutex;
|
||||
+ }
|
||||
+
|
||||
@@ -1416,11 +1450,13 @@ index 0000000000..dd72ee0ed6
|
||||
+ 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_vma_cb, di, errp))) {
|
||||
+ if (!(di->target = bdrv_co_backup_dump_create(VMA_CLUSTER_SIZE, di->size, pvebackup_co_dump_vma_cb, di, errp))) {
|
||||
+ goto err_mutex;
|
||||
+ }
|
||||
+
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ const char *devname = bdrv_get_device_name(di->bs);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ di->dev_id = vma_writer_register_stream(vmaw, devname, di->size);
|
||||
+ if (di->dev_id <= 0) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
@@ -1428,54 +1464,21 @@ index 0000000000..dd72ee0ed6
|
||||
+ goto err_mutex;
|
||||
+ }
|
||||
+ }
|
||||
+ } else if (format == BACKUP_FORMAT_DIR) {
|
||||
+ if (mkdir(backup_file, 0640) != 0) {
|
||||
+ error_setg_errno(errp, errno, "can't create directory '%s'\n",
|
||||
+ backup_file);
|
||||
+ goto err_mutex;
|
||||
+ }
|
||||
+ backup_dir = backup_file;
|
||||
+
|
||||
+ l = di_list;
|
||||
+ while (l) {
|
||||
+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
+ l = g_list_next(l);
|
||||
+
|
||||
+ const char *devname = bdrv_get_device_name(di->bs);
|
||||
+ snprintf(di->targetfile, PATH_MAX, "%s/%s.raw", backup_dir, devname);
|
||||
+
|
||||
+ int flags = BDRV_O_RDWR;
|
||||
+ bdrv_img_create(di->targetfile, "raw", NULL, NULL, NULL,
|
||||
+ di->size, flags, false, &local_err);
|
||||
+ if (local_err) {
|
||||
+ error_propagate(errp, local_err);
|
||||
+ goto err_mutex;
|
||||
+ }
|
||||
+
|
||||
+ di->target = bdrv_co_open(di->targetfile, NULL, NULL, flags, &local_err);
|
||||
+ if (!di->target) {
|
||||
+ error_propagate(errp, local_err);
|
||||
+ goto err_mutex;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "unknown backup format");
|
||||
+ goto err_mutex;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ /* add configuration file to archive */
|
||||
+ if (config_file) {
|
||||
+ if (pvebackup_co_add_config(config_file, config_name, format, backup_dir,
|
||||
+ vmaw, pbs, errp) != 0) {
|
||||
+ if (pvebackup_co_add_config(config_file, config_name, format, vmaw, pbs, errp) != 0) {
|
||||
+ goto err_mutex;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* add firewall file to archive */
|
||||
+ if (firewall_file) {
|
||||
+ if (pvebackup_co_add_config(firewall_file, firewall_name, format, backup_dir,
|
||||
+ vmaw, pbs, errp) != 0) {
|
||||
+ if (pvebackup_co_add_config(firewall_file, firewall_name, format, vmaw, pbs, errp) != 0) {
|
||||
+ goto err_mutex;
|
||||
+ }
|
||||
+ }
|
||||
@@ -1565,18 +1568,11 @@ index 0000000000..dd72ee0ed6
|
||||
+ bdrv_co_unref(di->target);
|
||||
+ }
|
||||
+
|
||||
+ if (di->targetfile[0]) {
|
||||
+ unlink(di->targetfile);
|
||||
+ }
|
||||
+ g_free(di);
|
||||
+ }
|
||||
+ g_list_free(di_list);
|
||||
+ backup_state.di_list = NULL;
|
||||
+
|
||||
+ if (devs) {
|
||||
+ g_strfreev(devs);
|
||||
+ }
|
||||
+
|
||||
+ if (vmaw) {
|
||||
+ Error *err = NULL;
|
||||
+ vma_writer_close(vmaw, &err);
|
||||
@@ -1588,10 +1584,6 @@ index 0000000000..dd72ee0ed6
|
||||
+ backup_state.pbs = NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (backup_dir) {
|
||||
+ rmdir(backup_dir);
|
||||
+ }
|
||||
+
|
||||
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
+ return NULL;
|
||||
+}
|
||||
@@ -1689,10 +1681,10 @@ index 0000000000..dd72ee0ed6
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 542add004b..4ec70acf95 100644
|
||||
index 321d1fd0e1..68caf30084 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -835,6 +835,232 @@
|
||||
@@ -851,6 +851,239 @@
|
||||
{ 'command': 'query-block', 'returns': ['BlockInfo'],
|
||||
'allow-preconfig': true }
|
||||
|
||||
@@ -1742,9 +1734,12 @@ index 542add004b..4ec70acf95 100644
|
||||
+# An enumeration of supported backup formats.
|
||||
+#
|
||||
+# @vma: Proxmox vma backup format
|
||||
+#
|
||||
+# @pbs: Proxmox backup server format
|
||||
+#
|
||||
+##
|
||||
+{ 'enum': 'BackupFormat',
|
||||
+ 'data': [ 'vma', 'dir', 'pbs' ] }
|
||||
+ 'data': [ 'vma', 'pbs' ] }
|
||||
+
|
||||
+##
|
||||
+# @backup:
|
||||
@@ -1758,6 +1753,9 @@ index 542add004b..4ec70acf95 100644
|
||||
+# @config-file: a configuration file to include into
|
||||
+# the backup archive.
|
||||
+#
|
||||
+# @firewall-file: a firewall configuration file to include into the backup
|
||||
+# archive.
|
||||
+#
|
||||
+# @speed: the maximum speed, in bytes per second
|
||||
+#
|
||||
+# @devlist: list of block device names (separated by ',', ';'
|
||||
@@ -1825,9 +1823,7 @@ index 542add004b..4ec70acf95 100644
|
||||
+#
|
||||
+# Cancel the current executing backup process.
|
||||
+#
|
||||
+# Returns: nothing on success
|
||||
+#
|
||||
+# Notes: This command succeeds even if there is no backup process running.
|
||||
+# .. note:: This command succeeds even if there is no backup process running.
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'backup-cancel', 'coroutine': true }
|
||||
@@ -1850,6 +1846,9 @@ index 542add004b..4ec70acf95 100644
|
||||
+#
|
||||
+# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
|
||||
+#
|
||||
+# @backup-max-workers: Whether the 'max-workers' @BackupPerf setting is
|
||||
+# supported or not.
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'ProxmoxSupportStatus',
|
||||
+ 'data': { 'pbs-dirty-bitmap': 'bool',
|
||||
@@ -1926,10 +1925,10 @@ index 542add004b..4ec70acf95 100644
|
||||
# @BlockDeviceTimedStats:
|
||||
#
|
||||
diff --git a/qapi/common.json b/qapi/common.json
|
||||
index 356db3f670..aae8a3b682 100644
|
||||
index 6ffc7a3789..9c6c671ece 100644
|
||||
--- a/qapi/common.json
|
||||
+++ b/qapi/common.json
|
||||
@@ -206,3 +206,16 @@
|
||||
@@ -212,3 +212,17 @@
|
||||
##
|
||||
{ 'struct': 'HumanReadableText',
|
||||
'data': { 'human-readable-text': 'str' } }
|
||||
@@ -1943,11 +1942,12 @@ index 356db3f670..aae8a3b682 100644
|
||||
+#
|
||||
+# Since: 0.14.0
|
||||
+#
|
||||
+# Notes: If no UUID was specified for the guest, a null UUID is returned.
|
||||
+# .. note:: If no UUID was specified for the guest, a null UUID is
|
||||
+# returned.
|
||||
+##
|
||||
+{ 'struct': 'UuidInfo', 'data': {'UUID': 'str'} }
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 47f3facdb2..46760978ae 100644
|
||||
index 12cfd3f260..a8abdb42a3 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -4,6 +4,8 @@
|
||||
@@ -1959,7 +1959,7 @@ index 47f3facdb2..46760978ae 100644
|
||||
##
|
||||
# = Machines
|
||||
##
|
||||
@@ -228,19 +230,6 @@
|
||||
@@ -302,20 +304,6 @@
|
||||
##
|
||||
{ 'command': 'query-target', 'returns': 'TargetInfo' }
|
||||
|
||||
@@ -1972,7 +1972,8 @@ index 47f3facdb2..46760978ae 100644
|
||||
-#
|
||||
-# Since: 0.14
|
||||
-#
|
||||
-# Notes: If no UUID was specified for the guest, a null UUID is returned.
|
||||
-# .. note:: If no UUID was specified for the guest, the nil UUID (all
|
||||
-# zeroes) is returned.
|
||||
-##
|
||||
-{ 'struct': 'UuidInfo', 'data': {'UUID': 'str'} }
|
||||
-
|
||||
|
@@ -14,20 +14,20 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
create mode 100644 pbs-restore.c
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 443b3238f9..32ab849ce6 100644
|
||||
index f6fb9b4fd8..f666d0f028 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -3656,6 +3656,10 @@ if have_tools
|
||||
@@ -4350,6 +4350,10 @@ if have_tools
|
||||
vma = executable('vma', files('vma.c', 'vma-reader.c') + genh,
|
||||
dependencies: [authz, block, crypto, io, qom], install: true)
|
||||
dependencies: [authz, block, crypto, io, qemuutil, qom], install: true)
|
||||
|
||||
+ pbs_restore = executable('pbs-restore', files('pbs-restore.c') + genh,
|
||||
+ dependencies: [authz, block, crypto, io, qom,
|
||||
+ dependencies: [authz, block, crypto, io, qemuutil, qom,
|
||||
+ libproxmox_backup_qemu], install: true)
|
||||
+
|
||||
subdir('storage-daemon')
|
||||
subdir('contrib/rdmacm-mux')
|
||||
subdir('contrib/elf2dmp')
|
||||
|
||||
foreach exe: [ 'qemu-img', 'qemu-io', 'qemu-nbd', 'qemu-storage-daemon']
|
||||
diff --git a/pbs-restore.c b/pbs-restore.c
|
||||
new file mode 100644
|
||||
index 0000000000..f03d9bab8d
|
||||
|
@@ -14,35 +14,33 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
getlength is now a coroutine function]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/meson.build | 3 +
|
||||
block/pbs.c | 305 +++++++++++++++++++++++++++++++++++++++++++
|
||||
configure | 9 ++
|
||||
block/meson.build | 2 +
|
||||
block/pbs.c | 306 +++++++++++++++++++++++++++++++++++++++++++
|
||||
meson.build | 2 +-
|
||||
qapi/block-core.json | 13 ++
|
||||
qapi/block-core.json | 29 ++++
|
||||
qapi/pragma.json | 1 +
|
||||
6 files changed, 332 insertions(+), 1 deletion(-)
|
||||
5 files changed, 339 insertions(+), 1 deletion(-)
|
||||
create mode 100644 block/pbs.c
|
||||
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index 5bcebb934b..eece0d5743 100644
|
||||
index 2367e1ac1b..e178047ec9 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -54,6 +54,9 @@ block_ss.add(files(
|
||||
@@ -49,6 +49,8 @@ block_ss.add(files(
|
||||
'../pve-backup.c',
|
||||
), libproxmox_backup_qemu)
|
||||
|
||||
+block_ss.add(when: 'CONFIG_PBS_BDRV', if_true: files('pbs.c'))
|
||||
+block_ss.add(when: 'CONFIG_PBS_BDRV', if_true: libproxmox_backup_qemu)
|
||||
+block_ss.add(files('pbs.c'), libproxmox_backup_qemu)
|
||||
+
|
||||
|
||||
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
softmmu_ss.add(files('block-ram-registrar.c'))
|
||||
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..a2211e0f3b
|
||||
index 0000000000..2d5e28ce8f
|
||||
--- /dev/null
|
||||
+++ b/block/pbs.c
|
||||
@@ -0,0 +1,305 @@
|
||||
@@ -0,0 +1,306 @@
|
||||
+/*
|
||||
+ * Proxmox Backup Server read-only block driver
|
||||
+ */
|
||||
@@ -70,7 +68,7 @@ index 0000000000..a2211e0f3b
|
||||
+
|
||||
+typedef struct {
|
||||
+ ProxmoxRestoreHandle *conn;
|
||||
+ char aid;
|
||||
+ uint8_t aid;
|
||||
+ int64_t length;
|
||||
+
|
||||
+ char *repository;
|
||||
@@ -203,12 +201,18 @@ index 0000000000..a2211e0f3b
|
||||
+ }
|
||||
+
|
||||
+ /* 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);
|
||||
@@ -219,12 +223,6 @@ index 0000000000..a2211e0f3b
|
||||
+ 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);
|
||||
@@ -234,7 +232,8 @@ index 0000000000..a2211e0f3b
|
||||
+ proxmox_restore_disconnect(s->conn);
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int64_t pbs_co_getlength(BlockDriverState *bs)
|
||||
+static coroutine_fn int64_t GRAPH_RDLOCK
|
||||
+pbs_co_getlength(BlockDriverState *bs)
|
||||
+{
|
||||
+ BDRVPBSState *s = bs->opaque;
|
||||
+ return s->length;
|
||||
@@ -251,9 +250,9 @@ index 0000000000..a2211e0f3b
|
||||
+ aio_co_schedule(rcb->ctx, rcb->co);
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int pbs_co_preadv(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes,
|
||||
+ QEMUIOVector *qiov, BdrvRequestFlags 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;
|
||||
@@ -298,16 +297,17 @@ index 0000000000..a2211e0f3b
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int pbs_co_pwritev(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes,
|
||||
+ QEMUIOVector *qiov, BdrvRequestFlags 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;
|
||||
+ if (s->namespace) {
|
||||
@@ -330,7 +330,6 @@ index 0000000000..a2211e0f3b
|
||||
+
|
||||
+ .bdrv_parse_filename = pbs_parse_filename,
|
||||
+
|
||||
+ .bdrv_file_open = pbs_file_open,
|
||||
+ .bdrv_open = pbs_open,
|
||||
+ .bdrv_close = pbs_close,
|
||||
+ .bdrv_co_getlength = pbs_co_getlength,
|
||||
@@ -348,65 +347,24 @@ index 0000000000..a2211e0f3b
|
||||
+}
|
||||
+
|
||||
+block_init(bdrv_pbs_init);
|
||||
diff --git a/configure b/configure
|
||||
index a62a3e6be9..1ac0feb46b 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -288,6 +288,7 @@ linux_user=""
|
||||
bsd_user=""
|
||||
pie=""
|
||||
coroutine=""
|
||||
+pbs_bdrv="yes"
|
||||
plugins="$default_feature"
|
||||
meson=""
|
||||
ninja=""
|
||||
@@ -873,6 +874,10 @@ for opt do
|
||||
;;
|
||||
--with-coroutine=*) coroutine="$optarg"
|
||||
;;
|
||||
+ --disable-pbs-bdrv) pbs_bdrv="no"
|
||||
+ ;;
|
||||
+ --enable-pbs-bdrv) pbs_bdrv="yes"
|
||||
+ ;;
|
||||
--with-git=*) git="$optarg"
|
||||
;;
|
||||
--with-git-submodules=*)
|
||||
@@ -1049,6 +1054,7 @@ cat << EOF
|
||||
debug-info debugging information
|
||||
safe-stack SafeStack Stack Smash Protection. Depends on
|
||||
clang/llvm and requires coroutine backend ucontext.
|
||||
+ pbs-bdrv Proxmox backup server read-only block driver support
|
||||
|
||||
NOTE: The object files are built at the place where configure is launched
|
||||
EOF
|
||||
@@ -2386,6 +2392,9 @@ echo "TARGET_DIRS=$target_list" >> $config_host_mak
|
||||
if test "$modules" = "yes"; then
|
||||
echo "CONFIG_MODULES=y" >> $config_host_mak
|
||||
fi
|
||||
+if test "$pbs_bdrv" = "yes" ; then
|
||||
+ echo "CONFIG_PBS_BDRV=y" >> $config_host_mak
|
||||
+fi
|
||||
|
||||
# XXX: suppress that
|
||||
if [ "$bsd" = "yes" ] ; then
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 32ab849ce6..69afe3441b 100644
|
||||
index f666d0f028..4c85736ec3 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -4041,7 +4041,7 @@ summary_info += {'bzip2 support': libbzip2}
|
||||
summary_info += {'lzfse support': liblzfse}
|
||||
summary_info += {'zstd support': zstd}
|
||||
@@ -4815,7 +4815,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 += {'libudev': libudev}
|
||||
summary_info += {'libcbor support': libcbor}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 4ec70acf95..47118bf83e 100644
|
||||
index 68caf30084..d45e8975a7 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -3301,6 +3301,7 @@
|
||||
@@ -3466,6 +3466,7 @@
|
||||
'parallels', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum',
|
||||
'raw', 'rbd',
|
||||
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
|
||||
@@ -414,7 +372,7 @@ index 4ec70acf95..47118bf83e 100644
|
||||
'ssh', 'throttle', 'vdi', 'vhdx',
|
||||
{ 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
|
||||
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
|
||||
@@ -3377,6 +3378,17 @@
|
||||
@@ -3552,6 +3553,33 @@
|
||||
{ 'struct': 'BlockdevOptionsNull',
|
||||
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
|
||||
|
||||
@@ -423,6 +381,22 @@ index 4ec70acf95..47118bf83e 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',
|
||||
@@ -432,7 +406,7 @@ index 4ec70acf95..47118bf83e 100644
|
||||
##
|
||||
# @BlockdevOptionsNVMe:
|
||||
#
|
||||
@@ -4750,6 +4762,7 @@
|
||||
@@ -4993,6 +5021,7 @@
|
||||
'nfs': 'BlockdevOptionsNfs',
|
||||
'null-aio': 'BlockdevOptionsNull',
|
||||
'null-co': 'BlockdevOptionsNull',
|
||||
@@ -441,10 +415,10 @@ index 4ec70acf95..47118bf83e 100644
|
||||
'nvme-io_uring': { 'type': 'BlockdevOptionsNvmeIoUring',
|
||||
'if': 'CONFIG_BLKIO' },
|
||||
diff --git a/qapi/pragma.json b/qapi/pragma.json
|
||||
index 325e684411..b6079f6a0e 100644
|
||||
index 6aaa9cb975..e9c595c4ba 100644
|
||||
--- a/qapi/pragma.json
|
||||
+++ b/qapi/pragma.json
|
||||
@@ -45,6 +45,7 @@
|
||||
@@ -91,6 +91,7 @@
|
||||
'BlockInfo', # query-block
|
||||
'BlockdevAioOptions', # blockdev-add, -blockdev
|
||||
'BlockdevDriver', # blockdev-add, query-blockstats, ...
|
||||
|
@@ -9,15 +9,15 @@ fitting.
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
meson.build | 2 ++
|
||||
meson.build | 3 ++-
|
||||
os-posix.c | 7 +++++--
|
||||
2 files changed, 7 insertions(+), 2 deletions(-)
|
||||
2 files changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 69afe3441b..b2e9b2aec7 100644
|
||||
index 4c85736ec3..57f666d722 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -1528,6 +1528,7 @@ keyutils = dependency('libkeyutils', required: false,
|
||||
@@ -2130,6 +2130,7 @@ endif
|
||||
has_gettid = cc.has_function('gettid')
|
||||
|
||||
libuuid = cc.find_library('uuid', required: true)
|
||||
@@ -25,28 +25,29 @@ index 69afe3441b..b2e9b2aec7 100644
|
||||
libproxmox_backup_qemu = cc.find_library('proxmox_backup_qemu', required: true)
|
||||
|
||||
# libselinux
|
||||
@@ -3144,6 +3145,7 @@ if have_block
|
||||
# os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
|
||||
# os-win32.c does not
|
||||
blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
|
||||
+ blockdev_ss.add(when: 'CONFIG_POSIX', if_true: libsystemd)
|
||||
softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
|
||||
@@ -3744,7 +3745,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 90ea71725f..33745a8c22 100644
|
||||
index 43f9a43f3f..a47e46d1c2 100644
|
||||
--- a/os-posix.c
|
||||
+++ b/os-posix.c
|
||||
@@ -28,6 +28,8 @@
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <libgen.h>
|
||||
+#include <systemd/sd-journal.h>
|
||||
+#include <syslog.h>
|
||||
|
||||
/* Needed early for CONFIG_BSD etc. */
|
||||
#include "net/slirp.h"
|
||||
@@ -301,9 +303,10 @@ void os_setup_post(void)
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/log.h"
|
||||
@@ -306,9 +308,10 @@ void os_setup_post(void)
|
||||
|
||||
dup2(fd, 0);
|
||||
dup2(fd, 1);
|
||||
|
@@ -26,47 +26,52 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
create mode 100644 migration/pbs-state.c
|
||||
|
||||
diff --git a/include/migration/misc.h b/include/migration/misc.h
|
||||
index 8b49841016..78f63ca400 100644
|
||||
index 804eb23c06..c75b146ae6 100644
|
||||
--- a/include/migration/misc.h
|
||||
+++ b/include/migration/misc.h
|
||||
@@ -77,4 +77,7 @@ bool migration_in_bg_snapshot(void);
|
||||
/* migration/block-dirty-bitmap.c */
|
||||
void dirty_bitmap_mig_init(void);
|
||||
@@ -106,4 +106,7 @@ bool migration_incoming_postcopy_advised(void);
|
||||
/* True if background snapshot is active */
|
||||
bool migration_in_bg_snapshot(void);
|
||||
|
||||
+/* migration/pbs-state.c */
|
||||
+void pbs_state_mig_init(void);
|
||||
+
|
||||
#endif
|
||||
diff --git a/migration/meson.build b/migration/meson.build
|
||||
index a7824b5266..de6a271b58 100644
|
||||
index 075b013971..eca57cb2a3 100644
|
||||
--- a/migration/meson.build
|
||||
+++ b/migration/meson.build
|
||||
@@ -6,8 +6,10 @@ migration_files = files(
|
||||
'vmstate.c',
|
||||
@@ -8,6 +8,7 @@ migration_files = files(
|
||||
'qemu-file.c',
|
||||
'yank_functions.c',
|
||||
+ 'pbs-state.c',
|
||||
)
|
||||
softmmu_ss.add(migration_files)
|
||||
+softmmu_ss.add(libproxmox_backup_qemu)
|
||||
+system_ss.add(libproxmox_backup_qemu)
|
||||
|
||||
softmmu_ss.add(files(
|
||||
system_ss.add(files(
|
||||
'block-dirty-bitmap.c',
|
||||
@@ -27,6 +28,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 99f86bd6c2..db229e72c9 100644
|
||||
index 8c5bd0a75c..491d9aa017 100644
|
||||
--- a/migration/migration.c
|
||||
+++ b/migration/migration.c
|
||||
@@ -245,6 +245,7 @@ void migration_object_init(void)
|
||||
blk_mig_init();
|
||||
ram_mig_init();
|
||||
dirty_bitmap_mig_init();
|
||||
@@ -266,6 +266,7 @@ void migration_object_init(void)
|
||||
|
||||
/* Initialize cpu throttle timers */
|
||||
cpu_throttle_init();
|
||||
+ pbs_state_mig_init();
|
||||
}
|
||||
|
||||
void migration_cancel(const Error *error)
|
||||
typedef struct {
|
||||
diff --git a/migration/pbs-state.c b/migration/pbs-state.c
|
||||
new file mode 100644
|
||||
index 0000000000..887e998b9e
|
||||
index 0000000000..a97187e4d7
|
||||
--- /dev/null
|
||||
+++ b/migration/pbs-state.c
|
||||
@@ -0,0 +1,104 @@
|
||||
@@ -115,7 +120,7 @@ index 0000000000..887e998b9e
|
||||
+}
|
||||
+
|
||||
+/* 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);
|
||||
@@ -175,10 +180,10 @@ index 0000000000..887e998b9e
|
||||
+ NULL);
|
||||
+}
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index dd72ee0ed6..cb5312fff3 100644
|
||||
index fea0152de0..faa6a9b93c 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -1090,6 +1090,7 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
@@ -1083,6 +1083,7 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
ret->pbs_library_version = g_strdup(proxmox_backup_qemu_version());
|
||||
ret->pbs_dirty_bitmap = true;
|
||||
ret->pbs_dirty_bitmap_savevm = true;
|
||||
@@ -187,10 +192,10 @@ index dd72ee0ed6..cb5312fff3 100644
|
||||
ret->pbs_masterkey = true;
|
||||
ret->backup_max_workers = true;
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 47118bf83e..809f3c61bc 100644
|
||||
index d45e8975a7..9795247c1f 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -984,6 +984,11 @@
|
||||
@@ -1004,6 +1004,11 @@
|
||||
# @pbs-dirty-bitmap-savevm: True if 'dirty-bitmaps' migration capability can
|
||||
# safely be set for savevm-async.
|
||||
#
|
||||
@@ -202,7 +207,7 @@ index 47118bf83e..809f3c61bc 100644
|
||||
# @pbs-masterkey: True if the QMP backup call supports the 'master_keyfile'
|
||||
# parameter.
|
||||
#
|
||||
@@ -994,6 +999,7 @@
|
||||
@@ -1017,6 +1022,7 @@
|
||||
'data': { 'pbs-dirty-bitmap': 'bool',
|
||||
'query-bitmap-info': 'bool',
|
||||
'pbs-dirty-bitmap-savevm': 'bool',
|
||||
|
@@ -15,18 +15,22 @@ 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 fe73aa94b1..a6440929fa 100644
|
||||
index a7d55048c2..44078ea670 100644
|
||||
--- a/migration/block-dirty-bitmap.c
|
||||
+++ b/migration/block-dirty-bitmap.c
|
||||
@@ -539,7 +539,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;
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 30 insertions(+)
|
||||
|
||||
diff --git a/block/iscsi.c b/block/iscsi.c
|
||||
index 9fc0bed90b..1d40933165 100644
|
||||
index 979bf90cb7..961714a4be 100644
|
||||
--- a/block/iscsi.c
|
||||
+++ b/block/iscsi.c
|
||||
@@ -1392,12 +1392,42 @@ static char *get_initiator_name(QemuOpts *opts)
|
||||
|
@@ -11,7 +11,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block/stream.c b/block/stream.c
|
||||
index 7f9e1ecdbb..6a29d80398 100644
|
||||
index 9076203193..1d1c65f061 100644
|
||||
--- a/block/stream.c
|
||||
+++ b/block/stream.c
|
||||
@@ -27,7 +27,7 @@ enum {
|
||||
|
@@ -19,27 +19,33 @@ 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.
|
||||
|
||||
If 'auto-remove' is set, alloc-track will automatically detach itself
|
||||
once the backing image is removed. It will be replaced by 'file'.
|
||||
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]
|
||||
avoid premature break during read
|
||||
adhere to block graph lock requirements]
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/alloc-track.c | 352 ++++++++++++++++++++++++++++++++++++++++++++
|
||||
block/alloc-track.c | 366 ++++++++++++++++++++++++++++++++++++++++++++
|
||||
block/meson.build | 1 +
|
||||
2 files changed, 353 insertions(+)
|
||||
block/stream.c | 34 ++++
|
||||
3 files changed, 401 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..b75d7c6460
|
||||
index 0000000000..b4a9851144
|
||||
--- /dev/null
|
||||
+++ b/block/alloc-track.c
|
||||
@@ -0,0 +1,352 @@
|
||||
@@ -0,0 +1,366 @@
|
||||
+/*
|
||||
+ * 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
|
||||
@@ -56,9 +62,11 @@ index 0000000000..b75d7c6460
|
||||
+#include "qapi/error.h"
|
||||
+#include "block/block_int.h"
|
||||
+#include "block/dirty-bitmap.h"
|
||||
+#include "block/graph-lock.h"
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
+#include "qapi/qmp/qstring.h"
|
||||
+#include "qemu/cutils.h"
|
||||
+#include "qemu/error-report.h"
|
||||
+#include "qemu/option.h"
|
||||
+#include "qemu/module.h"
|
||||
+#include "sysemu/block-backend.h"
|
||||
@@ -67,12 +75,12 @@ index 0000000000..b75d7c6460
|
||||
+
|
||||
+typedef enum DropState {
|
||||
+ DropNone,
|
||||
+ DropRequested,
|
||||
+ DropInProgress,
|
||||
+} DropState;
|
||||
+
|
||||
+typedef struct {
|
||||
+ BdrvDirtyBitmap *bitmap;
|
||||
+ uint64_t granularity;
|
||||
+ DropState drop_state;
|
||||
+ bool auto_remove;
|
||||
+} BDRVAllocTrackState;
|
||||
@@ -91,26 +99,29 @@ index 0000000000..b75d7c6460
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static void track_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
+static void GRAPH_RDLOCK
|
||||
+track_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
+{
|
||||
+ BlockDriverInfo bdi;
|
||||
+ 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 (no partial
|
||||
+ * cluster allocation in 'file') */
|
||||
+ bdrv_get_info(bs->file->bs, &bdi);
|
||||
+ /*
|
||||
+ * 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,
|
||||
+ MAX(bdi.cluster_size, BDRV_SECTOR_SIZE));
|
||||
+ 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;
|
||||
@@ -126,18 +137,45 @@ index 0000000000..b75d7c6460
|
||||
+ s->auto_remove = qemu_opt_get_bool(opts, TRACK_OPT_AUTO_REMOVE, false);
|
||||
+
|
||||
+ /* open the target (write) node, backing will be attached by block layer */
|
||||
+ bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
|
||||
+ BDRV_CHILD_DATA | BDRV_CHILD_METADATA, false,
|
||||
+ &local_err);
|
||||
+ 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);
|
||||
+ uint64_t gran = bs->bl.request_alignment;
|
||||
+ s->bitmap = bdrv_create_dirty_bitmap(bs->file->bs, gran, NULL, &local_err);
|
||||
+ 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);
|
||||
@@ -148,7 +186,9 @@ index 0000000000..b75d7c6460
|
||||
+
|
||||
+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);
|
||||
+ }
|
||||
@@ -165,13 +205,15 @@ index 0000000000..b75d7c6460
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int64_t track_co_getlength(BlockDriverState *bs)
|
||||
+static coroutine_fn int64_t GRAPH_RDLOCK
|
||||
+track_co_getlength(BlockDriverState *bs)
|
||||
+{
|
||||
+ return bdrv_co_getlength(bs->file->bs);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn track_co_preadv(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+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;
|
||||
@@ -229,36 +271,39 @@ index 0000000000..b75d7c6460
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn track_co_pwritev(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+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 track_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes, BdrvRequestFlags 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 track_co_pdiscard(BlockDriverState *bs,
|
||||
+ int64_t offset, int64_t bytes)
|
||||
+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 track_co_flush(BlockDriverState *bs)
|
||||
+static coroutine_fn int GRAPH_RDLOCK
|
||||
+track_co_flush(BlockDriverState *bs)
|
||||
+{
|
||||
+ return bdrv_co_flush(bs->file->bs);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn track_co_block_status(BlockDriverState *bs,
|
||||
+ bool want_zero,
|
||||
+ int64_t offset,
|
||||
+ int64_t bytes,
|
||||
+ int64_t *pnum,
|
||||
+ int64_t *map,
|
||||
+ BlockDriverState **file)
|
||||
+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;
|
||||
+
|
||||
@@ -284,10 +329,10 @@ index 0000000000..b75d7c6460
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void track_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||
+ BdrvChildRole role, BlockReopenQueue *reopen_queue,
|
||||
+ uint64_t perm, uint64_t shared,
|
||||
+ uint64_t *nperm, uint64_t *nshared)
|
||||
+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)
|
||||
+{
|
||||
+ BDRVAllocTrackState *s = bs->opaque;
|
||||
+
|
||||
@@ -310,53 +355,28 @@ index 0000000000..b75d7c6460
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void track_drop(void *opaque)
|
||||
+static int coroutine_fn GRAPH_RDLOCK
|
||||
+track_co_change_backing_file(BlockDriverState *bs, const char *backing_file,
|
||||
+ const char *backing_fmt)
|
||||
+{
|
||||
+ BlockDriverState *bs = (BlockDriverState*)opaque;
|
||||
+ BlockDriverState *file = bs->file->bs;
|
||||
+ BDRVAllocTrackState *s = bs->opaque;
|
||||
+
|
||||
+ assert(file);
|
||||
+
|
||||
+ /* we rely on the fact that we're not used anywhere else, so let's wait
|
||||
+ * until we're only used once - in the drive connected to the guest (and one
|
||||
+ * ref is held by bdrv_ref in track_change_backing_file) */
|
||||
+ if (bs->refcnt > 2) {
|
||||
+ aio_bh_schedule_oneshot(qemu_get_aio_context(), track_drop, opaque);
|
||||
+ return;
|
||||
+ }
|
||||
+ AioContext *aio_context = bdrv_get_aio_context(bs);
|
||||
+ aio_context_acquire(aio_context);
|
||||
+
|
||||
+ bdrv_drained_begin(bs);
|
||||
+
|
||||
+ /* now that we're drained, we can safely set 'DropInProgress' */
|
||||
+ s->drop_state = DropInProgress;
|
||||
+ bdrv_child_refresh_perms(bs, bs->file, &error_abort);
|
||||
+
|
||||
+ bdrv_replace_node(bs, file, &error_abort);
|
||||
+ bdrv_set_backing_hd(bs, NULL, &error_abort);
|
||||
+ bdrv_drained_end(bs);
|
||||
+ bdrv_unref(bs);
|
||||
+ aio_context_release(aio_context);
|
||||
+}
|
||||
+
|
||||
+static int track_change_backing_file(BlockDriverState *bs,
|
||||
+ const char *backing_file,
|
||||
+ const char *backing_fmt)
|
||||
+{
|
||||
+ BDRVAllocTrackState *s = bs->opaque;
|
||||
+ if (s->auto_remove && s->drop_state == DropNone &&
|
||||
+ backing_file == NULL && backing_fmt == NULL)
|
||||
+ {
|
||||
+ /* backing file has been disconnected, there's no longer any use for
|
||||
+ * this node, so let's remove ourselves from the block graph - we need
|
||||
+ * to schedule this for later however, since when this function is
|
||||
+ * called, the blockjob modifying us is probably not done yet and has a
|
||||
+ * blocker on 'bs' */
|
||||
+ s->drop_state = DropRequested;
|
||||
+ bdrv_ref(bs);
|
||||
+ aio_bh_schedule_oneshot(qemu_get_aio_context(), track_drop, (void*)bs);
|
||||
+ /*
|
||||
+ * 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).
|
||||
+ */
|
||||
+ if (backing_file == NULL) {
|
||||
+ BDRVAllocTrackState *s = bs->opaque;
|
||||
+ bdrv_drained_begin(bs);
|
||||
+ s->drop_state = DropInProgress;
|
||||
+ bdrv_child_refresh_perms(bs, bs->file, &error_abort);
|
||||
+ bdrv_drained_end(bs);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
@@ -366,7 +386,7 @@ index 0000000000..b75d7c6460
|
||||
+ .format_name = "alloc-track",
|
||||
+ .instance_size = sizeof(BDRVAllocTrackState),
|
||||
+
|
||||
+ .bdrv_file_open = track_open,
|
||||
+ .bdrv_open = track_open,
|
||||
+ .bdrv_close = track_close,
|
||||
+ .bdrv_co_getlength = track_co_getlength,
|
||||
+ .bdrv_child_perm = track_child_perm,
|
||||
@@ -383,7 +403,7 @@ index 0000000000..b75d7c6460
|
||||
+ .supports_backing = true,
|
||||
+
|
||||
+ .bdrv_co_block_status = track_co_block_status,
|
||||
+ .bdrv_change_backing_file = track_change_backing_file,
|
||||
+ .bdrv_co_change_backing_file = track_co_change_backing_file,
|
||||
+};
|
||||
+
|
||||
+static void bdrv_alloc_track_init(void)
|
||||
@@ -393,7 +413,7 @@ index 0000000000..b75d7c6460
|
||||
+
|
||||
+block_init(bdrv_alloc_track_init);
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index eece0d5743..8a68162cc0 100644
|
||||
index e178047ec9..7ef7250d31 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -2,6 +2,7 @@ block_ss.add(genh)
|
||||
@@ -404,3 +424,48 @@ index eece0d5743..8a68162cc0 100644
|
||||
'amend.c',
|
||||
'backup.c',
|
||||
'backup-dump.c',
|
||||
diff --git a/block/stream.c b/block/stream.c
|
||||
index 1d1c65f061..d499c8883f 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,33 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Tue, 2 Mar 2021 16:11:54 +0100
|
||||
Subject: [PATCH] block/io: accept NULL qiov in bdrv_pad_request
|
||||
|
||||
Some operations, e.g. block-stream, perform reads while discarding the
|
||||
results (only copy-on-read matters). In this case they will pass NULL as
|
||||
the target QEMUIOVector, which will however trip bdrv_pad_request, since
|
||||
it wants to extend its passed vector.
|
||||
|
||||
Simply check for NULL and do nothing, there's no reason to pad the
|
||||
target if it will be discarded anyway.
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/io.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/block/io.c b/block/io.c
|
||||
index 2e267a85ab..449a44bf20 100644
|
||||
--- a/block/io.c
|
||||
+++ b/block/io.c
|
||||
@@ -1576,6 +1576,10 @@ static int bdrv_pad_request(BlockDriverState *bs,
|
||||
{
|
||||
int ret;
|
||||
|
||||
+ if (!qiov) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
bdrv_check_qiov_request(*offset, *bytes, *qiov, *qiov_offset, &error_abort);
|
||||
|
||||
if (!bdrv_init_padding(bs, *offset, *bytes, pad)) {
|
@@ -7,15 +7,16 @@ 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 a4749f3b1b..53e0396b51 100644
|
||||
index 728bce3b1e..6c9a8e0add 100644
|
||||
--- a/block/rbd.c
|
||||
+++ b/block/rbd.c
|
||||
@@ -1511,7 +1511,6 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
||||
@@ -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;
|
||||
@@ -23,7 +24,7 @@ index a4749f3b1b..53e0396b51 100644
|
||||
|
||||
assert(offset + bytes <= s->image_size);
|
||||
|
||||
@@ -1539,43 +1538,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
||||
@@ -1543,43 +1542,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ index a4749f3b1b..53e0396b51 100644
|
||||
qemu_rbd_diff_iterate_cb, &req);
|
||||
if (r < 0 && r != QEMU_RBD_EXIT_DIFF_ITERATE2) {
|
||||
return status;
|
||||
@@ -1594,8 +1557,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
||||
@@ -1598,8 +1561,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
||||
status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
|
||||
}
|
||||
|
@@ -8,15 +8,16 @@ 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 53e0396b51..0913a0af39 100644
|
||||
index 6c9a8e0add..6f5fe90f3a 100644
|
||||
--- a/block/rbd.c
|
||||
+++ b/block/rbd.c
|
||||
@@ -1470,11 +1470,11 @@ static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
|
||||
@@ -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);
|
@@ -18,12 +18,13 @@ 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 0913a0af39..1dab254517 100644
|
||||
index 6f5fe90f3a..24e820d056 100644
|
||||
--- a/block/rbd.c
|
||||
+++ b/block/rbd.c
|
||||
@@ -108,12 +108,6 @@ typedef struct RBDTask {
|
||||
@@ -39,7 +40,7 @@ index 0913a0af39..1dab254517 100644
|
||||
static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
||||
BlockdevOptionsRbd *opts, bool cache,
|
||||
const char *keypairs, const char *secretid,
|
||||
@@ -1456,111 +1450,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
|
||||
@@ -1460,111 +1454,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
|
||||
return spec_info;
|
||||
}
|
||||
|
||||
@@ -151,7 +152,7 @@ index 0913a0af39..1dab254517 100644
|
||||
static int64_t coroutine_fn qemu_rbd_co_getlength(BlockDriverState *bs)
|
||||
{
|
||||
BDRVRBDState *s = bs->opaque;
|
||||
@@ -1796,7 +1685,6 @@ static BlockDriver bdrv_rbd = {
|
||||
@@ -1801,7 +1690,6 @@ static BlockDriver bdrv_rbd = {
|
||||
#ifdef LIBRBD_SUPPORTS_WRITE_ZEROES
|
||||
.bdrv_co_pwrite_zeroes = qemu_rbd_co_pwrite_zeroes,
|
||||
#endif
|
43
debian/patches/pve/0042-alloc-track-error-out-when-auto-remove-is-not-set.patch
vendored
Normal file
43
debian/patches/pve/0042-alloc-track-error-out-when-auto-remove-is-not-set.patch
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Tue, 26 Mar 2024 14:57:51 +0100
|
||||
Subject: [PATCH] alloc-track: error out when auto-remove is not set
|
||||
|
||||
Since replacing the node now happens in the stream job, where the
|
||||
option cannot be read from (it's internal to the driver), it will
|
||||
always be treated as on.
|
||||
|
||||
qemu-server will always set it, make sure to have other users notice
|
||||
the change (should they even exist). The option can be fully dropped
|
||||
in the future while adding a version guard in qemu-server.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/alloc-track.c | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/block/alloc-track.c b/block/alloc-track.c
|
||||
index b4a9851144..fc7d58a5d0 100644
|
||||
--- a/block/alloc-track.c
|
||||
+++ b/block/alloc-track.c
|
||||
@@ -34,7 +34,6 @@ typedef struct {
|
||||
BdrvDirtyBitmap *bitmap;
|
||||
uint64_t granularity;
|
||||
DropState drop_state;
|
||||
- bool auto_remove;
|
||||
} BDRVAllocTrackState;
|
||||
|
||||
static QemuOptsList runtime_opts = {
|
||||
@@ -86,7 +85,11 @@ static int track_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- s->auto_remove = qemu_opt_get_bool(opts, TRACK_OPT_AUTO_REMOVE, false);
|
||||
+ 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,
|
84
debian/patches/pve/0043-alloc-track-avoid-seemingly-superfluous-child-permis.patch
vendored
Normal file
84
debian/patches/pve/0043-alloc-track-avoid-seemingly-superfluous-child-permis.patch
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 27 Mar 2024 11:15:39 +0100
|
||||
Subject: [PATCH] alloc-track: avoid seemingly superfluous child permission
|
||||
update
|
||||
|
||||
Doesn't seem necessary nowadays (maybe after commit "alloc-track: fix
|
||||
deadlock during drop" where the dropping is not rescheduled and delayed
|
||||
anymore or some upstream change). Should there really be some issue,
|
||||
instead of having a drop state, this could also be just based off the
|
||||
fact whether there is still a backing child.
|
||||
|
||||
Dumping the cumulative (shared) permissions for the BDS with a debug
|
||||
print yields the same values after this patch and with QEMU 8.1,
|
||||
namely 3 and 5.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/alloc-track.c | 26 --------------------------
|
||||
1 file changed, 26 deletions(-)
|
||||
|
||||
diff --git a/block/alloc-track.c b/block/alloc-track.c
|
||||
index fc7d58a5d0..b56425b7f0 100644
|
||||
--- a/block/alloc-track.c
|
||||
+++ b/block/alloc-track.c
|
||||
@@ -25,15 +25,9 @@
|
||||
|
||||
#define TRACK_OPT_AUTO_REMOVE "auto-remove"
|
||||
|
||||
-typedef enum DropState {
|
||||
- DropNone,
|
||||
- DropInProgress,
|
||||
-} DropState;
|
||||
-
|
||||
typedef struct {
|
||||
BdrvDirtyBitmap *bitmap;
|
||||
uint64_t granularity;
|
||||
- DropState drop_state;
|
||||
} BDRVAllocTrackState;
|
||||
|
||||
static QemuOptsList runtime_opts = {
|
||||
@@ -137,8 +131,6 @@ static int track_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- s->drop_state = DropNone;
|
||||
-
|
||||
fail:
|
||||
if (ret < 0) {
|
||||
bdrv_graph_wrlock();
|
||||
@@ -289,18 +281,8 @@ track_child_perm(BlockDriverState *bs, BdrvChild *c, BdrvChildRole role,
|
||||
BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared,
|
||||
uint64_t *nperm, uint64_t *nshared)
|
||||
{
|
||||
- BDRVAllocTrackState *s = bs->opaque;
|
||||
-
|
||||
*nshared = BLK_PERM_ALL;
|
||||
|
||||
- /* in case we're currently dropping ourselves, claim to not use any
|
||||
- * permissions at all - which is fine, since from this point on we will
|
||||
- * never issue a read or write anymore */
|
||||
- if (s->drop_state == DropInProgress) {
|
||||
- *nperm = 0;
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
if (role & BDRV_CHILD_DATA) {
|
||||
*nperm = perm & DEFAULT_PERM_PASSTHROUGH;
|
||||
} else {
|
||||
@@ -326,14 +308,6 @@ track_co_change_backing_file(BlockDriverState *bs, const char *backing_file,
|
||||
* 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).
|
||||
*/
|
||||
- if (backing_file == NULL) {
|
||||
- BDRVAllocTrackState *s = bs->opaque;
|
||||
- bdrv_drained_begin(bs);
|
||||
- s->drop_state = DropInProgress;
|
||||
- bdrv_child_refresh_perms(bs, bs->file, &error_abort);
|
||||
- bdrv_drained_end(bs);
|
||||
- }
|
||||
-
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,153 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 6 Apr 2023 14:59:31 +0200
|
||||
Subject: [PATCH] alloc-track: fix deadlock during drop
|
||||
|
||||
by replacing the block node directly after changing the backing file
|
||||
instead of rescheduling it.
|
||||
|
||||
With changes in QEMU 8.0, calling bdrv_get_info (and bdrv_unref)
|
||||
during drop can lead to a deadlock when using iothread (only triggered
|
||||
with multiple disks, except during debugging where it also triggered
|
||||
with one disk sometimes):
|
||||
1. job_unref_locked acquires the AioContext and calls job->driver->free
|
||||
2. track_drop gets scheduled
|
||||
3. bdrv_graph_wrlock is called and polls which leads to track_drop being
|
||||
called
|
||||
4. track_drop acquires the AioContext recursively
|
||||
5. bdrv_get_info is a wrapped coroutine (since 8.0) and thus polls for
|
||||
bdrv_co_get_info. This releases the AioContext, but only once! The
|
||||
documentation for the AIO_WAIT_WHILE macro states that the
|
||||
AioContext lock needs to be acquired exactly once, but there does
|
||||
not seem to be a way for track_drop to know if it acquired the lock
|
||||
recursively or not (without adding further hacks).
|
||||
6. Because the AioContext is still held by the main thread once, it can't
|
||||
be acquired before entering bdrv_co_get_info in co_schedule_bh_cb
|
||||
which happens in the iothread
|
||||
|
||||
When doing the operation in change_backing_file, the AioContext has
|
||||
already been acquired by the caller, so the issue with the recursive
|
||||
lock goes away.
|
||||
|
||||
The comment explaining why delaying the replace is necessary is
|
||||
> we need to schedule this for later however, since when this function
|
||||
> is called, the blockjob modifying us is probably not done yet and
|
||||
> has a blocker on 'bs'
|
||||
|
||||
However, there is no check for blockers in bdrv_replace_node. It would
|
||||
need to be done by us, the caller, with check_to_replace_node.
|
||||
Furthermore, the mirror job also does its call to bdrv_replace_node
|
||||
while there is an active blocker (inserted by mirror itself) and they
|
||||
use a specialized version to check for blockers instead of
|
||||
check_to_replace_node there. Alloc-track could also do something
|
||||
similar to check for other blockers, but it should be fine to rely on
|
||||
Proxmox VE that no other operation with the blockdev is going on.
|
||||
|
||||
Mirror also drains the target before replacing the node, but the
|
||||
target can have other users. In case of alloc-track the file child
|
||||
should not be accessible by anybody else and so there can't be an
|
||||
in-flight operation for the file child when alloc-track is drained.
|
||||
|
||||
The rescheduling based on refcounting is a hack and it doesn't seem to
|
||||
be necessary anymore. It's not clear what the original issue from the
|
||||
comment was. Testing with older builds with track_drop done directly
|
||||
without rescheduling also didn't lead to any noticable issue for me.
|
||||
|
||||
One issue it might have been is the one fixed by b1e1af394d
|
||||
("block/stream: Drain subtree around graph change"), where
|
||||
block-stream had a use-after-free if the base node changed at an
|
||||
inconvenient time (which alloc-track's auto-drop does).
|
||||
|
||||
It's also not possible to just not auto-replace the alloc-track. Not
|
||||
replacing it at all leads to other operations like block resize
|
||||
hanging, and there is no good way to replace it manually via QMP
|
||||
(there is x-blockdev-change, but it is experimental and doesn't
|
||||
implement the required operation yet). Also, it's just cleaner in
|
||||
general to not leave unnecessary block nodes lying around.
|
||||
|
||||
Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/alloc-track.c | 54 ++++++++++++++-------------------------------
|
||||
1 file changed, 16 insertions(+), 38 deletions(-)
|
||||
|
||||
diff --git a/block/alloc-track.c b/block/alloc-track.c
|
||||
index b75d7c6460..76da140a68 100644
|
||||
--- a/block/alloc-track.c
|
||||
+++ b/block/alloc-track.c
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
typedef enum DropState {
|
||||
DropNone,
|
||||
- DropRequested,
|
||||
DropInProgress,
|
||||
} DropState;
|
||||
|
||||
@@ -268,37 +267,6 @@ static void track_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||
}
|
||||
}
|
||||
|
||||
-static void track_drop(void *opaque)
|
||||
-{
|
||||
- BlockDriverState *bs = (BlockDriverState*)opaque;
|
||||
- BlockDriverState *file = bs->file->bs;
|
||||
- BDRVAllocTrackState *s = bs->opaque;
|
||||
-
|
||||
- assert(file);
|
||||
-
|
||||
- /* we rely on the fact that we're not used anywhere else, so let's wait
|
||||
- * until we're only used once - in the drive connected to the guest (and one
|
||||
- * ref is held by bdrv_ref in track_change_backing_file) */
|
||||
- if (bs->refcnt > 2) {
|
||||
- aio_bh_schedule_oneshot(qemu_get_aio_context(), track_drop, opaque);
|
||||
- return;
|
||||
- }
|
||||
- AioContext *aio_context = bdrv_get_aio_context(bs);
|
||||
- aio_context_acquire(aio_context);
|
||||
-
|
||||
- bdrv_drained_begin(bs);
|
||||
-
|
||||
- /* now that we're drained, we can safely set 'DropInProgress' */
|
||||
- s->drop_state = DropInProgress;
|
||||
- bdrv_child_refresh_perms(bs, bs->file, &error_abort);
|
||||
-
|
||||
- bdrv_replace_node(bs, file, &error_abort);
|
||||
- bdrv_set_backing_hd(bs, NULL, &error_abort);
|
||||
- bdrv_drained_end(bs);
|
||||
- bdrv_unref(bs);
|
||||
- aio_context_release(aio_context);
|
||||
-}
|
||||
-
|
||||
static int track_change_backing_file(BlockDriverState *bs,
|
||||
const char *backing_file,
|
||||
const char *backing_fmt)
|
||||
@@ -308,13 +276,23 @@ static int track_change_backing_file(BlockDriverState *bs,
|
||||
backing_file == NULL && backing_fmt == NULL)
|
||||
{
|
||||
/* backing file has been disconnected, there's no longer any use for
|
||||
- * this node, so let's remove ourselves from the block graph - we need
|
||||
- * to schedule this for later however, since when this function is
|
||||
- * called, the blockjob modifying us is probably not done yet and has a
|
||||
- * blocker on 'bs' */
|
||||
- s->drop_state = DropRequested;
|
||||
+ * this node, so let's remove ourselves from the block graph */
|
||||
+ BlockDriverState *file = bs->file->bs;
|
||||
+
|
||||
+ /* Just to be sure, because bdrv_replace_node unrefs it */
|
||||
bdrv_ref(bs);
|
||||
- aio_bh_schedule_oneshot(qemu_get_aio_context(), track_drop, (void*)bs);
|
||||
+ bdrv_drained_begin(bs);
|
||||
+
|
||||
+ /* now that we're drained, we can safely set 'DropInProgress' */
|
||||
+ s->drop_state = DropInProgress;
|
||||
+
|
||||
+ bdrv_child_refresh_perms(bs, bs->file, &error_abort);
|
||||
+
|
||||
+ bdrv_replace_node(bs, file, &error_abort);
|
||||
+ bdrv_set_backing_hd(bs, NULL, &error_abort);
|
||||
+
|
||||
+ bdrv_drained_end(bs);
|
||||
+ bdrv_unref(bs);
|
||||
}
|
||||
|
||||
return 0;
|
337
debian/patches/pve/0044-PVE-backup-add-fleecing-option.patch
vendored
Normal file
337
debian/patches/pve/0044-PVE-backup-add-fleecing-option.patch
vendored
Normal file
@@ -0,0 +1,337 @@
|
||||
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>
|
||||
---
|
||||
block/monitor/block-hmp-cmds.c | 1 +
|
||||
pve-backup.c | 135 ++++++++++++++++++++++++++++++++-
|
||||
qapi/block-core.json | 10 ++-
|
||||
3 files changed, 142 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index 439a7a14c8..d0e7771dcc 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1044,6 +1044,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 faa6a9b93c..4b0820c8a7 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -7,9 +7,11 @@
|
||||
#include "sysemu/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"
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qemu/cutils.h"
|
||||
|
||||
@@ -80,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;
|
||||
@@ -353,6 +362,22 @@ static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
PVEBackupDevInfo *di = opaque;
|
||||
di->completed_ret = ret;
|
||||
|
||||
+ /*
|
||||
+ * 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.
|
||||
+ */
|
||||
+ 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;
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* Needs to happen outside of coroutine, because it takes the graph write lock.
|
||||
*/
|
||||
@@ -519,9 +544,77 @@ 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;
|
||||
+ bdrv_graph_co_rdlock();
|
||||
+ const char *job_id = bdrv_get_device_name(di->bs);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ if (di->fleecing.bs) {
|
||||
+ 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");
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ 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) {
|
||||
+ error_setg(errp, "setting up snapshot access for fleecing failed: %s",
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ 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,
|
||||
+ job_id, 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);
|
||||
|
||||
@@ -577,6 +670,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
|
||||
@@ -584,6 +685,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;
|
||||
@@ -607,6 +709,31 @@ static GList coroutine_fn GRAPH_RDLOCK *get_device_info(
|
||||
}
|
||||
PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
di->bs = 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++;
|
||||
}
|
||||
@@ -656,6 +783,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());
|
||||
@@ -684,7 +812,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);
|
||||
@@ -1087,5 +1215,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 9795247c1f..c581f1f238 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -948,6 +948,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
|
||||
#
|
||||
##
|
||||
@@ -968,7 +972,8 @@
|
||||
'*firewall-file': 'str',
|
||||
'*devlist': 'str',
|
||||
'*speed': 'int',
|
||||
- '*max-workers': 'int' },
|
||||
+ '*max-workers': 'int',
|
||||
+ '*fleecing': 'bool' },
|
||||
'returns': 'UuidInfo', 'coroutine': true }
|
||||
|
||||
##
|
||||
@@ -1014,6 +1019,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.
|
||||
#
|
||||
@@ -1025,6 +1032,7 @@
|
||||
'pbs-dirty-bitmap-migration': 'bool',
|
||||
'pbs-masterkey': 'bool',
|
||||
'pbs-library-version': 'str',
|
||||
+ 'backup-fleecing': 'bool',
|
||||
'backup-max-workers': 'bool' } }
|
||||
|
||||
##
|
@@ -1,190 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Fri, 5 May 2023 13:39:53 +0200
|
||||
Subject: [PATCH] migration: for snapshots, hold the BQL during setup callbacks
|
||||
|
||||
In spirit, this is a partial revert of commit 9b09503752 ("migration:
|
||||
run setup callbacks out of big lock"), but only for the snapshot case.
|
||||
|
||||
For snapshots, the bdrv_writev_vmstate() function is used during setup
|
||||
(in QIOChannelBlock backing the QEMUFile), but not holding the BQL
|
||||
while calling it could lead to an assertion failure. To understand
|
||||
how, first note the following:
|
||||
|
||||
1. Generated coroutine wrappers for block layer functions spawn the
|
||||
coroutine and use AIO_WAIT_WHILE()/aio_poll() to wait for it.
|
||||
2. If the host OS switches threads at an inconvenient time, it can
|
||||
happen that a bottom half scheduled for the main thread's AioContext
|
||||
is executed as part of a vCPU thread's aio_poll().
|
||||
|
||||
An example leading to the assertion failure is as follows:
|
||||
|
||||
main thread:
|
||||
1. A snapshot-save QMP command gets issued.
|
||||
2. snapshot_save_job_bh() is scheduled.
|
||||
|
||||
vCPU thread:
|
||||
3. aio_poll() for the main thread's AioContext is called (e.g. when
|
||||
the guest writes to a pflash device, as part of blk_pwrite which is a
|
||||
generated coroutine wrapper).
|
||||
4. snapshot_save_job_bh() is executed as part of aio_poll().
|
||||
3. qemu_savevm_state() is called.
|
||||
4. qemu_mutex_unlock_iothread() is called. Now
|
||||
qemu_get_current_aio_context() returns 0x0.
|
||||
5. bdrv_writev_vmstate() is executed during the usual savevm setup.
|
||||
But this function is a generated coroutine wrapper, so it uses
|
||||
AIO_WAIT_WHILE. There, the assertion
|
||||
assert(qemu_get_current_aio_context() == qemu_get_aio_context());
|
||||
will fail.
|
||||
|
||||
To fix it, ensure that the BQL is held during setup. To avoid changing
|
||||
the behavior for migration too, introduce conditionals for the setup
|
||||
callbacks that need the BQL and only take the lock if it's not already
|
||||
held.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
include/migration/register.h | 2 +-
|
||||
migration/block-dirty-bitmap.c | 15 ++++++++++++---
|
||||
migration/block.c | 15 ++++++++++++---
|
||||
migration/ram.c | 16 +++++++++++++---
|
||||
migration/savevm.c | 2 --
|
||||
5 files changed, 38 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/include/migration/register.h b/include/migration/register.h
|
||||
index a8dfd8fefd..fa9b0b0f10 100644
|
||||
--- a/include/migration/register.h
|
||||
+++ b/include/migration/register.h
|
||||
@@ -43,9 +43,9 @@ typedef struct SaveVMHandlers {
|
||||
* by other locks.
|
||||
*/
|
||||
int (*save_live_iterate)(QEMUFile *f, void *opaque);
|
||||
+ int (*save_setup)(QEMUFile *f, void *opaque);
|
||||
|
||||
/* This runs outside the iothread lock! */
|
||||
- int (*save_setup)(QEMUFile *f, void *opaque);
|
||||
/* Note for save_live_pending:
|
||||
* must_precopy:
|
||||
* - must be migrated in precopy or in stopped state
|
||||
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
|
||||
index a6440929fa..69fab3275c 100644
|
||||
--- a/migration/block-dirty-bitmap.c
|
||||
+++ b/migration/block-dirty-bitmap.c
|
||||
@@ -1214,10 +1214,17 @@ static int dirty_bitmap_save_setup(QEMUFile *f, void *opaque)
|
||||
{
|
||||
DBMSaveState *s = &((DBMState *)opaque)->save;
|
||||
SaveBitmapState *dbms = NULL;
|
||||
+ bool release_lock = false;
|
||||
|
||||
- qemu_mutex_lock_iothread();
|
||||
+ /* For snapshots, the BQL is held during setup. */
|
||||
+ if (!qemu_mutex_iothread_locked()) {
|
||||
+ qemu_mutex_lock_iothread();
|
||||
+ release_lock = true;
|
||||
+ }
|
||||
if (init_dirty_bitmap_migration(s) < 0) {
|
||||
- qemu_mutex_unlock_iothread();
|
||||
+ if (release_lock) {
|
||||
+ qemu_mutex_unlock_iothread();
|
||||
+ }
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1225,7 +1232,9 @@ static int dirty_bitmap_save_setup(QEMUFile *f, void *opaque)
|
||||
send_bitmap_start(f, s, dbms);
|
||||
}
|
||||
qemu_put_bitmap_flags(f, DIRTY_BITMAP_MIG_FLAG_EOS);
|
||||
- qemu_mutex_unlock_iothread();
|
||||
+ if (release_lock) {
|
||||
+ qemu_mutex_unlock_iothread();
|
||||
+ }
|
||||
return 0;
|
||||
}
|
||||
|
||||
diff --git a/migration/block.c b/migration/block.c
|
||||
index b2497bbd32..c9d55be642 100644
|
||||
--- a/migration/block.c
|
||||
+++ b/migration/block.c
|
||||
@@ -716,21 +716,30 @@ static void block_migration_cleanup(void *opaque)
|
||||
static int block_save_setup(QEMUFile *f, void *opaque)
|
||||
{
|
||||
int ret;
|
||||
+ bool release_lock = false;
|
||||
|
||||
trace_migration_block_save("setup", block_mig_state.submitted,
|
||||
block_mig_state.transferred);
|
||||
|
||||
- qemu_mutex_lock_iothread();
|
||||
+ /* For snapshots, the BQL is held during setup. */
|
||||
+ if (!qemu_mutex_iothread_locked()) {
|
||||
+ qemu_mutex_lock_iothread();
|
||||
+ release_lock = true;
|
||||
+ }
|
||||
ret = init_blk_migration(f);
|
||||
if (ret < 0) {
|
||||
- qemu_mutex_unlock_iothread();
|
||||
+ if (release_lock) {
|
||||
+ qemu_mutex_unlock_iothread();
|
||||
+ }
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* start track dirty blocks */
|
||||
ret = set_dirty_tracking();
|
||||
|
||||
- qemu_mutex_unlock_iothread();
|
||||
+ if (release_lock) {
|
||||
+ qemu_mutex_unlock_iothread();
|
||||
+ }
|
||||
|
||||
if (ret) {
|
||||
return ret;
|
||||
diff --git a/migration/ram.c b/migration/ram.c
|
||||
index 79d881f735..0ecbbc3202 100644
|
||||
--- a/migration/ram.c
|
||||
+++ b/migration/ram.c
|
||||
@@ -3117,8 +3117,16 @@ static void migration_bitmap_clear_discarded_pages(RAMState *rs)
|
||||
|
||||
static void ram_init_bitmaps(RAMState *rs)
|
||||
{
|
||||
- /* For memory_global_dirty_log_start below. */
|
||||
- qemu_mutex_lock_iothread();
|
||||
+ bool release_lock = false;
|
||||
+
|
||||
+ /*
|
||||
+ * For memory_global_dirty_log_start below.
|
||||
+ * For snapshots, the BQL is held during setup.
|
||||
+ */
|
||||
+ if (!qemu_mutex_iothread_locked()) {
|
||||
+ qemu_mutex_lock_iothread();
|
||||
+ release_lock = true;
|
||||
+ }
|
||||
qemu_mutex_lock_ramlist();
|
||||
|
||||
WITH_RCU_READ_LOCK_GUARD() {
|
||||
@@ -3130,7 +3138,9 @@ static void ram_init_bitmaps(RAMState *rs)
|
||||
}
|
||||
}
|
||||
qemu_mutex_unlock_ramlist();
|
||||
- qemu_mutex_unlock_iothread();
|
||||
+ if (release_lock) {
|
||||
+ qemu_mutex_unlock_iothread();
|
||||
+ }
|
||||
|
||||
/*
|
||||
* After an eventual first bitmap sync, fixup the initial bitmap
|
||||
diff --git a/migration/savevm.c b/migration/savevm.c
|
||||
index aa54a67fda..fc6a82a555 100644
|
||||
--- a/migration/savevm.c
|
||||
+++ b/migration/savevm.c
|
||||
@@ -1621,10 +1621,8 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
|
||||
memset(&compression_counters, 0, sizeof(compression_counters));
|
||||
ms->to_dst_file = f;
|
||||
|
||||
- qemu_mutex_unlock_iothread();
|
||||
qemu_savevm_state_header(f);
|
||||
qemu_savevm_state_setup(f);
|
||||
- qemu_mutex_lock_iothread();
|
||||
|
||||
while (qemu_file_get_error(f) == 0) {
|
||||
if (qemu_savevm_state_iterate(f, false) > 0) {
|
117
debian/patches/pve/0045-PVE-backup-improve-error-when-copy-before-write-fail.patch
vendored
Normal file
117
debian/patches/pve/0045-PVE-backup-improve-error-when-copy-before-write-fail.patch
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Mon, 29 Apr 2024 14:43:58 +0200
|
||||
Subject: [PATCH] PVE backup: improve error when copy-before-write fails for
|
||||
fleecing
|
||||
|
||||
With fleecing, failure for copy-before-write does not fail the guest
|
||||
write, but only sets the snapshot error that is associated to the
|
||||
copy-before-write filter, making further requests to the snapshot
|
||||
access fail with EACCES, which then also fails the job. But that error
|
||||
code is not the root cause of why the backup failed, so bubble up the
|
||||
original snapshot error instead.
|
||||
|
||||
Reported-by: Friedrich Weber <f.weber@proxmox.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Tested-by: Friedrich Weber <f.weber@proxmox.com>
|
||||
---
|
||||
block/copy-before-write.c | 18 ++++++++++++------
|
||||
block/copy-before-write.h | 1 +
|
||||
pve-backup.c | 9 +++++++++
|
||||
3 files changed, 22 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
|
||||
index 81afeff1c7..fdf9cdc0cd 100644
|
||||
--- a/block/copy-before-write.c
|
||||
+++ b/block/copy-before-write.c
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "qapi/qmp/qjson.h"
|
||||
|
||||
#include "sysemu/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/pve-backup.c b/pve-backup.c
|
||||
index 4b0820c8a7..81697d9bf9 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -374,6 +374,15 @@ static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
di->fleecing.snapshot_access = NULL;
|
||||
}
|
||||
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;
|
||||
+ }
|
||||
bdrv_cbw_drop(di->fleecing.cbw);
|
||||
di->fleecing.cbw = NULL;
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Fri, 5 May 2023 15:30:16 +0200
|
||||
Subject: [PATCH] savevm-async: don't hold BQL during setup
|
||||
|
||||
See commit "migration: for snapshots, hold the BQL during setup
|
||||
callbacks" for why. This is separate, because a version of that one
|
||||
will hopefully land upstream.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
migration/savevm-async.c | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index ea3b2f36a6..dd7744ab66 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -403,10 +403,8 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
snap_state.state = SAVE_STATE_ACTIVE;
|
||||
snap_state.finalize_bh = qemu_bh_new(process_savevm_finalize, &snap_state);
|
||||
snap_state.co = qemu_coroutine_create(&process_savevm_co, NULL);
|
||||
- qemu_mutex_unlock_iothread();
|
||||
qemu_savevm_state_header(snap_state.file);
|
||||
qemu_savevm_state_setup(snap_state.file);
|
||||
- qemu_mutex_lock_iothread();
|
||||
|
||||
/* Async processing from here on out happens in iohandler context, so let
|
||||
* the target bdrv have its home there.
|
103
debian/patches/pve/0046-PVE-backup-fixup-error-handling-for-fleecing.patch
vendored
Normal file
103
debian/patches/pve/0046-PVE-backup-fixup-error-handling-for-fleecing.patch
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 7 Nov 2024 17:51:14 +0100
|
||||
Subject: [PATCH] PVE backup: fixup error handling for fleecing
|
||||
|
||||
The drained section needs to be terminated before breaking out of the
|
||||
loop in the error scenarios. Otherwise, guest IO on the drive would
|
||||
become stuck.
|
||||
|
||||
If the job is created successfully, then the job completion callback
|
||||
will clean up the snapshot access block nodes. In case failure
|
||||
happened before the job is created, there was no cleanup for the
|
||||
snapshot access block nodes yet. Add it.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 38 +++++++++++++++++++++++++-------------
|
||||
1 file changed, 25 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 81697d9bf9..320c660589 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -357,22 +357,23 @@ static void coroutine_fn pvebackup_co_complete_stream(void *opaque)
|
||||
qemu_co_mutex_unlock(&backup_state.backup_mutex);
|
||||
}
|
||||
|
||||
-static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
+static void cleanup_snapshot_access(PVEBackupDevInfo *di)
|
||||
{
|
||||
- PVEBackupDevInfo *di = opaque;
|
||||
- di->completed_ret = ret;
|
||||
-
|
||||
- /*
|
||||
- * 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.
|
||||
- */
|
||||
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
|
||||
@@ -383,10 +384,17 @@ static void pvebackup_complete_cb(void *opaque, int ret)
|
||||
if (di->completed_ret == -EACCES && snapshot_error) {
|
||||
di->completed_ret = snapshot_error;
|
||||
}
|
||||
- bdrv_cbw_drop(di->fleecing.cbw);
|
||||
- di->fleecing.cbw = NULL;
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ * 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.
|
||||
*/
|
||||
@@ -587,6 +595,7 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
if (!di->fleecing.cbw) {
|
||||
error_setg(errp, "appending cbw node for fleecing failed: %s",
|
||||
local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ bdrv_drained_end(di->bs);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -599,6 +608,8 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
if (!di->fleecing.snapshot_access) {
|
||||
error_setg(errp, "setting up snapshot access for fleecing failed: %s",
|
||||
local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ cleanup_snapshot_access(di);
|
||||
+ bdrv_drained_end(di->bs);
|
||||
break;
|
||||
}
|
||||
source_bs = di->fleecing.snapshot_access;
|
||||
@@ -637,6 +648,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;
|
135
debian/patches/pve/0047-PVE-backup-factor-out-setting-up-snapshot-access-for.patch
vendored
Normal file
135
debian/patches/pve/0047-PVE-backup-factor-out-setting-up-snapshot-access-for.patch
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 7 Nov 2024 17:51:15 +0100
|
||||
Subject: [PATCH] PVE backup: factor out setting up snapshot access for
|
||||
fleecing
|
||||
|
||||
Avoids some line bloat in the create_backup_jobs_bh() function and is
|
||||
in preparation for setting up the snapshot access independently of
|
||||
fleecing, in particular that will be useful for providing access to
|
||||
the snapshot via NBD.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 95 ++++++++++++++++++++++++++++++++--------------------
|
||||
1 file changed, 58 insertions(+), 37 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 320c660589..d8d0c04b0f 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -525,6 +525,62 @@ 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) {
|
||||
+ 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.
|
||||
@@ -569,49 +625,14 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
const char *job_id = bdrv_get_device_name(di->bs);
|
||||
bdrv_graph_co_rdunlock();
|
||||
if (di->fleecing.bs) {
|
||||
- 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");
|
||||
- bdrv_drained_end(di->bs);
|
||||
- break;
|
||||
- }
|
||||
-
|
||||
- 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) {
|
||||
+ if (setup_snapshot_access(di, &local_err) < 0) {
|
||||
error_setg(errp, "setting up snapshot access for fleecing failed: %s",
|
||||
local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
cleanup_snapshot_access(di);
|
||||
bdrv_drained_end(di->bs);
|
||||
break;
|
||||
}
|
||||
+
|
||||
source_bs = di->fleecing.snapshot_access;
|
||||
discard_source = true;
|
||||
|
135
debian/patches/pve/0048-PVE-backup-save-device-name-in-device-info-structure.patch
vendored
Normal file
135
debian/patches/pve/0048-PVE-backup-save-device-name-in-device-info-structure.patch
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 7 Nov 2024 17:51:16 +0100
|
||||
Subject: [PATCH] PVE backup: save device name in device info structure
|
||||
|
||||
The device name needs to be queried while holding the graph read lock
|
||||
and since it doesn't change during the whole operation, just get it
|
||||
once during setup and avoid the need to query it again in different
|
||||
places.
|
||||
|
||||
Also in preparation to use it more often in error messages and for the
|
||||
upcoming external backup access API.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 29 +++++++++++++++--------------
|
||||
1 file changed, 15 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index d8d0c04b0f..e2110ce0db 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -94,6 +94,7 @@ typedef struct PVEBackupDevInfo {
|
||||
size_t size;
|
||||
uint64_t block_size;
|
||||
uint8_t dev_id;
|
||||
+ char* device_name;
|
||||
int completed_ret; // INT_MAX if not completed
|
||||
BdrvDirtyBitmap *bitmap;
|
||||
BlockDriverState *target;
|
||||
@@ -327,6 +328,8 @@ static void coroutine_fn pvebackup_co_complete_stream(void *opaque)
|
||||
}
|
||||
|
||||
di->bs = NULL;
|
||||
+ g_free(di->device_name);
|
||||
+ di->device_name = NULL;
|
||||
|
||||
assert(di->target == NULL);
|
||||
|
||||
@@ -621,9 +624,6 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
|
||||
BlockDriverState *source_bs = di->bs;
|
||||
bool discard_source = false;
|
||||
- bdrv_graph_co_rdlock();
|
||||
- const char *job_id = bdrv_get_device_name(di->bs);
|
||||
- bdrv_graph_co_rdunlock();
|
||||
if (di->fleecing.bs) {
|
||||
if (setup_snapshot_access(di, &local_err) < 0) {
|
||||
error_setg(errp, "setting up snapshot access for fleecing failed: %s",
|
||||
@@ -654,7 +654,7 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
}
|
||||
|
||||
BlockJob *job = backup_job_create(
|
||||
- job_id, source_bs, di->target, backup_state.speed, sync_mode, di->bitmap,
|
||||
+ 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);
|
||||
@@ -751,6 +751,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));
|
||||
|
||||
if (fleecing && device_uses_fleecing(*d)) {
|
||||
g_autofree gchar *fleecing_devid = g_strconcat(*d, "-fleecing", NULL);
|
||||
@@ -789,6 +790,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_list = g_list_append(di_list, di);
|
||||
}
|
||||
}
|
||||
@@ -956,9 +958,6 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
|
||||
di->block_size = dump_cb_block_size;
|
||||
|
||||
- bdrv_graph_co_rdlock();
|
||||
- const char *devname = bdrv_get_device_name(di->bs);
|
||||
- bdrv_graph_co_rdunlock();
|
||||
PBSBitmapAction action = PBS_BITMAP_ACTION_NOT_USED;
|
||||
size_t dirty = di->size;
|
||||
|
||||
@@ -973,7 +972,8 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
}
|
||||
action = PBS_BITMAP_ACTION_NEW;
|
||||
} else {
|
||||
- expect_only_dirty = proxmox_backup_check_incremental(pbs, devname, di->size) != 0;
|
||||
+ expect_only_dirty =
|
||||
+ proxmox_backup_check_incremental(pbs, di->device_name, di->size) != 0;
|
||||
}
|
||||
|
||||
if (expect_only_dirty) {
|
||||
@@ -997,7 +997,8 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
}
|
||||
}
|
||||
|
||||
- int dev_id = proxmox_backup_co_register_image(pbs, devname, di->size, expect_only_dirty, errp);
|
||||
+ int dev_id = proxmox_backup_co_register_image(pbs, di->device_name, di->size,
|
||||
+ expect_only_dirty, errp);
|
||||
if (dev_id < 0) {
|
||||
goto err_mutex;
|
||||
}
|
||||
@@ -1009,7 +1010,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
di->dev_id = dev_id;
|
||||
|
||||
PBSBitmapInfo *info = g_malloc(sizeof(*info));
|
||||
- info->drive = g_strdup(devname);
|
||||
+ info->drive = g_strdup(di->device_name);
|
||||
info->action = action;
|
||||
info->size = di->size;
|
||||
info->dirty = dirty;
|
||||
@@ -1032,10 +1033,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
goto err_mutex;
|
||||
}
|
||||
|
||||
- bdrv_graph_co_rdlock();
|
||||
- const char *devname = bdrv_get_device_name(di->bs);
|
||||
- bdrv_graph_co_rdunlock();
|
||||
- di->dev_id = vma_writer_register_stream(vmaw, devname, di->size);
|
||||
+ di->dev_id = vma_writer_register_stream(vmaw, di->device_name, di->size);
|
||||
if (di->dev_id <= 0) {
|
||||
error_set(errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
"register_stream failed");
|
||||
@@ -1146,6 +1144,9 @@ err:
|
||||
bdrv_co_unref(di->target);
|
||||
}
|
||||
|
||||
+ g_free(di->device_name);
|
||||
+ di->device_name = NULL;
|
||||
+
|
||||
g_free(di);
|
||||
}
|
||||
g_list_free(di_list);
|
25
debian/patches/pve/0049-PVE-backup-include-device-name-in-error-when-setting.patch
vendored
Normal file
25
debian/patches/pve/0049-PVE-backup-include-device-name-in-error-when-setting.patch
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 7 Nov 2024 17:51:17 +0100
|
||||
Subject: [PATCH] PVE backup: include device name in error when setting up
|
||||
snapshot access fails
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index e2110ce0db..32352fb5ec 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -626,7 +626,8 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
bool discard_source = false;
|
||||
if (di->fleecing.bs) {
|
||||
if (setup_snapshot_access(di, &local_err) < 0) {
|
||||
- error_setg(errp, "setting up snapshot access for fleecing failed: %s",
|
||||
+ error_setg(errp, "%s - setting up snapshot access for fleecing failed: %s",
|
||||
+ di->device_name,
|
||||
local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
cleanup_snapshot_access(di);
|
||||
bdrv_drained_end(di->bs);
|
137
debian/patches/pve/0050-adapt-machine-version-deprecation-for-Proxmox-VE.patch
vendored
Normal file
137
debian/patches/pve/0050-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 d1741ea121..3f9befda14 100644
|
||||
--- a/include/hw/boards.h
|
||||
+++ b/include/hw/boards.h
|
||||
@@ -631,42 +631,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)
|
||||
@@ -675,7 +699,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)
|
||||
@@ -684,7 +708,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
|
50
debian/patches/pve/0051-Revert-hpet-avoid-timer-storms-on-periodic-timers.patch
vendored
Normal file
50
debian/patches/pve/0051-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 5399f1b2a3..8ccc421cbb 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -59,7 +59,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 {
|
||||
@@ -267,7 +266,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) {
|
||||
@@ -366,15 +364,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));
|
||||
}
|
||||
|
||||
/*
|
203
debian/patches/pve/0052-Revert-hpet-store-full-64-bit-target-value-of-the-co.patch
vendored
Normal file
203
debian/patches/pve/0052-Revert-hpet-store-full-64-bit-target-value-of-the-co.patch
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
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 | 111 +++++++++++++++++++++++++++---------------------
|
||||
1 file changed, 62 insertions(+), 49 deletions(-)
|
||||
|
||||
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
|
||||
index 8ccc421cbb..415a9433f1 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -54,7 +54,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.
|
||||
@@ -116,6 +115,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);
|
||||
}
|
||||
@@ -152,32 +156,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)
|
||||
@@ -261,12 +260,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)
|
||||
@@ -362,10 +356,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);
|
||||
+ }
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -374,44 +372,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) {
|
||||
-
|
||||
- /* 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)) {
|
||||
+ 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 (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)
|
||||
@@ -542,7 +550,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)) {
|
281
debian/patches/pve/0053-Revert-hpet-accept-64-bit-reads-and-writes.patch
vendored
Normal file
281
debian/patches/pve/0053-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 415a9433f1..e1ac877759 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -437,7 +437,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);
|
||||
@@ -452,33 +451,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;
|
||||
@@ -492,11 +510,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) {
|
||||
@@ -508,12 +526,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
|
||||
@@ -521,7 +536,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);
|
||||
@@ -534,28 +550,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)) {
|
||||
@@ -563,7 +607,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();
|
||||
@@ -571,14 +618,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 =
|
||||
@@ -608,8 +653,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)) {
|
||||
@@ -621,7 +668,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();
|
||||
@@ -635,11 +690,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 5cfc369fba..219747df2f 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"
|
64
debian/patches/pve/0054-Revert-hpet-place-read-only-bits-directly-in-new_val.patch
vendored
Normal file
64
debian/patches/pve/0054-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 e1ac877759..b12bbaf10d 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -510,7 +510,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);
|
||||
@@ -536,12 +536,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;
|
||||
@@ -622,8 +623,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 =
|
||||
@@ -657,9 +658,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);
|
||||
}
|
||||
}
|
68
debian/patches/pve/0055-Revert-hpet-remove-unnecessary-variable-index.patch
vendored
Normal file
68
debian/patches/pve/0055-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 b12bbaf10d..6f83d88516 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -437,12 +437,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];
|
||||
|
||||
@@ -469,7 +469,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:
|
||||
@@ -510,14 +510,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];
|
||||
|
||||
@@ -619,7 +620,7 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
- switch (addr) {
|
||||
+ switch (index) {
|
||||
case HPET_ID:
|
||||
return;
|
||||
case HPET_CFG:
|
40
debian/patches/pve/0056-Revert-hpet-ignore-high-bits-of-comparator-in-32-bit.patch
vendored
Normal file
40
debian/patches/pve/0056-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 6f83d88516..509986c0a9 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -585,10 +585,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 219747df2f..b86870fb22 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/0057-Revert-hpet-fix-and-cleanup-persistence-of-interrupt.patch
vendored
Normal file
120
debian/patches/pve/0057-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 509986c0a9..402cc960f0 100644
|
||||
--- a/hw/timer/hpet.c
|
||||
+++ b/hw/timer/hpet.c
|
||||
@@ -196,31 +196,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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,13 +414,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,
|
||||
@@ -530,26 +515,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
|
||||
@@ -627,10 +606,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. */
|
81
debian/patches/pve/0058-savevm-async-improve-setting-state-of-snapshot-opera.patch
vendored
Normal file
81
debian/patches/pve/0058-savevm-async-improve-setting-state-of-snapshot-opera.patch
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Mon, 31 Mar 2025 16:55:02 +0200
|
||||
Subject: [PATCH] savevm-async: improve setting state of snapshot operation in
|
||||
savevm-end handler
|
||||
|
||||
One of the callers of wait_for_close_co() already sets the state to
|
||||
SAVE_STATE_DONE before, but that is not fully correct, because at that
|
||||
moment, the operation is not fully done. In particular, if closing the
|
||||
target later fails, the state would even be set to SAVE_STATE_ERROR
|
||||
afterwards. DONE -> ERROR is not a valid state transition. Although,
|
||||
it should not matter in practice as long as the relevant QMP commands
|
||||
are sequential.
|
||||
|
||||
The other caller does not set the state and so there seems to be a
|
||||
race that could lead to the state not getting set at all. This is
|
||||
because before this commit, the wait_for_close_co() function could
|
||||
return early when there is no target file anymore. This can only
|
||||
happen when canceling and needs to happen right around the time when
|
||||
the snapshot is already finishing and closing the target.
|
||||
|
||||
Simply avoid the early return and always set the state within the
|
||||
wait_for_close_co() function rather than at the call site.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
migration/savevm-async.c | 33 +++++++++++++++------------------
|
||||
1 file changed, 15 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index 1e79fce9ba..e63dc6d8a3 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -450,23 +450,22 @@ static void coroutine_fn wait_for_close_co(void *opaque)
|
||||
{
|
||||
int64_t timeout;
|
||||
|
||||
- if (!snap_state.target) {
|
||||
- DPRINTF("savevm-end: no target file open\n");
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- /* wait until cleanup is done before returning, this ensures that after this
|
||||
- * call exits the statefile will be closed and can be removed immediately */
|
||||
- DPRINTF("savevm-end: waiting for cleanup\n");
|
||||
- timeout = 30L * 1000 * 1000 * 1000;
|
||||
- qemu_co_sleep_ns_wakeable(&snap_state.target_close_wait,
|
||||
- QEMU_CLOCK_REALTIME, timeout);
|
||||
if (snap_state.target) {
|
||||
- save_snapshot_error("timeout waiting for target file close in "
|
||||
- "qmp_savevm_end");
|
||||
- /* we cannot assume the snapshot finished in this case, so leave the
|
||||
- * state alone - caller has to figure something out */
|
||||
- return;
|
||||
+ /* wait until cleanup is done before returning, this ensures that after this
|
||||
+ * call exits the statefile will be closed and can be removed immediately */
|
||||
+ DPRINTF("savevm-end: waiting for cleanup\n");
|
||||
+ timeout = 30L * 1000 * 1000 * 1000;
|
||||
+ qemu_co_sleep_ns_wakeable(&snap_state.target_close_wait,
|
||||
+ QEMU_CLOCK_REALTIME, timeout);
|
||||
+ if (snap_state.target) {
|
||||
+ save_snapshot_error("timeout waiting for target file close in "
|
||||
+ "qmp_savevm_end");
|
||||
+ /* we cannot assume the snapshot finished in this case, so leave the
|
||||
+ * state alone - caller has to figure something out */
|
||||
+ return;
|
||||
+ }
|
||||
+ } else {
|
||||
+ DPRINTF("savevm-end: no target file open\n");
|
||||
}
|
||||
|
||||
// File closed and no other error, so ensure next snapshot can be started.
|
||||
@@ -497,8 +496,6 @@ void qmp_savevm_end(Error **errp)
|
||||
snap_state.saved_vm_running = false;
|
||||
}
|
||||
|
||||
- snap_state.state = SAVE_STATE_DONE;
|
||||
-
|
||||
qemu_coroutine_enter(wait_for_close);
|
||||
}
|
||||
|
71
debian/patches/pve/0059-savevm-async-rename-saved_vm_running-to-vm_needs_sta.patch
vendored
Normal file
71
debian/patches/pve/0059-savevm-async-rename-saved_vm_running-to-vm_needs_sta.patch
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Mon, 31 Mar 2025 16:55:03 +0200
|
||||
Subject: [PATCH] savevm-async: rename saved_vm_running to vm_needs_start
|
||||
|
||||
This is what the variable actually expresses. Otherwise, setting it
|
||||
to false after starting the VM doesn't make sense.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
migration/savevm-async.c | 16 ++++++++--------
|
||||
1 file changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index e63dc6d8a3..1e34c31e8b 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -51,7 +51,7 @@ static struct SnapshotState {
|
||||
int state;
|
||||
Error *error;
|
||||
Error *blocker;
|
||||
- int saved_vm_running;
|
||||
+ int vm_needs_start;
|
||||
QEMUFile *file;
|
||||
int64_t total_time;
|
||||
QEMUBH *finalize_bh;
|
||||
@@ -224,9 +224,9 @@ static void process_savevm_finalize(void *opaque)
|
||||
save_snapshot_error("process_savevm_cleanup: invalid state: %d",
|
||||
snap_state.state);
|
||||
}
|
||||
- if (snap_state.saved_vm_running) {
|
||||
+ if (snap_state.vm_needs_start) {
|
||||
vm_start();
|
||||
- snap_state.saved_vm_running = false;
|
||||
+ snap_state.vm_needs_start = false;
|
||||
}
|
||||
|
||||
DPRINTF("timing: process_savevm_finalize (full) took %ld ms\n",
|
||||
@@ -352,7 +352,7 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
}
|
||||
|
||||
/* initialize snapshot info */
|
||||
- snap_state.saved_vm_running = runstate_is_running();
|
||||
+ snap_state.vm_needs_start = runstate_is_running();
|
||||
snap_state.bs_pos = 0;
|
||||
snap_state.total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
|
||||
snap_state.blocker = NULL;
|
||||
@@ -440,9 +440,9 @@ restart:
|
||||
|
||||
save_snapshot_error("setup failed");
|
||||
|
||||
- if (snap_state.saved_vm_running) {
|
||||
+ if (snap_state.vm_needs_start) {
|
||||
vm_start();
|
||||
- snap_state.saved_vm_running = false;
|
||||
+ snap_state.vm_needs_start = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,9 +491,9 @@ void qmp_savevm_end(Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
- if (snap_state.saved_vm_running) {
|
||||
+ if (snap_state.vm_needs_start) {
|
||||
vm_start();
|
||||
- snap_state.saved_vm_running = false;
|
||||
+ snap_state.vm_needs_start = false;
|
||||
}
|
||||
|
||||
qemu_coroutine_enter(wait_for_close);
|
120
debian/patches/pve/0060-savevm-async-improve-runstate-preservation-cleanup-e.patch
vendored
Normal file
120
debian/patches/pve/0060-savevm-async-improve-runstate-preservation-cleanup-e.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: Mon, 31 Mar 2025 16:55:04 +0200
|
||||
Subject: [PATCH] savevm-async: improve runstate preservation, cleanup error
|
||||
handling
|
||||
|
||||
Determine if VM needs to be started after finishing right before
|
||||
actually stopping the VM instead of at the beginning.
|
||||
|
||||
In qmp_savevm_start(), the only path stopping the VM returns right
|
||||
aftwards, so there is no need for the vm_start() handling after
|
||||
errors.
|
||||
|
||||
Lastly, improve the code style for checking whether migrate_init()
|
||||
failed by explicitly comparing against 0.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
[WB: squashed error handling commits, rename goto branch instead of
|
||||
inlining it]
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
migration/savevm-async.c | 25 ++++++++++---------------
|
||||
1 file changed, 10 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index 1e34c31e8b..d8d2c80475 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -178,6 +178,7 @@ static void process_savevm_finalize(void *opaque)
|
||||
*/
|
||||
blk_set_aio_context(snap_state.target, qemu_get_aio_context(), NULL);
|
||||
|
||||
+ snap_state.vm_needs_start = runstate_is_running();
|
||||
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
|
||||
if (ret < 0) {
|
||||
save_snapshot_error("vm_stop_force_state error %d", ret);
|
||||
@@ -352,7 +353,6 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
}
|
||||
|
||||
/* initialize snapshot info */
|
||||
- snap_state.vm_needs_start = runstate_is_running();
|
||||
snap_state.bs_pos = 0;
|
||||
snap_state.total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
|
||||
snap_state.blocker = NULL;
|
||||
@@ -364,13 +364,14 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
}
|
||||
|
||||
if (!statefile) {
|
||||
+ snap_state.vm_needs_start = runstate_is_running();
|
||||
vm_stop(RUN_STATE_SAVE_VM);
|
||||
snap_state.state = SAVE_STATE_COMPLETED;
|
||||
return;
|
||||
}
|
||||
|
||||
if (qemu_savevm_state_blocked(errp)) {
|
||||
- return;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
/* Open the image */
|
||||
@@ -380,12 +381,12 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
snap_state.target = blk_new_open(statefile, NULL, options, bdrv_oflags, &local_err);
|
||||
if (!snap_state.target) {
|
||||
error_setg(errp, "failed to open '%s'", statefile);
|
||||
- goto restart;
|
||||
+ goto fail;
|
||||
}
|
||||
target_bs = blk_bs(snap_state.target);
|
||||
if (!target_bs) {
|
||||
error_setg(errp, "failed to open '%s' - no block driver state", statefile);
|
||||
- goto restart;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
QIOChannel *ioc = QIO_CHANNEL(qio_channel_savevm_async_new(snap_state.target,
|
||||
@@ -394,7 +395,7 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
|
||||
if (!snap_state.file) {
|
||||
error_setg(errp, "failed to open '%s'", statefile);
|
||||
- goto restart;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -402,8 +403,8 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
* State is cleared in process_savevm_co, but has to be initialized
|
||||
* here (blocking main thread, from QMP) to avoid race conditions.
|
||||
*/
|
||||
- if (migrate_init(ms, errp)) {
|
||||
- return;
|
||||
+ if (migrate_init(ms, errp) != 0) {
|
||||
+ goto fail;
|
||||
}
|
||||
memset(&mig_stats, 0, sizeof(mig_stats));
|
||||
ms->to_dst_file = snap_state.file;
|
||||
@@ -418,7 +419,7 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
if (ret != 0) {
|
||||
error_setg_errno(errp, -ret, "savevm state setup failed: %s",
|
||||
local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
- return;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
/* Async processing from here on out happens in iohandler context, so let
|
||||
@@ -436,14 +437,8 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
|
||||
return;
|
||||
|
||||
-restart:
|
||||
-
|
||||
+fail:
|
||||
save_snapshot_error("setup failed");
|
||||
-
|
||||
- if (snap_state.vm_needs_start) {
|
||||
- vm_start();
|
||||
- snap_state.vm_needs_start = false;
|
||||
- }
|
||||
}
|
||||
|
||||
static void coroutine_fn wait_for_close_co(void *opaque)
|
185
debian/patches/pve/0061-savevm-async-use-dedicated-iothread-for-state-file.patch
vendored
Normal file
185
debian/patches/pve/0061-savevm-async-use-dedicated-iothread-for-state-file.patch
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Mon, 31 Mar 2025 16:55:06 +0200
|
||||
Subject: [PATCH] savevm-async: use dedicated iothread for state file
|
||||
|
||||
Having the state file be in the iohandler context means that a
|
||||
blk_drain_all() call in the main thread or vCPU thread that happens
|
||||
while the snapshot is running will result in a deadlock.
|
||||
|
||||
For example, the main thread might be stuck in:
|
||||
|
||||
> 0 0x00007300ac9552d6 in __ppoll (fds=0x64bd5a411a50, nfds=2, timeout=<optimized out>, timeout@entry=0x0, sigmask=sigmask@entry=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:42
|
||||
> 1 0x000064bd51af3cad in ppoll (__ss=0x0, __timeout=0x0, __nfds=<optimized out>, __fds=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/poll2.h:64
|
||||
> 2 0x000064bd51ad8799 in fdmon_poll_wait (ctx=0x64bd58d968a0, ready_list=0x7ffcfcc15558, timeout=-1) at ../util/fdmon-poll.c:79
|
||||
> 3 0x000064bd51ad7c3d in aio_poll (ctx=0x64bd58d968a0, blocking=blocking@entry=true) at ../util/aio-posix.c:671
|
||||
> 4 0x000064bd519a0b5d in bdrv_drain_all_begin () at ../block/io.c:531
|
||||
> 5 bdrv_drain_all_begin () at ../block/io.c:510
|
||||
> 6 0x000064bd519943c4 in blk_drain_all () at ../block/block-backend.c:2085
|
||||
> 7 0x000064bd5160fc5a in virtio_scsi_dataplane_stop (vdev=0x64bd5a215190) at ../hw/scsi/virtio-scsi-dataplane.c:213
|
||||
> 8 0x000064bd51664e90 in virtio_bus_stop_ioeventfd (bus=0x64bd5a215110) at ../hw/virtio/virtio-bus.c:259
|
||||
> 9 0x000064bd5166511b in virtio_bus_stop_ioeventfd (bus=<optimized out>) at ../hw/virtio/virtio-bus.c:251
|
||||
> 10 virtio_bus_reset (bus=<optimized out>) at ../hw/virtio/virtio-bus.c:107
|
||||
> 11 0x000064bd51667431 in virtio_pci_reset (qdev=<optimized out>) at ../hw/virtio/virtio-pci.c:2296
|
||||
...
|
||||
> 34 0x000064bd517aa951 in pc_machine_reset (machine=<optimized out>, type=<optimized out>) at ../hw/i386/pc.c:1722
|
||||
> 35 0x000064bd516aa4c4 in qemu_system_reset (reason=reason@entry=SHUTDOWN_CAUSE_GUEST_RESET) at ../system/runstate.c:525
|
||||
> 36 0x000064bd516aaeb9 in main_loop_should_exit (status=<synthetic pointer>) at ../system/runstate.c:801
|
||||
> 37 qemu_main_loop () at ../system/runstate.c:834
|
||||
|
||||
which is in block/io.c:
|
||||
|
||||
> /* Now poll the in-flight requests */
|
||||
> AIO_WAIT_WHILE_UNLOCKED(NULL, bdrv_drain_all_poll());
|
||||
|
||||
The working theory is: The deadlock happens because the IO is issued
|
||||
from the process_savevm_co() coroutine, which doesn't get scheduled
|
||||
again to complete in-flight requests when the main thread is stuck
|
||||
there polling. The main thread itself is the one that would need to
|
||||
schedule it. In case of a vCPU triggering the VirtIO SCSI dataplane
|
||||
stop, which happens during (Linux) boot, the vCPU thread will hold the
|
||||
big QEMU lock (BQL) blocking the main thread from making progress
|
||||
scheduling the process_savevm_co() coroutine.
|
||||
|
||||
This change should also help in general to 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.
|
||||
|
||||
With some luck, it could also help with bug #6262 [0]. The failure
|
||||
there happens while issuing/right after the savevm-start QMP command,
|
||||
so the most likely coroutine is the process_savevm_co() that was
|
||||
previously scheduled to the iohandler context. Likely someone polls
|
||||
the iohandler context and wants to enter the already scheduled
|
||||
coroutine leading to the abort():
|
||||
> qemu_aio_coroutine_enter: Co-routine was already scheduled in 'aio_co_schedule'
|
||||
With a dedicated iothread, there hopefully is no such race.
|
||||
|
||||
The comment above querying the pending bytes wrongly talked about the
|
||||
"iothread lock", but should've been "iohandler lock". This was even
|
||||
renamed to BQL (big QEMU lock) a few releases ago. Even if that was
|
||||
not a typo to begin with, there are no AioContext locks anymore.
|
||||
|
||||
[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=6262
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
[WB: update to the changed error handling in the previous commit]
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
migration/savevm-async.c | 42 ++++++++++++++++++++++++++++------------
|
||||
1 file changed, 30 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index d8d2c80475..11ea4c601d 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/rcu.h"
|
||||
#include "qemu/yank.h"
|
||||
+#include "sysemu/iothread.h"
|
||||
|
||||
/* #define DEBUG_SAVEVM_STATE */
|
||||
|
||||
@@ -57,6 +58,7 @@ static struct SnapshotState {
|
||||
QEMUBH *finalize_bh;
|
||||
Coroutine *co;
|
||||
QemuCoSleep target_close_wait;
|
||||
+ IOThread *iothread;
|
||||
} snap_state;
|
||||
|
||||
static bool savevm_aborted(void)
|
||||
@@ -256,16 +258,13 @@ static void coroutine_fn process_savevm_co(void *opaque)
|
||||
uint64_t threshold = 400 * 1000;
|
||||
|
||||
/*
|
||||
- * pending_{estimate,exact} are expected to be called without iothread
|
||||
- * lock. Similar to what is done in migration.c, call the exact variant
|
||||
- * only once pend_precopy in the estimate is below the threshold.
|
||||
+ * Similar to what is done in migration.c, call the exact variant only
|
||||
+ * once pend_precopy in the estimate is below the threshold.
|
||||
*/
|
||||
- bql_unlock();
|
||||
qemu_savevm_state_pending_estimate(&pend_precopy, &pend_postcopy);
|
||||
if (pend_precopy <= threshold) {
|
||||
qemu_savevm_state_pending_exact(&pend_precopy, &pend_postcopy);
|
||||
}
|
||||
- bql_lock();
|
||||
pending_size = pend_precopy + pend_postcopy;
|
||||
|
||||
/*
|
||||
@@ -332,11 +331,17 @@ static void coroutine_fn process_savevm_co(void *opaque)
|
||||
qemu_bh_schedule(snap_state.finalize_bh);
|
||||
}
|
||||
|
||||
+static void savevm_cleanup_iothread(void) {
|
||||
+ if (snap_state.iothread) {
|
||||
+ iothread_destroy(snap_state.iothread);
|
||||
+ snap_state.iothread = NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
MigrationState *ms = migrate_get_current();
|
||||
- AioContext *iohandler_ctx = iohandler_get_aio_context();
|
||||
BlockDriverState *target_bs = NULL;
|
||||
int ret = 0;
|
||||
|
||||
@@ -374,6 +379,19 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
+ if (snap_state.iothread) {
|
||||
+ /* This is not expected, so warn about it, but no point in re-creating a new iothread. */
|
||||
+ warn_report("iothread for snapshot already exists - re-using");
|
||||
+ } else {
|
||||
+ snap_state.iothread =
|
||||
+ iothread_create("__proxmox_savevm_async_iothread__", &local_err);
|
||||
+ if (!snap_state.iothread) {
|
||||
+ error_setg(errp, "creating iothread failed: %s",
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ goto fail;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/* Open the image */
|
||||
QDict *options = NULL;
|
||||
options = qdict_new();
|
||||
@@ -422,22 +440,20 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- /* Async processing from here on out happens in iohandler context, so let
|
||||
- * the target bdrv have its home there.
|
||||
- */
|
||||
- ret = blk_set_aio_context(snap_state.target, iohandler_ctx, &local_err);
|
||||
+ ret = blk_set_aio_context(snap_state.target, snap_state.iothread->ctx, &local_err);
|
||||
if (ret != 0) {
|
||||
- warn_report("failed to set iohandler context for VM state target: %s %s",
|
||||
+ warn_report("failed to set iothread context for VM state target: %s %s",
|
||||
local_err ? error_get_pretty(local_err) : "unknown error",
|
||||
strerror(-ret));
|
||||
}
|
||||
|
||||
snap_state.co = qemu_coroutine_create(&process_savevm_co, NULL);
|
||||
- aio_co_schedule(iohandler_ctx, snap_state.co);
|
||||
+ aio_co_schedule(snap_state.iothread->ctx, snap_state.co);
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
+ savevm_cleanup_iothread();
|
||||
save_snapshot_error("setup failed");
|
||||
}
|
||||
|
||||
@@ -463,6 +479,8 @@ static void coroutine_fn wait_for_close_co(void *opaque)
|
||||
DPRINTF("savevm-end: no target file open\n");
|
||||
}
|
||||
|
||||
+ savevm_cleanup_iothread();
|
||||
+
|
||||
// File closed and no other error, so ensure next snapshot can be started.
|
||||
if (snap_state.state != SAVE_STATE_ERROR) {
|
||||
snap_state.state = SAVE_STATE_DONE;
|
33
debian/patches/pve/0062-savevm-async-treat-failure-to-set-iothread-context-a.patch
vendored
Normal file
33
debian/patches/pve/0062-savevm-async-treat-failure-to-set-iothread-context-a.patch
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Mon, 31 Mar 2025 16:55:07 +0200
|
||||
Subject: [PATCH] savevm-async: treat failure to set iothread context as a hard
|
||||
failure
|
||||
|
||||
This is not expected to ever fail and there might be assumptions about
|
||||
having the expected context down the line.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
[WB: update to changed error handling]
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
migration/savevm-async.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index 11ea4c601d..f2b10b5519 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -442,9 +442,9 @@ void qmp_savevm_start(const char *statefile, Error **errp)
|
||||
|
||||
ret = blk_set_aio_context(snap_state.target, snap_state.iothread->ctx, &local_err);
|
||||
if (ret != 0) {
|
||||
- warn_report("failed to set iothread context for VM state target: %s %s",
|
||||
- local_err ? error_get_pretty(local_err) : "unknown error",
|
||||
- strerror(-ret));
|
||||
+ error_setg_errno(errp, -ret, "failed to set iothread context for VM state target: %s",
|
||||
+ local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
snap_state.co = qemu_coroutine_create(&process_savevm_co, NULL);
|
41
debian/patches/pve/0063-PVE-backup-clean-up-directly-in-setup_snapshot_acces.patch
vendored
Normal file
41
debian/patches/pve/0063-PVE-backup-clean-up-directly-in-setup_snapshot_acces.patch
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 3 Apr 2025 14:30:41 +0200
|
||||
Subject: [PATCH] PVE backup: clean up directly in setup_snapshot_access() when
|
||||
it fails
|
||||
|
||||
The only thing that might need to be cleaned up after
|
||||
setup_snapshot_access() failed is dropping the cbw filter. Do so in
|
||||
the single branch it matters inside setup_snapshot_access() itself.
|
||||
This avoids the need that callers of setup_snapshot_access() use
|
||||
cleanup_snapshot_access() when the call failed.
|
||||
|
||||
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 | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 32352fb5ec..2408f182bc 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -576,6 +576,9 @@ static int setup_snapshot_access(PVEBackupDevInfo *di, Error **errp)
|
||||
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;
|
||||
@@ -629,7 +632,6 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
error_setg(errp, "%s - setting up snapshot access for fleecing failed: %s",
|
||||
di->device_name,
|
||||
local_err ? error_get_pretty(local_err) : "unknown error");
|
||||
- cleanup_snapshot_access(di);
|
||||
bdrv_drained_end(di->bs);
|
||||
break;
|
||||
}
|
59
debian/patches/pve/0064-PVE-backup-factor-out-helper-to-clear-backup-state-s.patch
vendored
Normal file
59
debian/patches/pve/0064-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 2408f182bc..915649b5f9 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) {
|
95
debian/patches/pve/0065-PVE-backup-factor-out-helper-to-initialize-backup-st.patch
vendored
Normal file
95
debian/patches/pve/0065-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 915649b5f9..88a981f81c 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/0066-PVE-backup-add-target-ID-in-backup-state.patch
vendored
Normal file
63
debian/patches/pve/0066-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 88a981f81c..8789a0667a 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));
|
57
debian/patches/pve/0067-PVE-backup-get-device-info-allow-caller-to-specify-f.patch
vendored
Normal file
57
debian/patches/pve/0067-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 8789a0667a..755f1abcf1 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);
|
495
debian/patches/pve/0068-PVE-backup-implement-backup-access-setup-and-teardow.patch
vendored
Normal file
495
debian/patches/pve/0068-PVE-backup-implement-backup-access-setup-and-teardow.patch
vendored
Normal file
@@ -0,0 +1,495 @@
|
||||
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.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 264 ++++++++++++++++++++++++++++++++++++++++++-
|
||||
pve-backup.h | 16 +++
|
||||
qapi/block-core.json | 49 ++++++++
|
||||
system/runstate.c | 6 +
|
||||
4 files changed, 329 insertions(+), 6 deletions(-)
|
||||
create mode 100644 pve-backup.h
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 755f1abcf1..091b5bd231 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"
|
||||
@@ -588,6 +589,36 @@ 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 (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 +755,11 @@ 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;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* 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
|
||||
@@ -839,8 +875,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 +892,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 +917,216 @@ 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,
|
||||
+ const char *devlist,
|
||||
+ 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();
|
||||
+ di_list = get_device_info(devlist, fleecing_all, &local_err);
|
||||
+ bdrv_graph_co_rdunlock();
|
||||
+ if (local_err) {
|
||||
+ error_propagate(errp, local_err);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ 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();
|
||||
+
|
||||
+ /* 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;
|
||||
+
|
||||
+ *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);
|
||||
+
|
||||
+ 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(void)
|
||||
+{
|
||||
+ 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;
|
||||
+ }
|
||||
+
|
||||
+ 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();
|
||||
+
|
||||
+ /* return */
|
||||
+ aio_co_enter(data->ctx, data->co);
|
||||
+}
|
||||
+
|
||||
+void coroutine_fn qmp_backup_access_teardown(const char *target_id, 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(),
|
||||
+ };
|
||||
+ 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,
|
||||
@@ -1119,7 +1370,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 +1549,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..4033bc848f
|
||||
--- /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(void);
|
||||
+
|
||||
+#endif /* PVE_BACKUP_H */
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index c581f1f238..3f092221ce 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -1019,6 +1019,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
|
||||
@@ -1032,6 +1035,7 @@
|
||||
'pbs-dirty-bitmap-migration': 'bool',
|
||||
'pbs-masterkey': 'bool',
|
||||
'pbs-library-version': 'str',
|
||||
+ 'backup-access-api': 'bool',
|
||||
'backup-fleecing': 'bool',
|
||||
'backup-max-workers': 'bool' } }
|
||||
|
||||
@@ -1098,6 +1102,51 @@
|
||||
##
|
||||
{ '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.
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'BackupAccessInfo',
|
||||
+ 'data': { 'node-name': 'str', 'device': 'str', 'size': 'size' } }
|
||||
+
|
||||
+##
|
||||
+# @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.
|
||||
+#
|
||||
+# @devlist: list of block device names (separated by ',', ';' or ':'). By
|
||||
+# default the backup includes all writable block devices.
|
||||
+#
|
||||
+# Returns: a list of @BackupAccessInfo, one for each device.
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'backup-access-setup',
|
||||
+ 'data': { 'target-id': 'str', '*devlist': 'str' },
|
||||
+ '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.
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'backup-access-teardown', 'data': { 'target-id': 'str' },
|
||||
+ 'coroutine': true }
|
||||
+
|
||||
##
|
||||
# @BlockDeviceTimedStats:
|
||||
#
|
||||
diff --git a/system/runstate.c b/system/runstate.c
|
||||
index c2c9afa905..6f93d7c2fb 100644
|
||||
--- a/system/runstate.c
|
||||
+++ b/system/runstate.c
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "sysemu/tpm.h"
|
||||
#include "trace.h"
|
||||
+#include "pve-backup.h"
|
||||
|
||||
static NotifierList exit_notifiers =
|
||||
NOTIFIER_LIST_INITIALIZER(exit_notifiers);
|
||||
@@ -920,6 +921,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();
|
||||
job_cancel_sync_all();
|
||||
bdrv_close_all();
|
||||
|
122
debian/patches/pve/0069-PVE-backup-factor-out-get_single_device_info-helper.patch
vendored
Normal file
122
debian/patches/pve/0069-PVE-backup-factor-out-get_single_device_info-helper.patch
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 3 Apr 2025 14:30:47 +0200
|
||||
Subject: [PATCH] PVE backup: factor out get_single_device_info() helper
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
[WB: free di and di->device_name on error]
|
||||
Sigend-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 90 +++++++++++++++++++++++++++++++---------------------
|
||||
1 file changed, 53 insertions(+), 37 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 091b5bd231..8b7414f057 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -760,6 +760,57 @@ 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
|
||||
@@ -778,45 +829,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);
|
||||
+ PVEBackupDevInfo *di = get_single_device_info(*d, device_uses_fleecing, errp);
|
||||
+ if (!di) {
|
||||
goto err;
|
||||
}
|
||||
- BlockDriverState *bs = blk_bs(blk);
|
||||
- if (!bdrv_co_is_inserted(bs)) {
|
||||
- error_setg(errp, "Device '%s' has no medium", *d);
|
||||
- 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++;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user