commit 12062ab set rerror=ignore when error_policy="enospace" was
selected (since the rerror option in qemu doesn't accept "enospc", as
the werror option does).
After that patch was already pushed, Paolo Bonzini noticed it and
commented that leaving rerror at the default ("report") would be a
better choice. This patch corrects the problem - if error_policy =
"enospace" is given, rerror is left off the qemu commandline,
effectively setting it to "report". For other values, rerror is still
set to match werror.
Additionally, the parsing of error_policy was changed to no longer
erroneously allow "default" as a choice - as with most other
attributes, if you want the default setting, just don't specify an
error_policy.
Finally, two ommissions in the first patch were corrected - a
long-dormant qemuxml2argv test for enospace was enabled, and fixed to
pass, and the argv2xml parser in qemu_command.c was updated to
recognize the different spelling on the qemu commandline.
---
src/conf/domain_conf.c | 2 +-
src/qemu/qemu_command.c | 15 ++++++++-------
...uxml2argv-disk-drive-error-policy-enospace.args | 2 +-
tests/qemuxml2argvtest.c | 2 ++
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f9007ce..55e6c34 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2554,7 +2554,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
}
if (error_policy &&
- (def->error_policy = virDomainDiskErrorPolicyTypeFromString(error_policy))
< 0) {
+ (def->error_policy = virDomainDiskErrorPolicyTypeFromString(error_policy))
<= 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown disk error policy '%s'"),
error_policy);
goto error;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 123bcab..5f729a4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1696,15 +1696,16 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
if (disk->error_policy)
wpolicy = virDomainDiskErrorPolicyTypeToString(disk->error_policy);
- if (!rpolicy)
- rpolicy = wpolicy;
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.
+ /* in the case of enospace, the option is spelled
+ * differently in qemu, and it's only valid for werror,
+ * not for rerror, so leave leave rerror NULL.
*/
- wpolicy="enospc";
- rpolicy="ignore";
+ wpolicy = "enospc";
+ } else if (!rpolicy) {
+ /* for other policies, rpolicy can match wpolicy */
+ rpolicy = wpolicy;
}
if (wpolicy)
@@ -5636,7 +5637,7 @@ qemuParseCommandLineDisk(virCapsPtr caps,
def->error_policy = VIR_DOMAIN_DISK_ERROR_POLICY_STOP;
else if (STREQ(values[i], "ignore"))
def->error_policy = VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE;
- else if (STREQ(values[i], "enospace"))
+ else if (STREQ(values[i], "enospc"))
def->error_policy = VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE;
} else if (STREQ(keywords[i], "index")) {
if (virStrToLong_i(values[i], NULL, 10, &idx) < 0) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args
index 267eb5f..981d410 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args
@@ -1,6 +1,6 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
-no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,\
-format=qcow2,cache=off,werror=enospace,rerror=enospace -drive \
+format=qcow2,cache=off,werror=enospc -drive \
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,bus=1,unit=0,format=raw -net \
none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 9e174b3..24e831c 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -332,6 +332,8 @@ mymain(void)
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
DO_TEST("disk-drive-error-policy-stop", false,
QEMU_CAPS_DRIVE, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_DRIVE_FORMAT);
+ DO_TEST("disk-drive-error-policy-enospace", false,
+ QEMU_CAPS_DRIVE, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_DRIVE_FORMAT);
DO_TEST("disk-drive-cache-v2-wt", false,
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT);
DO_TEST("disk-drive-cache-v2-wb", false,
--
1.7.3.4