The virStorageSourceGetActualType() function returns either virStorageSource->type (which is of type virStorageType), or virStorageSourcePoolDef->type, which really stores a value of the same enum. Thus, the latter struct can be changed so that the virStorageSourceGetActualType() function can return correct type instead of generic int.
Signed-off-by: Michal Privoznik <mpriv...@redhat.com> --- src/conf/storage_source_conf.c | 2 +- src/conf/storage_source_conf.h | 4 ++-- src/libxl/libxl_conf.c | 2 +- src/libxl/libxl_domain.c | 2 +- src/libxl/xen_xl.c | 4 ++-- src/locking/domain_lock.c | 2 +- src/qemu/qemu_block.c | 12 ++++++------ src/qemu/qemu_command.c | 8 ++++---- src/qemu/qemu_domain.c | 4 ++-- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_migration.c | 4 ++-- src/qemu/qemu_snapshot.c | 16 ++++++++-------- src/storage_file/storage_source.c | 4 ++-- 13 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index 1a7284ec12..2b4cf5e241 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -1004,7 +1004,7 @@ virStorageSourcePoolDefFree(virStorageSourcePoolDef *def) * and virDomainDiskTranslateSourcePool was called on @def the actual type * of the storage volume is returned rather than VIR_STORAGE_TYPE_VOLUME. */ -int +virStorageType virStorageSourceGetActualType(const virStorageSource *def) { if (def->type == VIR_STORAGE_TYPE_VOLUME && diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index 035ea7016d..f2440cec6a 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -199,7 +199,7 @@ struct _virStorageSourcePoolDef { char *volume; /* volume name */ int voltype; /* virStorageVolType, internal only */ int pooltype; /* virStoragePoolType from storage_conf.h, internal only */ - int actualtype; /* virStorageType, internal only */ + virStorageType actualtype; /* internal only */ int mode; /* virStorageSourcePoolMode, currently makes sense only for iscsi pool */ }; @@ -469,7 +469,7 @@ virStorageSourcePoolDefFree(virStorageSourcePoolDef *def); void virStorageSourceClear(virStorageSource *def); -int +virStorageType virStorageSourceGetActualType(const virStorageSource *def); bool diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 726ecdc945..401e47344e 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1067,7 +1067,7 @@ libxlMakeDisk(virDomainDiskDef *l_disk, libxl_device_disk *x_disk) { const char *driver = virDomainDiskGetDriver(l_disk); int format = virDomainDiskGetFormat(l_disk); - int actual_type = virStorageSourceGetActualType(l_disk->src); + virStorageType actual_type = virStorageSourceGetActualType(l_disk->src); if (actual_type == VIR_STORAGE_TYPE_NETWORK) { if (STRNEQ_NULLABLE(driver, "qemu")) { diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index af938192a9..49ac09d8a4 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -330,7 +330,7 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDef *dev, if (dev->type == VIR_DOMAIN_DEVICE_DISK) { virDomainDiskDef *disk = dev->data.disk; - int actual_type = virStorageSourceGetActualType(disk->src); + virStorageType actual_type = virStorageSourceGetActualType(disk->src); int format = virDomainDiskGetFormat(disk); /* for network-based disks, set 'qemu' as the default driver */ diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 6b7f638783..eb3b0b3718 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1489,14 +1489,14 @@ xenFormatXLDiskSrcNet(virStorageSource *src) static int xenFormatXLDiskSrc(virStorageSource *src, char **srcstr) { - int actualType = virStorageSourceGetActualType(src); + virStorageType actualType = virStorageSourceGetActualType(src); *srcstr = NULL; if (virStorageSourceIsEmpty(src)) return 0; - switch ((virStorageType)actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_DIR: diff --git a/src/locking/domain_lock.c b/src/locking/domain_lock.c index 9934e91aa9..8966980532 100644 --- a/src/locking/domain_lock.c +++ b/src/locking/domain_lock.c @@ -72,7 +72,7 @@ static int virDomainLockManagerAddImage(virLockManager *lock, virStorageSource *src) { unsigned int diskFlags = 0; - int type = virStorageSourceGetActualType(src); + virStorageType type = virStorageSourceGetActualType(src); if (!src->path) return 0; diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 60e03d418e..877c66d62b 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1128,7 +1128,7 @@ virJSONValue * qemuBlockStorageSourceGetBackendProps(virStorageSource *src, unsigned int flags) { - int actualType = virStorageSourceGetActualType(src); + virStorageType actualType = virStorageSourceGetActualType(src); g_autoptr(virJSONValue) fileprops = NULL; const char *driver = NULL; virTristateBool aro = VIR_TRISTATE_BOOL_ABSENT; @@ -1145,7 +1145,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource *src, ro = VIR_TRISTATE_BOOL_NO; } - switch ((virStorageType)actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: if (virStorageSourceIsBlockLocal(src)) { @@ -2200,7 +2200,7 @@ char * qemuBlockGetBackingStoreString(virStorageSource *src, bool pretty) { - int actualType = virStorageSourceGetActualType(src); + virStorageType actualType = virStorageSourceGetActualType(src); g_autoptr(virJSONValue) backingProps = NULL; g_autoptr(virJSONValue) sliceProps = NULL; virJSONValue *props = NULL; @@ -2599,12 +2599,12 @@ int qemuBlockStorageSourceCreateGetStorageProps(virStorageSource *src, virJSONValue **props) { - int actualType = virStorageSourceGetActualType(src); + virStorageType actualType = virStorageSourceGetActualType(src); g_autoptr(virJSONValue) location = NULL; const char *driver = NULL; const char *filename = NULL; - switch ((virStorageType) actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_FILE: driver = "file"; filename = src->path; @@ -2745,7 +2745,7 @@ qemuBlockStorageSourceCreateStorage(virDomainObj *vm, virStorageSource *chain, virDomainAsyncJob asyncJob) { - int actualType = virStorageSourceGetActualType(src); + virStorageType actualType = virStorageSourceGetActualType(src); g_autoptr(virJSONValue) createstorageprops = NULL; int ret; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 34dffb0615..33069ea131 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1736,7 +1736,7 @@ qemuGetDriveSourceString(virStorageSource *src, qemuDomainSecretInfo *secinfo, char **source) { - int actualType = virStorageSourceGetActualType(src); + virStorageType actualType = virStorageSourceGetActualType(src); *source = NULL; @@ -1744,7 +1744,7 @@ qemuGetDriveSourceString(virStorageSource *src, if (virStorageSourceIsEmpty(src)) return 1; - switch ((virStorageType)actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_DIR: @@ -1803,7 +1803,7 @@ qemuDiskBusIsSD(int bus) static bool qemuDiskSourceNeedsProps(virStorageSource *src) { - int actualType = virStorageSourceGetActualType(src); + virStorageType actualType = virStorageSourceGetActualType(src); if (actualType == VIR_STORAGE_TYPE_NETWORK && src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER && @@ -1879,7 +1879,7 @@ static int qemuBuildDriveSourceStr(virDomainDiskDef *disk, virBuffer *buf) { - int actualType = virStorageSourceGetActualType(disk->src); + virStorageType actualType = virStorageSourceGetActualType(disk->src); qemuDomainStorageSourcePrivate *srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); qemuDomainSecretInfo *secinfo = NULL; qemuDomainSecretInfo *encinfo = NULL; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 31e60c7359..948ab76304 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4809,7 +4809,7 @@ qemuDomainValidateStorageSource(virStorageSource *src, virQEMUCaps *qemuCaps, bool maskBlockdev) { - int actualType = virStorageSourceGetActualType(src); + virStorageType actualType = virStorageSourceGetActualType(src); bool blockdev = virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV); if (maskBlockdev) @@ -10932,7 +10932,7 @@ qemuDomainPrepareDiskSource(virDomainDiskDef *disk, /* set default format for storage pool based disks */ if (disk->src->type == VIR_STORAGE_TYPE_VOLUME && disk->src->format <= VIR_STORAGE_FILE_NONE) { - int actualType = virStorageSourceGetActualType(disk->src); + virStorageType actualType = virStorageSourceGetActualType(disk->src); if (actualType == VIR_STORAGE_TYPE_DIR) disk->src->format = VIR_STORAGE_FILE_FAT; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6631edb9d6..1d50aa5271 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14790,7 +14790,7 @@ qemuDomainBlockCopyValidateMirror(virStorageSource *mirror, const char *dst, bool *reuse) { - int desttype = virStorageSourceGetActualType(mirror); + virStorageType desttype = virStorageSourceGetActualType(mirror); struct stat st; if (!virStorageSourceIsLocalStorage(mirror)) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 176c25cd11..97ce9ac27e 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1504,7 +1504,7 @@ qemuMigrationSrcIsSafe(virDomainDef *def, for (i = 0; i < def->ndisks; i++) { virDomainDiskDef *disk = def->disks[i]; const char *src = virDomainDiskGetSource(disk); - int actualType = virStorageSourceGetActualType(disk->src); + virStorageType actualType = virStorageSourceGetActualType(disk->src); bool unsafe = false; /* Disks without any source (i.e. floppies and CD-ROMs) @@ -1519,7 +1519,7 @@ qemuMigrationSrcIsSafe(virDomainDef *def, continue; /* However, disks on local FS (e.g. ext4) are not safe. */ - switch ((virStorageType) actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_FILE: if ((rc = virFileIsSharedFS(src)) < 0) { return false; diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index b62fab7bb3..c6beeda1d0 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -380,10 +380,10 @@ static int qemuSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDef *snapdisk, virDomainDiskDef *domdisk) { - int domDiskType = virStorageSourceGetActualType(domdisk->src); - int snapDiskType = virStorageSourceGetActualType(snapdisk->src); + virStorageType domDiskType = virStorageSourceGetActualType(domdisk->src); + virStorageType snapDiskType = virStorageSourceGetActualType(snapdisk->src); - switch ((virStorageType)domDiskType) { + switch (domDiskType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: break; @@ -425,7 +425,7 @@ qemuSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDef *snapdisk, return -1; } - switch ((virStorageType)snapDiskType) { + switch (snapDiskType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: break; @@ -456,7 +456,7 @@ qemuSnapshotPrepareDiskExternalActive(virDomainObj *vm, virDomainDiskDef *domdisk, bool blockdev) { - int actualType = virStorageSourceGetActualType(snapdisk->src); + virStorageType actualType = virStorageSourceGetActualType(snapdisk->src); if (snapdisk->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_MANUAL) return 0; @@ -471,7 +471,7 @@ qemuSnapshotPrepareDiskExternalActive(virDomainObj *vm, if (!qemuDomainDiskBlockJobIsSupported(vm, domdisk)) return -1; - switch ((virStorageType)actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: break; @@ -620,7 +620,7 @@ static int qemuSnapshotPrepareDiskInternal(virDomainDiskDef *disk, bool active) { - int actualType; + virStorageType actualType; /* active disks are handled by qemu itself so no need to worry about those */ if (active) @@ -631,7 +631,7 @@ qemuSnapshotPrepareDiskInternal(virDomainDiskDef *disk, actualType = virStorageSourceGetActualType(disk->src); - switch ((virStorageType)actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: return 0; diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_source.c index 698b9eb79d..dd2bb2641d 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -807,7 +807,7 @@ static int virStorageSourceGetBackendForSupportCheck(const virStorageSource *src, virStorageFileBackend **backend) { - int actualType; + virStorageType actualType; if (!src) { @@ -944,7 +944,7 @@ int virStorageSourceInitAs(virStorageSource *src, uid_t uid, gid_t gid) { - int actualType = virStorageSourceGetActualType(src); + virStorageType actualType = virStorageSourceGetActualType(src); virStorageDriverData *drv = g_new0(virStorageDriverData, 1); src->drv = drv; -- 2.35.1