Skip to content

Conversation

townsend2010
Copy link
Contributor

@townsend2010 townsend2010 commented Aug 8, 2019

This enables the backends to define how they check if their prerequisites are met before running and to also handle error conditions better and surface those to the user,

Fixes #6, Fixes #770, Fixes #775, Fixes #811

@townsend2010
Copy link
Contributor Author

Tests are segfaulting...will look tomorrow.

@townsend2010 townsend2010 force-pushed the implement-backend-healthcheck branch from b4a68ed to b8dcc74 Compare August 9, 2019 13:35
Chris Townsend added 7 commits August 13, 2019 15:37
Also, only run the check if there are no instances running.
This will check if /dev/kvm is already in use before trying to launch/start
an instance.

Fixes #6
On any calls into the Libvirt backend, try a connection to libvirtd to ensure
it is there instead of keeping a presistent connection that can become stale.

Also, modify the whole state machine to better get the actual current state from
libvirt.

Modify and add new tests as seen fit for these modifications.
@townsend2010 townsend2010 force-pushed the implement-backend-healthcheck branch from b8dcc74 to b6d0ae7 Compare August 13, 2019 19:38
@codecov
Copy link

codecov bot commented Aug 13, 2019

Codecov Report

Merging #948 into master will increase coverage by 0.14%.
The diff coverage is 63.86%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #948      +/-   ##
==========================================
+ Coverage   69.49%   69.63%   +0.14%     
==========================================
  Files         192      192              
  Lines        6788     6790       +2     
