qemu: Add netdev options to the Device structure

With the NetDev and MACAddress strings, we can now create networking
device drivers.
We also add a unit test for netdev Device creation.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz
2016-09-15 14:45:21 +02:00
parent 4780e2371f
commit eda8607cc6
2 changed files with 32 additions and 6 deletions

View File

@@ -117,7 +117,7 @@ var deviceNVDIMMString = "-device nvdimm,id=nv0,memdev=mem0"
func TestAppendDeviceNVDIMM(t *testing.T) {
device := Device{
Type: "nvdimm",
Driver: "nvdimm",
ID: "nv0",
MemDev: "mem0",
}
@@ -129,7 +129,7 @@ var deviceFSString = "-device virtio-9p-pci,fsdev=workload9p,mount_tag=rootfs"
func TestAppendDeviceFS(t *testing.T) {
device := Device{
Type: "virtio-9p-pci",
Driver: "virtio-9p-pci",
FSDev: "workload9p",
MountTag: "rootfs",
}
@@ -137,6 +137,18 @@ func TestAppendDeviceFS(t *testing.T) {
testAppend(device, deviceFSString, t)
}
var deviceNetworkString = "-device virtio-net-pci,netdev=eth0,mac=01:02:de:ad:be:ef"
func TestAppendDeviceNetwork(t *testing.T) {
device := Device{
Driver: "virtio-net-pci",
NetDev: "eth0",
MACAddress: "01:02:de:ad:be:ef",
}
testAppend(device, deviceNetworkString, t)
}
func TestAppendEmptyDevice(t *testing.T) {
device := Device{}