Commit Graph

689 Commits

Author SHA1 Message Date
Gerben Meijer
4536218d33 Move version sanity check to vagrant-libvirt.rb
If this check is executed in plugin.rb, the message is not displayed on
older versions of vagrant, which defeats the purpose of the test.
2016-04-09 20:29:37 +02:00
stanley karunditu
ebbf35cc18 fix #492 - tcp tunnel source ip not configurable 2016-03-31 11:31:18 -04:00
dima
25c1662213 0.0.33 2016-03-29 12:32:22 +02:00
Gerben Meijer
64af328879 Make sure we update xml on dtb addition 2016-03-23 11:02:18 +01:00
Gerben Meijer
dd7133fdc0 Add dynamic kernel and initrd startup checks
Allows for changing kernel or initrd at 'vagrant up'
2016-03-23 11:01:14 +01:00
Gerben Meijer
0016f34851 Support graphics_type = none
Devices which do not support any default vga device (e.g. ARM boards)
can't be started when a video device is present. Libvirt automatically
adds a <video> device whenever a <graphics> element is defined.

Using 'none' was already documented as supported but did not work.
2016-03-17 03:19:50 +01:00
Gerben Meijer
dc1a8d421f Add device tree binary image support
This is required for correct emulation of ARM devices
2016-03-14 16:03:32 +01:00
Gerben Meijer
98f2eaed5e Add cpu_model and cpu_fallback.
This allows for specific CPU selection and enforcement when cpu_mode =
custom, which is important when emulating CPUs of different architecture
than the host.
2016-03-14 16:03:27 +01:00
Dmitry Vasilets
c458a5fc90 Merge pull request #558 from fred-a-kemp/feature/emulator_path
Make it possible to set the path to the device model emulator.
2016-03-10 08:25:43 +01:00
anonym
59ab65523a Fixup on emulator_path configuration.
Thanks to Gerben Meijer for the fix!
2016-03-10 03:19:24 +01:00
Jim Minter
b6fa93e643 simplify as preferred 2016-03-07 14:19:03 +00:00
Jim Minter
2fc38f6067 don't barf if VM has multiple identical IP addresses 2016-03-07 13:57:50 +00:00
Kirill Shirinkin
9ca19cbf29 Fix handling missing box.img 2016-03-06 19:14:14 +01:00
Darragh Bailey
e21465771d Add additional debug info for mac searching
Reporting the MAC address being looked for in the ARP table should help
determine why some machines pick up an address belonging to another
when starting multiple VM's in parallel.
2016-02-26 11:33:05 +00:00
anonym
19eb62a93b Make it possible to set the path to the device model emulator.
On some systems (e.g. Debian) omitting this setting results in the
following error:

    Error while creating domain: Error saving the server: Call to
    virDomainDefineXML failed: invalid argument: could not find
    capabilities for domaintype=kvm

Which has been reported as:

    https://github.com/pradels/vagrant-libvirt/issues/539
2016-02-17 22:34:01 +01:00
Gerben Meijer
73f5b7aba4 Support libvirt autostart functionality 2016-02-12 20:28:39 +01:00
Gerben Meijer
c3f1e88066 Fix typo in policy option check 2016-02-11 14:40:28 +01:00
Guto Andreollo
0be1fc017a Added basic support for CPU features
The following option was added:

* cpu_feature - Defaults to unset, needs two options: "name" and "policy", as interpreted by libvirt

This only adds support for creating a VM with specific CPU features defined, not for changing them after the VM was created
2016-02-11 14:35:01 +01:00
Darragh Bailey
1ecab7a9e9 Support --no-destroy-on-error option
Vagrant supports a --no-destroy-on-error option to up to skip destroying
of the machine if there was an error on bringing it up. This can be
useful where an environment can trigger a bug which would normally
result in the domain being torn down preventing additional analysis.

Make sure to simply exit the loops by returning terminate, instead of
looking to execute the remaining retries.

Add spec tests to check that terminate does not call the runner to
remove the domain if the user has disabled destroy on error.

