提交 1bf4dfc0 编写于 作者: P Peter Krempa

qemu: command: Move formatting of disk io error policy from -drive

That's a disk frontend attribute. Move the code to a separate function
since it's non-trivial and call it from the frontend attribute
formatter.
上级 3443fddf
......@@ -1663,6 +1663,41 @@ qemuBuildDiskThrottling(virDomainDiskDefPtr disk,
}
static void
qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDefPtr disk,
virQEMUCapsPtr qemuCaps,
virBufferPtr buf)
{
const char *wpolicy = NULL;
const char *rpolicy = NULL;
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MONITOR_JSON))
return;
if (disk->error_policy)
wpolicy = virDomainDiskErrorPolicyTypeToString(disk->error_policy);
if (disk->rerror_policy)
rpolicy = virDomainDiskErrorPolicyTypeToString(disk->rerror_policy);
if (disk->error_policy == VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE) {
/* in the case of enospace, the option is spelled
* differently in qemu, and it's only valid for werror,
* not for rerror, so leave rerror NULL.
*/
wpolicy = "enospc";
} else if (!rpolicy) {
/* for other policies, rpolicy can match wpolicy */
rpolicy = wpolicy;
}
if (wpolicy)
virBufferAsprintf(buf, ",werror=%s", wpolicy);
if (rpolicy)
virBufferAsprintf(buf, ",rerror=%s", rpolicy);
}
static void
qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
virQEMUCapsPtr qemuCaps,
......@@ -1687,6 +1722,8 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
virBufferAddLit(buf, ",serial=");
virBufferEscape(buf, '\\', " ", "%s", disk->serial);
}
qemuBuildDiskFrontendAttributeErrorPolicy(disk, qemuCaps, buf);
}
......@@ -1786,31 +1823,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
virDomainDiskDetectZeroesTypeToString(detect_zeroes));
}
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MONITOR_JSON)) {
const char *wpolicy = NULL, *rpolicy = NULL;
if (disk->error_policy)
wpolicy = virDomainDiskErrorPolicyTypeToString(disk->error_policy);
if (disk->rerror_policy)
rpolicy = virDomainDiskErrorPolicyTypeToString(disk->rerror_policy);
if (disk->error_policy == VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE) {
/* in the case of enospace, the option is spelled
* differently in qemu, and it's only valid for werror,
* not for rerror, so leave rerror NULL.
*/
wpolicy = "enospc";
} else if (!rpolicy) {
/* for other policies, rpolicy can match wpolicy */
rpolicy = wpolicy;
}
if (wpolicy)
virBufferAsprintf(&opt, ",werror=%s", wpolicy);
if (rpolicy)
virBufferAsprintf(&opt, ",rerror=%s", rpolicy);
}
if (disk->iomode) {
virBufferAsprintf(&opt, ",aio=%s",
virDomainDiskIoTypeToString(disk->iomode));
......
......@@ -20,7 +20,7 @@ server,nowait \
-boot c \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
cache=none,werror=enospc \
werror=enospc,cache=none \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\
media=cdrom,readonly=on \
......
......@@ -20,7 +20,7 @@ server,nowait \
-boot c \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
cache=none,werror=stop,rerror=stop \
werror=stop,rerror=stop,cache=none \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\
media=cdrom,readonly=on \
......
......@@ -20,7 +20,7 @@ server,nowait \
-boot c \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
cache=none,werror=report,rerror=ignore \
werror=report,rerror=ignore,cache=none \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\
media=cdrom,readonly=on \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册