]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: storage: add JSON backing volume parser 'raw' block driver
authorTomáš Golembiovský <tgolembi@redhat.com>
Mon, 13 Feb 2017 22:53:43 +0000 (23:53 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 22 Feb 2017 09:39:57 +0000 (10:39 +0100)
The 'raw' block driver in Qemu is not directly interesting from
libvirt's perspective, but it can be layered above some other block
drivers and this may be interesting for the user.

The patch adds support for the 'raw' block driver. The driver is treated
simply as a pass-through and child driver in JSON is queried to get the
necessary information.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
src/util/virstoragefile.c
tests/virstoragetest.c

index 715c0429d7f84ea8539b15adc829c8939968f968..c9420fdb79216d7f5cbafb0e890c347daa85319b 100644 (file)
@@ -2647,6 +2647,11 @@ virStorageSourceParseBackingColon(virStorageSourcePtr src,
 }
 
 
+static int
+virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
+                                         virJSONValuePtr json);
+
+
 static int
 virStorageSourceParseBackingJSONPath(virStorageSourcePtr src,
                                      virJSONValuePtr json,
@@ -2963,6 +2968,16 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
     return -1;
 }
 
+static int
+virStorageSourceParseBackingJSONRaw(virStorageSourcePtr src,
+                                    virJSONValuePtr json,
+                                    int opaque ATTRIBUTE_UNUSED)
+{
+    /* There are no interesting attributes in raw driver.
+     * Treat it as pass-through.
+     */
+    return virStorageSourceParseBackingJSONInternal(src, json);
+}
 
 struct virStorageSourceJSONDriverParser {
     const char *drvname;
@@ -2985,6 +3000,7 @@ static const struct virStorageSourceJSONDriverParser jsonParsers[] = {
     {"sheepdog", virStorageSourceParseBackingJSONSheepdog, 0},
     {"ssh", virStorageSourceParseBackingJSONSSH, 0},
     {"rbd", virStorageSourceParseBackingJSONRBD, 0},
+    {"raw", virStorageSourceParseBackingJSONRaw, 0},
 };
 
 
index 36567753baefefc59d0f9fa76cc047384d2fa4f0..984994d8e7f79292b9fd4828ea89b9863d4046ee 100644 (file)
@@ -1496,6 +1496,12 @@ mymain(void)
                        "<source protocol='rbd' name='testshare'>\n"
                        "  <host name='example.com'/>\n"
                        "</source>\n");
+    TEST_BACKING_PARSE("json:{ \"file\": { "
+                                "\"driver\": \"raw\","
+                                "\"file\": {"
+                                    "\"driver\": \"file\","
+                                    "\"filename\": \"/path/to/file\" } } }",
+                       "<source file='/path/to/file'/>\n");
 
  cleanup:
     /* Final cleanup */