提交 1ee47196 编写于 作者: M Michal Privoznik

qemuMigrationSrcIsSafe: Rework slightly

There are going to be more disk types that are considered unsafe
with respect to migration. Therefore, move the error reporting
call outside of if() body and rework if-else combo to switch().
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NCole Robinson <crobinso@redhat.com>
上级 4fac30d9
...@@ -1257,6 +1257,8 @@ qemuMigrationSrcIsSafe(virDomainDefPtr def, ...@@ -1257,6 +1257,8 @@ qemuMigrationSrcIsSafe(virDomainDefPtr def,
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
virDomainDiskDefPtr disk = def->disks[i]; virDomainDiskDefPtr disk = def->disks[i];
const char *src = virDomainDiskGetSource(disk); const char *src = virDomainDiskGetSource(disk);
int actualType = virStorageSourceGetActualType(disk->src);
bool unsafe = false;
/* Disks without any source (i.e. floppies and CD-ROMs) /* Disks without any source (i.e. floppies and CD-ROMs)
* OR readonly are safe. */ * OR readonly are safe. */
...@@ -1270,21 +1272,34 @@ qemuMigrationSrcIsSafe(virDomainDefPtr def, ...@@ -1270,21 +1272,34 @@ qemuMigrationSrcIsSafe(virDomainDefPtr def,
continue; continue;
/* However, disks on local FS (e.g. ext4) are not safe. */ /* However, disks on local FS (e.g. ext4) are not safe. */
if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_FILE) { switch ((virStorageType) actualType) {
case VIR_STORAGE_TYPE_FILE:
if ((rc = virFileIsSharedFS(src)) < 0) { if ((rc = virFileIsSharedFS(src)) < 0) {
return false; return false;
} else if (rc == 0) { } else if (rc == 0) {
virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", unsafe = true;
_("Migration without shared storage is unsafe"));
return false;
} }
if ((rc = virStorageFileIsClusterFS(src)) < 0) if ((rc = virStorageFileIsClusterFS(src)) < 0)
return false; return false;
else if (rc == 1) else if (rc == 1)
continue; continue;
} else if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_NETWORK) { break;
case VIR_STORAGE_TYPE_NETWORK:
/* But network disks are safe again. */ /* But network disks are safe again. */
continue; continue;
case VIR_STORAGE_TYPE_NONE:
case VIR_STORAGE_TYPE_BLOCK:
case VIR_STORAGE_TYPE_DIR:
case VIR_STORAGE_TYPE_VOLUME:
case VIR_STORAGE_TYPE_LAST:
break;
}
if (unsafe) {
virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s",
_("Migration without shared storage is unsafe"));
return false;
} }
/* Our code elsewhere guarantees shared disks are either readonly (in /* Our code elsewhere guarantees shared disks are either readonly (in
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册