[libvirt] [PATCH v2 1/3] qemu: Remove CPU features functions calling for non-x86 platform.

Li Zhang zhlcindy at gmail.com
Fri Sep 6 06:34:09 UTC 2013


On 2013年09月05日 19:08, Daniel P. Berrange wrote:
> On Tue, Sep 03, 2013 at 02:28:23PM +0800, Li Zhang wrote:
>> From: Li Zhang <zhlcindy at linux.vnet.ibm.com>
>>
>> CPU features are not supported on non-x86 and hasFeatures will be NULL.
>>
>> This patch is to remove CPU features functions calling to avoid errors.
>>
>> Signed-off-by: Li Zhang <zhlcindy at linux.vnet.ibm.com>
>> ---
>>   src/qemu/qemu_command.c | 16 ++++++++++------
>>   1 file changed, 10 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
>> index f8fccea..3b6ba7a 100644
>> --- a/src/qemu/qemu_command.c
>> +++ b/src/qemu/qemu_command.c
>> @@ -6349,7 +6349,6 @@ qemuBuildCpuArgStr(const virQEMUDriverPtr driver,
>>           (def->cpu->mode != VIR_CPU_MODE_CUSTOM || def->cpu->model)) {
>>           virCPUCompareResult cmp;
>>           const char *preferred;
>> -        int hasSVM;
>>   
>>           if (!host ||
>>               !host->model ||
>> @@ -6389,10 +6388,13 @@ qemuBuildCpuArgStr(const virQEMUDriverPtr driver,
>>           /* Only 'svm' requires --enable-nesting. The nested
>>            * 'vmx' patches now simply hook off the CPU features
>>            */
>> -        hasSVM = cpuHasFeature(data, "svm");
>> -        if (hasSVM < 0)
>> -            goto cleanup;
>> -        *hasHwVirt = hasSVM > 0 ? true : false;
>> +        if (def->os.arch == VIR_ARCH_X86_64 ||
>> +            def->os.arch == VIR_ARCH_I686) {
>> +            int hasSVM = cpuHasFeature(data, "svm");
>> +            if (hasSVM < 0)
>> +                goto cleanup;
>> +            *hasHwVirt = hasSVM > 0 ? true : false;
>> +        }
>>   
>>           if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) {
>>               const char *mode = virCPUModeTypeToString(cpu->mode);
> This bit looks good.
>
>> @@ -10575,7 +10577,9 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
>>                       model = NULL;
>>                   }
>>   
>> -                if (virCPUDefAddFeature(cpu, feature, policy) < 0)
>> +                if ((dom->os.arch == VIR_ARCH_X86_64 ||
>> +                    dom->os.arch == VIR_ARCH_I686) &&
>> +                    virCPUDefAddFeature(cpu, feature, policy) < 0)
>>                       goto cleanup;
>>               }
>>           } else if (STRPREFIX(tokens[i], "hv_")) {
> For this, I think we should virReportError() if we find a CPU flag on
> the command line for non-x86 arches, instead of silently ignoring it.

Okay, I will change it.

Thanks.
>
> I think I'd also like to split this patch in two. I'll apply the first
> chunk of it now.
>
> Daniel




More information about the libvir-list mailing list