Define a missing constant for vagrant < 1.6 exposed by the added tests.
2016-01-27 18:21:25 +00:00
Darragh Bailey
dde1b9bd43 Raise correct exception on domain not found
Update spec to check the actually exception raised and fix the code to
raise the correct one instead of throwing constant not defined.
2016-01-27 18:21:25 +00:00
Michal Rostecki
b4a66bb43f Allow to forward ports from a custom adapter
Before this change, vagrant-libvirt assumed that all
port forwards should be done on eth0 adapter. Now
user can provide a custom adapter via "adapter" option
when calling forwarded_port.
2016-01-12 10:37:48 +01:00
Trevor Vaughan
ecb1339312 Added TPM Device support
Added TPM device support to include switching out the TPM device on
reboot if necessary.

The following options were added:

* tpm_model - Defaults to 'tpm-tis'
* tpm_type  - Defaults to 'passthrough'
* tpm_path  - Must be specified, other options are ignored if this is
              not specified. Most users will set this to /dev/tpm0.

For additional information on using a TPM with Libvirt see the following:

* http://wiki.qemu.org/Features/TPM
* https://libvirt.org/formatdomain.html#elementsTpm
2016-01-06 09:48:20 -05:00
Florian Mauracher
ca6c012f57 Fix network interface configuration for windows guests
Change the return format of the nic_mac_addresses capability to comply
with the format expected by Vagrant:
    # Vagrant expects a hash with an index starting at 1 as key
    # and the mac as uppercase string without colons as value

This fixes the configuration of additional network interfaces for
Windows guests. Other guests don't require the mac address of a
interface to configure it, thus this only affected windows guests.
2015-12-29 23:32:11 +01:00
Simon McFarlane
a478c3a81d Allow KVM hiding with the kvm_hidden attr 2015-12-16 14:22:37 -08:00
Luke Hollins
96ebe9662f Added machine memory string to integer conversion 2015-12-14 07:02:01 -05:00
Felix Kaiser
bfea80d789 Add support for USB passthrough 2015-11-25 00:46:55 +01:00
Paul Bourke
9869213a4f Allow disabling guest-to-guest ipv6 comms in libvirt networks
Background
----------
The default private_network template we supply has the following tag:

    <network ipv6='yes'>

This enables ipv6 on guest interfaces for guest-to-guest communication.
This causes a problem on hosts that either do not have ipv6 enabled or
configured correctly, resulting in an error on 'vagrant up' as follows:

    Error while activating network: Call to virNetworkCreate failed: internal error: Failed to apply firewall rules /usr/sbin/ip6tables --table filter --insert FORWARD --in-interface virbr1 --jump REJECT: ip6tables v1.4.21: can't initialize ip6tables table `filter': Address family not supported by protocol
    Perhaps ip6tables or your kernel needs to be upgraded.

Reading here:
http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=705e67d40b09a905cd6a4b8b418d5cb94eaa95a8
would suggest the above option should really be off by default, however,
I don't want to break existing behaviour or setups. This patch adds two
new config items, one for the default management network, and one for
additional user defined private networks.

Usage
-----
To disable ipv6 for the managment network:

    config.vm.provider :libvirt do |libvirt|
        libvirt.management_network_guest_ipv6 = "no"
    end

To disable for a custom private network:

    config.vm.network "private_network", ip: "192.168.33.10", libvirt__guest_ipv6: "no"

Extra Notes:
------------
Also note, if you get hit by the above error and want to apply the above
fix, you will need to clear out the management network manually:

    $ sudo virsh net-list --all
    Name                 State      Autostart     Persistent
    ----------------------------------------------------------
    default              active     yes           yes
    vagrant-libvirt      inactive   no            yes

    $ sudo virsh net-undefine vagrant-libvirt
    Network vagrant-libvirt has been undefined
2015-11-09 17:45:10 +00:00
Simon Vigneux
70e0f4e6c7 Allow dots in domain_name
As we are sometimes using FQDNs as box names, it would be nice to keep the dots. 
I tested this minor change on version 0.0.32 and it creates domain/disk correctly. 

