]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: catch failure of drive_add
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 17 Jan 2017 16:14:11 +0000 (16:14 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 19 Jan 2017 10:56:53 +0000 (10:56 +0000)
Previously when QEMU failed "drive_add" due to an error opening
a file it would report

  "could not open disk image"

These days though, QEMU reports

  "Could not open '/tmp/virtd-test_e3hnhh5/disk1.qcow2': Permission denied"

which we were not detecting as an error condition.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/qemu/qemu_monitor_text.c

index bc832187e7d1c1dfabcbf7f3f4ab3ae2f1bc026a..9c9eeea01dff3442cdadc89373661cb2e1be5799 100644 (file)
@@ -1959,6 +1959,16 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
         goto cleanup;
     }
 
+    if (strstr(reply, "Could not open")) {
+        size_t len = strlen(reply);
+        if (reply[len - 1] == '\n')
+            reply[len - 1] = '\0';
+
+        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                       reply);
+        goto cleanup;
+    }
+
     ret = 0;
 
  cleanup: