Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ SONIC_BUILD_INSTRUCTION := make \
SONIC_ENABLE_IMAGE_SIGNATURE=$(ENABLE_IMAGE_SIGNATURE) \
ENABLE_HOST_SERVICE_ON_START=$(ENABLE_HOST_SERVICE_ON_START) \
SLAVE_DIR=$(SLAVE_DIR) \
BUILD_MKVM=$(BUILD_MKVM) \
$(SONIC_OVERRIDE_BUILD_VARS)

.PHONY: sonic-slave-build sonic-slave-bash init reset
Expand Down
70 changes: 47 additions & 23 deletions build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,46 @@ fi

IMAGE_VERSION="${SONIC_IMAGE_VERSION}"

generate_kvm_image()
{
NUM_ASIC=$1
if [ $NUM_ASIC == 1 ]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make default as 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as per comment.

KVM_IMAGE=$OUTPUT_KVM_IMAGE
RECOVERY_ISO=$onie_recovery_image
elif [ $NUM_ASIC == 4 ]; then
KVM_IMAGE=$OUTPUT_MKVM_4ASIC_IMAGE
RECOVERY_ISO=$onie_recovery_mkvm_4asic_image
elif [ $NUM_ASIC == 6 ]; then
KVM_IMAGE=$OUTPUT_MKVM_6ASIC_IMAGE
RECOVERY_ISO=$onie_recovery_mkvm_6asic_image
fi

echo "Build 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()
{
# Copy platform-specific ONIE installer config files where onie-mk-demo.sh expects them
Expand Down Expand Up @@ -93,32 +133,16 @@ elif [ "$IMAGE_TYPE" = "raw" ]; 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

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

if [ $? -ne 0 ]; then
echo "Error : build kvm image failed"
exit 1
# Generate single asic KVM image
generate_kvm_image 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to pass 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as per comment.

if [ "$BUILD_MKVM" == "y" ]; then
# Genrate 4-asic KVM image
generate_kvm_image 4
# Generate 6-asic KVM image
generate_kvm_image 6
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
elif [ "$IMAGE_TYPE" = "aboot" ]; then
Expand Down
7 changes: 7 additions & 0 deletions onie-image.conf
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ OUTPUT_ABOOT_IMAGE=target/sonic-aboot-$TARGET_MACHINE.swi

## Aboot boot image name
ABOOT_BOOT_IMAGE=.sonic-boot.swi

## Output file name for 4-asic mkvm image
OUTPUT_MKVM_4ASIC_IMAGE=target/sonic-4asic-$TARGET_MACHINE.img

### Output file name for 6-asic mkvm image
OUTPUT_MKVM_6ASIC_IMAGE=target/sonic-6asic-$TARGET_MACHINE.img

3 changes: 3 additions & 0 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -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
REGISTRY_PORT ?= 443
REGISTRY_SERVER ?= sonicdev-microsoft.azurecr.io

# Default number of asics in VS platform
DEFAULT_BUILD_MKVM = n
13 changes: 13 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ endif
MAKEFLAGS += -j $(SONIC_BUILD_JOBS)
export SONIC_CONFIG_MAKE_JOBS

ifeq ($(BUILD_MKVM),)
override BUILD_MKVM := $(DEFAULT_BUILD_MKVM)
endif

ifeq ($(CONFIGURED_PLATFORM),vs)
export BUILD_MKVM=$(BUILD_MKVM)
endif

###############################################################################
## Routing stack related exports
###############################################################################
Expand Down Expand Up @@ -272,6 +280,9 @@ $(info "TELEMETRY_WRITABLE" : "$(TELEMETRY_WRITABLE)")
$(info "PDDF_SUPPORT" : "$(PDDF_SUPPORT)")
$(info "MULTIARCH_QEMU_ENVIRON" : "$(MULTIARCH_QEMU_ENVIRON)")
$(info "SONIC_VERSION_CONTROL_COMPONENTS": "$(SONIC_VERSION_CONTROL_COMPONENTS)")
ifeq ($(CONFIGURED_PLATFORM),vs)
$(info "BUILD_MKVM" : "$(BUILD_MKVM)")
endif
$(info )
else
$(info SONiC Build System for $(CONFIGURED_PLATFORM):$(CONFIGURED_ARCH))
Expand Down Expand Up @@ -924,6 +935,8 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export initramfs_tools="$(IMAGE_DISTRO_DEBS_PATH)/$(INITRAMFS_TOOLS)"
export linux_kernel="$(IMAGE_DISTRO_DEBS_PATH)/$(LINUX_KERNEL)"
export onie_recovery_image="$(FILES_PATH)/$(ONIE_RECOVERY_IMAGE)"
export onie_recovery_mkvm_4asic_image="$(FILES_PATH)/$(ONIE_RECOVERY_MKVM_4ASIC_IMAGE)"
export onie_recovery_mkvm_6asic_image="$(FILES_PATH)/$(ONIE_RECOVERY_MKVM_4ASIC_IMAGE)"
export kversion="$(KVERSION)"
export image_type="$($*_IMAGE_TYPE)"
export sonicadmin_user="$(USERNAME)"
Expand Down