提交 639a0098 编写于 作者: P Peter Krempa

qemu: Report better errors from broken backing chains

Request erroring out from the backing chain traveller and drop qemu's
internal backing chain integrity tester.

The backing chain traveller reports errors by itself with possibly more
detail than qemuDiskChainCheckBroken ever could.

We also need to make sure that we reconnect to existing qemu instances
even at the cost of losing the backing chain info (this really should be
stored in the XML rather than reloaded from disk, but that needs some
work).
上级 172ca0e7
......@@ -2513,27 +2513,6 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
return -1;
}
static int
qemuDiskChainCheckBroken(virDomainDiskDefPtr disk)
{
char *brokenFile = NULL;
if (!virDomainDiskGetSource(disk))
return 0;
if (virStorageFileChainGetBroken(disk->src, &brokenFile) < 0)
return -1;
if (brokenFile) {
virReportError(VIR_ERR_INVALID_ARG,
_("Backing file '%s' of image '%s' is missing."),
brokenFile, virDomainDiskGetSource(disk));
VIR_FREE(brokenFile);
return -1;
}
return 0;
}
int
qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
......@@ -2561,8 +2540,7 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
virFileExists(virDomainDiskGetSource(disk)))
continue;
if (qemuDomainDetermineDiskChain(driver, vm, disk, false) >= 0 &&
qemuDiskChainCheckBroken(disk) >= 0)
if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) >= 0)
continue;
if (disk->startupPolicy &&
......@@ -2707,7 +2685,8 @@ int
qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
bool force_probe)
bool force_probe,
bool report_broken)
{
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
int ret = 0;
......@@ -2729,7 +2708,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
if (virStorageFileGetMetadata(disk->src,
uid, gid,
cfg->allowDiskFormatProbing,
false) < 0)
report_broken) < 0)
ret = -1;
cleanup:
......
......@@ -370,7 +370,8 @@ int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
bool force_probe);
bool force_probe,
bool report_broken);
int qemuDomainStorageFileInit(virQEMUDriverPtr driver,
virDomainObjPtr vm,
......
......@@ -6833,7 +6833,7 @@ qemuDomainChangeDiskMediaLive(virConnectPtr conn,
if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
goto end;
if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0)
if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
goto end;
switch (disk->device) {
......@@ -13254,7 +13254,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
for (i = 0; i < snap->def->ndisks; i++) {
if (snap->def->disks[i].snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
continue;
qemuDomainDetermineDiskChain(driver, vm, vm->def->disks[i], true);
ignore_value(qemuDomainDetermineDiskChain(driver, vm, vm->def->disks[i],
true, true));
}
if (orig_err) {
virSetError(orig_err);
......@@ -15062,7 +15063,7 @@ qemuDomainBlockPivot(virConnectPtr conn,
oldsrc = disk->src;
disk->src = disk->mirror;
if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0)
if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
goto cleanup;
if (disk->mirror->format &&
......@@ -15575,7 +15576,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
goto endjob;
}
if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0)
if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
goto endjob;
if ((flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW) &&
......@@ -15944,7 +15945,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
disk->dst);
goto endjob;
}
if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0)
if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
goto endjob;
if (!top)
......
......@@ -779,7 +779,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
if (qemuSetUnprivSGIO(dev) < 0)
goto end;
if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0)
if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
goto end;
switch (disk->device) {
......
......@@ -1090,7 +1090,8 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
save = disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
qemuDomainDetermineDiskChain(driver, vm, disk, true);
ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk,
true, true));
} else if (disk->mirror &&
(type == VIR_DOMAIN_BLOCK_JOB_TYPE_COPY ||
type == VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT)) {
......@@ -3430,9 +3431,12 @@ qemuProcessReconnect(void *opaque)
if (virStorageTranslateDiskSourcePool(conn, obj->def->disks[i]) < 0)
goto error;
/* XXX we should be able to restore all data from XML in the future */
if (qemuDomainDetermineDiskChain(driver, obj,
obj->def->disks[i], true) < 0)
/* XXX we should be able to restore all data from XML in the future.
* This should be the only place that calls qemuDomainDetermineDiskChain
* with @report_broken == false to guarantee best-effort domain
* reconnect */
if (qemuDomainDetermineDiskChain(driver, obj, obj->def->disks[i],
true, false) < 0)
goto error;
dev.type = VIR_DOMAIN_DEVICE_DISK;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册