[libvirt] Re: [PATCH] also allow use of XZ for Qemu image compression

Chris Lalancette clalance at redhat.com
Wed Sep 9 07:28:25 UTC 2009


Jim Meyering wrote:
> At Chris' suggestion, I've added a comment warning not to do what I did ;-)
> 
> To make it even more obvious that these numbers matter,
> I've assigned explicit constants in the enum:
> 
>   +    QEMUD_SAVE_FORMAT_RAW = 0,
>   +    QEMUD_SAVE_FORMAT_GZIP = 1,
>   +    QEMUD_SAVE_FORMAT_BZIP2 = 2,
> 
> Currently, if someone accidentally adds this (mistakenly reused number):
> 
>   +    QEMUD_SAVE_FORMAT_OOPS = 2,
> 
> the compiler won't catch it.
> However, with a small additional change to use VIR_ENUM_DECL
> and VIR_ENUM_IMPL, thus replacing the if/elsif/ chains,
> and the compiler *would* detect that mistake.
> It'd also help to factor out the QEMUD_SAVE_FORMAT_<> to "<>"
> association, rather than having literals like "gzip" and "bzip2"
> in two places.
> 
> Now that I've described that, I'll prepare a separate patch.
> For now, here's the added comment and enum initializers.

ACK, this looks good, and your above cleanups also sound like they are good ideas.

-- 
Chris Lalancette




More information about the libvir-list mailing list