Avi Kivity <a...@redhat.com> writes: > On 06/04/2010 05:16 PM, Markus Armbruster wrote: >> - "protocol": json-array of json-object >> Each element object has a member "name" >> - Possible values: "file", "nbd", ... >> Additional members depend on the value of "name". >> For "name" = "file": >> - "file": file name (json-string) >> For "name" = "nbd": >> - "domain": address family (json-string, optional) >> - Possible values: "inet" (default), "unix" >> - "file": file name (json-string), only with "domain" = "unix" >> - "host": host name (json-string), only with "domain" = "inet" >> - "port": port (json-int), only with "domain" = "inet" >> ... >> >> > > This loses the nesting that protocols have. I'd like to see the each > nested protocol as member of the parent protocol. Besides the lovely > } } }s in the json representation, this allows us to have more > complicated protocols, for example a mirror protocol that has two > child protocol each specifying a different backing store.
Even though we don't have such a protocol yet, not even plans to get it, your argument tips the balance towards nesting. Revised sketch: instead of - "file": the disk image file to use (json-string, optional) - "format": disk format (json-string, optional) - Possible values: "raw", "qcow2", ... have - "format": image format (json-string, optional) - Possible values: "raw", "qcow2", [...] - "protocol": image access protocol (json-object) - It has a member "name" (json-string), and depending on its value additional members. - For "name" = "auto", "file", [...] - "file": name of image file (json-string) - For "name" = "nbd": - "domain": address family (json-string, optional) - Possible values: "inet" (default), "unix" - "file": name of socket file (json-string), only with "domain" = "unix" - "host": host name (json-string), only with "domain" = "inet" - "port": port (json-int), only with "domain" = "inet" - For "name" = "blkdebug": - "config": name of config file (json-string) - "protocol": image access protocol (json-object), as above [...] Examples: * Format "qcow2", protocol "auto" with argument filename "foo.img" "format": "qcow2", "protocol": { "name": "auto", "file": "foo.qcow2" } * Format "raw", protocol "nbd" with arguments domain "unix", filename "/tmp/my_socket" "format": "raw" "protocol": { "name": "nbd", "domain": "unix", "file": "/tmp/my_socket" } * Format not specified (system guesses one), protocol "blkdebug" with argument filename "/tmp/blkdebug.cfg" stacked onto protocol "fat" with arguments floppy true, dirname "/tmp/dir" "protocol": { "name": "blkdebug", "file": "/tmp/blkdebug.cfg", "protocol": { "name": "fat", "floppy": true, "dir": "/tmp/dir" } } This nesting business is easy enough for QMP, but it'll be awkward on the command line. Ideas on how to do it cleanly with -blockdev?