Move file format enum to libvirt_util
Rename virStorageVolFormatFileSystem to virStorageFileFormat and move to src/util/storage_file.[ch] * src/Makefile.am: add src/util/storage_file.[ch] * src/conf/storage_conf.[ch]: move enum from here ... * src/util/storage_file.[ch]: .. to here * src/libvirt_private.syms: update To/FromString exports * src/storage/storage_backend.c, src/storage/storage_backend_fs.c, src/vbox/vbox_tmpl.c: update for above changes
This commit is contained in:
parent
c6f1459eb9
commit
00fd3ff49b
@ -49,6 +49,7 @@ UTIL_SOURCES = \
|
|||||||
util/hostusb.c util/hostusb.h \
|
util/hostusb.c util/hostusb.h \
|
||||||
util/qparams.c util/qparams.h \
|
util/qparams.c util/qparams.h \
|
||||||
util/stats_linux.c util/stats_linux.h \
|
util/stats_linux.c util/stats_linux.h \
|
||||||
|
util/storage_file.c util/storage_file.h \
|
||||||
util/threads.c util/threads.h \
|
util/threads.c util/threads.h \
|
||||||
util/threads-pthread.h \
|
util/threads-pthread.h \
|
||||||
util/threads-win32.h \
|
util/threads-win32.h \
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "virterror_internal.h"
|
#include "virterror_internal.h"
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "storage_conf.h"
|
#include "storage_conf.h"
|
||||||
|
#include "storage_file.h"
|
||||||
|
|
||||||
#include "xml.h"
|
#include "xml.h"
|
||||||
#include "uuid.h"
|
#include "uuid.h"
|
||||||
@ -82,12 +83,6 @@ VIR_ENUM_IMPL(virStorageVolFormatDisk,
|
|||||||
"linux-lvm", "linux-raid",
|
"linux-lvm", "linux-raid",
|
||||||
"extended")
|
"extended")
|
||||||
|
|
||||||
VIR_ENUM_IMPL(virStorageVolFormatFileSystem,
|
|
||||||
VIR_STORAGE_VOL_FILE_LAST,
|
|
||||||
"raw", "dir", "bochs",
|
|
||||||
"cloop", "cow", "dmg", "iso",
|
|
||||||
"qcow", "qcow2", "vmdk", "vpc")
|
|
||||||
|
|
||||||
VIR_ENUM_IMPL(virStoragePartedFsType,
|
VIR_ENUM_IMPL(virStoragePartedFsType,
|
||||||
VIR_STORAGE_PARTED_FS_TYPE_LAST,
|
VIR_STORAGE_PARTED_FS_TYPE_LAST,
|
||||||
"ext2", "ext2", "fat16",
|
"ext2", "ext2", "fat16",
|
||||||
@ -150,9 +145,9 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
|
|||||||
},
|
},
|
||||||
{ .poolType = VIR_STORAGE_POOL_DIR,
|
{ .poolType = VIR_STORAGE_POOL_DIR,
|
||||||
.volOptions = {
|
.volOptions = {
|
||||||
.defaultFormat = VIR_STORAGE_VOL_FILE_RAW,
|
.defaultFormat = VIR_STORAGE_FILE_RAW,
|
||||||
.formatFromString = virStorageVolFormatFileSystemTypeFromString,
|
.formatFromString = virStorageFileFormatTypeFromString,
|
||||||
.formatToString = virStorageVolFormatFileSystemTypeToString,
|
.formatToString = virStorageFileFormatTypeToString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ .poolType = VIR_STORAGE_POOL_FS,
|
{ .poolType = VIR_STORAGE_POOL_FS,
|
||||||
@ -162,9 +157,9 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
|
|||||||
.formatToString = virStoragePoolFormatFileSystemTypeToString,
|
.formatToString = virStoragePoolFormatFileSystemTypeToString,
|
||||||
},
|
},
|
||||||
.volOptions = {
|
.volOptions = {
|
||||||
.defaultFormat = VIR_STORAGE_VOL_FILE_RAW,
|
.defaultFormat = VIR_STORAGE_FILE_RAW,
|
||||||
.formatFromString = virStorageVolFormatFileSystemTypeFromString,
|
.formatFromString = virStorageFileFormatTypeFromString,
|
||||||
.formatToString = virStorageVolFormatFileSystemTypeToString,
|
.formatToString = virStorageFileFormatTypeToString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ .poolType = VIR_STORAGE_POOL_NETFS,
|
{ .poolType = VIR_STORAGE_POOL_NETFS,
|
||||||
@ -176,9 +171,9 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
|
|||||||
.formatToString = virStoragePoolFormatFileSystemNetTypeToString,
|
.formatToString = virStoragePoolFormatFileSystemNetTypeToString,
|
||||||
},
|
},
|
||||||
.volOptions = {
|
.volOptions = {
|
||||||
.defaultFormat = VIR_STORAGE_VOL_FILE_RAW,
|
.defaultFormat = VIR_STORAGE_FILE_RAW,
|
||||||
.formatFromString = virStorageVolFormatFileSystemTypeFromString,
|
.formatFromString = virStorageFileFormatTypeFromString,
|
||||||
.formatToString = virStorageVolFormatFileSystemTypeToString,
|
.formatToString = virStorageFileFormatTypeToString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ .poolType = VIR_STORAGE_POOL_ISCSI,
|
{ .poolType = VIR_STORAGE_POOL_ISCSI,
|
||||||
|
@ -429,23 +429,6 @@ enum virStoragePoolFormatLogical {
|
|||||||
};
|
};
|
||||||
VIR_ENUM_DECL(virStoragePoolFormatLogical)
|
VIR_ENUM_DECL(virStoragePoolFormatLogical)
|
||||||
|
|
||||||
|
|
||||||
enum virStorageVolFormatFileSystem {
|
|
||||||
VIR_STORAGE_VOL_FILE_RAW = 0,
|
|
||||||
VIR_STORAGE_VOL_FILE_DIR,
|
|
||||||
VIR_STORAGE_VOL_FILE_BOCHS,
|
|
||||||
VIR_STORAGE_VOL_FILE_CLOOP,
|
|
||||||
VIR_STORAGE_VOL_FILE_COW,
|
|
||||||
VIR_STORAGE_VOL_FILE_DMG,
|
|
||||||
VIR_STORAGE_VOL_FILE_ISO,
|
|
||||||
VIR_STORAGE_VOL_FILE_QCOW,
|
|
||||||
VIR_STORAGE_VOL_FILE_QCOW2,
|
|
||||||
VIR_STORAGE_VOL_FILE_VMDK,
|
|
||||||
VIR_STORAGE_VOL_FILE_VPC,
|
|
||||||
VIR_STORAGE_VOL_FILE_LAST,
|
|
||||||
};
|
|
||||||
VIR_ENUM_DECL(virStorageVolFormatFileSystem)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX these are basically partition types.
|
* XXX these are basically partition types.
|
||||||
*
|
*
|
||||||
|
@ -380,8 +380,6 @@ virStorageVolDefParseNode;
|
|||||||
virStoragePoolFormatDiskTypeToString;
|
virStoragePoolFormatDiskTypeToString;
|
||||||
virStoragePoolFormatFileSystemTypeToString;
|
virStoragePoolFormatFileSystemTypeToString;
|
||||||
virStoragePoolFormatFileSystemNetTypeToString;
|
virStoragePoolFormatFileSystemNetTypeToString;
|
||||||
virStorageVolFormatFileSystemTypeToString;
|
|
||||||
virStorageVolFormatFileSystemTypeFromString;
|
|
||||||
virStoragePoolTypeFromString;
|
virStoragePoolTypeFromString;
|
||||||
virStoragePartedFsTypeTypeToString;
|
virStoragePartedFsTypeTypeToString;
|
||||||
virStoragePoolObjLock;
|
virStoragePoolObjLock;
|
||||||
@ -394,6 +392,9 @@ virStorageEncryptionParseNode;
|
|||||||
virStorageEncryptionFormat;
|
virStorageEncryptionFormat;
|
||||||
virStorageGenerateQcowPassphrase;
|
virStorageGenerateQcowPassphrase;
|
||||||
|
|
||||||
|
# storage_file.h
|
||||||
|
virStorageFileFormatTypeToString;
|
||||||
|
virStorageFileFormatTypeFromString;
|
||||||
|
|
||||||
# threads.h
|
# threads.h
|
||||||
virMutexInit;
|
virMutexInit;
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "secret_conf.h"
|
#include "secret_conf.h"
|
||||||
#include "uuid.h"
|
#include "uuid.h"
|
||||||
|
#include "storage_file.h"
|
||||||
#include "storage_backend.h"
|
#include "storage_backend.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
@ -461,16 +462,16 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
|
|||||||
char *create_tool;
|
char *create_tool;
|
||||||
short use_kvmimg;
|
short use_kvmimg;
|
||||||
|
|
||||||
const char *type = virStorageVolFormatFileSystemTypeToString(vol->target.format);
|
const char *type = virStorageFileFormatTypeToString(vol->target.format);
|
||||||
const char *backingType = vol->backingStore.path ?
|
const char *backingType = vol->backingStore.path ?
|
||||||
virStorageVolFormatFileSystemTypeToString(vol->backingStore.format) : NULL;
|
virStorageFileFormatTypeToString(vol->backingStore.format) : NULL;
|
||||||
|
|
||||||
const char *inputBackingPath = (inputvol ? inputvol->backingStore.path
|
const char *inputBackingPath = (inputvol ? inputvol->backingStore.path
|
||||||
: NULL);
|
: NULL);
|
||||||
const char *inputPath = inputvol ? inputvol->target.path : NULL;
|
const char *inputPath = inputvol ? inputvol->target.path : NULL;
|
||||||
/* Treat input block devices as 'raw' format */
|
/* Treat input block devices as 'raw' format */
|
||||||
const char *inputType = inputPath ?
|
const char *inputType = inputPath ?
|
||||||
virStorageVolFormatFileSystemTypeToString(inputvol->type == VIR_STORAGE_VOL_BLOCK ? VIR_STORAGE_VOL_FILE_RAW : inputvol->target.format) :
|
virStorageFileFormatTypeToString(inputvol->type == VIR_STORAGE_VOL_BLOCK ? VIR_STORAGE_FILE_RAW : inputvol->target.format) :
|
||||||
NULL;
|
NULL;
|
||||||
|
|
||||||
const char **imgargv;
|
const char **imgargv;
|
||||||
@ -551,8 +552,8 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
|
|||||||
if (vol->target.encryption != NULL) {
|
if (vol->target.encryption != NULL) {
|
||||||
virStorageEncryptionPtr enc;
|
virStorageEncryptionPtr enc;
|
||||||
|
|
||||||
if (vol->target.format != VIR_STORAGE_VOL_FILE_QCOW &&
|
if (vol->target.format != VIR_STORAGE_FILE_QCOW &&
|
||||||
vol->target.format != VIR_STORAGE_VOL_FILE_QCOW2) {
|
vol->target.format != VIR_STORAGE_FILE_QCOW2) {
|
||||||
virStorageReportError(conn, VIR_ERR_NO_SUPPORT,
|
virStorageReportError(conn, VIR_ERR_NO_SUPPORT,
|
||||||
_("qcow volume encryption unsupported with "
|
_("qcow volume encryption unsupported with "
|
||||||
"volume format %s"), type);
|
"volume format %s"), type);
|
||||||
@ -643,7 +644,7 @@ virStorageBackendCreateQcowCreate(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vol->target.format != VIR_STORAGE_VOL_FILE_QCOW2) {
|
if (vol->target.format != VIR_STORAGE_FILE_QCOW2) {
|
||||||
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unsupported storage vol type %d"),
|
_("unsupported storage vol type %d"),
|
||||||
vol->target.format);
|
vol->target.format);
|
||||||
@ -734,9 +735,9 @@ virStorageBackendGetBuildVolFromFunction(virConnectPtr conn,
|
|||||||
* tool for converting
|
* tool for converting
|
||||||
*/
|
*/
|
||||||
if ((vol->type == VIR_STORAGE_VOL_FILE &&
|
if ((vol->type == VIR_STORAGE_VOL_FILE &&
|
||||||
vol->target.format != VIR_STORAGE_VOL_FILE_RAW) ||
|
vol->target.format != VIR_STORAGE_FILE_RAW) ||
|
||||||
(inputvol->type == VIR_STORAGE_VOL_FILE &&
|
(inputvol->type == VIR_STORAGE_VOL_FILE &&
|
||||||
inputvol->target.format != VIR_STORAGE_VOL_FILE_RAW)) {
|
inputvol->target.format != VIR_STORAGE_FILE_RAW)) {
|
||||||
|
|
||||||
if ((tool_type = virStorageBackendFindFSImageTool(NULL)) < 0) {
|
if ((tool_type = virStorageBackendFindFSImageTool(NULL)) < 0) {
|
||||||
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "virterror_internal.h"
|
#include "virterror_internal.h"
|
||||||
#include "storage_backend_fs.h"
|
#include "storage_backend_fs.h"
|
||||||
#include "storage_conf.h"
|
#include "storage_conf.h"
|
||||||
|
#include "storage_file.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "xml.h"
|
#include "xml.h"
|
||||||
@ -91,7 +92,7 @@ struct FileTypeInfo {
|
|||||||
struct FileTypeInfo const fileTypeInfo[] = {
|
struct FileTypeInfo const fileTypeInfo[] = {
|
||||||
/* Bochs */
|
/* Bochs */
|
||||||
/* XXX Untested
|
/* XXX Untested
|
||||||
{ VIR_STORAGE_VOL_FILE_BOCHS, "Bochs Virtual HD Image", NULL,
|
{ VIR_STORAGE_FILE_BOCHS, "Bochs Virtual HD Image", NULL,
|
||||||
LV_LITTLE_ENDIAN, 64, 0x20000,
|
LV_LITTLE_ENDIAN, 64, 0x20000,
|
||||||
32+16+16+4+4+4+4+4, 8, 1, -1, NULL },*/
|
32+16+16+4+4+4+4+4, 8, 1, -1, NULL },*/
|
||||||
/* CLoop */
|
/* CLoop */
|
||||||
@ -100,45 +101,45 @@ struct FileTypeInfo const fileTypeInfo[] = {
|
|||||||
LV_LITTLE_ENDIAN, -1, 0,
|
LV_LITTLE_ENDIAN, -1, 0,
|
||||||
-1, 0, 0, -1, NULL }, */
|
-1, 0, 0, -1, NULL }, */
|
||||||
/* Cow */
|
/* Cow */
|
||||||
{ VIR_STORAGE_VOL_FILE_COW, "OOOM", NULL,
|
{ VIR_STORAGE_FILE_COW, "OOOM", NULL,
|
||||||
LV_BIG_ENDIAN, 4, 2,
|
LV_BIG_ENDIAN, 4, 2,
|
||||||
4+4+1024+4, 8, 1, -1, cowGetBackingStore },
|
4+4+1024+4, 8, 1, -1, cowGetBackingStore },
|
||||||
/* DMG */
|
/* DMG */
|
||||||
/* XXX QEMU says there's no magic for dmg, but we should check... */
|
/* XXX QEMU says there's no magic for dmg, but we should check... */
|
||||||
{ VIR_STORAGE_VOL_FILE_DMG, NULL, ".dmg",
|
{ VIR_STORAGE_FILE_DMG, NULL, ".dmg",
|
||||||
0, -1, 0,
|
0, -1, 0,
|
||||||
-1, 0, 0, -1, NULL },
|
-1, 0, 0, -1, NULL },
|
||||||
/* XXX there's probably some magic for iso we can validate too... */
|
/* XXX there's probably some magic for iso we can validate too... */
|
||||||
{ VIR_STORAGE_VOL_FILE_ISO, NULL, ".iso",
|
{ VIR_STORAGE_FILE_ISO, NULL, ".iso",
|
||||||
0, -1, 0,
|
0, -1, 0,
|
||||||
-1, 0, 0, -1, NULL },
|
-1, 0, 0, -1, NULL },
|
||||||
/* Parallels */
|
/* Parallels */
|
||||||
/* XXX Untested
|
/* XXX Untested
|
||||||
{ VIR_STORAGE_VOL_FILE_PARALLELS, "WithoutFreeSpace", NULL,
|
{ VIR_STORAGE_FILE_PARALLELS, "WithoutFreeSpace", NULL,
|
||||||
LV_LITTLE_ENDIAN, 16, 2,
|
LV_LITTLE_ENDIAN, 16, 2,
|
||||||
16+4+4+4+4, 4, 512, -1, NULL },
|
16+4+4+4+4, 4, 512, -1, NULL },
|
||||||
*/
|
*/
|
||||||
/* QCow */
|
/* QCow */
|
||||||
{ VIR_STORAGE_VOL_FILE_QCOW, "QFI", NULL,
|
{ VIR_STORAGE_FILE_QCOW, "QFI", NULL,
|
||||||
LV_BIG_ENDIAN, 4, 1,
|
LV_BIG_ENDIAN, 4, 1,
|
||||||
4+4+8+4+4, 8, 1, 4+4+8+4+4+8+1+1+2, qcowXGetBackingStore },
|
4+4+8+4+4, 8, 1, 4+4+8+4+4+8+1+1+2, qcowXGetBackingStore },
|
||||||
/* QCow 2 */
|
/* QCow 2 */
|
||||||
{ VIR_STORAGE_VOL_FILE_QCOW2, "QFI", NULL,
|
{ VIR_STORAGE_FILE_QCOW2, "QFI", NULL,
|
||||||
LV_BIG_ENDIAN, 4, 2,
|
LV_BIG_ENDIAN, 4, 2,
|
||||||
4+4+8+4+4, 8, 1, 4+4+8+4+4+8, qcowXGetBackingStore },
|
4+4+8+4+4, 8, 1, 4+4+8+4+4+8, qcowXGetBackingStore },
|
||||||
/* VMDK 3 */
|
/* VMDK 3 */
|
||||||
/* XXX Untested
|
/* XXX Untested
|
||||||
{ VIR_STORAGE_VOL_FILE_VMDK, "COWD", NULL,
|
{ VIR_STORAGE_FILE_VMDK, "COWD", NULL,
|
||||||
LV_LITTLE_ENDIAN, 4, 1,
|
LV_LITTLE_ENDIAN, 4, 1,
|
||||||
4+4+4, 4, 512, -1, NULL },
|
4+4+4, 4, 512, -1, NULL },
|
||||||
*/
|
*/
|
||||||
/* VMDK 4 */
|
/* VMDK 4 */
|
||||||
{ VIR_STORAGE_VOL_FILE_VMDK, "KDMV", NULL,
|
{ VIR_STORAGE_FILE_VMDK, "KDMV", NULL,
|
||||||
LV_LITTLE_ENDIAN, 4, 1,
|
LV_LITTLE_ENDIAN, 4, 1,
|
||||||
4+4+4, 8, 512, -1, vmdk4GetBackingStore },
|
4+4+4, 8, 512, -1, vmdk4GetBackingStore },
|
||||||
/* Connectix / VirtualPC */
|
/* Connectix / VirtualPC */
|
||||||
/* XXX Untested
|
/* XXX Untested
|
||||||
{ VIR_STORAGE_VOL_FILE_VPC, "conectix", NULL,
|
{ VIR_STORAGE_FILE_VPC, "conectix", NULL,
|
||||||
LV_BIG_ENDIAN, -1, 0,
|
LV_BIG_ENDIAN, -1, 0,
|
||||||
-1, 0, 0, -1, NULL},
|
-1, 0, 0, -1, NULL},
|
||||||
*/
|
*/
|
||||||
@ -452,7 +453,7 @@ static int virStorageBackendProbeTarget(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* All fails, so call it a raw file */
|
/* All fails, so call it a raw file */
|
||||||
target->format = VIR_STORAGE_VOL_FILE_RAW;
|
target->format = VIR_STORAGE_FILE_RAW;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,7 +892,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn,
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
vol->type = VIR_STORAGE_VOL_FILE;
|
vol->type = VIR_STORAGE_VOL_FILE;
|
||||||
vol->target.format = VIR_STORAGE_VOL_FILE_RAW; /* Real value is filled in during probe */
|
vol->target.format = VIR_STORAGE_FILE_RAW; /* Real value is filled in during probe */
|
||||||
if (virAsprintf(&vol->target.path, "%s/%s",
|
if (virAsprintf(&vol->target.path, "%s/%s",
|
||||||
pool->def->target.path,
|
pool->def->target.path,
|
||||||
vol->name) == -1)
|
vol->name) == -1)
|
||||||
@ -918,7 +919,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (backingStore != NULL) {
|
if (backingStore != NULL) {
|
||||||
if (vol->target.format == VIR_STORAGE_VOL_FILE_QCOW2 &&
|
if (vol->target.format == VIR_STORAGE_FILE_QCOW2 &&
|
||||||
STRPREFIX("fmt:", backingStore)) {
|
STRPREFIX("fmt:", backingStore)) {
|
||||||
char *fmtstr = backingStore + 4;
|
char *fmtstr = backingStore + 4;
|
||||||
char *path = strchr(fmtstr, ':');
|
char *path = strchr(fmtstr, ':');
|
||||||
@ -927,7 +928,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn,
|
|||||||
} else {
|
} else {
|
||||||
*path = '\0';
|
*path = '\0';
|
||||||
if ((vol->backingStore.format =
|
if ((vol->backingStore.format =
|
||||||
virStorageVolFormatFileSystemTypeFromString(fmtstr)) < 0) {
|
virStorageFileFormatTypeFromString(fmtstr)) < 0) {
|
||||||
VIR_FREE(backingStore);
|
VIR_FREE(backingStore);
|
||||||
} else {
|
} else {
|
||||||
memmove(backingStore, path, strlen(path) + 1);
|
memmove(backingStore, path, strlen(path) + 1);
|
||||||
@ -1121,9 +1122,9 @@ _virStorageBackendFileSystemVolBuild(virConnectPtr conn,
|
|||||||
inputvol);
|
inputvol);
|
||||||
if (!create_func)
|
if (!create_func)
|
||||||
return -1;
|
return -1;
|
||||||
} else if (vol->target.format == VIR_STORAGE_VOL_FILE_RAW) {
|
} else if (vol->target.format == VIR_STORAGE_FILE_RAW) {
|
||||||
create_func = virStorageBackendCreateRaw;
|
create_func = virStorageBackendCreateRaw;
|
||||||
} else if (vol->target.format == VIR_STORAGE_VOL_FILE_DIR) {
|
} else if (vol->target.format == VIR_STORAGE_FILE_DIR) {
|
||||||
create_func = createFileDir;
|
create_func = createFileDir;
|
||||||
} else if ((tool_type = virStorageBackendFindFSImageTool(NULL)) != -1) {
|
} else if ((tool_type = virStorageBackendFindFSImageTool(NULL)) != -1) {
|
||||||
create_func = virStorageBackendFSImageToolTypeToFunc(conn, tool_type);
|
create_func = virStorageBackendFSImageToolTypeToFunc(conn, tool_type);
|
||||||
|
31
src/util/storage_file.c
Normal file
31
src/util/storage_file.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* storage_file.c: file utility functions for FS storage backend
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2009 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2007-2008 Daniel P. Berrange
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include "storage_file.h"
|
||||||
|
|
||||||
|
VIR_ENUM_IMPL(virStorageFileFormat,
|
||||||
|
VIR_STORAGE_FILE_LAST,
|
||||||
|
"raw", "dir", "bochs",
|
||||||
|
"cloop", "cow", "dmg", "iso",
|
||||||
|
"qcow", "qcow2", "vmdk", "vpc")
|
46
src/util/storage_file.h
Normal file
46
src/util/storage_file.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* storage_file.c: file utility functions for FS storage backend
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2009 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2007-2008 Daniel P. Berrange
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __VIR_STORAGE_FILE_H__
|
||||||
|
#define __VIR_STORAGE_FILE_H__
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
enum virStorageFileFormat {
|
||||||
|
VIR_STORAGE_FILE_RAW = 0,
|
||||||
|
VIR_STORAGE_FILE_DIR,
|
||||||
|
VIR_STORAGE_FILE_BOCHS,
|
||||||
|
VIR_STORAGE_FILE_CLOOP,
|
||||||
|
VIR_STORAGE_FILE_COW,
|
||||||
|
VIR_STORAGE_FILE_DMG,
|
||||||
|
VIR_STORAGE_FILE_ISO,
|
||||||
|
VIR_STORAGE_FILE_QCOW,
|
||||||
|
VIR_STORAGE_FILE_QCOW2,
|
||||||
|
VIR_STORAGE_FILE_VMDK,
|
||||||
|
VIR_STORAGE_FILE_VPC,
|
||||||
|
VIR_STORAGE_FILE_LAST,
|
||||||
|
};
|
||||||
|
|
||||||
|
VIR_ENUM_DECL(virStorageFileFormat);
|
||||||
|
|
||||||
|
#endif /* __VIR_STORAGE_FILE_H__ */
|
@ -45,6 +45,7 @@
|
|||||||
#include "virterror_internal.h"
|
#include "virterror_internal.h"
|
||||||
#include "domain_event.h"
|
#include "domain_event.h"
|
||||||
#include "storage_conf.h"
|
#include "storage_conf.h"
|
||||||
|
#include "storage_file.h"
|
||||||
#include "uuid.h"
|
#include "uuid.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
@ -5985,14 +5986,14 @@ static virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
/* TODO: for now only the vmdk, vpc and vdi type harddisk
|
/* TODO: for now only the vmdk, vpc and vdi type harddisk
|
||||||
* variants can be created, also since there is no vdi
|
* variants can be created, also since there is no vdi
|
||||||
* type in enum virStorageVolFormatFileSystem {} the default
|
* type in enum virStorageFileFormat {} the default
|
||||||
* will be to create vdi if nothing is specified in
|
* will be to create vdi if nothing is specified in
|
||||||
* def->target.format
|
* def->target.format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (def->target.format == VIR_STORAGE_VOL_FILE_VMDK) {
|
if (def->target.format == VIR_STORAGE_FILE_VMDK) {
|
||||||
data->pFuncs->pfnUtf8ToUtf16("VMDK", &hddFormatUtf16);
|
data->pFuncs->pfnUtf8ToUtf16("VMDK", &hddFormatUtf16);
|
||||||
} else if (def->target.format == VIR_STORAGE_VOL_FILE_VPC) {
|
} else if (def->target.format == VIR_STORAGE_FILE_VPC) {
|
||||||
data->pFuncs->pfnUtf8ToUtf16("VHD", &hddFormatUtf16);
|
data->pFuncs->pfnUtf8ToUtf16("VHD", &hddFormatUtf16);
|
||||||
} else {
|
} else {
|
||||||
data->pFuncs->pfnUtf8ToUtf16("VDI", &hddFormatUtf16);
|
data->pFuncs->pfnUtf8ToUtf16("VDI", &hddFormatUtf16);
|
||||||
@ -6307,13 +6308,13 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A
|
|||||||
DEBUG("Storage Volume Format: %s", hddFormatUtf8);
|
DEBUG("Storage Volume Format: %s", hddFormatUtf8);
|
||||||
|
|
||||||
if (STRCASEEQ("vmdk", hddFormatUtf8))
|
if (STRCASEEQ("vmdk", hddFormatUtf8))
|
||||||
def.target.format = VIR_STORAGE_VOL_FILE_VMDK;
|
def.target.format = VIR_STORAGE_FILE_VMDK;
|
||||||
else if (STRCASEEQ("vhd", hddFormatUtf8))
|
else if (STRCASEEQ("vhd", hddFormatUtf8))
|
||||||
def.target.format = VIR_STORAGE_VOL_FILE_VPC;
|
def.target.format = VIR_STORAGE_FILE_VPC;
|
||||||
else
|
else
|
||||||
def.target.format = VIR_STORAGE_VOL_FILE_RAW;
|
def.target.format = VIR_STORAGE_FILE_RAW;
|
||||||
|
|
||||||
/* TODO: need to add vdi to enum virStorageVolFormatFileSystem {}
|
/* TODO: need to add vdi to enum virStorageFileFormat {}
|
||||||
* and then add it here
|
* and then add it here
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user