diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0e504fe290e52aef86ca9b2256f950920581c2ea..44ae8dcef7b7d8775775317b49b7decf692ba206 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1667,7 +1667,8 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, /* werror/rerror are really frontend attributes, but older * qemu requires them on -drive instead of -device */ - qemuBuildDiskFrontendAttributeErrorPolicy(disk, &opt); + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_STORAGE_WERROR)) + qemuBuildDiskFrontendAttributeErrorPolicy(disk, &opt); /* While this is a frontend attribute, it only makes sense to be used when @@ -2129,6 +2130,9 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, qemuBuildDiskFrontendAttributes(disk, &opt); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_STORAGE_WERROR)) + qemuBuildDiskFrontendAttributeErrorPolicy(disk, &opt); + if (virBufferCheckError(&opt) < 0) goto error; diff --git a/tests/qemuxml2argvdata/disk-drive-error-policy.x86_64-latest.args b/tests/qemuxml2argvdata/disk-drive-error-policy.x86_64-latest.args index 388f78df0f8a55fa2ba4d9416f1085d89301468f..e8fa9e24522ee59335ae4e781a222362eb963415 100644 --- a/tests/qemuxml2argvdata/disk-drive-error-policy.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-drive-error-policy.x86_64-latest.args @@ -25,17 +25,17 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ -werror=stop,rerror=stop,cache=none \ +cache=none \ -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1,\ -write-cache=on \ +write-cache=on,werror=stop,rerror=stop \ -drive file=/dev/HostVG/QEMUGuest2,format=qcow2,if=none,id=drive-ide0-0-1,\ -werror=enospc,cache=none \ +cache=none \ -device ide-hd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,\ -write-cache=on \ +write-cache=on,werror=enospc \ -drive file=/dev/HostVG/QEMUGuest3,format=qcow2,if=none,id=drive-ide0-1-0,\ -werror=report,rerror=ignore,cache=none \ +cache=none \ -device ide-hd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\ -write-cache=on \ +write-cache=on,werror=report,rerror=ignore \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on