[libvirt] [PATCH v2 01/10] conf: Introduce readonly to hostdev and change helper function

Laine Stump laine at laine.org
Mon Apr 8 15:13:51 UTC 2013


On 04/05/2013 05:10 AM, Han Cheng wrote:
> On 04/02/2013 10:15 AM, Hu Tao wrote:
>> On Mon, Apr 01, 2013 at 08:00:53PM +0800, Han Cheng wrote:
>>> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
>>> index edddf25..f8e3973 100644
>>> --- a/src/conf/domain_conf.h
>>> +++ b/src/conf/domain_conf.h
>>> @@ -439,6 +439,8 @@ struct _virDomainHostdevDef {
>>>       } source;
>>>       virDomainHostdevOrigStates origstates;
>>>       virDomainDeviceInfoPtr info; /* Guest address */
>>> +    /* readonly is only used for scsi hostdev */
>>> +    unsigned int readonly;
>>
>> bool readonly;
>>
>>>   };
>>>
>>>   /* Two types of disk backends */
>
> How about:
> struct _virDomainHostdevDef {
>     ...
>     unsigned int managed : 1;
>     unsigned int missing : 1;
>     unsigned int readonly : 1; /* readonly is only used for scsi
> hostdev */
>     ...
> };

Actually the use of bitfields for booleans has kind of fallen out of
favor in libvirt, and those left in the code seem to be there just
because nobody has thought it was important enough to change it. If you
want consistency, I think it would be more appropriate to make a patch
that changed managed and missing from bitfields into bool, then add
readonly as a bool too.




More information about the libvir-list mailing list