mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-04 21:47:16 +03:00
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.
This commit is contained in:
parent
3443fddfea
commit
1bf4dfc02a
@ -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
|
static void
|
||||||
qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
|
qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
|
||||||
virQEMUCapsPtr qemuCaps,
|
virQEMUCapsPtr qemuCaps,
|
||||||
@ -1687,6 +1722,8 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
|
|||||||
virBufferAddLit(buf, ",serial=");
|
virBufferAddLit(buf, ",serial=");
|
||||||
virBufferEscape(buf, '\\', " ", "%s", disk->serial);
|
virBufferEscape(buf, '\\', " ", "%s", disk->serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qemuBuildDiskFrontendAttributeErrorPolicy(disk, qemuCaps, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1786,31 +1823,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
|
|||||||
virDomainDiskDetectZeroesTypeToString(detect_zeroes));
|
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) {
|
if (disk->iomode) {
|
||||||
virBufferAsprintf(&opt, ",aio=%s",
|
virBufferAsprintf(&opt, ",aio=%s",
|
||||||
virDomainDiskIoTypeToString(disk->iomode));
|
virDomainDiskIoTypeToString(disk->iomode));
|
||||||
|
@ -20,7 +20,7 @@ server,nowait \
|
|||||||
-boot c \
|
-boot c \
|
||||||
-usb \
|
-usb \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
|
-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 \
|
-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,\
|
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\
|
||||||
media=cdrom,readonly=on \
|
media=cdrom,readonly=on \
|
||||||
|
@ -20,7 +20,7 @@ server,nowait \
|
|||||||
-boot c \
|
-boot c \
|
||||||
-usb \
|
-usb \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
|
-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 \
|
-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,\
|
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\
|
||||||
media=cdrom,readonly=on \
|
media=cdrom,readonly=on \
|
||||||
|
@ -20,7 +20,7 @@ server,nowait \
|
|||||||
-boot c \
|
-boot c \
|
||||||
-usb \
|
-usb \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
|
-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 \
|
-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,\
|
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\
|
||||||
media=cdrom,readonly=on \
|
media=cdrom,readonly=on \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user