[libvirt] [PATCH 5/5] create storage volumes

Henrik Persson E henrik.e.persson at ericsson.com
Thu Jun 25 16:05:49 UTC 2009


Hi,

Well it doesn't really do the trick, since it maps to "linux-lvm" and
"linux-raid" which is not a valid fs-type for parted. But maybe I should
update the enum to reflect the valid fs-types of parted if that was the
intention of the enum?

/Henrik

 

> -----Original Message-----
> From: Daniel P. Berrange [mailto:berrange at redhat.com] 
> Sent: den 25 juni 2009 11:28
> To: Henrik Persson E
> Cc: libvirt-list at redhat.com
> Subject: Re: [libvirt] [PATCH 5/5] create storage volumes
> 
> On Wed, Jun 24, 2009 at 11:21:48AM +0200, Henrik Persson wrote:
> > This patch does the last magic to be able to create storage volumes 
> > when using a disk as backend
> 
> > --- libvirt-0.6.4.patches/src/storage_backend_disk.c	
> 2009-06-23 18:17:30.885038000 +0200
> > +++ libvirt-0.6.4/src/storage_backend_disk.c	
> 2009-06-24 10:08:23.499326000 +0200
> > @@ -381,47 +381,246 @@ virStorageBackendDiskBuildPool(virConnec
> >  
> >      return 0;
> >  }
> > +/**
> > + * Maps internal libvirt volume disk format to parted fs_type  */ 
> > +static void virStorageBackendDiskVolFormatToPartedFormat(int 
> > +volFormat, char* partedFormat) {
> > +    switch (volFormat) {
> > +        case VIR_STORAGE_VOL_DISK_LINUX:
> > +        case VIR_STORAGE_VOL_DISK_LINUX_LVM:
> > +        case VIR_STORAGE_VOL_DISK_LINUX_RAID:
> > +            /* lvm and raid is set by flags */
> > +            sprintf(partedFormat, "ext2");
> > +            break;
> > +        case VIR_STORAGE_VOL_DISK_FAT16:
> > +            sprintf(partedFormat, "fat16");
> > +            break;
> > +        case VIR_STORAGE_VOL_DISK_FAT32:
> > +            sprintf(partedFormat, "fat32");
> > +            break;
> > +        case VIR_STORAGE_VOL_DISK_LINUX_SWAP:
> > +            sprintf(partedFormat, "linux-swap");
> > +            break;
> > +        case VIR_STORAGE_VOL_DISK_EXTENDED:
> > +            sprintf(partedFormat, "extended");
> > +            break;
> > +        default:
> > +            break;
> > +        }
> > +}
> 
> We already have a enumeration that declares this mapping. You 
> should be able to just call 
> virStorageVolFormatDiskToString(int fmt) and / or 
> virStorageVolFormatDiskFromString(const char *str) as 
> appropriate, to convert int <-> const char *
> 
> eg
> 
>    const char *partedFormat = 
> virStorageVolFormatDiskToString(VIR_STORAGE_VOL_DISK_FAT32)
> 
> ...don't forget to check for NULL
> 
> Aside from making that change, I think your code looks OK. 
> 
> Regards,
> Daniel
> -- 
> |: Red Hat, Engineering, London   -o-   
> http://people.redhat.com/berrange/ :|
> |: http://libvirt.org  -o-  http://virt-manager.org  -o-  
> http://ovirt.org :|
> |: http://autobuild.org       -o-         
> http://search.cpan.org/~danberr/ :|
> |: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 
> |9505 :|
> 




More information about the libvir-list mailing list