mirror of https://gitee.com/openkylin/libvirt.git
conf: use common struct in storage volumes
A fairly smooth transition. And now that domain disks and storage volumes share a common struct, it opens the doors for a future patch to expose more details in the XML for both objects. * src/conf/storage_conf.h (_virStorageVolTarget): Delete. (_virStorageVolDef): Use common type. * src/conf/storage_conf.c (virStorageVolDefFree) (virStorageVolTargetDefFormat): Update clients. * src/storage/storage_backend.h: Likewise. * src/storage/storage_backend.c (virStorageBackendDetectBlockVolFormatFD) (virStorageBackendUpdateVolTargetInfo) (virStorageBackendUpdateVolTargetInfoFD): Likewise. * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
2a4fd2281e
commit
df17611525
|
@ -329,22 +329,8 @@ virStorageVolDefFree(virStorageVolDefPtr def)
|
||||||
}
|
}
|
||||||
VIR_FREE(def->source.extents);
|
VIR_FREE(def->source.extents);
|
||||||
|
|
||||||
VIR_FREE(def->target.compat);
|
virStorageSourceClear(&def->target);
|
||||||
virBitmapFree(def->target.features);
|
virStorageSourceClear(&def->backingStore);
|
||||||
VIR_FREE(def->target.path);
|
|
||||||
if (def->target.perms) {
|
|
||||||
VIR_FREE(def->target.perms->label);
|
|
||||||
VIR_FREE(def->target.perms);
|
|
||||||
}
|
|
||||||
VIR_FREE(def->target.timestamps);
|
|
||||||
virStorageEncryptionFree(def->target.encryption);
|
|
||||||
VIR_FREE(def->backingStore.path);
|
|
||||||
if (def->backingStore.perms) {
|
|
||||||
VIR_FREE(def->backingStore.perms->label);
|
|
||||||
VIR_FREE(def->backingStore.perms);
|
|
||||||
}
|
|
||||||
VIR_FREE(def->backingStore.timestamps);
|
|
||||||
virStorageEncryptionFree(def->backingStore.encryption);
|
|
||||||
VIR_FREE(def);
|
VIR_FREE(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1528,7 +1514,7 @@ virStorageVolTimestampFormat(virBufferPtr buf, const char *name,
|
||||||
static int
|
static int
|
||||||
virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
|
virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
|
||||||
virBufferPtr buf,
|
virBufferPtr buf,
|
||||||
virStorageVolTargetPtr def,
|
virStorageSourcePtr def,
|
||||||
const char *type)
|
const char *type)
|
||||||
{
|
{
|
||||||
virBufferAsprintf(buf, "<%s>\n", type);
|
virBufferAsprintf(buf, "<%s>\n", type);
|
||||||
|
|
|
@ -56,24 +56,6 @@ struct _virStorageVolSource {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* How the volume appears on the host
|
|
||||||
*/
|
|
||||||
typedef struct _virStorageVolTarget virStorageVolTarget;
|
|
||||||
typedef virStorageVolTarget *virStorageVolTargetPtr;
|
|
||||||
struct _virStorageVolTarget {
|
|
||||||
char *path;
|
|
||||||
int format; /* enum virStorageFileFormat */
|
|
||||||
virStoragePermsPtr perms;
|
|
||||||
virStorageTimestampsPtr timestamps;
|
|
||||||
|
|
||||||
/* The next three are currently only used in vol->target,
|
|
||||||
* not in vol->backingStore. */
|
|
||||||
virStorageEncryptionPtr encryption;
|
|
||||||
virBitmapPtr features;
|
|
||||||
char *compat;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct _virStorageVolDef virStorageVolDef;
|
typedef struct _virStorageVolDef virStorageVolDef;
|
||||||
typedef virStorageVolDef *virStorageVolDefPtr;
|
typedef virStorageVolDef *virStorageVolDefPtr;
|
||||||
struct _virStorageVolDef {
|
struct _virStorageVolDef {
|
||||||
|
@ -87,8 +69,8 @@ struct _virStorageVolDef {
|
||||||
unsigned long long capacity; /* bytes */
|
unsigned long long capacity; /* bytes */
|
||||||
|
|
||||||
virStorageVolSource source;
|
virStorageVolSource source;
|
||||||
virStorageVolTarget target;
|
virStorageSource target;
|
||||||
virStorageVolTarget backingStore;
|
virStorageSource backingStore;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _virStorageVolDefList virStorageVolDefList;
|
typedef struct _virStorageVolDefList virStorageVolDefList;
|
||||||
|
|
|
@ -1236,7 +1236,7 @@ static struct diskType const disk_types[] = {
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virStorageBackendDetectBlockVolFormatFD(virStorageVolTargetPtr target,
|
virStorageBackendDetectBlockVolFormatFD(virStorageSourcePtr target,
|
||||||
int fd)
|
int fd)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -1384,7 +1384,7 @@ virStorageBackendVolOpen(const char *path, struct stat *sb,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
|
virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
|
||||||
unsigned long long *allocation,
|
unsigned long long *allocation,
|
||||||
unsigned long long *capacity,
|
unsigned long long *capacity,
|
||||||
bool withBlockVolFormat,
|
bool withBlockVolFormat,
|
||||||
|
@ -1451,7 +1451,7 @@ virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
|
||||||
* Returns 0 for success, -1 on a legitimate error condition.
|
* Returns 0 for success, -1 on a legitimate error condition.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
|
virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
|
||||||
int fd,
|
int fd,
|
||||||
struct stat *sb,
|
struct stat *sb,
|
||||||
unsigned long long *allocation,
|
unsigned long long *allocation,
|
||||||
|
|
|
@ -141,12 +141,12 @@ int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
|
||||||
bool withCapacity,
|
bool withCapacity,
|
||||||
bool withBlockVolFormat,
|
bool withBlockVolFormat,
|
||||||
unsigned int openflags);
|
unsigned int openflags);
|
||||||
int virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
|
int virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
|
||||||
unsigned long long *allocation,
|
unsigned long long *allocation,
|
||||||
unsigned long long *capacity,
|
unsigned long long *capacity,
|
||||||
bool withBlockVolFormat,
|
bool withBlockVolFormat,
|
||||||
unsigned int openflags);
|
unsigned int openflags);
|
||||||
int virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
|
int virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
|
||||||
int fd,
|
int fd,
|
||||||
struct stat *sb,
|
struct stat *sb,
|
||||||
unsigned long long *allocation,
|
unsigned long long *allocation,
|
||||||
|
|
|
@ -62,7 +62,7 @@ VIR_LOG_INIT("storage.storage_backend_fs");
|
||||||
~VIR_STORAGE_VOL_OPEN_ERROR)
|
~VIR_STORAGE_VOL_OPEN_ERROR)
|
||||||
|
|
||||||
static int ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
static int ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
||||||
virStorageBackendProbeTarget(virStorageVolTargetPtr target,
|
virStorageBackendProbeTarget(virStorageSourcePtr target,
|
||||||
char **backingStore,
|
char **backingStore,
|
||||||
int *backingStoreFormat,
|
int *backingStoreFormat,
|
||||||
unsigned long long *allocation,
|
unsigned long long *allocation,
|
||||||
|
|
Loading…
Reference in New Issue