From a87acf93d8705cccf91fda3c702da04c365d9e9d Mon Sep 17 00:00:00 2001 From: alexanderbazhenoff Date: Thu, 25 Oct 2018 13:58:13 +0300 Subject: [PATCH] kvm: improved performance on creating VM (#2923) Improved performance on creating VM for KVM virtualization. On a huge hosts every "ifconfig | grep" takes a lot of time (about 2.5-3 minutes on hosts with 500 machines). For example: ip link show dev $vlanDev > /dev/null is faster than ifconfig |grep -w $vlanDev > /dev/null. But using ip command is much better. Using this patch you can create 500s machine in 10 seconds. You don't need slow ifconfig prints anymore. --- scripts/vm/network/vnet/modifyvlan.sh | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/scripts/vm/network/vnet/modifyvlan.sh b/scripts/vm/network/vnet/modifyvlan.sh index 24a38a18050..affa7780a9f 100755 --- a/scripts/vm/network/vnet/modifyvlan.sh +++ b/scripts/vm/network/vnet/modifyvlan.sh @@ -48,11 +48,7 @@ addVlan() { fi # is up? - ifconfig |grep -w $vlanDev > /dev/null - if [ $? -gt 0 ] - then - ifconfig $vlanDev up > /dev/null - fi + ip link set $vlanDev up > /dev/null 2>/dev/null if [ ! -d /sys/class/net/$vlanBr ] then @@ -86,11 +82,7 @@ addVlan() { fi fi # is vlanBr up? - ifconfig |grep -w $vlanBr > /dev/null - if [ $? -gt 0 ] - then - ifconfig $vlanBr up - fi + ip link set $vlanBr up > /dev/null 2>/dev/null return 0 } @@ -109,7 +101,7 @@ deleteVlan() { return 1 fi - ifconfig $vlanBr down + ip link set $vlanBr down if [ $? -gt 0 ] then