Skip to content

nova: enable nested virt on Intel#1304

Merged
rsalevsky merged 1 commit into
crowbar:masterfrom
SUSE-Cloud:nestedvirtm
May 17, 2018
Merged

nova: enable nested virt on Intel#1304
rsalevsky merged 1 commit into
crowbar:masterfrom
SUSE-Cloud:nestedvirtm

Conversation

@bmwiedemann

Copy link
Copy Markdown
Member

because it defaults to off
but a lot of people rely on nested virt being available

While in https://fate.suse.com/320082 the virtualisation team
declined to promote nested virt to fully supported status for SLE12,
we are using this since 2012 in all kinds of places without problems.

same as #1261

nicolasbock
nicolasbock previously approved these changes Sep 22, 2017

@vuntz vuntz left a comment

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.

As said in the other pull request: I'm not really a big fan of enabling this by default. If anything, I'd prefer if it were an option.

My rationale is that enabling by default something that is tech preview leads people to believe it's not tech preview.

@nicolasbock nicolasbock dismissed their stale review September 25, 2017 12:20

I think @vuntz has a point...

@dirkmueller dirkmueller left a comment

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.

make it a configurable, defaulting to off?

Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
if grep -qw vmx /proc/cpuinfo ; then
! grep -q nested /etc/modprobe.d/80-kvm-intel.conf &&
echo "options kvm_intel nested=1" > /etc/modprobe.d/80-kvm-intel.conf &&
/sbin/modprobe -r kvm-intel

@dirkmueller dirkmueller Jan 15, 2018

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.

/sbin/modprobe -r kvm_intel

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.

Either should work.

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.

Either should work.

Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
! grep -q nested /etc/modprobe.d/80-kvm-intel.conf &&
echo "options kvm_intel nested=1" > /etc/modprobe.d/80-kvm-intel.conf &&
/sbin/modprobe -r kvm-intel
/sbin/modprobe kvm-intel

@dirkmueller dirkmueller Jan 15, 2018

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.

/sbin/modprobe kvm_intel

nicolasbock
nicolasbock previously approved these changes Jan 15, 2018
Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
if grep -qw vmx /proc/cpuinfo ; then
! grep -q nested /etc/modprobe.d/80-kvm-intel.conf &&
echo "options kvm_intel nested=1" > /etc/modprobe.d/80-kvm-intel.conf &&
/sbin/modprobe -r kvm-intel

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.

Either should work.

Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
! grep -q N /sys/module/kvm_intel/parameters/nested ||
/sbin/modprobe -r kvm_intel
EOF
only_if { node[:nova][:kvm][:nested_virt] && `uname -r`.include?("default") && system("grep -qw vmx /proc/cpuinfo") }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [131/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)

Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
echo "options kvm_intel nested=1" > /etc/modprobe.d/80-kvm-intel.conf
! grep -q N /sys/module/kvm_intel/parameters/nested ||
/sbin/modprobe -r kvm_intel
EOF

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Naming/HeredocDelimiterNaming: Use meaningful heredoc delimiters. (https://github.com/bbatsov/ruby-style-guide#heredoc-delimiters)

Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
EOF
only_if { node[:nova][:kvm][:nested_virt] &&
`uname -r`.include?("default") &&
system("grep -qw vmx /proc/cpuinfo") }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylemultilineoperationindentation)
Layout/BlockEndNewline: Expression at 121, 56 should be on its own line.

/sbin/modprobe -r kvm_intel
EOF
only_if { node[:nova][:kvm][:nested_virt] &&
`uname -r`.include?("default") &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylemultilineoperationindentation)

Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
! grep -q N /sys/module/kvm_intel/parameters/nested ||
/sbin/modprobe -r kvm_intel
EOF
only_if { node[:nova][:kvm][:nested_virt] &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style/BlockDelimiters: Avoid using {...} for multi-line blocks. (https://github.com/bbatsov/ruby-style-guide#single-line-blocks)
Layout/MultilineBlockLayout: Block body expression is on the same line as the block start.

@bmwiedemann

Copy link
Copy Markdown
Member Author

updated it with an optional bool (without migration because it is not required and makes downgrades easier)

Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
only_if do
node[:nova][:kvm][:nested_virt] &&
`uname -r`.include?("default") &&
system("grep -qw vmx /proc/cpuinfo")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Use 2 (not 0) spaces for indenting an expression spanning multiple lines. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylemultilineoperationindentation)

Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
SHELL
only_if do
node[:nova][:kvm][:nested_virt] &&
`uname -r`.include?("default") &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Use 2 (not 0) spaces for indenting an expression spanning multiple lines. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylemultilineoperationindentation)

