[libvirt PATCH v4 3/3] add virQEMUCapsProbeQMPTCGState function to set QEMU_CAPS_TCG_DISABLED

Michal Privoznik mprivozn at redhat.com
Fri Apr 24 15:31:10 UTC 2020


On 4/24/20 9:58 AM, Peter Krempa wrote:
> On Wed, Apr 22, 2020 at 17:50:44 -0400, Tobin Feldman-Fitzthum wrote:
>> Add virQEMUCapsProbeQMPTCGState to set TCG_DISABLED cap if version
>> is > 2.10, KVM is enabled, and tcg-accel is not present in
>> qom-list-types result.
>>
>> Signed-off-by: Tobin Feldman-Fitzthum <tobin at linux.vnet.ibm.com>
>> ---
>>   src/qemu/qemu_capabilities.c | 34 ++++++++++++++++++++++++++++++++--
>>   1 file changed, 32 insertions(+), 2 deletions(-)
> 
> I don't feel comfortable reviewing the other two patches which deal with
> the actual use of the capability, so I'll leave those for somebody else.
> 
>> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
>> index e7179ea048..4a3170fc5c 100644
>> --- a/src/qemu/qemu_capabilities.c
>> +++ b/src/qemu/qemu_capabilities.c
>> @@ -2576,7 +2576,35 @@ virQEMUCapsProbeQMPGenericProps(virQEMUCapsPtr qemuCaps,
>>   }
>>   
>>   static int
>> -virQEMUCapsProbeQMPDevices(virQEMUCapsPtr qemuCaps,
>> +virQEMUCapsProbeQMPTCGState(virQEMUCapsPtr qemuCaps,
> 
> Returned value of the new function is not used, so please define it as
> 'void'
> 
>> +                            char **values,
>> +                            int nvalues)
>> +{
>> +    size_t i;
>> +    bool found = false;
>> +    /*
>> +     * As of version 2.10, QEMU can be built without the TCG.
>> +     * */
>> +    if (qemuCaps->version < 2010000)
>> +        return 0;
>> +    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
>> +        return 0;
>> +
>> +    for (i = 0; i < nvalues; i++) {
>> +        if (STREQ(values[i], "tcg-accel")) {
>> +            found = true;
> 
> You can set the capability here without intermediate variable and just
> return.

I'm not quite sure what you mean. The capability tracks lack of 
tcg-accel. So what can be done here is return and drop the check before 
setting the capability below.

> 
>> +            break;
>> +        }
>> +    }
>> +
>> +    if (!found)
>> +        virQEMUCapsSet(qemuCaps, QEMU_CAPS_TCG_DISABLED);
>> +
>> +    return 0;
>> +}
>> +
>> +static int
>> +virQEMUCapsProbeQMPTypes(virQEMUCapsPtr qemuCaps,
>>                              qemuMonitorPtr mon)
>>   {
>>       int nvalues;
> 
> With the above resolved:
> 
> Reviewed-by: Peter Krempa <pkrempa at redhat.com>
> 

Michal




More information about the libvir-list mailing list