Skip to content

Commit a87acf9

Browse files
alexanderbazhenoffyadvr
authored andcommitted
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.
1 parent 9cf57d2 commit a87acf9

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

scripts/vm/network/vnet/modifyvlan.sh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ addVlan() {
4848
fi
4949

5050
# is up?
51-
ifconfig |grep -w $vlanDev > /dev/null
52-
if [ $? -gt 0 ]
53-
then
54-
ifconfig $vlanDev up > /dev/null
55-
fi
51+
ip link set $vlanDev up > /dev/null 2>/dev/null
5652

5753
if [ ! -d /sys/class/net/$vlanBr ]
5854
then
@@ -86,11 +82,7 @@ addVlan() {
8682
fi
8783
fi
8884
# is vlanBr up?
89-
ifconfig |grep -w $vlanBr > /dev/null
90-
if [ $? -gt 0 ]
91-
then
92-
ifconfig $vlanBr up
93-
fi
85+
ip link set $vlanBr up > /dev/null 2>/dev/null
9486

9587
return 0
9688
}
@@ -109,7 +101,7 @@ deleteVlan() {
109101
return 1
110102
fi
111103

112-
ifconfig $vlanBr down
104+
ip link set $vlanBr down
113105

114106
if [ $? -gt 0 ]
115107
then

0 commit comments

Comments
 (0)