From: Roman Bolshakov <r.bolshakov(a)yadro.com>
It replaces hardcoded checks for KVM. It'll be cleaner to use
the function once multiple accelerators are supported in the
QEMU driver.
Explicit KVM domain checks should be done only when a feature is
available only for KVM.
Signed-off-by: Roman Bolshakov <r.bolshakov(a)yadro.com>
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c246e1b6ce..8e127c9041 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -802,6 +802,13 @@ virQEMUCapsAccelStr(virDomainVirtType type)
}
+static bool
+virQEMUCapsTypeIsAccelerated(virDomainVirtType type)
+{
+ return type == VIR_DOMAIN_VIRT_KVM;
+}
+
+
/* Checks whether a domain with @guest arch can run natively on @host.
*/
bool
@@ -2342,7 +2349,7 @@ virQEMUCapsIsCPUModeSupported(virQEMUCaps *qemuCaps,
switch (mode) {
case VIR_CPU_MODE_HOST_PASSTHROUGH:
- return type == VIR_DOMAIN_VIRT_KVM &&
+ return virQEMUCapsTypeIsAccelerated(type) &&
virQEMUCapsGuestIsNative(hostarch, qemuCaps->arch);
case VIR_CPU_MODE_HOST_MODEL:
@@ -3004,7 +3011,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps,
qemuMonitor *mon,
virDomainVirtType virtType)
{
- const char *model = virtType == VIR_DOMAIN_VIRT_KVM ? "host" :
"max";
+ const char *model = virQEMUCapsTypeIsAccelerated(virtType) ? "host" :
"max";
g_autoptr(qemuMonitorCPUModelInfo) modelInfo = NULL;
g_autoptr(qemuMonitorCPUModelInfo) nonMigratable = NULL;
g_autoptr(GHashTable) hash = NULL;
@@ -3715,7 +3722,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps,
virArchToString(qemuCaps->arch),
virDomainVirtTypeToString(type));
goto error;
- } else if (type == VIR_DOMAIN_VIRT_KVM &&
+ } else if (virQEMUCapsTypeIsAccelerated(type) &&
virCPUGetHostIsSupported(qemuCaps->arch)) {
if (!(fullCPU = virQEMUCapsProbeHostCPU(qemuCaps->arch, NULL)))
goto error;
@@ -5848,10 +5855,10 @@ virQEMUCapsCacheLookupDefault(virFileCache *cache,
if (virttype == VIR_DOMAIN_VIRT_NONE)
virttype = capsType;
- if (virttype == VIR_DOMAIN_VIRT_KVM && capsType == VIR_DOMAIN_VIRT_QEMU) {
+ if (virQEMUCapsTypeIsAccelerated(virttype) && capsType ==
VIR_DOMAIN_VIRT_QEMU) {
virReportError(VIR_ERR_INVALID_ARG,
- _("KVM is not supported by '%s' on this host"),
- binary);
+ _("the accel '%s' is not supported by '%s' on
this host"),
+ virQEMUCapsAccelStr(virttype), binary);
return NULL;
}
--
2.31.1