util: storage: Add support for host device backing specified via JSON

JSON pseudo protocol for qemu allows to explicitly specify devices.
Add convertor to the internal type.
This commit is contained in:
Peter Krempa 2016-07-14 13:58:26 +02:00
parent e91f767c74
commit 47f292dd35
2 changed files with 8 additions and 0 deletions

View 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},
};

View 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 */