[libvirt] [PATCH] storage: report VIR_ERR_NO_STORAGE_VOL when the file doesn't exist

Report VIR_ERR_NO_STORAGE_VOL instead of a system error when lstat fails because the file doesn't exist. Fixes this problem in virt-install: https://bugzilla.redhat.com/show_bug.cgi?id=1108922 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/storage/storage_backend.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 380ca58..b38af52 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -1305,9 +1305,15 @@ virStorageBackendVolOpen(const char *path, struct stat *sb, bool noerror = (flags & VIR_STORAGE_VOL_OPEN_NOERROR); if (lstat(path, sb) < 0) { - if (errno == ENOENT && noerror) { - VIR_WARN("ignoring missing file '%s'", path); - return -2; + if (errno == ENOENT) { + if (noerror) { + VIR_WARN("ignoring missing file '%s'", path); + return -2; + } + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching path '%s'"), + path); + return -1; } virReportSystemError(errno, _("cannot stat file '%s'"), -- 1.9.3

On 06/13/2014 08:48 AM, Giuseppe Scrivano wrote:
Report VIR_ERR_NO_STORAGE_VOL instead of a system error when lstat fails because the file doesn't exist.
Fixes this problem in virt-install:
https://bugzilla.redhat.com/show_bug.cgi?id=1108922
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/storage/storage_backend.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
ACK -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 06/13/2014 08:52 AM, Eric Blake wrote:
On 06/13/2014 08:48 AM, Giuseppe Scrivano wrote:
Report VIR_ERR_NO_STORAGE_VOL instead of a system error when lstat fails because the file doesn't exist.
Fixes this problem in virt-install:
https://bugzilla.redhat.com/show_bug.cgi?id=1108922
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/storage/storage_backend.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
ACK
and pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Giuseppe Scrivano