]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: leave rerror policy at default when enospace is requested
authorLaine Stump <laine@laine.org>
Wed, 5 Oct 2011 15:19:28 +0000 (11:19 -0400)
committerLaine Stump <laine@laine.org>
Thu, 6 Oct 2011 18:49:13 +0000 (14:49 -0400)
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
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args
tests/qemuxml2argvtest.c

index f9007ce5a9b678aaffcf2cd36d61eb8200a2ac66..55e6c3433db91112f88445cb3ec2b306cc6868c2 100644 (file)
@@ -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;
index 123bcabd700131d981035abe6111ce56204f85d9..5f729a4fa1757e56b42b11dfa263ff43fcaba76a 100644 (file)
@@ -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) {
index 267eb5fa1092907beeab03ec1fac4e8157bda252..981d410431f58e81bb891364b8518c66b57a5a6b 100644 (file)
@@ -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
index 9e174b378f39c09d421c6b9ae56a3ea0e3082209..24e831cf0a5c23d1a6f2bdc15ddeb62bb6ae6ce2 100644 (file)
@@ -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,