[libvirt] [PATCH 05/35] qemu: block: Extract formatting of props for 'file' backend

Peter Krempa posted 35 patches 7 years ago
[libvirt] [PATCH 05/35] qemu: block: Extract formatting of props for 'file' backend
Posted by Peter Krempa 7 years ago
'file' backend in qemu supports few more options than the current
implementation. Extract it so that changes don't pollute the code.

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

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index c0cf6a95ad..e7bd6c909d 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -974,6 +974,18 @@ qemuBlockStorageSourceGetSshProps(virStorageSourcePtr src)
 }


+static virJSONValuePtr
+qemuBlockStorageSourceGetFileProps(virStorageSourcePtr src)
+{
+    virJSONValuePtr ret = NULL;
+
+    ignore_value(virJSONValueObjectCreate(&ret,
+                                          "s:driver", "file",
+                                          "s:filename", src->path, NULL) < 0);
+    return ret;
+}
+
+
 /**
  * qemuBlockStorageSourceGetBackendProps:
  * @src: disk source
@@ -991,9 +1003,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
     case VIR_STORAGE_TYPE_BLOCK:
     case VIR_STORAGE_TYPE_FILE:
     case VIR_STORAGE_TYPE_DIR:
-        if (virJSONValueObjectCreate(&fileprops,
-                                     "s:driver", "file",
-                                     "s:filename", src->path, NULL) < 0)
+        if (!(fileprops = qemuBlockStorageSourceGetFileProps(src)))
             return NULL;
         break;

-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 05/35] qemu: block: Extract formatting of props for 'file' backend
Posted by John Ferlan 7 years ago

On 04/25/2018 11:15 AM, Peter Krempa wrote:
> 'file' backend in qemu supports few more options than the current
> implementation. Extract it so that changes don't pollute the code.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/qemu/qemu_block.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list