[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH]: Export the 'label' on block devices



Chris Lalancette <clalance redhat com> wrote:
> Daniel P. Berrange wrote:
>> I know you're just replicating the existing code, but both these functions can
>> be killed off and replaced with auto-generated code from our enum support
>> macros
>>
>>     VIR_ENUM_IMPL(virStorageBackendDiskLabel,
>>                   VIR_STORAGE_POOL_DISK_LAST,
>>                   "dos", "dvh", "gpt", "mac",
>>                   "bsd", "pc98", "sun", "lvm2"
>>                   "unknown")
>>
>> And in the header file just
>>
>>     VIR_ENUM_DECL(virStorageBackendDiskLabel)
>
> I've implemented this, and there was quite a bit of fallout from it.  In
> particular, I had to change the signature of poolOptions.formatToString and
> formatFromString, which required a bunch of changes elsewhere in the storage
> code.  The good news is that we remove quite a bit of very similar hand crafted
> code, so this patch actually removes more code than it adds.  Tested by me as
> before.

Lots of good fallout.
ACK with a tiny tweak:

> Chris Lalancette
> Index: src/storage_backend.c
> ===================================================================
> RCS file: /data/cvs/libvirt/src/storage_backend.c,v
> retrieving revision 1.21
> diff -u -r1.21 storage_backend.c
> --- a/src/storage_backend.c	5 Sep 2008 12:03:45 -0000	1.21
> +++ b/src/storage_backend.c	16 Oct 2008 12:31:23 -0000
> @@ -60,6 +60,11 @@
>  #include "storage_backend_fs.h"
>  #endif
>
> +VIR_ENUM_IMPL(virStorageBackendPartTable,
> +              VIR_STORAGE_POOL_DISK_LAST,
> +              "unknown", "dos", "dvh", "gpt",
> +              "mac", "bsd", "pc98", "sun", "lvm2");
> +
>  static virStorageBackendPtr backends[] = {
>  #if WITH_STORAGE_DIR
>      &virStorageBackendDirectory,
> @@ -192,6 +197,30 @@
>      return ret;
>  }
>
> +const struct diskType const disk_types[] = {

s/const/static/

> +    { VIR_STORAGE_POOL_DISK_LVM2, 0x218, 8, 0x31303020324D564CUL },
> +    { VIR_STORAGE_POOL_DISK_GPT,  0x200, 8, 0x5452415020494645UL },
> +    { VIR_STORAGE_POOL_DISK_DVH,  0x0,   4, 0x41A9E50BUL },
> +    { VIR_STORAGE_POOL_DISK_MAC,  0x0,   2, 0x5245UL },
> +    { VIR_STORAGE_POOL_DISK_BSD,  0x40,  4, 0x82564557UL },
> +    { VIR_STORAGE_POOL_DISK_SUN,  0x1fc, 2, 0xBEDAUL },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]