Compare commits
67 Commits
v5.2.0-11+
...
v6.2.0-11-
Author | SHA1 | Date | |
---|---|---|---|
f0bb2e89bd | |||
7564d2396c | |||
![]() |
4e4b9ab13f | ||
![]() |
39e84ba82d | ||
![]() |
4fd0fa7fb3 | ||
![]() |
539e333eaa | ||
![]() |
68569ea2ff | ||
![]() |
41aedfb6db | ||
![]() |
7bd4d8645a | ||
![]() |
ed3b5b8ab8 | ||
![]() |
7f4326d1dc | ||
![]() |
53bff441c5 | ||
![]() |
f9a4b1cea7 | ||
![]() |
dc265df350 | ||
![]() |
e0076597c6 | ||
![]() |
ee99c1f813 | ||
![]() |
58a5492e9c | ||
![]() |
e67b8b5bd9 | ||
![]() |
309b5c1694 | ||
![]() |
4ce5937f89 | ||
![]() |
f87d0523df | ||
![]() |
2fd4ea2813 | ||
![]() |
2653a5f029 | ||
![]() |
664ecf59a9 | ||
![]() |
4de9440f87 | ||
![]() |
9b348f8c6d | ||
![]() |
799cf8c5a3 | ||
![]() |
b02e62dba0 | ||
![]() |
fc03e1b6bf | ||
![]() |
c8ba14bed0 | ||
![]() |
daea534caa | ||
![]() |
27199bd753 | ||
![]() |
e050683663 | ||
![]() |
13184117e4 | ||
![]() |
aa4b14ea10 | ||
![]() |
3aa5b7598d | ||
![]() |
13d3e10aa6 | ||
![]() |
58c3533a58 | ||
![]() |
fe0542bed9 | ||
![]() |
f6d40bfdf4 | ||
![]() |
107132becc | ||
![]() |
4567474e95 | ||
![]() |
33a2d3a826 | ||
![]() |
2bf61c3eb6 | ||
![]() |
c07b2203b3 | ||
![]() |
ddbf7a872d | ||
![]() |
95c7156d1e | ||
![]() |
570d4ad51d | ||
![]() |
c5e8e7c998 | ||
![]() |
7cf6b60926 | ||
![]() |
50999525c6 | ||
![]() |
edbcc10a69 | ||
![]() |
cc707c362e | ||
![]() |
af64ed13eb | ||
![]() |
f376b2b9e2 | ||
![]() |
89fa943ef9 | ||
![]() |
26eee146bc | ||
![]() |
277d33454f | ||
![]() |
611b692181 | ||
![]() |
0114d3cd02 | ||
![]() |
bb3e494bdc | ||
![]() |
403f23a0c3 | ||
![]() |
db687e3cac | ||
![]() |
8893def37c | ||
![]() |
263fef5b4c | ||
![]() |
eb96e850ac | ||
![]() |
8dca018b68 |
2
Makefile
2
Makefile
@@ -49,7 +49,7 @@ update:
|
||||
|
||||
.PHONY: upload
|
||||
upload: $(DEBS)
|
||||
tar cf - ${DEBS} | ssh repoman@repo.proxmox.com upload --product pve --dist buster
|
||||
tar cf - ${DEBS} | ssh repoman@repo.proxmox.com upload --product pve --dist bullseye
|
||||
|
||||
.PHONY: distclean clean
|
||||
distclean: clean
|
||||
|
171
debian/changelog
vendored
171
debian/changelog
vendored
@@ -1,3 +1,174 @@
|
||||
pve-qemu-kvm (6.2.0-11+vitastor2) bullseye; urgency=medium
|
||||
|
||||
* Add bdrv_co_block_status implementation for QCOW2 export support
|
||||
|
||||
-- Vitaliy Filippov <vitalif@yourcmc.ru> Fri, 13 Jan 2023 20:14:59 +0300
|
||||
|
||||
pve-qemu-kvm (6.2.0-11+vitastor1) bullseye; urgency=medium
|
||||
|
||||
* Add Vitastor support
|
||||
|
||||
-- Vitaliy Filippov <vitalif@yourcmc.ru> Thu, 14 Dec 2022 18:13:59 +0300
|
||||
|
||||
pve-qemu-kvm (6.2.0-11) bullseye; urgency=medium
|
||||
|
||||
* add 'namespace' to BlockdevOptionsPbs for live-restore support
|
||||
|
||||
* vma: create: support 64KiB-unaligned input images like to improve backing
|
||||
up some VM templates
|
||||
|
||||
* block: alloc-track: avoid unlikely, but possible premature break
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 22 Jun 2022 15:54:54 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-10) bullseye; urgency=medium
|
||||
|
||||
* fix #4101: fix backup cancellation bug with iothreads
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 9 Jun 2022 16:35:51 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-9) bullseye; urgency=medium
|
||||
|
||||
* fix possible race conditions during cancellation of a PBS backup
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 08 Jun 2022 14:03:22 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-8) bullseye; urgency=medium
|
||||
|
||||
* revert "block/rbd: implement bdrv_co_block_status" to work around
|
||||
performance regression when backing up large RBD disk
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 19 May 2022 09:24:45 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-7) bullseye; urgency=medium
|
||||
|
||||
* Proxmox Backup Server namespace support
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 12 May 2022 16:05:56 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-6) bullseye; urgency=medium
|
||||
|
||||
* block/gluster: correctly set max_pdiscard which is int64_t to avoid
|
||||
triggering assertion
|
||||
|
||||
* ui/vnc.c: Fixed a deadlock bug
|
||||
|
||||
* display/qxl-render: fix race condition in qxl_cursor (CVE-2021-4207) and
|
||||
integer overflow in cursor_alloc (CVE-2021-4206)
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 11 May 2022 10:42:53 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-5) bullseye; urgency=medium
|
||||
|
||||
* vma: allow partial restore by skipping some disk
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 25 Apr 2022 10:13:46 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-4) bullseye; urgency=medium
|
||||
|
||||
* d/control: add libgbm to build dependencies
|
||||
|
||||
* d/control: add suggest dependency-hint for libgl1
|
||||
|
||||
* various stable backports:
|
||||
+ virtio-net: fix map leaking on error during receive
|
||||
+ memory: Fix incorrect calls of log_global_start/stop
|
||||
+ acpi: fix OEM ID/OEM Table ID padding
|
||||
+ vhost-vsock: detach the virqueue element in case of error
|
||||
+ vhost-user: remove VirtQ notifier restore
|
||||
+ vhost-user: fix VirtQ notifier cleanup
|
||||
+ virtio: fix the condition for iommu_platform not supported
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 22 Apr 2022 11:52:30 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-3) bullseye; urgency=medium
|
||||
|
||||
* cherry-pick fix for some manually added ACPI table SLIC entries via the
|
||||
custom args flag.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 15 Apr 2022 09:09:37 +0200
|
||||
|
||||
pve-qemu-kvm (6.2.0-2) bullseye; urgency=medium
|
||||
|
||||
* compile in virgl support
|
||||
|
||||
* enable zstd support
|
||||
|
||||
* drop sdl dependency (it was disabled at compile time already)
|
||||
|
||||
* recommend 'numactl'
|
||||
|
||||
* fix an issue with multi-disk backups where chunks would be written
|
||||
multiple times
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 03 Mar 2022 12:03:44 +0100
|
||||
|
||||
pve-qemu-kvm (6.2.0-1) bullseye; urgency=medium
|
||||
|
||||
* update to QEMU stable release 6.2.0
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 17 Feb 2022 06:23:14 +0100
|
||||
|
||||
pve-qemu-kvm (6.1.1-2) bullseye; urgency=medium
|
||||
|
||||
* vma: create: register all streams before entering coroutines to avoid that
|
||||
an early stream starts to write already before all got registered.
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 14 Feb 2022 15:53:15 +0100
|
||||
|
||||
pve-qemu-kvm (6.1.1-1) bullseye; urgency=medium
|
||||
|
||||
* update to 6.1.1 stable release
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 13 Jan 2022 10:57:43 +0100
|
||||
|
||||
pve-qemu-kvm (6.1.0-3) bullseye; urgency=medium
|
||||
|
||||
* fix #3738: cherry-pick "block: introduce max_hw_iov for use in scsi-
|
||||
generic
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 01 Dec 2021 15:35:43 +0100
|
||||
|
||||
pve-qemu-kvm (6.1.0-2) bullseye; urgency=medium
|
||||
|
||||
* avoid a possible segmentation fault during block (disk) mirror
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 16 Nov 2021 09:38:10 +0100
|
||||
|
||||
pve-qemu-kvm (6.1.0-1) bullseye; urgency=medium
|
||||
|
||||
* update to QEMU stable release 6.1.0
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 11 Oct 2021 15:15:19 +0200
|
||||
|
||||
pve-qemu-kvm (6.0.0-4) bullseye; urgency=medium
|
||||
|
||||
* drop the ancient workaround that force disabled SMM due to observing VM
|
||||
hangs on old kernel versions.
|
||||
|
||||
* monitor/qmp: fix race with clients disconnecting early resulting in other
|
||||
clients receiving a message with the (now wrong) ID of the former
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Mon, 06 Sep 2021 07:30:00 +0200
|
||||
|
||||
pve-qemu-kvm (6.0.0-3) bullseye; urgency=medium
|
||||
|
||||
* io_uring: resubmit when result is -EAGAIN
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Tue, 3 Aug 2021 15:01:31 +0200
|
||||
|
||||
pve-qemu-kvm (6.0.0-2) bullseye; urgency=medium
|
||||
|
||||
* enable io-uring support in QEMU builds
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Wed, 23 Jun 2021 11:03:54 +0200
|
||||
|
||||
pve-qemu-kvm (6.0.0-1) bullseye; urgency=medium
|
||||
|
||||
* update to QEMU stable release 6.0.0
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Fri, 28 May 2021 11:30:50 +0200
|
||||
|
||||
pve-qemu-kvm (5.2.0-11) bullseye; urgency=medium
|
||||
|
||||
* re-build for Proxmox VE 7 / Debian Bullseye
|
||||
|
13
debian/control
vendored
13
debian/control
vendored
@@ -10,7 +10,9 @@ Build-Depends: autotools-dev,
|
||||
libattr1-dev,
|
||||
libcap-ng-dev,
|
||||
libcurl4-gnutls-dev,
|
||||
libepoxy-dev,
|
||||
libfdt-dev,
|
||||
libgbm-dev,
|
||||
libglusterfs-dev (>= 5.2-2),
|
||||
libgnutls28-dev,
|
||||
libiscsi-dev (>= 1.12.0),
|
||||
@@ -20,18 +22,22 @@ Build-Depends: autotools-dev,
|
||||
libnuma-dev,
|
||||
libpci-dev,
|
||||
libpixman-1-dev,
|
||||
libproxmox-backup-qemu0-dev (>= 1.0.3-1),
|
||||
libproxmox-backup-qemu0-dev (>= 1.3.0-1),
|
||||
librbd-dev (>= 0.48),
|
||||
libsdl1.2-dev,
|
||||
libseccomp-dev,
|
||||
libspice-protocol-dev (>= 0.12.14~),
|
||||
libspice-server-dev (>= 0.14.0~),
|
||||
libsystemd-dev,
|
||||
liburing-dev,
|
||||
libusb-1.0-0-dev (>= 1.0.17-1),
|
||||
libusbredirparser-dev (>= 0.6-2),
|
||||
libvirglrenderer-dev,
|
||||
libzstd-dev,
|
||||
meson,
|
||||
python3-minimal,
|
||||
python3-sphinx,
|
||||
python3-sphinx-rtd-theme,
|
||||
quilt,
|
||||
texi2html,
|
||||
texinfo,
|
||||
@@ -43,7 +49,6 @@ Package: pve-qemu-kvm
|
||||
Architecture: any
|
||||
Depends: ceph-common (>= 0.48),
|
||||
iproute2,
|
||||
libaio1,
|
||||
libgfapi0 | glusterfs-common (>= 5.6),
|
||||
libgfchangelog0 | glusterfs-common (>= 5.6),
|
||||
libgfdb0 | glusterfs-common (>= 5.6),
|
||||
@@ -54,14 +59,14 @@ Depends: ceph-common (>= 0.48),
|
||||
libiscsi4 (>= 1.12.0) | libiscsi7,
|
||||
libjemalloc2,
|
||||
libjpeg62-turbo,
|
||||
libsdl1.2debian,
|
||||
libspice-server1 (>= 0.14.0~),
|
||||
libusb-1.0-0 (>= 1.0.17-1),
|
||||
libusbredirparser1 (>= 0.6-2),
|
||||
libuuid1,
|
||||
numactl,
|
||||
${misc:Depends},
|
||||
${shlibs:Depends},
|
||||
Recommends: numactl
|
||||
Suggests: libgl1
|
||||
Conflicts: kvm,
|
||||
pve-kvm,
|
||||
pve-qemu-kvm-2.6.18,
|
||||
|
2
debian/copyright
vendored
2
debian/copyright
vendored
@@ -25,7 +25,7 @@ License:
|
||||
|
||||
In particular, the QEMU virtual CPU core library (libqemu.a) is
|
||||
released under the GNU Lesser General Public License version 2 or later.
|
||||
On Debian systems, the complete text of the GNU Lesser General Public
|
||||
On Debian systems, the complete text of the GNU Lesser General Public
|
||||
License can be found in the file /usr/share/common-licenses/LGPL.
|
||||
|
||||
Some hardware device emulation sources and other QEMU functionality are
|
||||
|
@@ -26,16 +26,17 @@ Suggested-by: Ma Haocong <mahaocong@didichuxing.com>
|
||||
Signed-off-by: Ma Haocong <mahaocong@didichuxing.com>
|
||||
Signed-off-by: John Snow <jsnow@redhat.com>
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/mirror.c | 98 ++++++++++++++++++++++++++++++-------
|
||||
blockdev.c | 39 +++++++++++++--
|
||||
include/block/block_int.h | 4 +-
|
||||
qapi/block-core.json | 29 +++++++++--
|
||||
tests/test-block-iothread.c | 4 +-
|
||||
block/mirror.c | 98 +++++++++++++++++++++++++-------
|
||||
blockdev.c | 39 ++++++++++++-
|
||||
include/block/block_int.h | 4 +-
|
||||
qapi/block-core.json | 29 ++++++++--
|
||||
tests/unit/test-block-iothread.c | 4 +-
|
||||
5 files changed, 145 insertions(+), 29 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index 8e1ad6eceb..97843992c2 100644
|
||||
index efec2c7674..f7804638f9 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -50,7 +50,7 @@ typedef struct MirrorBlockJob {
|
||||
@@ -47,7 +48,7 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
BlockMirrorBackingMode backing_mode;
|
||||
/* Whether the target image requires explicit zero-initialization */
|
||||
bool zero_target;
|
||||
@@ -65,6 +65,8 @@ typedef struct MirrorBlockJob {
|
||||
@@ -64,6 +64,8 @@ typedef struct MirrorBlockJob {
|
||||
size_t buf_size;
|
||||
int64_t bdev_length;
|
||||
unsigned long *cow_bitmap;
|
||||
@@ -56,7 +57,7 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
BdrvDirtyBitmap *dirty_bitmap;
|
||||
BdrvDirtyBitmapIter *dbi;
|
||||
uint8_t *buf;
|
||||
@@ -677,7 +679,8 @@ static int mirror_exit_common(Job *job)
|
||||
@@ -695,7 +697,8 @@ static int mirror_exit_common(Job *job)
|
||||
bdrv_child_refresh_perms(mirror_top_bs, mirror_top_bs->backing,
|
||||
&error_abort);
|
||||
if (!abort && s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) {
|
||||
@@ -66,7 +67,7 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
BlockDriverState *unfiltered_target = bdrv_skip_filters(target_bs);
|
||||
|
||||
if (bdrv_cow_bs(unfiltered_target) != backing) {
|
||||
@@ -774,6 +777,16 @@ static void mirror_abort(Job *job)
|
||||
@@ -800,6 +803,16 @@ static void mirror_abort(Job *job)
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
static void coroutine_fn mirror_throttle(MirrorBlockJob *s)
|
||||
{
|
||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
||||
@@ -955,7 +968,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
|
||||
@@ -979,7 +992,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
|
||||
mirror_free_init(s);
|
||||
|
||||
s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
||||
@@ -93,23 +94,23 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
ret = mirror_dirty_init(s);
|
||||
if (ret < 0 || job_is_cancelled(&s->common.job)) {
|
||||
goto immediate_exit;
|
||||
@@ -1188,6 +1202,7 @@ static const BlockJobDriver mirror_job_driver = {
|
||||
@@ -1221,6 +1235,7 @@ static const BlockJobDriver mirror_job_driver = {
|
||||
.run = mirror_run,
|
||||
.prepare = mirror_prepare,
|
||||
.abort = mirror_abort,
|
||||
+ .clean = mirror_clean,
|
||||
.pause = mirror_pause,
|
||||
.complete = mirror_complete,
|
||||
},
|
||||
@@ -1203,6 +1218,7 @@ static const BlockJobDriver commit_active_job_driver = {
|
||||
.cancel = mirror_cancel,
|
||||
@@ -1237,6 +1252,7 @@ static const BlockJobDriver commit_active_job_driver = {
|
||||
.run = mirror_run,
|
||||
.prepare = mirror_prepare,
|
||||
.abort = mirror_abort,
|
||||
+ .clean = mirror_clean,
|
||||
.pause = mirror_pause,
|
||||
.complete = mirror_complete,
|
||||
},
|
||||
@@ -1550,7 +1566,10 @@ static BlockJob *mirror_start_job(
|
||||
.cancel = commit_active_cancel,
|
||||
@@ -1602,7 +1618,10 @@ static BlockJob *mirror_start_job(
|
||||
BlockCompletionFunc *cb,
|
||||
void *opaque,
|
||||
const BlockJobDriver *driver,
|
||||
@@ -121,12 +122,11 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
bool auto_complete, const char *filter_node_name,
|
||||
bool is_mirror, MirrorCopyMode copy_mode,
|
||||
Error **errp)
|
||||
@@ -1563,10 +1582,39 @@ static BlockJob *mirror_start_job(
|
||||
Error *local_err = NULL;
|
||||
@@ -1614,10 +1633,39 @@ static BlockJob *mirror_start_job(
|
||||
uint64_t target_perms, target_shared_perms;
|
||||
int ret;
|
||||
|
||||
- if (granularity == 0) {
|
||||
- granularity = bdrv_get_default_bitmap_granularity(target);
|
||||
+ if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
|
||||
+ error_setg(errp, "Sync mode '%s' not supported",
|
||||
+ MirrorSyncMode_str(sync_mode));
|
||||
@@ -147,8 +147,8 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
+ "sync mode '%s' is not compatible with bitmaps",
|
||||
+ MirrorSyncMode_str(sync_mode));
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ if (bitmap) {
|
||||
+ if (granularity) {
|
||||
+ error_setg(errp, "granularity (%d)"
|
||||
@@ -158,12 +158,13 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
+ }
|
||||
+ granularity = bdrv_dirty_bitmap_granularity(bitmap);
|
||||
+ } else if (granularity == 0) {
|
||||
+ granularity = bdrv_get_default_bitmap_granularity(target);
|
||||
+ }
|
||||
granularity = bdrv_get_default_bitmap_granularity(target);
|
||||
}
|
||||
-
|
||||
assert(is_power_of_2(granularity));
|
||||
|
||||
if (buf_size < 0) {
|
||||
@@ -1705,7 +1753,9 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1755,7 +1803,9 @@ static BlockJob *mirror_start_job(
|
||||
s->replaces = g_strdup(replaces);
|
||||
s->on_source_error = on_source_error;
|
||||
s->on_target_error = on_target_error;
|
||||
@@ -174,7 +175,7 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
s->backing_mode = backing_mode;
|
||||
s->zero_target = zero_target;
|
||||
s->copy_mode = copy_mode;
|
||||
@@ -1726,6 +1776,18 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1776,6 +1826,18 @@ static BlockJob *mirror_start_job(
|
||||
bdrv_disable_dirty_bitmap(s->dirty_bitmap);
|
||||
}
|
||||
|
||||
@@ -193,7 +194,7 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
ret = block_job_add_bdrv(&s->common, "source", bs, 0,
|
||||
BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE |
|
||||
BLK_PERM_CONSISTENT_READ,
|
||||
@@ -1803,6 +1865,9 @@ fail:
|
||||
@@ -1853,6 +1915,9 @@ fail:
|
||||
if (s->dirty_bitmap) {
|
||||
bdrv_release_dirty_bitmap(s->dirty_bitmap);
|
||||
}
|
||||
@@ -203,7 +204,7 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
job_early_fail(&s->common.job);
|
||||
}
|
||||
|
||||
@@ -1820,29 +1885,23 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
|
||||
@@ -1870,29 +1935,23 @@ 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,
|
||||
@@ -238,7 +239,7 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
}
|
||||
|
||||
BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
|
||||
@@ -1868,7 +1927,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
|
||||
@@ -1917,7 +1976,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
|
||||
job_id, bs, creation_flags, base, NULL, speed, 0, 0,
|
||||
MIRROR_LEAVE_BACKING_CHAIN, false,
|
||||
on_error, on_error, true, cb, opaque,
|
||||
@@ -246,13 +247,13 @@ index 8e1ad6eceb..97843992c2 100644
|
||||
+ &commit_active_job_driver, MIRROR_SYNC_MODE_FULL,
|
||||
+ NULL, 0, base, auto_complete,
|
||||
filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND,
|
||||
&local_err);
|
||||
if (local_err) {
|
||||
errp);
|
||||
if (!job) {
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index fe6fb5dc1d..394920613d 100644
|
||||
index b35072644e..9940116fe0 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -2930,6 +2930,10 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2956,6 +2956,10 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
BlockDriverState *target,
|
||||
bool has_replaces, const char *replaces,
|
||||
enum MirrorSyncMode sync,
|
||||
@@ -263,7 +264,7 @@ index fe6fb5dc1d..394920613d 100644
|
||||
BlockMirrorBackingMode backing_mode,
|
||||
bool zero_target,
|
||||
bool has_speed, int64_t speed,
|
||||
@@ -2949,6 +2953,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -2975,6 +2979,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
{
|
||||
BlockDriverState *unfiltered_bs;
|
||||
int job_flags = JOB_DEFAULT;
|
||||
@@ -271,7 +272,7 @@ index fe6fb5dc1d..394920613d 100644
|
||||
|
||||
if (!has_speed) {
|
||||
speed = 0;
|
||||
@@ -3003,6 +3008,29 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -3029,6 +3034,29 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
sync = MIRROR_SYNC_MODE_FULL;
|
||||
}
|
||||
|
||||
@@ -301,7 +302,7 @@ index fe6fb5dc1d..394920613d 100644
|
||||
if (!has_replaces) {
|
||||
/* We want to mirror from @bs, but keep implicit filters on top */
|
||||
unfiltered_bs = bdrv_skip_implicit_filters(bs);
|
||||
@@ -3049,8 +3077,8 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -3075,8 +3103,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,
|
||||
@@ -312,7 +313,7 @@ index fe6fb5dc1d..394920613d 100644
|
||||
on_source_error, on_target_error, unmap, filter_node_name,
|
||||
copy_mode, errp);
|
||||
}
|
||||
@@ -3195,6 +3223,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
||||
@@ -3221,6 +3249,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
||||
|
||||
blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, target_bs,
|
||||
arg->has_replaces, arg->replaces, arg->sync,
|
||||
@@ -321,7 +322,7 @@ index fe6fb5dc1d..394920613d 100644
|
||||
backing_mode, zero_target,
|
||||
arg->has_speed, arg->speed,
|
||||
arg->has_granularity, arg->granularity,
|
||||
@@ -3216,6 +3246,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
|
||||
@@ -3242,6 +3272,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
|
||||
const char *device, const char *target,
|
||||
bool has_replaces, const char *replaces,
|
||||
MirrorSyncMode sync,
|
||||
@@ -330,7 +331,7 @@ index fe6fb5dc1d..394920613d 100644
|
||||
bool has_speed, int64_t speed,
|
||||
bool has_granularity, uint32_t granularity,
|
||||
bool has_buf_size, int64_t buf_size,
|
||||
@@ -3265,7 +3297,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
|
||||
@@ -3291,7 +3323,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
|
||||
}
|
||||
|
||||
blockdev_mirror_common(has_job_id ? job_id : NULL, bs, target_bs,
|
||||
@@ -341,10 +342,10 @@ index fe6fb5dc1d..394920613d 100644
|
||||
has_granularity, granularity,
|
||||
has_buf_size, buf_size,
|
||||
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
||||
index 95d9333be1..6f8eda629a 100644
|
||||
index f4c75e8ba9..ee0aeb1414 100644
|
||||
--- a/include/block/block_int.h
|
||||
+++ b/include/block/block_int.h
|
||||
@@ -1230,7 +1230,9 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
|
||||
@@ -1287,7 +1287,9 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
|
||||
BlockDriverState *target, const char *replaces,
|
||||
int creation_flags, int64_t speed,
|
||||
uint32_t granularity, int64_t buf_size,
|
||||
@@ -356,10 +357,10 @@ index 95d9333be1..6f8eda629a 100644
|
||||
BlockdevOnError on_source_error,
|
||||
BlockdevOnError on_target_error,
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 04ad80bc1e..9db3120716 100644
|
||||
index 1d3dd9cb48..da5dca1e3b 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -1971,10 +1971,19 @@
|
||||
@@ -1995,10 +1995,19 @@
|
||||
# (all the disk, only the sectors allocated in the topmost image, or
|
||||
# only new I/O).
|
||||
#
|
||||
@@ -380,7 +381,7 @@ index 04ad80bc1e..9db3120716 100644
|
||||
#
|
||||
# @buf-size: maximum amount of data in flight from source to
|
||||
# target (since 1.4).
|
||||
@@ -2012,7 +2021,9 @@
|
||||
@@ -2036,7 +2045,9 @@
|
||||
{ 'struct': 'DriveMirror',
|
||||
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
|
||||
'*format': 'str', '*node-name': 'str', '*replaces': 'str',
|
||||
@@ -391,7 +392,7 @@ index 04ad80bc1e..9db3120716 100644
|
||||
'*speed': 'int', '*granularity': 'uint32',
|
||||
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
|
||||
'*on-target-error': 'BlockdevOnError',
|
||||
@@ -2280,10 +2291,19 @@
|
||||
@@ -2308,10 +2319,19 @@
|
||||
# (all the disk, only the sectors allocated in the topmost image, or
|
||||
# only new I/O).
|
||||
#
|
||||
@@ -412,7 +413,7 @@ index 04ad80bc1e..9db3120716 100644
|
||||
#
|
||||
# @buf-size: maximum amount of data in flight from source to
|
||||
# target
|
||||
@@ -2332,7 +2352,8 @@
|
||||
@@ -2360,7 +2380,8 @@
|
||||
{ 'command': 'blockdev-mirror',
|
||||
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
|
||||
'*replaces': 'str',
|
||||
@@ -422,11 +423,11 @@ index 04ad80bc1e..9db3120716 100644
|
||||
'*speed': 'int', '*granularity': 'uint32',
|
||||
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
|
||||
'*on-target-error': 'BlockdevOnError',
|
||||
diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c
|
||||
index 3f866a35c6..500ede71c8 100644
|
||||
--- a/tests/test-block-iothread.c
|
||||
+++ b/tests/test-block-iothread.c
|
||||
@@ -623,8 +623,8 @@ static void test_propagate_mirror(void)
|
||||
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
|
||||
index aea660aeed..22b9770a3e 100644
|
||||
--- a/tests/unit/test-block-iothread.c
|
||||
+++ b/tests/unit/test-block-iothread.c
|
||||
@@ -626,8 +626,8 @@ static void test_propagate_mirror(void)
|
||||
|
||||
/* Start a mirror job */
|
||||
mirror_start("job0", src, target, NULL, JOB_DEFAULT, 0, 0, 0,
|
||||
|
@@ -18,15 +18,16 @@ incremental backup modes; we can use this bitmap to later refresh a
|
||||
successfully created mirror.
|
||||
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/mirror.c | 24 ++++++++++++++++++------
|
||||
1 file changed, 18 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index 97843992c2..d1cce079da 100644
|
||||
index f7804638f9..4f5f74e2cf 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -654,8 +654,6 @@ static int mirror_exit_common(Job *job)
|
||||
@@ -672,8 +672,6 @@ static int mirror_exit_common(Job *job)
|
||||
bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs);
|
||||
}
|
||||
|
||||
@@ -35,7 +36,7 @@ index 97843992c2..d1cce079da 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);
|
||||
@@ -755,6 +753,18 @@ static int mirror_exit_common(Job *job)
|
||||
@@ -781,6 +779,18 @@ static int mirror_exit_common(Job *job)
|
||||
blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort);
|
||||
blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort);
|
||||
|
||||
@@ -54,7 +55,7 @@ index 97843992c2..d1cce079da 100644
|
||||
bs_opaque->job = NULL;
|
||||
|
||||
bdrv_drained_end(src);
|
||||
@@ -1592,10 +1602,6 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1643,10 +1653,6 @@ static BlockJob *mirror_start_job(
|
||||
" sync mode",
|
||||
MirrorSyncMode_str(sync_mode));
|
||||
return NULL;
|
||||
@@ -65,7 +66,7 @@ index 97843992c2..d1cce079da 100644
|
||||
}
|
||||
} else if (bitmap) {
|
||||
error_setg(errp,
|
||||
@@ -1612,6 +1618,12 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1663,6 +1669,12 @@ static BlockJob *mirror_start_job(
|
||||
return NULL;
|
||||
}
|
||||
granularity = bdrv_dirty_bitmap_granularity(bitmap);
|
||||
|
@@ -10,15 +10,16 @@ as one without the other does not make much sense with the current set
|
||||
of modes.
|
||||
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
blockdev.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index 394920613d..4f8bd38b58 100644
|
||||
index 9940116fe0..b113e57d68 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -3029,6 +3029,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -3055,6 +3055,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) {
|
||||
return;
|
||||
}
|
||||
|
@@ -10,15 +10,16 @@ since sync_bitmap is busy at the point of merging, and we checked access
|
||||
beforehand.
|
||||
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/mirror.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
block/mirror.c | 11 ++++-------
|
||||
1 file changed, 4 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index d1cce079da..e6140cf018 100644
|
||||
index 4f5f74e2cf..7024f3bbf0 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -759,8 +759,8 @@ static int mirror_exit_common(Job *job)
|
||||
@@ -785,8 +785,8 @@ static int mirror_exit_common(Job *job)
|
||||
job->ret == 0 && ret == 0)) {
|
||||
/* Success; synchronize copy back to sync. */
|
||||
bdrv_clear_dirty_bitmap(s->sync_bitmap, NULL);
|
||||
@@ -29,14 +30,17 @@ index d1cce079da..e6140cf018 100644
|
||||
}
|
||||
}
|
||||
bdrv_release_dirty_bitmap(s->dirty_bitmap);
|
||||
@@ -1793,8 +1793,8 @@ static BlockJob *mirror_start_job(
|
||||
@@ -1843,11 +1843,8 @@ static BlockJob *mirror_start_job(
|
||||
}
|
||||
|
||||
if (s->sync_mode == MIRROR_SYNC_MODE_BITMAP) {
|
||||
- bdrv_merge_dirty_bitmap(s->dirty_bitmap, s->sync_bitmap,
|
||||
- NULL, &local_err);
|
||||
- if (local_err) {
|
||||
- goto fail;
|
||||
- }
|
||||
+ bdrv_dirty_bitmap_merge_internal(s->dirty_bitmap, s->sync_bitmap,
|
||||
+ NULL, true);
|
||||
if (local_err) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
ret = block_job_add_bdrv(&s->common, "source", bs, 0,
|
||||
|
@@ -20,11 +20,11 @@ intentionally keeping copyright and ownership of original test case to
|
||||
honor provenance.
|
||||
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
tests/qemu-iotests/384 | 547 +++++++
|
||||
tests/qemu-iotests/384.out | 2846 ++++++++++++++++++++++++++++++++++++
|
||||
tests/qemu-iotests/group | 1 +
|
||||
3 files changed, 3394 insertions(+)
|
||||
2 files changed, 3393 insertions(+)
|
||||
create mode 100755 tests/qemu-iotests/384
|
||||
create mode 100644 tests/qemu-iotests/384.out
|
||||
|
||||
@@ -3433,15 +3433,3 @@ index 0000000000..9b7408b6d6
|
||||
+{"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
|
||||
+{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
|
||||
+
|
||||
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
|
||||
index 2960dff728..952dceba1f 100644
|
||||
--- a/tests/qemu-iotests/group
|
||||
+++ b/tests/qemu-iotests/group
|
||||
@@ -270,6 +270,7 @@
|
||||
253 rw quick
|
||||
254 rw backing quick
|
||||
255 rw quick
|
||||
+384 rw
|
||||
256 rw auto quick
|
||||
257 rw
|
||||
258 rw quick
|
||||
|
@@ -11,6 +11,7 @@ mode was never available for drive-mirror, it makes the interface more
|
||||
uniform w.r.t. backup block jobs.
|
||||
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/mirror.c | 28 +++------------
|
||||
blockdev.c | 29 +++++++++++++++
|
||||
@@ -18,11 +19,11 @@ Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
3 files changed, 70 insertions(+), 59 deletions(-)
|
||||
|
||||
diff --git a/block/mirror.c b/block/mirror.c
|
||||
index e6140cf018..3a08239a78 100644
|
||||
index 7024f3bbf0..6211ff22fc 100644
|
||||
--- a/block/mirror.c
|
||||
+++ b/block/mirror.c
|
||||
@@ -1592,31 +1592,13 @@ static BlockJob *mirror_start_job(
|
||||
Error *local_err = NULL;
|
||||
@@ -1643,31 +1643,13 @@ static BlockJob *mirror_start_job(
|
||||
uint64_t target_perms, target_shared_perms;
|
||||
int ret;
|
||||
|
||||
- if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
|
||||
@@ -59,10 +60,10 @@ index e6140cf018..3a08239a78 100644
|
||||
|
||||
if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index 4f8bd38b58..a40c6fd0f6 100644
|
||||
index b113e57d68..4be0863050 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -3008,7 +3008,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
@@ -3034,7 +3034,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
||||
sync = MIRROR_SYNC_MODE_FULL;
|
||||
}
|
||||
|
||||
|
@@ -1,33 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
Date: Mon, 14 Sep 2020 19:32:21 +0200
|
||||
Subject: [PATCH] Revert "qemu-img convert: Don't pre-zero images"
|
||||
|
||||
This reverts commit edafc70c0c8510862f2f213a3acf7067113bcd08.
|
||||
|
||||
As it correlates with causing issues on LVM allocation
|
||||
https://bugzilla.proxmox.com/show_bug.cgi?id=3002
|
||||
---
|
||||
qemu-img.c | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 8bdea40b58..f9050bfaad 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -2104,6 +2104,15 @@ static int convert_do_copy(ImgConvertState *s)
|
||||
s->has_zero_init = bdrv_has_zero_init(blk_bs(s->target));
|
||||
}
|
||||
|
||||
+ if (!s->has_zero_init && !s->target_has_backing &&
|
||||
+ bdrv_can_write_zeroes_with_unmap(blk_bs(s->target)))
|
||||
+ {
|
||||
+ ret = blk_make_zero(s->target, BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK);
|
||||
+ if (ret == 0) {
|
||||
+ s->has_zero_init = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/* Allocate buffer for copied data. For compressed images, only one cluster
|
||||
* can be copied at a time. */
|
||||
if (s->compressed) {
|
206
debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
vendored
Normal file
206
debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Mon, 23 Aug 2021 11:28:32 +0200
|
||||
Subject: [PATCH] monitor/qmp: fix race with clients disconnecting early
|
||||
|
||||
The following sequence can produce a race condition that results in
|
||||
responses meant for different clients being sent to the wrong one:
|
||||
|
||||
(QMP, no OOB)
|
||||
1) client A connects
|
||||
2) client A sends 'qmp_capabilities'
|
||||
3) 'qmp_dispatch' runs in coroutine, schedules out to
|
||||
'do_qmp_dispatch_bh' and yields
|
||||
4) client A disconnects (i.e. aborts, crashes, etc...)
|
||||
5) client B connects
|
||||
6) 'do_qmp_dispatch_bh' runs 'qmp_capabilities' and wakes calling coroutine
|
||||
7) capabilities are now set and 'mon->commands' is set to '&qmp_commands'
|
||||
8) 'qmp_dispatch' returns to 'monitor_qmp_dispatch'
|
||||
9) success message is sent to client B *without it ever having sent
|
||||
'qmp_capabilities' itself*
|
||||
9a) even if client B ignores it, it will now presumably send it's own
|
||||
greeting, which will error because caps are already set
|
||||
|
||||
The fix proposed here uses an atomic, sequential connection number
|
||||
stored in the MonitorQMP struct, which is incremented everytime a new
|
||||
client connects. Since it is not changed on CHR_EVENT_CLOSED, the
|
||||
behaviour of allowing a client to disconnect only one side of the
|
||||
connection is retained.
|
||||
|
||||
The connection_nr needs to be exposed outside of the monitor subsystem,
|
||||
since qmp_dispatch lives in qapi code. It needs to be checked twice,
|
||||
once for actually running the command in the BH (fixes 7), and once for
|
||||
sending back a response (fixes 9).
|
||||
|
||||
This satisfies my local reproducer - using multiple clients constantly
|
||||
looping to open a connection, send the greeting, then exiting no longer
|
||||
crashes other, normally behaving clients with unrelated responses.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
include/monitor/monitor.h | 1 +
|
||||
monitor/monitor-internal.h | 7 +++++++
|
||||
monitor/monitor.c | 15 +++++++++++++++
|
||||
monitor/qmp.c | 15 ++++++++++++++-
|
||||
qapi/qmp-dispatch.c | 21 +++++++++++++++++----
|
||||
stubs/monitor-core.c | 5 +++++
|
||||
6 files changed, 59 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
|
||||
index 12d395d62d..b182943324 100644
|
||||
--- a/include/monitor/monitor.h
|
||||
+++ b/include/monitor/monitor.h
|
||||
@@ -16,6 +16,7 @@ extern QemuOptsList qemu_mon_opts;
|
||||
Monitor *monitor_cur(void);
|
||||
Monitor *monitor_set_cur(Coroutine *co, Monitor *mon);
|
||||
bool monitor_cur_is_qmp(void);
|
||||
+int monitor_get_connection_nr(const Monitor *mon);
|
||||
|
||||
void monitor_init_globals(void);
|
||||
void monitor_init_globals_core(void);
|
||||
diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
|
||||
index 3da3f86c6a..9953e0cd2d 100644
|
||||
--- a/monitor/monitor-internal.h
|
||||
+++ b/monitor/monitor-internal.h
|
||||
@@ -151,6 +151,13 @@ typedef struct {
|
||||
QemuMutex qmp_queue_lock;
|
||||
/* Input queue that holds all the parsed QMP requests */
|
||||
GQueue *qmp_requests;
|
||||
+
|
||||
+ /*
|
||||
+ * A sequential number that gets incremented on every new CHR_EVENT_OPENED.
|
||||
+ * Used to avoid leftover responses in BHs from being sent to the wrong
|
||||
+ * client. Access with atomics.
|
||||
+ */
|
||||
+ int connection_nr;
|
||||
} MonitorQMP;
|
||||
|
||||
/**
|
||||
diff --git a/monitor/monitor.c b/monitor/monitor.c
|
||||
index 21c7a68758..ad9813567a 100644
|
||||
--- a/monitor/monitor.c
|
||||
+++ b/monitor/monitor.c
|
||||
@@ -135,6 +135,21 @@ bool monitor_cur_is_qmp(void)
|
||||
return cur_mon && monitor_is_qmp(cur_mon);
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * If @mon is a QMP monitor, return the connection_nr, otherwise -1.
|
||||
+ */
|
||||
+int monitor_get_connection_nr(const Monitor *mon)
|
||||
+{
|
||||
+ MonitorQMP *qmp_mon;
|
||||
+
|
||||
+ if (!monitor_is_qmp(mon)) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ qmp_mon = container_of(mon, MonitorQMP, common);
|
||||
+ return qatomic_read(&qmp_mon->connection_nr);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* Is @mon is using readline?
|
||||
* Note: not all HMP monitors use readline, e.g., gdbserver has a
|
||||
diff --git a/monitor/qmp.c b/monitor/qmp.c
|
||||
index 092c527b6f..6b8cfcf6d8 100644
|
||||
--- a/monitor/qmp.c
|
||||
+++ b/monitor/qmp.c
|
||||
@@ -141,6 +141,8 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
QDict *rsp;
|
||||
QDict *error;
|
||||
|
||||
+ int conn_nr_before = qatomic_read(&mon->connection_nr);
|
||||
+
|
||||
rsp = qmp_dispatch(mon->commands, req, qmp_oob_enabled(mon),
|
||||
&mon->common);
|
||||
|
||||
@@ -156,7 +158,17 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)
|
||||
}
|
||||
}
|
||||
|
||||
- monitor_qmp_respond(mon, rsp);
|
||||
+ /*
|
||||
+ * qmp_dispatch might have yielded and waited for a BH, in which case there
|
||||
+ * is a chance a new client connected in the meantime - if this happened,
|
||||
+ * the command will not have been executed, but we also need to ensure that
|
||||
+ * we don't send back a corresponding response on a line that no longer
|
||||
+ * belongs to this request.
|
||||
+ */
|
||||
+ if (conn_nr_before == qatomic_read(&mon->connection_nr)) {
|
||||
+ monitor_qmp_respond(mon, rsp);
|
||||
+ }
|
||||
+
|
||||
qobject_unref(rsp);
|
||||
}
|
||||
|
||||
@@ -444,6 +456,7 @@ static void monitor_qmp_event(void *opaque, QEMUChrEvent event)
|
||||
|
||||
switch (event) {
|
||||
case CHR_EVENT_OPENED:
|
||||
+ qatomic_inc_fetch(&mon->connection_nr);
|
||||
mon->commands = &qmp_cap_negotiation_commands;
|
||||
monitor_qmp_caps_reset(mon);
|
||||
data = qmp_greeting(mon);
|
||||
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
|
||||
index d378bccac7..fb8936e7cd 100644
|
||||
--- a/qapi/qmp-dispatch.c
|
||||
+++ b/qapi/qmp-dispatch.c
|
||||
@@ -118,16 +118,28 @@ typedef struct QmpDispatchBH {
|
||||
QObject **ret;
|
||||
Error **errp;
|
||||
Coroutine *co;
|
||||
+ int conn_nr;
|
||||
} QmpDispatchBH;
|
||||
|
||||
static void do_qmp_dispatch_bh(void *opaque)
|
||||
{
|
||||
QmpDispatchBH *data = opaque;
|
||||
|
||||
- assert(monitor_cur() == NULL);
|
||||
- monitor_set_cur(qemu_coroutine_self(), data->cur_mon);
|
||||
- data->cmd->fn(data->args, data->ret, data->errp);
|
||||
- monitor_set_cur(qemu_coroutine_self(), NULL);
|
||||
+ /*
|
||||
+ * A QMP monitor tracks it's client with a connection number, if this
|
||||
+ * changes during the scheduling delay of this BH, we must not execute the
|
||||
+ * command. Otherwise a badly placed 'qmp_capabilities' might affect the
|
||||
+ * connection state of a client it was never meant for.
|
||||
+ */
|
||||
+ if (data->conn_nr == monitor_get_connection_nr(data->cur_mon)) {
|
||||
+ assert(monitor_cur() == NULL);
|
||||
+ monitor_set_cur(qemu_coroutine_self(), data->cur_mon);
|
||||
+ data->cmd->fn(data->args, data->ret, data->errp);
|
||||
+ monitor_set_cur(qemu_coroutine_self(), NULL);
|
||||
+ } else {
|
||||
+ error_setg(data->errp, "active monitor connection changed");
|
||||
+ }
|
||||
+
|
||||
aio_co_wake(data->co);
|
||||
}
|
||||
|
||||
@@ -232,6 +244,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
|
||||
.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,
|
||||
&data);
|
||||
diff --git a/stubs/monitor-core.c b/stubs/monitor-core.c
|
||||
index d058a2a00d..3290b58120 100644
|
||||
--- a/stubs/monitor-core.c
|
||||
+++ b/stubs/monitor-core.c
|
||||
@@ -13,6 +13,11 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+int monitor_get_connection_nr(const Monitor *mon)
|
||||
+{
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
|
||||
{
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Thu, 28 Jan 2021 15:19:51 +0100
|
||||
Subject: [PATCH] docs: don't install man page if guest agent is disabled
|
||||
|
||||
No sense outputting the qemu-ga and qemu-ga-ref man pages when the guest
|
||||
agent binary itself is disabled. This mirrors behaviour from before the
|
||||
meson switch.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
docs/meson.build | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/docs/meson.build b/docs/meson.build
|
||||
index ebd85d59f9..cc6f5007f8 100644
|
||||
--- a/docs/meson.build
|
||||
+++ b/docs/meson.build
|
||||
@@ -46,6 +46,8 @@ if build_docs
|
||||
meson.source_root() / 'docs/sphinx/qmp_lexer.py',
|
||||
qapi_gen_depends ]
|
||||
|
||||
+ have_ga = have_tools and config_host.has_key('CONFIG_GUEST_AGENT')
|
||||
+
|
||||
configure_file(output: 'index.html',
|
||||
input: files('index.html.in'),
|
||||
configuration: {'VERSION': meson.project_version()},
|
||||
@@ -53,8 +55,8 @@ if build_docs
|
||||
manuals = [ 'devel', 'interop', 'tools', 'specs', 'system', 'user' ]
|
||||
man_pages = {
|
||||
'interop' : {
|
||||
- 'qemu-ga.8': (have_tools ? 'man8' : ''),
|
||||
- 'qemu-ga-ref.7': 'man7',
|
||||
+ 'qemu-ga.8': (have_ga ? 'man8' : ''),
|
||||
+ 'qemu-ga-ref.7': (have_ga ? 'man7' : ''),
|
||||
'qemu-qmp-ref.7': 'man7',
|
||||
},
|
||||
'tools': {
|
55
debian/patches/extra/0002-monitor-hmp-add-support-for-flag-argument-with-value.patch
vendored
Normal file
55
debian/patches/extra/0002-monitor-hmp-add-support-for-flag-argument-with-value.patch
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Wed, 1 Sep 2021 16:51:04 +0200
|
||||
Subject: [PATCH] monitor/hmp: add support for flag argument with value
|
||||
|
||||
Adds support for the "-xS" parameter type, where "-x" denotes a flag
|
||||
name and the "S" suffix indicates that this flag is supposed to take an
|
||||
arbitrary string parameter.
|
||||
|
||||
These parameters are always optional, the entry in the qdict will be
|
||||
omitted if the flag is not given.
|
||||
|
||||
Reviewed-by: Eric Blake <eblake@redhat.com>
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
monitor/hmp.c | 17 ++++++++++++++++-
|
||||
1 file changed, 16 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/monitor/hmp.c b/monitor/hmp.c
|
||||
index b20737e63c..b29dbb1833 100644
|
||||
--- a/monitor/hmp.c
|
||||
+++ b/monitor/hmp.c
|
||||
@@ -981,6 +981,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
|
||||
{
|
||||
const char *tmp = p;
|
||||
int skip_key = 0;
|
||||
+ int ret;
|
||||
/* option */
|
||||
|
||||
c = *typestr++;
|
||||
@@ -1003,8 +1004,22 @@ static QDict *monitor_parse_arguments(Monitor *mon,
|
||||
}
|
||||
if (skip_key) {
|
||||
p = tmp;
|
||||
+ } else if (*typestr == 'S') {
|
||||
+ /* has option with string value */
|
||||
+ typestr++;
|
||||
+ tmp = p++;
|
||||
+ while (qemu_isspace(*p)) {
|
||||
+ p++;
|
||||
+ }
|
||||
+ ret = get_str(buf, sizeof(buf), &p);
|
||||
+ if (ret < 0) {
|
||||
+ monitor_printf(mon, "%s: value expected for -%c\n",
|
||||
+ cmd->name, *tmp);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+ qdict_put_str(qdict, key, buf);
|
||||
} else {
|
||||
- /* has option */
|
||||
+ /* has boolean option */
|
||||
p++;
|
||||
qdict_put_bool(qdict, key, true);
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Thu, 4 Feb 2021 17:06:19 +0100
|
||||
Subject: [PATCH] migration: only check page size match if RAM postcopy is
|
||||
enabled
|
||||
|
||||
Postcopy may also be advised for dirty-bitmap migration only, in which
|
||||
case the remote page size will not be available and we'll instead read
|
||||
bogus data, blocking migration with a mismatch error if the VM uses
|
||||
hugepages.
|
||||
|
||||
Fixes: 58110f0acb ("migration: split common postcopy out of ram postcopy")
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
---
|
||||
migration/ram.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/migration/ram.c b/migration/ram.c
|
||||
index 7811cde643..6ace15261c 100644
|
||||
--- a/migration/ram.c
|
||||
+++ b/migration/ram.c
|
||||
@@ -3521,7 +3521,7 @@ static int ram_load_precopy(QEMUFile *f)
|
||||
}
|
||||
}
|
||||
/* For postcopy we need to check hugepage sizes match */
|
||||
- if (postcopy_advised &&
|
||||
+ if (postcopy_advised && migrate_postcopy_ram() &&
|
||||
block->page_size != qemu_host_page_size) {
|
||||
uint64_t remote_page_size = qemu_get_be64(f);
|
||||
if (remote_page_size != block->page_size) {
|
477
debian/patches/extra/0003-monitor-refactor-set-expire_password-and-allow-VNC-d.patch
vendored
Normal file
477
debian/patches/extra/0003-monitor-refactor-set-expire_password-and-allow-VNC-d.patch
vendored
Normal file
@@ -0,0 +1,477 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Wed, 25 Aug 2021 11:14:13 +0200
|
||||
Subject: [PATCH] monitor: refactor set/expire_password and allow VNC display
|
||||
id
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
It is possible to specify more than one VNC server on the command line,
|
||||
either with an explicit ID or the auto-generated ones à la "default",
|
||||
"vnc2", "vnc3", ...
|
||||
|
||||
It is not possible to change the password on one of these extra VNC
|
||||
displays though. Fix this by adding a "display" parameter to the
|
||||
"set_password" and "expire_password" QMP and HMP commands.
|
||||
|
||||
For HMP, the display is specified using the "-d" value flag.
|
||||
|
||||
For QMP, the schema is updated to explicitly express the supported
|
||||
variants of the commands with protocol-discriminated unions.
|
||||
|
||||
Suggested-by: Eric Blake <eblake@redhat.com>
|
||||
Suggested-by: Markus Armbruster <armbru@redhat.com>
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
hmp-commands.hx | 24 ++++---
|
||||
monitor/hmp-cmds.c | 57 +++++++++++++++-
|
||||
monitor/qmp-cmds.c | 62 ++++++-----------
|
||||
qapi/ui.json | 165 ++++++++++++++++++++++++++++++++++++++-------
|
||||
4 files changed, 231 insertions(+), 77 deletions(-)
|
||||
|
||||
diff --git a/hmp-commands.hx b/hmp-commands.hx
|
||||
index 70a9136ac2..5efb47fc32 100644
|
||||
--- a/hmp-commands.hx
|
||||
+++ b/hmp-commands.hx
|
||||
@@ -1514,33 +1514,35 @@ ERST
|
||||
|
||||
{
|
||||
.name = "set_password",
|
||||
- .args_type = "protocol:s,password:s,connected:s?",
|
||||
- .params = "protocol password action-if-connected",
|
||||
+ .args_type = "protocol:s,password:s,display:-dS,connected:s?",
|
||||
+ .params = "protocol password [-d display] [action-if-connected]",
|
||||
.help = "set spice/vnc password",
|
||||
.cmd = hmp_set_password,
|
||||
},
|
||||
|
||||
SRST
|
||||
-``set_password [ vnc | spice ] password [ action-if-connected ]``
|
||||
- Change spice/vnc password. *action-if-connected* specifies what
|
||||
- should happen in case a connection is established: *fail* makes the
|
||||
- password change fail. *disconnect* changes the password and
|
||||
+``set_password [ vnc | spice ] password [ -d display ] [ action-if-connected ]``
|
||||
+ Change spice/vnc password. *display* can be used with 'vnc' to specify
|
||||
+ which display to set the password on. *action-if-connected* specifies
|
||||
+ what should happen in case a connection is established: *fail* makes
|
||||
+ the password change fail. *disconnect* changes the password and
|
||||
disconnects the client. *keep* changes the password and keeps the
|
||||
connection up. *keep* is the default.
|
||||
ERST
|
||||
|
||||
{
|
||||
.name = "expire_password",
|
||||
- .args_type = "protocol:s,time:s",
|
||||
- .params = "protocol time",
|
||||
+ .args_type = "protocol:s,time:s,display:-dS",
|
||||
+ .params = "protocol time [-d display]",
|
||||
.help = "set spice/vnc password expire-time",
|
||||
.cmd = hmp_expire_password,
|
||||
},
|
||||
|
||||
SRST
|
||||
-``expire_password [ vnc | spice ]`` *expire-time*
|
||||
- Specify when a password for spice/vnc becomes
|
||||
- invalid. *expire-time* accepts:
|
||||
+``expire_password [ vnc | spice ] expire-time [ -d display ]``
|
||||
+ Specify when a password for spice/vnc becomes invalid.
|
||||
+ *display* behaves the same as in ``set_password``.
|
||||
+ *expire-time* accepts:
|
||||
|
||||
``now``
|
||||
Invalidate password instantly.
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index 9c91bf93e9..2e91ccb738 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -1384,10 +1384,41 @@ void hmp_set_password(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *protocol = qdict_get_str(qdict, "protocol");
|
||||
const char *password = qdict_get_str(qdict, "password");
|
||||
+ const char *display = qdict_get_try_str(qdict, "display");
|
||||
const char *connected = qdict_get_try_str(qdict, "connected");
|
||||
Error *err = NULL;
|
||||
+ DisplayProtocol proto;
|
||||
|
||||
- qmp_set_password(protocol, password, !!connected, connected, &err);
|
||||
+ SetPasswordOptions opts = {
|
||||
+ .password = g_strdup(password),
|
||||
+ .u.vnc.display = NULL,
|
||||
+ };
|
||||
+
|
||||
+ proto = qapi_enum_parse(&DisplayProtocol_lookup, protocol,
|
||||
+ DISPLAY_PROTOCOL_VNC, &err);
|
||||
+ if (err) {
|
||||
+ hmp_handle_error(mon, err);
|
||||
+ return;
|
||||
+ }
|
||||
+ opts.protocol = proto;
|
||||
+
|
||||
+ if (proto == DISPLAY_PROTOCOL_VNC) {
|
||||
+ opts.u.vnc.has_display = !!display;
|
||||
+ opts.u.vnc.display = g_strdup(display);
|
||||
+ } else if (proto == DISPLAY_PROTOCOL_SPICE) {
|
||||
+ opts.u.spice.has_connected = !!connected;
|
||||
+ opts.u.spice.connected =
|
||||
+ qapi_enum_parse(&SetPasswordAction_lookup, connected,
|
||||
+ SET_PASSWORD_ACTION_KEEP, &err);
|
||||
+ if (err) {
|
||||
+ hmp_handle_error(mon, err);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ qmp_set_password(&opts, &err);
|
||||
+ g_free(opts.password);
|
||||
+ g_free(opts.u.vnc.display);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
@@ -1395,9 +1426,31 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *protocol = qdict_get_str(qdict, "protocol");
|
||||
const char *whenstr = qdict_get_str(qdict, "time");
|
||||
+ const char *display = qdict_get_try_str(qdict, "display");
|
||||
Error *err = NULL;
|
||||
+ DisplayProtocol proto;
|
||||
|
||||
- qmp_expire_password(protocol, whenstr, &err);
|
||||
+ ExpirePasswordOptions opts = {
|
||||
+ .time = g_strdup(whenstr),
|
||||
+ .u.vnc.display = NULL,
|
||||
+ };
|
||||
+
|
||||
+ proto = qapi_enum_parse(&DisplayProtocol_lookup, protocol,
|
||||
+ DISPLAY_PROTOCOL_VNC, &err);
|
||||
+ if (err) {
|
||||
+ hmp_handle_error(mon, err);
|
||||
+ return;
|
||||
+ }
|
||||
+ opts.protocol = proto;
|
||||
+
|
||||
+ if (proto == DISPLAY_PROTOCOL_VNC) {
|
||||
+ opts.u.vnc.has_display = !!display;
|
||||
+ opts.u.vnc.display = g_strdup(display);
|
||||
+ }
|
||||
+
|
||||
+ qmp_expire_password(&opts, &err);
|
||||
+ g_free(opts.time);
|
||||
+ g_free(opts.u.vnc.display);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
|
||||
index 343353e27a..729ca7cceb 100644
|
||||
--- a/monitor/qmp-cmds.c
|
||||
+++ b/monitor/qmp-cmds.c
|
||||
@@ -167,45 +167,30 @@ void qmp_system_wakeup(Error **errp)
|
||||
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, errp);
|
||||
}
|
||||
|
||||
-void qmp_set_password(const char *protocol, const char *password,
|
||||
- bool has_connected, const char *connected, Error **errp)
|
||||
+void qmp_set_password(SetPasswordOptions *opts, Error **errp)
|
||||
{
|
||||
- int disconnect_if_connected = 0;
|
||||
- int fail_if_connected = 0;
|
||||
- int rc;
|
||||
+ bool disconnect_if_connected = false;
|
||||
+ bool fail_if_connected = false;
|
||||
+ int rc = 0;
|
||||
|
||||
- if (has_connected) {
|
||||
- if (strcmp(connected, "fail") == 0) {
|
||||
- fail_if_connected = 1;
|
||||
- } else if (strcmp(connected, "disconnect") == 0) {
|
||||
- disconnect_if_connected = 1;
|
||||
- } else if (strcmp(connected, "keep") == 0) {
|
||||
- /* nothing */
|
||||
- } else {
|
||||
- error_setg(errp, QERR_INVALID_PARAMETER, "connected");
|
||||
- return;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (strcmp(protocol, "spice") == 0) {
|
||||
+ if (opts->protocol == DISPLAY_PROTOCOL_SPICE) {
|
||||
if (!qemu_using_spice(errp)) {
|
||||
return;
|
||||
}
|
||||
- rc = qemu_spice.set_passwd(password, fail_if_connected,
|
||||
+ if (opts->u.spice.has_connected) {
|
||||
+ fail_if_connected =
|
||||
+ opts->u.spice.connected == SET_PASSWORD_ACTION_FAIL;
|
||||
+ disconnect_if_connected =
|
||||
+ opts->u.spice.connected == SET_PASSWORD_ACTION_DISCONNECT;
|
||||
+ }
|
||||
+ rc = qemu_spice.set_passwd(opts->password, fail_if_connected,
|
||||
disconnect_if_connected);
|
||||
- } else if (strcmp(protocol, "vnc") == 0) {
|
||||
- if (fail_if_connected || disconnect_if_connected) {
|
||||
- /* vnc supports "connected=keep" only */
|
||||
- error_setg(errp, QERR_INVALID_PARAMETER, "connected");
|
||||
- return;
|
||||
- }
|
||||
+ } else if (opts->protocol == DISPLAY_PROTOCOL_VNC) {
|
||||
/* Note that setting an empty password will not disable login through
|
||||
* this interface. */
|
||||
- rc = vnc_display_password(NULL, password);
|
||||
- } else {
|
||||
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol",
|
||||
- "'vnc' or 'spice'");
|
||||
- return;
|
||||
+ rc = vnc_display_password(
|
||||
+ opts->u.vnc.has_display ? opts->u.vnc.display : NULL,
|
||||
+ opts->password);
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
@@ -213,11 +198,11 @@ void qmp_set_password(const char *protocol, const char *password,
|
||||
}
|
||||
}
|
||||
|
||||
-void qmp_expire_password(const char *protocol, const char *whenstr,
|
||||
- Error **errp)
|
||||
+void qmp_expire_password(ExpirePasswordOptions *opts, Error **errp)
|
||||
{
|
||||
time_t when;
|
||||
int rc;
|
||||
+ const char* whenstr = opts->time;
|
||||
|
||||
if (strcmp(whenstr, "now") == 0) {
|
||||
when = 0;
|
||||
@@ -229,17 +214,14 @@ void qmp_expire_password(const char *protocol, const char *whenstr,
|
||||
when = strtoull(whenstr, NULL, 10);
|
||||
}
|
||||
|
||||
- if (strcmp(protocol, "spice") == 0) {
|
||||
+ if (opts->protocol == DISPLAY_PROTOCOL_SPICE) {
|
||||
if (!qemu_using_spice(errp)) {
|
||||
return;
|
||||
}
|
||||
rc = qemu_spice.set_pw_expire(when);
|
||||
- } else if (strcmp(protocol, "vnc") == 0) {
|
||||
- rc = vnc_display_pw_expire(NULL, when);
|
||||
- } else {
|
||||
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol",
|
||||
- "'vnc' or 'spice'");
|
||||
- return;
|
||||
+ } else if (opts->protocol == DISPLAY_PROTOCOL_VNC) {
|
||||
+ rc = vnc_display_pw_expire(
|
||||
+ opts->u.vnc.has_display ? opts->u.vnc.display : NULL, when);
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
diff --git a/qapi/ui.json b/qapi/ui.json
|
||||
index d7567ac866..4244c62c30 100644
|
||||
--- a/qapi/ui.json
|
||||
+++ b/qapi/ui.json
|
||||
@@ -9,22 +9,23 @@
|
||||
{ 'include': 'common.json' }
|
||||
{ 'include': 'sockets.json' }
|
||||
|
||||
+##
|
||||
+# @DisplayProtocol:
|
||||
+#
|
||||
+# Display protocols which support changing password options.
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'enum': 'DisplayProtocol',
|
||||
+ 'data': [ { 'name': 'vnc', 'if': 'CONFIG_VNC' },
|
||||
+ { 'name': 'spice', 'if': 'CONFIG_SPICE' } ] }
|
||||
+
|
||||
##
|
||||
# @set_password:
|
||||
#
|
||||
# Sets the password of a remote display session.
|
||||
#
|
||||
-# @protocol: - 'vnc' to modify the VNC server password
|
||||
-# - 'spice' to modify the Spice server password
|
||||
-#
|
||||
-# @password: the new password
|
||||
-#
|
||||
-# @connected: how to handle existing clients when changing the
|
||||
-# password. If nothing is specified, defaults to 'keep'
|
||||
-# 'fail' to fail the command if clients are connected
|
||||
-# 'disconnect' to disconnect existing clients
|
||||
-# 'keep' to maintain existing clients
|
||||
-#
|
||||
# Returns: - Nothing on success
|
||||
# - If Spice is not enabled, DeviceNotFound
|
||||
#
|
||||
@@ -37,16 +38,123 @@
|
||||
# <- { "return": {} }
|
||||
#
|
||||
##
|
||||
-{ 'command': 'set_password',
|
||||
- 'data': {'protocol': 'str', 'password': 'str', '*connected': 'str'} }
|
||||
+{ 'command': 'set_password', 'boxed': true, 'data': 'SetPasswordOptions' }
|
||||
+
|
||||
+##
|
||||
+# @SetPasswordOptions:
|
||||
+#
|
||||
+# Data required to set a new password on a display server protocol.
|
||||
+#
|
||||
+# @protocol: - 'vnc' to modify the VNC server password
|
||||
+# - 'spice' to modify the Spice server password
|
||||
+#
|
||||
+# @password: the new password
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'union': 'SetPasswordOptions',
|
||||
+ 'base': { 'protocol': 'DisplayProtocol',
|
||||
+ 'password': 'str' },
|
||||
+ 'discriminator': 'protocol',
|
||||
+ 'data': { 'vnc': 'SetPasswordOptionsVnc',
|
||||
+ 'spice': 'SetPasswordOptionsSpice' } }
|
||||
+
|
||||
+##
|
||||
+# @SetPasswordAction:
|
||||
+#
|
||||
+# An action to take on changing a password on a connection with active clients.
|
||||
+#
|
||||
+# @fail: fail the command if clients are connected
|
||||
+#
|
||||
+# @disconnect: disconnect existing clients
|
||||
+#
|
||||
+# @keep: maintain existing clients
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'enum': 'SetPasswordAction',
|
||||
+ 'data': [ 'fail', 'disconnect', 'keep' ] }
|
||||
+
|
||||
+##
|
||||
+# @SetPasswordActionVnc:
|
||||
+#
|
||||
+# See @SetPasswordAction. VNC only supports the keep action. 'connection'
|
||||
+# should just be omitted for VNC, this is kept for backwards compatibility.
|
||||
+#
|
||||
+# @keep: maintain existing clients
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'enum': 'SetPasswordActionVnc',
|
||||
+ 'data': [ 'keep' ] }
|
||||
+
|
||||
+##
|
||||
+# @SetPasswordOptionsSpice:
|
||||
+#
|
||||
+# Options for set_password specific to the VNC procotol.
|
||||
+#
|
||||
+# @connected: How to handle existing clients when changing the
|
||||
+# password. If nothing is specified, defaults to 'keep'.
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'SetPasswordOptionsSpice',
|
||||
+ 'data': { '*connected': 'SetPasswordAction' } }
|
||||
+
|
||||
+##
|
||||
+# @SetPasswordOptionsVnc:
|
||||
+#
|
||||
+# Options for set_password specific to the VNC procotol.
|
||||
+#
|
||||
+# @display: The id of the display where the password should be changed.
|
||||
+# Defaults to the first.
|
||||
+#
|
||||
+# @connected: How to handle existing clients when changing the
|
||||
+# password.
|
||||
+#
|
||||
+# Features:
|
||||
+# @deprecated: For VNC, @connected will always be 'keep', parameter should be
|
||||
+# omitted.
|
||||
+#
|
||||
+# Since: 6.2
|
||||
+#
|
||||
+##
|
||||
+{ 'struct': 'SetPasswordOptionsVnc',
|
||||
+ 'data': { '*display': 'str',
|
||||
+ '*connected': { 'type': 'SetPasswordActionVnc',
|
||||
+ 'features': ['deprecated'] } } }
|
||||
|
||||
##
|
||||
# @expire_password:
|
||||
#
|
||||
# Expire the password of a remote display server.
|
||||
#
|
||||
-# @protocol: the name of the remote display protocol 'vnc' or 'spice'
|
||||
+# Returns: - Nothing on success
|
||||
+# - If @protocol is 'spice' and Spice is not active, DeviceNotFound
|
||||
#
|
||||
+# Since: 0.14
|
||||
+#
|
||||
+# Example:
|
||||
+#
|
||||
+# -> { "execute": "expire_password", "arguments": { "protocol": "vnc",
|
||||
+# "time": "+60" } }
|
||||
+# <- { "return": {} }
|
||||
+#
|
||||
+##
|
||||
+{ 'command': 'expire_password', 'boxed': true, 'data': 'ExpirePasswordOptions' }
|
||||
+
|
||||
+##
|
||||
+# @ExpirePasswordOptions:
|
||||
+#
|
||||
+# Data required to set password expiration on a display server protocol.
|
||||
+#
|
||||
+# @protocol: - 'vnc' to modify the VNC server expiration
|
||||
+# - 'spice' to modify the Spice server expiration
|
||||
+
|
||||
# @time: when to expire the password.
|
||||
#
|
||||
# - 'now' to expire the password immediately
|
||||
@@ -54,24 +162,33 @@
|
||||
# - '+INT' where INT is the number of seconds from now (integer)
|
||||
# - 'INT' where INT is the absolute time in seconds
|
||||
#
|
||||
-# Returns: - Nothing on success
|
||||
-# - If @protocol is 'spice' and Spice is not active, DeviceNotFound
|
||||
-#
|
||||
-# Since: 0.14
|
||||
-#
|
||||
# Notes: Time is relative to the server and currently there is no way to
|
||||
# coordinate server time with client time. It is not recommended to
|
||||
# use the absolute time version of the @time parameter unless you're
|
||||
# sure you are on the same machine as the QEMU instance.
|
||||
#
|
||||
-# Example:
|
||||
+# Since: 6.2
|
||||
#
|
||||
-# -> { "execute": "expire_password", "arguments": { "protocol": "vnc",
|
||||
-# "time": "+60" } }
|
||||
-# <- { "return": {} }
|
||||
+##
|
||||
+{ 'union': 'ExpirePasswordOptions',
|
||||
+ 'base': { 'protocol': 'DisplayProtocol',
|
||||
+ 'time': 'str' },
|
||||
+ 'discriminator': 'protocol',
|
||||
+ 'data': { 'vnc': 'ExpirePasswordOptionsVnc' } }
|
||||
+
|
||||
+##
|
||||
+# @ExpirePasswordOptionsVnc:
|
||||
+#
|
||||
+# Options for expire_password specific to the VNC procotol.
|
||||
+#
|
||||
+# @display: The id of the display where the expiration should be changed.
|
||||
+# Defaults to the first.
|
||||
+#
|
||||
+# Since: 6.2
|
||||
#
|
||||
##
|
||||
-{ 'command': 'expire_password', 'data': {'protocol': 'str', 'time': 'str'} }
|
||||
+{ 'struct': 'ExpirePasswordOptionsVnc',
|
||||
+ 'data': { '*display': 'str' } }
|
||||
|
||||
##
|
||||
# @screendump:
|
@@ -1,143 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Date: Thu, 4 Feb 2021 18:34:35 +0000
|
||||
Subject: [PATCH] virtiofsd: extract lo_do_open() from lo_open()
|
||||
|
||||
Both lo_open() and lo_create() have similar code to open a file. Extract
|
||||
a common lo_do_open() function from lo_open() that will be used by
|
||||
lo_create() in a later commit.
|
||||
|
||||
Since lo_do_open() does not otherwise need fuse_req_t req, convert
|
||||
lo_add_fd_mapping() to use struct lo_data *lo instead.
|
||||
|
||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Message-Id: <20210204150208.367837-2-stefanha@redhat.com>
|
||||
Reviewed-by: Greg Kurz <groug@kaod.org>
|
||||
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
tools/virtiofsd/passthrough_ll.c | 73 ++++++++++++++++++++------------
|
||||
1 file changed, 46 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
|
||||
index 97485b22b4..218e20e9d7 100644
|
||||
--- a/tools/virtiofsd/passthrough_ll.c
|
||||
+++ b/tools/virtiofsd/passthrough_ll.c
|
||||
@@ -471,17 +471,17 @@ static void lo_map_remove(struct lo_map *map, size_t key)
|
||||
}
|
||||
|
||||
/* Assumes lo->mutex is held */
|
||||
-static ssize_t lo_add_fd_mapping(fuse_req_t req, int fd)
|
||||
+static ssize_t lo_add_fd_mapping(struct lo_data *lo, int fd)
|
||||
{
|
||||
struct lo_map_elem *elem;
|
||||
|
||||
- elem = lo_map_alloc_elem(&lo_data(req)->fd_map);
|
||||
+ elem = lo_map_alloc_elem(&lo->fd_map);
|
||||
if (!elem) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
elem->fd = fd;
|
||||
- return elem - lo_data(req)->fd_map.elems;
|
||||
+ return elem - lo->fd_map.elems;
|
||||
}
|
||||
|
||||
/* Assumes lo->mutex is held */
|
||||
@@ -1661,6 +1661,38 @@ static void update_open_flags(int writeback, int allow_direct_io,
|
||||
}
|
||||
}
|
||||
|
||||
+static int lo_do_open(struct lo_data *lo, struct lo_inode *inode,
|
||||
+ struct fuse_file_info *fi)
|
||||
+{
|
||||
+ char buf[64];
|
||||
+ ssize_t fh;
|
||||
+ int fd;
|
||||
+
|
||||
+ update_open_flags(lo->writeback, lo->allow_direct_io, fi);
|
||||
+
|
||||
+ sprintf(buf, "%i", inode->fd);
|
||||
+ fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
|
||||
+ if (fd == -1) {
|
||||
+ return errno;
|
||||
+ }
|
||||
+
|
||||
+ pthread_mutex_lock(&lo->mutex);
|
||||
+ fh = lo_add_fd_mapping(lo, fd);
|
||||
+ pthread_mutex_unlock(&lo->mutex);
|
||||
+ if (fh == -1) {
|
||||
+ close(fd);
|
||||
+ return ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ fi->fh = fh;
|
||||
+ if (lo->cache == CACHE_NONE) {
|
||||
+ fi->direct_io = 1;
|
||||
+ } else if (lo->cache == CACHE_ALWAYS) {
|
||||
+ fi->keep_cache = 1;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
|
||||
mode_t mode, struct fuse_file_info *fi)
|
||||
{
|
||||
@@ -1701,7 +1733,7 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
|
||||
ssize_t fh;
|
||||
|
||||
pthread_mutex_lock(&lo->mutex);
|
||||
- fh = lo_add_fd_mapping(req, fd);
|
||||
+ fh = lo_add_fd_mapping(lo, fd);
|
||||
pthread_mutex_unlock(&lo->mutex);
|
||||
if (fh == -1) {
|
||||
close(fd);
|
||||
@@ -1892,38 +1924,25 @@ static void lo_fsyncdir(fuse_req_t req, fuse_ino_t ino, int datasync,
|
||||
|
||||
static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
|
||||
{
|
||||
- int fd;
|
||||
- ssize_t fh;
|
||||
- char buf[64];
|
||||
struct lo_data *lo = lo_data(req);
|
||||
+ struct lo_inode *inode = lo_inode(req, ino);
|
||||
+ int err;
|
||||
|
||||
fuse_log(FUSE_LOG_DEBUG, "lo_open(ino=%" PRIu64 ", flags=%d)\n", ino,
|
||||
fi->flags);
|
||||
|
||||
- update_open_flags(lo->writeback, lo->allow_direct_io, fi);
|
||||
-
|
||||
- sprintf(buf, "%i", lo_fd(req, ino));
|
||||
- fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
|
||||
- if (fd == -1) {
|
||||
- return (void)fuse_reply_err(req, errno);
|
||||
- }
|
||||
-
|
||||
- pthread_mutex_lock(&lo->mutex);
|
||||
- fh = lo_add_fd_mapping(req, fd);
|
||||
- pthread_mutex_unlock(&lo->mutex);
|
||||
- if (fh == -1) {
|
||||
- close(fd);
|
||||
- fuse_reply_err(req, ENOMEM);
|
||||
+ if (!inode) {
|
||||
+ fuse_reply_err(req, EBADF);
|
||||
return;
|
||||
}
|
||||
|
||||
- fi->fh = fh;
|
||||
- if (lo->cache == CACHE_NONE) {
|
||||
- fi->direct_io = 1;
|
||||
- } else if (lo->cache == CACHE_ALWAYS) {
|
||||
- fi->keep_cache = 1;
|
||||
+ err = lo_do_open(lo, inode, fi);
|
||||
+ lo_inode_put(lo, &inode);
|
||||
+ if (err) {
|
||||
+ fuse_reply_err(req, err);
|
||||
+ } else {
|
||||
+ fuse_reply_open(req, fi);
|
||||
}
|
||||
- fuse_reply_open(req, fi);
|
||||
}
|
||||
|
||||
static void lo_release(fuse_req_t req, fuse_ino_t ino,
|
@@ -1,107 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Date: Thu, 4 Feb 2021 18:34:36 +0000
|
||||
Subject: [PATCH] virtiofsd: optionally return inode pointer from
|
||||
lo_do_lookup()
|
||||
|
||||
lo_do_lookup() finds an existing inode or allocates a new one. It
|
||||
increments nlookup so that the inode stays alive until the client
|
||||
releases it.
|
||||
|
||||
Existing callers don't need the struct lo_inode so the function doesn't
|
||||
return it. Extend the function to optionally return the inode. The next
|
||||
commit will need it.
|
||||
|
||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Reviewed-by: Greg Kurz <groug@kaod.org>
|
||||
Message-Id: <20210204150208.367837-3-stefanha@redhat.com>
|
||||
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
tools/virtiofsd/passthrough_ll.c | 29 +++++++++++++++++++++--------
|
||||
1 file changed, 21 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
|
||||
index 218e20e9d7..2bd050b620 100644
|
||||
--- a/tools/virtiofsd/passthrough_ll.c
|
||||
+++ b/tools/virtiofsd/passthrough_ll.c
|
||||
@@ -843,11 +843,13 @@ static int do_statx(struct lo_data *lo, int dirfd, const char *pathname,
|
||||
}
|
||||
|
||||
/*
|
||||
- * Increments nlookup and caller must release refcount using
|
||||
- * lo_inode_put(&parent).
|
||||
+ * Increments nlookup on the inode on success. unref_inode_lolocked() must be
|
||||
+ * called eventually to decrement nlookup again. If inodep is non-NULL, the
|
||||
+ * inode pointer is stored and the caller must call lo_inode_put().
|
||||
*/
|
||||
static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
|
||||
- struct fuse_entry_param *e)
|
||||
+ struct fuse_entry_param *e,
|
||||
+ struct lo_inode **inodep)
|
||||
{
|
||||
int newfd;
|
||||
int res;
|
||||
@@ -857,6 +859,10 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
|
||||
struct lo_inode *inode = NULL;
|
||||
struct lo_inode *dir = lo_inode(req, parent);
|
||||
|
||||
+ if (inodep) {
|
||||
+ *inodep = NULL;
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* name_to_handle_at() and open_by_handle_at() can reach here with fuse
|
||||
* mount point in guest, but we don't have its inode info in the
|
||||
@@ -924,7 +930,14 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
|
||||
pthread_mutex_unlock(&lo->mutex);
|
||||
}
|
||||
e->ino = inode->fuse_ino;
|
||||
- lo_inode_put(lo, &inode);
|
||||
+
|
||||
+ /* Transfer ownership of inode pointer to caller or drop it */
|
||||
+ if (inodep) {
|
||||
+ *inodep = inode;
|
||||
+ } else {
|
||||
+ lo_inode_put(lo, &inode);
|
||||
+ }
|
||||
+
|
||||
lo_inode_put(lo, &dir);
|
||||
|
||||
fuse_log(FUSE_LOG_DEBUG, " %lli/%s -> %lli\n", (unsigned long long)parent,
|
||||
@@ -959,7 +972,7 @@ static void lo_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
|
||||
return;
|
||||
}
|
||||
|
||||
- err = lo_do_lookup(req, parent, name, &e);
|
||||
+ err = lo_do_lookup(req, parent, name, &e, NULL);
|
||||
if (err) {
|
||||
fuse_reply_err(req, err);
|
||||
} else {
|
||||
@@ -1067,7 +1080,7 @@ static void lo_mknod_symlink(fuse_req_t req, fuse_ino_t parent,
|
||||
goto out;
|
||||
}
|
||||
|
||||
- saverr = lo_do_lookup(req, parent, name, &e);
|
||||
+ saverr = lo_do_lookup(req, parent, name, &e, NULL);
|
||||
if (saverr) {
|
||||
goto out;
|
||||
}
|
||||
@@ -1544,7 +1557,7 @@ static void lo_do_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
|
||||
|
||||
if (plus) {
|
||||
if (!is_dot_or_dotdot(name)) {
|
||||
- err = lo_do_lookup(req, ino, name, &e);
|
||||
+ err = lo_do_lookup(req, ino, name, &e, NULL);
|
||||
if (err) {
|
||||
goto error;
|
||||
}
|
||||
@@ -1742,7 +1755,7 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
|
||||
}
|
||||
|
||||
fi->fh = fh;
|
||||
- err = lo_do_lookup(req, parent, name, &e);
|
||||
+ err = lo_do_lookup(req, parent, name, &e, NULL);
|
||||
}
|
||||
if (lo->cache == CACHE_NONE) {
|
||||
fi->direct_io = 1;
|
43
debian/patches/extra/0006-block-io-Update-BSC-only-if-want_zero-is-true.patch
vendored
Normal file
43
debian/patches/extra/0006-block-io-Update-BSC-only-if-want_zero-is-true.patch
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hanna Reitz <hreitz@redhat.com>
|
||||
Date: Tue, 18 Jan 2022 17:59:59 +0100
|
||||
Subject: [PATCH] block/io: Update BSC only if want_zero is true
|
||||
|
||||
We update the block-status cache whenever we get new information from a
|
||||
bdrv_co_block_status() call to the block driver. However, if we have
|
||||
passed want_zero=false to that call, it may flag areas containing zeroes
|
||||
as data, and so we would update the block-status cache with wrong
|
||||
information.
|
||||
|
||||
Therefore, we should not update the cache with want_zero=false.
|
||||
|
||||
Reported-by: Nir Soffer <nsoffer@redhat.com>
|
||||
Fixes: 0bc329fbb00 ("block: block-status cache for data regions")
|
||||
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
||||
Message-Id: <20220118170000.49423-2-hreitz@redhat.com>
|
||||
Reviewed-by: Eric Blake <eblake@redhat.com>
|
||||
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||||
---
|
||||
block/io.c | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block/io.c b/block/io.c
|
||||
index bb0a254def..4e4cb556c5 100644
|
||||
--- a/block/io.c
|
||||
+++ b/block/io.c
|
||||
@@ -2497,8 +2497,12 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
|
||||
* non-protocol nodes, and then it is never used. However, filling
|
||||
* the cache requires an RCU update, so double check here to avoid
|
||||
* such an update if possible.
|
||||
+ *
|
||||
+ * Check want_zero, because we only want to update the cache when we
|
||||
+ * have accurate information about what is zero and what is data.
|
||||
*/
|
||||
- if (ret == (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) &&
|
||||
+ if (want_zero &&
|
||||
+ ret == (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) &&
|
||||
QLIST_EMPTY(&bs->children))
|
||||
{
|
||||
/*
|
@@ -1,296 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Date: Thu, 4 Feb 2021 18:34:37 +0000
|
||||
Subject: [PATCH] virtiofsd: prevent opening of special files (CVE-2020-35517)
|
||||
|
||||
A well-behaved FUSE client does not attempt to open special files with
|
||||
FUSE_OPEN because they are handled on the client side (e.g. device nodes
|
||||
are handled by client-side device drivers).
|
||||
|
||||
The check to prevent virtiofsd from opening special files is missing in
|
||||
a few cases, most notably FUSE_OPEN. A malicious client can cause
|
||||
virtiofsd to open a device node, potentially allowing the guest to
|
||||
escape. This can be exploited by a modified guest device driver. It is
|
||||
not exploitable from guest userspace since the guest kernel will handle
|
||||
special files inside the guest instead of sending FUSE requests.
|
||||
|
||||
This patch fixes this issue by introducing the lo_inode_open() function
|
||||
to check the file type before opening it. This is a short-term solution
|
||||
because it does not prevent a compromised virtiofsd process from opening
|
||||
device nodes on the host.
|
||||
|
||||
Restructure lo_create() to try O_CREAT | O_EXCL first. Note that O_CREAT
|
||||
| O_EXCL does not follow symlinks, so O_NOFOLLOW masking is not
|
||||
necessary here. If the file exists and the user did not specify O_EXCL,
|
||||
open it via lo_do_open().
|
||||
|
||||
Reported-by: Alex Xu <alex@alxu.ca>
|
||||
Fixes: CVE-2020-35517
|
||||
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
Reviewed-by: Vivek Goyal <vgoyal@redhat.com>
|
||||
Reviewed-by: Greg Kurz <groug@kaod.org>
|
||||
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Message-Id: <20210204150208.367837-4-stefanha@redhat.com>
|
||||
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
tools/virtiofsd/passthrough_ll.c | 144 ++++++++++++++++++++-----------
|
||||
1 file changed, 92 insertions(+), 52 deletions(-)
|
||||
|
||||
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
|
||||
index 2bd050b620..03c5e0d13c 100644
|
||||
--- a/tools/virtiofsd/passthrough_ll.c
|
||||
+++ b/tools/virtiofsd/passthrough_ll.c
|
||||
@@ -567,6 +567,38 @@ static int lo_fd(fuse_req_t req, fuse_ino_t ino)
|
||||
return fd;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Open a file descriptor for an inode. Returns -EBADF if the inode is not a
|
||||
+ * regular file or a directory.
|
||||
+ *
|
||||
+ * Use this helper function instead of raw openat(2) to prevent security issues
|
||||
+ * when a malicious client opens special files such as block device nodes.
|
||||
+ * Symlink inodes are also rejected since symlinks must already have been
|
||||
+ * traversed on the client side.
|
||||
+ */
|
||||
+static int lo_inode_open(struct lo_data *lo, struct lo_inode *inode,
|
||||
+ int open_flags)
|
||||
+{
|
||||
+ g_autofree char *fd_str = g_strdup_printf("%d", inode->fd);
|
||||
+ int fd;
|
||||
+
|
||||
+ if (!S_ISREG(inode->filetype) && !S_ISDIR(inode->filetype)) {
|
||||
+ return -EBADF;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * The file is a symlink so O_NOFOLLOW must be ignored. We checked earlier
|
||||
+ * that the inode is not a special file but if an external process races
|
||||
+ * with us then symlinks are traversed here. It is not possible to escape
|
||||
+ * the shared directory since it is mounted as "/" though.
|
||||
+ */
|
||||
+ fd = openat(lo->proc_self_fd, fd_str, open_flags & ~O_NOFOLLOW);
|
||||
+ if (fd < 0) {
|
||||
+ return -errno;
|
||||
+ }
|
||||
+ return fd;
|
||||
+}
|
||||
+
|
||||
static void lo_init(void *userdata, struct fuse_conn_info *conn)
|
||||
{
|
||||
struct lo_data *lo = (struct lo_data *)userdata;
|
||||
@@ -696,9 +728,9 @@ static void lo_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
|
||||
if (fi) {
|
||||
truncfd = fd;
|
||||
} else {
|
||||
- sprintf(procname, "%i", ifd);
|
||||
- truncfd = openat(lo->proc_self_fd, procname, O_RDWR);
|
||||
+ truncfd = lo_inode_open(lo, inode, O_RDWR);
|
||||
if (truncfd < 0) {
|
||||
+ errno = -truncfd;
|
||||
goto out_err;
|
||||
}
|
||||
}
|
||||
@@ -860,7 +892,7 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
|
||||
struct lo_inode *dir = lo_inode(req, parent);
|
||||
|
||||
if (inodep) {
|
||||
- *inodep = NULL;
|
||||
+ *inodep = NULL; /* in case there is an error */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1674,19 +1706,26 @@ static void update_open_flags(int writeback, int allow_direct_io,
|
||||
}
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Open a regular file, set up an fd mapping, and fill out the struct
|
||||
+ * fuse_file_info for it. If existing_fd is not negative, use that fd instead
|
||||
+ * opening a new one. Takes ownership of existing_fd.
|
||||
+ *
|
||||
+ * Returns 0 on success or a positive errno.
|
||||
+ */
|
||||
static int lo_do_open(struct lo_data *lo, struct lo_inode *inode,
|
||||
- struct fuse_file_info *fi)
|
||||
+ int existing_fd, struct fuse_file_info *fi)
|
||||
{
|
||||
- char buf[64];
|
||||
ssize_t fh;
|
||||
- int fd;
|
||||
+ int fd = existing_fd;
|
||||
|
||||
update_open_flags(lo->writeback, lo->allow_direct_io, fi);
|
||||
|
||||
- sprintf(buf, "%i", inode->fd);
|
||||
- fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
|
||||
- if (fd == -1) {
|
||||
- return errno;
|
||||
+ if (fd < 0) {
|
||||
+ fd = lo_inode_open(lo, inode, fi->flags);
|
||||
+ if (fd < 0) {
|
||||
+ return -fd;
|
||||
+ }
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&lo->mutex);
|
||||
@@ -1709,9 +1748,10 @@ static int lo_do_open(struct lo_data *lo, struct lo_inode *inode,
|
||||
static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
|
||||
mode_t mode, struct fuse_file_info *fi)
|
||||
{
|
||||
- int fd;
|
||||
+ int fd = -1;
|
||||
struct lo_data *lo = lo_data(req);
|
||||
struct lo_inode *parent_inode;
|
||||
+ struct lo_inode *inode = NULL;
|
||||
struct fuse_entry_param e;
|
||||
int err;
|
||||
struct lo_cred old = {};
|
||||
@@ -1737,36 +1777,38 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
|
||||
|
||||
update_open_flags(lo->writeback, lo->allow_direct_io, fi);
|
||||
|
||||
- fd = openat(parent_inode->fd, name, (fi->flags | O_CREAT) & ~O_NOFOLLOW,
|
||||
- mode);
|
||||
+ /* Try to create a new file but don't open existing files */
|
||||
+ fd = openat(parent_inode->fd, name, fi->flags | O_CREAT | O_EXCL, mode);
|
||||
err = fd == -1 ? errno : 0;
|
||||
- lo_restore_cred(&old);
|
||||
|
||||
- if (!err) {
|
||||
- ssize_t fh;
|
||||
+ lo_restore_cred(&old);
|
||||
|
||||
- pthread_mutex_lock(&lo->mutex);
|
||||
- fh = lo_add_fd_mapping(lo, fd);
|
||||
- pthread_mutex_unlock(&lo->mutex);
|
||||
- if (fh == -1) {
|
||||
- close(fd);
|
||||
- err = ENOMEM;
|
||||
- goto out;
|
||||
- }
|
||||
+ /* Ignore the error if file exists and O_EXCL was not given */
|
||||
+ if (err && (err != EEXIST || (fi->flags & O_EXCL))) {
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
- fi->fh = fh;
|
||||
- err = lo_do_lookup(req, parent, name, &e, NULL);
|
||||
+ err = lo_do_lookup(req, parent, name, &e, &inode);
|
||||
+ if (err) {
|
||||
+ goto out;
|
||||
}
|
||||
- if (lo->cache == CACHE_NONE) {
|
||||
- fi->direct_io = 1;
|
||||
- } else if (lo->cache == CACHE_ALWAYS) {
|
||||
- fi->keep_cache = 1;
|
||||
+
|
||||
+ err = lo_do_open(lo, inode, fd, fi);
|
||||
+ fd = -1; /* lo_do_open() takes ownership of fd */
|
||||
+ if (err) {
|
||||
+ /* Undo lo_do_lookup() nlookup ref */
|
||||
+ unref_inode_lolocked(lo, inode, 1);
|
||||
}
|
||||
|
||||
out:
|
||||
+ lo_inode_put(lo, &inode);
|
||||
lo_inode_put(lo, &parent_inode);
|
||||
|
||||
if (err) {
|
||||
+ if (fd >= 0) {
|
||||
+ close(fd);
|
||||
+ }
|
||||
+
|
||||
fuse_reply_err(req, err);
|
||||
} else {
|
||||
fuse_reply_create(req, &e, fi);
|
||||
@@ -1780,7 +1822,6 @@ static struct lo_inode_plock *lookup_create_plock_ctx(struct lo_data *lo,
|
||||
pid_t pid, int *err)
|
||||
{
|
||||
struct lo_inode_plock *plock;
|
||||
- char procname[64];
|
||||
int fd;
|
||||
|
||||
plock =
|
||||
@@ -1797,12 +1838,10 @@ static struct lo_inode_plock *lookup_create_plock_ctx(struct lo_data *lo,
|
||||
}
|
||||
|
||||
/* Open another instance of file which can be used for ofd locks. */
|
||||
- sprintf(procname, "%i", inode->fd);
|
||||
-
|
||||
/* TODO: What if file is not writable? */
|
||||
- fd = openat(lo->proc_self_fd, procname, O_RDWR);
|
||||
- if (fd == -1) {
|
||||
- *err = errno;
|
||||
+ fd = lo_inode_open(lo, inode, O_RDWR);
|
||||
+ if (fd < 0) {
|
||||
+ *err = -fd;
|
||||
free(plock);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1949,7 +1988,7 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
|
||||
return;
|
||||
}
|
||||
|
||||
- err = lo_do_open(lo, inode, fi);
|
||||
+ err = lo_do_open(lo, inode, -1, fi);
|
||||
lo_inode_put(lo, &inode);
|
||||
if (err) {
|
||||
fuse_reply_err(req, err);
|
||||
@@ -2005,39 +2044,40 @@ static void lo_flush(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
|
||||
static void lo_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
|
||||
struct fuse_file_info *fi)
|
||||
{
|
||||
+ struct lo_inode *inode = lo_inode(req, ino);
|
||||
+ struct lo_data *lo = lo_data(req);
|
||||
int res;
|
||||
int fd;
|
||||
- char *buf;
|
||||
|
||||
fuse_log(FUSE_LOG_DEBUG, "lo_fsync(ino=%" PRIu64 ", fi=0x%p)\n", ino,
|
||||
(void *)fi);
|
||||
|
||||
- if (!fi) {
|
||||
- struct lo_data *lo = lo_data(req);
|
||||
-
|
||||
- res = asprintf(&buf, "%i", lo_fd(req, ino));
|
||||
- if (res == -1) {
|
||||
- return (void)fuse_reply_err(req, errno);
|
||||
- }
|
||||
+ if (!inode) {
|
||||
+ fuse_reply_err(req, EBADF);
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
- fd = openat(lo->proc_self_fd, buf, O_RDWR);
|
||||
- free(buf);
|
||||
- if (fd == -1) {
|
||||
- return (void)fuse_reply_err(req, errno);
|
||||
+ if (!fi) {
|
||||
+ fd = lo_inode_open(lo, inode, O_RDWR);
|
||||
+ if (fd < 0) {
|
||||
+ res = -fd;
|
||||
+ goto out;
|
||||
}
|
||||
} else {
|
||||
fd = lo_fi_fd(req, fi);
|
||||
}
|
||||
|
||||
if (datasync) {
|
||||
- res = fdatasync(fd);
|
||||
+ res = fdatasync(fd) == -1 ? errno : 0;
|
||||
} else {
|
||||
- res = fsync(fd);
|
||||
+ res = fsync(fd) == -1 ? errno : 0;
|
||||
}
|
||||
if (!fi) {
|
||||
close(fd);
|
||||
}
|
||||
- fuse_reply_err(req, res == -1 ? errno : 0);
|
||||
+out:
|
||||
+ lo_inode_put(lo, &inode);
|
||||
+ fuse_reply_err(req, res);
|
||||
}
|
||||
|
||||
static void lo_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t offset,
|
40
debian/patches/extra/0007-block-nbd-Delete-reconnect-delay-timer-when-done.patch
vendored
Normal file
40
debian/patches/extra/0007-block-nbd-Delete-reconnect-delay-timer-when-done.patch
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hanna Reitz <hreitz@redhat.com>
|
||||
Date: Wed, 9 Feb 2022 15:02:52 +0100
|
||||
Subject: [PATCH] block/nbd: Delete reconnect delay timer when done
|
||||
|
||||
We start the reconnect delay timer to cancel the reconnection attempt
|
||||
after a while. Once nbd_co_do_establish_connection() has returned, this
|
||||
attempt is over, and we no longer need the timer.
|
||||
|
||||
Delete it before returning from nbd_reconnect_attempt(), so that it does
|
||||
not persist beyond the I/O request that was paused for reconnecting; we
|
||||
do not want it to fire in a drained section, because all sort of things
|
||||
can happen in such a section (e.g. the AioContext might be changed, and
|
||||
we do not want the timer to fire in the wrong context; or the BDS might
|
||||
even be deleted, and so the timer CB would access already-freed data).
|
||||
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
||||
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
||||
---
|
||||
block/nbd.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/block/nbd.c b/block/nbd.c
|
||||
index 5ef462db1b..b8e5a9b4cc 100644
|
||||
--- a/block/nbd.c
|
||||
+++ b/block/nbd.c
|
||||
@@ -353,6 +353,13 @@ static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s)
|
||||
}
|
||||
|
||||
nbd_co_do_establish_connection(s->bs, NULL);
|
||||
+
|
||||
+ /*
|
||||
+ * The reconnect attempt is done (maybe successfully, maybe not), so
|
||||
+ * we no longer need this timer. Delete it so it will not outlive
|
||||
+ * this I/O request (so draining removes all timers).
|
||||
+ */
|
||||
+ reconnect_delay_timer_del(s);
|
||||
}
|
||||
|
||||
static coroutine_fn int nbd_receive_replies(BDRVNBDState *s, uint64_t handle)
|
@@ -1,29 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Greg Kurz <groug@kaod.org>
|
||||
Date: Thu, 4 Feb 2021 18:34:38 +0000
|
||||
Subject: [PATCH] virtiofsd: Add _llseek to the seccomp whitelist
|
||||
|
||||
This is how glibc implements lseek(2) on POWER.
|
||||
|
||||
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1917692
|
||||
Signed-off-by: Greg Kurz <groug@kaod.org>
|
||||
Message-Id: <20210121171540.1449777-1-groug@kaod.org>
|
||||
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
tools/virtiofsd/passthrough_seccomp.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/tools/virtiofsd/passthrough_seccomp.c b/tools/virtiofsd/passthrough_seccomp.c
|
||||
index 11623f56f2..bb8ef5b17f 100644
|
||||
--- a/tools/virtiofsd/passthrough_seccomp.c
|
||||
+++ b/tools/virtiofsd/passthrough_seccomp.c
|
||||
@@ -68,6 +68,7 @@ static const int syscall_whitelist[] = {
|
||||
SCMP_SYS(linkat),
|
||||
SCMP_SYS(listxattr),
|
||||
SCMP_SYS(lseek),
|
||||
+ SCMP_SYS(_llseek), /* For POWER */
|
||||
SCMP_SYS(madvise),
|
||||
SCMP_SYS(mkdirat),
|
||||
SCMP_SYS(mknodat),
|
34
debian/patches/extra/0008-block-nbd-Assert-there-are-no-timers-when-closed.patch
vendored
Normal file
34
debian/patches/extra/0008-block-nbd-Assert-there-are-no-timers-when-closed.patch
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hanna Reitz <hreitz@redhat.com>
|
||||
Date: Wed, 9 Feb 2022 15:02:54 +0100
|
||||
Subject: [PATCH] block/nbd: Assert there are no timers when closed
|
||||
|
||||
Our two timers must not remain armed beyond nbd_clear_bdrvstate(), or
|
||||
they will access freed data when they fire.
|
||||
|
||||
This patch is separate from the patches that actually fix the issue
|
||||
(HEAD^^ and HEAD^) so that you can run the associated regression iotest
|
||||
(281) on a configuration that reproducibly exposes the bug.
|
||||
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
||||
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
||||
[FE: backport (open_timer doesn't exist yet in 6.2.0)]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/nbd.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/block/nbd.c b/block/nbd.c
|
||||
index b8e5a9b4cc..aab20125d8 100644
|
||||
--- a/block/nbd.c
|
||||
+++ b/block/nbd.c
|
||||
@@ -108,6 +108,9 @@ static void nbd_clear_bdrvstate(BlockDriverState *bs)
|
||||
|
||||
yank_unregister_instance(BLOCKDEV_YANK_INSTANCE(bs->node_name));
|
||||
|
||||
+ /* Must not leave timers behind that would access freed data */
|
||||
+ assert(!s->reconnect_delay_timer);
|
||||
+
|
||||
object_unref(OBJECT(s->tlscreds));
|
||||
qapi_free_SocketAddress(s->saddr);
|
||||
s->saddr = NULL;
|
@@ -1,31 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Greg Kurz <groug@kaod.org>
|
||||
Date: Thu, 4 Feb 2021 18:34:39 +0000
|
||||
Subject: [PATCH] virtiofsd: Add restart_syscall to the seccomp whitelist
|
||||
|
||||
This is how linux restarts some system calls after SIGSTOP/SIGCONT.
|
||||
This is needed to avoid virtiofsd termination when resuming execution
|
||||
under GDB for example.
|
||||
|
||||
Signed-off-by: Greg Kurz <groug@kaod.org>
|
||||
Message-Id: <20210201193305.136390-1-groug@kaod.org>
|
||||
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
tools/virtiofsd/passthrough_seccomp.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/tools/virtiofsd/passthrough_seccomp.c b/tools/virtiofsd/passthrough_seccomp.c
|
||||
index bb8ef5b17f..44d75e0e36 100644
|
||||
--- a/tools/virtiofsd/passthrough_seccomp.c
|
||||
+++ b/tools/virtiofsd/passthrough_seccomp.c
|
||||
@@ -92,6 +92,7 @@ static const int syscall_whitelist[] = {
|
||||
SCMP_SYS(renameat),
|
||||
SCMP_SYS(renameat2),
|
||||
SCMP_SYS(removexattr),
|
||||
+ SCMP_SYS(restart_syscall),
|
||||
SCMP_SYS(rt_sigaction),
|
||||
SCMP_SYS(rt_sigprocmask),
|
||||
SCMP_SYS(rt_sigreturn),
|
90
debian/patches/extra/0009-block-nbd-Move-s-ioc-on-AioContext-change.patch
vendored
Normal file
90
debian/patches/extra/0009-block-nbd-Move-s-ioc-on-AioContext-change.patch
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hanna Reitz <hreitz@redhat.com>
|
||||
Date: Wed, 9 Feb 2022 15:02:57 +0100
|
||||
Subject: [PATCH] block/nbd: Move s->ioc on AioContext change
|
||||
|
||||
s->ioc must always be attached to the NBD node's AioContext. If that
|
||||
context changes, s->ioc must be attached to the new context.
|
||||
|
||||
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2033626
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
||||
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
||||
[FE: backport (open_timer doesn't exist yet in 6.2.0)]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/nbd.c | 41 +++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 41 insertions(+)
|
||||
|
||||
diff --git a/block/nbd.c b/block/nbd.c
|
||||
index aab20125d8..a3896c7f5f 100644
|
||||
--- a/block/nbd.c
|
||||
+++ b/block/nbd.c
|
||||
@@ -2003,6 +2003,38 @@ static void nbd_cancel_in_flight(BlockDriverState *bs)
|
||||
nbd_co_establish_connection_cancel(s->conn);
|
||||
}
|
||||
|
||||
+static void nbd_attach_aio_context(BlockDriverState *bs,
|
||||
+ AioContext *new_context)
|
||||
+{
|
||||
+ BDRVNBDState *s = bs->opaque;
|
||||
+
|
||||
+ /*
|
||||
+ * The reconnect_delay_timer is scheduled in I/O paths when the
|
||||
+ * connection is lost, to cancel the reconnection attempt after a
|
||||
+ * given time. Once this attempt is done (successfully or not),
|
||||
+ * nbd_reconnect_attempt() ensures the timer is deleted before the
|
||||
+ * respective I/O request is resumed.
|
||||
+ * Since the AioContext can only be changed when a node is drained,
|
||||
+ * the reconnect_delay_timer cannot be active here.
|
||||
+ */
|
||||
+ assert(!s->reconnect_delay_timer);
|
||||
+
|
||||
+ if (s->ioc) {
|
||||
+ qio_channel_attach_aio_context(s->ioc, new_context);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void nbd_detach_aio_context(BlockDriverState *bs)
|
||||
+{
|
||||
+ BDRVNBDState *s = bs->opaque;
|
||||
+
|
||||
+ assert(!s->reconnect_delay_timer);
|
||||
+
|
||||
+ if (s->ioc) {
|
||||
+ qio_channel_detach_aio_context(s->ioc);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static BlockDriver bdrv_nbd = {
|
||||
.format_name = "nbd",
|
||||
.protocol_name = "nbd",
|
||||
@@ -2026,6 +2058,9 @@ static BlockDriver bdrv_nbd = {
|
||||
.bdrv_dirname = nbd_dirname,
|
||||
.strong_runtime_opts = nbd_strong_runtime_opts,
|
||||
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
|
||||
+
|
||||
+ .bdrv_attach_aio_context = nbd_attach_aio_context,
|
||||
+ .bdrv_detach_aio_context = nbd_detach_aio_context,
|
||||
};
|
||||
|
||||
static BlockDriver bdrv_nbd_tcp = {
|
||||
@@ -2051,6 +2086,9 @@ static BlockDriver bdrv_nbd_tcp = {
|
||||
.bdrv_dirname = nbd_dirname,
|
||||
.strong_runtime_opts = nbd_strong_runtime_opts,
|
||||
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
|
||||
+
|
||||
+ .bdrv_attach_aio_context = nbd_attach_aio_context,
|
||||
+ .bdrv_detach_aio_context = nbd_detach_aio_context,
|
||||
};
|
||||
|
||||
static BlockDriver bdrv_nbd_unix = {
|
||||
@@ -2076,6 +2114,9 @@ static BlockDriver bdrv_nbd_unix = {
|
||||
.bdrv_dirname = nbd_dirname,
|
||||
.strong_runtime_opts = nbd_strong_runtime_opts,
|
||||
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
|
||||
+
|
||||
+ .bdrv_attach_aio_context = nbd_attach_aio_context,
|
||||
+ .bdrv_detach_aio_context = nbd_detach_aio_context,
|
||||
};
|
||||
|
||||
static void bdrv_nbd_init(void)
|
@@ -1,108 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Vitaly Cheptsov <cheptsov@ispras.ru>
|
||||
Date: Tue, 2 Mar 2021 09:21:10 -0500
|
||||
Subject: [PATCH] i386/acpi: restore device paths for pre-5.1 vms
|
||||
|
||||
After fixing the _UID value for the primary PCI root bridge in
|
||||
af1b80ae it was discovered that this change updates Windows
|
||||
configuration in an incompatible way causing network configuration
|
||||
failure unless DHCP is used. More details provided on the list:
|
||||
|
||||
https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg08484.html
|
||||
|
||||
This change reverts the _UID update from 1 to 0 for q35 and i440fx
|
||||
VMs before version 5.2 to maintain the original behaviour when
|
||||
upgrading.
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Cc: qemu-devel@nongnu.org
|
||||
Reported-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
Suggested-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>
|
||||
Message-Id: <20210301195919.9333-1-cheptsov@ispras.ru>
|
||||
Tested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Fixes: af1b80ae56c9 ("i386/acpi: fix inconsistent QEMU/OVMF device paths")
|
||||
---
|
||||
hw/i386/acpi-build.c | 4 ++--
|
||||
hw/i386/pc_piix.c | 2 ++
|
||||
hw/i386/pc_q35.c | 2 ++
|
||||
include/hw/i386/pc.h | 1 +
|
||||
4 files changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
|
||||
index 1f5c211245..b5616582a5 100644
|
||||
--- a/hw/i386/acpi-build.c
|
||||
+++ b/hw/i386/acpi-build.c
|
||||
@@ -1513,7 +1513,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
|
||||
dev = aml_device("PCI0");
|
||||
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
|
||||
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
|
||||
- aml_append(dev, aml_name_decl("_UID", aml_int(0)));
|
||||
+ aml_append(dev, aml_name_decl("_UID", aml_int(pcmc->pci_root_uid)));
|
||||
aml_append(sb_scope, dev);
|
||||
aml_append(dsdt, sb_scope);
|
||||
|
||||
@@ -1530,7 +1530,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
|
||||
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08")));
|
||||
aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03")));
|
||||
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
|
||||
- aml_append(dev, aml_name_decl("_UID", aml_int(0)));
|
||||
+ aml_append(dev, aml_name_decl("_UID", aml_int(pcmc->pci_root_uid)));
|
||||
aml_append(dev, build_q35_osc_method());
|
||||
aml_append(sb_scope, dev);
|
||||
|
||||
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
|
||||
index 13d1628f13..2524c96216 100644
|
||||
--- a/hw/i386/pc_piix.c
|
||||
+++ b/hw/i386/pc_piix.c
|
||||
@@ -417,6 +417,7 @@ static void pc_i440fx_machine_options(MachineClass *m)
|
||||
{
|
||||
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
|
||||
pcmc->default_nic_model = "e1000";
|
||||
+ pcmc->pci_root_uid = 0;
|
||||
|
||||
m->family = "pc_piix";
|
||||
m->desc = "Standard PC (i440FX + PIIX, 1996)";
|
||||
@@ -448,6 +449,7 @@ static void pc_i440fx_5_1_machine_options(MachineClass *m)
|
||||
compat_props_add(m->compat_props, hw_compat_5_1, hw_compat_5_1_len);
|
||||
compat_props_add(m->compat_props, pc_compat_5_1, pc_compat_5_1_len);
|
||||
pcmc->kvmclock_create_always = false;
|
||||
+ pcmc->pci_root_uid = 1;
|
||||
}
|
||||
|
||||
DEFINE_I440FX_MACHINE(v5_1, "pc-i440fx-5.1", NULL,
|
||||
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
|
||||
index a3f4959c43..c58dad5ae3 100644
|
||||
--- a/hw/i386/pc_q35.c
|
||||
+++ b/hw/i386/pc_q35.c
|
||||
@@ -329,6 +329,7 @@ static void pc_q35_machine_options(MachineClass *m)
|
||||
{
|
||||
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
|
||||
pcmc->default_nic_model = "e1000e";
|
||||
+ pcmc->pci_root_uid = 0;
|
||||
|
||||
m->family = "pc_q35";
|
||||
m->desc = "Standard PC (Q35 + ICH9, 2009)";
|
||||
@@ -364,6 +365,7 @@ static void pc_q35_5_1_machine_options(MachineClass *m)
|
||||
compat_props_add(m->compat_props, hw_compat_5_1, hw_compat_5_1_len);
|
||||
compat_props_add(m->compat_props, pc_compat_5_1, pc_compat_5_1_len);
|
||||
pcmc->kvmclock_create_always = false;
|
||||
+ pcmc->pci_root_uid = 1;
|
||||
}
|
||||
|
||||
DEFINE_Q35_MACHINE(v5_1, "pc-q35-5.1", NULL,
|
||||
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
|
||||
index 911e460097..7f8e1a791f 100644
|
||||
--- a/include/hw/i386/pc.h
|
||||
+++ b/include/hw/i386/pc.h
|
||||
@@ -99,6 +99,7 @@ struct PCMachineClass {
|
||||
int legacy_acpi_table_size;
|
||||
unsigned acpi_data_size;
|
||||
bool do_not_add_smb_acpi;
|
||||
+ int pci_root_uid;
|
||||
|
||||
/* SMBIOS compat: */
|
||||
bool smbios_defaults;
|
89
debian/patches/extra/0010-acpi-fix-QEMU-crash-when-started-with-SLIC-table.patch
vendored
Normal file
89
debian/patches/extra/0010-acpi-fix-QEMU-crash-when-started-with-SLIC-table.patch
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Igor Mammedov <imammedo@redhat.com>
|
||||
Date: Mon, 27 Dec 2021 14:31:17 -0500
|
||||
Subject: [PATCH] acpi: fix QEMU crash when started with SLIC table
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
if QEMU is started with used provided SLIC table blob,
|
||||
|
||||
-acpitable sig=SLIC,oem_id='CRASH ',oem_table_id="ME",oem_rev=00002210,asl_compiler_id="",asl_compiler_rev=00000000,data=/dev/null
|
||||
it will assert with:
|
||||
|
||||
hw/acpi/aml-build.c:61:build_append_padded_str: assertion failed: (len <= maxlen)
|
||||
|
||||
and following backtrace:
|
||||
|
||||
...
|
||||
build_append_padded_str (array=0x555556afe320, str=0x555556afdb2e "CRASH ME", maxlen=0x6, pad=0x20) at hw/acpi/aml-build.c:61
|
||||
acpi_table_begin (desc=0x7fffffffd1b0, array=0x555556afe320) at hw/acpi/aml-build.c:1727
|
||||
build_fadt (tbl=0x555556afe320, linker=0x555557ca3830, f=0x7fffffffd318, oem_id=0x555556afdb2e "CRASH ME", oem_table_id=0x555556afdb34 "ME") at hw/acpi/aml-build.c:2064
|
||||
...
|
||||
|
||||
which happens due to acpi_table_begin() expecting NULL terminated
|
||||
oem_id and oem_table_id strings, which is normally the case, but
|
||||
in case of user provided SLIC table, oem_id points to table's blob
|
||||
directly and as result oem_id became longer than expected.
|
||||
|
||||
Fix issue by handling oem_id consistently and make acpi_get_slic_oem()
|
||||
return NULL terminated strings.
|
||||
|
||||
PS:
|
||||
After [1] refactoring, oem_id semantics became inconsistent, where
|
||||
NULL terminated string was coming from machine and old way pointer
|
||||
into byte array coming from -acpitable option. That used to work
|
||||
since build_header() wasn't expecting NULL terminated string and
|
||||
blindly copied the 1st 6 bytes only.
|
||||
|
||||
However commit [2] broke that by replacing build_header() with
|
||||
acpi_table_begin(), which was expecting NULL terminated string
|
||||
and was checking oem_id size.
|
||||
|
||||
1) 602b45820 ("acpi: Permit OEM ID and OEM table ID fields to be changed")
|
||||
2)
|
||||
Fixes: 4b56e1e4eb08 ("acpi: build_fadt: use acpi_table_begin()/acpi_table_end() instead of build_header()")
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/786
|
||||
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
||||
Message-Id: <20211227193120.1084176-2-imammedo@redhat.com>
|
||||
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
||||
Tested-by: Denis Lisov <dennis.lissov@gmail.com>
|
||||
Tested-by: Alexander Tsoy <alexander@tsoy.me>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit 8cdb99af45365727ac17f45239a9b8c1d5155c6d)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/acpi/core.c | 4 ++--
|
||||
hw/i386/acpi-build.c | 2 ++
|
||||
2 files changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
|
||||
index 1e004d0078..3e811bf03c 100644
|
||||
--- a/hw/acpi/core.c
|
||||
+++ b/hw/acpi/core.c
|
||||
@@ -345,8 +345,8 @@ int acpi_get_slic_oem(AcpiSlicOem *oem)
|
||||
struct acpi_table_header *hdr = (void *)(u - sizeof(hdr->_length));
|
||||
|
||||
if (memcmp(hdr->sig, "SLIC", 4) == 0) {
|
||||
- oem->id = hdr->oem_id;
|
||||
- oem->table_id = hdr->oem_table_id;
|
||||
+ oem->id = g_strndup(hdr->oem_id, 6);
|
||||
+ oem->table_id = g_strndup(hdr->oem_table_id, 8);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
|
||||
index a99c6e4fe3..570f82997b 100644
|
||||
--- a/hw/i386/acpi-build.c
|
||||
+++ b/hw/i386/acpi-build.c
|
||||
@@ -2721,6 +2721,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
||||
|
||||
/* Cleanup memory that's no longer used. */
|
||||
g_array_free(table_offsets, true);
|
||||
+ g_free(slic_oem.id);
|
||||
+ g_free(slic_oem.table_id);
|
||||
}
|
||||
|
||||
static void acpi_ram_update(MemoryRegion *mr, GArray *data)
|
@@ -1,48 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Mon, 22 Mar 2021 15:20:04 +0100
|
||||
Subject: [PATCH] monitor/qmp: fix race on CHR_EVENT_CLOSED without OOB
|
||||
|
||||
The QMP dispatcher coroutine holds the qmp_queue_lock over a yield
|
||||
point, where it expects to be rescheduled from the main context. If a
|
||||
CHR_EVENT_CLOSED event is received just then, it can race and block the
|
||||
main thread on the mutex in monitor_qmp_cleanup_queue_and_resume.
|
||||
|
||||
Calculate need_resume immediately after we pop a request from the queue,
|
||||
so that we can release the mutex before yielding.
|
||||
|
||||
Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
monitor/qmp.c | 11 ++++++-----
|
||||
1 file changed, 6 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/monitor/qmp.c b/monitor/qmp.c
|
||||
index 2e37d11bd3..2aff833f7a 100644
|
||||
--- a/monitor/qmp.c
|
||||
+++ b/monitor/qmp.c
|
||||
@@ -252,6 +252,12 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
+ mon = req_obj->mon;
|
||||
+ /* qmp_oob_enabled() might change after "qmp_capabilities" */
|
||||
+ need_resume = !qmp_oob_enabled(mon) ||
|
||||
+ mon->qmp_requests->length == QMP_REQ_QUEUE_LEN_MAX - 1;
|
||||
+ qemu_mutex_unlock(&mon->qmp_queue_lock);
|
||||
+
|
||||
if (qatomic_xchg(&qmp_dispatcher_co_busy, true) == true) {
|
||||
/*
|
||||
* Someone rescheduled us (probably because a new requests
|
||||
@@ -270,11 +276,6 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)
|
||||
aio_co_schedule(qemu_get_aio_context(), qmp_dispatcher_co);
|
||||
qemu_coroutine_yield();
|
||||
|
||||
- mon = req_obj->mon;
|
||||
- /* qmp_oob_enabled() might change after "qmp_capabilities" */
|
||||
- need_resume = !qmp_oob_enabled(mon) ||
|
||||
- mon->qmp_requests->length == QMP_REQ_QUEUE_LEN_MAX - 1;
|
||||
- qemu_mutex_unlock(&mon->qmp_queue_lock);
|
||||
if (req_obj->req) {
|
||||
QDict *qdict = qobject_to(QDict, req_obj->req);
|
||||
QObject *id = qdict ? qdict_get(qdict, "id") : NULL;
|
@@ -1,42 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Wolf <kwolf@redhat.com>
|
||||
Date: Thu, 3 Dec 2020 18:23:10 +0100
|
||||
Subject: [PATCH] block: Fix locking in qmp_block_resize()
|
||||
|
||||
The drain functions assume that we hold the AioContext lock of the
|
||||
drained block node. Make sure to actually take the lock.
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: eb94b81a94bce112e6b206df846c1551aaf6cab6
|
||||
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||||
Message-Id: <20201203172311.68232-3-kwolf@redhat.com>
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
||||
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
blockdev.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index fe6fb5dc1d..9a86e9fb4b 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -2481,14 +2481,17 @@ void coroutine_fn qmp_block_resize(bool has_device, const char *device,
|
||||
goto out;
|
||||
}
|
||||
|
||||
+ bdrv_co_lock(bs);
|
||||
bdrv_drained_begin(bs);
|
||||
+ bdrv_co_unlock(bs);
|
||||
+
|
||||
old_ctx = bdrv_co_enter(bs);
|
||||
blk_truncate(blk, size, false, PREALLOC_MODE_OFF, 0, errp);
|
||||
bdrv_co_leave(bs, old_ctx);
|
||||
- bdrv_drained_end(bs);
|
||||
|
||||
out:
|
||||
bdrv_co_lock(bs);
|
||||
+ bdrv_drained_end(bs);
|
||||
blk_unref(blk);
|
||||
bdrv_co_unlock(bs);
|
||||
}
|
38
debian/patches/extra/0011-virtio-net-fix-map-leaking-on-error-during-receive.patch
vendored
Normal file
38
debian/patches/extra/0011-virtio-net-fix-map-leaking-on-error-during-receive.patch
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Wang <jasowang@redhat.com>
|
||||
Date: Tue, 8 Mar 2022 10:42:51 +0800
|
||||
Subject: [PATCH] virtio-net: fix map leaking on error during receive
|
||||
|
||||
Commit bedd7e93d0196 ("virtio-net: fix use after unmap/free for sg")
|
||||
tries to fix the use after free of the sg by caching the virtqueue
|
||||
elements in an array and unmap them at once after receiving the
|
||||
packets, But it forgot to unmap the cached elements on error which
|
||||
will lead to leaking of mapping and other unexpected results.
|
||||
|
||||
Fixing this by detaching the cached elements on error. This addresses
|
||||
CVE-2022-26353.
|
||||
|
||||
Reported-by: Victor Tom <vv474172261@gmail.com>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: CVE-2022-26353
|
||||
Fixes: bedd7e93d0196 ("virtio-net: fix use after unmap/free for sg")
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
||||
(cherry picked from commit abe300d9d894f7138e1af7c8e9c88c04bfe98b37)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/net/virtio-net.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
|
||||
index f2014d5ea0..e1f4748831 100644
|
||||
--- a/hw/net/virtio-net.c
|
||||
+++ b/hw/net/virtio-net.c
|
||||
@@ -1862,6 +1862,7 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
|
||||
|
||||
err:
|
||||
for (j = 0; j < i; j++) {
|
||||
+ virtqueue_detach_element(q->rx_vq, elems[j], lens[j]);
|
||||
g_free(elems[j]);
|
||||
}
|
||||
|
@@ -1,118 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Wolf <kwolf@redhat.com>
|
||||
Date: Thu, 3 Dec 2020 18:23:11 +0100
|
||||
Subject: [PATCH] block: Fix deadlock in bdrv_co_yield_to_drain()
|
||||
|
||||
If bdrv_co_yield_to_drain() is called for draining a block node that
|
||||
runs in a different AioContext, it keeps that AioContext locked while it
|
||||
yields and schedules a BH in the AioContext to do the actual drain.
|
||||
|
||||
As long as executing the BH is the very next thing that the event loop
|
||||
of the node's AioContext does, this actually happens to work, but when
|
||||
it tries to execute something else that wants to take the AioContext
|
||||
lock, it will deadlock. (In the bug report, this other thing is a
|
||||
virtio-scsi device running virtio_scsi_data_plane_handle_cmd().)
|
||||
|
||||
Instead, always drop the AioContext lock across the yield and reacquire
|
||||
it only when the coroutine is reentered. The BH needs to unconditionally
|
||||
take the lock for itself now.
|
||||
|
||||
This fixes the 'block_resize' QMP command on a block node that runs in
|
||||
an iothread.
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: eb94b81a94bce112e6b206df846c1551aaf6cab6
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1903511
|
||||
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||||
Message-Id: <20201203172311.68232-4-kwolf@redhat.com>
|
||||
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
||||
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
block/io.c | 41 ++++++++++++++++++++++++-----------------
|
||||
1 file changed, 24 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/block/io.c b/block/io.c
|
||||
index ec5e152bb7..a9f56a9ab1 100644
|
||||
--- a/block/io.c
|
||||
+++ b/block/io.c
|
||||
@@ -306,17 +306,7 @@ static void bdrv_co_drain_bh_cb(void *opaque)
|
||||
|
||||
if (bs) {
|
||||
AioContext *ctx = bdrv_get_aio_context(bs);
|
||||
- AioContext *co_ctx = qemu_coroutine_get_aio_context(co);
|
||||
-
|
||||
- /*
|
||||
- * When the coroutine yielded, the lock for its home context was
|
||||
- * released, so we need to re-acquire it here. If it explicitly
|
||||
- * acquired a different context, the lock is still held and we don't
|
||||
- * want to lock it a second time (or AIO_WAIT_WHILE() would hang).
|
||||
- */
|
||||
- if (ctx == co_ctx) {
|
||||
- aio_context_acquire(ctx);
|
||||
- }
|
||||
+ aio_context_acquire(ctx);
|
||||
bdrv_dec_in_flight(bs);
|
||||
if (data->begin) {
|
||||
assert(!data->drained_end_counter);
|
||||
@@ -328,9 +318,7 @@ static void bdrv_co_drain_bh_cb(void *opaque)
|
||||
data->ignore_bds_parents,
|
||||
data->drained_end_counter);
|
||||
}
|
||||
- if (ctx == co_ctx) {
|
||||
- aio_context_release(ctx);
|
||||
- }
|
||||
+ aio_context_release(ctx);
|
||||
} else {
|
||||
assert(data->begin);
|
||||
bdrv_drain_all_begin();
|
||||
@@ -348,13 +336,16 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
|
||||
int *drained_end_counter)
|
||||
{
|
||||
BdrvCoDrainData data;
|
||||
+ Coroutine *self = qemu_coroutine_self();
|
||||
+ AioContext *ctx = bdrv_get_aio_context(bs);
|
||||
+ AioContext *co_ctx = qemu_coroutine_get_aio_context(self);
|
||||
|
||||
/* Calling bdrv_drain() from a BH ensures the current coroutine yields and
|
||||
* other coroutines run if they were queued by aio_co_enter(). */
|
||||
|
||||
assert(qemu_in_coroutine());
|
||||
data = (BdrvCoDrainData) {
|
||||
- .co = qemu_coroutine_self(),
|
||||
+ .co = self,
|
||||
.bs = bs,
|
||||
.done = false,
|
||||
.begin = begin,
|
||||
@@ -368,13 +359,29 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
|
||||
if (bs) {
|
||||
bdrv_inc_in_flight(bs);
|
||||
}
|
||||
- replay_bh_schedule_oneshot_event(bdrv_get_aio_context(bs),
|
||||
- bdrv_co_drain_bh_cb, &data);
|
||||
+
|
||||
+ /*
|
||||
+ * Temporarily drop the lock across yield or we would get deadlocks.
|
||||
+ * bdrv_co_drain_bh_cb() reaquires the lock as needed.
|
||||
+ *
|
||||
+ * When we yield below, the lock for the current context will be
|
||||
+ * released, so if this is actually the lock that protects bs, don't drop
|
||||
+ * it a second time.
|
||||
+ */
|
||||
+ if (ctx != co_ctx) {
|
||||
+ aio_context_release(ctx);
|
||||
+ }
|
||||
+ replay_bh_schedule_oneshot_event(ctx, bdrv_co_drain_bh_cb, &data);
|
||||
|
||||
qemu_coroutine_yield();
|
||||
/* If we are resumed from some other event (such as an aio completion or a
|
||||
* timer callback), it is a bug in the caller that should be fixed. */
|
||||
assert(data.done);
|
||||
+
|
||||
+ /* Reaquire the AioContext of bs if we dropped it */
|
||||
+ if (ctx != co_ctx) {
|
||||
+ aio_context_acquire(ctx);
|
||||
+ }
|
||||
}
|
||||
|
||||
void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
|
86
debian/patches/extra/0012-memory-Fix-incorrect-calls-of-log_global_start-stop.patch
vendored
Normal file
86
debian/patches/extra/0012-memory-Fix-incorrect-calls-of-log_global_start-stop.patch
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Xu <peterx@redhat.com>
|
||||
Date: Tue, 30 Nov 2021 16:00:28 +0800
|
||||
Subject: [PATCH] memory: Fix incorrect calls of log_global_start/stop
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
We should only call the log_global_start/stop when the global dirty track
|
||||
bitmask changes from zero<->non-zero.
|
||||
|
||||
No real issue reported for this yet probably because no immediate user to
|
||||
enable both dirty rate measurement and migration at the same time. However
|
||||
it'll be good to be prepared for it.
|
||||
|
||||
Fixes: 63b41db4bc ("memory: make global_dirty_tracking a bitmask")
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Cc: Hyman Huang <huangy81@chinatelecom.cn>
|
||||
Cc: Paolo Bonzini <pbonzini@redhat.com>
|
||||
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
Cc: Juan Quintela <quintela@redhat.com>
|
||||
Cc: David Hildenbrand <david@redhat.com>
|
||||
Signed-off-by: Peter Xu <peterx@redhat.com>
|
||||
Reviewed-by: David Hildenbrand <david@redhat.com>
|
||||
Message-Id: <20211130080028.6474-1-peterx@redhat.com>
|
||||
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
(cherry picked from commit 7b0538ed3a22ce30817f818449d10701fb0821f9)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
softmmu/memory.c | 27 ++++++++++++++-------------
|
||||
1 file changed, 14 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/softmmu/memory.c b/softmmu/memory.c
|
||||
index 7340e19ff5..81d4bf1454 100644
|
||||
--- a/softmmu/memory.c
|
||||
+++ b/softmmu/memory.c
|
||||
@@ -2773,6 +2773,8 @@ static VMChangeStateEntry *vmstate_change;
|
||||
|
||||
void memory_global_dirty_log_start(unsigned int flags)
|
||||
{
|
||||
+ unsigned int old_flags = global_dirty_tracking;
|
||||
+
|
||||
if (vmstate_change) {
|
||||
qemu_del_vm_change_state_handler(vmstate_change);
|
||||
vmstate_change = NULL;
|
||||
@@ -2781,15 +2783,14 @@ void memory_global_dirty_log_start(unsigned int flags)
|
||||
assert(flags && !(flags & (~GLOBAL_DIRTY_MASK)));
|
||||
assert(!(global_dirty_tracking & flags));
|
||||
global_dirty_tracking |= flags;
|
||||
-
|
||||
trace_global_dirty_changed(global_dirty_tracking);
|
||||
|
||||
- MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
|
||||
-
|
||||
- /* Refresh DIRTY_MEMORY_MIGRATION bit. */
|
||||
- memory_region_transaction_begin();
|
||||
- memory_region_update_pending = true;
|
||||
- memory_region_transaction_commit();
|
||||
+ if (!old_flags) {
|
||||
+ MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
|
||||
+ memory_region_transaction_begin();
|
||||
+ memory_region_update_pending = true;
|
||||
+ memory_region_transaction_commit();
|
||||
+ }
|
||||
}
|
||||
|
||||
static void memory_global_dirty_log_do_stop(unsigned int flags)
|
||||
@@ -2800,12 +2801,12 @@ static void memory_global_dirty_log_do_stop(unsigned int flags)
|
||||
|
||||
trace_global_dirty_changed(global_dirty_tracking);
|
||||
|
||||
- /* Refresh DIRTY_MEMORY_MIGRATION bit. */
|
||||
- memory_region_transaction_begin();
|
||||
- memory_region_update_pending = true;
|
||||
- memory_region_transaction_commit();
|
||||
-
|
||||
- MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
|
||||
+ if (!global_dirty_tracking) {
|
||||
+ memory_region_transaction_begin();
|
||||
+ memory_region_update_pending = true;
|
||||
+ memory_region_transaction_commit();
|
||||
+ MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
|
||||
+ }
|
||||
}
|
||||
|
||||
static void memory_vm_change_state_handler(void *opaque, bool running,
|
59
debian/patches/extra/0013-acpi-fix-OEM-ID-OEM-Table-ID-padding.patch
vendored
Normal file
59
debian/patches/extra/0013-acpi-fix-OEM-ID-OEM-Table-ID-padding.patch
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Igor Mammedov <imammedo@redhat.com>
|
||||
Date: Wed, 12 Jan 2022 08:03:31 -0500
|
||||
Subject: [PATCH] acpi: fix OEM ID/OEM Table ID padding
|
||||
|
||||
Commit [2] broke original '\0' padding of OEM ID and OEM Table ID
|
||||
fields in headers of ACPI tables. While it doesn't have impact on
|
||||
default values since QEMU uses 6 and 8 characters long values
|
||||
respectively, it broke usecase where IDs are provided on QEMU CLI.
|
||||
It shouldn't affect guest (but may cause licensing verification
|
||||
issues in guest OS).
|
||||
One of the broken usecases is user supplied SLIC table with IDs
|
||||
shorter than max possible length, where [2] mangles IDs with extra
|
||||
spaces in RSDT and FADT tables whereas guest OS expects those to
|
||||
mirror the respective values of the used SLIC table.
|
||||
|
||||
Fix it by replacing whitespace padding with '\0' padding in
|
||||
accordance with [1] and expectations of guest OS
|
||||
|
||||
1) ACPI spec, v2.0b
|
||||
17.2 AML Grammar Definition
|
||||
...
|
||||
//OEM ID of up to 6 characters. If the OEM ID is
|
||||
//shorter than 6 characters, it can be terminated
|
||||
//with a NULL character.
|
||||
|
||||
2)
|
||||
Fixes: 602b458201 ("acpi: Permit OEM ID and OEM table ID fields to be changed")
|
||||
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/707
|
||||
Reported-by: Dmitry V. Orekhov <dima.orekhov@gmail.com>
|
||||
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Message-Id: <20220112130332.1648664-4-imammedo@redhat.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Reviewed-by: Ani Sinha <ani@anisinha.ca>
|
||||
Tested-by: Dmitry V. Orekhov dima.orekhov@gmail.com
|
||||
(cherry picked from commit 748c030f360a940fe0c9382c8ca1649096c3a80d)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/acpi/aml-build.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
|
||||
index b3b3310df3..65148d5b9d 100644
|
||||
--- a/hw/acpi/aml-build.c
|
||||
+++ b/hw/acpi/aml-build.c
|
||||
@@ -1724,9 +1724,9 @@ void acpi_table_begin(AcpiTable *desc, GArray *array)
|
||||
build_append_int_noprefix(array, 0, 4); /* Length */
|
||||
build_append_int_noprefix(array, desc->rev, 1); /* Revision */
|
||||
build_append_int_noprefix(array, 0, 1); /* Checksum */
|
||||
- build_append_padded_str(array, desc->oem_id, 6, ' '); /* OEMID */
|
||||
+ build_append_padded_str(array, desc->oem_id, 6, '\0'); /* OEMID */
|
||||
/* OEM Table ID */
|
||||
- build_append_padded_str(array, desc->oem_table_id, 8, ' ');
|
||||
+ build_append_padded_str(array, desc->oem_table_id, 8, '\0');
|
||||
build_append_int_noprefix(array, 1, 4); /* OEM Revision */
|
||||
g_array_append_vals(array, ACPI_BUILD_APPNAME8, 4); /* Creator ID */
|
||||
build_append_int_noprefix(array, 1, 4); /* Creator Revision */
|
55
debian/patches/extra/0014-vhost-vsock-detach-the-virqueue-element-in-case-of-e.patch
vendored
Normal file
55
debian/patches/extra/0014-vhost-vsock-detach-the-virqueue-element-in-case-of-e.patch
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefano Garzarella <sgarzare@redhat.com>
|
||||
Date: Mon, 28 Feb 2022 10:50:58 +0100
|
||||
Subject: [PATCH] vhost-vsock: detach the virqueue element in case of error
|
||||
|
||||
In vhost_vsock_common_send_transport_reset(), if an element popped from
|
||||
the virtqueue is invalid, we should call virtqueue_detach_element() to
|
||||
detach it from the virtqueue before freeing its memory.
|
||||
|
||||
Fixes: fc0b9b0e1c ("vhost-vsock: add virtio sockets device")
|
||||
Fixes: CVE-2022-26354
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Reported-by: VictorV <vv474172261@gmail.com>
|
||||
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
|
||||
Message-Id: <20220228095058.27899-1-sgarzare@redhat.com>
|
||||
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit 8d1b247f3748ac4078524130c6d7ae42b6140aaf)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/virtio/vhost-vsock-common.c | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
|
||||
index 3f3771274e..ed706681ac 100644
|
||||
--- a/hw/virtio/vhost-vsock-common.c
|
||||
+++ b/hw/virtio/vhost-vsock-common.c
|
||||
@@ -153,19 +153,23 @@ static void vhost_vsock_common_send_transport_reset(VHostVSockCommon *vvc)
|
||||
if (elem->out_num) {
|
||||
error_report("invalid vhost-vsock event virtqueue element with "
|
||||
"out buffers");
|
||||
- goto out;
|
||||
+ goto err;
|
||||
}
|
||||
|
||||
if (iov_from_buf(elem->in_sg, elem->in_num, 0,
|
||||
&event, sizeof(event)) != sizeof(event)) {
|
||||
error_report("vhost-vsock event virtqueue element is too short");
|
||||
- goto out;
|
||||
+ goto err;
|
||||
}
|
||||
|
||||
virtqueue_push(vq, elem, sizeof(event));
|
||||
virtio_notify(VIRTIO_DEVICE(vvc), vq);
|
||||
|
||||
-out:
|
||||
+ g_free(elem);
|
||||
+ return;
|
||||
+
|
||||
+err:
|
||||
+ virtqueue_detach_element(vq, elem, 0);
|
||||
g_free(elem);
|
||||
}
|
||||
|
98
debian/patches/extra/0015-vhost-user-remove-VirtQ-notifier-restore.patch
vendored
Normal file
98
debian/patches/extra/0015-vhost-user-remove-VirtQ-notifier-restore.patch
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Xueming Li <xuemingl@nvidia.com>
|
||||
Date: Mon, 7 Feb 2022 15:19:28 +0800
|
||||
Subject: [PATCH] vhost-user: remove VirtQ notifier restore
|
||||
|
||||
Notifier set when vhost-user backend asks qemu to mmap an FD and
|
||||
offset. When vhost-user backend restart or getting killed, VQ notifier
|
||||
FD and mmap addresses become invalid. After backend restart, MR contains
|
||||
the invalid address will be restored and fail on notifier access.
|
||||
|
||||
On the other hand, qemu should munmap the notifier, release underlying
|
||||
hardware resources to enable backend restart and allocate hardware
|
||||
notifier resources correctly.
|
||||
|
||||
Qemu shouldn't reference and use resources of disconnected backend.
|
||||
|
||||
This patch removes VQ notifier restore, uses the default vhost-user
|
||||
notifier to avoid invalid address access.
|
||||
|
||||
After backend restart, the backend should ask qemu to install a hardware
|
||||
notifier if needed.
|
||||
|
||||
Fixes: 44866521bd6e ("vhost-user: support registering external host notifiers")
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
|
||||
Message-Id: <20220207071929.527149-2-xuemingl@nvidia.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit e867144b73b3c5009266b6df07d5ff44acfb82c3)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/virtio/vhost-user.c | 19 +------------------
|
||||
include/hw/virtio/vhost-user.h | 1 -
|
||||
2 files changed, 1 insertion(+), 19 deletions(-)
|
||||
|
||||
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
|
||||
index bf6e50223c..c671719e9b 100644
|
||||
--- a/hw/virtio/vhost-user.c
|
||||
+++ b/hw/virtio/vhost-user.c
|
||||
@@ -1143,19 +1143,6 @@ static int vhost_user_set_vring_num(struct vhost_dev *dev,
|
||||
return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring);
|
||||
}
|
||||
|
||||
-static void vhost_user_host_notifier_restore(struct vhost_dev *dev,
|
||||
- int queue_idx)
|
||||
-{
|
||||
- struct vhost_user *u = dev->opaque;
|
||||
- VhostUserHostNotifier *n = &u->user->notifier[queue_idx];
|
||||
- VirtIODevice *vdev = dev->vdev;
|
||||
-
|
||||
- if (n->addr && !n->set) {
|
||||
- virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true);
|
||||
- n->set = true;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
static void vhost_user_host_notifier_remove(struct vhost_dev *dev,
|
||||
int queue_idx)
|
||||
{
|
||||
@@ -1163,17 +1150,14 @@ static void vhost_user_host_notifier_remove(struct vhost_dev *dev,
|
||||
VhostUserHostNotifier *n = &u->user->notifier[queue_idx];
|
||||
VirtIODevice *vdev = dev->vdev;
|
||||
|
||||
- if (n->addr && n->set) {
|
||||
+ if (n->addr) {
|
||||
virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
|
||||
- n->set = false;
|
||||
}
|
||||
}
|
||||
|
||||
static int vhost_user_set_vring_base(struct vhost_dev *dev,
|
||||
struct vhost_vring_state *ring)
|
||||
{
|
||||
- vhost_user_host_notifier_restore(dev, ring->index);
|
||||
-
|
||||
return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring);
|
||||
}
|
||||
|
||||
@@ -1538,7 +1522,6 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
|
||||
}
|
||||
|
||||
n->addr = addr;
|
||||
- n->set = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h
|
||||
index a9abca3288..f6012b2078 100644
|
||||
--- a/include/hw/virtio/vhost-user.h
|
||||
+++ b/include/hw/virtio/vhost-user.h
|
||||
@@ -14,7 +14,6 @@
|
||||
typedef struct VhostUserHostNotifier {
|
||||
MemoryRegion mr;
|
||||
void *addr;
|
||||
- bool set;
|
||||
} VhostUserHostNotifier;
|
||||
|
||||
typedef struct VhostUserState {
|
149
debian/patches/extra/0016-vhost-user-fix-VirtQ-notifier-cleanup.patch
vendored
Normal file
149
debian/patches/extra/0016-vhost-user-fix-VirtQ-notifier-cleanup.patch
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Xueming Li <xuemingl@nvidia.com>
|
||||
Date: Mon, 7 Feb 2022 15:19:29 +0800
|
||||
Subject: [PATCH] vhost-user: fix VirtQ notifier cleanup
|
||||
|
||||
When vhost-user device cleanup, remove notifier MR and munmaps notifier
|
||||
address in the event-handling thread, VM CPU thread writing the notifier
|
||||
in concurrent fails with an error of accessing invalid address. It
|
||||
happens because MR is still being referenced and accessed in another
|
||||
thread while the underlying notifier mmap address is being freed and
|
||||
becomes invalid.
|
||||
|
||||
This patch calls RCU and munmap notifiers in the callback after the
|
||||
memory flatview update finish.
|
||||
|
||||
Fixes: 44866521bd6e ("vhost-user: support registering external host notifiers")
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
|
||||
Message-Id: <20220207071929.527149-3-xuemingl@nvidia.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
(cherry picked from commit 0b0af4d62f7002b31cd7b2762b26d2fcb76bb2ba)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/virtio/vhost-user.c | 48 ++++++++++++++++++++--------------
|
||||
include/hw/virtio/vhost-user.h | 2 ++
|
||||
2 files changed, 31 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
|
||||
index c671719e9b..ed5f9a5471 100644
|
||||
--- a/hw/virtio/vhost-user.c
|
||||
+++ b/hw/virtio/vhost-user.c
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "migration/migration.h"
|
||||
#include "migration/postcopy-ram.h"
|
||||
#include "trace.h"
|
||||
+#include "exec/ramblock.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -1143,15 +1144,26 @@ static int vhost_user_set_vring_num(struct vhost_dev *dev,
|
||||
return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring);
|
||||
}
|
||||
|
||||
-static void vhost_user_host_notifier_remove(struct vhost_dev *dev,
|
||||
- int queue_idx)
|
||||
+static void vhost_user_host_notifier_free(VhostUserHostNotifier *n)
|
||||
{
|
||||
- struct vhost_user *u = dev->opaque;
|
||||
- VhostUserHostNotifier *n = &u->user->notifier[queue_idx];
|
||||
- VirtIODevice *vdev = dev->vdev;
|
||||
+ assert(n && n->unmap_addr);
|
||||
+ munmap(n->unmap_addr, qemu_real_host_page_size);
|
||||
+ n->unmap_addr = NULL;
|
||||
+}
|
||||
+
|
||||
+static void vhost_user_host_notifier_remove(VhostUserState *user,
|
||||
+ VirtIODevice *vdev, int queue_idx)
|
||||
+{
|
||||
+ VhostUserHostNotifier *n = &user->notifier[queue_idx];
|
||||
|
||||
if (n->addr) {
|
||||
- virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
|
||||
+ if (vdev) {
|
||||
+ virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
|
||||
+ }
|
||||
+ assert(!n->unmap_addr);
|
||||
+ n->unmap_addr = n->addr;
|
||||
+ n->addr = NULL;
|
||||
+ call_rcu(n, vhost_user_host_notifier_free, rcu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1190,8 +1202,9 @@ static int vhost_user_get_vring_base(struct vhost_dev *dev,
|
||||
.payload.state = *ring,
|
||||
.hdr.size = sizeof(msg.payload.state),
|
||||
};
|
||||
+ struct vhost_user *u = dev->opaque;
|
||||
|
||||
- vhost_user_host_notifier_remove(dev, ring->index);
|
||||
+ vhost_user_host_notifier_remove(u->user, dev->vdev, ring->index);
|
||||
|
||||
if (vhost_user_write(dev, &msg, NULL, 0) < 0) {
|
||||
return -1;
|
||||
@@ -1486,12 +1499,7 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
|
||||
|
||||
n = &user->notifier[queue_idx];
|
||||
|
||||
- if (n->addr) {
|
||||
- virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
|
||||
- object_unparent(OBJECT(&n->mr));
|
||||
- munmap(n->addr, page_size);
|
||||
- n->addr = NULL;
|
||||
- }
|
||||
+ vhost_user_host_notifier_remove(user, vdev, queue_idx);
|
||||
|
||||
if (area->u64 & VHOST_USER_VRING_NOFD_MASK) {
|
||||
return 0;
|
||||
@@ -1510,9 +1518,12 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
|
||||
|
||||
name = g_strdup_printf("vhost-user/host-notifier@%p mmaps[%d]",
|
||||
user, queue_idx);
|
||||
- if (!n->mr.ram) /* Don't init again after suspend. */
|
||||
+ if (!n->mr.ram) { /* Don't init again after suspend. */
|
||||
memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name,
|
||||
page_size, addr);
|
||||
+ } else {
|
||||
+ n->mr.ram_block->host = addr;
|
||||
+ }
|
||||
g_free(name);
|
||||
|
||||
if (virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true)) {
|
||||
@@ -2460,17 +2471,16 @@ bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp)
|
||||
void vhost_user_cleanup(VhostUserState *user)
|
||||
{
|
||||
int i;
|
||||
+ VhostUserHostNotifier *n;
|
||||
|
||||
if (!user->chr) {
|
||||
return;
|
||||
}
|
||||
memory_region_transaction_begin();
|
||||
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
|
||||
- if (user->notifier[i].addr) {
|
||||
- object_unparent(OBJECT(&user->notifier[i].mr));
|
||||
- munmap(user->notifier[i].addr, qemu_real_host_page_size);
|
||||
- user->notifier[i].addr = NULL;
|
||||
- }
|
||||
+ n = &user->notifier[i];
|
||||
+ vhost_user_host_notifier_remove(user, NULL, i);
|
||||
+ object_unparent(OBJECT(&n->mr));
|
||||
}
|
||||
memory_region_transaction_commit();
|
||||
user->chr = NULL;
|
||||
diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h
|
||||
index f6012b2078..e44a41bb70 100644
|
||||
--- a/include/hw/virtio/vhost-user.h
|
||||
+++ b/include/hw/virtio/vhost-user.h
|
||||
@@ -12,8 +12,10 @@
|
||||
#include "hw/virtio/virtio.h"
|
||||
|
||||
typedef struct VhostUserHostNotifier {
|
||||
+ struct rcu_head rcu;
|
||||
MemoryRegion mr;
|
||||
void *addr;
|
||||
+ void *unmap_addr;
|
||||
} VhostUserHostNotifier;
|
||||
|
||||
typedef struct VhostUserState {
|
101
debian/patches/extra/0017-virtio-fix-the-condition-for-iommu_platform-not-supp.patch
vendored
Normal file
101
debian/patches/extra/0017-virtio-fix-the-condition-for-iommu_platform-not-supp.patch
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Halil Pasic <pasic@linux.ibm.com>
|
||||
Date: Mon, 7 Feb 2022 12:28:57 +0100
|
||||
Subject: [PATCH] virtio: fix the condition for iommu_platform not supported
|
||||
|
||||
The commit 04ceb61a40 ("virtio: Fail if iommu_platform is requested, but
|
||||
unsupported") claims to fail the device hotplug when iommu_platform
|
||||
is requested, but not supported by the (vhost) device. On the first
|
||||
glance the condition for detecting that situation looks perfect, but
|
||||
because a certain peculiarity of virtio_platform it ain't.
|
||||
|
||||
In fact the aforementioned commit introduces a regression. It breaks
|
||||
virtio-fs support for Secure Execution, and most likely also for AMD SEV
|
||||
or any other confidential guest scenario that relies encrypted guest
|
||||
memory. The same also applies to any other vhost device that does not
|
||||
support _F_ACCESS_PLATFORM.
|
||||
|
||||
The peculiarity is that iommu_platform and _F_ACCESS_PLATFORM collates
|
||||
"device can not access all of the guest RAM" and "iova != gpa, thus
|
||||
device needs to translate iova".
|
||||
|
||||
Confidential guest technologies currently rely on the device/hypervisor
|
||||
offering _F_ACCESS_PLATFORM, so that, after the feature has been
|
||||
negotiated, the guest grants access to the portions of memory the
|
||||
device needs to see. So in for confidential guests, generally,
|
||||
_F_ACCESS_PLATFORM is about the restricted access to memory, but not
|
||||
about the addresses used being something else than guest physical
|
||||
addresses.
|
||||
|
||||
This is the very reason for which commit f7ef7e6e3b ("vhost: correctly
|
||||
turn on VIRTIO_F_IOMMU_PLATFORM") fences _F_ACCESS_PLATFORM from the
|
||||
vhost device that does not need it, because on the vhost interface it
|
||||
only means "I/O address translation is needed".
|
||||
|
||||
This patch takes inspiration from f7ef7e6e3b ("vhost: correctly turn on
|
||||
VIRTIO_F_IOMMU_PLATFORM"), and uses the same condition for detecting the
|
||||
situation when _F_ACCESS_PLATFORM is requested, but no I/O translation
|
||||
by the device, and thus no device capability is needed. In this
|
||||
situation claiming that the device does not support iommu_plattform=on
|
||||
is counter-productive. So let us stop doing that!
|
||||
|
||||
Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
|
||||
Reported-by: Jakob Naucke <Jakob.Naucke@ibm.com>
|
||||
Fixes: 04ceb61a40 ("virtio: Fail if iommu_platform is requested, but
|
||||
unsupported")
|
||||
Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
|
||||
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
|
||||
Cc: Kevin Wolf <kwolf@redhat.com>
|
||||
Cc: qemu-stable@nongnu.org
|
||||
|
||||
Message-Id: <20220207112857.607829-1-pasic@linux.ibm.com>
|
||||
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
Acked-by: Jason Wang <jasowang@redhat.com>
|
||||
(cherry picked from commit e65902a913bf31ba79a83a3bd3621108b85cf645)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/virtio/virtio-bus.c | 12 +++++++-----
|
||||
1 file changed, 7 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
|
||||
index d23db98c56..0f69d1c742 100644
|
||||
--- a/hw/virtio/virtio-bus.c
|
||||
+++ b/hw/virtio/virtio-bus.c
|
||||
@@ -48,6 +48,7 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
|
||||
VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
|
||||
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
|
||||
bool has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
|
||||
+ bool vdev_has_iommu;
|
||||
Error *local_err = NULL;
|
||||
|
||||
DPRINTF("%s: plug device.\n", qbus->name);
|
||||
@@ -69,11 +70,6 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
- if (has_iommu && !virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) {
|
||||
- error_setg(errp, "iommu_platform=true is not supported by the device");
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
if (klass->device_plugged != NULL) {
|
||||
klass->device_plugged(qbus->parent, &local_err);
|
||||
}
|
||||
@@ -82,9 +78,15 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
+ vdev_has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
|
||||
if (klass->get_dma_as != NULL && has_iommu) {
|
||||
virtio_add_feature(&vdev->host_features, VIRTIO_F_IOMMU_PLATFORM);
|
||||
vdev->dma_as = klass->get_dma_as(qbus->parent);
|
||||
+ if (!vdev_has_iommu && vdev->dma_as != &address_space_memory) {
|
||||
+ error_setg(errp,
|
||||
+ "iommu_platform=true is not supported by the device");
|
||||
+ return;
|
||||
+ }
|
||||
} else {
|
||||
vdev->dma_as = &address_space_memory;
|
||||
}
|
38
debian/patches/extra/0018-block-gluster-correctly-set-max_pdiscard-which-is-in.patch
vendored
Normal file
38
debian/patches/extra/0018-block-gluster-correctly-set-max_pdiscard-which-is-in.patch
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Fri, 6 May 2022 14:38:35 +0200
|
||||
Subject: [PATCH] block/gluster: correctly set max_pdiscard which is int64_t
|
||||
|
||||
Previously, max_pdiscard would be zero in the following assertion:
|
||||
qemu-system-x86_64: ../block/io.c:3166: bdrv_co_pdiscard: Assertion
|
||||
`max_pdiscard >= bs->bl.request_alignment' failed.
|
||||
|
||||
Fixes: 0c8022876f ("block: use int64_t instead of int in driver discard handlers")
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/gluster.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/block/gluster.c b/block/gluster.c
|
||||
index 398976bc66..592e71b22a 100644
|
||||
--- a/block/gluster.c
|
||||
+++ b/block/gluster.c
|
||||
@@ -891,7 +891,7 @@ out:
|
||||
static void qemu_gluster_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
{
|
||||
bs->bl.max_transfer = GLUSTER_MAX_TRANSFER;
|
||||
- bs->bl.max_pdiscard = SIZE_MAX;
|
||||
+ bs->bl.max_pdiscard = INT64_MAX;
|
||||
}
|
||||
|
||||
static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
|
||||
@@ -1304,7 +1304,7 @@ static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs,
|
||||
GlusterAIOCB acb;
|
||||
BDRVGlusterState *s = bs->opaque;
|
||||
|
||||
- assert(bytes <= SIZE_MAX); /* rely on max_pdiscard */
|
||||
+ assert(bytes <= INT64_MAX); /* rely on max_pdiscard */
|
||||
|
||||
acb.size = 0;
|
||||
acb.ret = 0;
|
72
debian/patches/extra/0019-ui-vnc.c-Fixed-a-deadlock-bug.patch
vendored
Normal file
72
debian/patches/extra/0019-ui-vnc.c-Fixed-a-deadlock-bug.patch
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Rao Lei <lei.rao@intel.com>
|
||||
Date: Fri, 6 May 2022 14:38:36 +0200
|
||||
Subject: [PATCH] ui/vnc.c: Fixed a deadlock bug.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The GDB statck is as follows:
|
||||
(gdb) bt
|
||||
0 __lll_lock_wait (futex=futex@entry=0x56211df20360, private=0) at lowlevellock.c:52
|
||||
1 0x00007f263caf20a3 in __GI___pthread_mutex_lock (mutex=0x56211df20360) at ../nptl/pthread_mutex_lock.c:80
|
||||
2 0x000056211a757364 in qemu_mutex_lock_impl (mutex=0x56211df20360, file=0x56211a804857 "../ui/vnc-jobs.h", line=60)
|
||||
at ../util/qemu-thread-posix.c:80
|
||||
3 0x000056211a0ef8c7 in vnc_lock_output (vs=0x56211df14200) at ../ui/vnc-jobs.h:60
|
||||
4 0x000056211a0efcb7 in vnc_clipboard_send (vs=0x56211df14200, count=1, dwords=0x7ffdf1701338) at ../ui/vnc-clipboard.c:138
|
||||
5 0x000056211a0f0129 in vnc_clipboard_notify (notifier=0x56211df244c8, data=0x56211dd1bbf0) at ../ui/vnc-clipboard.c:209
|
||||
6 0x000056211a75dde8 in notifier_list_notify (list=0x56211afa17d0 <clipboard_notifiers>, data=0x56211dd1bbf0) at ../util/notify.c:39
|
||||
7 0x000056211a0bf0e6 in qemu_clipboard_update (info=0x56211dd1bbf0) at ../ui/clipboard.c:50
|
||||
8 0x000056211a0bf05d in qemu_clipboard_peer_release (peer=0x56211df244c0, selection=QEMU_CLIPBOARD_SELECTION_CLIPBOARD)
|
||||
at ../ui/clipboard.c:41
|
||||
9 0x000056211a0bef9b in qemu_clipboard_peer_unregister (peer=0x56211df244c0) at ../ui/clipboard.c:19
|
||||
10 0x000056211a0d45f3 in vnc_disconnect_finish (vs=0x56211df14200) at ../ui/vnc.c:1358
|
||||
11 0x000056211a0d4c9d in vnc_client_read (vs=0x56211df14200) at ../ui/vnc.c:1611
|
||||
12 0x000056211a0d4df8 in vnc_client_io (ioc=0x56211ce70690, condition=G_IO_IN, opaque=0x56211df14200) at ../ui/vnc.c:1649
|
||||
13 0x000056211a5b976c in qio_channel_fd_source_dispatch
|
||||
(source=0x56211ce50a00, callback=0x56211a0d4d71 <vnc_client_io>, user_data=0x56211df14200) at ../io/channel-watch.c:84
|
||||
14 0x00007f263ccede8e in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
|
||||
15 0x000056211a77d4a1 in glib_pollfds_poll () at ../util/main-loop.c:232
|
||||
16 0x000056211a77d51f in os_host_main_loop_wait (timeout=958545) at ../util/main-loop.c:255
|
||||
17 0x000056211a77d630 in main_loop_wait (nonblocking=0) at ../util/main-loop.c:531
|
||||
18 0x000056211a45bc8e in qemu_main_loop () at ../softmmu/runstate.c:726
|
||||
19 0x000056211a0b45fa in main (argc=69, argv=0x7ffdf1701778, envp=0x7ffdf17019a8) at ../softmmu/main.c:50
|
||||
|
||||
From the call trace, we can see it is a deadlock bug.
|
||||
vnc_disconnect_finish will acquire the output_mutex.
|
||||
But, the output_mutex will be acquired again in vnc_clipboard_send.
|
||||
Repeated locking will cause deadlock. So, I move
|
||||
qemu_clipboard_peer_unregister() behind vnc_unlock_output();
|
||||
|
||||
Fixes: 0bf41cab93e ("ui/vnc: clipboard support")
|
||||
Signed-off-by: Lei Rao <lei.rao@intel.com>
|
||||
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
Message-Id: <20220105020808.597325-1-lei.rao@intel.com>
|
||||
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
||||
(cherry-picked from commit 1dbbe6f172810026c51dc84ed927a3cc23017949)
|
||||
[FE: trivial backport for 6.2]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
ui/vnc.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/ui/vnc.c b/ui/vnc.c
|
||||
index af02522e84..b253e85c65 100644
|
||||
--- a/ui/vnc.c
|
||||
+++ b/ui/vnc.c
|
||||
@@ -1354,12 +1354,12 @@ void vnc_disconnect_finish(VncState *vs)
|
||||
/* last client gone */
|
||||
vnc_update_server_surface(vs->vd);
|
||||
}
|
||||
+ vnc_unlock_output(vs);
|
||||
+
|
||||
if (vs->cbpeer.update.notify) {
|
||||
qemu_clipboard_peer_unregister(&vs->cbpeer);
|
||||
}
|
||||
|
||||
- vnc_unlock_output(vs);
|
||||
-
|
||||
qemu_mutex_destroy(&vs->output_mutex);
|
||||
if (vs->bh != NULL) {
|
||||
qemu_bh_delete(vs->bh);
|
37
debian/patches/extra/0020-display-qxl-render-fix-race-condition-in-qxl_cursor-.patch
vendored
Normal file
37
debian/patches/extra/0020-display-qxl-render-fix-race-condition-in-qxl_cursor-.patch
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mauro Matteo Cascella <mcascell@redhat.com>
|
||||
Date: Thu, 7 Apr 2022 10:11:06 +0200
|
||||
Subject: [PATCH] display/qxl-render: fix race condition in qxl_cursor
|
||||
(CVE-2021-4207)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Avoid fetching 'width' and 'height' a second time to prevent possible
|
||||
race condition. Refer to security advisory
|
||||
https://starlabs.sg/advisories/22-4207/ for more information.
|
||||
|
||||
Fixes: CVE-2021-4207
|
||||
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
|
||||
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
Message-Id: <20220407081106.343235-1-mcascell@redhat.com>
|
||||
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
||||
(cherry picked from commit 9569f5cb5b4bffa9d3ebc8ba7da1e03830a9a895)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/display/qxl-render.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c
|
||||
index d28849b121..237ed293ba 100644
|
||||
--- a/hw/display/qxl-render.c
|
||||
+++ b/hw/display/qxl-render.c
|
||||
@@ -266,7 +266,7 @@ static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor,
|
||||
}
|
||||
break;
|
||||
case SPICE_CURSOR_TYPE_ALPHA:
|
||||
- size = sizeof(uint32_t) * cursor->header.width * cursor->header.height;
|
||||
+ size = sizeof(uint32_t) * c->width * c->height;
|
||||
qxl_unpack_chunks(c->data, size, qxl, &cursor->chunk, group_id);
|
||||
if (qxl->debug > 2) {
|
||||
cursor_print_ascii_art(c, "qxl/alpha");
|
83
debian/patches/extra/0021-ui-cursor-fix-integer-overflow-in-cursor_alloc-CVE-2.patch
vendored
Normal file
83
debian/patches/extra/0021-ui-cursor-fix-integer-overflow-in-cursor_alloc-CVE-2.patch
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mauro Matteo Cascella <mcascell@redhat.com>
|
||||
Date: Thu, 7 Apr 2022 10:17:12 +0200
|
||||
Subject: [PATCH] ui/cursor: fix integer overflow in cursor_alloc
|
||||
(CVE-2021-4206)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Prevent potential integer overflow by limiting 'width' and 'height' to
|
||||
512x512. Also change 'datasize' type to size_t. Refer to security
|
||||
advisory https://starlabs.sg/advisories/22-4206/ for more information.
|
||||
|
||||
Fixes: CVE-2021-4206
|
||||
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
|
||||
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
Message-Id: <20220407081712.345609-1-mcascell@redhat.com>
|
||||
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
||||
(cherry picked from commit fa892e9abb728e76afcf27323ab29c57fb0fe7aa)
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/display/qxl-render.c | 7 +++++++
|
||||
hw/display/vmware_vga.c | 2 ++
|
||||
ui/cursor.c | 8 +++++++-
|
||||
3 files changed, 16 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c
|
||||
index 237ed293ba..ca217004bf 100644
|
||||
--- a/hw/display/qxl-render.c
|
||||
+++ b/hw/display/qxl-render.c
|
||||
@@ -247,6 +247,13 @@ static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor,
|
||||
size_t size;
|
||||
|
||||
c = cursor_alloc(cursor->header.width, cursor->header.height);
|
||||
+
|
||||
+ if (!c) {
|
||||
+ qxl_set_guest_bug(qxl, "%s: cursor %ux%u alloc error", __func__,
|
||||
+ cursor->header.width, cursor->header.height);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
c->hot_x = cursor->header.hot_spot_x;
|
||||
c->hot_y = cursor->header.hot_spot_y;
|
||||
switch (cursor->header.type) {
|
||||
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
|
||||
index e2969a6c81..2b81d6122f 100644
|
||||
--- a/hw/display/vmware_vga.c
|
||||
+++ b/hw/display/vmware_vga.c
|
||||
@@ -509,6 +509,8 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
|
||||
int i, pixels;
|
||||
|
||||
qc = cursor_alloc(c->width, c->height);
|
||||
+ assert(qc != NULL);
|
||||
+
|
||||
qc->hot_x = c->hot_x;
|
||||
qc->hot_y = c->hot_y;
|
||||
switch (c->bpp) {
|
||||
diff --git a/ui/cursor.c b/ui/cursor.c
|
||||
index 1d62ddd4d0..835f0802f9 100644
|
||||
--- a/ui/cursor.c
|
||||
+++ b/ui/cursor.c
|
||||
@@ -46,6 +46,8 @@ static QEMUCursor *cursor_parse_xpm(const char *xpm[])
|
||||
|
||||
/* parse pixel data */
|
||||
c = cursor_alloc(width, height);
|
||||
+ assert(c != NULL);
|
||||
+
|
||||
for (pixel = 0, y = 0; y < height; y++, line++) {
|
||||
for (x = 0; x < height; x++, pixel++) {
|
||||
idx = xpm[line][x];
|
||||
@@ -91,7 +93,11 @@ QEMUCursor *cursor_builtin_left_ptr(void)
|
||||
QEMUCursor *cursor_alloc(int width, int height)
|
||||
{
|
||||
QEMUCursor *c;
|
||||
- int datasize = width * height * sizeof(uint32_t);
|
||||
+ size_t datasize = width * height * sizeof(uint32_t);
|
||||
+
|
||||
+ if (width > 512 || height > 512) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
|
||||
c = g_malloc0(sizeof(QEMUCursor) + datasize);
|
||||
c->width = width;
|
971
debian/patches/pve-qemu-6.2-vitastor.patch
vendored
Normal file
971
debian/patches/pve-qemu-6.2-vitastor.patch
vendored
Normal file
@@ -0,0 +1,971 @@
|
||||
Index: qemu/block/meson.build
|
||||
===================================================================
|
||||
--- qemu.orig/block/meson.build
|
||||
+++ qemu/block/meson.build
|
||||
@@ -91,6 +91,7 @@ foreach m : [
|
||||
[libnfs, 'nfs', files('nfs.c')],
|
||||
[libssh, 'ssh', files('ssh.c')],
|
||||
[rbd, 'rbd', files('rbd.c')],
|
||||
+ [vitastor, 'vitastor', files('vitastor.c')],
|
||||
]
|
||||
if m[0].found()
|
||||
module_ss = ss.source_set()
|
||||
Index: qemu/meson.build
|
||||
===================================================================
|
||||
--- qemu.orig/meson.build
|
||||
+++ qemu/meson.build
|
||||
@@ -838,6 +838,26 @@ if not get_option('rbd').auto() or have_
|
||||
endif
|
||||
endif
|
||||
|
||||
+vitastor = not_found
|
||||
+if not get_option('vitastor').auto() or have_block
|
||||
+ libvitastor_client = cc.find_library('vitastor_client', has_headers: ['vitastor_c.h'],
|
||||
+ required: get_option('vitastor'), kwargs: static_kwargs)
|
||||
+ if libvitastor_client.found()
|
||||
+ if cc.links('''
|
||||
+ #include <vitastor_c.h>
|
||||
+ int main(void) {
|
||||
+ vitastor_c_create_qemu(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
+ return 0;
|
||||
+ }''', dependencies: libvitastor_client)
|
||||
+ vitastor = declare_dependency(dependencies: libvitastor_client)
|
||||
+ elif get_option('vitastor').enabled()
|
||||
+ error('could not link libvitastor_client')
|
||||
+ else
|
||||
+ warning('could not link libvitastor_client, disabling')
|
||||
+ endif
|
||||
+ endif
|
||||
+endif
|
||||
+
|
||||
glusterfs = not_found
|
||||
glusterfs_ftruncate_has_stat = false
|
||||
glusterfs_iocb_has_stat = false
|
||||
@@ -1459,6 +1479,7 @@ config_host_data.set('CONFIG_LINUX_AIO',
|
||||
config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
|
||||
config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
|
||||
config_host_data.set('CONFIG_RBD', rbd.found())
|
||||
+config_host_data.set('CONFIG_VITASTOR', vitastor.found())
|
||||
config_host_data.set('CONFIG_SDL', sdl.found())
|
||||
config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
|
||||
config_host_data.set('CONFIG_SECCOMP', seccomp.found())
|
||||
@@ -3424,6 +3445,7 @@ if spice_protocol.found()
|
||||
summary_info += {' spice server support': spice}
|
||||
endif
|
||||
summary_info += {'rbd support': rbd}
|
||||
+summary_info += {'vitastor support': vitastor}
|
||||
summary_info += {'xfsctl support': config_host.has_key('CONFIG_XFS')}
|
||||
summary_info += {'smartcard support': cacard}
|
||||
summary_info += {'U2F support': u2f}
|
||||
Index: qemu/meson_options.txt
|
||||
===================================================================
|
||||
--- qemu.orig/meson_options.txt
|
||||
+++ qemu/meson_options.txt
|
||||
@@ -121,6 +121,8 @@ option('lzo', type : 'feature', value :
|
||||
description: 'lzo compression support')
|
||||
option('rbd', type : 'feature', value : 'auto',
|
||||
description: 'Ceph block device driver')
|
||||
+option('vitastor', type : 'feature', value : 'auto',
|
||||
+ description: 'Vitastor block device driver')
|
||||
option('gtk', type : 'feature', value : 'auto',
|
||||
description: 'GTK+ user interface')
|
||||
option('sdl', type : 'feature', value : 'auto',
|
||||
Index: qemu/qapi/block-core.json
|
||||
===================================================================
|
||||
--- qemu.orig/qapi/block-core.json
|
||||
+++ qemu/qapi/block-core.json
|
||||
@@ -3179,7 +3179,7 @@
|
||||
'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
|
||||
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
|
||||
'pbs',
|
||||
- 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
|
||||
+ 'ssh', 'throttle', 'vdi', 'vhdx', 'vitastor', 'vmdk', 'vpc', 'vvfat' ] }
|
||||
|
||||
##
|
||||
# @BlockdevOptionsFile:
|
||||
@@ -4125,6 +4125,28 @@
|
||||
'*server': ['InetSocketAddressBase'] } }
|
||||
|
||||
##
|
||||
+# @BlockdevOptionsVitastor:
|
||||
+#
|
||||
+# Driver specific block device options for vitastor
|
||||
+#
|
||||
+# @image: Image name
|
||||
+# @inode: Inode number
|
||||
+# @pool: Pool ID
|
||||
+# @size: Desired image size in bytes
|
||||
+# @config-path: Path to Vitastor configuration
|
||||
+# @etcd-host: etcd connection address(es)
|
||||
+# @etcd-prefix: etcd key/value prefix
|
||||
+##
|
||||
+{ 'struct': 'BlockdevOptionsVitastor',
|
||||
+ 'data': { '*inode': 'uint64',
|
||||
+ '*pool': 'uint64',
|
||||
+ '*size': 'uint64',
|
||||
+ '*image': 'str',
|
||||
+ '*config-path': 'str',
|
||||
+ '*etcd-host': 'str',
|
||||
+ '*etcd-prefix': 'str' } }
|
||||
+
|
||||
+##
|
||||
# @ReplicationMode:
|
||||
#
|
||||
# An enumeration of replication modes.
|
||||
@@ -4520,6 +4542,7 @@
|
||||
'throttle': 'BlockdevOptionsThrottle',
|
||||
'vdi': 'BlockdevOptionsGenericFormat',
|
||||
'vhdx': 'BlockdevOptionsGenericFormat',
|
||||
+ 'vitastor': 'BlockdevOptionsVitastor',
|
||||
'vmdk': 'BlockdevOptionsGenericCOWFormat',
|
||||
'vpc': 'BlockdevOptionsGenericFormat',
|
||||
'vvfat': 'BlockdevOptionsVVFAT'
|
||||
@@ -4910,6 +4933,17 @@
|
||||
'*encrypt' : 'RbdEncryptionCreateOptions' } }
|
||||
|
||||
##
|
||||
+# @BlockdevCreateOptionsVitastor:
|
||||
+#
|
||||
+# Driver specific image creation options for Vitastor.
|
||||
+#
|
||||
+# @size: Size of the virtual disk in bytes
|
||||
+##
|
||||
+{ 'struct': 'BlockdevCreateOptionsVitastor',
|
||||
+ 'data': { 'location': 'BlockdevOptionsVitastor',
|
||||
+ 'size': 'size' } }
|
||||
+
|
||||
+##
|
||||
# @BlockdevVmdkSubformat:
|
||||
#
|
||||
# Subformat options for VMDK images
|
||||
@@ -5108,6 +5142,7 @@
|
||||
'ssh': 'BlockdevCreateOptionsSsh',
|
||||
'vdi': 'BlockdevCreateOptionsVdi',
|
||||
'vhdx': 'BlockdevCreateOptionsVhdx',
|
||||
+ 'vitastor': 'BlockdevCreateOptionsVitastor',
|
||||
'vmdk': 'BlockdevCreateOptionsVmdk',
|
||||
'vpc': 'BlockdevCreateOptionsVpc'
|
||||
} }
|
||||
Index: qemu/scripts/ci/org.centos/stream/8/x86_64/configure
|
||||
===================================================================
|
||||
--- qemu.orig/scripts/ci/org.centos/stream/8/x86_64/configure
|
||||
+++ qemu/scripts/ci/org.centos/stream/8/x86_64/configure
|
||||
@@ -31,7 +31,7 @@
|
||||
--with-git=meson \
|
||||
--with-git-submodules=update \
|
||||
--target-list="x86_64-softmmu" \
|
||||
---block-drv-rw-whitelist="qcow2,raw,file,host_device,nbd,iscsi,rbd,blkdebug,luks,null-co,nvme,copy-on-read,throttle,gluster" \
|
||||
+--block-drv-rw-whitelist="qcow2,raw,file,host_device,nbd,iscsi,rbd,vitastor,blkdebug,luks,null-co,nvme,copy-on-read,throttle,gluster" \
|
||||
--audio-drv-list="" \
|
||||
--block-drv-ro-whitelist="vmdk,vhdx,vpc,https,ssh" \
|
||||
--with-coroutine=ucontext \
|
||||
@@ -183,6 +183,7 @@
|
||||
--enable-opengl \
|
||||
--enable-pie \
|
||||
--enable-rbd \
|
||||
+--enable-vitastor \
|
||||
--enable-rdma \
|
||||
--enable-seccomp \
|
||||
--enable-snappy \
|
||||
Index: a/block/vitastor.c
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ a/block/vitastor.c
|
||||
@@ -0,0 +1,797 @@
|
||||
+// Copyright (c) Vitaliy Filippov, 2019+
|
||||
+// License: VNPL-1.1 or GNU GPL-2.0+ (see README.md for details)
|
||||
+
|
||||
+// QEMU block driver
|
||||
+
|
||||
+#ifdef VITASTOR_SOURCE_TREE
|
||||
+#define BUILD_DSO
|
||||
+#define _GNU_SOURCE
|
||||
+#endif
|
||||
+#include "qemu/osdep.h"
|
||||
+#include "qemu/main-loop.h"
|
||||
+#include "block/block_int.h"
|
||||
+#include "qapi/error.h"
|
||||
+#include "qapi/qmp/qdict.h"
|
||||
+#include "qapi/qmp/qerror.h"
|
||||
+#include "qemu/uri.h"
|
||||
+#include "qemu/error-report.h"
|
||||
+#include "qemu/module.h"
|
||||
+#include "qemu/option.h"
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3
|
||||
+#include "qemu/units.h"
|
||||
+#include "block/qdict.h"
|
||||
+#include "qemu/cutils.h"
|
||||
+#elif QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 10
|
||||
+#include "qemu/cutils.h"
|
||||
+#include "qapi/qmp/qstring.h"
|
||||
+#include "qapi/qmp/qjson.h"
|
||||
+#else
|
||||
+#include "qapi/qmp/qint.h"
|
||||
+#define qdict_put_int(options, name, num_val) qdict_put_obj(options, name, QOBJECT(qint_from_int(num_val)))
|
||||
+#define qdict_put_str(options, name, value) qdict_put_obj(options, name, QOBJECT(qstring_from_str(value)))
|
||||
+#define qobject_unref QDECREF
|
||||
+#endif
|
||||
+
|
||||
+#include "vitastor_c.h"
|
||||
+
|
||||
+#ifdef VITASTOR_SOURCE_TREE
|
||||
+void qemu_module_dummy(void)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+void DSO_STAMP_FUN(void)
|
||||
+{
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+typedef struct VitastorClient
|
||||
+{
|
||||
+ void *proxy;
|
||||
+ void *watch;
|
||||
+ char *config_path;
|
||||
+ char *etcd_host;
|
||||
+ char *etcd_prefix;
|
||||
+ char *image;
|
||||
+ int skip_parents;
|
||||
+ uint64_t inode;
|
||||
+ uint64_t pool;
|
||||
+ uint64_t size;
|
||||
+ long readonly;
|
||||
+ int use_rdma;
|
||||
+ char *rdma_device;
|
||||
+ int rdma_port_num;
|
||||
+ int rdma_gid_index;
|
||||
+ int rdma_mtu;
|
||||
+ QemuMutex mutex;
|
||||
+
|
||||
+ uint64_t last_bitmap_inode, last_bitmap_offset, last_bitmap_len;
|
||||
+ uint32_t last_bitmap_granularity;
|
||||
+ uint8_t *last_bitmap;
|
||||
+} VitastorClient;
|
||||
+
|
||||
+typedef struct VitastorRPC
|
||||
+{
|
||||
+ BlockDriverState *bs;
|
||||
+ Coroutine *co;
|
||||
+ QEMUIOVector *iov;
|
||||
+ long ret;
|
||||
+ int complete;
|
||||
+ uint64_t inode, offset, len;
|
||||
+ uint32_t bitmap_granularity;
|
||||
+ uint8_t *bitmap;
|
||||
+} VitastorRPC;
|
||||
+
|
||||
+static void vitastor_co_init_task(BlockDriverState *bs, VitastorRPC *task);
|
||||
+static void vitastor_co_generic_bh_cb(void *opaque, long retval);
|
||||
+static void vitastor_co_read_cb(void *opaque, long retval, uint64_t version);
|
||||
+static void vitastor_close(BlockDriverState *bs);
|
||||
+
|
||||
+static char *qemu_vitastor_next_tok(char *src, char delim, char **p)
|
||||
+{
|
||||
+ char *end;
|
||||
+ *p = NULL;
|
||||
+ for (end = src; *end; ++end)
|
||||
+ {
|
||||
+ if (*end == delim)
|
||||
+ break;
|
||||
+ if (*end == '\\' && end[1] != '\0')
|
||||
+ end++;
|
||||
+ }
|
||||
+ if (*end == delim)
|
||||
+ {
|
||||
+ *p = end + 1;
|
||||
+ *end = '\0';
|
||||
+ }
|
||||
+ return src;
|
||||
+}
|
||||
+
|
||||
+static void qemu_vitastor_unescape(char *src)
|
||||
+{
|
||||
+ char *p;
|
||||
+ for (p = src; *src; ++src, ++p)
|
||||
+ {
|
||||
+ if (*src == '\\' && src[1] != '\0')
|
||||
+ src++;
|
||||
+ *p = *src;
|
||||
+ }
|
||||
+ *p = '\0';
|
||||
+}
|
||||
+
|
||||
+// vitastor[:key=value]*
|
||||
+// vitastor[:etcd_host=127.0.0.1]:inode=1:pool=1[:rdma_gid_index=3]
|
||||
+// vitastor:config_path=/etc/vitastor/vitastor.conf:image=testimg
|
||||
+static void vitastor_parse_filename(const char *filename, QDict *options, Error **errp)
|
||||
+{
|
||||
+ const char *start;
|
||||
+ char *p, *buf;
|
||||
+
|
||||
+ if (!strstart(filename, "vitastor:", &start))
|
||||
+ {
|
||||
+ error_setg(errp, "File name must start with 'vitastor:'");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ buf = g_strdup(start);
|
||||
+ p = buf;
|
||||
+
|
||||
+ // The following are all key/value pairs
|
||||
+ while (p)
|
||||
+ {
|
||||
+ int i;
|
||||
+ char *name, *value;
|
||||
+ name = qemu_vitastor_next_tok(p, '=', &p);
|
||||
+ if (!p)
|
||||
+ {
|
||||
+ error_setg(errp, "conf option %s has no value", name);
|
||||
+ break;
|
||||
+ }
|
||||
+ for (i = 0; i < strlen(name); i++)
|
||||
+ if (name[i] == '_')
|
||||
+ name[i] = '-';
|
||||
+ qemu_vitastor_unescape(name);
|
||||
+ value = qemu_vitastor_next_tok(p, ':', &p);
|
||||
+ qemu_vitastor_unescape(value);
|
||||
+ if (!strcmp(name, "inode") ||
|
||||
+ !strcmp(name, "pool") ||
|
||||
+ !strcmp(name, "size") ||
|
||||
+ !strcmp(name, "skip-parents") ||
|
||||
+ !strcmp(name, "use-rdma") ||
|
||||
+ !strcmp(name, "rdma-port_num") ||
|
||||
+ !strcmp(name, "rdma-gid-index") ||
|
||||
+ !strcmp(name, "rdma-mtu"))
|
||||
+ {
|
||||
+ unsigned long long num_val;
|
||||
+ if (parse_uint_full(value, &num_val, 0))
|
||||
+ {
|
||||
+ error_setg(errp, "Illegal %s: %s", name, value);
|
||||
+ goto out;
|
||||
+ }
|
||||
+ qdict_put_int(options, name, num_val);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ qdict_put_str(options, name, value);
|
||||
+ }
|
||||
+ }
|
||||
+ if (!qdict_get_try_str(options, "image"))
|
||||
+ {
|
||||
+ if (!qdict_get_try_int(options, "inode", 0))
|
||||
+ {
|
||||
+ error_setg(errp, "one of image (name) and inode (number) must be specified");
|
||||
+ goto out;
|
||||
+ }
|
||||
+ if (!(qdict_get_try_int(options, "inode", 0) >> (64-POOL_ID_BITS)) &&
|
||||
+ !qdict_get_try_int(options, "pool", 0))
|
||||
+ {
|
||||
+ error_setg(errp, "pool number must be specified or included in the inode number");
|
||||
+ goto out;
|
||||
+ }
|
||||
+ if (!qdict_get_try_int(options, "size", 0))
|
||||
+ {
|
||||
+ error_setg(errp, "size must be specified when inode number is used instead of image name");
|
||||
+ goto out;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+out:
|
||||
+ g_free(buf);
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static void coroutine_fn vitastor_co_get_metadata(VitastorRPC *task)
|
||||
+{
|
||||
+ BlockDriverState *bs = task->bs;
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ task->co = qemu_coroutine_self();
|
||||
+
|
||||
+ qemu_mutex_lock(&client->mutex);
|
||||
+ vitastor_c_watch_inode(client->proxy, client->image, vitastor_co_generic_bh_cb, task);
|
||||
+ qemu_mutex_unlock(&client->mutex);
|
||||
+
|
||||
+ while (!task->complete)
|
||||
+ {
|
||||
+ qemu_coroutine_yield();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void vitastor_aio_set_fd_handler(void *ctx, int fd, int unused1, IOHandler *fd_read, IOHandler *fd_write, void *unused2, void *opaque)
|
||||
+{
|
||||
+ aio_set_fd_handler(ctx, fd,
|
||||
+#if QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 5 || QEMU_VERSION_MAJOR >= 3
|
||||
+ 0 /*is_external*/,
|
||||
+#endif
|
||||
+ fd_read, fd_write,
|
||||
+#if QEMU_VERSION_MAJOR == 1 && QEMU_VERSION_MINOR <= 6 || QEMU_VERSION_MAJOR < 1
|
||||
+ NULL /*io_flush*/,
|
||||
+#endif
|
||||
+#if QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 9 || QEMU_VERSION_MAJOR >= 3
|
||||
+ NULL /*io_poll*/,
|
||||
+#endif
|
||||
+#if QEMU_VERSION_MAJOR >= 7
|
||||
+ NULL /*io_poll_ready*/,
|
||||
+#endif
|
||||
+ opaque);
|
||||
+}
|
||||
+
|
||||
+static int vitastor_file_open(BlockDriverState *bs, QDict *options, int flags, Error **errp)
|
||||
+{
|
||||
+ VitastorRPC task;
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ void *image = NULL;
|
||||
+ int64_t ret = 0;
|
||||
+ qemu_mutex_init(&client->mutex);
|
||||
+ client->config_path = g_strdup(qdict_get_try_str(options, "config-path"));
|
||||
+ // FIXME: Rename to etcd_address
|
||||
+ client->etcd_host = g_strdup(qdict_get_try_str(options, "etcd-host"));
|
||||
+ client->etcd_prefix = g_strdup(qdict_get_try_str(options, "etcd-prefix"));
|
||||
+ client->skip_parents = qdict_get_try_int(options, "skip-parents", 0);
|
||||
+ client->use_rdma = qdict_get_try_int(options, "use-rdma", -1);
|
||||
+ client->rdma_device = g_strdup(qdict_get_try_str(options, "rdma-device"));
|
||||
+ client->rdma_port_num = qdict_get_try_int(options, "rdma-port-num", 0);
|
||||
+ client->rdma_gid_index = qdict_get_try_int(options, "rdma-gid-index", 0);
|
||||
+ client->rdma_mtu = qdict_get_try_int(options, "rdma-mtu", 0);
|
||||
+ client->proxy = vitastor_c_create_qemu(
|
||||
+ vitastor_aio_set_fd_handler, bdrv_get_aio_context(bs), client->config_path, client->etcd_host, client->etcd_prefix,
|
||||
+ client->use_rdma, client->rdma_device, client->rdma_port_num, client->rdma_gid_index, client->rdma_mtu, 0
|
||||
+ );
|
||||
+ image = client->image = g_strdup(qdict_get_try_str(options, "image"));
|
||||
+ client->readonly = (flags & BDRV_O_RDWR) ? 1 : 0;
|
||||
+ // Get image metadata (size and readonly flag) or just wait until the client is ready
|
||||
+ if (!image)
|
||||
+ client->image = (char*)"x";
|
||||
+ task.complete = 0;
|
||||
+ task.bs = bs;
|
||||
+ if (qemu_in_coroutine())
|
||||
+ {
|
||||
+ vitastor_co_get_metadata(&task);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ bdrv_coroutine_enter(bs, qemu_coroutine_create((void(*)(void*))vitastor_co_get_metadata, &task));
|
||||
+ BDRV_POLL_WHILE(bs, !task.complete);
|
||||
+ }
|
||||
+ client->image = image;
|
||||
+ if (client->image)
|
||||
+ {
|
||||
+ client->watch = (void*)task.ret;
|
||||
+ client->readonly = client->readonly || vitastor_c_inode_get_readonly(client->watch);
|
||||
+ client->size = vitastor_c_inode_get_size(client->watch);
|
||||
+ if (!vitastor_c_inode_get_num(client->watch))
|
||||
+ {
|
||||
+ error_setg(errp, "image does not exist");
|
||||
+ vitastor_close(bs);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if (!client->size)
|
||||
+ {
|
||||
+ client->size = qdict_get_try_int(options, "size", 0);
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ client->watch = NULL;
|
||||
+ client->inode = qdict_get_try_int(options, "inode", 0);
|
||||
+ client->pool = qdict_get_try_int(options, "pool", 0);
|
||||
+ if (client->pool)
|
||||
+ {
|
||||
+ client->inode = (client->inode & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1)) | (client->pool << (64-POOL_ID_BITS));
|
||||
+ }
|
||||
+ client->size = qdict_get_try_int(options, "size", 0);
|
||||
+ vitastor_c_close_watch(client->proxy, (void*)task.ret);
|
||||
+ }
|
||||
+ if (!client->size)
|
||||
+ {
|
||||
+ error_setg(errp, "image size not specified");
|
||||
+ vitastor_close(bs);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bs->total_sectors = client->size / BDRV_SECTOR_SIZE;
|
||||
+ //client->aio_context = bdrv_get_aio_context(bs);
|
||||
+ qdict_del(options, "use-rdma");
|
||||
+ qdict_del(options, "rdma-mtu");
|
||||
+ qdict_del(options, "rdma-gid-index");
|
||||
+ qdict_del(options, "rdma-port-num");
|
||||
+ qdict_del(options, "rdma-device");
|
||||
+ qdict_del(options, "config-path");
|
||||
+ qdict_del(options, "etcd-host");
|
||||
+ qdict_del(options, "etcd-prefix");
|
||||
+ qdict_del(options, "image");
|
||||
+ qdict_del(options, "inode");
|
||||
+ qdict_del(options, "pool");
|
||||
+ qdict_del(options, "size");
|
||||
+ qdict_del(options, "skip-parents");
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void vitastor_close(BlockDriverState *bs)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ vitastor_c_destroy(client->proxy);
|
||||
+ qemu_mutex_destroy(&client->mutex);
|
||||
+ if (client->config_path)
|
||||
+ g_free(client->config_path);
|
||||
+ if (client->etcd_host)
|
||||
+ g_free(client->etcd_host);
|
||||
+ if (client->etcd_prefix)
|
||||
+ g_free(client->etcd_prefix);
|
||||
+ if (client->image)
|
||||
+ g_free(client->image);
|
||||
+ free(client->last_bitmap);
|
||||
+ client->last_bitmap = NULL;
|
||||
+}
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 2
|
||||
+static int vitastor_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
|
||||
+{
|
||||
+ bsz->phys = 4096;
|
||||
+ bsz->log = 512;
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 12
|
||||
+static int coroutine_fn vitastor_co_create_opts(
|
||||
+#if QEMU_VERSION_MAJOR >= 4
|
||||
+ BlockDriver *drv,
|
||||
+#endif
|
||||
+ const char *url, QemuOpts *opts, Error **errp)
|
||||
+{
|
||||
+ QDict *options;
|
||||
+ int ret;
|
||||
+
|
||||
+ options = qdict_new();
|
||||
+ vitastor_parse_filename(url, options, errp);
|
||||
+ if (*errp)
|
||||
+ {
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ // inodes don't require creation in Vitastor. FIXME: They will when there will be some metadata
|
||||
+
|
||||
+ ret = 0;
|
||||
+out:
|
||||
+ qobject_unref(options);
|
||||
+ return ret;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3
|
||||
+static int coroutine_fn vitastor_co_truncate(BlockDriverState *bs, int64_t offset,
|
||||
+#if QEMU_VERSION_MAJOR >= 4
|
||||
+ bool exact,
|
||||
+#endif
|
||||
+ PreallocMode prealloc,
|
||||
+#if QEMU_VERSION_MAJOR >= 5 && QEMU_VERSION_MINOR >= 1 || QEMU_VERSION_MAJOR > 5 || defined RHEL_BDRV_CO_TRUNCATE_FLAGS
|
||||
+ BdrvRequestFlags flags,
|
||||
+#endif
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+
|
||||
+ if (prealloc != PREALLOC_MODE_OFF)
|
||||
+ {
|
||||
+ error_setg(errp, "Unsupported preallocation mode '%s'", PreallocMode_str(prealloc));
|
||||
+ return -ENOTSUP;
|
||||
+ }
|
||||
+
|
||||
+ // TODO: Resize inode to <offset> bytes
|
||||
+ client->size = offset / BDRV_SECTOR_SIZE;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static int vitastor_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
|
||||
+{
|
||||
+ bdi->cluster_size = 4096;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int64_t vitastor_getlength(BlockDriverState *bs)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ return client->size;
|
||||
+}
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 0
|
||||
+static void vitastor_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
+#else
|
||||
+static int vitastor_refresh_limits(BlockDriverState *bs)
|
||||
+#endif
|
||||
+{
|
||||
+ bs->bl.request_alignment = 4096;
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 3
|
||||
+ bs->bl.min_mem_alignment = 4096;
|
||||
+#endif
|
||||
+ bs->bl.opt_mem_alignment = 4096;
|
||||
+#if QEMU_VERSION_MAJOR < 2 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR == 0
|
||||
+ return 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+//static int64_t vitastor_get_allocated_file_size(BlockDriverState *bs)
|
||||
+//{
|
||||
+// return 0;
|
||||
+//}
|
||||
+
|
||||
+static void vitastor_co_init_task(BlockDriverState *bs, VitastorRPC *task)
|
||||
+{
|
||||
+ *task = (VitastorRPC) {
|
||||
+ .co = qemu_coroutine_self(),
|
||||
+ .bs = bs,
|
||||
+ };
|
||||
+}
|
||||
+
|
||||
+static void vitastor_co_generic_bh_cb(void *opaque, long retval)
|
||||
+{
|
||||
+ VitastorRPC *task = opaque;
|
||||
+ task->ret = retval;
|
||||
+ task->complete = 1;
|
||||
+ if (qemu_coroutine_self() != task->co)
|
||||
+ {
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 8
|
||||
+ aio_co_wake(task->co);
|
||||
+#else
|
||||
+ qemu_coroutine_enter(task->co, NULL);
|
||||
+ qemu_aio_release(task);
|
||||
+#endif
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void vitastor_co_read_cb(void *opaque, long retval, uint64_t version)
|
||||
+{
|
||||
+ vitastor_co_generic_bh_cb(opaque, retval);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn vitastor_co_preadv(BlockDriverState *bs,
|
||||
+#if QEMU_VERSION_MAJOR >= 7 || QEMU_VERSION_MAJOR == 6 && QEMU_VERSION_MINOR >= 2
|
||||
+ int64_t offset, int64_t bytes, QEMUIOVector *iov, BdrvRequestFlags flags
|
||||
+#else
|
||||
+ uint64_t offset, uint64_t bytes, QEMUIOVector *iov, int flags
|
||||
+#endif
|
||||
+)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ VitastorRPC task;
|
||||
+ vitastor_co_init_task(bs, &task);
|
||||
+ task.iov = iov;
|
||||
+
|
||||
+ uint64_t inode = client->watch ? vitastor_c_inode_get_num(client->watch) : client->inode;
|
||||
+ qemu_mutex_lock(&client->mutex);
|
||||
+ vitastor_c_read(client->proxy, inode, offset, bytes, iov->iov, iov->niov, vitastor_co_read_cb, &task);
|
||||
+ qemu_mutex_unlock(&client->mutex);
|
||||
+
|
||||
+ while (!task.complete)
|
||||
+ {
|
||||
+ qemu_coroutine_yield();
|
||||
+ }
|
||||
+
|
||||
+ return task.ret;
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn vitastor_co_pwritev(BlockDriverState *bs,
|
||||
+#if QEMU_VERSION_MAJOR >= 7 || QEMU_VERSION_MAJOR == 6 && QEMU_VERSION_MINOR >= 2
|
||||
+ int64_t offset, int64_t bytes, QEMUIOVector *iov, BdrvRequestFlags flags
|
||||
+#else
|
||||
+ uint64_t offset, uint64_t bytes, QEMUIOVector *iov, int flags
|
||||
+#endif
|
||||
+)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ VitastorRPC task;
|
||||
+ vitastor_co_init_task(bs, &task);
|
||||
+ task.iov = iov;
|
||||
+
|
||||
+ if (client->last_bitmap)
|
||||
+ {
|
||||
+ // Invalidate last bitmap on write
|
||||
+ free(client->last_bitmap);
|
||||
+ client->last_bitmap = NULL;
|
||||
+ }
|
||||
+
|
||||
+ uint64_t inode = client->watch ? vitastor_c_inode_get_num(client->watch) : client->inode;
|
||||
+ qemu_mutex_lock(&client->mutex);
|
||||
+ vitastor_c_write(client->proxy, inode, offset, bytes, 0, iov->iov, iov->niov, vitastor_co_generic_bh_cb, &task);
|
||||
+ qemu_mutex_unlock(&client->mutex);
|
||||
+
|
||||
+ while (!task.complete)
|
||||
+ {
|
||||
+ qemu_coroutine_yield();
|
||||
+ }
|
||||
+
|
||||
+ return task.ret;
|
||||
+}
|
||||
+
|
||||
+#if defined VITASTOR_C_API_VERSION && VITASTOR_C_API_VERSION >= 1
|
||||
+#if QEMU_VERSION_MAJOR >= 2 || QEMU_VERSION_MAJOR == 1 && QEMU_VERSION_MINOR >= 7
|
||||
+static void vitastor_co_read_bitmap_cb(void *opaque, long retval, uint8_t *bitmap)
|
||||
+{
|
||||
+ VitastorRPC *task = opaque;
|
||||
+ VitastorClient *client = task->bs->opaque;
|
||||
+ task->ret = retval;
|
||||
+ task->complete = 1;
|
||||
+ if (retval >= 0)
|
||||
+ {
|
||||
+ task->bitmap = bitmap;
|
||||
+ if (client->last_bitmap_inode == task->inode &&
|
||||
+ client->last_bitmap_offset == task->offset &&
|
||||
+ client->last_bitmap_len == task->len)
|
||||
+ {
|
||||
+ free(client->last_bitmap);
|
||||
+ client->last_bitmap = bitmap;
|
||||
+ }
|
||||
+ }
|
||||
+ if (qemu_coroutine_self() != task->co)
|
||||
+ {
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 8
|
||||
+ aio_co_wake(task->co);
|
||||
+#else
|
||||
+ qemu_coroutine_enter(task->co, NULL);
|
||||
+ qemu_aio_release(task);
|
||||
+#endif
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn vitastor_co_block_status(
|
||||
+ BlockDriverState *bs, bool want_zero, int64_t offset, int64_t bytes,
|
||||
+ int64_t *pnum, int64_t *map, BlockDriverState **file)
|
||||
+{
|
||||
+ // Allocated => return BDRV_BLOCK_DATA|BDRV_BLOCK_OFFSET_VALID
|
||||
+ // Not allocated => return 0
|
||||
+ // Error => return -errno
|
||||
+ // Set pnum to length of the extent, `*map` = `offset`, `*file` = `bs`
|
||||
+ VitastorRPC task;
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ uint64_t inode = client->watch ? vitastor_c_inode_get_num(client->watch) : client->inode;
|
||||
+ uint8_t bit = 0;
|
||||
+ if (client->last_bitmap && client->last_bitmap_inode == inode &&
|
||||
+ client->last_bitmap_offset <= offset &&
|
||||
+ client->last_bitmap_offset+client->last_bitmap_len >= (want_zero ? offset+1 : offset+bytes))
|
||||
+ {
|
||||
+ // Use the previously read bitmap
|
||||
+ task.bitmap_granularity = client->last_bitmap_granularity;
|
||||
+ task.offset = client->last_bitmap_offset;
|
||||
+ task.len = client->last_bitmap_len;
|
||||
+ task.bitmap = client->last_bitmap;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ // Read bitmap from this position, rounding to full inode PG blocks
|
||||
+ uint32_t block_size = vitastor_c_inode_get_block_size(client->proxy, inode);
|
||||
+ if (!block_size)
|
||||
+ return -EAGAIN;
|
||||
+ // Init coroutine
|
||||
+ vitastor_co_init_task(bs, &task);
|
||||
+ free(client->last_bitmap);
|
||||
+ task.inode = client->last_bitmap_inode = inode;
|
||||
+ task.bitmap_granularity = client->last_bitmap_granularity = vitastor_c_inode_get_bitmap_granularity(client->proxy, inode);
|
||||
+ task.offset = client->last_bitmap_offset = offset / block_size * block_size;
|
||||
+ task.len = client->last_bitmap_len = (offset+bytes+block_size-1) / block_size * block_size - task.offset;
|
||||
+ task.bitmap = client->last_bitmap = NULL;
|
||||
+ qemu_mutex_lock(&client->mutex);
|
||||
+ vitastor_c_read_bitmap(client->proxy, task.inode, task.offset, task.len, !client->skip_parents, vitastor_co_read_bitmap_cb, &task);
|
||||
+ qemu_mutex_unlock(&client->mutex);
|
||||
+ while (!task.complete)
|
||||
+ {
|
||||
+ qemu_coroutine_yield();
|
||||
+ }
|
||||
+ if (task.ret < 0)
|
||||
+ {
|
||||
+ // Error
|
||||
+ return task.ret;
|
||||
+ }
|
||||
+ }
|
||||
+ if (want_zero)
|
||||
+ {
|
||||
+ // Get precise mapping with all holes
|
||||
+ uint64_t bmp_pos = (offset-task.offset) / task.bitmap_granularity;
|
||||
+ uint64_t bmp_len = task.len / task.bitmap_granularity;
|
||||
+ uint64_t bmp_end = bmp_pos+1;
|
||||
+ bit = (task.bitmap[bmp_pos >> 3] >> (bmp_pos & 0x7)) & 1;
|
||||
+ while (bmp_end < bmp_len && ((task.bitmap[bmp_end >> 3] >> (bmp_end & 0x7)) & 1) == bit)
|
||||
+ {
|
||||
+ bmp_end++;
|
||||
+ }
|
||||
+ *pnum = (bmp_end-bmp_pos) * task.bitmap_granularity;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ // Get larger allocated extents, possibly with false positives
|
||||
+ uint64_t bmp_pos = (offset-task.offset) / task.bitmap_granularity;
|
||||
+ uint64_t bmp_end = (offset+bytes-task.offset) / task.bitmap_granularity - bmp_pos;
|
||||
+ while (bmp_pos < bmp_end)
|
||||
+ {
|
||||
+ if (!(bmp_pos & 7) && bmp_end >= bmp_pos+8)
|
||||
+ {
|
||||
+ bit = bit || task.bitmap[bmp_pos >> 3];
|
||||
+ bmp_pos += 8;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ bit = bit || ((task.bitmap[bmp_pos >> 3] >> (bmp_pos & 0x7)) & 1);
|
||||
+ bmp_pos++;
|
||||
+ }
|
||||
+ }
|
||||
+ *pnum = bytes;
|
||||
+ }
|
||||
+ if (bit)
|
||||
+ {
|
||||
+ *map = offset;
|
||||
+ *file = bs;
|
||||
+ }
|
||||
+ return (bit ? (BDRV_BLOCK_DATA|BDRV_BLOCK_OFFSET_VALID) : 0);
|
||||
+}
|
||||
+#endif
|
||||
+#if QEMU_VERSION_MAJOR == 1 && QEMU_VERSION_MINOR >= 7 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR < 12
|
||||
+// QEMU 1.7-2.11
|
||||
+static int64_t coroutine_fn vitastor_co_get_block_status(BlockDriverState *bs,
|
||||
+ int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file)
|
||||
+{
|
||||
+ int64_t map = 0;
|
||||
+ int64_t pnumbytes = 0;
|
||||
+ int r = vitastor_co_block_status(bs, 1, sector_num*BDRV_SECTOR_SIZE, nb_sectors*BDRV_SECTOR_SIZE, &pnumbytes, &map, &file);
|
||||
+ *pnum = pnumbytes/BDRV_SECTOR_SIZE;
|
||||
+ return r;
|
||||
+}
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
+#if !( QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 7 )
|
||||
+static int coroutine_fn vitastor_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov)
|
||||
+{
|
||||
+ return vitastor_co_preadv(bs, sector_num*BDRV_SECTOR_SIZE, nb_sectors*BDRV_SECTOR_SIZE, iov, 0);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn vitastor_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov)
|
||||
+{
|
||||
+ return vitastor_co_pwritev(bs, sector_num*BDRV_SECTOR_SIZE, nb_sectors*BDRV_SECTOR_SIZE, iov, 0);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static int coroutine_fn vitastor_co_flush(BlockDriverState *bs)
|
||||
+{
|
||||
+ VitastorClient *client = bs->opaque;
|
||||
+ VitastorRPC task;
|
||||
+ vitastor_co_init_task(bs, &task);
|
||||
+
|
||||
+ qemu_mutex_lock(&client->mutex);
|
||||
+ vitastor_c_sync(client->proxy, vitastor_co_generic_bh_cb, &task);
|
||||
+ qemu_mutex_unlock(&client->mutex);
|
||||
+
|
||||
+ while (!task.complete)
|
||||
+ {
|
||||
+ qemu_coroutine_yield();
|
||||
+ }
|
||||
+
|
||||
+ return task.ret;
|
||||
+}
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 0
|
||||
+static QemuOptsList vitastor_create_opts = {
|
||||
+ .name = "vitastor-create-opts",
|
||||
+ .head = QTAILQ_HEAD_INITIALIZER(vitastor_create_opts.head),
|
||||
+ .desc = {
|
||||
+ {
|
||||
+ .name = BLOCK_OPT_SIZE,
|
||||
+ .type = QEMU_OPT_SIZE,
|
||||
+ .help = "Virtual disk size"
|
||||
+ },
|
||||
+ { /* end of list */ }
|
||||
+ }
|
||||
+};
|
||||
+#else
|
||||
+static QEMUOptionParameter vitastor_create_opts[] = {
|
||||
+ {
|
||||
+ .name = BLOCK_OPT_SIZE,
|
||||
+ .type = OPT_SIZE,
|
||||
+ .help = "Virtual disk size"
|
||||
+ },
|
||||
+ { NULL }
|
||||
+};
|
||||
+#endif
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 4
|
||||
+static const char *vitastor_strong_runtime_opts[] = {
|
||||
+ "inode",
|
||||
+ "pool",
|
||||
+ "config-path",
|
||||
+ "etcd-host",
|
||||
+ "etcd-prefix",
|
||||
+
|
||||
+ NULL
|
||||
+};
|
||||
+#endif
|
||||
+
|
||||
+static BlockDriver bdrv_vitastor = {
|
||||
+ .format_name = "vitastor",
|
||||
+ .protocol_name = "vitastor",
|
||||
+
|
||||
+ .instance_size = sizeof(VitastorClient),
|
||||
+ .bdrv_parse_filename = vitastor_parse_filename,
|
||||
+
|
||||
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
||||
+ .bdrv_get_info = vitastor_get_info,
|
||||
+ .bdrv_getlength = vitastor_getlength,
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 2
|
||||
+ .bdrv_probe_blocksizes = vitastor_probe_blocksizes,
|
||||
+#endif
|
||||
+ .bdrv_refresh_limits = vitastor_refresh_limits,
|
||||
+
|
||||
+ // FIXME: Implement it along with per-inode statistics
|
||||
+ //.bdrv_get_allocated_file_size = vitastor_get_allocated_file_size,
|
||||
+
|
||||
+ .bdrv_file_open = vitastor_file_open,
|
||||
+ .bdrv_close = vitastor_close,
|
||||
+
|
||||
+ // Option list for the create operation
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 0
|
||||
+ .create_opts = &vitastor_create_opts,
|
||||
+#else
|
||||
+ .create_options = vitastor_create_opts,
|
||||
+#endif
|
||||
+
|
||||
+ // For qmp_blockdev_create(), used by the qemu monitor / QAPI
|
||||
+ // Requires patching QAPI IDL, thus unimplemented
|
||||
+ //.bdrv_co_create = vitastor_co_create,
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 12
|
||||
+ // For bdrv_create(), used by qemu-img
|
||||
+ .bdrv_co_create_opts = vitastor_co_create_opts,
|
||||
+#endif
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3
|
||||
+ .bdrv_co_truncate = vitastor_co_truncate,
|
||||
+#endif
|
||||
+
|
||||
+#if defined VITASTOR_C_API_VERSION && VITASTOR_C_API_VERSION >= 1
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 12
|
||||
+ // For snapshot export
|
||||
+ .bdrv_co_block_status = vitastor_co_block_status,
|
||||
+#elif QEMU_VERSION_MAJOR == 1 && QEMU_VERSION_MINOR >= 7 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR < 12
|
||||
+ .bdrv_co_get_block_status = vitastor_co_get_block_status,
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 7
|
||||
+ .bdrv_co_preadv = vitastor_co_preadv,
|
||||
+ .bdrv_co_pwritev = vitastor_co_pwritev,
|
||||
+#else
|
||||
+ .bdrv_co_readv = vitastor_co_readv,
|
||||
+ .bdrv_co_writev = vitastor_co_writev,
|
||||
+#endif
|
||||
+
|
||||
+ .bdrv_co_flush_to_disk = vitastor_co_flush,
|
||||
+
|
||||
+#if QEMU_VERSION_MAJOR >= 4
|
||||
+ .strong_runtime_opts = vitastor_strong_runtime_opts,
|
||||
+#endif
|
||||
+};
|
||||
+
|
||||
+static void vitastor_block_init(void)
|
||||
+{
|
||||
+ bdrv_register(&bdrv_vitastor);
|
||||
+}
|
||||
+
|
||||
+block_init(vitastor_block_init);
|
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/block/file-posix.c b/block/file-posix.c
|
||||
index d5fd1dbcd2..bda3e606dc 100644
|
||||
index b283093e5b..821405fd02 100644
|
||||
--- a/block/file-posix.c
|
||||
+++ b/block/file-posix.c
|
||||
@@ -508,7 +508,7 @@ static QemuOptsList raw_runtime_opts = {
|
||||
@@ -552,7 +552,7 @@ static QemuOptsList raw_runtime_opts = {
|
||||
{
|
||||
.name = "locking",
|
||||
.type = QEMU_OPT_STRING,
|
||||
@@ -26,7 +26,7 @@ index d5fd1dbcd2..bda3e606dc 100644
|
||||
},
|
||||
{
|
||||
.name = "pr-manager",
|
||||
@@ -606,7 +606,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
@@ -652,7 +652,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
s->use_lock = false;
|
||||
break;
|
||||
case ON_OFF_AUTO_AUTO:
|
||||
|
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/include/net/net.h b/include/net/net.h
|
||||
index 778fc787ca..fb2db6bb75 100644
|
||||
index 523136c7ac..c27859b4f6 100644
|
||||
--- a/include/net/net.h
|
||||
+++ b/include/net/net.h
|
||||
@@ -210,8 +210,8 @@ void netdev_add(QemuOpts *opts, Error **errp);
|
||||
@@ -226,8 +226,8 @@ void netdev_add(QemuOpts *opts, Error **errp);
|
||||
int net_hub_id_for_client(NetClientState *nc, int *id);
|
||||
NetClientState *net_hub_port_find(int hub_id);
|
||||
|
||||
|
@@ -10,10 +10,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
|
||||
index 88e8586f8f..93563ee0c2 100644
|
||||
index 04f2b790c9..19fdbb981c 100644
|
||||
--- a/target/i386/cpu.h
|
||||
+++ b/target/i386/cpu.h
|
||||
@@ -1973,9 +1973,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
|
||||
@@ -2039,9 +2039,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
|
||||
#define CPU_RESOLVING_TYPE TYPE_X86_CPU
|
||||
|
||||
#ifdef TARGET_X86_64
|
||||
@@ -24,4 +24,4 @@ index 88e8586f8f..93563ee0c2 100644
|
||||
+#define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("kvm32")
|
||||
#endif
|
||||
|
||||
#define cpu_signal_handler cpu_x86_signal_handler
|
||||
#define cpu_list x86_cpu_list
|
||||
|
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 9 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/ui/spice-core.c b/ui/spice-core.c
|
||||
index eea52f5389..d09ee7f09e 100644
|
||||
index 31974b8d6c..a3acdbd682 100644
|
||||
--- a/ui/spice-core.c
|
||||
+++ b/ui/spice-core.c
|
||||
@@ -667,32 +667,35 @@ static void qemu_spice_init(void)
|
||||
@@ -689,32 +689,35 @@ static void qemu_spice_init(void)
|
||||
|
||||
if (tls_port) {
|
||||
x509_dir = qemu_opt_get(opts, "x509-dir");
|
||||
|
@@ -9,7 +9,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 11 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/block/gluster.c b/block/gluster.c
|
||||
index 4f1448e2bc..715f06394c 100644
|
||||
index 592e71b22a..aebfece6eb 100644
|
||||
--- a/block/gluster.c
|
||||
+++ b/block/gluster.c
|
||||
@@ -42,7 +42,7 @@
|
@@ -1,24 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Derumier <aderumier@odiso.com>
|
||||
Date: Mon, 6 Apr 2020 12:16:34 +0200
|
||||
Subject: [PATCH] PVE: [Config] smm_available = false
|
||||
|
||||
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/i386/x86.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
|
||||
index 5944fc44ed..31b481b4e9 100644
|
||||
--- a/hw/i386/x86.c
|
||||
+++ b/hw/i386/x86.c
|
||||
@@ -1115,7 +1115,7 @@ bool x86_machine_is_smm_enabled(const X86MachineState *x86ms)
|
||||
if (tcg_enabled() || qtest_enabled()) {
|
||||
smm_available = true;
|
||||
} else if (kvm_enabled()) {
|
||||
- smm_available = kvm_has_smm();
|
||||
+ smm_available = false;
|
||||
}
|
||||
|
||||
if (smm_available) {
|
@@ -18,10 +18,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/block/rbd.c b/block/rbd.c
|
||||
index 9bd2bce716..c7195a2342 100644
|
||||
index def96292e0..a4b8fb482c 100644
|
||||
--- a/block/rbd.c
|
||||
+++ b/block/rbd.c
|
||||
@@ -609,6 +609,8 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
||||
@@ -820,6 +820,8 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
||||
rados_conf_set(*cluster, "rbd_cache", "false");
|
||||
}
|
||||
|
@@ -11,10 +11,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
3 files changed, 43 insertions(+)
|
||||
|
||||
diff --git a/net/net.c b/net/net.c
|
||||
index 6a2c3d9567..a1e9514fb8 100644
|
||||
index f0d14dbfc1..6d476c47ef 100644
|
||||
--- a/net/net.c
|
||||
+++ b/net/net.c
|
||||
@@ -1277,6 +1277,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
|
||||
@@ -1334,6 +1334,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ index 6a2c3d9567..a1e9514fb8 100644
|
||||
{
|
||||
NetClientState *nc;
|
||||
diff --git a/qapi/net.json b/qapi/net.json
|
||||
index a3a1336001..b8092c4e20 100644
|
||||
index 7fab2e7cd8..74c9a6109e 100644
|
||||
--- a/qapi/net.json
|
||||
+++ b/qapi/net.json
|
||||
@@ -35,6 +35,21 @@
|
||||
@@ -75,14 +75,14 @@ index a3a1336001..b8092c4e20 100644
|
||||
# @netdev_add:
|
||||
#
|
||||
diff --git a/qapi/pragma.json b/qapi/pragma.json
|
||||
index cffae27666..5a3e3de95f 100644
|
||||
index 3bc0335d1f..7c91ea3685 100644
|
||||
--- a/qapi/pragma.json
|
||||
+++ b/qapi/pragma.json
|
||||
@@ -5,6 +5,7 @@
|
||||
{ 'pragma': {
|
||||
# Commands allowed to return a non-dictionary:
|
||||
'returns-whitelist': [
|
||||
+ 'get_link_status',
|
||||
@@ -22,6 +22,7 @@
|
||||
'system_reset',
|
||||
'system_wakeup' ],
|
||||
'command-returns-exceptions': [
|
||||
+ 'get_link_status',
|
||||
'human-monitor-command',
|
||||
'qom-get',
|
||||
'query-migrate-cache-size',
|
||||
'query-tpm-models',
|
@@ -16,7 +16,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block/gluster.c b/block/gluster.c
|
||||
index 715f06394c..6d02170d9b 100644
|
||||
index aebfece6eb..3b7ee2f649 100644
|
||||
--- a/block/gluster.c
|
||||
+++ b/block/gluster.c
|
||||
@@ -57,6 +57,7 @@ typedef struct GlusterAIOCB {
|
||||
@@ -27,7 +27,7 @@ index 715f06394c..6d02170d9b 100644
|
||||
} GlusterAIOCB;
|
||||
|
||||
typedef struct BDRVGlusterState {
|
||||
@@ -759,8 +760,10 @@ static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret,
|
||||
@@ -752,8 +753,10 @@ static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret,
|
||||
acb->ret = 0; /* Success */
|
||||
} else if (ret < 0) {
|
||||
acb->ret = -errno; /* Read/Write failed */
|
||||
@@ -39,15 +39,15 @@ index 715f06394c..6d02170d9b 100644
|
||||
}
|
||||
|
||||
aio_co_schedule(acb->aio_context, acb->coroutine);
|
||||
@@ -1028,6 +1031,7 @@ static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
@@ -1022,6 +1025,7 @@ static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
acb.ret = 0;
|
||||
acb.coroutine = qemu_coroutine_self();
|
||||
acb.aio_context = bdrv_get_aio_context(bs);
|
||||
+ acb.is_write = true;
|
||||
|
||||
ret = glfs_zerofill_async(s->fd, offset, size, gluster_finish_aiocb, &acb);
|
||||
ret = glfs_zerofill_async(s->fd, offset, bytes, gluster_finish_aiocb, &acb);
|
||||
if (ret < 0) {
|
||||
@@ -1209,9 +1213,11 @@ static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs,
|
||||
@@ -1203,9 +1207,11 @@ static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs,
|
||||
acb.aio_context = bdrv_get_aio_context(bs);
|
||||
|
||||
if (write) {
|
||||
@@ -59,7 +59,7 @@ index 715f06394c..6d02170d9b 100644
|
||||
ret = glfs_preadv_async(s->fd, qiov->iov, qiov->niov, offset, 0,
|
||||
gluster_finish_aiocb, &acb);
|
||||
}
|
||||
@@ -1275,6 +1281,7 @@ static coroutine_fn int qemu_gluster_co_flush_to_disk(BlockDriverState *bs)
|
||||
@@ -1269,6 +1275,7 @@ static coroutine_fn int qemu_gluster_co_flush_to_disk(BlockDriverState *bs)
|
||||
acb.ret = 0;
|
||||
acb.coroutine = qemu_coroutine_self();
|
||||
acb.aio_context = bdrv_get_aio_context(bs);
|
||||
@@ -67,11 +67,11 @@ index 715f06394c..6d02170d9b 100644
|
||||
|
||||
ret = glfs_fsync_async(s->fd, gluster_finish_aiocb, &acb);
|
||||
if (ret < 0) {
|
||||
@@ -1321,6 +1328,7 @@ static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs,
|
||||
@@ -1317,6 +1324,7 @@ static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs,
|
||||
acb.ret = 0;
|
||||
acb.coroutine = qemu_coroutine_self();
|
||||
acb.aio_context = bdrv_get_aio_context(bs);
|
||||
+ acb.is_write = true;
|
||||
|
||||
ret = glfs_discard_async(s->fd, offset, size, gluster_finish_aiocb, &acb);
|
||||
ret = glfs_discard_async(s->fd, offset, bytes, gluster_finish_aiocb, &acb);
|
||||
if (ret < 0) {
|
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index f9050bfaad..7e6666b5f7 100644
|
||||
index f036a1d428..080ad9bca7 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -3022,7 +3022,8 @@ static int img_info(int argc, char **argv)
|
||||
@@ -2989,7 +2989,8 @@ static int img_info(int argc, char **argv)
|
||||
list = collect_image_info_list(image_opts, filename, fmt, chain,
|
||||
force_share);
|
||||
if (!list) {
|
@@ -33,11 +33,11 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
qemu-img-cmds.hx | 4 +-
|
||||
qemu-img.c | 191 +++++++++++++++++++++++++++++------------------
|
||||
2 files changed, 121 insertions(+), 74 deletions(-)
|
||||
qemu-img.c | 187 +++++++++++++++++++++++++++++------------------
|
||||
2 files changed, 119 insertions(+), 72 deletions(-)
|
||||
|
||||
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
||||
index b3620f29e5..e70ef3dc91 100644
|
||||
index 72bcdcfbfa..0b2999f3ab 100644
|
||||
--- a/qemu-img-cmds.hx
|
||||
+++ b/qemu-img-cmds.hx
|
||||
@@ -58,9 +58,9 @@ SRST
|
||||
@@ -53,10 +53,10 @@ index b3620f29e5..e70ef3dc91 100644
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 7e6666b5f7..44cf942bd2 100644
|
||||
index 080ad9bca7..1f457d9e80 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4897,10 +4897,12 @@ static int img_bitmap(int argc, char **argv)
|
||||
@@ -4805,10 +4805,12 @@ static int img_bitmap(int argc, char **argv)
|
||||
#define C_IF 04
|
||||
#define C_OF 010
|
||||
#define C_SKIP 020
|
||||
@@ -69,7 +69,7 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
};
|
||||
|
||||
struct DdIo {
|
||||
@@ -4976,6 +4978,19 @@ static int img_dd_skip(const char *arg,
|
||||
@@ -4884,6 +4886,19 @@ static int img_dd_skip(const char *arg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
static int img_dd(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -5016,6 +5031,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -4924,6 +4939,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ "if", img_dd_if, C_IF },
|
||||
{ "of", img_dd_of, C_OF },
|
||||
{ "skip", img_dd_skip, C_SKIP },
|
||||
@@ -97,7 +97,7 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
const struct option long_options[] = {
|
||||
@@ -5094,8 +5110,13 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -4999,91 +5015,112 @@ static int img_dd(int argc, char **argv)
|
||||
arg = NULL;
|
||||
}
|
||||
|
||||
@@ -105,53 +105,30 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
- error_report("Must specify both input and output files");
|
||||
+ if (!(dd.flags & C_IF) && (!fmt || strcmp(fmt, "raw") != 0)) {
|
||||
+ error_report("Input format must be raw when readin from stdin");
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
-
|
||||
- blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
|
||||
- force_share);
|
||||
-
|
||||
- if (!blk1) {
|
||||
+ if (!(dd.flags & C_OF) && strcmp(out_fmt, "raw") != 0) {
|
||||
+ error_report("Output format must be raw when writing to stdout");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
@@ -5107,85 +5128,101 @@ static int img_dd(int argc, char **argv)
|
||||
goto out;
|
||||
}
|
||||
|
||||
- blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
|
||||
- force_share);
|
||||
+ if (dd.flags & C_IF) {
|
||||
+ blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
|
||||
+ force_share);
|
||||
|
||||
- if (!blk1) {
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+ if (!blk1) {
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
|
||||
- drv = bdrv_find_format(out_fmt);
|
||||
- if (!drv) {
|
||||
- error_report("Unknown file format");
|
||||
+ if (dd.flags & C_OSIZE) {
|
||||
+ size = dd.osize;
|
||||
+ } else if (dd.flags & C_IF) {
|
||||
+ size = blk_getlength(blk1);
|
||||
+ if (size < 0) {
|
||||
+ error_report("Failed to get size for '%s'", in.filename);
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ } else if (dd.flags & C_COUNT) {
|
||||
+ size = dd.count * in.bsz;
|
||||
+ } else {
|
||||
+ error_report("Output size must be known when reading from stdin");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
- }
|
||||
- proto_drv = bdrv_find_protocol(out.filename, true, &local_err);
|
||||
+ if (dd.flags & C_IF) {
|
||||
+ blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
|
||||
+ force_share);
|
||||
|
||||
- if (!proto_drv) {
|
||||
- error_report_err(local_err);
|
||||
@@ -169,14 +146,50 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
- proto_drv->format_name);
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+ if (!(dd.flags & C_OSIZE) && dd.flags & C_COUNT && dd.count <= INT64_MAX / in.bsz &&
|
||||
+ dd.count * in.bsz < size) {
|
||||
+ size = dd.count * in.bsz;
|
||||
+ if (!blk1) {
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
- create_opts = qemu_opts_append(create_opts, drv->create_opts);
|
||||
- create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
|
||||
|
||||
- opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
|
||||
-
|
||||
- size = blk_getlength(blk1);
|
||||
- if (size < 0) {
|
||||
- error_report("Failed to get size for '%s'", in.filename);
|
||||
+ if (dd.flags & C_OSIZE) {
|
||||
+ size = dd.osize;
|
||||
+ } else if (dd.flags & C_IF) {
|
||||
+ size = blk_getlength(blk1);
|
||||
+ if (size < 0) {
|
||||
+ error_report("Failed to get size for '%s'", in.filename);
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ } else if (dd.flags & C_COUNT) {
|
||||
+ size = dd.count * in.bsz;
|
||||
+ } else {
|
||||
+ error_report("Output size must be known when reading from stdin");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
- if (dd.flags & C_COUNT && dd.count <= INT64_MAX / in.bsz &&
|
||||
+ if (!(dd.flags & C_OSIZE) && dd.flags & C_COUNT && dd.count <= INT64_MAX / in.bsz &&
|
||||
dd.count * in.bsz < size) {
|
||||
size = dd.count * in.bsz;
|
||||
}
|
||||
|
||||
- /* Overflow means the specified offset is beyond input image's size */
|
||||
- if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
|
||||
- size < in.bsz * in.offset)) {
|
||||
- qemu_opt_set_number(opts, BLOCK_OPT_SIZE, 0, &error_abort);
|
||||
- } else {
|
||||
- qemu_opt_set_number(opts, BLOCK_OPT_SIZE,
|
||||
- size - in.bsz * in.offset, &error_abort);
|
||||
- }
|
||||
+ if (dd.flags & C_OF) {
|
||||
+ drv = bdrv_find_format(out_fmt);
|
||||
+ if (!drv) {
|
||||
@@ -186,9 +199,11 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
+ }
|
||||
+ proto_drv = bdrv_find_protocol(out.filename, true, &local_err);
|
||||
|
||||
- size = blk_getlength(blk1);
|
||||
- if (size < 0) {
|
||||
- error_report("Failed to get size for '%s'", in.filename);
|
||||
- ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
- if (ret < 0) {
|
||||
- error_reportf_err(local_err,
|
||||
- "%s: error while creating output image: ",
|
||||
- out.filename);
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
- }
|
||||
@@ -212,20 +227,18 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
+ create_opts = qemu_opts_append(create_opts, drv->create_opts);
|
||||
+ create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
|
||||
|
||||
- if (dd.flags & C_COUNT && dd.count <= INT64_MAX / in.bsz &&
|
||||
- dd.count * in.bsz < size) {
|
||||
- size = dd.count * in.bsz;
|
||||
- }
|
||||
- /* TODO, we can't honour --image-opts for the target,
|
||||
- * since it needs to be given in a format compatible
|
||||
- * with the bdrv_create() call above which does not
|
||||
- * support image-opts style.
|
||||
- */
|
||||
- blk2 = img_open_file(out.filename, NULL, out_fmt, BDRV_O_RDWR,
|
||||
- false, false, false);
|
||||
+ opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
|
||||
|
||||
- /* Overflow means the specified offset is beyond input image's size */
|
||||
- if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
|
||||
- size < in.bsz * in.offset)) {
|
||||
- qemu_opt_set_number(opts, BLOCK_OPT_SIZE, 0, &error_abort);
|
||||
- } else {
|
||||
- qemu_opt_set_number(opts, BLOCK_OPT_SIZE,
|
||||
- size - in.bsz * in.offset, &error_abort);
|
||||
- }
|
||||
- if (!blk2) {
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+ /* Overflow means the specified offset is beyond input image's size */
|
||||
+ if (dd.flags & C_OSIZE) {
|
||||
+ qemu_opt_set_number(opts, BLOCK_OPT_SIZE, size, &error_abort);
|
||||
@@ -236,15 +249,7 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
+ qemu_opt_set_number(opts, BLOCK_OPT_SIZE,
|
||||
+ size - in.bsz * in.offset, &error_abort);
|
||||
+ }
|
||||
|
||||
- ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
- if (ret < 0) {
|
||||
- error_reportf_err(local_err,
|
||||
- "%s: error while creating output image: ",
|
||||
- out.filename);
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
- }
|
||||
+
|
||||
+ ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
+ if (ret < 0) {
|
||||
+ error_reportf_err(local_err,
|
||||
@@ -253,14 +258,7 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
- /* TODO, we can't honour --image-opts for the target,
|
||||
- * since it needs to be given in a format compatible
|
||||
- * with the bdrv_create() call above which does not
|
||||
- * support image-opts style.
|
||||
- */
|
||||
- blk2 = img_open_file(out.filename, NULL, out_fmt, BDRV_O_RDWR,
|
||||
- false, false, false);
|
||||
+
|
||||
+ /* TODO, we can't honour --image-opts for the target,
|
||||
+ * since it needs to be given in a format compatible
|
||||
+ * with the bdrv_create() call above which does not
|
||||
@@ -268,10 +266,7 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
+ */
|
||||
+ blk2 = img_open_file(out.filename, NULL, out_fmt, BDRV_O_RDWR,
|
||||
+ false, false, false);
|
||||
|
||||
- if (!blk2) {
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+
|
||||
+ if (!blk2) {
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
@@ -279,7 +274,7 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
}
|
||||
|
||||
if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
|
||||
@@ -5203,11 +5240,17 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5101,11 +5138,17 @@ static int img_dd(int argc, char **argv)
|
||||
|
||||
for (out_pos = 0; in_pos < size; block_count++) {
|
||||
int in_ret, out_ret;
|
||||
@@ -301,7 +296,7 @@ index 7e6666b5f7..44cf942bd2 100644
|
||||
}
|
||||
if (in_ret < 0) {
|
||||
error_report("error while reading from input image file: %s",
|
||||
@@ -5217,9 +5260,13 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5115,9 +5158,13 @@ static int img_dd(int argc, char **argv)
|
||||
}
|
||||
in_pos += in_ret;
|
||||
|
@@ -15,10 +15,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
1 file changed, 25 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 44cf942bd2..5ce60e8a45 100644
|
||||
index 1f457d9e80..d9e8a8c4d4 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4898,11 +4898,13 @@ static int img_bitmap(int argc, char **argv)
|
||||
@@ -4806,11 +4806,13 @@ static int img_bitmap(int argc, char **argv)
|
||||
#define C_OF 010
|
||||
#define C_SKIP 020
|
||||
#define C_OSIZE 040
|
||||
@@ -32,7 +32,7 @@ index 44cf942bd2..5ce60e8a45 100644
|
||||
};
|
||||
|
||||
struct DdIo {
|
||||
@@ -4991,6 +4993,19 @@ static int img_dd_osize(const char *arg,
|
||||
@@ -4899,6 +4901,19 @@ static int img_dd_osize(const char *arg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ index 44cf942bd2..5ce60e8a45 100644
|
||||
static int img_dd(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -5005,12 +5020,14 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -4913,12 +4928,14 @@ static int img_dd(int argc, char **argv)
|
||||
int c, i;
|
||||
const char *out_fmt = "raw";
|
||||
const char *fmt = NULL;
|
||||
@@ -68,7 +68,7 @@ index 44cf942bd2..5ce60e8a45 100644
|
||||
};
|
||||
struct DdIo in = {
|
||||
.bsz = 512, /* Block size is by default 512 bytes */
|
||||
@@ -5032,6 +5049,7 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -4940,6 +4957,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ "of", img_dd_of, C_OF },
|
||||
{ "skip", img_dd_skip, C_SKIP },
|
||||
{ "osize", img_dd_osize, C_OSIZE },
|
||||
@@ -76,7 +76,7 @@ index 44cf942bd2..5ce60e8a45 100644
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
const struct option long_options[] = {
|
||||
@@ -5238,14 +5256,18 @@ static int img_dd(int argc, char **argv)
|
||||
@@ -5136,14 +5154,18 @@ static int img_dd(int argc, char **argv)
|
||||
|
||||
in.buf = g_new(uint8_t, in.bsz);
|
||||
|
121
debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
vendored
Normal file
121
debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Derumier <aderumier@odiso.com>
|
||||
Date: Mon, 6 Apr 2020 12:16:42 +0200
|
||||
Subject: [PATCH] PVE: [Up] qemu-img dd: add -n skip_create
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: fix getopt-string + add documentation]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
docs/tools/qemu-img.rst | 11 ++++++++++-
|
||||
qemu-img-cmds.hx | 4 ++--
|
||||
qemu-img.c | 23 ++++++++++++++---------
|
||||
3 files changed, 26 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
|
||||
index d663dd92bd..a49badb158 100644
|
||||
--- a/docs/tools/qemu-img.rst
|
||||
+++ b/docs/tools/qemu-img.rst
|
||||
@@ -208,6 +208,10 @@ Parameters to convert subcommand:
|
||||
|
||||
Parameters to dd subcommand:
|
||||
|
||||
+.. option:: -n
|
||||
+
|
||||
+ Skip the creation of the target volume
|
||||
+
|
||||
.. program:: qemu-img-dd
|
||||
|
||||
.. option:: bs=BLOCK_SIZE
|
||||
@@ -488,7 +492,7 @@ Command description:
|
||||
it doesn't need to be specified separately in this case.
|
||||
|
||||
|
||||
-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
|
||||
+.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
|
||||
|
||||
dd copies from *INPUT* file to *OUTPUT* file converting it from
|
||||
*FMT* format to *OUTPUT_FMT* format.
|
||||
@@ -499,6 +503,11 @@ Command description:
|
||||
|
||||
The size syntax is similar to :manpage:`dd(1)`'s size syntax.
|
||||
|
||||
+ If the ``-n`` option is specified, the target volume creation will be
|
||||
+ skipped. This is useful for formats such as ``rbd`` if the target
|
||||
+ volume has already been created with site specific options that cannot
|
||||
+ be supplied through ``qemu-img``.
|
||||
+
|
||||
.. option:: info [--object OBJECTDEF] [--image-opts] [-f FMT] [--output=OFMT] [--backing-chain] [-U] FILENAME
|
||||
|
||||
Give information about the disk image *FILENAME*. Use it in
|
||||
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
||||
index 0b2999f3ab..f3b2b1b4de 100644
|
||||
--- a/qemu-img-cmds.hx
|
||||
+++ b/qemu-img-cmds.hx
|
||||
@@ -58,9 +58,9 @@ SRST
|
||||
ERST
|
||||
|
||||
DEF("dd", img_dd,
|
||||
- "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
|
||||
+ "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [-n] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
|
||||
SRST
|
||||
-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT
|
||||
+.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT
|
||||
ERST
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index d9e8a8c4d4..015d6d2ce4 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4930,7 +4930,7 @@ static int img_dd(int argc, char **argv)
|
||||
const char *fmt = NULL;
|
||||
int64_t size = 0, readsize = 0;
|
||||
int64_t block_count = 0, out_pos, in_pos;
|
||||
- bool force_share = false;
|
||||
+ bool force_share = false, skip_create = false;
|
||||
struct DdInfo dd = {
|
||||
.flags = 0,
|
||||
.count = 0,
|
||||
@@ -4968,7 +4968,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
- while ((c = getopt_long(argc, argv, ":hf:O:U", long_options, NULL))) {
|
||||
+ while ((c = getopt_long(argc, argv, ":hf:O:Un", long_options, NULL))) {
|
||||
if (c == EOF) {
|
||||
break;
|
||||
}
|
||||
@@ -4988,6 +4988,9 @@ static int img_dd(int argc, char **argv)
|
||||
case 'h':
|
||||
help();
|
||||
break;
|
||||
+ case 'n':
|
||||
+ skip_create = true;
|
||||
+ break;
|
||||
case 'U':
|
||||
force_share = true;
|
||||
break;
|
||||
@@ -5118,13 +5121,15 @@ static int img_dd(int argc, char **argv)
|
||||
size - in.bsz * in.offset, &error_abort);
|
||||
}
|
||||
|
||||
- ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
- if (ret < 0) {
|
||||
- error_reportf_err(local_err,
|
||||
- "%s: error while creating output image: ",
|
||||
- out.filename);
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+ if (!skip_create) {
|
||||
+ ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
+ if (ret < 0) {
|
||||
+ error_reportf_err(local_err,
|
||||
+ "%s: error while creating output image: ",
|
||||
+ out.filename);
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* TODO, we can't honour --image-opts for the target,
|
@@ -1,65 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Derumier <aderumier@odiso.com>
|
||||
Date: Mon, 6 Apr 2020 12:16:42 +0200
|
||||
Subject: [PATCH] PVE: [Up] qemu-img dd: add -n skip_create
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
qemu-img.c | 23 ++++++++++++++---------
|
||||
1 file changed, 14 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 5ce60e8a45..86bfd0288b 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -5022,7 +5022,7 @@ static int img_dd(int argc, char **argv)
|
||||
const char *fmt = NULL;
|
||||
int64_t size = 0, readsize = 0;
|
||||
int64_t block_count = 0, out_pos, in_pos;
|
||||
- bool force_share = false;
|
||||
+ bool force_share = false, skip_create = false;
|
||||
struct DdInfo dd = {
|
||||
.flags = 0,
|
||||
.count = 0,
|
||||
@@ -5060,7 +5060,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
- while ((c = getopt_long(argc, argv, ":hf:O:U", long_options, NULL))) {
|
||||
+ while ((c = getopt_long(argc, argv, ":hf:O:U:n", long_options, NULL))) {
|
||||
if (c == EOF) {
|
||||
break;
|
||||
}
|
||||
@@ -5080,6 +5080,9 @@ static int img_dd(int argc, char **argv)
|
||||
case 'h':
|
||||
help();
|
||||
break;
|
||||
+ case 'n':
|
||||
+ skip_create = true;
|
||||
+ break;
|
||||
case 'U':
|
||||
force_share = true;
|
||||
break;
|
||||
@@ -5220,13 +5223,15 @@ static int img_dd(int argc, char **argv)
|
||||
size - in.bsz * in.offset, &error_abort);
|
||||
}
|
||||
|
||||
- ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
- if (ret < 0) {
|
||||
- error_reportf_err(local_err,
|
||||
- "%s: error while creating output image: ",
|
||||
- out.filename);
|
||||
- ret = -1;
|
||||
- goto out;
|
||||
+ if (!skip_create) {
|
||||
+ ret = bdrv_create(drv, out.filename, opts, &local_err);
|
||||
+ if (ret < 0) {
|
||||
+ error_reportf_err(local_err,
|
||||
+ "%s: error while creating output image: ",
|
||||
+ out.filename);
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* TODO, we can't honour --image-opts for the target,
|
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
3 files changed, 81 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
|
||||
index b22b5beda3..6e581439bf 100644
|
||||
index 9a4f491b54..1faa16234e 100644
|
||||
--- a/hw/virtio/virtio-balloon.c
|
||||
+++ b/hw/virtio/virtio-balloon.c
|
||||
@@ -805,8 +805,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
|
||||
@@ -812,8 +812,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;
|
||||
@@ -58,10 +58,10 @@ index b22b5beda3..6e581439bf 100644
|
||||
|
||||
static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index 65d8ff4849..705f08a8f1 100644
|
||||
index 2e91ccb738..e9fa9af6bd 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -695,7 +695,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
|
||||
@@ -696,7 +696,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,10 +99,10 @@ index 65d8ff4849..705f08a8f1 100644
|
||||
qapi_free_BalloonInfo(info);
|
||||
}
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 7c9a263778..3e59199280 100644
|
||||
index 067e3f5378..91f3be6f44 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -1205,10 +1205,30 @@
|
||||
@@ -1018,10 +1018,30 @@
|
||||
# @actual: the logical size of the VM in bytes
|
||||
# Formula used: logical_vm_size = vm_ram_size - balloon_size
|
||||
#
|
||||
@@ -122,7 +122,7 @@ index 7c9a263778..3e59199280 100644
|
||||
+#
|
||||
+# @max_mem: amount of memory (in bytes) assigned to the guest
|
||||
+#
|
||||
# Since: 0.14.0
|
||||
# Since: 0.14
|
||||
#
|
||||
##
|
||||
-{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
|
@@ -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 5362c80a18..3fcb82ce2f 100644
|
||||
index 4f4ab30f8c..76fff60a6b 100644
|
||||
--- a/hw/core/machine-qmp-cmds.c
|
||||
+++ b/hw/core/machine-qmp-cmds.c
|
||||
@@ -234,6 +234,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
||||
@@ -99,6 +99,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
||||
info->hotpluggable_cpus = mc->has_hotpluggable_cpus;
|
||||
info->numa_mem_supported = mc->numa_mem_supported;
|
||||
info->deprecated = !!mc->deprecation_reason;
|
||||
@@ -30,19 +30,19 @@ index 5362c80a18..3fcb82ce2f 100644
|
||||
info->default_cpu_type = g_strdup(mc->default_cpu_type);
|
||||
info->has_default_cpu_type = true;
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 3e59199280..dfc1a49d3c 100644
|
||||
index 91f3be6f44..0905618e25 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -318,6 +318,8 @@
|
||||
@@ -141,6 +141,8 @@
|
||||
#
|
||||
# @is-default: whether the machine is default
|
||||
#
|
||||
+# @is-current: whether this machine is currently used
|
||||
+#
|
||||
# @cpu-max: maximum number of CPUs supported by the machine type
|
||||
# (since 1.5.0)
|
||||
# (since 1.5)
|
||||
#
|
||||
@@ -339,7 +341,7 @@
|
||||
@@ -162,7 +164,7 @@
|
||||
##
|
||||
{ 'struct': 'MachineInfo',
|
||||
'data': { 'name': 'str', '*alias': 'str',
|
@@ -12,29 +12,29 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
2 files changed, 8 insertions(+)
|
||||
|
||||
diff --git a/qapi/ui.json b/qapi/ui.json
|
||||
index 6c7b33cb72..39ff301d1e 100644
|
||||
index 4244c62c30..f946fbd8c1 100644
|
||||
--- a/qapi/ui.json
|
||||
+++ b/qapi/ui.json
|
||||
@@ -215,11 +215,14 @@
|
||||
@@ -333,11 +333,14 @@
|
||||
#
|
||||
# @channels: a list of @SpiceChannel for each active spice channel
|
||||
#
|
||||
+# @ticket: The last ticket set with set_password
|
||||
+#
|
||||
# Since: 0.14.0
|
||||
# Since: 0.14
|
||||
##
|
||||
{ 'struct': 'SpiceInfo',
|
||||
'data': {'enabled': 'bool', 'migrated': 'bool', '*host': 'str', '*port': 'int',
|
||||
'*tls-port': 'int', '*auth': 'str', '*compiled-version': 'str',
|
||||
+ '*ticket': 'str',
|
||||
'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChannel']},
|
||||
'if': 'defined(CONFIG_SPICE)' }
|
||||
'if': 'CONFIG_SPICE' }
|
||||
|
||||
diff --git a/ui/spice-core.c b/ui/spice-core.c
|
||||
index d09ee7f09e..da3d2644d1 100644
|
||||
index a3acdbd682..756776778d 100644
|
||||
--- a/ui/spice-core.c
|
||||
+++ b/ui/spice-core.c
|
||||
@@ -538,6 +538,11 @@ static SpiceInfo *qmp_query_spice_real(Error **errp)
|
||||
@@ -534,6 +534,11 @@ static SpiceInfo *qmp_query_spice_real(Error **errp)
|
||||
micro = SPICE_SERVER_VERSION & 0xff;
|
||||
info->compiled_version = g_strdup_printf("%d.%d.%d", major, minor, micro);
|
||||
|
@@ -26,7 +26,7 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
hmp-commands-info.hx | 13 +
|
||||
hmp-commands.hx | 33 ++
|
||||
include/migration/snapshot.h | 1 +
|
||||
include/migration/snapshot.h | 2 +
|
||||
include/monitor/hmp.h | 5 +
|
||||
migration/meson.build | 1 +
|
||||
migration/savevm-async.c | 598 +++++++++++++++++++++++++++++++++++
|
||||
@@ -35,15 +35,15 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
qapi/misc.json | 32 ++
|
||||
qemu-options.hx | 12 +
|
||||
softmmu/vl.c | 10 +
|
||||
11 files changed, 796 insertions(+)
|
||||
11 files changed, 797 insertions(+)
|
||||
create mode 100644 migration/savevm-async.c
|
||||
|
||||
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
|
||||
index 117ba25f91..b3b797ca28 100644
|
||||
index 407a1da800..245f8acc55 100644
|
||||
--- a/hmp-commands-info.hx
|
||||
+++ b/hmp-commands-info.hx
|
||||
@@ -580,6 +580,19 @@ SRST
|
||||
Show current migration xbzrle cache size.
|
||||
@@ -536,6 +536,19 @@ SRST
|
||||
Show current migration parameters.
|
||||
ERST
|
||||
|
||||
+ {
|
||||
@@ -63,13 +63,13 @@ index 117ba25f91..b3b797ca28 100644
|
||||
.name = "balloon",
|
||||
.args_type = "",
|
||||
diff --git a/hmp-commands.hx b/hmp-commands.hx
|
||||
index ff2d7aa8f3..d294c234a5 100644
|
||||
index 5efb47fc32..1ad13b668b 100644
|
||||
--- a/hmp-commands.hx
|
||||
+++ b/hmp-commands.hx
|
||||
@@ -1866,3 +1866,36 @@ ERST
|
||||
.flags = "p",
|
||||
@@ -1746,3 +1746,36 @@ ERST
|
||||
"\n\t\t\t -b to specify dirty bitmap as method of calculation)",
|
||||
.cmd = hmp_calc_dirty_rate,
|
||||
},
|
||||
|
||||
+
|
||||
+ {
|
||||
+ .name = "savevm-start",
|
||||
@@ -104,21 +104,21 @@ index ff2d7aa8f3..d294c234a5 100644
|
||||
+ .coroutine = true,
|
||||
+ },
|
||||
diff --git a/include/migration/snapshot.h b/include/migration/snapshot.h
|
||||
index c85b6ec75b..4411b7121d 100644
|
||||
index e72083b117..c846d37806 100644
|
||||
--- a/include/migration/snapshot.h
|
||||
+++ b/include/migration/snapshot.h
|
||||
@@ -17,5 +17,6 @@
|
||||
@@ -61,4 +61,6 @@ bool delete_snapshot(const char *name,
|
||||
bool has_devices, strList *devices,
|
||||
Error **errp);
|
||||
|
||||
int save_snapshot(const char *name, Error **errp);
|
||||
int load_snapshot(const char *name, Error **errp);
|
||||
+int load_snapshot_from_blockdev(const char *filename, Error **errp);
|
||||
|
||||
+
|
||||
#endif
|
||||
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
|
||||
index ed2913fd18..4e06f89e8e 100644
|
||||
index 96d014826a..3a39ba41b5 100644
|
||||
--- a/include/monitor/hmp.h
|
||||
+++ b/include/monitor/hmp.h
|
||||
@@ -25,6 +25,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
|
||||
@@ -26,6 +26,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_uuid(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_chardev(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_mice(Monitor *mon, const QDict *qdict);
|
||||
@@ -126,7 +126,7 @@ index ed2913fd18..4e06f89e8e 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);
|
||||
@@ -83,6 +84,10 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict);
|
||||
@@ -80,6 +81,10 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict);
|
||||
void hmp_netdev_del(Monitor *mon, const QDict *qdict);
|
||||
void hmp_getfd(Monitor *mon, const QDict *qdict);
|
||||
void hmp_closefd(Monitor *mon, const QDict *qdict);
|
||||
@@ -138,7 +138,7 @@ index ed2913fd18..4e06f89e8e 100644
|
||||
void 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 980e37865c..e62b79b60f 100644
|
||||
index f8714dcb15..ea9aedeefc 100644
|
||||
--- a/migration/meson.build
|
||||
+++ b/migration/meson.build
|
||||
@@ -23,6 +23,7 @@ softmmu_ss.add(files(
|
||||
@@ -148,10 +148,10 @@ index 980e37865c..e62b79b60f 100644
|
||||
+ 'savevm-async.c',
|
||||
'socket.c',
|
||||
'tls.c',
|
||||
))
|
||||
), gnutls)
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
new file mode 100644
|
||||
index 0000000000..593a619088
|
||||
index 0000000000..79a0cda906
|
||||
--- /dev/null
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -0,0 +1,598 @@
|
||||
@@ -210,7 +210,7 @@ index 0000000000..593a619088
|
||||
+ int64_t total_time;
|
||||
+ QEMUBH *finalize_bh;
|
||||
+ Coroutine *co;
|
||||
+ QemuCoSleepState *target_close_wait;
|
||||
+ QemuCoSleep *target_close_wait;
|
||||
+} snap_state;
|
||||
+
|
||||
+static bool savevm_aborted(void)
|
||||
@@ -653,8 +653,8 @@ index 0000000000..593a619088
|
||||
+ * 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(QEMU_CLOCK_REALTIME, timeout,
|
||||
+ &snap_state.target_close_wait);
|
||||
+ qemu_co_sleep_ns_wakeable(snap_state.target_close_wait,
|
||||
+ QEMU_CLOCK_REALTIME, timeout);
|
||||
+ snap_state.target_close_wait = NULL;
|
||||
+ if (snap_state.target) {
|
||||
+ save_snapshot_error("timeout waiting for target file close in "
|
||||
@@ -754,10 +754,10 @@ index 0000000000..593a619088
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index 705f08a8f1..77ab152aab 100644
|
||||
index e9fa9af6bd..5000ce39d1 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -1949,6 +1949,63 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
|
||||
@@ -1903,6 +1903,63 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
@@ -822,10 +822,10 @@ index 705f08a8f1..77ab152aab 100644
|
||||
{
|
||||
IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
|
||||
diff --git a/qapi/migration.json b/qapi/migration.json
|
||||
index 3c75820527..cb3627884c 100644
|
||||
index bbfd48cf0b..45686390a2 100644
|
||||
--- a/qapi/migration.json
|
||||
+++ b/qapi/migration.json
|
||||
@@ -242,6 +242,40 @@
|
||||
@@ -247,6 +247,40 @@
|
||||
'*compression': 'CompressionStats',
|
||||
'*socket-address': ['SocketAddress'] } }
|
||||
|
||||
@@ -867,10 +867,10 @@ index 3c75820527..cb3627884c 100644
|
||||
# @query-migrate:
|
||||
#
|
||||
diff --git a/qapi/misc.json b/qapi/misc.json
|
||||
index 40df513856..4f5333d960 100644
|
||||
index 358548abe1..25b3febc52 100644
|
||||
--- a/qapi/misc.json
|
||||
+++ b/qapi/misc.json
|
||||
@@ -476,6 +476,38 @@
|
||||
@@ -435,6 +435,38 @@
|
||||
##
|
||||
{ 'command': 'query-fdsets', 'returns': ['FdsetInfo'] }
|
||||
|
||||
@@ -910,10 +910,10 @@ index 40df513856..4f5333d960 100644
|
||||
# @CommandLineParameterType:
|
||||
#
|
||||
diff --git a/qemu-options.hx b/qemu-options.hx
|
||||
index 104632ea34..c1352312c2 100644
|
||||
index ae2c6dbbfc..423144abeb 100644
|
||||
--- a/qemu-options.hx
|
||||
+++ b/qemu-options.hx
|
||||
@@ -3903,6 +3903,18 @@ SRST
|
||||
@@ -4171,6 +4171,18 @@ SRST
|
||||
Start right away with a saved state (``loadvm`` in monitor)
|
||||
ERST
|
||||
|
||||
@@ -933,31 +933,21 @@ index 104632ea34..c1352312c2 100644
|
||||
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 e6e0ad5a92..03152c816c 100644
|
||||
index 620a1f1367..fd82efb8b3 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -2878,6 +2878,7 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
int optind;
|
||||
const char *optarg;
|
||||
const char *loadvm = NULL;
|
||||
+ const char *loadstate = NULL;
|
||||
MachineClass *machine_class;
|
||||
const char *cpu_option;
|
||||
const char *vga_model = NULL;
|
||||
@@ -3439,6 +3440,9 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
case QEMU_OPTION_loadvm:
|
||||
loadvm = optarg;
|
||||
break;
|
||||
+ case QEMU_OPTION_loadstate:
|
||||
+ loadstate = optarg;
|
||||
+ break;
|
||||
case QEMU_OPTION_full_screen:
|
||||
dpy.has_full_screen = true;
|
||||
dpy.full_screen = true;
|
||||
@@ -4478,6 +4482,12 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
autostart = 0;
|
||||
exit(1);
|
||||
}
|
||||
@@ -156,6 +156,7 @@ static const char *incoming;
|
||||
static const char *loadvm;
|
||||
static const char *accelerators;
|
||||
static QDict *machine_opts_dict;
|
||||
+static const char *loadstate;
|
||||
static QTAILQ_HEAD(, ObjectOption) object_opts = QTAILQ_HEAD_INITIALIZER(object_opts);
|
||||
static QTAILQ_HEAD(, DeviceOption) device_opts = QTAILQ_HEAD_INITIALIZER(device_opts);
|
||||
static ram_addr_t maxram_size;
|
||||
@@ -2743,6 +2744,12 @@ void qmp_x_exit_preconfig(Error **errp)
|
||||
|
||||
if (loadvm) {
|
||||
load_snapshot(loadvm, NULL, false, NULL, &error_fatal);
|
||||
+ } else if (loadstate) {
|
||||
+ Error *local_err = NULL;
|
||||
+ if (load_snapshot_from_blockdev(loadstate, &local_err) < 0) {
|
||||
@@ -967,3 +957,13 @@ index e6e0ad5a92..03152c816c 100644
|
||||
}
|
||||
if (replay_mode != REPLAY_MODE_NONE) {
|
||||
replay_vmstate_init();
|
||||
@@ -3284,6 +3291,9 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
case QEMU_OPTION_loadvm:
|
||||
loadvm = optarg;
|
||||
break;
|
||||
+ case QEMU_OPTION_loadstate:
|
||||
+ loadstate = optarg;
|
||||
+ break;
|
||||
case QEMU_OPTION_full_screen:
|
||||
dpy.has_full_screen = true;
|
||||
dpy.full_screen = true;
|
@@ -9,6 +9,7 @@ increase performance storing the state onto ceph.
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
[increase max IOV count in QEMUFile to actually write more data]
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
migration/qemu-file.c | 38 +++++++++++++++++++++++++-------------
|
||||
migration/qemu-file.h | 1 +
|
||||
@@ -16,7 +17,7 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
3 files changed, 28 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
|
||||
index be21518c57..1926b5202c 100644
|
||||
index 6338d8e2ff..6697a93a7e 100644
|
||||
--- a/migration/qemu-file.c
|
||||
+++ b/migration/qemu-file.c
|
||||
@@ -30,8 +30,8 @@
|
||||
@@ -40,34 +41,34 @@ index be21518c57..1926b5202c 100644
|
||||
|
||||
DECLARE_BITMAP(may_free, MAX_IOV_SIZE);
|
||||
struct iovec iov[MAX_IOV_SIZE];
|
||||
@@ -101,7 +102,7 @@ bool qemu_file_mode_is_not_valid(const char *mode)
|
||||
@@ -103,7 +104,7 @@ bool qemu_file_mode_is_not_valid(const char *mode)
|
||||
return false;
|
||||
}
|
||||
|
||||
-QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
|
||||
+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, size_t buffer_size)
|
||||
-QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
|
||||
+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, bool has_ioc, size_t buffer_size)
|
||||
{
|
||||
QEMUFile *f;
|
||||
|
||||
@@ -109,9 +110,17 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
|
||||
|
||||
@@ -112,9 +113,17 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
|
||||
f->opaque = opaque;
|
||||
f->ops = ops;
|
||||
f->has_ioc = has_ioc;
|
||||
+ f->buf_allocated_size = buffer_size;
|
||||
+ f->buf = malloc(buffer_size);
|
||||
+
|
||||
return f;
|
||||
}
|
||||
|
||||
+QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
|
||||
+QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
|
||||
+{
|
||||
+ return qemu_fopen_ops_sized(opaque, ops, DEFAULT_IO_BUF_SIZE);
|
||||
+ return qemu_fopen_ops_sized(opaque, ops, has_ioc, DEFAULT_IO_BUF_SIZE);
|
||||
+}
|
||||
+
|
||||
|
||||
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks)
|
||||
{
|
||||
@@ -346,7 +355,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
|
||||
@@ -349,7 +358,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
|
||||
}
|
||||
|
||||
len = f->ops->get_buffer(f->opaque, f->buf + pending, f->pos,
|
||||
@@ -76,7 +77,7 @@ index be21518c57..1926b5202c 100644
|
||||
if (len > 0) {
|
||||
f->buf_size += len;
|
||||
f->pos += len;
|
||||
@@ -386,6 +395,9 @@ int qemu_fclose(QEMUFile *f)
|
||||
@@ -389,6 +398,9 @@ int qemu_fclose(QEMUFile *f)
|
||||
ret = ret2;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +87,7 @@ index be21518c57..1926b5202c 100644
|
||||
/* If any error was spotted before closing, we should report it
|
||||
* instead of the close() return value.
|
||||
*/
|
||||
@@ -435,7 +447,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
|
||||
@@ -443,7 +455,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
|
||||
{
|
||||
if (!add_to_iovec(f, f->buf + f->buf_index, len, false)) {
|
||||
f->buf_index += len;
|
||||
@@ -95,7 +96,7 @@ index be21518c57..1926b5202c 100644
|
||||
qemu_fflush(f);
|
||||
}
|
||||
}
|
||||
@@ -461,7 +473,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
|
||||
@@ -469,7 +481,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
|
||||
}
|
||||
|
||||
while (size > 0) {
|
||||
@@ -104,7 +105,7 @@ index be21518c57..1926b5202c 100644
|
||||
if (l > size) {
|
||||
l = size;
|
||||
}
|
||||
@@ -508,8 +520,8 @@ size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset)
|
||||
@@ -516,8 +528,8 @@ size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset)
|
||||
size_t index;
|
||||
|
||||
assert(!qemu_file_is_writable(f));
|
||||
@@ -115,7 +116,7 @@ index be21518c57..1926b5202c 100644
|
||||
|
||||
/* The 1st byte to read from */
|
||||
index = f->buf_index + offset;
|
||||
@@ -559,7 +571,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
|
||||
@@ -567,7 +579,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
|
||||
size_t res;
|
||||
uint8_t *src;
|
||||
|
||||
@@ -124,16 +125,16 @@ index be21518c57..1926b5202c 100644
|
||||
if (res == 0) {
|
||||
return done;
|
||||
}
|
||||
@@ -593,7 +605,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
|
||||
@@ -601,7 +613,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
|
||||
*/
|
||||
size_t qemu_get_buffer_in_place(QEMUFile *f, uint8_t **buf, size_t size)
|
||||
{
|
||||
- if (size < IO_BUF_SIZE) {
|
||||
+ if (size < f->buf_allocated_size) {
|
||||
size_t res;
|
||||
uint8_t *src;
|
||||
uint8_t *src = NULL;
|
||||
|
||||
@@ -618,7 +630,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
|
||||
@@ -626,7 +638,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
|
||||
int index = f->buf_index + offset;
|
||||
|
||||
assert(!qemu_file_is_writable(f));
|
||||
@@ -142,7 +143,7 @@ index be21518c57..1926b5202c 100644
|
||||
|
||||
if (index >= f->buf_size) {
|
||||
qemu_fill_buffer(f);
|
||||
@@ -770,7 +782,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
|
||||
@@ -778,7 +790,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
|
||||
ssize_t qemu_put_compression_data(QEMUFile *f, z_stream *stream,
|
||||
const uint8_t *p, size_t size)
|
||||
{
|
||||
@@ -152,19 +153,19 @@ index be21518c57..1926b5202c 100644
|
||||
if (blen < compressBound(size)) {
|
||||
return -1;
|
||||
diff --git a/migration/qemu-file.h b/migration/qemu-file.h
|
||||
index a9b6d6ccb7..8752d27c74 100644
|
||||
index 3f36d4dc8c..67501fd9cf 100644
|
||||
--- a/migration/qemu-file.h
|
||||
+++ b/migration/qemu-file.h
|
||||
@@ -120,6 +120,7 @@ typedef struct QEMUFileHooks {
|
||||
@@ -121,6 +121,7 @@ typedef struct QEMUFileHooks {
|
||||
} QEMUFileHooks;
|
||||
|
||||
QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops);
|
||||
+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, size_t buffer_size);
|
||||
QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc);
|
||||
+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, bool has_ioc, size_t buffer_size);
|
||||
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks);
|
||||
int qemu_get_fd(QEMUFile *f);
|
||||
int qemu_fclose(QEMUFile *f);
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index 593a619088..cc2552d977 100644
|
||||
index 79a0cda906..970ee3b3fc 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -418,7 +418,7 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp)
|
||||
@@ -172,7 +173,7 @@ index 593a619088..cc2552d977 100644
|
||||
}
|
||||
|
||||
- snap_state.file = qemu_fopen_ops(&snap_state, &block_file_ops);
|
||||
+ snap_state.file = qemu_fopen_ops_sized(&snap_state, &block_file_ops, 4 * 1024 * 1024);
|
||||
+ snap_state.file = qemu_fopen_ops_sized(&snap_state, &block_file_ops, false, 4 * 1024 * 1024);
|
||||
|
||||
if (!snap_state.file) {
|
||||
error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
|
||||
@@ -181,7 +182,7 @@ index 593a619088..cc2552d977 100644
|
||||
|
||||
/* restore the VM state */
|
||||
- f = qemu_fopen_ops(be, &loadstate_file_ops);
|
||||
+ f = qemu_fopen_ops_sized(be, &loadstate_file_ops, 4 * 1024 * 1024);
|
||||
+ f = qemu_fopen_ops_sized(be, &loadstate_file_ops, false, 4 * 1024 * 1024);
|
||||
if (!f) {
|
||||
error_setg(errp, "Could not open VM state file");
|
||||
goto the_end;
|
@@ -4,6 +4,8 @@ Date: Mon, 6 Apr 2020 12:16:47 +0200
|
||||
Subject: [PATCH] PVE: block: add the zeroinit block driver filter
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[adapt to changed function signatures]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/meson.build | 1 +
|
||||
block/zeroinit.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@@ -11,20 +13,20 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
create mode 100644 block/zeroinit.c
|
||||
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index 5dcc1e5cce..c10d544864 100644
|
||||
index deb73ca389..c9d1fdca7d 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -39,6 +39,7 @@ block_ss.add(files(
|
||||
@@ -41,6 +41,7 @@ block_ss.add(files(
|
||||
'vmdk.c',
|
||||
'vpc.c',
|
||||
'write-threshold.c',
|
||||
+ 'zeroinit.c',
|
||||
), zstd, zlib)
|
||||
), zstd, zlib, gnutls)
|
||||
|
||||
softmmu_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..5529627f7e
|
||||
index 0000000000..20ee611f22
|
||||
--- /dev/null
|
||||
+++ b/block/zeroinit.c
|
||||
@@ -0,0 +1,196 @@
|
||||
@@ -138,22 +140,22 @@ index 0000000000..5529627f7e
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_preadv(BlockDriverState *bs,
|
||||
+ uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags)
|
||||
+ int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
||||
+ int count, BdrvRequestFlags flags)
|
||||
+ int64_t bytes, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ BDRVZeroinitState *s = bs->opaque;
|
||||
+ if (offset >= s->extents)
|
||||
+ return 0;
|
||||
+ return bdrv_pwrite_zeroes(bs->file, offset, count, flags);
|
||||
+ return bdrv_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_pwritev(BlockDriverState *bs,
|
||||
+ uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags)
|
||||
+ int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ BDRVZeroinitState *s = bs->opaque;
|
||||
+ int64_t extents = offset + bytes;
|
||||
@@ -174,9 +176,9 @@ index 0000000000..5529627f7e
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn zeroinit_co_pdiscard(BlockDriverState *bs,
|
||||
+ int64_t offset, int count)
|
||||
+ int64_t offset, int64_t bytes)
|
||||
+{
|
||||
+ return bdrv_co_pdiscard(bs->file, offset, count);
|
||||
+ return bdrv_co_pdiscard(bs->file, offset, bytes);
|
||||
+}
|
||||
+
|
||||
+static int zeroinit_co_truncate(BlockDriverState *bs, int64_t offset,
|
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
2 files changed, 11 insertions(+)
|
||||
|
||||
diff --git a/qemu-options.hx b/qemu-options.hx
|
||||
index c1352312c2..9a0cb6780e 100644
|
||||
index 423144abeb..4879471aeb 100644
|
||||
--- a/qemu-options.hx
|
||||
+++ b/qemu-options.hx
|
||||
@@ -906,6 +906,9 @@ DEFHEADING()
|
||||
@@ -1019,6 +1019,9 @@ DEFHEADING()
|
||||
|
||||
DEFHEADING(Block device options:)
|
||||
|
||||
@@ -28,20 +28,20 @@ index c1352312c2..9a0cb6780e 100644
|
||||
"-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 03152c816c..da204d24f0 100644
|
||||
index fd82efb8b3..eb05e5a000 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -2866,6 +2866,7 @@ static char *find_datadir(void)
|
||||
void qemu_init(int argc, char **argv, char **envp)
|
||||
{
|
||||
int i;
|
||||
@@ -2779,6 +2779,7 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
MachineClass *machine_class;
|
||||
bool userconfig = true;
|
||||
FILE *vmstate_dump_file = NULL;
|
||||
+ long vm_id;
|
||||
int snapshot, linux_boot;
|
||||
const char *initrd_filename;
|
||||
const char *kernel_filename, *kernel_cmdline;
|
||||
@@ -3557,6 +3558,13 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
qemu_add_opts(&qemu_drive_opts);
|
||||
qemu_add_drive_opts(&qemu_legacy_drive_opts);
|
||||
@@ -3421,6 +3422,13 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
machine_parse_property_opt(qemu_find_opts("smp-opts"),
|
||||
"smp", optarg);
|
||||
break;
|
||||
+ case QEMU_OPTION_id:
|
||||
+ vm_id = strtol(optarg, (char **)&optarg, 10);
|
||||
@@ -51,5 +51,5 @@ index 03152c816c..da204d24f0 100644
|
||||
+ }
|
||||
+ break;
|
||||
case QEMU_OPTION_vnc:
|
||||
vnc_parse(optarg, &error_fatal);
|
||||
vnc_parse(optarg);
|
||||
break;
|
@@ -11,7 +11,7 @@ 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 502e94effc..590ef6ec8e 100644
|
||||
index 2a20982066..7968ad5a93 100644
|
||||
--- a/hw/intc/apic_common.c
|
||||
+++ b/hw/intc/apic_common.c
|
||||
@@ -278,6 +278,15 @@ static void apic_reset_common(DeviceState *dev)
|
@@ -8,15 +8,15 @@ Otherwise creating images on nfs/cifs can be problematic.
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/file-posix.c | 61 +++++++++++++++++++++++++++++---------------
|
||||
block/file-posix.c | 59 ++++++++++++++++++++++++++++++--------------
|
||||
qapi/block-core.json | 3 ++-
|
||||
2 files changed, 43 insertions(+), 21 deletions(-)
|
||||
2 files changed, 42 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/block/file-posix.c b/block/file-posix.c
|
||||
index bda3e606dc..037839622e 100644
|
||||
index 821405fd02..e3b6c3c524 100644
|
||||
--- a/block/file-posix.c
|
||||
+++ b/block/file-posix.c
|
||||
@@ -2388,6 +2388,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -2465,6 +2465,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
int fd;
|
||||
uint64_t perm, shared;
|
||||
int result = 0;
|
||||
@@ -24,7 +24,7 @@ index bda3e606dc..037839622e 100644
|
||||
|
||||
/* Validate options and set default values */
|
||||
assert(options->driver == BLOCKDEV_DRIVER_FILE);
|
||||
@@ -2428,19 +2429,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -2505,19 +2506,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 bda3e606dc..037839622e 100644
|
||||
}
|
||||
|
||||
/* Clear the file by truncating it to 0 */
|
||||
@@ -2494,13 +2498,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
@@ -2571,13 +2575,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
}
|
||||
|
||||
out_unlock:
|
||||
@@ -82,7 +82,7 @@ index bda3e606dc..037839622e 100644
|
||||
}
|
||||
|
||||
out_close:
|
||||
@@ -2525,6 +2531,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
@@ -2602,6 +2608,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
PreallocMode prealloc;
|
||||
char *buf = NULL;
|
||||
Error *local_err = NULL;
|
||||
@@ -90,7 +90,7 @@ index bda3e606dc..037839622e 100644
|
||||
|
||||
/* Skip file: protocol prefix */
|
||||
strstart(filename, "file:", &filename);
|
||||
@@ -2547,6 +2554,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
@@ -2624,6 +2631,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ index bda3e606dc..037839622e 100644
|
||||
options = (BlockdevCreateOptions) {
|
||||
.driver = BLOCKDEV_DRIVER_FILE,
|
||||
.u.file = {
|
||||
@@ -2558,6 +2577,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
@@ -2635,6 +2654,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
.nocow = nocow,
|
||||
.has_extent_size_hint = has_extent_size_hint,
|
||||
.extent_size_hint = extent_size_hint,
|
||||
@@ -118,20 +118,11 @@ index bda3e606dc..037839622e 100644
|
||||
},
|
||||
};
|
||||
return raw_co_create(&options, errp);
|
||||
@@ -3104,7 +3125,7 @@ static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared,
|
||||
}
|
||||
|
||||
/* Copy locks to the new fd */
|
||||
- if (s->perm_change_fd) {
|
||||
+ if (s->use_lock && s->perm_change_fd) {
|
||||
ret = raw_apply_lock_bytes(NULL, s->perm_change_fd, perm, ~shared,
|
||||
false, errp);
|
||||
if (ret < 0) {
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 9db3120716..d285622589 100644
|
||||
index 1d3dd9cb48..3f81d6a5c0 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -4224,7 +4224,8 @@
|
||||
@@ -4445,7 +4445,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 b42f8c6af3..2e37d11bd3 100644
|
||||
index 6b8cfcf6d8..3ec67e32d3 100644
|
||||
--- a/monitor/qmp.c
|
||||
+++ b/monitor/qmp.c
|
||||
@@ -466,8 +466,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
|
||||
@@ -519,8 +519,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 d0408049b5..5b38cf9356 100644
|
||||
index 53a99abc56..ad2cb2592e 100644
|
||||
--- a/hw/core/machine.c
|
||||
+++ b/hw/core/machine.c
|
||||
@@ -78,7 +78,8 @@ GlobalProperty hw_compat_4_0[] = {
|
||||
@@ -113,7 +113,8 @@ GlobalProperty hw_compat_4_0[] = {
|
||||
{ "virtio-vga", "edid", "false" },
|
||||
{ "virtio-gpu-device", "edid", "false" },
|
||||
{ "virtio-device", "use-started", "false" },
|
128
debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch
vendored
Normal file
128
debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dietmar Maurer <dietmar@proxmox.com>
|
||||
Date: Mon, 6 Apr 2020 12:16:55 +0200
|
||||
Subject: [PATCH] PVE: Allow version code in machine type
|
||||
|
||||
E.g. pc-i440fx-4.0+pve3 would print 'pve3' as version code while
|
||||
selecting pc-i440fx-4.0 as machine type.
|
||||
|
||||
Version is made available as 'pve-version' in query-machines (same as,
|
||||
and only if 'is-current').
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
hw/core/machine-qmp-cmds.c | 6 ++++++
|
||||
include/hw/boards.h | 2 ++
|
||||
qapi/machine.json | 4 +++-
|
||||
softmmu/vl.c | 25 +++++++++++++++++++++++++
|
||||
4 files changed, 36 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
|
||||
index 76fff60a6b..ec9201fb9a 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)
|
||||
if (strcmp(mc->name, MACHINE_GET_CLASS(current_machine)->name) == 0) {
|
||||
info->has_is_current = true;
|
||||
info->is_current = true;
|
||||
+
|
||||
+ // PVE version string only exists for current machine
|
||||
+ if (mc->pve_version) {
|
||||
+ info->has_pve_version = true;
|
||||
+ info->pve_version = g_strdup(mc->pve_version);
|
||||
+ }
|
||||
}
|
||||
|
||||
if (mc->default_cpu_type) {
|
||||
diff --git a/include/hw/boards.h b/include/hw/boards.h
|
||||
index 9c1c190104..51e04bde62 100644
|
||||
--- a/include/hw/boards.h
|
||||
+++ b/include/hw/boards.h
|
||||
@@ -227,6 +227,8 @@ struct MachineClass {
|
||||
const char *desc;
|
||||
const char *deprecation_reason;
|
||||
|
||||
+ const char *pve_version;
|
||||
+
|
||||
void (*init)(MachineState *state);
|
||||
void (*reset)(MachineState *state);
|
||||
void (*wakeup)(MachineState *state);
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 0905618e25..a05c46e253 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -160,6 +160,8 @@
|
||||
#
|
||||
# @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
|
||||
#
|
||||
+# @pve-version: custom PVE version suffix specified as 'machine+pveN'
|
||||
+#
|
||||
# Since: 1.2
|
||||
##
|
||||
{ 'struct': 'MachineInfo',
|
||||
@@ -167,7 +169,7 @@
|
||||
'*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
|
||||
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
|
||||
'deprecated': 'bool', '*default-cpu-type': 'str',
|
||||
- '*default-ram-id': 'str' } }
|
||||
+ '*default-ram-id': 'str', '*pve-version': 'str' } }
|
||||
|
||||
##
|
||||
# @query-machines:
|
||||
diff --git a/softmmu/vl.c b/softmmu/vl.c
|
||||
index eb05e5a000..f306d21d63 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -1655,6 +1655,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
|
||||
static MachineClass *select_machine(QDict *qdict, Error **errp)
|
||||
{
|
||||
const char *optarg = qdict_get_try_str(qdict, "type");
|
||||
+ const char *pvever = qdict_get_try_str(qdict, "pvever");
|
||||
GSList *machines = object_class_get_list(TYPE_MACHINE, false);
|
||||
MachineClass *machine_class;
|
||||
Error *local_err = NULL;
|
||||
@@ -1672,6 +1673,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
+ if (machine_class) {
|
||||
+ 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");
|
||||
@@ -3363,12 +3369,31 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
case QEMU_OPTION_machine:
|
||||
{
|
||||
bool help;
|
||||
+ size_t pvever_index, name_len;
|
||||
+ const gchar *name;
|
||||
+ gchar *name_clean, *pvever;
|
||||
|
||||
keyval_parse_into(machine_opts_dict, optarg, "type", &help, &error_fatal);
|
||||
if (help) {
|
||||
machine_help_func(machine_opts_dict);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
+
|
||||
+ // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
|
||||
+ name = qdict_get_try_str(machine_opts_dict, "type");
|
||||
+ if (name != NULL) {
|
||||
+ name_len = strlen(name);
|
||||
+ pvever_index = strcspn(name, "+");
|
||||
+ if (pvever_index < name_len) {
|
||||
+ name_clean = g_strndup(name, pvever_index);
|
||||
+ pvever = g_strndup(name + pvever_index + 1, name_len - pvever_index - 1);
|
||||
+ qdict_put_str(machine_opts_dict, "pvever", pvever);
|
||||
+ qdict_put_str(machine_opts_dict, "type", name_clean);
|
||||
+ g_free(name_clean);
|
||||
+ g_free(pvever);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
break;
|
||||
}
|
||||
case QEMU_OPTION_accel:
|
@@ -1,109 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dietmar Maurer <dietmar@proxmox.com>
|
||||
Date: Mon, 6 Apr 2020 12:16:55 +0200
|
||||
Subject: [PATCH] PVE: Allow version code in machine type
|
||||
|
||||
E.g. pc-i440fx-4.0+pve3 would print 'pve3' as version code while
|
||||
selecting pc-i440fx-4.0 as machine type.
|
||||
|
||||
Version is made available as 'pve-version' in query-machines (same as,
|
||||
and only if 'is-current').
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
---
|
||||
hw/core/machine-qmp-cmds.c | 6 ++++++
|
||||
include/hw/boards.h | 2 ++
|
||||
qapi/machine.json | 4 +++-
|
||||
softmmu/vl.c | 15 ++++++++++++++-
|
||||
4 files changed, 25 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
|
||||
index 3fcb82ce2f..7868241bd5 100644
|
||||
--- a/hw/core/machine-qmp-cmds.c
|
||||
+++ b/hw/core/machine-qmp-cmds.c
|
||||
@@ -238,6 +238,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
||||
if (strcmp(mc->name, MACHINE_GET_CLASS(current_machine)->name) == 0) {
|
||||
info->has_is_current = true;
|
||||
info->is_current = true;
|
||||
+
|
||||
+ // PVE version string only exists for current machine
|
||||
+ if (mc->pve_version) {
|
||||
+ info->has_pve_version = true;
|
||||
+ info->pve_version = g_strdup(mc->pve_version);
|
||||
+ }
|
||||
}
|
||||
|
||||
if (mc->default_cpu_type) {
|
||||
diff --git a/include/hw/boards.h b/include/hw/boards.h
|
||||
index a49e3a6b44..8e0a8c5571 100644
|
||||
--- a/include/hw/boards.h
|
||||
+++ b/include/hw/boards.h
|
||||
@@ -165,6 +165,8 @@ struct MachineClass {
|
||||
const char *desc;
|
||||
const char *deprecation_reason;
|
||||
|
||||
+ const char *pve_version;
|
||||
+
|
||||
void (*init)(MachineState *state);
|
||||
void (*reset)(MachineState *state);
|
||||
void (*wakeup)(MachineState *state);
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index dfc1a49d3c..32fc674042 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -337,6 +337,8 @@
|
||||
#
|
||||
# @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
|
||||
#
|
||||
+# @pve-version: custom PVE version suffix specified as 'machine+pveN'
|
||||
+#
|
||||
# Since: 1.2.0
|
||||
##
|
||||
{ 'struct': 'MachineInfo',
|
||||
@@ -344,7 +346,7 @@
|
||||
'*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
|
||||
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
|
||||
'deprecated': 'bool', '*default-cpu-type': 'str',
|
||||
- '*default-ram-id': 'str' } }
|
||||
+ '*default-ram-id': 'str', '*pve-version': 'str' } }
|
||||
|
||||
##
|
||||
# @query-machines:
|
||||
diff --git a/softmmu/vl.c b/softmmu/vl.c
|
||||
index da204d24f0..5b5512128e 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -2325,6 +2325,8 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
|
||||
{
|
||||
MachineClass *mc;
|
||||
GSList *el;
|
||||
+ size_t pvever_index = 0;
|
||||
+ gchar *name_clean;
|
||||
|
||||
if (is_help_option(name)) {
|
||||
printf("Supported machines are:\n");
|
||||
@@ -2341,12 +2343,23 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
- mc = find_machine(name, machines);
|
||||
+ // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
|
||||
+ pvever_index = strcspn(name, "+");
|
||||
+
|
||||
+ name_clean = g_strndup(name, pvever_index);
|
||||
+ mc = find_machine(name_clean, machines);
|
||||
+ g_free(name_clean);
|
||||
+
|
||||
if (!mc) {
|
||||
error_report("unsupported machine type");
|
||||
error_printf("Use -machine help to list supported machines\n");
|
||||
exit(1);
|
||||
}
|
||||
+
|
||||
+ if (pvever_index < strlen(name)) {
|
||||
+ mc->pve_version = &name[pvever_index+1];
|
||||
+ }
|
||||
+
|
||||
return mc;
|
||||
}
|
||||
|
59
debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
vendored
Normal file
59
debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 2 Mar 2022 08:35:05 +0100
|
||||
Subject: [PATCH] block/backup: move bcs bitmap initialization to job creation
|
||||
|
||||
For backing up the state of multiple disks from the same time, a job
|
||||
for each disk has to be created. It's convenient if the jobs don't
|
||||
have to be started at the same time and if operation of the VM can be
|
||||
resumed after job creation. This would lead to a window between job
|
||||
creation and running the job, where writes can happen. But no writes
|
||||
should happen between setting up the copy-before-write filter and
|
||||
setting up the block copy state bitmap, because then new writes would
|
||||
just pass through.
|
||||
|
||||
Commit 06e0a9c16405c0a4c1eca33cf286cc04c42066a2 moved initalization of
|
||||
the bitmap to setting up the copy-before-write filter when sync_mode
|
||||
is not MIRROR_SYNC_MODE_BITMAP. Ensure that the bitmap is initialized
|
||||
upon job creation for the remaining case too, by moving the
|
||||
backup_init_bcs_bitmap call to backup_job_create.
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/backup.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/block/backup.c b/block/backup.c
|
||||
index 21d5983779..47e218857d 100644
|
||||
--- a/block/backup.c
|
||||
+++ b/block/backup.c
|
||||
@@ -239,8 +239,8 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
|
||||
assert(ret);
|
||||
} else if (job->sync_mode == MIRROR_SYNC_MODE_TOP) {
|
||||
/*
|
||||
- * We can't hog the coroutine to initialize this thoroughly.
|
||||
- * Set a flag and resume work when we are able to yield safely.
|
||||
+ * Initialization is costly here. Simply set a flag and let the
|
||||
+ * backup_run coroutine resume work once it can yield safely.
|
||||
*/
|
||||
block_copy_set_skip_unallocated(job->bcs, true);
|
||||
}
|
||||
@@ -254,8 +254,6 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
|
||||
BackupBlockJob *s = container_of(job, BackupBlockJob, common.job);
|
||||
int ret;
|
||||
|
||||
- backup_init_bcs_bitmap(s);
|
||||
-
|
||||
if (s->sync_mode == MIRROR_SYNC_MODE_TOP) {
|
||||
int64_t offset = 0;
|
||||
int64_t count;
|
||||
@@ -493,6 +491,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL,
|
||||
&error_abort);
|
||||
|
||||
+ backup_init_bcs_bitmap(job);
|
||||
+
|
||||
return &job->common;
|
||||
|
||||
error:
|
@@ -3,26 +3,29 @@ From: Dietmar Maurer <dietmar@proxmox.com>
|
||||
Date: Mon, 6 Apr 2020 12:16:57 +0200
|
||||
Subject: [PATCH] PVE-Backup: add vma backup format code
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[FE: create: register all streams before entering coroutines]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/meson.build | 2 +
|
||||
meson.build | 5 +
|
||||
vma-reader.c | 857 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma-reader.c | 860 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma-writer.c | 790 ++++++++++++++++++++++++++++++++++++++++++
|
||||
vma.c | 839 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma.c | 849 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
vma.h | 150 ++++++++
|
||||
6 files changed, 2643 insertions(+)
|
||||
6 files changed, 2656 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 c10d544864..feffbc8623 100644
|
||||
index c9d1fdca7d..72081a9974 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -42,6 +42,8 @@ block_ss.add(files(
|
||||
@@ -44,6 +44,8 @@ block_ss.add(files(
|
||||
'zeroinit.c',
|
||||
), zstd, zlib)
|
||||
), zstd, zlib, gnutls)
|
||||
|
||||
+block_ss.add(files('../vma-writer.c'), libuuid)
|
||||
+
|
||||
@@ -30,23 +33,23 @@ index c10d544864..feffbc8623 100644
|
||||
|
||||
block_ss.add(when: 'CONFIG_QCOW1', if_true: files('qcow.c'))
|
||||
diff --git a/meson.build b/meson.build
|
||||
index e3386196ba..d5b660516b 100644
|
||||
index 96de1a6ef9..54c23b9567 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -725,6 +725,8 @@ keyutils = dependency('libkeyutils', required: false,
|
||||
@@ -1202,6 +1202,8 @@ keyutils = dependency('libkeyutils', required: false,
|
||||
|
||||
has_gettid = cc.has_function('gettid')
|
||||
|
||||
+libuuid = cc.find_library('uuid', required: true)
|
||||
+
|
||||
# Malloc tests
|
||||
# libselinux
|
||||
selinux = dependency('libselinux',
|
||||
required: get_option('selinux'),
|
||||
@@ -3070,6 +3072,9 @@ if have_tools
|
||||
dependencies: [blockdev, qemuutil, gnutls, selinux],
|
||||
install: true)
|
||||
|
||||
malloc = []
|
||||
@@ -1907,6 +1909,9 @@ if have_tools
|
||||
qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
|
||||
dependencies: [blockdev, qemuutil], install: true)
|
||||
|
||||
+ vma = executable('vma', files('vma.c', 'vma-reader.c'),
|
||||
+ vma = executable('vma', files('vma.c', 'vma-reader.c') + genh,
|
||||
+ dependencies: [authz, block, crypto, io, qom], install: true)
|
||||
+
|
||||
subdir('storage-daemon')
|
||||
@@ -54,10 +57,10 @@ index e3386196ba..d5b660516b 100644
|
||||
subdir('contrib/elf2dmp')
|
||||
diff --git a/vma-reader.c b/vma-reader.c
|
||||
new file mode 100644
|
||||
index 0000000000..2b1d1cdab3
|
||||
index 0000000000..4f4ee2b47b
|
||||
--- /dev/null
|
||||
+++ b/vma-reader.c
|
||||
@@ -0,0 +1,857 @@
|
||||
@@ -0,0 +1,860 @@
|
||||
+/*
|
||||
+ * VMA: Virtual Machine Archive
|
||||
+ *
|
||||
@@ -252,6 +255,9 @@ index 0000000000..2b1d1cdab3
|
||||
+ if (vmar->rstate[i].bitmap) {
|
||||
+ g_free(vmar->rstate[i].bitmap);
|
||||
+ }
|
||||
+ if (vmar->rstate[i].target) {
|
||||
+ blk_unref(vmar->rstate[i].target);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (vmar->md5csum) {
|
||||
@@ -1713,10 +1719,10 @@ index 0000000000..11d8321ffd
|
||||
+}
|
||||
diff --git a/vma.c b/vma.c
|
||||
new file mode 100644
|
||||
index 0000000000..2eea2fc281
|
||||
index 0000000000..89440733b1
|
||||
--- /dev/null
|
||||
+++ b/vma.c
|
||||
@@ -0,0 +1,839 @@
|
||||
@@ -0,0 +1,849 @@
|
||||
+/*
|
||||
+ * VMA: Virtual Machine Archive
|
||||
+ *
|
||||
@@ -2028,8 +2034,6 @@ index 0000000000..2eea2fc281
|
||||
+ int vmstate_fd = -1;
|
||||
+ guint8 vmstate_stream = 0;
|
||||
+
|
||||
+ BlockBackend *blk = NULL;
|
||||
+
|
||||
+ for (i = 1; i < 255; i++) {
|
||||
+ VmaDeviceInfo *di = vma_reader_get_device_info(vmar, i);
|
||||
+ if (di && (strcmp(di->devname, "vmstate") == 0)) {
|
||||
@@ -2050,6 +2054,8 @@ index 0000000000..2eea2fc281
|
||||
+ int flags = BDRV_O_RDWR;
|
||||
+ bool write_zero = true;
|
||||
+
|
||||
+ BlockBackend *blk = NULL;
|
||||
+
|
||||
+ if (readmap) {
|
||||
+ RestoreMap *map;
|
||||
+ map = (RestoreMap *)g_hash_table_lookup(devmap, di->devname);
|
||||
@@ -2162,8 +2168,6 @@ index 0000000000..2eea2fc281
|
||||
+
|
||||
+ vma_reader_destroy(vmar);
|
||||
+
|
||||
+ blk_unref(blk);
|
||||
+
|
||||
+ bdrv_close_all();
|
||||
+
|
||||
+ return ret;
|
||||
@@ -2292,6 +2296,7 @@ index 0000000000..2eea2fc281
|
||||
+ int i, c;
|
||||
+ int verbose = 0;
|
||||
+ const char *archivename;
|
||||
+ GList *backup_coroutines = NULL;
|
||||
+ GList *config_files = NULL;
|
||||
+
|
||||
+ for (;;) {
|
||||
@@ -2380,7 +2385,9 @@ index 0000000000..2eea2fc281
|
||||
+ job->dev_id = dev_id;
|
||||
+
|
||||
+ Coroutine *co = qemu_coroutine_create(backup_run, job);
|
||||
+ qemu_coroutine_enter(co);
|
||||
+ // Don't enter coroutine yet, because it might write the header before
|
||||
+ // all streams can be registered.
|
||||
+ backup_coroutines = g_list_append(backup_coroutines, co);
|
||||
+ }
|
||||
+
|
||||
+ VmaStatus vmastat;
|
||||
@@ -2388,6 +2395,13 @@ index 0000000000..2eea2fc281
|
||||
+ int last_percent = -1;
|
||||
+
|
||||
+ if (devcount) {
|
||||
+ GList *entry = backup_coroutines;
|
||||
+ while (entry && entry->data) {
|
||||
+ Coroutine *co = entry->data;
|
||||
+ qemu_coroutine_enter(co);
|
||||
+ entry = g_list_next(entry);
|
||||
+ }
|
||||
+
|
||||
+ while (1) {
|
||||
+ main_loop_wait(false);
|
||||
+ vma_writer_get_status(vmaw, &vmastat);
|
||||
@@ -2452,6 +2466,8 @@ index 0000000000..2eea2fc281
|
||||
+ g_error("creating vma archive failed");
|
||||
+ }
|
||||
+
|
||||
+ g_list_free(backup_coroutines);
|
||||
+ g_list_free(config_files);
|
||||
+ vma_writer_destroy(vmaw);
|
||||
+ return 0;
|
||||
+}
|
||||
|
@@ -7,13 +7,15 @@ Subject: [PATCH] PVE-Backup: add backup-dump block driver
|
||||
- move BackupBlockJob declaration from block/backup.c to include/block/block_int.h
|
||||
- block/backup.c - backup-job-create: also consider source cluster size
|
||||
- job.c: make job_should_pause non-static
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/backup-dump.c | 168 ++++++++++++++++++++++++++++++++++++++
|
||||
block/backup.c | 23 ++----
|
||||
block/backup.c | 30 ++-----
|
||||
block/meson.build | 1 +
|
||||
include/block/block_int.h | 30 +++++++
|
||||
include/block/block_int.h | 35 ++++++++
|
||||
job.c | 3 +-
|
||||
5 files changed, 206 insertions(+), 19 deletions(-)
|
||||
5 files changed, 214 insertions(+), 23 deletions(-)
|
||||
create mode 100644 block/backup-dump.c
|
||||
|
||||
diff --git a/block/backup-dump.c b/block/backup-dump.c
|
||||
@@ -191,17 +193,18 @@ index 0000000000..93d7f46950
|
||||
+ return bs;
|
||||
+}
|
||||
diff --git a/block/backup.c b/block/backup.c
|
||||
index 9afa0bf3b4..3df3d532d5 100644
|
||||
index 47e218857d..4d8fad70c4 100644
|
||||
--- a/block/backup.c
|
||||
+++ b/block/backup.c
|
||||
@@ -32,24 +32,6 @@
|
||||
@@ -29,28 +29,6 @@
|
||||
|
||||
#define BACKUP_CLUSTER_SIZE_DEFAULT (1 << 16)
|
||||
#include "block/copy-before-write.h"
|
||||
|
||||
-typedef struct BackupBlockJob {
|
||||
- BlockJob common;
|
||||
- BlockDriverState *backup_top;
|
||||
- BlockDriverState *cbw;
|
||||
- BlockDriverState *source_bs;
|
||||
- BlockDriverState *target_bs;
|
||||
-
|
||||
- BdrvDirtyBitmap *sync_bitmap;
|
||||
-
|
||||
@@ -210,29 +213,35 @@ index 9afa0bf3b4..3df3d532d5 100644
|
||||
- BlockdevOnError on_source_error;
|
||||
- BlockdevOnError on_target_error;
|
||||
- uint64_t len;
|
||||
- uint64_t bytes_read;
|
||||
- int64_t cluster_size;
|
||||
- BackupPerf perf;
|
||||
-
|
||||
- BlockCopyState *bcs;
|
||||
-
|
||||
- bool wait;
|
||||
- BlockCopyCallState *bg_bcs_call;
|
||||
-} BackupBlockJob;
|
||||
-
|
||||
static const BlockJobDriver backup_job_driver;
|
||||
|
||||
static void backup_progress_bytes_callback(int64_t bytes, void *opaque)
|
||||
@@ -423,6 +405,11 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
goto error;
|
||||
static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret)
|
||||
@@ -455,6 +433,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||
}
|
||||
|
||||
cluster_size = block_copy_cluster_size(bcs);
|
||||
+ if (cluster_size < 0) {
|
||||
+ goto error;
|
||||
+ }
|
||||
+
|
||||
+ BlockDriverInfo bdi;
|
||||
+ if (bdrv_get_info(bs, &bdi) == 0) {
|
||||
+ cluster_size = MAX(cluster_size, bdi.cluster_size);
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* If source is in backing chain of target assume that target is going to be
|
||||
* used for "image fleecing", i.e. it should represent a kind of snapshot of
|
||||
|
||||
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 feffbc8623..2507af1168 100644
|
||||
index 72081a9974..7883df047c 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -4,6 +4,7 @@ block_ss.add(files(
|
||||
@@ -240,14 +249,22 @@ index feffbc8623..2507af1168 100644
|
||||
'amend.c',
|
||||
'backup.c',
|
||||
+ 'backup-dump.c',
|
||||
'backup-top.c',
|
||||
'copy-before-write.c',
|
||||
'blkdebug.c',
|
||||
'blklogwrites.c',
|
||||
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
||||
index 6f8eda629a..5455102da8 100644
|
||||
index f4c75e8ba9..169dc43d59 100644
|
||||
--- a/include/block/block_int.h
|
||||
+++ b/include/block/block_int.h
|
||||
@@ -63,6 +63,36 @@
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "block/accounting.h"
|
||||
#include "block/block.h"
|
||||
+#include "block/block-copy.h"
|
||||
#include "block/aio-wait.h"
|
||||
#include "qemu/queue.h"
|
||||
#include "qemu/coroutine.h"
|
||||
@@ -64,6 +65,40 @@
|
||||
|
||||
#define BLOCK_PROBE_BUF_SIZE 512
|
||||
|
||||
@@ -265,8 +282,9 @@ index 6f8eda629a..5455102da8 100644
|
||||
+typedef struct BlockCopyState BlockCopyState;
|
||||
+typedef struct BackupBlockJob {
|
||||
+ BlockJob common;
|
||||
+ BlockDriverState *backup_top;
|
||||
+ BlockDriverState *cbw;
|
||||
+ BlockDriverState *source_bs;
|
||||
+ BlockDriverState *target_bs;
|
||||
+
|
||||
+ BdrvDirtyBitmap *sync_bitmap;
|
||||
+
|
||||
@@ -275,20 +293,23 @@ index 6f8eda629a..5455102da8 100644
|
||||
+ BlockdevOnError on_source_error;
|
||||
+ BlockdevOnError on_target_error;
|
||||
+ uint64_t len;
|
||||
+ uint64_t bytes_read;
|
||||
+ int64_t cluster_size;
|
||||
+ BackupPerf perf;
|
||||
+
|
||||
+ BlockCopyState *bcs;
|
||||
+
|
||||
+ bool wait;
|
||||
+ BlockCopyCallState *bg_bcs_call;
|
||||
+} BackupBlockJob;
|
||||
+
|
||||
enum BdrvTrackedRequestType {
|
||||
BDRV_TRACKED_READ,
|
||||
BDRV_TRACKED_WRITE,
|
||||
diff --git a/job.c b/job.c
|
||||
index 8fecf38960..f9884e7d9d 100644
|
||||
index dbfa67bb0a..af25dd5b98 100644
|
||||
--- a/job.c
|
||||
+++ b/job.c
|
||||
@@ -269,7 +269,8 @@ static bool job_started(Job *job)
|
||||
@@ -276,7 +276,8 @@ static bool job_started(Job *job)
|
||||
return job->co;
|
||||
}
|
||||
|
||||
|
@@ -6,11 +6,14 @@ Subject: [PATCH] PVE-Backup: proxmox backup patches for qemu
|
||||
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
|
||||
[PVE-Backup: avoid coroutines to fix AIO freeze, cleanups]
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[add new force parameter to job_cancel_sync calls]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/meson.build | 5 +
|
||||
block/monitor/block-hmp-cmds.c | 33 ++
|
||||
blockdev.c | 1 +
|
||||
hmp-commands-info.hx | 13 +
|
||||
hmp-commands-info.hx | 14 +
|
||||
hmp-commands.hx | 29 +
|
||||
include/block/block_int.h | 2 +-
|
||||
include/monitor/hmp.h | 3 +
|
||||
@@ -18,21 +21,21 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
monitor/hmp-cmds.c | 44 ++
|
||||
proxmox-backup-client.c | 176 ++++++
|
||||
proxmox-backup-client.h | 59 ++
|
||||
pve-backup.c | 957 +++++++++++++++++++++++++++++++++
|
||||
pve-backup.c | 959 +++++++++++++++++++++++++++++++++
|
||||
qapi/block-core.json | 109 ++++
|
||||
qapi/common.json | 13 +
|
||||
qapi/machine.json | 15 +-
|
||||
15 files changed, 1446 insertions(+), 14 deletions(-)
|
||||
15 files changed, 1449 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 2507af1168..dfae565db3 100644
|
||||
index 7883df047c..9d3dd5b7c3 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -44,6 +44,11 @@ block_ss.add(files(
|
||||
), zstd, zlib)
|
||||
@@ -46,6 +46,11 @@ block_ss.add(files(
|
||||
), zstd, zlib, gnutls)
|
||||
|
||||
block_ss.add(files('../vma-writer.c'), libuuid)
|
||||
+block_ss.add(files(
|
||||
@@ -44,10 +47,10 @@ index 2507af1168..dfae565db3 100644
|
||||
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index d15a2be827..9ba7c774a2 100644
|
||||
index 2ac4aedfff..f6668ab01d 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1012,3 +1012,36 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
|
||||
@@ -1015,3 +1015,36 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
|
||||
g_free(sn_tab);
|
||||
g_free(global_snapshots);
|
||||
}
|
||||
@@ -85,7 +88,7 @@ index d15a2be827..9ba7c774a2 100644
|
||||
+ hmp_handle_error(mon, error);
|
||||
+}
|
||||
diff --git a/blockdev.c b/blockdev.c
|
||||
index a40c6fd0f6..e2f826ca62 100644
|
||||
index b35072644e..c0bc3db33e 100644
|
||||
--- a/blockdev.c
|
||||
+++ b/blockdev.c
|
||||
@@ -36,6 +36,7 @@
|
||||
@@ -97,13 +100,14 @@ index a40c6fd0f6..e2f826ca62 100644
|
||||
#include "monitor/monitor.h"
|
||||
#include "qemu/error-report.h"
|
||||
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
|
||||
index b3b797ca28..295e14e64f 100644
|
||||
index 245f8acc55..3e7f2421eb 100644
|
||||
--- a/hmp-commands-info.hx
|
||||
+++ b/hmp-commands-info.hx
|
||||
@@ -513,6 +513,19 @@ SRST
|
||||
Show CPU statistics.
|
||||
@@ -482,6 +482,20 @@ SRST
|
||||
Show the current VM UUID.
|
||||
ERST
|
||||
|
||||
+
|
||||
+ {
|
||||
+ .name = "backup",
|
||||
+ .args_type = "",
|
||||
@@ -121,10 +125,10 @@ index b3b797ca28..295e14e64f 100644
|
||||
{
|
||||
.name = "usernet",
|
||||
diff --git a/hmp-commands.hx b/hmp-commands.hx
|
||||
index d294c234a5..0c6b944850 100644
|
||||
index 1ad13b668b..d4bb00216e 100644
|
||||
--- a/hmp-commands.hx
|
||||
+++ b/hmp-commands.hx
|
||||
@@ -98,6 +98,35 @@ ERST
|
||||
@@ -99,6 +99,35 @@ ERST
|
||||
SRST
|
||||
``block_stream``
|
||||
Copy data from a backing file into a block device.
|
||||
@@ -161,10 +165,10 @@ index d294c234a5..0c6b944850 100644
|
||||
|
||||
{
|
||||
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
||||
index 5455102da8..1bd4b64522 100644
|
||||
index 169dc43d59..92f90c43eb 100644
|
||||
--- a/include/block/block_int.h
|
||||
+++ b/include/block/block_int.h
|
||||
@@ -65,7 +65,7 @@
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
typedef int BackupDumpFunc(void *opaque, uint64_t offset, uint64_t bytes, const void *buf);
|
||||
|
||||
@@ -174,18 +178,18 @@ index 5455102da8..1bd4b64522 100644
|
||||
uint64_t byte_size,
|
||||
BackupDumpFunc *dump_cb,
|
||||
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
|
||||
index 4e06f89e8e..10f52bd92a 100644
|
||||
index 3a39ba41b5..d269b4c99c 100644
|
||||
--- a/include/monitor/hmp.h
|
||||
+++ b/include/monitor/hmp.h
|
||||
@@ -30,6 +30,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict);
|
||||
@@ -30,6 +30,7 @@ void hmp_info_savevm(Monitor *mon, const QDict *qdict);
|
||||
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);
|
||||
void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict);
|
||||
+void hmp_info_backup(Monitor *mon, const QDict *qdict);
|
||||
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);
|
||||
@@ -76,6 +77,8 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict);
|
||||
@@ -73,6 +74,8 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict);
|
||||
void hmp_set_password(Monitor *mon, const QDict *qdict);
|
||||
void hmp_expire_password(Monitor *mon, const QDict *qdict);
|
||||
void hmp_change(Monitor *mon, const QDict *qdict);
|
||||
@@ -195,19 +199,19 @@ index 4e06f89e8e..10f52bd92a 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 d5b660516b..3094f98c47 100644
|
||||
index 54c23b9567..37dab249cc 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -726,6 +726,7 @@ keyutils = dependency('libkeyutils', required: false,
|
||||
@@ -1203,6 +1203,7 @@ keyutils = dependency('libkeyutils', required: false,
|
||||
has_gettid = cc.has_function('gettid')
|
||||
|
||||
libuuid = cc.find_library('uuid', required: true)
|
||||
+libproxmox_backup_qemu = cc.find_library('proxmox_backup_qemu', required: true)
|
||||
|
||||
# Malloc tests
|
||||
|
||||
# libselinux
|
||||
selinux = dependency('libselinux',
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index 77ab152aab..182e79c943 100644
|
||||
index 5000ce39d1..b2687eae3a 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -195,6 +195,50 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
|
||||
@@ -510,10 +514,10 @@ index 0000000000..1dda8b7d8f
|
||||
+#endif /* PROXMOX_BACKUP_CLIENT_H */
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
new file mode 100644
|
||||
index 0000000000..d40f3f2fd6
|
||||
index 0000000000..88f5ee133f
|
||||
--- /dev/null
|
||||
+++ b/pve-backup.c
|
||||
@@ -0,0 +1,957 @@
|
||||
@@ -0,0 +1,959 @@
|
||||
+#include "proxmox-backup-client.h"
|
||||
+#include "vma.h"
|
||||
+
|
||||
@@ -870,7 +874,7 @@ index 0000000000..d40f3f2fd6
|
||||
+ if (next_job) {
|
||||
+ AioContext *aio_context = next_job->job.aio_context;
|
||||
+ aio_context_acquire(aio_context);
|
||||
+ job_cancel_sync(&next_job->job);
|
||||
+ job_cancel_sync(&next_job->job, true);
|
||||
+ aio_context_release(aio_context);
|
||||
+ } else {
|
||||
+ break;
|
||||
@@ -957,7 +961,7 @@ index 0000000000..d40f3f2fd6
|
||||
+ if (job_should_pause(&job->job)) {
|
||||
+ bool error_or_canceled = pvebackup_error_or_canceled();
|
||||
+ if (error_or_canceled) {
|
||||
+ job_cancel_sync(&job->job);
|
||||
+ job_cancel_sync(&job->job, true);
|
||||
+ } else {
|
||||
+ job_resume(&job->job);
|
||||
+ }
|
||||
@@ -978,6 +982,8 @@ index 0000000000..d40f3f2fd6
|
||||
+
|
||||
+ Error *local_err = NULL;
|
||||
+
|
||||
+ BackupPerf perf = { .max_workers = 16 };
|
||||
+
|
||||
+ /* create and start all jobs (paused state) */
|
||||
+ GList *l = backup_state.di_list;
|
||||
+ while (l) {
|
||||
@@ -991,8 +997,8 @@ index 0000000000..d40f3f2fd6
|
||||
+
|
||||
+ BlockJob *job = backup_job_create(
|
||||
+ NULL, di->bs, di->target, backup_state.speed, MIRROR_SYNC_MODE_FULL, NULL,
|
||||
+ BITMAP_SYNC_MODE_NEVER, false, NULL, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
+ JOB_DEFAULT, pvebackup_complete_cb, di, 1, NULL, &local_err);
|
||||
+ BITMAP_SYNC_MODE_NEVER, false, NULL, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
+ JOB_DEFAULT, pvebackup_complete_cb, di, NULL, &local_err);
|
||||
+
|
||||
+ aio_context_release(aio_context);
|
||||
+
|
||||
@@ -1472,10 +1478,10 @@ index 0000000000..d40f3f2fd6
|
||||
+ return info;
|
||||
+}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index d285622589..9054db608c 100644
|
||||
index 3f81d6a5c0..551ee28275 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -745,6 +745,115 @@
|
||||
@@ -744,6 +744,115 @@
|
||||
{ 'command': 'query-block', 'returns': ['BlockInfo'] }
|
||||
|
||||
|
||||
@@ -1592,13 +1598,13 @@ index d285622589..9054db608c 100644
|
||||
# @BlockDeviceTimedStats:
|
||||
#
|
||||
diff --git a/qapi/common.json b/qapi/common.json
|
||||
index 716712d4b3..556dab79e1 100644
|
||||
index 412cc4f5ae..3e7a77ea66 100644
|
||||
--- a/qapi/common.json
|
||||
+++ b/qapi/common.json
|
||||
@@ -145,3 +145,16 @@
|
||||
@@ -208,3 +208,16 @@
|
||||
##
|
||||
{ 'enum': 'PCIELinkWidth',
|
||||
'data': [ '1', '2', '4', '8', '12', '16', '32' ] }
|
||||
{ 'struct': 'HumanReadableText',
|
||||
'data': { 'human-readable-text': 'str' } }
|
||||
+
|
||||
+##
|
||||
+# @UuidInfo:
|
||||
@@ -1613,7 +1619,7 @@ index 716712d4b3..556dab79e1 100644
|
||||
+##
|
||||
+{ 'struct': 'UuidInfo', 'data': {'UUID': 'str'} }
|
||||
diff --git a/qapi/machine.json b/qapi/machine.json
|
||||
index 32fc674042..145f1a4fa2 100644
|
||||
index a05c46e253..e2cec7922f 100644
|
||||
--- a/qapi/machine.json
|
||||
+++ b/qapi/machine.json
|
||||
@@ -4,6 +4,8 @@
|
||||
@@ -1625,7 +1631,7 @@ index 32fc674042..145f1a4fa2 100644
|
||||
##
|
||||
# = Machines
|
||||
##
|
||||
@@ -406,19 +408,6 @@
|
||||
@@ -229,19 +231,6 @@
|
||||
##
|
||||
{ 'command': 'query-target', 'returns': 'TargetInfo' }
|
||||
|
||||
@@ -1636,7 +1642,7 @@ index 32fc674042..145f1a4fa2 100644
|
||||
-#
|
||||
-# @UUID: the UUID of the guest
|
||||
-#
|
||||
-# Since: 0.14.0
|
||||
-# Since: 0.14
|
||||
-#
|
||||
-# Notes: If no UUID was specified for the guest, a null UUID is returned.
|
||||
-##
|
||||
|
@@ -12,14 +12,14 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
create mode 100644 pbs-restore.c
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 3094f98c47..6f1fafee14 100644
|
||||
index 37dab249cc..1a4dfab4e2 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -1913,6 +1913,10 @@ if have_tools
|
||||
vma = executable('vma', files('vma.c', 'vma-reader.c'),
|
||||
@@ -3076,6 +3076,10 @@ if have_tools
|
||||
vma = executable('vma', files('vma.c', 'vma-reader.c') + genh,
|
||||
dependencies: [authz, block, crypto, io, qom], install: true)
|
||||
|
||||
+ pbs_restore = executable('pbs-restore', files('pbs-restore.c'),
|
||||
+ pbs_restore = executable('pbs-restore', files('pbs-restore.c') + genh,
|
||||
+ dependencies: [authz, block, crypto, io, qom,
|
||||
+ libproxmox_backup_qemu], install: true)
|
||||
+
|
||||
|
@@ -29,10 +29,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
6 files changed, 142 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index 9ba7c774a2..056d14deee 100644
|
||||
index f6668ab01d..3c06734e6d 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1039,6 +1039,7 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
|
||||
@@ -1042,6 +1042,7 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
|
||||
false, NULL, // PBS fingerprint
|
||||
false, NULL, // PBS backup-id
|
||||
false, 0, // PBS backup-time
|
||||
@@ -41,7 +41,7 @@ index 9ba7c774a2..056d14deee 100644
|
||||
false, NULL, false, NULL, !!devlist,
|
||||
devlist, qdict_haskey(qdict, "speed"), speed, &error);
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index 182e79c943..604026bb37 100644
|
||||
index b2687eae3a..cfd7a60f32 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -221,19 +221,42 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
|
||||
@@ -132,7 +132,7 @@ index 1dda8b7d8f..8cbf645b2c 100644
|
||||
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index d40f3f2fd6..1cd9d31d7c 100644
|
||||
index 88f5ee133f..1c49cd178d 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -28,6 +28,8 @@
|
||||
@@ -232,7 +232,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
g_free(di);
|
||||
|
||||
qemu_mutex_unlock(&backup_state.backup_mutex);
|
||||
@@ -470,12 +495,18 @@ static bool create_backup_jobs(void) {
|
||||
@@ -472,12 +497,18 @@ static bool create_backup_jobs(void) {
|
||||
|
||||
assert(di->target != NULL);
|
||||
|
||||
@@ -247,13 +247,13 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
|
||||
BlockJob *job = backup_job_create(
|
||||
- NULL, di->bs, di->target, backup_state.speed, MIRROR_SYNC_MODE_FULL, NULL,
|
||||
- BITMAP_SYNC_MODE_NEVER, false, NULL, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
- BITMAP_SYNC_MODE_NEVER, false, NULL, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
+ NULL, di->bs, di->target, backup_state.speed, sync_mode, di->bitmap,
|
||||
+ bitmap_mode, false, NULL, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
JOB_DEFAULT, pvebackup_complete_cb, di, 1, NULL, &local_err);
|
||||
+ bitmap_mode, false, NULL, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
JOB_DEFAULT, pvebackup_complete_cb, di, NULL, &local_err);
|
||||
|
||||
aio_context_release(aio_context);
|
||||
@@ -526,6 +557,8 @@ typedef struct QmpBackupTask {
|
||||
@@ -528,6 +559,8 @@ typedef struct QmpBackupTask {
|
||||
const char *fingerprint;
|
||||
bool has_fingerprint;
|
||||
int64_t backup_time;
|
||||
@@ -262,7 +262,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
bool has_format;
|
||||
BackupFormat format;
|
||||
bool has_config_file;
|
||||
@@ -617,6 +650,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -619,6 +652,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
|
||||
size_t total = 0;
|
||||
@@ -270,7 +270,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
|
||||
l = di_list;
|
||||
while (l) {
|
||||
@@ -654,6 +688,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -656,6 +690,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
int dump_cb_block_size = PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE; // Hardcoded (4M)
|
||||
firewall_name = "fw.conf";
|
||||
|
||||
@@ -279,7 +279,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
char *pbs_err = NULL;
|
||||
pbs = proxmox_backup_new(
|
||||
task->backup_file,
|
||||
@@ -673,7 +709,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -675,7 +711,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
goto err;
|
||||
|
||||
/* register all devices */
|
||||
@@ -684,9 +721,40 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -686,9 +723,40 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
|
||||
const char *devname = bdrv_get_device_name(di->bs);
|
||||
|
||||
@@ -332,7 +332,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
|
||||
if (!(di->target = bdrv_backup_dump_create(dump_cb_block_size, di->size, pvebackup_co_dump_pbs_cb, di, task->errp))) {
|
||||
goto err;
|
||||
@@ -695,6 +763,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -697,6 +765,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
di->dev_id = dev_id;
|
||||
}
|
||||
} else if (format == BACKUP_FORMAT_VMA) {
|
||||
@@ -341,7 +341,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
vmaw = vma_writer_create(task->backup_file, uuid, &local_err);
|
||||
if (!vmaw) {
|
||||
if (local_err) {
|
||||
@@ -722,6 +792,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -724,6 +794,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
}
|
||||
} else if (format == BACKUP_FORMAT_DIR) {
|
||||
@@ -350,7 +350,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
if (mkdir(task->backup_file, 0640) != 0) {
|
||||
error_setg_errno(task->errp, errno, "can't create directory '%s'\n",
|
||||
task->backup_file);
|
||||
@@ -794,8 +866,10 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -796,8 +868,10 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
char *uuid_str = g_strdup(backup_state.stat.uuid_str);
|
||||
|
||||
backup_state.stat.total = total;
|
||||
@@ -361,7 +361,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
@@ -819,6 +893,10 @@ err:
|
||||
@@ -821,6 +895,10 @@ err:
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
l = g_list_next(l);
|
||||
|
||||
@@ -372,7 +372,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
if (di->target) {
|
||||
bdrv_unref(di->target);
|
||||
}
|
||||
@@ -860,6 +938,7 @@ UuidInfo *qmp_backup(
|
||||
@@ -862,6 +940,7 @@ UuidInfo *qmp_backup(
|
||||
bool has_fingerprint, const char *fingerprint,
|
||||
bool has_backup_id, const char *backup_id,
|
||||
bool has_backup_time, int64_t backup_time,
|
||||
@@ -380,7 +380,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
bool has_format, BackupFormat format,
|
||||
bool has_config_file, const char *config_file,
|
||||
bool has_firewall_file, const char *firewall_file,
|
||||
@@ -878,6 +957,8 @@ UuidInfo *qmp_backup(
|
||||
@@ -880,6 +959,8 @@ UuidInfo *qmp_backup(
|
||||
.backup_id = backup_id,
|
||||
.has_backup_time = has_backup_time,
|
||||
.backup_time = backup_time,
|
||||
@@ -389,7 +389,7 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
.has_format = has_format,
|
||||
.format = format,
|
||||
.has_config_file = has_config_file,
|
||||
@@ -946,10 +1027,14 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
@@ -948,10 +1029,14 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
|
||||
info->has_total = true;
|
||||
info->total = backup_state.stat.total;
|
||||
@@ -405,10 +405,10 @@ index d40f3f2fd6..1cd9d31d7c 100644
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 9054db608c..d4e1c98c50 100644
|
||||
index 551ee28275..b9d6f52f0c 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -758,8 +758,13 @@
|
||||
@@ -757,8 +757,13 @@
|
||||
#
|
||||
# @total: total amount of bytes involved in the backup process
|
||||
#
|
||||
@@ -422,7 +422,7 @@ index 9054db608c..d4e1c98c50 100644
|
||||
# @zero-bytes: amount of 'zero' bytes detected.
|
||||
#
|
||||
# @start-time: time (epoch) when backup job started.
|
||||
@@ -772,8 +777,8 @@
|
||||
@@ -771,8 +776,8 @@
|
||||
#
|
||||
##
|
||||
{ 'struct': 'BackupStatus',
|
||||
@@ -433,7 +433,7 @@ index 9054db608c..d4e1c98c50 100644
|
||||
'*start-time': 'int', '*end-time': 'int',
|
||||
'*backup-file': 'str', '*uuid': 'str' } }
|
||||
|
||||
@@ -816,6 +821,8 @@
|
||||
@@ -815,6 +820,8 @@
|
||||
#
|
||||
# @backup-time: backup timestamp (Unix epoch, required for format 'pbs')
|
||||
#
|
||||
@@ -442,7 +442,7 @@ index 9054db608c..d4e1c98c50 100644
|
||||
# Returns: the uuid of the backup job
|
||||
#
|
||||
##
|
||||
@@ -826,6 +833,7 @@
|
||||
@@ -825,6 +832,7 @@
|
||||
'*fingerprint': 'str',
|
||||
'*backup-id': 'str',
|
||||
'*backup-time': 'int',
|
||||
|
@@ -11,6 +11,7 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
|
||||
PVE: add zero block handling to PBS dump callback
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/monitor/block-hmp-cmds.c | 4 ++-
|
||||
pve-backup.c | 57 +++++++++++++++++++++++++++-------
|
||||
@@ -18,10 +19,10 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
3 files changed, 54 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index 056d14deee..46c63b1cf9 100644
|
||||
index 3c06734e6d..4481b60a5c 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1039,7 +1039,9 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
|
||||
@@ -1042,7 +1042,9 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
|
||||
false, NULL, // PBS fingerprint
|
||||
false, NULL, // PBS backup-id
|
||||
false, 0, // PBS backup-time
|
||||
@@ -33,7 +34,7 @@ index 056d14deee..46c63b1cf9 100644
|
||||
false, NULL, false, NULL, !!devlist,
|
||||
devlist, qdict_haskey(qdict, "speed"), speed, &error);
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 1cd9d31d7c..b8182aaf89 100644
|
||||
index 1c49cd178d..c15abefdda 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -8,6 +8,7 @@
|
||||
@@ -123,7 +124,7 @@ index 1cd9d31d7c..b8182aaf89 100644
|
||||
if (ret < 0) {
|
||||
Error *local_err = NULL;
|
||||
vma_writer_error_propagate(backup_state.vmaw, &local_err);
|
||||
@@ -567,6 +583,10 @@ typedef struct QmpBackupTask {
|
||||
@@ -569,6 +585,10 @@ typedef struct QmpBackupTask {
|
||||
const char *firewall_file;
|
||||
bool has_devlist;
|
||||
const char *devlist;
|
||||
@@ -134,7 +135,7 @@ index 1cd9d31d7c..b8182aaf89 100644
|
||||
bool has_speed;
|
||||
int64_t speed;
|
||||
Error **errp;
|
||||
@@ -690,6 +710,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -692,6 +712,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
|
||||
bool use_dirty_bitmap = task->has_use_dirty_bitmap && task->use_dirty_bitmap;
|
||||
|
||||
@@ -142,7 +143,7 @@ index 1cd9d31d7c..b8182aaf89 100644
|
||||
char *pbs_err = NULL;
|
||||
pbs = proxmox_backup_new(
|
||||
task->backup_file,
|
||||
@@ -699,8 +720,10 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -701,8 +722,10 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
task->has_password ? task->password : NULL,
|
||||
task->has_keyfile ? task->keyfile : NULL,
|
||||
task->has_key_password ? task->key_password : NULL,
|
||||
@@ -154,7 +155,7 @@ index 1cd9d31d7c..b8182aaf89 100644
|
||||
|
||||
if (!pbs) {
|
||||
error_set(task->errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
@@ -719,6 +742,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -721,6 +744,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
l = g_list_next(l);
|
||||
|
||||
@@ -163,7 +164,7 @@ index 1cd9d31d7c..b8182aaf89 100644
|
||||
const char *devname = bdrv_get_device_name(di->bs);
|
||||
|
||||
BdrvDirtyBitmap *bitmap = bdrv_find_dirty_bitmap(di->bs, PBS_BITMAP_NAME);
|
||||
@@ -939,6 +964,8 @@ UuidInfo *qmp_backup(
|
||||
@@ -941,6 +966,8 @@ UuidInfo *qmp_backup(
|
||||
bool has_backup_id, const char *backup_id,
|
||||
bool has_backup_time, int64_t backup_time,
|
||||
bool has_use_dirty_bitmap, bool use_dirty_bitmap,
|
||||
@@ -172,7 +173,7 @@ index 1cd9d31d7c..b8182aaf89 100644
|
||||
bool has_format, BackupFormat format,
|
||||
bool has_config_file, const char *config_file,
|
||||
bool has_firewall_file, const char *firewall_file,
|
||||
@@ -949,6 +976,8 @@ UuidInfo *qmp_backup(
|
||||
@@ -951,6 +978,8 @@ UuidInfo *qmp_backup(
|
||||
.backup_file = backup_file,
|
||||
.has_password = has_password,
|
||||
.password = password,
|
||||
@@ -181,7 +182,7 @@ index 1cd9d31d7c..b8182aaf89 100644
|
||||
.has_key_password = has_key_password,
|
||||
.key_password = key_password,
|
||||
.has_fingerprint = has_fingerprint,
|
||||
@@ -959,6 +988,10 @@ UuidInfo *qmp_backup(
|
||||
@@ -961,6 +990,10 @@ UuidInfo *qmp_backup(
|
||||
.backup_time = backup_time,
|
||||
.has_use_dirty_bitmap = has_use_dirty_bitmap,
|
||||
.use_dirty_bitmap = use_dirty_bitmap,
|
||||
@@ -193,10 +194,10 @@ index 1cd9d31d7c..b8182aaf89 100644
|
||||
.format = format,
|
||||
.has_config_file = has_config_file,
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index d4e1c98c50..0fda1e3fd3 100644
|
||||
index b9d6f52f0c..5d8e2eb303 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -823,6 +823,10 @@
|
||||
@@ -822,6 +822,10 @@
|
||||
#
|
||||
# @use-dirty-bitmap: use dirty bitmap to detect incremental changes since last job (optional for format 'pbs')
|
||||
#
|
||||
@@ -207,7 +208,7 @@ index d4e1c98c50..0fda1e3fd3 100644
|
||||
# Returns: the uuid of the backup job
|
||||
#
|
||||
##
|
||||
@@ -834,6 +838,8 @@
|
||||
@@ -833,6 +837,8 @@
|
||||
'*backup-id': 'str',
|
||||
'*backup-time': 'int',
|
||||
'*use-dirty-bitmap': 'bool',
|
||||
|
@@ -6,20 +6,23 @@ Subject: [PATCH] PVE: Add PBS block driver to map backup archives into VMs
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
[error cleanups, file_open implementation]
|
||||
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[adapt to changed function signatures]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/meson.build | 3 +
|
||||
block/pbs.c | 271 +++++++++++++++++++++++++++++++++++++++++++
|
||||
block/pbs.c | 276 +++++++++++++++++++++++++++++++++++++++++++
|
||||
configure | 9 ++
|
||||
meson.build | 1 +
|
||||
qapi/block-core.json | 14 ++-
|
||||
5 files changed, 297 insertions(+), 1 deletion(-)
|
||||
qapi/block-core.json | 13 ++
|
||||
5 files changed, 302 insertions(+)
|
||||
create mode 100644 block/pbs.c
|
||||
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index dfae565db3..a070060e53 100644
|
||||
index 9d3dd5b7c3..8c758c0218 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -49,6 +49,9 @@ block_ss.add(files(
|
||||
@@ -51,6 +51,9 @@ block_ss.add(files(
|
||||
'../pve-backup.c',
|
||||
), libproxmox_backup_qemu)
|
||||
|
||||
@@ -31,10 +34,10 @@ index dfae565db3..a070060e53 100644
|
||||
|
||||
diff --git a/block/pbs.c b/block/pbs.c
|
||||
new file mode 100644
|
||||
index 0000000000..1481a2bfd1
|
||||
index 0000000000..0b05ea9080
|
||||
--- /dev/null
|
||||
+++ b/block/pbs.c
|
||||
@@ -0,0 +1,271 @@
|
||||
@@ -0,0 +1,276 @@
|
||||
+/*
|
||||
+ * Proxmox Backup Server read-only block driver
|
||||
+ */
|
||||
@@ -231,20 +234,25 @@ index 0000000000..1481a2bfd1
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int pbs_co_preadv(BlockDriverState *bs,
|
||||
+ uint64_t offset, uint64_t bytes,
|
||||
+ QEMUIOVector *qiov, int flags)
|
||||
+ int64_t offset, int64_t bytes,
|
||||
+ QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ BDRVPBSState *s = bs->opaque;
|
||||
+ int ret;
|
||||
+ char *pbs_error = NULL;
|
||||
+ uint8_t *buf = malloc(bytes);
|
||||
+
|
||||
+ if (offset < 0 || bytes < 0) {
|
||||
+ fprintf(stderr, "unexpected negative 'offset' or 'bytes' value!\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ ReadCallbackData rcb = {
|
||||
+ .co = qemu_coroutine_self(),
|
||||
+ .ctx = bdrv_get_aio_context(bs),
|
||||
+ };
|
||||
+
|
||||
+ proxmox_restore_read_image_at_async(s->conn, s->aid, buf, offset, bytes,
|
||||
+ proxmox_restore_read_image_at_async(s->conn, s->aid, buf, (uint64_t)offset, (uint64_t)bytes,
|
||||
+ read_callback, (void *) &rcb, &ret, &pbs_error);
|
||||
+
|
||||
+ qemu_coroutine_yield();
|
||||
@@ -262,8 +270,8 @@ index 0000000000..1481a2bfd1
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int pbs_co_pwritev(BlockDriverState *bs,
|
||||
+ uint64_t offset, uint64_t bytes,
|
||||
+ QEMUIOVector *qiov, int flags)
|
||||
+ 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");
|
||||
@@ -307,20 +315,20 @@ index 0000000000..1481a2bfd1
|
||||
+
|
||||
+block_init(bdrv_pbs_init);
|
||||
diff --git a/configure b/configure
|
||||
index 18c26e0389..33d9933871 100755
|
||||
index 48c21775f3..eda4e9225a 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -436,6 +436,7 @@ vvfat="yes"
|
||||
qed="yes"
|
||||
parallels="yes"
|
||||
sheepdog="no"
|
||||
@@ -356,6 +356,7 @@ vdi=${default_feature:-yes}
|
||||
vvfat=${default_feature:-yes}
|
||||
qed=${default_feature:-yes}
|
||||
parallels=${default_feature:-yes}
|
||||
+pbs_bdrv="yes"
|
||||
libxml2=""
|
||||
debug_mutex="no"
|
||||
libpmem=""
|
||||
@@ -1461,6 +1462,10 @@ for opt do
|
||||
plugins="$default_feature"
|
||||
rng_none="no"
|
||||
@@ -1126,6 +1127,10 @@ for opt do
|
||||
;;
|
||||
--enable-sheepdog) sheepdog="yes"
|
||||
--enable-parallels) parallels="yes"
|
||||
;;
|
||||
+ --disable-pbs-bdrv) pbs_bdrv="no"
|
||||
+ ;;
|
||||
@@ -329,50 +337,49 @@ index 18c26e0389..33d9933871 100755
|
||||
--disable-vhost-user) vhost_user="no"
|
||||
;;
|
||||
--enable-vhost-user) vhost_user="yes"
|
||||
@@ -1843,6 +1848,7 @@ disabled with --disable-FEATURE, default is enabled if available:
|
||||
@@ -1465,6 +1470,7 @@ cat << EOF
|
||||
vvfat vvfat image format support
|
||||
qed qed image format support
|
||||
parallels parallels image format support
|
||||
sheepdog sheepdog block driver support (deprecated)
|
||||
+ pbs-bdrv Proxmox backup server read-only block driver support
|
||||
crypto-afalg Linux AF_ALG crypto backend driver
|
||||
capstone capstone disassembler support
|
||||
debug-mutex mutex debugging support
|
||||
@@ -6682,6 +6688,9 @@ if test "$sheepdog" = "yes" ; then
|
||||
add_to deprecated_features "sheepdog"
|
||||
echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
|
||||
rng-none dummy RNG, avoid using /dev/(u)random and getrandom()
|
||||
@@ -3534,6 +3540,9 @@ if test "$xen" = "enabled" ; then
|
||||
echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
|
||||
echo "XEN_LIBS=$xen_libs" >> $config_host_mak
|
||||
fi
|
||||
+if test "$pbs_bdrv" = "yes" ; then
|
||||
+ echo "CONFIG_PBS_BDRV=y" >> $config_host_mak
|
||||
+fi
|
||||
if test "$pty_h" = "yes" ; then
|
||||
echo "HAVE_PTY_H=y" >> $config_host_mak
|
||||
if test "$vhost_scsi" = "yes" ; then
|
||||
echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
|
||||
fi
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 6f1fafee14..4d156d35ce 100644
|
||||
index 1a4dfab4e2..85b3c63199 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -2199,6 +2199,7 @@ summary_info += {'vvfat support': config_host.has_key('CONFIG_VVFAT')}
|
||||
summary_info += {'qed support': config_host.has_key('CONFIG_QED')}
|
||||
summary_info += {'parallels support': config_host.has_key('CONFIG_PARALLELS')}
|
||||
summary_info += {'sheepdog support': config_host.has_key('CONFIG_SHEEPDOG')}
|
||||
@@ -3448,6 +3448,7 @@ summary_info += {'lzfse support': liblzfse}
|
||||
summary_info += {'zstd support': zstd}
|
||||
summary_info += {'NUMA host support': config_host.has_key('CONFIG_NUMA')}
|
||||
summary_info += {'libxml2': libxml2}
|
||||
+summary_info += {'PBS bdrv support': config_host.has_key('CONFIG_PBS_BDRV')}
|
||||
summary_info += {'capstone': capstone_opt == 'disabled' ? false : capstone_opt}
|
||||
summary_info += {'libpmem support': config_host.has_key('CONFIG_LIBPMEM')}
|
||||
summary_info += {'libdaxctl support': config_host.has_key('CONFIG_LIBDAXCTL')}
|
||||
summary_info += {'capstone': capstone_opt == 'internal' ? capstone_opt : capstone}
|
||||
summary_info += {'libpmem support': libpmem}
|
||||
summary_info += {'libdaxctl support': libdaxctl}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 0fda1e3fd3..553112d998 100644
|
||||
index 5d8e2eb303..777863e33b 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -2975,7 +2975,7 @@
|
||||
@@ -3053,6 +3053,7 @@
|
||||
'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
|
||||
'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
|
||||
{ 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' },
|
||||
- 'sheepdog',
|
||||
+ 'sheepdog', 'pbs',
|
||||
'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
|
||||
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
|
||||
+ 'pbs',
|
||||
'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
|
||||
|
||||
##
|
||||
@@ -3039,6 +3039,17 @@
|
||||
@@ -3125,6 +3126,17 @@
|
||||
{ 'struct': 'BlockdevOptionsNull',
|
||||
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
|
||||
|
||||
@@ -390,11 +397,11 @@ index 0fda1e3fd3..553112d998 100644
|
||||
##
|
||||
# @BlockdevOptionsNVMe:
|
||||
#
|
||||
@@ -4148,6 +4159,7 @@
|
||||
@@ -4367,6 +4379,7 @@
|
||||
'nfs': 'BlockdevOptionsNfs',
|
||||
'null-aio': 'BlockdevOptionsNull',
|
||||
'null-co': 'BlockdevOptionsNull',
|
||||
+ 'pbs': 'BlockdevOptionsPbs',
|
||||
'nvme': 'BlockdevOptionsNVMe',
|
||||
'parallels': 'BlockdevOptionsGenericFormat',
|
||||
'qcow2': 'BlockdevOptionsQcow2',
|
||||
'preallocate':'BlockdevOptionsPreallocate',
|
||||
|
@@ -16,10 +16,10 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
2 files changed, 38 insertions(+)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index b8182aaf89..98e79552ef 100644
|
||||
index c15abefdda..4684789813 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -1073,3 +1073,12 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
@@ -1075,3 +1075,12 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
|
||||
return info;
|
||||
}
|
||||
@@ -33,10 +33,10 @@ index b8182aaf89..98e79552ef 100644
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 553112d998..f3608390c4 100644
|
||||
index 777863e33b..cfd980b70f 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -868,6 +868,35 @@
|
||||
@@ -867,6 +867,35 @@
|
||||
##
|
||||
{ 'command': 'backup-cancel' }
|
||||
|
||||
|
@@ -7,6 +7,7 @@ Returns advanced information about dirty bitmaps used (or not used) for
|
||||
the latest PBS backup.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
monitor/hmp-cmds.c | 28 ++++++-----
|
||||
pve-backup.c | 117 ++++++++++++++++++++++++++++++++-----------
|
||||
@@ -14,7 +15,7 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
3 files changed, 159 insertions(+), 42 deletions(-)
|
||||
|
||||
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||||
index 604026bb37..95f4e7f5c1 100644
|
||||
index cfd7a60f32..b613190a3c 100644
|
||||
--- a/monitor/hmp-cmds.c
|
||||
+++ b/monitor/hmp-cmds.c
|
||||
@@ -198,6 +198,7 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
|
||||
@@ -68,7 +69,7 @@ index 604026bb37..95f4e7f5c1 100644
|
||||
info->zero_bytes, zero_per);
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 98e79552ef..8305105fd5 100644
|
||||
index 4684789813..f90abaa50a 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -46,6 +46,7 @@ static struct PVEBackupState {
|
||||
@@ -79,7 +80,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
} stat;
|
||||
int64_t speed;
|
||||
VmaWriter *vmaw;
|
||||
@@ -670,7 +671,6 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -672,7 +673,6 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
|
||||
size_t total = 0;
|
||||
@@ -87,7 +88,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
|
||||
l = di_list;
|
||||
while (l) {
|
||||
@@ -691,18 +691,33 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -693,18 +693,33 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
|
||||
uuid_generate(uuid);
|
||||
|
||||
@@ -124,7 +125,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
}
|
||||
|
||||
int dump_cb_block_size = PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE; // Hardcoded (4M)
|
||||
@@ -729,12 +744,12 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -731,12 +746,12 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
error_set(task->errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
"proxmox_backup_new failed: %s", pbs_err);
|
||||
proxmox_backup_free_error(pbs_err);
|
||||
@@ -139,7 +140,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
|
||||
/* register all devices */
|
||||
l = di_list;
|
||||
@@ -745,6 +760,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -747,6 +762,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
di->block_size = dump_cb_block_size;
|
||||
|
||||
const char *devname = bdrv_get_device_name(di->bs);
|
||||
@@ -148,7 +149,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
|
||||
BdrvDirtyBitmap *bitmap = bdrv_find_dirty_bitmap(di->bs, PBS_BITMAP_NAME);
|
||||
bool expect_only_dirty = false;
|
||||
@@ -753,49 +770,59 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -755,49 +772,59 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
if (bitmap == NULL) {
|
||||
bitmap = bdrv_create_dirty_bitmap(di->bs, dump_cb_block_size, PBS_BITMAP_NAME, task->errp);
|
||||
if (!bitmap) {
|
||||
@@ -218,7 +219,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
}
|
||||
|
||||
/* register all devices for vma writer */
|
||||
@@ -805,7 +832,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -807,7 +834,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
l = g_list_next(l);
|
||||
|
||||
if (!(di->target = bdrv_backup_dump_create(VMA_CLUSTER_SIZE, di->size, pvebackup_co_dump_vma_cb, di, task->errp))) {
|
||||
@@ -227,7 +228,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
}
|
||||
|
||||
const char *devname = bdrv_get_device_name(di->bs);
|
||||
@@ -813,16 +840,14 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -815,16 +842,14 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
if (di->dev_id <= 0) {
|
||||
error_set(task->errp, ERROR_CLASS_GENERIC_ERROR,
|
||||
"register_stream failed");
|
||||
@@ -246,7 +247,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
}
|
||||
backup_dir = task->backup_file;
|
||||
|
||||
@@ -839,18 +864,18 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -841,18 +866,18 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
di->size, flags, false, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(task->errp, local_err);
|
||||
@@ -268,7 +269,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
}
|
||||
|
||||
|
||||
@@ -858,7 +883,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -860,7 +885,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
if (task->has_config_file) {
|
||||
if (pvebackup_co_add_config(task->config_file, config_name, format, backup_dir,
|
||||
vmaw, pbs, task->errp) != 0) {
|
||||
@@ -277,7 +278,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
}
|
||||
}
|
||||
|
||||
@@ -866,12 +891,11 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -868,12 +893,11 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
if (task->has_firewall_file) {
|
||||
if (pvebackup_co_add_config(task->firewall_file, firewall_name, format, backup_dir,
|
||||
vmaw, pbs, task->errp) != 0) {
|
||||
@@ -292,7 +293,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
|
||||
if (backup_state.stat.error) {
|
||||
error_free(backup_state.stat.error);
|
||||
@@ -891,10 +915,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -893,10 +917,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
char *uuid_str = g_strdup(backup_state.stat.uuid_str);
|
||||
|
||||
backup_state.stat.total = total;
|
||||
@@ -304,7 +305,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
@@ -911,6 +934,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -913,6 +936,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
task->result = uuid_info;
|
||||
return;
|
||||
|
||||
@@ -314,7 +315,7 @@ index 98e79552ef..8305105fd5 100644
|
||||
err:
|
||||
|
||||
l = di_list;
|
||||
@@ -1074,11 +1100,42 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
@@ -1076,11 +1102,42 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -358,10 +359,10 @@ index 98e79552ef..8305105fd5 100644
|
||||
return ret;
|
||||
}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index f3608390c4..f57fda122c 100644
|
||||
index cfd980b70f..8833060385 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -876,6 +876,8 @@
|
||||
@@ -875,6 +875,8 @@
|
||||
# @pbs-dirty-bitmap: True if dirty-bitmap-incremental backups to PBS are
|
||||
# supported.
|
||||
#
|
||||
@@ -370,7 +371,7 @@ index f3608390c4..f57fda122c 100644
|
||||
# @pbs-dirty-bitmap-savevm: True if 'dirty-bitmaps' migration capability can
|
||||
# safely be set for savevm-async.
|
||||
#
|
||||
@@ -884,6 +886,7 @@
|
||||
@@ -883,6 +885,7 @@
|
||||
##
|
||||
{ 'struct': 'ProxmoxSupportStatus',
|
||||
'data': { 'pbs-dirty-bitmap': 'bool',
|
||||
@@ -378,7 +379,7 @@ index f3608390c4..f57fda122c 100644
|
||||
'pbs-dirty-bitmap-savevm': 'bool',
|
||||
'pbs-library-version': 'str' } }
|
||||
|
||||
@@ -897,6 +900,59 @@
|
||||
@@ -896,6 +899,59 @@
|
||||
##
|
||||
{ 'command': 'query-proxmox-support', 'returns': 'ProxmoxSupportStatus' }
|
||||
|
||||
|
@@ -7,33 +7,34 @@ QEMU uses the logging for error messages usually, so LOG_ERR is most
|
||||
fitting.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
meson.build | 2 ++
|
||||
os-posix.c | 7 +++++--
|
||||
2 files changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 4d156d35ce..737ea9e5d7 100644
|
||||
index 85b3c63199..31ba7d70d6 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -726,6 +726,7 @@ keyutils = dependency('libkeyutils', required: false,
|
||||
@@ -1203,6 +1203,7 @@ keyutils = dependency('libkeyutils', required: false,
|
||||
has_gettid = cc.has_function('gettid')
|
||||
|
||||
libuuid = cc.find_library('uuid', required: true)
|
||||
+libsystemd = cc.find_library('systemd', required: true)
|
||||
libproxmox_backup_qemu = cc.find_library('proxmox_backup_qemu', required: true)
|
||||
|
||||
# Malloc tests
|
||||
@@ -1539,6 +1540,7 @@ blockdev_ss.add(files(
|
||||
# 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')])
|
||||
# libselinux
|
||||
@@ -2571,6 +2572,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')])
|
||||
endif
|
||||
|
||||
common_ss.add(files('cpus-common.c'))
|
||||
diff --git a/os-posix.c b/os-posix.c
|
||||
index 1de2839554..ac4f652923 100644
|
||||
index ae6c9f2a5e..36807806bf 100644
|
||||
--- a/os-posix.c
|
||||
+++ b/os-posix.c
|
||||
@@ -28,6 +28,8 @@
|
||||
@@ -45,7 +46,7 @@ index 1de2839554..ac4f652923 100644
|
||||
|
||||
#include "qemu-common.h"
|
||||
/* Needed early for CONFIG_BSD etc. */
|
||||
@@ -288,9 +290,10 @@ void os_setup_post(void)
|
||||
@@ -291,9 +293,10 @@ void os_setup_post(void)
|
||||
|
||||
dup2(fd, 0);
|
||||
dup2(fd, 1);
|
||||
|
@@ -4,16 +4,17 @@ Date: Thu, 20 Aug 2020 14:31:59 +0200
|
||||
Subject: [PATCH] PVE: Add sequential job transaction support
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
include/qemu/job.h | 12 ++++++++++++
|
||||
job.c | 31 +++++++++++++++++++++++++++++++
|
||||
2 files changed, 43 insertions(+)
|
||||
|
||||
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
||||
index 32aabb1c60..f7a6a0926a 100644
|
||||
index 6e67b6977f..60376c99ee 100644
|
||||
--- a/include/qemu/job.h
|
||||
+++ b/include/qemu/job.h
|
||||
@@ -280,6 +280,18 @@ typedef enum JobCreateFlags {
|
||||
@@ -294,6 +294,18 @@ typedef enum JobCreateFlags {
|
||||
*/
|
||||
JobTxn *job_txn_new(void);
|
||||
|
||||
@@ -33,7 +34,7 @@ index 32aabb1c60..f7a6a0926a 100644
|
||||
* Release a reference that was previously acquired with job_txn_add_job or
|
||||
* job_txn_new. If it's the last reference to the object, it will be freed.
|
||||
diff --git a/job.c b/job.c
|
||||
index f9884e7d9d..05b7797e82 100644
|
||||
index af25dd5b98..d0d152e697 100644
|
||||
--- a/job.c
|
||||
+++ b/job.c
|
||||
@@ -72,6 +72,8 @@ struct JobTxn {
|
||||
@@ -71,7 +72,7 @@ index f9884e7d9d..05b7797e82 100644
|
||||
static void job_txn_ref(JobTxn *txn)
|
||||
{
|
||||
txn->refcnt++;
|
||||
@@ -841,6 +862,9 @@ static void job_completed_txn_success(Job *job)
|
||||
@@ -888,6 +909,9 @@ static void job_completed_txn_success(Job *job)
|
||||
*/
|
||||
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
|
||||
if (!job_is_completed(other_job)) {
|
||||
@@ -81,7 +82,7 @@ index f9884e7d9d..05b7797e82 100644
|
||||
return;
|
||||
}
|
||||
assert(other_job->ret == 0);
|
||||
@@ -1011,6 +1035,13 @@ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
|
||||
@@ -1082,6 +1106,13 @@ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
|
@@ -11,12 +11,15 @@ To keep the rate-limiting and IO impact from before, we use a sequential
|
||||
transaction, so drives will still be backed up one after the other.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[add new force parameter to job_cancel_sync calls]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 167 +++++++++++++++------------------------------------
|
||||
1 file changed, 49 insertions(+), 118 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 8305105fd5..d7f2b2206f 100644
|
||||
index f90abaa50a..63c686463f 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -52,6 +52,7 @@ static struct PVEBackupState {
|
||||
@@ -158,7 +161,7 @@ index 8305105fd5..d7f2b2206f 100644
|
||||
- if (next_job) {
|
||||
- AioContext *aio_context = next_job->job.aio_context;
|
||||
- aio_context_acquire(aio_context);
|
||||
- job_cancel_sync(&next_job->job);
|
||||
- job_cancel_sync(&next_job->job, true);
|
||||
- aio_context_release(aio_context);
|
||||
- } else {
|
||||
- break;
|
||||
@@ -166,7 +169,7 @@ index 8305105fd5..d7f2b2206f 100644
|
||||
+ if (cancel_job) {
|
||||
+ AioContext *aio_context = cancel_job->job.aio_context;
|
||||
+ aio_context_acquire(aio_context);
|
||||
+ job_cancel_sync(&cancel_job->job);
|
||||
+ job_cancel_sync(&cancel_job->job, true);
|
||||
+ job_unref(&cancel_job->job);
|
||||
+ aio_context_release(aio_context);
|
||||
}
|
||||
@@ -200,7 +203,7 @@ index 8305105fd5..d7f2b2206f 100644
|
||||
- if (job_should_pause(&job->job)) {
|
||||
- bool error_or_canceled = pvebackup_error_or_canceled();
|
||||
- if (error_or_canceled) {
|
||||
- job_cancel_sync(&job->job);
|
||||
- job_cancel_sync(&job->job, true);
|
||||
- } else {
|
||||
- job_resume(&job->job);
|
||||
- }
|
||||
@@ -228,19 +231,19 @@ index 8305105fd5..d7f2b2206f 100644
|
||||
+ }
|
||||
+ backup_state.txn = job_txn_new_seq();
|
||||
+
|
||||
BackupPerf perf = { .max_workers = 16 };
|
||||
|
||||
/* create and start all jobs (paused state) */
|
||||
GList *l = backup_state.di_list;
|
||||
while (l) {
|
||||
@@ -524,7 +448,7 @@ static bool create_backup_jobs(void) {
|
||||
@@ -526,7 +450,7 @@ static bool create_backup_jobs(void) {
|
||||
BlockJob *job = backup_job_create(
|
||||
NULL, di->bs, di->target, backup_state.speed, sync_mode, di->bitmap,
|
||||
bitmap_mode, false, NULL, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
- JOB_DEFAULT, pvebackup_complete_cb, di, 1, NULL, &local_err);
|
||||
bitmap_mode, false, NULL, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
- JOB_DEFAULT, pvebackup_complete_cb, di, NULL, &local_err);
|
||||
+ JOB_DEFAULT, pvebackup_complete_cb, di, backup_state.txn, &local_err);
|
||||
|
||||
aio_context_release(aio_context);
|
||||
|
||||
@@ -536,7 +460,8 @@ static bool create_backup_jobs(void) {
|
||||
@@ -538,7 +462,8 @@ static bool create_backup_jobs(void) {
|
||||
pvebackup_propagate_error(create_job_err);
|
||||
break;
|
||||
}
|
||||
@@ -250,7 +253,7 @@ index 8305105fd5..d7f2b2206f 100644
|
||||
|
||||
bdrv_unref(di->target);
|
||||
di->target = NULL;
|
||||
@@ -554,6 +479,10 @@ static bool create_backup_jobs(void) {
|
||||
@@ -556,6 +481,10 @@ static bool create_backup_jobs(void) {
|
||||
bdrv_unref(di->target);
|
||||
di->target = NULL;
|
||||
}
|
||||
@@ -261,7 +264,7 @@ index 8305105fd5..d7f2b2206f 100644
|
||||
}
|
||||
}
|
||||
|
||||
@@ -944,10 +873,6 @@ err:
|
||||
@@ -946,10 +875,6 @@ err:
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
l = g_list_next(l);
|
||||
|
||||
@@ -272,7 +275,7 @@ index 8305105fd5..d7f2b2206f 100644
|
||||
if (di->target) {
|
||||
bdrv_unref(di->target);
|
||||
}
|
||||
@@ -1036,9 +961,15 @@ UuidInfo *qmp_backup(
|
||||
@@ -1038,9 +963,15 @@ UuidInfo *qmp_backup(
|
||||
block_on_coroutine_fn(pvebackup_co_prepare, &task);
|
||||
|
||||
if (*errp == NULL) {
|
||||
|
@@ -48,13 +48,16 @@ before.
|
||||
[0] https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg03515.html
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[add new force parameter to job_cancel_sync calls]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 217 ++++++++++++++++++++++++++++---------------
|
||||
qapi/block-core.json | 5 +-
|
||||
2 files changed, 144 insertions(+), 78 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index d7f2b2206f..e671ed8d48 100644
|
||||
index 63c686463f..6f05796fad 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -33,7 +33,9 @@ const char *PBS_BITMAP_NAME = "pbs-incremental-dirty-bitmap";
|
||||
@@ -228,7 +231,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
+ Job *job = (Job*)data->data;
|
||||
+ AioContext *job_ctx = job->aio_context;
|
||||
+ aio_context_acquire(job_ctx);
|
||||
+ job_cancel_sync(job);
|
||||
+ job_cancel_sync(job, true);
|
||||
+ aio_context_release(job_ctx);
|
||||
+ aio_co_enter(data->ctx, data->co);
|
||||
+}
|
||||
@@ -267,7 +270,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
- if (cancel_job) {
|
||||
- AioContext *aio_context = cancel_job->job.aio_context;
|
||||
- aio_context_acquire(aio_context);
|
||||
- job_cancel_sync(&cancel_job->job);
|
||||
- job_cancel_sync(&cancel_job->job, true);
|
||||
- job_unref(&cancel_job->job);
|
||||
- aio_context_release(aio_context);
|
||||
- }
|
||||
@@ -301,7 +304,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
Error *local_err = NULL;
|
||||
|
||||
/* create job transaction to synchronize bitmap commit and cancel all
|
||||
@@ -452,24 +494,19 @@ static bool create_backup_jobs(void) {
|
||||
@@ -454,24 +496,19 @@ static bool create_backup_jobs(void) {
|
||||
|
||||
aio_context_release(aio_context);
|
||||
|
||||
@@ -331,13 +334,13 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
l = backup_state.di_list;
|
||||
while (l) {
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
@@ -481,12 +518,17 @@ static bool create_backup_jobs(void) {
|
||||
@@ -483,12 +520,17 @@ static bool create_backup_jobs(void) {
|
||||
}
|
||||
|
||||
if (di->job) {
|
||||
+ AioContext *ctx = di->job->job.aio_context;
|
||||
+ aio_context_acquire(ctx);
|
||||
+ job_cancel_sync(&di->job->job);
|
||||
+ job_cancel_sync(&di->job->job, true);
|
||||
job_unref(&di->job->job);
|
||||
+ aio_context_release(ctx);
|
||||
}
|
||||
@@ -350,7 +353,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
}
|
||||
|
||||
typedef struct QmpBackupTask {
|
||||
@@ -523,11 +565,12 @@ typedef struct QmpBackupTask {
|
||||
@@ -525,11 +567,12 @@ typedef struct QmpBackupTask {
|
||||
UuidInfo *result;
|
||||
} QmpBackupTask;
|
||||
|
||||
@@ -364,7 +367,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
QmpBackupTask *task = opaque;
|
||||
|
||||
task->result = NULL; // just to be sure
|
||||
@@ -548,8 +591,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -550,8 +593,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
const char *firewall_name = "qemu-server.fw";
|
||||
|
||||
if (backup_state.di_list) {
|
||||
@@ -375,7 +378,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -616,6 +660,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -618,6 +662,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
di->size = size;
|
||||
total += size;
|
||||
@@ -384,7 +387,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
}
|
||||
|
||||
uuid_generate(uuid);
|
||||
@@ -847,6 +893,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -849,6 +895,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
backup_state.stat.dirty = total - backup_state.stat.reused;
|
||||
backup_state.stat.transferred = 0;
|
||||
backup_state.stat.zero_bytes = 0;
|
||||
@@ -393,7 +396,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
@@ -861,6 +909,33 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -863,6 +911,33 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
uuid_info->UUID = uuid_str;
|
||||
|
||||
task->result = uuid_info;
|
||||
@@ -427,7 +430,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
return;
|
||||
|
||||
err_mutex:
|
||||
@@ -883,6 +958,7 @@ err:
|
||||
@@ -885,6 +960,7 @@ err:
|
||||
g_free(di);
|
||||
}
|
||||
g_list_free(di_list);
|
||||
@@ -435,7 +438,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
|
||||
if (devs) {
|
||||
g_strfreev(devs);
|
||||
@@ -903,6 +979,8 @@ err:
|
||||
@@ -905,6 +981,8 @@ err:
|
||||
}
|
||||
|
||||
task->result = NULL;
|
||||
@@ -444,7 +447,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -956,24 +1034,8 @@ UuidInfo *qmp_backup(
|
||||
@@ -958,24 +1036,8 @@ UuidInfo *qmp_backup(
|
||||
.errp = errp,
|
||||
};
|
||||
|
||||
@@ -469,7 +472,7 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
return task.result;
|
||||
}
|
||||
|
||||
@@ -1025,6 +1087,7 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
@@ -1027,6 +1089,7 @@ BackupStatus *qmp_query_backup(Error **errp)
|
||||
info->transferred = backup_state.stat.transferred;
|
||||
info->has_reused = true;
|
||||
info->reused = backup_state.stat.reused;
|
||||
@@ -478,10 +481,10 @@ index d7f2b2206f..e671ed8d48 100644
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index f57fda122c..9b827cbe43 100644
|
||||
index 8833060385..6a67adf923 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -775,12 +775,15 @@
|
||||
@@ -774,12 +774,15 @@
|
||||
#
|
||||
# @uuid: uuid for this backup job
|
||||
#
|
||||
|
@@ -12,21 +12,22 @@ Also add a flag to query-proxmox-support so qemu-server can determine if
|
||||
safe migration is possible and makes sense.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
include/migration/misc.h | 3 ++
|
||||
migration/meson.build | 2 +
|
||||
migration/migration.c | 1 +
|
||||
migration/pbs-state.c | 106 +++++++++++++++++++++++++++++++++++++++
|
||||
pve-backup.c | 1 +
|
||||
qapi/block-core.json | 6 +++
|
||||
softmmu/vl.c | 1 +
|
||||
6 files changed, 119 insertions(+)
|
||||
create mode 100644 migration/pbs-state.c
|
||||
|
||||
diff --git a/include/migration/misc.h b/include/migration/misc.h
|
||||
index 34e7d75713..f83816dd3c 100644
|
||||
index 465906710d..4f0aeceb6f 100644
|
||||
--- a/include/migration/misc.h
|
||||
+++ b/include/migration/misc.h
|
||||
@@ -75,4 +75,7 @@ bool migration_in_incoming_postcopy(void);
|
||||
@@ -75,4 +75,7 @@ bool migration_in_bg_snapshot(void);
|
||||
/* migration/block-dirty-bitmap.c */
|
||||
void dirty_bitmap_mig_init(void);
|
||||
|
||||
@@ -35,13 +36,13 @@ index 34e7d75713..f83816dd3c 100644
|
||||
+
|
||||
#endif
|
||||
diff --git a/migration/meson.build b/migration/meson.build
|
||||
index e62b79b60f..b90a04aa75 100644
|
||||
index ea9aedeefc..c27dc9bd97 100644
|
||||
--- a/migration/meson.build
|
||||
+++ b/migration/meson.build
|
||||
@@ -7,8 +7,10 @@ migration_files = files(
|
||||
'qemu-file-channel.c',
|
||||
'qemu-file.c',
|
||||
'qjson.c',
|
||||
'yank_functions.c',
|
||||
+ 'pbs-state.c',
|
||||
)
|
||||
softmmu_ss.add(migration_files)
|
||||
@@ -49,6 +50,18 @@ index e62b79b60f..b90a04aa75 100644
|
||||
|
||||
softmmu_ss.add(files(
|
||||
'block-dirty-bitmap.c',
|
||||
diff --git a/migration/migration.c b/migration/migration.c
|
||||
index abaf6f9e3d..d925fd7488 100644
|
||||
--- a/migration/migration.c
|
||||
+++ b/migration/migration.c
|
||||
@@ -213,6 +213,7 @@ void migration_object_init(void)
|
||||
blk_mig_init();
|
||||
ram_mig_init();
|
||||
dirty_bitmap_mig_init();
|
||||
+ pbs_state_mig_init();
|
||||
}
|
||||
|
||||
void migration_cancel(const Error *error)
|
||||
diff --git a/migration/pbs-state.c b/migration/pbs-state.c
|
||||
new file mode 100644
|
||||
index 0000000000..29f2b3860d
|
||||
@@ -162,10 +175,10 @@ index 0000000000..29f2b3860d
|
||||
+ NULL);
|
||||
+}
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index e671ed8d48..bd2647e5f3 100644
|
||||
index 6f05796fad..5fa3cc1352 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -1130,6 +1130,7 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
@@ -1132,6 +1132,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;
|
||||
@@ -174,10 +187,10 @@ index e671ed8d48..bd2647e5f3 100644
|
||||
return ret;
|
||||
}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 9b827cbe43..30eb1262ff 100644
|
||||
index 6a67adf923..c99ddf8628 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -884,6 +884,11 @@
|
||||
@@ -883,6 +883,11 @@
|
||||
# @pbs-dirty-bitmap-savevm: True if 'dirty-bitmaps' migration capability can
|
||||
# safely be set for savevm-async.
|
||||
#
|
||||
@@ -189,7 +202,7 @@ index 9b827cbe43..30eb1262ff 100644
|
||||
# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
|
||||
#
|
||||
##
|
||||
@@ -891,6 +896,7 @@
|
||||
@@ -890,6 +895,7 @@
|
||||
'data': { 'pbs-dirty-bitmap': 'bool',
|
||||
'query-bitmap-info': 'bool',
|
||||
'pbs-dirty-bitmap-savevm': 'bool',
|
||||
@@ -197,15 +210,3 @@ index 9b827cbe43..30eb1262ff 100644
|
||||
'pbs-library-version': 'str' } }
|
||||
|
||||
##
|
||||
diff --git a/softmmu/vl.c b/softmmu/vl.c
|
||||
index 5b5512128e..6721889fee 100644
|
||||
--- a/softmmu/vl.c
|
||||
+++ b/softmmu/vl.c
|
||||
@@ -4304,6 +4304,7 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||
blk_mig_init();
|
||||
ram_mig_init();
|
||||
dirty_bitmap_mig_init();
|
||||
+ pbs_state_mig_init();
|
||||
|
||||
qemu_opts_foreach(qemu_find_opts("mon"),
|
||||
mon_init_func, NULL, &error_fatal);
|
||||
|
@@ -13,15 +13,16 @@ that are obviously marked as "busy", which would cause none at all to be
|
||||
transferred.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
migration/block-dirty-bitmap.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
|
||||
index c61d382be8..26e4e5c99c 100644
|
||||
index 9aba7d9c22..f4ecf9c9f9 100644
|
||||
--- a/migration/block-dirty-bitmap.c
|
||||
+++ b/migration/block-dirty-bitmap.c
|
||||
@@ -534,7 +534,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
|
||||
@@ -538,7 +538,7 @@ 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);
|
||||
|
@@ -15,15 +15,16 @@ According to RFC 3720, an initiator name is at most 223 bytes long, so the
|
||||
4 KiB buffer is big enough, even if many whitespaces are used.
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/iscsi.c | 30 ++++++++++++++++++++++++++++++
|
||||
1 file changed, 30 insertions(+)
|
||||
|
||||
diff --git a/block/iscsi.c b/block/iscsi.c
|
||||
index e30a7e3606..6c70bbe351 100644
|
||||
index 57aa07a40d..a8902b84d5 100644
|
||||
--- a/block/iscsi.c
|
||||
+++ b/block/iscsi.c
|
||||
@@ -1374,12 +1374,42 @@ static char *get_initiator_name(QemuOpts *opts)
|
||||
@@ -1386,12 +1386,42 @@ static char *get_initiator_name(QemuOpts *opts)
|
||||
const char *name;
|
||||
char *iscsi_name;
|
||||
UuidInfo *uuid_info;
|
||||
|
@@ -22,6 +22,7 @@ monitor for that coroutine ourselves, but let's just fix it the right
|
||||
way instead)
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/monitor/block-hmp-cmds.c | 4 +-
|
||||
hmp-commands.hx | 2 +
|
||||
@@ -31,10 +32,10 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
5 files changed, 77 insertions(+), 196 deletions(-)
|
||||
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index 46c63b1cf9..11c84d5508 100644
|
||||
index 4481b60a5c..c9849a5b29 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1013,7 +1013,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
|
||||
@@ -1016,7 +1016,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
|
||||
g_free(global_snapshots);
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ index 46c63b1cf9..11c84d5508 100644
|
||||
{
|
||||
Error *error = NULL;
|
||||
|
||||
@@ -1022,7 +1022,7 @@ void hmp_backup_cancel(Monitor *mon, const QDict *qdict)
|
||||
@@ -1025,7 +1025,7 @@ void hmp_backup_cancel(Monitor *mon, const QDict *qdict)
|
||||
hmp_handle_error(mon, error);
|
||||
}
|
||||
|
||||
@@ -53,10 +54,10 @@ index 46c63b1cf9..11c84d5508 100644
|
||||
Error *error = NULL;
|
||||
|
||||
diff --git a/hmp-commands.hx b/hmp-commands.hx
|
||||
index 0c6b944850..54de3f80e6 100644
|
||||
index d4bb00216e..4e21911fa6 100644
|
||||
--- a/hmp-commands.hx
|
||||
+++ b/hmp-commands.hx
|
||||
@@ -108,6 +108,7 @@ ERST
|
||||
@@ -109,6 +109,7 @@ ERST
|
||||
"\n\t\t\t Use -d to dump data into a directory instead"
|
||||
"\n\t\t\t of using VMA format.",
|
||||
.cmd = hmp_backup,
|
||||
@@ -64,7 +65,7 @@ index 0c6b944850..54de3f80e6 100644
|
||||
},
|
||||
|
||||
SRST
|
||||
@@ -121,6 +122,7 @@ ERST
|
||||
@@ -122,6 +123,7 @@ ERST
|
||||
.params = "",
|
||||
.help = "cancel the current VM backup",
|
||||
.cmd = hmp_backup_cancel,
|
||||
@@ -115,7 +116,7 @@ index 4ce7bc0b5e..0923037dec 100644
|
||||
static void proxmox_backup_schedule_wake(void *data) {
|
||||
CoCtxData *waker = (CoCtxData *)data;
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index bd2647e5f3..dec9c0d188 100644
|
||||
index 5fa3cc1352..323014744c 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -357,7 +357,7 @@ static void job_cancel_bh(void *opaque) {
|
||||
@@ -139,7 +140,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
// assumes the caller holds backup_mutex
|
||||
static int coroutine_fn pvebackup_co_add_config(
|
||||
const char *file,
|
||||
@@ -531,50 +526,27 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
@@ -533,50 +528,27 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
aio_co_enter(data->ctx, data->co);
|
||||
}
|
||||
|
||||
@@ -206,7 +207,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
BlockBackend *blk;
|
||||
BlockDriverState *bs = NULL;
|
||||
const char *backup_dir = NULL;
|
||||
@@ -591,17 +563,17 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -593,17 +565,17 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
const char *firewall_name = "qemu-server.fw";
|
||||
|
||||
if (backup_state.di_list) {
|
||||
@@ -229,7 +230,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
|
||||
gchar **d = devs;
|
||||
while (d && *d) {
|
||||
@@ -609,14 +581,14 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -611,14 +583,14 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
if (blk) {
|
||||
bs = blk_bs(blk);
|
||||
if (!bdrv_is_inserted(bs)) {
|
||||
@@ -246,7 +247,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
"Device '%s' not found", *d);
|
||||
goto err;
|
||||
}
|
||||
@@ -639,7 +611,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -641,7 +613,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
|
||||
if (!di_list) {
|
||||
@@ -255,7 +256,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -649,13 +621,13 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -651,13 +623,13 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
while (l) {
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
l = g_list_next(l);
|
||||
@@ -271,7 +272,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
goto err;
|
||||
}
|
||||
di->size = size;
|
||||
@@ -682,47 +654,44 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -684,47 +656,44 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
|
||||
if (format == BACKUP_FORMAT_PBS) {
|
||||
@@ -336,7 +337,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
if (connect_result < 0)
|
||||
goto err_mutex;
|
||||
|
||||
@@ -741,9 +710,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -743,9 +712,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
BdrvDirtyBitmap *bitmap = bdrv_find_dirty_bitmap(di->bs, PBS_BITMAP_NAME);
|
||||
bool expect_only_dirty = false;
|
||||
|
||||
@@ -348,7 +349,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
if (!bitmap) {
|
||||
goto err_mutex;
|
||||
}
|
||||
@@ -773,12 +742,12 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -775,12 +744,12 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,7 +364,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
goto err_mutex;
|
||||
}
|
||||
|
||||
@@ -792,10 +761,10 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -794,10 +763,10 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
backup_state.stat.bitmap_list = g_list_append(backup_state.stat.bitmap_list, info);
|
||||
}
|
||||
} else if (format == BACKUP_FORMAT_VMA) {
|
||||
@@ -376,7 +377,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
}
|
||||
goto err_mutex;
|
||||
}
|
||||
@@ -806,25 +775,25 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -808,25 +777,25 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
l = g_list_next(l);
|
||||
|
||||
@@ -408,7 +409,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
|
||||
l = di_list;
|
||||
while (l) {
|
||||
@@ -838,34 +807,34 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -840,34 +809,34 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
bdrv_img_create(di->targetfile, "raw", NULL, NULL, NULL,
|
||||
di->size, flags, false, &local_err);
|
||||
if (local_err) {
|
||||
@@ -452,7 +453,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
goto err_mutex;
|
||||
}
|
||||
}
|
||||
@@ -883,7 +852,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -885,7 +854,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
if (backup_state.stat.backup_file) {
|
||||
g_free(backup_state.stat.backup_file);
|
||||
}
|
||||
@@ -461,7 +462,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
|
||||
uuid_copy(backup_state.stat.uuid, uuid);
|
||||
uuid_unparse_lower(uuid, backup_state.stat.uuid_str);
|
||||
@@ -898,7 +867,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -900,7 +869,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
|
||||
@@ -470,7 +471,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
|
||||
backup_state.vmaw = vmaw;
|
||||
backup_state.pbs = pbs;
|
||||
@@ -908,8 +877,6 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -910,8 +879,6 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
uuid_info = g_malloc0(sizeof(*uuid_info));
|
||||
uuid_info->UUID = uuid_str;
|
||||
|
||||
@@ -479,7 +480,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
/* Run create_backup_jobs_bh outside of coroutine (in BH) but keep
|
||||
* backup_mutex locked. This is fine, a CoMutex can be held across yield
|
||||
* points, and we'll release it as soon as the BH reschedules us.
|
||||
@@ -923,7 +890,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -925,7 +892,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
qemu_coroutine_yield();
|
||||
|
||||
if (local_err) {
|
||||
@@ -488,7 +489,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -936,7 +903,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
@@ -938,7 +905,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
|
||||
/* start the first job in the transaction */
|
||||
job_txn_start_seq(backup_state.txn);
|
||||
|
||||
@@ -497,7 +498,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
|
||||
err_mutex:
|
||||
qemu_mutex_unlock(&backup_state.stat.lock);
|
||||
@@ -967,7 +934,7 @@ err:
|
||||
@@ -969,7 +936,7 @@ err:
|
||||
if (vmaw) {
|
||||
Error *err = NULL;
|
||||
vma_writer_close(vmaw, &err);
|
||||
@@ -506,7 +507,7 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
}
|
||||
|
||||
if (pbs) {
|
||||
@@ -978,65 +945,8 @@ err:
|
||||
@@ -980,65 +947,8 @@ err:
|
||||
rmdir(backup_dir);
|
||||
}
|
||||
|
||||
@@ -574,10 +575,10 @@ index bd2647e5f3..dec9c0d188 100644
|
||||
|
||||
BackupStatus *qmp_query_backup(Error **errp)
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 30eb1262ff..6ff5367383 100644
|
||||
index c99ddf8628..829dc7b8e9 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -847,7 +847,7 @@
|
||||
@@ -846,7 +846,7 @@
|
||||
'*config-file': 'str',
|
||||
'*firewall-file': 'str',
|
||||
'*devlist': 'str', '*speed': 'int' },
|
||||
@@ -586,7 +587,7 @@ index 30eb1262ff..6ff5367383 100644
|
||||
|
||||
##
|
||||
# @query-backup:
|
||||
@@ -869,7 +869,7 @@
|
||||
@@ -868,7 +868,7 @@
|
||||
# Notes: This command succeeds even if there is no backup process running.
|
||||
#
|
||||
##
|
||||
|
@@ -11,6 +11,7 @@ from the PVE side to avoid QMP calls with unsupported parameters.
|
||||
|
||||
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/monitor/block-hmp-cmds.c | 1 +
|
||||
pve-backup.c | 3 +++
|
||||
@@ -18,10 +19,10 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
3 files changed, 11 insertions(+)
|
||||
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index 11c84d5508..0932deb28c 100644
|
||||
index c9849a5b29..52ddbf95ad 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1036,6 +1036,7 @@ void coroutine_fn hmp_backup(Monitor *mon, const QDict *qdict)
|
||||
@@ -1039,6 +1039,7 @@ void coroutine_fn hmp_backup(Monitor *mon, const QDict *qdict)
|
||||
false, NULL, // PBS password
|
||||
false, NULL, // PBS keyfile
|
||||
false, NULL, // PBS key_password
|
||||
@@ -30,10 +31,10 @@ index 11c84d5508..0932deb28c 100644
|
||||
false, NULL, // PBS backup-id
|
||||
false, 0, // PBS backup-time
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index dec9c0d188..076146cc1e 100644
|
||||
index 323014744c..9f6c04a512 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -531,6 +531,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
@@ -533,6 +533,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
bool has_password, const char *password,
|
||||
bool has_keyfile, const char *keyfile,
|
||||
bool has_key_password, const char *key_password,
|
||||
@@ -41,7 +42,7 @@ index dec9c0d188..076146cc1e 100644
|
||||
bool has_fingerprint, const char *fingerprint,
|
||||
bool has_backup_id, const char *backup_id,
|
||||
bool has_backup_time, int64_t backup_time,
|
||||
@@ -679,6 +680,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
@@ -681,6 +682,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
has_password ? password : NULL,
|
||||
has_keyfile ? keyfile : NULL,
|
||||
has_key_password ? key_password : NULL,
|
||||
@@ -49,7 +50,7 @@ index dec9c0d188..076146cc1e 100644
|
||||
has_compress ? compress : true,
|
||||
has_encrypt ? encrypt : has_keyfile,
|
||||
has_fingerprint ? fingerprint : NULL,
|
||||
@@ -1042,5 +1044,6 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
@@ -1044,5 +1046,6 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
ret->pbs_dirty_bitmap_savevm = true;
|
||||
ret->pbs_dirty_bitmap_migration = true;
|
||||
ret->query_bitmap_info = true;
|
||||
@@ -57,10 +58,10 @@ index dec9c0d188..076146cc1e 100644
|
||||
return ret;
|
||||
}
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index 6ff5367383..bef9b65fec 100644
|
||||
index 829dc7b8e9..d089328a1f 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -818,6 +818,8 @@
|
||||
@@ -817,6 +817,8 @@
|
||||
#
|
||||
# @key-password: password for keyfile (optional for format 'pbs')
|
||||
#
|
||||
@@ -69,7 +70,7 @@ index 6ff5367383..bef9b65fec 100644
|
||||
# @fingerprint: server cert fingerprint (optional for format 'pbs')
|
||||
#
|
||||
# @backup-id: backup ID (required for format 'pbs')
|
||||
@@ -837,6 +839,7 @@
|
||||
@@ -836,6 +838,7 @@
|
||||
'*password': 'str',
|
||||
'*keyfile': 'str',
|
||||
'*key-password': 'str',
|
||||
@@ -77,7 +78,7 @@ index 6ff5367383..bef9b65fec 100644
|
||||
'*fingerprint': 'str',
|
||||
'*backup-id': 'str',
|
||||
'*backup-time': 'int',
|
||||
@@ -889,6 +892,9 @@
|
||||
@@ -888,6 +891,9 @@
|
||||
# migration cap if this is false/unset may lead
|
||||
# to crashes on migration!
|
||||
#
|
||||
@@ -87,7 +88,7 @@ index 6ff5367383..bef9b65fec 100644
|
||||
# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
|
||||
#
|
||||
##
|
||||
@@ -897,6 +903,7 @@
|
||||
@@ -896,6 +902,7 @@
|
||||
'query-bitmap-info': 'bool',
|
||||
'pbs-dirty-bitmap-savevm': 'bool',
|
||||
'pbs-dirty-bitmap-migration': 'bool',
|
||||
|
@@ -11,12 +11,13 @@ Tracing shows the fast-path is taken almost all the time, though not
|
||||
100% so the slow one is still necessary.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/pbs.c | 17 ++++++++++++++---
|
||||
1 file changed, 14 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/block/pbs.c b/block/pbs.c
|
||||
index 1481a2bfd1..fbf0d8d845 100644
|
||||
index 0b05ea9080..c5eb4d5bad 100644
|
||||
--- a/block/pbs.c
|
||||
+++ b/block/pbs.c
|
||||
@@ -200,7 +200,16 @@ static coroutine_fn int pbs_co_preadv(BlockDriverState *bs,
|
||||
@@ -35,9 +36,9 @@ index 1481a2bfd1..fbf0d8d845 100644
|
||||
+ buf = g_malloc(bytes);
|
||||
+ }
|
||||
|
||||
ReadCallbackData rcb = {
|
||||
.co = qemu_coroutine_self(),
|
||||
@@ -218,8 +227,10 @@ static coroutine_fn int pbs_co_preadv(BlockDriverState *bs,
|
||||
if (offset < 0 || bytes < 0) {
|
||||
fprintf(stderr, "unexpected negative 'offset' or 'bytes' value!\n");
|
||||
@@ -223,8 +232,10 @@ static coroutine_fn int pbs_co_preadv(BlockDriverState *bs,
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@@ -4,15 +4,17 @@ Date: Tue, 2 Mar 2021 16:34:28 +0100
|
||||
Subject: [PATCH] PVE: block/stream: increase chunk size
|
||||
|
||||
Ceph favors bigger chunks, so increase to 4M.
|
||||
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/stream.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/block/stream.c b/block/stream.c
|
||||
index 236384f2f7..a5371420e3 100644
|
||||
index e45113aed6..c3c0c5febe 100644
|
||||
--- a/block/stream.c
|
||||
+++ b/block/stream.c
|
||||
@@ -26,7 +26,7 @@ enum {
|
||||
@@ -28,7 +28,7 @@ enum {
|
||||
* large enough to process multiple clusters in a single call, so
|
||||
* that populating contiguous regions of the image is efficient.
|
||||
*/
|
||||
|
@@ -10,33 +10,24 @@ 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 | 13 ++++++++-----
|
||||
1 file changed, 8 insertions(+), 5 deletions(-)
|
||||
block/io.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/block/io.c b/block/io.c
|
||||
index ec5e152bb7..08dee005ec 100644
|
||||
index 4e4cb556c5..04061f1e68 100644
|
||||
--- a/block/io.c
|
||||
+++ b/block/io.c
|
||||
@@ -1613,13 +1613,16 @@ static bool bdrv_pad_request(BlockDriverState *bs,
|
||||
return false;
|
||||
}
|
||||
@@ -1765,6 +1765,10 @@ static int bdrv_pad_request(BlockDriverState *bs,
|
||||
{
|
||||
int ret;
|
||||
|
||||
- qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head,
|
||||
- *qiov, *qiov_offset, *bytes,
|
||||
- pad->buf + pad->buf_len - pad->tail, pad->tail);
|
||||
+ if (*qiov) {
|
||||
+ qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head,
|
||||
+ *qiov, *qiov_offset, *bytes,
|
||||
+ pad->buf + pad->buf_len - pad->tail, pad->tail);
|
||||
+ *qiov = &pad->local_qiov;
|
||||
+ *qiov_offset = 0;
|
||||
+ if (!qiov) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
*bytes += pad->head + pad->tail;
|
||||
*offset -= pad->head;
|
||||
- *qiov = &pad->local_qiov;
|
||||
- *qiov_offset = 0;
|
||||
bdrv_check_qiov_request(*offset, *bytes, *qiov, *qiov_offset, &error_abort);
|
||||
|
||||
return true;
|
||||
}
|
||||
if (!bdrv_init_padding(bs, *offset, *bytes, pad)) {
|
||||
|
@@ -23,18 +23,21 @@ If 'auto-remove' is set, alloc-track will automatically detach itself
|
||||
once the backing image is removed. It will be replaced by 'file'.
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
[adapt to changed function signatures]
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/alloc-track.c | 342 ++++++++++++++++++++++++++++++++++++++++++++
|
||||
block/alloc-track.c | 350 ++++++++++++++++++++++++++++++++++++++++++++
|
||||
block/meson.build | 1 +
|
||||
2 files changed, 343 insertions(+)
|
||||
2 files changed, 351 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..b579380279
|
||||
index 0000000000..6b50fbe537
|
||||
--- /dev/null
|
||||
+++ b/block/alloc-track.c
|
||||
@@ -0,0 +1,345 @@
|
||||
@@ -0,0 +1,350 @@
|
||||
+/*
|
||||
+ * 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
|
||||
@@ -165,7 +168,7 @@ index 0000000000..b579380279
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn track_co_preadv(BlockDriverState *bs,
|
||||
+ uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags)
|
||||
+ int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ BDRVAllocTrackState *s = bs->opaque;
|
||||
+ QEMUIOVector local_qiov;
|
||||
@@ -176,6 +179,11 @@ index 0000000000..b579380279
|
||||
+ int64_t local_bytes;
|
||||
+ bool alloc;
|
||||
+
|
||||
+ if (offset < 0 || bytes < 0) {
|
||||
+ fprintf(stderr, "unexpected negative 'offset' or 'bytes' value!\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ /* a read request can span multiple granularity-sized chunks, and can thus
|
||||
+ * contain blocks with different allocation status - we could just iterate
|
||||
+ * granularity-wise, but for better performance use bdrv_dirty_bitmap_next_X
|
||||
@@ -218,21 +226,21 @@ index 0000000000..b579380279
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn track_co_pwritev(BlockDriverState *bs,
|
||||
+ uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags)
|
||||
+ 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, int count, BdrvRequestFlags flags)
|
||||
+ int64_t offset, int64_t bytes, BdrvRequestFlags flags)
|
||||
+{
|
||||
+ return bdrv_co_pwrite_zeroes(bs->file, offset, count, flags);
|
||||
+ return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
+}
|
||||
+
|
||||
+static int coroutine_fn track_co_pdiscard(BlockDriverState *bs,
|
||||
+ int64_t offset, int count)
|
||||
+ int64_t offset, int64_t bytes)
|
||||
+{
|
||||
+ return bdrv_co_pdiscard(bs->file, offset, count);
|
||||
+ return bdrv_co_pdiscard(bs->file, offset, bytes);
|
||||
+}
|
||||
+
|
||||
+static coroutine_fn int track_co_flush(BlockDriverState *bs)
|
||||
@@ -381,7 +389,7 @@ index 0000000000..b579380279
|
||||
+
|
||||
+block_init(bdrv_alloc_track_init);
|
||||
diff --git a/block/meson.build b/block/meson.build
|
||||
index a070060e53..e387990764 100644
|
||||
index 8c758c0218..45b72e10f1 100644
|
||||
--- a/block/meson.build
|
||||
+++ b/block/meson.build
|
||||
@@ -2,6 +2,7 @@ block_ss.add(genh)
|
||||
|
33
debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
vendored
Normal file
33
debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Wed, 26 May 2021 15:26:30 +0200
|
||||
Subject: [PATCH] PVE: whitelist 'invalid' QAPI names for backwards compat
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
qapi/pragma.json | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/qapi/pragma.json b/qapi/pragma.json
|
||||
index 7c91ea3685..c3888d654c 100644
|
||||
--- a/qapi/pragma.json
|
||||
+++ b/qapi/pragma.json
|
||||
@@ -12,6 +12,7 @@
|
||||
'device_add',
|
||||
'device_del',
|
||||
'expire_password',
|
||||
+ 'get_link_status',
|
||||
'migrate_cancel',
|
||||
'netdev_add',
|
||||
'netdev_del',
|
||||
@@ -60,6 +61,8 @@
|
||||
'SysEmuTarget', # query-cpu-fast, query-target
|
||||
'UuidInfo', # query-uuid
|
||||
'VncClientInfo', # query-vnc, query-vnc-servers, ...
|
||||
- 'X86CPURegister32' # qom-get of x86 CPU properties
|
||||
+ 'X86CPURegister32', # qom-get of x86 CPU properties
|
||||
# feature-words, filtered-features
|
||||
+ 'BlockdevOptionsPbs', # for PBS backwards compat
|
||||
+ 'BalloonInfo'
|
||||
] } }
|
35
debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch
vendored
Normal file
35
debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Date: Wed, 26 May 2021 17:36:55 +0200
|
||||
Subject: [PATCH] PVE: savevm-async: register yank before
|
||||
migration_incoming_state_destroy
|
||||
|
||||
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
migration/savevm-async.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
|
||||
index 970ee3b3fc..b3ccc069f1 100644
|
||||
--- a/migration/savevm-async.c
|
||||
+++ b/migration/savevm-async.c
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "qemu/timer.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/rcu.h"
|
||||
+#include "qemu/yank.h"
|
||||
|
||||
/* #define DEBUG_SAVEVM_STATE */
|
||||
|
||||
@@ -580,6 +581,10 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
|
||||
dirty_bitmap_mig_before_vm_start();
|
||||
|
||||
qemu_fclose(f);
|
||||
+
|
||||
+ /* state_destroy assumes a real migration which would have added a yank */
|
||||
+ yank_register_instance(MIGRATION_YANK_INSTANCE, &error_abort);
|
||||
+
|
||||
migration_incoming_state_destroy();
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Error while loading VM state");
|
130
debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
vendored
Normal file
130
debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Mon, 7 Feb 2022 14:21:01 +0100
|
||||
Subject: [PATCH] qemu-img: dd: add -l option for loading a snapshot
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
docs/tools/qemu-img.rst | 6 +++---
|
||||
qemu-img-cmds.hx | 4 ++--
|
||||
qemu-img.c | 33 +++++++++++++++++++++++++++++++--
|
||||
3 files changed, 36 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
|
||||
index a49badb158..1039aec01c 100644
|
||||
--- a/docs/tools/qemu-img.rst
|
||||
+++ b/docs/tools/qemu-img.rst
|
||||
@@ -492,10 +492,10 @@ Command description:
|
||||
it doesn't need to be specified separately in this case.
|
||||
|
||||
|
||||
-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
|
||||
+.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [-l SNAPSHOT_PARAM] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
|
||||
|
||||
- dd copies from *INPUT* file to *OUTPUT* file converting it from
|
||||
- *FMT* format to *OUTPUT_FMT* format.
|
||||
+ dd copies from *INPUT* file or snapshot *SNAPSHOT_PARAM* to *OUTPUT* file
|
||||
+ converting it from *FMT* format to *OUTPUT_FMT* format.
|
||||
|
||||
The data is by default read and written using blocks of 512 bytes but can be
|
||||
modified by specifying *BLOCK_SIZE*. If count=\ *BLOCKS* is specified
|
||||
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
||||
index f3b2b1b4de..e77ed9347f 100644
|
||||
--- a/qemu-img-cmds.hx
|
||||
+++ b/qemu-img-cmds.hx
|
||||
@@ -58,9 +58,9 @@ SRST
|
||||
ERST
|
||||
|
||||
DEF("dd", img_dd,
|
||||
- "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [-n] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
|
||||
+ "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [-n] [-l snapshot_param] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
|
||||
SRST
|
||||
-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT
|
||||
+.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [-l SNAPSHOT_PARAM] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT
|
||||
ERST
|
||||
|
||||
DEF("info", img_info,
|
||||
diff --git a/qemu-img.c b/qemu-img.c
|
||||
index 015d6d2ce4..7031195e32 100644
|
||||
--- a/qemu-img.c
|
||||
+++ b/qemu-img.c
|
||||
@@ -4922,6 +4922,7 @@ static int img_dd(int argc, char **argv)
|
||||
BlockDriver *drv = NULL, *proto_drv = NULL;
|
||||
BlockBackend *blk1 = NULL, *blk2 = NULL;
|
||||
QemuOpts *opts = NULL;
|
||||
+ QemuOpts *sn_opts = NULL;
|
||||
QemuOptsList *create_opts = NULL;
|
||||
Error *local_err = NULL;
|
||||
bool image_opts = false;
|
||||
@@ -4931,6 +4932,7 @@ static int img_dd(int argc, char **argv)
|
||||
int64_t size = 0, readsize = 0;
|
||||
int64_t block_count = 0, out_pos, in_pos;
|
||||
bool force_share = false, skip_create = false;
|
||||
+ const char *snapshot_name = NULL;
|
||||
struct DdInfo dd = {
|
||||
.flags = 0,
|
||||
.count = 0,
|
||||
@@ -4968,7 +4970,7 @@ static int img_dd(int argc, char **argv)
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
- while ((c = getopt_long(argc, argv, ":hf:O:Un", long_options, NULL))) {
|
||||
+ while ((c = getopt_long(argc, argv, ":hf:O:l:Un", long_options, NULL))) {
|
||||
if (c == EOF) {
|
||||
break;
|
||||
}
|
||||
@@ -4991,6 +4993,19 @@ static int img_dd(int argc, char **argv)
|
||||
case 'n':
|
||||
skip_create = true;
|
||||
break;
|
||||
+ case 'l':
|
||||
+ if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
|
||||
+ sn_opts = qemu_opts_parse_noisily(&internal_snapshot_opts,
|
||||
+ optarg, false);
|
||||
+ if (!sn_opts) {
|
||||
+ error_report("Failed in parsing snapshot param '%s'",
|
||||
+ optarg);
|
||||
+ goto out;
|
||||
+ }
|
||||
+ } else {
|
||||
+ snapshot_name = optarg;
|
||||
+ }
|
||||
+ break;
|
||||
case 'U':
|
||||
force_share = true;
|
||||
break;
|
||||
@@ -5050,11 +5065,24 @@ static int img_dd(int argc, char **argv)
|
||||
if (dd.flags & C_IF) {
|
||||
blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
|
||||
force_share);
|
||||
-
|
||||
if (!blk1) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
+ if (sn_opts) {
|
||||
+ bdrv_snapshot_load_tmp(blk_bs(blk1),
|
||||
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID),
|
||||
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME),
|
||||
+ &local_err);
|
||||
+ } else if (snapshot_name != NULL) {
|
||||
+ bdrv_snapshot_load_tmp_by_id_or_name(blk_bs(blk1), snapshot_name,
|
||||
+ &local_err);
|
||||
+ }
|
||||
+ if (local_err) {
|
||||
+ error_reportf_err(local_err, "Failed to load snapshot: ");
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
}
|
||||
|
||||
if (dd.flags & C_OSIZE) {
|
||||
@@ -5203,6 +5231,7 @@ static int img_dd(int argc, char **argv)
|
||||
out:
|
||||
g_free(arg);
|
||||
qemu_opts_del(opts);
|
||||
+ qemu_opts_del(sn_opts);
|
||||
qemu_opts_free(create_opts);
|
||||
blk_unref(blk1);
|
||||
blk_unref(blk2);
|
407
debian/patches/pve/0051-vma-allow-partial-restore.patch
vendored
Normal file
407
debian/patches/pve/0051-vma-allow-partial-restore.patch
vendored
Normal file
@@ -0,0 +1,407 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Thu, 21 Apr 2022 13:26:48 +0200
|
||||
Subject: [PATCH] vma: allow partial restore
|
||||
|
||||
Introduce a new map line for skipping a certain drive, of the form
|
||||
skip=drive-scsi0
|
||||
|
||||
Since in PVE, most archives are compressed and piped to vma for
|
||||
restore, it's not easily possible to skip reads.
|
||||
|
||||
For the reader, a new skip flag for VmaRestoreState is added and the
|
||||
target is allowed to be NULL if skip is specified when registering. If
|
||||
the skip flag is set, no writes will be made as well as no check for
|
||||
duplicate clusters. Therefore, the flag is not set for verify.
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
vma-reader.c | 64 ++++++++++++---------
|
||||
vma.c | 157 +++++++++++++++++++++++++++++----------------------
|
||||
vma.h | 2 +-
|
||||
3 files changed, 126 insertions(+), 97 deletions(-)
|
||||
|
||||
diff --git a/vma-reader.c b/vma-reader.c
|
||||
index 4f4ee2b47b..844d95a5ba 100644
|
||||
--- a/vma-reader.c
|
||||
+++ b/vma-reader.c
|
||||
@@ -29,6 +29,7 @@ typedef struct VmaRestoreState {
|
||||
bool write_zeroes;
|
||||
unsigned long *bitmap;
|
||||
int bitmap_size;
|
||||
+ bool skip;
|
||||
} VmaRestoreState;
|
||||
|
||||
struct VmaReader {
|
||||
@@ -426,13 +427,14 @@ VmaDeviceInfo *vma_reader_get_device_info(VmaReader *vmar, guint8 dev_id)
|
||||
}
|
||||
|
||||
static void allocate_rstate(VmaReader *vmar, guint8 dev_id,
|
||||
- BlockBackend *target, bool write_zeroes)
|
||||
+ BlockBackend *target, bool write_zeroes, bool skip)
|
||||
{
|
||||
assert(vmar);
|
||||
assert(dev_id);
|
||||
|
||||
vmar->rstate[dev_id].target = target;
|
||||
vmar->rstate[dev_id].write_zeroes = write_zeroes;
|
||||
+ vmar->rstate[dev_id].skip = skip;
|
||||
|
||||
int64_t size = vmar->devinfo[dev_id].size;
|
||||
|
||||
@@ -447,28 +449,30 @@ static void allocate_rstate(VmaReader *vmar, guint8 dev_id,
|
||||
}
|
||||
|
||||
int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id, BlockBackend *target,
|
||||
- bool write_zeroes, Error **errp)
|
||||
+ bool write_zeroes, bool skip, Error **errp)
|
||||
{
|
||||
assert(vmar);
|
||||
- assert(target != NULL);
|
||||
+ assert(target != NULL || skip);
|
||||
assert(dev_id);
|
||||
- assert(vmar->rstate[dev_id].target == NULL);
|
||||
-
|
||||
- int64_t size = blk_getlength(target);
|
||||
- int64_t size_diff = size - vmar->devinfo[dev_id].size;
|
||||
-
|
||||
- /* storage types can have different size restrictions, so it
|
||||
- * is not always possible to create an image with exact size.
|
||||
- * So we tolerate a size difference up to 4MB.
|
||||
- */
|
||||
- if ((size_diff < 0) || (size_diff > 4*1024*1024)) {
|
||||
- error_setg(errp, "vma_reader_register_bs for stream %s failed - "
|
||||
- "unexpected size %zd != %zd", vmar->devinfo[dev_id].devname,
|
||||
- size, vmar->devinfo[dev_id].size);
|
||||
- return -1;
|
||||
+ assert(vmar->rstate[dev_id].target == NULL && !vmar->rstate[dev_id].skip);
|
||||
+
|
||||
+ if (target != NULL) {
|
||||
+ int64_t size = blk_getlength(target);
|
||||
+ int64_t size_diff = size - vmar->devinfo[dev_id].size;
|
||||
+
|
||||
+ /* storage types can have different size restrictions, so it
|
||||
+ * is not always possible to create an image with exact size.
|
||||
+ * So we tolerate a size difference up to 4MB.
|
||||
+ */
|
||||
+ if ((size_diff < 0) || (size_diff > 4*1024*1024)) {
|
||||
+ error_setg(errp, "vma_reader_register_bs for stream %s failed - "
|
||||
+ "unexpected size %zd != %zd", vmar->devinfo[dev_id].devname,
|
||||
+ size, vmar->devinfo[dev_id].size);
|
||||
+ return -1;
|
||||
+ }
|
||||
}
|
||||
|
||||
- allocate_rstate(vmar, dev_id, target, write_zeroes);
|
||||
+ allocate_rstate(vmar, dev_id, target, write_zeroes, skip);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -561,19 +565,23 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
|
||||
VmaRestoreState *rstate = &vmar->rstate[dev_id];
|
||||
BlockBackend *target = NULL;
|
||||
|
||||
+ bool skip = rstate->skip;
|
||||
+
|
||||
if (dev_id != vmar->vmstate_stream) {
|
||||
target = rstate->target;
|
||||
- if (!verify && !target) {
|
||||
+ if (!verify && !target && !skip) {
|
||||
error_setg(errp, "got wrong dev id %d", dev_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
- if (vma_reader_get_bitmap(rstate, cluster_num)) {
|
||||
- error_setg(errp, "found duplicated cluster %zd for stream %s",
|
||||
- cluster_num, vmar->devinfo[dev_id].devname);
|
||||
- return -1;
|
||||
+ if (!skip) {
|
||||
+ if (vma_reader_get_bitmap(rstate, cluster_num)) {
|
||||
+ error_setg(errp, "found duplicated cluster %zd for stream %s",
|
||||
+ cluster_num, vmar->devinfo[dev_id].devname);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ vma_reader_set_bitmap(rstate, cluster_num, 1);
|
||||
}
|
||||
- vma_reader_set_bitmap(rstate, cluster_num, 1);
|
||||
|
||||
max_sector = vmar->devinfo[dev_id].size/BDRV_SECTOR_SIZE;
|
||||
} else {
|
||||
@@ -619,7 +627,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
|
||||
return -1;
|
||||
}
|
||||
|
||||
- if (!verify) {
|
||||
+ if (!verify && !skip) {
|
||||
int nb_sectors = end_sector - sector_num;
|
||||
if (restore_write_data(vmar, dev_id, target, vmstate_fd,
|
||||
buf + start, sector_num, nb_sectors,
|
||||
@@ -655,7 +663,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
|
||||
return -1;
|
||||
}
|
||||
|
||||
- if (!verify) {
|
||||
+ if (!verify && !skip) {
|
||||
int nb_sectors = end_sector - sector_num;
|
||||
if (restore_write_data(vmar, dev_id, target, vmstate_fd,
|
||||
buf + start, sector_num,
|
||||
@@ -680,7 +688,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
|
||||
vmar->partial_zero_cluster_data += zero_size;
|
||||
}
|
||||
|
||||
- if (rstate->write_zeroes && !verify) {
|
||||
+ if (rstate->write_zeroes && !verify && !skip) {
|
||||
if (restore_write_data(vmar, dev_id, target, vmstate_fd,
|
||||
zero_vma_block, sector_num,
|
||||
nb_sectors, errp) < 0) {
|
||||
@@ -851,7 +859,7 @@ int vma_reader_verify(VmaReader *vmar, bool verbose, Error **errp)
|
||||
|
||||
for (dev_id = 1; dev_id < 255; dev_id++) {
|
||||
if (vma_reader_get_device_info(vmar, dev_id)) {
|
||||
- allocate_rstate(vmar, dev_id, NULL, false);
|
||||
+ allocate_rstate(vmar, dev_id, NULL, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/vma.c b/vma.c
|
||||
index 89440733b1..21e765a469 100644
|
||||
--- a/vma.c
|
||||
+++ b/vma.c
|
||||
@@ -138,6 +138,7 @@ typedef struct RestoreMap {
|
||||
char *throttling_group;
|
||||
char *cache;
|
||||
bool write_zero;
|
||||
+ bool skip;
|
||||
} RestoreMap;
|
||||
|
||||
static bool try_parse_option(char **line, const char *optname, char **out, const char *inbuf) {
|
||||
@@ -245,47 +246,61 @@ static int extract_content(int argc, char **argv)
|
||||
char *bps = NULL;
|
||||
char *group = NULL;
|
||||
char *cache = NULL;
|
||||
+ char *devname = NULL;
|
||||
+ bool skip = false;
|
||||
+ uint64_t bps_value = 0;
|
||||
+ const char *path = NULL;
|
||||
+ bool write_zero = true;
|
||||
+
|
||||
if (!line || line[0] == '\0' || !strcmp(line, "done\n")) {
|
||||
break;
|
||||
}
|
||||
int len = strlen(line);
|
||||
if (line[len - 1] == '\n') {
|
||||
line[len - 1] = '\0';
|
||||
- if (len == 1) {
|
||||
+ len = len - 1;
|
||||
+ if (len == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- while (1) {
|
||||
- if (!try_parse_option(&line, "format", &format, inbuf) &&
|
||||
- !try_parse_option(&line, "throttling.bps", &bps, inbuf) &&
|
||||
- !try_parse_option(&line, "throttling.group", &group, inbuf) &&
|
||||
- !try_parse_option(&line, "cache", &cache, inbuf))
|
||||
- {
|
||||
- break;
|
||||
+ if (strncmp(line, "skip", 4) == 0) {
|
||||
+ if (len < 6 || line[4] != '=') {
|
||||
+ g_error("read map failed - option 'skip' has no value ('%s')",
|
||||
+ inbuf);
|
||||
+ } else {
|
||||
+ devname = line + 5;
|
||||
+ skip = true;
|
||||
+ }
|
||||
+ } else {
|
||||
+ while (1) {
|
||||
+ if (!try_parse_option(&line, "format", &format, inbuf) &&
|
||||
+ !try_parse_option(&line, "throttling.bps", &bps, inbuf) &&
|
||||
+ !try_parse_option(&line, "throttling.group", &group, inbuf) &&
|
||||
+ !try_parse_option(&line, "cache", &cache, inbuf))
|
||||
+ {
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
- }
|
||||
|
||||
- uint64_t bps_value = 0;
|
||||
- if (bps) {
|
||||
- bps_value = verify_u64(bps);
|
||||
- g_free(bps);
|
||||
- }
|
||||
+ if (bps) {
|
||||
+ bps_value = verify_u64(bps);
|
||||
+ g_free(bps);
|
||||
+ }
|
||||
|
||||
- const char *path;
|
||||
- bool write_zero;
|
||||
- if (line[0] == '0' && line[1] == ':') {
|
||||
- path = line + 2;
|
||||
- write_zero = false;
|
||||
- } else if (line[0] == '1' && line[1] == ':') {
|
||||
- path = line + 2;
|
||||
- write_zero = true;
|
||||
- } else {
|
||||
- g_error("read map failed - parse error ('%s')", inbuf);
|
||||
+ if (line[0] == '0' && line[1] == ':') {
|
||||
+ path = line + 2;
|
||||
+ write_zero = false;
|
||||
+ } else if (line[0] == '1' && line[1] == ':') {
|
||||
+ path = line + 2;
|
||||
+ write_zero = true;
|
||||
+ } else {
|
||||
+ g_error("read map failed - parse error ('%s')", inbuf);
|
||||
+ }
|
||||
+
|
||||
+ path = extract_devname(path, &devname, -1);
|
||||
}
|
||||
|
||||
- char *devname = NULL;
|
||||
- path = extract_devname(path, &devname, -1);
|
||||
if (!devname) {
|
||||
g_error("read map failed - no dev name specified ('%s')",
|
||||
inbuf);
|
||||
@@ -299,6 +314,7 @@ static int extract_content(int argc, char **argv)
|
||||
map->throttling_group = group;
|
||||
map->cache = cache;
|
||||
map->write_zero = write_zero;
|
||||
+ map->skip = skip;
|
||||
|
||||
g_hash_table_insert(devmap, map->devname, map);
|
||||
|
||||
@@ -328,6 +344,7 @@ static int extract_content(int argc, char **argv)
|
||||
const char *cache = NULL;
|
||||
int flags = BDRV_O_RDWR;
|
||||
bool write_zero = true;
|
||||
+ bool skip = false;
|
||||
|
||||
BlockBackend *blk = NULL;
|
||||
|
||||
@@ -343,6 +360,7 @@ static int extract_content(int argc, char **argv)
|
||||
throttling_group = map->throttling_group;
|
||||
cache = map->cache;
|
||||
write_zero = map->write_zero;
|
||||
+ skip = map->skip;
|
||||
} else {
|
||||
devfn = g_strdup_printf("%s/tmp-disk-%s.raw",
|
||||
dirname, di->devname);
|
||||
@@ -361,57 +379,60 @@ static int extract_content(int argc, char **argv)
|
||||
write_zero = false;
|
||||
}
|
||||
|
||||
- size_t devlen = strlen(devfn);
|
||||
- QDict *options = NULL;
|
||||
- bool writethrough;
|
||||
- if (format) {
|
||||
- /* explicit format from commandline */
|
||||
- options = qdict_new();
|
||||
- qdict_put_str(options, "driver", format);
|
||||
- } else if ((devlen > 4 && strcmp(devfn+devlen-4, ".raw") == 0) ||
|
||||
- strncmp(devfn, "/dev/", 5) == 0)
|
||||
- {
|
||||
- /* This part is now deprecated for PVE as well (just as qemu
|
||||
- * deprecated not specifying an explicit raw format, too.
|
||||
- */
|
||||
- /* explicit raw format */
|
||||
- options = qdict_new();
|
||||
- qdict_put_str(options, "driver", "raw");
|
||||
- }
|
||||
- if (cache && bdrv_parse_cache_mode(cache, &flags, &writethrough)) {
|
||||
- g_error("invalid cache option: %s\n", cache);
|
||||
- }
|
||||
+ if (!skip) {
|
||||
+ size_t devlen = strlen(devfn);
|
||||
+ QDict *options = NULL;
|
||||
+ bool writethrough;
|
||||
+ if (format) {
|
||||
+ /* explicit format from commandline */
|
||||
+ options = qdict_new();
|
||||
+ qdict_put_str(options, "driver", format);
|
||||
+ } else if ((devlen > 4 && strcmp(devfn+devlen-4, ".raw") == 0) ||
|
||||
+ strncmp(devfn, "/dev/", 5) == 0)
|
||||
+ {
|
||||
+ /* This part is now deprecated for PVE as well (just as qemu
|
||||
+ * deprecated not specifying an explicit raw format, too.
|
||||
+ */
|
||||
+ /* explicit raw format */
|
||||
+ options = qdict_new();
|
||||
+ qdict_put_str(options, "driver", "raw");
|
||||
+ }
|
||||
|
||||
- if (errp || !(blk = blk_new_open(devfn, NULL, options, flags, &errp))) {
|
||||
- g_error("can't open file %s - %s", devfn,
|
||||
- error_get_pretty(errp));
|
||||
- }
|
||||
+ if (cache && bdrv_parse_cache_mode(cache, &flags, &writethrough)) {
|
||||
+ g_error("invalid cache option: %s\n", cache);
|
||||
+ }
|
||||
|
||||
- if (cache) {
|
||||
- blk_set_enable_write_cache(blk, !writethrough);
|
||||
- }
|
||||
+ if (errp || !(blk = blk_new_open(devfn, NULL, options, flags, &errp))) {
|
||||
+ g_error("can't open file %s - %s", devfn,
|
||||
+ error_get_pretty(errp));
|
||||
+ }
|
||||
|
||||
- if (throttling_group) {
|
||||
- blk_io_limits_enable(blk, throttling_group);
|
||||
- }
|
||||
+ if (cache) {
|
||||
+ blk_set_enable_write_cache(blk, !writethrough);
|
||||
+ }
|
||||
|
||||
- if (throttling_bps) {
|
||||
- if (!throttling_group) {
|
||||
- blk_io_limits_enable(blk, devfn);
|
||||
+ if (throttling_group) {
|
||||
+ blk_io_limits_enable(blk, throttling_group);
|
||||
}
|
||||
|
||||
- ThrottleConfig cfg;
|
||||
- throttle_config_init(&cfg);
|
||||
- cfg.buckets[THROTTLE_BPS_WRITE].avg = throttling_bps;
|
||||
- Error *err = NULL;
|
||||
- if (!throttle_is_valid(&cfg, &err)) {
|
||||
- error_report_err(err);
|
||||
- g_error("failed to apply throttling");
|
||||
+ if (throttling_bps) {
|
||||
+ if (!throttling_group) {
|
||||
+ blk_io_limits_enable(blk, devfn);
|
||||
+ }
|
||||
+
|
||||
+ ThrottleConfig cfg;
|
||||
+ throttle_config_init(&cfg);
|
||||
+ cfg.buckets[THROTTLE_BPS_WRITE].avg = throttling_bps;
|
||||
+ Error *err = NULL;
|
||||
+ if (!throttle_is_valid(&cfg, &err)) {
|
||||
+ error_report_err(err);
|
||||
+ g_error("failed to apply throttling");
|
||||
+ }
|
||||
+ blk_set_io_limits(blk, &cfg);
|
||||
}
|
||||
- blk_set_io_limits(blk, &cfg);
|
||||
}
|
||||
|
||||
- if (vma_reader_register_bs(vmar, i, blk, write_zero, &errp) < 0) {
|
||||
+ if (vma_reader_register_bs(vmar, i, blk, write_zero, skip, &errp) < 0) {
|
||||
g_error("%s", error_get_pretty(errp));
|
||||
}
|
||||
|
||||
diff --git a/vma.h b/vma.h
|
||||
index c895c97f6d..1b62859165 100644
|
||||
--- a/vma.h
|
||||
+++ b/vma.h
|
||||
@@ -142,7 +142,7 @@ GList *vma_reader_get_config_data(VmaReader *vmar);
|
||||
VmaDeviceInfo *vma_reader_get_device_info(VmaReader *vmar, guint8 dev_id);
|
||||
int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id,
|
||||
BlockBackend *target, bool write_zeroes,
|
||||
- Error **errp);
|
||||
+ bool skip, Error **errp);
|
||||
int vma_reader_restore(VmaReader *vmar, int vmstate_fd, bool verbose,
|
||||
Error **errp);
|
||||
int vma_reader_verify(VmaReader *vmar, bool verbose, Error **errp);
|
233
debian/patches/pve/0052-pbs-namespace-support.patch
vendored
Normal file
233
debian/patches/pve/0052-pbs-namespace-support.patch
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Date: Tue, 26 Apr 2022 16:06:28 +0200
|
||||
Subject: [PATCH] pbs: namespace support
|
||||
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
block/monitor/block-hmp-cmds.c | 1 +
|
||||
block/pbs.c | 25 +++++++++++++++++++++----
|
||||
pbs-restore.c | 19 ++++++++++++++++---
|
||||
pve-backup.c | 6 +++++-
|
||||
qapi/block-core.json | 5 ++++-
|
||||
5 files changed, 47 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
|
||||
index 52ddbf95ad..69c868887a 100644
|
||||
--- a/block/monitor/block-hmp-cmds.c
|
||||
+++ b/block/monitor/block-hmp-cmds.c
|
||||
@@ -1041,6 +1041,7 @@ void coroutine_fn hmp_backup(Monitor *mon, const QDict *qdict)
|
||||
false, NULL, // PBS key_password
|
||||
false, NULL, // PBS master_keyfile
|
||||
false, NULL, // PBS fingerprint
|
||||
+ false, NULL, // PBS backup-ns
|
||||
false, NULL, // PBS backup-id
|
||||
false, 0, // PBS backup-time
|
||||
false, false, // PBS use-dirty-bitmap
|
||||
diff --git a/block/pbs.c b/block/pbs.c
|
||||
index c5eb4d5bad..7471e2ef9d 100644
|
||||
--- a/block/pbs.c
|
||||
+++ b/block/pbs.c
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <proxmox-backup-qemu.h>
|
||||
|
||||
#define PBS_OPT_REPOSITORY "repository"
|
||||
+#define PBS_OPT_NAMESPACE "namespace"
|
||||
#define PBS_OPT_SNAPSHOT "snapshot"
|
||||
#define PBS_OPT_ARCHIVE "archive"
|
||||
#define PBS_OPT_KEYFILE "keyfile"
|
||||
@@ -27,6 +28,7 @@ typedef struct {
|
||||
int64_t length;
|
||||
|
||||
char *repository;
|
||||
+ char *namespace;
|
||||
char *snapshot;
|
||||
char *archive;
|
||||
} BDRVPBSState;
|
||||
@@ -40,6 +42,11 @@ static QemuOptsList runtime_opts = {
|
||||
.type = QEMU_OPT_STRING,
|
||||
.help = "The server address and repository to connect to.",
|
||||
},
|
||||
+ {
|
||||
+ .name = PBS_OPT_NAMESPACE,
|
||||
+ .type = QEMU_OPT_STRING,
|
||||
+ .help = "Optional: The snapshot's namespace.",
|
||||
+ },
|
||||
{
|
||||
.name = PBS_OPT_SNAPSHOT,
|
||||
.type = QEMU_OPT_STRING,
|
||||
@@ -76,7 +83,7 @@ static QemuOptsList runtime_opts = {
|
||||
|
||||
|
||||
// filename format:
|
||||
-// pbs:repository=<repo>,snapshot=<snap>,password=<pw>,key_password=<kpw>,fingerprint=<fp>,archive=<archive>
|
||||
+// pbs:repository=<repo>,namespace=<ns>,snapshot=<snap>,password=<pw>,key_password=<kpw>,fingerprint=<fp>,archive=<archive>
|
||||
static void pbs_parse_filename(const char *filename, QDict *options,
|
||||
Error **errp)
|
||||
{
|
||||
@@ -112,6 +119,7 @@ static int pbs_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
s->archive = g_strdup(qemu_opt_get(opts, PBS_OPT_ARCHIVE));
|
||||
const char *keyfile = qemu_opt_get(opts, PBS_OPT_KEYFILE);
|
||||
const char *password = qemu_opt_get(opts, PBS_OPT_PASSWORD);
|
||||
+ const char *namespace = qemu_opt_get(opts, PBS_OPT_NAMESPACE);
|
||||
const char *fingerprint = qemu_opt_get(opts, PBS_OPT_FINGERPRINT);
|
||||
const char *key_password = qemu_opt_get(opts, PBS_OPT_ENCRYPTION_PASSWORD);
|
||||
|
||||
@@ -124,9 +132,12 @@ static int pbs_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
if (!key_password) {
|
||||
key_password = getenv("PBS_ENCRYPTION_PASSWORD");
|
||||
}
|
||||
+ if (namespace) {
|
||||
+ s->namespace = g_strdup(namespace);
|
||||
+ }
|
||||
|
||||
/* connect to PBS server in read mode */
|
||||
- s->conn = proxmox_restore_new(s->repository, s->snapshot, password,
|
||||
+ s->conn = proxmox_restore_new_ns(s->repository, s->snapshot, s->namespace, password,
|
||||
keyfile, key_password, fingerprint, &pbs_error);
|
||||
|
||||
/* invalidates qemu_opt_get char pointers from above */
|
||||
@@ -171,6 +182,7 @@ static int pbs_file_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
static void pbs_close(BlockDriverState *bs) {
|
||||
BDRVPBSState *s = bs->opaque;
|
||||
g_free(s->repository);
|
||||
+ g_free(s->namespace);
|
||||
g_free(s->snapshot);
|
||||
g_free(s->archive);
|
||||
proxmox_restore_disconnect(s->conn);
|
||||
@@ -252,8 +264,13 @@ static coroutine_fn int pbs_co_pwritev(BlockDriverState *bs,
|
||||
static void pbs_refresh_filename(BlockDriverState *bs)
|
||||
{
|
||||
BDRVPBSState *s = bs->opaque;
|
||||
- snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s/%s(%s)",
|
||||
- s->repository, s->snapshot, s->archive);
|
||||
+ if (s->namespace) {
|
||||
+ snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s/%s:%s(%s)",
|
||||
+ s->repository, s->namespace, s->snapshot, s->archive);
|
||||
+ } else {
|
||||
+ snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s/%s(%s)",
|
||||
+ s->repository, s->snapshot, s->archive);
|
||||
+ }
|
||||
}
|
||||
|
||||
static const char *const pbs_strong_runtime_opts[] = {
|
||||
diff --git a/pbs-restore.c b/pbs-restore.c
|
||||
index 4d3f925a1b..62042bdd93 100644
|
||||
--- a/pbs-restore.c
|
||||
+++ b/pbs-restore.c
|
||||
@@ -30,7 +30,7 @@
|
||||
static void help(void)
|
||||
{
|
||||
const char *help_msg =
|
||||
- "usage: pbs-restore [--repository <repo>] snapshot archive-name target [command options]\n"
|
||||
+ "usage: pbs-restore [--repository <repo>] [--ns namespace] snapshot archive-name target [command options]\n"
|
||||
;
|
||||
|
||||
printf("%s", help_msg);
|
||||
@@ -78,6 +78,7 @@ int main(int argc, char **argv)
|
||||
Error *main_loop_err = NULL;
|
||||
const char *format = "raw";
|
||||
const char *repository = NULL;
|
||||
+ const char *backup_ns = NULL;
|
||||
const char *keyfile = NULL;
|
||||
int verbose = false;
|
||||
bool skip_zero = false;
|
||||
@@ -91,6 +92,7 @@ int main(int argc, char **argv)
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"format", required_argument, 0, 'f'},
|
||||
{"repository", required_argument, 0, 'r'},
|
||||
+ {"ns", required_argument, 0, 'n'},
|
||||
{"keyfile", required_argument, 0, 'k'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
@@ -111,6 +113,9 @@ int main(int argc, char **argv)
|
||||
case 'r':
|
||||
repository = g_strdup(argv[optind - 1]);
|
||||
break;
|
||||
+ case 'n':
|
||||
+ backup_ns = g_strdup(argv[optind - 1]);
|
||||
+ break;
|
||||
case 'k':
|
||||
keyfile = g_strdup(argv[optind - 1]);
|
||||
break;
|
||||
@@ -161,8 +166,16 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "connecting to repository '%s'\n", repository);
|
||||
}
|
||||
char *pbs_error = NULL;
|
||||
- ProxmoxRestoreHandle *conn = proxmox_restore_new(
|
||||
- repository, snapshot, password, keyfile, key_password, fingerprint, &pbs_error);
|
||||
+ ProxmoxRestoreHandle *conn = proxmox_restore_new_ns(
|
||||
+ repository,
|
||||
+ snapshot,
|
||||
+ backup_ns,
|
||||
+ password,
|
||||
+ keyfile,
|
||||
+ key_password,
|
||||
+ fingerprint,
|
||||
+ &pbs_error
|
||||
+ );
|
||||
if (conn == NULL) {
|
||||
fprintf(stderr, "restore failed: %s\n", pbs_error);
|
||||
return -1;
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 9f6c04a512..f6a5f8c785 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qemu/cutils.h"
|
||||
|
||||
+#include <proxmox-backup-qemu.h>
|
||||
+
|
||||
/* PVE backup state and related function */
|
||||
|
||||
/*
|
||||
@@ -535,6 +537,7 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
bool has_key_password, const char *key_password,
|
||||
bool has_master_keyfile, const char *master_keyfile,
|
||||
bool has_fingerprint, const char *fingerprint,
|
||||
+ bool has_backup_ns, const char *backup_ns,
|
||||
bool has_backup_id, const char *backup_id,
|
||||
bool has_backup_time, int64_t backup_time,
|
||||
bool has_use_dirty_bitmap, bool use_dirty_bitmap,
|
||||
@@ -674,8 +677,9 @@ UuidInfo coroutine_fn *qmp_backup(
|
||||
firewall_name = "fw.conf";
|
||||
|
||||
char *pbs_err = NULL;
|
||||
- pbs = proxmox_backup_new(
|
||||
+ pbs = proxmox_backup_new_ns(
|
||||
backup_file,
|
||||
+ has_backup_ns ? backup_ns : NULL,
|
||||
backup_id,
|
||||
backup_time,
|
||||
dump_cb_block_size,
|
||||
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
||||
index d089328a1f..705f0c97ba 100644
|
||||
--- a/qapi/block-core.json
|
||||
+++ b/qapi/block-core.json
|
||||
@@ -821,6 +821,8 @@
|
||||
#
|
||||
# @fingerprint: server cert fingerprint (optional for format 'pbs')
|
||||
#
|
||||
+# @backup-ns: backup namespace (required for format 'pbs')
|
||||
+#
|
||||
# @backup-id: backup ID (required for format 'pbs')
|
||||
#
|
||||
# @backup-time: backup timestamp (Unix epoch, required for format 'pbs')
|
||||
@@ -840,6 +842,7 @@
|
||||
'*key-password': 'str',
|
||||
'*master-keyfile': 'str',
|
||||
'*fingerprint': 'str',
|
||||
+ '*backup-ns': 'str',
|
||||
'*backup-id': 'str',
|
||||
'*backup-time': 'int',
|
||||
'*use-dirty-bitmap': 'bool',
|
||||
@@ -3236,7 +3239,7 @@
|
||||
{ 'struct': 'BlockdevOptionsPbs',
|
||||
'data': { 'repository': 'str', 'snapshot': 'str', 'archive': 'str',
|
||||
'*keyfile': 'str', '*password': 'str', '*fingerprint': 'str',
|
||||
- '*key_password': 'str' } }
|
||||
+ '*key_password': 'str', '*namespace': 'str' } }
|
||||
|
||||
##
|
||||
# @BlockdevOptionsNVMe:
|
161
debian/patches/pve/0053-Revert-block-rbd-implement-bdrv_co_block_status.patch
vendored
Normal file
161
debian/patches/pve/0053-Revert-block-rbd-implement-bdrv_co_block_status.patch
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Tue, 17 May 2022 09:46:02 +0200
|
||||
Subject: [PATCH] Revert "block/rbd: implement bdrv_co_block_status"
|
||||
|
||||
During backup, bdrv_co_block_status is called for each block copy
|
||||
chunk. When RBD is used, the current implementation with
|
||||
rbd_diff_iterate2() using whole_object=true takes about linearly more
|
||||
time, depending on the image size. Since there are linearly more
|
||||
chunks, the slowdown is quadratic, becoming unacceptable for large
|
||||
images (starting somewhere between 500-1000 GiB in my testing).
|
||||
|
||||
This reverts commit 0347a8fd4c3faaedf119be04c197804be40a384b as a
|
||||
stop-gap measure, until it's clear how to make the implemenation
|
||||
more efficient.
|
||||
|
||||
Upstream bug report:
|
||||
https://gitlab.com/qemu-project/qemu/-/issues/1026
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
---
|
||||
block/rbd.c | 112 ----------------------------------------------------
|
||||
1 file changed, 112 deletions(-)
|
||||
|
||||
diff --git a/block/rbd.c b/block/rbd.c
|
||||
index a4b8fb482c..3393b06a4e 100644
|
||||
--- a/block/rbd.c
|
||||
+++ b/block/rbd.c
|
||||
@@ -97,12 +97,6 @@ typedef struct RBDTask {
|
||||
int64_t ret;
|
||||
} RBDTask;
|
||||
|
||||
-typedef struct RBDDiffIterateReq {
|
||||
- uint64_t offs;
|
||||
- uint64_t bytes;
|
||||
- bool exists;
|
||||
-} RBDDiffIterateReq;
|
||||
-
|
||||
static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
||||
BlockdevOptionsRbd *opts, bool cache,
|
||||
const char *keypairs, const char *secretid,
|
||||
@@ -1267,111 +1261,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
|
||||
return spec_info;
|
||||
}
|
||||
|
||||
-/*
|
||||
- * rbd_diff_iterate2 allows to interrupt the exection by returning a negative
|
||||
- * value in the callback routine. Choose a value that does not conflict with
|
||||
- * an existing exitcode and return it if we want to prematurely stop the
|
||||
- * execution because we detected a change in the allocation status.
|
||||
- */
|
||||
-#define QEMU_RBD_EXIT_DIFF_ITERATE2 -9000
|
||||
-
|
||||
-static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
|
||||
- int exists, void *opaque)
|
||||
-{
|
||||
- RBDDiffIterateReq *req = opaque;
|
||||
-
|
||||
- assert(req->offs + req->bytes <= offs);
|
||||
- /*
|
||||
- * we do not diff against a snapshot so we should never receive a callback
|
||||
- * for a hole.
|
||||
- */
|
||||
- assert(exists);
|
||||
-
|
||||
- if (!req->exists && offs > req->offs) {
|
||||
- /*
|
||||
- * we started in an unallocated area and hit the first allocated
|
||||
- * block. req->bytes must be set to the length of the unallocated area
|
||||
- * before the allocated area. stop further processing.
|
||||
- */
|
||||
- req->bytes = offs - req->offs;
|
||||
- return QEMU_RBD_EXIT_DIFF_ITERATE2;
|
||||
- }
|
||||
-
|
||||
- if (req->exists && offs > req->offs + req->bytes) {
|
||||
- /*
|
||||
- * we started in an allocated area and jumped over an unallocated area,
|
||||
- * req->bytes contains the length of the allocated area before the
|
||||
- * unallocated area. stop further processing.
|
||||
- */
|
||||
- return QEMU_RBD_EXIT_DIFF_ITERATE2;
|
||||
- }
|
||||
-
|
||||
- req->bytes += len;
|
||||
- req->exists = true;
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
||||
- bool want_zero, int64_t offset,
|
||||
- int64_t bytes, int64_t *pnum,
|
||||
- int64_t *map,
|
||||
- BlockDriverState **file)
|
||||
-{
|
||||
- BDRVRBDState *s = bs->opaque;
|
||||
- int status, r;
|
||||
- RBDDiffIterateReq req = { .offs = offset };
|
||||
- uint64_t features, flags;
|
||||
-
|
||||
- assert(offset + bytes <= s->image_size);
|
||||
-
|
||||
- /* default to all sectors allocated */
|
||||
- status = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID;
|
||||
- *map = offset;
|
||||
- *file = bs;
|
||||
- *pnum = bytes;
|
||||
-
|
||||
- /* check if RBD image supports fast-diff */
|
||||
- r = rbd_get_features(s->image, &features);
|
||||
- if (r < 0) {
|
||||
- return status;
|
||||
- }
|
||||
- if (!(features & RBD_FEATURE_FAST_DIFF)) {
|
||||
- return status;
|
||||
- }
|
||||
-
|
||||
- /* check if RBD fast-diff result is valid */
|
||||
- r = rbd_get_flags(s->image, &flags);
|
||||
- if (r < 0) {
|
||||
- return status;
|
||||
- }
|
||||
- if (flags & RBD_FLAG_FAST_DIFF_INVALID) {
|
||||
- return status;
|
||||
- }
|
||||
-
|
||||
- r = rbd_diff_iterate2(s->image, NULL, offset, bytes, true, true,
|
||||
- qemu_rbd_diff_iterate_cb, &req);
|
||||
- if (r < 0 && r != QEMU_RBD_EXIT_DIFF_ITERATE2) {
|
||||
- return status;
|
||||
- }
|
||||
- assert(req.bytes <= bytes);
|
||||
- if (!req.exists) {
|
||||
- if (r == 0) {
|
||||
- /*
|
||||
- * rbd_diff_iterate2 does not invoke callbacks for unallocated
|
||||
- * areas. This here catches the case where no callback was
|
||||
- * invoked at all (req.bytes == 0).
|
||||
- */
|
||||
- assert(req.bytes == 0);
|
||||
- req.bytes = bytes;
|
||||
- }
|
||||
- status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
|
||||
- }
|
||||
-
|
||||
- *pnum = req.bytes;
|
||||
- return status;
|
||||
-}
|
||||
-
|
||||
static int64_t qemu_rbd_getlength(BlockDriverState *bs)
|
||||
{
|
||||
BDRVRBDState *s = bs->opaque;
|
||||
@@ -1607,7 +1496,6 @@ static BlockDriver bdrv_rbd = {
|
||||
#ifdef LIBRBD_SUPPORTS_WRITE_ZEROES
|
||||
.bdrv_co_pwrite_zeroes = qemu_rbd_co_pwrite_zeroes,
|
||||
#endif
|
||||
- .bdrv_co_block_status = qemu_rbd_co_block_status,
|
||||
|
||||
.bdrv_snapshot_create = qemu_rbd_snap_create,
|
||||
.bdrv_snapshot_delete = qemu_rbd_snap_remove,
|
59
debian/patches/pve/0054-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
vendored
Normal file
59
debian/patches/pve/0054-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 25 May 2022 13:59:37 +0200
|
||||
Subject: [PATCH] PVE-Backup: create jobs: correctly cancel in error scenario
|
||||
|
||||
The first call to job_cancel_sync() will cancel and free all jobs in
|
||||
the transaction, so ensure that it's called only once and get rid of
|
||||
the job_unref() that would operate on freed memory.
|
||||
|
||||
It's also necessary to NULL backup_state.pbs in the error scenario,
|
||||
because a subsequent backup_cancel QMP call (as happens in PVE when
|
||||
the backup QMP command fails) would try to call proxmox_backup_abort()
|
||||
and run into a segfault.
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 10 ++++++++--
|
||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index f6a5f8c785..5bed6f4014 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -506,6 +506,11 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
}
|
||||
|
||||
if (*errp) {
|
||||
+ /*
|
||||
+ * It's enough to cancel one job in the transaction, the rest will
|
||||
+ * follow automatically.
|
||||
+ */
|
||||
+ bool canceled = false;
|
||||
l = backup_state.di_list;
|
||||
while (l) {
|
||||
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
|
||||
@@ -516,12 +521,12 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
di->target = NULL;
|
||||
}
|
||||
|
||||
- if (di->job) {
|
||||
+ if (!canceled && di->job) {
|
||||
AioContext *ctx = di->job->job.aio_context;
|
||||
aio_context_acquire(ctx);
|
||||
job_cancel_sync(&di->job->job, true);
|
||||
- job_unref(&di->job->job);
|
||||
aio_context_release(ctx);
|
||||
+ canceled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -947,6 +952,7 @@ err:
|
||||
|
||||
if (pbs) {
|
||||
proxmox_backup_disconnect(pbs);
|
||||
+ backup_state.pbs = NULL;
|
||||
}
|
||||
|
||||
if (backup_dir) {
|
76
debian/patches/pve/0055-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
vendored
Normal file
76
debian/patches/pve/0055-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Date: Wed, 25 May 2022 13:59:38 +0200
|
||||
Subject: [PATCH] PVE-Backup: ensure jobs in di_list are referenced
|
||||
|
||||
Ensures that qmp_backup_cancel doesn't pick a job that's already been
|
||||
freed. With unlucky timings it seems possible that:
|
||||
1. job_exit -> job_completed -> job_finalize_single starts
|
||||
2. pvebackup_co_complete_stream gets spawned in completion callback
|
||||
3. job finalize_single finishes -> job's refcount hits zero -> job is
|
||||
freed
|
||||
4. qmp_backup_cancel comes in and locks backup_state.backup_mutex
|
||||
before pvebackup_co_complete_stream can remove the job from the
|
||||
di_list
|
||||
5. qmp_backup_cancel will pick a job that's already been freed
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
---
|
||||
pve-backup.c | 25 ++++++++++++++++++++-----
|
||||
1 file changed, 20 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 5bed6f4014..0c34428713 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -316,6 +316,14 @@ static void coroutine_fn pvebackup_co_complete_stream(void *opaque)
|
||||
}
|
||||
}
|
||||
|
||||
+ if (di->job) {
|
||||
+ AioContext *ctx = di->job->job.aio_context;
|
||||
+ aio_context_acquire(ctx);
|
||||
+ job_unref(&di->job->job);
|
||||
+ di->job = NULL;
|
||||
+ aio_context_release(ctx);
|
||||
+ }
|
||||
+
|
||||
// remove self from job list
|
||||
backup_state.di_list = g_list_remove(backup_state.di_list, di);
|
||||
|
||||
@@ -491,9 +499,12 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
bitmap_mode, false, NULL, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||
JOB_DEFAULT, pvebackup_complete_cb, di, backup_state.txn, &local_err);
|
||||
|
||||
- aio_context_release(aio_context);
|
||||
-
|
||||
di->job = job;
|
||||
+ if (job) {
|
||||
+ job_ref(&job->job);
|
||||
+ }
|
||||
+
|
||||
+ aio_context_release(aio_context);
|
||||
|
||||
if (!job || local_err) {
|
||||
error_setg(errp, "backup_job_create failed: %s",
|
||||
@@ -521,12 +532,16 @@ static void create_backup_jobs_bh(void *opaque) {
|
||||
di->target = NULL;
|
||||
}
|
||||
|
||||
- if (!canceled && di->job) {
|
||||
+ if (di->job) {
|
||||
AioContext *ctx = di->job->job.aio_context;
|
||||
aio_context_acquire(ctx);
|
||||
- job_cancel_sync(&di->job->job, true);
|
||||
+ if (!canceled) {
|
||||
+ job_cancel_sync(&di->job->job, true);
|
||||
+ canceled = true;
|
||||
+ }
|
||||
+ job_unref(&di->job->job);
|
||||
+ di->job = NULL;
|
||||
aio_context_release(ctx);
|
||||
- canceled = true;
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user