[vs][multi-asic]: Add support to build multi-asic vs images (#8270)

Why I did it
Pre-requisite: #8269
To be able to generate multi-asic KVM image.
To provide flexibility to generate single asic or both single and multi-asic images.
How I did it
Add a new build param, BUILD_MULTIASIC_KVM, if set to "y", the multi-asic VS target KVM images will be generated. If not, only single asic VS image will be generated.
Make changes to build_image.sh to generate 4-asic and 6-asic KVM images if BUILD_MULTIASIC_KVM parameter is set to y
How to verify it
Generate single-asic VS as currently done, no change in build steps:
make configure PLATFORM=vs
make target/sonic-vs.img.gz - will generate only single asic KVM image.

make BUILD_MULTIASIC_KVM=y target/sonic-vs.img.gz - will generate single asic and multi-asic KVM images.
should generate:
sonic-vs.bin
sonic-vs.img.gz
sonic-4asic-vs.img.gz
sonic-6asic-vs.img.gz
This commit is contained in:
SuvarnaMeenakshi 2021-09-01 17:28:13 -07:00 committed by GitHub
parent 3fa8c2595f
commit 1646678fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 67 additions and 23 deletions

View File

@ -280,6 +280,7 @@ SONIC_BUILD_INSTRUCTION := make \
SONIC_ENABLE_IMAGE_SIGNATURE=$(ENABLE_IMAGE_SIGNATURE) \ SONIC_ENABLE_IMAGE_SIGNATURE=$(ENABLE_IMAGE_SIGNATURE) \
ENABLE_HOST_SERVICE_ON_START=$(ENABLE_HOST_SERVICE_ON_START) \ ENABLE_HOST_SERVICE_ON_START=$(ENABLE_HOST_SERVICE_ON_START) \
SLAVE_DIR=$(SLAVE_DIR) \ SLAVE_DIR=$(SLAVE_DIR) \
BUILD_MULTIASIC_KVM=$(BUILD_MULTIASIC_KVM) \
$(SONIC_OVERRIDE_BUILD_VARS) $(SONIC_OVERRIDE_BUILD_VARS)
.PHONY: sonic-slave-build sonic-slave-bash init reset .PHONY: sonic-slave-build sonic-slave-bash init reset

View File

@ -25,6 +25,47 @@ fi
IMAGE_VERSION="${SONIC_IMAGE_VERSION}" IMAGE_VERSION="${SONIC_IMAGE_VERSION}"
generate_kvm_image()
{
NUM_ASIC=$1
if [ $NUM_ASIC == 4 ]; then
KVM_IMAGE=$OUTPUT_KVM_4ASIC_IMAGE
RECOVERY_ISO=$onie_recovery_kvm_4asic_image
elif [ $NUM_ASIC == 6 ]; then
KVM_IMAGE=$OUTPUT_KVM_6ASIC_IMAGE
RECOVERY_ISO=$onie_recovery_kvm_6asic_image
else
KVM_IMAGE=$OUTPUT_KVM_IMAGE
RECOVERY_ISO=$onie_recovery_image
NUM_ASIC=1
fi
echo "Build $NUM_ASIC-asic KVM image"
KVM_IMAGE_DISK=${KVM_IMAGE%.gz}
sudo rm -f $KVM_IMAGE_DISK $KVM_IMAGE_DISK.gz
SONIC_USERNAME=$USERNAME PASSWD=$PASSWORD sudo -E ./scripts/build_kvm_image.sh $KVM_IMAGE_DISK $RECOVERY_ISO $OUTPUT_ONIE_IMAGE $KVM_IMAGE_DISK_SIZE
if [ $? -ne 0 ]; then
echo "Error : build kvm image failed"
exit 1
fi
[ -r $KVM_IMAGE_DISK ] || {
echo "Error : $KVM_IMAGE_DISK not generated!"
exit 1
}
gzip $KVM_IMAGE_DISK
[ -r $KVM_IMAGE_DISK.gz ] || {
echo "Error : gzip $KVM_IMAGE_DISK failed!"
exit 1
}
echo "The compressed kvm image is in $KVM_IMAGE_DISK.gz"
}
generate_onie_installer_image() generate_onie_installer_image()
{ {
# Copy platform-specific ONIE installer config files where onie-mk-demo.sh expects them # Copy platform-specific ONIE installer config files where onie-mk-demo.sh expects them
@ -93,32 +134,16 @@ elif [ "$IMAGE_TYPE" = "raw" ]; then
elif [ "$IMAGE_TYPE" = "kvm" ]; then elif [ "$IMAGE_TYPE" = "kvm" ]; then
echo "Build KVM image"
KVM_IMAGE_DISK=${OUTPUT_KVM_IMAGE%.gz}
sudo rm -f $KVM_IMAGE_DISK $KVM_IMAGE_DISK.gz
generate_onie_installer_image generate_onie_installer_image
# Generate single asic KVM image
SONIC_USERNAME=$USERNAME PASSWD=$PASSWORD sudo -E ./scripts/build_kvm_image.sh $KVM_IMAGE_DISK $onie_recovery_image $OUTPUT_ONIE_IMAGE $KVM_IMAGE_DISK_SIZE generate_kvm_image
if [ "$BUILD_MULTIASIC_KVM" == "y" ]; then
if [ $? -ne 0 ]; then # Genrate 4-asic KVM image
echo "Error : build kvm image failed" generate_kvm_image 4
exit 1 # Generate 6-asic KVM image
generate_kvm_image 6
fi fi
[ -r $KVM_IMAGE_DISK ] || {
echo "Error : $KVM_IMAGE_DISK not generated!"
exit 1
}
gzip $KVM_IMAGE_DISK
[ -r $KVM_IMAGE_DISK.gz ] || {
echo "Error : gzip $KVM_IMAGE_DISK failed!"
exit 1
}
echo "The compressed kvm image is in $KVM_IMAGE_DISK.gz"
## Use 'aboot' as target machine category which includes Aboot as bootloader ## Use 'aboot' as target machine category which includes Aboot as bootloader
elif [ "$IMAGE_TYPE" = "aboot" ]; then elif [ "$IMAGE_TYPE" = "aboot" ]; then

View File

@ -50,3 +50,9 @@ OUTPUT_ABOOT_IMAGE=target/sonic-aboot-$TARGET_MACHINE.swi
## Aboot boot image name ## Aboot boot image name
ABOOT_BOOT_IMAGE=.sonic-boot.swi ABOOT_BOOT_IMAGE=.sonic-boot.swi
## Output file name for 4-asic kvm image
OUTPUT_KVM_4ASIC_IMAGE=target/sonic-4asic-$TARGET_MACHINE.img
### Output file name for 6-asic kvm image
OUTPUT_KVM_6ASIC_IMAGE=target/sonic-6asic-$TARGET_MACHINE.img

View File

@ -196,3 +196,6 @@ SONIC_VERSION_CONTROL_COMPONENTS ?= none
# Set the env variable ENABLE_DOCKER_BASE_PULL = y to enable pulling sonic-slave docker from registry # Set the env variable ENABLE_DOCKER_BASE_PULL = y to enable pulling sonic-slave docker from registry
REGISTRY_PORT ?= 443 REGISTRY_PORT ?= 443
REGISTRY_SERVER ?= sonicdev-microsoft.azurecr.io REGISTRY_SERVER ?= sonicdev-microsoft.azurecr.io
# BUILD_MULTIASIC_KVM - if set to y multi-asic KVM images will be generated.
BUILD_MULTIASIC_KVM = n

View File

@ -218,6 +218,10 @@ endif
MAKEFLAGS += -j $(SONIC_BUILD_JOBS) MAKEFLAGS += -j $(SONIC_BUILD_JOBS)
export SONIC_CONFIG_MAKE_JOBS export SONIC_CONFIG_MAKE_JOBS
ifeq ($(CONFIGURED_PLATFORM),vs)
export BUILD_MULTIASIC_KVM=$(BUILD_MULTIASIC_KVM)
endif
############################################################################### ###############################################################################
## Routing stack related exports ## Routing stack related exports
############################################################################### ###############################################################################
@ -281,6 +285,9 @@ $(info "TELEMETRY_WRITABLE" : "$(TELEMETRY_WRITABLE)")
$(info "PDDF_SUPPORT" : "$(PDDF_SUPPORT)") $(info "PDDF_SUPPORT" : "$(PDDF_SUPPORT)")
$(info "MULTIARCH_QEMU_ENVIRON" : "$(MULTIARCH_QEMU_ENVIRON)") $(info "MULTIARCH_QEMU_ENVIRON" : "$(MULTIARCH_QEMU_ENVIRON)")
$(info "SONIC_VERSION_CONTROL_COMPONENTS": "$(SONIC_VERSION_CONTROL_COMPONENTS)") $(info "SONIC_VERSION_CONTROL_COMPONENTS": "$(SONIC_VERSION_CONTROL_COMPONENTS)")
ifeq ($(CONFIGURED_PLATFORM),vs)
$(info "BUILD_MULTIASIC_KVM" : "$(BUILD_MULTIASIC_KVM)")
endif
$(info ) $(info )
else else
$(info SONiC Build System for $(CONFIGURED_PLATFORM):$(CONFIGURED_ARCH)) $(info SONiC Build System for $(CONFIGURED_PLATFORM):$(CONFIGURED_ARCH))
@ -933,6 +940,8 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export initramfs_tools="$(IMAGE_DISTRO_DEBS_PATH)/$(INITRAMFS_TOOLS)" export initramfs_tools="$(IMAGE_DISTRO_DEBS_PATH)/$(INITRAMFS_TOOLS)"
export linux_kernel="$(IMAGE_DISTRO_DEBS_PATH)/$(LINUX_KERNEL)" export linux_kernel="$(IMAGE_DISTRO_DEBS_PATH)/$(LINUX_KERNEL)"
export onie_recovery_image="$(FILES_PATH)/$(ONIE_RECOVERY_IMAGE)" export onie_recovery_image="$(FILES_PATH)/$(ONIE_RECOVERY_IMAGE)"
export onie_recovery_kvm_4asic_image="$(FILES_PATH)/$(ONIE_RECOVERY_KVM_4ASIC_IMAGE)"
export onie_recovery_kvm_6asic_image="$(FILES_PATH)/$(ONIE_RECOVERY_KVM_4ASIC_IMAGE)"
export kversion="$(KVERSION)" export kversion="$(KVERSION)"
export image_type="$($*_IMAGE_TYPE)" export image_type="$($*_IMAGE_TYPE)"
export sonicadmin_user="$(USERNAME)" export sonicadmin_user="$(USERNAME)"