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

add basic nested hyperv on kvm test case #3723

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

lixuemin2016
Copy link
Contributor

@lixuemin2016 lixuemin2016 commented May 23, 2023

Signed-off-by: lixuemin2016 [email protected]

@lixuemin2016
Copy link
Contributor Author

Signed-off-by: lixuemin2016 [email protected]

@lixuemin2016 lixuemin2016 force-pushed the new_nested branch 5 times, most recently from ef9b698 to 6725efa Compare May 23, 2023 07:17
@peixiu
Copy link
Contributor

peixiu commented May 29, 2023

Tested on a host with Haswell CPU, it can be passed.

Tested with Win2019 guest os, commands as:
python3 ConfigTest.py --testcase=nested_hyperv_on_kvm --guestname=Win2019 --clone=yes

(1/2) Host_RHEL.m9.u3.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2019.x86_64.io-github-autotest-qemu.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_threads.q35: STARTED
(1/2) Host_RHEL.m9.u3.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2019.x86_64.io-github-autotest-qemu.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_threads.q35: PASS (1387.53 s)
(2/2) Host_RHEL.m9.u3.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2019.x86_64.io-github-autotest-qemu.nested_hyperv_on_kvm.q35: STARTED
(2/2) Host_RHEL.m9.u3.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2019.x86_64.io-github-autotest-qemu.nested_hyperv_on_kvm.q35: PASS (1053.16 s)

CPU flags as:
-cpu 'Haswell-noTSX',hv_reset,hv_crash,hv-no-nonarch-coresharing=auto,hv_emsr_bitmap,hv_evmcs,+vmx,hv_stimer,hv_synic,hv_vpindex,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,hv_frequencies,hv_runtime,hv_tlbflush,hv_reenlightenment,hv_stimer_direct,hv_ipi,+kvm_pv_unhalt \

@peixiu
Copy link
Contributor

peixiu commented May 29, 2023

@lixuemin2016 For commit log, you can add some description for this fix, It's more helpful for others to understand this patch~

@lixuemin2016
Copy link
Contributor Author

@lixuemin2016 For commit log, you can add some description for this fix, It's more helpful for others to understand this patch~

@peixiu thank you so much, Peixiu, updated with more descriptions in the commit log.

  1. Start L1 Windows VM (w2022,2019,2016,win10)
  2. Start L2 BIOS/UEFI VM via booting up fedora image

Test pass for win2022,2019,2016,win10 Gen1/Gen2 VM. For win11, after enable Hyper-V role in L1, it cannot boot up with cpu flags as below:
-cpu 'Haswell-noTSX',hv_reset,hv_crash,hv-no-nonarch-coresharing=auto,hv_emsr_bitmap,hv_evmcs,+vmx,hv_stimer,hv_synic,hv_vpindex,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,hv_frequencies,hv_runtime,hv_tlbflush,hv_reenlightenment,hv_stimer_direct,hv_ipi,+kvm_pv_unhalt \

@lixuemin2016
Copy link
Contributor Author

close by mistake :)

@lixuemin2016 lixuemin2016 reopened this Jun 1, 2023
@lixuemin2016
Copy link
Contributor Author

Test result for w2022 for example:
./ConfigTest.py --testcase=nested_hyperv_on_kvm.q35 --guestname=Win2022 --platform=x86_64 --machines=q35

JOB LOG : /root/avocado/job-results/job-2023-06-01T14.34-63165d4/job.log
(1/3) Host_RHEL.m9.u0.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_threads.q35: STARTED
(1/3) Host_RHEL.m9.u0.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_threads.q35: PASS (1529.38 s)
(2/3) Host_RHEL.m9.u0.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.nested_hyperv_on_kvm.q35: STARTED
(2/3) Host_RHEL.m9.u0.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.nested_hyperv_on_kvm.q35: PASS (831.57 s)
(3/3) Host_RHEL.m9.u0.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.nested_hyperv_on_kvm.q35: STARTED
(3/3) Host_RHEL.m9.u0.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.nested_hyperv_on_kvm.q35: PASS (501.29 s)
RESULTS : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML : /root/avocado/job-results/job-2023-06-01T14.34-63165d4/results.html

@lixuemin2016
Copy link
Contributor Author

@YongxueHong Could you please help to review this PR? Thank you so much.

