Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2490 from jcvenegas/fix-2489
Browse files Browse the repository at this point in the history
clh: Fix version check
  • Loading branch information
GabyCT authored Feb 25, 2020
2 parents d9d4820 + 3345977 commit 18b21eb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions virtcontainers/clh.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const (
virtioFsSocket = "virtiofsd.sock"
clhSerial = "serial-tty.log"
supportedMajorVersion = 0
supportedMinorVersion = 3
supportedMinorVersion = 5
defaultClhPath = "/usr/local/bin/cloud-hypervisor"
virtioFsCacheAlways = "always"
maxClhVcpus = uint32(64)
Expand Down Expand Up @@ -677,6 +677,8 @@ func (clh *cloudHypervisor) getAvailableVersion() error {

}

// Remove 'v' prefix if has one
versionSplit[0] = strings.TrimLeft(versionSplit[0], "v")
major, err := strconv.ParseUint(versionSplit[0], 10, 64)
if err != nil {
return err
Expand All @@ -687,10 +689,15 @@ func (clh *cloudHypervisor) getAvailableVersion() error {
return err

}
revision, err := strconv.ParseUint(versionSplit[2], 10, 64)

// revision could have aditional commit information separated by '-'
revisionSplit := strings.SplitN(versionSplit[2], "-", -1)
if len(revisionSplit) < 1 {
return errors.Errorf("Failed parse cloud-hypervisor revision %s", versionSplit[2])
}
revision, err := strconv.ParseUint(revisionSplit[0], 10, 64)
if err != nil {
return err

}

clh.version = CloudHypervisorVersion{
Expand Down

0 comments on commit 18b21eb

Please sign in to comment.