mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-16 06:18:58 +00:00
Merge pull request #99 from alicefr/devno-blk-ccw
Support for virtio-blk-ccw
This commit is contained in:
72
qemu/qemu.go
72
qemu/qemu.go
@@ -103,6 +103,9 @@ const (
|
||||
|
||||
// PCIePCIBridgeDriver represents a PCIe to PCI bridge device type.
|
||||
PCIePCIBridgeDriver DeviceDriver = "pcie-pci-bridge"
|
||||
|
||||
// VirtioBlockCCW is the CCW block device driver
|
||||
VirtioBlockCCW DeviceDriver = "virtio-blk-ccw"
|
||||
)
|
||||
|
||||
// disableModern returns the parameters with the disable-modern option.
|
||||
@@ -249,6 +252,9 @@ type FSDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the FSDevice structure is valid and complete.
|
||||
@@ -275,6 +281,9 @@ func (fsdev FSDevice) QemuParams(config *Config) []string {
|
||||
if isVirtioPCI[fsdev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", fsdev.ROMFile))
|
||||
}
|
||||
if isVirtioCCW[fsdev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", fsdev.DevNo))
|
||||
}
|
||||
|
||||
fsParams = append(fsParams, string(fsdev.FSDriver))
|
||||
fsParams = append(fsParams, fmt.Sprintf(",id=%s", fsdev.ID))
|
||||
@@ -335,6 +344,9 @@ type CharDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the CharDevice structure is valid and complete.
|
||||
@@ -368,6 +380,10 @@ func (cdev CharDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", cdev.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[cdev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", cdev.DevNo))
|
||||
}
|
||||
|
||||
cdevParams = append(cdevParams, string(cdev.Backend))
|
||||
cdevParams = append(cdevParams, fmt.Sprintf(",id=%s", cdev.ID))
|
||||
if cdev.Backend == Socket {
|
||||
@@ -450,6 +466,9 @@ type NetDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the NetDevice structure is valid and complete.
|
||||
@@ -488,6 +507,7 @@ func (netdev NetDevice) mqParameter() string {
|
||||
vectors := len(netdev.FDs)*2 + 2
|
||||
p = append(p, fmt.Sprintf(",vectors=%d", vectors))
|
||||
}
|
||||
|
||||
return strings.Join(p, "")
|
||||
}
|
||||
|
||||
@@ -526,6 +546,10 @@ func (netdev NetDevice) QemuDeviceParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", netdev.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[netdev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", netdev.DevNo))
|
||||
}
|
||||
|
||||
return deviceParams
|
||||
}
|
||||
|
||||
@@ -617,6 +641,9 @@ type SerialDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the SerialDevice structure is valid and complete.
|
||||
@@ -642,6 +669,10 @@ func (dev SerialDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", dev.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[dev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", dev.DevNo))
|
||||
}
|
||||
|
||||
qemuParams = append(qemuParams, "-device")
|
||||
qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
|
||||
|
||||
@@ -694,6 +725,9 @@ type BlockDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the BlockDevice structure is valid and complete.
|
||||
@@ -728,6 +762,10 @@ func (blkdev BlockDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", blkdev.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[blkdev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", blkdev.DevNo))
|
||||
}
|
||||
|
||||
blkParams = append(blkParams, fmt.Sprintf("id=%s", blkdev.ID))
|
||||
blkParams = append(blkParams, fmt.Sprintf(",file=%s", blkdev.File))
|
||||
blkParams = append(blkParams, fmt.Sprintf(",aio=%s", blkdev.AIO))
|
||||
@@ -860,6 +898,9 @@ type VFIODevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the VFIODevice structure is valid and complete.
|
||||
@@ -879,6 +920,10 @@ func (vfioDev VFIODevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", vfioDev.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", vfioDev.DevNo))
|
||||
}
|
||||
|
||||
qemuParams = append(qemuParams, "-device")
|
||||
qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
|
||||
|
||||
@@ -903,6 +948,9 @@ type SCSIController struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the SCSIController structure is valid and complete.
|
||||
@@ -933,6 +981,10 @@ func (scsiCon SCSIController) QemuParams(config *Config) []string {
|
||||
devParams = append(devParams, fmt.Sprintf("romfile=%s", scsiCon.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[driver] {
|
||||
devParams = append(devParams, fmt.Sprintf("devno=%s", scsiCon.DevNo))
|
||||
}
|
||||
|
||||
qemuParams = append(qemuParams, "-device")
|
||||
qemuParams = append(qemuParams, strings.Join(devParams, ","))
|
||||
|
||||
@@ -1041,6 +1093,9 @@ type VSOCKDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -1086,6 +1141,10 @@ func (vsock VSOCKDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", vsock.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", vsock.DevNo))
|
||||
}
|
||||
|
||||
qemuParams = append(qemuParams, "-device")
|
||||
qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
|
||||
|
||||
@@ -1104,6 +1163,8 @@ type RngDevice struct {
|
||||
Period uint
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the RngDevice structure is valid and complete.
|
||||
@@ -1131,6 +1192,10 @@ func (v RngDevice) QemuParams(_ *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf("romfile=%s", v.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf("devno=%s", v.DevNo))
|
||||
}
|
||||
|
||||
if v.Filename != "" {
|
||||
objectParams = append(objectParams, "filename="+v.Filename)
|
||||
}
|
||||
@@ -1160,6 +1225,9 @@ type BalloonDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// QemuParams returns the qemu parameters built out of the BalloonDevice.
|
||||
@@ -1178,6 +1246,10 @@ func (b BalloonDevice) QemuParams(_ *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf("romfile=%s", b.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf("devno=%s", b.DevNo))
|
||||
}
|
||||
|
||||
if b.DeflateOnOOM {
|
||||
deviceParams = append(deviceParams, "deflate-on-oom=on")
|
||||
} else {
|
||||
|
@@ -61,6 +61,9 @@ var isVirtioPCI = map[DeviceDriver]bool{
|
||||
PCIePCIBridgeDriver: true,
|
||||
}
|
||||
|
||||
// isVirtioCCW is a dummy map to return always false on no-s390x arch
|
||||
var isVirtioCCW = map[DeviceDriver]bool{}
|
||||
|
||||
// QemuNetdevParam converts to the QEMU -netdev parameter notation
|
||||
func (n NetDeviceType) QemuNetdevParam() string {
|
||||
switch n {
|
||||
|
@@ -24,8 +24,6 @@ var (
|
||||
deviceFSString = "-device virtio-9p-pci,disable-modern=true,fsdev=workload9p,mount_tag=rootfs,romfile=efi-virtio.rom -fsdev local,id=workload9p,path=/var/lib/docker/devicemapper/mnt/e31ebda2,security_model=none"
|
||||
deviceNetworkString = "-netdev tap,id=tap0,vhost=on,ifname=ceth0,downscript=no,script=no -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,disable-modern=true,romfile=efi-virtio.rom"
|
||||
deviceNetworkStringMq = "-netdev tap,id=tap0,vhost=on,fds=3:4 -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,disable-modern=true,mq=on,vectors=6,romfile=efi-virtio.rom"
|
||||
deviceNetworkPCIString = "-netdev tap,id=tap0,vhost=on,ifname=ceth0,downscript=no,script=no -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,bus=/pci-bus/pcie.0,addr=ff,disable-modern=true,romfile=efi-virtio.rom"
|
||||
deviceNetworkPCIStringMq = "-netdev tap,id=tap0,vhost=on,fds=3:4 -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,bus=/pci-bus/pcie.0,addr=ff,disable-modern=true,mq=on,vectors=6,romfile=efi-virtio.rom"
|
||||
deviceSerialString = "-device virtio-serial-pci,disable-modern=true,id=serial0,romfile=efi-virtio.rom"
|
||||
deviceVhostUserNetString = "-chardev socket,id=char1,path=/tmp/nonexistentsocket.socket -netdev type=vhost-user,id=net1,chardev=char1,vhostforce -device virtio-net-pci,netdev=net1,mac=00:11:22:33:44:55,romfile=efi-virtio.rom"
|
||||
deviceVSOCKString = "-device vhost-vsock-pci,disable-modern=true,id=vhost-vsock-pci0,guest-cid=4,romfile=efi-virtio.rom"
|
||||
|
@@ -27,6 +27,13 @@ import (
|
||||
const agentUUID = "4cb19522-1e18-439a-883a-f9b2a3a95f5e"
|
||||
const volumeUUID = "67d86208-b46c-4465-9018-e14187d4010"
|
||||
|
||||
var (
|
||||
deviceNetworkPCIString = "-netdev tap,id=tap0,vhost=on,ifname=ceth0,downscript=no,script=no -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,bus=/pci-bus/pcie.0,addr=ff,disable-modern=true,romfile=efi-virtio.rom"
|
||||
deviceNetworkPCIStringMq = "-netdev tap,id=tap0,vhost=on,fds=3:4 -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,bus=/pci-bus/pcie.0,addr=ff,disable-modern=true,mq=on,vectors=6,romfile=efi-virtio.rom"
|
||||
)
|
||||
|
||||
const DevNo = "fe.1.1234"
|
||||
|
||||
func testAppend(structure interface{}, expected string, t *testing.T) {
|
||||
var config Config
|
||||
testConfigAppend(&config, structure, expected, t)
|
||||
@@ -136,6 +143,10 @@ func TestAppendDeviceFS(t *testing.T) {
|
||||
ROMFile: "efi-virtio.rom",
|
||||
}
|
||||
|
||||
if isVirtioCCW[fsdev.Driver] {
|
||||
fsdev.DevNo = DevNo
|
||||
}
|
||||
|
||||
testAppend(fsdev, deviceFSString, t)
|
||||
}
|
||||
|
||||
@@ -153,6 +164,10 @@ func TestAppendDeviceNetwork(t *testing.T) {
|
||||
ROMFile: "efi-virtio.rom",
|
||||
}
|
||||
|
||||
if isVirtioCCW[netdev.Driver] {
|
||||
netdev.DevNo = DevNo
|
||||
}
|
||||
|
||||
testAppend(netdev, deviceNetworkString, t)
|
||||
}
|
||||
|
||||
@@ -180,6 +195,9 @@ func TestAppendDeviceNetworkMq(t *testing.T) {
|
||||
DisableModern: true,
|
||||
ROMFile: "efi-virtio.rom",
|
||||
}
|
||||
if isVirtioCCW[netdev.Driver] {
|
||||
netdev.DevNo = DevNo
|
||||
}
|
||||
|
||||
testAppend(netdev, deviceNetworkStringMq, t)
|
||||
}
|
||||
@@ -201,6 +219,10 @@ func TestAppendDeviceNetworkPCI(t *testing.T) {
|
||||
ROMFile: romfile,
|
||||
}
|
||||
|
||||
if !isVirtioPCI[netdev.Driver] {
|
||||
t.Skip("Test valid only for PCI devices")
|
||||
}
|
||||
|
||||
testAppend(netdev, deviceNetworkPCIString, t)
|
||||
}
|
||||
|
||||
@@ -231,6 +253,10 @@ func TestAppendDeviceNetworkPCIMq(t *testing.T) {
|
||||
ROMFile: romfile,
|
||||
}
|
||||
|
||||
if !isVirtioPCI[netdev.Driver] {
|
||||
t.Skip("Test valid only for PCI devices")
|
||||
}
|
||||
|
||||
testAppend(netdev, deviceNetworkPCIStringMq, t)
|
||||
}
|
||||
|
||||
@@ -241,6 +267,9 @@ func TestAppendDeviceSerial(t *testing.T) {
|
||||
DisableModern: true,
|
||||
ROMFile: romfile,
|
||||
}
|
||||
if isVirtioCCW[sdev.Driver] {
|
||||
sdev.DevNo = DevNo
|
||||
}
|
||||
|
||||
testAppend(sdev, deviceSerialString, t)
|
||||
}
|
||||
@@ -256,7 +285,9 @@ func TestAppendDeviceSerialPort(t *testing.T) {
|
||||
Path: "/tmp/char.sock",
|
||||
Name: "channel.0",
|
||||
}
|
||||
|
||||
if isVirtioCCW[chardev.Driver] {
|
||||
chardev.DevNo = DevNo
|
||||
}
|
||||
testAppend(chardev, deviceSerialPortString, t)
|
||||
}
|
||||
|
||||
@@ -273,7 +304,9 @@ func TestAppendDeviceBlock(t *testing.T) {
|
||||
DisableModern: true,
|
||||
ROMFile: romfile,
|
||||
}
|
||||
|
||||
if isVirtioCCW[blkdev.Driver] {
|
||||
blkdev.DevNo = DevNo
|
||||
}
|
||||
testAppend(blkdev, deviceBlockString, t)
|
||||
}
|
||||
|
||||
@@ -283,6 +316,10 @@ func TestAppendDeviceVFIO(t *testing.T) {
|
||||
ROMFile: romfile,
|
||||
}
|
||||
|
||||
if isVirtioCCW[Vfio] {
|
||||
vfioDevice.DevNo = DevNo
|
||||
}
|
||||
|
||||
testAppend(vfioDevice, deviceVFIOString, t)
|
||||
}
|
||||
|
||||
@@ -295,6 +332,10 @@ func TestAppendVSOCK(t *testing.T) {
|
||||
ROMFile: romfile,
|
||||
}
|
||||
|
||||
if isVirtioCCW[VHostVSock] {
|
||||
vsockDevice.DevNo = DevNo
|
||||
}
|
||||
|
||||
testAppend(vsockDevice, deviceVSOCKString, t)
|
||||
}
|
||||
|
||||
@@ -334,6 +375,11 @@ func TestAppendVirtioRng(t *testing.T) {
|
||||
ROMFile: romfile,
|
||||
}
|
||||
|
||||
if isVirtioCCW[VirtioRng] {
|
||||
rngDevice.DevNo = DevNo
|
||||
deviceString += ",devno=" + rngDevice.DevNo
|
||||
}
|
||||
|
||||
testAppend(rngDevice, objectString+" "+deviceString, t)
|
||||
|
||||
rngDevice.Filename = "/dev/urandom"
|
||||
@@ -389,6 +435,11 @@ func TestAppendDeviceSCSIController(t *testing.T) {
|
||||
ID: "foo",
|
||||
ROMFile: romfile,
|
||||
}
|
||||
|
||||
if isVirtioCCW[VirtioScsi] {
|
||||
scsiCon.DevNo = DevNo
|
||||
}
|
||||
|
||||
testAppend(scsiCon, deviceSCSIControllerStr, t)
|
||||
|
||||
scsiCon.Bus = "pci.0"
|
||||
|
@@ -63,6 +63,27 @@ var isVirtioPCI = map[DeviceDriver]bool{
|
||||
PCIePCIBridgeDriver: false,
|
||||
}
|
||||
|
||||
// isVirtioCCW returns if the device is a ccw device
|
||||
var isVirtioCCW = map[DeviceDriver]bool{
|
||||
NVDIMM: false,
|
||||
Virtio9P: true,
|
||||
VirtioNetCCW: true,
|
||||
VirtioSerial: true,
|
||||
VirtioBlock: true,
|
||||
VirtioBlockCCW: true,
|
||||
Console: false,
|
||||
VirtioSerialPort: false,
|
||||
VHostVSock: true,
|
||||
VirtioRng: true,
|
||||
VirtioBalloon: true,
|
||||
VhostUserSCSI: false,
|
||||
VhostUserBlk: false,
|
||||
Vfio: true,
|
||||
VirtioScsi: true,
|
||||
PCIBridgeDriver: false,
|
||||
PCIePCIBridgeDriver: false,
|
||||
}
|
||||
|
||||
// QemuDeviceParam converts to the QEMU -device parameter notation
|
||||
// This function has been reimplemented for the s390x architecture to deal
|
||||
// with the VHOSTUSER case. Vhost user devices are not implemented on s390x
|
||||
|
@@ -23,17 +23,15 @@ import "testing"
|
||||
// -pci devices don't play well with Z hence replace them with corresponding -ccw devices
|
||||
// See https://wiki.qemu.org/Documentation/Platforms/S390X
|
||||
var (
|
||||
deviceFSString = "-device virtio-9p-ccw,fsdev=workload9p,mount_tag=rootfs -fsdev local,id=workload9p,path=/var/lib/docker/devicemapper/mnt/e31ebda2,security_model=none"
|
||||
deviceNetworkString = "-netdev tap,id=tap0,vhost=on,ifname=ceth0,downscript=no,script=no -device driver=virtio-net-ccw,netdev=tap0,mac=01:02:de:ad:be:ef"
|
||||
deviceNetworkStringMq = "-netdev tap,id=tap0,vhost=on,fds=3:4 -device driver=virtio-net-ccw,netdev=tap0,mac=01:02:de:ad:be:ef,mq=on"
|
||||
deviceNetworkPCIString = "-netdev tap,id=tap0,vhost=on,ifname=ceth0,downscript=no,script=no -device driver=virtio-net-ccw,netdev=tap0,mac=01:02:de:ad:be:ef,bus=/pci-bus/pcie.0,addr=ff"
|
||||
deviceNetworkPCIStringMq = "-netdev tap,id=tap0,vhost=on,fds=3:4 -device driver=virtio-net-ccw,netdev=tap0,mac=01:02:de:ad:be:ef,bus=/pci-bus/pcie.0,addr=ff,mq=on"
|
||||
deviceSerialString = "-device virtio-serial-ccw,id=serial0"
|
||||
deviceVSOCKString = "-device vhost-vsock-ccw,id=vhost-vsock-pci0,guest-cid=4"
|
||||
deviceVFIOString = "-device vfio-ccw,host=02:10.0"
|
||||
deviceSCSIControllerStr = "-device virtio-scsi-ccw,id=foo"
|
||||
deviceSCSIControllerBusAddrStr = "-device virtio-scsi-ccw,id=foo,bus=pci.0,addr=00:04.0,iothread=iothread1"
|
||||
deviceBlockString = "-device virtio-blk,drive=hd0,scsi=off,config-wce=off -drive id=hd0,file=/var/lib/vm.img,aio=threads,format=qcow2,if=none"
|
||||
deviceFSString = "-device virtio-9p-ccw,fsdev=workload9p,mount_tag=rootfs,devno=" + DevNo + " -fsdev local,id=workload9p,path=/var/lib/docker/devicemapper/mnt/e31ebda2,security_model=none"
|
||||
deviceNetworkString = "-netdev tap,id=tap0,vhost=on,ifname=ceth0,downscript=no,script=no -device driver=virtio-net-ccw,netdev=tap0,mac=01:02:de:ad:be:ef,devno=" + DevNo
|
||||
deviceNetworkStringMq = "-netdev tap,id=tap0,vhost=on,fds=3:4 -device driver=virtio-net-ccw,netdev=tap0,mac=01:02:de:ad:be:ef,mq=on,devno=" + DevNo
|
||||
deviceSerialString = "-device virtio-serial-ccw,id=serial0,devno=" + DevNo
|
||||
deviceVSOCKString = "-device vhost-vsock-ccw,id=vhost-vsock-pci0,guest-cid=4,devno=" + DevNo
|
||||
deviceVFIOString = "-device vfio-ccw,host=02:10.0,devno=" + DevNo
|
||||
deviceSCSIControllerStr = "-device virtio-scsi-ccw,id=foo,devno=" + DevNo
|
||||
deviceSCSIControllerBusAddrStr = "-device virtio-scsi-ccw,id=foo,bus=pci.0,addr=00:04.0,iothread=iothread1,devno=" + DevNo
|
||||
deviceBlockString = "-device virtio-blk,drive=hd0,scsi=off,config-wce=off,devno=" + DevNo + " -drive id=hd0,file=/var/lib/vm.img,aio=threads,format=qcow2,if=none"
|
||||
devicePCIBridgeString = "-device pci-bridge,bus=/pci-bus/pcie.0,id=mybridge,chassis_nr=5,shpc=on,addr=ff"
|
||||
devicePCIEBridgeString = "-device pcie-pci-bridge,bus=/pci-bus/pcie.0,id=mybridge,addr=ff"
|
||||
romfile = ""
|
||||
@@ -46,12 +44,13 @@ func TestAppendVirtioBalloon(t *testing.T) {
|
||||
|
||||
var deviceString = "-device " + string(VirtioBalloon)
|
||||
deviceString += ",id=" + balloonDevice.ID
|
||||
balloonDevice.DevNo = DevNo
|
||||
devnoOptios := ",devno=" + DevNo
|
||||
|
||||
var OnDeflateOnOMM = ",deflate-on-oom=on"
|
||||
var OffDeflateOnOMM = ",deflate-on-oom=off"
|
||||
|
||||
testAppend(balloonDevice, deviceString+OffDeflateOnOMM, t)
|
||||
testAppend(balloonDevice, deviceString+devnoOptios+OffDeflateOnOMM, t)
|
||||
|
||||
balloonDevice.DeflateOnOOM = true
|
||||
testAppend(balloonDevice, deviceString+OnDeflateOnOMM, t)
|
||||
testAppend(balloonDevice, deviceString+devnoOptios+OnDeflateOnOMM, t)
|
||||
}
|
||||
|
18
qemu/qmp.go
18
qemu/qmp.go
@@ -822,9 +822,13 @@ func (q *QMP) ExecuteDeviceAdd(ctx context.Context, blockdevID, devID, driver, b
|
||||
"driver": driver,
|
||||
"drive": blockdevID,
|
||||
}
|
||||
if bus != "" {
|
||||
|
||||
if isVirtioCCW[DeviceDriver(driver)] {
|
||||
args["devno"] = bus
|
||||
} else if bus != "" {
|
||||
args["bus"] = bus
|
||||
}
|
||||
|
||||
if shared && (q.version.Major > 2 || (q.version.Major == 2 && q.version.Minor >= 10)) {
|
||||
args["share-rw"] = "on"
|
||||
}
|
||||
@@ -870,8 +874,14 @@ func (q *QMP) ExecuteSCSIDeviceAdd(ctx context.Context, blockdevID, devID, drive
|
||||
"id": devID,
|
||||
"driver": driver,
|
||||
"drive": blockdevID,
|
||||
"bus": bus,
|
||||
}
|
||||
|
||||
if isVirtioCCW[DeviceDriver(driver)] {
|
||||
args["devno"] = bus
|
||||
} else {
|
||||
args["bus"] = bus
|
||||
}
|
||||
|
||||
if scsiID >= 0 {
|
||||
args["scsi-id"] = scsiID
|
||||
}
|
||||
@@ -1023,13 +1033,13 @@ func (q *QMP) ExecuteNetPCIDeviceAdd(ctx context.Context, netdevID, devID, macAd
|
||||
// using the device_add command. devID is the id of the device to add.
|
||||
// Must be valid QMP identifier. netdevID is the id of nic added by previous netdev_add.
|
||||
// queues is the number of queues of a nic.
|
||||
func (q *QMP) ExecuteNetCCWDeviceAdd(ctx context.Context, netdevID, devID, macAddr, addr, bus string, queues int) error {
|
||||
func (q *QMP) ExecuteNetCCWDeviceAdd(ctx context.Context, netdevID, devID, macAddr, bus string, queues int) error {
|
||||
args := map[string]interface{}{
|
||||
"id": devID,
|
||||
"driver": VirtioNetCCW,
|
||||
"netdev": netdevID,
|
||||
"mac": macAddr,
|
||||
"addr": addr,
|
||||
"devno": bus,
|
||||
}
|
||||
|
||||
if queues > 0 {
|
||||
|
@@ -557,7 +557,7 @@ func TestQMPNetCCWDeviceAdd(t *testing.T) {
|
||||
cfg := QMPConfig{Logger: qmpTestLogger{}}
|
||||
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
|
||||
checkVersion(t, connectedCh)
|
||||
err := q.ExecuteNetCCWDeviceAdd(context.Background(), "br0", "virtio-0", "02:42:ac:11:00:02", "0x7", "", 8)
|
||||
err := q.ExecuteNetCCWDeviceAdd(context.Background(), "br0", "virtio-0", "02:42:ac:11:00:02", DevNo, 8)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user