qemu: Add a NetDevice slice to the Config structure

The NetDevice structure represents a network device to be emulated by
qemu.
We also add the corresponding unit test.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz
2016-09-13 19:52:06 +02:00
parent c0e2aacad2
commit 137e7c7242
2 changed files with 74 additions and 0 deletions

View File

@@ -81,6 +81,13 @@ func testAppend(structure interface{}, expected string, t *testing.T) {
}
params = appendQMPSocket([]string{}, config)
case NetDevice:
config := Config{
NetDevices: []NetDevice{s},
}
params = appendNetDevices([]string{}, config)
}
result := strings.Join(params, " ")
@@ -258,3 +265,17 @@ func TestAppendStrings(t *testing.T) {
t.Fatalf("Failed to append parameters [%s] != [%s]", result, qemuString)
}
}
var netdevString = "-netdev tap,id=ceth0,ifname=ceth0,downscript=no,script=no"
func TestAppendNetDevices(t *testing.T) {
netdev := NetDevice{
Type: "tap",
ID: "ceth0",
IfName: "ceth0",
Script: "no",
DownScript: "no",
}
testAppend(netdev, netdevString, t)
}