From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Eric Blake <eblake@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Peter Krempa <pkrempa@redhat.com>
Subject: [Qemu-devel] [PATCH] qmp: add query-qemu-capabilities
Date: Fri, 22 Feb 2019 15:32:54 +0000 [thread overview]
Message-ID: <20190222153254.22739-1-stefanha@redhat.com> (raw)
QMP clients can usually detect the presence of features via schema
introspection. There are rare features that do not involve schema
changes and are therefore impossible to detect with schema
introspection.
This patch adds the query-qemu-capabilities command. It returns a list
of capabilities that this QEMU supports.
The decision to make this a command rather than something statically
defined in the schema is intentional. It allows QEMU to decide which
capabilities are available at runtime, if necessary.
This new interface is necessary so that QMP clients can discover that
migrating disk image files is safe with cache.direct=off on Linux.
There is no other way to detect whether or not QEMU supports this.
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
qapi/misc.json | 42 ++++++++++++++++++++++++++++++++++++++++++
qmp.c | 18 ++++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/qapi/misc.json b/qapi/misc.json
index 8b3ca4fdd3..9cf24919a3 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -3051,3 +3051,45 @@
'data': 'NumaOptions',
'allow-preconfig': true
}
+
+##
+# @QemuCapability:
+#
+# Capabilities that are not otherwise introspectable.
+#
+# @migrate-with-cache-direct-off-on-linux:
+# It is safe to migrate disk image files with cache.direct=off on Linux.
+# Previously only cache.direct=on was supported for live migration.
+#
+# Since: 4.0
+##
+{ 'enum': 'QemuCapability',
+ 'data': [
+ 'migrate-with-cache-direct-off-on-linux'
+ ]
+}
+
+##
+# @QemuCapabilities:
+#
+# Capability information.
+#
+# @capabilities: supported capabilities
+#
+# Since: 4.0
+##
+{ 'struct': 'QemuCapabilities',
+ 'data': { 'capabilities': ['QemuCapability'] } }
+
+##
+# @query-qemu-capabilities:
+#
+# Return the capabilities supported by this QEMU. Most features can be
+# detected via schema introspection but some are not observable from the
+# schema. This command offers a way to check for the presence of such
+# features.
+#
+# Since: 4.0
+##
+{ 'command': 'query-qemu-capabilities',
+ 'returns': 'QemuCapabilities' }
diff --git a/qmp.c b/qmp.c
index b92d62cd5f..91a1228be7 100644
--- a/qmp.c
+++ b/qmp.c
@@ -717,3 +717,21 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp)
return mem_info;
}
+
+QemuCapabilities *qmp_query_qemu_capabilities(Error **errp)
+{
+ QemuCapabilities *caps = g_new0(QemuCapabilities, 1);
+ QemuCapabilityList **prev = &caps->capabilities;
+ QemuCapability cap_val;
+
+ /* Add all QemuCapability enum values defined in the schema */
+ for (cap_val = 0; cap_val < QEMU_CAPABILITY__MAX; cap_val++) {
+ QemuCapabilityList *cap = g_new0(QemuCapabilityList, 1);
+
+ cap->value = cap_val;
+ *prev = cap;
+ prev = &cap->next;
+ }
+
+ return caps;
+}
--
2.20.1
next reply other threads:[~2019-02-22 15:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 15:32 Stefan Hajnoczi [this message]
2019-02-25 8:50 ` [Qemu-devel] [PATCH] qmp: add query-qemu-capabilities Markus Armbruster
2019-02-25 9:28 ` Peter Krempa
2019-02-25 17:40 ` Stefan Hajnoczi
2019-02-26 7:44 ` Peter Krempa
2019-02-26 9:09 ` Markus Armbruster
2019-02-27 14:51 ` Stefan Hajnoczi
2019-02-27 19:25 ` Markus Armbruster
2019-02-27 15:15 ` Stefan Hajnoczi
2019-02-27 15:25 ` Daniel P. Berrangé
2019-02-27 17:12 ` Stefan Hajnoczi
2019-02-25 17:06 ` Stefan Hajnoczi
2019-02-26 7:23 ` Markus Armbruster
2019-03-08 10:35 ` Stefan Hajnoczi
2019-03-08 12:15 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190222153254.22739-1-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=pkrempa@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).