[libvirt] [PATCH] Add domain type checking

Matthias Bolte matthias.bolte at googlemail.com
Mon Jul 11 17:58:09 UTC 2011


2011/7/11 Eric Blake <eblake at redhat.com>:
> On 07/11/2011 10:16 AM, Matthias Bolte wrote:
>>> > My only regret here is that we can't really suggest the value expected
>>> > because QEmu accepts more than one, but for other drivers we should be
>>> > able to provide what type is expected.
>> Yes, we can do that even for QEMU. See attached diff between v2 and v3
>> for easier review.
>
>> +++ b/src/conf/domain_conf.c
>> @@ -29,6 +29,7 @@
>>  #include <fcntl.h>
>>  #include <dirent.h>
>>  #include <sys/time.h>
>> +#include <math.h>
>
> What was this needed for?

For log2 to convert 1 << x back to x in case only one bit is set in
expectedVirtTypes.

>> @@ -5846,10 +5848,42 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
>>      }
>>      VIR_FREE(tmp);
>>
>> -    if (((1 << def->virtType) & expectedVirtTypes) == 0) {
>> -        virDomainReportError(VIR_ERR_INTERNAL_ERROR,
>> -                             _("unexpected domain type %s"),
>> -                             virDomainVirtTypeToString(def->virtType));
>> +    if ((expectedVirtTypes & (1 << def->virtType)) == 0) {
>> +        if (count_one_bits(expectedVirtTypes) == 1) {
>> +            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
>> +                                 _("unexpected domain type %s, expecting %s"),
>
> I like it.  ACK to this difference.

So I have a completely ACKed v3 and pushed it, thanks.

-- 
Matthias Bolte
http://photron.blogspot.com




More information about the libvir-list mailing list