fgrehm / vagrant-cachier

Caffeine reducer
http://fgrehm.viewdocs.io/vagrant-cachier
MIT License
1.08k stars 111 forks source link

add vagrant-libvirt support #83

Closed varac closed 10 years ago

varac commented 10 years ago

hej,

similar to the vagrant-kvm feature request: it would be great to have support for the vagrant-libvirt provider !

Greetings, varac

fgrehm commented 10 years ago

This should be in place as soon as I find the time to do some more testing on https://github.com/fgrehm/vagrant-cachier/pull/79 and cut a new release. I'll leave this issue open for now so we can double check that once the release is out :-)

fgrehm commented 10 years ago

Hey @varac, 0.6.0 is out, please give it a go and LMK in case you have trouble configuring the plugin for vagrant-libvirt, if all works well we can add back vagrant-libvirt to the compatible providers list :-)

varac commented 10 years ago

hi fgrehm,

i tried it with vagrant-libvirt, and it doesn't cache. installing a package on a debian box, removing it, apt-get clean, reinstalling it does download the package the second time. there's even no .vagrant/machines//cache directory

vagrant plugin list sahara (0.0.16) vagrant-cachier (0.6.0) vagrant-libvirt (0.0.15)

greets, varac

fgrehm commented 10 years ago

Oh, you can't "apt-get clean"! I think it is written on the docs somewhere but that will remove all cached packages!

Would u mind trying again without the "apt-get clean"? If it doesn't work, please show us your Vagrantfile if possible.

Thanks in advance!

Fábio Rehm Sent on the run On Mar 12, 2014 6:59 PM, "varac" notifications@github.com wrote:

hi fgrehm,

i tried it with vagrant-libvirt, and it doesn't cache. installing a package on a debian box, removing it, apt-get clean, reinstalling it does download the package the second time. there's even no .vagrant/machines//cache directory

vagrant plugin list sahara (0.0.16) vagrant-cachier (0.6.0) vagrant-libvirt (0.0.15)

greets, varac

Reply to this email directly or view it on GitHubhttps://github.com/fgrehm/vagrant-cachier/issues/83#issuecomment-37474214 .

varac commented 10 years ago

i tried installing another package, without cleaning the cache.

testbot@greyhound:~/vagrant-test-testbot$ cat Vagrantfile 
Vagrant.configure("2") do |config|
  config.vm.define :testvm do |testvm|
    testvm.vm.box = "leap-wheezy"
    testvm.vm.box_url = "https://downloads.leap.se/leap-debian-libvirt.box"
    testvm.vm.network :private_network, :ip => '10.6.6.201'
  end

  config.vm.provider :libvirt do |libvirt|
    libvirt.connect_via_ssh = false
  end

  if Vagrant.has_plugin?("vagrant-cachier")
    config.cache.scope = :machine
  end
end

and this is the content of the .vagrant dir (after installing thje package on the box):

testbot@greyhound:~/vagrant-test-testbot$ find .vagrant/
.vagrant/
.vagrant/machines
.vagrant/machines/testvm
.vagrant/machines/testvm/libvirt
.vagrant/machines/testvm/libvirt/created_networks
.vagrant/machines/testvm/libvirt/action_provision
.vagrant/machines/testvm/libvirt/id
.vagrant/machines/testvm/virtualbox
fgrehm commented 10 years ago

Oh, I think this needs to be fixed from vagrant-libvirt's side as they are using a custom action for provisioning the VMs and we hook into Vagrant's default action.

/cc @pradels

varac commented 10 years ago

i opened an issue for vagrant-cachier already: https://github.com/pradels/vagrant-libvirt/issues/153

@sciurus was wondering in that issue what steps need to be done to support it, maybe you could point him in the right direction ?

cheers, varac

sciurus commented 10 years ago

I'm testing this with a modified vagrant-libvirt.

I set

config.cache.scope = :machine

like varac did. /tmp/vagrant-cache is created and the appropriate symlinks are set up.

However, we still have a problem with synced folders. Vagrant-libvirts default of rsync won't work because it's unidirection. If I turn on NFS in my Vagrantfile with

config.cache.synced_folder_opts = { type: :nfs }

then vagrant-cachier will run

@env[:machine].config.vm.synced_folder cache_root, '/tmp/vagrant-cache', { :id => "vagrant-cache" , :type => nfs }

However, vagrant-libvirt wants :nfs => true instead of :type => nfs. From #73 I see this was a change for Vagrant 1.4. Seems like we should support both syntaxes in vagrant-libvirt. I'll work on that.

sciurus commented 10 years ago

Actually, on further examination the problem must be something else. Currently vagrant-libvirt is unexpectedly defaulting to using nfs as covered at pradels/vagrant-libvirt#154. I simply don't see any synced folder being setup for vagrant-cachier. If I have VAGRANT_LOG=info and grep the output for synced_folders the only entry I see is

INFO synced_folders: - /vagrant: . => /vagrant

fgrehm commented 10 years ago

@sciurus what vagrant version are you using?

sciurus commented 10 years ago

1.4.3. I probably won't come back to this problem until I've got vagrant-libvirt's synced folder issues sorted out. I'm not sure yet what vagrant version we'll require for the next release. Vagrant-cachier supports 1.4 and 1.5, right?

fgrehm commented 10 years ago

I use 1.4.3 as well and it has been working just fine for me with the lxc provider.

Can we run libvirt from inside a VBox VM? Sorry if this sound silly but I'm not too familiar with libvirt. If that is possible, I'd love some help setting up a VM to help you out debugging the issue. I've been using a set of Vagrant VBox VMs as a common ground for debugging vagrant-lxc issues for a while with great success :-)

tuminoid commented 10 years ago

@fgrehm If you turn on hardware virtualization, you can run VM inside VM (not sure of libvirt even requires it, but I have it on for all VMs anyway).

Add this for Virtualbox:

  config.vm.provider "virtualbox" do |v|
    v.customize [ "modifyvm", :id, "--hwvirtex", "on" ]
  end

or VMWare

  config.vm.provider "vmware_fusion" do |v|
    v.vmx["vhv.enable"] = "TRUE"
  end
sciurus commented 10 years ago

@tuminoid I think you're right about VMware Fusion but not about VirtualBox. The VirtualBox documentation says of hwvirtex "This enables or disables the use of hardware virtualization extensions (Intel VT-x or AMD-V) in the processor of your host system". It doesn't say that these functions are exposed for use in the guest system. That's typically called nested virtualization, and virtualbox ticket #4032 suggests it's not supported.

@fgrehm you should be able to run libvirt in VirtualBox. In the absence of hardware virtualization support, QEMU should fall back to emulation instead of using KVM. However, this will be painfully slow.

tuminoid commented 10 years ago

@sciurus I stand corrected, thank you.

fgrehm commented 10 years ago

Oh well, let's just reopen the issue to keep it on our radars.

@sciurus I'm not sure when I'll be able to dig into this but could you please gist the full output of running a VAGRANT_LOG=debug vagrant up from scratch over there?

sciurus commented 10 years ago

This is working for me on my HackNashville branch of vagrant-libvirt.

fgrehm commented 10 years ago

Awesome! Please let us know if there's anything else we need to do over here and let us know when a new vagrant-libvirt version is released so we can add it to the list of compatible providers!

varac commented 10 years ago

hi, it somehow works for me, but only on the initial "vagrant up". I added a bug here: " Vagrant-cachier works fine on initial 'vagrant up', but not on subsequent tries #119", https://github.com/fgrehm/vagrant-cachier/issues/119