RFC: bhyve supported features reporting

Roman Bogorodskiy novel at freebsd.org
Sun Jun 24 10:13:17 UTC 2018


Bhyve evolves over time, and new features get added, such as new
devices support, new guest configurations and so on. However, it's not
really straight-forward to figure out what features a given bhyve binary
supports. This makes it harder to develop tools on top of bhyve,
specifically error reporting.

For example, libvirt's bhyve driver [1] probes bhyve capabilities [2] using:

 * Running 'bhyve -h' and parsing output,
 * For detecting devices, it runs 'bhyve -s 0,dev' and parses error
   output to see if the device is supported.

It's not very effective because 'bhyve' binary has to be executed
multiple times just to check things. Additionally, it's harder to check
things on a deeper level, e.g. specific device parameters. Also, this is
error-prone because help output generally is not designed for
machine-parsing, and this could easily break on slight formatting
change.

I would like to discuss introducing a general way of reporting features
bhyve supports. To start a discussion, I've created a simple draft/PoC
which adds '-f' (as for features) command line switch to bhyve. This
switch makes bhyve print its supported features. I'll use JSON as
example, however, as it's done using libxo, XML is also supported.
Example JSON output with inline comments below:

"bhyve": {

    // 'features' schema version using the common versioning pattern:
    //    major version increments on incompatible changes,
    //    minor version increments on compatible changes (extensions).
    "schema_version": "1.0",

    // there could also go some general properties like max_cpus etc

    // list of specific features, mostly should be self-descriptive
    "features": {
        "rtc_utc": {
	    "description": "RTC keeps UTC time",
            "cmd": {
		"switch": "-u"
    	    }
	},
        "wire_guest_memory": {
            "description": "Wire guest memory",
	    "cmd": {
		 "switch": "-S"
            }
	},
        "devices": {
	    "description": "Devices support",
            "cmd": {
		  "switch": "-s",
		  "arguments": [
 
		      // Probably, it'd be better to make this more organized,
                      // e.g. instead of a string with all arguments and arg/value paris,
                      // use a list of objects which would include possible values,
                      // required/optional, etc

		      {"options": "virtio-net,tapN,mac=xx:xx:xx:xx:xx:xx",
		       "description": "Virtio network device"
		      },
		      {"options": "virtio-blk,path,nocache,direct,ro,sectorsize=logical/physical",
		       "description": "Virtio block device"
		      },
		      {"options": "fbuf,rfb,rfb=IP:port,w=width,h=heigh,vga=vgaconf,wait,password=password",
		       "description": "Framebuffer device"
		      }
		   ]
	     }
	}
     }
}

Sample code is here: https://reviews.freebsd.org/D15992. At this point
it's just an excuse to start a discussion; it needs some macros to make
items creation easier, and it needs to have all the other
features/devices populated.

1: https://libvirt.org/drvbhyve.html
2:
https://github.com/libvirt/libvirt/blob/master/src/bhyve/bhyve_capabilities.c

Roman Bogorodskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-virtualization/attachments/20180624/6dcfcc24/attachment.sig>


More information about the freebsd-virtualization mailing list