mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 04:55:18 +00:00
virStorageSourceGetActualType: Change type of retval
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 <mprivozn@redhat.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
This commit is contained in:
parent
2307f06cb2
commit
215b2466cd
@ -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 &&
|
||||
|
@ -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
|
||||
|
@ -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")) {
|
||||
|
@ -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 */
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user