qemu: Disable the default romfile used by virtio-pci

As we try to make sure we don't pull unneeded dependency when using
QEMU or NEMU as the hypervisor, and because SeaBIOS and OVMF firmware
already handle what's done by the default efi-virtio.rom binary, this
commit gets rid of this dependency by providing a default empty one.

Fixes #812

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2018-10-16 18:27:28 -07:00
parent 6f0873a2c3
commit 0ae5b142a6
2 changed files with 14 additions and 9 deletions

View File

@ -23,6 +23,11 @@ import (
"github.com/kata-containers/runtime/virtcontainers/utils" "github.com/kata-containers/runtime/virtcontainers/utils"
) )
// romFile is the file name of the ROM that can be used for virtio-pci devices.
// If this file name is empty, this means we expect the firmware used by Qemu,
// such as SeaBIOS or OVMF for instance, to handle this directly.
const romFile = ""
type qmpChannel struct { type qmpChannel struct {
ctx context.Context ctx context.Context
path string path string
@ -744,7 +749,7 @@ func (q *qemu) hotplugBlockDevice(drive *config.BlockDrive, op operation) error
// PCI address is in the format bridge-addr/device-addr eg. "03/02" // PCI address is in the format bridge-addr/device-addr eg. "03/02"
drive.PCIAddr = fmt.Sprintf("%02x", bridge.Addr) + "/" + addr drive.PCIAddr = fmt.Sprintf("%02x", bridge.Addr) + "/" + addr
if err = q.qmpMonitorCh.qmp.ExecutePCIDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, addr, bridge.ID, true); err != nil { if err = q.qmpMonitorCh.qmp.ExecutePCIDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, addr, bridge.ID, romFile, true); err != nil {
return err return err
} }
} else { } else {
@ -759,7 +764,7 @@ func (q *qemu) hotplugBlockDevice(drive *config.BlockDrive, op operation) error
return err return err
} }
if err = q.qmpMonitorCh.qmp.ExecuteSCSIDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, bus, scsiID, lun, true); err != nil { if err = q.qmpMonitorCh.qmp.ExecuteSCSIDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, bus, romFile, scsiID, lun, true); err != nil {
return err return err
} }
} }
@ -797,9 +802,9 @@ func (q *qemu) hotplugVFIODevice(device *config.VFIODev, op operation) error {
if q.state.HotplugVFIOOnRootBus { if q.state.HotplugVFIOOnRootBus {
switch device.Type { switch device.Type {
case config.VFIODeviceNormalType: case config.VFIODeviceNormalType:
return q.qmpMonitorCh.qmp.ExecuteVFIODeviceAdd(q.qmpMonitorCh.ctx, devID, device.BDF) return q.qmpMonitorCh.qmp.ExecuteVFIODeviceAdd(q.qmpMonitorCh.ctx, devID, device.BDF, romFile)
case config.VFIODeviceMediatedType: case config.VFIODeviceMediatedType:
return q.qmpMonitorCh.qmp.ExecutePCIVFIOMediatedDeviceAdd(q.qmpMonitorCh.ctx, devID, device.SysfsDev, "", "") return q.qmpMonitorCh.qmp.ExecutePCIVFIOMediatedDeviceAdd(q.qmpMonitorCh.ctx, devID, device.SysfsDev, "", "", romFile)
default: default:
return fmt.Errorf("Incorrect VFIO device type found") return fmt.Errorf("Incorrect VFIO device type found")
} }
@ -812,9 +817,9 @@ func (q *qemu) hotplugVFIODevice(device *config.VFIODev, op operation) error {
switch device.Type { switch device.Type {
case config.VFIODeviceNormalType: case config.VFIODeviceNormalType:
return q.qmpMonitorCh.qmp.ExecutePCIVFIODeviceAdd(q.qmpMonitorCh.ctx, devID, device.BDF, addr, bridge.ID) return q.qmpMonitorCh.qmp.ExecutePCIVFIODeviceAdd(q.qmpMonitorCh.ctx, devID, device.BDF, addr, bridge.ID, romFile)
case config.VFIODeviceMediatedType: case config.VFIODeviceMediatedType:
return q.qmpMonitorCh.qmp.ExecutePCIVFIOMediatedDeviceAdd(q.qmpMonitorCh.ctx, devID, device.SysfsDev, addr, bridge.ID) return q.qmpMonitorCh.qmp.ExecutePCIVFIOMediatedDeviceAdd(q.qmpMonitorCh.ctx, devID, device.SysfsDev, addr, bridge.ID, romFile)
default: default:
return fmt.Errorf("Incorrect VFIO device type found") return fmt.Errorf("Incorrect VFIO device type found")
} }
@ -882,7 +887,7 @@ func (q *qemu) hotplugNetDevice(drive *VethEndpoint, op operation) error {
return err return err
} }
drive.PCIAddr = fmt.Sprintf("%02x/%s", bridge.Addr, addr) drive.PCIAddr = fmt.Sprintf("%02x/%s", bridge.Addr, addr)
if err = q.qmpMonitorCh.qmp.ExecuteNetPCIDeviceAdd(q.qmpMonitorCh.ctx, drive.NetPair.Name, devID, drive.NetPair.TAPIface.HardAddr, addr, bridge.ID, int(q.config.NumVCPUs)); err != nil { if err = q.qmpMonitorCh.qmp.ExecuteNetPCIDeviceAdd(q.qmpMonitorCh.ctx, drive.NetPair.Name, devID, drive.NetPair.TAPIface.HardAddr, addr, bridge.ID, romFile, int(q.config.NumVCPUs)); err != nil {
return err return err
} }
} else { } else {
@ -1000,7 +1005,7 @@ func (q *qemu) hotplugAddCPUs(amount uint32) (uint32, error) {
socketID := fmt.Sprintf("%d", hc.Properties.Socket) socketID := fmt.Sprintf("%d", hc.Properties.Socket)
coreID := fmt.Sprintf("%d", hc.Properties.Core) coreID := fmt.Sprintf("%d", hc.Properties.Core)
threadID := fmt.Sprintf("%d", hc.Properties.Thread) threadID := fmt.Sprintf("%d", hc.Properties.Thread)
if err := q.qmpMonitorCh.qmp.ExecuteCPUDeviceAdd(q.qmpMonitorCh.ctx, driver, cpuID, socketID, coreID, threadID); err != nil { if err := q.qmpMonitorCh.qmp.ExecuteCPUDeviceAdd(q.qmpMonitorCh.ctx, driver, cpuID, socketID, coreID, threadID, romFile); err != nil {
// don't fail, let's try with other CPU // don't fail, let's try with other CPU
continue continue
} }

View File

@ -518,7 +518,7 @@ func (q *qemuArchBase) appendVhostUserDevice(devices []govmmQemu.Device, attr co
case config.VhostUserBlk: case config.VhostUserBlk:
} }
qemuVhostUserDevice.VhostUserType = govmmQemu.VhostUserDeviceType(attr.Type) qemuVhostUserDevice.VhostUserType = govmmQemu.DeviceDriver(attr.Type)
qemuVhostUserDevice.SocketPath = attr.SocketPath qemuVhostUserDevice.SocketPath = attr.SocketPath
qemuVhostUserDevice.CharDevID = utils.MakeNameID("char", attr.DevID, maxDevIDSize) qemuVhostUserDevice.CharDevID = utils.MakeNameID("char", attr.DevID, maxDevIDSize)