Merge pull request #85 from markdryan/fix-travis

Fix travis
This commit is contained in:
Sebastien Boeuf 2019-01-28 08:02:40 -08:00 committed by GitHub
commit b9c8f76ebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 72 deletions

View File

@ -1,8 +1,8 @@
language: go language: go
go: go:
- 1.8 - "1.10"
- 1.9 - "1.11"
- tip - tip
go_import_path: github.com/intel/govmm go_import_path: github.com/intel/govmm

View File

@ -51,18 +51,18 @@ func CreateCloudInitISO(ctx context.Context, scratchDir, isoPath string,
err := os.MkdirAll(dataDirPath, 0750) err := os.MkdirAll(dataDirPath, 0750)
if err != nil { if err != nil {
return fmt.Errorf("Unable to create config drive directory %s : %v", return fmt.Errorf("unable to create config drive directory %s : %v",
dataDirPath, err) dataDirPath, err)
} }
err = ioutil.WriteFile(metaDataPath, metaData, 0644) err = ioutil.WriteFile(metaDataPath, metaData, 0644)
if err != nil { if err != nil {
return fmt.Errorf("Unable to create %s : %v", metaDataPath, err) return fmt.Errorf("unable to create %s : %v", metaDataPath, err)
} }
err = ioutil.WriteFile(userDataPath, userData, 0644) err = ioutil.WriteFile(userDataPath, userData, 0644)
if err != nil { if err != nil {
return fmt.Errorf("Unable to create %s : %v", userDataPath, err) return fmt.Errorf("unable to create %s : %v", userDataPath, err)
} }
cmd := exec.CommandContext(ctx, "xorriso", "-as", "mkisofs", "-R", "-V", "config-2", cmd := exec.CommandContext(ctx, "xorriso", "-as", "mkisofs", "-R", "-V", "config-2",
@ -70,7 +70,7 @@ func CreateCloudInitISO(ctx context.Context, scratchDir, isoPath string,
cmd.SysProcAttr = attr cmd.SysProcAttr = attr
err = cmd.Run() err = cmd.Run()
if err != nil { if err != nil {
return fmt.Errorf("Unable to create cloudinit iso image %v", err) return fmt.Errorf("unable to create cloudinit iso image %v", err)
} }
return nil return nil

View File

@ -260,7 +260,7 @@ func (fsdev FSDevice) QemuParams(config *Config) []string {
var deviceParams []string var deviceParams []string
var qemuParams []string var qemuParams []string
deviceParams = append(deviceParams, fmt.Sprintf("%s", fsdev.Driver)) deviceParams = append(deviceParams, string(fsdev.Driver))
if s := fsdev.Driver.disableModern(fsdev.DisableModern); s != "" { if s := fsdev.Driver.disableModern(fsdev.DisableModern); s != "" {
deviceParams = append(deviceParams, fmt.Sprintf(",%s", s)) deviceParams = append(deviceParams, fmt.Sprintf(",%s", s))
} }
@ -346,7 +346,7 @@ func (cdev CharDevice) QemuParams(config *Config) []string {
var deviceParams []string var deviceParams []string
var qemuParams []string var qemuParams []string
deviceParams = append(deviceParams, fmt.Sprintf("%s", cdev.Driver)) deviceParams = append(deviceParams, string(cdev.Driver))
if s := cdev.Driver.disableModern(cdev.DisableModern); s != "" { if s := cdev.Driver.disableModern(cdev.DisableModern); s != "" {
deviceParams = append(deviceParams, fmt.Sprintf(",%s", s)) deviceParams = append(deviceParams, fmt.Sprintf(",%s", s))
} }
@ -534,7 +534,7 @@ func (netdev NetDevice) QemuNetdevParams(config *Config) []string {
netdevParams = append(netdevParams, netdev.Type.QemuNetdevParam()) netdevParams = append(netdevParams, netdev.Type.QemuNetdevParam())
netdevParams = append(netdevParams, fmt.Sprintf(",id=%s", netdev.ID)) netdevParams = append(netdevParams, fmt.Sprintf(",id=%s", netdev.ID))
if netdev.VHost == true { if netdev.VHost {
netdevParams = append(netdevParams, ",vhost=on") netdevParams = append(netdevParams, ",vhost=on")
if len(netdev.VhostFDs) > 0 { if len(netdev.VhostFDs) > 0 {
var fdParams []string var fdParams []string
@ -627,7 +627,7 @@ func (dev SerialDevice) QemuParams(config *Config) []string {
var deviceParams []string var deviceParams []string
var qemuParams []string var qemuParams []string
deviceParams = append(deviceParams, fmt.Sprintf("%s", dev.Driver)) deviceParams = append(deviceParams, string(dev.Driver))
if s := dev.Driver.disableModern(dev.DisableModern); s != "" { if s := dev.Driver.disableModern(dev.DisableModern); s != "" {
deviceParams = append(deviceParams, fmt.Sprintf(",%s", s)) deviceParams = append(deviceParams, fmt.Sprintf(",%s", s))
} }
@ -705,16 +705,16 @@ func (blkdev BlockDevice) QemuParams(config *Config) []string {
var deviceParams []string var deviceParams []string
var qemuParams []string var qemuParams []string
deviceParams = append(deviceParams, fmt.Sprintf("%s", blkdev.Driver)) deviceParams = append(deviceParams, string(blkdev.Driver))
if s := blkdev.Driver.disableModern(blkdev.DisableModern); s != "" { if s := blkdev.Driver.disableModern(blkdev.DisableModern); s != "" {
deviceParams = append(deviceParams, fmt.Sprintf(",%s", s)) deviceParams = append(deviceParams, fmt.Sprintf(",%s", s))
} }
deviceParams = append(deviceParams, fmt.Sprintf(",drive=%s", blkdev.ID)) deviceParams = append(deviceParams, fmt.Sprintf(",drive=%s", blkdev.ID))
if blkdev.SCSI == false { if !blkdev.SCSI {
deviceParams = append(deviceParams, ",scsi=off") deviceParams = append(deviceParams, ",scsi=off")
} }
if blkdev.WCE == false { if !blkdev.WCE {
deviceParams = append(deviceParams, ",config-wce=off") deviceParams = append(deviceParams, ",config-wce=off")
} }
@ -842,11 +842,7 @@ type VFIODevice struct {
// Valid returns true if the VFIODevice structure is valid and complete. // Valid returns true if the VFIODevice structure is valid and complete.
func (vfioDev VFIODevice) Valid() bool { func (vfioDev VFIODevice) Valid() bool {
if vfioDev.BDF == "" { return vfioDev.BDF != ""
return false
}
return true
} }
// QemuParams returns the qemu parameters built out of this vfio device. // QemuParams returns the qemu parameters built out of this vfio device.
@ -889,11 +885,7 @@ type SCSIController struct {
// Valid returns true if the SCSIController structure is valid and complete. // Valid returns true if the SCSIController structure is valid and complete.
func (scsiCon SCSIController) Valid() bool { func (scsiCon SCSIController) Valid() bool {
if scsiCon.ID == "" { return scsiCon.ID != ""
return false
}
return true
} }
// QemuParams returns the qemu parameters built out of this SCSIController device. // QemuParams returns the qemu parameters built out of this SCSIController device.
@ -910,7 +902,7 @@ func (scsiCon SCSIController) QemuParams(config *Config) []string {
devParams = append(devParams, fmt.Sprintf("addr=%s", scsiCon.Addr)) devParams = append(devParams, fmt.Sprintf("addr=%s", scsiCon.Addr))
} }
if s := driver.disableModern(scsiCon.DisableModern); s != "" { if s := driver.disableModern(scsiCon.DisableModern); s != "" {
devParams = append(devParams, fmt.Sprintf("%s", s)) devParams = append(devParams, s)
} }
if scsiCon.IOThread != "" { if scsiCon.IOThread != "" {
devParams = append(devParams, fmt.Sprintf("iothread=%s", scsiCon.IOThread)) devParams = append(devParams, fmt.Sprintf("iothread=%s", scsiCon.IOThread))
@ -1057,7 +1049,7 @@ func (vsock VSOCKDevice) QemuParams(config *Config) []string {
var qemuParams []string var qemuParams []string
driver := VHostVSock driver := VHostVSock
deviceParams = append(deviceParams, fmt.Sprintf("%s", driver)) deviceParams = append(deviceParams, string(driver))
if s := driver.disableModern(vsock.DisableModern); s != "" { if s := driver.disableModern(vsock.DisableModern); s != "" {
deviceParams = append(deviceParams, fmt.Sprintf(",%s", s)) deviceParams = append(deviceParams, fmt.Sprintf(",%s", s))
} }
@ -1094,11 +1086,7 @@ type RngDevice struct {
// Valid returns true if the RngDevice structure is valid and complete. // Valid returns true if the RngDevice structure is valid and complete.
func (v RngDevice) Valid() bool { func (v RngDevice) Valid() bool {
if v.ID == "" { return v.ID != ""
return false
}
return true
} }
// QemuParams returns the qemu parameters built out of the RngDevice. // QemuParams returns the qemu parameters built out of the RngDevice.
@ -1174,7 +1162,7 @@ func (b BalloonDevice) QemuParams(_ *Config) []string {
deviceParams = append(deviceParams, "deflate-on-oom=off") deviceParams = append(deviceParams, "deflate-on-oom=off")
} }
if s := driver.disableModern(b.DisableModern); s != "" { if s := driver.disableModern(b.DisableModern); s != "" {
deviceParams = append(deviceParams, fmt.Sprintf("%s", s)) deviceParams = append(deviceParams, string(s))
} }
qemuParams = append(qemuParams, "-device") qemuParams = append(qemuParams, "-device")
qemuParams = append(qemuParams, strings.Join(deviceParams, ",")) qemuParams = append(qemuParams, strings.Join(deviceParams, ","))
@ -1184,11 +1172,7 @@ func (b BalloonDevice) QemuParams(_ *Config) []string {
// Valid returns true if the balloonDevice structure is valid and complete. // Valid returns true if the balloonDevice structure is valid and complete.
func (b BalloonDevice) Valid() bool { func (b BalloonDevice) Valid() bool {
if b.ID == "" { return b.ID != ""
return false
}
return true
} }
// RTCBaseType is the qemu RTC base time type. // RTCBaseType is the qemu RTC base time type.
@ -1523,15 +1507,15 @@ func (config *Config) appendCPUModel() {
func (config *Config) appendQMPSockets() { func (config *Config) appendQMPSockets() {
for _, q := range config.QMPSockets { for _, q := range config.QMPSockets {
if q.Valid() == false { if !q.Valid() {
continue continue
} }
qmpParams := append([]string{}, fmt.Sprintf("%s:", q.Type)) qmpParams := append([]string{}, fmt.Sprintf("%s:", q.Type))
qmpParams = append(qmpParams, fmt.Sprintf("%s", q.Name)) qmpParams = append(qmpParams, q.Name)
if q.Server == true { if q.Server {
qmpParams = append(qmpParams, ",server") qmpParams = append(qmpParams, ",server")
if q.NoWait == true { if q.NoWait {
qmpParams = append(qmpParams, ",nowait") qmpParams = append(qmpParams, ",nowait")
} }
} }
@ -1543,7 +1527,7 @@ func (config *Config) appendQMPSockets() {
func (config *Config) appendDevices() { func (config *Config) appendDevices() {
for _, d := range config.Devices { for _, d := range config.Devices {
if d.Valid() == false { if !d.Valid() {
continue continue
} }
@ -1611,7 +1595,7 @@ func (config *Config) appendCPUs() error {
} }
func (config *Config) appendRTC() { func (config *Config) appendRTC() {
if config.RTC.Valid() == false { if !config.RTC.Valid() {
return return
} }
@ -1663,7 +1647,7 @@ func (config *Config) appendKernel() {
} }
func (config *Config) appendMemoryKnobs() { func (config *Config) appendMemoryKnobs() {
if config.Knobs.HugePages == true { if config.Knobs.HugePages {
if config.Memory.Size != "" { if config.Memory.Size != "" {
dimmName := "dimm1" dimmName := "dimm1"
objMemParam := "memory-backend-file,id=" + dimmName + ",size=" + config.Memory.Size + ",mem-path=/dev/hugepages,share=on,prealloc=on" objMemParam := "memory-backend-file,id=" + dimmName + ",size=" + config.Memory.Size + ",mem-path=/dev/hugepages,share=on,prealloc=on"
@ -1675,7 +1659,7 @@ func (config *Config) appendMemoryKnobs() {
config.qemuParams = append(config.qemuParams, "-numa") config.qemuParams = append(config.qemuParams, "-numa")
config.qemuParams = append(config.qemuParams, numaMemParam) config.qemuParams = append(config.qemuParams, numaMemParam)
} }
} else if config.Knobs.MemPrealloc == true { } else if config.Knobs.MemPrealloc {
if config.Memory.Size != "" { if config.Memory.Size != "" {
dimmName := "dimm1" dimmName := "dimm1"
objMemParam := "memory-backend-ram,id=" + dimmName + ",size=" + config.Memory.Size + ",prealloc=on" objMemParam := "memory-backend-ram,id=" + dimmName + ",size=" + config.Memory.Size + ",prealloc=on"
@ -1687,11 +1671,11 @@ func (config *Config) appendMemoryKnobs() {
config.qemuParams = append(config.qemuParams, "-numa") config.qemuParams = append(config.qemuParams, "-numa")
config.qemuParams = append(config.qemuParams, numaMemParam) config.qemuParams = append(config.qemuParams, numaMemParam)
} }
} else if config.Knobs.FileBackedMem == true { } else if config.Knobs.FileBackedMem {
if config.Memory.Size != "" && config.Memory.Path != "" { if config.Memory.Size != "" && config.Memory.Path != "" {
dimmName := "dimm1" dimmName := "dimm1"
objMemParam := "memory-backend-file,id=" + dimmName + ",size=" + config.Memory.Size + ",mem-path=" + config.Memory.Path objMemParam := "memory-backend-file,id=" + dimmName + ",size=" + config.Memory.Size + ",mem-path=" + config.Memory.Path
if config.Knobs.FileBackedMemShared == true { if config.Knobs.FileBackedMemShared {
objMemParam += ",share=on" objMemParam += ",share=on"
} }
numaMemParam := "node,memdev=" + dimmName numaMemParam := "node,memdev=" + dimmName
@ -1706,45 +1690,45 @@ func (config *Config) appendMemoryKnobs() {
} }
func (config *Config) appendKnobs() { func (config *Config) appendKnobs() {
if config.Knobs.NoUserConfig == true { if config.Knobs.NoUserConfig {
config.qemuParams = append(config.qemuParams, "-no-user-config") config.qemuParams = append(config.qemuParams, "-no-user-config")
} }
if config.Knobs.NoDefaults == true { if config.Knobs.NoDefaults {
config.qemuParams = append(config.qemuParams, "-nodefaults") config.qemuParams = append(config.qemuParams, "-nodefaults")
} }
if config.Knobs.NoGraphic == true { if config.Knobs.NoGraphic {
config.qemuParams = append(config.qemuParams, "-nographic") config.qemuParams = append(config.qemuParams, "-nographic")
} }
if config.Knobs.Daemonize == true { if config.Knobs.Daemonize {
config.qemuParams = append(config.qemuParams, "-daemonize") config.qemuParams = append(config.qemuParams, "-daemonize")
} }
config.appendMemoryKnobs() config.appendMemoryKnobs()
if config.Knobs.Realtime == true { if config.Knobs.Realtime {
config.qemuParams = append(config.qemuParams, "-realtime") config.qemuParams = append(config.qemuParams, "-realtime")
// This path is redundant as the default behaviour is locked memory // This path is redundant as the default behaviour is locked memory
// Realtime today does not control any other feature even though // Realtime today does not control any other feature even though
// other features may be added in the future // other features may be added in the future
// https://lists.gnu.org/archive/html/qemu-devel/2012-12/msg03330.html // https://lists.gnu.org/archive/html/qemu-devel/2012-12/msg03330.html
if config.Knobs.Mlock == true { if config.Knobs.Mlock {
config.qemuParams = append(config.qemuParams, "mlock=on") config.qemuParams = append(config.qemuParams, "mlock=on")
} else { } else {
config.qemuParams = append(config.qemuParams, "mlock=off") config.qemuParams = append(config.qemuParams, "mlock=off")
} }
} else { } else {
// In order to turn mlock off we need the -realtime option as well // In order to turn mlock off we need the -realtime option as well
if config.Knobs.Mlock == false { if !config.Knobs.Mlock {
//Enable realtime anyway just to get the right swapping behaviour //Enable realtime anyway just to get the right swapping behaviour
config.qemuParams = append(config.qemuParams, "-realtime") config.qemuParams = append(config.qemuParams, "-realtime")
config.qemuParams = append(config.qemuParams, "mlock=off") config.qemuParams = append(config.qemuParams, "mlock=off")
} }
} }
if config.Knobs.Stopped == true { if config.Knobs.Stopped {
config.qemuParams = append(config.qemuParams, "-S") config.qemuParams = append(config.qemuParams, "-S")
} }
} }

View File

@ -30,8 +30,6 @@ const volumeUUID = "67d86208-b46c-4465-9018-e14187d4010"
func testAppend(structure interface{}, expected string, t *testing.T) { func testAppend(structure interface{}, expected string, t *testing.T) {
var config Config var config Config
testConfigAppend(&config, structure, expected, t) testConfigAppend(&config, structure, expected, t)
return
} }
func testConfigAppend(config *Config, structure interface{}, expected string, t *testing.T) { func testConfigAppend(config *Config, structure interface{}, expected string, t *testing.T) {

View File

@ -329,14 +329,14 @@ func (q *QMP) errorDesc(errorData interface{}) (string, error) {
// convert error to json // convert error to json
data, err := json.Marshal(errorData) data, err := json.Marshal(errorData)
if err != nil { if err != nil {
return "", fmt.Errorf("Unable to extract error information: %v", err) return "", fmt.Errorf("unable to extract error information: %v", err)
} }
// see: https://github.com/qemu/qemu/blob/stable-2.12/qapi/qmp-dispatch.c#L125 // see: https://github.com/qemu/qemu/blob/stable-2.12/qapi/qmp-dispatch.c#L125
var qmpErr map[string]string var qmpErr map[string]string
// convert json to qmpError // convert json to qmpError
if err = json.Unmarshal(data, &qmpErr); err != nil { if err = json.Unmarshal(data, &qmpErr); err != nil {
return "", fmt.Errorf("Unable to convert json to qmpError: %v", err) return "", fmt.Errorf("unable to convert json to qmpError: %v", err)
} }
return qmpErr["desc"], nil return qmpErr["desc"], nil
@ -404,7 +404,7 @@ func (q *QMP) writeNextQMPCommand(cmdQueue *list.List) {
encodedCmd, err := json.Marshal(&cmdData) encodedCmd, err := json.Marshal(&cmdData)
if err != nil { if err != nil {
cmd.res <- qmpResult{ cmd.res <- qmpResult{
err: fmt.Errorf("Unable to marhsall command %s: %v", err: fmt.Errorf("unable to marhsall command %s: %v",
cmd.name, err), cmd.name, err),
} }
cmdQueue.Remove(cmdEl) cmdQueue.Remove(cmdEl)
@ -419,7 +419,7 @@ func (q *QMP) writeNextQMPCommand(cmdQueue *list.List) {
if err != nil { if err != nil {
cmd.res <- qmpResult{ cmd.res <- qmpResult{
err: fmt.Errorf("Unable to write command to qmp socket %v", err), err: fmt.Errorf("unable to write command to qmp socket %v", err),
} }
cmdQueue.Remove(cmdEl) cmdQueue.Remove(cmdEl)
} }
@ -525,7 +525,7 @@ func (q *QMP) mainLoop() {
} }
/* #nosec */ /* #nosec */
_ = q.conn.Close() _ = q.conn.Close()
_ = <-fromVMCh <-fromVMCh
failOutstandingCommands(cmdQueue) failOutstandingCommands(cmdQueue)
close(q.disconnectedCh) close(q.disconnectedCh)
}() }()
@ -689,12 +689,12 @@ func QMPStart(ctx context.Context, socket string, cfg QMPConfig, disconnectedCh
case <-ctx.Done(): case <-ctx.Done():
q.Shutdown() q.Shutdown()
<-disconnectedCh <-disconnectedCh
return nil, nil, fmt.Errorf("Canceled by caller") return nil, nil, fmt.Errorf("canceled by caller")
case <-disconnectedCh: case <-disconnectedCh:
return nil, nil, fmt.Errorf("Lost connection to VM") return nil, nil, fmt.Errorf("lost connection to VM")
case q.version = <-connectedCh: case q.version = <-connectedCh:
if q.version == nil { if q.version == nil {
return nil, nil, fmt.Errorf("Failed to find QMP version information") return nil, nil, fmt.Errorf("failed to find QMP version information")
} }
} }
@ -860,7 +860,7 @@ func (q *QMP) ExecuteSCSIDeviceAdd(ctx context.Context, blockdevID, devID, drive
} }
if !isSCSIDriver { if !isSCSIDriver {
return fmt.Errorf("Invalid SCSI driver provided %s", driver) return fmt.Errorf("invalid SCSI driver provided %s", driver)
} }
args := map[string]interface{}{ args := map[string]interface{}{
@ -1171,13 +1171,13 @@ func (q *QMP) ExecuteQueryHotpluggableCPUs(ctx context.Context) ([]HotpluggableC
// convert response to json // convert response to json
data, err := json.Marshal(response) data, err := json.Marshal(response)
if err != nil { if err != nil {
return nil, fmt.Errorf("Unable to extract CPU information: %v", err) return nil, fmt.Errorf("unable to extract CPU information: %v", err)
} }
var cpus []HotpluggableCPU var cpus []HotpluggableCPU
// convert json to []HotpluggableCPU // convert json to []HotpluggableCPU
if err = json.Unmarshal(data, &cpus); err != nil { if err = json.Unmarshal(data, &cpus); err != nil {
return nil, fmt.Errorf("Unable to convert json to hotpluggable CPU: %v", err) return nil, fmt.Errorf("unable to convert json to hotpluggable CPU: %v", err)
} }
return cpus, nil return cpus, nil
@ -1211,7 +1211,7 @@ func (q *QMP) ExecQueryMemoryDevices(ctx context.Context) ([]MemoryDevices, erro
// convert response to json // convert response to json
data, err := json.Marshal(response) data, err := json.Marshal(response)
if err != nil { if err != nil {
return nil, fmt.Errorf("Unable to extract memory devices information: %v", err) return nil, fmt.Errorf("unable to extract memory devices information: %v", err)
} }
var memoryDevices []MemoryDevices var memoryDevices []MemoryDevices
@ -1235,7 +1235,7 @@ func (q *QMP) ExecQueryCpus(ctx context.Context) ([]CPUInfo, error) {
// convert response to json // convert response to json
data, err := json.Marshal(response) data, err := json.Marshal(response)
if err != nil { if err != nil {
return nil, fmt.Errorf("Unable to extract memory devices information: %v", err) return nil, fmt.Errorf("unable to extract memory devices information: %v", err)
} }
var cpuInfo []CPUInfo var cpuInfo []CPUInfo
@ -1259,7 +1259,7 @@ func (q *QMP) ExecQueryCpusFast(ctx context.Context) ([]CPUInfoFast, error) {
// convert response to json // convert response to json
data, err := json.Marshal(response) data, err := json.Marshal(response)
if err != nil { if err != nil {
return nil, fmt.Errorf("Unable to extract memory devices information: %v", err) return nil, fmt.Errorf("unable to extract memory devices information: %v", err)
} }
var cpuInfoFast []CPUInfoFast var cpuInfoFast []CPUInfoFast
@ -1434,12 +1434,12 @@ func (q *QMP) ExecuteQueryMigration(ctx context.Context) (MigrationStatus, error
data, err := json.Marshal(response) data, err := json.Marshal(response)
if err != nil { if err != nil {
return MigrationStatus{}, fmt.Errorf("Unable to extract migrate status information: %v", err) return MigrationStatus{}, fmt.Errorf("unable to extract migrate status information: %v", err)
} }
var status MigrationStatus var status MigrationStatus
if err = json.Unmarshal(data, &status); err != nil { if err = json.Unmarshal(data, &status); err != nil {
return MigrationStatus{}, fmt.Errorf("Unable to convert migrate status information: %v", err) return MigrationStatus{}, fmt.Errorf("unable to convert migrate status information: %v", err)
} }
return status, nil return status, nil