Testsuite: Adding support for running on non-kvm hosts

This commit is contained in:
Runar Borge 2019-09-27 21:31:59 +02:00
parent 8bfc9cf652
commit 00752f98ab

View File

@ -65,7 +65,10 @@ parser.add_argument('--silent', help='Do not show output on stdout unless an err
parser.add_argument('--debug', help='Send all debug output to stdout', parser.add_argument('--debug', help='Send all debug output to stdout',
action='store_true', action='store_true',
default=False) default=False)
parser.add_argument('--logfile', help='Log to file') parser.add_argument('--logfile', help='Log to file')
parser.add_argument('--no-kvm', help='Disable use of kvm',
action='store_true',
default=False)
args = parser.parse_args() args = parser.parse_args()
@ -130,6 +133,14 @@ if not os.path.isfile(args.iso):
log.error("Unable to find iso image to install") log.error("Unable to find iso image to install")
sys.exit(1) sys.exit(1)
if args.no_kvm:
log.error("KVM forced off by command line")
kvm=False
elif not os.path.exists("/dev/kvm"):
log.error("KVM is not enabled on host, proceeding with software emulation")
kvm=False
else:
kvm=True
# Creating diskimage!! # Creating diskimage!!
@ -153,12 +164,14 @@ try:
-m 1G \ -m 1G \
-nic user,model=virtio,mac=52:54:99:12:34:56,hostfwd=tcp::2299-:22 \ -nic user,model=virtio,mac=52:54:99:12:34:56,hostfwd=tcp::2299-:22 \
-machine accel=kvm \ -machine accel=kvm \
-cpu host -smp 2 \ {CPU} \
-smp 2 \
-vnc 0.0.0.0:99 \ -vnc 0.0.0.0:99 \
-nographic \ -nographic \
-boot d -cdrom {CD} \ -boot d -cdrom {CD} \
{KVM} \
-drive format=raw,file={DISK} -drive format=raw,file={DISK}
""".format(CD=args.iso, DISK=args.disk) """.format(CD=args.iso, DISK=args.disk, KVM="" if kvm else "--no-kvm", CPU="-cpu host" if kvm else "")
log.debug("Executing command: {}".format(cmd)) log.debug("Executing command: {}".format(cmd))
c = pexpect.spawn(cmd, logfile=stl) c = pexpect.spawn(cmd, logfile=stl)
@ -240,11 +253,13 @@ try:
-m 1G \ -m 1G \
-nic user,model=virtio,mac=52:54:99:12:34:56,hostfwd=tcp::2299-:22 -nic user,model=virtio,mac=52:54:99:12:34:56,hostfwd=tcp::2299-:22
-machine accel=kvm \ -machine accel=kvm \
-cpu host -smp 2 \ {CPU} \
-smp 2 \
-vnc 0.0.0.0:99 \ -vnc 0.0.0.0:99 \
-nographic \ -nographic \
{KVM} \
-drive format=raw,file={DISK} -drive format=raw,file={DISK}
""".format(DISK=args.disk) """.format(DISK=args.disk, KVM="" if kvm else "--no-kvm", CPU="-cpu host" if kvm else "")
log.debug('Executing command: {}'.format(cmd)) log.debug('Executing command: {}'.format(cmd))
c = pexpect.spawn(cmd, logfile=stl) c = pexpect.spawn(cmd, logfile=stl)