If you need me to do anything else, just let me know. Thanks
2015-11-06 12:23:16 -05:00
Jonathan Toppins
c197d0f11c interfaces: allow user to specify an interface name
Allow the user to specify what the domif name will be for an interface
by defining a name in the Vagrantfile. This allows one to later build link
toggling from within vagrant or easily toggle the link using virsh. An
example using virsh.

By default the name of tunnel interfaces will be "tnet" + interface
number.

Given a Vagrantfile snippet:
    node.vm.network :private_network,
          :libvirt__tunnel_type => 'udp',
          :libvirt__tunnel_port => 8001,
          :libvirt__tunnel_local_port =>  8002,
          :libvirt__iface_name => 'test1'

Generates named domain interface called 'test1':
    $ virsh -c qemu:///system  domiflist vagrant_default
    Interface  Type       Source     Model       MAC
    -------------------------------------------------------
    vnet0      network    vagrant-libvirt virtio      52:54:00:2f:c1:82
    vnet1      network    switch_mgmt virtio      12:11:22:33:44:11
    test1      udp        -          virtio      52:54:00:7d:8a:2a
    tnet3      udp        -          virtio      52:54:00:ec:39:12

To toggle the interface link status one can do the following, toggle
the link up:
    $ virsh -c qemu:///system domif-setlink vagrant_default test1 up
    $ vagrant ssh -- sudo ip link set eth2 up
    $ vagrant ssh -- ip link show eth2
    4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
    state UP mode DEFAULT group default qlen 1000
        link/ether 52:54:00:7d:8a:2a brd ff:ff:ff:ff:ff:ff

Toggle the link down:
    $ virsh -c qemu:///system domif-setlink vagrant_default test1 down
    $ vagrant ssh -- sudo ip link set eth2 up
    $ vagrant ssh -- ip link show eth2
    4: eth2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast
    state DOWN mode DEFAULT group default qlen 1000
        link/ether 52:54:00:7d:8a:2a brd ff:ff:ff:ff:ff:ff

Signed-off-by: Jonathan Toppins <jtoppins@cumulusnetworks.com>
2015-10-30 14:45:52 -04:00
Dmitry Vasilets
5ed8a2a4f2 Merge pull request #491 from giacomolozito/9p_nomount
Option to disable p9 automounting at boot
2015-10-26 14:06:18 +01:00
Giacomo Lozito
b3fd0c36f0 Provide a mount: option to disable automount for p9 synced folders 2015-10-25 18:22:59 +00:00
Giacomo Lozito
79e08cf2d9 Do not mount folders with an empty guest path 2015-10-25 18:21:28 +00:00
Maxim Petrunin
b2684d310f Add PCI device passthrough functionality 2015-10-23 11:12:57 +03:00
raghavendra talur
97dd1f20f2 Allow empty prefix for domain names
Allows one to set a empty prefix for domain names
and it would create domain with the same name as set by define
method in the Vagrantfile.

Signed-off-by: raghavendra talur <raghavendra.talur@gmail.com>
2015-10-19 12:28:32 +05:30
devopsjedi
9b7f5b2cc1 Update forward_ports.rb to fix spaces in private key path
When the path to the Vagrant environment contains spaces, the IdentityFile argument to SSH does not get parsed correctly.  The result is that the command fails and no ports are forwarded to the host.  Log Output: command-line line 0: garbage at end of line;

This update places a double quote around the private key path with another pair of single quotes outside of it.  With single or double quotes alone, the command fails.  Combining the double quotes embedded in single quotes results in SSH parsing the argument correctly and the ports are forwarded properly.
2015-10-18 15:34:30 -04:00
Dmitry Vasilets
686a42446d typo 2015-10-10 09:45:43 +02:00
bcambl
e75ea34b93 Fix indentation from commit 2525be90 2015-10-09 18:32:47 -06:00
dima
5840a95ab4 0.0.32 2015-10-06 11:50:52 +02:00
Max Kutsevol
1fd789534d Customising libvirt settings can only be done when creating a box #418
* Fixed regression when using additional disks. Now disk_bus setting
applies only to main disk.
* Added ability to change additional disk bus on reload. Updated readme.

