https://bugzilla.redhat.com/show_bug.cgi?id=1140981 reports that
the qemu-kvm shipped as part of RHEL 7.0 intentionally cripples
block jobs by removing the 'block-stream' QMP command, but that
our probe for whether block jobs work was merely whether
'block-job-cancel' exists. As the crippling did not remove
job cancellation, we end up trying the qemu command and printing
an ugly message:
error: Requested operation is not valid: Command 'block-stream' is not found
even though our code base was already prepared to print a nice
message that jobs are unsupported:
error: unsupported configuration: block jobs not supported with this qemu binary
Doing one more QMP probe lets us match the reality of crippled qemu.
Yes, we really have to cater to two spellings of the command, due to
older upstream qemu.
* src/qemu/qemu_capabilities.h (QEMU_CAPS_BLOCK_STREAM): New probe.
* src/qemu/qemu_capabilities.c (virQEMUCapsProbeQMPCommands): Kill
block jobs with nice error message if qemu is crippled.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 11 +++++++++++
src/qemu/qemu_capabilities.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 6fcb5c7..53cf05f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -271,6 +271,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"iothread",
"migrate-rdma",
"ivshmem",
+ "block-stream",
);
@@ -1424,6 +1425,8 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = {
{ "transaction", QEMU_CAPS_TRANSACTION },
{ "block_job_cancel", QEMU_CAPS_BLOCKJOB_SYNC },
{ "block-job-cancel", QEMU_CAPS_BLOCKJOB_ASYNC },
+ { "block_stream", QEMU_CAPS_BLOCK_STREAM },
+ { "block-stream", QEMU_CAPS_BLOCK_STREAM },
{ "dump-guest-memory", QEMU_CAPS_DUMP_GUEST_MEMORY },
{ "query-spice", QEMU_CAPS_SPICE },
{ "query-kvm", QEMU_CAPS_KVM },
@@ -2195,6 +2198,14 @@ virQEMUCapsProbeQMPCommands(virQEMUCapsPtr qemuCaps,
ncommands, commands);
virQEMUCapsFreeStringList(ncommands, commands);
+ /* Some RHEL builds of qemu-kvm have 'block-job-cancel' but no way
+ * to start a block job; in that case, our error messages are
+ * nicer if we pretend there is no blockjob support at all. */
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCK_STREAM)) {
+ virQEMUCapsClear(qemuCaps, QEMU_CAPS_BLOCKJOB_ASYNC);
+ virQEMUCapsClear(qemuCaps, QEMU_CAPS_BLOCKJOB_SYNC);
+ }
+
/* QMP add-fd was introduced in 1.2, but did not support
* management control of set numbering, and did not have a
* counterpart -add-fd command line option. We require the
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 0214f30..6486b5b 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -218,6 +218,7 @@ typedef enum {
QEMU_CAPS_OBJECT_IOTHREAD = 176, /* -object iothread */
QEMU_CAPS_MIGRATE_RDMA = 177, /* have rdma migration */
QEMU_CAPS_DEVICE_IVSHMEM = 178, /* -device ivshmem */
+ QEMU_CAPS_BLOCK_STREAM = 179, /* block-stream exists */
QEMU_CAPS_LAST, /* this must always be the last item */
} virQEMUCapsFlags;
--
1.9.3