Daniel P. Berrange wrote:
>> diff -u -r1.15 storage_backend_fs.c
>> --- a/src/storage_backend_fs.c 13 Oct 2008 16:46:29 -0000 1.15
>> +++ b/src/storage_backend_fs.c 16 Oct 2008 12:31:23 -0000
>> @@ -48,7 +48,8 @@
>> #include "xml.h"
>>
>> enum {
>> - VIR_STORAGE_POOL_FS_AUTO = 0,
>> + VIR_STORAGE_POOL_FS_UNKNOWN = 0,
>> + VIR_STORAGE_POOL_FS_AUTO = 1,
>
> This shouldn't be added - automatic is intended to be default.
>
>>
>> enum {
>> - VIR_STORAGE_VOL_RAW,
>> + VIR_STORAGE_VOL_UNKNOWN = 0,
>> + VIR_STORAGE_VOL_RAW = 1,
>
OK, hopefully last try. Fixed the above two errors and made the disk_type array
static as suggested by Jim.
--
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 13:37:26 -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;
}
+static struct diskType const disk_types[] = {
+ { VIR_STORAGE_POOL_DISK_LVM2, 0x218, 8, 0x31303020324D564CULL },
+ { VIR_STORAGE_POOL_DISK_GPT, 0x200, 8, 0x5452415020494645ULL },
+ { VIR_STORAGE_POOL_DISK_DVH, 0x0, 4, 0x41A9E50BULL },
+ { VIR_STORAGE_POOL_DISK_MAC, 0x0, 2, 0x5245ULL },
+ { VIR_STORAGE_POOL_DISK_BSD, 0x40, 4, 0x82564557ULL },
+ { VIR_STORAGE_POOL_DISK_SUN, 0x1fc, 2, 0xBEDAULL },
+ /*
+ * NOTE: pc98 is funky; the actual signature is 0x55AA (just like dos), so
+ * we can't use that. At the moment I'm relying on the "dummy" IPL
+ * bootloader data that comes from parted. Luckily, the chances of running
+ * into a pc98 machine running libvirt are approximately nil.
+ */
+ /*{ 0x1fe, 2, 0xAA55UL },*/
+ { VIR_STORAGE_POOL_DISK_PC98, 0x0, 8, 0x314C5049000000CBULL },
+ /*
+ * NOTE: the order is important here; some other disk types (like GPT and
+ * and PC98) also have 0x55AA at this offset. For that reason, the DOS
+ * one must be the last one.
+ */
+ { VIR_STORAGE_POOL_DISK_DOS, 0x1fe, 2, 0xAA55ULL },
+ { -1, 0x0, 0, 0x0ULL },
+};
+
int
virStorageBackendUpdateVolInfoFD(virConnectPtr conn,
virStorageVolDefPtr vol,
@@ -245,6 +274,41 @@
if (withCapacity) vol->capacity = end;
}
+ /* make sure to set the target format "unknown" to begin with */
+ vol->target.format = VIR_STORAGE_POOL_DISK_UNKNOWN;
+
+ if (S_ISBLK(sb.st_mode)) {
+ off_t start;
+ int i;
+ unsigned char buffer[1024];
+ ssize_t bytes;
+
+ start = lseek(fd, 0, SEEK_SET);
+ if (start < 0) {
+ virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("cannot seek to beginning of file '%s':%s"),
+ vol->target.path, strerror(errno));
+ return -1;
+ }
+ bytes = saferead(fd, buffer, sizeof(buffer));
+ if (bytes < 0) {
+ virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("cannot read beginning of file '%s':%s"),
+ vol->target.path, strerror(errno));
+ return -1;
+ }
+
+ for (i = 0; disk_types[i].part_table_type != -1; i++) {
+ if (disk_types[i].offset + disk_types[i].length > bytes)
+ continue;
+ if (memcmp(buffer+disk_types[i].offset, &disk_types[i].magic,
+ disk_types[i].length) == 0) {
+ vol->target.format = disk_types[i].part_table_type;
+ break;
+ }
+ }
+ }
+
vol->target.perms.mode = sb.st_mode;
vol->target.perms.uid = sb.st_uid;
vol->target.perms.gid = sb.st_gid;
Index: src/storage_backend.h
===================================================================
RCS file: /data/cvs/libvirt/src/storage_backend.h,v
retrieving revision 1.7
diff -u -r1.7 storage_backend.h
--- a/src/storage_backend.h 2 Sep 2008 14:15:42 -0000 1.7
+++ b/src/storage_backend.h 16 Oct 2008 13:37:26 -0000
@@ -26,18 +26,14 @@
#include <libvirt/libvirt.h>
#include "storage_conf.h"
+#include "util.h"
-typedef const char *(*virStorageVolFormatToString)(virConnectPtr conn,
- int format);
-typedef int (*virStorageVolFormatFromString)(virConnectPtr conn,
- const char *format);
-
-typedef const char *(*virStoragePoolFormatToString)(virConnectPtr conn,
- int format);
-typedef int (*virStoragePoolFormatFromString)(virConnectPtr conn,
- const char *format);
+typedef const char *(*virStorageVolFormatToString)(int format);
+typedef int (*virStorageVolFormatFromString)(const char *format);
+typedef const char *(*virStoragePoolFormatToString)(int format);
+typedef int (*virStoragePoolFormatFromString)(const char *format);
typedef struct _virStorageBackendVolOptions virStorageBackendVolOptions;
typedef virStorageBackendVolOptions *virStorageBackendVolOptionsPtr;
@@ -56,6 +52,27 @@
VIR_STORAGE_BACKEND_POOL_SOURCE_NAME = (1<<4),
};
+enum partTableType {
+ VIR_STORAGE_POOL_DISK_UNKNOWN = 0,
+ VIR_STORAGE_POOL_DISK_DOS = 1,
+ VIR_STORAGE_POOL_DISK_DVH,
+ VIR_STORAGE_POOL_DISK_GPT,
+ VIR_STORAGE_POOL_DISK_MAC,
+ VIR_STORAGE_POOL_DISK_BSD,
+ VIR_STORAGE_POOL_DISK_PC98,
+ VIR_STORAGE_POOL_DISK_SUN,
+ VIR_STORAGE_POOL_DISK_LVM2,
+ VIR_STORAGE_POOL_DISK_LAST,
+};
+
+struct diskType {
+ enum partTableType part_table_type;
+ unsigned short offset;
+ unsigned short length;
+ unsigned long long magic;
+};
+VIR_ENUM_DECL(virStorageBackendPartTable);
+
typedef struct _virStorageBackendPoolOptions virStorageBackendPoolOptions;
typedef virStorageBackendPoolOptions *virStorageBackendPoolOptionsPtr;
struct _virStorageBackendPoolOptions {
Index: src/storage_backend_disk.c
===================================================================
RCS file: /data/cvs/libvirt/src/storage_backend_disk.c,v
retrieving revision 1.14
diff -u -r1.14 storage_backend_disk.c
--- a/src/storage_backend_disk.c 13 Oct 2008 16:46:29 -0000 1.14
+++ b/src/storage_backend_disk.c 16 Oct 2008 13:37:26 -0000
@@ -30,16 +30,6 @@
#include "util.h"
#include "memory.h"
-enum {
- VIR_STORAGE_POOL_DISK_DOS = 0,
- VIR_STORAGE_POOL_DISK_DVH,
- VIR_STORAGE_POOL_DISK_GPT,
- VIR_STORAGE_POOL_DISK_MAC,
- VIR_STORAGE_POOL_DISK_BSD,
- VIR_STORAGE_POOL_DISK_PC98,
- VIR_STORAGE_POOL_DISK_SUN,
-};
-
/*
* XXX these are basically partition types.
*
@@ -58,117 +48,19 @@
VIR_STORAGE_VOL_DISK_LINUX_LVM,
VIR_STORAGE_VOL_DISK_LINUX_RAID,
VIR_STORAGE_VOL_DISK_EXTENDED,
+ VIR_STORAGE_VOL_DISK_LAST,
};
+VIR_ENUM_DECL(virStorageBackendDiskVol);
+VIR_ENUM_IMPL(virStorageBackendDiskVol,
+ VIR_STORAGE_VOL_DISK_LAST,
+ "none", "linux", "fat16",
+ "fat32", "linux-swap",
+ "linux-lvm", "linux-raid",
+ "extended");
#define PARTHELPER BINDIR "/libvirt_parthelper"
static int
-virStorageBackendDiskPoolFormatFromString(virConnectPtr conn,
- const char *format) {
- if (format == NULL)
- return VIR_STORAGE_POOL_DISK_DOS;
-
- if (STREQ(format, "dos"))
- return VIR_STORAGE_POOL_DISK_DOS;
- if (STREQ(format, "dvh"))
- return VIR_STORAGE_POOL_DISK_DVH;
- if (STREQ(format, "gpt"))
- return VIR_STORAGE_POOL_DISK_GPT;
- if (STREQ(format, "mac"))
- return VIR_STORAGE_POOL_DISK_MAC;
- if (STREQ(format, "bsd"))
- return VIR_STORAGE_POOL_DISK_BSD;
- if (STREQ(format, "pc98"))
- return VIR_STORAGE_POOL_DISK_PC98;
- if (STREQ(format, "sun"))
- return VIR_STORAGE_POOL_DISK_SUN;
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported pool format %s"), format);
- return -1;
-}
-
-static const char *
-virStorageBackendDiskPoolFormatToString(virConnectPtr conn,
- int format) {
- switch (format) {
- case VIR_STORAGE_POOL_DISK_DOS:
- return "dos";
- case VIR_STORAGE_POOL_DISK_DVH:
- return "dvh";
- case VIR_STORAGE_POOL_DISK_GPT:
- return "gpt";
- case VIR_STORAGE_POOL_DISK_MAC:
- return "mac";
- case VIR_STORAGE_POOL_DISK_BSD:
- return "bsd";
- case VIR_STORAGE_POOL_DISK_PC98:
- return "pc98";
- case VIR_STORAGE_POOL_DISK_SUN:
- return "sun";
- }
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported pool format %d"), format);
- return NULL;
-}
-
-static int
-virStorageBackendDiskVolFormatFromString(virConnectPtr conn,
- const char *format) {
- if (format == NULL)
- return VIR_STORAGE_VOL_DISK_NONE;
-
- if (STREQ(format, "none"))
- return VIR_STORAGE_VOL_DISK_NONE;
- if (STREQ(format, "linux"))
- return VIR_STORAGE_VOL_DISK_LINUX;
- if (STREQ(format, "fat16"))
- return VIR_STORAGE_VOL_DISK_FAT16;
- if (STREQ(format, "fat32"))
- return VIR_STORAGE_VOL_DISK_FAT32;
- if (STREQ(format, "linux-swap"))
- return VIR_STORAGE_VOL_DISK_LINUX_SWAP;
- if (STREQ(format, "linux-lvm"))
- return VIR_STORAGE_VOL_DISK_LINUX_LVM;
- if (STREQ(format, "linux-raid"))
- return VIR_STORAGE_VOL_DISK_LINUX_RAID;
- if (STREQ(format, "extended"))
- return VIR_STORAGE_VOL_DISK_EXTENDED;
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported volume format %s"), format);
- return -1;
-}
-
-static const char *
-virStorageBackendDiskVolFormatToString(virConnectPtr conn,
- int format) {
- switch (format) {
- case VIR_STORAGE_VOL_DISK_NONE:
- return "none";
- case VIR_STORAGE_VOL_DISK_LINUX:
- return "linux";
- case VIR_STORAGE_VOL_DISK_FAT16:
- return "fat16";
- case VIR_STORAGE_VOL_DISK_FAT32:
- return "fat32";
- case VIR_STORAGE_VOL_DISK_LINUX_SWAP:
- return "linux-swap";
- case VIR_STORAGE_VOL_DISK_LINUX_LVM:
- return "linux-lvm";
- case VIR_STORAGE_VOL_DISK_LINUX_RAID:
- return "linux-raid";
- case VIR_STORAGE_VOL_DISK_EXTENDED:
- return "extended";
- }
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported volume format %d"), format);
- return NULL;
-}
-
-static int
virStorageBackendDiskMakeDataVol(virConnectPtr conn,
virStoragePoolObjPtr pool,
char **const groups,
@@ -414,8 +306,7 @@
"mklabel",
"--script",
((pool->def->source.format == VIR_STORAGE_POOL_DISK_DOS) ? "msdos" :
- virStorageBackendDiskPoolFormatToString(conn,
- pool->def->source.format)),
+ virStorageBackendPartTableTypeToString(pool->def->source.format)),
NULL,
};
@@ -557,12 +448,12 @@
.poolOptions = {
.flags = (VIR_STORAGE_BACKEND_POOL_SOURCE_DEVICE),
- .formatFromString = virStorageBackendDiskPoolFormatFromString,
- .formatToString = virStorageBackendDiskPoolFormatToString,
+ .formatFromString = virStorageBackendPartTableTypeFromString,
+ .formatToString = virStorageBackendPartTableTypeToString,
},
.volOptions = {
- .formatFromString = virStorageBackendDiskVolFormatFromString,
- .formatToString = virStorageBackendDiskVolFormatToString,
+ .formatFromString = virStorageBackendDiskVolTypeFromString,
+ .formatToString = virStorageBackendDiskVolTypeToString,
},
.volType = VIR_STORAGE_VOL_BLOCK,
Index: src/storage_backend_fs.c
===================================================================
RCS file: /data/cvs/libvirt/src/storage_backend_fs.c,v
retrieving revision 1.15
diff -u -r1.15 storage_backend_fs.c
--- a/src/storage_backend_fs.c 13 Oct 2008 16:46:29 -0000 1.15
+++ b/src/storage_backend_fs.c 16 Oct 2008 13:37:26 -0000
@@ -60,17 +60,29 @@
VIR_STORAGE_POOL_FS_VFAT,
VIR_STORAGE_POOL_FS_HFSPLUS,
VIR_STORAGE_POOL_FS_XFS,
+ VIR_STORAGE_POOL_FS_LAST,
};
+VIR_ENUM_DECL(virStorageBackendFileSystemPool);
+VIR_ENUM_IMPL(virStorageBackendFileSystemPool,
+ VIR_STORAGE_POOL_FS_LAST,
+ "auto", "ext2", "ext3",
+ "ext4", "ufs", "iso9660", "udf",
+ "gfs", "gfs2", "vfat", "hfs+", "xfs");
enum {
- VIR_STORAGE_POOL_NETFS_AUTO = 0,
+ VIR_STORAGE_POOL_NETFS_UNKNOWN = 0,
+ VIR_STORAGE_POOL_NETFS_AUTO = 1,
VIR_STORAGE_POOL_NETFS_NFS,
+ VIR_STORAGE_POOL_NETFS_LAST,
};
-
+VIR_ENUM_DECL(virStorageBackendFileSystemNetPool);
+VIR_ENUM_IMPL(virStorageBackendFileSystemNetPool,
+ VIR_STORAGE_POOL_NETFS_LAST,
+ "unknown", "auto", "nfs");
enum {
- VIR_STORAGE_VOL_RAW,
+ VIR_STORAGE_VOL_RAW = 0,
VIR_STORAGE_VOL_DIR,
VIR_STORAGE_VOL_BOCHS,
VIR_STORAGE_VOL_CLOOP,
@@ -81,7 +93,14 @@
VIR_STORAGE_VOL_QCOW2,
VIR_STORAGE_VOL_VMDK,
VIR_STORAGE_VOL_VPC,
+ VIR_STORAGE_VOL_LAST,
};
+VIR_ENUM_DECL(virStorageBackendFileSystemVol);
+VIR_ENUM_IMPL(virStorageBackendFileSystemVol,
+ VIR_STORAGE_VOL_LAST,
+ "raw", "dir", "bochs",
+ "cloop", "cow", "dmg", "iso",
+ "qcow", "qcow2", "vmdk", "vpc");
/* Either 'magic' or 'extension' *must* be provided */
struct FileTypeInfo {
@@ -159,178 +178,6 @@
-static int
-virStorageBackendFileSystemVolFormatFromString(virConnectPtr conn,
- const char *format) {
- if (format == NULL)
- return VIR_STORAGE_VOL_RAW;
-
- if (STREQ(format, "raw"))
- return VIR_STORAGE_VOL_RAW;
- if (STREQ(format, "dir"))
- return VIR_STORAGE_VOL_DIR;
- if (STREQ(format, "bochs"))
- return VIR_STORAGE_VOL_BOCHS;
- if (STREQ(format, "cow"))
- return VIR_STORAGE_VOL_COW;
- if (STREQ(format, "cloop"))
- return VIR_STORAGE_VOL_CLOOP;
- if (STREQ(format, "dmg"))
- return VIR_STORAGE_VOL_DMG;
- if (STREQ(format, "iso"))
- return VIR_STORAGE_VOL_ISO;
- if (STREQ(format, "qcow"))
- return VIR_STORAGE_VOL_QCOW;
- if (STREQ(format, "qcow2"))
- return VIR_STORAGE_VOL_QCOW2;
- if (STREQ(format, "vmdk"))
- return VIR_STORAGE_VOL_VMDK;
- if (STREQ(format, "vpc"))
- return VIR_STORAGE_VOL_VPC;
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported volume format %s"), format);
- return -1;
-}
-
-static const char *
-virStorageBackendFileSystemVolFormatToString(virConnectPtr conn,
- int format) {
- switch (format) {
- case VIR_STORAGE_VOL_RAW:
- return "raw";
- case VIR_STORAGE_VOL_DIR:
- return "dir";
- case VIR_STORAGE_VOL_BOCHS:
- return "bochs";
- case VIR_STORAGE_VOL_CLOOP:
- return "cloop";
- case VIR_STORAGE_VOL_COW:
- return "cow";
- case VIR_STORAGE_VOL_DMG:
- return "dmg";
- case VIR_STORAGE_VOL_ISO:
- return "iso";
- case VIR_STORAGE_VOL_QCOW:
- return "qcow";
- case VIR_STORAGE_VOL_QCOW2:
- return "qcow2";
- case VIR_STORAGE_VOL_VMDK:
- return "vmdk";
- case VIR_STORAGE_VOL_VPC:
- return "vpc";
- }
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported volume format %d"), format);
- return NULL;
-}
-
-
-static int
-virStorageBackendFileSystemPoolFormatFromString(virConnectPtr conn,
- const char *format) {
- if (format == NULL)
- return VIR_STORAGE_POOL_FS_AUTO;
-
- if (STREQ(format, "auto"))
- return VIR_STORAGE_POOL_FS_AUTO;
- if (STREQ(format, "ext2"))
- return VIR_STORAGE_POOL_FS_EXT2;
- if (STREQ(format, "ext3"))
- return VIR_STORAGE_POOL_FS_EXT3;
- if (STREQ(format, "ext4"))
- return VIR_STORAGE_POOL_FS_EXT4;
- if (STREQ(format, "ufs"))
- return VIR_STORAGE_POOL_FS_UFS;
- if (STREQ(format, "iso9660"))
- return VIR_STORAGE_POOL_FS_ISO;
- if (STREQ(format, "udf"))
- return VIR_STORAGE_POOL_FS_UDF;
- if (STREQ(format, "gfs"))
- return VIR_STORAGE_POOL_FS_GFS;
- if (STREQ(format, "gfs2"))
- return VIR_STORAGE_POOL_FS_GFS2;
- if (STREQ(format, "vfat"))
- return VIR_STORAGE_POOL_FS_VFAT;
- if (STREQ(format, "hfs+"))
- return VIR_STORAGE_POOL_FS_HFSPLUS;
- if (STREQ(format, "xfs"))
- return VIR_STORAGE_POOL_FS_XFS;
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported volume format %s"), format);
- return -1;
-}
-
-static const char *
-virStorageBackendFileSystemPoolFormatToString(virConnectPtr conn,
- int format) {
- switch (format) {
- case VIR_STORAGE_POOL_FS_AUTO:
- return "auto";
- case VIR_STORAGE_POOL_FS_EXT2:
- return "ext2";
- case VIR_STORAGE_POOL_FS_EXT3:
- return "ext3";
- case VIR_STORAGE_POOL_FS_EXT4:
- return "ext4";
- case VIR_STORAGE_POOL_FS_UFS:
- return "ufs";
- case VIR_STORAGE_POOL_FS_ISO:
- return "iso";
- case VIR_STORAGE_POOL_FS_UDF:
- return "udf";
- case VIR_STORAGE_POOL_FS_GFS:
- return "gfs";
- case VIR_STORAGE_POOL_FS_GFS2:
- return "gfs2";
- case VIR_STORAGE_POOL_FS_VFAT:
- return "vfat";
- case VIR_STORAGE_POOL_FS_HFSPLUS:
- return "hfs+";
- case VIR_STORAGE_POOL_FS_XFS:
- return "xfs";
- }
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported volume format %d"), format);
- return NULL;
-}
-
-
-static int
-virStorageBackendFileSystemNetPoolFormatFromString(virConnectPtr conn,
- const char *format) {
- if (format == NULL)
- return VIR_STORAGE_POOL_NETFS_AUTO;
-
- if (STREQ(format, "auto"))
- return VIR_STORAGE_POOL_NETFS_AUTO;
- if (STREQ(format, "nfs"))
- return VIR_STORAGE_POOL_NETFS_NFS;
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported volume format %s"), format);
- return -1;
-}
-
-static const char *
-virStorageBackendFileSystemNetPoolFormatToString(virConnectPtr conn,
- int format) {
- switch (format) {
- case VIR_STORAGE_POOL_NETFS_AUTO:
- return "auto";
- case VIR_STORAGE_POOL_NETFS_NFS:
- return "nfs";
- }
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported volume format %d"), format);
- return NULL;
-}
-
-
/**
* Probe the header of a file to determine what type of disk image
* it is, and info about its capacity if available.
@@ -635,10 +482,8 @@
MOUNT,
"-t",
pool->def->type == VIR_STORAGE_POOL_FS ?
- virStorageBackendFileSystemPoolFormatToString(conn,
- pool->def->source.format) :
- virStorageBackendFileSystemNetPoolFormatToString(conn,
- pool->def->source.format),
+ virStorageBackendFileSystemPoolTypeToString(pool->def->source.format) :
+ virStorageBackendFileSystemNetPoolTypeToString(pool->def->source.format),
NULL, /* Fill in shortly - careful not to add extra fields
before this */
pool->def->target.path,
@@ -1036,8 +881,7 @@
char size[100];
const char *imgargv[7];
- if ((type = virStorageBackendFileSystemVolFormatToString(conn,
- vol->target.format)) == NULL) {
+ if ((type = virStorageBackendFileSystemVolTypeToString(vol->target.format)) == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("unknown storage vol type %d"),
vol->target.format);
@@ -1194,8 +1038,8 @@
.deleteVol = virStorageBackendFileSystemVolDelete,
.volOptions = {
- .formatFromString = virStorageBackendFileSystemVolFormatFromString,
- .formatToString = virStorageBackendFileSystemVolFormatToString,
+ .formatFromString = virStorageBackendFileSystemVolTypeFromString,
+ .formatToString = virStorageBackendFileSystemVolTypeToString,
},
.volType = VIR_STORAGE_VOL_FILE,
};
@@ -1215,12 +1059,12 @@
.poolOptions = {
.flags = (VIR_STORAGE_BACKEND_POOL_SOURCE_DEVICE),
- .formatFromString = virStorageBackendFileSystemPoolFormatFromString,
- .formatToString = virStorageBackendFileSystemPoolFormatToString,
+ .formatFromString = virStorageBackendFileSystemPoolTypeFromString,
+ .formatToString = virStorageBackendFileSystemPoolTypeToString,
},
.volOptions = {
- .formatFromString = virStorageBackendFileSystemVolFormatFromString,
- .formatToString = virStorageBackendFileSystemVolFormatToString,
+ .formatFromString = virStorageBackendFileSystemVolTypeFromString,
+ .formatToString = virStorageBackendFileSystemVolTypeToString,
},
.volType = VIR_STORAGE_VOL_FILE,
};
@@ -1240,12 +1084,12 @@
.poolOptions = {
.flags = (VIR_STORAGE_BACKEND_POOL_SOURCE_HOST |
VIR_STORAGE_BACKEND_POOL_SOURCE_DIR),
- .formatFromString = virStorageBackendFileSystemNetPoolFormatFromString,
- .formatToString = virStorageBackendFileSystemNetPoolFormatToString,
+ .formatFromString = virStorageBackendFileSystemNetPoolTypeFromString,
+ .formatToString = virStorageBackendFileSystemNetPoolTypeToString,
},
.volOptions = {
- .formatFromString = virStorageBackendFileSystemVolFormatFromString,
- .formatToString = virStorageBackendFileSystemVolFormatToString,
+ .formatFromString = virStorageBackendFileSystemVolTypeFromString,
+ .formatToString = virStorageBackendFileSystemVolTypeToString,
},
.volType = VIR_STORAGE_VOL_FILE,
};
Index: src/storage_backend_iscsi.c
===================================================================
RCS file: /data/cvs/libvirt/src/storage_backend_iscsi.c,v
retrieving revision 1.14
diff -u -r1.14 storage_backend_iscsi.c
--- a/src/storage_backend_iscsi.c 10 Oct 2008 15:13:28 -0000 1.14
+++ b/src/storage_backend_iscsi.c 16 Oct 2008 13:37:26 -0000
@@ -636,18 +636,20 @@
return 0;
}
-
virStorageBackend virStorageBackendISCSI = {
- .type = VIR_STORAGE_POOL_ISCSI,
+ .type = VIR_STORAGE_POOL_ISCSI,
- .startPool = virStorageBackendISCSIStartPool,
- .refreshPool = virStorageBackendISCSIRefreshPool,
- .stopPool = virStorageBackendISCSIStopPool,
+ .startPool = virStorageBackendISCSIStartPool,
+ .refreshPool = virStorageBackendISCSIRefreshPool,
+ .stopPool = virStorageBackendISCSIStopPool,
- .poolOptions = {
+ .poolOptions = {
.flags = (VIR_STORAGE_BACKEND_POOL_SOURCE_HOST |
VIR_STORAGE_BACKEND_POOL_SOURCE_DEVICE)
},
- .volType = VIR_STORAGE_VOL_BLOCK,
+ .volType = VIR_STORAGE_VOL_BLOCK,
+ .volOptions = {
+ .formatToString = virStorageBackendPartTableTypeToString,
+ }
};
Index: src/storage_backend_logical.c
===================================================================
RCS file: /data/cvs/libvirt/src/storage_backend_logical.c,v
retrieving revision 1.18
diff -u -r1.18 storage_backend_logical.c
--- a/src/storage_backend_logical.c 13 Oct 2008 16:46:29 -0000 1.18
+++ b/src/storage_backend_logical.c 16 Oct 2008 13:37:26 -0000
@@ -40,36 +40,14 @@
#define PV_BLANK_SECTOR_SIZE 512
enum {
- VIR_STORAGE_POOL_LOGICAL_LVM2 = 0,
+ VIR_STORAGE_POOL_LOGICAL_UNKNOWN = 0,
+ VIR_STORAGE_POOL_LOGICAL_LVM2 = 1,
+ VIR_STORAGE_POOL_LOGICAL_LAST,
};
-
-
-static int
-virStorageBackendLogicalPoolFormatFromString(virConnectPtr conn,
- const char *format) {
- if (format == NULL)
- return VIR_STORAGE_POOL_LOGICAL_LVM2;
-
- if (STREQ(format, "lvm2"))
- return VIR_STORAGE_POOL_LOGICAL_LVM2;
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported pool format %s"), format);
- return -1;
-}
-
-static const char *
-virStorageBackendLogicalPoolFormatToString(virConnectPtr conn,
- int format) {
- switch (format) {
- case VIR_STORAGE_POOL_LOGICAL_LVM2:
- return "lvm2";
- }
-
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unsupported pool format %d"), format);
- return NULL;
-}
+VIR_ENUM_DECL(virStorageBackendLogicalPool);
+VIR_ENUM_IMPL(virStorageBackendLogicalPool,
+ VIR_STORAGE_POOL_LOGICAL_LAST,
+ "unknown", "lvm2");
static int
virStorageBackendLogicalSetActive(virConnectPtr conn,
@@ -638,8 +616,8 @@
.poolOptions = {
.flags = (VIR_STORAGE_BACKEND_POOL_SOURCE_NAME |
VIR_STORAGE_BACKEND_POOL_SOURCE_DEVICE),
- .formatFromString = virStorageBackendLogicalPoolFormatFromString,
- .formatToString = virStorageBackendLogicalPoolFormatToString,
+ .formatFromString = virStorageBackendLogicalPoolTypeFromString,
+ .formatToString = virStorageBackendLogicalPoolTypeToString,
},
.volType = VIR_STORAGE_VOL_BLOCK,
Index: src/storage_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/storage_conf.c,v
retrieving revision 1.17
diff -u -r1.17 storage_conf.c
--- a/src/storage_conf.c 10 Oct 2008 15:13:28 -0000 1.17
+++ b/src/storage_conf.c 16 Oct 2008 13:37:27 -0000
@@ -275,7 +275,7 @@
if (options->formatFromString) {
char *format = virXPathString(conn, "string(/pool/source/format/@type)", ctxt);
- if ((ret->source.format = (options->formatFromString)(conn, format)) < 0) {
+ if ((ret->source.format = (options->formatFromString)(format)) < 0) {
VIR_FREE(format);
goto cleanup;
}
@@ -520,7 +520,7 @@
virBufferVSprintf(&buf," <name>%s</name>\n", def->source.name);
if (options->formatToString) {
- const char *format = (options->formatToString)(conn, def->source.format);
+ const char *format = (options->formatToString)(def->source.format);
if (!format)
goto cleanup;
virBufferVSprintf(&buf," <format type='%s'/>\n", format);
@@ -750,7 +750,7 @@
ret->target.path = virXPathString(conn, "string(/volume/target/path)", ctxt);
if (options->formatFromString) {
char *format = virXPathString(conn, "string(/volume/target/format/@type)", ctxt);
- if ((ret->target.format = (options->formatFromString)(conn, format)) < 0) {
+ if ((ret->target.format = (options->formatFromString)(format)) < 0) {
VIR_FREE(format);
goto cleanup;
}
@@ -884,8 +884,7 @@
virBufferVSprintf(&buf," <path>%s</path>\n", def->target.path);
if (options->formatToString) {
- const char *format = (options->formatToString)(conn,
- def->target.format);
+ const char *format = (options->formatToString)(def->target.format);
if (!format)
goto cleanup;
virBufferVSprintf(&buf," <format type='%s'/>\n", format);
--
Libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list