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

kvm2: Add support for LIBVIRT_DEFAULT_URI #4069

Closed
youdX opened this issue Apr 9, 2019 · 4 comments · Fixed by #4401
Closed

kvm2: Add support for LIBVIRT_DEFAULT_URI #4069

youdX opened this issue Apr 9, 2019 · 4 comments · Fixed by #4401
Labels
co/kvm2-driver KVM2 driver related issues help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. kind/feature Categorizes issue or PR as related to a new feature. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. r/2019q2 Issue was last reviewed 2019q2

Comments

@youdX
Copy link

youdX commented Apr 9, 2019

LIBVIRT_DEFAULT_URI=qemu+tcp://127.0.0.1:16509/system minikube start --vm-driver kvm2

😄  minikube v1.0.0 on linux (amd64)
🤹  Downloading Kubernetes v1.14.0 images in the background ...
💡  Tip: Use 'minikube start -p <name>' to create a new cluster, or 'minikube delete' to delete this one.

💣  Unable to start VM: Error getting state for host: getting connection: getting domain: 
Error connecting to libvirt socket.  Have you set up libvirt correctly?

# Install libvirt and qemu-kvm on your system, e.g.
# Debian/Ubuntu (for older Debian/Ubuntu versions, you may have to use libvirt-bin instead of libvirt-clients and libvirt-daemon-system)
$ sudo apt install libvirt-clients libvirt-daemon-system qemu-kvm
# Fedora/CentOS/RHEL
$ sudo yum install libvirt-daemon-kvm qemu-kvm

# Add yourself to the libvirt group so you don't need to sudo
# NOTE: For older Debian/Ubuntu versions change the group to [libvirtd]
$ sudo usermod -a -G libvirt $(whoami)

# Update your current session for the group change to take effect
# NOTE: For older Debian/Ubuntu versions change the group to [libvirtd]
$ newgrp libvirt

Visit https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#kvm2-driver for more information.
: virError(Code=38, Domain=7, Message='Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory')

😿  Sorry that minikube crashed. If this was unexpected, we would love to hear from you:
👉  https://github.com/kubernetes/minikube/issues/new

Archlinux, Linux clx 4.19.34-1-lts #1 SMP Sat Apr 6 19:41:19 CEST 2019 x86_64 GNU/Linux

A fix might have to be done here, taking in an environment variable or some new flag:

pkg/drivers/kvm/domain.go:143: conn, err := libvirt.NewConnect(qemusystem)
pkg/drivers/kvm/kvm.go:85: qemusystem = "qemu:///system"

@youdX
Copy link
Author

youdX commented Apr 9, 2019

A workaround could be to do like this: sudo socat -d -d -d -lf socat.log UNIX-LISTEN:/var/run/libvirt/libvirt-sock,fork,user=someuser,group=someuser TCP4:127.0.0.1:16509

This acts as a proxy, creating the unix domain socket where it should be and proxying the traffic to the tcp socket

@tstromberg tstromberg changed the title Start minikube with libvirt at qemu+tcp using the kvm2 driver fails Custom LIBVIRT_DEFAULT_URI: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory Apr 9, 2019
@tstromberg tstromberg added co/kvm2-driver KVM2 driver related issues help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. labels Apr 9, 2019
@tstromberg
Copy link
Contributor

The kvm2 driver should be sudo-less, so I'm not a big fan of the socat approach.

That said, I would be happy to review any PR which fixes this that does not require root. Help wanted!

@tstromberg tstromberg added the priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. label Apr 9, 2019
@tstromberg tstromberg changed the title Custom LIBVIRT_DEFAULT_URI: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory kvm2: Add support for LIBVIRT_DEFAULT_URI May 23, 2019
@tstromberg tstromberg added kind/feature Categorizes issue or PR as related to a new feature. r/2019q2 Issue was last reviewed 2019q2 labels May 23, 2019
@josedonizetti
Copy link
Member

josedonizetti commented May 31, 2019

@afbjorklund I'm working on this issue here. Basically allowing the user to pass a flag --kvm-qemu-uri. This allows one to pass the URI for a remote system qemu. But this also allows one to pass URI for qemu:///session, which I saw is a problem you commented on #4288.

Do we still want to support remote QEMU? Or based on the problems you described, we want to force the use for qemu://system only. Or maybe we want to validate the URL, and as long as the user passes the system URI (remote or local) we allow, but for session one we fail the start.

WDYT?

@afbjorklund
Copy link
Collaborator

As long as the default still works, I have no problem with allowing advanced users to override with e.g. MINIKUBE_LIBVIRT_DEFAULT_URI. But the result won't be "supported" as such, especially if it is just some root-equivalent hack similar to docker.sock.

I also don't want to support remote KVM, there are a lot of other options if you want to run Kubernetes in a cloud ? We just need something that can spin up a VM locally, similar to the "good ole" VirtualBox. And preferrably without using SLIRP networking...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
co/kvm2-driver KVM2 driver related issues help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. kind/feature Categorizes issue or PR as related to a new feature. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. r/2019q2 Issue was last reviewed 2019q2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants