qemu: Add support for romfile option

Any device inheriting from virtio-pci can specify a ROM file. This
option is provisioned by default with "efi-virtio.rom", but most
of the time, firmwares such as OVMF or seabios will already support
what is provided by this ROM file.

In order to reduce the "forced" dependency on such ROM file, govmm
should provide an empty path if the consumer of the library does not
provide one.

This patch reorganizes the list of devices, so that it gets easier to
list which devices inherit from virtio-pci, and then adds the romfile
option to every single device that support this option.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2018-10-08 16:04:17 -07:00
parent 35b7308881
commit 7fdfc6a4c9
4 changed files with 245 additions and 89 deletions

View File

@@ -504,7 +504,7 @@ func TestQMPNetPCIDeviceAdd(t *testing.T) {
cfg := QMPConfig{Logger: qmpTestLogger{}}
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
checkVersion(t, connectedCh)
err := q.ExecuteNetPCIDeviceAdd(context.Background(), "br0", "virtio-0", "02:42:ac:11:00:02", "0x7", "", 8)
err := q.ExecuteNetPCIDeviceAdd(context.Background(), "br0", "virtio-0", "02:42:ac:11:00:02", "0x7", "", "", 8)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
@@ -529,7 +529,7 @@ func TestQMPDeviceAdd(t *testing.T) {
blockdevID := fmt.Sprintf("drive_%s", volumeUUID)
devID := fmt.Sprintf("device_%s", volumeUUID)
err := q.ExecuteDeviceAdd(context.Background(), blockdevID, devID,
"virtio-blk-pci", "", true)
"virtio-blk-pci", "", "", true)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
@@ -554,7 +554,7 @@ func TestQMPSCSIDeviceAdd(t *testing.T) {
blockdevID := fmt.Sprintf("drive_%s", volumeUUID)
devID := fmt.Sprintf("device_%s", volumeUUID)
err := q.ExecuteSCSIDeviceAdd(context.Background(), blockdevID, devID,
"scsi-hd", "scsi0.0", 1, 2, true)
"scsi-hd", "scsi0.0", "", 1, 2, true)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
@@ -972,7 +972,7 @@ func TestQMPPCIDeviceAdd(t *testing.T) {
blockdevID := fmt.Sprintf("drive_%s", volumeUUID)
devID := fmt.Sprintf("device_%s", volumeUUID)
err := q.ExecutePCIDeviceAdd(context.Background(), blockdevID, devID,
"virtio-blk-pci", "0x1", "", true)
"virtio-blk-pci", "0x1", "", "", true)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
@@ -996,7 +996,7 @@ func TestQMPPCIVFIOMediatedDeviceAdd(t *testing.T) {
checkVersion(t, connectedCh)
sysfsDev := "/sys/bus/pci/devices/0000:00:02.0/a297db4a-f4c2-11e6-90f6-d3b88d6c9525"
devID := fmt.Sprintf("device_%s", volumeUUID)
err := q.ExecutePCIVFIOMediatedDeviceAdd(context.Background(), devID, sysfsDev, "0x1", "")
err := q.ExecutePCIVFIOMediatedDeviceAdd(context.Background(), devID, sysfsDev, "0x1", "", "")
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
@@ -1018,7 +1018,7 @@ func TestQMPCPUDeviceAdd(t *testing.T) {
socketID := "0"
coreID := "1"
threadID := "0"
err := q.ExecuteCPUDeviceAdd(context.Background(), driver, cpuID, socketID, coreID, threadID)
err := q.ExecuteCPUDeviceAdd(context.Background(), driver, cpuID, socketID, coreID, threadID, "")
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
@@ -1237,7 +1237,7 @@ func TestExecutePCIVSockAdd(t *testing.T) {
cfg := QMPConfig{Logger: qmpTestLogger{}}
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
checkVersion(t, connectedCh)
err := q.ExecutePCIVSockAdd(context.Background(), "vsock-pci0", "3", "1", "1", "1", true)
err := q.ExecutePCIVSockAdd(context.Background(), "vsock-pci0", "3", "1", "1", "1", "", true)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}