adrahon / vagrant-kvm

This project is dead, please use vagrant-libvirt instead! A Vagrant 1.4+ plugin that adds a KVM provider to Vagrant, allowing Vagrant to control and provision KVM/QEMU VM.
MIT License
366 stars 60 forks source link

v0.2.0dev: restarting halted guest got network duplicaton #204

Closed miurahr closed 10 years ago

miurahr commented 10 years ago

When start from status

miurahr@miurahr-note:/opt/vagrant/users/miurahr/work/fedora20$ vagrant status
Current machine states:

default                   poweroff (kvm)

The VM is powered off. To restart the VM, simply run `vagrant up`

got error.

miurahr@miurahr-note:/opt/vagrant/users/miurahr/work/fedora20$ vagrant up
Bringing machine 'default' up with 'kvm' provider...
==> default: Preparing network interfaces based on configuration...
/home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/driver/driver.rb:203:in `update': Call to virNetworkUpdate failed: Requested operation is not valid: there is an existing dhcp host entry in network 'vagrant-34' that matches "<host mac='00:16:3e:4a:fd:41' name='nic-1396758486' ip='192.168.34.10'/>" (Libvirt::Error)
    from /home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/driver/driver.rb:203:in `create_network'
    from /home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/action/network.rb:91:in `add_private_network_host'
    from /home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/action/network.rb:50:in `block in create_or_update_private_network!'
    from /home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/action/network.rb:47:in `each'
    from /home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/action/network.rb:47:in `each_with_index'
    from /home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/action/network.rb:47:in `create_or_update_private_network!'
    from /home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/action/network.rb:20:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/action/prepare_kvmconfig.rb:18:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/runner.rb:69:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/runner.rb:69:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/builtin/call.rb:51:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/runner.rb:69:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/runner.rb:69:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/builtin/call.rb:51:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/runner.rb:69:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/runner.rb:69:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/builtin/call.rb:51:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/action/check_kvm.rb:18:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/builtin/call.rb:57:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/action/init_storage_pool.rb:16:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /home/miurahr/.vagrant.d/gems/gems/vagrant-kvm-0.2.0.dev/lib/vagrant-kvm/action/check_kvm.rb:18:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/runner.rb:69:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/action/runner.rb:69:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/machine.rb:157:in `action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/batch_action.rb:72:in `block (2 levels) in run'

because previous configured network entries exist.

miurahr@miurahr-note:/opt/vagrant/users/miurahr/work/fedora20$ sudo cat /etc/libvirt/qemu/networks/vagrant-34.xml 
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh net-edit vagrant-34
or other application using the libvirt API.
-->

<network>
  <name>vagrant-34</name>
  <uuid>454ecd2f-d077-4d8d-9bf8-bd19d160f5d6</uuid>
  <forward mode='nat'/>
  <bridge name='virbr3' stp='on' delay='0' />
  <mac address='52:54:00:f6:1d:94'/>
  <domain name='vagrant.local'/>
  <ip address='192.168.34.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.34.100' end='192.168.34.200' />
      <host mac='00:16:3e:74:6b:c5' name='nic-1396566239' ip='192.168.34.10' />
    </dhcp>
  </ip>
</network>

This nic 00:16:3e:74:6b:c5 is owned by the guest vm.

miurahr commented 10 years ago

Is it enough to fix? Side effect? It works for me on Ubuntu Precise + PPA.

diff --git a/lib/vagrant-kvm/action.rb b/lib/vagrant-kvm/action.rb
index 0543e8c..e7bb4bd 100644
--- a/lib/vagrant-kvm/action.rb
+++ b/lib/vagrant-kvm/action.rb
@@ -13,7 +13,6 @@ module VagrantPlugins
       # a bootup (i.e. not saved).
       def self.action_boot
         Vagrant::Action::Builder.new.tap do |b|
-          b.use Network
           b.use Provision
           b.use Vagrant::Action::Builtin::HandleForwardedPortCollisions
           b.use PrepareNFSValidIds
@@ -256,6 +255,7 @@ module VagrantPlugins
               b2.use Customize, "pre-import"
               b2.use Import
               b2.use MatchMACAddress
+              b2.use Network
             end
           end
           b.use action_start