mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
support: Take version strings in support declarations
This commit is contained in:
parent
a98505e691
commit
4788499bbd
@ -80,6 +80,20 @@ def _split_function_name(function):
|
||||
return (output[0], output[1])
|
||||
|
||||
|
||||
def _version_str_to_int(verstr):
|
||||
if verstr is None:
|
||||
return None
|
||||
if verstr == 0:
|
||||
return 0
|
||||
|
||||
if verstr.count(".") != 2:
|
||||
raise RuntimeError("programming error: version string '%s' needs "
|
||||
"two '.' in it.")
|
||||
|
||||
return ((int(verstr.split(".")[0]) * 1000000) +
|
||||
(int(verstr.split(".")[1]) * 1000) + (int(verstr.split(".")[2])))
|
||||
|
||||
|
||||
class _SupportCheck(object):
|
||||
"""
|
||||
@version: Minimum libvirt version required for this feature. Not used
|
||||
@ -104,20 +118,19 @@ class _SupportCheck(object):
|
||||
self.function = function
|
||||
self.args = args
|
||||
self.flag = flag
|
||||
self.version = version and int(version) or 0
|
||||
self.version = version
|
||||
self.drv_version = drv_version or {}
|
||||
self.drv_libvirt_version = drv_libvirt_version or {}
|
||||
|
||||
versions = ([self.version] + self.drv_libvirt_version.values())
|
||||
for v in versions:
|
||||
if v != 0 and v < 7009:
|
||||
for vstr in versions:
|
||||
v = _version_str_to_int(vstr)
|
||||
if vstr is not None and v != 0 and v < 7009:
|
||||
raise RuntimeError("programming error: Cannot enforce "
|
||||
"support checks for libvirt versions less than 0.7.9, "
|
||||
"since required APIs were not available. ver=%s" % v)
|
||||
"since required APIs were not available. ver=%s" % vstr)
|
||||
|
||||
def check_support(self, conn, data):
|
||||
minimum_libvirt_version = self.version
|
||||
|
||||
object_name, function_name = _split_function_name(self.function)
|
||||
|
||||
if function_name:
|
||||
@ -160,21 +173,23 @@ class _SupportCheck(object):
|
||||
actual_drv_ver = conn.conn_version()
|
||||
|
||||
# Check that local libvirt version is sufficient
|
||||
if minimum_libvirt_version > actual_lib_ver:
|
||||
if _version_str_to_int(self.version) > actual_lib_ver:
|
||||
return False
|
||||
|
||||
if self.drv_version:
|
||||
if drv_type not in self.drv_version:
|
||||
if "all" not in self.drv_version:
|
||||
return False
|
||||
elif actual_drv_ver < self.drv_version[drv_type]:
|
||||
elif (actual_drv_ver <
|
||||
_version_str_to_int(self.drv_version[drv_type])):
|
||||
return False
|
||||
|
||||
if self.drv_libvirt_version:
|
||||
if drv_type not in self.drv_libvirt_version:
|
||||
if "all" not in self.drv_version:
|
||||
return False
|
||||
elif actual_lib_ver < self.drv_libvirt_version[drv_type]:
|
||||
elif (actual_lib_ver <
|
||||
_version_str_to_int(self.drv_libvirt_version[drv_type])):
|
||||
return False
|
||||
|
||||
return True
|
||||
@ -198,21 +213,20 @@ SUPPORT_CONN_STORAGE = _make(function="virConnect.listStoragePools",
|
||||
SUPPORT_CONN_NODEDEV = _make(function="virConnect.listDevices", args=(None, 0))
|
||||
SUPPORT_CONN_FINDPOOLSOURCES = _make(
|
||||
function="virConnect.findStoragePoolSources")
|
||||
SUPPORT_CONN_KEYMAP_AUTODETECT = _make(drv_version={"qemu": 11000})
|
||||
SUPPORT_CONN_KEYMAP_AUTODETECT = _make(drv_version={"qemu": "0.11.0"})
|
||||
SUPPORT_CONN_GETHOSTNAME = _make(function="virConnect.getHostname", args=())
|
||||
SUPPORT_CONN_NETWORK = _make(function="virConnect.listNetworks", args=())
|
||||
SUPPORT_CONN_INTERFACE = _make(function="virConnect.listInterfaces", args=())
|
||||
SUPPORT_CONN_MAXVCPUS_XML = _make(version=8005)
|
||||
SUPPORT_CONN_MAXVCPUS_XML = _make(version="0.8.5")
|
||||
# Earliest version with working bindings
|
||||
SUPPORT_CONN_STREAM = _make(version=9003,
|
||||
function="virConnect.newStream",
|
||||
args=(0,))
|
||||
SUPPORT_CONN_STREAM = _make(
|
||||
version="0.9.3", function="virConnect.newStream", args=(0,))
|
||||
SUPPORT_CONN_GETVERSION = _make(function="virConnect.getVersion", args=())
|
||||
SUPPORT_CONN_LIBVERSION = _make(function="virConnect.getLibVersion", args=())
|
||||
SUPPORT_CONN_LISTALLDOMAINS = _make(function="virConnect.listAllDomains",
|
||||
args=())
|
||||
SUPPORT_CONN_LISTALLNETWORKS = _make(function="virConnect.listAllNetworks",
|
||||
args=())
|
||||
SUPPORT_CONN_LISTALLDOMAINS = _make(
|
||||
function="virConnect.listAllDomains", args=())
|
||||
SUPPORT_CONN_LISTALLNETWORKS = _make(
|
||||
function="virConnect.listAllNetworks", args=())
|
||||
SUPPORT_CONN_LISTALLSTORAGEPOOLS = _make(
|
||||
function="virConnect.listAllStoragePools",
|
||||
args=())
|
||||
@ -220,40 +234,43 @@ SUPPORT_CONN_LISTALLINTERFACES = _make(function="virConnect.listAllInterfaces",
|
||||
args=())
|
||||
SUPPORT_CONN_LISTALLDEVICES = _make(function="virConnect.listAllDevices",
|
||||
args=())
|
||||
SUPPORT_CONN_VIRTIO_MMIO = _make(version=1001002,
|
||||
drv_version={"qemu": 1006000})
|
||||
SUPPORT_CONN_DISK_SD = _make(version=1001002)
|
||||
SUPPORT_CONN_VIRTIO_MMIO = _make(
|
||||
version="1.1.2", drv_version={"qemu": "1.6.0"})
|
||||
SUPPORT_CONN_DISK_SD = _make(version="1.1.2")
|
||||
# This is an arbitrary check to say whether it's a good idea to
|
||||
# default to qcow2. It might be fine for xen or qemu older than the versions
|
||||
# here, but until someone tests things I'm going to be a bit conservative.
|
||||
SUPPORT_CONN_DEFAULT_QCOW2 = _make(version=8000,
|
||||
drv_version={"qemu": 1002000, "test": 0})
|
||||
SUPPORT_CONN_DEFAULT_USB2 = _make(version=9007,
|
||||
drv_version={"qemu": 1000000, "test": 0})
|
||||
SUPPORT_CONN_CAN_ACPI = _make(drv_version={"xen": 3001000, "all": 0})
|
||||
SUPPORT_CONN_SOUND_AC97 = _make(version=8000, drv_version={"qemu": 11000})
|
||||
SUPPORT_CONN_SOUND_ICH6 = _make(version=8008, drv_version={"qemu": 14000})
|
||||
SUPPORT_CONN_GRAPHICS_SPICE = _make(version=8006, drv_version={"qemu": 14000})
|
||||
SUPPORT_CONN_CHAR_SPICEVMC = _make(version=8008, drv_version={"qemu": 14000})
|
||||
SUPPORT_CONN_DIRECT_INTERFACE = _make(version=8007,
|
||||
drv_version={"qemu": 0, "test": 0})
|
||||
SUPPORT_CONN_DEFAULT_QCOW2 = _make(
|
||||
version="0.8.0", drv_version={"qemu": "1.2.0", "test": 0})
|
||||
SUPPORT_CONN_DEFAULT_USB2 = _make(
|
||||
version="0.9.7", drv_version={"qemu": "1.0.0", "test": 0})
|
||||
SUPPORT_CONN_CAN_ACPI = _make(drv_version={"xen": "3.1.0", "all": 0})
|
||||
SUPPORT_CONN_SOUND_AC97 = _make(
|
||||
version="0.8.0", drv_version={"qemu": "0.11.0"})
|
||||
SUPPORT_CONN_SOUND_ICH6 = _make(
|
||||
version="0.8.8", drv_version={"qemu": "0.14.0"})
|
||||
SUPPORT_CONN_GRAPHICS_SPICE = _make(
|
||||
version="0.8.6", drv_version={"qemu": "0.14.0"})
|
||||
SUPPORT_CONN_CHAR_SPICEVMC = _make(
|
||||
version="0.8.8", drv_version={"qemu": "0.14.0"})
|
||||
SUPPORT_CONN_DIRECT_INTERFACE = _make(
|
||||
version="0.8.7", drv_version={"qemu": 0, "test": 0})
|
||||
SUPPORT_CONN_FILESYSTEM = _make(
|
||||
drv_version={"qemu": 13000, "lxc": 0, "openvz": 0, "test": 0},
|
||||
drv_libvirt_version={"qemu": 8005, "lxc": 0, "openvz": 0, "test": 0})
|
||||
SUPPORT_CONN_AUTOSOCKET = _make(drv_libvirt_version={"qemu": 1000006})
|
||||
SUPPORT_CONN_ADVANCED_CLOCK = _make(
|
||||
drv_libvirt_version={"qemu": 8000})
|
||||
SUPPORT_CONN_VIRTIO_CONSOLE = _make(drv_libvirt_version={"qemu": 8003})
|
||||
SUPPORT_CONN_PANIC_DEVICE = _make(version=1002001,
|
||||
drv_version={"qemu": 1005000, "test": 0})
|
||||
SUPPORT_CONN_PM_DISABLE = _make(version="10002",
|
||||
drv_version={"qemu": 1002000, "test": 0})
|
||||
SUPPORT_CONN_QCOW2_LAZY_REFCOUNTS = _make(version="1001000",
|
||||
drv_version={"qemu": 1002000, "test": 0})
|
||||
SUPPORT_CONN_USBREDIR = _make(version="9005",
|
||||
drv_version={"qemu": 1003000, "test": 0})
|
||||
SUPPORT_CONN_DEVICE_BOOTORDER = _make(version="8008",
|
||||
drv_version={"qemu": 0, "test": 0})
|
||||
drv_version={"qemu": "0.13.0", "lxc": 0, "openvz": 0, "test": 0},
|
||||
drv_libvirt_version={"qemu": "0.8.5", "lxc": 0, "openvz": 0, "test": 0})
|
||||
SUPPORT_CONN_AUTOSOCKET = _make(drv_libvirt_version={"qemu": "1.0.6"})
|
||||
SUPPORT_CONN_ADVANCED_CLOCK = _make(drv_libvirt_version={"qemu": "0.8.0"})
|
||||
SUPPORT_CONN_VIRTIO_CONSOLE = _make(drv_libvirt_version={"qemu": "0.8.3"})
|
||||
SUPPORT_CONN_PANIC_DEVICE = _make(
|
||||
version="1.2.1", drv_version={"qemu": "1.5.0", "test": 0})
|
||||
SUPPORT_CONN_PM_DISABLE = _make(
|
||||
version="0.10.2", drv_version={"qemu": "1.2.0", "test": 0})
|
||||
SUPPORT_CONN_QCOW2_LAZY_REFCOUNTS = _make(
|
||||
version="1.1.0", drv_version={"qemu": "1.2.0", "test": 0})
|
||||
SUPPORT_CONN_USBREDIR = _make(
|
||||
version="0.9.5", drv_version={"qemu": "1.3.0", "test": 0})
|
||||
SUPPORT_CONN_DEVICE_BOOTORDER = _make(
|
||||
version="0.8.8", drv_version={"qemu": 0, "test": 0})
|
||||
|
||||
|
||||
# Domain checks
|
||||
@ -271,9 +288,9 @@ SUPPORT_DOMAIN_MIGRATE_DOWNTIME = _make(
|
||||
# downtime value
|
||||
args=(30, 12345678))
|
||||
SUPPORT_DOMAIN_JOB_INFO = _make(function="virDomain.jobInfo", args=())
|
||||
SUPPORT_DOMAIN_CONSOLE_STREAM = _make(version=8006)
|
||||
SUPPORT_DOMAIN_SET_METADATA = _make(version=9010)
|
||||
SUPPORT_DOMAIN_CPU_HOST_MODEL = _make(version=9010)
|
||||
SUPPORT_DOMAIN_CONSOLE_STREAM = _make(version="0.8.6")
|
||||
SUPPORT_DOMAIN_SET_METADATA = _make(version="0.9.10")
|
||||
SUPPORT_DOMAIN_CPU_HOST_MODEL = _make(version="0.9.10")
|
||||
SUPPORT_DOMAIN_LIST_SNAPSHOTS = _make(
|
||||
function="virDomain.listAllSnapshots", args=())
|
||||
SUPPORT_DOMAIN_GET_METADATA = _make(function="virDomain.metadata",
|
||||
@ -282,14 +299,14 @@ SUPPORT_DOMAIN_MEMORY_STATS = _make(function="virDomain.memoryStats", args=())
|
||||
|
||||
|
||||
# Pool checks
|
||||
SUPPORT_POOL_CREATEVOLFROM = _make(function="virStoragePool.createXMLFrom",
|
||||
version=8000)
|
||||
SUPPORT_POOL_CREATEVOLFROM = _make(
|
||||
function="virStoragePool.createXMLFrom", version="0.8.0")
|
||||
SUPPORT_POOL_ISACTIVE = _make(function="virStoragePool.isActive", args=())
|
||||
SUPPORT_POOL_LISTALLVOLUMES = _make(
|
||||
function="virStoragePool.listAllVolumes", args=())
|
||||
SUPPORT_POOL_METADATA_PREALLOC = _make(
|
||||
flag="VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA",
|
||||
version="1000001")
|
||||
version="1.0.1")
|
||||
|
||||
|
||||
# Interface checks
|
||||
@ -302,7 +319,7 @@ SUPPORT_INTERFACE_ISACTIVE = _make(function="virInterface.isActive", args=())
|
||||
# Stream checks
|
||||
# Latest I tested with, and since we will use it by default
|
||||
# for URL installs, want to be sure it works
|
||||
SUPPORT_STREAM_UPLOAD = _make(version=9004)
|
||||
SUPPORT_STREAM_UPLOAD = _make(version="0.9.4")
|
||||
|
||||
# Network checks
|
||||
SUPPORT_NET_ISACTIVE = _make(function="virNetwork.isActive", args=())
|
||||
|
Loading…
Reference in New Issue
Block a user