[libvirt] [PATCH] virDomainDiskDef: Turn @device into enum

Laine Stump laine at laine.org
Mon Sep 28 16:35:31 UTC 2015

On 09/17/2015 11:37 AM, Michal Privoznik wrote:
> It's used as enum everywhere, so why store its value in an int?

There are a lot of these. I *think* the only reason this was done 
anywhere in the first place was because the size of an enum isn't 
guaranteed to be the same across different platforms, so you can't use 
an enum type in any wire protocol (e.g. libvirt client to server), and 
somehow this usage leaked over into the internal-only data structures; 
after that  the general "that works! Copy it!" cargo cult generation of 
new code meant that we now have lots of instances of this (there may 
also be cases where someone chose to use -1 to indicate "not specified" 
rather than 0/the first enum value).

Or it could be there's some other reason for using int instead of an 
enum type in the internal config objects that I've forgotten.

More information about the libvir-list mailing list