[libvirt] [PATCH 04/25] util: storage: Add support for host device backing specified via JSON

Peter Krempa pkrempa at redhat.com
Mon Jul 25 18:11:49 UTC 2016


JSON pseudo protocol for qemu allows to explicitly specify devices.
Add convertor to the internal type.
---
 src/util/virstoragefile.c | 2 ++
 tests/virstoragetest.c    | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 826e4ba..2e47bdb 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2545,6 +2545,8 @@ 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},
 };


diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index 46bbfb5..552b4d0 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -1363,6 +1363,12 @@ mymain(void)
     TEST_BACKING_PARSE("json:{\"file.driver\":\"file\", "
                              "\"file.filename\":\"/path/to/file\"}",
                        "<source file='/path/to/file'/>\n");
+    TEST_BACKING_PARSE("json:{\"file.driver\":\"host_device\", "
+                             "\"file.filename\":\"/path/to/dev\"}",
+                       "<source dev='/path/to/dev'/>\n");
+    TEST_BACKING_PARSE("json:{\"file.driver\":\"host_cdrom\", "
+                             "\"file.filename\":\"/path/to/cdrom\"}",
+                       "<source dev='/path/to/cdrom'/>\n");

  cleanup:
     /* Final cleanup */
-- 
2.9.0




More information about the libvir-list mailing list