|
|
357786 |
From 1ac2f161e5585d1ed71b79e8279c9d78b2efe35e Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Date: Mon, 17 Sep 2018 07:48:43 +0200
|
|
|
357786 |
Subject: [PATCH 01/49] commit: Add top-node/base-node options
|
|
|
357786 |
|
|
|
357786 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Message-id: <20180911130704.6641-2-kwolf@redhat.com>
|
|
|
357786 |
Patchwork-id: 82114
|
|
|
357786 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/2] commit: Add top-node/base-node options
|
|
|
357786 |
Bugzilla: 1624012
|
|
|
357786 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
357786 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
The block-commit QMP command required specifying the top and base nodes
|
|
|
357786 |
of the commit jobs using the file name of that node. While this works
|
|
|
357786 |
in simple cases (local files with absolute paths), the file names
|
|
|
357786 |
generated for more complicated setups can be hard to predict.
|
|
|
357786 |
|
|
|
357786 |
The block-commit command has more problems than just this, so we want to
|
|
|
357786 |
replace it altogether in the long run, but libvirt needs a reliable way
|
|
|
357786 |
to address nodes now. So we don't want to wait for a new, cleaner
|
|
|
357786 |
command, but just add the minimal thing needed right now.
|
|
|
357786 |
|
|
|
357786 |
This adds two new options top-node and base-node to the command, which
|
|
|
357786 |
allow specifying node names instead. They are mutually exclusive with
|
|
|
357786 |
the old options.
|
|
|
357786 |
|
|
|
357786 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
blockdev.c | 32 ++++++++++++++++++++++++++++++--
|
|
|
357786 |
qapi/block-core.json | 24 ++++++++++++++++++------
|
|
|
357786 |
2 files changed, 48 insertions(+), 8 deletions(-)
|
|
|
357786 |
|
|
|
357786 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
357786 |
index 0eb6bba..fb355c8 100644
|
|
|
357786 |
--- a/blockdev.c
|
|
|
357786 |
+++ b/blockdev.c
|
|
|
357786 |
@@ -3371,7 +3371,9 @@ out:
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
|
|
|
357786 |
+ bool has_base_node, const char *base_node,
|
|
|
357786 |
bool has_base, const char *base,
|
|
|
357786 |
+ bool has_top_node, const char *top_node,
|
|
|
357786 |
bool has_top, const char *top,
|
|
|
357786 |
bool has_backing_file, const char *backing_file,
|
|
|
357786 |
bool has_speed, int64_t speed,
|
|
|
357786 |
@@ -3432,7 +3434,20 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
|
|
|
357786 |
/* default top_bs is the active layer */
|
|
|
357786 |
top_bs = bs;
|
|
|
357786 |
|
|
|
357786 |
- if (has_top && top) {
|
|
|
357786 |
+ if (has_top_node && has_top) {
|
|
|
357786 |
+ error_setg(errp, "'top-node' and 'top' are mutually exclusive");
|
|
|
357786 |
+ goto out;
|
|
|
357786 |
+ } else if (has_top_node) {
|
|
|
357786 |
+ top_bs = bdrv_lookup_bs(NULL, top_node, errp);
|
|
|
357786 |
+ if (top_bs == NULL) {
|
|
|
357786 |
+ goto out;
|
|
|
357786 |
+ }
|
|
|
357786 |
+ if (!bdrv_chain_contains(bs, top_bs)) {
|
|
|
357786 |
+ error_setg(errp, "'%s' is not in this backing file chain",
|
|
|
357786 |
+ top_node);
|
|
|
357786 |
+ goto out;
|
|
|
357786 |
+ }
|
|
|
357786 |
+ } else if (has_top && top) {
|
|
|
357786 |
if (strcmp(bs->filename, top) != 0) {
|
|
|
357786 |
top_bs = bdrv_find_backing_image(bs, top);
|
|
|
357786 |
}
|
|
|
357786 |
@@ -3445,7 +3460,20 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
|
|
|
357786 |
|
|
|
357786 |
assert(bdrv_get_aio_context(top_bs) == aio_context);
|
|
|
357786 |
|
|
|
357786 |
- if (has_base && base) {
|
|
|
357786 |
+ if (has_base_node && has_base) {
|
|
|
357786 |
+ error_setg(errp, "'base-node' and 'base' are mutually exclusive");
|
|
|
357786 |
+ goto out;
|
|
|
357786 |
+ } else if (has_base_node) {
|
|
|
357786 |
+ base_bs = bdrv_lookup_bs(NULL, base_node, errp);
|
|
|
357786 |
+ if (base_bs == NULL) {
|
|
|
357786 |
+ goto out;
|
|
|
357786 |
+ }
|
|
|
357786 |
+ if (!bdrv_chain_contains(top_bs, base_bs)) {
|
|
|
357786 |
+ error_setg(errp, "'%s' is not in this backing file chain",
|
|
|
357786 |
+ base_node);
|
|
|
357786 |
+ goto out;
|
|
|
357786 |
+ }
|
|
|
357786 |
+ } else if (has_base && base) {
|
|
|
357786 |
base_bs = bdrv_find_backing_image(top_bs, base);
|
|
|
357786 |
} else {
|
|
|
357786 |
base_bs = bdrv_find_base(top_bs);
|
|
|
357786 |
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
|
|
357786 |
index 56937db..8da07cd 100644
|
|
|
357786 |
--- a/qapi/block-core.json
|
|
|
357786 |
+++ b/qapi/block-core.json
|
|
|
357786 |
@@ -1440,12 +1440,23 @@
|
|
|
357786 |
#
|
|
|
357786 |
# @device: the device name or node-name of a root node
|
|
|
357786 |
#
|
|
|
357786 |
-# @base: The file name of the backing image to write data into.
|
|
|
357786 |
-# If not specified, this is the deepest backing image.
|
|
|
357786 |
+# @base-node: The node name of the backing image to write data into.
|
|
|
357786 |
+# If not specified, this is the deepest backing image.
|
|
|
357786 |
+# (since: 3.1)
|
|
|
357786 |
#
|
|
|
357786 |
-# @top: The file name of the backing image within the image chain,
|
|
|
357786 |
-# which contains the topmost data to be committed down. If
|
|
|
357786 |
-# not specified, this is the active layer.
|
|
|
357786 |
+# @base: Same as @base-node, except that it is a file name rather than a node
|
|
|
357786 |
+# name. This must be the exact filename string that was used to open the
|
|
|
357786 |
+# node; other strings, even if addressing the same file, are not
|
|
|
357786 |
+# accepted (deprecated, use @base-node instead)
|
|
|
357786 |
+#
|
|
|
357786 |
+# @top-node: The node name of the backing image within the image chain
|
|
|
357786 |
+# which contains the topmost data to be committed down. If
|
|
|
357786 |
+# not specified, this is the active layer. (since: 3.1)
|
|
|
357786 |
+#
|
|
|
357786 |
+# @top: Same as @top-node, except that it is a file name rather than a node
|
|
|
357786 |
+# name. This must be the exact filename string that was used to open the
|
|
|
357786 |
+# node; other strings, even if addressing the same file, are not
|
|
|
357786 |
+# accepted (deprecated, use @base-node instead)
|
|
|
357786 |
#
|
|
|
357786 |
# @backing-file: The backing file string to write into the overlay
|
|
|
357786 |
# image of 'top'. If 'top' is the active layer,
|
|
|
357786 |
@@ -1514,7 +1525,8 @@
|
|
|
357786 |
#
|
|
|
357786 |
##
|
|
|
357786 |
{ 'command': 'block-commit',
|
|
|
357786 |
- 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str', '*top': 'str',
|
|
|
357786 |
+ 'data': { '*job-id': 'str', 'device': 'str', '*base-node': 'str',
|
|
|
357786 |
+ '*base': 'str', '*top-node': 'str', '*top': 'str',
|
|
|
357786 |
'*backing-file': 'str', '*speed': 'int',
|
|
|
357786 |
'*filter-node-name': 'str',
|
|
|
357786 |
'*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|