[libvirt] [libvirt RFC PATCH 03/10] util: storage: Add support for host device backing specified via JSON

Peter Krempa pkrempa at redhat.com
Fri Jul 15 13:46:36 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 aa56b61..24bb419 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -1361,6 +1361,12 @@ mymain(void)
     TEST_BACKING_PARSE(10, "json:{\"file.driver\":\"file\", "
                                  "\"file.filename\":\"/path/to/file\"}",
                        "<source file='/path/to/file'/>\n");
+    TEST_BACKING_PARSE(11, "json:{\"file.driver\":\"host_device\", "
+                                 "\"file.filename\":\"/path/to/dev\"}",
+                       "<source dev='/path/to/dev'/>\n");
+    TEST_BACKING_PARSE(12, "json:{\"file.driver\":\"host_cdrom\", "
+                                 "\"file.filename\":\"/path/to/cdrom\"}",
+                       "<source dev='/path/to/cdrom'/>\n");

  cleanup:
     /* Final cleanup */
-- 
2.8.2




More information about the libvir-list mailing list