mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +00:00
Fix qemu commandline issue with empty romfile
Currently, if romfile field is empty, the commandline will shows like below: -device driver=virtio-net-pci,...,mq=on,vectors=4,romfile= This does not make sense, just remove this field in commandline Add unittest support. Signed-off-by: Michael Qiu <qiudayu@huayun.com>
This commit is contained in:
parent
8ba62b02ca
commit
511cf58b0c
26
qemu/qemu.go
26
qemu/qemu.go
@ -429,7 +429,7 @@ func (fsdev FSDevice) QemuParams(config *Config) []string {
|
||||
}
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",fsdev=%s", fsdev.ID))
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",mount_tag=%s", fsdev.MountTag))
|
||||
if fsdev.Transport.isVirtioPCI(config) {
|
||||
if fsdev.Transport.isVirtioPCI(config) && fsdev.ROMFile != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", fsdev.ROMFile))
|
||||
}
|
||||
if fsdev.Transport.isVirtioCCW(config) {
|
||||
@ -562,7 +562,7 @@ func (cdev CharDevice) QemuParams(config *Config) []string {
|
||||
if cdev.Name != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",name=%s", cdev.Name))
|
||||
}
|
||||
if cdev.Driver == VirtioSerial && cdev.Transport.isVirtioPCI(config) {
|
||||
if cdev.Driver == VirtioSerial && cdev.Transport.isVirtioPCI(config) && cdev.ROMFile != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", cdev.ROMFile))
|
||||
}
|
||||
|
||||
@ -832,7 +832,7 @@ func (netdev NetDevice) QemuDeviceParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, netdev.mqParameter(config))
|
||||
}
|
||||
|
||||
if netdev.Transport.isVirtioPCI(config) {
|
||||
if netdev.Transport.isVirtioPCI(config) && netdev.ROMFile != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", netdev.ROMFile))
|
||||
}
|
||||
|
||||
@ -965,7 +965,7 @@ func (dev SerialDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",%s", s))
|
||||
}
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",id=%s", dev.ID))
|
||||
if dev.Transport.isVirtioPCI(config) {
|
||||
if dev.Transport.isVirtioPCI(config) && dev.ROMFile != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", dev.ROMFile))
|
||||
if dev.Driver == VirtioSerial && dev.MaxPorts != 0 {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",max_ports=%d", dev.MaxPorts))
|
||||
@ -1096,7 +1096,7 @@ func (blkdev BlockDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, ",config-wce=off")
|
||||
}
|
||||
|
||||
if blkdev.Transport.isVirtioPCI(config) {
|
||||
if blkdev.Transport.isVirtioPCI(config) && blkdev.ROMFile != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", blkdev.ROMFile))
|
||||
}
|
||||
|
||||
@ -1341,7 +1341,7 @@ func (vhostuserDev VhostUserDevice) QemuParams(config *Config) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
if vhostuserDev.Transport.isVirtioPCI(config) {
|
||||
if vhostuserDev.Transport.isVirtioPCI(config) && vhostuserDev.ROMFile != "" {
|
||||
devParams = append(devParams, fmt.Sprintf("romfile=%s", vhostuserDev.ROMFile))
|
||||
}
|
||||
|
||||
@ -1531,7 +1531,9 @@ func (vfioDev VFIODevice) QemuParams(config *Config) []string {
|
||||
if vfioDev.DeviceID != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",x-pci-device-id=%s", vfioDev.DeviceID))
|
||||
}
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", vfioDev.ROMFile))
|
||||
if vfioDev.ROMFile != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", vfioDev.ROMFile))
|
||||
}
|
||||
}
|
||||
|
||||
if vfioDev.Bus != "" {
|
||||
@ -1616,7 +1618,7 @@ func (scsiCon SCSIController) QemuParams(config *Config) []string {
|
||||
if scsiCon.IOThread != "" {
|
||||
devParams = append(devParams, fmt.Sprintf("iothread=%s", scsiCon.IOThread))
|
||||
}
|
||||
if scsiCon.Transport.isVirtioPCI(config) {
|
||||
if scsiCon.Transport.isVirtioPCI(config) && scsiCon.ROMFile != "" {
|
||||
devParams = append(devParams, fmt.Sprintf("romfile=%s", scsiCon.ROMFile))
|
||||
}
|
||||
|
||||
@ -1722,7 +1724,7 @@ func (bridgeDev BridgeDevice) QemuParams(config *Config) []string {
|
||||
}
|
||||
|
||||
var transport VirtioTransport
|
||||
if transport.isVirtioPCI(config) {
|
||||
if transport.isVirtioPCI(config) && bridgeDev.ROMFile != "" {
|
||||
deviceParam = append(deviceParam, fmt.Sprintf(",romfile=%s", bridgeDev.ROMFile))
|
||||
}
|
||||
|
||||
@ -1801,7 +1803,7 @@ func (vsock VSOCKDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",id=%s", vsock.ID))
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",%s=%d", VSOCKGuestCID, vsock.ContextID))
|
||||
|
||||
if vsock.Transport.isVirtioPCI(config) {
|
||||
if vsock.Transport.isVirtioPCI(config) && vsock.ROMFile != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", vsock.ROMFile))
|
||||
}
|
||||
|
||||
@ -1874,7 +1876,7 @@ func (v RngDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, v.deviceName(config))
|
||||
deviceParams = append(deviceParams, "rng="+v.ID)
|
||||
|
||||
if v.Transport.isVirtioPCI(config) {
|
||||
if v.Transport.isVirtioPCI(config) && v.ROMFile != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf("romfile=%s", v.ROMFile))
|
||||
}
|
||||
|
||||
@ -1951,7 +1953,7 @@ func (b BalloonDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, "id="+b.ID)
|
||||
}
|
||||
|
||||
if b.Transport.isVirtioPCI(config) {
|
||||
if b.Transport.isVirtioPCI(config) && b.ROMFile != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf("romfile=%s", b.ROMFile))
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ var (
|
||||
deviceVFIOString = "-device vfio-pci,host=02:10.0,x-pci-vendor-id=0x1234,x-pci-device-id=0x5678,romfile=efi-virtio.rom"
|
||||
devicePCIeRootPortSimpleString = "-device pcie-root-port,id=rp1,bus=pcie.0,chassis=0x00,slot=0x00,multifunction=off"
|
||||
devicePCIeRootPortFullString = "-device pcie-root-port,id=rp2,bus=pcie.0,chassis=0x0,slot=0x1,addr=0x2,multifunction=on,bus-reserve=0x3,pref64-reserve=16G,mem-reserve=1G,io-reserve=512M,romfile=efi-virtio.rom"
|
||||
deviceVFIOPCIeSimpleString = "-device vfio-pci,host=02:00.0,romfile=,bus=rp0"
|
||||
deviceVFIOPCIeSimpleString = "-device vfio-pci,host=02:00.0,bus=rp0"
|
||||
deviceVFIOPCIeFullString = "-device vfio-pci,host=02:00.0,x-pci-vendor-id=0x10de,x-pci-device-id=0x15f8,romfile=efi-virtio.rom,bus=rp1"
|
||||
deviceSCSIControllerStr = "-device virtio-scsi-pci,id=foo,disable-modern=false,romfile=efi-virtio.rom"
|
||||
deviceSCSIControllerBusAddrStr = "-device virtio-scsi-pci,id=foo,bus=pci.0,addr=00:04.0,disable-modern=true,iothread=iothread1,romfile=efi-virtio.rom"
|
||||
|
Loading…
Reference in New Issue
Block a user