mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-14 00:25:17 +00:00
qemu: migration: Skip cache=none check for disks which are storage-migrated
Since the disks are copied by qemu, there's no need to enforce cache=none. Thankfully the code that added qemuMigrateDisk did not break existing configs, since if you don't select any disk to migrate explicitly the code behaves sanely. The logic for determining whether a disk should be migrated is open-coded since using qemuMigrateDisk twice would be semantically incorrect.
This commit is contained in:
parent
f99bc451fe
commit
41e9f54d05
@ -1127,9 +1127,14 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver,
|
|||||||
static bool
|
static bool
|
||||||
qemuMigrationIsSafe(virDomainDefPtr def,
|
qemuMigrationIsSafe(virDomainDefPtr def,
|
||||||
size_t nmigrate_disks,
|
size_t nmigrate_disks,
|
||||||
const char **migrate_disks)
|
const char **migrate_disks,
|
||||||
|
unsigned int flags)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
bool storagemigration = flags & (VIR_MIGRATE_NON_SHARED_DISK |
|
||||||
|
VIR_MIGRATE_NON_SHARED_INC);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
int rc;
|
||||||
|
|
||||||
for (i = 0; i < def->ndisks; i++) {
|
for (i = 0; i < def->ndisks; i++) {
|
||||||
virDomainDiskDefPtr disk = def->disks[i];
|
virDomainDiskDefPtr disk = def->disks[i];
|
||||||
@ -1137,29 +1142,35 @@ qemuMigrationIsSafe(virDomainDefPtr def,
|
|||||||
|
|
||||||
/* Our code elsewhere guarantees shared disks are either readonly (in
|
/* Our code elsewhere guarantees shared disks are either readonly (in
|
||||||
* which case cache mode doesn't matter) or used with cache=none */
|
* which case cache mode doesn't matter) or used with cache=none */
|
||||||
if (qemuMigrateDisk(disk, nmigrate_disks, migrate_disks) &&
|
if (virStorageSourceIsEmpty(disk->src) ||
|
||||||
disk->cachemode != VIR_DOMAIN_DISK_CACHE_DISABLE) {
|
disk->src->readonly ||
|
||||||
int rc;
|
disk->src->shared ||
|
||||||
|
disk->cachemode == VIR_DOMAIN_DISK_CACHE_DISABLE)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_FILE) {
|
/* disks which are migrated by qemu are safe too */
|
||||||
if ((rc = virFileIsSharedFS(src)) < 0)
|
if (storagemigration &&
|
||||||
return false;
|
qemuMigrateDisk(disk, nmigrate_disks, migrate_disks))
|
||||||
else if (rc == 0)
|
continue;
|
||||||
continue;
|
|
||||||
if ((rc = virStorageFileIsClusterFS(src)) < 0)
|
if (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_FILE) {
|
||||||
return false;
|
if ((rc = virFileIsSharedFS(src)) < 0)
|
||||||
else if (rc == 1)
|
return false;
|
||||||
continue;
|
else if (rc == 0)
|
||||||
} else if (disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
|
|
||||||
disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
if ((rc = virStorageFileIsClusterFS(src)) < 0)
|
||||||
|
return false;
|
||||||
virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s",
|
else if (rc == 1)
|
||||||
_("Migration may lead to data corruption if disks"
|
continue;
|
||||||
" use cache != none"));
|
} else if (disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
|
||||||
return false;
|
disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s",
|
||||||
|
_("Migration may lead to data corruption if disks"
|
||||||
|
" use cache != none"));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1916,7 +1927,7 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(flags & VIR_MIGRATE_UNSAFE) &&
|
if (!(flags & VIR_MIGRATE_UNSAFE) &&
|
||||||
!qemuMigrationIsSafe(vm->def, nmigrate_disks, migrate_disks))
|
!qemuMigrationIsSafe(vm->def, nmigrate_disks, migrate_disks, flags))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (flags & VIR_MIGRATE_POSTCOPY &&
|
if (flags & VIR_MIGRATE_POSTCOPY &&
|
||||||
@ -4774,7 +4785,7 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (!(flags & VIR_MIGRATE_UNSAFE) &&
|
if (!(flags & VIR_MIGRATE_UNSAFE) &&
|
||||||
!qemuMigrationIsSafe(vm->def, nmigrate_disks, migrate_disks))
|
!qemuMigrationIsSafe(vm->def, nmigrate_disks, migrate_disks, flags))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
qemuMigrationStoreDomainState(vm);
|
qemuMigrationStoreDomainState(vm);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user