src/cpu/cpu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
virCPUCompareUnusable can be called with blockers == NULL in case the
CPU model itself is usable (i.e., QEMU reports an empty list of
blockers), but the CPU definition contains some additional features
which have to be checked.
Fixes: v10.8.0-129-g5f8abbb7d0
Reported-by: Han Han <hhan@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
src/cpu/cpu.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index 2b0d641e78..58fba3781c 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -201,11 +201,13 @@ virCPUCompareUnusable(virArch arch,
char **blocker;
size_t i;
- for (blocker = blockers; *blocker; blocker++) {
- if (!(feat = virCPUDefFindFeature(cpu, *blocker)) ||
- feat->policy != VIR_CPU_FEATURE_DISABLE) {
- virBufferAddStr(&features, *blocker);
- virBufferAddLit(&features, ", ");
+ if (blockers) {
+ for (blocker = blockers; *blocker; blocker++) {
+ if (!(feat = virCPUDefFindFeature(cpu, *blocker)) ||
+ feat->policy != VIR_CPU_FEATURE_DISABLE) {
+ virBufferAddStr(&features, *blocker);
+ virBufferAddLit(&features, ", ");
+ }
}
}
--
2.47.0
On Wed, Nov 27, 2024 at 08:38:41 +0100, Jiri Denemark wrote: > virCPUCompareUnusable can be called with blockers == NULL in case the > CPU model itself is usable (i.e., QEMU reports an empty list of > blockers), but the CPU definition contains some additional features > which have to be checked. > > Fixes: v10.8.0-129-g5f8abbb7d0 > Reported-by: Han Han <hhan@redhat.com> > Signed-off-by: Jiri Denemark <jdenemar@redhat.com> > --- > src/cpu/cpu.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) Reviewed-by: Peter Krempa <pkrempa@redhat.com>
On Wed, Nov 27, 2024 at 3:39 PM Jiri Denemark <jdenemar@redhat.com> wrote: > virCPUCompareUnusable can be called with blockers == NULL in case the > CPU model itself is usable (i.e., QEMU reports an empty list of > blockers), but the CPU definition contains some additional features > which have to be checked. > > Fixes: v10.8.0-129-g5f8abbb7d0 > Reported-by: Han Han <hhan@redhat.com> > Signed-off-by: Jiri Denemark <jdenemar@redhat.com> > --- > src/cpu/cpu.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > Patch it to v10.10.0-rc1-1-g444f45135a and test as the following: ➜ ~ virsh capabilities --xpath //cpu > /tmp/cpu.xml ➜ ~ virsh hypervisor-cpu-compare /tmp/cpu.xml The CPU provided by hypervisor on the host is a superset of CPU described in /tmp/cpu.xml No segment fault. It works. > diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c > index 2b0d641e78..58fba3781c 100644 > --- a/src/cpu/cpu.c > +++ b/src/cpu/cpu.c > @@ -201,11 +201,13 @@ virCPUCompareUnusable(virArch arch, > char **blocker; > size_t i; > > - for (blocker = blockers; *blocker; blocker++) { > - if (!(feat = virCPUDefFindFeature(cpu, *blocker)) || > - feat->policy != VIR_CPU_FEATURE_DISABLE) { > - virBufferAddStr(&features, *blocker); > - virBufferAddLit(&features, ", "); > + if (blockers) { > + for (blocker = blockers; *blocker; blocker++) { > + if (!(feat = virCPUDefFindFeature(cpu, *blocker)) || > + feat->policy != VIR_CPU_FEATURE_DISABLE) { > + virBufferAddStr(&features, *blocker); > + virBufferAddLit(&features, ", "); > + } > } > } > > -- > 2.47.0 > > -- Tested-by: Han Han <hhan@redhat.com>
© 2016 - 2024 Red Hat, Inc.