On 08/12/2016 09:33 AM, Jiri Denemark wrote:
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 55 ++++++++++++++++++++++++++++++++++----------
src/qemu/qemu_capabilities.h | 4 ++++
2 files changed, 47 insertions(+), 12 deletions(-)
So another 10 down almost 75% done! Let's consider ACK's again...
Still not sure about patch 20 w/r/t to the need for "unknown" printing,
the sorting by yes, no, and unknown, and whether LoadCache should "read"
what's been printed and validate against the current (if that matters).
As for 21-30, if there's no reply then an ACK can be implied. A couple
of replies (23, 24) make suggestions for function name changes - your
choice on those. Two (25, 27) I've just left some thoughts - they don't
really require changes.
Patch 22 will need an adjustment for an ACK, but the build would fail
anyway, so it's obvious.
Patch 26 needs an adjust to fix a leak for an ACK, your choice on
renaming cpuModel, and I think the virResetLastError should be called.
I've seen "future" patches where returning NULL may come into play...
Patch 28 - your call on the domain page reference
That just leaves this one with one innocuous adjustment shown below. Not
required for an ACK
John
diff --git a/src/qemu/qemu_capabilities.c
b/src/qemu/qemu_capabilities.c
index 670f944..f70a36c 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2302,6 +2302,32 @@ virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps)
}
+bool
+virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
+ virCapsPtr caps,
+ virDomainVirtType type,
+ virCPUMode mode)
+{
+ switch (mode) {
+ case VIR_CPU_MODE_HOST_PASSTHROUGH:
+ return type == VIR_DOMAIN_VIRT_KVM &&
+ virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch);
+
+ case VIR_CPU_MODE_HOST_MODEL:
+ return !!qemuCaps->cpuModel;
+
+ case VIR_CPU_MODE_CUSTOM:
+ return qemuCaps->cpuDefinitions &&
+ qemuCaps->cpuDefinitions->count > 0;
+
+ case VIR_CPU_MODE_LAST:
+ break;
+ }
+
+ return false;
+}
+
+
int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
size_t *nmachines,
virCapsGuestMachinePtr **machines)
@@ -4260,22 +4286,27 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps,
virQEMUCapsPtr qemuCaps,
virDomainCapsPtr domCaps)
{
- virDomainCapsCPUModelsPtr filtered = NULL;
- char **models = NULL;
-
- if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM &&
- virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch))
+ if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
+ VIR_CPU_MODE_HOST_PASSTHROUGH))
domCaps->cpu.hostPassthrough = true;
- domCaps->cpu.hostModel = virCPUDefCopy(qemuCaps->cpuModel);
+ if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
+ VIR_CPU_MODE_HOST_MODEL))
+ domCaps->cpu.hostModel = virCPUDefCopy(qemuCaps->cpuModel);
- if (qemuCaps->cpuDefinitions &&
- cpuGetModels(domCaps->arch, &models) >= 0) {
- filtered = virDomainCapsCPUModelsFilter(qemuCaps->cpuDefinitions,
- models);
- virStringFreeList(models);
+ if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
+ VIR_CPU_MODE_CUSTOM)) {
+ virDomainCapsCPUModelsPtr filtered = NULL;
+ char **models = NULL;
+
+ if (qemuCaps->cpuDefinitions &&
Redundant check for MODE_CUSTOM when ModeSupported is true
+ cpuGetModels(domCaps->arch, &models) >= 0) {
+ filtered = virDomainCapsCPUModelsFilter(qemuCaps->cpuDefinitions,
+ models);
+ virStringFreeList(models);
+ }
+ domCaps->cpu.custom = filtered;
}
- domCaps->cpu.custom = filtered;
return 0;
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 1203073..2ea5849 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -425,6 +425,10 @@ int virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
char ***names,
size_t *count);
virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps);
+bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
+ virCapsPtr caps,
+ virDomainVirtType type,
+ virCPUMode mode);
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
const char *name);
int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,