Blob Blame History Raw
From e551ad605fd99e92a85acdab53bc52efaa6facb2 Mon Sep 17 00:00:00 2001
Message-Id: <e551ad605fd99e92a85acdab53bc52efaa6facb2@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 19 Feb 2020 15:10:08 +0100
Subject: [PATCH] virStorageSourceJSONDriverParser: annotate 'format' drivers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The parser was originally designed only for protocol parsers. Since
we already have 'raw' format driver in the list we'll need to be able
to parse it too. In later patches this will be used to prevent parsing
nested format drivers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 7e13ff8dc016dda5ffd50ff5c059f01c76486c82)

https://bugzilla.redhat.com/show_bug.cgi?id=1791788
Message-Id: <ef05c98383c79aa7487ea97c7e1cbfb384c80440.1582120424.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/util/virstoragefile.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index c97a3a9d6e..b6749b150c 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -3563,6 +3563,7 @@ virStorageSourceParseBackingJSONVxHS(virStorageSourcePtr src,
 
 struct virStorageSourceJSONDriverParser {
     const char *drvname;
+    bool formatdriver;
     /**
      * The callback gets a pre-allocated storage source @src and the JSON
      * object to parse. The callback shall return -1 on error and report error
@@ -3575,22 +3576,22 @@ struct virStorageSourceJSONDriverParser {
 };
 
 static const struct virStorageSourceJSONDriverParser jsonParsers[] = {
-    {"file", virStorageSourceParseBackingJSONPath, VIR_STORAGE_TYPE_FILE},
-    {"host_device", virStorageSourceParseBackingJSONPath, VIR_STORAGE_TYPE_BLOCK},
-    {"host_cdrom", virStorageSourceParseBackingJSONPath, VIR_STORAGE_TYPE_BLOCK},
-    {"http", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_HTTP},
-    {"https", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_HTTPS},
-    {"ftp", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_FTP},
-    {"ftps", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_FTPS},
-    {"tftp", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_TFTP},
-    {"gluster", virStorageSourceParseBackingJSONGluster, 0},
-    {"iscsi", virStorageSourceParseBackingJSONiSCSI, 0},
-    {"nbd", virStorageSourceParseBackingJSONNbd, 0},
-    {"sheepdog", virStorageSourceParseBackingJSONSheepdog, 0},
-    {"ssh", virStorageSourceParseBackingJSONSSH, 0},
-    {"rbd", virStorageSourceParseBackingJSONRBD, 0},
-    {"raw", virStorageSourceParseBackingJSONRaw, 0},
-    {"vxhs", virStorageSourceParseBackingJSONVxHS, 0},
+    {"file", false, virStorageSourceParseBackingJSONPath, VIR_STORAGE_TYPE_FILE},
+    {"host_device", false, virStorageSourceParseBackingJSONPath, VIR_STORAGE_TYPE_BLOCK},
+    {"host_cdrom", false, virStorageSourceParseBackingJSONPath, VIR_STORAGE_TYPE_BLOCK},
+    {"http", false, virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_HTTP},
+    {"https", false, virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_HTTPS},
+    {"ftp", false, virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_FTP},
+    {"ftps", false, virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_FTPS},
+    {"tftp", false, virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_TFTP},
+    {"gluster", false, virStorageSourceParseBackingJSONGluster, 0},
+    {"iscsi", false, virStorageSourceParseBackingJSONiSCSI, 0},
+    {"nbd", false, virStorageSourceParseBackingJSONNbd, 0},
+    {"sheepdog", false, virStorageSourceParseBackingJSONSheepdog, 0},
+    {"ssh", false, virStorageSourceParseBackingJSONSSH, 0},
+    {"rbd", false, virStorageSourceParseBackingJSONRBD, 0},
+    {"raw", true, virStorageSourceParseBackingJSONRaw, 0},
+    {"vxhs", false, virStorageSourceParseBackingJSONVxHS, 0},
 };
 
 
-- 
2.25.0