5 files changed, 145 insertions(+), 29 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index 3c4ab1159d..f2eca983f1 100644
+index 251adc5ae0..8ead5f77a0 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -51,7 +51,7 @@ typedef struct MirrorBlockJob {
BdrvDirtyBitmap *dirty_bitmap;
BdrvDirtyBitmapIter *dbi;
uint8_t *buf;
-@@ -696,7 +698,8 @@ static int mirror_exit_common(Job *job)
+@@ -699,7 +701,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) {
BlockDriverState *unfiltered_target = bdrv_skip_filters(target_bs);
if (bdrv_cow_bs(unfiltered_target) != backing) {
-@@ -794,6 +797,16 @@ static void mirror_abort(Job *job)
+@@ -797,6 +800,16 @@ static void mirror_abort(Job *job)
assert(ret == 0);
}
static void coroutine_fn mirror_throttle(MirrorBlockJob *s)
{
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
-@@ -973,7 +986,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
+@@ -977,7 +990,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);
ret = mirror_dirty_init(s);
if (ret < 0 || job_is_cancelled(&s->common.job)) {
goto immediate_exit;
-@@ -1212,6 +1226,7 @@ static const BlockJobDriver mirror_job_driver = {
+@@ -1224,6 +1238,7 @@ static const BlockJobDriver mirror_job_driver = {
.run = mirror_run,
.prepare = mirror_prepare,
.abort = mirror_abort,
.pause = mirror_pause,
.complete = mirror_complete,
.cancel = mirror_cancel,
-@@ -1228,6 +1243,7 @@ static const BlockJobDriver commit_active_job_driver = {
+@@ -1240,6 +1255,7 @@ static const BlockJobDriver commit_active_job_driver = {
.run = mirror_run,
.prepare = mirror_prepare,
.abort = mirror_abort,
.pause = mirror_pause,
.complete = mirror_complete,
.cancel = commit_active_cancel,
-@@ -1593,7 +1609,10 @@ static BlockJob *mirror_start_job(
+@@ -1627,7 +1643,10 @@ static BlockJob *mirror_start_job(
BlockCompletionFunc *cb,
void *opaque,
const BlockJobDriver *driver,
bool auto_complete, const char *filter_node_name,
bool is_mirror, MirrorCopyMode copy_mode,
Error **errp)
-@@ -1605,10 +1624,39 @@ static BlockJob *mirror_start_job(
+@@ -1639,10 +1658,39 @@ static BlockJob *mirror_start_job(
uint64_t target_perms, target_shared_perms;
int ret;
assert(is_power_of_2(granularity));
if (buf_size < 0) {
-@@ -1740,7 +1788,9 @@ static BlockJob *mirror_start_job(
+@@ -1774,7 +1822,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;
s->backing_mode = backing_mode;
s->zero_target = zero_target;
s->copy_mode = copy_mode;
-@@ -1761,6 +1811,18 @@ static BlockJob *mirror_start_job(
+@@ -1795,6 +1845,18 @@ static BlockJob *mirror_start_job(
bdrv_disable_dirty_bitmap(s->dirty_bitmap);
}
ret = block_job_add_bdrv(&s->common, "source", bs, 0,
BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE |
BLK_PERM_CONSISTENT_READ,
-@@ -1838,6 +1900,9 @@ fail:
+@@ -1872,6 +1934,9 @@ fail:
if (s->dirty_bitmap) {
bdrv_release_dirty_bitmap(s->dirty_bitmap);
}
job_early_fail(&s->common.job);
}
-@@ -1855,31 +1920,25 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
+@@ -1889,31 +1954,25 @@ 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,
}
BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
-@@ -1906,7 +1965,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
+@@ -1940,7 +1999,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,
errp);
if (!job) {
diff --git a/blockdev.c b/blockdev.c
-index 9230888e34..9a1a3118ed 100644
+index 3f1dec6242..2ee30323cb 100644
--- a/blockdev.c
+++ b/blockdev.c
-@@ -2951,6 +2951,10 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -2946,6 +2946,10 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
BlockDriverState *target,
bool has_replaces, const char *replaces,
enum MirrorSyncMode sync,
BlockMirrorBackingMode backing_mode,
bool zero_target,
bool has_speed, int64_t speed,
-@@ -2970,6 +2974,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -2965,6 +2969,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
{
BlockDriverState *unfiltered_bs;
int job_flags = JOB_DEFAULT;
if (!has_speed) {
speed = 0;
-@@ -3024,6 +3029,29 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -3019,6 +3024,29 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
sync = MIRROR_SYNC_MODE_FULL;
}
if (!has_replaces) {
/* We want to mirror from @bs, but keep implicit filters on top */
unfiltered_bs = bdrv_skip_implicit_filters(bs);
-@@ -3070,8 +3098,8 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -3065,8 +3093,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,
on_source_error, on_target_error, unmap, filter_node_name,
copy_mode, errp);
}
-@@ -3216,6 +3244,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
+@@ -3211,6 +3239,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,
backing_mode, zero_target,
arg->has_speed, arg->speed,
arg->has_granularity, arg->granularity,
-@@ -3237,6 +3267,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
+@@ -3232,6 +3262,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,
bool has_speed, int64_t speed,
bool has_granularity, uint32_t granularity,
bool has_buf_size, int64_t buf_size,
-@@ -3286,7 +3318,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
+@@ -3281,7 +3313,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,
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 2173e7734a..e1857e7094 100644
+index 95ac4fa634..7daaf545be 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2000,10 +2000,19 @@
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
-index 8b55eccc89..f4650be8e5 100644
+index 8ca5adec5e..dae80e5a5f 100644
--- a/tests/unit/test-block-iothread.c
+++ b/tests/unit/test-block-iothread.c
-@@ -753,8 +753,8 @@ static void test_propagate_mirror(void)
+@@ -755,8 +755,8 @@ static void test_propagate_mirror(void)
/* Start a mirror job */
mirror_start("job0", src, target, NULL, JOB_DEFAULT, 0, 0, 0,
+ false, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
false, "filter_node", MIRROR_COPY_MODE_BACKGROUND,
&error_abort);
- job = job_get("job0");
+ WITH_JOB_LOCK_GUARD() {
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index f2eca983f1..b6475d50ad 100644
+index 8ead5f77a0..35c1b8f25d 100644
--- a/block/mirror.c
+++ b/block/mirror.c
-@@ -673,8 +673,6 @@ static int mirror_exit_common(Job *job)
+@@ -676,8 +676,6 @@ static int mirror_exit_common(Job *job)
bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs);
}
/* Make sure that the source BDS doesn't go away during bdrv_replace_node,
* before we can call bdrv_drained_end */
bdrv_ref(src);
-@@ -775,6 +773,18 @@ static int mirror_exit_common(Job *job)
+@@ -778,6 +776,18 @@ static int mirror_exit_common(Job *job)
block_job_remove_all_bdrv(bjob);
bdrv_replace_node(mirror_top_bs, mirror_top_bs->backing->bs, &error_abort);
bs_opaque->job = NULL;
bdrv_drained_end(src);
-@@ -1634,10 +1644,6 @@ static BlockJob *mirror_start_job(
+@@ -1668,10 +1678,6 @@ static BlockJob *mirror_start_job(
" sync mode",
MirrorSyncMode_str(sync_mode));
return NULL;
}
} else if (bitmap) {
error_setg(errp,
-@@ -1654,6 +1660,12 @@ static BlockJob *mirror_start_job(
+@@ -1688,6 +1694,12 @@ static BlockJob *mirror_start_job(
return NULL;
}
granularity = bdrv_dirty_bitmap_granularity(bitmap);
1 file changed, 3 insertions(+)
diff --git a/blockdev.c b/blockdev.c
-index 9a1a3118ed..a57b0af2e7 100644
+index 2ee30323cb..dd1c2cdef7 100644
--- a/blockdev.c
+++ b/blockdev.c
-@@ -3050,6 +3050,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -3045,6 +3045,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) {
return;
}
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index b6475d50ad..8b3342f9ec 100644
+index 35c1b8f25d..4969c6833c 100644
--- a/block/mirror.c
+++ b/block/mirror.c
-@@ -779,8 +779,8 @@ static int mirror_exit_common(Job *job)
+@@ -782,8 +782,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);
}
}
bdrv_release_dirty_bitmap(s->dirty_bitmap);
-@@ -1828,11 +1828,8 @@ static BlockJob *mirror_start_job(
+@@ -1862,11 +1862,8 @@ static BlockJob *mirror_start_job(
}
if (s->sync_mode == MIRROR_SYNC_MODE_BITMAP) {
3 files changed, 70 insertions(+), 59 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index 8b3342f9ec..1d4ff0efad 100644
+index 4969c6833c..cf85ae1074 100644
--- a/block/mirror.c
+++ b/block/mirror.c
-@@ -1634,31 +1634,13 @@ static BlockJob *mirror_start_job(
+@@ -1668,31 +1668,13 @@ static BlockJob *mirror_start_job(
uint64_t target_perms, target_shared_perms;
int ret;
if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
diff --git a/blockdev.c b/blockdev.c
-index a57b0af2e7..ce62a9b439 100644
+index dd1c2cdef7..756e980889 100644
--- a/blockdev.c
+++ b/blockdev.c
-@@ -3029,7 +3029,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -3024,7 +3024,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
sync = MIRROR_SYNC_MODE_FULL;
}
6 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
-index a4b40e8391..d64ae8f34e 100644
+index 737e750670..38804b8595 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -16,6 +16,7 @@ extern QemuOptsList qemu_mon_opts;
void monitor_init_globals(void);
void monitor_init_globals_core(void);
diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
-index caa2e90ef2..e1596f79ab 100644
+index a2cdbbf646..b531bd50e7 100644
--- a/monitor/monitor-internal.h
+++ b/monitor/monitor-internal.h
@@ -152,6 +152,13 @@ typedef struct {
+++ /dev/null
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Sam Li <faithilikerun@gmail.com>
-Date: Sat, 24 Sep 2022 22:48:15 +0800
-Subject: [PATCH] block/io_uring: revert "Use io_uring_register_ring_fd() to
- skip fd operations"
-
-Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1193
-
-The commit "Use io_uring_register_ring_fd() to skip fd operations" broke
-when booting a guest with iothread and io_uring. That is because the
-io_uring_register_ring_fd() call is made from the main thread instead of
-IOThread where io_uring_submit() is called. It can not be guaranteed
-to register the ring fd in the correct thread or unregister the same ring
-fd if the IOThread is disabled. This optimization is not critical so we
-will revert previous commit.
-
-This reverts commit e2848bc574fe2715c694bf8fe9a1ba7f78a1125a
-and 77e3f038af1764983087e3551a0fde9951952c4d.
-
-Signed-off-by: Sam Li <faithilikerun@gmail.com>
----
- block/io_uring.c | 13 +------------
- meson.build | 1 -
- 2 files changed, 1 insertion(+), 13 deletions(-)
-
-diff --git a/block/io_uring.c b/block/io_uring.c
-index a1760152e0..973e15d876 100644
---- a/block/io_uring.c
-+++ b/block/io_uring.c
-@@ -11,7 +11,6 @@
- #include "qemu/osdep.h"
- #include <liburing.h>
- #include "block/aio.h"
--#include "qemu/error-report.h"
- #include "qemu/queue.h"
- #include "block/block.h"
- #include "block/raw-aio.h"
-@@ -19,7 +18,6 @@
- #include "qapi/error.h"
- #include "trace.h"
-
--
- /* io_uring ring size */
- #define MAX_ENTRIES 128
-
-@@ -432,17 +430,8 @@ LuringState *luring_init(Error **errp)
- }
-
- ioq_init(&s->io_q);
--#ifdef CONFIG_LIBURING_REGISTER_RING_FD
-- if (io_uring_register_ring_fd(&s->ring) < 0) {
-- /*
-- * Only warn about this error: we will fallback to the non-optimized
-- * io_uring operations.
-- */
-- warn_report("failed to register linux io_uring ring file descriptor");
-- }
--#endif
--
- return s;
-+
- }
-
- void luring_cleanup(LuringState *s)
-diff --git a/meson.build b/meson.build
-index 20fddbd707..d5230eadd6 100644
---- a/meson.build
-+++ b/meson.build
-@@ -1793,7 +1793,6 @@ config_host_data.set('CONFIG_LIBNFS', libnfs.found())
- config_host_data.set('CONFIG_LIBSSH', libssh.found())
- config_host_data.set('CONFIG_LINUX_AIO', libaio.found())
- config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
--config_host_data.set('CONFIG_LIBURING_REGISTER_RING_FD', cc.has_function('io_uring_register_ring_fd', prefix: '#include <liburing.h>', dependencies:linux_io_uring))
- config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
- config_host_data.set('CONFIG_NUMA', numa.found())
- config_host_data.set('CONFIG_OPENGL', opengl.found())
--- /dev/null
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Fiona Ebner <f.ebner@proxmox.com>
+Date: Fri, 28 Oct 2022 10:09:46 +0200
+Subject: [PATCH] init: daemonize: defuse PID file resolve error
+
+When proxmox-file-restore invokes QEMU, the PID file is a (temporary)
+file that's already unlinked, so resolving the absolute path here
+failed.
+
+It should not be a critical error when the PID file unlink handler
+can't be registered, because the path can't be resolved for whatever
+reason. If the file is already gone from QEMU's perspective (i.e.
+errno is ENOENT), silently ignore the error. Otherwise, print a
+warning.
+
+Reported-by: Dominik Csapak <d.csapak@proxmox.com>
+Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
+---
+ softmmu/vl.c | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/softmmu/vl.c b/softmmu/vl.c
+index 5115221efe..5f7f6ca981 100644
+--- a/softmmu/vl.c
++++ b/softmmu/vl.c
+@@ -2460,10 +2460,11 @@ static void qemu_maybe_daemonize(const char *pid_file)
+
+ pid_file_realpath = g_malloc0(PATH_MAX);
+ if (!realpath(pid_file, pid_file_realpath)) {
+- error_report("cannot resolve PID file path: %s: %s",
+- pid_file, strerror(errno));
+- unlink(pid_file);
+- exit(1);
++ if (errno != ENOENT) {
++ warn_report("not removing PID file on exit: cannot resolve PID "
++ "file path: %s: %s", pid_file, strerror(errno));
++ }
++ return;
+ }
+
+ qemu_unlink_pidfile_notifier = (struct UnlinkPidfileNotifier) {
+++ /dev/null
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
-Date: Thu, 18 Aug 2022 14:46:19 -0400
-Subject: [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
-
-The "%f" specifier in g_date_time_format() is only available in glib
-2.65.2 or later. If combined with older glib, the function returns null
-and the timestamp displayed as "(null)".
-
-For backward compatibility, g_date_time_get_microsecond should be used
-to retrieve subsecond.
-
-In this patch the g_date_time_format() leaves subsecond field as "%06d"
-and let next snprintf to format with g_date_time_get_microsecond.
-
-Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
-Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
-Message-id: 20220818184618.2205172-1-yokada.996@gmail.com
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-(cherry-picked from commit f16d15c9276bd8f501f861c39cbd4adc812d0c1d)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- tools/virtiofsd/passthrough_ll.c | 7 +++++--
- 1 file changed, 5 insertions(+), 2 deletions(-)
-
-diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
-index 371a7bead6..20f0f41f99 100644
---- a/tools/virtiofsd/passthrough_ll.c
-+++ b/tools/virtiofsd/passthrough_ll.c
-@@ -4185,6 +4185,7 @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile)
- static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
- {
- g_autofree char *localfmt = NULL;
-+ char buf[64];
-
- if (current_log_level < level) {
- return;
-@@ -4197,9 +4198,11 @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
- fmt);
- } else {
- g_autoptr(GDateTime) now = g_date_time_new_now_utc();
-- g_autofree char *nowstr = g_date_time_format(now, "%Y-%m-%d %H:%M:%S.%f%z");
-+ g_autofree char *nowstr = g_date_time_format(now,
-+ "%Y-%m-%d %H:%M:%S.%%06d%z");
-+ snprintf(buf, 64, nowstr, g_date_time_get_microsecond(now));
- localfmt = g_strdup_printf("[%s] [ID: %08ld] %s",
-- nowstr, syscall(__NR_gettid), fmt);
-+ buf, syscall(__NR_gettid), fmt);
- }
- fmt = localfmt;
- }
+++ /dev/null
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Maksim Davydov <davydov-max@yandex-team.ru>
-Date: Thu, 25 Aug 2022 19:52:47 +0300
-Subject: [PATCH] chardev: fix segfault in finalize
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-If finalize chardev-msmouse or chardev-wctable is called immediately after
-init it cases QEMU to crash with segfault. This happens because of
-QTAILQ_REMOVE in qemu_input_handler_unregister tries to dereference
-NULL pointer.
-For instance, this error can be reproduced via `qom-list-properties`
-command.
-
-Signed-off-by: Maksim Davydov <davydov-max@yandex-team.ru>
-Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
-Message-Id: <20220825165247.33704-1-davydov-max@yandex-team.ru>
-(trivial backport from fc0c128531ed55f058bfbad4f1348ebd9a0187f2)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- chardev/msmouse.c | 4 +++-
- chardev/wctablet.c | 4 +++-
- 2 files changed, 6 insertions(+), 2 deletions(-)
-
-diff --git a/chardev/msmouse.c b/chardev/msmouse.c
-index eb9231dcdb..2cc1b16561 100644
---- a/chardev/msmouse.c
-+++ b/chardev/msmouse.c
-@@ -146,7 +146,9 @@ static void char_msmouse_finalize(Object *obj)
- {
- MouseChardev *mouse = MOUSE_CHARDEV(obj);
-
-- qemu_input_handler_unregister(mouse->hs);
-+ if (mouse->hs) {
-+ qemu_input_handler_unregister(mouse->hs);
-+ }
- }
-
- static QemuInputHandler msmouse_handler = {
-diff --git a/chardev/wctablet.c b/chardev/wctablet.c
-index e8b292c43c..43bdf6b608 100644
---- a/chardev/wctablet.c
-+++ b/chardev/wctablet.c
-@@ -319,7 +319,9 @@ static void wctablet_chr_finalize(Object *obj)
- {
- TabletChardev *tablet = WCTABLET_CHARDEV(obj);
-
-- qemu_input_handler_unregister(tablet->hs);
-+ if (tablet->hs) {
-+ qemu_input_handler_unregister(tablet->hs);
-+ }
- }
-
- static void wctablet_chr_open(Chardev *chr,
+++ /dev/null
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Fiona Ebner <f.ebner@proxmox.com>
-Date: Fri, 28 Oct 2022 10:09:46 +0200
-Subject: [PATCH] init: daemonize: defuse PID file resolve error
-
-When proxmox-file-restore invokes QEMU, the PID file is a (temporary)
-file that's already unlinked, so resolving the absolute path here
-failed.
-
-It should not be a critical error when the PID file unlink handler
-can't be registered, because the path can't be resolved for whatever
-reason. If the file is already gone from QEMU's perspective (i.e.
-errno is ENOENT), silently ignore the error. Otherwise, print a
-warning.
-
-Reported-by: Dominik Csapak <d.csapak@proxmox.com>
-Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- softmmu/vl.c | 9 +++++----
- 1 file changed, 5 insertions(+), 4 deletions(-)
-
-diff --git a/softmmu/vl.c b/softmmu/vl.c
-index 706bd7cff7..3381c56af7 100644
---- a/softmmu/vl.c
-+++ b/softmmu/vl.c
-@@ -2438,10 +2438,11 @@ static void qemu_maybe_daemonize(const char *pid_file)
-
- pid_file_realpath = g_malloc0(PATH_MAX);
- if (!realpath(pid_file, pid_file_realpath)) {
-- error_report("cannot resolve PID file path: %s: %s",
-- pid_file, strerror(errno));
-- unlink(pid_file);
-- exit(1);
-+ if (errno != ENOENT) {
-+ warn_report("not removing PID file on exit: cannot resolve PID "
-+ "file path: %s: %s", pid_file, strerror(errno));
-+ }
-+ return;
- }
-
- qemu_unlink_pidfile_notifier = (struct UnlinkPidfileNotifier) {
+++ /dev/null
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
-Date: Thu, 27 Oct 2022 03:27:26 -0400
-Subject: [PATCH] block/block-backend: blk_set_enable_write_cache is IO_CODE
-
-blk_set_enable_write_cache() is defined as GLOBAL_STATE_CODE
-but can be invoked from iothreads when handling scsi requests.
-This triggers an assertion failure:
-
- 0x00007fd6c3515ce1 in raise () from /lib/x86_64-linux-gnu/libc.so.6
- 0x00007fd6c34ff537 in abort () from /lib/x86_64-linux-gnu/libc.so.6
- 0x00007fd6c34ff40f in ?? () from /lib/x86_64-linux-gnu/libc.so.6
- 0x00007fd6c350e662 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
- 0x000056149e2cea03 in blk_set_enable_write_cache (wce=true, blk=0x5614a01c27f0)
- at ../src/block/block-backend.c:1949
- 0x000056149e2d0a67 in blk_set_enable_write_cache (blk=0x5614a01c27f0,
- wce=<optimized out>) at ../src/block/block-backend.c:1951
- 0x000056149dfe9c59 in scsi_disk_apply_mode_select (p=0x7fd6b400c00e "\004",
- page=<optimized out>, s=<optimized out>) at ../src/hw/scsi/scsi-disk.c:1520
- mode_select_pages (change=true, len=18, p=0x7fd6b400c00e "\004", r=0x7fd6b4001ff0)
- at ../src/hw/scsi/scsi-disk.c:1570
- scsi_disk_emulate_mode_select (inbuf=<optimized out>, r=0x7fd6b4001ff0) at
- ../src/hw/scsi/scsi-disk.c:1640
- scsi_disk_emulate_write_data (req=0x7fd6b4001ff0) at ../src/hw/scsi/scsi-disk.c:1934
- 0x000056149e18ff16 in virtio_scsi_handle_cmd_req_submit (req=<optimized out>,
- req=<optimized out>, s=0x5614a12f16b0) at ../src/hw/scsi/virtio-scsi.c:719
- virtio_scsi_handle_cmd_vq (vq=0x7fd6bab92140, s=0x5614a12f16b0) at
- ../src/hw/scsi/virtio-scsi.c:761
- virtio_scsi_handle_cmd (vq=<optimized out>, vdev=<optimized out>) at
- ../src/hw/scsi/virtio-scsi.c:775
- virtio_scsi_handle_cmd (vdev=0x5614a12f16b0, vq=0x7fd6bab92140) at
- ../src/hw/scsi/virtio-scsi.c:765
- 0x000056149e1a8aa6 in virtio_queue_notify_vq (vq=0x7fd6bab92140) at
- ../src/hw/virtio/virtio.c:2365
- 0x000056149e3ccea5 in aio_dispatch_handler (ctx=ctx@entry=0x5614a01babe0,
- node=<optimized out>) at ../src/util/aio-posix.c:369
- 0x000056149e3cd868 in aio_dispatch_ready_handlers (ready_list=0x7fd6c09b2680,
- ctx=0x5614a01babe0) at ../src/util/aio-posix.c:399
- aio_poll (ctx=0x5614a01babe0, blocking=blocking@entry=true) at
- ../src/util/aio-posix.c:713
- 0x000056149e2a7796 in iothread_run (opaque=opaque@entry=0x56149ffde500) at
- ../src/iothread.c:67
- 0x000056149e3d0859 in qemu_thread_start (args=0x7fd6c09b26f0) at
- ../src/util/qemu-thread-posix.c:504
- 0x00007fd6c36b9ea7 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
- 0x00007fd6c35d9aef in clone () from /lib/x86_64-linux-gnu/libc.so.6
-
-Changing GLOBAL_STATE_CODE in IO_CODE is allowed, since GSC callers are
-allowed to call IO_CODE.
-
-Resolves: #1272
-
-Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
-Message-Id: <20221027072726.2681500-1-eesposit@redhat.com>
-Reviewed-by: Kevin Wolf <kwolf@redhat.com>
-Reviewed-by: Hanna Reitz <hreitz@redhat.com>
-Tested-by: Antoine Damhet <antoine.damhet@shadow.tech>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry picked from commit be8da05b5ed8fb546731b9edb997f303f272bad8)
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- block/block-backend.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/block/block-backend.c b/block/block-backend.c
-index d4a5df2ac2..1b563e628b 100644
---- a/block/block-backend.c
-+++ b/block/block-backend.c
-@@ -1946,7 +1946,7 @@ bool blk_enable_write_cache(BlockBackend *blk)
-
- void blk_set_enable_write_cache(BlockBackend *blk, bool wce)
- {
-- GLOBAL_STATE_CODE();
-+ IO_CODE();
- blk->enable_write_cache = wce;
- }
-
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
-index 48cd096624..3d60b80286 100644
+index b9647c5ffc..9a16d86344 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
-@@ -553,7 +553,7 @@ static QemuOptsList raw_runtime_opts = {
+@@ -552,7 +552,7 @@ static QemuOptsList raw_runtime_opts = {
{
.name = "locking",
.type = QEMU_OPT_STRING,
},
{
.name = "pr-manager",
-@@ -653,7 +653,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:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/net.h b/include/net/net.h
-index 523136c7ac..c27859b4f6 100644
+index dc20b31e9f..5ae04a8693 100644
--- a/include/net/net.h
+++ b/include/net/net.h
-@@ -226,8 +226,8 @@ void netdev_add(QemuOpts *opts, Error **errp);
+@@ -236,8 +236,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);
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
-index 82004b65b9..4868db8f94 100644
+index d4bc19577a..be7da64f38 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
-@@ -2133,9 +2133,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
+@@ -2174,9 +2174,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
#define CPU_RESOLVING_TYPE TYPE_X86_CPU
#ifdef TARGET_X86_64
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/block/gluster.c b/block/gluster.c
-index b60213ab80..93da76bc31 100644
+index 7c90f7ba4b..2e03102f00 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -42,7 +42,7 @@
3 files changed, 43 insertions(+)
diff --git a/net/net.c b/net/net.c
-index 2db160e063..8329347891 100644
+index 840ad9dca5..28e97c5d85 100644
--- a/net/net.c
+++ b/net/net.c
-@@ -1343,6 +1343,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
+@@ -1372,6 +1372,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
}
}
{
NetClientState *nc;
diff --git a/qapi/net.json b/qapi/net.json
-index 75ba2cb989..a3c93ab88f 100644
+index 522ac582ed..327d7c5a37 100644
--- a/qapi/net.json
+++ b/qapi/net.json
-@@ -35,6 +35,21 @@
+@@ -36,6 +36,21 @@
##
{ 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/block/gluster.c b/block/gluster.c
-index 93da76bc31..1079b6186b 100644
+index 2e03102f00..7886c5fe8c 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -57,6 +57,7 @@ typedef struct GlusterAIOCB {
ret = glfs_preadv_async(s->fd, qiov->iov, qiov->niov, offset, 0,
gluster_finish_aiocb, &acb);
}
-@@ -1269,6 +1275,7 @@ static coroutine_fn int qemu_gluster_co_flush_to_disk(BlockDriverState *bs)
+@@ -1268,6 +1274,7 @@ static coroutine_fn int qemu_gluster_co_flush_to_disk(BlockDriverState *bs)
acb.ret = 0;
acb.coroutine = qemu_coroutine_self();
acb.aio_context = bdrv_get_aio_context(bs);
ret = glfs_fsync_async(s->fd, gluster_finish_aiocb, &acb);
if (ret < 0) {
-@@ -1317,6 +1324,7 @@ static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs,
+@@ -1316,6 +1323,7 @@ static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs,
acb.ret = 0;
acb.coroutine = qemu_coroutine_self();
acb.aio_context = bdrv_get_aio_context(bs);
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/qemu-img.c b/qemu-img.c
-index 7d4b33b3da..bb36f42dd2 100644
+index a9b3a8103c..0bc9f1af59 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -3010,7 +3010,8 @@ static int img_info(int argc, char **argv)
+@@ -3013,7 +3013,8 @@ static int img_info(int argc, char **argv)
list = collect_image_info_list(image_opts, filename, fmt, chain,
force_share);
if (!list) {
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index bb36f42dd2..74afcb79ef 100644
+index 0bc9f1af59..221b9d6a16 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4826,10 +4826,12 @@ static int img_bitmap(int argc, char **argv)
+@@ -4829,10 +4829,12 @@ static int img_bitmap(int argc, char **argv)
#define C_IF 04
#define C_OF 010
#define C_SKIP 020
};
struct DdIo {
-@@ -4905,6 +4907,19 @@ static int img_dd_skip(const char *arg,
+@@ -4908,6 +4910,19 @@ static int img_dd_skip(const char *arg,
return 0;
}
static int img_dd(int argc, char **argv)
{
int ret = 0;
-@@ -4945,6 +4960,7 @@ static int img_dd(int argc, char **argv)
+@@ -4948,6 +4963,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 },
{ NULL, NULL, 0 }
};
const struct option long_options[] = {
-@@ -5020,91 +5036,112 @@ static int img_dd(int argc, char **argv)
+@@ -5023,91 +5039,112 @@ static int img_dd(int argc, char **argv)
arg = NULL;
}
}
if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
-@@ -5121,20 +5158,43 @@ static int img_dd(int argc, char **argv)
+@@ -5124,20 +5161,43 @@ static int img_dd(int argc, char **argv)
in.buf = g_new(uint8_t, in.bsz);
- for (out_pos = 0; in_pos < size; block_count++) {
+ for (out_pos = 0; in_pos < size; ) {
+ int in_ret, out_ret;
int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz;
-
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
-index 74afcb79ef..14594d44b6 100644
+index 221b9d6a16..c1306385a8 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4827,11 +4827,13 @@ static int img_bitmap(int argc, char **argv)
+@@ -4830,11 +4830,13 @@ static int img_bitmap(int argc, char **argv)
#define C_OF 010
#define C_SKIP 020
#define C_OSIZE 040
};
struct DdIo {
-@@ -4920,6 +4922,19 @@ static int img_dd_osize(const char *arg,
+@@ -4923,6 +4925,19 @@ static int img_dd_osize(const char *arg,
return 0;
}
static int img_dd(int argc, char **argv)
{
int ret = 0;
-@@ -4934,12 +4949,14 @@ static int img_dd(int argc, char **argv)
+@@ -4937,12 +4952,14 @@ static int img_dd(int argc, char **argv)
int c, i;
const char *out_fmt = "raw";
const char *fmt = NULL;
- int64_t size = 0;
+ int64_t size = 0, readsize = 0;
- int64_t block_count = 0, out_pos, in_pos;
+ int64_t out_pos, in_pos;
bool force_share = false;
struct DdInfo dd = {
.flags = 0,
};
struct DdIo in = {
.bsz = 512, /* Block size is by default 512 bytes */
-@@ -4961,6 +4978,7 @@ static int img_dd(int argc, char **argv)
+@@ -4964,6 +4981,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 },
{ NULL, NULL, 0 }
};
const struct option long_options[] = {
-@@ -5157,9 +5175,10 @@ static int img_dd(int argc, char **argv)
+@@ -5160,9 +5178,10 @@ static int img_dd(int argc, char **argv)
in.buf = g_new(uint8_t, in.bsz);
-- for (out_pos = 0; in_pos < size; block_count++) {
+- for (out_pos = 0; in_pos < size; ) {
+ readsize = (dd.isize > 0) ? dd.isize : size;
-+ for (out_pos = 0; in_pos < readsize; block_count++) {
++ for (out_pos = 0; in_pos < readsize; ) {
int in_ret, out_ret;
- int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz;
+ int bytes = (in_pos + in.bsz > readsize) ? readsize - in_pos : in.bsz;
if (blk1) {
in_ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
if (in_ret == 0) {
-@@ -5168,6 +5187,9 @@ static int img_dd(int argc, char **argv)
+@@ -5171,6 +5190,9 @@ static int img_dd(int argc, char **argv)
} else {
in_ret = read(STDIN_FILENO, in.buf, bytes);
if (in_ret == 0) {
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
[FE: fix getopt-string + add documentation]
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
docs/tools/qemu-img.rst | 11 ++++++++++-
qemu-img-cmds.hx | 4 ++--
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
-index 85a6e05b35..699229eef6 100644
+index 15aeddc6d8..5e713e231d 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -208,6 +208,10 @@ Parameters to convert subcommand:
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index 14594d44b6..c6b4a5567d 100644
+index c1306385a8..59c403373b 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4951,7 +4951,7 @@ static int img_dd(int argc, char **argv)
+@@ -4954,7 +4954,7 @@ static int img_dd(int argc, char **argv)
const char *fmt = NULL;
int64_t size = 0, readsize = 0;
- int64_t block_count = 0, out_pos, in_pos;
+ int64_t out_pos, in_pos;
- bool force_share = false;
+ bool force_share = false, skip_create = false;
struct DdInfo dd = {
.flags = 0,
.count = 0,
-@@ -4989,7 +4989,7 @@ static int img_dd(int argc, char **argv)
+@@ -4992,7 +4992,7 @@ static int img_dd(int argc, char **argv)
{ 0, 0, 0, 0 }
};
if (c == EOF) {
break;
}
-@@ -5009,6 +5009,9 @@ static int img_dd(int argc, char **argv)
+@@ -5012,6 +5012,9 @@ static int img_dd(int argc, char **argv)
case 'h':
help();
break;
case 'U':
force_share = true;
break;
-@@ -5139,13 +5142,15 @@ static int img_dd(int argc, char **argv)
+@@ -5142,13 +5145,15 @@ static int img_dd(int argc, char **argv)
size - in.bsz * in.offset, &error_abort);
}
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 c6cd6f91dd..15572befb1 100644
+index 01b789a79e..480b798963 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -715,7 +715,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
+@@ -696,7 +696,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
return;
}
qapi_free_BalloonInfo(info);
}
diff --git a/qapi/machine.json b/qapi/machine.json
-index 6afd1936b0..8b4be9b718 100644
+index b9228a5e46..10e77a9af3 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1054,9 +1054,29 @@
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 8b4be9b718..555458f785 100644
+index 10e77a9af3..9156103c8f 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -138,6 +138,8 @@
2 files changed, 8 insertions(+)
diff --git a/qapi/ui.json b/qapi/ui.json
-index cf58ab4283..0be2388941 100644
+index 0abba3e930..bf8f441227 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -310,11 +310,14 @@
create mode 100644 migration/savevm-async.c
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
-index 188d9ece3b..97b88eaaad 100644
+index 754b1e8408..489c524e9e 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
-@@ -538,6 +538,19 @@ SRST
+@@ -540,6 +540,19 @@ SRST
Show current migration parameters.
ERST
.name = "balloon",
.args_type = "",
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 182e639d14..bbcc73e942 100644
+index 673e39a697..039be0033d 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
-@@ -1800,3 +1800,36 @@ ERST
- "\n\t\t\t\t\t limit on a specified virtual cpu",
- .cmd = hmp_cancel_vcpu_dirty_limit,
- },
+@@ -1815,3 +1815,36 @@ SRST
+ Dump the FDT in dtb format to *filename*.
+ ERST
+ #endif
+
+ {
+ .name = "savevm-start",
+
#endif
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
-index a618eb1e4e..55067beff1 100644
+index dfbc0c9a2f..440f86aba8 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
-@@ -26,6 +26,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
+@@ -27,6 +27,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);
void hmp_info_migrate(Monitor *mon, const QDict *qdict);
void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict);
-@@ -80,6 +81,10 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict);
+@@ -81,6 +82,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);
+void hmp_delete_drive_snapshot(Monitor *mon, const QDict *qdict);
+void hmp_savevm_end(Monitor *mon, const QDict *qdict);
void hmp_sendkey(Monitor *mon, const QDict *qdict);
- void hmp_screendump(Monitor *mon, const QDict *qdict);
+ void coroutine_fn hmp_screendump(Monitor *mon, const QDict *qdict);
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
diff --git a/migration/meson.build b/migration/meson.build
index 8cac83c06c..0842d00cd2 100644
+ return ret;
+}
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index 15572befb1..1507180990 100644
+index 480b798963..cfebfd1db5 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -1925,6 +1925,63 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
+@@ -1906,6 +1906,63 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, err);
}
{
IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
diff --git a/qapi/migration.json b/qapi/migration.json
-index 81185d4311..3129f71fa8 100644
+index 88ecf86ac8..4435866379 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -261,6 +261,40 @@
# @CommandLineParameterType:
#
diff --git a/qemu-options.hx b/qemu-options.hx
-index 31c04f7eea..c2ca6e91b5 100644
+index 7f99d15b23..54efb127c4 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
-@@ -4341,6 +4341,18 @@ SRST
+@@ -4391,6 +4391,18 @@ SRST
Start right away with a saved state (``loadvm`` in monitor)
ERST
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 706bd7cff7..b8637c4262 100644
+index 5f7f6ca981..21f067d115 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -165,6 +165,7 @@ static const char *accelerators;
+@@ -164,6 +164,7 @@ static const char *accelerators;
static bool have_custom_ram_size;
static const char *ram_memdev_id;
static QDict *machine_opts_dict;
static QTAILQ_HEAD(, ObjectOption) object_opts = QTAILQ_HEAD_INITIALIZER(object_opts);
static QTAILQ_HEAD(, DeviceOption) device_opts = QTAILQ_HEAD_INITIALIZER(device_opts);
static int display_remote;
-@@ -2584,6 +2585,12 @@ void qmp_x_exit_preconfig(Error **errp)
+@@ -2607,6 +2608,12 @@ void qmp_x_exit_preconfig(Error **errp)
if (loadvm) {
load_snapshot(loadvm, NULL, false, NULL, &error_fatal);
}
if (replay_mode != REPLAY_MODE_NONE) {
replay_vmstate_init();
-@@ -3133,6 +3140,9 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3151,6 +3158,9 @@ void qemu_init(int argc, char **argv)
case QEMU_OPTION_loadvm:
loadvm = optarg;
break;
3 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
-index 4f400c2e52..21e8998867 100644
+index 2d5f74ffc2..9fd97e6fe1 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -31,8 +31,8 @@
DECLARE_BITMAP(may_free, MAX_IOV_SIZE);
struct iovec iov[MAX_IOV_SIZE];
-@@ -106,7 +107,9 @@ bool qemu_file_mode_is_not_valid(const char *mode)
+@@ -127,7 +128,9 @@ bool qemu_file_mode_is_not_valid(const char *mode)
return false;
}
{
QEMUFile *f;
-@@ -115,6 +118,8 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
+@@ -136,6 +139,8 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
object_ref(ioc);
f->ioc = ioc;
f->is_writable = is_writable;
return f;
}
-@@ -125,17 +130,27 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
+@@ -146,17 +151,27 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
*/
QEMUFile *qemu_file_get_return_path(QEMUFile *f)
{
}
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks)
-@@ -393,7 +408,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
+@@ -414,7 +429,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
do {
len = qio_channel_read(f->ioc,
(char *)f->buf + pending,
&local_error);
if (len == QIO_CHANNEL_ERR_BLOCK) {
if (qemu_in_coroutine()) {
-@@ -443,6 +458,8 @@ int qemu_fclose(QEMUFile *f)
+@@ -464,6 +479,8 @@ int qemu_fclose(QEMUFile *f)
}
g_clear_pointer(&f->ioc, object_unref);
/* If any error was spotted before closing, we should report it
* instead of the close() return value.
*/
-@@ -497,7 +514,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
+@@ -518,7 +535,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;
qemu_fflush(f);
}
}
-@@ -523,7 +540,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
+@@ -544,7 +561,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
}
while (size > 0) {
if (l > size) {
l = size;
}
-@@ -570,8 +587,8 @@ size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset)
+@@ -591,8 +608,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));
/* The 1st byte to read from */
index = f->buf_index + offset;
-@@ -621,7 +638,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
+@@ -642,7 +659,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
size_t res;
uint8_t *src;
if (res == 0) {
return done;
}
-@@ -655,7 +672,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
+@@ -676,7 +693,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)
{
size_t res;
uint8_t *src = NULL;
-@@ -680,7 +697,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
+@@ -701,7 +718,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
int index = f->buf_index + offset;
assert(!qemu_file_is_writable(f));
if (index >= f->buf_size) {
qemu_fill_buffer(f);
-@@ -832,7 +849,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
+@@ -853,7 +870,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
ssize_t qemu_put_compression_data(QEMUFile *f, z_stream *stream,
const uint8_t *p, size_t size)
{
int qemu_fclose(QEMUFile *f);
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
-index b3692739a0..e65a5e3482 100644
+index 05d394c0e2..bafe6ae5eb 100644
--- a/migration/savevm-async.c
+++ b/migration/savevm-async.c
@@ -367,7 +367,7 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp)
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
block/meson.build | 1 +
- block/zeroinit.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 197 insertions(+)
+ block/zeroinit.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 199 insertions(+)
create mode 100644 block/zeroinit.c
diff --git a/block/meson.build b/block/meson.build
-index 60bc305597..ad40c10b6a 100644
+index b7c68b83a3..020a89ae07 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -43,6 +43,7 @@ block_ss.add(files(
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..20ee611f22
+index 0000000000..b60e1b84dc
--- /dev/null
+++ b/block/zeroinit.c
-@@ -0,0 +1,196 @@
+@@ -0,0 +1,198 @@
+/*
+ * Filter to fake a zero-initialized block device.
+ *
+
+ /* Open the raw file */
+ bs->file = bdrv_open_child(qemu_opt_get(opts, "x-next"), options, "next",
-+ bs, &child_of_bds, BDRV_CHILD_FILTERED, false, &local_err);
++ bs, &child_of_bds,
++ BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
++ false, &local_err);
+ if (local_err) {
+ ret = -EINVAL;
+ error_propagate(errp, local_err);
2 files changed, 11 insertions(+)
diff --git a/qemu-options.hx b/qemu-options.hx
-index c2ca6e91b5..ab4734ef32 100644
+index 54efb127c4..ef456d03ec 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
-@@ -1118,6 +1118,9 @@ backend describes how QEMU handles the data.
+@@ -1147,6 +1147,9 @@ backend describes how QEMU handles the data.
ERST
"-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 b8637c4262..39f149924e 100644
+index 21f067d115..9d737e7914 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -2620,6 +2620,7 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -2643,6 +2643,7 @@ void qemu_init(int argc, char **argv)
MachineClass *machine_class;
bool userconfig = true;
FILE *vmstate_dump_file = NULL;
qemu_add_opts(&qemu_drive_opts);
qemu_add_drive_opts(&qemu_legacy_drive_opts);
-@@ -3245,6 +3246,13 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3263,6 +3264,13 @@ void qemu_init(int argc, char **argv)
machine_parse_property_opt(qemu_find_opts("smp-opts"),
"smp", optarg);
break;
2 files changed, 42 insertions(+), 20 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
-index 3d60b80286..49ee1db5f9 100644
+index 9a16d86344..bd68df57ad 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
-@@ -2475,6 +2475,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2487,6 +2487,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
int fd;
uint64_t perm, shared;
int result = 0;
/* Validate options and set default values */
assert(options->driver == BLOCKDEV_DRIVER_FILE);
-@@ -2515,19 +2516,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2527,19 +2528,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
perm = BLK_PERM_WRITE | BLK_PERM_RESIZE;
shared = BLK_PERM_ALL & ~BLK_PERM_RESIZE;
}
/* Clear the file by truncating it to 0 */
-@@ -2581,13 +2585,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2593,13 +2597,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
}
out_unlock:
}
out_close:
-@@ -2612,6 +2618,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2624,6 +2630,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
PreallocMode prealloc;
char *buf = NULL;
Error *local_err = NULL;
/* Skip file: protocol prefix */
strstart(filename, "file:", &filename);
-@@ -2634,6 +2641,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2646,6 +2653,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
return -EINVAL;
}
options = (BlockdevCreateOptions) {
.driver = BLOCKDEV_DRIVER_FILE,
.u.file = {
-@@ -2645,6 +2664,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2657,6 +2676,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,
};
return raw_co_create(&options, errp);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index e1857e7094..ddac91e8f6 100644
+index 7daaf545be..9e902b96bb 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -4537,7 +4537,8 @@
+@@ -4624,7 +4624,8 @@
'size': 'size',
'*preallocation': 'PreallocMode',
'*nocow': 'bool',
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
-index a673302cce..fa424440bd 100644
+index 8d34caa31d..2df9037c4e 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
-@@ -127,7 +127,8 @@ GlobalProperty hw_compat_4_0[] = {
+@@ -132,7 +132,8 @@ GlobalProperty hw_compat_4_0[] = {
{ "virtio-vga", "edid", "false" },
{ "virtio-gpu-device", "edid", "false" },
{ "virtio-device", "use-started", "false" },
if (mc->default_cpu_type) {
diff --git a/include/hw/boards.h b/include/hw/boards.h
-index 7b416c9787..8ae15c51aa 100644
+index 90f1dd3aeb..14d60520d9 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -230,6 +230,8 @@ struct MachineClass {
+ const char *pve_version;
+
void (*init)(MachineState *state);
- void (*reset)(MachineState *state);
+ void (*reset)(MachineState *state, ShutdownCause reason);
void (*wakeup)(MachineState *state);
diff --git a/qapi/machine.json b/qapi/machine.json
-index 555458f785..d868e4d31d 100644
+index 9156103c8f..f4fb1b2c9c 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -157,6 +157,8 @@
##
# @query-machines:
diff --git a/softmmu/vl.c b/softmmu/vl.c
-index 39f149924e..0d233d55f3 100644
+index 9d737e7914..a64eee2fad 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -1580,6 +1580,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
+@@ -1578,6 +1578,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");
GSList *machines = object_class_get_list(TYPE_MACHINE, false);
MachineClass *machine_class;
Error *local_err = NULL;
-@@ -1597,6 +1598,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
+@@ -1595,6 +1596,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
}
}
g_slist_free(machines);
if (local_err) {
error_append_hint(&local_err, "Use -machine help to list supported machines\n");
-@@ -3187,12 +3193,31 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3205,12 +3211,31 @@ void qemu_init(int argc, char **argv)
case QEMU_OPTION_machine:
{
bool help;
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/backup.c b/block/backup.c
-index b2b649e305..b6fa9e8a69 100644
+index 6a9ad97a53..9b0151c5be 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -237,8 +237,8 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
create mode 100644 vma.h
diff --git a/block/meson.build b/block/meson.build
-index ad40c10b6a..3a0b84bc11 100644
+index 020a89ae07..4feae20e37 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -46,6 +46,8 @@ block_ss.add(files(
+block_ss.add(files('../vma-writer.c'), libuuid)
+
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
+ softmmu_ss.add(files('block-ram-registrar.c'))
- if get_option('qcow1').allowed()
diff --git a/meson.build b/meson.build
-index d5230eadd6..ffff66c0cc 100644
+index 5c6b5a1c75..e8cf7e3d78 100644
--- a/meson.build
+++ b/meson.build
-@@ -1462,6 +1462,8 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1525,6 +1525,8 @@ keyutils = dependency('libkeyutils', required: false,
has_gettid = cc.has_function('gettid')
# libselinux
selinux = dependency('libselinux',
required: get_option('selinux'),
-@@ -3607,6 +3609,9 @@ if have_tools
+@@ -3596,6 +3598,9 @@ if have_tools
dependencies: [blockdev, qemuutil, gnutls, selinux],
install: true)
+ return bs;
+}
diff --git a/block/backup.c b/block/backup.c
-index b6fa9e8a69..789f8b7799 100644
+index 9b0151c5be..6e8f6e67b3 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -29,28 +29,6 @@
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 3a0b84bc11..7f22e7f177 100644
+index 4feae20e37..0d7023fc82 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -4,6 +4,7 @@ block_ss.add(files(
'blkdebug.c',
'blklogwrites.c',
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
-index 8947abab76..f272d0d8dc 100644
+index 31ae91e56e..37b64bcd93 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -26,6 +26,7 @@
BDRV_TRACKED_READ,
BDRV_TRACKED_WRITE,
diff --git a/job.c b/job.c
-index 075c6f3a20..e5699ad200 100644
+index 72d57f0934..93e22d180b 100644
--- a/job.c
+++ b/job.c
-@@ -276,7 +276,8 @@ static bool job_started(Job *job)
- return job->co;
+@@ -330,7 +330,8 @@ static bool job_started_locked(Job *job)
}
--static bool job_should_pause(Job *job)
-+bool job_should_pause(Job *job);
-+bool job_should_pause(Job *job)
+ /* Called with job_mutex held. */
+-static bool job_should_pause_locked(Job *job)
++bool job_should_pause_locked(Job *job);
++bool job_should_pause_locked(Job *job)
{
return job->pause_count > 0;
}
[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>
+[FE: add new force parameter to job_cancel_sync calls
+ adapt for new job lock mechanism replacing AioContext locks]
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
block/meson.build | 5 +
block/monitor/block-hmp-cmds.c | 33 ++
monitor/hmp-cmds.c | 44 ++
proxmox-backup-client.c | 176 ++++++
proxmox-backup-client.h | 59 ++
- pve-backup.c | 959 +++++++++++++++++++++++++++++++++
+ pve-backup.c | 956 +++++++++++++++++++++++++++++++++
qapi/block-core.json | 109 ++++
qapi/common.json | 13 +
qapi/machine.json | 15 +-
- 14 files changed, 1448 insertions(+), 13 deletions(-)
+ 14 files changed, 1445 insertions(+), 13 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 7f22e7f177..2783b77e9c 100644
+index 0d7023fc82..e995ae72b9 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -48,6 +48,11 @@ block_ss.add(files(
+
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
-
+ softmmu_ss.add(files('block-ram-registrar.c'))
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index bfb3c043a0..89ca64444d 100644
+index b6135e9bfe..477044c54a 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1015,3 +1015,36 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
+ hmp_handle_error(mon, error);
+}
diff --git a/blockdev.c b/blockdev.c
-index ce62a9b439..1600b24eab 100644
+index 756e980889..bc8d67b290 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -36,6 +36,7 @@
#include "monitor/monitor.h"
#include "qemu/error-report.h"
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
-index 97b88eaaad..92a8867afb 100644
+index 489c524e9e..bc1d46d845 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
-@@ -484,6 +484,20 @@ SRST
+@@ -486,6 +486,20 @@ SRST
Show the current VM UUID.
ERST
{
.name = "usernet",
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index bbcc73e942..97f24942b3 100644
+index 039be0033d..fcf9461295 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -101,6 +101,35 @@ ERST
{
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
-index 55067beff1..5a98d2d927 100644
+index 440f86aba8..350527e599 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
-@@ -30,6 +30,7 @@ void hmp_info_savevm(Monitor *mon, const QDict *qdict);
+@@ -31,6 +31,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_cpus(Monitor *mon, const QDict *qdict);
void hmp_info_vnc(Monitor *mon, const QDict *qdict);
void hmp_info_spice(Monitor *mon, const QDict *qdict);
-@@ -73,6 +74,8 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict);
+@@ -74,6 +75,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);
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 ffff66c0cc..0bc2fb5b10 100644
+index e8cf7e3d78..782756162c 100644
--- a/meson.build
+++ b/meson.build
-@@ -1463,6 +1463,7 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1526,6 +1526,7 @@ keyutils = dependency('libkeyutils', required: false,
has_gettid = cc.has_function('gettid')
libuuid = cc.find_library('uuid', required: true)
# libselinux
selinux = dependency('libselinux',
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index 1507180990..1168773da7 100644
+index cfebfd1db5..a40b25e906 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -197,6 +197,50 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
+@@ -199,6 +199,50 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
qapi_free_MouseInfoList(mice_list);
}
+ qapi_free_BackupStatus(info);
+}
+
- static char *SocketAddress_to_str(SocketAddress *addr)
+ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
{
- switch (addr->type) {
+ MigrationInfo *info;
diff --git a/proxmox-backup-client.c b/proxmox-backup-client.c
new file mode 100644
index 0000000000..a8f6653a81
+#endif /* PROXMOX_BACKUP_CLIENT_H */
diff --git a/pve-backup.c b/pve-backup.c
new file mode 100644
-index 0000000000..88f5ee133f
+index 0000000000..3d28975eaa
--- /dev/null
+++ b/pve-backup.c
-@@ -0,0 +1,959 @@
+@@ -0,0 +1,956 @@
+#include "proxmox-backup-client.h"
+#include "vma.h"
+
+lookup_active_block_job(PVEBackupDevInfo *di)
+{
+ if (!di->completed && di->bs) {
-+ for (BlockJob *job = block_job_next(NULL); job; job = block_job_next(job)) {
-+ if (job->job.driver->job_type != JOB_TYPE_BACKUP) {
-+ continue;
-+ }
++ WITH_JOB_LOCK_GUARD() {
++ for (BlockJob *job = block_job_next_locked(NULL); job; job = block_job_next_locked(job)) {
++ if (job->job.driver->job_type != JOB_TYPE_BACKUP) {
++ continue;
++ }
+
-+ BackupBlockJob *bjob = container_of(job, BackupBlockJob, common);
-+ if (bjob && bjob->source_bs == di->bs) {
-+ return job;
++ BackupBlockJob *bjob = container_of(job, BackupBlockJob, common);
++ if (bjob && bjob->source_bs == di->bs) {
++ return job;
++ }
+ }
+ }
+ }
+ qemu_mutex_unlock(&backup_state.backup_mutex);
+
+ if (next_job) {
-+ AioContext *aio_context = next_job->job.aio_context;
-+ aio_context_acquire(aio_context);
+ job_cancel_sync(&next_job->job, true);
-+ aio_context_release(aio_context);
+ } else {
+ break;
+ }
+ goto out;
+}
+
-+bool job_should_pause(Job *job);
++bool job_should_pause_locked(Job *job);
+
+static void pvebackup_run_next_job(void)
+{
+ if (job) {
+ qemu_mutex_unlock(&backup_state.backup_mutex);
+
-+ AioContext *aio_context = job->job.aio_context;
-+ aio_context_acquire(aio_context);
-+
-+ if (job_should_pause(&job->job)) {
-+ bool error_or_canceled = pvebackup_error_or_canceled();
-+ if (error_or_canceled) {
-+ job_cancel_sync(&job->job, true);
-+ } else {
-+ job_resume(&job->job);
++ WITH_JOB_LOCK_GUARD() {
++ if (job_should_pause_locked(&job->job)) {
++ bool error_or_canceled = pvebackup_error_or_canceled();
++ if (error_or_canceled) {
++ job_cancel_sync_locked(&job->job, true);
++ } else {
++ job_resume_locked(&job->job);
++ }
+ }
+ }
-+ aio_context_release(aio_context);
+ return;
+ }
+ }
+ return info;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index ddac91e8f6..90ad07b7ee 100644
+index 9e902b96bb..c3b6b93472 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -740,6 +740,115 @@
+##
+{ 'struct': 'UuidInfo', 'data': {'UUID': 'str'} }
diff --git a/qapi/machine.json b/qapi/machine.json
-index d868e4d31d..a63d9a078d 100644
+index f4fb1b2c9c..0d6ee836ed 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -4,6 +4,8 @@
create mode 100644 pbs-restore.c
diff --git a/meson.build b/meson.build
-index 0bc2fb5b10..f48d2e0457 100644
+index 782756162c..63ea813a9a 100644
--- a/meson.build
+++ b/meson.build
-@@ -3613,6 +3613,10 @@ if have_tools
+@@ -3602,6 +3602,10 @@ if have_tools
vma = executable('vma', files('vma.c', 'vma-reader.c') + genh,
dependencies: [authz, block, crypto, io, qom], install: true)
6 files changed, 142 insertions(+), 23 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index 89ca64444d..45da74d7a0 100644
+index 477044c54a..556af25861 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1042,6 +1042,7 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
false, NULL, false, NULL, !!devlist,
devlist, qdict_haskey(qdict, "speed"), speed, &error);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index 1168773da7..4c1671e289 100644
+index a40b25e906..670f783515 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -223,19 +223,42 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
+@@ -225,19 +225,42 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "End time: %s", ctime(&info->end_time));
}
diff --git a/pve-backup.c b/pve-backup.c
-index 88f5ee133f..1c49cd178d 100644
+index 3d28975eaa..abd7062afe 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -28,6 +28,8 @@
BlockDriverState *target;
} PVEBackupDevInfo;
-@@ -105,11 +110,12 @@ static bool pvebackup_error_or_canceled(void)
+@@ -107,11 +112,12 @@ static bool pvebackup_error_or_canceled(void)
return error_or_canceled;
}
qemu_mutex_unlock(&backup_state.stat.lock);
}
-@@ -148,7 +154,8 @@ pvebackup_co_dump_pbs_cb(
+@@ -150,7 +156,8 @@ pvebackup_co_dump_pbs_cb(
pvebackup_propagate_error(local_err);
return pbs_res;
} else {
}
return size;
-@@ -208,11 +215,11 @@ pvebackup_co_dump_vma_cb(
+@@ -210,11 +217,11 @@ pvebackup_co_dump_vma_cb(
} else {
if (remaining >= VMA_CLUSTER_SIZE) {
assert(ret == VMA_CLUSTER_SIZE);
remaining = 0;
}
}
-@@ -248,6 +255,18 @@ static void coroutine_fn pvebackup_co_cleanup(void *unused)
+@@ -250,6 +257,18 @@ static void coroutine_fn pvebackup_co_cleanup(void *unused)
if (local_err != NULL) {
pvebackup_propagate_error(local_err);
}
}
proxmox_backup_disconnect(backup_state.pbs);
-@@ -303,6 +322,12 @@ static void pvebackup_complete_cb(void *opaque, int ret)
+@@ -305,6 +324,12 @@ static void pvebackup_complete_cb(void *opaque, int ret)
// remove self from job queue
backup_state.di_list = g_list_remove(backup_state.di_list, di);
g_free(di);
qemu_mutex_unlock(&backup_state.backup_mutex);
-@@ -472,12 +497,18 @@ static bool create_backup_jobs(void) {
+@@ -469,12 +494,18 @@ static bool create_backup_jobs(void) {
assert(di->target != NULL);
JOB_DEFAULT, pvebackup_complete_cb, di, NULL, &local_err);
aio_context_release(aio_context);
-@@ -528,6 +559,8 @@ typedef struct QmpBackupTask {
+@@ -525,6 +556,8 @@ typedef struct QmpBackupTask {
const char *fingerprint;
bool has_fingerprint;
int64_t backup_time;
bool has_format;
BackupFormat format;
bool has_config_file;
-@@ -619,6 +652,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -616,6 +649,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
}
size_t total = 0;
l = di_list;
while (l) {
-@@ -656,6 +690,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -653,6 +687,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";
char *pbs_err = NULL;
pbs = proxmox_backup_new(
task->backup_file,
-@@ -675,7 +711,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -672,7 +708,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
goto err;
}
goto err;
/* register all devices */
-@@ -686,9 +723,40 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -683,9 +720,40 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
const char *devname = bdrv_get_device_name(di->bs);
if (!(di->target = bdrv_backup_dump_create(dump_cb_block_size, di->size, pvebackup_co_dump_pbs_cb, di, task->errp))) {
goto err;
-@@ -697,6 +765,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -694,6 +762,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
di->dev_id = dev_id;
}
} else if (format == BACKUP_FORMAT_VMA) {
vmaw = vma_writer_create(task->backup_file, uuid, &local_err);
if (!vmaw) {
if (local_err) {
-@@ -724,6 +794,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -721,6 +791,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
}
}
} else if (format == BACKUP_FORMAT_DIR) {
if (mkdir(task->backup_file, 0640) != 0) {
error_setg_errno(task->errp, errno, "can't create directory '%s'\n",
task->backup_file);
-@@ -796,8 +868,10 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -793,8 +865,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;
qemu_mutex_unlock(&backup_state.stat.lock);
-@@ -821,6 +895,10 @@ err:
+@@ -818,6 +892,10 @@ err:
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
l = g_list_next(l);
if (di->target) {
bdrv_unref(di->target);
}
-@@ -862,6 +940,7 @@ UuidInfo *qmp_backup(
+@@ -859,6 +937,7 @@ UuidInfo *qmp_backup(
bool has_fingerprint, const char *fingerprint,
bool has_backup_id, const char *backup_id,
bool has_backup_time, int64_t backup_time,
bool has_format, BackupFormat format,
bool has_config_file, const char *config_file,
bool has_firewall_file, const char *firewall_file,
-@@ -880,6 +959,8 @@ UuidInfo *qmp_backup(
+@@ -877,6 +956,8 @@ UuidInfo *qmp_backup(
.backup_id = backup_id,
.has_backup_time = has_backup_time,
.backup_time = backup_time,
.has_format = has_format,
.format = format,
.has_config_file = has_config_file,
-@@ -948,10 +1029,14 @@ BackupStatus *qmp_query_backup(Error **errp)
+@@ -945,10 +1026,14 @@ BackupStatus *qmp_query_backup(Error **errp)
info->has_total = true;
info->total = backup_state.stat.total;
qemu_mutex_unlock(&backup_state.stat.lock);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 90ad07b7ee..3ad9eb5d1a 100644
+index c3b6b93472..992e6c1e3f 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -753,8 +753,13 @@
3 files changed, 54 insertions(+), 13 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index 45da74d7a0..ea7b665aa2 100644
+index 556af25861..a09f722fea 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1042,7 +1042,9 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
false, NULL, false, NULL, !!devlist,
devlist, qdict_haskey(qdict, "speed"), speed, &error);
diff --git a/pve-backup.c b/pve-backup.c
-index 1c49cd178d..c15abefdda 100644
+index abd7062afe..e113ab61b9 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -8,6 +8,7 @@
uint8_t dev_id;
bool completed;
char targetfile[PATH_MAX];
-@@ -135,10 +137,13 @@ pvebackup_co_dump_pbs_cb(
+@@ -137,10 +139,13 @@ pvebackup_co_dump_pbs_cb(
PVEBackupDevInfo *di = opaque;
assert(backup_state.pbs);
qemu_co_mutex_lock(&backup_state.dump_callback_mutex);
// avoid deadlock if job is cancelled
-@@ -147,17 +152,29 @@ pvebackup_co_dump_pbs_cb(
+@@ -149,17 +154,29 @@ pvebackup_co_dump_pbs_cb(
return -1;
}
return size;
}
-@@ -178,6 +195,7 @@ pvebackup_co_dump_vma_cb(
+@@ -180,6 +197,7 @@ pvebackup_co_dump_vma_cb(
int ret = -1;
assert(backup_state.vmaw);
uint64_t remaining = size;
-@@ -204,9 +222,7 @@ pvebackup_co_dump_vma_cb(
+@@ -206,9 +224,7 @@ pvebackup_co_dump_vma_cb(
qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
++cluster_num;
if (ret < 0) {
Error *local_err = NULL;
vma_writer_error_propagate(backup_state.vmaw, &local_err);
-@@ -569,6 +585,10 @@ typedef struct QmpBackupTask {
+@@ -566,6 +582,10 @@ typedef struct QmpBackupTask {
const char *firewall_file;
bool has_devlist;
const char *devlist;
bool has_speed;
int64_t speed;
Error **errp;
-@@ -692,6 +712,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -689,6 +709,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
bool use_dirty_bitmap = task->has_use_dirty_bitmap && task->use_dirty_bitmap;
char *pbs_err = NULL;
pbs = proxmox_backup_new(
task->backup_file,
-@@ -701,8 +722,10 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -698,8 +719,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,
if (!pbs) {
error_set(task->errp, ERROR_CLASS_GENERIC_ERROR,
-@@ -721,6 +744,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -718,6 +741,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
l = g_list_next(l);
const char *devname = bdrv_get_device_name(di->bs);
BdrvDirtyBitmap *bitmap = bdrv_find_dirty_bitmap(di->bs, PBS_BITMAP_NAME);
-@@ -941,6 +966,8 @@ UuidInfo *qmp_backup(
+@@ -938,6 +963,8 @@ UuidInfo *qmp_backup(
bool has_backup_id, const char *backup_id,
bool has_backup_time, int64_t backup_time,
bool has_use_dirty_bitmap, bool use_dirty_bitmap,
bool has_format, BackupFormat format,
bool has_config_file, const char *config_file,
bool has_firewall_file, const char *firewall_file,
-@@ -951,6 +978,8 @@ UuidInfo *qmp_backup(
+@@ -948,6 +975,8 @@ UuidInfo *qmp_backup(
.backup_file = backup_file,
.has_password = has_password,
.password = password,
.has_key_password = has_key_password,
.key_password = key_password,
.has_fingerprint = has_fingerprint,
-@@ -961,6 +990,10 @@ UuidInfo *qmp_backup(
+@@ -958,6 +987,10 @@ UuidInfo *qmp_backup(
.backup_time = backup_time,
.has_use_dirty_bitmap = has_use_dirty_bitmap,
.use_dirty_bitmap = use_dirty_bitmap,
.format = format,
.has_config_file = has_config_file,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 3ad9eb5d1a..4120052690 100644
+index 992e6c1e3f..5ac6276dc1 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -818,6 +818,10 @@
create mode 100644 block/pbs.c
diff --git a/block/meson.build b/block/meson.build
-index 2783b77e9c..a26a69434e 100644
+index e995ae72b9..7ef2fa72d5 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -53,6 +53,9 @@ block_ss.add(files(
+
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
-
+ softmmu_ss.add(files('block-ram-registrar.c'))
diff --git a/block/pbs.c b/block/pbs.c
new file mode 100644
index 0000000000..9d1f1f39d4
+
+block_init(bdrv_pbs_init);
diff --git a/configure b/configure
-index 72ab03f11a..7203c270ec 100755
+index 26c7bc5154..c587e986c7 100755
--- a/configure
+++ b/configure
-@@ -309,6 +309,7 @@ linux_user=""
+@@ -285,6 +285,7 @@ linux_user=""
bsd_user=""
pie=""
coroutine=""
+pbs_bdrv="yes"
plugins="$default_feature"
meson=""
- meson_args=""
-@@ -902,6 +903,10 @@ for opt do
+ ninja=""
+@@ -864,6 +865,10 @@ for opt do
--enable-uuid|--disable-uuid)
echo "$0: $opt is obsolete, UUID support is always built" >&2
;;
--with-git=*) git="$optarg"
;;
--with-git-submodules=*)
-@@ -1087,6 +1092,7 @@ cat << EOF
+@@ -1049,6 +1054,7 @@ cat << EOF
debug-info debugging information
safe-stack SafeStack Stack Smash Protection. Depends on
clang/llvm >= 3.7 and requires coroutine backend ucontext.
NOTE: The object files are built at the place where configure is launched
EOF
-@@ -2463,6 +2469,9 @@ echo "TARGET_DIRS=$target_list" >> $config_host_mak
+@@ -2372,6 +2378,9 @@ echo "TARGET_DIRS=$target_list" >> $config_host_mak
if test "$modules" = "yes"; then
echo "CONFIG_MODULES=y" >> $config_host_mak
fi
# XXX: suppress that
if [ "$bsd" = "yes" ] ; then
diff --git a/meson.build b/meson.build
-index f48d2e0457..be4785e2f6 100644
+index 63ea813a9a..f7f5b3f253 100644
--- a/meson.build
+++ b/meson.build
-@@ -3986,7 +3986,7 @@ summary_info += {'bzip2 support': libbzip2}
+@@ -3978,7 +3978,7 @@ summary_info += {'bzip2 support': libbzip2}
summary_info += {'lzfse support': liblzfse}
summary_info += {'zstd support': zstd}
summary_info += {'NUMA host support': numa}
summary_info += {'libdaxctl support': libdaxctl}
summary_info += {'libudev': libudev}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 4120052690..96bc696aaa 100644
+index 5ac6276dc1..45b63dfe26 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3099,6 +3099,7 @@
- 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
- 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
+@@ -3103,6 +3103,7 @@
+ 'parallels', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum',
+ 'raw', 'rbd',
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
+ 'pbs',
- 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
-
- ##
-@@ -3171,6 +3172,17 @@
+ 'ssh', 'throttle', 'vdi', 'vhdx',
+ { 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
+ { 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
+@@ -3179,6 +3180,17 @@
{ 'struct': 'BlockdevOptionsNull',
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
##
# @BlockdevOptionsNVMe:
#
-@@ -4455,6 +4467,7 @@
+@@ -4531,6 +4543,7 @@
'nfs': 'BlockdevOptionsNfs',
'null-aio': 'BlockdevOptionsNull',
'null-co': 'BlockdevOptionsNull',
+ 'pbs': 'BlockdevOptionsPbs',
'nvme': 'BlockdevOptionsNVMe',
- 'parallels': 'BlockdevOptionsGenericFormat',
- 'preallocate':'BlockdevOptionsPreallocate',
+ 'nvme-io_uring': { 'type': 'BlockdevOptionsNvmeIoUring',
+ 'if': 'CONFIG_BLKIO' },
2 files changed, 38 insertions(+)
diff --git a/pve-backup.c b/pve-backup.c
-index c15abefdda..4684789813 100644
+index e113ab61b9..9318ca4f0c 100644
--- a/pve-backup.c
+++ b/pve-backup.c
-@@ -1075,3 +1075,12 @@ BackupStatus *qmp_query_backup(Error **errp)
+@@ -1072,3 +1072,12 @@ BackupStatus *qmp_query_backup(Error **errp)
return info;
}
+ return ret;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 96bc696aaa..0b453c61d4 100644
+index 45b63dfe26..8b0e0d92de 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -863,6 +863,35 @@
3 files changed, 159 insertions(+), 42 deletions(-)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index 4c1671e289..c1152f55a7 100644
+index 670f783515..d819e5fc36 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -200,6 +200,7 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
+@@ -202,6 +202,7 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
void hmp_info_backup(Monitor *mon, const QDict *qdict)
{
BackupStatus *info;
info = qmp_query_backup(NULL);
-@@ -230,26 +231,29 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
+@@ -232,26 +233,29 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
// this should not happen normally
monitor_printf(mon, "Total size: %d\n", 0);
} else {
info->zero_bytes, zero_per);
diff --git a/pve-backup.c b/pve-backup.c
-index 4684789813..f90abaa50a 100644
+index 9318ca4f0c..c85b2ecd83 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -46,6 +46,7 @@ static struct PVEBackupState {
} stat;
int64_t speed;
VmaWriter *vmaw;
-@@ -672,7 +673,6 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -669,7 +670,6 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
}
size_t total = 0;
l = di_list;
while (l) {
-@@ -693,18 +693,33 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -690,18 +690,33 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
uuid_generate(uuid);
}
int dump_cb_block_size = PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE; // Hardcoded (4M)
-@@ -731,12 +746,12 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -728,12 +743,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);
/* register all devices */
l = di_list;
-@@ -747,6 +762,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -744,6 +759,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);
BdrvDirtyBitmap *bitmap = bdrv_find_dirty_bitmap(di->bs, PBS_BITMAP_NAME);
bool expect_only_dirty = false;
-@@ -755,49 +772,59 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -752,49 +769,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) {
}
/* register all devices for vma writer */
-@@ -807,7 +834,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -804,7 +831,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))) {
}
const char *devname = bdrv_get_device_name(di->bs);
-@@ -815,16 +842,14 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -812,16 +839,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");
}
backup_dir = task->backup_file;
-@@ -841,18 +866,18 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -838,18 +863,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);
}
-@@ -860,7 +885,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -857,7 +882,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) {
}
}
-@@ -868,12 +893,11 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -865,12 +890,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) {
if (backup_state.stat.error) {
error_free(backup_state.stat.error);
-@@ -893,10 +917,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -890,10 +914,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;
qemu_mutex_unlock(&backup_state.stat.lock);
-@@ -913,6 +936,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -910,6 +933,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
task->result = uuid_info;
return;
err:
l = di_list;
-@@ -1076,11 +1102,42 @@ BackupStatus *qmp_query_backup(Error **errp)
+@@ -1073,11 +1099,42 @@ BackupStatus *qmp_query_backup(Error **errp)
return info;
}
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 0b453c61d4..16e184dd28 100644
+index 8b0e0d92de..7fde927621 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -871,6 +871,8 @@
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/meson.build b/meson.build
-index be4785e2f6..3fc7c8d435 100644
+index f7f5b3f253..283b0e356e 100644
--- a/meson.build
+++ b/meson.build
-@@ -1463,6 +1463,7 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1526,6 +1526,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)
# libselinux
-@@ -3105,6 +3106,7 @@ if have_block
+@@ -3096,6 +3097,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'))
endif
diff --git a/os-posix.c b/os-posix.c
-index 321fc4bd13..b1870d2690 100644
+index 4858650c3e..c5cb12226a 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -28,6 +28,8 @@
/* Needed early for CONFIG_BSD etc. */
#include "net/slirp.h"
-@@ -281,9 +283,10 @@ void os_setup_post(void)
+@@ -287,9 +289,10 @@ void os_setup_post(void)
dup2(fd, 0);
dup2(fd, 1);
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
include/qemu/job.h | 12 ++++++++++++
- job.c | 31 +++++++++++++++++++++++++++++++
- 2 files changed, 43 insertions(+)
+ job.c | 34 ++++++++++++++++++++++++++++++++++
+ 2 files changed, 46 insertions(+)
diff --git a/include/qemu/job.h b/include/qemu/job.h
-index c105b31076..5096679571 100644
+index e502787dd8..963cf2bef5 100644
--- a/include/qemu/job.h
+++ b/include/qemu/job.h
-@@ -316,6 +316,18 @@ typedef enum JobCreateFlags {
+@@ -381,6 +381,18 @@ void job_unlock(void);
*/
JobTxn *job_txn_new(void);
* 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 e5699ad200..34c9758349 100644
+index 93e22d180b..2b31f1e14f 100644
--- a/job.c
+++ b/job.c
-@@ -72,6 +72,8 @@ struct JobTxn {
+@@ -93,6 +93,8 @@ struct JobTxn {
/* Reference count */
int refcnt;
+ bool sequential;
};
- /* Right now, this mutex is only needed to synchronize accesses to job->busy
-@@ -102,6 +104,25 @@ JobTxn *job_txn_new(void)
+ void job_lock(void)
+@@ -118,6 +120,25 @@ JobTxn *job_txn_new(void)
return txn;
}
+ job_start(first);
+}
+
- static void job_txn_ref(JobTxn *txn)
+ /* Called with job_mutex held. */
+ static void job_txn_ref_locked(JobTxn *txn)
{
- txn->refcnt++;
-@@ -897,6 +918,9 @@ static void job_completed_txn_success(Job *job)
+@@ -1057,6 +1078,12 @@ static void job_completed_txn_success_locked(Job *job)
*/
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
- if (!job_is_completed(other_job)) {
+ if (!job_is_completed_locked(other_job)) {
+ if (txn->sequential) {
++ job_unlock();
++ /* Needs to be called without holding the job lock */
+ job_start(other_job);
++ job_lock();
+ }
return;
}
assert(other_job->ret == 0);
-@@ -1093,6 +1117,13 @@ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
+@@ -1268,6 +1295,13 @@ int job_finish_sync_locked(Job *job,
return -EBUSY;
}
+ * of cancelling, these have not begun work so job_enter won't do anything,
+ * let's ensure they are marked as ABORTING if required */
+ if (job->status == JOB_STATUS_CREATED && job->txn->sequential) {
-+ job_update_rc(job);
++ job_update_rc_locked(job);
+ }
+
- AIO_WAIT_WHILE(job->aio_context,
- (job_enter(job), !job_is_completed(job)));
-
+ job_unlock();
+ AIO_WAIT_WHILE_UNLOCKED(job->aio_context,
+ (job_enter(job), !job_is_completed(job)));
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>
+[FE: add new force parameter to job_cancel_sync calls
+ adapt for new job lock mechanism replacing AioContext locks]
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
- pve-backup.c | 167 +++++++++++++++------------------------------------
- 1 file changed, 49 insertions(+), 118 deletions(-)
+ pve-backup.c | 163 ++++++++++++++++-----------------------------------
+ 1 file changed, 50 insertions(+), 113 deletions(-)
diff --git a/pve-backup.c b/pve-backup.c
-index f90abaa50a..63c686463f 100644
+index c85b2ecd83..b5fb844434 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -52,6 +52,7 @@ static struct PVEBackupState {
QemuMutex backup_mutex;
CoMutex dump_callback_mutex;
} backup_state;
-@@ -71,32 +72,12 @@ typedef struct PVEBackupDevInfo {
+@@ -71,34 +72,12 @@ typedef struct PVEBackupDevInfo {
size_t size;
uint64_t block_size;
uint8_t dev_id;
-lookup_active_block_job(PVEBackupDevInfo *di)
-{
- if (!di->completed && di->bs) {
-- for (BlockJob *job = block_job_next(NULL); job; job = block_job_next(job)) {
-- if (job->job.driver->job_type != JOB_TYPE_BACKUP) {
-- continue;
-- }
+- WITH_JOB_LOCK_GUARD() {
+- for (BlockJob *job = block_job_next_locked(NULL); job; job = block_job_next_locked(job)) {
+- if (job->job.driver->job_type != JOB_TYPE_BACKUP) {
+- continue;
+- }
-
-- BackupBlockJob *bjob = container_of(job, BackupBlockJob, common);
-- if (bjob && bjob->source_bs == di->bs) {
-- return job;
+- BackupBlockJob *bjob = container_of(job, BackupBlockJob, common);
+- if (bjob && bjob->source_bs == di->bs) {
+- return job;
+- }
- }
- }
- }
static void pvebackup_propagate_error(Error *err)
{
qemu_mutex_lock(&backup_state.stat.lock);
-@@ -272,18 +253,6 @@ static void coroutine_fn pvebackup_co_cleanup(void *unused)
+@@ -274,18 +253,6 @@ static void coroutine_fn pvebackup_co_cleanup(void *unused)
if (local_err != NULL) {
pvebackup_propagate_error(local_err);
}
}
proxmox_backup_disconnect(backup_state.pbs);
-@@ -322,8 +291,6 @@ static void pvebackup_complete_cb(void *opaque, int ret)
+@@ -324,8 +291,6 @@ static void pvebackup_complete_cb(void *opaque, int ret)
qemu_mutex_lock(&backup_state.backup_mutex);
if (ret < 0) {
Error *local_err = NULL;
error_setg(&local_err, "job failed with err %d - %s", ret, strerror(-ret));
-@@ -336,20 +303,17 @@ static void pvebackup_complete_cb(void *opaque, int ret)
+@@ -338,20 +303,17 @@ static void pvebackup_complete_cb(void *opaque, int ret)
block_on_coroutine_fn(pvebackup_complete_stream, di);
}
static void pvebackup_cancel(void)
-@@ -371,36 +335,28 @@ static void pvebackup_cancel(void)
+@@ -373,32 +335,28 @@ static void pvebackup_cancel(void)
proxmox_backup_abort(backup_state.pbs, "backup canceled");
}
- for(;;) {
-
- BlockJob *next_job = NULL;
--
-- qemu_mutex_lock(&backup_state.backup_mutex);
--
-- GList *l = backup_state.di_list;
-- while (l) {
-- PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
-- l = g_list_next(l);
+ /* it's enough to cancel one job in the transaction, the rest will follow
+ * automatically */
+ GList *bdi = g_list_first(backup_state.di_list);
+ ((PVEBackupDevInfo *)bdi->data)->job :
+ NULL;
+- qemu_mutex_lock(&backup_state.backup_mutex);
+-
+- GList *l = backup_state.di_list;
+- while (l) {
+- PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
+- l = g_list_next(l);
+-
- BlockJob *job = lookup_active_block_job(di);
- if (job != NULL) {
- next_job = job;
- break;
- }
-- }
+ /* ref the job before releasing the mutex, just to be safe */
+ if (cancel_job) {
-+ job_ref(&cancel_job->job);
++ WITH_JOB_LOCK_GUARD() {
++ job_ref_locked(&cancel_job->job);
+ }
+ }
- qemu_mutex_unlock(&backup_state.backup_mutex);
+ qemu_mutex_unlock(&backup_state.backup_mutex);
- if (next_job) {
-- AioContext *aio_context = next_job->job.aio_context;
-- aio_context_acquire(aio_context);
- job_cancel_sync(&next_job->job, true);
-- aio_context_release(aio_context);
- } else {
- break;
-- }
+ if (cancel_job) {
-+ AioContext *aio_context = cancel_job->job.aio_context;
-+ aio_context_acquire(aio_context);
-+ job_cancel_sync(&cancel_job->job, true);
-+ job_unref(&cancel_job->job);
-+ aio_context_release(aio_context);
++ WITH_JOB_LOCK_GUARD() {
++ job_cancel_sync_locked(&cancel_job->job, true);
++ job_unref_locked(&cancel_job->job);
+ }
}
}
-
-@@ -459,51 +415,19 @@ static int coroutine_fn pvebackup_co_add_config(
+@@ -458,49 +416,19 @@ static int coroutine_fn pvebackup_co_add_config(
goto out;
}
--bool job_should_pause(Job *job);
+-bool job_should_pause_locked(Job *job);
-
-static void pvebackup_run_next_job(void)
-{
- if (job) {
- qemu_mutex_unlock(&backup_state.backup_mutex);
-
-- AioContext *aio_context = job->job.aio_context;
-- aio_context_acquire(aio_context);
--
-- if (job_should_pause(&job->job)) {
-- bool error_or_canceled = pvebackup_error_or_canceled();
-- if (error_or_canceled) {
-- job_cancel_sync(&job->job, true);
-- } else {
-- job_resume(&job->job);
+- WITH_JOB_LOCK_GUARD() {
+- if (job_should_pause_locked(&job->job)) {
+- bool error_or_canceled = pvebackup_error_or_canceled();
+- if (error_or_canceled) {
+- job_cancel_sync_locked(&job->job, true);
+- } else {
+- job_resume_locked(&job->job);
+- }
- }
- }
-- aio_context_release(aio_context);
- return;
- }
- }
BackupPerf perf = { .max_workers = 16 };
/* create and start all jobs (paused state) */
-@@ -526,7 +450,7 @@ static bool create_backup_jobs(void) {
+@@ -523,7 +451,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, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
aio_context_release(aio_context);
-@@ -538,7 +462,8 @@ static bool create_backup_jobs(void) {
+@@ -535,7 +463,8 @@ static bool create_backup_jobs(void) {
pvebackup_propagate_error(create_job_err);
break;
}
bdrv_unref(di->target);
di->target = NULL;
-@@ -556,6 +481,10 @@ static bool create_backup_jobs(void) {
+@@ -553,6 +482,12 @@ static bool create_backup_jobs(void) {
bdrv_unref(di->target);
di->target = NULL;
}
+
+ if (di->job) {
-+ job_unref(&di->job->job);
++ WITH_JOB_LOCK_GUARD() {
++ job_unref_locked(&di->job->job);
++ }
+ }
}
}
-@@ -946,10 +875,6 @@ err:
+@@ -943,10 +878,6 @@ err:
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
l = g_list_next(l);
if (di->target) {
bdrv_unref(di->target);
}
-@@ -1038,9 +963,15 @@ UuidInfo *qmp_backup(
+@@ -1035,9 +966,15 @@ UuidInfo *qmp_backup(
block_on_coroutine_fn(pvebackup_co_prepare, &task);
if (*errp == NULL) {
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>
+[FE: add new force parameter to job_cancel_sync calls]
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
- pve-backup.c | 217 ++++++++++++++++++++++++++++---------------
+ pve-backup.c | 212 +++++++++++++++++++++++++++----------------
qapi/block-core.json | 5 +-
- 2 files changed, 144 insertions(+), 78 deletions(-)
+ 2 files changed, 138 insertions(+), 79 deletions(-)
diff --git a/pve-backup.c b/pve-backup.c
-index 63c686463f..6f05796fad 100644
+index b5fb844434..88268bb586 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -33,7 +33,9 @@ const char *PBS_BITMAP_NAME = "pbs-incremental-dirty-bitmap";
// remove self from job list
backup_state.di_list = g_list_remove(backup_state.di_list, di);
-@@ -310,21 +321,49 @@ static void pvebackup_complete_cb(void *opaque, int ret)
+@@ -310,21 +321,46 @@ static void pvebackup_complete_cb(void *opaque, int ret)
/* call cleanup if we're the last job */
if (!g_list_first(backup_state.di_list)) {
+static void job_cancel_bh(void *opaque) {
+ CoCtxData *data = (CoCtxData*)opaque;
+ Job *job = (Job*)data->data;
-+ AioContext *job_ctx = job->aio_context;
-+ aio_context_acquire(job_ctx);
+ job_cancel_sync(job, true);
-+ aio_context_release(job_ctx);
+ aio_co_enter(data->ctx, data->co);
+}
if (backup_state.vmaw) {
/* make sure vma writer does not block anymore */
-@@ -342,27 +381,22 @@ static void pvebackup_cancel(void)
+@@ -342,28 +378,22 @@ static void pvebackup_cancel(void)
((PVEBackupDevInfo *)bdi->data)->job :
NULL;
- /* ref the job before releasing the mutex, just to be safe */
if (cancel_job) {
-- job_ref(&cancel_job->job);
+- WITH_JOB_LOCK_GUARD() {
+- job_ref_locked(&cancel_job->job);
+- }
+ CoCtxData data = {
+ .ctx = qemu_get_current_aio_context(),
+ .co = qemu_coroutine_self(),
- qemu_mutex_unlock(&backup_state.backup_mutex);
-
- if (cancel_job) {
-- AioContext *aio_context = cancel_job->job.aio_context;
-- aio_context_acquire(aio_context);
-- job_cancel_sync(&cancel_job->job, true);
-- job_unref(&cancel_job->job);
-- aio_context_release(aio_context);
+- WITH_JOB_LOCK_GUARD() {
+- job_cancel_sync_locked(&cancel_job->job, true);
+- job_unref_locked(&cancel_job->job);
+- }
- }
+ qemu_co_mutex_unlock(&backup_state.backup_mutex);
}
}
// assumes the caller holds backup_mutex
-@@ -415,10 +449,18 @@ static int coroutine_fn pvebackup_co_add_config(
+@@ -416,10 +446,18 @@ static int coroutine_fn pvebackup_co_add_config(
goto out;
}
Error *local_err = NULL;
/* create job transaction to synchronize bitmap commit and cancel all
-@@ -454,24 +496,19 @@ static bool create_backup_jobs(void) {
+@@ -455,24 +493,19 @@ static bool create_backup_jobs(void) {
aio_context_release(aio_context);
l = backup_state.di_list;
while (l) {
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
-@@ -483,12 +520,17 @@ static bool create_backup_jobs(void) {
- }
+@@ -485,13 +518,15 @@ 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, true);
- job_unref(&di->job->job);
-+ aio_context_release(ctx);
+ WITH_JOB_LOCK_GUARD() {
++ job_cancel_sync_locked(&di->job->job, true);
+ job_unref_locked(&di->job->job);
+ }
}
}
}
}
typedef struct QmpBackupTask {
-@@ -525,11 +567,12 @@ typedef struct QmpBackupTask {
+@@ -528,11 +563,12 @@ typedef struct QmpBackupTask {
UuidInfo *result;
} QmpBackupTask;
QmpBackupTask *task = opaque;
task->result = NULL; // just to be sure
-@@ -550,8 +593,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -553,8 +589,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
const char *firewall_name = "qemu-server.fw";
if (backup_state.di_list) {
return;
}
-@@ -618,6 +662,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -621,6 +658,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
}
di->size = size;
total += size;
}
uuid_generate(uuid);
-@@ -849,6 +895,8 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -852,6 +891,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;
qemu_mutex_unlock(&backup_state.stat.lock);
-@@ -863,6 +911,33 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -866,6 +907,33 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
uuid_info->UUID = uuid_str;
task->result = uuid_info;
return;
err_mutex:
-@@ -885,6 +960,7 @@ err:
+@@ -888,6 +956,7 @@ err:
g_free(di);
}
g_list_free(di_list);
if (devs) {
g_strfreev(devs);
-@@ -905,6 +981,8 @@ err:
+@@ -908,6 +977,8 @@ err:
}
task->result = NULL;
return;
}
-@@ -958,24 +1036,8 @@ UuidInfo *qmp_backup(
+@@ -961,24 +1032,8 @@ UuidInfo *qmp_backup(
.errp = errp,
};
return task.result;
}
-@@ -1027,6 +1089,7 @@ BackupStatus *qmp_query_backup(Error **errp)
+@@ -1030,6 +1085,7 @@ BackupStatus *qmp_query_backup(Error **errp)
info->transferred = backup_state.stat.transferred;
info->has_reused = true;
info->reused = backup_state.stat.reused;
qemu_mutex_unlock(&backup_state.stat.lock);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 16e184dd28..cb17d00fe0 100644
+index 7fde927621..bf559c6d52 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -770,12 +770,15 @@
softmmu_ss.add(files(
'block-dirty-bitmap.c',
diff --git a/migration/migration.c b/migration/migration.c
-index bb8bbddfe4..8109e468eb 100644
+index f485eea5fb..89b287180f 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -229,6 +229,7 @@ void migration_object_init(void)
+ NULL);
+}
diff --git a/pve-backup.c b/pve-backup.c
-index 6f05796fad..5fa3cc1352 100644
+index 88268bb586..fa9c6c4493 100644
--- a/pve-backup.c
+++ b/pve-backup.c
-@@ -1132,6 +1132,7 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
+@@ -1128,6 +1128,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;
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index cb17d00fe0..bd978ea562 100644
+index bf559c6d52..24f30260c8 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -879,6 +879,11 @@
1 file changed, 30 insertions(+)
diff --git a/block/iscsi.c b/block/iscsi.c
-index d707d0b354..da6ed52323 100644
+index a316d46d96..3ed4a50c0d 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
-@@ -1386,12 +1386,42 @@ static char *get_initiator_name(QemuOpts *opts)
+@@ -1387,12 +1387,42 @@ static char *get_initiator_name(QemuOpts *opts)
const char *name;
char *iscsi_name;
UuidInfo *uuid_info;
5 files changed, 77 insertions(+), 196 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index ea7b665aa2..ef45552e3b 100644
+index a09f722fea..71ed202491 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1016,7 +1016,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
Error *error = NULL;
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 97f24942b3..7a2be816da 100644
+index fcf9461295..5fdb198ca4 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -111,6 +111,7 @@ ERST
static void proxmox_backup_schedule_wake(void *data) {
CoCtxData *waker = (CoCtxData *)data;
diff --git a/pve-backup.c b/pve-backup.c
-index 5fa3cc1352..323014744c 100644
+index fa9c6c4493..109498eaf9 100644
--- a/pve-backup.c
+++ b/pve-backup.c
-@@ -357,7 +357,7 @@ static void job_cancel_bh(void *opaque) {
+@@ -354,7 +354,7 @@ static void job_cancel_bh(void *opaque) {
aio_co_enter(data->ctx, data->co);
}
{
Error *cancel_err = NULL;
error_setg(&cancel_err, "backup canceled");
-@@ -394,11 +394,6 @@ static void coroutine_fn pvebackup_co_cancel(void *opaque)
+@@ -391,11 +391,6 @@ static void coroutine_fn pvebackup_co_cancel(void *opaque)
qemu_co_mutex_unlock(&backup_state.backup_mutex);
}
// assumes the caller holds backup_mutex
static int coroutine_fn pvebackup_co_add_config(
const char *file,
-@@ -533,50 +528,27 @@ static void create_backup_jobs_bh(void *opaque) {
+@@ -529,50 +524,27 @@ static void create_backup_jobs_bh(void *opaque) {
aio_co_enter(data->ctx, data->co);
}
BlockBackend *blk;
BlockDriverState *bs = NULL;
const char *backup_dir = NULL;
-@@ -593,17 +565,17 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -589,17 +561,17 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
const char *firewall_name = "qemu-server.fw";
if (backup_state.di_list) {
gchar **d = devs;
while (d && *d) {
-@@ -611,14 +583,14 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -607,14 +579,14 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
if (blk) {
bs = blk_bs(blk);
if (!bdrv_is_inserted(bs)) {
"Device '%s' not found", *d);
goto err;
}
-@@ -641,7 +613,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -637,7 +609,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
}
if (!di_list) {
goto err;
}
-@@ -651,13 +623,13 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -647,13 +619,13 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
while (l) {
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
l = g_list_next(l);
goto err;
}
di->size = size;
-@@ -684,47 +656,44 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -680,47 +652,44 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
}
if (format == BACKUP_FORMAT_PBS) {
if (connect_result < 0)
goto err_mutex;
-@@ -743,9 +712,9 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -739,9 +708,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;
if (!bitmap) {
goto err_mutex;
}
-@@ -775,12 +744,12 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -771,12 +740,12 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
}
}
goto err_mutex;
}
-@@ -794,10 +763,10 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -790,10 +759,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) {
}
goto err_mutex;
}
-@@ -808,25 +777,25 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -804,25 +773,25 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
l = g_list_next(l);
l = di_list;
while (l) {
-@@ -840,34 +809,34 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -836,34 +805,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) {
goto err_mutex;
}
}
-@@ -885,7 +854,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -881,7 +850,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
if (backup_state.stat.backup_file) {
g_free(backup_state.stat.backup_file);
}
uuid_copy(backup_state.stat.uuid, uuid);
uuid_unparse_lower(uuid, backup_state.stat.uuid_str);
-@@ -900,7 +869,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -896,7 +865,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
qemu_mutex_unlock(&backup_state.stat.lock);
backup_state.vmaw = vmaw;
backup_state.pbs = pbs;
-@@ -910,8 +879,6 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -906,8 +875,6 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
uuid_info = g_malloc0(sizeof(*uuid_info));
uuid_info->UUID = uuid_str;
/* 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.
-@@ -925,7 +892,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -921,7 +888,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
qemu_coroutine_yield();
if (local_err) {
goto err;
}
-@@ -938,7 +905,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
+@@ -934,7 +901,7 @@ static void coroutine_fn pvebackup_co_prepare(void *opaque)
/* start the first job in the transaction */
job_txn_start_seq(backup_state.txn);
err_mutex:
qemu_mutex_unlock(&backup_state.stat.lock);
-@@ -969,7 +936,7 @@ err:
+@@ -965,7 +932,7 @@ err:
if (vmaw) {
Error *err = NULL;
vma_writer_close(vmaw, &err);
}
if (pbs) {
-@@ -980,65 +947,8 @@ err:
+@@ -976,65 +943,8 @@ err:
rmdir(backup_dir);
}
BackupStatus *qmp_query_backup(Error **errp)
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index bd978ea562..ca1966f54b 100644
+index 24f30260c8..4e8c35a3a2 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -842,7 +842,7 @@
3 files changed, 11 insertions(+)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index ef45552e3b..4c799f00d9 100644
+index 71ed202491..c7468e5d3b 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1039,6 +1039,7 @@ void coroutine_fn hmp_backup(Monitor *mon, const QDict *qdict)
false, NULL, // PBS backup-id
false, 0, // PBS backup-time
diff --git a/pve-backup.c b/pve-backup.c
-index 323014744c..9f6c04a512 100644
+index 109498eaf9..4b5134ed27 100644
--- a/pve-backup.c
+++ b/pve-backup.c
-@@ -533,6 +533,7 @@ UuidInfo coroutine_fn *qmp_backup(
+@@ -529,6 +529,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,
bool has_fingerprint, const char *fingerprint,
bool has_backup_id, const char *backup_id,
bool has_backup_time, int64_t backup_time,
-@@ -681,6 +682,7 @@ UuidInfo coroutine_fn *qmp_backup(
+@@ -677,6 +678,7 @@ UuidInfo coroutine_fn *qmp_backup(
has_password ? password : NULL,
has_keyfile ? keyfile : NULL,
has_key_password ? key_password : NULL,
has_compress ? compress : true,
has_encrypt ? encrypt : has_keyfile,
has_fingerprint ? fingerprint : NULL,
-@@ -1044,5 +1046,6 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
+@@ -1040,5 +1042,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;
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index ca1966f54b..fc8a125451 100644
+index 4e8c35a3a2..d8c7331090 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -813,6 +813,8 @@
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/block/pbs.c b/block/pbs.c
-index 0b05ea9080..c5eb4d5bad 100644
+index 9d1f1f39d4..ce9a870885 100644
--- a/block/pbs.c
+++ b/block/pbs.c
@@ -200,7 +200,16 @@ static coroutine_fn int pbs_co_preadv(BlockDriverState *bs,
1 file changed, 4 insertions(+)
diff --git a/block/io.c b/block/io.c
-index 0a8cbefe86..531b3b7a2d 100644
+index b9424024f9..01f50d28c8 100644
--- a/block/io.c
+++ b/block/io.c
-@@ -1734,6 +1734,10 @@ static int bdrv_pad_request(BlockDriverState *bs,
+@@ -1730,6 +1730,10 @@ static int bdrv_pad_request(BlockDriverState *bs,
{
int ret;
+
+block_init(bdrv_alloc_track_init);
diff --git a/block/meson.build b/block/meson.build
-index a26a69434e..74e5f49758 100644
+index 7ef2fa72d5..15352f579f 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -2,6 +2,7 @@ block_ss.add(genh)
1 file changed, 5 insertions(+)
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
-index e65a5e3482..2ed2536816 100644
+index bafe6ae5eb..da3634048f 100644
--- a/migration/savevm-async.c
+++ b/migration/savevm-async.c
@@ -20,6 +20,7 @@
3 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
-index 699229eef6..4189ced8bc 100644
+index 5e713e231d..9390d5e5cf 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -492,10 +492,10 @@ Command description:
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index c6b4a5567d..041c203fc3 100644
+index 59c403373b..065a54cc42 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4943,6 +4943,7 @@ static int img_dd(int argc, char **argv)
+@@ -4946,6 +4946,7 @@ static int img_dd(int argc, char **argv)
BlockDriver *drv = NULL, *proto_drv = NULL;
BlockBackend *blk1 = NULL, *blk2 = NULL;
QemuOpts *opts = NULL;
QemuOptsList *create_opts = NULL;
Error *local_err = NULL;
bool image_opts = false;
-@@ -4952,6 +4953,7 @@ static int img_dd(int argc, char **argv)
+@@ -4955,6 +4956,7 @@ static int img_dd(int argc, char **argv)
int64_t size = 0, readsize = 0;
- int64_t block_count = 0, out_pos, in_pos;
+ int64_t out_pos, in_pos;
bool force_share = false, skip_create = false;
+ const char *snapshot_name = NULL;
struct DdInfo dd = {
.flags = 0,
.count = 0,
-@@ -4989,7 +4991,7 @@ static int img_dd(int argc, char **argv)
+@@ -4992,7 +4994,7 @@ static int img_dd(int argc, char **argv)
{ 0, 0, 0, 0 }
};
if (c == EOF) {
break;
}
-@@ -5012,6 +5014,19 @@ static int img_dd(int argc, char **argv)
+@@ -5015,6 +5017,19 @@ static int img_dd(int argc, char **argv)
case 'n':
skip_create = true;
break;
case 'U':
force_share = true;
break;
-@@ -5071,11 +5086,24 @@ static int img_dd(int argc, char **argv)
+@@ -5074,11 +5089,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 (dd.flags & C_OSIZE) {
-@@ -5230,6 +5258,7 @@ static int img_dd(int argc, char **argv)
+@@ -5233,6 +5261,7 @@ static int img_dd(int argc, char **argv)
out:
g_free(arg);
qemu_opts_del(opts);
5 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index 4c799f00d9..0502f42be6 100644
+index c7468e5d3b..57b2457f1e 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, 0, // PBS backup-time
false, false, // PBS use-dirty-bitmap
diff --git a/block/pbs.c b/block/pbs.c
-index c5eb4d5bad..7471e2ef9d 100644
+index ce9a870885..9192f3e41b 100644
--- a/block/pbs.c
+++ b/block/pbs.c
@@ -14,6 +14,7 @@
fprintf(stderr, "restore failed: %s\n", pbs_error);
return -1;
diff --git a/pve-backup.c b/pve-backup.c
-index 9f6c04a512..f6a5f8c785 100644
+index 4b5134ed27..262e7d3894 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -10,6 +10,8 @@
/* PVE backup state and related function */
/*
-@@ -535,6 +537,7 @@ UuidInfo coroutine_fn *qmp_backup(
+@@ -531,6 +533,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_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(
+@@ -670,8 +673,9 @@ UuidInfo coroutine_fn *qmp_backup(
firewall_name = "fw.conf";
char *pbs_err = NULL;
backup_time,
dump_cb_block_size,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index fc8a125451..cc2ead0b75 100644
+index d8c7331090..889726fc26 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -817,6 +817,8 @@
'*backup-id': 'str',
'*backup-time': 'int',
'*use-dirty-bitmap': 'bool',
-@@ -3282,7 +3285,7 @@
+@@ -3290,7 +3293,7 @@
{ 'struct': 'BlockdevOptionsPbs',
'data': { 'repository': 'str', 'snapshot': 'str', 'archive': 'str',
'*keyfile': 'str', '*password': 'str', '*fingerprint': 'str',
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: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
+[FE: adapt for new job lock mechanism replacing AioContext locks]
+Signed-off-by: Fiona Ebner <f.ebner@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
+index 262e7d3894..fde3554133 100644
--- a/pve-backup.c
+++ b/pve-backup.c
-@@ -506,6 +506,11 @@ static void create_backup_jobs_bh(void *opaque) {
+@@ -503,6 +503,11 @@ static void create_backup_jobs_bh(void *opaque) {
}
if (*errp) {
l = backup_state.di_list;
while (l) {
PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
-@@ -516,12 +521,12 @@ static void create_backup_jobs_bh(void *opaque) {
+@@ -513,11 +518,11 @@ 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);
+ WITH_JOB_LOCK_GUARD() {
+ job_cancel_sync_locked(&di->job->job, true);
+- job_unref_locked(&di->job->job);
+ }
+ canceled = true;
}
}
}
-@@ -947,6 +952,7 @@ err:
+@@ -943,6 +948,7 @@ err:
if (pbs) {
proxmox_backup_disconnect(pbs);
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: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
+[FE: adapt for new job lock mechanism replacing AioContext locks]
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
- pve-backup.c | 25 ++++++++++++++++++++-----
- 1 file changed, 20 insertions(+), 5 deletions(-)
+ pve-backup.c | 22 +++++++++++++++++++---
+ 1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/pve-backup.c b/pve-backup.c
-index 5bed6f4014..0c34428713 100644
+index fde3554133..0cf30e1ced 100644
--- a/pve-backup.c
+++ b/pve-backup.c
-@@ -316,6 +316,14 @@ static void coroutine_fn pvebackup_co_complete_stream(void *opaque)
+@@ -316,6 +316,13 @@ 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);
++ WITH_JOB_LOCK_GUARD() {
++ job_unref_locked(&di->job->job);
++ di->job = NULL;
++ }
+ }
+
// remove self from job list
backup_state.di_list = g_list_remove(backup_state.di_list, di);
-@@ -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);
+@@ -491,6 +498,11 @@ static void create_backup_jobs_bh(void *opaque) {
+ aio_context_release(aio_context);
-- aio_context_release(aio_context);
--
di->job = job;
+ if (job) {
-+ job_ref(&job->job);
++ WITH_JOB_LOCK_GUARD() {
++ job_ref_locked(&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) {
+@@ -518,11 +530,15 @@ 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);
+ WITH_JOB_LOCK_GUARD() {
+- job_cancel_sync_locked(&di->job->job, true);
++ if (!canceled) {
++ job_cancel_sync_locked(&di->job->job, true);
++ canceled = true;
++ }
++ job_unref_locked(&di->job->job);
++ di->job = NULL;
+ }
- canceled = true;
}
}
it's still necessary and possible to cancel, but the approach with
using the first non-completed job seemed more robust.
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
+[FE: adapt for new job lock mechanism replacing AioContext locks]
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
- pve-backup.c | 61 +++++++++++++++++++++++++++++++++-------------------
- 1 file changed, 39 insertions(+), 22 deletions(-)
+ pve-backup.c | 57 ++++++++++++++++++++++++++++++++++------------------
+ 1 file changed, 38 insertions(+), 19 deletions(-)
diff --git a/pve-backup.c b/pve-backup.c
-index 0c34428713..2e22030eec 100644
+index 0cf30e1ced..4067018dbe 100644
--- a/pve-backup.c
+++ b/pve-backup.c
-@@ -355,15 +355,42 @@ static void pvebackup_complete_cb(void *opaque, int ret)
+@@ -354,12 +354,41 @@ static void pvebackup_complete_cb(void *opaque, int ret)
/*
* job_cancel(_sync) does not like to be called from coroutines, so defer to
static void job_cancel_bh(void *opaque) {
CoCtxData *data = (CoCtxData*)opaque;
- Job *job = (Job*)data->data;
-- AioContext *job_ctx = job->aio_context;
-- aio_context_acquire(job_ctx);
- job_cancel_sync(job, true);
-- aio_context_release(job_ctx);
+
+ /*
+ * Be careful to pick a valid job to cancel:
+ BlockJob *bj = ((PVEBackupDevInfo *)bdi->data)->job;
+ if (bj) {
+ Job *job = &bj->job;
-+ if (!job_is_completed(job)) {
-+ AioContext *job_ctx = job->aio_context;
-+ aio_context_acquire(job_ctx);
-+ job_cancel_sync(job, true);
-+ aio_context_release(job_ctx);
-+ /*
-+ * It's enough to cancel one job in the transaction, the
-+ * rest will follow automatically.
-+ */
-+ break;
++ WITH_JOB_LOCK_GUARD() {
++ if (!job_is_completed_locked(job)) {
++ job_cancel_sync_locked(job, true);
++ /*
++ * It's enough to cancel one job in the transaction, the
++ * rest will follow automatically.
++ */
++ break;
++ }
+ }
+ }
+ }
aio_co_enter(data->ctx, data->co);
}
-@@ -384,22 +411,12 @@ void coroutine_fn qmp_backup_cancel(Error **errp)
+@@ -380,22 +409,12 @@ void coroutine_fn qmp_backup_cancel(Error **errp)
proxmox_backup_abort(backup_state.pbs, "backup canceled");
}
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block/alloc-track.c b/block/alloc-track.c
-index 6b50fbe537..c1160af04b 100644
+index 43d40d11af..95c9c67cd8 100644
--- a/block/alloc-track.c
+++ b/block/alloc-track.c
@@ -174,7 +174,8 @@ static int coroutine_fn track_co_preadv(BlockDriverState *bs,
3 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index 0502f42be6..cc231ec3f2 100644
+index 57b2457f1e..ab0c988ae9 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1049,7 +1049,9 @@ void coroutine_fn hmp_backup(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, error);
}
diff --git a/pve-backup.c b/pve-backup.c
-index 2e22030eec..e9aa7e0f49 100644
+index 4067018dbe..3ca4f74cb8 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -55,6 +55,7 @@ static struct PVEBackupState {
VmaWriter *vmaw;
ProxmoxBackupHandle *pbs;
GList *di_list;
-@@ -492,8 +493,6 @@ static void create_backup_jobs_bh(void *opaque) {
+@@ -490,8 +491,6 @@ static void create_backup_jobs_bh(void *opaque) {
}
backup_state.txn = job_txn_new_seq();
/* create and start all jobs (paused state) */
GList *l = backup_state.di_list;
while (l) {
-@@ -513,8 +512,9 @@ static void create_backup_jobs_bh(void *opaque) {
+@@ -511,8 +510,9 @@ static void create_backup_jobs_bh(void *opaque) {
BlockJob *job = backup_job_create(
NULL, di->bs, di->target, backup_state.speed, sync_mode, di->bitmap,
+ BLOCKDEV_ON_ERROR_REPORT, JOB_DEFAULT, pvebackup_complete_cb, di, backup_state.txn,
+ &local_err);
- di->job = job;
- if (job) {
-@@ -584,7 +584,9 @@ UuidInfo coroutine_fn *qmp_backup(
+ aio_context_release(aio_context);
+
+@@ -583,7 +583,9 @@ UuidInfo coroutine_fn *qmp_backup(
bool has_config_file, const char *config_file,
bool has_firewall_file, const char *firewall_file,
bool has_devlist, const char *devlist,
{
assert(qemu_in_coroutine());
-@@ -914,6 +916,11 @@ UuidInfo coroutine_fn *qmp_backup(
+@@ -913,6 +915,11 @@ UuidInfo coroutine_fn *qmp_backup(
backup_state.speed = (has_speed && speed > 0) ? speed : 0;
backup_state.vmaw = vmaw;
backup_state.pbs = pbs;
-@@ -1089,5 +1096,6 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
+@@ -1088,5 +1095,6 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
ret->pbs_dirty_bitmap_migration = true;
ret->query_bitmap_info = true;
ret->pbs_masterkey = true;
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index cc2ead0b75..e3f62faa81 100644
+index 889726fc26..65795b7204 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -829,6 +829,8 @@
extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
-extra/0002-block-io_uring-revert-Use-io_uring_register_ring_fd-.patch
-extra/0003-virtiofsd-use-g_date_time_get_microsecond-to-get-sub.patch
-extra/0004-chardev-fix-segfault-in-finalize.patch
-extra/0005-init-daemonize-defuse-PID-file-resolve-error.patch
-extra/0006-block-block-backend-blk_set_enable_write_cache-is-IO.patch
+extra/0002-init-daemonize-defuse-PID-file-resolve-error.patch
bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
-Subproject commit 621da7789083b80d6f1ff1c0fb499334007b4f51
+Subproject commit b67b00e6b4c7831a3f5bc684bc0df7a9bfd1bd56