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:
Eric Blake 2014-04-01 15:11:30 -06:00
parent 2a4fd2281e
commit df17611525
5 changed files with 11 additions and 43 deletions

View File

@ -329,22 +329,8 @@ virStorageVolDefFree(virStorageVolDefPtr def)
}
VIR_FREE(def->source.extents);
VIR_FREE(def->target.compat);
virBitmapFree(def->target.features);
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);
virStorageSourceClear(&def->target);
virStorageSourceClear(&def->backingStore);
VIR_FREE(def);
}
@ -1528,7 +1514,7 @@ virStorageVolTimestampFormat(virBufferPtr buf, const char *name,
static int
virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
virBufferPtr buf,
virStorageVolTargetPtr def,
virStorageSourcePtr def,
const char *type)
{
virBufferAsprintf(buf, "<%s>\n", type);

View File

@ -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 virStorageVolDef *virStorageVolDefPtr;
struct _virStorageVolDef {
@ -87,8 +69,8 @@ struct _virStorageVolDef {
unsigned long long capacity; /* bytes */
virStorageVolSource source;
virStorageVolTarget target;
virStorageVolTarget backingStore;
virStorageSource target;
virStorageSource backingStore;
};
typedef struct _virStorageVolDefList virStorageVolDefList;

View File

@ -1236,7 +1236,7 @@ static struct diskType const disk_types[] = {
static int
virStorageBackendDetectBlockVolFormatFD(virStorageVolTargetPtr target,
virStorageBackendDetectBlockVolFormatFD(virStorageSourcePtr target,
int fd)
{
size_t i;
@ -1384,7 +1384,7 @@ virStorageBackendVolOpen(const char *path, struct stat *sb,
}
int
virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
unsigned long long *allocation,
unsigned long long *capacity,
bool withBlockVolFormat,
@ -1451,7 +1451,7 @@ virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
* Returns 0 for success, -1 on a legitimate error condition.
*/
int
virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
int fd,
struct stat *sb,
unsigned long long *allocation,

View File

@ -141,12 +141,12 @@ int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
bool withCapacity,
bool withBlockVolFormat,
unsigned int openflags);
int virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
int virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
unsigned long long *allocation,
unsigned long long *capacity,
bool withBlockVolFormat,
unsigned int openflags);
int virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
int virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
int fd,
struct stat *sb,
unsigned long long *allocation,

View File

@ -62,7 +62,7 @@ VIR_LOG_INIT("storage.storage_backend_fs");
~VIR_STORAGE_VOL_OPEN_ERROR)
static int ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
virStorageBackendProbeTarget(virStorageVolTargetPtr target,
virStorageBackendProbeTarget(virStorageSourcePtr target,
char **backingStore,
int *backingStoreFormat,
unsigned long long *allocation,