提交 dbca8414 编写于 作者: G Guannan Ren

qemu: check presence of each disk and its backing file as well

For disk with startupPolicy support, such as cdrom and floppy
when its chain is broken, the startup policy will apply,
otherwise, report an error.
上级 d7b7aa2c
...@@ -2043,19 +2043,11 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver, ...@@ -2043,19 +2043,11 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
break; break;
case VIR_DOMAIN_STARTUP_POLICY_MANDATORY: case VIR_DOMAIN_STARTUP_POLICY_MANDATORY:
virReportSystemError(errno,
_("cannot access file '%s'"),
disk->src);
goto error; goto error;
break;
case VIR_DOMAIN_STARTUP_POLICY_REQUISITE: case VIR_DOMAIN_STARTUP_POLICY_REQUISITE:
if (cold_boot) { if (cold_boot)
virReportSystemError(errno,
_("cannot access file '%s'"),
disk->src);
goto error; goto error;
}
break; break;
case VIR_DOMAIN_STARTUP_POLICY_DEFAULT: case VIR_DOMAIN_STARTUP_POLICY_DEFAULT:
...@@ -2064,6 +2056,7 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver, ...@@ -2064,6 +2056,7 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
break; break;
} }
virResetLastError();
VIR_DEBUG("Dropping disk '%s' on domain '%s' (UUID '%s') " VIR_DEBUG("Dropping disk '%s' on domain '%s' (UUID '%s') "
"due to inaccessible source '%s'", "due to inaccessible source '%s'",
disk->dst, vm->def->name, uuid, disk->src); disk->dst, vm->def->name, uuid, disk->src);
...@@ -2089,30 +2082,30 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver, ...@@ -2089,30 +2082,30 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
int ret = -1; int ret = -1;
size_t i; size_t i;
virDomainDiskDefPtr disk; virDomainDiskDefPtr disk;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
VIR_DEBUG("Checking for disk presence");
for (i = 0; i < vm->def->ndisks; i++) { for (i = 0; i < vm->def->ndisks; i++) {
disk = vm->def->disks[i]; disk = vm->def->disks[i];
if (!disk->startupPolicy || !disk->src) if (!disk->src)
continue; continue;
if (virFileAccessibleAs(disk->src, F_OK, if (qemuDomainDetermineDiskChain(driver, disk, false) >= 0 &&
cfg->user, qemuDiskChainCheckBroken(disk) >= 0)
cfg->group) >= 0) {
/* disk accessible */
continue; continue;
if (disk->startupPolicy) {
if (qemuDomainCheckDiskStartupPolicy(driver, vm, disk,
cold_boot) >= 0)
continue;
} }
if (qemuDomainCheckDiskStartupPolicy(driver, vm, disk, goto error;
cold_boot) < 0)
goto cleanup;
} }
ret = 0; ret = 0;
cleanup: error:
virObjectUnref(cfg);
return ret; return ret;
} }
......
...@@ -3621,16 +3621,10 @@ int qemuProcessStart(virConnectPtr conn, ...@@ -3621,16 +3621,10 @@ int qemuProcessStart(virConnectPtr conn,
if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0) if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
goto cleanup; goto cleanup;
VIR_DEBUG("Checking for CDROM and floppy presence");
if (qemuDomainCheckDiskPresence(driver, vm, if (qemuDomainCheckDiskPresence(driver, vm,
flags & VIR_QEMU_PROCESS_START_COLD) < 0) flags & VIR_QEMU_PROCESS_START_COLD) < 0)
goto cleanup; goto cleanup;
for (i = 0; i < vm->def->ndisks; i++) {
if (qemuDomainDetermineDiskChain(driver, vm->def->disks[i],
false) < 0)
goto cleanup;
}
/* Get the advisory nodeset from numad if 'placement' of /* Get the advisory nodeset from numad if 'placement' of
* either <vcpu> or <numatune> is 'auto'. * either <vcpu> or <numatune> is 'auto'.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册