diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f9007ce5a9..55e6c3433d 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 123bcabd70..5f729a4fa1 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 267eb5fa10..981d410431 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 9e174b378f..24e831cf0a 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,