From e4c6d4ae557a5de3a4b9a7e789df0e8f1d140557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Date: Mon, 13 Feb 2017 23:53:43 +0100 Subject: [PATCH] util: storage: add JSON backing volume parser 'raw' block driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ý --- src/util/virstoragefile.c | 16 ++++++++++++++++ tests/virstoragetest.c | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 715c0429d7..c9420fdb79 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -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}, }; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 36567753ba..984994d8e7 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1496,6 +1496,12 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE("json:{ \"file\": { " + "\"driver\": \"raw\"," + "\"file\": {" + "\"driver\": \"file\"," + "\"filename\": \"/path/to/file\" } } }", + "\n"); cleanup: /* Final cleanup */