runtime: Allow to specify properties for accelerator
PATCH v4 1/1 runtime: Allow to specify properties for accelerator
There are extra properties for accelerators to enable the specific features. For example, the dirty ring for KVM accelerator can be enabled by "-accel kvm,dirty-ring-sizee536". Unfortuntely, the extra properties for the accelerators aren't supported. It makes it's impossible to test the combination of KVM and dirty ring as the following error message indicates.
# cd /home/gavin/sandbox/kvm-unit-tests/tests
# QEMU=/home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \
ACCEL=kvm,dirty-ring-sizee536 ./its-migration
:
BUILD_HEAD/ffb37e
timeout -k 1s --foreground 90s \
/home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \
-nodefaults -machine virt -accel kvm,dirty-ring-sizee536 \
-cpu cortex-a57 -device virtio-serial-device \
-device virtconsole,chardev=ctd -chardev testdev,id=ctd \
-device pci-testdev -display none -serial stdio \
-kernel _NO_FILE_4Uhere_ -smp 160 -machine gic-version=3 \
-append its-pending-migration # -initrd /tmp/tmp.gfDLa1EtWk
:
qemu-system-aarch64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0):
Invalid argumentAllow to specify extra properties for accelerators. With this, the "its-migration" can be tested for the combination of KVM and dirty ring. Rename get_qemu_accelerator() to set_qemu_accelerator() since no values are returned by printing at return.
---
v4: Rename get_qemu_accelerator() to set_qemu_accelerator() and
don't break the fix included in commit c7d6c7f00e7c by setting $ACCEL to "tcg" before set_qemu_accelerator() is called, suggested by Drew.
--- arm/run | 20 ++++++++------------ powerpc/run | 5 ++--- s390x/run | 5 ++--- scripts/arch-run.bash | 23 ++++++++++++++--------- x86/run | 5 ++--- 5 files changed, 28 insertions(+), 30 deletions(-)
arm/run +8 -12
@@ -10,24 +10,20 @@ if [ -z "$KUT_STANDALONE" ]; then fi processor="$PROCESSOR" -accel=$(get_qemu_accelerator) || - exit $? +if [ "$QEMU" ] && [ -z "$ACCEL" ] && + [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] && + [ "$(basename $QEMU)" = "qemu-system-arm" ]; then + ACCEL="tcg" +fi -if [ "$accel" = "kvm" ]; then +set_qemu_accelerator || exit $? +if [ "$ACCEL" = "kvm" ]; then QEMU_ARCH=$HOST fi qemu=$(search_qemu_binary) || exit $? -if [ "$QEMU" ] && [ -z "$ACCEL" ] && - [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] && - [ "$(basename $QEMU)" = "qemu-system-arm" ]; then - accel=tcg -fi - -ACCEL=$accel - if ! $qemu -machine '?' | grep -q 'ARM Virtual Machine'; then echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting." exit 2
@@ -72,7 +68,7 @@ if $qemu $M -device '?' | grep -q pci-testdev; then pci_testdev="-device pci-testdev" fi -A="-accel $ACCEL" +A="-accel $ACCEL$ACCEL_PROPS" command="$qemu -nodefaults $M $A -cpu $processor $chr_testdev $pci_testdev" command+=" -display none -serial stdio -kernel" command="$(migration_cmd) $(timeout_cmd) $command"
powerpc/run +2 -3
@@ -9,8 +9,7 @@ if [ -z "$KUT_STANDALONE" ]; then source scripts/arch-run.bash fi -ACCEL=$(get_qemu_accelerator) || - exit $? +set_qemu_accelerator || exit $? qemu=$(search_qemu_binary) || exit $?
@@ -21,7 +20,7 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then fi M='-machine pseries' -M+=",accel=$ACCEL" +M+=",accel=$ACCEL$ACCEL_PROPS" command="$qemu -nodefaults $M -bios $FIRMWARE" command+=" -display none -serial stdio -kernel" command="$(migration_cmd) $(timeout_cmd) $command"
s390x/run +2 -3
@@ -9,8 +9,7 @@ if [ -z "$KUT_STANDALONE" ]; then source scripts/arch-run.bash fi -ACCEL=$(get_qemu_accelerator) || - exit $? +set_qemu_accelerator || exit $? qemu=$(search_qemu_binary) || exit $?
@@ -26,7 +25,7 @@ if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$MIGRATION" fi M='-machine s390-ccw-virtio' -M+=",accel=$ACCEL" +M+=",accel=$ACCEL$ACCEL_PROPS" command="$qemu -nodefaults -nographic $M" command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0" command+=" -kernel"
scripts/arch-run.bash +14 -9
@@ -410,8 +410,11 @@ hvf_available () ( [ "$HOST" = x86_64 ] && [ "$ARCH" = i386 ] ) } -get_qemu_accelerator () +set_qemu_accelerator () { + ACCEL_PROPS=${ACCEL#"${ACCEL%%,*}"} + ACCEL=${ACCEL%%,*} + if [ "$ACCEL" = "kvm" ] && ! kvm_available; then echo "KVM is needed, but not available on this host" >&2 return 2
@@ -421,13 +424,15 @@ get_qemu_accelerator () return 2 fi - if [ "$ACCEL" ]; then - echo $ACCEL - elif kvm_available; then - echo kvm - elif hvf_available; then - echo hvf - else - echo tcg + if [ -z "$ACCEL" ]; then + if kvm_available; then + ACCEL="kvm" + elif hvf_available; then + ACCEL="hvf" + else + ACCEL="tcg" + fi fi + + return 0 }
x86/run +2 -3
@@ -9,8 +9,7 @@ if [ -z "$KUT_STANDALONE" ]; then source scripts/arch-run.bash fi -ACCEL=$(get_qemu_accelerator) || - exit $? +set_qemu_accelerator || exit $? qemu=$(search_qemu_binary) || exit $?
@@ -38,7 +37,7 @@ else fi command="${qemu} --no-reboot -nodefaults $pc_testdev -vnc none -serial stdio $pci_testdev" -command+=" -machine accel=$ACCEL" +command+=" -machine accel=$ACCEL$ACCEL_PROPS" if [ "${CONFIG_EFI}" != y ]; then command+=" -kernel" fi
Signature · 1 line
2.40.1
Quoted 203 lines · Gavin Shan
There are extra properties for accelerators to enable the specific features. For example, the dirty ring for KVM accelerator can be enabled by "-accel kvm,dirty-ring-sizee536". Unfortuntely, the extra properties for the accelerators aren't supported. It makes it's impossible to test the combination of KVM and dirty ring as the following error message indicates.
# cd /home/gavin/sandbox/kvm-unit-tests/tests # QEMU=/home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ ACCEL=kvm,dirty-ring-sizee536 ./its-migration : BUILD_HEAD/ffb37e timeout -k 1s --foreground 90s \ /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ -nodefaults -machine virt -accel kvm,dirty-ring-sizee536 \ -cpu cortex-a57 -device virtio-serial-device \ -device virtconsole,chardev=ctd -chardev testdev,id=ctd \ -device pci-testdev -display none -serial stdio \ -kernel _NO_FILE_4Uhere_ -smp 160 -machine gic-version=3 \ -append its-pending-migration # -initrd /tmp/tmp.gfDLa1EtWk : qemu-system-aarch64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argumentAllow to specify extra properties for accelerators. With this, the "its-migration" can be tested for the combination of KVM and dirty ring. Rename
get_qemu_accelerator()toset_qemu_accelerator()since no values are returned by printing at return.Signed-off-by Gavin Shan <[email protected]>Tested-by Nico Boehr <[email protected]>Acked-by Nico Boehr <[email protected]>---
v4: Renameget_qemu_accelerator()toset_qemu_accelerator()and
don't break the fix included in commitc7d6c7f00e7cby setting $ACCEL to "tcg" beforeset_qemu_accelerator()is called, suggested by Drew.--- arm/run | 20 ++++++++------------ powerpc/run | 5 ++--- s390x/run | 5 ++--- scripts/arch-run.bash | 23 ++++++++++++++--------- x86/run | 5 ++--- 5 files changed, 28 insertions(+), 30 deletions(-)arm/run +8
-12@@ -10,24 +10,20 @@ if [ -z "$KUT_STANDALONE" ]; then fi processor="$PROCESSOR" -accel=$(get_qemu_accelerator) || - exit $? +if [ "$QEMU" ] && [ -z "$ACCEL" ] && + [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] && + [ "$(basename $QEMU)" = "qemu-system-arm" ]; then + ACCEL="tcg" +fi -if [ "$accel" = "kvm" ]; then +set_qemu_accelerator || exit $? +if [ "$ACCEL" = "kvm" ]; then QEMU_ARCH=$HOST fi qemu=$(search_qemu_binary) || exit $? -if [ "$QEMU" ] && [ -z "$ACCEL" ] && - [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] && - [ "$(basename $QEMU)" = "qemu-system-arm" ]; then - accel=tcg -fi - -ACCEL=$accel - if ! $qemu -machine '?' | grep -q 'ARM Virtual Machine'; then echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting." exit 2@@ -72,7 +68,7 @@ if $qemu $M -device '?' | grep -q pci-testdev; then pci_testdev="-device pci-testdev" fi -A="-accel $ACCEL" +A="-accel $ACCEL$ACCEL_PROPS" command="$qemu -nodefaults $M $A -cpu $processor $chr_testdev $pci_testdev" command+=" -display none -serial stdio -kernel" command="$(migration_cmd) $(timeout_cmd) $command"powerpc/run +2
-3@@ -9,8 +9,7 @@ if [ -z "$KUT_STANDALONE" ]; then source scripts/arch-run.bash fi -ACCEL=$(get_qemu_accelerator) || - exit $? +set_qemu_accelerator || exit $? qemu=$(search_qemu_binary) || exit $?@@ -21,7 +20,7 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then fi M='-machine pseries' -M+=",accel=$ACCEL" +M+=",accel=$ACCEL$ACCEL_PROPS" command="$qemu -nodefaults $M -bios $FIRMWARE" command+=" -display none -serial stdio -kernel" command="$(migration_cmd) $(timeout_cmd) $command"s390x/run +2
-3@@ -9,8 +9,7 @@ if [ -z "$KUT_STANDALONE" ]; then source scripts/arch-run.bash fi -ACCEL=$(get_qemu_accelerator) || - exit $? +set_qemu_accelerator || exit $? qemu=$(search_qemu_binary) || exit $?@@ -26,7 +25,7 @@ if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$MIGRATION" fi M='-machine s390-ccw-virtio' -M+=",accel=$ACCEL" +M+=",accel=$ACCEL$ACCEL_PROPS" command="$qemu -nodefaults -nographic $M" command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0" command+=" -kernel"scripts/arch-run.bash +14
-9@@ -410,8 +410,11 @@ hvf_available () ( [ "$HOST" = x86_64 ] && [ "$ARCH" = i386 ] ) } -get_qemu_accelerator () +set_qemu_accelerator () { + ACCEL_PROPS=${ACCEL#"${ACCEL%%,*}"} + ACCEL=${ACCEL%%,*} + if [ "$ACCEL" = "kvm" ] && ! kvm_available; then echo "KVM is needed, but not available on this host" >&2 return 2@@ -421,13 +424,15 @@ get_qemu_accelerator () return 2 fi - if [ "$ACCEL" ]; then - echo $ACCEL - elif kvm_available; then - echo kvm - elif hvf_available; then - echo hvf - else - echo tcg + if [ -z "$ACCEL" ]; then + if kvm_available; then + ACCEL="kvm" + elif hvf_available; then + ACCEL="hvf" + else + ACCEL="tcg" + fi fi + + return 0 }x86/run +2
-3@@ -9,8 +9,7 @@ if [ -z "$KUT_STANDALONE" ]; then source scripts/arch-run.bash fi -ACCEL=$(get_qemu_accelerator) || - exit $? +set_qemu_accelerator || exit $? qemu=$(search_qemu_binary) || exit $?@@ -38,7 +37,7 @@ else fi command="${qemu} --no-reboot -nodefaults $pc_testdev -vnc none -serial stdio $pci_testdev" -command+=" -machine accel=$ACCEL" +command+=" -machine accel=$ACCEL$ACCEL_PROPS" if [ "${CONFIG_EFI}" != y ]; then command+=" -kernel" fiSignature · 1 line
2.40.1
Andrew Jones
AppliedQuoted 203 lines · Gavin Shan
There are extra properties for accelerators to enable the specific features. For example, the dirty ring for KVM accelerator can be enabled by "-accel kvm,dirty-ring-sizee536". Unfortuntely, the extra properties for the accelerators aren't supported. It makes it's impossible to test the combination of KVM and dirty ring as the following error message indicates.
# cd /home/gavin/sandbox/kvm-unit-tests/tests # QEMU=/home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ ACCEL=kvm,dirty-ring-sizee536 ./its-migration : BUILD_HEAD/ffb37e timeout -k 1s --foreground 90s \ /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ -nodefaults -machine virt -accel kvm,dirty-ring-sizee536 \ -cpu cortex-a57 -device virtio-serial-device \ -device virtconsole,chardev=ctd -chardev testdev,id=ctd \ -device pci-testdev -display none -serial stdio \ -kernel _NO_FILE_4Uhere_ -smp 160 -machine gic-version=3 \ -append its-pending-migration # -initrd /tmp/tmp.gfDLa1EtWk : qemu-system-aarch64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argumentAllow to specify extra properties for accelerators. With this, the "its-migration" can be tested for the combination of KVM and dirty ring. Rename
get_qemu_accelerator()toset_qemu_accelerator()since no values are returned by printing at return.Signed-off-by Gavin Shan <[email protected]>Tested-by Nico Boehr <[email protected]>Acked-by Nico Boehr <[email protected]>---
v4: Renameget_qemu_accelerator()toset_qemu_accelerator()and
don't break the fix included in commitc7d6c7f00e7cby setting $ACCEL to "tcg" beforeset_qemu_accelerator()is called, suggested by Drew.--- arm/run | 20 ++++++++------------ powerpc/run | 5 ++--- s390x/run | 5 ++--- scripts/arch-run.bash | 23 ++++++++++++++--------- x86/run | 5 ++--- 5 files changed, 28 insertions(+), 30 deletions(-)arm/run +8
-12@@ -10,24 +10,20 @@ if [ -z "$KUT_STANDALONE" ]; then fi processor="$PROCESSOR" -accel=$(get_qemu_accelerator) || - exit $? +if [ "$QEMU" ] && [ -z "$ACCEL" ] && + [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] && + [ "$(basename $QEMU)" = "qemu-system-arm" ]; then + ACCEL="tcg" +fi -if [ "$accel" = "kvm" ]; then +set_qemu_accelerator || exit $? +if [ "$ACCEL" = "kvm" ]; then QEMU_ARCH=$HOST fi qemu=$(search_qemu_binary) || exit $? -if [ "$QEMU" ] && [ -z "$ACCEL" ] && - [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] && - [ "$(basename $QEMU)" = "qemu-system-arm" ]; then - accel=tcg -fi - -ACCEL=$accel - if ! $qemu -machine '?' | grep -q 'ARM Virtual Machine'; then echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting." exit 2@@ -72,7 +68,7 @@ if $qemu $M -device '?' | grep -q pci-testdev; then pci_testdev="-device pci-testdev" fi -A="-accel $ACCEL" +A="-accel $ACCEL$ACCEL_PROPS" command="$qemu -nodefaults $M $A -cpu $processor $chr_testdev $pci_testdev" command+=" -display none -serial stdio -kernel" command="$(migration_cmd) $(timeout_cmd) $command"powerpc/run +2
-3@@ -9,8 +9,7 @@ if [ -z "$KUT_STANDALONE" ]; then source scripts/arch-run.bash fi -ACCEL=$(get_qemu_accelerator) || - exit $? +set_qemu_accelerator || exit $? qemu=$(search_qemu_binary) || exit $?@@ -21,7 +20,7 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then fi M='-machine pseries' -M+=",accel=$ACCEL" +M+=",accel=$ACCEL$ACCEL_PROPS" command="$qemu -nodefaults $M -bios $FIRMWARE" command+=" -display none -serial stdio -kernel" command="$(migration_cmd) $(timeout_cmd) $command"s390x/run +2
-3@@ -9,8 +9,7 @@ if [ -z "$KUT_STANDALONE" ]; then source scripts/arch-run.bash fi -ACCEL=$(get_qemu_accelerator) || - exit $? +set_qemu_accelerator || exit $? qemu=$(search_qemu_binary) || exit $?@@ -26,7 +25,7 @@ if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$MIGRATION" fi M='-machine s390-ccw-virtio' -M+=",accel=$ACCEL" +M+=",accel=$ACCEL$ACCEL_PROPS" command="$qemu -nodefaults -nographic $M" command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0" command+=" -kernel"scripts/arch-run.bash +14
-9@@ -410,8 +410,11 @@ hvf_available () ( [ "$HOST" = x86_64 ] && [ "$ARCH" = i386 ] ) } -get_qemu_accelerator () +set_qemu_accelerator () { + ACCEL_PROPS=${ACCEL#"${ACCEL%%,*}"} + ACCEL=${ACCEL%%,*} + if [ "$ACCEL" = "kvm" ] && ! kvm_available; then echo "KVM is needed, but not available on this host" >&2 return 2@@ -421,13 +424,15 @@ get_qemu_accelerator () return 2 fi - if [ "$ACCEL" ]; then - echo $ACCEL - elif kvm_available; then - echo kvm - elif hvf_available; then - echo hvf - else - echo tcg + if [ -z "$ACCEL" ]; then + if kvm_available; then + ACCEL="kvm" + elif hvf_available; then + ACCEL="hvf" + else + ACCEL="tcg" + fi fi + + return 0 }x86/run +2
-3@@ -9,8 +9,7 @@ if [ -z "$KUT_STANDALONE" ]; then source scripts/arch-run.bash fi -ACCEL=$(get_qemu_accelerator) || - exit $? +set_qemu_accelerator || exit $? qemu=$(search_qemu_binary) || exit $?@@ -38,7 +37,7 @@ else fi command="${qemu} --no-reboot -nodefaults $pc_testdev -vnc none -serial stdio $pci_testdev" -command+=" -machine accel=$ACCEL" +command+=" -machine accel=$ACCEL$ACCEL_PROPS" if [ "${CONFIG_EFI}" != y ]; then command+=" -kernel" fiSignature · 1 line
2.40.1
Applied to arm/queue
https://gitlab.com/jones-drew/kvm-unit-tests/-/commits/arm/queue
Thanks,
drew