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

2 network interfaces instead of one #231

Closed
roman-holovin opened this issue May 14, 2014 · 6 comments · Fixed by #232
Closed

2 network interfaces instead of one #231

roman-holovin opened this issue May 14, 2014 · 6 comments · Fixed by #232

Comments

@roman-holovin
Copy link

I've launched box with static IP. 2 networks were created: vagrant and vagrant-33, but my ubuntu box have only one network interface, and have 192.168.123.xx ip, which is not that ip configured in Vagrantfile

vagrant 1.6.2, vagrant-kvm 0.2.0-dev

@miurahr
Copy link
Collaborator

miurahr commented May 15, 2014

vagrant-kvm 0.2.0-dev is designed to add NIC according to Vagrantfile definitions.
It always create default NW and NIC for guest, vagrant and 192.168.123.xx ip.
then it create private network for it.

It is an almost same behevior with vagrant and virtualbox. (A difference is that it is host only NIC for VirtualBox but in KVM it is NAT)

There are methods to add NIC to guest definition:
https://github.com/adrahon/vagrant-kvm/blob/master/lib/vagrant-kvm/util/vm_definition.rb#L137
https://github.com/adrahon/vagrant-kvm/blob/master/lib/vagrant-kvm/util/vm_definition.rb#L169

And It launches such a driver functions
https://github.com/adrahon/vagrant-kvm/blob/master/lib/vagrant-kvm/action/network.rb#L40

Because network action created network 'vagrant-33', add_nic() was also processed.
https://github.com/adrahon/vagrant-kvm/blob/master/lib/vagrant-kvm/action/network.rb#L77
https://github.com/adrahon/vagrant-kvm/blob/master/lib/vagrant-kvm/driver/driver.rb#L488

For further debug, could you post debug log?
That include machine domain definition XML.

Is it better that is disable default nic when configured with private network?

@roman-holovin
Copy link
Author

Issue is that if I explicitly requested to have certain ip address, VM must be available at this ip address without any modifications in my internal box configs. Of course, I can ssh in box and add new adapter, make sure that it will get desired address, but as a user why I'm supposed to do such thing? I'm not sure who caused a problem, from one point of view, box running in vm with 2 nics, so there should be 2 nics available inside OS, but there is only one. From other side, why there are 2 nics in first place, if in Vagrantfile I requested my box to have a private network with static ip.

@roman-holovin
Copy link
Author

Oops, missclick, reopened

@roman-holovin roman-holovin reopened this May 15, 2014
@adrahon
Copy link
Owner

adrahon commented May 17, 2014

I agree with @Dantix that the default behaviour should be to use the IP address that was specified in the Vagrant file and not add a NIC. It isn't simple, though, what if the user creates 3 Vagrant boxes with different networks? Do we create 3 networks with libvirt? Do we remove them when the box is destroyed? What if there's another VM using that network? etc.

Here is what I propose:

  • make the default behaviour clear in the doc (don't chose an IP, vagrant-kvm does it for you)
  • make the default subnet configurable
  • create a new network if user specifies an IP with a different subnet than the default
  • let the user manage the network mess if they create to many

@miurahr
Copy link
Collaborator

miurahr commented May 17, 2014

No creating static IP is a bug, because it designed to create static IP.

If the user creates 3 vagrant boxes with different networks, vagrant-kvm create 3 different networks and 1 default network to communicate for provision. Each guest have 2 NIC, one is specified in Vagrantfile and other is random in default network (in design)
Also when the box is destroyed, subnets are also destroyed.(in design)
If another VM using same subnet, vagrant-kvm update the subnet and both VMs can communicate each other.

The report is that vagrant-kvm is designed to create 2 nic and to assign IP address but not creating nic and not assign address. This is simply a bug.

The default subnet is hard coded now. So we need to improve there.

The comment #231 (comment) pointed the code vagrant-kvm assigning private IP address for guest.

@miurahr
Copy link
Collaborator

miurahr commented May 17, 2014

I can reproduce it.

Here is a log.
https://gist.github.com/miurahr/664b9d44ddb807e8bb18

vagrant debug log.
https://gist.github.com/miurahr/664b9d44ddb807e8bb18#file-vagrant_up-log

Vagrant-KVM create NIC for domain. Here is a copy of /etc/libvirt/qemu/fedora20.xml
https://gist.github.com/miurahr/664b9d44ddb807e8bb18#file-libvirt_domain_fedora20-xml

 <interface type='network'>
<mac address='08:00:27:73:3d:d7'/>
<source network='vagrant'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<interface type='network'>
<mac address='00:16:3e:13:8a:52'/>
<source network='vagrant-34'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x1'/>
</interface>

but guest does not recognize it. Only eth0 is created.
https://gist.github.com/miurahr/664b9d44ddb807e8bb18#file-ifconfig_on_guest-log

I have checked guest dmesg log.
https://gist.github.com/miurahr/664b9d44ddb807e8bb18#file-dmesg_in_fesora20_guest-log

It may be a problem as followings:

2nd network definition in XML is slot 0x0a and function 0x1 but it should be slot 0x0a and function 0x0.

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

Successfully merging a pull request may close this issue.

3 participants