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 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list