[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 1/2] qemu: correct misspelled 'enospc' option, and only use for werror



This resolves:

     https://bugzilla.redhat.com/show_bug.cgi?id=730909

When support for setting the qemu disk error policy to 'enospc' was
added, it was inadvertantly as "enospace". This patch corrects that on
the qemu commandline (while retaining the "enospace" spelling for
libvirt's XML.

Also, while examining the qemu source, I found that "enospc" is not
allowed for the read error policy, only for write error policy (makes
sense). Since libvirt currently only has a single error policy
setting, when "enospace" is selected, the read error policy is set to
"ignore".
---
 src/qemu/qemu_command.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ff83e2d..123bcab 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1692,11 +1692,25 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
     }
 
     if (qemuCapsGet(qemuCaps, QEMU_CAPS_MONITOR_JSON)) {
-        if (disk->error_policy) {
-            virBufferAsprintf(&opt, ",werror=%s,rerror=%s",
-                              virDomainDiskErrorPolicyTypeToString(disk->error_policy),
-                              virDomainDiskErrorPolicyTypeToString(disk->error_policy));
+        const char *wpolicy = NULL, *rpolicy = NULL;
+
+        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.
+             */
+            wpolicy="enospc";
+            rpolicy="ignore";
         }
+
+        if (wpolicy)
+            virBufferAsprintf(&opt, ",werror=%s", wpolicy);
+        if (rpolicy)
+            virBufferAsprintf(&opt, ",rerror=%s", rpolicy);
     }
 
     if (disk->iomode) {
-- 
1.7.3.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]