Skip to content

Commit 64a2b1c

Browse files
authored
[vs]: build sonic vs kvm image (#2269)
Signed-off-by: Guohan Lu <[email protected]>
1 parent 465ebba commit 64a2b1c

40 files changed

+1275
-97
lines changed

build_debian.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/hooks/union-fsck
152152
pushd $FILESYSTEM_ROOT/usr/share/initramfs-tools/scripts/init-bottom && sudo patch -p1 < $OLDPWD/files/initramfs-tools/udev.patch; popd
153153

154154
## Install latest intel ixgbe driver
155-
sudo cp target/debs/ixgbe.ko $FILESYSTEM_ROOT/lib/modules/${LINUX_KERNEL_VERSION}-amd64/kernel/drivers/net/ethernet/intel/ixgbe/ixgbe.ko
155+
sudo cp target/files/ixgbe.ko $FILESYSTEM_ROOT/lib/modules/${LINUX_KERNEL_VERSION}-amd64/kernel/drivers/net/ethernet/intel/ixgbe/ixgbe.ko
156156

157157
## Install docker
158158
echo '[INFO] Install docker'

build_image.sh

+25-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,30 @@ elif [ "$IMAGE_TYPE" = "raw" ]; then
7777
mv $OUTPUT_RAW_IMAGE.gz $OUTPUT_RAW_IMAGE
7878
echo "The compressed raw image is in $OUTPUT_RAW_IMAGE"
7979

80+
elif [ "$IMAGE_TYPE" = "kvm" ]; then
81+
82+
echo "Build KVM image"
83+
KVM_IMAGE_DISK=${OUTPUT_KVM_IMAGE%.gz}
84+
sudo rm -f $KVM_IMAGE_DISK $KVM_IMAGE_DISK.gz
85+
86+
generate_onie_installer_image
87+
88+
SONIC_USERNAME=$USERNAME PASSWD=$PASSWORD sudo -E ./build_kvm_image.sh $KVM_IMAGE_DISK $onie_recovery_image $OUTPUT_ONIE_IMAGE $KVM_IMAGE_DISK_SIZE
89+
90+
[ -r $KVM_IMAGE_DISK ] || {
91+
echo "Error : $KVM_IMAGE_DISK not generated!"
92+
exit 1
93+
}
94+
95+
gzip $KVM_IMAGE_DISK
96+
97+
[ -r $KVM_IMAGE_DISK.gz ] || {
98+
echo "Error : gzip $KVM_IMAGE_DISK failed!"
99+
exit 1
100+
}
101+
102+
echo "The compressed kvm image is in $KVM_IMAGE_DISK.gz"
103+
80104
## Use 'aboot' as target machine category which includes Aboot as bootloader
81105
elif [ "$IMAGE_TYPE" = "aboot" ]; then
82106
echo "Build Aboot installer"
@@ -104,6 +128,6 @@ elif [ "$IMAGE_TYPE" = "aboot" ]; then
104128
zip -g $OUTPUT_ABOOT_IMAGE $ABOOT_BOOT_IMAGE
105129
rm $ABOOT_BOOT_IMAGE
106130
else
107-
echo "Error: Non supported target platform: $TARGET_PLATFORM"
131+
echo "Error: Non supported image type $IMAGE_TYPE"
108132
exit 1
109133
fi

build_kvm_image.sh

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/sh -ex
2+
3+
# Copyright (C) 2014 Curt Brune <[email protected]>
4+
#
5+
# SPDX-License-Identifier: GPL-2.0
6+
7+
MEM=2048
8+
DISK=$1
9+
ONIE_RECOVERY_ISO=$2
10+
INSTALLER=$3
11+
DISK_SIZE=$4
12+
13+
INSTALLER_DISK="./sonic-installer.img"
14+
15+
# VM will listen on telnet port $KVM_PORT
16+
KVM_PORT=9000
17+
18+
on_exit()
19+
{
20+
rm -f $kvm_log
21+
}
22+
23+
kvm_log=$(mktemp)
24+
trap on_exit EXIT
25+
26+
create_disk()
27+
{
28+
echo "Creating SONiC kvm disk : $DISK of size $DISK_SIZE GB"
29+
qemu-img create -f qcow2 $DISK ${DISK_SIZE}G
30+
}
31+
32+
prepare_installer_disk()
33+
{
34+
fallocate -l 1024M $INSTALLER_DISK
35+
36+
mkfs.vfat $INSTALLER_DISK
37+
38+
tmpdir=$(mktemp -d)
39+
40+
mount -o loop $INSTALLER_DISK $tmpdir
41+
42+
cp $INSTALLER $tmpdir/onie-installer.bin
43+
44+
umount $tmpdir
45+
}
46+
47+
create_disk
48+
prepare_installer_disk
49+
50+
/usr/bin/kvm -m $MEM \
51+
-name "onie" \
52+
-boot "order=cd,once=d" -cdrom "$ONIE_RECOVERY_ISO" \
53+
-device e1000,netdev=onienet \
54+
-netdev user,id=onienet,hostfwd=:0.0.0.0:3041-:22 \
55+
-vnc 0.0.0.0:0 \
56+
-vga std \
57+
-drive file=$DISK,media=disk,if=virtio,index=0 \
58+
-drive file=$INSTALLER_DISK,if=virtio,index=1 \
59+
-serial telnet:localhost:$KVM_PORT,server > $kvm_log 2>&1 &
60+
61+
kvm_pid=$!
62+
63+
sleep 2.0
64+
65+
[ -d "/proc/$kvm_pid" ] || {
66+
echo "ERROR: kvm died."
67+
cat $kvm_log
68+
exit 1
69+
}
70+
71+
echo "to kill kvm: sudo kill $kvm_pid"
72+
73+
./check_install.py -u $SONIC_USERNAME -P $PASSWD -p $KVM_PORT
74+
75+
kill $kvm_pid
76+
77+
exit 0

check_install.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python
2+
3+
import pexpect
4+
import argparse
5+
import sys
6+
import time
7+
8+
def main():
9+
10+
parser = argparse.ArgumentParser(description='test_login cmdline parser')
11+
parser.add_argument('-u', default="admin", help='login user name')
12+
parser.add_argument('-P', default="YourPaSsWoRd", help='login password')
13+
parser.add_argument('-p', type=int, default=9000, help='local port')
14+
15+
args = parser.parse_args()
16+
17+
KEY_UP = '\x1b[A'
18+
KEY_DOWN = '\x1b[B'
19+
KEY_RIGHT = '\x1b[C'
20+
KEY_LEFT = '\x1b[D'
21+
22+
login_prompt = 'sonic login:'
23+
passwd_prompt = 'Password:'
24+
cmd_prompt = "%s@sonic:~\$ $" % args.u
25+
grub_selection = "The highlighted entry will be executed"
26+
27+
p = pexpect.spawn("telnet 127.0.0.1 %s" % args.p, timeout=600, logfile=sys.stdout)
28+
29+
# select ONIE embed
30+
p.expect(grub_selection)
31+
p.sendline(KEY_DOWN)
32+
33+
# install sonic image
34+
while True:
35+
i = p.expect([login_prompt, passwd_prompt, grub_selection, cmd_prompt])
36+
if i == 0:
37+
# send user name
38+
p.sendline(args.u)
39+
elif i == 1:
40+
# send password
41+
p.sendline(args.P)
42+
elif i == 2:
43+
# select onie install
44+
p.sendline()
45+
else:
46+
break
47+
48+
# check version
49+
time.sleep(5)
50+
p.sendline('show version')
51+
p.expect([cmd_prompt])
52+
53+
if __name__ == '__main__':
54+
main()

platform/vs/docker-sonic-vs/buffers.json.j2 renamed to device/virtual/x86_64-kvm_x86_64-r0/Force10-S6000/buffers.json.j2

+19-53
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{# Default values which will be used if no actual configura available #}
22
{% set default_cable = '300m' %}
3+
{% set default_speed = '100G' %}
34
{% set default_ports_num = 32 -%}
45

56
{# Port configuration to cable length look-up table #}
@@ -66,97 +67,62 @@
6667
{% endfor %}
6768
}
6869
},
69-
{%if switch_role == 'ToRRouter' %}
70-
{% set ingress_lossless_pool_size = '4194304' %}
71-
{% set ingress_lossy_pool_size = '7340032' %}
72-
{% set egress_lossless_pool_size = '16777152' %}
73-
{% set egress_lossy_pool_size = '7340032' %}
74-
{% else %}
75-
{% set ingress_lossless_pool_size = '2097152' %}
76-
{% set ingress_lossy_pool_size = '5242880' %}
77-
{% set egress_lossless_pool_size = '16777152' %}
78-
{% set egress_lossy_pool_size = '5242880' %}
79-
{%endif %}
8070
"BUFFER_POOL": {
8171
"ingress_lossless_pool": {
82-
"size": "{{ ingress_lossless_pool_size }}",
83-
"type": "ingress",
84-
"mode": "dynamic"
85-
},
86-
"ingress_lossy_pool": {
87-
"size": "{{ ingress_lossy_pool_size }}",
72+
"size": "12766208",
8873
"type": "ingress",
8974
"mode": "dynamic"
9075
},
9176
"egress_lossless_pool": {
92-
"size": "{{ egress_lossless_pool_size }}",
77+
"size": "12766208",
9378
"type": "egress",
94-
"mode": "dynamic"
79+
"mode": "static"
9580
},
9681
"egress_lossy_pool": {
97-
"size": "{{ egress_lossy_pool_size }}",
82+
"size": "8072396",
9883
"type": "egress",
9984
"mode": "dynamic"
10085
}
10186
},
10287
"BUFFER_PROFILE": {
10388
"ingress_lossless_profile": {
10489
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
105-
"size":"0",
106-
"dynamic_th":"0"
90+
"xon":"18432",
91+
"xoff":"40560",
92+
"size":"41808",
93+
"dynamic_th":"-4",
94+
"xon_offset":"2496"
10795
},
10896
"ingress_lossy_profile": {
109-
"pool":"[BUFFER_POOL|ingress_lossy_pool]",
97+
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
11098
"size":"0",
11199
"dynamic_th":"3"
112100
},
113101
"egress_lossless_profile": {
114102
"pool":"[BUFFER_POOL|egress_lossless_pool]",
115103
"size":"0",
116-
"dynamic_th":"7"
104+
"static_th":"12766208"
117105
},
118106
"egress_lossy_profile": {
119107
"pool":"[BUFFER_POOL|egress_lossy_pool]",
120-
"size":"4096",
121-
"dynamic_th":"3"
122-
},
123-
"pg_lossy_profile": {
124-
"pool":"[BUFFER_POOL|ingress_lossy_pool]",
125-
"size":"0",
126-
"dynamic_th":"3"
127-
},
128-
"q_lossless_profile": {
129-
"pool":"[BUFFER_POOL|egress_lossless_pool]",
130-
"size":"0",
131-
"dynamic_th":"7"
132-
},
133-
"q_lossy_profile": {
134-
"pool":"[BUFFER_POOL|egress_lossy_pool]",
135-
"size":"0",
108+
"size":"1518",
136109
"dynamic_th":"3"
137110
}
138111
},
139-
"BUFFER_PORT_INGRESS_PROFILE_LIST": {
140-
"{{ port_names }}": {
141-
"profile_list" : "[BUFFER_PROFILE|ingress_lossless_profile],[BUFFER_PROFILE|ingress_lossy_profile]"
142-
}
143-
},
144-
"BUFFER_PORT_EGRESS_PROFILE_LIST": {
145-
"{{ port_names }}": {
146-
"profile_list" : "[BUFFER_PROFILE|egress_lossless_profile],[BUFFER_PROFILE|egress_lossy_profile]"
147-
}
148-
},
149112
"BUFFER_PG": {
113+
"{{ port_names }}|3-4": {
114+
"profile" : "[BUFFER_PROFILE|ingress_lossless_profile]"
115+
},
150116
"{{ port_names }}|0-1": {
151-
"profile" : "[BUFFER_PROFILE|pg_lossy_profile]"
117+
"profile" : "[BUFFER_PROFILE|ingress_lossy_profile]"
152118
}
153119
},
154120
"BUFFER_QUEUE": {
155121
"{{ port_names }}|3-4": {
156-
"profile" : "[BUFFER_PROFILE|q_lossless_profile]"
122+
"profile" : "[BUFFER_PROFILE|egress_lossless_profile]"
157123
},
158124
"{{ port_names }}|0-1": {
159-
"profile" : "[BUFFER_PROFILE|q_lossy_profile]"
125+
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]"
160126
}
161127
}
162128
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
; comment
2+
# comment
3+
eth1:29,30,31,32
4+
eth2:25,26,27,28
5+
eth3:37,38,39,40
6+
eth4:33,34,35,36
7+
eth5:41,42,43,44
8+
eth6:45,46,47,48
9+
eth7:5,6,7,8
10+
eth8:1,2,3,4
11+
eth9:9,10,11,12
12+
eth10:13,14,15,16
13+
eth11:21,22,23,24
14+
eth12:17,18,19,20
15+
eth13:49,50,51,52
16+
eth14:53,54,55,56
17+
eth15:61,62,63,64
18+
eth16:57,58,59,60
19+
eth17:65,66,67,68
20+
eth18:69,70,71,72
21+
eth19:77,78,79,80
22+
eth20:73,74,75,76
23+
eth21:105,106,107,108
24+
eth22:109,110,111,112
25+
eth23:117,118,119,120
26+
eth24:113,114,115,116
27+
eth25:121,122,123,124
28+
eth26:125,126,127,128
29+
eth27:85,86,87,88
30+
eth28:81,82,83,84
31+
eth29:89,90,91,92
32+
eth30:93,94,95,96
33+
eth31:97,98,99,100
34+
eth32:101,102,103,104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# name lanes alias
2+
Ethernet0 29,30,31,32 fortyGigE0/0
3+
Ethernet4 25,26,27,28 fortyGigE0/4
4+
Ethernet8 37,38,39,40 fortyGigE0/8
5+
Ethernet12 33,34,35,36 fortyGigE0/12
6+
Ethernet16 41,42,43,44 fortyGigE0/16
7+
Ethernet20 45,46,47,48 fortyGigE0/20
8+
Ethernet24 5,6,7,8 fortyGigE0/24
9+
Ethernet28 1,2,3,4 fortyGigE0/28
10+
Ethernet32 9,10,11,12 fortyGigE0/32
11+
Ethernet36 13,14,15,16 fortyGigE0/36
12+
Ethernet40 21,22,23,24 fortyGigE0/40
13+
Ethernet44 17,18,19,20 fortyGigE0/44
14+
Ethernet48 49,50,51,52 fortyGigE0/48
15+
Ethernet52 53,54,55,56 fortyGigE0/52
16+
Ethernet56 61,62,63,64 fortyGigE0/56
17+
Ethernet60 57,58,59,60 fortyGigE0/60
18+
Ethernet64 65,66,67,68 fortyGigE0/64
19+
Ethernet68 69,70,71,72 fortyGigE0/68
20+
Ethernet72 77,78,79,80 fortyGigE0/72
21+
Ethernet76 73,74,75,76 fortyGigE0/76
22+
Ethernet80 105,106,107,108 fortyGigE0/80
23+
Ethernet84 109,110,111,112 fortyGigE0/84
24+
Ethernet88 117,118,119,120 fortyGigE0/88
25+
Ethernet92 113,114,115,116 fortyGigE0/92
26+
Ethernet96 121,122,123,124 fortyGigE0/96
27+
Ethernet100 125,126,127,128 fortyGigE0/100
28+
Ethernet104 85,86,87,88 fortyGigE0/104
29+
Ethernet108 81,82,83,84 fortyGigE0/108
30+
Ethernet112 89,90,91,92 fortyGigE0/112
31+
Ethernet116 93,94,95,96 fortyGigE0/116
32+
Ethernet120 97,98,99,100 fortyGigE0/120
33+
Ethernet124 101,102,103,104 fortyGigE0/124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{%- include 'qos_config.j2' %}

platform/vs/docker-sonic-vs/brcm.profile.ini renamed to device/virtual/x86_64-kvm_x86_64-r0/Force10-S6000/sai.profile

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ SAI_WARM_BOOT_READ_FILE=/var/cache/sai_warmboot.bin
22
SAI_WARM_BOOT_WRITE_FILE=/var/cache/sai_warmboot.bin
33
SAI_VS_SWITCH_TYPE=SAI_VS_SWITCH_TYPE_BCM56850
44
SAI_VS_HOSTIF_USE_TAP_DEVICE=true
5+
SAI_VS_INTERFACE_LANE_MAP_FILE=/usr/share/sonic/hwsku/lanemap.ini

0 commit comments

Comments
 (0)