"secret_uuid": ""
},
"kvm": {
"nested_virt": false,

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.

Don't you need a migration?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

no, the value is marked as optional (required false) in the .schema file

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.

Ooh, that's a new one for me 😄 Ok, thanks this looks good then!

nicolasbock
nicolasbock previously approved these changes Jan 19, 2018
"secret_uuid": ""
},
"kvm": {
"nested_virt": false,

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.

Ooh, that's a new one for me 😄 Ok, thanks this looks good then!

@bmwiedemann

Copy link
Copy Markdown
Member Author

@vuntz @dirkmueller please re-review.

dirkmueller
dirkmueller previously approved these changes Apr 3, 2018
execute "enable kvm intel nested virt" do
command <<-SHELL
grep -q nested /etc/modprobe.d/80-kvm-intel.conf ||
echo "options kvm_intel nested=1" > /etc/modprobe.d/80-kvm-intel.conf

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.

Just wondering (because that's how I would have done it): why is this part not a cookbook_file resource?

`uname -r`.include?("default") &&
system("grep -qw vmx /proc/cpuinfo")
end
end

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.

If nested_virt is false, we also need code to disable nested virtualization.

grep -q nested /etc/modprobe.d/80-kvm-intel.conf ||
echo "options kvm_intel nested=1" > /etc/modprobe.d/80-kvm-intel.conf
! grep -q N /sys/module/kvm_intel/parameters/nested ||
/sbin/modprobe -r kvm_intel

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.

Won't this cause failures if there's already a VM running?

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.

the module cannot be unloaded then anymore

@dirkmueller dirkmueller dismissed stale reviews from nicolasbock and themself via ef50233 April 4, 2018 07:56
Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
})
only_if do
`uname -r`.include?("default") &&
system("grep -qw vmx /proc/cpuinfo")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Use 2 (not 0) spaces for indenting an expression spanning multiple lines. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylemultilineoperationindentation)

Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
source "kvm-intel-nested.conf.erb"
variables({
kvm: node[:nova][:kvm]
kvm_nested_enabled: node[:nova][:kvm][:nested_virt]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Layout/IndentHash: Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.

Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
template "/etc/default/qemu-kvm" do
source "qemu-kvm.erb"
# set the nested KVM setting
template "/etc/modprobe.d/80-kvm-intel.conf" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style/MultilineIfModifier: Favor a normal if-statement over a modifier clause in a multiline statement. (https://github.com/bbatsov/ruby-style-guide#no-multiline-if-modifiers)

vuntz
vuntz previously approved these changes Apr 4, 2018
Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
only_if do
node[:platform_family] == "suse" &&
`uname -r`.include?("default") &&
system("grep -qw vmx /proc/cpuinfo")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Use 2 (not 0) spaces for indenting an expression spanning multiple lines. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylemultilineoperationindentation)

Comment thread chef/cookbooks/nova/recipes/compute.rb Outdated
)
only_if do
node[:platform_family] == "suse" &&
`uname -r`.include?("default") &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Use 2 (not 0) spaces for indenting an expression spanning multiple lines. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylemultilineoperationindentation)

vuntz
vuntz previously approved these changes Apr 4, 2018
toabctl
toabctl previously approved these changes Apr 4, 2018
@toabctl toabctl added this to the Cloud 8 GMC milestone Apr 4, 2018
nicolasbock
nicolasbock previously approved these changes Apr 4, 2018
@rsalevsky

Copy link
Copy Markdown
Member

Needs a rebase.

because it defaults to off
but a lot of people rely on nested virt being available

While in https://fate.suse.com/320082 the virtualisation team
declined to promote nested virt to fully supported status for SLE12,
we are using this since 2012 in all kinds of places without problems.
@bmwiedemann bmwiedemann dismissed stale reviews from nicolasbock, toabctl, and vuntz via afbcc5c May 16, 2018 09:11
@rsalevsky rsalevsky merged commit 0da741a into crowbar:master May 17, 2018
@rsalevsky rsalevsky deleted the nestedvirtm branch May 17, 2018 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

7 participants