vendor: Update govmm

Changes:

- qemu/qmp: support query-memory-devices qmp command.
- qemu: Add virtio RNG device.

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
Jose Carlos Venegas Munoz
2018-09-10 13:27:20 -05:00
parent 8f5fec8064
commit f1829d078a
4 changed files with 103 additions and 3 deletions

View File

@@ -85,6 +85,9 @@ const (
// VHostVSockPCI is the vhost vsock pci driver.
VHostVSockPCI DeviceDriver = "vhost-vsock-pci"
// VirtioRng is the paravirtualized RNG device driver.
VirtioRng DeviceDriver = "virtio-rng"
)
// ObjectType is a string representing a qemu object type.
@@ -1017,6 +1020,63 @@ func (vsock VSOCKDevice) QemuParams(config *Config) []string {
return qemuParams
}
// RngDevice represents a random number generator device.
type RngDevice struct {
// ID is the device ID
ID string
// Filename is entropy source on the host
Filename string
// MaxBytes is the bytes allowed to guest to get from the hosts entropy per period
MaxBytes uint
// Period is duration of a read period in seconds
Period uint
}
// Valid returns true if the RngDevice structure is valid and complete.
func (v RngDevice) Valid() bool {
if v.ID == "" {
return false
}
return true
}
// QemuParams returns the qemu parameters built out of the RngDevice.
func (v RngDevice) QemuParams(_ *Config) []string {
var qemuParams []string
//-object rng-random,filename=/dev/hwrng,id=rng0
var objectParams []string
//-device virtio-rng-pci,rng=rng0,max-bytes=1024,period=1000
var deviceParams []string
objectParams = append(objectParams, "rng-random")
objectParams = append(objectParams, "id="+v.ID)
deviceParams = append(deviceParams, string(VirtioRng))
deviceParams = append(deviceParams, "rng="+v.ID)
if v.Filename != "" {
objectParams = append(objectParams, "filename="+v.Filename)
}
if v.MaxBytes > 0 {
deviceParams = append(deviceParams, fmt.Sprintf("max-bytes=%d", v.MaxBytes))
}
if v.Period > 0 {
deviceParams = append(deviceParams, fmt.Sprintf("period=%d", v.Period))
}
qemuParams = append(qemuParams, "-object")
qemuParams = append(qemuParams, strings.Join(objectParams, ","))
qemuParams = append(qemuParams, "-device")
qemuParams = append(qemuParams, strings.Join(deviceParams, ","))
return qemuParams
}
// RTCBaseType is the qemu RTC base time type.
type RTCBaseType string