Fix SystemVMs running in Xen HVM mode are not configured (#2760)#2824
Conversation
| hypervisor() { | ||
| local try=$([ -x /usr/sbin/virt-what ] && virt-what | tail -1) | ||
| [ "$try" != "" ] && echo $try && return 0 | ||
| [ -x /usr/sbin/virt-what ] && local facts=( $(virt-what) ) |
There was a problem hiding this comment.
I have a question here. What is the return if it is a PV VM? Is it only xen-pv?
There was a problem hiding this comment.
Good catch, according to the virt-what script, the returns should be:
Xen PV:
xen+xen-domU- or just
xen
Xen HVM:
xen+xen-hvm
virt-what never returns xen-pv.
I think the xen-pv case in the get_boot_params() function should be xen-pv|xen-domU|xen) to ensure that any PV VMs read their configuration from /proc/cmdline.
There was a problem hiding this comment.
Also, when I use virt-what in an HVM machine I get:
xen
xen-hvm
There was a problem hiding this comment.
virt-what always returns xen + xen-hvm on Xen HVM guests when it's cpuid helper detects XenVMMXenVMM signature.
You can have a look here to see in details how virt-what detects Xen guests.
| [ -x /usr/sbin/virt-what ] && local facts=( $(virt-what) ) | ||
| if [ "$facts" != "" ]; then | ||
| # Xen HVM is recognized as Hyperv when Viridian extensions are enabled | ||
| if [ "${facts[-1]}" == "xen-domU" ] && [ "${facts[0]}" == "hyperv" ]; then |
There was a problem hiding this comment.
We have support for hyperv, it may be wrong to return 'xen-hvm' when fact is hyperv? I'm not sure how this may affect hyperv.
There was a problem hiding this comment.
If I'm not mistaken, we will get xen-hvm only if the latest fact returned by virt-what is "xen-domU" when the first fact is hyperv. On all other cases, we will get the latest fact.
| [ "$try" != "" ] && echo $try && return 0 | ||
| [ -x /usr/sbin/virt-what ] && local facts=( $(virt-what) ) | ||
| if [ "$facts" != "" ]; then | ||
| # Xen HVM is recognized as Hyperv when Viridian extensions are enabled |
There was a problem hiding this comment.
I'm not an expert about it but, as I understand, it's a Xen feature which speeds up Windows guests by providing some hyperV extensions. Viridian was the codename of HyperV.
|
|
||
| get_boot_params() { | ||
| case $HYPERVISOR in | ||
| xen-pv|xen-domU) |
There was a problem hiding this comment.
What if xen-domU is returned, removing the case would mean we no longer could process hypervisor where xen-domU would be returned.
There was a problem hiding this comment.
Right, it's my mistake. This line should not be changed.
There was a problem hiding this comment.
In that case, please remove/revert the change @dpassante
|
I also ran virt-what (original and 1.15 versions) in an older PV SSVM (ACS 4.3) running on XenServer 6.2 and I get: I'm sure the VM is a PV guest since the following lines are present in the dmesg: and there is no reference to Perhaps we should use the |
|
@dpassante sounds good to me if you want to grep |
- Set hypervisor to xen-hvm when virt-what detects both HyperV cpuid and xen-domU
26ce558 to
470bf3f
Compare
yadvr
left a comment
There was a problem hiding this comment.
LGTM, but this will require regression testing across all supported hypervisors. There is no way to do it without building a new systemvmtemplate, so I'll merge this tentatively. Note: If something comes up in testing, we may have to revert it.
|
@DaanHoogland @nvazquez @PaulAngus @GabrielBrascher @wido @khos2ow can you please review this? I won't be able to test it without building a new systemvmtemplate, if we agree we can merge this based on review and run testing after #2829 is merged, revert if necessary. |
DaanHoogland
left a comment
There was a problem hiding this comment.
one small doubt, no objections
| fi | ||
| fi | ||
|
|
||
| grep -q QEMU /proc/cpuinfo && echo "kvm" && return 0 |
There was a problem hiding this comment.
I realize this is old code moved but it does not seem reliable or future proof. How about a call to virsh (--version or so)?
There was a problem hiding this comment.
virsh is only the hypervisor host, not in the guest VM.
khos2ow
left a comment
There was a problem hiding this comment.
I'm approving this PR with one comment below. IMO if condition on line 51 can be removed if by removing, it still works on Hyper-V which I haven't tested.
| [ -x /usr/sbin/virt-what ] && local facts=( $(virt-what) ) | ||
| if [ "$facts" != "" ]; then | ||
| # Xen HVM is recognized as Hyperv when Viridian extensions are enabled | ||
| if [ "${facts[-1]}" == "xen-domU" ] && [ "${facts[0]}" == "hyperv" ]; then |
There was a problem hiding this comment.
From XenServer only point of view, this block of code is redundant. Because result of dmesg | grep -q "Xen HVM" on HVM instance on XenServer, line 41, will work 100% of the time. The gotcha point of this function is to look for hvm on xen the first thing and if not a match let the rest of the function try to detect the type.
A while back I had the same issue and did a non-conclusive investigation about how virt-what works, and was actually getting all sorts of results/order on HVM and PV instance on Xen Server. Essentially the workaround I came up was the one I mentioned above.
|
@rhtyd IIRC you don't need to build a new systemvm template for this to be pushed to instances, this will be populated and pushed to instances with |
|
@khos2ow the changes are in cloud-early-config which patches using systemvm.iso, so the first time a systemvm boots it won't be able to patch and use the new cloud-early-config from a (new) |
|
Merging based on commentary, we'll proceed with testing a new systemvmtemplate from latest 4.11 branch and conclude next week if this needs to be reverted at all. |
Set hypervisor to xen-hvm when virt-what detects both HyperV cpuid and xen-domU
Description
Types of changes
GitHub Issue/PRs
Fixes: #2760
Screenshots (if appropriate):
How Has This Been Tested?
Tested on Cloudstack 4.11.1 + XenServer 7.1.1 with a patched systemvm template.
Checklist:
Testing