[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 17/42] commit: Add top-node/base-node options
From: |
Max Reitz |
Subject: |
[Qemu-block] [PULL 17/42] commit: Add top-node/base-node options |
Date: |
Tue, 25 Sep 2018 17:15:16 +0200 |
From: Kevin Wolf <address@hidden>
The block-commit QMP command required specifying the top and base nodes
of the commit jobs using the file name of that node. While this works
in simple cases (local files with absolute paths), the file names
generated for more complicated setups can be hard to predict.
The block-commit command has more problems than just this, so we want to
replace it altogether in the long run, but libvirt needs a reliable way
to address nodes now. So we don't want to wait for a new, cleaner
command, but just add the minimal thing needed right now.
This adds two new options top-node and base-node to the command, which
allow specifying node names instead. They are mutually exclusive with
the old options.
Signed-off-by: Kevin Wolf <address@hidden>
---
qapi/block-core.json | 24 ++++++++++++++++++------
blockdev.c | 32 ++++++++++++++++++++++++++++++--
2 files changed, 48 insertions(+), 8 deletions(-)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index c0b3d33dbb..ac3b48ee54 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1457,12 +1457,23 @@
#
# @device: the device name or node-name of a root node
#
-# @base: The file name of the backing image to write data into.
-# If not specified, this is the deepest backing image.
+# @base-node: The node name of the backing image to write data into.
+# If not specified, this is the deepest backing image.
+# (since: 3.1)
#
-# @top: The file name of the backing image within the image chain,
-# which contains the topmost data to be committed down. If
-# not specified, this is the active layer.
+# @base: Same as @base-node, except that it is a file name rather than a node
+# name. This must be the exact filename string that was used to open the
+# node; other strings, even if addressing the same file, are not
+# accepted (deprecated, use @base-node instead)
+#
+# @top-node: The node name of the backing image within the image chain
+# which contains the topmost data to be committed down. If
+# not specified, this is the active layer. (since: 3.1)
+#
+# @top: Same as @top-node, except that it is a file name rather than a node
+# name. This must be the exact filename string that was used to open the
+# node; other strings, even if addressing the same file, are not
+# accepted (deprecated, use @base-node instead)
#
# @backing-file: The backing file string to write into the overlay
# image of 'top'. If 'top' is the active layer,
@@ -1528,7 +1539,8 @@
#
##
{ 'command': 'block-commit',
- 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str', '*top': 'str',
+ 'data': { '*job-id': 'str', 'device': 'str', '*base-node': 'str',
+ '*base': 'str', '*top-node': 'str', '*top': 'str',
'*backing-file': 'str', '*speed': 'int',
'*filter-node-name': 'str',
'*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
diff --git a/blockdev.c b/blockdev.c
index d4b42403df..a8755bd908 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3214,7 +3214,9 @@ out:
}
void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
+ bool has_base_node, const char *base_node,
bool has_base, const char *base,
+ bool has_top_node, const char *top_node,
bool has_top, const char *top,
bool has_backing_file, const char *backing_file,
bool has_speed, int64_t speed,
@@ -3275,7 +3277,20 @@ void qmp_block_commit(bool has_job_id, const char
*job_id, const char *device,
/* default top_bs is the active layer */
top_bs = bs;
- if (has_top && top) {
+ if (has_top_node && has_top) {
+ error_setg(errp, "'top-node' and 'top' are mutually exclusive");
+ goto out;
+ } else if (has_top_node) {
+ top_bs = bdrv_lookup_bs(NULL, top_node, errp);
+ if (top_bs == NULL) {
+ goto out;
+ }
+ if (!bdrv_chain_contains(bs, top_bs)) {
+ error_setg(errp, "'%s' is not in this backing file chain",
+ top_node);
+ goto out;
+ }
+ } else if (has_top && top) {
if (strcmp(bs->filename, top) != 0) {
top_bs = bdrv_find_backing_image(bs, top);
}
@@ -3288,7 +3303,20 @@ void qmp_block_commit(bool has_job_id, const char
*job_id, const char *device,
assert(bdrv_get_aio_context(top_bs) == aio_context);
- if (has_base && base) {
+ if (has_base_node && has_base) {
+ error_setg(errp, "'base-node' and 'base' are mutually exclusive");
+ goto out;
+ } else if (has_base_node) {
+ base_bs = bdrv_lookup_bs(NULL, base_node, errp);
+ if (base_bs == NULL) {
+ goto out;
+ }
+ if (!bdrv_chain_contains(top_bs, base_bs)) {
+ error_setg(errp, "'%s' is not in this backing file chain",
+ base_node);
+ goto out;
+ }
+ } else if (has_base && base) {
base_bs = bdrv_find_backing_image(top_bs, base);
} else {
base_bs = bdrv_find_base(top_bs);
--
2.17.1
- [Qemu-block] [PULL 08/42] tests/blockjob: replace Blockjob with Job, (continued)
- [Qemu-block] [PULL 08/42] tests/blockjob: replace Blockjob with Job, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 10/42] tests/test-blockjob-txn: move .exit to .clean, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 09/42] tests/test-blockjob: remove exit callback, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 12/42] qapi/block-commit: expose new job properties, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 11/42] jobs: remove .exit callback, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 16/42] blockdev: document transactional shortcomings, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 13/42] qapi/block-mirror: expose new job properties, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 15/42] block/backup: qapi documentation fixup, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 14/42] qapi/block-stream: expose new job properties, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 19/42] block/linux-aio: acquire AioContext before qemu_laio_process_completions, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 17/42] commit: Add top-node/base-node options,
Max Reitz <=
- [Qemu-block] [PULL 18/42] qemu-iotests: Test commit with top-node/base-node, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 20/42] block: Fix use after free error in bdrv_open_inherit(), Max Reitz, 2018/09/25
- [Qemu-block] [PULL 21/42] qemu-iotests: Test snapshot=on with nonexistent TMPDIR, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 22/42] util/async: use qemu_aio_coroutine_enter in co_schedule_bh_cb, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 25/42] blockjob: Wake up BDS when job becomes idle, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 24/42] job: Fix missing locking due to mismerge, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 23/42] job: Fix nested aio_poll() hanging in job_txn_apply, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 26/42] aio-wait: Increase num_waiters even in home thread, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 27/42] test-bdrv-drain: Drain with block jobs in an I/O thread, Max Reitz, 2018/09/25
- [Qemu-block] [PULL 28/42] test-blockjob: Acquire AioContext around job_cancel_sync(), Max Reitz, 2018/09/25