vendor: Update govmm vendoring

Shortlog:

ef72505 qemu: Fix the support of PCIe bridge
56f645e qmp: add ExecuteQueryMigration
a429677 govmm: fix memory prealloc
1130aab qmp: add "query-cpus" support

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2018-10-02 17:09:03 -07:00
parent c061fe1ff5
commit 0de7572f7b
4 changed files with 147 additions and 16 deletions

View File

@@ -144,7 +144,7 @@ type QMPVersion struct {
Capabilities []string
}
// CPUProperties contains the properties to be used for hotplugging a CPU instance
// CPUProperties contains the properties of a CPU instance
type CPUProperties struct {
Node int `json:"node-id"`
Socket int `json:"socket-id"`
@@ -178,6 +178,68 @@ type MemoryDevices struct {
Type string `json:"type"`
}
// CPUInfo represents information about each virtual CPU
type CPUInfo struct {
CPU int `json:"CPU"`
Current bool `json:"current"`
Halted bool `json:"halted"`
QomPath string `json:"qom_path"`
Arch string `json:"arch"`
Pc int `json:"pc"`
ThreadID int `json:"thread_id"`
Props CPUProperties `json:"props"`
}
// CPUInfoFast represents information about each virtual CPU
type CPUInfoFast struct {
CPUIndex int `json:"cpu-index"`
QomPath string `json:"qom-path"`
Arch string `json:"arch"`
ThreadID int `json:"thread-id"`
Target string `json:"target"`
Props CPUProperties `json:"props"`
}
// MigrationRAM represents migration ram status
type MigrationRAM struct {
Total int64 `json:"total"`
Remaining int64 `json:"remaining"`
Transferred int64 `json:"transferred"`
TotalTime int64 `json:"total-time"`
SetupTime int64 `json:"setup-time"`
ExpectedDowntime int64 `json:"expected-downtime"`
Duplicate int64 `json:"duplicate"`
Normal int64 `json:"normal"`
NormalBytes int64 `json:"normal-bytes"`
DirtySyncCount int64 `json:"dirty-sync-count"`
}
// MigrationDisk represents migration disk status
type MigrationDisk struct {
Total int64 `json:"total"`
Remaining int64 `json:"remaining"`
Transferred int64 `json:"transferred"`
}
// MigrationXbzrleCache represents migration XbzrleCache status
type MigrationXbzrleCache struct {
CacheSize int64 `json:"cache-size"`
Bytes int64 `json:"bytes"`
Pages int64 `json:"pages"`
CacheMiss int64 `json:"cache-miss"`
CacheMissRate int64 `json:"cache-miss-rate"`
Overflow int64 `json:"overflow"`
}
// MigrationStatus represents migration status of a vm
type MigrationStatus struct {
Status string `json:"status"`
Capabilities []map[string]interface{} `json:"capabilities,omitempty"`
RAM MigrationRAM `json:"ram,omitempty"`
Disk MigrationDisk `json:"disk,omitempty"`
XbzrleCache MigrationXbzrleCache `json:"xbzrle-cache,omitempty"`
}
func (q *QMP) readLoop(fromVMCh chan<- []byte) {
scanner := bufio.NewScanner(q.conn)
for scanner.Scan() {
@@ -1033,6 +1095,54 @@ func (q *QMP) ExecQueryMemoryDevices(ctx context.Context) ([]MemoryDevices, erro
return memoryDevices, nil
}
// ExecQueryCpus returns a slice with the list of `CpuInfo`
// Since qemu 2.12, we have `query-cpus-fast` as a better choice in production
// we can still choose `ExecQueryCpus` for compatibility though not recommended.
func (q *QMP) ExecQueryCpus(ctx context.Context) ([]CPUInfo, error) {
response, err := q.executeCommandWithResponse(ctx, "query-cpus", nil, nil, nil)
if err != nil {
return nil, err
}
// convert response to json
data, err := json.Marshal(response)
if err != nil {
return nil, fmt.Errorf("Unable to extract memory devices information: %v", err)
}
var cpuInfo []CPUInfo
// convert json to []CPUInfo
if err = json.Unmarshal(data, &cpuInfo); err != nil {
return nil, fmt.Errorf("unable to convert json to CPUInfo: %v", err)
}
return cpuInfo, nil
}
// ExecQueryCpusFast returns a slice with the list of `CpuInfoFast`
// This is introduced since 2.12, it does not incur a performance penalty and
// should be used in production instead of query-cpus.
func (q *QMP) ExecQueryCpusFast(ctx context.Context) ([]CPUInfoFast, error) {
response, err := q.executeCommandWithResponse(ctx, "query-cpus-fast", nil, nil, nil)
if err != nil {
return nil, err
}
// convert response to json
data, err := json.Marshal(response)
if err != nil {
return nil, fmt.Errorf("Unable to extract memory devices information: %v", err)
}
var cpuInfoFast []CPUInfoFast
// convert json to []CPUInfoFast
if err = json.Unmarshal(data, &cpuInfoFast); err != nil {
return nil, fmt.Errorf("unable to convert json to CPUInfoFast: %v", err)
}
return cpuInfoFast, nil
}
// ExecHotplugMemory adds size of MiB memory to the guest
func (q *QMP) ExecHotplugMemory(ctx context.Context, qomtype, id, mempath string, size int) error {
args := map[string]interface{}{
@@ -1136,3 +1246,23 @@ func (q *QMP) ExecuteVirtSerialPortAdd(ctx context.Context, id, name, chardev st
return q.executeCommand(ctx, "device_add", args, nil)
}
// ExecuteQueryMigration queries migration progress.
func (q *QMP) ExecuteQueryMigration(ctx context.Context) (MigrationStatus, error) {
response, err := q.executeCommandWithResponse(ctx, "query-migrate", nil, nil, nil)
if err != nil {
return MigrationStatus{}, err
}
data, err := json.Marshal(response)
if err != nil {
return MigrationStatus{}, fmt.Errorf("Unable to extract migrate status information: %v", err)
}
var status MigrationStatus
if err = json.Unmarshal(data, &status); err != nil {
return MigrationStatus{}, fmt.Errorf("Unable to convert migrate status information: %v", err)
}
return status, nil
}