diff --git a/guest-test/common.json b/guest-test/common.json new file mode 100644 index 0000000..04d92b0 --- /dev/null +++ b/guest-test/common.json @@ -0,0 +1,10 @@ +{ + "kernel_img": "/boot/vmlinuz-xxx-yyy", + "initrd_img": "/boot/initramfs-xxx-yyy", + "bios_img": "/path/to/EDKII/OVMF.fd or other virtual BIOS", + "qemu_img": "/path/to/qemu-kvm with proper capabilty of VM test", + "guest_img": "/path/to/prepared/guest_os_image, in qcow2 or raw image format", + "guest_img_format": "raw", + "boot_pattern": "*Kernel*on*an*x86_64*", + "guest_root_passwd": "123456" +} \ No newline at end of file diff --git a/guest-test/guest.test_launcher.sh b/guest-test/guest.test_launcher.sh index 2c5a05a..ae091c5 100755 --- a/guest-test/guest.test_launcher.sh +++ b/guest-test/guest.test_launcher.sh @@ -63,6 +63,7 @@ NOTE!! args passed here will override params in qemu.confg.json -c guest kernel extra commandline -p guest pmu off/on -g [optional, default off] code coverage test mode off/on + -i [optional] path under guest-test to standalone common.json file -j [optional] path under guest-test to standalone qemu.config.json file -h HELP info EOF @@ -105,7 +106,7 @@ echo PORT="$PORT" > "$SCRIPT_DIR"/test_params.py # used across test_launcher.sh, qemu_runner.py, test_executor.sh # get args for QEMU boot configurable parameters -while getopts :v:s:m:d:t:x:c:p:g:j:h arg; do +while getopts :v:s:m:d:t:x:c:p:g:i:j:h arg; do case $arg in v) VCPU=$OPTARG @@ -143,9 +144,13 @@ while getopts :v:s:m:d:t:x:c:p:g:j:h arg; do GCOV=$OPTARG echo GCOV="\"$GCOV\"" >> "$SCRIPT_DIR"/test_params.py ;; + i) + JSON_C=$OPTARG + echo JSON_C="\"$JSON_C\"" >> "$SCRIPT_DIR"/test_params.py + ;; j) - JSON=$OPTARG - echo JSON="\"$JSON\"" >> "$SCRIPT_DIR"/test_params.py + JSON_Q=$OPTARG + echo JSON_Q="\"$JSON_Q\"" >> "$SCRIPT_DIR"/test_params.py ;; h) usage && exit 0 diff --git a/guest-test/osv_sanity/common.json b/guest-test/osv_sanity/common.json new file mode 100644 index 0000000..04d92b0 --- /dev/null +++ b/guest-test/osv_sanity/common.json @@ -0,0 +1,10 @@ +{ + "kernel_img": "/boot/vmlinuz-xxx-yyy", + "initrd_img": "/boot/initramfs-xxx-yyy", + "bios_img": "/path/to/EDKII/OVMF.fd or other virtual BIOS", + "qemu_img": "/path/to/qemu-kvm with proper capabilty of VM test", + "guest_img": "/path/to/prepared/guest_os_image, in qcow2 or raw image format", + "guest_img_format": "raw", + "boot_pattern": "*Kernel*on*an*x86_64*", + "guest_root_passwd": "123456" +} \ No newline at end of file diff --git a/guest-test/osv_sanity/qemu.config.default.json b/guest-test/osv_sanity/qemu.config.default.json index 786d085..4e166c0 100644 --- a/guest-test/osv_sanity/qemu.config.default.json +++ b/guest-test/osv_sanity/qemu.config.default.json @@ -1,13 +1,5 @@ { "common": { - "kernel_img": "/boot/vmlinuz-xxx-yyy", - "initrd_img": "/boot/initramfs-xxx-yyy", - "bios_img": "/path/to/EDKII/OVMF.fd or other virtual BIOS", - "qemu_img": "/path/to/qemu-kvm with proper capabilty of VM test", - "guest_img": "/path/to/prepared/guest_os_image, in qcow2 or raw image format", - "guest_img_format": "raw", - "boot_pattern": "*Kernel*on*an*x86_64*", - "guest_root_passwd": "123456", "vm_type": "tdx", "pmu": "off", "cpus": "4", @@ -26,7 +18,7 @@ "cfg_var_3": "-smp cpus=$VCPU,sockets=$SOCKETS ", "cfg_var_4": "-m $MEMG ", "cfg_var_5": "-kernel $KERNEL_IMG ", - "cfg_var_6": "-initrd $INITRD_IMG", + "cfg_var_6": "-initrd $INITRD_IMG ", "cfg_var_7": "-netdev user,id=mynet0,hostfwd=tcp::$PORT-:22 ", "cfg_var_8": "-drive file=$GUEST_IMG,if=virtio,format=$IMG_FORMAT ", "cfg_var_9": "-append \"root=/dev/vda3 ro console=hvc0 earlyprintk=ttyS0 ignore_loglevel debug earlyprintk l1tf=off initcall_debug log_buf_len=200M nokaslr tsc=reliable efi=debug mce=off efi=debug $CMDLINE\" ", diff --git a/guest-test/osv_sanity/qemu.config.tsc.json b/guest-test/osv_sanity/qemu.config.tsc.json index 91ff82d..9ec9b1d 100644 --- a/guest-test/osv_sanity/qemu.config.tsc.json +++ b/guest-test/osv_sanity/qemu.config.tsc.json @@ -1,13 +1,5 @@ { "common": { - "kernel_img": "/boot/vmlinuz-xxx-yyy", - "initrd_img": "/boot/initramfs-xxx-yyy", - "bios_img": "/path/to/EDKII/OVMF.fd or other virtual BIOS", - "qemu_img": "/path/to/qemu-kvm with proper capabilty of VM test", - "guest_img": "/path/to/prepared/guest_os_image, in qcow2 or raw image format", - "guest_img_format": "raw", - "boot_pattern": "*Kernel*on*an*x86_64*", - "guest_root_passwd": "123456", "vm_type": "tdx", "pmu": "off", "cpus": "4", @@ -26,7 +18,7 @@ "cfg_var_3": "-smp cpus=$VCPU,sockets=$SOCKETS ", "cfg_var_4": "-m $MEMG ", "cfg_var_5": "-kernel $KERNEL_IMG ", - "cfg_var_6": "-initrd $INITRD_IMG", + "cfg_var_6": "-initrd $INITRD_IMG ", "cfg_var_7": "-netdev user,id=mynet0,hostfwd=tcp::$PORT-:22 ", "cfg_var_8": "-drive file=$GUEST_IMG,if=virtio,format=$IMG_FORMAT ", "cfg_var_9": "-append \"root=/dev/vda3 ro console=hvc0 earlyprintk=ttyS0 ignore_loglevel debug earlyprintk l1tf=off initcall_debug log_buf_len=200M nokaslr tsc=reliable efi=debug mce=off efi=debug $CMDLINE\" ", diff --git a/guest-test/osv_sanity/test_2.1.1.4 b/guest-test/osv_sanity/test_2.1.1.4 index e839ae8..dc4337a 100755 --- a/guest-test/osv_sanity/test_2.1.1.4 +++ b/guest-test/osv_sanity/test_2.1.1.4 @@ -1,4 +1,4 @@ # Create TDX guest with default qemu config and check TSC value on guest -guest.test_launcher.sh -v 1 -s 1 -m 4 -d on -t tdx -x TD_TSC_DEFAULT -p off -j "osv_sanity/qemu.config.default.json" +guest.test_launcher.sh -v 1 -s 1 -m 4 -d on -t tdx -x TD_TSC_DEFAULT -p off -i "osv_sanity/common.json" -j "osv_sanity/qemu.config.default.json" # Create TDX guest with tsc-freq specified qemu config and check TSC value on guest -guest.test_launcher.sh -v 1 -s 1 -m 4 -d on -t tdx -x TD_TSC_CONFIG -p off -j "osv_sanity/qemu.config.tsc.json" \ No newline at end of file +guest.test_launcher.sh -v 1 -s 1 -m 4 -d on -t tdx -x TD_TSC_CONFIG -p off -i "osv_santiy/common.json" -j "osv_sanity/qemu.config.tsc.json" \ No newline at end of file diff --git a/guest-test/qemu.config.json b/guest-test/qemu.config.json index 786d085..4e166c0 100644 --- a/guest-test/qemu.config.json +++ b/guest-test/qemu.config.json @@ -1,13 +1,5 @@ { "common": { - "kernel_img": "/boot/vmlinuz-xxx-yyy", - "initrd_img": "/boot/initramfs-xxx-yyy", - "bios_img": "/path/to/EDKII/OVMF.fd or other virtual BIOS", - "qemu_img": "/path/to/qemu-kvm with proper capabilty of VM test", - "guest_img": "/path/to/prepared/guest_os_image, in qcow2 or raw image format", - "guest_img_format": "raw", - "boot_pattern": "*Kernel*on*an*x86_64*", - "guest_root_passwd": "123456", "vm_type": "tdx", "pmu": "off", "cpus": "4", @@ -26,7 +18,7 @@ "cfg_var_3": "-smp cpus=$VCPU,sockets=$SOCKETS ", "cfg_var_4": "-m $MEMG ", "cfg_var_5": "-kernel $KERNEL_IMG ", - "cfg_var_6": "-initrd $INITRD_IMG", + "cfg_var_6": "-initrd $INITRD_IMG ", "cfg_var_7": "-netdev user,id=mynet0,hostfwd=tcp::$PORT-:22 ", "cfg_var_8": "-drive file=$GUEST_IMG,if=virtio,format=$IMG_FORMAT ", "cfg_var_9": "-append \"root=/dev/vda3 ro console=hvc0 earlyprintk=ttyS0 ignore_loglevel debug earlyprintk l1tf=off initcall_debug log_buf_len=200M nokaslr tsc=reliable efi=debug mce=off efi=debug $CMDLINE\" ", diff --git a/guest-test/qemu_get_config.py b/guest-test/qemu_get_config.py index 98e59d5..5d79b71 100755 --- a/guest-test/qemu_get_config.py +++ b/guest-test/qemu_get_config.py @@ -25,26 +25,31 @@ # read from qemu.config.json format for all raw qemu vm config cwd = Path(os.getcwd()) if cwd.stem == "guest-test": - if JSON is not None: - # customized qemu.confg.xxx.json located by JSON under guest-test folder - raw_config = Path(os.path.join(f"{os.getcwd()}/", JSON)).read_text() - else: + try: + JSON + except NameError: # default qemu.config.json under guest-test + common_config = Path(f"{os.getcwd()}/common.json").read_text() raw_config = Path(f"{os.getcwd()}/qemu.config.json").read_text() + else: + # customized qemu.confg.xxx.json located by JSON under guest-test folder + common_config = Path(os.path.join(f"{os.getcwd()}/", JSON_C)).read_text() + raw_config = Path(os.path.join(f"{os.getcwd()}/", JSON_Q)).read_text() else: exit(1) +image_config = json.loads(common_config) qemu_config = json.loads(raw_config) -# pre-config G-list variables' values confirmed by qemu.config.json -kernel_img = qemu_config["common"]["kernel_img"] -initrd_img = qemu_config["common"]["initrd_img"] -bios_img = qemu_config["common"]["bios_img"] -qemu_img = qemu_config["common"]["qemu_img"] -guest_img = qemu_config["common"]["guest_img"] -guest_img_format = qemu_config["common"]["guest_img_format"] -boot_pattern = qemu_config["common"]["boot_pattern"] -guest_root_passwd = qemu_config["common"]["guest_root_passwd"] +# pre-config G-list variables' values confirmed by common.json +kernel_img = image_config["kernel_img"] +initrd_img = image_config["initrd_img"] +bios_img = image_config["bios_img"] +qemu_img = image_config["qemu_img"] +guest_img = image_config["guest_img"] +guest_img_format = image_config["guest_img_format"] +boot_pattern = image_config["boot_pattern"] +guest_root_passwd = image_config["guest_root_passwd"] port = PORT port_tel = port - 1000