Task-Url: https://github.com/pradels/vagrant-libvirt/issues/418
Signed-off-by: Max Kutsevol <max@coolvds.com>
2015-10-06 12:39:11 +03:00
Gerben Meijer
3bbba3240b Use env[:machine].config.vm.box variable, not .box
In some cases env[:machine].box is 'nil' when a box is
not already locally present. Combined with the box_optional
flag this causes the box definition in the Vagrantfile to be
ignored completely, yielding unexpected results. All references
are changed to ensure it does not cause other issues.
2015-10-06 01:07:25 +02:00
Max Kutsevol
0345bc3bd0 suspend to disk? #411
* Error handler in case of error when saving domain state with a hint
how to handle the problem. 
* Managed saves are deleted prior to undefining a domain.

Task-Url: https://github.com/pradels/vagrant-libvirt/issues/411
Signed-off-by: Max Kutsevol <max@coolvds.com>
2015-09-27 15:13:22 +03:00
Max Kutsevol
837a344724 suspend to disk? #411
* Added the suspend_mode domain specific option. Now it can perform a
managed save/resume. Switching this domain specific option can be done
when the domain is supended, it will correctly resume the domain. 

Task-Url: https://github.com/pradels/vagrant-libvirt/issues/411
Signed-off-by: Max Kutsevol <max@coolvds.com>
2015-09-27 14:23:09 +03:00
Max Kutsevol
45e293748a Customising libvirt settings can only be done when creating a box #418
* Changed logging level on error when changing xml description from info
to error.

Task-Url: https://github.com/pradels/vagrant-libvirt/issues/418
Signed-off-by: Max Kutsevol <max@coolvds.com>
2015-09-27 12:40:08 +03:00
Max Kutsevol
d11b0b970f Customising libvirt settings can only be done when creating a box #418
* Added support to modify domain specific options on already defined
domain, updated relevant documentation. For list of modifiable options
please see updated documentation.
* Added new domain specific option - uuid. To force domain UUID when
creating new VM.


Task-Url: https://github.com/pradels/vagrant-libvirt/issues/418
Signed-off-by: Max Kutsevol <max@coolvds.com>
2015-09-26 20:46:33 +03:00
dima
2a880b8e76 0.0.31 2015-09-25 20:16:38 +02:00
Max Kutsevol
01c2fe6276 Issue with emulated CPU types.
For better VM performance CPU type should be set not to qemu64, but to
the host cpu type. 
For example see the difference (uppercased)

flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 clflush mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc
rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2
x2apic popcnt tsc_deadline_timer aes xsave avx hypervisor lahf_lm
tpr_shadow vnmi flexpriority ept xsaveopt

Added extensions when emulating host cpu model: 
flags		: fpu VME de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
PAT pse36 clflush mmx fxsr sse sse2 SS syscall nx RDTSCP lm CONSTANT_TSC
rep_good nopl EAGERFPU pni PCLMULQDQ vmx SSSE3 cx16 PCID SSE4_1 SSE4_2
x2apic popcnt TSC_DEADLINE_TIMER AES XSAVE AVX hypervisor lahf_lm
tpr_shadow vnmi flexpriority ept XSAVEOPT

Nested virtualization requires VMX/SVM capabilities, which are still
being added when domain.nested is set to true. 

Using the current default value for cpu_mode everyone will benefit from
the better VMs performance.

Signed-off-by: Max Kutsevol <max@kutsevol.com>
2015-09-25 13:58:08 +03:00
Martin André
795124eac9 Accept both symbol and string for network type
Previously, following Vagrant documentation to setup private DHCP
network failed with:

  config.vm.network "private_network", type: "dhcp"

Now libvirt provider accepts both "dhcp" and :dhcp
2015-09-24 14:40:18 +09:00
Dmitry Vasilets
91fa94c62b typo 2015-09-24 04:57:31 +02:00
Dmitry Vasilets
b20c99ffd8 Merge pull request #462 from mandre/private-network-dhcp
Handle private networks with type DHCP
2015-09-24 04:56:20 +02:00
root
2525be90bf works 2015-09-23 20:37:24 -06:00