d03e1b3ce3
User-facing breaking change: The slirp submodule for user networking got removed. It would be necessary to add the --enable-slirp option to the build and/or install the appropriate library to continue building it. Since PVE is not explicitly supporting it, it would require additionally installing the libslirp0 package on all installations and there is *very* little mention on the community forum when searching for "slirp" or "netdev user", the plan is to only enable it again if there is some real demand for it. Notable changes: * The big change for this release is the rework of job locking, using a job mutex and introducing _locked() variants of job API functions moving away from call-side AioContext locking. See (in the qemu submodule) commit 6f592e5aca ("job.c: enable job lock/unlock and remove Aiocontext locks") and previous commits for context. Changes required for the backup patches: * Use WITH_JOB_LOCK_GUARD() and call the _locked() variant of job API functions where appropriate (many are only availalbe as a _locked() variant). * Remove acquiring/releasing AioContext around functions taking the job mutex lock internally. The patch introducing sequential transaction support for jobs needs to temporarily unlock the job mutex to call job_start() when starting the next job in the transaction. * The zeroinit block driver now marks its child as primary. The documentation in include/block/block-common.h states: > Filter node has exactly one FILTERED|PRIMARY child, and may have > other children which must not have these bits Without this, an assert will trigger when copying to a zeroinit target with qemu-img convert, because bdrv_child_cb_attach() expects any non-PRIMARY child to be not FILTERED: > qemu-img convert -n -p -f raw -O raw input.raw zeroinit:output.raw > qemu-img: ../block.c:1476: bdrv_child_cb_attach: Assertion > `!(child->role & BDRV_CHILD_FILTERED)' failed. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
131 lines
5.1 KiB
Diff
131 lines
5.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Fabian Ebner <f.ebner@proxmox.com>
|
|
Date: Mon, 7 Feb 2022 14:21:01 +0100
|
|
Subject: [PATCH] qemu-img: dd: add -l option for loading a snapshot
|
|
|
|
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
|
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
|
---
|
|
docs/tools/qemu-img.rst | 6 +++---
|
|
qemu-img-cmds.hx | 4 ++--
|
|
qemu-img.c | 33 +++++++++++++++++++++++++++++++--
|
|
3 files changed, 36 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
|
|
index 5e713e231d..9390d5e5cf 100644
|
|
--- a/docs/tools/qemu-img.rst
|
|
+++ b/docs/tools/qemu-img.rst
|
|
@@ -492,10 +492,10 @@ Command description:
|
|
it doesn't need to be specified separately in this case.
|
|
|
|
|
|
-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
|
|
+.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [-l SNAPSHOT_PARAM] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
|
|
|
|
- dd copies from *INPUT* file to *OUTPUT* file converting it from
|
|
- *FMT* format to *OUTPUT_FMT* format.
|
|
+ dd copies from *INPUT* file or snapshot *SNAPSHOT_PARAM* to *OUTPUT* file
|
|
+ converting it from *FMT* format to *OUTPUT_FMT* format.
|
|
|
|
The data is by default read and written using blocks of 512 bytes but can be
|
|
modified by specifying *BLOCK_SIZE*. If count=\ *BLOCKS* is specified
|
|
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
|
index b5b0bb4467..36f97e1f19 100644
|
|
--- a/qemu-img-cmds.hx
|
|
+++ b/qemu-img-cmds.hx
|
|
@@ -58,9 +58,9 @@ SRST
|
|
ERST
|
|
|
|
DEF("dd", img_dd,
|
|
- "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [-n] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
|
|
+ "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [-n] [-l snapshot_param] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
|
|
SRST
|
|
-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT
|
|
+.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [-l SNAPSHOT_PARAM] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT
|
|
ERST
|
|
|
|
DEF("info", img_info,
|
|
diff --git a/qemu-img.c b/qemu-img.c
|
|
index 59c403373b..065a54cc42 100644
|
|
--- a/qemu-img.c
|
|
+++ b/qemu-img.c
|
|
@@ -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;
|
|
+ QemuOpts *sn_opts = NULL;
|
|
QemuOptsList *create_opts = NULL;
|
|
Error *local_err = NULL;
|
|
bool image_opts = false;
|
|
@@ -4955,6 +4956,7 @@ static int img_dd(int argc, char **argv)
|
|
int64_t size = 0, readsize = 0;
|
|
int64_t out_pos, in_pos;
|
|
bool force_share = false, skip_create = false;
|
|
+ const char *snapshot_name = NULL;
|
|
struct DdInfo dd = {
|
|
.flags = 0,
|
|
.count = 0,
|
|
@@ -4992,7 +4994,7 @@ static int img_dd(int argc, char **argv)
|
|
{ 0, 0, 0, 0 }
|
|
};
|
|
|
|
- while ((c = getopt_long(argc, argv, ":hf:O:Un", long_options, NULL))) {
|
|
+ while ((c = getopt_long(argc, argv, ":hf:O:l:Un", long_options, NULL))) {
|
|
if (c == EOF) {
|
|
break;
|
|
}
|
|
@@ -5015,6 +5017,19 @@ static int img_dd(int argc, char **argv)
|
|
case 'n':
|
|
skip_create = true;
|
|
break;
|
|
+ case 'l':
|
|
+ if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
|
|
+ sn_opts = qemu_opts_parse_noisily(&internal_snapshot_opts,
|
|
+ optarg, false);
|
|
+ if (!sn_opts) {
|
|
+ error_report("Failed in parsing snapshot param '%s'",
|
|
+ optarg);
|
|
+ goto out;
|
|
+ }
|
|
+ } else {
|
|
+ snapshot_name = optarg;
|
|
+ }
|
|
+ break;
|
|
case 'U':
|
|
force_share = true;
|
|
break;
|
|
@@ -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 (!blk1) {
|
|
ret = -1;
|
|
goto out;
|
|
}
|
|
+ if (sn_opts) {
|
|
+ bdrv_snapshot_load_tmp(blk_bs(blk1),
|
|
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID),
|
|
+ qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME),
|
|
+ &local_err);
|
|
+ } else if (snapshot_name != NULL) {
|
|
+ bdrv_snapshot_load_tmp_by_id_or_name(blk_bs(blk1), snapshot_name,
|
|
+ &local_err);
|
|
+ }
|
|
+ if (local_err) {
|
|
+ error_reportf_err(local_err, "Failed to load snapshot: ");
|
|
+ ret = -1;
|
|
+ goto out;
|
|
+ }
|
|
}
|
|
|
|
if (dd.flags & C_OSIZE) {
|
|
@@ -5233,6 +5261,7 @@ static int img_dd(int argc, char **argv)
|
|
out:
|
|
g_free(arg);
|
|
qemu_opts_del(opts);
|
|
+ qemu_opts_del(sn_opts);
|
|
qemu_opts_free(create_opts);
|
|
blk_unref(blk1);
|
|
blk_unref(blk2);
|