From: Daniel P. Berrange Date: Tue, 17 Jan 2017 16:14:11 +0000 (+0000) Subject: qemu: catch failure of drive_add X-Git-Tag: CVE-2017-2635~264 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9cc6316c078cccc82addf607de09520a52d88e1;p=thirdparty%2Flibvirt.git qemu: catch failure of drive_add 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 --- diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index bc832187e7..9c9eeea01d 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -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: