Skip to content
This repository was archived by the owner on Sep 18, 2020. It is now read-only.

Commit 1237669

Browse files
committed
build_library: Use FLAGS_mem over built-ins
Fixup inconsistent use of FLAGS_mem and '_get_vm_opt MEM'. The user supplied FLAGS_mem is passed to write_vm_conf, and it should take presidence over built-in values returned by '_get_vm_opt MEM'. Signed-off-by: Geoff Levand <[email protected]>
1 parent 491e144 commit 1237669

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

build_library/vm_image_util.sh

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ write_vm_conf() {
669669

670670
_write_qemu_common() {
671671
local script="$1"
672-
local vm_mem="$(_get_vm_opt MEM)"
672+
local vm_mem="$2"
673673

674674
sed -e "s%^VM_NAME=.*%VM_NAME='${VM_NAME}'%" \
675675
-e "s%^VM_MEMORY=.*%VM_MEMORY='${vm_mem}'%" \
@@ -701,14 +701,14 @@ _write_qemu_conf() {
701701
local script="$(_dst_dir)/$(_dst_name ".sh")"
702702
local dst_name=$(basename "$VM_DST_IMG")
703703

704-
_write_qemu_common "${script}"
704+
_write_qemu_common "${script}" "$@"
705705
sed -e "s%^VM_IMAGE=.*%VM_IMAGE='${dst_name}'%" -i "${script}"
706706
}
707707

708708
_write_qemu_uefi_conf() {
709709
local script="$(_dst_dir)/$(_dst_name ".sh")"
710710

711-
_write_qemu_conf
711+
_write_qemu_conf "$@"
712712

713713
local flash_ro="$(_dst_name "_efi_code.fd")"
714714
local flash_rw="$(_dst_name "_efi_vars.fd")"
@@ -741,7 +741,7 @@ _write_qemu_uefi_conf() {
741741
_write_qemu_uefi_secure_conf() {
742742
local flash_rw="$(_dst_name "_efi_vars.fd")"
743743

744-
_write_qemu_uefi_conf
744+
_write_qemu_uefi_conf "$@"
745745
cert-to-efi-sig-list "/usr/share/sb_keys/PK.crt" "${VM_TMP_DIR}/PK.esl"
746746
cert-to-efi-sig-list "/usr/share/sb_keys/KEK.crt" "${VM_TMP_DIR}/KEK.esl"
747747
cert-to-efi-sig-list "/usr/share/sb_keys/DB.crt" "${VM_TMP_DIR}/DB.esl"
@@ -755,7 +755,7 @@ _write_pxe_conf() {
755755
local vmlinuz_name="$(_dst_name ".vmlinuz")"
756756
local dst_name=$(basename "$VM_DST_IMG")
757757

758-
_write_qemu_common "${script}"
758+
_write_qemu_common "${script}" "$@"
759759
sed -e "s%^VM_KERNEL=.*%VM_KERNEL='${vmlinuz_name}'%" \
760760
-e "s%^VM_INITRD=.*%VM_INITRD='${dst_name}'%" -i "${script}"
761761

@@ -772,14 +772,14 @@ EOF
772772
_write_iso_conf() {
773773
local script="$(_dst_dir)/$(_dst_name ".sh")"
774774
local dst_name=$(basename "$VM_DST_IMG")
775-
_write_qemu_common "${script}"
775+
_write_qemu_common "${script}" "$@"
776776
sed -e "s%^VM_CDROM=.*%VM_CDROM='${dst_name}'%" -i "${script}"
777777
}
778778

779779
# Generate the vmware config file
780780
# A good reference doc: http://www.sanbarrow.com/vmx.html
781781
_write_vmx_conf() {
782-
local vm_mem="${1:-$(_get_vm_opt MEM)}"
782+
local vm_mem="${1}"
783783
local src_name=$(basename "$VM_SRC_IMG")
784784
local dst_name=$(basename "$VM_DST_IMG")
785785
local dst_dir=$(dirname "$VM_DST_IMG")
@@ -837,7 +837,7 @@ _write_vmware_zip_conf() {
837837
local vmx_file=$(basename "${vmx_path}")
838838
local zip="${dst_dir}/$(_src_to_dst_name "${src_name}" ".zip")"
839839

840-
_write_vmx_conf "$1"
840+
_write_vmx_conf "$@"
841841

842842
# Move the disk/vmx to tmp, they will be zipped.
843843
mv "${VM_DST_IMG}" "${VM_TMP_DIR}/${dst_name}"
@@ -889,7 +889,7 @@ EOF
889889

890890
# Generate a new-style (xl) Xen config file for both pvgrub and pygrub
891891
_write_xl_conf() {
892-
local vm_mem="${1:-$(_get_vm_opt MEM)}"
892+
local vm_mem="${1}"
893893
local src_name=$(basename "$VM_SRC_IMG")
894894
local dst_name=$(basename "$VM_DST_IMG")
895895
local dst_dir=$(dirname "$VM_DST_IMG")
@@ -936,7 +936,7 @@ EOF
936936
}
937937

938938
_write_ovf_virtualbox_conf() {
939-
local vm_mem="${1:-$(_get_vm_opt MEM)}"
939+
local vm_mem="${1}"
940940
local src_name=$(basename "$VM_SRC_IMG")
941941
local dst_name=$(basename "$VM_DST_IMG")
942942
local dst_dir=$(dirname "$VM_DST_IMG")
@@ -958,7 +958,7 @@ EOF
958958
}
959959

960960
_write_vagrant_conf() {
961-
local vm_mem="${1:-$(_get_vm_opt MEM)}"
961+
local vm_mem="${1}"
962962
local ovf="${VM_TMP_DIR}/box/box.ovf"
963963
local mac="${VM_TMP_DIR}/box/base_mac.rb"
964964

@@ -971,16 +971,15 @@ _write_vagrant_conf() {
971971
}
972972

973973
_write_vagrant_vmware_fusion_conf() {
974-
local vm_mem="${1:-$(_get_vm_opt MEM)}"
975974
local vmx=$(_dst_path ".vmx")
976975

977976
mkdir -p "${VM_TMP_DIR}/box"
978-
_write_vmx_conf ${vm_mem}
977+
_write_vmx_conf "$@"
979978
mv "${vmx}" "${VM_TMP_DIR}/box"
980979
}
981980

982981
_write_vagrant_parallels_conf() {
983-
local vm_mem="${1:-$(_get_vm_opt MEM)}"
982+
local vm_mem="${1}"
984983
local pvs=$(_dst_path ".pvs")
985984

986985
"${BUILD_LIBRARY_DIR}/parallels_pvs.sh" \
@@ -992,7 +991,7 @@ _write_vagrant_parallels_conf() {
992991
}
993992

994993
_write_pvs_conf() {
995-
local vm_mem="${1:-$(_get_vm_opt MEM)}"
994+
local vm_mem="${1}"
996995
local pvs=$(_dst_path ".pvs")
997996

998997
"${BUILD_LIBRARY_DIR}/parallels_pvs.sh" \
@@ -1013,7 +1012,7 @@ _write_gce_conf() {
10131012
}
10141013

10151014
_write_niftycloud_conf() {
1016-
local vm_mem="${1:-$(_get_vm_opt MEM)}"
1015+
local vm_mem="${1}"
10171016
local src_name=$(basename "$VM_SRC_IMG")
10181017
local dst_name=$(basename "$VM_DST_IMG")
10191018
local ovf="$(_dst_dir)/$(_src_to_dst_name "${src_name}" ".ovf")"
@@ -1033,7 +1032,7 @@ EOF
10331032
}
10341033

10351034
_write_ovf_vmware_conf() {
1036-
local vm_mem="${1:-$(_get_vm_opt MEM)}"
1035+
local vm_mem="${1}"
10371036
local vm_cpus="$(_get_vm_opt CPUS)"
10381037
local vmdk_file_size=$(du --bytes "${VM_DST_IMG}" | cut -f1)
10391038
local vmdk_capacity=$(vmdk-convert -i "${VM_DST_IMG}" | jq .capacity)
@@ -1052,7 +1051,7 @@ _write_ovf_vmware_conf() {
10521051
}
10531052

10541053
_write_interoute_conf() {
1055-
local vm_mem="${1:-$(_get_vm_opt MEM)}"
1054+
local vm_mem="${1}"
10561055
local vm_cpus="$(_get_vm_opt CPUS)"
10571056
local vmdk_file_size=$(du --bytes "${VM_DST_IMG}" | cut -f1)
10581057
local vmdk_capacity=$(vmdk-convert -i "${VM_DST_IMG}" | jq .capacity)

0 commit comments

Comments
 (0)