==========================================
+ Hits         4717     4728      +11     
+ Misses       2071     2062       -9
Impacted Files Coverage Δ
...backends/libvirt/libvirt_virtual_machine_factory.h 0% <ø> (ø) ⬆️
...tform/backends/qemu/qemu_virtual_machine_factory.h 0% <ø> (ø) ⬆️
include/multipass/virtual_machine_factory.h 0% <ø> (ø) ⬆️
...orm/backends/qemu/qemu_virtual_machine_factory.cpp 85.71% <0%> (-2.19%) ⬇️
...c/platform/backends/shared/linux/backend_utils.cpp 55.84% <42.85%> (+11.79%) ⬆️
src/daemon/daemon.cpp 30.44% <55.55%> (-0.06%) ⬇️
...tform/backends/libvirt/libvirt_virtual_machine.cpp 52.12% <69.01%> (+8.67%) ⬆️
...ckends/libvirt/libvirt_virtual_machine_factory.cpp 48% <72.72%> (-2%) ⬇️
...c/platform/backends/shared/linux/linux_process.cpp 77.55% <0%> (-7.64%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d28b857...b6d0ae7. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 13, 2019

Codecov Report

Merging #948 into master will increase coverage by 0.21%.
The diff coverage is 71.09%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #948      +/-   ##
=========================================
+ Coverage   69.49%   69.7%   +0.21%     
=========================================
  Files         192     192              
  Lines        6788    6852      +64     
=========================================
+ Hits         4717    4776      +59     
- Misses       2071    2076       +5
Impacted Files Coverage Δ
...backends/libvirt/libvirt_virtual_machine_factory.h 0% <ø> (ø) ⬆️
...tform/backends/qemu/qemu_virtual_machine_factory.h 0% <ø> (ø) ⬆️
include/multipass/virtual_machine_factory.h 0% <ø> (ø) ⬆️
...orm/backends/qemu/qemu_virtual_machine_factory.cpp 87.34% <0%> (-0.56%) ⬇️
src/daemon/daemon.cpp 30.65% <55.55%> (+0.15%) ⬆️
...tform/backends/libvirt/libvirt_virtual_machine.cpp 52.12% <69.01%> (+8.67%) ⬆️
...ckends/libvirt/libvirt_virtual_machine_factory.cpp 56.66% <80.64%> (+6.66%) ⬆️
...c/platform/backends/shared/linux/backend_utils.cpp 55.05% <85.71%> (+11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d28b857...4eba7c8. Read the comment docs.

@townsend2010
Copy link
Contributor Author

I'm working on a fix for #325 and was going to include it in this PR, but that should be in its own PR. So this is good for review 😁

@Saviq
Copy link
Collaborator

Saviq commented Aug 14, 2019

Having broken KVM (renamed the module files), I'm getting this:

$ multipass start snapcraft-multipass
start failed: modprobe: ERROR: ../libkmod/libkmod-module.c:192 kmod_module_parse_depline() ctx=0x55dabd9ea260 path=/lib/modules/5.0.0-25-generic/kernel/arch/x86/kvm/kvm.ko error=No such file or directory
modprobe: ERROR: ../libkmod/libkmod-module.c:192 kmod_module_parse_depline() ctx=0x55dabd9ea260 path=/lib/modules/5.0.0-25-generic/kernel/arch/x86/kvm/kvm.ko error=No such file or directory
modprobe: ERROR: could not insert 'kvm_intel': Unknown symbol in module, or unknown parameter (see dmesg)

Could we wrap this in a better error message?

@Saviq
Copy link
Collaborator

Saviq commented Aug 14, 2019

Having disabled VT, qemu behaves nice:

$ multipass start snapcraft-multipass
start failed: KVM (vmx) is disabled by your BIOS.                               
Enter your BIOS setup and enable Virtualization Technology (VT).

But after switching to libvirt:

$ multipass start snapcraft-multipass           
start failed: invalid domain pointer in virDomainCreate

@townsend2010
Copy link
Contributor Author

@Saviq

Could we wrap this in a better error message?

Yeah, I need to redirect modprobe's output to /dev/null there.

But after switching to libvirt:

Hmm, seems libvirt is quite lacking when it comes to checking for the actually support of the hypervisor. I'll see if there is something in the native API, and if not, then I'll just have the libvirt backend health check run the check_kvm_support script as well.

- check_kvm_support: Output "modprobe" to /dev/null
- libvirt: Run check_kvm_support in health check
- check_if_kvm_is_in_use: Use "virtual machine manager" instead of "hypervisor"
@townsend2010
Copy link
Contributor Author

@Saviq,

I addressed your concerns and pushed.

@Saviq
Copy link
Collaborator

Saviq commented Aug 14, 2019

Having broken KVM (renamed the module files), I'm getting this:

So that's now (both qemu and libvirt):

$ multipass start snapcraft-multipass
start failed:

meh.

@townsend2010
Copy link
Contributor Author

meh.

Oh right, I have the script set to stop execution on errors, so it doesn't get to the output of not being able to load the module. I'll fix that 😁

Copy link
Contributor

@gerboland gerboland left a comment

Choose a reason for hiding this comment

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

Couple of niggles inline. Still testing

check_kvm_module

echo "Unable to load '$kvm_mod'."
echo "Unable to load kvm support. Please ensure kvm is installed on your machine."
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: you capitalize KVM in other messages above. Why not here? Also, can KVM actually be installed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Checking the return code of the modprobe, and if failure, printing its error message would help people debug the issue. And us, if people paste that output into a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you capitalize KVM in other messages above. Why not here?

Oops, I will do that.

Also, can KVM actually be installed?

Well, it's a kernel module, so perhaps it's not compiled in the kernel being used? I'm not sure how else to word that without being too technical.

Checking the return code of the modprobe, and if failure, printing its error message would help people debug the issue. And us, if people paste that output into a bug.

I originally had the output of modprobe, but @Saviq pointed out that it's not what we want in #811 and #948 (comment). So I'm not sure how else to handle that other to be generic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, pushed the change for capitalizing 'KVM'.

Copy link
Contributor

Choose a reason for hiding this comment

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

You mean @Saviq 's comment "Could we wrap this in a better error message?" ?

Could we compromise by printing the modprobe error to stderr, and setting QProcess::ForwardedErrorChannel so that it'll end up in the journal?

I just hate throwing away a useful error message.

- check_kvm_support: Capitalize 'KVM'
- backend::check_for_kvm_support(): Detect if check_kvm_support() is in multipassd's PATH
@townsend2010
Copy link
Contributor Author

@gerboland,
I also pushed the change to catch if check_kvm_support is not in multipassd's PATH.

Copy link
Contributor

@gerboland gerboland left a comment

Choose a reason for hiding this comment

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

I've tested it as much as I can, and healthcheck appears to do the job for both backends. libvirt improvements welcome!

@townsend2010
Copy link
Contributor Author

bors r=Saviq,gerboland

bors bot added a commit that referenced this pull request Aug 15, 2019
948: Implement backend healthcheck r=Saviq,gerboland a=townsend2010

This enables the backends to define how they check if their prerequisites are met before running and to also handle error conditions better and surface those to the user,

Fixes #6, Fixes #770, Fixes #775, Fixes #811 

Co-authored-by: Chris Townsend <[email protected]>
@townsend2010 townsend2010 merged commit 4eba7c8 into master Aug 15, 2019
@bors bors bot deleted the implement-backend-healthcheck branch August 15, 2019 16:13
@bors
Copy link
Contributor

bors bot commented Aug 15, 2019

Build failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants