mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 11:44:38 +00:00
qemu: Add multi-queue and vhost definitions to NetDevice
We can now specify if we want vhost to be enabled and wich fds we should use for multiqueue support. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
137e7c7242
commit
4780e2371f
21
qemu.go
21
qemu.go
@ -191,6 +191,13 @@ type NetDevice struct {
|
||||
|
||||
// Script is the tap interface configuration script.
|
||||
Script string
|
||||
|
||||
// FDs represents the list of already existing file descriptors to be used.
|
||||
// This is mostly useful for mq support.
|
||||
FDs []int
|
||||
|
||||
// VHost enables virtio device emulation from the host kernel instead of from qemu.
|
||||
VHost bool
|
||||
}
|
||||
|
||||
// Config is the qemu configuration structure.
|
||||
@ -557,6 +564,20 @@ func appendNetDevices(params []string, config Config) []string {
|
||||
netdevParams = append(netdevParams, fmt.Sprintf(",script=%s", d.Script))
|
||||
}
|
||||
|
||||
if len(d.FDs) > 0 {
|
||||
var fdParams []string
|
||||
|
||||
for _, fd := range d.FDs {
|
||||
fdParams = append(fdParams, fmt.Sprintf("%d", fd))
|
||||
}
|
||||
|
||||
netdevParams = append(netdevParams, fmt.Sprintf(",fds=%s", strings.Join(fdParams, ":")))
|
||||
}
|
||||
|
||||
if d.VHost == true {
|
||||
netdevParams = append(netdevParams, ",vhost=on")
|
||||
}
|
||||
|
||||
params = append(params, "-netdev")
|
||||
params = append(params, strings.Join(netdevParams, ""))
|
||||
}
|
||||
|
@ -266,15 +266,16 @@ func TestAppendStrings(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
var netdevString = "-netdev tap,id=ceth0,ifname=ceth0,downscript=no,script=no"
|
||||
var netdevString = "-netdev tap,id=ceth0,downscript=no,script=no,fds=8:9:10,vhost=on"
|
||||
|
||||
func TestAppendNetDevices(t *testing.T) {
|
||||
netdev := NetDevice{
|
||||
Type: "tap",
|
||||
ID: "ceth0",
|
||||
IfName: "ceth0",
|
||||
Script: "no",
|
||||
DownScript: "no",
|
||||
FDs: []int{8, 9, 10},
|
||||
VHost: true,
|
||||
}
|
||||
|
||||
testAppend(netdev, netdevString, t)
|
||||
|
Loading…
Reference in New Issue
Block a user