From cafd967109f56690648b9dac0591499b4859f7f4 Mon Sep 17 00:00:00 2001 From: Jianyong Wu Date: Mon, 16 Nov 2020 11:46:41 +0800 Subject: [PATCH] Gopkg: update govmm to involve pflash in pflash has enabled in govmm which is needed for acpi on arm64 Fixes: #3078 Signed-off-by: Jianyong Wu --- Gopkg.lock | 4 +- Gopkg.toml | 2 +- vendor/github.com/intel/govmm/CONTRIBUTORS.md | 22 ---- vendor/github.com/intel/govmm/qemu/qemu.go | 103 ++++++++++++++++++ vendor/github.com/intel/govmm/qemu/qmp.go | 39 ++++++- 5 files changed, 143 insertions(+), 27 deletions(-) delete mode 100644 vendor/github.com/intel/govmm/CONTRIBUTORS.md diff --git a/Gopkg.lock b/Gopkg.lock index 0634bad00a..1ed2ef2673 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -420,11 +420,11 @@ revision = "2f1d1f20f75d5404f53b9edf6b53ed5505508675" [[projects]] - digest = "1:e4b04b215d8cb0310c06f4a5af631f7df6648ffebf1911d3f4de7f3ea605db87" + digest = "1:647e03799be4f4878fa6deb1656f1c172c13d1e31b3aaf96384755006c94ded9" name = "github.com/intel/govmm" packages = ["qemu"] pruneopts = "NUT" - revision = "547a8518098aaa71c5d5d7a370f211e00161016b" + revision = "5e9aa08c4fd1201d65c6dd1136c8ab70ff17ee82" [[projects]] digest = "1:ee3d719407ec4bd877eaa4da37e2935298c3d9029ec3c20e502c0e14768b754c" diff --git a/Gopkg.toml b/Gopkg.toml index 2cdbda4adc..879effcaf8 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -48,7 +48,7 @@ [[constraint]] name = "github.com/intel/govmm" - revision = "547a8518098aaa71c5d5d7a370f211e00161016b" + revision = "5e9aa08c4fd1201d65c6dd1136c8ab70ff17ee82" [[constraint]] name = "github.com/kata-containers/agent" diff --git a/vendor/github.com/intel/govmm/CONTRIBUTORS.md b/vendor/github.com/intel/govmm/CONTRIBUTORS.md deleted file mode 100644 index 7a822adbe0..0000000000 --- a/vendor/github.com/intel/govmm/CONTRIBUTORS.md +++ /dev/null @@ -1,22 +0,0 @@ -This file is a partial list of contributors to the Virtual Machine -Manager for Go project. To see the full list of contributors, see the -revision history in source control. - -Contributors who wish to be recognized in this file should add -themselves (or their employer, as appropriate). - -- afrosi@de.ibm.com -- archana.m.shinde@intel.com -- caoruidong@huawei.com -- clare.chenhui@huawei.com -- eric.ernst@intel.com -- james.o.hunt@intel.com -- jose.carlos.venegas.munoz@intel.com -- julio.montes@intel.com -- manohar.r.castelino@intel.com -- mark.d.ryan@intel.com -- robert.bradford@intel.com -- sameo@linux.intel.com -- sebastien.boeuf@intel.com -- teawater@hyper.sh -- xinda.zhao@intel.com diff --git a/vendor/github.com/intel/govmm/qemu/qemu.go b/vendor/github.com/intel/govmm/qemu/qemu.go index e326713e1e..567a316f40 100644 --- a/vendor/github.com/intel/govmm/qemu/qemu.go +++ b/vendor/github.com/intel/govmm/qemu/qemu.go @@ -123,6 +123,9 @@ const ( // VfioCCW is the vfio driver with CCW transport. VfioCCW DeviceDriver = "vfio-ccw" + // VfioAP is the vfio driver with AP transport. + VfioAP DeviceDriver = "vfio-ap" + // VHostVSockPCI is a generic Vsock vhost device with PCI transport. VHostVSockPCI DeviceDriver = "vhost-vsock-pci" @@ -1081,6 +1084,8 @@ func (blkdev BlockDevice) QemuParams(config *Config) []string { deviceParams = append(deviceParams, fmt.Sprintf(",share-rw=on")) } + deviceParams = append(deviceParams, fmt.Sprintf(",serial=%s", blkdev.ID)) + 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)) @@ -1115,6 +1120,24 @@ func (blkdev BlockDevice) deviceName(config *Config) string { return string(blkdev.Driver) } +// PVPanicDevice represents a qemu pvpanic device. +type PVPanicDevice struct { + NoShutdown bool +} + +// Valid always returns true for pvpanic device +func (dev PVPanicDevice) Valid() bool { + return true +} + +// QemuParams returns the qemu parameters built out of this serial device. +func (dev PVPanicDevice) QemuParams(config *Config) []string { + if dev.NoShutdown { + return []string{"-device", "pvpanic", "-no-shutdown"} + } + return []string{"-device", "pvpanic"} +} + // VhostUserDevice represents a qemu vhost-user device meant to be passed // in to the guest type VhostUserDevice struct { @@ -2100,6 +2123,56 @@ type Kernel struct { Params string } +// FwCfg allows QEMU to pass entries to the guest +// File and Str are mutually exclusive +type FwCfg struct { + Name string + File string + Str string +} + +// Valid returns true if the FwCfg structure is valid and complete. +func (fwcfg FwCfg) Valid() bool { + if fwcfg.Name == "" { + return false + } + + if fwcfg.File != "" && fwcfg.Str != "" { + return false + } + + if fwcfg.File == "" && fwcfg.Str == "" { + return false + } + + return true +} + +// QemuParams returns the qemu parameters built out of the FwCfg object +func (fwcfg FwCfg) QemuParams(config *Config) []string { + var fwcfgParams []string + var qemuParams []string + + for _, f := range config.FwCfg { + if f.Name != "" { + fwcfgParams = append(fwcfgParams, fmt.Sprintf("name=%s", f.Name)) + + if f.File != "" { + fwcfgParams = append(fwcfgParams, fmt.Sprintf(",file=%s", f.File)) + } + + if f.Str != "" { + fwcfgParams = append(fwcfgParams, fmt.Sprintf(",string=%s", f.Str)) + } + } + + qemuParams = append(qemuParams, "-fw_cfg") + qemuParams = append(qemuParams, strings.Join(fwcfgParams, "")) + } + + return qemuParams +} + // Knobs regroups a set of qemu boolean settings type Knobs struct { // NoUserConfig prevents qemu from loading user config files. @@ -2227,12 +2300,18 @@ type Config struct { // Bios is the -bios parameter Bios string + // PFlash specifies the parallel flash images (-pflash parameter) + PFlash []string + // Incoming controls migration source preparation Incoming Incoming // fds is a list of open file descriptors to be passed to the spawned qemu process fds []*os.File + // FwCfg is the -fw_cfg parameter + FwCfg []FwCfg + IOThreads []IOThread // PidFile is the -pidfile parameter @@ -2414,6 +2493,13 @@ func (config *Config) appendGlobalParam() { } } +func (config *Config) appendPFlashParam() { + for _, p := range config.PFlash { + config.qemuParams = append(config.qemuParams, "-pflash") + config.qemuParams = append(config.qemuParams, p) + } +} + func (config *Config) appendVGA() { if config.VGA != "" { config.qemuParams = append(config.qemuParams, "-vga") @@ -2565,6 +2651,21 @@ func (config *Config) appendLogFile() { } } +func (config *Config) appendFwCfg(logger QMPLog) { + if logger == nil { + logger = qmpNullLogger{} + } + + for _, f := range config.FwCfg { + if !f.Valid() { + logger.Errorf("fw_cfg is not valid: %+v", config.FwCfg) + continue + } + + config.qemuParams = append(config.qemuParams, f.QemuParams(config)...) + } +} + // LaunchQemu can be used to launch a new qemu instance. // // The Config parameter contains a set of qemu parameters and settings. @@ -2584,6 +2685,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) { config.appendDevices() config.appendRTC() config.appendGlobalParam() + config.appendPFlashParam() config.appendVGA() config.appendKnobs() config.appendKernel() @@ -2592,6 +2694,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) { config.appendIncoming() config.appendPidFile() config.appendLogFile() + config.appendFwCfg(logger) if err := config.appendCPUs(); err != nil { return "", err diff --git a/vendor/github.com/intel/govmm/qemu/qmp.go b/vendor/github.com/intel/govmm/qemu/qmp.go index 5585a8792b..53ba105a8e 100644 --- a/vendor/github.com/intel/govmm/qemu/qmp.go +++ b/vendor/github.com/intel/govmm/qemu/qmp.go @@ -268,7 +268,7 @@ func (q *QMP) readLoop(fromVMCh chan<- []byte) { for scanner.Scan() { line := scanner.Bytes() if q.cfg.Logger.V(1) { - q.cfg.Logger.Infof("%s", string(line)) + q.cfg.Logger.Infof("read from QMP: %s", string(line)) } // Since []byte channel type transfer slice info(include slice underlying array pointer, len, cap) @@ -281,7 +281,7 @@ func (q *QMP) readLoop(fromVMCh chan<- []byte) { fromVMCh <- sendLine } - q.cfg.Logger.Infof("sanner return error: %v", scanner.Err()) + q.cfg.Logger.Infof("scanner return error: %v", scanner.Err()) close(fromVMCh) } @@ -1217,6 +1217,15 @@ func (q *QMP) ExecutePCIVFIOMediatedDeviceAdd(ctx context.Context, devID, sysfsd return q.executeCommand(ctx, "device_add", args, nil) } +// ExecuteAPVFIOMediatedDeviceAdd adds a VFIO mediated AP device to a QEMU instance using the device_add command. +func (q *QMP) ExecuteAPVFIOMediatedDeviceAdd(ctx context.Context, sysfsdev string) error { + args := map[string]interface{}{ + "driver": VfioAP, + "sysfsdev": sysfsdev, + } + return q.executeCommand(ctx, "device_add", args, nil) +} + // isSocketIDSupported returns if the cpu driver supports the socket id option func isSocketIDSupported(driver string) bool { if driver == "host-s390x-cpu" || driver == "host-powerpc64-cpu" { @@ -1630,3 +1639,29 @@ func (q *QMP) ExecQomSet(ctx context.Context, path, property string, value uint6 return q.executeCommand(ctx, "qom-set", args, nil) } + +// ExecQomGet qom-get path property +func (q *QMP) ExecQomGet(ctx context.Context, path, property string) (interface{}, error) { + args := map[string]interface{}{ + "path": path, + "property": property, + } + + response, err := q.executeCommandWithResponse(ctx, "qom-get", args, nil, nil) + if err != nil { + return "", err + } + + return response, nil +} + +// ExecuteDumpGuestMemory dump guest memory to host +func (q *QMP) ExecuteDumpGuestMemory(ctx context.Context, protocol string, paging bool, format string) error { + args := map[string]interface{}{ + "protocol": protocol, + "paging": paging, + "format": format, + } + + return q.executeCommand(ctx, "dump-guest-memory", args, nil) +}