[libvirt] [PATCHv2] Add XML config switch to enable/disable vhost-net support

Laine Stump laine at laine.org
Fri Jan 14 19:21:27 UTC 2011


On 01/14/2011 02:02 PM, Eric Blake wrote:
>>       <interface type="network">
>>         <model type="virtio"/>
>>         <driver name="vhost"/>
>>
>> will force use of vhost-net (if it's not available, the domain will
>> fail to start). if driver name="qemu", vhost-net will not be used even
>> if it is available.
>> @@ -2559,6 +2567,19 @@ virDomainNetDefParseXML(virCapsPtr caps,
>>           model = NULL;
>>       }
>>
>> +    if ((backend != NULL)&&
>> +        (def->model&&  STREQ(def->model, "virtio"))) {
>> +        int b;
>> +        if (((b = virDomainNetBackendTypeFromString(backend))<  0) ||
>> +            (b == 0)) {
> I probably would have done either this shorthand:
>
> (b = virDomain...FromString)<= 0
>
> or, keeping the long form, used a symbolic name rather than a magic number:
>
> (b = virDomain...FromString)<  0 ||
> (b == VIR_DOMAIN_NET_BACKEND_TYPE_DEFAULT)
>
> But that's just style, so up to you if you want to make a tweak, or keep
> it as-is.
>

Heh. I was so zero'ed in on the change that I didn't notice the context. 
I do like the idea of a separate comparison, but with the enum name, so 
that it will be immediately obvious to someone reading the code that 
"default" isn't allowed explicitly.

> ACK.
>

Thanks. I'm pushing with that one change.




More information about the libvir-list mailing list