Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guest test enhance for osv_sanity reference #133

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions guest-test/common.json
Original file line number Diff line number Diff line change
@@ -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"
}
11 changes: 8 additions & 3 deletions guest-test/guest.test_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions guest-test/osv_sanity/common.json
Original file line number Diff line number Diff line change
@@ -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"
}
10 changes: 1 addition & 9 deletions guest-test/osv_sanity/qemu.config.default.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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\" ",
Expand Down
10 changes: 1 addition & 9 deletions guest-test/osv_sanity/qemu.config.tsc.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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\" ",
Expand Down
4 changes: 2 additions & 2 deletions guest-test/osv_sanity/test_2.1.1.4
Original file line number Diff line number Diff line change
@@ -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"
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"
10 changes: 1 addition & 9 deletions guest-test/qemu.config.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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\" ",
Expand Down
31 changes: 18 additions & 13 deletions guest-test/qemu_get_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading