mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 08:47:56 +00:00
vendor: update github.com/intel/govmm
update to commit 52b2309a55
Fixes: #1894
Signed-off-by: Ace-Tang <aceapril@126.com>
This commit is contained in:
parent
d987a30367
commit
2cf4189244
22
Gopkg.lock
generated
22
Gopkg.lock
generated
@ -65,6 +65,14 @@
|
||||
revision = "ccb8e960c48f04d6935e72476ae4a51028f9e22f"
|
||||
version = "v9"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:45c41cd27a8d986998680bfc86da0bbff5fa4f90d0f446c00636c8b099028ffe"
|
||||
name = "github.com/blang/semver"
|
||||
packages = ["."]
|
||||
pruneopts = "NUT"
|
||||
revision = "ba2c2ddd89069b46a7011d4106f6868f17ee1705"
|
||||
version = "v3.6.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:8ecb89af7dfe3ac401bdb0c9390b134ef96a97e85f732d2b0604fb7b3977839f"
|
||||
@ -359,14 +367,18 @@
|
||||
revision = "8e809c8a86450a29b90dcc9efbf062d0fe6d9746"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:f0d9d74edbd40fdeada436d5ac9cb5197407899af3fef85ff0137077ffe8ae19"
|
||||
name = "github.com/hashicorp/errwrap"
|
||||
packages = ["."]
|
||||
pruneopts = "NUT"
|
||||
revision = "8a6fb523712970c966eefc6b39ed2c5e74880354"
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:2ed138049ab373f696db2081ca48f15c5abdf20893803612a284f2bdce2bf443"
|
||||
name = "github.com/hashicorp/go-multierror"
|
||||
packages = ["."]
|
||||
pruneopts = "NUT"
|
||||
revision = "886a7fbe3eb1c874d46f623bfa70af45f425b3d1"
|
||||
version = "v1.0.0"
|
||||
|
||||
@ -379,11 +391,11 @@
|
||||
revision = "2f1d1f20f75d5404f53b9edf6b53ed5505508675"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:8e8b93094815f3bbc3792eaf78ce5cf45e0376b8ba0c92f3d58714d7a34f5d0b"
|
||||
digest = "1:6b643bd5e349019c33430301a3e5c38324c3014c423fe5e7cf857a8dd341efe2"
|
||||
name = "github.com/intel/govmm"
|
||||
packages = ["qemu"]
|
||||
pruneopts = "NUT"
|
||||
revision = "9f389cb319af066f210b28dc8846d679878fe9f2"
|
||||
revision = "52b2309a558fe89b3e81b85440144b535288ce4f"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:36dfd4701e98a9d8371dd3053e32d4f29e82b07bcc9e655db82138f9273bcb0f"
|
||||
@ -685,6 +697,7 @@
|
||||
analyzer-version = 1
|
||||
input-imports = [
|
||||
"github.com/BurntSushi/toml",
|
||||
"github.com/blang/semver",
|
||||
"github.com/containerd/cgroups",
|
||||
"github.com/containerd/containerd/api/events",
|
||||
"github.com/containerd/containerd/api/types",
|
||||
@ -706,10 +719,15 @@
|
||||
"github.com/dlespiau/covertool/pkg/cover",
|
||||
"github.com/docker/go-units",
|
||||
"github.com/go-ini/ini",
|
||||
"github.com/go-openapi/errors",
|
||||
"github.com/go-openapi/runtime",
|
||||
"github.com/go-openapi/runtime/client",
|
||||
"github.com/go-openapi/strfmt",
|
||||
"github.com/go-openapi/swag",
|
||||
"github.com/go-openapi/validate",
|
||||
"github.com/gogo/protobuf/proto",
|
||||
"github.com/gogo/protobuf/types",
|
||||
"github.com/hashicorp/go-multierror",
|
||||
"github.com/intel/govmm/qemu",
|
||||
"github.com/kata-containers/agent/pkg/types",
|
||||
"github.com/kata-containers/agent/protocols/client",
|
||||
|
@ -48,7 +48,7 @@
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/intel/govmm"
|
||||
revision = "9f389cb319af066f210b28dc8846d679878fe9f2"
|
||||
revision = "52b2309a558fe89b3e81b85440144b535288ce4f"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/kata-containers/agent"
|
||||
|
22
vendor/github.com/blang/semver/LICENSE
generated
vendored
Normal file
22
vendor/github.com/blang/semver/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2014 Benedikt Lang <github at benediktlang.de>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
23
vendor/github.com/blang/semver/json.go
generated
vendored
Normal file
23
vendor/github.com/blang/semver/json.go
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
package semver
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// MarshalJSON implements the encoding/json.Marshaler interface.
|
||||
func (v Version) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.String())
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the encoding/json.Unmarshaler interface.
|
||||
func (v *Version) UnmarshalJSON(data []byte) (err error) {
|
||||
var versionString string
|
||||
|
||||
if err = json.Unmarshal(data, &versionString); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
*v, err = Parse(versionString)
|
||||
|
||||
return
|
||||
}
|
416
vendor/github.com/blang/semver/range.go
generated
vendored
Normal file
416
vendor/github.com/blang/semver/range.go
generated
vendored
Normal file
@ -0,0 +1,416 @@
|
||||
package semver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
type wildcardType int
|
||||
|
||||
const (
|
||||
noneWildcard wildcardType = iota
|
||||
majorWildcard wildcardType = 1
|
||||
minorWildcard wildcardType = 2
|
||||
patchWildcard wildcardType = 3
|
||||
)
|
||||
|
||||
func wildcardTypefromInt(i int) wildcardType {
|
||||
switch i {
|
||||
case 1:
|
||||
return majorWildcard
|
||||
case 2:
|
||||
return minorWildcard
|
||||
case 3:
|
||||
return patchWildcard
|
||||
default:
|
||||
return noneWildcard
|
||||
}
|
||||
}
|
||||
|
||||
type comparator func(Version, Version) bool
|
||||
|
||||
var (
|
||||
compEQ comparator = func(v1 Version, v2 Version) bool {
|
||||
return v1.Compare(v2) == 0
|
||||
}
|
||||
compNE = func(v1 Version, v2 Version) bool {
|
||||
return v1.Compare(v2) != 0
|
||||
}
|
||||
compGT = func(v1 Version, v2 Version) bool {
|
||||
return v1.Compare(v2) == 1
|
||||
}
|
||||
compGE = func(v1 Version, v2 Version) bool {
|
||||
return v1.Compare(v2) >= 0
|
||||
}
|
||||
compLT = func(v1 Version, v2 Version) bool {
|
||||
return v1.Compare(v2) == -1
|
||||
}
|
||||
compLE = func(v1 Version, v2 Version) bool {
|
||||
return v1.Compare(v2) <= 0
|
||||
}
|
||||
)
|
||||
|
||||
type versionRange struct {
|
||||
v Version
|
||||
c comparator
|
||||
}
|
||||
|
||||
// rangeFunc creates a Range from the given versionRange.
|
||||
func (vr *versionRange) rangeFunc() Range {
|
||||
return Range(func(v Version) bool {
|
||||
return vr.c(v, vr.v)
|
||||
})
|
||||
}
|
||||
|
||||
// Range represents a range of versions.
|
||||
// A Range can be used to check if a Version satisfies it:
|
||||
//
|
||||
// range, err := semver.ParseRange(">1.0.0 <2.0.0")
|
||||
// range(semver.MustParse("1.1.1") // returns true
|
||||
type Range func(Version) bool
|
||||
|
||||
// OR combines the existing Range with another Range using logical OR.
|
||||
func (rf Range) OR(f Range) Range {
|
||||
return Range(func(v Version) bool {
|
||||
return rf(v) || f(v)
|
||||
})
|
||||
}
|
||||
|
||||
// AND combines the existing Range with another Range using logical AND.
|
||||
func (rf Range) AND(f Range) Range {
|
||||
return Range(func(v Version) bool {
|
||||
return rf(v) && f(v)
|
||||
})
|
||||
}
|
||||
|
||||
// ParseRange parses a range and returns a Range.
|
||||
// If the range could not be parsed an error is returned.
|
||||
//
|
||||
// Valid ranges are:
|
||||
// - "<1.0.0"
|
||||
// - "<=1.0.0"
|
||||
// - ">1.0.0"
|
||||
// - ">=1.0.0"
|
||||
// - "1.0.0", "=1.0.0", "==1.0.0"
|
||||
// - "!1.0.0", "!=1.0.0"
|
||||
//
|
||||
// A Range can consist of multiple ranges separated by space:
|
||||
// Ranges can be linked by logical AND:
|
||||
// - ">1.0.0 <2.0.0" would match between both ranges, so "1.1.1" and "1.8.7" but not "1.0.0" or "2.0.0"
|
||||
// - ">1.0.0 <3.0.0 !2.0.3-beta.2" would match every version between 1.0.0 and 3.0.0 except 2.0.3-beta.2
|
||||
//
|
||||
// Ranges can also be linked by logical OR:
|
||||
// - "<2.0.0 || >=3.0.0" would match "1.x.x" and "3.x.x" but not "2.x.x"
|
||||
//
|
||||
// AND has a higher precedence than OR. It's not possible to use brackets.
|
||||
//
|
||||
// Ranges can be combined by both AND and OR
|
||||
//
|
||||
// - `>1.0.0 <2.0.0 || >3.0.0 !4.2.1` would match `1.2.3`, `1.9.9`, `3.1.1`, but not `4.2.1`, `2.1.1`
|
||||
func ParseRange(s string) (Range, error) {
|
||||
parts := splitAndTrim(s)
|
||||
orParts, err := splitORParts(parts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
expandedParts, err := expandWildcardVersion(orParts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var orFn Range
|
||||
for _, p := range expandedParts {
|
||||
var andFn Range
|
||||
for _, ap := range p {
|
||||
opStr, vStr, err := splitComparatorVersion(ap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vr, err := buildVersionRange(opStr, vStr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Could not parse Range %q: %s", ap, err)
|
||||
}
|
||||
rf := vr.rangeFunc()
|
||||
|
||||
// Set function
|
||||
if andFn == nil {
|
||||
andFn = rf
|
||||
} else { // Combine with existing function
|
||||
andFn = andFn.AND(rf)
|
||||
}
|
||||
}
|
||||
if orFn == nil {
|
||||
orFn = andFn
|
||||
} else {
|
||||
orFn = orFn.OR(andFn)
|
||||
}
|
||||
|
||||
}
|
||||
return orFn, nil
|
||||
}
|
||||
|
||||
// splitORParts splits the already cleaned parts by '||'.
|
||||
// Checks for invalid positions of the operator and returns an
|
||||
// error if found.
|
||||
func splitORParts(parts []string) ([][]string, error) {
|
||||
var ORparts [][]string
|
||||
last := 0
|
||||
for i, p := range parts {
|
||||
if p == "||" {
|
||||
if i == 0 {
|
||||
return nil, fmt.Errorf("First element in range is '||'")
|
||||
}
|
||||
ORparts = append(ORparts, parts[last:i])
|
||||
last = i + 1
|
||||
}
|
||||
}
|
||||
if last == len(parts) {
|
||||
return nil, fmt.Errorf("Last element in range is '||'")
|
||||
}
|
||||
ORparts = append(ORparts, parts[last:])
|
||||
return ORparts, nil
|
||||
}
|
||||
|
||||
// buildVersionRange takes a slice of 2: operator and version
|
||||
// and builds a versionRange, otherwise an error.
|
||||
func buildVersionRange(opStr, vStr string) (*versionRange, error) {
|
||||
c := parseComparator(opStr)
|
||||
if c == nil {
|
||||
return nil, fmt.Errorf("Could not parse comparator %q in %q", opStr, strings.Join([]string{opStr, vStr}, ""))
|
||||
}
|
||||
v, err := Parse(vStr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Could not parse version %q in %q: %s", vStr, strings.Join([]string{opStr, vStr}, ""), err)
|
||||
}
|
||||
|
||||
return &versionRange{
|
||||
v: v,
|
||||
c: c,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
// inArray checks if a byte is contained in an array of bytes
|
||||
func inArray(s byte, list []byte) bool {
|
||||
for _, el := range list {
|
||||
if el == s {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// splitAndTrim splits a range string by spaces and cleans whitespaces
|
||||
func splitAndTrim(s string) (result []string) {
|
||||
last := 0
|
||||
var lastChar byte
|
||||
excludeFromSplit := []byte{'>', '<', '='}
|
||||
for i := 0; i < len(s); i++ {
|
||||
if s[i] == ' ' && !inArray(lastChar, excludeFromSplit) {
|
||||
if last < i-1 {
|
||||
result = append(result, s[last:i])
|
||||
}
|
||||
last = i + 1
|
||||
} else if s[i] != ' ' {
|
||||
lastChar = s[i]
|
||||
}
|
||||
}
|
||||
if last < len(s)-1 {
|
||||
result = append(result, s[last:])
|
||||
}
|
||||
|
||||
for i, v := range result {
|
||||
result[i] = strings.Replace(v, " ", "", -1)
|
||||
}
|
||||
|
||||
// parts := strings.Split(s, " ")
|
||||
// for _, x := range parts {
|
||||
// if s := strings.TrimSpace(x); len(s) != 0 {
|
||||
// result = append(result, s)
|
||||
// }
|
||||
// }
|
||||
return
|
||||
}
|
||||
|
||||
// splitComparatorVersion splits the comparator from the version.
|
||||
// Input must be free of leading or trailing spaces.
|
||||
func splitComparatorVersion(s string) (string, string, error) {
|
||||
i := strings.IndexFunc(s, unicode.IsDigit)
|
||||
if i == -1 {
|
||||
return "", "", fmt.Errorf("Could not get version from string: %q", s)
|
||||
}
|
||||
return strings.TrimSpace(s[0:i]), s[i:], nil
|
||||
}
|
||||
|
||||
// getWildcardType will return the type of wildcard that the
|
||||
// passed version contains
|
||||
func getWildcardType(vStr string) wildcardType {
|
||||
parts := strings.Split(vStr, ".")
|
||||
nparts := len(parts)
|
||||
wildcard := parts[nparts-1]
|
||||
|
||||
possibleWildcardType := wildcardTypefromInt(nparts)
|
||||
if wildcard == "x" {
|
||||
return possibleWildcardType
|
||||
}
|
||||
|
||||
return noneWildcard
|
||||
}
|
||||
|
||||
// createVersionFromWildcard will convert a wildcard version
|
||||
// into a regular version, replacing 'x's with '0's, handling
|
||||
// special cases like '1.x.x' and '1.x'
|
||||
func createVersionFromWildcard(vStr string) string {
|
||||
// handle 1.x.x
|
||||
vStr2 := strings.Replace(vStr, ".x.x", ".x", 1)
|
||||
vStr2 = strings.Replace(vStr2, ".x", ".0", 1)
|
||||
parts := strings.Split(vStr2, ".")
|
||||
|
||||
// handle 1.x
|
||||
if len(parts) == 2 {
|
||||
return vStr2 + ".0"
|
||||
}
|
||||
|
||||
return vStr2
|
||||
}
|
||||
|
||||
// incrementMajorVersion will increment the major version
|
||||
// of the passed version
|
||||
func incrementMajorVersion(vStr string) (string, error) {
|
||||
parts := strings.Split(vStr, ".")
|
||||
i, err := strconv.Atoi(parts[0])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
parts[0] = strconv.Itoa(i + 1)
|
||||
|
||||
return strings.Join(parts, "."), nil
|
||||
}
|
||||
|
||||
// incrementMajorVersion will increment the minor version
|
||||
// of the passed version
|
||||
func incrementMinorVersion(vStr string) (string, error) {
|
||||
parts := strings.Split(vStr, ".")
|
||||
i, err := strconv.Atoi(parts[1])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
parts[1] = strconv.Itoa(i + 1)
|
||||
|
||||
return strings.Join(parts, "."), nil
|
||||
}
|
||||
|
||||
// expandWildcardVersion will expand wildcards inside versions
|
||||
// following these rules:
|
||||
//
|
||||
// * when dealing with patch wildcards:
|
||||
// >= 1.2.x will become >= 1.2.0
|
||||
// <= 1.2.x will become < 1.3.0
|
||||
// > 1.2.x will become >= 1.3.0
|
||||
// < 1.2.x will become < 1.2.0
|
||||
// != 1.2.x will become < 1.2.0 >= 1.3.0
|
||||
//
|
||||
// * when dealing with minor wildcards:
|
||||
// >= 1.x will become >= 1.0.0
|
||||
// <= 1.x will become < 2.0.0
|
||||
// > 1.x will become >= 2.0.0
|
||||
// < 1.0 will become < 1.0.0
|
||||
// != 1.x will become < 1.0.0 >= 2.0.0
|
||||
//
|
||||
// * when dealing with wildcards without
|
||||
// version operator:
|
||||
// 1.2.x will become >= 1.2.0 < 1.3.0
|
||||
// 1.x will become >= 1.0.0 < 2.0.0
|
||||
func expandWildcardVersion(parts [][]string) ([][]string, error) {
|
||||
var expandedParts [][]string
|
||||
for _, p := range parts {
|
||||
var newParts []string
|
||||
for _, ap := range p {
|
||||
if strings.Contains(ap, "x") {
|
||||
opStr, vStr, err := splitComparatorVersion(ap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
versionWildcardType := getWildcardType(vStr)
|
||||
flatVersion := createVersionFromWildcard(vStr)
|
||||
|
||||
var resultOperator string
|
||||
var shouldIncrementVersion bool
|
||||
switch opStr {
|
||||
case ">":
|
||||
resultOperator = ">="
|
||||
shouldIncrementVersion = true
|
||||
case ">=":
|
||||
resultOperator = ">="
|
||||
case "<":
|
||||
resultOperator = "<"
|
||||
case "<=":
|
||||
resultOperator = "<"
|
||||
shouldIncrementVersion = true
|
||||
case "", "=", "==":
|
||||
newParts = append(newParts, ">="+flatVersion)
|
||||
resultOperator = "<"
|
||||
shouldIncrementVersion = true
|
||||
case "!=", "!":
|
||||
newParts = append(newParts, "<"+flatVersion)
|
||||
resultOperator = ">="
|
||||
shouldIncrementVersion = true
|
||||
}
|
||||
|
||||
var resultVersion string
|
||||
if shouldIncrementVersion {
|
||||
switch versionWildcardType {
|
||||
case patchWildcard:
|
||||
resultVersion, _ = incrementMinorVersion(flatVersion)
|
||||
case minorWildcard:
|
||||
resultVersion, _ = incrementMajorVersion(flatVersion)
|
||||
}
|
||||
} else {
|
||||
resultVersion = flatVersion
|
||||
}
|
||||
|
||||
ap = resultOperator + resultVersion
|
||||
}
|
||||
newParts = append(newParts, ap)
|
||||
}
|
||||
expandedParts = append(expandedParts, newParts)
|
||||
}
|
||||
|
||||
return expandedParts, nil
|
||||
}
|
||||
|
||||
func parseComparator(s string) comparator {
|
||||
switch s {
|
||||
case "==":
|
||||
fallthrough
|
||||
case "":
|
||||
fallthrough
|
||||
case "=":
|
||||
return compEQ
|
||||
case ">":
|
||||
return compGT
|
||||
case ">=":
|
||||
return compGE
|
||||
case "<":
|
||||
return compLT
|
||||
case "<=":
|
||||
return compLE
|
||||
case "!":
|
||||
fallthrough
|
||||
case "!=":
|
||||
return compNE
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MustParseRange is like ParseRange but panics if the range cannot be parsed.
|
||||
func MustParseRange(s string) Range {
|
||||
r, err := ParseRange(s)
|
||||
if err != nil {
|
||||
panic(`semver: ParseRange(` + s + `): ` + err.Error())
|
||||
}
|
||||
return r
|
||||
}
|
455
vendor/github.com/blang/semver/semver.go
generated
vendored
Normal file
455
vendor/github.com/blang/semver/semver.go
generated
vendored
Normal file
@ -0,0 +1,455 @@
|
||||
package semver
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
numbers string = "0123456789"
|
||||
alphas = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-"
|
||||
alphanum = alphas + numbers
|
||||
)
|
||||
|
||||
// SpecVersion is the latest fully supported spec version of semver
|
||||
var SpecVersion = Version{
|
||||
Major: 2,
|
||||
Minor: 0,
|
||||
Patch: 0,
|
||||
}
|
||||
|
||||
// Version represents a semver compatible version
|
||||
type Version struct {
|
||||
Major uint64
|
||||
Minor uint64
|
||||
Patch uint64
|
||||
Pre []PRVersion
|
||||
Build []string //No Precedence
|
||||
}
|
||||
|
||||
// Version to string
|
||||
func (v Version) String() string {
|
||||
b := make([]byte, 0, 5)
|
||||
b = strconv.AppendUint(b, v.Major, 10)
|
||||
b = append(b, '.')
|
||||
b = strconv.AppendUint(b, v.Minor, 10)
|
||||
b = append(b, '.')
|
||||
b = strconv.AppendUint(b, v.Patch, 10)
|
||||
|
||||
if len(v.Pre) > 0 {
|
||||
b = append(b, '-')
|
||||
b = append(b, v.Pre[0].String()...)
|
||||
|
||||
for _, pre := range v.Pre[1:] {
|
||||
b = append(b, '.')
|
||||
b = append(b, pre.String()...)
|
||||
}
|
||||
}
|
||||
|
||||
if len(v.Build) > 0 {
|
||||
b = append(b, '+')
|
||||
b = append(b, v.Build[0]...)
|
||||
|
||||
for _, build := range v.Build[1:] {
|
||||
b = append(b, '.')
|
||||
b = append(b, build...)
|
||||
}
|
||||
}
|
||||
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// Equals checks if v is equal to o.
|
||||
func (v Version) Equals(o Version) bool {
|
||||
return (v.Compare(o) == 0)
|
||||
}
|
||||
|
||||
// EQ checks if v is equal to o.
|
||||
func (v Version) EQ(o Version) bool {
|
||||
return (v.Compare(o) == 0)
|
||||
}
|
||||
|
||||
// NE checks if v is not equal to o.
|
||||
func (v Version) NE(o Version) bool {
|
||||
return (v.Compare(o) != 0)
|
||||
}
|
||||
|
||||
// GT checks if v is greater than o.
|
||||
func (v Version) GT(o Version) bool {
|
||||
return (v.Compare(o) == 1)
|
||||
}
|
||||
|
||||
// GTE checks if v is greater than or equal to o.
|
||||
func (v Version) GTE(o Version) bool {
|
||||
return (v.Compare(o) >= 0)
|
||||
}
|
||||
|
||||
// GE checks if v is greater than or equal to o.
|
||||
func (v Version) GE(o Version) bool {
|
||||
return (v.Compare(o) >= 0)
|
||||
}
|
||||
|
||||
// LT checks if v is less than o.
|
||||
func (v Version) LT(o Version) bool {
|
||||
return (v.Compare(o) == -1)
|
||||
}
|
||||
|
||||
// LTE checks if v is less than or equal to o.
|
||||
func (v Version) LTE(o Version) bool {
|
||||
return (v.Compare(o) <= 0)
|
||||
}
|
||||
|
||||
// LE checks if v is less than or equal to o.
|
||||
func (v Version) LE(o Version) bool {
|
||||
return (v.Compare(o) <= 0)
|
||||
}
|
||||
|
||||
// Compare compares Versions v to o:
|
||||
// -1 == v is less than o
|
||||
// 0 == v is equal to o
|
||||
// 1 == v is greater than o
|
||||
func (v Version) Compare(o Version) int {
|
||||
if v.Major != o.Major {
|
||||
if v.Major > o.Major {
|
||||
return 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
if v.Minor != o.Minor {
|
||||
if v.Minor > o.Minor {
|
||||
return 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
if v.Patch != o.Patch {
|
||||
if v.Patch > o.Patch {
|
||||
return 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// Quick comparison if a version has no prerelease versions
|
||||
if len(v.Pre) == 0 && len(o.Pre) == 0 {
|
||||
return 0
|
||||
} else if len(v.Pre) == 0 && len(o.Pre) > 0 {
|
||||
return 1
|
||||
} else if len(v.Pre) > 0 && len(o.Pre) == 0 {
|
||||
return -1
|
||||
}
|
||||
|
||||
i := 0
|
||||
for ; i < len(v.Pre) && i < len(o.Pre); i++ {
|
||||
if comp := v.Pre[i].Compare(o.Pre[i]); comp == 0 {
|
||||
continue
|
||||
} else if comp == 1 {
|
||||
return 1
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
// If all pr versions are the equal but one has further prversion, this one greater
|
||||
if i == len(v.Pre) && i == len(o.Pre) {
|
||||
return 0
|
||||
} else if i == len(v.Pre) && i < len(o.Pre) {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// IncrementPatch increments the patch version
|
||||
func (v *Version) IncrementPatch() error {
|
||||
if v.Major == 0 {
|
||||
return fmt.Errorf("Patch version can not be incremented for %q", v.String())
|
||||
}
|
||||
v.Patch += 1
|
||||
return nil
|
||||
}
|
||||
|
||||
// IncrementMinor increments the minor version
|
||||
func (v *Version) IncrementMinor() error {
|
||||
if v.Major == 0 {
|
||||
return fmt.Errorf("Minor version can not be incremented for %q", v.String())
|
||||
}
|
||||
v.Minor += 1
|
||||
v.Patch = 0
|
||||
return nil
|
||||
}
|
||||
|
||||
// IncrementMajor increments the major version
|
||||
func (v *Version) IncrementMajor() error {
|
||||
if v.Major == 0 {
|
||||
return fmt.Errorf("Major version can not be incremented for %q", v.String())
|
||||
}
|
||||
v.Major += 1
|
||||
v.Minor = 0
|
||||
v.Patch = 0
|
||||
return nil
|
||||
}
|
||||
|
||||
// Validate validates v and returns error in case
|
||||
func (v Version) Validate() error {
|
||||
// Major, Minor, Patch already validated using uint64
|
||||
|
||||
for _, pre := range v.Pre {
|
||||
if !pre.IsNum { //Numeric prerelease versions already uint64
|
||||
if len(pre.VersionStr) == 0 {
|
||||
return fmt.Errorf("Prerelease can not be empty %q", pre.VersionStr)
|
||||
}
|
||||
if !containsOnly(pre.VersionStr, alphanum) {
|
||||
return fmt.Errorf("Invalid character(s) found in prerelease %q", pre.VersionStr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, build := range v.Build {
|
||||
if len(build) == 0 {
|
||||
return fmt.Errorf("Build meta data can not be empty %q", build)
|
||||
}
|
||||
if !containsOnly(build, alphanum) {
|
||||
return fmt.Errorf("Invalid character(s) found in build meta data %q", build)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// New is an alias for Parse and returns a pointer, parses version string and returns a validated Version or error
|
||||
func New(s string) (vp *Version, err error) {
|
||||
v, err := Parse(s)
|
||||
vp = &v
|
||||
return
|
||||
}
|
||||
|
||||
// Make is an alias for Parse, parses version string and returns a validated Version or error
|
||||
func Make(s string) (Version, error) {
|
||||
return Parse(s)
|
||||
}
|
||||
|
||||
// ParseTolerant allows for certain version specifications that do not strictly adhere to semver
|
||||
// specs to be parsed by this library. It does so by normalizing versions before passing them to
|
||||
// Parse(). It currently trims spaces, removes a "v" prefix, adds a 0 patch number to versions
|
||||
// with only major and minor components specified, and removes leading 0s.
|
||||
func ParseTolerant(s string) (Version, error) {
|
||||
s = strings.TrimSpace(s)
|
||||
s = strings.TrimPrefix(s, "v")
|
||||
|
||||
// Split into major.minor.(patch+pr+meta)
|
||||
parts := strings.SplitN(s, ".", 3)
|
||||
// Remove leading zeros.
|
||||
for i, p := range parts {
|
||||
if len(p) > 1 {
|
||||
parts[i] = strings.TrimPrefix(p, "0")
|
||||
}
|
||||
}
|
||||
// Fill up shortened versions.
|
||||
if len(parts) < 3 {
|
||||
if strings.ContainsAny(parts[len(parts)-1], "+-") {
|
||||
return Version{}, errors.New("Short version cannot contain PreRelease/Build meta data")
|
||||
}
|
||||
for len(parts) < 3 {
|
||||
parts = append(parts, "0")
|
||||
}
|
||||
}
|
||||
s = strings.Join(parts, ".")
|
||||
|
||||
return Parse(s)
|
||||
}
|
||||
|
||||
// Parse parses version string and returns a validated Version or error
|
||||
func Parse(s string) (Version, error) {
|
||||
if len(s) == 0 {
|
||||
return Version{}, errors.New("Version string empty")
|
||||
}
|
||||
|
||||
// Split into major.minor.(patch+pr+meta)
|
||||
parts := strings.SplitN(s, ".", 3)
|
||||
if len(parts) != 3 {
|
||||
return Version{}, errors.New("No Major.Minor.Patch elements found")
|
||||
}
|
||||
|
||||
// Major
|
||||
if !containsOnly(parts[0], numbers) {
|
||||
return Version{}, fmt.Errorf("Invalid character(s) found in major number %q", parts[0])
|
||||
}
|
||||
if hasLeadingZeroes(parts[0]) {
|
||||
return Version{}, fmt.Errorf("Major number must not contain leading zeroes %q", parts[0])
|
||||
}
|
||||
major, err := strconv.ParseUint(parts[0], 10, 64)
|
||||
if err != nil {
|
||||
return Version{}, err
|
||||
}
|
||||
|
||||
// Minor
|
||||
if !containsOnly(parts[1], numbers) {
|
||||
return Version{}, fmt.Errorf("Invalid character(s) found in minor number %q", parts[1])
|
||||
}
|
||||
if hasLeadingZeroes(parts[1]) {
|
||||
return Version{}, fmt.Errorf("Minor number must not contain leading zeroes %q", parts[1])
|
||||
}
|
||||
minor, err := strconv.ParseUint(parts[1], 10, 64)
|
||||
if err != nil {
|
||||
return Version{}, err
|
||||
}
|
||||
|
||||
v := Version{}
|
||||
v.Major = major
|
||||
v.Minor = minor
|
||||
|
||||
var build, prerelease []string
|
||||
patchStr := parts[2]
|
||||
|
||||
if buildIndex := strings.IndexRune(patchStr, '+'); buildIndex != -1 {
|
||||
build = strings.Split(patchStr[buildIndex+1:], ".")
|
||||
patchStr = patchStr[:buildIndex]
|
||||
}
|
||||
|
||||
if preIndex := strings.IndexRune(patchStr, '-'); preIndex != -1 {
|
||||
prerelease = strings.Split(patchStr[preIndex+1:], ".")
|
||||
patchStr = patchStr[:preIndex]
|
||||
}
|
||||
|
||||
if !containsOnly(patchStr, numbers) {
|
||||
return Version{}, fmt.Errorf("Invalid character(s) found in patch number %q", patchStr)
|
||||
}
|
||||
if hasLeadingZeroes(patchStr) {
|
||||
return Version{}, fmt.Errorf("Patch number must not contain leading zeroes %q", patchStr)
|
||||
}
|
||||
patch, err := strconv.ParseUint(patchStr, 10, 64)
|
||||
if err != nil {
|
||||
return Version{}, err
|
||||
}
|
||||
|
||||
v.Patch = patch
|
||||
|
||||
// Prerelease
|
||||
for _, prstr := range prerelease {
|
||||
parsedPR, err := NewPRVersion(prstr)
|
||||
if err != nil {
|
||||
return Version{}, err
|
||||
}
|
||||
v.Pre = append(v.Pre, parsedPR)
|
||||
}
|
||||
|
||||
// Build meta data
|
||||
for _, str := range build {
|
||||
if len(str) == 0 {
|
||||
return Version{}, errors.New("Build meta data is empty")
|
||||
}
|
||||
if !containsOnly(str, alphanum) {
|
||||
return Version{}, fmt.Errorf("Invalid character(s) found in build meta data %q", str)
|
||||
}
|
||||
v.Build = append(v.Build, str)
|
||||
}
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// MustParse is like Parse but panics if the version cannot be parsed.
|
||||
func MustParse(s string) Version {
|
||||
v, err := Parse(s)
|
||||
if err != nil {
|
||||
panic(`semver: Parse(` + s + `): ` + err.Error())
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// PRVersion represents a PreRelease Version
|
||||
type PRVersion struct {
|
||||
VersionStr string
|
||||
VersionNum uint64
|
||||
IsNum bool
|
||||
}
|
||||
|
||||
// NewPRVersion creates a new valid prerelease version
|
||||
func NewPRVersion(s string) (PRVersion, error) {
|
||||
if len(s) == 0 {
|
||||
return PRVersion{}, errors.New("Prerelease is empty")
|
||||
}
|
||||
v := PRVersion{}
|
||||
if containsOnly(s, numbers) {
|
||||
if hasLeadingZeroes(s) {
|
||||
return PRVersion{}, fmt.Errorf("Numeric PreRelease version must not contain leading zeroes %q", s)
|
||||
}
|
||||
num, err := strconv.ParseUint(s, 10, 64)
|
||||
|
||||
// Might never be hit, but just in case
|
||||
if err != nil {
|
||||
return PRVersion{}, err
|
||||
}
|
||||
v.VersionNum = num
|
||||
v.IsNum = true
|
||||
} else if containsOnly(s, alphanum) {
|
||||
v.VersionStr = s
|
||||
v.IsNum = false
|
||||
} else {
|
||||
return PRVersion{}, fmt.Errorf("Invalid character(s) found in prerelease %q", s)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IsNumeric checks if prerelease-version is numeric
|
||||
func (v PRVersion) IsNumeric() bool {
|
||||
return v.IsNum
|
||||
}
|
||||
|
||||
// Compare compares two PreRelease Versions v and o:
|
||||
// -1 == v is less than o
|
||||
// 0 == v is equal to o
|
||||
// 1 == v is greater than o
|
||||
func (v PRVersion) Compare(o PRVersion) int {
|
||||
if v.IsNum && !o.IsNum {
|
||||
return -1
|
||||
} else if !v.IsNum && o.IsNum {
|
||||
return 1
|
||||
} else if v.IsNum && o.IsNum {
|
||||
if v.VersionNum == o.VersionNum {
|
||||
return 0
|
||||
} else if v.VersionNum > o.VersionNum {
|
||||
return 1
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
} else { // both are Alphas
|
||||
if v.VersionStr == o.VersionStr {
|
||||
return 0
|
||||
} else if v.VersionStr > o.VersionStr {
|
||||
return 1
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PreRelease version to string
|
||||
func (v PRVersion) String() string {
|
||||
if v.IsNum {
|
||||
return strconv.FormatUint(v.VersionNum, 10)
|
||||
}
|
||||
return v.VersionStr
|
||||
}
|
||||
|
||||
func containsOnly(s string, set string) bool {
|
||||
return strings.IndexFunc(s, func(r rune) bool {
|
||||
return !strings.ContainsRune(set, r)
|
||||
}) == -1
|
||||
}
|
||||
|
||||
func hasLeadingZeroes(s string) bool {
|
||||
return len(s) > 1 && s[0] == '0'
|
||||
}
|
||||
|
||||
// NewBuildVersion creates a new valid build version
|
||||
func NewBuildVersion(s string) (string, error) {
|
||||
if len(s) == 0 {
|
||||
return "", errors.New("Buildversion is empty")
|
||||
}
|
||||
if !containsOnly(s, alphanum) {
|
||||
return "", fmt.Errorf("Invalid character(s) found in build meta data %q", s)
|
||||
}
|
||||
return s, nil
|
||||
}
|
28
vendor/github.com/blang/semver/sort.go
generated
vendored
Normal file
28
vendor/github.com/blang/semver/sort.go
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
package semver
|
||||
|
||||
import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Versions represents multiple versions.
|
||||
type Versions []Version
|
||||
|
||||
// Len returns length of version collection
|
||||
func (s Versions) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
// Swap swaps two versions inside the collection by its indices
|
||||
func (s Versions) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
|
||||
// Less checks if version at index i is less than version at index j
|
||||
func (s Versions) Less(i, j int) bool {
|
||||
return s[i].LT(s[j])
|
||||
}
|
||||
|
||||
// Sort sorts a slice of versions
|
||||
func Sort(versions []Version) {
|
||||
sort.Sort(Versions(versions))
|
||||
}
|
30
vendor/github.com/blang/semver/sql.go
generated
vendored
Normal file
30
vendor/github.com/blang/semver/sql.go
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
package semver
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Scan implements the database/sql.Scanner interface.
|
||||
func (v *Version) Scan(src interface{}) (err error) {
|
||||
var str string
|
||||
switch src := src.(type) {
|
||||
case string:
|
||||
str = src
|
||||
case []byte:
|
||||
str = string(src)
|
||||
default:
|
||||
return fmt.Errorf("version.Scan: cannot convert %T to string", src)
|
||||
}
|
||||
|
||||
if t, err := Parse(str); err == nil {
|
||||
*v = t
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the database/sql/driver.Valuer interface.
|
||||
func (v Version) Value() (driver.Value, error) {
|
||||
return v.String(), nil
|
||||
}
|
89
vendor/github.com/hashicorp/errwrap/README.md
generated
vendored
89
vendor/github.com/hashicorp/errwrap/README.md
generated
vendored
@ -1,89 +0,0 @@
|
||||
# errwrap
|
||||
|
||||
`errwrap` is a package for Go that formalizes the pattern of wrapping errors
|
||||
and checking if an error contains another error.
|
||||
|
||||
There is a common pattern in Go of taking a returned `error` value and
|
||||
then wrapping it (such as with `fmt.Errorf`) before returning it. The problem
|
||||
with this pattern is that you completely lose the original `error` structure.
|
||||
|
||||
Arguably the _correct_ approach is that you should make a custom structure
|
||||
implementing the `error` interface, and have the original error as a field
|
||||
on that structure, such [as this example](http://golang.org/pkg/os/#PathError).
|
||||
This is a good approach, but you have to know the entire chain of possible
|
||||
rewrapping that happens, when you might just care about one.
|
||||
|
||||
`errwrap` formalizes this pattern (it doesn't matter what approach you use
|
||||
above) by giving a single interface for wrapping errors, checking if a specific
|
||||
error is wrapped, and extracting that error.
|
||||
|
||||
## Installation and Docs
|
||||
|
||||
Install using `go get github.com/hashicorp/errwrap`.
|
||||
|
||||
Full documentation is available at
|
||||
http://godoc.org/github.com/hashicorp/errwrap
|
||||
|
||||
## Usage
|
||||
|
||||
#### Basic Usage
|
||||
|
||||
Below is a very basic example of its usage:
|
||||
|
||||
```go
|
||||
// A function that always returns an error, but wraps it, like a real
|
||||
// function might.
|
||||
func tryOpen() error {
|
||||
_, err := os.Open("/i/dont/exist")
|
||||
if err != nil {
|
||||
return errwrap.Wrapf("Doesn't exist: {{err}}", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := tryOpen()
|
||||
|
||||
// We can use the Contains helpers to check if an error contains
|
||||
// another error. It is safe to do this with a nil error, or with
|
||||
// an error that doesn't even use the errwrap package.
|
||||
if errwrap.Contains(err, "does not exist") {
|
||||
// Do something
|
||||
}
|
||||
if errwrap.ContainsType(err, new(os.PathError)) {
|
||||
// Do something
|
||||
}
|
||||
|
||||
// Or we can use the associated `Get` functions to just extract
|
||||
// a specific error. This would return nil if that specific error doesn't
|
||||
// exist.
|
||||
perr := errwrap.GetType(err, new(os.PathError))
|
||||
}
|
||||
```
|
||||
|
||||
#### Custom Types
|
||||
|
||||
If you're already making custom types that properly wrap errors, then
|
||||
you can get all the functionality of `errwraps.Contains` and such by
|
||||
implementing the `Wrapper` interface with just one function. Example:
|
||||
|
||||
```go
|
||||
type AppError {
|
||||
Code ErrorCode
|
||||
Err error
|
||||
}
|
||||
|
||||
func (e *AppError) WrappedErrors() []error {
|
||||
return []error{e.Err}
|
||||
}
|
||||
```
|
||||
|
||||
Now this works:
|
||||
|
||||
```go
|
||||
err := &AppError{Err: fmt.Errorf("an error")}
|
||||
if errwrap.ContainsType(err, fmt.Errorf("")) {
|
||||
// This will work!
|
||||
}
|
||||
```
|
94
vendor/github.com/hashicorp/errwrap/errwrap_test.go
generated
vendored
94
vendor/github.com/hashicorp/errwrap/errwrap_test.go
generated
vendored
@ -1,94 +0,0 @@
|
||||
package errwrap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWrappedError_impl(t *testing.T) {
|
||||
var _ error = new(wrappedError)
|
||||
}
|
||||
|
||||
func TestGetAll(t *testing.T) {
|
||||
cases := []struct {
|
||||
Err error
|
||||
Msg string
|
||||
Len int
|
||||
}{
|
||||
{},
|
||||
{
|
||||
fmt.Errorf("foo"),
|
||||
"foo",
|
||||
1,
|
||||
},
|
||||
{
|
||||
fmt.Errorf("bar"),
|
||||
"foo",
|
||||
0,
|
||||
},
|
||||
{
|
||||
Wrapf("bar", fmt.Errorf("foo")),
|
||||
"foo",
|
||||
1,
|
||||
},
|
||||
{
|
||||
Wrapf("{{err}}", fmt.Errorf("foo")),
|
||||
"foo",
|
||||
2,
|
||||
},
|
||||
{
|
||||
Wrapf("bar", Wrapf("baz", fmt.Errorf("foo"))),
|
||||
"foo",
|
||||
1,
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
actual := GetAll(tc.Err, tc.Msg)
|
||||
if len(actual) != tc.Len {
|
||||
t.Fatalf("%d: bad: %#v", i, actual)
|
||||
}
|
||||
for _, v := range actual {
|
||||
if v.Error() != tc.Msg {
|
||||
t.Fatalf("%d: bad: %#v", i, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAllType(t *testing.T) {
|
||||
cases := []struct {
|
||||
Err error
|
||||
Type interface{}
|
||||
Len int
|
||||
}{
|
||||
{},
|
||||
{
|
||||
fmt.Errorf("foo"),
|
||||
"foo",
|
||||
0,
|
||||
},
|
||||
{
|
||||
fmt.Errorf("bar"),
|
||||
fmt.Errorf("foo"),
|
||||
1,
|
||||
},
|
||||
{
|
||||
Wrapf("bar", fmt.Errorf("foo")),
|
||||
fmt.Errorf("baz"),
|
||||
2,
|
||||
},
|
||||
{
|
||||
Wrapf("bar", Wrapf("baz", fmt.Errorf("foo"))),
|
||||
Wrapf("", nil),
|
||||
0,
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
actual := GetAllType(tc.Err, tc.Type)
|
||||
if len(actual) != tc.Len {
|
||||
t.Fatalf("%d: bad: %#v", i, actual)
|
||||
}
|
||||
}
|
||||
}
|
1
vendor/github.com/hashicorp/errwrap/go.mod
generated
vendored
1
vendor/github.com/hashicorp/errwrap/go.mod
generated
vendored
@ -1 +0,0 @@
|
||||
module github.com/hashicorp/errwrap
|
12
vendor/github.com/hashicorp/go-multierror/.travis.yml
generated
vendored
12
vendor/github.com/hashicorp/go-multierror/.travis.yml
generated
vendored
@ -1,12 +0,0 @@
|
||||
sudo: false
|
||||
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.x
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
script: make test testrace
|
31
vendor/github.com/hashicorp/go-multierror/Makefile
generated
vendored
31
vendor/github.com/hashicorp/go-multierror/Makefile
generated
vendored
@ -1,31 +0,0 @@
|
||||
TEST?=./...
|
||||
|
||||
default: test
|
||||
|
||||
# test runs the test suite and vets the code.
|
||||
test: generate
|
||||
@echo "==> Running tests..."
|
||||
@go list $(TEST) \
|
||||
| grep -v "/vendor/" \
|
||||
| xargs -n1 go test -timeout=60s -parallel=10 ${TESTARGS}
|
||||
|
||||
# testrace runs the race checker
|
||||
testrace: generate
|
||||
@echo "==> Running tests (race)..."
|
||||
@go list $(TEST) \
|
||||
| grep -v "/vendor/" \
|
||||
| xargs -n1 go test -timeout=60s -race ${TESTARGS}
|
||||
|
||||
# updatedeps installs all the dependencies needed to run and build.
|
||||
updatedeps:
|
||||
@sh -c "'${CURDIR}/scripts/deps.sh' '${NAME}'"
|
||||
|
||||
# generate runs `go generate` to build the dynamically generated source files.
|
||||
generate:
|
||||
@echo "==> Generating..."
|
||||
@find . -type f -name '.DS_Store' -delete
|
||||
@go list ./... \
|
||||
| grep -v "/vendor/" \
|
||||
| xargs -n1 go generate
|
||||
|
||||
.PHONY: default test testrace updatedeps generate
|
97
vendor/github.com/hashicorp/go-multierror/README.md
generated
vendored
97
vendor/github.com/hashicorp/go-multierror/README.md
generated
vendored
@ -1,97 +0,0 @@
|
||||
# go-multierror
|
||||
|
||||
[][travis]
|
||||
[][godocs]
|
||||
|
||||
[travis]: https://travis-ci.org/hashicorp/go-multierror
|
||||
[godocs]: https://godoc.org/github.com/hashicorp/go-multierror
|
||||
|
||||
`go-multierror` is a package for Go that provides a mechanism for
|
||||
representing a list of `error` values as a single `error`.
|
||||
|
||||
This allows a function in Go to return an `error` that might actually
|
||||
be a list of errors. If the caller knows this, they can unwrap the
|
||||
list and access the errors. If the caller doesn't know, the error
|
||||
formats to a nice human-readable format.
|
||||
|
||||
`go-multierror` implements the
|
||||
[errwrap](https://github.com/hashicorp/errwrap) interface so that it can
|
||||
be used with that library, as well.
|
||||
|
||||
## Installation and Docs
|
||||
|
||||
Install using `go get github.com/hashicorp/go-multierror`.
|
||||
|
||||
Full documentation is available at
|
||||
http://godoc.org/github.com/hashicorp/go-multierror
|
||||
|
||||
## Usage
|
||||
|
||||
go-multierror is easy to use and purposely built to be unobtrusive in
|
||||
existing Go applications/libraries that may not be aware of it.
|
||||
|
||||
**Building a list of errors**
|
||||
|
||||
The `Append` function is used to create a list of errors. This function
|
||||
behaves a lot like the Go built-in `append` function: it doesn't matter
|
||||
if the first argument is nil, a `multierror.Error`, or any other `error`,
|
||||
the function behaves as you would expect.
|
||||
|
||||
```go
|
||||
var result error
|
||||
|
||||
if err := step1(); err != nil {
|
||||
result = multierror.Append(result, err)
|
||||
}
|
||||
if err := step2(); err != nil {
|
||||
result = multierror.Append(result, err)
|
||||
}
|
||||
|
||||
return result
|
||||
```
|
||||
|
||||
**Customizing the formatting of the errors**
|
||||
|
||||
By specifying a custom `ErrorFormat`, you can customize the format
|
||||
of the `Error() string` function:
|
||||
|
||||
```go
|
||||
var result *multierror.Error
|
||||
|
||||
// ... accumulate errors here, maybe using Append
|
||||
|
||||
if result != nil {
|
||||
result.ErrorFormat = func([]error) string {
|
||||
return "errors!"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Accessing the list of errors**
|
||||
|
||||
`multierror.Error` implements `error` so if the caller doesn't know about
|
||||
multierror, it will work just fine. But if you're aware a multierror might
|
||||
be returned, you can use type switches to access the list of errors:
|
||||
|
||||
```go
|
||||
if err := something(); err != nil {
|
||||
if merr, ok := err.(*multierror.Error); ok {
|
||||
// Use merr.Errors
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Returning a multierror only if there are errors**
|
||||
|
||||
If you build a `multierror.Error`, you can use the `ErrorOrNil` function
|
||||
to return an `error` implementation only if there are errors to return:
|
||||
|
||||
```go
|
||||
var result *multierror.Error
|
||||
|
||||
// ... accumulate errors here
|
||||
|
||||
// Return the `error` only if errors were added to the multierror, otherwise
|
||||
// return nil since there are no errors.
|
||||
return result.ErrorOrNil()
|
||||
```
|
82
vendor/github.com/hashicorp/go-multierror/append_test.go
generated
vendored
82
vendor/github.com/hashicorp/go-multierror/append_test.go
generated
vendored
@ -1,82 +0,0 @@
|
||||
package multierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAppend_Error(t *testing.T) {
|
||||
original := &Error{
|
||||
Errors: []error{errors.New("foo")},
|
||||
}
|
||||
|
||||
result := Append(original, errors.New("bar"))
|
||||
if len(result.Errors) != 2 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
|
||||
original = &Error{}
|
||||
result = Append(original, errors.New("bar"))
|
||||
if len(result.Errors) != 1 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
|
||||
// Test when a typed nil is passed
|
||||
var e *Error
|
||||
result = Append(e, errors.New("baz"))
|
||||
if len(result.Errors) != 1 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
|
||||
// Test flattening
|
||||
original = &Error{
|
||||
Errors: []error{errors.New("foo")},
|
||||
}
|
||||
|
||||
result = Append(original, Append(nil, errors.New("foo"), errors.New("bar")))
|
||||
if len(result.Errors) != 3 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppend_NilError(t *testing.T) {
|
||||
var err error
|
||||
result := Append(err, errors.New("bar"))
|
||||
if len(result.Errors) != 1 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppend_NilErrorArg(t *testing.T) {
|
||||
var err error
|
||||
var nilErr *Error
|
||||
result := Append(err, nilErr)
|
||||
if len(result.Errors) != 0 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppend_NilErrorIfaceArg(t *testing.T) {
|
||||
var err error
|
||||
var nilErr error
|
||||
result := Append(err, nilErr)
|
||||
if len(result.Errors) != 0 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppend_NonError(t *testing.T) {
|
||||
original := errors.New("foo")
|
||||
result := Append(original, errors.New("bar"))
|
||||
if len(result.Errors) != 2 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppend_NonError_Error(t *testing.T) {
|
||||
original := errors.New("foo")
|
||||
result := Append(original, Append(nil, errors.New("bar")))
|
||||
if len(result.Errors) != 2 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
46
vendor/github.com/hashicorp/go-multierror/flatten_test.go
generated
vendored
46
vendor/github.com/hashicorp/go-multierror/flatten_test.go
generated
vendored
@ -1,46 +0,0 @@
|
||||
package multierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFlatten(t *testing.T) {
|
||||
original := &Error{
|
||||
Errors: []error{
|
||||
errors.New("one"),
|
||||
&Error{
|
||||
Errors: []error{
|
||||
errors.New("two"),
|
||||
&Error{
|
||||
Errors: []error{
|
||||
errors.New("three"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
expected := `3 errors occurred:
|
||||
* one
|
||||
* two
|
||||
* three
|
||||
|
||||
`
|
||||
actual := fmt.Sprintf("%s", Flatten(original))
|
||||
|
||||
if expected != actual {
|
||||
t.Fatalf("expected: %s, got: %s", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlatten_nonError(t *testing.T) {
|
||||
err := errors.New("foo")
|
||||
actual := Flatten(err)
|
||||
if !reflect.DeepEqual(actual, err) {
|
||||
t.Fatalf("bad: %#v", actual)
|
||||
}
|
||||
}
|
40
vendor/github.com/hashicorp/go-multierror/format_test.go
generated
vendored
40
vendor/github.com/hashicorp/go-multierror/format_test.go
generated
vendored
@ -1,40 +0,0 @@
|
||||
package multierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestListFormatFuncSingle(t *testing.T) {
|
||||
expected := `1 error occurred:
|
||||
* foo
|
||||
|
||||
`
|
||||
|
||||
errors := []error{
|
||||
errors.New("foo"),
|
||||
}
|
||||
|
||||
actual := ListFormatFunc(errors)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: %#v", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestListFormatFuncMultiple(t *testing.T) {
|
||||
expected := `2 errors occurred:
|
||||
* foo
|
||||
* bar
|
||||
|
||||
`
|
||||
|
||||
errors := []error{
|
||||
errors.New("foo"),
|
||||
errors.New("bar"),
|
||||
}
|
||||
|
||||
actual := ListFormatFunc(errors)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: %#v", actual)
|
||||
}
|
||||
}
|
3
vendor/github.com/hashicorp/go-multierror/go.mod
generated
vendored
3
vendor/github.com/hashicorp/go-multierror/go.mod
generated
vendored
@ -1,3 +0,0 @@
|
||||
module github.com/hashicorp/go-multierror
|
||||
|
||||
require github.com/hashicorp/errwrap v1.0.0
|
4
vendor/github.com/hashicorp/go-multierror/go.sum
generated
vendored
4
vendor/github.com/hashicorp/go-multierror/go.sum
generated
vendored
@ -1,4 +0,0 @@
|
||||
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce h1:prjrVgOk2Yg6w+PflHoszQNLTUh4kaByUcEWM/9uin4=
|
||||
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
71
vendor/github.com/hashicorp/go-multierror/multierror_test.go
generated
vendored
71
vendor/github.com/hashicorp/go-multierror/multierror_test.go
generated
vendored
@ -1,71 +0,0 @@
|
||||
package multierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestError_Impl(t *testing.T) {
|
||||
var _ error = new(Error)
|
||||
}
|
||||
|
||||
func TestErrorError_custom(t *testing.T) {
|
||||
errors := []error{
|
||||
errors.New("foo"),
|
||||
errors.New("bar"),
|
||||
}
|
||||
|
||||
fn := func(es []error) string {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
multi := &Error{Errors: errors, ErrorFormat: fn}
|
||||
if multi.Error() != "foo" {
|
||||
t.Fatalf("bad: %s", multi.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorError_default(t *testing.T) {
|
||||
expected := `2 errors occurred:
|
||||
* foo
|
||||
* bar
|
||||
|
||||
`
|
||||
|
||||
errors := []error{
|
||||
errors.New("foo"),
|
||||
errors.New("bar"),
|
||||
}
|
||||
|
||||
multi := &Error{Errors: errors}
|
||||
if multi.Error() != expected {
|
||||
t.Fatalf("bad: %s", multi.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorErrorOrNil(t *testing.T) {
|
||||
err := new(Error)
|
||||
if err.ErrorOrNil() != nil {
|
||||
t.Fatalf("bad: %#v", err.ErrorOrNil())
|
||||
}
|
||||
|
||||
err.Errors = []error{errors.New("foo")}
|
||||
if v := err.ErrorOrNil(); v == nil {
|
||||
t.Fatal("should not be nil")
|
||||
} else if !reflect.DeepEqual(v, err) {
|
||||
t.Fatalf("bad: %#v", v)
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorWrappedErrors(t *testing.T) {
|
||||
errors := []error{
|
||||
errors.New("foo"),
|
||||
errors.New("bar"),
|
||||
}
|
||||
|
||||
multi := &Error{Errors: errors}
|
||||
if !reflect.DeepEqual(multi.Errors, multi.WrappedErrors()) {
|
||||
t.Fatalf("bad: %s", multi.WrappedErrors())
|
||||
}
|
||||
}
|
33
vendor/github.com/hashicorp/go-multierror/prefix_test.go
generated
vendored
33
vendor/github.com/hashicorp/go-multierror/prefix_test.go
generated
vendored
@ -1,33 +0,0 @@
|
||||
package multierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPrefix_Error(t *testing.T) {
|
||||
original := &Error{
|
||||
Errors: []error{errors.New("foo")},
|
||||
}
|
||||
|
||||
result := Prefix(original, "bar")
|
||||
if result.(*Error).Errors[0].Error() != "bar foo" {
|
||||
t.Fatalf("bad: %s", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrefix_NilError(t *testing.T) {
|
||||
var err error
|
||||
result := Prefix(err, "bar")
|
||||
if result != nil {
|
||||
t.Fatalf("bad: %#v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrefix_NonError(t *testing.T) {
|
||||
original := errors.New("foo")
|
||||
result := Prefix(original, "bar")
|
||||
if result.Error() != "bar foo" {
|
||||
t.Fatalf("bad: %s", result)
|
||||
}
|
||||
}
|
52
vendor/github.com/hashicorp/go-multierror/sort_test.go
generated
vendored
52
vendor/github.com/hashicorp/go-multierror/sort_test.go
generated
vendored
@ -1,52 +0,0 @@
|
||||
package multierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSortSingle(t *testing.T) {
|
||||
errFoo := errors.New("foo")
|
||||
|
||||
expected := []error{
|
||||
errFoo,
|
||||
}
|
||||
|
||||
err := &Error{
|
||||
Errors: []error{
|
||||
errFoo,
|
||||
},
|
||||
}
|
||||
|
||||
sort.Sort(err)
|
||||
if !reflect.DeepEqual(err.Errors, expected) {
|
||||
t.Fatalf("bad: %#v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortMultiple(t *testing.T) {
|
||||
errBar := errors.New("bar")
|
||||
errBaz := errors.New("baz")
|
||||
errFoo := errors.New("foo")
|
||||
|
||||
expected := []error{
|
||||
errBar,
|
||||
errBaz,
|
||||
errFoo,
|
||||
}
|
||||
|
||||
err := &Error{
|
||||
Errors: []error{
|
||||
errFoo,
|
||||
errBar,
|
||||
errBaz,
|
||||
},
|
||||
}
|
||||
|
||||
sort.Sort(err)
|
||||
if !reflect.DeepEqual(err.Errors, expected) {
|
||||
t.Fatalf("bad: %#v", err)
|
||||
}
|
||||
}
|
84
vendor/github.com/intel/govmm/qemu/qemu.go
generated
vendored
84
vendor/github.com/intel/govmm/qemu/qemu.go
generated
vendored
@ -103,6 +103,9 @@ const (
|
||||
|
||||
// PCIePCIBridgeDriver represents a PCIe to PCI bridge device type.
|
||||
PCIePCIBridgeDriver DeviceDriver = "pcie-pci-bridge"
|
||||
|
||||
// VirtioBlockCCW is the CCW block device driver
|
||||
VirtioBlockCCW DeviceDriver = "virtio-blk-ccw"
|
||||
)
|
||||
|
||||
// disableModern returns the parameters with the disable-modern option.
|
||||
@ -249,6 +252,9 @@ type FSDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the FSDevice structure is valid and complete.
|
||||
@ -275,6 +281,9 @@ func (fsdev FSDevice) QemuParams(config *Config) []string {
|
||||
if isVirtioPCI[fsdev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", fsdev.ROMFile))
|
||||
}
|
||||
if isVirtioCCW[fsdev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", fsdev.DevNo))
|
||||
}
|
||||
|
||||
fsParams = append(fsParams, string(fsdev.FSDriver))
|
||||
fsParams = append(fsParams, fmt.Sprintf(",id=%s", fsdev.ID))
|
||||
@ -335,6 +344,9 @@ type CharDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the CharDevice structure is valid and complete.
|
||||
@ -368,6 +380,10 @@ func (cdev CharDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", cdev.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[cdev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", cdev.DevNo))
|
||||
}
|
||||
|
||||
cdevParams = append(cdevParams, string(cdev.Backend))
|
||||
cdevParams = append(cdevParams, fmt.Sprintf(",id=%s", cdev.ID))
|
||||
if cdev.Backend == Socket {
|
||||
@ -450,6 +466,9 @@ type NetDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the NetDevice structure is valid and complete.
|
||||
@ -488,6 +507,7 @@ func (netdev NetDevice) mqParameter() string {
|
||||
vectors := len(netdev.FDs)*2 + 2
|
||||
p = append(p, fmt.Sprintf(",vectors=%d", vectors))
|
||||
}
|
||||
|
||||
return strings.Join(p, "")
|
||||
}
|
||||
|
||||
@ -526,6 +546,10 @@ func (netdev NetDevice) QemuDeviceParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", netdev.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[netdev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", netdev.DevNo))
|
||||
}
|
||||
|
||||
return deviceParams
|
||||
}
|
||||
|
||||
@ -617,6 +641,9 @@ type SerialDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the SerialDevice structure is valid and complete.
|
||||
@ -642,6 +669,10 @@ func (dev SerialDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", dev.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[dev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", dev.DevNo))
|
||||
}
|
||||
|
||||
qemuParams = append(qemuParams, "-device")
|
||||
qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
|
||||
|
||||
@ -694,6 +725,9 @@ type BlockDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the BlockDevice structure is valid and complete.
|
||||
@ -728,6 +762,10 @@ func (blkdev BlockDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", blkdev.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[blkdev.Driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", blkdev.DevNo))
|
||||
}
|
||||
|
||||
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))
|
||||
@ -860,6 +898,15 @@ type VFIODevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
|
||||
// VendorID specifies vendor id
|
||||
VendorID string
|
||||
|
||||
// DeviceID specifies device id
|
||||
DeviceID string
|
||||
}
|
||||
|
||||
// Valid returns true if the VFIODevice structure is valid and complete.
|
||||
@ -876,9 +923,19 @@ func (vfioDev VFIODevice) QemuParams(config *Config) []string {
|
||||
|
||||
deviceParams = append(deviceParams, fmt.Sprintf("%s,host=%s", driver, vfioDev.BDF))
|
||||
if isVirtioPCI[driver] {
|
||||
if vfioDev.VendorID != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",x-pci-vendor-id=%s", vfioDev.VendorID))
|
||||
}
|
||||
if vfioDev.DeviceID != "" {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",x-pci-device-id=%s", vfioDev.DeviceID))
|
||||
}
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", vfioDev.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", vfioDev.DevNo))
|
||||
}
|
||||
|
||||
qemuParams = append(qemuParams, "-device")
|
||||
qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
|
||||
|
||||
@ -903,6 +960,9 @@ type SCSIController struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the SCSIController structure is valid and complete.
|
||||
@ -933,6 +993,10 @@ func (scsiCon SCSIController) QemuParams(config *Config) []string {
|
||||
devParams = append(devParams, fmt.Sprintf("romfile=%s", scsiCon.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[driver] {
|
||||
devParams = append(devParams, fmt.Sprintf("devno=%s", scsiCon.DevNo))
|
||||
}
|
||||
|
||||
qemuParams = append(qemuParams, "-device")
|
||||
qemuParams = append(qemuParams, strings.Join(devParams, ","))
|
||||
|
||||
@ -1041,6 +1105,9 @@ type VSOCKDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
const (
|
||||
@ -1086,6 +1153,10 @@ func (vsock VSOCKDevice) QemuParams(config *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",romfile=%s", vsock.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", vsock.DevNo))
|
||||
}
|
||||
|
||||
qemuParams = append(qemuParams, "-device")
|
||||
qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
|
||||
|
||||
@ -1104,6 +1175,8 @@ type RngDevice struct {
|
||||
Period uint
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// Valid returns true if the RngDevice structure is valid and complete.
|
||||
@ -1131,6 +1204,10 @@ func (v RngDevice) QemuParams(_ *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf("romfile=%s", v.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf("devno=%s", v.DevNo))
|
||||
}
|
||||
|
||||
if v.Filename != "" {
|
||||
objectParams = append(objectParams, "filename="+v.Filename)
|
||||
}
|
||||
@ -1160,6 +1237,9 @@ type BalloonDevice struct {
|
||||
|
||||
// ROMFile specifies the ROM file being used for this device.
|
||||
ROMFile string
|
||||
|
||||
// DevNo identifies the ccw devices for s390x architecture
|
||||
DevNo string
|
||||
}
|
||||
|
||||
// QemuParams returns the qemu parameters built out of the BalloonDevice.
|
||||
@ -1178,6 +1258,10 @@ func (b BalloonDevice) QemuParams(_ *Config) []string {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf("romfile=%s", b.ROMFile))
|
||||
}
|
||||
|
||||
if isVirtioCCW[driver] {
|
||||
deviceParams = append(deviceParams, fmt.Sprintf("devno=%s", b.DevNo))
|
||||
}
|
||||
|
||||
if b.DeflateOnOOM {
|
||||
deviceParams = append(deviceParams, "deflate-on-oom=on")
|
||||
} else {
|
||||
|
3
vendor/github.com/intel/govmm/qemu/qemu_arch_base.go
generated
vendored
3
vendor/github.com/intel/govmm/qemu/qemu_arch_base.go
generated
vendored
@ -61,6 +61,9 @@ var isVirtioPCI = map[DeviceDriver]bool{
|
||||
PCIePCIBridgeDriver: true,
|
||||
}
|
||||
|
||||
// isVirtioCCW is a dummy map to return always false on no-s390x arch
|
||||
var isVirtioCCW = map[DeviceDriver]bool{}
|
||||
|
||||
// QemuNetdevParam converts to the QEMU -netdev parameter notation
|
||||
func (n NetDeviceType) QemuNetdevParam() string {
|
||||
switch n {
|
||||
|
21
vendor/github.com/intel/govmm/qemu/qemus390x.go
generated
vendored
21
vendor/github.com/intel/govmm/qemu/qemus390x.go
generated
vendored
@ -63,6 +63,27 @@ var isVirtioPCI = map[DeviceDriver]bool{
|
||||
PCIePCIBridgeDriver: false,
|
||||
}
|
||||
|
||||
// isVirtioCCW returns if the device is a ccw device
|
||||
var isVirtioCCW = map[DeviceDriver]bool{
|
||||
NVDIMM: false,
|
||||
Virtio9P: true,
|
||||
VirtioNetCCW: true,
|
||||
VirtioSerial: true,
|
||||
VirtioBlock: true,
|
||||
VirtioBlockCCW: true,
|
||||
Console: false,
|
||||
VirtioSerialPort: false,
|
||||
VHostVSock: true,
|
||||
VirtioRng: true,
|
||||
VirtioBalloon: true,
|
||||
VhostUserSCSI: false,
|
||||
VhostUserBlk: false,
|
||||
Vfio: true,
|
||||
VirtioScsi: true,
|
||||
PCIBridgeDriver: false,
|
||||
PCIePCIBridgeDriver: false,
|
||||
}
|
||||
|
||||
// QemuDeviceParam converts to the QEMU -device parameter notation
|
||||
// This function has been reimplemented for the s390x architecture to deal
|
||||
// with the VHOSTUSER case. Vhost user devices are not implemented on s390x
|
||||
|
18
vendor/github.com/intel/govmm/qemu/qmp.go
generated
vendored
18
vendor/github.com/intel/govmm/qemu/qmp.go
generated
vendored
@ -822,9 +822,13 @@ func (q *QMP) ExecuteDeviceAdd(ctx context.Context, blockdevID, devID, driver, b
|
||||
"driver": driver,
|
||||
"drive": blockdevID,
|
||||
}
|
||||
if bus != "" {
|
||||
|
||||
if isVirtioCCW[DeviceDriver(driver)] {
|
||||
args["devno"] = bus
|
||||
} else if bus != "" {
|
||||
args["bus"] = bus
|
||||
}
|
||||
|
||||
if shared && (q.version.Major > 2 || (q.version.Major == 2 && q.version.Minor >= 10)) {
|
||||
args["share-rw"] = "on"
|
||||
}
|
||||
@ -870,8 +874,14 @@ func (q *QMP) ExecuteSCSIDeviceAdd(ctx context.Context, blockdevID, devID, drive
|
||||
"id": devID,
|
||||
"driver": driver,
|
||||
"drive": blockdevID,
|
||||
"bus": bus,
|
||||
}
|
||||
|
||||
if isVirtioCCW[DeviceDriver(driver)] {
|
||||
args["devno"] = bus
|
||||
} else {
|
||||
args["bus"] = bus
|
||||
}
|
||||
|
||||
if scsiID >= 0 {
|
||||
args["scsi-id"] = scsiID
|
||||
}
|
||||
@ -1023,13 +1033,13 @@ func (q *QMP) ExecuteNetPCIDeviceAdd(ctx context.Context, netdevID, devID, macAd
|
||||
// using the device_add command. devID is the id of the device to add.
|
||||
// Must be valid QMP identifier. netdevID is the id of nic added by previous netdev_add.
|
||||
// queues is the number of queues of a nic.
|
||||
func (q *QMP) ExecuteNetCCWDeviceAdd(ctx context.Context, netdevID, devID, macAddr, addr, bus string, queues int) error {
|
||||
func (q *QMP) ExecuteNetCCWDeviceAdd(ctx context.Context, netdevID, devID, macAddr, bus string, queues int) error {
|
||||
args := map[string]interface{}{
|
||||
"id": devID,
|
||||
"driver": VirtioNetCCW,
|
||||
"netdev": netdevID,
|
||||
"mac": macAddr,
|
||||
"addr": addr,
|
||||
"devno": bus,
|
||||
}
|
||||
|
||||
if queues > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user