s390x: add devno support

DevNo is used to identify the ccw device for s390x systems

Signed-off-by: Alice Frosi <afrosi@de.ibm.com>
This commit is contained in:
Alice Frosi 2019-07-01 13:43:00 +02:00
parent 9f389cb319
commit 9cf98da0be
4 changed files with 106 additions and 4 deletions

View File

@ -249,6 +249,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 +278,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 +341,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 +377,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 +463,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 +504,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 +543,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 +638,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 +666,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 +722,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 +759,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 +895,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 +917,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 +945,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 +978,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 +1090,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 +1138,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 +1160,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 +1189,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 +1222,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 +1243,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 {

View File

@ -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 {

View File

@ -63,6 +63,26 @@ 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,
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

View File

@ -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 {