render / rpms / libvirt

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