render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
edecca
From b8ca3f396e09f0ba190656363c0d1fc6a0dd9cd6 Mon Sep 17 00:00:00 2001
edecca
Message-Id: <b8ca3f396e09f0ba190656363c0d1fc6a0dd9cd6@dist-git>
edecca
From: Andrea Bolognani <abologna@redhat.com>
edecca
Date: Mon, 17 Sep 2018 18:00:52 +0200
edecca
Subject: [PATCH] qemu: Clarify QEMU_CAPS_KVM
edecca
edecca
This capability is documented as having one meaning (whether
edecca
KVM is enabled by default) but is actually assigned two other
edecca
meanings over its life: whether the query-kvm QMP command is
edecca
available at first, and later on whether KVM is usable / was
edecca
used during probing.
edecca
edecca
Since the query-kvm QMP command was available in 1.5.0, we
edecca
can avoid probing for it; additionally, we can simplify the
edecca
logic by setting the flag when it applies instead of initially
edecca
setting it and then clearing it when it doesn't.
edecca
edecca
The flag's description is also updated to reflect reality.
edecca
edecca
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
edecca
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
edecca
(cherry picked from commit c3be8bb4235b447dc29568f96b8c31cc741fc358)
edecca
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1629862
edecca
edecca
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
edecca
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
edecca
---
edecca
 src/qemu/qemu_capabilities.c | 19 ++-----------------
edecca
 src/qemu/qemu_capabilities.h |  2 +-
edecca
 2 files changed, 3 insertions(+), 18 deletions(-)
edecca
edecca
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
edecca
index 9b3f35553b..c7ece21dd2 100644
edecca
--- a/src/qemu/qemu_capabilities.c
edecca
+++ b/src/qemu/qemu_capabilities.c
edecca
@@ -1003,7 +1003,6 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = {
edecca
     { "block-stream", QEMU_CAPS_BLOCKJOB_ASYNC },
edecca
     { "dump-guest-memory", QEMU_CAPS_DUMP_GUEST_MEMORY },
edecca
     { "query-spice", QEMU_CAPS_SPICE },
edecca
-    { "query-kvm", QEMU_CAPS_KVM },
edecca
     { "block-commit", QEMU_CAPS_BLOCK_COMMIT },
edecca
     { "query-vnc", QEMU_CAPS_VNC },
edecca
     { "drive-mirror", QEMU_CAPS_DRIVE_MIRROR },
edecca
@@ -2584,25 +2583,11 @@ virQEMUCapsProbeQMPKVMState(virQEMUCapsPtr qemuCaps,
edecca
     bool enabled = false;
edecca
     bool present = false;
edecca
 
edecca
-    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
edecca
-        return 0;
edecca
-
edecca
     if (qemuMonitorGetKVMState(mon, &enabled, &present) < 0)
edecca
         return -1;
edecca
 
edecca
-    /* The QEMU_CAPS_KVM flag was initially set according to the QEMU
edecca
-     * reporting the recognition of 'query-kvm' QMP command. That merely
edecca
-     * indicates existence of the command though, not whether KVM support
edecca
-     * is actually available, nor whether it is enabled by default.
edecca
-     *
edecca
-     * If it is not present we need to clear the flag, and if it is
edecca
-     * not enabled by default we need to change the flag.
edecca
-     */
edecca
-    if (!present) {
edecca
-        virQEMUCapsClear(qemuCaps, QEMU_CAPS_KVM);
edecca
-    } else if (!enabled) {
edecca
-        virQEMUCapsClear(qemuCaps, QEMU_CAPS_KVM);
edecca
-    }
edecca
+    if (present && enabled)
edecca
+        virQEMUCapsSet(qemuCaps, QEMU_CAPS_KVM);
edecca
 
edecca
     return 0;
edecca
 }
edecca
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
edecca
index 98668115d6..6acd9fe825 100644
edecca
--- a/src/qemu/qemu_capabilities.h
edecca
+++ b/src/qemu/qemu_capabilities.h
edecca
@@ -65,7 +65,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
edecca
     X_QEMU_CAPS_MIGRATE_QEMU_TCP, /* have qemu tcp migration */
edecca
     X_QEMU_CAPS_MIGRATE_QEMU_EXEC, /* have qemu exec migration */
edecca
     X_QEMU_CAPS_DRIVE_CACHE_V2, /* cache= flag wanting new v2 values */
edecca
-    QEMU_CAPS_KVM, /* Whether KVM is enabled by default */
edecca
+    QEMU_CAPS_KVM, /* Whether KVM is usable / was used during probing */
edecca
     X_QEMU_CAPS_DRIVE_FORMAT, /* Is -drive format= avail */
edecca
 
edecca
     /* 15 */
edecca
-- 
edecca
2.19.1
edecca