2014-02-06 15:12:12 +04:00
# Copyright (C) 2013, 2014 Red Hat, Inc.
2013-03-18 01:06:52 +04:00
#
2018-04-04 16:35:41 +03:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 22:00:02 +03:00
# See the COPYING file in the top-level directory.
2013-03-18 01:06:52 +04:00
import atexit
2018-01-06 23:08:23 +03:00
from distutils . spawn import find_executable
2017-10-11 14:35:50 +03:00
import io
2013-03-18 01:06:52 +04:00
import logging
import os
import shlex
2013-09-29 01:23:23 +04:00
import shutil
2013-03-18 01:06:52 +04:00
import sys
import traceback
import unittest
2018-12-19 19:53:14 +03:00
try :
import argcomplete
except ImportError :
argcomplete = None
2014-09-07 02:05:43 +04:00
from tests import virtinstall , virtclone , virtconvert , virtxml
2013-04-11 03:48:07 +04:00
from tests import utils
2013-03-18 01:06:52 +04:00
os . environ [ " LANG " ] = " en_US.UTF-8 "
2013-09-28 22:42:37 +04:00
os . environ [ " HOME " ] = " /tmp "
os . environ [ " DISPLAY " ] = " :3.4 "
2018-06-12 19:26:13 +03:00
TMP_IMAGE_DIR = " /tmp/__virtinst_cli_ "
XMLDIR = " tests/cli-test-xml "
2019-01-30 19:55:40 +03:00
OLD_OSINFO = utils . has_old_osinfo ( )
HAS_ISOINFO = find_executable ( " isoinfo " )
2013-03-18 01:06:52 +04:00
# Images that will be created by virt-install/virt-clone, and removed before
# each run
new_images = [
2018-06-12 19:26:13 +03:00
TMP_IMAGE_DIR + " new1.img " ,
TMP_IMAGE_DIR + " new2.img " ,
TMP_IMAGE_DIR + " new3.img " ,
TMP_IMAGE_DIR + " exist1-clone.img " ,
TMP_IMAGE_DIR + " exist2-clone.img " ,
2013-03-18 01:06:52 +04:00
]
# Images that are expected to exist before a command is run
exist_images = [
2018-06-12 19:26:13 +03:00
TMP_IMAGE_DIR + " exist1.img " ,
TMP_IMAGE_DIR + " exist2.img " ,
2013-03-18 01:06:52 +04:00
]
2018-10-13 00:15:20 +03:00
iso_links = [
" /tmp/fake-fedora17-tree.iso " ,
" /tmp/fake-centos65-label.iso " ,
2019-02-01 02:07:09 +03:00
" /tmp/fake-no-osinfo.iso " ,
2018-10-13 00:15:20 +03:00
]
2015-04-23 00:48:40 +03:00
exist_files = exist_images
2014-09-07 02:05:43 +04:00
new_files = new_images
2018-10-13 00:15:20 +03:00
clean_files = ( new_images + exist_images + iso_links )
2013-03-18 01:06:52 +04:00
test_files = {
2018-06-12 18:48:11 +03:00
' URI-TEST-FULL ' : utils . URIs . test_full ,
' URI-TEST-REMOTE ' : utils . URIs . test_remote ,
' URI-KVM ' : utils . URIs . kvm ,
' URI-KVM-ARMV7L ' : utils . URIs . kvm_armv7l ,
' URI-KVM-AARCH64 ' : utils . URIs . kvm_aarch64 ,
' URI-KVM-PPC64LE ' : utils . URIs . kvm_ppc64le ,
' URI-KVM-S390X ' : utils . URIs . kvm_s390x ,
2019-04-04 13:49:42 +03:00
' URI-QEMU-RISCV64 ' : utils . URIs . qemu_riscv64 ,
2018-06-12 19:26:13 +03:00
' NEWIMG1 ' : " /dev/default-pool/new1.img " ,
' NEWIMG2 ' : " /dev/default-pool/new2.img " ,
' NEWCLONEIMG1 ' : new_images [ 0 ] ,
' NEWCLONEIMG2 ' : new_images [ 1 ] ,
' NEWCLONEIMG3 ' : new_images [ 2 ] ,
' EXISTIMG1 ' : " /dev/default-pool/testvol1.img " ,
' EXISTIMG2 ' : " /dev/default-pool/testvol2.img " ,
' EXISTIMG3 ' : exist_images [ 0 ] ,
' EXISTIMG4 ' : exist_images [ 1 ] ,
2018-10-13 00:15:20 +03:00
' ISOTREE ' : iso_links [ 0 ] ,
' ISOLABEL ' : iso_links [ 1 ] ,
2019-02-01 02:07:09 +03:00
' ISO-NO-OS ' : iso_links [ 2 ] ,
2018-06-12 19:26:13 +03:00
' TREEDIR ' : " %s /fakefedoratree " % XMLDIR ,
' COLLIDE ' : " /dev/default-pool/collidevol1.img " ,
2013-03-18 01:06:52 +04:00
}
2019-01-30 19:55:40 +03:00
def has_old_osinfo ( ) :
if OLD_OSINFO :
return " osinfo is too old "
2019-02-04 00:18:50 +03:00
def missing_isoinfo ( ) :
2019-01-30 19:55:40 +03:00
if not HAS_ISOINFO :
return " isoinfo not installed "
2013-03-18 01:06:52 +04:00
######################
# Test class helpers #
######################
class Command ( object ) :
"""
Instance of a single cli command to test
"""
def __init__ ( self , cmd ) :
self . cmdstr = cmd % test_files
self . check_success = True
self . compare_file = None
2014-01-26 03:16:16 +04:00
self . input_file = None
2013-03-18 01:06:52 +04:00
2018-12-18 22:20:57 +03:00
self . need_conn = True
2019-01-30 19:55:40 +03:00
self . skip_cb = None
2018-09-01 01:28:08 +03:00
self . check_version = None
2018-10-11 19:14:19 +03:00
self . grep = None
2018-12-18 22:20:57 +03:00
self . nogrep = None
2014-01-30 17:50:52 +04:00
2013-03-18 01:06:52 +04:00
app , opts = self . cmdstr . split ( " " , 1 )
2014-01-19 02:01:43 +04:00
self . app = app
2013-03-18 01:06:52 +04:00
self . argv = [ os . path . abspath ( app ) ] + shlex . split ( opts )
2018-12-18 22:20:57 +03:00
self . env = None
2013-03-18 01:06:52 +04:00
2014-01-30 17:50:52 +04:00
def _launch_command ( self , conn ) :
2013-03-18 01:06:52 +04:00
logging . debug ( self . cmdstr )
app = self . argv [ 0 ]
2018-12-18 22:20:57 +03:00
oldenv = None
2013-03-18 01:06:52 +04:00
oldstdout = sys . stdout
oldstderr = sys . stderr
2014-01-26 03:16:16 +04:00
oldstdin = sys . stdin
2013-03-18 01:06:52 +04:00
oldargv = sys . argv
try :
2018-12-18 22:20:57 +03:00
if self . env :
oldenv = os . environ . copy ( )
os . environ . update ( self . env )
2018-01-27 22:19:12 +03:00
out = io . StringIO ( )
2017-10-11 14:36:00 +03:00
2013-03-18 01:06:52 +04:00
sys . stdout = out
sys . stderr = out
sys . argv = self . argv
2014-01-26 03:16:16 +04:00
if self . input_file :
2017-05-05 21:19:54 +03:00
sys . stdin = open ( self . input_file )
2013-03-18 01:06:52 +04:00
2014-02-09 01:36:45 +04:00
exc = " "
2013-03-18 01:06:52 +04:00
try :
2018-02-14 03:04:08 +03:00
if " virt-install " in app :
2013-03-18 01:06:52 +04:00
ret = virtinstall . main ( conn = conn )
2018-02-14 03:04:08 +03:00
elif " virt-clone " in app :
2013-03-18 01:06:52 +04:00
ret = virtclone . main ( conn = conn )
2018-02-14 03:04:08 +03:00
elif " virt-convert " in app :
2014-02-06 04:09:26 +04:00
ret = virtconvert . main ( conn = conn )
2018-02-14 03:04:08 +03:00
elif " virt-xml " in app :
2014-02-06 04:09:26 +04:00
ret = virtxml . main ( conn = conn )
2017-05-05 19:47:21 +03:00
except SystemExit as sys_e :
2013-03-18 01:06:52 +04:00
ret = sys_e . code
2014-02-09 01:36:45 +04:00
except Exception :
ret = - 1
exc = " \n " + " " . join ( traceback . format_exc ( ) )
2013-03-18 01:06:52 +04:00
if ret != 0 :
ret = - 1
2014-02-09 01:36:45 +04:00
outt = out . getvalue ( ) + exc
2013-03-18 01:06:52 +04:00
if outt . endswith ( " \n " ) :
outt = outt [ : - 1 ]
return ( ret , outt )
finally :
sys . stdout = oldstdout
sys . stderr = oldstderr
2014-01-26 03:16:16 +04:00
sys . stdin = oldstdin
2013-03-18 01:06:52 +04:00
sys . argv = oldargv
2018-12-18 22:20:57 +03:00
if oldenv :
os . environ = oldenv
2013-03-18 01:06:52 +04:00
2014-01-30 17:50:52 +04:00
def _get_output ( self , conn ) :
2013-03-18 01:06:52 +04:00
try :
for i in new_files :
2013-09-29 01:23:23 +04:00
if os . path . isdir ( i ) :
shutil . rmtree ( i )
elif os . path . exists ( i ) :
os . unlink ( i )
2013-03-18 01:06:52 +04:00
2014-01-30 17:50:52 +04:00
code , output = self . _launch_command ( conn )
2013-03-18 01:06:52 +04:00
2018-03-02 11:01:23 +03:00
logging . debug ( " %s \n " , output )
2013-03-18 01:06:52 +04:00
return code , output
2017-05-05 19:47:21 +03:00
except Exception as e :
2013-03-18 01:06:52 +04:00
return ( - 1 , " " . join ( traceback . format_exc ( ) ) + str ( e ) )
2016-01-27 04:00:38 +03:00
def _check_support ( self , tests , conn , check , skipmsg ) :
if check is None :
2013-08-17 21:50:36 +04:00
return
2013-08-18 16:59:19 +04:00
if conn is None :
2016-01-27 04:00:38 +03:00
raise RuntimeError ( " skip check is not None, but conn is None " )
2018-09-01 01:28:08 +03:00
# pylint: disable=protected-access
if conn . _check_version ( check ) :
return
2016-01-27 04:00:38 +03:00
tests . skipTest ( skipmsg )
return True
2013-08-17 21:50:36 +04:00
2019-05-14 16:54:12 +03:00
def _check_compare_file ( self , conn , tests , output ) :
if self . _check_support ( tests , conn , self . check_version ,
" Skipping compare check due to lack of support " ) :
return
# Generate test files that don't exist yet
filename = self . compare_file
if ( utils . clistate . regenerate_output or
not os . path . exists ( filename ) ) :
open ( filename , " w " ) . write ( output )
if " --print-diff " in self . argv and output . count ( " \n " ) > 3 :
# 1) Strip header
# 2) Simplify context lines to reduce churn when
# libvirt or testdriver changes
newlines = [ ]
for line in output . splitlines ( ) [ 3 : ] :
if line . startswith ( " @@ " ) :
line = " @@ "
newlines . append ( line )
output = " \n " . join ( newlines )
utils . diff_compare ( output , filename )
2019-05-14 17:09:57 +03:00
# Define the <domain>s generated for compare output, to ensure
# we are generating valid XML
if " --print-xml " in self . argv or " --print-step " in self . argv :
for domxml in output . split ( " </domain> " ) :
if " <domain " not in domxml :
continue
domxml = domxml + " </domain> "
try :
dom = conn . defineXML ( domxml )
dom . undefine ( )
except Exception as e :
raise AssertionError ( " Bad XML: \n %s \n \n Error was: %s : %s " %
( domxml , e . __class__ . __name__ , str ( e ) ) )
2019-05-14 16:54:12 +03:00
def _run ( self , tests ) :
conn = None
for idx in reversed ( range ( len ( self . argv ) ) ) :
if self . argv [ idx ] == " --connect " :
conn = utils . URIs . openconn ( self . argv [ idx + 1 ] )
break
if not conn and self . need_conn :
raise RuntimeError ( " couldn ' t parse URI from command %s " %
self . argv )
if self . skip_cb and self . skip_cb ( ) :
tests . skipTest ( " skip_cb: %s " % self . skip_cb ( ) )
return
code , output = self . _get_output ( conn )
def _raise_error ( _msg ) :
raise AssertionError (
( " Command was: %s \n " % self . cmdstr ) +
( " Error code : %d \n " % code ) +
( " Output was: \n %s " % output ) +
( " \n \n \n TESTSUITE: " + _msg + " \n " ) )
if bool ( code ) == self . check_success :
_raise_error ( " Expected command to %s , but it didn ' t. \n " %
( self . check_success and " pass " or " fail " ) )
if self . grep and self . grep not in output :
_raise_error ( " Didn ' t find grep= %s " % self . grep )
if self . nogrep and self . nogrep in output :
_raise_error ( " Found grep= %s when we shouldn ' t see it " %
self . nogrep )
if self . compare_file :
self . _check_compare_file ( conn , tests , output )
2013-08-18 16:59:19 +04:00
def run ( self , tests ) :
2013-03-18 01:06:52 +04:00
err = None
try :
2019-05-14 16:54:12 +03:00
self . _run ( tests )
2017-05-05 19:47:21 +03:00
except AssertionError as e :
2013-03-18 01:06:52 +04:00
err = self . cmdstr + " \n " + str ( e )
2013-08-18 16:59:19 +04:00
if err :
tests . fail ( err )
2013-03-18 01:06:52 +04:00
2013-08-17 17:44:11 +04:00
class _CategoryProxy ( object ) :
2019-01-30 19:55:40 +03:00
def __init__ ( self , app , name , default_args , skip_cb , check_version ) :
2013-08-17 17:44:11 +04:00
self . _app = app
self . _name = name
2014-01-30 17:50:52 +04:00
self . default_args = default_args
2019-01-30 19:55:40 +03:00
self . skip_cb = skip_cb
2018-09-01 01:28:08 +03:00
self . check_version = check_version
2014-01-30 17:50:52 +04:00
2013-08-17 17:44:11 +04:00
def add_valid ( self , * args , * * kwargs ) :
return self . _app . add_valid ( self . _name , * args , * * kwargs )
def add_invalid ( self , * args , * * kwargs ) :
return self . _app . add_invalid ( self . _name , * args , * * kwargs )
def add_compare ( self , * args , * * kwargs ) :
return self . _app . add_compare ( self . _name , * args , * * kwargs )
2013-04-24 00:16:30 +04:00
class App ( object ) :
2018-09-01 01:28:08 +03:00
def __init__ ( self , appname , uri = None , check_version = None ) :
2013-04-24 00:16:30 +04:00
self . appname = appname
self . categories = { }
self . cmds = [ ]
2018-09-01 01:28:08 +03:00
self . check_version = check_version
2018-02-20 23:00:46 +03:00
self . uri = uri
2013-04-24 00:16:30 +04:00
2014-05-12 03:19:00 +04:00
def _default_args ( self , cli , iscompare , auto_printarg ) :
2013-04-24 00:16:30 +04:00
args = " "
if not iscompare :
args = " --debug "
2014-02-06 04:09:26 +04:00
if " --connect " not in cli :
2018-06-12 19:26:13 +03:00
uri = self . uri or utils . URIs . test_suite
2018-02-20 23:00:46 +03:00
args + = " --connect %s " % uri
2013-04-24 00:16:30 +04:00
if self . appname in [ " virt-install " ] :
if " --name " not in cli :
args + = " --name foobar "
if " --ram " not in cli :
args + = " --ram 64 "
2014-05-12 03:19:00 +04:00
if iscompare and auto_printarg :
2013-04-24 00:16:30 +04:00
if self . appname == " virt-install " :
2018-02-14 03:04:08 +03:00
if ( " --print-xml " not in cli and
" --print-step " not in cli and
" --quiet " not in cli ) :
2013-04-24 00:16:30 +04:00
args + = " --print-step all "
elif self . appname == " virt-clone " :
2018-02-14 03:04:08 +03:00
if " --print-xml " not in cli :
2013-04-24 00:16:30 +04:00
args + = " --print-xml "
return args
2014-01-30 17:50:52 +04:00
def add_category ( self , catname , default_args ,
2019-01-30 19:55:40 +03:00
skip_cb = None , check_version = None ) :
2014-01-30 17:50:52 +04:00
obj = _CategoryProxy ( self , catname , default_args ,
2019-01-30 19:55:40 +03:00
skip_cb , check_version )
2014-01-30 17:50:52 +04:00
self . categories [ catname ] = obj
return obj
def _add ( self , catname , testargs , valid , compfile ,
2019-01-30 19:55:40 +03:00
skip_cb = None , check_version = None , input_file = None ,
2018-10-11 19:14:19 +03:00
auto_printarg = True , grep = None ) :
2013-04-24 00:16:30 +04:00
2014-01-30 17:50:52 +04:00
category = self . categories [ catname ]
args = category . default_args + " " + testargs
2014-05-12 03:19:00 +04:00
args = ( self . _default_args ( args , bool ( compfile ) , auto_printarg ) +
" " + args )
2013-04-24 00:16:30 +04:00
cmdstr = " ./ %s %s " % ( self . appname , args )
cmd = Command ( cmdstr )
cmd . check_success = valid
if compfile :
2014-02-06 04:09:26 +04:00
compfile = os . path . basename ( self . appname ) + " - " + compfile
2018-06-12 19:26:13 +03:00
compare_XMLDIR = " %s /compare " % XMLDIR
cmd . compare_file = " %s / %s .xml " % ( compare_XMLDIR , compfile )
2019-01-30 19:55:40 +03:00
cmd . skip_cb = skip_cb or category . skip_cb
2018-09-01 01:28:08 +03:00
cmd . check_version = ( check_version or
category . check_version or
self . check_version )
2014-01-26 03:16:16 +04:00
cmd . input_file = input_file
2018-10-11 19:14:19 +03:00
cmd . grep = grep
2013-04-24 00:16:30 +04:00
self . cmds . append ( cmd )
2013-08-17 21:50:36 +04:00
def add_valid ( self , cat , args , * * kwargs ) :
self . _add ( cat , args , True , None , * * kwargs )
def add_invalid ( self , cat , args , * * kwargs ) :
self . _add ( cat , args , False , None , * * kwargs )
def add_compare ( self , cat , args , compfile , * * kwargs ) :
self . _add ( cat , args , not compfile . endswith ( " -fail " ) ,
compfile , * * kwargs )
2013-04-24 00:16:30 +04:00
#
# The test matrix
#
# add_valid: A test that should pass
# add_invalid: A test that should fail
# add_compare: Get the generated XML, and compare against the passed filename
# in tests/clitest-xml/compare/
#
2014-12-10 17:33:02 +03:00
######################
# virt-install tests #
######################
2013-08-17 17:44:11 +04:00
2014-12-10 17:33:02 +03:00
vinst = App ( " virt-install " )
2013-08-17 17:44:11 +04:00
2014-12-10 17:33:02 +03:00
#############################################
# virt-install verbose XML comparison tests #
#############################################
2019-01-30 19:55:40 +03:00
c = vinst . add_category ( " xml-comparsion " , " --connect % (URI-KVM)s --noautoconsole --os-variant fedora-unknown " , skip_cb = has_old_osinfo )
2014-12-10 17:33:02 +03:00
# Singleton element test #1, for simpler strings
2019-05-14 18:25:52 +03:00
c . add_compare ( """
- - memory 1024
- - vcpus 4 , cores = 2 , threads = 2 , sockets = 2 - - cpuset = 1 , 3 - 5
- - cpu host - copy
- - description \" foobar & baz \"
2019-05-14 20:43:56 +03:00
- - boot uefi , smbios_mode = emulate , boot1 . dev = hd , boot . dev = network , initarg1 = bar = baz , initarg = foo
2019-05-14 18:25:52 +03:00
- - security type = dynamic
- - security type = none , model = dac
- - numatune 1 , 2 , 3 , 5 - 7 , ^ 6
- - memorybacking hugepages = on
- - features apic = off
- - clock offset = localtime
- - resource / virtualmachines / production
- - events on_crash = restart
2019-05-14 21:26:19 +03:00
- - metadata genid_enable = yes
2019-05-14 18:25:52 +03:00
- - disk none
- - console none
- - channel none
- - network none
- - controller usb2
- - graphics spice
- - video vga
- - sound none
- - redirdev none
- - memballoon none
- - smartcard none
- - watchdog default
- - tpm / dev / tpm0
- - rng / dev / random
2018-09-01 01:28:08 +03:00
""" , " singleton-config-1 " )
2014-12-10 17:33:02 +03:00
# Singleton element test #2, for complex strings
2019-05-14 18:25:52 +03:00
c . add_compare ( """ --pxe
- - memory 512 , maxmemory = 1024
- - vcpus 9
2019-05-15 23:14:33 +03:00
- - cpu foobar , + x2apic , + x2apicagain , - distest , forbid = foo , forbid = bar , disable = distest2 , optional = opttest , require = reqtest , match = strict , vendor = meee , mode = custom , \
virtinst: Add NUMA distance support
Now that libvirt has support for administration of distances between NUMA cells
it would be nice to be able to set those with virt-install directly instead of
having to 'virsh edit' the domain XML manually after installation.
For example
--cpu cell0.memory=1234,cell0.cpus=0-3,cell1.memory=5678,cell1.cpus=4-7,\
cell0.distances.sibling0.id=0,cell0.distances.sibling0.value=10,\
cell0.distances.sibling1.id=1,cell0.distances.sibling1.value=21,\
cell1.distances.sibling0.id=0,cell1.distances.sibling0.value=21,\
cell1.distances.sibling1.id=1,cell1.distances.sibling1.value=10
would generate the following XML:
<cpu>
<numa>
<cell cpus="0-3" memory="1234">
<distances>
<sibling id="0" value="10"/>
<sibling id="1" value="21"/>
</distances>
</cell>
<cell cpus="4-7" memory="5678">
<distances>
<sibling id="0" value="21"/>
<sibling id="1" value="10"/>
</distances>
</cell>
</numa>
</cpu>
Signed-off-by: Menno Lageman <menno.lageman@oracle.com>
(crobinso: rework cli format, drop some validation, drop man changes)
2018-01-22 15:36:00 +03:00
cell . id = 0 , cell . cpus = 1 , 2 , 3 , cell . memory = 1024 , \
cell1 . id = 1 , cell1 . memory = 256 , cell1 . cpus = 5 - 8 , \
2019-05-14 22:45:16 +03:00
numa . cell2 . id = 2 , numa . cell2 . memory = 256 , numa . cell2 . cpus = 4 , \
virtinst: Add NUMA distance support
Now that libvirt has support for administration of distances between NUMA cells
it would be nice to be able to set those with virt-install directly instead of
having to 'virsh edit' the domain XML manually after installation.
For example
--cpu cell0.memory=1234,cell0.cpus=0-3,cell1.memory=5678,cell1.cpus=4-7,\
cell0.distances.sibling0.id=0,cell0.distances.sibling0.value=10,\
cell0.distances.sibling1.id=1,cell0.distances.sibling1.value=21,\
cell1.distances.sibling0.id=0,cell1.distances.sibling0.value=21,\
cell1.distances.sibling1.id=1,cell1.distances.sibling1.value=10
would generate the following XML:
<cpu>
<numa>
<cell cpus="0-3" memory="1234">
<distances>
<sibling id="0" value="10"/>
<sibling id="1" value="21"/>
</distances>
</cell>
<cell cpus="4-7" memory="5678">
<distances>
<sibling id="0" value="21"/>
<sibling id="1" value="10"/>
</distances>
</cell>
</numa>
</cpu>
Signed-off-by: Menno Lageman <menno.lageman@oracle.com>
(crobinso: rework cli format, drop some validation, drop man changes)
2018-01-22 15:36:00 +03:00
cell0 . distances . sibling0 . id = 0 , cell0 . distances . sibling0 . value = 10 , \
cell0 . distances . sibling1 . id = 1 , cell0 . distances . sibling1 . value = 21 , \
2019-05-15 23:14:33 +03:00
numa . cell1 . distances . sibling0 . id = 0 , numa . cell1 . distances . sibling0 . value = 21 , \
virtinst: Add NUMA distance support
Now that libvirt has support for administration of distances between NUMA cells
it would be nice to be able to set those with virt-install directly instead of
having to 'virsh edit' the domain XML manually after installation.
For example
--cpu cell0.memory=1234,cell0.cpus=0-3,cell1.memory=5678,cell1.cpus=4-7,\
cell0.distances.sibling0.id=0,cell0.distances.sibling0.value=10,\
cell0.distances.sibling1.id=1,cell0.distances.sibling1.value=21,\
cell1.distances.sibling0.id=0,cell1.distances.sibling0.value=21,\
cell1.distances.sibling1.id=1,cell1.distances.sibling1.value=10
would generate the following XML:
<cpu>
<numa>
<cell cpus="0-3" memory="1234">
<distances>
<sibling id="0" value="10"/>
<sibling id="1" value="21"/>
</distances>
</cell>
<cell cpus="4-7" memory="5678">
<distances>
<sibling id="0" value="21"/>
<sibling id="1" value="10"/>
</distances>
</cell>
</numa>
</cpu>
Signed-off-by: Menno Lageman <menno.lageman@oracle.com>
(crobinso: rework cli format, drop some validation, drop man changes)
2018-01-22 15:36:00 +03:00
cell1 . distances . sibling1 . id = 1 , cell1 . distances . sibling1 . value = 10 , \
2019-05-14 18:25:52 +03:00
cache . mode = emulate , cache . level = 3
- - cputune vcpupin0 . vcpu = 0 , vcpupin0 . cpuset = 0 - 3
2019-05-14 21:26:19 +03:00
- - metadata title = my - title , description = my - description , uuid = 00000000 - 1111 - 2222 - 3333 - 444444444444 , genid = e9392370 - 2917 - 565e-692 b - d057f46512d6
2019-05-14 20:43:56 +03:00
- - boot cdrom , fd , hd , network , menu = off , loader = / foo / bar , emulator = / new / emu , bootloader = / new / bootld , rebootTimeout = 3 , initargs = " foo=bar baz=woo "
2019-05-14 18:25:52 +03:00
- - idmap uid_start = 0 , uid_target = 1000 , uid_count = 10 , gid_start = 0 , gid_target = 1000 , gid_count = 10
- - security type = static , label = ' system_u:object_r:svirt_image_t:s0:c100,c200 ' , relabel = yes , baselabel = baselabel
- - numatune 1 - 3 , 4 , mode = strict
- - memtune hard_limit = 10 , soft_limit = 20 , swap_hard_limit = 30 , min_guarantee = 40
- - blkiotune weight = 100 , device_path = / home / test / 1. img , device_weight = 200
2019-05-14 22:50:51 +03:00
- - memorybacking size = 1 , unit = ' G ' , nodeset = 0 , 1 , nosharepages = yes , locked = yes , discard = yes , allocation . mode = ondemand , access_mode = shared , source_type = anonymous , hugepages . page . size = 12 , hugepages . page1 . size = 1234 , hugepages . page1 . unit = MB , hugepages . page1 . nodeset = 2
2019-05-15 23:31:45 +03:00
- - features acpi = off , eoi = on , privnet = on , hyperv_synic = on , hyperv_reset = on , hyperv_spinlocks = on , hyperv_spinlocks_retries = 5678 , vmport = off , pmu = off , vmcoreinfo = on , kvm_hidden = off , hyperv_vapic = on
2019-05-14 18:25:52 +03:00
- - clock offset = utc , hpet_present = no , rtc_tickpolicy = merge , timer2 . name = hypervclock , timer3 . name = pit , timer1 . present = yes , timer3 . tickpolicy = delay , timer2 . present = no
- - sysinfo type = smbios , bios_vendor = " Acme LLC " , bios_version = 1.2 .3 , bios_date = 01 / 01 / 1970 , bios_release = 10.22
- - sysinfo type = smbios , system_manufacturer = " Acme Inc. " , system_product = Computer , system_version = 3.2 .1 , system_serial = 123456789 , system_uuid = 00000000 - 1111 - 2222 - 3333 - 444444444444 , system_sku = abc - 123 , system_family = Server
- - sysinfo type = smbios , baseBoard_manufacturer = " Acme Corp. " , baseBoard_product = Motherboard , baseBoard_version = A01 , baseBoard_serial = 1234 - 5678 , baseBoard_asset = Tag , baseBoard_location = Chassis
2019-05-14 21:05:08 +03:00
- - sysinfo type = smbios , chassis . manufacturer = " Chassis Corp. " , chassis . serial = 1234 chassis , chassis . asset = chasset , chassis . sku = chassku , chassis . version = 4.0
2019-05-14 21:16:14 +03:00
- - sysinfo type = smbios , oemStrings . entry2 = " complicated parsing, foo=bar " , oemStrings . entry1 = test1 , oemStrings . entry0 = test0
2019-05-14 18:25:52 +03:00
- - pm suspend_to_mem = yes , suspend_to_disk = no
- - resource partition = / virtualmachines / production
- - events on_poweroff = destroy , on_reboot = restart , on_crash = preserve , on_lockfailure = ignore
- - controller usb3
- - controller scsi , model = virtio - scsi
- - graphics vnc
- - filesystem / foo / source , / bar / target
- - memballoon virtio
- - watchdog ib700 , action = pause
- - tpm passthrough , model = tpm - crb , path = / dev / tpm0
- - rng egd , backend_host = 127.0 .0 .1 , backend_service = 8000 , backend_type = udp , backend_mode = bind , backend_connect_host = foo , backend_connect_service = 708
- - panic iobase = 0x506
2014-12-10 17:33:02 +03:00
""" , " singleton-config-2 " )
2019-05-15 22:31:43 +03:00
# Test the implied defaults for gl=yes setting virgl=on
c . add_compare ( """
- - memory 1024
- - disk none
2019-05-15 23:31:45 +03:00
- - features apic . eoi = off , hap = on , hyperv . synic . state = on , hyperv . reset . state = off , hyperv . spinlocks . state = on , hyperv . spinlocks . retries = 5678 , pae = on , pmu . state = on , pvspinlock . state = off , smm . state = off , viridian = on , vmcoreinfo . state = on , vmport . state = off , kvm . hidden . state = on , hyperv . vapic . state = off , hyperv . relaxed . state = off , gic . version = host
2019-05-15 23:08:28 +03:00
- - clock rtc_present = no , pit_present = yes , pit_tickpolicy = catchup , tsc_present = no , platform_present = no , hypervclock_present = no , platform_tickpolicy = foo , hpet_tickpolicy = bar , tsc_tickpolicy = wibble , kvmclock_tickpolicy = wobble , hypervclock_tickpolicy = woo
2019-05-15 22:46:08 +03:00
- - boot bios . useserial = no , bios . rebootTimeout = 60 , cmdline = root = / foo , smbios . mode = host , bootmenu . enable = yes , loader_ro = yes , loader . type = rom , loader = / tmp / foo
2019-05-15 23:01:38 +03:00
- - memorybacking access . mode = shared , source . type = anonymous , hugepages = on
2019-05-15 22:31:43 +03:00
- - graphics spice , gl = yes
- - rng egd , backend . type = nmdm , backend . source . master = / dev / foo1 , backend . source . slave = / dev / foo2
- - panic default , , address . type = isa , address . iobase = 0x500 , address . irq = 5
- - cpu topology . sockets = 1 , topology . cores = 3 , topology . threads = 2
2019-05-15 22:54:28 +03:00
- - vsock auto_cid = on
2019-05-15 22:31:43 +03:00
""" , " singleton-config-3 " )
2014-12-10 17:33:02 +03:00
2019-05-14 18:25:52 +03:00
c . add_compare ( """
2019-05-14 22:18:49 +03:00
- - vcpus 4 , cores = 1 , placement = static , \
vcpus . vcpu2 . id = 0 , vcpus . vcpu2 . enabled = no , \
vcpus . vcpu3 . id = 1 , vcpus . vcpu3 . hotpluggable = no , vcpus . vcpu3 . enabled = yes , \
vcpus . vcpu . id = 3 , vcpus . vcpu0 . enabled = yes , vcpus . vcpu0 . order = 3 , \
vcpus . vcpu1 . id = 2 , vcpus . vcpu1 . enabled = yes
2019-05-14 18:25:52 +03:00
- - cpu none
- - disk / dev / default - pool / UPPER , cache = writeback , io = threads , perms = sh , serial = WD - WMAP9A966149 , boot_order = 2
- - disk % ( NEWIMG1 ) s , sparse = false , size = .001 , perms = ro , error_policy = enospace , discard = unmap , detect_zeroes = unmap
- - disk device = cdrom , bus = sata , read_bytes_sec = 1 , read_iops_sec = 2 , write_bytes_sec = 5 , write_iops_sec = 6 , driver . copy_on_read = on , geometry . cyls = 16383 , geometry . heads = 16 , geometry . secs = 63 , geometry . trans = lba
- - disk size = 1
2019-05-15 23:26:23 +03:00
- - disk / iscsi - pool / diskvol1 , total_bytes_sec = 10 , total_iops_sec = 20 , bus = scsi , device = lun , sgio = unfiltered
- - disk / dev / default - pool / iso - vol , seclabel . model = dac , seclabel1 . model = selinux , seclabel1 . relabel = no , seclabel0 . label = foo , bar , baz , iotune . read_bytes_sec = 1 , iotune . read_iops_sec = 2 , iotune . write_bytes_sec = 5 , iotune . write_iops_sec = 6
- - disk / dev / default - pool / iso - vol , format = qcow2 , startup_policy = optional , iotune . total_bytes_sec = 10 , iotune . total_iops_sec = 20 ,
2019-05-14 18:25:52 +03:00
- - disk source_pool = rbd - ceph , source_volume = some - rbd - vol , size = .1 , driver_type = raw
2019-05-15 23:26:23 +03:00
- - disk pool = rbd - ceph , size = .1 , driver . name = qemu , driver . type = raw , driver . discard = unmap , driver . detect_zeroes = unmap , driver . io = native , driver . error_policy = stop
2019-05-14 18:25:52 +03:00
- - disk source_protocol = http , source_host_name = example . com , source_host_port = 8000 , source_name = / path / to / my / file
2019-05-15 23:26:23 +03:00
- - disk source . protocol = http , source . host0 . name = exampl2 . com , source . host . port = 8000 , source . name = / path / to / my / file
- - disk source . protocol = nbd , source . host . transport = unix , source . host . socket = / tmp / socket
- - disk source . protocol = nbd , source_host_transport = unix , source_host_socket = / tmp / socket , bus = scsi , logical_block_size = 512 , physical_block_size = 512 , blockio . logical_block_size = 512 , blockio . physical_block_size = 512 , target . dev = sdz
2019-05-14 18:25:52 +03:00
- - disk gluster : / / 192.168 .1 .100 / test - volume / some / dir / test - gluster . qcow2
- - disk nbd + unix : / / / var / foo / bar / socket , bus = usb , removable = on
- - disk path = http : / / [ 1 : 2 : 3 : 4 : 1 : 2 : 3 : 4 ] : 5522 / my / path ? query = foo
- - disk vol = gluster - pool / test - gluster . raw
2019-05-15 23:26:23 +03:00
- - disk / var , device = floppy , snapshot = no
- - disk % ( NEWIMG2 ) s , size = 1 , backing_store = / tmp / foo . img , backing_format = vmdk , bus = usb , target . removable = yes
2019-05-14 19:33:07 +03:00
- - disk / tmp / brand - new . img , size = 1 , backing_store = / dev / default - pool / iso - vol , boot . order = 10 , boot . loadparm = 5
2019-05-15 23:26:23 +03:00
- - disk path = / dev / disk - pool / diskvol7 , device = lun , bus = scsi , reservations . managed = no , reservations . source . type = unix , reservations . source . path = / var / run / test / pr - helper0 . sock , reservations . source . mode = client , \
source . reservations . managed = no , source . reservations . source . type = unix , source . reservations . source . path = / var / run / test / pr - helper0 . sock , source . reservations . source . mode = client
2019-05-14 18:25:52 +03:00
- - network user , mac = 12 : 34 : 56 : 78 : 11 : 22 , portgroup = foo , link_state = down , rom_bar = on , rom_file = / tmp / foo
- - network bridge = foobar , model = virtio , driver_name = qemu , driver_queues = 3
- - network bridge = ovsbr , virtualport_type = openvswitch , virtualport_profileid = demo , virtualport_interfaceid = 09 b11c53 - 8 b5c - 4 eeb - 8 f00 - d84eaa0aaa3b , link_state = yes
- - network type = direct , source = eth5 , source_mode = vepa , target = mytap12 , virtualport_type = 802.1 Qbg , virtualport_managerid = 12 , virtualport_typeid = 1193046 , virtualport_typeidversion = 1 , virtualport_instanceid = 09 b11c53 - 8 b5c - 4 eeb - 8 f00 - d84eaa0aaa3b , boot_order = 1 , trustGuestRxFilters = yes , mtu . size = 1500
- - network user , model = virtio , address . type = spapr - vio , address . reg = 0x500
- - network vhostuser , source_type = unix , source_path = / tmp / vhost1 . sock , source_mode = server , model = virtio
2019-05-14 19:33:07 +03:00
- - network user , address . type = ccw , address . cssid = 0xfe , address . ssid = 0 , address . devno = 01 , boot . order = 15 , boot . loadparm = SYSTEM1
2019-05-14 18:25:52 +03:00
- - graphics sdl
- - graphics spice , keymap = none
- - graphics vnc , port = 5950 , listen = 1.2 .3 .4 , keymap = ja , password = foo
- - graphics spice , port = 5950 , tlsport = 5950 , listen = 1.2 .3 .4 , keymap = ja
- - graphics spice , image_compression = glz , streaming_mode = filter , clipboard_copypaste = yes , mouse_mode = client , filetransfer_enable = on
- - graphics spice , gl = yes , listen = socket
- - graphics spice , gl = yes , listen = none
- - graphics spice , gl = yes , listen = none , rendernode = / dev / dri / foo
- - graphics spice , listens0 . type = address , listens0 . address = 1.2 .3 .4
- - graphics spice , listens0 . type = network , listens0 . network = default
- - graphics spice , listens0 . type = socket , listens0 . socket = / tmp / foobar
- - controller usb , model = ich9 - ehci1 , address = 0 : 0 : 4.7 , index = 0
- - controller usb , model = ich9 - uhci1 , address = 0 : 0 : 4.0 , index = 0 , master = 0 , address . multifunction = on
2019-05-15 23:13:38 +03:00
- - controller usb , model = ich9 - uhci2 , address = 0 : 0 : 4.1 , index = 0 , master . startport = 2
2019-05-14 18:25:52 +03:00
- - controller usb , model = ich9 - uhci3 , address = 0 : 0 : 4.2 , index = 0 , master = 4
2019-05-15 23:13:38 +03:00
- - controller scsi , model = virtio - scsi , driver_queues = 4 , driver . queues = 4
2019-05-14 18:25:52 +03:00
- - controller xenbus , maxGrantFrames = 64
- - input type = keyboard , bus = usb
- - input tablet
2019-05-15 21:43:37 +03:00
- - serial tcp , host = : 2222 , mode = bind , protocol = telnet , log . file = / tmp / foo . log , log . append = yes , , target . model . name = pci - serial
2019-05-14 19:25:00 +03:00
- - serial nmdm , source . master = / dev / foo1 , source . slave = / dev / foo2 , alias . name = testalias7
2019-05-14 18:25:52 +03:00
- - parallel udp , host = 0.0 .0 .0 : 1234 , bind_host = 127.0 .0 .1 : 1234
- - parallel unix , path = / tmp / foo - socket , source . seclabel0 . model = none , source . seclabel1 . model = dac , source . seclabel1 . relabel = yes , source . seclabel1 . label = foobar , source . seclabel . relabel = no
- - channel pty , target_type = guestfwd , target_address = 127.0 .0 .1 : 10000
2019-05-14 18:21:16 +03:00
- - channel pty , target_type = guestfwd , target_address = 127.0 .0 .1 , target . port = 1234
2019-05-14 18:25:52 +03:00
- - channel pty , target_type = virtio , name = org . linux - kvm . port1
- - console pty , target_type = virtio
- - channel spicevmc
- - hostdev net_00_1c_25_10_b1_e4 , boot_order = 4 , rom_bar = off
- - host - device usb_device_781_5151_2004453082054CA1BEEE
- - host - device 001.003
- - hostdev 15 : 0.1
- - host - device 2 : 15 : 0.2
2019-05-14 19:20:53 +03:00
- - hostdev 0 : 15 : 0.3 , address . type = pci , address . zpci . uid = 0xffff , address . zpci . fid = 0xffffffff
2019-05-14 18:25:52 +03:00
- - host - device 0x0781 : 0x5151 , driver_name = vfio
- - host - device 04 b3 : 4485
2019-05-15 23:03:26 +03:00
- - host - device pci_8086_2829_scsi_host_scsi_device_lun0 , rom . bar = on
2019-05-14 18:25:52 +03:00
- - hostdev usb_5_20 - - hostdev usb_5_21
2019-05-14 19:45:57 +03:00
- - filesystem / source , / target , alias . name = testfsalias , driver . ats = on , driver . iommu = off
2019-05-14 18:25:52 +03:00
- - filesystem template_name , / , type = template , mode = passthrough
- - filesystem type = file , source = / tmp / somefile . img , target = / mount / point , accessmode = squash
- - soundhw default
- - sound ac97
- - sound codec0 . type = micro , codec1 . type = duplex , codec2 . type = output
- - video cirrus
- - video model = qxl , vgamem = 1 , ram = 2 , vram = 3 , heads = 4 , accel3d = yes , vram64 = 65
- - smartcard passthrough , type = spicevmc
- - smartcard mode = host
- - smartcard default
2019-05-13 23:17:08 +03:00
- - smartcard passthrough , type = tcp , source . mode = bind , source . host = 1.2 .3 .4 , source . service = 5678 , protocol . type = telnet
2019-05-14 18:25:52 +03:00
- - smartcard host - certificates , type = spicevmc , database = / fake / path / to / database , certificate0 = / path / to / fake / cert0 , certificate1 = / path / to / fake / cert1 , certificate2 = / path / to / fake / cert2
- - redirdev usb , type = spicevmc
- - redirdev usb , type = tcp , server = localhost : 4000
- - redirdev usb , type = tcp , server = 127.0 .0 .1 : 4002 , boot_order = 3
- - redirdev default
2019-05-13 23:17:08 +03:00
- - redirdev type = unix , source . path = / tmp / foo . socket , log . file = / tmp / 123. log
2019-05-14 18:25:52 +03:00
- - rng egd , backend_host = 127.0 .0 .1 , backend_service = 8000 , backend_type = tcp
- - panic iobase = 507
- - vsock cid = 17
- - tpm emulator , model = tpm - crb , version = 2.0
- - qemu - commandline env = DISPLAY = : 0.1
- - qemu - commandline = " -display gtk,gl=on "
- - qemu - commandline = " -device vfio-pci,addr=05.0,sysfsdev=/sys/class/mdev_bus/0000:00:02.0/f321853c-c584-4a6b-b99a-3eee22a3919c "
- - qemu - commandline = " -set device.video0.driver=virtio-vga "
2018-09-01 01:28:08 +03:00
""" , " many-devices " , check_version= " 2.0.0 " ) # check_version=graphics listen=socket support
2013-08-17 17:44:11 +04:00
2016-03-04 14:31:53 +03:00
2017-01-26 17:08:36 +03:00
2017-01-26 18:11:31 +03:00
########################
# Boot install options #
########################
c = vinst . add_category ( " boot " , " --nographics --noautoconsole --import --disk none --controller usb,model=none " )
c . add_compare ( " --boot loader=/path/to/loader,loader_secure=yes " , " boot-loader-secure " )
2017-05-04 14:08:14 +03:00
2013-08-17 17:44:11 +04:00
2014-12-10 17:33:02 +03:00
####################################################
# CPU/RAM/numa and other singleton VM config tests #
####################################################
2013-08-17 17:44:11 +04:00
2014-12-10 17:33:02 +03:00
c = vinst . add_category ( " cpuram " , " --hvm --nographics --noautoconsole --nodisks --pxe " )
2018-06-12 19:26:13 +03:00
c . add_valid ( " --connect " + utils . URIs . xen + " --vcpus 4 --cpuset=auto " ) # cpuset=auto but xen doesn't support it
2014-12-10 17:33:02 +03:00
c . add_valid ( " --ram 4000000 " ) # Ram overcommit
c . add_valid ( " --vcpus sockets=2,threads=2 " ) # Topology only
c . add_valid ( " --cpu somemodel " ) # Simple --cpu
c . add_valid ( " --security label=foobar.label,relabel=yes " ) # --security implicit static
c . add_valid ( " --security label=foobar.label,a1,z2,b3,type=static,relabel=no " ) # static with commas 1
c . add_valid ( " --security label=foobar.label,a1,z2,b3 " ) # --security static with commas 2
c . add_invalid ( " --clock foo_tickpolicy=merge " ) # Unknown timer
c . add_invalid ( " --security foobar " ) # Busted --security
2018-02-23 02:21:51 +03:00
c . add_compare ( " --cpuset auto --vcpus 2 " , " cpuset-auto " ) # --cpuset=auto actually works
2019-05-14 19:25:00 +03:00
c . add_compare ( " --memory hotplugmemorymax=2048,hotplugmemoryslots=2 --cpu cell0.cpus=0,cell0.memory=1048576 --memdev dimm,access=private,target_size=512,target_node=0,source_pagesize=4,source_nodemask=1-2 --memdev nvdimm,source_path=/path/to/nvdimm,target_size=512,target_node=0,target_label_size=128,alias.name=mymemdev3 " , " memory-hotplug " )
2019-05-14 17:09:57 +03:00
c . add_compare ( " --memory currentMemory=100,memory=200,maxmemory=300,maxMemory=400,maxMemory.slots=1 " , " memory-option-backcompat " )
2019-03-29 12:59:25 +03:00
c . add_compare ( " --connect " + utils . URIs . kvm_q35 + " --cpu qemu64,secure=off " , " cpu-disable-sec " ) # disable security features that are added by default
2019-04-11 15:56:16 +03:00
c . add_compare ( " --connect " + utils . URIs . kvm_rhel , " cpu-rhel7-default " ) # default CPU for old QEMU where we cannot use host-model
2013-08-17 17:44:11 +04:00
2014-12-10 17:33:02 +03:00
########################
# Storage provisioning #
########################
2013-08-17 17:44:11 +04:00
c = vinst . add_category ( " storage " , " --pxe --nographics --noautoconsole --hvm " )
c . add_valid ( " --disk path= %(EXISTIMG1)s " ) # Existing disk, no extra options
2018-06-12 19:26:13 +03:00
c . add_valid ( " --disk pool=default-pool,size=.0001 --disk pool=default-pool,size=.0001 " ) # Create 2 volumes in a pool
c . add_valid ( " --disk vol=default-pool/testvol1.img " ) # Existing volume
2013-08-17 17:44:11 +04:00
c . add_valid ( " --disk path= %(EXISTIMG1)s --disk path= %(EXISTIMG1)s --disk path= %(EXISTIMG1)s --disk path= %(EXISTIMG1)s ,device=cdrom " ) # 3 IDE and CD
2014-12-10 17:33:02 +03:00
c . add_valid ( " --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi --disk path= %(EXISTIMG1)s ,bus=scsi " ) # > 16 scsi disks
2018-06-12 19:26:13 +03:00
c . add_valid ( " --disk path= %(NEWIMG1)s ,format=raw,size=.0000001 " ) # Managed file using format raw
c . add_valid ( " --disk path= %(NEWIMG1)s ,format=qcow2,size=.0000001 " ) # Managed file using format qcow2
2013-08-17 17:44:11 +04:00
c . add_valid ( " --disk %(EXISTIMG1)s " ) # Not specifying path=
c . add_valid ( " --disk %(NEWIMG1)s ,format=raw,size=.0000001 " ) # Not specifying path= but creating storage
2015-04-12 02:25:46 +03:00
c . add_valid ( " --disk %(COLLIDE)s --check path_in_use=off " ) # Colliding storage with --check
2013-08-17 17:44:11 +04:00
c . add_valid ( " --disk %(COLLIDE)s --force " ) # Colliding storage with --force
2018-06-12 19:26:13 +03:00
c . add_valid ( " --disk /dev/default-pool/sharevol.img,perms=sh " ) # Colliding shareable storage
2013-08-17 17:44:11 +04:00
c . add_valid ( " --disk path= %(EXISTIMG1)s ,device=cdrom --disk path= %(EXISTIMG1)s ,device=cdrom " ) # Two IDE cds
c . add_valid ( " --disk %(EXISTIMG1)s ,driver_name=qemu,driver_type=qcow2 " ) # Driver name and type options
2014-12-05 03:36:26 +03:00
c . add_valid ( " --disk /dev/zero " ) # Referencing a local unmanaged /dev node
2013-08-17 17:44:11 +04:00
c . add_valid ( " --disk pool=default,size=.00001 " ) # Building 'default' pool
2018-06-12 19:26:13 +03:00
c . add_valid ( " --disk /some/new/pool/dir/new,size=.1 " ) # autocreate the pool
2015-04-12 02:25:46 +03:00
c . add_valid ( " --disk %(NEWIMG1)s ,sparse=true,size=100000000 --check disk_size=off " ) # Don't warn about fully allocated file exceeding disk space
2017-09-06 10:13:44 +03:00
c . add_valid ( " --disk %(EXISTIMG1)s ,snapshot_policy=no " ) # Disable snasphot for disk
2013-08-17 17:44:11 +04:00
c . add_invalid ( " --file %(NEWIMG1)s --file-size 100000 --nonsparse " ) # Nonexisting file, size too big
c . add_invalid ( " --file %(NEWIMG1)s --file-size 100000 " ) # Huge file, sparse, but no prompting
c . add_invalid ( " --file %(NEWIMG1)s " ) # Nonexisting file, no size
c . add_invalid ( " --file %(EXISTIMG1)s --file %(EXISTIMG1)s --file %(EXISTIMG1)s --file %(EXISTIMG1)s --file %(EXISTIMG1)s " ) # Too many IDE
c . add_invalid ( " --disk pool=foopool,size=.0001 " ) # Specify a nonexistent pool
2018-06-12 19:26:13 +03:00
c . add_invalid ( " --disk vol=default-pool/foovol " ) # Specify a nonexistent volume
c . add_invalid ( " --disk pool=default-pool " ) # Specify a pool with no size
2013-08-17 17:44:11 +04:00
c . add_invalid ( " --disk path= %(EXISTIMG1)s ,perms=ro,size=.0001,cache=FOOBAR " ) # Unknown cache type
2014-02-09 01:36:45 +04:00
c . add_invalid ( " --disk path=/dev/foo/bar/baz,format=qcow2,size=.0000001 " ) # Unmanaged file using non-raw format
2018-06-12 19:26:13 +03:00
c . add_invalid ( " --disk path=/dev/disk-pool/newvol1.img,format=raw,size=.0000001 " ) # Managed disk using any format
2013-08-17 17:44:11 +04:00
c . add_invalid ( " --disk %(NEWIMG1)s " ) # Not specifying path= and non existent storage w/ no size
2014-02-05 01:16:39 +04:00
c . add_invalid ( " --disk %(NEWIMG1)s ,sparse=true,size=100000000000 " ) # Fail if fully allocated file would exceed disk space
2018-02-20 23:00:46 +03:00
c . add_invalid ( " --connect % (URI-TEST-FULL)s --disk %(COLLIDE)s " ) # Colliding storage without --force
c . add_invalid ( " --connect % (URI-TEST-FULL)s --disk %(COLLIDE)s --prompt " ) # Colliding storage with --prompt should still fail
c . add_invalid ( " --connect % (URI-TEST-FULL)s --disk /dev/default-pool/backingl3.img " ) # Colliding storage via backing store
2018-06-12 19:26:13 +03:00
c . add_invalid ( " --disk /var,device=cdrom " ) # Dir without floppy
2013-08-17 17:44:11 +04:00
c . add_invalid ( " --disk %(EXISTIMG1)s ,driver_name=foobar,driver_type=foobaz " ) # Unknown driver name and type options (as of 1.0.0)
2018-02-20 23:00:46 +03:00
c . add_invalid ( " --connect % (URI-TEST-FULL)s --disk source_pool=rbd-ceph,source_volume=vol1 " ) # Collision with existing VM, via source pool/volume
2019-05-15 23:26:23 +03:00
c . add_invalid ( " --disk source.pool=default-pool,source.volume=idontexist " ) # trying to lookup non-existent volume, hit specific error code
2015-09-06 20:42:07 +03:00
c . add_invalid ( " --disk size=1 --security model=foo,type=bar " ) # Libvirt will error on the invalid security params, which should trigger the code path to clean up the disk images we created.
2013-08-17 17:44:11 +04:00
2014-12-10 17:33:02 +03:00
################################################
# Invalid devices that hit virtinst code paths #
################################################
2013-08-17 17:44:11 +04:00
2014-12-10 17:33:02 +03:00
c = vinst . add_category ( " invalid-devices " , " --noautoconsole --nodisks --pxe " )
2018-02-20 23:00:46 +03:00
c . add_invalid ( " --connect % (URI-TEST-FULL)s --host-device 1d6b:2 " ) # multiple USB devices with identical vendorId and productId
c . add_invalid ( " --connect % (URI-TEST-FULL)s --host-device pci_8086_2850_scsi_host_scsi_host " ) # Unsupported hostdev type
2013-08-17 17:44:11 +04:00
c . add_invalid ( " --host-device foobarhostdev " ) # Unknown hostdev
c . add_invalid ( " --host-device 300:400 " ) # Parseable hostdev, but unknown digits
2014-12-10 17:33:02 +03:00
c . add_invalid ( " --graphics vnc,keymap=ZZZ " ) # Invalid keymap
c . add_invalid ( " --graphics vnc,port=-50 " ) # Invalid port
c . add_invalid ( " --graphics spice,tlsport=5 " ) # Invalid port
c . add_invalid ( " --serial unix " ) # Unix with no path
c . add_invalid ( " --channel pty,target_type=guestfwd " ) # --channel guestfwd without target_address
2015-02-18 23:16:48 +03:00
c . add_invalid ( " --boot uefi " ) # URI doesn't support UEFI bits
2015-04-23 00:06:35 +03:00
c . add_invalid ( " --connect % (URI-KVM)s --boot uefi,arch=ppc64 " ) # unsupported arch for UEFI
2018-02-23 02:21:51 +03:00
c . add_invalid ( " --features smm=on --machine pc " ) # smm=on doesn't work for machine=pc
2013-08-17 17:44:11 +04:00
2014-12-10 17:33:02 +03:00
########################
# Install option tests #
########################
c = vinst . add_category ( " nodisk-install " , " --nographics --noautoconsole --nodisks " )
2013-08-17 17:44:11 +04:00
c . add_valid ( " --hvm --cdrom %(EXISTIMG1)s " ) # Simple cdrom install
2014-12-10 17:33:02 +03:00
c . add_valid ( " --wait 0 --os-variant winxp --cdrom %(EXISTIMG1)s " ) # Windows (2 stage) install
c . add_valid ( " --pxe --virt-type test " ) # Explicit virt-type
2018-05-21 22:42:50 +03:00
c . add_valid ( " --arch i686 --pxe " ) # Explicitly fullvirt + arch
2019-01-31 19:34:13 +03:00
c . add_valid ( " --location location= %(TREEDIR)s " ) # Directory tree URL install
2014-12-10 17:33:02 +03:00
c . add_valid ( " --location %(TREEDIR)s --initrd-inject virt-install --extra-args ks=file:/virt-install " ) # initrd-inject
2013-08-17 17:44:11 +04:00
c . add_valid ( " --hvm --location %(TREEDIR)s --extra-args console=ttyS0 " ) # Directory tree URL install with extra-args
c . add_valid ( " --paravirt --location %(TREEDIR)s " ) # Paravirt location
c . add_valid ( " --paravirt --location %(TREEDIR)s --os-variant none " ) # Paravirt location with --os-variant none
2014-12-10 17:33:02 +03:00
c . add_valid ( " --location %(TREEDIR)s --os-variant fedora12 " ) # URL install with manual os-variant
c . add_valid ( " --cdrom %(EXISTIMG2)s --os-variant win2k3 --wait 0 " ) # HVM windows install with disk
virtinst: guest: drop 'continue_install' concept
continue_install is intended to facilitate windows XP style 3 stage
installs:
stage 1: initial dos style disk setup, reboot
stage 2: actual full installer, reboot
stage 3: OS is functional, virt-install is done
The code assumed that we needed to keep the cdrom as the primary
boot device for the second stage, so virt-install/virt-manager needed
to hang around through the second stage run, wait until the VM shutdown,
then encode the final XML to boot of the disk.
Windows is and always has been smart enough to handle that case though...
after the initial boot, if we set the hd as the primary boot device
for stage 2, the disk bits that windows already installed will make
use of the cdrom as necessary. So the entire premise of continue_install
is irrelevant. Maybe back when it was added, when xen didn't even have
working ACPI support, this served a purpose, but I'm pretty sure we
can safely drop it nowadays.
2016-06-16 23:13:54 +03:00
c . add_valid ( " --cdrom %(EXISTIMG2)s --os-variant win2k3 --wait 0 --print-step 2 " ) # HVM windows install, print 3rd stage XML
2014-12-10 17:33:02 +03:00
c . add_valid ( " --pxe --autostart " ) # --autostart flag
2018-10-12 22:40:40 +03:00
c . add_compare ( " --cdrom http://example.com/path/to/some.iso " , " cdrom-url " )
2014-12-10 17:33:02 +03:00
c . add_compare ( " --pxe --print-step all " , " simple-pxe " ) # Diskless PXE install
c . add_invalid ( " --pxe --virt-type bogus " ) # Bogus virt-type
c . add_invalid ( " --pxe --arch bogus " ) # Bogus arch
2013-08-17 17:44:11 +04:00
c . add_invalid ( " --livecd " ) # LiveCD with no media
2014-12-10 17:33:02 +03:00
c . add_invalid ( " --pxe --os-variant farrrrrrrge " ) # Bogus --os-variant
c . add_invalid ( " --pxe --boot menu=foobar " )
c . add_invalid ( " --cdrom %(EXISTIMG1)s --extra-args console=ttyS0 " ) # cdrom fail w/ extra-args
2014-09-23 22:14:21 +04:00
c . add_invalid ( " --hvm --boot kernel= %(TREEDIR)s /pxeboot/vmlinuz,initrd= %(TREEDIR)s /pxeboot/initrd.img,kernel_args= ' foo bar ' --initrd-inject virt-install " ) # initrd-inject with manual kernel/initrd
2019-02-01 02:07:09 +03:00
c . add_invalid ( " --disk none --location kernel=/dev/null,initrd=/dev/null " ) # --location with manual kernel/initrd, but not URL
2019-02-18 18:59:35 +03:00
c . add_invalid ( " --os-variant winxp,install=location " ) # no URL for winxp
c . add_invalid ( " --os-variant fedora28,install=fribber " ) # unknown install= value
2013-04-24 00:16:30 +04:00
2014-12-10 17:33:02 +03:00
c = vinst . add_category ( " single-disk-install " , " --nographics --noautoconsole --disk %(EXISTIMG1)s " )
c . add_valid ( " --hvm --import " ) # FV Import install
c . add_valid ( " --hvm --import --prompt --force " ) # Working scenario w/ prompt shouldn't ask anything
c . add_valid ( " --paravirt --import " ) # PV Import install
c . add_valid ( " --paravirt --print-xml " ) # print single XML, implied import install
c . add_compare ( " --cdrom %(EXISTIMG2)s --os-variant win2k3 --wait 0 --vcpus cores=4 --controller usb,model=none " , " w2k3-cdrom " ) # HVM windows install with disk
2015-04-05 00:10:45 +03:00
c . add_invalid ( " --paravirt --import --print-xml 2 " ) # PV Import install, no second XML step
2014-12-10 17:33:02 +03:00
c = vinst . add_category ( " misc-install " , " --nographics --noautoconsole " )
c . add_compare ( " " , " noargs-fail " , auto_printarg = False ) # No arguments
2019-05-11 00:22:23 +03:00
c . add_valid ( " --panic help --disk=? --check=help " , grep = " path_in_use " ) # Make sure introspection doesn't blow up
2018-06-12 17:50:36 +03:00
c . add_valid ( " --test-stub-command " ) # --test-stub-command
2018-10-13 19:55:34 +03:00
c . add_valid ( " --nodisks --pxe " , grep = " VM performance may suffer " ) # os variant warning
2014-12-10 17:33:02 +03:00
c . add_invalid ( " --hvm --nodisks --pxe foobar " ) # Positional arguments error
c . add_invalid ( " --nodisks --pxe --name test " ) # Colliding name
2018-10-13 17:23:00 +03:00
c . add_compare ( " --cdrom %(EXISTIMG1)s --disk size=1 --disk %(EXISTIMG2)s ,device=cdrom " , " cdrom-double " ) # ensure --disk device=cdrom is ordered after --cdrom, this is important for virtio-win installs with a driver ISO
2019-03-26 17:13:37 +03:00
c . add_valid ( " --connect %s --pxe --disk size=1 " % utils . URIs . test_defaultpool_collision ) # testdriver already has a pool using the 'default' path, make sure we don't error
2014-12-10 17:33:02 +03:00
#############################
# Remote URI specific tests #
#############################
2015-04-23 00:06:35 +03:00
c = vinst . add_category ( " remote " , " --connect % (URI-TEST-REMOTE)s --nographics --noautoconsole " )
2014-12-10 17:33:02 +03:00
c . add_valid ( " --nodisks --pxe " ) # Simple pxe nodisks
c . add_valid ( " --pxe --disk /foo/bar/baz,size=.01 " ) # Creating any random path on the remote host
c . add_valid ( " --pxe --disk /dev/zde " ) # /dev file that we just pass through to the remote VM
c . add_invalid ( " --pxe --disk /foo/bar/baz " ) # File that doesn't exist after auto storage setup
c . add_invalid ( " --nodisks --location /tmp " ) # Use of --location
c . add_invalid ( " --file /foo/bar/baz --pxe " ) # Trying to use unmanaged storage without size argument
###########################
# QEMU/KVM specific tests #
###########################
2018-09-01 01:28:08 +03:00
c = vinst . add_category ( " kvm-generic " , " --connect % (URI-KVM)s --noautoconsole " )
2019-01-30 19:55:40 +03:00
c . add_compare ( " --os-variant fedora-unknown --file %(EXISTIMG1)s --location %(TREEDIR)s --extra-args console=ttyS0 --cpu host --channel none --console none --sound none --redirdev none " , " kvm-fedoralatest-url " , skip_cb = has_old_osinfo ) # Fedora Directory tree URL install with extra-args
2014-12-10 17:33:02 +03:00
c . add_compare ( " --test-media-detection %(TREEDIR)s " , " test-url-detection " ) # --test-media-detection
2019-02-08 00:29:38 +03:00
c . add_compare ( " --os-variant full_id=http://fedoraproject.org/fedora/20 --disk %(NEWIMG1)s ,size=.01,format=vmdk --location %(TREEDIR)s --extra-args console=ttyS0 --quiet " , " quiet-url " , skip_cb = has_old_osinfo ) # Quiet URL install should make no noise
2014-12-10 17:33:02 +03:00
c . add_compare ( " --cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0 --sound --controller usb " , " kvm-win2k3-cdrom " ) # HVM windows install with disk
2017-02-22 22:38:32 +03:00
c . add_compare ( " --os-variant ubuntusaucy --nodisks --boot cdrom --virt-type qemu --cpu Penryn --input tablet " , " qemu-plain " ) # plain qemu
2019-01-30 19:55:40 +03:00
c . add_compare ( " --os-variant fedora20 --nodisks --boot network --nographics --arch i686 " , " qemu-32-on-64 " , skip_cb = has_old_osinfo ) # 32 on 64
2015-04-23 02:27:27 +03:00
# ppc64 tests
2016-06-07 17:32:18 +03:00
c . add_compare ( " --arch ppc64 --machine pseries --boot network --disk %(EXISTIMG1)s --disk device=cdrom --os-variant fedora20 --network none " , " ppc64-pseries-f20 " )
2014-12-10 17:33:02 +03:00
c . add_compare ( " --arch ppc64 --boot network --disk %(EXISTIMG1)s --os-variant fedora20 --network none " , " ppc64-machdefault-f20 " )
2018-02-23 02:21:51 +03:00
c . add_compare ( " --connect % (URI-KVM-PPC64LE)s --import --disk %(EXISTIMG1)s --os-variant fedora20 --panic default " , " ppc64le-kvm-import " )
2015-04-23 02:27:27 +03:00
2015-07-13 14:35:24 +03:00
# s390x tests
2019-01-30 19:55:40 +03:00
c . add_compare ( " --arch s390x --machine s390-ccw-virtio --connect % (URI-KVM-S390X)s --boot kernel=/kernel.img,initrd=/initrd.img --disk %(EXISTIMG1)s --disk %(EXISTIMG3)s ,device=cdrom --os-variant fedora21 " , " s390x-cdrom " , skip_cb = has_old_osinfo )
2018-12-14 00:39:43 +03:00
c . add_compare ( " --arch s390x --machine s390-ccw-virtio --connect " + utils . URIs . kvm_s390x_KVMIBM + " --boot kernel=/kernel.img,initrd=/initrd.img --disk %(EXISTIMG1)s --disk %(EXISTIMG3)s ,device=cdrom --os-variant fedora21 --watchdog diag288,action=reset --panic default --graphics vnc " , " s390x-cdrom-KVMIBM " )
2015-07-13 14:35:24 +03:00
2015-08-10 19:46:47 +03:00
# qemu:///session tests
2019-01-30 19:55:40 +03:00
c . add_compare ( " --connect " + utils . URIs . kvm_session + " --disk size=8 --os-variant fedora21 --cdrom %(EXISTIMG1)s " , " kvm-session-defaults " , skip_cb = has_old_osinfo )
2015-08-10 19:46:47 +03:00
# misc KVM config tests
2019-02-04 00:18:50 +03:00
c . add_compare ( " --disk none --location % (ISO-NO-OS)s,kernel=frib.img,initrd=/frob.img " , " location-manual-kernel " , skip_cb = missing_isoinfo ) # --location with an unknown ISO but manually specified kernel paths
c . add_compare ( " --disk %(EXISTIMG1)s --location %(ISOTREE)s --nonetworks " , " location-iso " , skip_cb = missing_isoinfo ) # Using --location iso mounting
2018-10-13 00:15:20 +03:00
c . add_compare ( " --disk %(EXISTIMG1)s --cdrom %(ISOLABEL)s " , " cdrom-centos-label " ) # Using --cdrom with centos CD label, should use virtio etc.
2018-09-14 21:37:12 +03:00
c . add_compare ( " --disk %(EXISTIMG1)s --pxe --os-variant rhel5.4 " , " kvm-rhel5 " ) # RHEL5 defaults
2014-12-10 17:33:02 +03:00
c . add_compare ( " --disk %(EXISTIMG1)s --pxe --os-variant rhel6.4 " , " kvm-rhel6 " ) # RHEL6 defaults
2019-01-30 19:55:40 +03:00
c . add_compare ( " --disk %(EXISTIMG1)s --pxe --os-variant rhel7.0 " , " kvm-rhel7 " , skip_cb = has_old_osinfo ) # RHEL7 defaults
c . add_compare ( " --connect " + utils . URIs . kvm_nodomcaps + " --disk %(EXISTIMG1)s --pxe --os-variant rhel7.0 " , " kvm-cpu-default-fallback " , skip_cb = has_old_osinfo ) # No domcaps, so mode=host-model isn't safe, so we fallback to host-model-only
2018-10-14 00:47:31 +03:00
c . add_compare ( " --connect " + utils . URIs . kvm_nodomcaps + " --cpu host-copy --disk none --pxe " , " kvm-hostcopy-fallback " ) # No domcaps so need to use capabilities for CPU host-copy
2019-01-30 19:55:40 +03:00
c . add_compare ( " --disk %(EXISTIMG1)s --pxe --os-variant centos7.0 " , " kvm-centos7 " , skip_cb = has_old_osinfo ) # Centos 7 defaults
c . add_compare ( " --disk %(EXISTIMG1)s --pxe --os-variant centos7.0 " , " kvm-centos7 " , skip_cb = has_old_osinfo ) # Centos 7 defaults
c . add_compare ( " --disk %(EXISTIMG1)s --cdrom %(EXISTIMG2)s --os-variant win10 " , " kvm-win10 " , skip_cb = has_old_osinfo ) # win10 defaults
c . add_compare ( " --os-variant win7 --cdrom %(EXISTIMG2)s --boot loader_type=pflash,loader=CODE.fd,nvram_template=VARS.fd --disk %(EXISTIMG1)s " , " win7-uefi " , skip_cb = has_old_osinfo ) # no HYPER-V with UEFI
2018-08-08 22:11:19 +03:00
c . add_compare ( " --arch i686 --boot uefi --pxe --disk none " , " kvm-i686-uefi " ) # i686 uefi
2015-04-23 02:27:27 +03:00
c . add_compare ( " --machine q35 --cdrom %(EXISTIMG2)s --disk %(EXISTIMG1)s " , " q35-defaults " ) # proper q35 disk defaults
2018-10-13 19:40:22 +03:00
c . add_compare ( " --disk size=20 --os-variant solaris10 " , " solaris10-defaults " ) # test solaris OS defaults, triggers a couple specific code paths
c . add_compare ( " --disk size=1 --os-variant openbsd4.9 " , " openbsd-defaults " ) # triggers net fallback scenario
2019-01-30 19:55:40 +03:00
c . add_compare ( " --connect " + utils . URIs . kvm_remote + " --import --disk %(EXISTIMG1)s --os-variant fedora21 --pm suspend_to_disk=yes " , " f21-kvm-remote " , skip_cb = has_old_osinfo )
2015-11-03 19:15:26 +03:00
2018-06-12 19:26:13 +03:00
c . add_valid ( " --arch aarch64 --nodisks --pxe --connect " + utils . URIs . kvm_nodomcaps ) # attempt to default to aarch64 UEFI, but it fails, but should only print warnings
2014-12-10 17:33:02 +03:00
c . add_invalid ( " --disk none --boot network --machine foobar " ) # Unknown machine type
c . add_invalid ( " --nodisks --boot network --arch mips --virt-type kvm " ) # Invalid domain type for arch
c . add_invalid ( " --nodisks --boot network --paravirt --arch mips " ) # Invalid arch/virt combo
2018-06-12 20:49:25 +03:00
c . add_invalid ( " --disk none --location nfs:example.com/fake --nonetworks " ) # Using --location nfs, no longer supported
2014-12-10 17:33:02 +03:00
2018-09-01 01:28:08 +03:00
c = vinst . add_category ( " kvm-q35 " , " --noautoconsole --connect " + utils . URIs . kvm_q35 )
2017-02-06 15:46:06 +03:00
c . add_compare ( " --boot uefi --disk none " , " boot-uefi " )
2014-12-10 17:33:02 +03:00
2018-09-01 01:28:08 +03:00
c = vinst . add_category ( " kvm-arm " , " --connect % (URI-KVM)s --noautoconsole " , check_version = " 3.3.0 " ) # required qemu-xhci from libvirt 3.3.0
# armv7l tests
c . add_compare ( " --arch armv7l --machine vexpress-a9 --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initrd,dtb=/f19-arm.dtb,extra_args= \" console=ttyAMA0 rw root=/dev/mmcblk0p3 \" --disk %(EXISTIMG1)s --nographics " , " arm-vexpress-plain " )
c . add_compare ( " --arch armv7l --machine virt --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initrd,kernel_args= \" console=ttyAMA0,1234 rw root=/dev/vda3 \" --disk %(EXISTIMG1)s --nographics --os-variant fedora20 " , " arm-virt-f20 " )
c . add_compare ( " --arch armv7l --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initrd,kernel_args= \" console=ttyAMA0,1234 rw root=/dev/vda3 \" ,extra_args=foo --disk %(EXISTIMG1)s --os-variant fedora20 " , " arm-defaultmach-f20 " )
c . add_compare ( " --connect % (URI-KVM-ARMV7L)s --disk %(EXISTIMG1)s --import --os-variant fedora20 " , " arm-kvm-import " )
# aarch64 tests
c . add_compare ( " --arch aarch64 --machine virt --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initrd,kernel_args= \" console=ttyAMA0,1234 rw root=/dev/vda3 \" --disk %(EXISTIMG1)s " , " aarch64-machvirt " )
c . add_compare ( " --arch aarch64 --boot kernel=/f19-arm.kernel,initrd=/f19-arm.initrd,kernel_args= \" console=ttyAMA0,1234 rw root=/dev/vda3 \" --disk %(EXISTIMG1)s " , " aarch64-machdefault " )
2019-05-15 22:46:08 +03:00
c . add_compare ( " --arch aarch64 --cdrom %(EXISTIMG2)s --boot loader=CODE.fd,nvram.template=VARS.fd --disk %(EXISTIMG1)s --cpu none --events on_crash=preserve,on_reboot=destroy,on_poweroff=restart " , " aarch64-cdrom " )
2018-09-01 01:28:08 +03:00
c . add_compare ( " --connect % (URI-KVM-AARCH64)s --disk %(EXISTIMG1)s --import --os-variant fedora21 " , " aarch64-kvm-import " )
c . add_compare ( " --connect % (URI-KVM-AARCH64)s --disk size=1 --os-variant fedora22 --features gic_version=host --network network=default,address.type=pci --controller type=scsi,model=virtio-scsi,address.type=pci " , " aarch64-kvm-gic " )
2019-03-20 18:52:31 +03:00
# Simple headless guests for various architectures
c = vinst . add_category ( " kvm-headless " , " --os-variant fedora29 --import --disk %(EXISTIMG1)s --network default --graphics none " )
c . add_compare ( " --connect % (URI-KVM-AARCH64)s --arch aarch64 " , " aarch64-headless " )
c . add_compare ( " --connect % (URI-KVM-PPC64LE)s --arch ppc64le " , " ppc64-headless " )
2019-04-04 13:49:49 +03:00
c . add_compare ( " --connect % (URI-QEMU-RISCV64)s --arch riscv64 " , " riscv64-headless " , check_version = " 5.3.0 " )
2019-03-20 18:52:31 +03:00
c . add_compare ( " --connect % (URI-KVM-S390X)s --arch s390x " , " s390x-headless " )
c . add_compare ( " --connect % (URI-KVM)s --arch x86_64 " , " x86_64-headless " )
2019-03-20 18:52:32 +03:00
# Simple guests with graphics for various architectures
c = vinst . add_category ( " kvm-graphics " , " --os-variant fedora29 --import --disk %(EXISTIMG1)s --network default --graphics vnc " )
c . add_compare ( " --connect % (URI-KVM-AARCH64)s --arch aarch64 " , " aarch64-graphics " )
c . add_compare ( " --connect % (URI-KVM-PPC64LE)s --arch ppc64le " , " ppc64-graphics " )
2019-04-04 13:49:49 +03:00
c . add_compare ( " --connect % (URI-QEMU-RISCV64)s --arch riscv64 " , " riscv64-graphics " , check_version = " 5.3.0 " )
2019-03-20 18:52:32 +03:00
c . add_compare ( " --connect % (URI-KVM-S390X)s --arch s390x " , " s390x-graphics " )
c . add_compare ( " --connect % (URI-KVM)s --arch x86_64 " , " x86_64-graphics " )
2018-09-01 01:28:08 +03:00
2014-12-10 17:33:02 +03:00
######################
# LXC specific tests #
######################
2018-06-12 19:26:13 +03:00
c = vinst . add_category ( " lxc " , " --name foolxc --memory 64 --noautoconsole --connect " + utils . URIs . lxc )
2014-12-10 17:33:02 +03:00
c . add_compare ( " " , " default " )
2019-02-03 23:38:48 +03:00
c . add_compare ( " --os-variant fedora27 " , " default-f27 " )
2014-12-10 17:33:02 +03:00
c . add_compare ( " --filesystem /source,/ " , " fs-default " )
c . add_compare ( " --init /usr/bin/httpd " , " manual-init " )
######################
# Xen specific tests #
######################
2018-06-12 19:26:13 +03:00
c = vinst . add_category ( " xen " , " --noautoconsole --connect " + utils . URIs . xen )
2015-09-22 18:26:13 +03:00
c . add_valid ( " --disk %(EXISTIMG1)s --location %(TREEDIR)s --paravirt --graphics none " ) # Xen PV install headless
2014-12-10 17:33:02 +03:00
c . add_compare ( " --disk %(EXISTIMG1)s --import " , " xen-default " ) # Xen default
2019-03-20 23:24:41 +03:00
c . add_compare ( " --disk %(EXISTIMG1)s --location %(TREEDIR)s --paravirt --controller xenbus,maxGrantFrames=64 " , " xen-pv " ) # Xen PV
2018-06-12 19:26:13 +03:00
c . add_compare ( " --disk /iscsi-pool/diskvol1 --cdrom %(EXISTIMG1)s --livecd --hvm " , " xen-hvm " ) # Xen HVM
2014-12-10 17:33:02 +03:00
2013-04-24 00:16:30 +04:00
2017-02-21 17:28:00 +03:00
#####################
# VZ specific tests #
#####################
2018-06-12 19:26:13 +03:00
c = vinst . add_category ( " vz " , " --noautoconsole --connect " + utils . URIs . vz )
2017-04-27 20:11:13 +03:00
c . add_valid ( " --container " ) # validate the special define+start logic
c . add_invalid ( " --container --transient " ) # doesn't support --transient
2019-05-14 18:25:52 +03:00
c . add_compare ( """
- - container
- - filesystem type = template , source = centos - 7 - x86_64 , target = " / "
- - network network = " Bridged "
2017-02-21 17:28:00 +03:00
""" , " vz-ct-template " )
2014-12-10 17:33:02 +03:00
#####################################
# Device option back compat testing #
#####################################
c = vinst . add_category ( " device-back-compat " , " --nodisks --pxe --noautoconsole " )
c . add_valid ( " --sdl " ) # SDL
c . add_valid ( " --vnc --keymap ja --vncport 5950 --vnclisten 1.2.3.4 " ) # VNC w/ lots of options
c . add_valid ( " --sound " ) # --sound with no option back compat
c . add_valid ( " --mac 22:22:33:44:55:AF " ) # Just a macaddr
c . add_valid ( " --bridge mybr0 --mac 22:22:33:44:55:AF " ) # Old bridge w/ mac
c . add_valid ( " --network bridge:mybr0,model=e1000 " ) # --network bridge:
c . add_valid ( " --network network:default --mac RANDOM " ) # VirtualNetwork with a random macaddr
c . add_valid ( " --vnc --keymap=local " ) # --keymap local
2017-09-04 19:40:34 +03:00
c . add_valid ( " --panic 0x505 " ) # ISA panic with iobase specified
2014-12-10 17:33:02 +03:00
c . add_invalid ( " --graphics vnc --vnclisten 1.2.3.4 " ) # mixing old and new
c . add_invalid ( " --network=FOO " ) # Nonexistent network
c . add_invalid ( " --mac 1234 " ) # Invalid mac
c . add_invalid ( " --network user --bridge foo0 " ) # Mixing bridge and network
2018-02-20 23:00:46 +03:00
c . add_invalid ( " --connect % (URI-TEST-FULL)s --mac 22:22:33:12:34:AB " ) # Colliding macaddr
2014-12-10 17:33:02 +03:00
c = vinst . add_category ( " storage-back-compat " , " --pxe --noautoconsole " )
c . add_valid ( " --file %(EXISTIMG1)s --nonsparse --file-size 4 " ) # Existing file, other opts
c . add_valid ( " --file %(EXISTIMG1)s " ) # Existing file, no opts
2015-04-12 02:25:46 +03:00
c . add_valid ( " --file %(EXISTIMG1)s --file %(EXISTIMG1)s " ) # Multiple existing files
2014-12-10 17:33:02 +03:00
c . add_valid ( " --file %(NEWIMG1)s --file-size .00001 --nonsparse " ) # Nonexistent file
2018-10-13 18:50:49 +03:00
c = vinst . add_category ( " console-tests " , " --nodisks " )
c . add_valid ( " --pxe " , grep = " testsuite console command: [ ' virt-viewer ' " ) # mock default graphics+virt-viewer usage
c . add_valid ( " --pxe --destroy-on-exit " , grep = " Restarting guest. \n " ) # destroy-on-exit
c . add_valid ( " --pxe --transient --destroy-on-exit " , grep = " Domain creation completed. " ) # destroy-on-exit + transient
c . add_valid ( " --pxe --graphics vnc --noreboot " , grep = " testsuite console command: [ ' virt-viewer ' " ) # mock virt-viewer waiting, with noreboot magic
c . add_valid ( " --nographics --cdrom %(EXISTIMG1)s " ) # console warning about cdrom + nographics
c . add_valid ( " --nographics --console none --location %(TREEDIR)s " ) # console warning about nographics + --console none
c . add_valid ( " --nographics --console none --location %(TREEDIR)s " ) # console warning about nographics + --console none
c . add_valid ( " --nographics --location %(TREEDIR)s " ) # console warning about nographics + missing extra args
c . add_invalid ( " --pxe --noautoconsole --wait 1 " , grep = " Installation has exceeded specified time limit " ) # --wait 1 is converted to 1 second if we are in the test suite, so this should actually touch the wait machinery. however in this case it exits with failure
c . add_valid ( " --pxe --nographics --transient " , grep = " testsuite console command: [ ' virsh ' " ) # --transient handling
2014-12-10 17:33:02 +03:00
##################
# virt-xml tests #
##################
2013-04-24 00:16:30 +04:00
2018-09-01 01:28:08 +03:00
vixml = App ( " virt-xml " , check_version = " 1.2.2 " ) # check_version for input type=keyboard output change
2014-01-19 19:37:14 +04:00
c = vixml . add_category ( " misc " , " " )
c . add_valid ( " --help " ) # basic --help test
2014-02-05 21:32:53 +04:00
c . add_valid ( " --sound=? --tpm=? " ) # basic introspection test
2018-04-03 19:43:14 +03:00
c . add_valid ( " test-state-shutoff --edit --update --boot menu=on " ) # --update with inactive VM, should work but warn
2019-02-26 12:56:44 +03:00
c . add_invalid ( " test-state-shutoff --edit --update --boot menu=on --start " )
2014-01-26 03:16:16 +04:00
c . add_invalid ( " test --edit --hostdev driver_name=vfio " ) # Guest has no hostdev to edit
c . add_invalid ( " test --edit --cpu host-passthrough --boot hd,network " ) # Specified more than 1 option
c . add_invalid ( " test --edit " ) # specified no edit option
2018-05-21 22:42:50 +03:00
c . add_invalid ( " test --edit 2 --cpu host-passthrough " ) # specifying --edit number where it doesn't make sense
2015-04-22 02:37:01 +03:00
c . add_invalid ( " test-for-virtxml --edit 5 --tpm /dev/tpm " ) # device edit out of range
2018-02-20 23:00:46 +03:00
c . add_invalid ( " test-for-virtxml --add-device --host-device 0x04b3:0x4485 --update " ) # test driver doesn't support attachdevice...
2015-04-22 02:37:01 +03:00
c . add_invalid ( " test-for-virtxml --remove-device --host-device 1 --update " ) # test driver doesn't support detachdevice...
c . add_invalid ( " test-for-virtxml --edit --graphics password=foo --update " ) # test driver doesn't support updatdevice...
2014-01-26 05:14:42 +04:00
c . add_invalid ( " --build-xml --memory 10,maxmemory=20 " ) # building XML for option that doesn't support it
2019-02-26 12:56:42 +03:00
c . add_invalid ( " test --edit --boot network,cdrom --define --no-define " )
2014-02-06 04:09:26 +04:00
c . add_compare ( " test --print-xml --edit --vcpus 7 " , " print-xml " ) # test --print-xml
2018-06-12 19:26:13 +03:00
c . add_compare ( " --edit --cpu host-passthrough " , " stdin-edit " , input_file = ( XMLDIR + " /virtxml-stdin-edit.xml " ) ) # stdin test
2014-02-06 04:09:26 +04:00
c . add_compare ( " --build-xml --cpu pentium3,+x2apic " , " build-cpu " )
2019-05-15 22:52:16 +03:00
c . add_compare ( " --build-xml --tpm path=/dev/tpm " , " build-tpm " )
2019-05-15 23:00:37 +03:00
c . add_compare ( " --build-xml --blkiotune weight=100,device0.path=/dev/sdf,device.weight=200 " , " build-blkiotune " )
c . add_compare ( " --build-xml --idmap uid.start=0,uid.target=1000,uid.count=10,gid.start=0,gid.target=1000,gid.count=10 " , " build-idmap " )
2019-03-21 20:34:52 +03:00
c . add_compare ( " 4a64cc71-19c4-2fd0-2323-3050941ea3c3 --edit --boot network,cdrom " , " edit-bootorder " ) # basic bootorder test, also using UUID lookup
c . add_compare ( " --confirm 1 --edit --cpu host-passthrough " , " prompt-response " ) # prompt response, also using domid lookup
2018-06-12 19:26:13 +03:00
c . add_compare ( " --edit --print-diff --qemu-commandline clearxml=yes " , " edit-clearxml-qemu-commandline " , input_file = ( XMLDIR + " /virtxml-qemu-commandline-clear.xml " ) )
2018-09-13 22:51:03 +03:00
c . add_compare ( " --connect % (URI-KVM)s test-hyperv-uefi --edit --boot uefi " , " hyperv-uefi-collision " )
2014-01-26 03:16:16 +04:00
2018-02-20 23:00:46 +03:00
c = vixml . add_category ( " simple edit diff " , " test-for-virtxml --edit --print-diff --define " )
2018-10-01 02:12:19 +03:00
c . add_compare ( """ --metadata name=foo-my-new-name,os_name=fedora13,uuid=12345678-12F4-1234-1234-123456789AFA,description= " hey this is my
2014-01-25 05:03:30 +04:00
new
2014-02-06 04:09:26 +04:00
very , very = new desc \\\' " ,title= " This is my,funky=new title " " " " , " edit-simple-metadata " )
2018-10-01 02:12:19 +03:00
c . add_compare ( """ --metadata os_full_id=http://fedoraproject.org/fedora/23 """ , " edit-metadata-full-os " )
2014-05-29 05:46:24 +04:00
c . add_compare ( " --events on_poweroff=destroy,on_reboot=restart,on_crash=preserve " , " edit-simple-events " )
2017-03-06 04:45:33 +03:00
c . add_compare ( " --qemu-commandline= ' -foo bar,baz= \" wib wob \" ' " , " edit-simple-qemu-commandline " )
2014-02-06 04:09:26 +04:00
c . add_compare ( " --memory 500,maxmemory=1000,hugepages=off " , " edit-simple-memory " )
c . add_compare ( " --vcpus 10,maxvcpus=20,cores=5,sockets=4,threads=1 " , " edit-simple-vcpus " )
c . add_compare ( " --cpu model=pentium2,+x2apic,forbid=pbe " , " edit-simple-cpu " )
2019-05-15 22:51:54 +03:00
c . add_compare ( " --numatune memory.nodeset=1-5,7,memory.mode=strict " , " edit-simple-numatune " )
2014-02-06 04:09:26 +04:00
c . add_compare ( " --blkiotune weight=500,device_path=/dev/sdf,device_weight=600 " , " edit-simple-blkiotune " )
2018-09-01 01:28:08 +03:00
c . add_compare ( " --idmap uid_start=0,uid_target=2000,uid_count=30,gid_start=0,gid_target=3000,gid_count=40 " , " edit-simple-idmap " )
2019-05-15 22:46:08 +03:00
c . add_compare ( " --boot loader=foo.bar,useserial=on,init=/bin/bash,nvram=/test/nvram.img,os_type=hvm,domain_type=test,loader.readonly=on,loader.secure=no,machine= " , " edit-simple-boot " )
2014-02-06 04:09:26 +04:00
c . add_compare ( " --security label=foo,bar,baz,UNKNOWN=val,relabel=on " , " edit-simple-security " )
c . add_compare ( " --features eoi=on,hyperv_relaxed=off,acpi= " , " edit-simple-features " )
2019-05-13 02:00:47 +03:00
c . add_compare ( " --clock offset=localtime,hpet_present=yes,kvmclock_present=no,kvmclock_tickpolicy=foo,rtc_tickpolicy=merge " , " edit-simple-clock " )
2019-05-15 22:51:54 +03:00
c . add_compare ( " --pm suspend_to_mem.enabled=yes,suspend_to_disk.enabled=no " , " edit-simple-pm " )
2019-05-15 23:26:23 +03:00
c . add_compare ( " --disk /dev/zero,perms=ro,source.startupPolicy=optional " , " edit-simple-disk " )
2014-02-06 04:09:26 +04:00
c . add_compare ( " --disk path= " , " edit-simple-disk-remove-path " )
c . add_compare ( " --network source=br0,type=bridge,model=virtio,mac= " , " edit-simple-network " )
2018-09-01 01:28:08 +03:00
c . add_compare ( " --graphics tlsport=5902,keymap=ja " , " edit-simple-graphics " , check_version = " 1.3.5 " ) # check_version=new graphics listen output
c . add_compare ( " --graphics listen=none " , " edit-graphics-listen-none " , check_version = " 2.0.0 " ) # check_version=graphics listen=none support
2016-06-11 23:44:54 +03:00
c . add_compare ( " --controller index=15,model=lsilogic " , " edit-simple-controller " )
2015-04-05 03:01:03 +03:00
c . add_compare ( " --controller index=15,model=lsilogic " , " edit-simple-controller " )
2014-02-06 04:09:26 +04:00
c . add_compare ( " --smartcard type=spicevmc " , " edit-simple-smartcard " )
c . add_compare ( " --redirdev type=spicevmc,server=example.com:12345 " , " edit-simple-redirdev " )
2019-05-15 22:52:16 +03:00
c . add_compare ( " --tpm backend.device.path=,backend.type=emulator,backend.version=2.0 " , " edit-simple-tpm " , check_version = " 1.3.5 " ) # check_version=new graphics listen output
2019-05-15 22:54:28 +03:00
c . add_compare ( " --vsock model=virtio,cid.address=,cid.auto=on " , " edit-simple-vsock " )
2014-02-06 04:09:26 +04:00
c . add_compare ( " --rng rate_bytes=3333,rate_period=4444 " , " edit-simple-rng " )
c . add_compare ( " --watchdog action=reset " , " edit-simple-watchdog " )
c . add_compare ( " --memballoon model=none " , " edit-simple-memballoon " )
c . add_compare ( " --serial pty " , " edit-simple-serial " )
c . add_compare ( " --parallel unix,path=/some/other/log " , " edit-simple-parallel " )
c . add_compare ( " --channel null " , " edit-simple-channel " )
2015-06-09 00:22:58 +03:00
c . add_compare ( " --console name=foo.bar.baz " , " edit-simple-console " )
2014-02-06 04:09:26 +04:00
c . add_compare ( " --filesystem /1/2/3,/4/5/6,mode=mapped " , " edit-simple-filesystem " )
2018-09-01 01:28:08 +03:00
c . add_compare ( " --video cirrus " , " edit-simple-video " , check_version = " 1.3.3 " ) # check_version=video primary= attribute
c . add_compare ( " --sound pcspk " , " edit-simple-soundhw " , check_version = " 1.3.5 " ) # check_version=new graphics listen output
2019-05-15 23:03:26 +03:00
c . add_compare ( " --host-device 0x04b3:0x4485,driver_name=vfio,type=usb " , " edit-simple-host-device " )
2014-01-19 19:37:14 +04:00
2018-02-20 23:00:46 +03:00
c = vixml . add_category ( " edit selection " , " test-for-virtxml --print-diff --define " )
2014-01-19 19:37:14 +04:00
c . add_invalid ( " --edit target=vvv --disk /dev/null " ) # no match found
2016-06-15 00:29:54 +03:00
c . add_invalid ( " --edit seclabel2.model=dac --disk /dev/null " ) # no match found
c . add_valid ( " --edit seclabel.model=dac --disk /dev/null " ) # match found
2018-09-01 01:28:08 +03:00
c . add_compare ( " --edit 3 --sound pcspk " , " edit-pos-num " , check_version = " 1.3.5 " ) # check_version=new graphics listen output
c . add_compare ( " --edit -1 --video qxl " , " edit-neg-num " , check_version = " 1.2.11 " ) # check_version=video ram output change
2019-05-15 23:03:26 +03:00
c . add_compare ( " --edit all --host-device driver.name=vfio " , " edit-all " )
2018-09-01 01:28:08 +03:00
c . add_compare ( " --edit ich6 --sound pcspk " , " edit-select-sound-model " , check_version = " 1.3.5 " ) # check_version=new graphics listen output
2014-02-06 04:09:26 +04:00
c . add_compare ( " --edit target=hda --disk /dev/null " , " edit-select-disk-target " )
c . add_compare ( " --edit /tmp/foobar2 --disk shareable=off,readonly=on " , " edit-select-disk-path " )
c . add_compare ( " --edit mac=00:11:7f:33:44:55 --network target=nic55 " , " edit-select-network-mac " )
2019-02-26 12:56:40 +03:00
c . add_compare ( " --edit target=hda --disk boot_order=1 " , " edit-select-disk-bootorder " )
2019-05-11 00:57:04 +03:00
c . add_compare ( " --edit path=/dev/null --disk path=,target=fdb,boot_order=12 " , " edit-disk-unset " ) # --disk matching, using empty value to unset path
2019-02-26 12:56:40 +03:00
2019-02-26 12:56:44 +03:00
c = vixml . add_category ( " edit and start selection " , " test-state-shutoff --print-diff --start " )
c . add_compare ( " --define --edit target=vda --disk boot_order=1 " , " start-select-disk-bootorder " )
c . add_invalid ( " --define --no-define --edit target=vda --disk boot_order=1 " )
c . add_compare ( " --edit target=vda --disk boot_order=1 " , " start-select-disk-bootorder2 " )
c . add_compare ( " --no-define --edit target=vda --disk boot_order=1 " , " start-select-disk-bootorder2 " )
2019-02-26 12:56:40 +03:00
c = vixml . add_category ( " edit selection 2 " , " test-collide --print-diff --define " )
c . add_compare ( " --edit target=hda --disk boot_order=1 " , " edit-select-disk-bootorder2 " )
2014-01-19 19:37:14 +04:00
2018-02-20 23:00:46 +03:00
c = vixml . add_category ( " edit clear " , " test-for-virtxml --print-diff --define " )
2014-01-26 05:20:55 +04:00
c . add_invalid ( " --edit --memory 200,clearxml=yes " ) # clear isn't wired up for memory
2017-01-17 19:47:46 +03:00
c . add_compare ( " --edit --disk path=/foo/bar,size=2,target=fda,bus=fdc,device=floppy,clearxml=yes " , " edit-clear-disk " )
2014-02-06 04:09:26 +04:00
c . add_compare ( " --edit --cpu host-passthrough,clearxml=yes " , " edit-clear-cpu " )
c . add_compare ( " --edit --clock offset=utc,clearxml=yes " , " edit-clear-clock " )
2016-05-20 21:45:24 +03:00
c . add_compare ( " --edit --video clearxml=yes,model=virtio,accel3d=yes " , " edit-video-virtio " )
2018-09-01 01:28:08 +03:00
c . add_compare ( " --edit --graphics clearxml=yes,type=spice,gl=on,listen=none " , " edit-graphics-spice-gl " , check_version = " 2.0.0 " ) # check_version=graphics listen=none support
2014-01-26 00:44:14 +04:00
2018-02-20 23:00:46 +03:00
c = vixml . add_category ( " add/rm devices " , " test-for-virtxml --print-diff --define " )
2015-05-04 01:08:10 +03:00
c . add_valid ( " --add-device --security model=dac " ) # --add-device works for seclabel
c . add_invalid ( " --add-device --pm suspend_to_disk=yes " ) # --add-device without a device
2014-01-26 02:06:31 +04:00
c . add_invalid ( " --remove-device --clock utc " ) # --remove-device without a dev
2018-02-20 23:00:46 +03:00
c . add_compare ( " --add-device --host-device usb_device_4b3_4485_noserial " , " add-host-device " )
2014-02-06 04:09:26 +04:00
c . add_compare ( " --add-device --sound pcspk " , " add-sound " )
c . add_compare ( " --add-device --disk %(EXISTIMG1)s ,bus=virtio,target=vdf " , " add-disk-basic " )
c . add_compare ( " --add-device --disk %(EXISTIMG1)s " , " add-disk-notarget " ) # filling in acceptable target
c . add_compare ( " --add-device --disk %(NEWIMG1)s ,size=.01 " , " add-disk-create-storage " )
2019-01-22 18:28:38 +03:00
c . add_compare ( " --add-device --disk size=.01 " , " add-disk-default-storage " )
2018-09-01 01:28:08 +03:00
c . add_compare ( " --remove-device --sound ich6 " , " remove-sound-model " , check_version = " 1.3.5 " ) # check_version=new graphics listen output
2015-04-22 02:37:01 +03:00
c . add_compare ( " --remove-device --disk 3 " , " remove-disk-index " )
2014-02-06 04:09:26 +04:00
c . add_compare ( " --remove-device --disk /dev/null " , " remove-disk-path " )
2018-09-01 01:28:08 +03:00
c . add_compare ( " --remove-device --video all " , " remove-video-all " , check_version = " 1.3.3 " ) # check_version=video primary= attribute
c . add_compare ( " --remove-device --host-device 0x04b3:0x4485 " , " remove-hostdev-name " , check_version = " 1.2.11 " ) # check_version=video ram output change
2014-01-26 00:44:14 +04:00
2019-02-26 12:56:44 +03:00
c = vixml . add_category ( " add/rm devices and start " , " test-state-shutoff --print-diff --start " )
c . add_invalid ( " --add-device --pm suspend_to_disk=yes " ) # --add-device without a device
c . add_invalid ( " --remove-device --clock utc " ) # --remove-device without a dev
# one test in combination with --define
c . add_compare ( " --define --add-device --host-device usb_device_4b3_4485_noserial " , " add-host-device-start " )
# all other test cases without
c . add_compare ( " --add-device --disk %(EXISTIMG1)s ,bus=virtio,target=vdf " , " add-disk-basic-start " )
c . add_compare ( " --add-device --disk %(NEWIMG1)s ,size=.01 " , " add-disk-create-storage-start " )
c . add_compare ( " --remove-device --disk /dev/null " , " remove-disk-path-start " )
2019-01-08 20:24:50 +03:00
c = vixml . add_category ( " add/rm devices OS KVM " , " --connect % (URI-KVM)s test --print-diff --define " )
c . add_compare ( " --add-device --disk %(EXISTIMG1)s " , " kvm-add-disk-os-from-xml " ) # Guest OS (none) from XML
c . add_compare ( " --add-device --disk %(EXISTIMG1)s --os-variant fedora28 " , " kvm-add-disk-os-from-cmdline " ) # Guest OS (fedora) provided on command line
c . add_compare ( " --add-device --network default " , " kvm-add-network-os-from-xml " ) # Guest OS information taken from the guest XML
2019-02-08 00:29:38 +03:00
c . add_compare ( " --add-device --network default --os-variant full_id=http://fedoraproject.org/fedora/28 " , " kvm-add-network-os-from-cmdline " ) # Guest OS information provided on the command line
2014-01-19 19:37:14 +04:00
2013-04-24 00:16:30 +04:00
2014-12-10 17:33:02 +03:00
####################
# virt-clone tests #
####################
2013-04-24 00:16:30 +04:00
2018-06-12 19:26:13 +03:00
_CLONE_UNMANAGED = " %s /clone-disk.xml " % XMLDIR
_CLONE_MANAGED = " %s /clone-disk-managed.xml " % XMLDIR
_CLONE_NOEXIST = " %s /clone-disk-noexist.xml " % XMLDIR
2013-04-24 00:16:30 +04:00
vclon = App ( " virt-clone " )
2015-04-23 00:06:35 +03:00
c = vclon . add_category ( " remote " , " --connect % (URI-TEST-REMOTE)s " )
2013-08-17 17:44:11 +04:00
c . add_valid ( " -o test --auto-clone " ) # Auto flag, no storage
2018-06-12 19:26:13 +03:00
c . add_valid ( " --original-xml " + _CLONE_MANAGED + " --auto-clone " ) # Auto flag w/ managed storage
c . add_invalid ( " --original-xml " + _CLONE_UNMANAGED + " --auto-clone " ) # Auto flag w/ local storage, which is invalid for remote connection
2013-08-17 17:44:11 +04:00
c = vclon . add_category ( " misc " , " " )
2018-09-01 01:28:08 +03:00
c . add_compare ( " --connect % (URI-KVM)s -o test-clone --auto-clone --clone-running " , " clone-auto1 " , check_version = " 1.2.15 " )
c . add_compare ( " --connect % (URI-TEST-FULL)s -o test-clone-simple --name newvm --auto-clone --clone-running " , " clone-auto2 " , check_version = " 1.2.15 " )
2013-08-17 17:44:11 +04:00
c . add_valid ( " -o test --auto-clone " ) # Auto flag, no storage
2018-06-12 19:26:13 +03:00
c . add_valid ( " --original-xml " + _CLONE_MANAGED + " --auto-clone " ) # Auto flag w/ managed storage
c . add_valid ( " --original-xml " + _CLONE_UNMANAGED + " --auto-clone " ) # Auto flag w/ local storage
2018-02-20 23:00:46 +03:00
c . add_valid ( " --connect % (URI-TEST-FULL)s -o test-clone --auto-clone --clone-running " ) # Auto flag, actual VM, skip state check
c . add_valid ( " --connect % (URI-TEST-FULL)s -o test-clone-simple -n newvm --preserve-data --file %(EXISTIMG1)s " ) # Preserve data shouldn't complain about existing volume
2018-06-12 19:26:13 +03:00
c . add_valid ( " -n clonetest --original-xml " + _CLONE_UNMANAGED + " --file %(EXISTIMG3)s --file %(EXISTIMG4)s --check path_exists=off " ) # Skip existing file check
2014-12-10 17:33:02 +03:00
c . add_invalid ( " --auto-clone " ) # Just the auto flag
2018-02-20 23:00:46 +03:00
c . add_invalid ( " --connect % (URI-TEST-FULL)s -o test-many-devices --auto-clone " ) # VM is running, but --clone-running isn't passed
c . add_invalid ( " --connect % (URI-TEST-FULL)s -o test-clone-simple -n newvm --file %(EXISTIMG1)s --clone-running " ) # Should complain about overwriting existing file
2013-08-17 17:44:11 +04:00
c = vclon . add_category ( " general " , " -n clonetest " )
2016-08-19 10:53:43 +03:00
c . add_valid ( " -o test --auto-clone " ) # Auto flag, no storage
2014-02-09 01:36:45 +04:00
c . add_valid ( " -o test --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s " ) # Nodisk, but with spurious files passed
c . add_valid ( " -o test --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s --prompt " ) # Working scenario w/ prompt shouldn't ask anything
2018-06-12 19:26:13 +03:00
c . add_valid ( " --original-xml " + _CLONE_UNMANAGED + " --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s " ) # XML File with 2 disks
c . add_valid ( " --original-xml " + _CLONE_UNMANAGED + " --file virt-install --file %(EXISTIMG1)s --preserve " ) # XML w/ disks, overwriting existing files with --preserve
c . add_valid ( " --original-xml " + _CLONE_UNMANAGED + " --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s --file %(NEWCLONEIMG3)s --force-copy=hdc " ) # XML w/ disks, force copy a readonly target
c . add_valid ( " --original-xml " + _CLONE_UNMANAGED + " --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s --force-copy=fda " ) # XML w/ disks, force copy a target with no media
c . add_valid ( " --original-xml " + _CLONE_MANAGED + " --file %(NEWIMG1)s " ) # XML w/ managed storage, specify managed path
c . add_valid ( " --original-xml " + _CLONE_NOEXIST + " --file %(EXISTIMG1)s --preserve " ) # XML w/ managed storage, specify managed path across pools# Libvirt test driver doesn't support cloning across pools# XML w/ non-existent storage, with --preserve
2018-02-20 23:00:46 +03:00
c . add_valid ( " --connect % (URI-TEST-FULL)s -o test -n test-clone --auto-clone --replace " ) # Overwriting existing VM
2013-08-17 17:44:11 +04:00
c . add_invalid ( " -o test foobar " ) # Positional arguments error
c . add_invalid ( " -o idontexist " ) # Non-existent vm name
c . add_invalid ( " -o idontexist --auto-clone " ) # Non-existent vm name with auto flag,
c . add_invalid ( " -o test -n test " ) # Colliding new name
2018-06-12 19:26:13 +03:00
c . add_invalid ( " --original-xml " + _CLONE_UNMANAGED + " " ) # XML file with several disks, but non specified
c . add_invalid ( " --original-xml " + _CLONE_UNMANAGED + " --file virt-install --file %(EXISTIMG1)s " ) # XML w/ disks, overwriting existing files with no --preserve
c . add_invalid ( " --original-xml " + _CLONE_UNMANAGED + " --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s --force-copy=hdc " ) # XML w/ disks, force copy but not enough disks passed
c . add_invalid ( " --original-xml " + _CLONE_MANAGED + " --file /tmp/clonevol " ) # XML w/ managed storage, specify unmanaged path (should fail)
c . add_invalid ( " --original-xml " + _CLONE_NOEXIST + " --file %(EXISTIMG1)s " ) # XML w/ non-existent storage, WITHOUT --preserve
2019-02-28 19:53:58 +03:00
c . add_valid ( " --original-xml " + _CLONE_MANAGED + " --auto-clone --force-copy fda " ) # force copy empty floppy drive
2013-04-24 00:16:30 +04:00
2014-12-10 17:33:02 +03:00
######################
# virt-convert tests #
######################
2018-06-12 19:26:13 +03:00
_OVF_IMG = " %s /tests/virtconv-files/ovf_input/test1.ovf " % os . getcwd ( )
_VMX_IMG = " %s /tests/virtconv-files/vmx_input/test1.vmx " % os . getcwd ( )
2014-12-10 17:33:02 +03:00
vconv = App ( " virt-convert " )
2018-09-01 01:28:08 +03:00
c = vconv . add_category ( " misc " , " --connect % (URI-KVM)s --dry " )
2018-06-12 19:26:13 +03:00
c . add_invalid ( _VMX_IMG + " --input-format foo " ) # invalid input format
2014-12-10 17:33:02 +03:00
c . add_invalid ( " %(EXISTIMG1)s " ) # invalid input file
2018-06-12 19:26:13 +03:00
c . add_compare ( _VMX_IMG + " --disk-format qcow2 --print-xml " , " vmx-compare " )
c . add_compare ( _OVF_IMG + " --disk-format none --destination /tmp --print-xml " , " ovf-compare " )
2014-12-10 17:33:02 +03:00
2018-12-18 22:20:57 +03:00
#################################
# argparse/autocomplete testing #
#################################
ARGCOMPLETE_CMDS = [ ]
def _add_argcomplete_cmd ( line , grep , nogrep = None ) :
env = {
" _ARGCOMPLETE " : " 1 " ,
" COMP_TYPE " : " 9 " ,
" COMP_POINT " : str ( len ( line ) ) ,
" COMP_LINE " : line ,
" _ARGCOMPLETE_COMP_WORDBREAKS " : " \" ' ><;|&(: " ,
}
cmd = Command ( line )
cmd . grep = grep
if nogrep :
cmd . nogrep = nogrep
cmd . env = env
cmd . need_conn = False
2019-01-30 19:55:40 +03:00
def have_argcomplete ( ) :
if not argcomplete :
return " argcomplete not installed "
cmd . skip_cb = have_argcomplete
2018-12-18 22:20:57 +03:00
ARGCOMPLETE_CMDS . append ( cmd )
_add_argcomplete_cmd ( " virt-install --di " , " --disk " )
_add_argcomplete_cmd ( " virt-install --disk " , " driver.copy_on_read= " ) # will list all --disk subprops
_add_argcomplete_cmd ( " virt-install --disk a " , " address.base " )
_add_argcomplete_cmd ( " virt-install --disk address.u " , " address.unit " )
_add_argcomplete_cmd ( " virt-install --disk address.unit=foo,sg " , " sgio " )
2019-05-15 20:06:29 +03:00
_add_argcomplete_cmd ( " virt-install --disk path=fooo, " , " driver.cache " ) # will list all --disk subprops
_add_argcomplete_cmd ( " virt-install --disk source.seclab " , " source.seclabel.relabel " ) # completer should strip out regexes from results
2019-01-07 03:01:35 +03:00
_add_argcomplete_cmd ( " virt-install --check d " , " disk_size " )
2019-02-08 00:26:04 +03:00
_add_argcomplete_cmd ( " virt-install --location k " , " kernel " )
_add_argcomplete_cmd ( " virt-install --os-variant nam " , " name " )
2018-12-18 22:20:57 +03:00
_add_argcomplete_cmd ( " virt-install --test-stub " , None ,
nogrep = " --test-stub-command " )
2019-02-22 11:40:08 +03:00
_add_argcomplete_cmd ( " virt-install --un " , " --unattended " )
_add_argcomplete_cmd ( " virt-install --unattended " , " profile= " ) # will list all --unattended subprops
_add_argcomplete_cmd ( " virt-install --unattended p " , " profile= " )
_add_argcomplete_cmd ( " virt-install --unattended a " , " admin-password= " )
_add_argcomplete_cmd ( " virt-install --unattended u " , " user-password= " )
2019-03-29 00:44:43 +03:00
_add_argcomplete_cmd ( " virt-install --unattended prod " , " product-key " )
2018-12-18 22:20:57 +03:00
_add_argcomplete_cmd ( " virt-clone --preserve " , " --preserve-data " )
_add_argcomplete_cmd ( " virt-xml --sound mode " , " model " )
_add_argcomplete_cmd ( " virt-convert --dest " , " --destination " )
2013-04-24 00:16:30 +04:00
2013-03-18 01:06:52 +04:00
#########################
# Test runner functions #
#########################
newidx = 0
curtest = 0
2013-04-13 22:34:52 +04:00
2013-03-18 01:06:52 +04:00
def setup ( ) :
"""
Create initial test files / dirs
"""
2018-10-13 00:15:20 +03:00
for i in iso_links :
src = " %s / %s " % ( os . path . abspath ( XMLDIR ) , os . path . basename ( i ) )
os . symlink ( src , i )
for i in exist_files :
open ( i , " a " )
2013-03-18 01:06:52 +04:00
def cleanup ( ) :
"""
Cleanup temporary files used for testing
"""
for i in clean_files :
os . system ( " chmod 777 %s > /dev/null 2>&1 " % i )
os . system ( " rm -rf %s > /dev/null 2>&1 " % i )
2013-04-13 22:34:52 +04:00
2013-03-18 01:06:52 +04:00
class CLITests ( unittest . TestCase ) :
def setUp ( self ) :
global curtest
curtest + = 1
# Only run this for first test
if curtest == 1 :
setup ( )
def tearDown ( self ) :
# Only run this on the last test
if curtest == newidx :
cleanup ( )
2013-04-13 22:34:52 +04:00
2013-03-18 01:06:52 +04:00
def maketest ( cmd ) :
2013-08-17 21:50:36 +04:00
def cmdtemplate ( self , _cmdobj ) :
2013-08-18 16:59:19 +04:00
_cmdobj . run ( self )
2013-03-18 01:06:52 +04:00
return lambda s : cmdtemplate ( s , cmd )
2015-04-23 00:35:39 +03:00
_cmdlist = [ ]
2013-04-24 00:16:30 +04:00
_cmdlist + = vinst . cmds
_cmdlist + = vclon . cmds
_cmdlist + = vconv . cmds
2014-01-19 19:37:14 +04:00
_cmdlist + = vixml . cmds
2018-12-18 22:20:57 +03:00
_cmdlist + = ARGCOMPLETE_CMDS
2013-04-24 00:16:30 +04:00
2016-06-11 22:52:08 +03:00
# Generate numbered names like testCLI%d
2013-03-18 01:06:52 +04:00
for _cmd in _cmdlist :
newidx + = 1
2016-06-11 22:52:08 +03:00
_name = " testCLI %.4d " % newidx
if _cmd . compare_file :
_base = os . path . splitext ( os . path . basename ( _cmd . compare_file ) ) [ 0 ]
_name + = _base . replace ( " - " , " _ " )
else :
_name + = _cmd . app . replace ( " - " , " _ " )
2014-02-01 23:17:03 +04:00
setattr ( CLITests , _name , maketest ( _cmd ) )
2013-03-18 01:06:52 +04:00
atexit . register ( cleanup )