|
|
76f597 |
From 6b716d543f7e9a8e4c467d2dd0ccb7910c15fdf5 Mon Sep 17 00:00:00 2001
|
|
|
76f597 |
Message-Id: <6b716d543f7e9a8e4c467d2dd0ccb7910c15fdf5@dist-git>
|
|
|
9de337 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
9de337 |
Date: Wed, 28 Jul 2021 17:37:21 +0200
|
|
|
9de337 |
Subject: [PATCH] RHEL: Enable usage of x-blockdev-reopen
|
|
|
9de337 |
MIME-Version: 1.0
|
|
|
9de337 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9de337 |
Content-Transfer-Encoding: 8bit
|
|
|
9de337 |
|
|
|
9de337 |
RHEL-only
|
|
|
9de337 |
|
|
|
9de337 |
Introduce a new capability QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API
|
|
|
9de337 |
based on the presence of '__com.redhat_rhel-av-8_2_0-api' feature for
|
|
|
9de337 |
'x-blockdev-reopen' which states that reopen works for what libvirt
|
|
|
9de337 |
is going to use it and wire up code to call the x- prefixed command.
|
|
|
9de337 |
|
|
|
9de337 |
This implementation will become dormant once qemu starts supporting
|
|
|
9de337 |
upstream-stable blockdev-reopen.
|
|
|
9de337 |
|
|
|
9de337 |
https://bugzilla.redhat.com/show_bug.cgi?id=1799013
|
|
|
9de337 |
|
|
|
9de337 |
Starting with libvirt-7.6, upstream has adapted to the new format of
|
|
|
9de337 |
arguments so this patch was modified to support blockdev-reopen which
|
|
|
9de337 |
takes an array of nodes to reopen.
|
|
|
9de337 |
|
|
|
9de337 |
https://bugzilla.redhat.com/show_bug.cgi?id=1929765
|
|
|
9de337 |
Message-Id: <3fcde2fc6add36d5276ae224caf18adc8bca7d48.1627486352.git.pkrempa@redhat.com>
|
|
|
9de337 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
9de337 |
---
|
|
|
9de337 |
src/qemu/qemu_block.c | 24 +++++++++++++++---------
|
|
|
9de337 |
src/qemu/qemu_block.h | 3 ++-
|
|
|
76f597 |
src/qemu/qemu_capabilities.c | 11 +++++++++++
|
|
|
76f597 |
src/qemu/qemu_capabilities.h | 1 +
|
|
|
9de337 |
src/qemu/qemu_monitor.c | 5 +++--
|
|
|
9de337 |
src/qemu/qemu_monitor.h | 3 ++-
|
|
|
9de337 |
src/qemu/qemu_monitor_json.c | 12 +++++++++---
|
|
|
9de337 |
src/qemu/qemu_monitor_json.h | 3 ++-
|
|
|
9de337 |
tests/qemumonitorjsontest.c | 2 +-
|
|
|
76f597 |
9 files changed, 46 insertions(+), 18 deletions(-)
|
|
|
9de337 |
|
|
|
9de337 |
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
|
|
|
76f597 |
index 34fdec2c4b..84528c2d17 100644
|
|
|
9de337 |
--- a/src/qemu/qemu_block.c
|
|
|
9de337 |
+++ b/src/qemu/qemu_block.c
|
|
|
76f597 |
@@ -3322,7 +3322,8 @@ qemuBlockBitmapsHandleCommitFinish(virStorageSource *topsrc,
|
|
|
9de337 |
|
|
|
9de337 |
int
|
|
|
9de337 |
qemuBlockReopenFormatMon(qemuMonitor *mon,
|
|
|
9de337 |
- virStorageSource *src)
|
|
|
9de337 |
+ virStorageSource *src,
|
|
|
9de337 |
+ bool downstream)
|
|
|
9de337 |
{
|
|
|
9de337 |
g_autoptr(virJSONValue) reopenprops = NULL;
|
|
|
9de337 |
g_autoptr(virJSONValue) srcprops = NULL;
|
|
|
76f597 |
@@ -3331,15 +3332,19 @@ qemuBlockReopenFormatMon(qemuMonitor *mon,
|
|
|
9de337 |
if (!(srcprops = qemuBlockStorageSourceGetBlockdevProps(src, src->backingStore)))
|
|
|
9de337 |
return -1;
|
|
|
9de337 |
|
|
|
9de337 |
- if (virJSONValueArrayAppend(reopenoptions, &srcprops) < 0)
|
|
|
9de337 |
- return -1;
|
|
|
9de337 |
+ if (downstream) {
|
|
|
9de337 |
+ reopenprops = g_steal_pointer(&srcprops);
|
|
|
9de337 |
+ } else {
|
|
|
9de337 |
+ if (virJSONValueArrayAppend(reopenoptions, &srcprops) < 0)
|
|
|
9de337 |
+ return -1;
|
|
|
9de337 |
|
|
|
9de337 |
- if (virJSONValueObjectCreate(&reopenprops,
|
|
|
9de337 |
- "a:options", &reopenoptions,
|
|
|
9de337 |
- NULL) < 0)
|
|
|
9de337 |
- return -1;
|
|
|
9de337 |
+ if (virJSONValueObjectCreate(&reopenprops,
|
|
|
9de337 |
+ "a:options", &reopenoptions,
|
|
|
9de337 |
+ NULL) < 0)
|
|
|
9de337 |
+ return -1;
|
|
|
9de337 |
+ }
|
|
|
9de337 |
|
|
|
9de337 |
- if (qemuMonitorBlockdevReopen(mon, &reopenprops) < 0)
|
|
|
9de337 |
+ if (qemuMonitorBlockdevReopen(mon, &reopenprops, downstream) < 0)
|
|
|
9de337 |
return -1;
|
|
|
9de337 |
|
|
|
9de337 |
return 0;
|
|
|
76f597 |
@@ -3363,6 +3368,7 @@ qemuBlockReopenFormat(virDomainObj *vm,
|
|
|
9de337 |
{
|
|
|
9de337 |
qemuDomainObjPrivate *priv = vm->privateData;
|
|
|
9de337 |
virQEMUDriver *driver = priv->driver;
|
|
|
9de337 |
+ bool downstream = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API);
|
|
|
9de337 |
int rc;
|
|
|
9de337 |
|
|
|
9de337 |
/* If we are lacking the object here, qemu might have opened an image with
|
|
|
76f597 |
@@ -3376,7 +3382,7 @@ qemuBlockReopenFormat(virDomainObj *vm,
|
|
|
9de337 |
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
|
|
9de337 |
return -1;
|
|
|
9de337 |
|
|
|
9de337 |
- rc = qemuBlockReopenFormatMon(priv->mon, src);
|
|
|
9de337 |
+ rc = qemuBlockReopenFormatMon(priv->mon, src, downstream);
|
|
|
9de337 |
|
|
|
9de337 |
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
|
|
|
9de337 |
return -1;
|
|
|
9de337 |
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
|
|
|
9de337 |
index 54601a48a9..88fc9974c4 100644
|
|
|
9de337 |
--- a/src/qemu/qemu_block.h
|
|
|
9de337 |
+++ b/src/qemu/qemu_block.h
|
|
|
9de337 |
@@ -268,7 +268,8 @@ qemuBlockBitmapsHandleCommitFinish(virStorageSource *topsrc,
|
|
|
9de337 |
/* only for use in qemumonitorjsontest */
|
|
|
9de337 |
int
|
|
|
9de337 |
qemuBlockReopenFormatMon(qemuMonitor *mon,
|
|
|
9de337 |
- virStorageSource *src);
|
|
|
9de337 |
+ virStorageSource *src,
|
|
|
9de337 |
+ bool downstream);
|
|
|
9de337 |
|
|
|
9de337 |
int
|
|
|
9de337 |
qemuBlockReopenReadWrite(virDomainObj *vm,
|
|
|
9de337 |
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
|
|
76f597 |
index 881bdaa855..24ac70048d 100644
|
|
|
9de337 |
--- a/src/qemu/qemu_capabilities.c
|
|
|
9de337 |
+++ b/src/qemu/qemu_capabilities.c
|
|
|
76f597 |
@@ -651,6 +651,7 @@ VIR_ENUM_IMPL(virQEMUCaps,
|
|
|
76f597 |
"device.json", /* QEMU_CAPS_DEVICE_JSON */
|
|
|
76f597 |
"query-dirty-rate", /* QEMU_CAPS_QUERY_DIRTY_RATE */
|
|
|
76f597 |
"rbd-encryption", /* QEMU_CAPS_RBD_ENCRYPTION */
|
|
|
aa5bf2 |
+ "blockdev-reopen.__com.redhat_rhel-av-8_2_0-api", /* QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API */
|
|
|
9de337 |
);
|
|
|
9de337 |
|
|
|
9de337 |
|
|
|
76f597 |
@@ -1552,6 +1553,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVhostUserFS[] =
|
|
|
9de337 |
/* see documentation for virQEMUQAPISchemaPathGet for the query format */
|
|
|
9de337 |
static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = {
|
|
|
aa5bf2 |
{ "block-commit/arg-type/*top", QEMU_CAPS_ACTIVE_COMMIT },
|
|
|
9de337 |
+ { "x-blockdev-reopen/$__com.redhat_rhel-av-8_2_0-api", QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API },
|
|
|
9de337 |
{ "blockdev-add/arg-type/options/+gluster/debug-level", QEMU_CAPS_GLUSTER_DEBUG_LEVEL},
|
|
|
9de337 |
{ "blockdev-add/arg-type/+gluster/debug", QEMU_CAPS_GLUSTER_DEBUG_LEVEL},
|
|
|
9de337 |
{ "blockdev-add/arg-type/+vxhs", QEMU_CAPS_VXHS},
|
|
|
76f597 |
@@ -5148,6 +5150,15 @@ virQEMUCapsInitProcessCaps(virQEMUCaps *qemuCaps)
|
|
|
9de337 |
qemuCaps->arch == VIR_ARCH_MIPS)
|
|
|
9de337 |
virQEMUCapsSet(qemuCaps, QEMU_CAPS_SCSI_NCR53C90);
|
|
|
9de337 |
|
|
|
9de337 |
+ /* RHEL-only:
|
|
|
9de337 |
+ * - if upstream blockdev-reopen is enabled, clear the downstream flag
|
|
|
9de337 |
+ * - if the downstream flag is present but not the upstream, assert the upstream flag too
|
|
|
9de337 |
+ */
|
|
|
9de337 |
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN))
|
|
|
9de337 |
+ virQEMUCapsClear(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API);
|
|
|
9de337 |
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API))
|
|
|
9de337 |
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN);
|
|
|
9de337 |
+
|
|
|
9de337 |
virQEMUCapsInitProcessCapsInterlock(qemuCaps);
|
|
|
9de337 |
}
|
|
|
9de337 |
|
|
|
9de337 |
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
|
|
|
76f597 |
index 2bca284e10..645a5f3cf5 100644
|
|
|
9de337 |
--- a/src/qemu/qemu_capabilities.h
|
|
|
9de337 |
+++ b/src/qemu/qemu_capabilities.h
|
|
|
76f597 |
@@ -631,6 +631,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
|
|
|
76f597 |
QEMU_CAPS_DEVICE_JSON, /* -device accepts JSON */
|
|
|
76f597 |
QEMU_CAPS_QUERY_DIRTY_RATE, /* accepts query-dirty-rate */
|
|
|
76f597 |
QEMU_CAPS_RBD_ENCRYPTION, /* Ceph RBD encryption support */
|
|
|
aa5bf2 |
+ QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API, /* downstream support for blockdev reopen in rhel-av-8.2.0 */
|
|
|
76f597 |
|
|
|
9de337 |
QEMU_CAPS_LAST /* this must always be the last item */
|
|
|
9de337 |
} virQEMUCapsFlags;
|
|
|
9de337 |
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
|
|
|
76f597 |
index 908ee0d302..4ac0b41df9 100644
|
|
|
9de337 |
--- a/src/qemu/qemu_monitor.c
|
|
|
9de337 |
+++ b/src/qemu/qemu_monitor.c
|
|
|
76f597 |
@@ -4309,14 +4309,15 @@ qemuMonitorBlockdevAdd(qemuMonitor *mon,
|
|
|
9de337 |
|
|
|
9de337 |
int
|
|
|
9de337 |
qemuMonitorBlockdevReopen(qemuMonitor *mon,
|
|
|
9de337 |
- virJSONValue **props)
|
|
|
9de337 |
+ virJSONValue **props,
|
|
|
9de337 |
+ bool downstream)
|
|
|
9de337 |
{
|
|
|
9de337 |
VIR_DEBUG("props=%p (node-name=%s)", *props,
|
|
|
9de337 |
NULLSTR(virJSONValueObjectGetString(*props, "node-name")));
|
|
|
9de337 |
|
|
|
9de337 |
QEMU_CHECK_MONITOR(mon);
|
|
|
9de337 |
|
|
|
9de337 |
- return qemuMonitorJSONBlockdevReopen(mon, props);
|
|
|
9de337 |
+ return qemuMonitorJSONBlockdevReopen(mon, props, downstream);
|
|
|
9de337 |
}
|
|
|
9de337 |
|
|
|
9de337 |
|
|
|
9de337 |
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
|
|
|
76f597 |
index b54c1cf87a..06b42b6a10 100644
|
|
|
9de337 |
--- a/src/qemu/qemu_monitor.h
|
|
|
9de337 |
+++ b/src/qemu/qemu_monitor.h
|
|
|
76f597 |
@@ -1420,7 +1420,8 @@ int qemuMonitorBlockdevAdd(qemuMonitor *mon,
|
|
|
9de337 |
virJSONValue **props);
|
|
|
9de337 |
|
|
|
9de337 |
int qemuMonitorBlockdevReopen(qemuMonitor *mon,
|
|
|
9de337 |
- virJSONValue **props);
|
|
|
9de337 |
+ virJSONValue **props,
|
|
|
9de337 |
+ bool downstream);
|
|
|
9de337 |
|
|
|
9de337 |
int qemuMonitorBlockdevDel(qemuMonitor *mon,
|
|
|
9de337 |
const char *nodename);
|
|
|
9de337 |
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
|
|
|
76f597 |
index e9be9bdabd..02b2b61dd3 100644
|
|
|
9de337 |
--- a/src/qemu/qemu_monitor_json.c
|
|
|
9de337 |
+++ b/src/qemu/qemu_monitor_json.c
|
|
|
76f597 |
@@ -7969,13 +7969,19 @@ qemuMonitorJSONBlockdevAdd(qemuMonitor *mon,
|
|
|
9de337 |
|
|
|
9de337 |
int
|
|
|
9de337 |
qemuMonitorJSONBlockdevReopen(qemuMonitor *mon,
|
|
|
9de337 |
- virJSONValue **props)
|
|
|
9de337 |
+ virJSONValue **props,
|
|
|
9de337 |
+ bool downstream)
|
|
|
9de337 |
{
|
|
|
9de337 |
g_autoptr(virJSONValue) cmd = NULL;
|
|
|
9de337 |
g_autoptr(virJSONValue) reply = NULL;
|
|
|
9de337 |
|
|
|
9de337 |
- if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", props)))
|
|
|
9de337 |
- return -1;
|
|
|
9de337 |
+ if (downstream) {
|
|
|
9de337 |
+ if (!(cmd = qemuMonitorJSONMakeCommandInternal("x-blockdev-reopen", props)))
|
|
|
9de337 |
+ return -1;
|
|
|
9de337 |
+ } else {
|
|
|
9de337 |
+ if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", props)))
|
|
|
9de337 |
+ return -1;
|
|
|
9de337 |
+ }
|
|
|
9de337 |
|
|
|
9de337 |
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
|
|
9de337 |
return -1;
|
|
|
9de337 |
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
|
|
|
76f597 |
index f9e01e5bf5..dba004be5b 100644
|
|
|
9de337 |
--- a/src/qemu/qemu_monitor_json.h
|
|
|
9de337 |
+++ b/src/qemu/qemu_monitor_json.h
|
|
|
76f597 |
@@ -594,7 +594,8 @@ int qemuMonitorJSONBlockdevAdd(qemuMonitor *mon,
|
|
|
9de337 |
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
9de337 |
|
|
|
9de337 |
int qemuMonitorJSONBlockdevReopen(qemuMonitor *mon,
|
|
|
9de337 |
- virJSONValue **props)
|
|
|
9de337 |
+ virJSONValue **props,
|
|
|
9de337 |
+ bool downstream)
|
|
|
9de337 |
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
9de337 |
|
|
|
9de337 |
int qemuMonitorJSONBlockdevDel(qemuMonitor *mon,
|
|
|
9de337 |
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
|
|
|
76f597 |
index e5ba39cd2f..f45302dfe8 100644
|
|
|
9de337 |
--- a/tests/qemumonitorjsontest.c
|
|
|
9de337 |
+++ b/tests/qemumonitorjsontest.c
|
|
|
76f597 |
@@ -2793,7 +2793,7 @@ testQemuMonitorJSONBlockdevReopen(const void *opaque)
|
|
|
9de337 |
if (qemuMonitorTestAddItem(test, "blockdev-reopen", "{\"return\":{}}") < 0)
|
|
|
9de337 |
return -1;
|
|
|
9de337 |
|
|
|
9de337 |
- if (qemuBlockReopenFormatMon(qemuMonitorTestGetMonitor(test), src) < 0)
|
|
|
9de337 |
+ if (qemuBlockReopenFormatMon(qemuMonitorTestGetMonitor(test), src, false) < 0)
|
|
|
9de337 |
return -1;
|
|
|
9de337 |
|
|
|
9de337 |
return 0;
|
|
|
9de337 |
--
|
|
|
76f597 |
2.33.1
|
|
|
9de337 |
|