From 99c1665ce717c86ae8bc300259fbc246cdf9ae06 Mon Sep 17 00:00:00 2001 Message-Id: <99c1665ce717c86ae8bc300259fbc246cdf9ae06@dist-git> From: Peter Krempa Date: Mon, 16 Mar 2020 22:12:34 +0100 Subject: [PATCH] RHEL: Enable usage of x-blockdev-reopen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RHEL-only Introduce a new capability QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API based on the presence of '__com.redhat_rhel-av-8_2_0-api' feature for 'x-blockdev-reopen' which states that reopen works for what libvirt is going to use it and wire up code to call the x- prefixed command. This implementation will become dormant once qemu starts supporting upstream-stable blockdev-reopen. https://bugzilla.redhat.com/show_bug.cgi?id=1953939 Message-Id: <098dc0e73e1b561af991f2a9ecf13436dde3b33d.1584391727.git.pkrempa@redhat.com> Reviewed-by: Ján Tomko --- src/qemu/qemu_block.c | 3 ++- src/qemu/qemu_capabilities.c | 11 +++++++++++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_monitor.c | 5 +++-- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 12 +++++++++--- src/qemu/qemu_monitor_json.h | 3 ++- 7 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 89f20eb1d2..e738433b04 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3305,6 +3305,7 @@ qemuBlockReopenFormat(virDomainObj *vm, qemuDomainObjPrivate *priv = vm->privateData; virQEMUDriver *driver = priv->driver; g_autoptr(virJSONValue) reopenprops = NULL; + bool downstream = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API); int rc; /* If we are lacking the object here, qemu might have opened an image with @@ -3321,7 +3322,7 @@ qemuBlockReopenFormat(virDomainObj *vm, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; - rc = qemuMonitorBlockdevReopen(priv->mon, &reopenprops); + rc = qemuMonitorBlockdevReopen(priv->mon, &reopenprops, downstream); if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) return -1; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7971a9c557..e2f4d6af7e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -629,6 +629,7 @@ VIR_ENUM_IMPL(virQEMUCaps, /* 400 */ "compat-deprecated", "acpi-index", + "blockdev-reopen.__com.redhat_rhel-av-8_2_0-api", ); @@ -1542,6 +1543,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVhostUserFS[] = /* see documentation for virQEMUQAPISchemaPathGet for the query format */ static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = { + { "x-blockdev-reopen/$__com.redhat_rhel-av-8_2_0-api", QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API }, { "blockdev-add/arg-type/options/+gluster/debug-level", QEMU_CAPS_GLUSTER_DEBUG_LEVEL}, { "blockdev-add/arg-type/+gluster/debug", QEMU_CAPS_GLUSTER_DEBUG_LEVEL}, { "blockdev-add/arg-type/+vxhs", QEMU_CAPS_VXHS}, @@ -5323,6 +5325,15 @@ virQEMUCapsInitProcessCaps(virQEMUCaps *qemuCaps) qemuCaps->arch == VIR_ARCH_MIPS) virQEMUCapsSet(qemuCaps, QEMU_CAPS_SCSI_NCR53C90); + /* RHEL-only: + * - if upstream blockdev-reopen is enabled, clear the downstream flag + * - if the downstream flag is present but not the upstream, assert the upstream flag too + */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN)) + virQEMUCapsClear(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API)) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN); + virQEMUCapsInitProcessCapsInterlock(qemuCaps); } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index f54aad5dfd..51e256e317 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -609,6 +609,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ /* 400 */ QEMU_CAPS_COMPAT_DEPRECATED, /* -compat deprecated-(input|output) is supported */ QEMU_CAPS_ACPI_INDEX, /* PCI device 'acpi-index' property */ + QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API, /* downstream support for blockdev reopen in rhel-av-8.2.0 */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 23161a0088..d5b53975f6 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4484,14 +4484,15 @@ qemuMonitorBlockdevAdd(qemuMonitor *mon, int qemuMonitorBlockdevReopen(qemuMonitor *mon, - virJSONValue **props) + virJSONValue **props, + bool downstream) { VIR_DEBUG("props=%p (node-name=%s)", *props, NULLSTR(virJSONValueObjectGetString(*props, "node-name"))); QEMU_CHECK_MONITOR(mon); - return qemuMonitorJSONBlockdevReopen(mon, props); + return qemuMonitorJSONBlockdevReopen(mon, props, downstream); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 420a85942a..759f9e1284 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1374,7 +1374,8 @@ int qemuMonitorBlockdevAdd(qemuMonitor *mon, virJSONValue **props); int qemuMonitorBlockdevReopen(qemuMonitor *mon, - virJSONValue **props); + virJSONValue **props, + bool downstream); int qemuMonitorBlockdevDel(qemuMonitor *mon, const char *nodename); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8de0e4b638..702c6fb8a1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8836,13 +8836,19 @@ qemuMonitorJSONBlockdevAdd(qemuMonitor *mon, int qemuMonitorJSONBlockdevReopen(qemuMonitor *mon, - virJSONValue **props) + virJSONValue **props, + bool downstream) { g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) reply = NULL; - if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", props))) - return -1; + if (downstream) { + if (!(cmd = qemuMonitorJSONMakeCommandInternal("x-blockdev-reopen", props))) + return -1; + } else { + if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", props))) + return -1; + } if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 8d8f2de479..b42fb8f83e 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -607,7 +607,8 @@ int qemuMonitorJSONBlockdevAdd(qemuMonitor *mon, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuMonitorJSONBlockdevReopen(qemuMonitor *mon, - virJSONValue **props) + virJSONValue **props, + bool downstream) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuMonitorJSONBlockdevDel(qemuMonitor *mon, -- 2.31.1