Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 112 +++++++++++++++++++++----------------------
src/qemu/qemu_capabilities.h | 5 --
2 files changed, 56 insertions(+), 61 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c9c28da556..8a2a73dc5b 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4282,6 +4282,62 @@ virQEMUCapsReset(virQEMUCapsPtr qemuCaps)
}
+static bool
+virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps,
+ time_t qemuctime,
+ uid_t runUid,
+ gid_t runGid)
+{
+ bool kvmUsable;
+
+ if (!qemuCaps->binary)
+ return true;
+
+ if (!qemuctime) {
+ struct stat sb;
+
+ if (stat(qemuCaps->binary, &sb) < 0) {
+ char ebuf[1024];
+ VIR_DEBUG("Failed to stat QEMU binary '%s': %s",
+ qemuCaps->binary,
+ virStrerror(errno, ebuf, sizeof(ebuf)));
+ return false;
+ }
+ qemuctime = sb.st_ctime;
+ }
+
+ if (qemuctime != qemuCaps->ctime) {
+ VIR_DEBUG("Outdated capabilities for '%s': QEMU binary changed
"
+ "(%lld vs %lld)",
+ qemuCaps->binary,
+ (long long) qemuctime, (long long) qemuCaps->ctime);
+ return false;
+ }
+
+ kvmUsable = virFileAccessibleAs("/dev/kvm", R_OK | W_OK,
+ runUid, runGid) == 0;
+
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_ENABLE_KVM) &&
+ kvmUsable) {
+ VIR_DEBUG("KVM was not enabled when probing '%s', "
+ "but it should be usable now",
+ qemuCaps->binary);
+ return false;
+ }
+
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
+ !kvmUsable) {
+ VIR_DEBUG("KVM was enabled when probing '%s', "
+ "but it is not available now",
+ qemuCaps->binary);
+ return false;
+ }
+
+ return true;
+}
+
+
static int
virQEMUCapsInitCached(virCapsPtr caps,
virQEMUCapsPtr qemuCaps,
@@ -5277,62 +5333,6 @@ virQEMUCapsNewForBinary(virCapsPtr caps,
}
-bool
-virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps,
- time_t qemuctime,
- uid_t runUid,
- gid_t runGid)
-{
- bool kvmUsable;
-
- if (!qemuCaps->binary)
- return true;
-
- if (!qemuctime) {
- struct stat sb;
-
- if (stat(qemuCaps->binary, &sb) < 0) {
- char ebuf[1024];
- VIR_DEBUG("Failed to stat QEMU binary '%s': %s",
- qemuCaps->binary,
- virStrerror(errno, ebuf, sizeof(ebuf)));
- return false;
- }
- qemuctime = sb.st_ctime;
- }
-
- if (qemuctime != qemuCaps->ctime) {
- VIR_DEBUG("Outdated capabilities for '%s': QEMU binary changed
"
- "(%lld vs %lld)",
- qemuCaps->binary,
- (long long) qemuctime, (long long) qemuCaps->ctime);
- return false;
- }
-
- kvmUsable = virFileAccessibleAs("/dev/kvm", R_OK | W_OK,
- runUid, runGid) == 0;
-
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_ENABLE_KVM) &&
- kvmUsable) {
- VIR_DEBUG("KVM was not enabled when probing '%s', "
- "but it should be usable now",
- qemuCaps->binary);
- return false;
- }
-
- if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
- !kvmUsable) {
- VIR_DEBUG("KVM was enabled when probing '%s', "
- "but it is not available now",
- qemuCaps->binary);
- return false;
- }
-
- return true;
-}
-
-
struct virQEMUCapsMachineTypeFilter {
const char *machineType;
virQEMUCapsFlags *flags;
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 6e95876e8d..7f5382df62 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -494,11 +494,6 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
size_t *nmachines,
virCapsGuestMachinePtr **machines);
-bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps,
- time_t ctime,
- uid_t runUid,
- gid_t runGid);
-
void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
const char *machineType);
--
2.13.2