libvirt-check-trim: improve machine type checking
This commit is contained in:
parent
b72e439aa9
commit
e18525babc
1 changed files with 8 additions and 3 deletions
|
@ -3,8 +3,10 @@
|
||||||
|
|
||||||
from __future__ import division, print_function
|
from __future__ import division, print_function
|
||||||
|
|
||||||
|
from distutils.version import LooseVersion
|
||||||
from lxml import objectify
|
from lxml import objectify
|
||||||
import libvirt
|
import libvirt
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,9 +26,12 @@ for domain in conn.listAllDomains():
|
||||||
tree = objectify.fromstring(xml)
|
tree = objectify.fromstring(xml)
|
||||||
|
|
||||||
machine = tree.os.type.get('machine')
|
machine = tree.os.type.get('machine')
|
||||||
if machine < 'pc-i440fx-2.1':
|
matches = re.match('^pc-(?:i440fx-)?([0-9.]*)', machine)
|
||||||
print('machine should be at least pc-i440fx-2.1')
|
if matches:
|
||||||
# Might want to check qemu-system-x86_64 -M help for supported
|
i440_version = matches.group(1)
|
||||||
|
if LooseVersion(i440_version) < LooseVersion('2.1'):
|
||||||
|
print('machine type (version) should be at least pc-i440fx-2.1')
|
||||||
|
# Might want to check "qemu-system-x86_64 -M help" for supported
|
||||||
# machines.
|
# machines.
|
||||||
|
|
||||||
if not hasattr(tree.devices, 'disk'):
|
if not hasattr(tree.devices, 'disk'):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue