[PATCH] qemuBlockStorageSourceGetBackendProps: Report errors on all switch cases

Peter Krempa posted 1 patch 2 weeks ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/302e9b7f7dccff42b133168b9371a73f2c23fc0b.1580981070.git.pkrempa@redhat.com
src/qemu/qemu_block.c | 7 +++++++
1 file changed, 7 insertions(+)

[PATCH] qemuBlockStorageSourceGetBackendProps: Report errors on all switch cases

Posted by Peter Krempa 2 weeks ago
Few switch cases returned failure but didn't report an error. For a
situation when the backingStore type='volume' was not translated the
following error would occur:

 $ virsh start VM
 error: Failed to start domain VM
 error: An error occurred, but the cause is unknown

After this patch:

 $ virsh start VM
 error: Failed to start domain VM
 error: internal error: storage source pool 'tmp' volume 'pull3.qcow2' is not translated

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_block.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 63116ef5f2..0ee10dd770 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -1081,8 +1081,14 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
         break;

     case VIR_STORAGE_TYPE_VOLUME:
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("storage source pool '%s' volume '%s' is not translated"),
+                       src->srcpool->pool, src->srcpool->volume);
+        return NULL;
+
     case VIR_STORAGE_TYPE_NONE:
     case VIR_STORAGE_TYPE_LAST:
+        virReportEnumRangeError(virStorageType, actualType);
         return NULL;

     case VIR_STORAGE_TYPE_NETWORK:
@@ -1141,6 +1147,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,

         case VIR_STORAGE_NET_PROTOCOL_NONE:
         case VIR_STORAGE_NET_PROTOCOL_LAST:
+            virReportEnumRangeError(virStorageNetProtocol, src->protocol);
             return NULL;
         }
         break;
-- 
2.24.1

Re: [PATCH] qemuBlockStorageSourceGetBackendProps: Report errors on all switch cases

Posted by Ján Tomko 2 weeks ago
On Thu, Feb 06, 2020 at 10:24:31AM +0100, Peter Krempa wrote:
>Few switch cases returned failure but didn't report an error. For a
>situation when the backingStore type='volume' was not translated the
>following error would occur:
>
> $ virsh start VM
> error: Failed to start domain VM
> error: An error occurred, but the cause is unknown
>
>After this patch:
>
> $ virsh start VM
> error: Failed to start domain VM
> error: internal error: storage source pool 'tmp' volume 'pull3.qcow2' is not translated
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_block.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano

Re: [PATCH] qemuBlockStorageSourceGetBackendProps: Report errors on all switch cases

Posted by Erik Skultety 2 weeks ago
On Thu, Feb 06, 2020 at 10:24:31AM +0100, Peter Krempa wrote:
> Few switch cases returned failure but didn't report an error. For a
> situation when the backingStore type='volume' was not translated the
> following error would occur:
>
>  $ virsh start VM
>  error: Failed to start domain VM
>  error: An error occurred, but the cause is unknown
>
> After this patch:
>
>  $ virsh start VM
>  error: Failed to start domain VM
>  error: internal error: storage source pool 'tmp' volume 'pull3.qcow2' is not translated
>
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>