summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-01-25 08:25:04 +0100
committerChristian Poessinger <christian@poessinger.com>2020-01-25 08:30:14 +0100
commit996cedd037e3320df135cb182e0305079da0dff1 (patch)
tree27378804c15ff831150557080b1ac57939efd91a /scripts
parent1749ed915088c625b3de85fe3d98bb89c1aeee73 (diff)
downloadvyos-build-996cedd037e3320df135cb182e0305079da0dff1.tar.gz
vyos-build-996cedd037e3320df135cb182e0305079da0dff1.zip
Testsuite: use single qemu command
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/check-qemu-install62
1 files changed, 30 insertions, 32 deletions
diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install
index 5c4e09b4..f015ad9b 100755
--- a/scripts/check-qemu-install
+++ b/scripts/check-qemu-install
@@ -94,6 +94,34 @@ class StreamToLogger(object):
def flush(self):
pass
+def get_qemu_cmd(name, enable_kvm, disk_img, iso_img=None):
+ kvm = ""
+ cpu = "-cpu host"
+ if not enable_kvm:
+ kvm = "--no-kvm"
+ cpu = ""
+
+ cdrom = ""
+ if iso_img:
+ cdrom = "-boot d -cdrom {}".format(iso_img)
+
+ cmd = 'qemu-system-x86_64 \
+ -name "{NAME}" \
+ -m 1G \
+ -nic user,model=virtio,mac=52:54:99:12:34:56 \
+ -nic user,model=virtio,mac=52:54:99:12:34:57 \
+ -nic user,model=virtio,mac=52:54:99:12:34:58 \
+ -nic user,model=virtio,mac=52:54:99:12:34:59 \
+ -machine accel=kvm \
+ {CPU} \
+ -smp 2 \
+ -nographic \
+ {CD} \
+ {KVM} \
+ -drive format=raw,file={DISK}'.format(NAME=name, CD=cdrom, DISK=disk_img, KVM=kvm, CPU=cpu)
+
+ return cmd
+
# Setting up logger
log = logging.getLogger()
@@ -150,22 +178,7 @@ try:
# Installing image to disk
#################################################
log.info("Installing system")
-
- cmd = """qemu-system-x86_64 \
- -name "TESTVM" \
- -m 1G \
- -nic user,model=virtio,mac=52:54:99:12:34:56 \
- -nic user,model=virtio,mac=52:54:99:12:34:57 \
- -nic user,model=virtio,mac=52:54:99:12:34:58 \
- -nic user,model=virtio,mac=52:54:99:12:34:59 \
- -machine accel=kvm \
- {CPU} \
- -smp 2 \
- -nographic \
- -boot d -cdrom {CD} \
- {KVM} \
- -drive format=raw,file={DISK}
- """.format(CD=args.iso, DISK=args.disk, KVM="" if kvm else "--no-kvm", CPU="-cpu host" if kvm else "")
+ cmd = get_qemu_cmd("TESTVM", kvm, args.disk, args.iso)
log.debug("Executing command: {}".format(cmd))
c = pexpect.spawn(cmd, logfile=stl)
@@ -239,22 +252,7 @@ try:
# Booting installed system
#################################################
log.info("Booting installed system")
-
- cmd = """qemu-system-x86_64 \
- -name "TESTVM" \
- -m 1G \
- -nic user,model=virtio,mac=52:54:99:12:34:56 \
- -nic user,model=virtio,mac=52:54:99:12:34:57 \
- -nic user,model=virtio,mac=52:54:99:12:34:58 \
- -nic user,model=virtio,mac=52:54:99:12:34:59 \
- -machine accel=kvm \
- {CPU} \
- -smp 2 \
- -nographic \
- {KVM} \
- -drive format=raw,file={DISK}
- """.format(DISK=args.disk, KVM="" if kvm else "--no-kvm", CPU="-cpu host" if kvm else "")
-
+ cmd = get_qemu_cmd("TESTVM", kvm, args.disk)
log.debug('Executing command: {}'.format(cmd))
c = pexpect.spawn(cmd, logfile=stl)