]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: storage: Add support for host device backing specified via JSON
authorPeter Krempa <pkrempa@redhat.com>
Thu, 14 Jul 2016 11:58:26 +0000 (13:58 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 27 Jul 2016 11:24:20 +0000 (13:24 +0200)
JSON pseudo protocol for qemu allows to explicitly specify devices.
Add convertor to the internal type.

src/util/virstoragefile.c
tests/virstoragetest.c

index 763bec6caedf9e8b828c67bd9fdddbeb1f949b12..766ae28562f6e2acd17406250c2b3ebd01704063 100644 (file)
@@ -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},
 };
 
 
index 04575f210f0a6bfa2ac9c59456c0a70d38546443..6873180db2f1854c9bfe2bf36ee930ef459d5b66 100644 (file)
@@ -1370,6 +1370,12 @@ mymain(void)
                                         "}"
                             "}",
                        "<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 */