Merge pull request #1599 from Jakob-Naucke/virtiofs-s390x

Enable virtio-fs on s390x
This commit is contained in:
Fabiano Fidêncio 2021-04-20 21:07:15 +02:00 committed by GitHub
commit 4c177b5c40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 57 additions and 36 deletions

View File

@ -31,7 +31,7 @@ require (
github.com/gogo/googleapis v1.4.0 // indirect github.com/gogo/googleapis v1.4.0 // indirect
github.com/gogo/protobuf v1.3.1 github.com/gogo/protobuf v1.3.1
github.com/hashicorp/go-multierror v1.0.0 github.com/hashicorp/go-multierror v1.0.0
github.com/kata-containers/govmm v0.0.0-20210112013750-7d320e8f5dca github.com/kata-containers/govmm v0.0.0-20210329205824-7fbc685865d2
github.com/mdlayher/vsock v0.0.0-20191108225356-d9c65923cb8f github.com/mdlayher/vsock v0.0.0-20191108225356-d9c65923cb8f
github.com/opencontainers/image-spec v1.0.1 // indirect github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/runc v1.0.0-rc9.0.20200102164712-2b52db75279c github.com/opencontainers/runc v1.0.0-rc9.0.20200102164712-2b52db75279c

View File

@ -276,6 +276,8 @@ github.com/juju/testing v0.0.0-20190613124551-e81189438503/go.mod h1:63prj8cnj0t
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kata-containers/govmm v0.0.0-20210112013750-7d320e8f5dca h1:UdXFthwasAPnmv37gLJUEFsW9FaabYA+mM6FoSi8kzU= github.com/kata-containers/govmm v0.0.0-20210112013750-7d320e8f5dca h1:UdXFthwasAPnmv37gLJUEFsW9FaabYA+mM6FoSi8kzU=
github.com/kata-containers/govmm v0.0.0-20210112013750-7d320e8f5dca/go.mod h1:VmAHbsL5lLfzHW/MNL96NVLF840DNEV5i683kISgFKk= github.com/kata-containers/govmm v0.0.0-20210112013750-7d320e8f5dca/go.mod h1:VmAHbsL5lLfzHW/MNL96NVLF840DNEV5i683kISgFKk=
github.com/kata-containers/govmm v0.0.0-20210329205824-7fbc685865d2 h1:oDJsQ5avmW8PFUkSJdsuaGL3SR4/YQRno51GNGl+IDU=
github.com/kata-containers/govmm v0.0.0-20210329205824-7fbc685865d2/go.mod h1:VmAHbsL5lLfzHW/MNL96NVLF840DNEV5i683kISgFKk=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=

View File

@ -131,6 +131,9 @@ const (
// PCIeRootPort is a PCIe Root Port, the PCIe device should be hotplugged to this port. // PCIeRootPort is a PCIe Root Port, the PCIe device should be hotplugged to this port.
PCIeRootPort DeviceDriver = "pcie-root-port" PCIeRootPort DeviceDriver = "pcie-root-port"
// Loader is the Loader device driver.
Loader DeviceDriver = "loader"
) )
func isDimmSupported(config *Config) bool { func isDimmSupported(config *Config) bool {
@ -552,7 +555,7 @@ func (cdev CharDevice) QemuParams(config *Config) []string {
cdevParams = append(cdevParams, string(cdev.Backend)) cdevParams = append(cdevParams, string(cdev.Backend))
cdevParams = append(cdevParams, fmt.Sprintf(",id=%s", cdev.ID)) cdevParams = append(cdevParams, fmt.Sprintf(",id=%s", cdev.ID))
if cdev.Backend == Socket { if cdev.Backend == Socket {
cdevParams = append(cdevParams, fmt.Sprintf(",path=%s,server,nowait", cdev.Path)) cdevParams = append(cdevParams, fmt.Sprintf(",path=%s,server=on,wait=off", cdev.Path))
} else { } else {
cdevParams = append(cdevParams, fmt.Sprintf(",path=%s", cdev.Path)) cdevParams = append(cdevParams, fmt.Sprintf(",path=%s", cdev.Path))
} }
@ -1138,6 +1141,40 @@ func (dev PVPanicDevice) QemuParams(config *Config) []string {
return []string{"-device", "pvpanic"} return []string{"-device", "pvpanic"}
} }
// LoaderDevice represents a qemu loader device.
type LoaderDevice struct {
File string
ID string
}
// Valid returns true if there is a valid structure defined for LoaderDevice
func (dev LoaderDevice) Valid() bool {
if dev.File == "" {
return false
}
if dev.ID == "" {
return false
}
return true
}
// QemuParams returns the qemu parameters built out of this loader device.
func (dev LoaderDevice) QemuParams(config *Config) []string {
var qemuParams []string
var devParams []string
devParams = append(devParams, "loader")
devParams = append(devParams, fmt.Sprintf("file=%s", dev.File))
devParams = append(devParams, fmt.Sprintf("id=%s", dev.ID))
qemuParams = append(qemuParams, "-device")
qemuParams = append(qemuParams, strings.Join(devParams, ","))
return qemuParams
}
// VhostUserDevice represents a qemu vhost-user device meant to be passed // VhostUserDevice represents a qemu vhost-user device meant to be passed
// in to the guest // in to the guest
type VhostUserDevice struct { type VhostUserDevice struct {
@ -2385,9 +2422,9 @@ func (config *Config) appendQMPSockets() {
qmpParams := append([]string{}, fmt.Sprintf("%s:", q.Type)) qmpParams := append([]string{}, fmt.Sprintf("%s:", q.Type))
qmpParams = append(qmpParams, q.Name) qmpParams = append(qmpParams, q.Name)
if q.Server { if q.Server {
qmpParams = append(qmpParams, ",server") qmpParams = append(qmpParams, ",server=on")
if q.NoWait { if q.NoWait {
qmpParams = append(qmpParams, ",nowait") qmpParams = append(qmpParams, ",wait=off")
} }
} }
@ -2528,9 +2565,6 @@ func (config *Config) appendMemoryKnobs() {
if config.Memory.Size == "" { if config.Memory.Size == "" {
return return
} }
if !isDimmSupported(config) {
return
}
var objMemParam, numaMemParam string var objMemParam, numaMemParam string
dimmName := "dimm1" dimmName := "dimm1"
if config.Knobs.HugePages { if config.Knobs.HugePages {
@ -2553,8 +2587,13 @@ func (config *Config) appendMemoryKnobs() {
config.qemuParams = append(config.qemuParams, "-object") config.qemuParams = append(config.qemuParams, "-object")
config.qemuParams = append(config.qemuParams, objMemParam) config.qemuParams = append(config.qemuParams, objMemParam)
config.qemuParams = append(config.qemuParams, "-numa") if isDimmSupported(config) {
config.qemuParams = append(config.qemuParams, numaMemParam) config.qemuParams = append(config.qemuParams, "-numa")
config.qemuParams = append(config.qemuParams, numaMemParam)
} else {
config.qemuParams = append(config.qemuParams, "-machine")
config.qemuParams = append(config.qemuParams, "memory-backend="+dimmName)
}
} }
func (config *Config) appendKnobs() { func (config *Config) appendKnobs() {

View File

@ -222,7 +222,7 @@ github.com/hashicorp/errwrap
# github.com/hashicorp/go-multierror v1.0.0 # github.com/hashicorp/go-multierror v1.0.0
## explicit ## explicit
github.com/hashicorp/go-multierror github.com/hashicorp/go-multierror
# github.com/kata-containers/govmm v0.0.0-20210112013750-7d320e8f5dca # github.com/kata-containers/govmm v0.0.0-20210329205824-7fbc685865d2
## explicit ## explicit
github.com/kata-containers/govmm/qemu github.com/kata-containers/govmm/qemu
# github.com/konsorten/go-windows-terminal-sequences v1.0.1 # github.com/konsorten/go-windows-terminal-sequences v1.0.1

View File

@ -1879,7 +1879,7 @@ func (q *qemu) addDevice(ctx context.Context, devInfo interface{}, devType devic
vhostDev.SocketPath = sockPath vhostDev.SocketPath = sockPath
vhostDev.DevID = id vhostDev.DevID = id
q.qemuConfig.Devices, err = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, vhostDev) q.qemuConfig.Devices = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, vhostDev)
} else { } else {
q.Logger().WithField("volume-type", "virtio-9p").Info("adding volume") q.Logger().WithField("volume-type", "virtio-9p").Info("adding volume")
q.qemuConfig.Devices, err = q.arch.append9PVolume(ctx, q.qemuConfig.Devices, v) q.qemuConfig.Devices, err = q.arch.append9PVolume(ctx, q.qemuConfig.Devices, v)
@ -1894,7 +1894,7 @@ func (q *qemu) addDevice(ctx context.Context, devInfo interface{}, devType devic
case config.BlockDrive: case config.BlockDrive:
q.qemuConfig.Devices, err = q.arch.appendBlockDevice(ctx, q.qemuConfig.Devices, v) q.qemuConfig.Devices, err = q.arch.appendBlockDevice(ctx, q.qemuConfig.Devices, v)
case config.VhostUserDeviceAttrs: case config.VhostUserDeviceAttrs:
q.qemuConfig.Devices, err = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, v) q.qemuConfig.Devices = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, v)
case config.VFIODev: case config.VFIODev:
q.qemuConfig.Devices = q.arch.appendVFIODevice(q.qemuConfig.Devices, v) q.qemuConfig.Devices = q.arch.appendVFIODevice(q.qemuConfig.Devices, v)
default: default:

View File

@ -96,7 +96,7 @@ type qemuArch interface {
appendBlockDevice(ctx context.Context, devices []govmmQemu.Device, drive config.BlockDrive) ([]govmmQemu.Device, error) appendBlockDevice(ctx context.Context, devices []govmmQemu.Device, drive config.BlockDrive) ([]govmmQemu.Device, error)
// appendVhostUserDevice appends a vhost user device to devices // appendVhostUserDevice appends a vhost user device to devices
appendVhostUserDevice(devices []govmmQemu.Device, drive config.VhostUserDeviceAttrs) ([]govmmQemu.Device, error) appendVhostUserDevice(devices []govmmQemu.Device, drive config.VhostUserDeviceAttrs) []govmmQemu.Device
// appendVFIODevice appends a VFIO device to devices // appendVFIODevice appends a VFIO device to devices
appendVFIODevice(devices []govmmQemu.Device, vfioDevice config.VFIODev) []govmmQemu.Device appendVFIODevice(devices []govmmQemu.Device, vfioDevice config.VFIODev) []govmmQemu.Device
@ -633,7 +633,7 @@ func (q *qemuArchBase) appendBlockDevice(_ context.Context, devices []govmmQemu.
return devices, nil return devices, nil
} }
func (q *qemuArchBase) appendVhostUserDevice(devices []govmmQemu.Device, attr config.VhostUserDeviceAttrs) ([]govmmQemu.Device, error) { func (q *qemuArchBase) appendVhostUserDevice(devices []govmmQemu.Device, attr config.VhostUserDeviceAttrs) []govmmQemu.Device {
qemuVhostUserDevice := govmmQemu.VhostUserDevice{} qemuVhostUserDevice := govmmQemu.VhostUserDevice{}
switch attr.Type { switch attr.Type {
@ -658,7 +658,7 @@ func (q *qemuArchBase) appendVhostUserDevice(devices []govmmQemu.Device, attr co
devices = append(devices, qemuVhostUserDevice) devices = append(devices, qemuVhostUserDevice)
return devices, nil return devices
} }
func (q *qemuArchBase) appendVFIODevice(devices []govmmQemu.Device, vfioDev config.VFIODev) []govmmQemu.Device { func (q *qemuArchBase) appendVFIODevice(devices []govmmQemu.Device, vfioDev config.VFIODev) []govmmQemu.Device {

View File

@ -224,7 +224,7 @@ func testQemuArchBaseAppend(t *testing.T, structure interface{}, expected []govm
case config.VFIODev: case config.VFIODev:
devices = qemuArchBase.appendVFIODevice(devices, s) devices = qemuArchBase.appendVFIODevice(devices, s)
case config.VhostUserDeviceAttrs: case config.VhostUserDeviceAttrs:
devices, err = qemuArchBase.appendVhostUserDevice(devices, s) devices = qemuArchBase.appendVhostUserDevice(devices, s)
} }
assert.NoError(err) assert.NoError(err)

View File

@ -152,12 +152,6 @@ func (q *qemuS390x) appendCCWBlockDevice(ctx context.Context, devices []govmmQem
return devices, nil return devices, nil
} }
// appendVhostUserDevice throws an error if vhost devices are tried to be used.
// See issue https://github.com/kata-containers/runtime/issues/659
func (q *qemuS390x) appendVhostUserDevice(devices []govmmQemu.Device, attr config.VhostUserDeviceAttrs) ([]govmmQemu.Device, error) {
return nil, fmt.Errorf("No vhost-user devices supported on s390x")
}
// supportGuestMemoryHotplug return false for s390x architecture. The pc-dimm backend device for s390x // supportGuestMemoryHotplug return false for s390x architecture. The pc-dimm backend device for s390x
// is not support. PC-DIMM is not listed in the devices supported by qemu-system-s390x -device help // is not support. PC-DIMM is not listed in the devices supported by qemu-system-s390x -device help
func (q *qemuS390x) supportGuestMemoryHotplug() bool { func (q *qemuS390x) supportGuestMemoryHotplug() bool {

View File

@ -52,17 +52,3 @@ func TestQemuS390xMemoryTopology(t *testing.T) {
m := s390x.memoryTopology(mem, hostMem, slots) m := s390x.memoryTopology(mem, hostMem, slots)
assert.Equal(expectedMemory, m) assert.Equal(expectedMemory, m)
} }
func TestQemuS390xAppendVhostUserDevice(t *testing.T) {
macAddress := "00:11:22:33:44:55:66"
qemu := qemuS390x{}
assert := assert.New(t)
vhostUserDevice := config.VhostUserDeviceAttrs{
Type: config.VhostUserNet,
MacAddress: macAddress,
}
_, err := qemu.appendVhostUserDevice(nil, vhostUserDevice)
assert.Error(err)
}