Skip to content

Fix SystemVMs running in Xen HVM mode are not configured (#2760)#2824

Merged
yadvr merged 2 commits into
apache:4.11from
dpassante:fix_viridian_vrouter
Sep 7, 2018
Merged

Fix SystemVMs running in Xen HVM mode are not configured (#2760)#2824
yadvr merged 2 commits into
apache:4.11from
dpassante:fix_viridian_vrouter

Conversation

@dpassante
Copy link
Copy Markdown
Contributor

Set hypervisor to xen-hvm when virt-what detects both HyperV cpuid and xen-domU

Description

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

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:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
    Testing
  • I have added tests to cover my changes.
  • All relevant new and existing integration tests have passed.
  • A full integration testsuite with all test that can run on my environment has passed.

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) )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have a question here. What is the return if it is a PV VM? Is it only xen-pv?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, when I use virt-what in an HVM machine I get:

xen
xen-hvm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

@yadvr yadvr Aug 30, 2018

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is a Viridian extension?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if xen-domU is returned, removing the case would mean we no longer could process hypervisor where xen-domU would be returned.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, it's my mistake. This line should not be changed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In that case, please remove/revert the change @dpassante

Copy link
Copy Markdown
Member

@yadvr yadvr left a comment

Choose a reason for hiding this comment

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

Outstanding questions

@dpassante
Copy link
Copy Markdown
Contributor Author

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:
xen
xen-hvm

I'm sure the VM is a PV guest since the following lines are present in the dmesg:

Booting paravirtualized kernel on Xen
Xen: using vcpuop timer interface
Initialising Xen virtual ethernet driver.

and there is no reference to HVM.

Perhaps we should use the dmesg method that seems to be more accurate than virt-what for Xen guests?

@yadvr
Copy link
Copy Markdown
Member

yadvr commented Aug 31, 2018

@dpassante sounds good to me if you want to grep dmesg for accuracy

- Set hypervisor to xen-hvm when virt-what detects both HyperV cpuid and xen-domU
@dpassante dpassante force-pushed the fix_viridian_vrouter branch from 26ce558 to 470bf3f Compare August 31, 2018 09:57
Copy link
Copy Markdown
Member

@yadvr yadvr left a comment

Choose a reason for hiding this comment

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

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.

@yadvr yadvr added this to the 4.11.2.0 milestone Sep 4, 2018
@yadvr
Copy link
Copy Markdown
Member

yadvr commented Sep 4, 2018

@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.

Copy link
Copy Markdown
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

one small doubt, no objections

fi
fi

grep -q QEMU /proc/cpuinfo && echo "kvm" && return 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

virsh is only the hypervisor host, not in the guest VM.

Copy link
Copy Markdown
Contributor

@khos2ow khos2ow left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@khos2ow khos2ow left a comment

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

@khos2ow khos2ow Sep 5, 2018

Choose a reason for hiding this comment

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

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.

@khos2ow
Copy link
Copy Markdown
Contributor

khos2ow commented Sep 5, 2018

@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 systemvm.iso. A new set of rpms will suffice.

@yadvr
Copy link
Copy Markdown
Member

yadvr commented Sep 5, 2018

@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) systemvm.iso. On after 2+ boots, it will be able to use any new changes in cloud-early-config. Therefore a systemvmtemplate change is needed.

@yadvr
Copy link
Copy Markdown
Member

yadvr commented Sep 7, 2018

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.

@yadvr yadvr merged commit 4b4555b into apache:4.11 Sep 7, 2018
@dpassante dpassante deleted the fix_viridian_vrouter branch September 17, 2018 07:11
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.

5 participants