From 856587ea64814d7d3d5bde30dc0ea4d352338c87 Mon Sep 17 00:00:00 2001 From: Tobin Feldman-Fitzthum <tobin@linux.vnet.ibm.com> Date: Wed, 22 Apr 2020 17:50:43 -0400 Subject: [PATCH] qemu: Add virQEMUCapsGetVirtType convenience function Signed-off-by: Tobin Feldman-Fitzthum <tobin@linux.vnet.ibm.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_capabilities.c | 25 ++++++++++++++++--------- src/qemu/qemu_capabilities.h | 2 ++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2c63506214..47f88481c8 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4999,6 +4999,20 @@ virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCapsPtr qemuCaps, #define QEMU_MIN_MINOR 5 #define QEMU_MIN_MICRO 0 +virDomainVirtType +virQEMUCapsGetVirtType(virQEMUCapsPtr qemuCaps) +{ + virDomainVirtType type; + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) + type = VIR_DOMAIN_VIRT_KVM; + else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_TCG)) + type = VIR_DOMAIN_VIRT_QEMU; + else + type = VIR_DOMAIN_VIRT_NONE; + + return type; +} + int virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) @@ -5043,11 +5057,7 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, if (virQEMUCapsProbeQMPKVMState(qemuCaps, mon) < 0) return -1; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) - type = VIR_DOMAIN_VIRT_KVM; - else - type = VIR_DOMAIN_VIRT_QEMU; - + type = virQEMUCapsGetVirtType(qemuCaps); accel = virQEMUCapsGetAccel(qemuCaps, type); if (virQEMUCapsProbeQMPEvents(qemuCaps, mon) < 0) @@ -5540,10 +5550,7 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache, goto cleanup; } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) - capsType = VIR_DOMAIN_VIRT_KVM; - else - capsType = VIR_DOMAIN_VIRT_QEMU; + capsType = virQEMUCapsGetVirtType(qemuCaps); if (virttype == VIR_DOMAIN_VIRT_NONE) virttype = capsType; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 9092da047d..cdeaf09cce 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -642,6 +642,8 @@ int virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps, bool migratable, char ***features); +virDomainVirtType virQEMUCapsGetVirtType(virQEMUCapsPtr qemuCaps); + bool virQEMUCapsIsArchSupported(virQEMUCapsPtr qemuCaps, virArch arch); bool virQEMUCapsIsVirtTypeSupported(virQEMUCapsPtr qemuCaps, -- GitLab