runtime: Allow to specify properties for accelerator
PATCH 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-size=65536". 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-size=65536 ./its-migration
:
BUILD_HEAD=2fffb37e
timeout -k 1s --foreground 90s /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \
-nodefaults -machine virt -accel kvm,dirty-ring-size=65536 -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.
--- arm/run | 4 ++-- scripts/arch-run.bash | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
arm/run +2 -2
@@ -35,13 +35,13 @@ fi M='-machine virt' -if [ "$ACCEL" = "kvm" ]; then +if [[ "$ACCEL" =~ ^kvm.* ]]; then if $qemu $M,\? | grep -q gic-version; then M+=',gic-version=host' fi fi -if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then +if [[ "$ACCEL" =~ ^kvm.* ]] || [[ "$ACCEL" =~ ^hvf.* ]]; then if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then processor="host" if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then
scripts/arch-run.bash +2 -2
@@ -412,11 +412,11 @@ hvf_available () get_qemu_accelerator () { - if [ "$ACCEL" = "kvm" ] && ! kvm_available; then + if [[ "$ACCEL" =~ ^kvm.* ]] && [[ ! kvm_available ]]; then echo "KVM is needed, but not available on this host" >&2 return 2 fi - if [ "$ACCEL" = "hvf" ] && ! hvf_available; then + if [[ "$ACCEL" =~ ^hvf.* ]] && [[ ! hvf_available ]]; then echo "HVF is needed, but not available on this host" >&2 return 2 fi
Signature · 1 line
2.23.0
Quoted 70 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-size=65536". 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-size=65536 ./its-migration : BUILD_HEAD=2fffb37e timeout -k 1s --foreground 90s /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ -nodefaults -machine virt -accel kvm,dirty-ring-size=65536 -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.
Signed-off-by Gavin Shan <[email protected]>--- arm/run | 4 ++-- scripts/arch-run.bash | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)arm/run +2
-2@@ -35,13 +35,13 @@ fi M='-machine virt' -if [ "$ACCEL" = "kvm" ]; then +if [[ "$ACCEL" =~ ^kvm.* ]]; then if $qemu $M,\? | grep -q gic-version; then M+=',gic-version=host' fi fi -if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then +if [[ "$ACCEL" =~ ^kvm.* ]] || [[ "$ACCEL" =~ ^hvf.* ]]; then if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then processor="host" if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; thenscripts/arch-run.bash +2
-2@@ -412,11 +412,11 @@ hvf_available () get_qemu_accelerator () { - if [ "$ACCEL" = "kvm" ] && ! kvm_available; then + if [[ "$ACCEL" =~ ^kvm.* ]] && [[ ! kvm_available ]]; then echo "KVM is needed, but not available on this host" >&2 return 2 fi - if [ "$ACCEL" = "hvf" ] && ! hvf_available; then + if [[ "$ACCEL" =~ ^hvf.* ]] && [[ ! hvf_available ]]; then echo "HVF is needed, but not available on this host" >&2 return 2 fiSignature · 1 line
2.23.0
Hi Gavin,
I'd prefer that when we want to match 'kvm', 'tcg', etc. that we split on the first comma, rather than use a regular expression that allows arbitrary characters to follow the pattern. Actually get_qemu_accelerator() could do the splitting itself, providing two variables, ACCEL (only kvm, tcg, etc.) and ACCEL_PROPS (which is either null or has a leading comma). Then command lines just need to use $ACCEL$ACCEL_PROPS. If we do that, then get_qemu_accelerator() should also allow the user to pre-split, i.e.
ACCEL=kvm ACCEL_PROPS=dirty-ring-size=65536 arm/run ...
Finally, did you also test this with the accel property in the unittests.cfg file run with run_tests.sh?
Thanks,
drew
Hi Drew,
Quoted 79 lines · Andrew Jones
Quoted 58 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-size=65536". 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-size=65536 ./its-migration : BUILD_HEAD=2fffb37e timeout -k 1s --foreground 90s /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ -nodefaults -machine virt -accel kvm,dirty-ring-size=65536 -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.
Signed-off-by Gavin Shan <[email protected]>--- arm/run | 4 ++-- scripts/arch-run.bash | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)arm/run +2
-2@@ -35,13 +35,13 @@ fi M='-machine virt' -if [ "$ACCEL" = "kvm" ]; then +if [[ "$ACCEL" =~ ^kvm.* ]]; then if $qemu $M,\? | grep -q gic-version; then M+=',gic-version=host' fi fi -if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then +if [[ "$ACCEL" =~ ^kvm.* ]] || [[ "$ACCEL" =~ ^hvf.* ]]; then if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then processor="host" if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; thenscripts/arch-run.bash +0
-0@@ -412,11 +412,11 @@ hvf_available () get_qemu_accelerator () {scripts/arch-run.bash hvf_available () · line 422
Quoted 10 lines
scripts/arch-run.bash +2
-2- if [ "$ACCEL" = "kvm" ] && ! kvm_available; then + if [[ "$ACCEL" =~ ^kvm.* ]] && [[ ! kvm_available ]]; then echo "KVM is needed, but not available on this host" >&2 return 2 fi - if [ "$ACCEL" = "hvf" ] && ! hvf_available; then + if [[ "$ACCEL" =~ ^hvf.* ]] && [[ ! hvf_available ]]; then echo "HVF is needed, but not available on this host" >&2 return 2 fiI'd prefer that when we want to match 'kvm', 'tcg', etc. that we split on the first comma, rather than use a regular expression that allows arbitrary characters to follow the pattern. Actually
get_qemu_accelerator()could do the splitting itself, providing two variables, ACCEL (only kvm, tcg, etc.) andACCEL_PROPS(which is either null or has a leading comma). Then command lines just need to use $ACCEL$ACCEL_PROPS. If we do that, thenget_qemu_accelerator()should also allow the user to pre-split, i.e.
Quoted 5 lines
ACCEL=kvm ACCEL_PROPS=dirty-ring-size=65536 arm/run ...Finally, did you also test this with the accel property in the unittests.cfg file run with
run_tests.sh?
Thanks for your quick comments. I think we can be smart to split $ACCEL in get_qemu_accelarator() into $ACCEL and $ACCEL_PROPS if you agree. It's not free to maintain another user visible property for $ACCEL_PROPS.
I forgot to run "./runtest.sh" to make sure nothing is broken. I will do this before v2 is posted. Note that v2 will be posted shortly :)
Thanks,
Gavin