lxd/util/sys.go
func RuntimeLiblxcVersionAtLeast(major int, minor int, micro int) bool {
	version := golxc.Version()
	version = strings.Replace(version, " (devel)", "-devel", 1)
	parts := strings.Split(version, ".")
	partsLen := len(parts)
	if partsLen == 0 {
		return false
	}

	develParts := strings.Split(parts[partsLen-1], "-")
	if len(develParts) == 2 && develParts[1] == "devel" {
		return true
	}

	maj := -1
	min := -1
	mic := -1

	for i, v := range parts {
		if i > 2 {
			break
		}

		num, err := strconv.Atoi(v)
		if err != nil {
			return false
		}

		switch i {
		case 0:
			maj = num
		case 1:
			min = num
		case 2:
			mic = num
		}
	}

	/* Major version is greater. */
	if maj > major {
		return true
	}

	if maj < major {
		return false
	}

	/* Minor number is greater.*/
	if min > minor {
		return true
	}

	if min < minor {
		return false
	}

	/* Patch number is greater. */
	if mic > micro {
		return true
	}

	if mic < micro {
		return false
	}

	return true
}
func RuntimeLiblxcVersionAtLeast(major int, minor int, micro int) bool {
	version := golxc.Version()
	version = strings.Replace(version, " (devel)", "-devel", 1)
	parts := strings.Split(version, ".")
	partsLen := len(parts)
	if partsLen == 0 {
		return false
	}

	develParts := strings.Split(parts[partsLen-1], "-")
	if len(develParts) == 2 && develParts[1] == "devel" {
		return true
	}

	maj := -1
	min := -1
	mic := -1

	for i, v := range parts {
		if i > 2 {
			break
		}

		num, err := strconv.Atoi(v)
		if err != nil {
			return false
		}

		switch i {
		case 0:
			maj = num
		case 1:
			min = num
		case 2:
			mic = num
		}
	}

	/* Major version is greater. */
	if maj > major {
		return true
	}

	if maj < major {
		return false
	}

	/* Minor number is greater.*/
	if min > minor {
		return true
	}

	if min < minor {
		return false
	}

	/* Patch number is greater. */
	if mic > micro {
		return true
	}

	if mic < micro {
		return false
	}

	return true
}
func RuntimeLiblxcVersionAtLeast ( major int , minor int , micro int ) bool { version := golxc . Version ( ) version = strings . Replace ( version , " " , " " , 1 ) parts := strings . Split ( version , " " ) partsLen := len ( parts ) if partsLen == 0 { return false } develParts := strings . Split ( parts [ partsLen - 1 ] , " " ) if len ( develParts ) == 2 && develParts [ 1 ] == " " { return true } maj := - 1 min := - 1 mic := - 1 for i , v := range parts { if i > 2 { break } num , err := strconv . Atoi ( v ) if err != nil { return false } switch i { case 0 : maj = num case 1 : min = num case 2 : mic = num } } /* Major version is greater. */ if maj > major { return true } if maj < major { return false } /* Minor number is greater.*/ if min > minor { return true } if min < minor { return false } /* Patch number is greater. */ if mic > micro { return true } if mic < micro { return false } return true }
// RuntimeLiblxcVersionAtLeast checks if the system's liblxc matches the
// provided version requirement
RuntimeLiblxcVersionAtLeast checks if the system s liblxc matches the provided version requirement