提交 5fb7ab2c 编写于 作者: P Peter Krempa

qemu: command: Refactor qemuBuildDriveStrValidate to make qemuCaps optional

To allow merging this with other disk type checks we need to check
qemuCaps only when available, since some of the checks are executed on
disk cold-plug and thus capabilities should not be checked.

Make the checks optional by making them conditional on qemuCaps not
being NULL.
上级 f15ed227
......@@ -1553,6 +1553,17 @@ qemuBuildDriveStrValidate(virDomainDiskDefPtr disk,
return -1;
}
if (disk->iomode == VIR_DOMAIN_DISK_IO_NATIVE &&
disk->cachemode != VIR_DOMAIN_DISK_CACHE_DIRECTSYNC &&
disk->cachemode != VIR_DOMAIN_DISK_CACHE_DISABLE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("native I/O needs either no disk cache "
"or directsync cache mode, QEMU will fallback "
"to aio=threads"));
return -1;
}
if (qemuCaps) {
if (disk->serial &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) {
if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI &&
......@@ -1578,16 +1589,6 @@ qemuBuildDriveStrValidate(virDomainDiskDefPtr disk,
return -1;
}
if (disk->iomode == VIR_DOMAIN_DISK_IO_NATIVE &&
disk->cachemode != VIR_DOMAIN_DISK_CACHE_DIRECTSYNC &&
disk->cachemode != VIR_DOMAIN_DISK_CACHE_DISABLE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("native I/O needs either no disk cache "
"or directsync cache mode, QEMU will fallback "
"to aio=threads"));
return -1;
}
if (disk->copy_on_read &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_COPY_ON_READ)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
......@@ -1615,6 +1616,7 @@ qemuBuildDriveStrValidate(virDomainDiskDefPtr disk,
_("disk aio mode not supported with this QEMU binary"));
return -1;
}
}
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册