@@ -0,0 +1,16 @@
- nested_hyperv_on_kvm:
type = nested_hyperv_on_kvm
download_url = "https://fedora.mirror.constant.com/fedora/linux/releases/37/Cloud/x86_64/images/Fedora-Cloud-Base-37-1.7.x86_64.qcow2"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
download_url = "https://fedora.mirror.constant.com/fedora/linux/releases/37/Cloud/x86_64/images/Fedora-Cloud-Base-37-1.7.x86_64.qcow2"
download_url = ""

It looks like this link is a private site we can not expose it in public.

Copy link
Contributor Author

@lixuemin2016 lixuemin2016 Jun 5, 2023

Choose a reason for hiding this comment

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

Yes, changed. Thank you for reminder. Even this URL can be accessed from public.

Copy link
Contributor Author

@lixuemin2016 lixuemin2016 Jun 5, 2023

Choose a reason for hiding this comment

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

@YongxueHong Hi Yongxue,

Thank you so much for your review and reminder, all the suggestions have been updated.

Best Regards,
Xuemin

qemu/tests/nested_hyperv_on_kvm.py Outdated Show resolved Hide resolved
qemu/tests/nested_hyperv_on_kvm.py Outdated Show resolved Hide resolved
qemu/tests/cfg/nested_hyperv_on_kvm.cfg Outdated Show resolved Hide resolved
@YongxueHong
Copy link
Contributor

YongxueHong commented Jun 2, 2023

Hi, @lixuemin2016
For the commit signed-off: Signed-off-by: root <[email protected]>, please update the root to your name, thanks.

@lixuemin2016
Copy link
Contributor Author

@PaulYuuu, @YongxueHong

Hi Yihuang, Yongxue,

I have updated this PR based on Yongxue's suggestion.

Could you please help to take a look again at this PR when you get time?
Thank you so much.

Best Regards,
Xuemin

get_vhdx()

need_reboot = 0
status, output = session.cmd_status_output("powershell Get-VM \
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
status, output = session.cmd_status_output("powershell Get-VM \
status = session.cmd_status("powershell Get-VM \

Copy link
Contributor Author

@lixuemin2016 lixuemin2016 Jul 6, 2023

Choose a reason for hiding this comment

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

@PaulYuuu Updated, thank you so much for your comment.

hyperv_source = os.path.join(data_dir.get_deps_dir(), "nested_hyperv")
vm.copy_files_to(hyperv_source, nested_dest)

# set ExecutionPolicy mainly for winows 11
Copy link
Contributor

Choose a reason for hiding this comment

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

Check Win version first?

Copy link
Contributor Author

@lixuemin2016 lixuemin2016 Jul 6, 2023

Choose a reason for hiding this comment

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

@PaulYuuu
Thank you so much for review.
Change the description to "set RemoteSigned policy mainly for windows 10/11, it is default for windows server". This powershell command "Set-ExecutionPolicy" can be executed to windows server (2016/2019/2022), and windows 10/11.

For windows server 2016/2019/2022, the default policy is 'RemoteSigned', after execute the command, it does not have side effect. For windows 10/11, the default is undefined, so must execute this command.

==============================================================================
Refer to https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3.

RemoteSigned
The default execution policy for Windows server computers.

Undefined
There is no execution policy set in the current scope.
If the execution policy in all scopes is Undefined, the effective execution policy is Restricted for Windows clients and RemoteSigned for Windows Server.

Thank you so much.
Xuemin

@@ -0,0 +1,15 @@
- nested_hyperv_on_kvm:
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider only x86_64 and only Windows

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, thank you so much for your comment @PaulYuuu

1. Start L1 Windows VM (w2022,2019,2016,win10)
2. Start L2 BIOS/UEFI VM via booting up fedora image

ID: 2219365
Signed-off-by: xuemin <[email protected]>
Comment on lines 1 to 7
import time
import os
from avocado.utils import download
from avocado.utils import process
from virttest import data_dir
from virttest import error_context
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import time
import os
from avocado.utils import download
from avocado.utils import process
from virttest import data_dir
from virttest import error_context
import time
import os
from avocado.utils import download
from avocado.utils import process
from virttest import data_dir
from virttest import error_context

Copy link
Contributor

@YongxueHong YongxueHong left a comment

Choose a reason for hiding this comment

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

LGTM.

@YongxueHong YongxueHong merged commit 3650d38 into autotest:master Jul 11, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants