qemu: blockjob: Always save status XML after block event

The status XML would be saved only for the copy job (in case of success)
or on failure even for other jobs. As the status contains the backing
chain data, which change after success we should always save it on
block job completion.
This commit is contained in:
Peter Krempa 2017-08-28 15:21:06 +02:00
parent c7e3fc1112
commit f7954d6b07

View File

@ -97,7 +97,6 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
const char *path; const char *path;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
virDomainDiskDefPtr persistDisk = NULL; virDomainDiskDefPtr persistDisk = NULL;
bool save = false;
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
VIR_DEBUG("disk=%s, mirrorState=%s, type=%d, status=%d", VIR_DEBUG("disk=%s, mirrorState=%s, type=%d, status=%d",
@ -164,7 +163,6 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
* rather than reprobing, but we haven't quite completed * rather than reprobing, but we haven't quite completed
* that conversion to use our XML tracking. */ * that conversion to use our XML tracking. */
disk->mirror = NULL; disk->mirror = NULL;
save = disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE; disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN; disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk, ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk,
@ -175,7 +173,6 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
case VIR_DOMAIN_BLOCK_JOB_READY: case VIR_DOMAIN_BLOCK_JOB_READY:
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_READY; disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_READY;
save = true;
break; break;
case VIR_DOMAIN_BLOCK_JOB_FAILED: case VIR_DOMAIN_BLOCK_JOB_FAILED:
@ -187,7 +184,6 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
} }
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE; disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN; disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
save = true;
diskPriv->blockjob = false; diskPriv->blockjob = false;
break; break;
@ -195,16 +191,14 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
break; break;
} }
if (save) {
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
VIR_WARN("Unable to save status on vm %s after block job", VIR_WARN("Unable to save status on vm %s after block job", vm->def->name);
vm->def->name);
if (persistDisk && virDomainSaveConfig(cfg->configDir, if (persistDisk && virDomainSaveConfig(cfg->configDir,
driver->caps, driver->caps,
vm->newDef) < 0) vm->newDef) < 0)
VIR_WARN("Unable to update persistent definition on vm %s " VIR_WARN("Unable to update persistent definition on vm %s "
"after block job", vm->def->name); "after block job", vm->def->name);
}
qemuDomainEventQueue(driver, event); qemuDomainEventQueue(driver, event);
qemuDomainEventQueue(driver, event2); qemuDomainEventQueue(driver, event2);