vagrant-kvm 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.travis.yml +14 -0
- data/CHANGELOG.md +29 -0
- data/DEVELOPMENT.md +87 -0
- data/Gemfile +1 -0
- data/INSTALL.md +229 -0
- data/LICENSE +2 -1
- data/README.md +154 -63
- data/Rakefile +24 -1
- data/example_box/README.md +8 -8
- data/lib/vagrant-kvm/action.rb +47 -5
- data/lib/vagrant-kvm/action/boot.rb +0 -4
- data/lib/vagrant-kvm/action/clear_forwarded_ports.rb +53 -0
- data/lib/vagrant-kvm/action/forward_ports.rb +104 -0
- data/lib/vagrant-kvm/action/import.rb +97 -18
- data/lib/vagrant-kvm/action/init_storage_pool.rb +3 -1
- data/lib/vagrant-kvm/action/message_not_running.rb +16 -0
- data/lib/vagrant-kvm/action/network.rb +12 -13
- data/lib/vagrant-kvm/action/package_vagrantfile.rb +3 -1
- data/lib/vagrant-kvm/action/prepare_gui.rb +20 -0
- data/lib/vagrant-kvm/action/prepare_nfs_settings.rb +8 -16
- data/lib/vagrant-kvm/action/prepare_nfs_valid_ids.rb +17 -0
- data/lib/vagrant-kvm/action/reset_image_permission.rb +23 -0
- data/lib/vagrant-kvm/action/resume_network.rb +28 -0
- data/lib/vagrant-kvm/action/share_folders.rb +6 -5
- data/lib/vagrant-kvm/action/suspend.rb +8 -1
- data/lib/vagrant-kvm/config.rb +103 -2
- data/lib/vagrant-kvm/driver/driver.rb +321 -99
- data/lib/vagrant-kvm/errors.rb +18 -0
- data/lib/vagrant-kvm/provider.rb +4 -1
- data/lib/vagrant-kvm/util.rb +3 -0
- data/lib/vagrant-kvm/util/commands.rb +23 -0
- data/lib/vagrant-kvm/util/definition_attributes.rb +33 -0
- data/lib/vagrant-kvm/util/disk_info.rb +48 -0
- data/lib/vagrant-kvm/util/network_definition.rb +44 -84
- data/lib/vagrant-kvm/util/vm_definition.rb +91 -103
- data/lib/vagrant-kvm/version.rb +1 -1
- data/locales/en.yml +8 -0
- data/locales/ja.yml +14 -0
- data/spec/acceptance/vagrant-kvm_spec.rb +80 -0
- data/spec/fedora/10.virt.rules +10 -0
- data/spec/fedora/50-vagrant-libvirt-access.pkla +6 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/support/libvirt_helper.rb +37 -0
- data/spec/support/vagrant_kvm_helper.rb +39 -0
- data/spec/test_files/box.xml +74 -0
- data/spec/vagrant-kvm/config_spec.rb +56 -0
- data/spec/vagrant-kvm/driver/driver_spec.rb +36 -0
- data/spec/vagrant-kvm/errors_spec.rb +25 -0
- data/spec/vagrant-kvm/util/network_definition_spec.rb +60 -0
- data/spec/vagrant-kvm/util/vm_definition_spec.rb +76 -0
- data/templates/libvirt_domain.erb +34 -12
- data/templates/libvirt_network.erb +13 -0
- data/templates/package_Vagrantfile.erb +11 -0
- data/vagrant-kvm.gemspec +1 -2
- metadata +41 -42
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 050ef979981ce83ec1d1afe226a6f4b7f6da29d9
|
4
|
+
data.tar.gz: 95b009356ebd8e0058e2ba18b2debaa43e2015ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 34a150ca16164e872cd72291c846312013346c659f22bf680f213c877477f9c404e46a5beb5c2dff16955bbb5e2b0b6efc6a8fb80a2eb8112230caf4f7bfbdd1
|
7
|
+
data.tar.gz: 0f8761c309f8f5b4acdcc11068300266bcbfacb306c167b65dc869e3818bd8cd55b8478357d9d6c73044feaa0246208c5ef6ab51904740dfc6e8aa84e424bb47
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
language: ruby
|
2
|
+
before_install:
|
3
|
+
- sudo add-apt-repository -y ppa:miurahr/vagrant
|
4
|
+
- sudo apt-get update -qq
|
5
|
+
- sudo apt-get install -qq libvirt-dev libvirt-bin qemu-kvm qemu
|
6
|
+
- gem install --version '~> 1.5.2' bundler
|
7
|
+
rvm:
|
8
|
+
- 2.0.0
|
9
|
+
script:
|
10
|
+
- export rvmsudo_secure_path=1
|
11
|
+
- rvmsudo ruby --version
|
12
|
+
- rvmsudo gem --version
|
13
|
+
- rvmsudo bundle --version
|
14
|
+
- rvmsudo bundle exec rspec spec/vagrant-kvm/
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
# 0.1.5 (March 22, 2014)
|
2
|
+
|
3
|
+
* Change default box format to qcow2 [GH-63]
|
4
|
+
* Support Vagrant 1.4.0+[GH-126]
|
5
|
+
* Remove VMDK conversion. It is now supported by vagrant-mutate[GH-105]
|
6
|
+
* Add support for configuration for memory/cpu [GH-54][GH-51][GH-68]
|
7
|
+
* Add support for gui configuration [GH-41][GH-53]
|
8
|
+
* Add support for 'vagrant package' [GH-69]
|
9
|
+
* Add support for port forwarding [GH-72]
|
10
|
+
* Speed-up by copy-on-write backing disk image [GH-63]
|
11
|
+
* VNC port/auth configuration[GH-116][GH-84]
|
12
|
+
* SATA/IDE disk support[GH-110]
|
13
|
+
* Respect disabled directive on synced_folder configuration [GH-65]
|
14
|
+
* Configuration options for video and networks[GH-101]
|
15
|
+
* Configuration option for disk_bus[GH-80]
|
16
|
+
* Fixes storage pool permission issue.[GH-130][GH-154]
|
17
|
+
* Add document how to avoid a permission error in Fedora/Arch [GH-163][GH-171]
|
18
|
+
* Fixes segment fault when VirtualBox installed [GH-57][GH-66]
|
19
|
+
* Making a path of qemu binary specifiable [GH-59]
|
20
|
+
* Fixes error when box has not private network defition[GH-70]
|
21
|
+
* Add Japanese error messages translation [GH-71]
|
22
|
+
* Add check for kvm kernel module and loading if needed [GH-67]
|
23
|
+
* Improve error handling [GH-50]
|
24
|
+
* Expanded/Fixes Readme file [GH-55]
|
25
|
+
* Add spec test and TravisCI test[GH-82]
|
26
|
+
* Resume network when resume from suspend[GH-134]
|
27
|
+
* Fixes error when suspending with SATA drive[GH-176]
|
28
|
+
* Search qemu/kvm binary in new qemu-system-* filename[GH-109]
|
29
|
+
|
1
30
|
# 0.1.4 (August 20, 2013)
|
2
31
|
|
3
32
|
* Add support for qcow2 and configuration for image type [GH-45]
|
data/DEVELOPMENT.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Development Note
|
2
|
+
|
3
|
+
Supported ruby version is 2.0.x on vagrant 1.4.0 and later.
|
4
|
+
You may need to use a recent OS version for development base
|
5
|
+
such as Ubuntu Saucy(13.10), Trusy(14.04) or Fedora 19,20.
|
6
|
+
|
7
|
+
If you're Mac user and you have Vagrant and VMware Fusion,
|
8
|
+
you can use bundled box for development.
|
9
|
+
|
10
|
+
If you're Linux user(of cource, you try to use KVM),
|
11
|
+
You are lucky to run development version of vagrant-kvm on Vagrant,
|
12
|
+
QEMU/KVM and vagrant-kvm itself.
|
13
|
+
|
14
|
+
Unfortunately VirtualBox don't support nested virtualization.
|
15
|
+
We cannot use it for vagrant-kvm development.
|
16
|
+
|
17
|
+
## Requirement
|
18
|
+
|
19
|
+
This plugin requires additional packages for development.
|
20
|
+
|
21
|
+
- For source:
|
22
|
+
* `git`
|
23
|
+
|
24
|
+
- For KVM:
|
25
|
+
* `qemu-utils` `libvirt-dev`
|
26
|
+
|
27
|
+
- For File share:
|
28
|
+
* `apparmor-utils` (Ubuntu)
|
29
|
+
|
30
|
+
- For Ruby:
|
31
|
+
* `ruby2.0` `ruby2.0-dev` `libxml2-dev` `libxslt-dev`
|
32
|
+
* gems: `rake` `bundler`
|
33
|
+
|
34
|
+
- For box development:
|
35
|
+
* `bsdtar` `libguestfs-tools`
|
36
|
+
|
37
|
+
It is better to use `rvm` or `rbenv` to control ruby version as same as one
|
38
|
+
vagrant bundled.
|
39
|
+
|
40
|
+
## Test vagrant-kvm with vagrant-kvm
|
41
|
+
|
42
|
+
You can run vagrant-kvm on kvm/qemu guest OS with vagrant-kvm.
|
43
|
+
It is required to run KVM with 64bit Operating System and configure
|
44
|
+
`kvm-intel` or `kvm-amd` kernel module to allow it.
|
45
|
+
|
46
|
+
Please add a file and reboot in order to use kvm with nested virtulization support.
|
47
|
+
|
48
|
+
/etc/modprobe.d/kvm.conf:
|
49
|
+
```
|
50
|
+
options kvm-intel nested=1
|
51
|
+
options kvm-amd nested=1
|
52
|
+
```
|
53
|
+
|
54
|
+
### Vagrantfile and configs
|
55
|
+
|
56
|
+
There are two `Vagrantfile` to help developers.
|
57
|
+
|
58
|
+
- `spec/Vagrantfile` make an environment on Ubuntu guest.
|
59
|
+
- `spec/fedora/Vagrantfile` make an alternative environment on Fedora guest.
|
60
|
+
|
61
|
+
|
62
|
+
## Specs
|
63
|
+
|
64
|
+
To run specs, you first need to add and prepare the Vagrant box which will be used.
|
65
|
+
|
66
|
+
```bash
|
67
|
+
$ bundle exec rake box:add
|
68
|
+
$ bundle exec rake box:prepare
|
69
|
+
```
|
70
|
+
|
71
|
+
Once box is added and prepared, you can run specs:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
$ bundle exec rspec spec/vagrant-kvm/
|
75
|
+
```
|
76
|
+
|
77
|
+
When you're done, feel free to remove the box.
|
78
|
+
|
79
|
+
```bash
|
80
|
+
$ bundle exec rake box:remove
|
81
|
+
```
|
82
|
+
|
83
|
+
## Travis-CI
|
84
|
+
|
85
|
+
TBD
|
86
|
+
|
87
|
+
|
data/Gemfile
CHANGED
data/INSTALL.md
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
# Installation
|
2
|
+
|
3
|
+
## Requirements
|
4
|
+
|
5
|
+
This plugin requires QEMU 1.1+.
|
6
|
+
|
7
|
+
It also requires libvirt development files to complete installation with
|
8
|
+
dependent ruby-libvirt gems.
|
9
|
+
|
10
|
+
### Debian/Ubuntu requirements
|
11
|
+
|
12
|
+
This plugin requires
|
13
|
+
|
14
|
+
- For KVM:
|
15
|
+
* `qemu`, `qemu-kvm`,`libvirt-bin` packages
|
16
|
+
* qemu 1.1 and after
|
17
|
+
* libvirt 1.0 and after
|
18
|
+
|
19
|
+
- For NFS:
|
20
|
+
* `nfs-kernel-server`,`nfs-common`,`portmap`
|
21
|
+
|
22
|
+
- For Networking:
|
23
|
+
* `redir` `dnsmasq-base` `bridge-utils`
|
24
|
+
|
25
|
+
- For `ruby-libvirt` gems installation dependency:
|
26
|
+
* `build-essential` `ruby2.0-dev` `libvirt-dev` `libxslt1-dev` `libxml2-dev`
|
27
|
+
|
28
|
+
Some kernel version has a bug that causes a permission error on image.
|
29
|
+
You are strongly recommended to upgrade a `linux-image` up-to-date.
|
30
|
+
If you have some reason not to update, you should install
|
31
|
+
`apparmor-profiles` and `apparmor-utils` and
|
32
|
+
consult the Known Issues section in README.md.
|
33
|
+
https://github.com/adrahon/vagrant-kvm/blob/master/README.md#known-issues
|
34
|
+
|
35
|
+
You can use a backported KVM/QEMU 1.4 with Private Package Archive(PPA)
|
36
|
+
for Ubuntu 12.04(LTS) at
|
37
|
+
[launchpad-ppa](https://launchpad.net/~miurahr/+archive/vagrant)
|
38
|
+
|
39
|
+
### Debian/Ubuntu preparation
|
40
|
+
|
41
|
+
Before starting plugin installation, you need to configure your user id.
|
42
|
+
Access to the management layer of libvirt is controlled through membership
|
43
|
+
to the libvirtd unix group.
|
44
|
+
|
45
|
+
To enable libvirt management access for a user, add them to this group:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
$ sudo usermod -G libvirtd -a ~~usrname~~
|
49
|
+
```
|
50
|
+
|
51
|
+
### Fedora/CentOS/RedHat/openSUSE requirements
|
52
|
+
|
53
|
+
- For KVM:
|
54
|
+
* `qemu-kvm` `libvirt` `libvirt-daemon-kvm.x86_64`
|
55
|
+
|
56
|
+
- For NFS:
|
57
|
+
* `nfs-utils`
|
58
|
+
|
59
|
+
- For Networking:
|
60
|
+
* `redir`
|
61
|
+
|
62
|
+
- For `ruby-libvirt` gems installation dependency:
|
63
|
+
* `gcc` `make` `rubygem-rake` `ruby-devel` `libvirt-devel` `libxslt-devel` `libxml2-devel`
|
64
|
+
|
65
|
+
### Fedora preparation
|
66
|
+
|
67
|
+
Home directory permission is too conservative for Vagrant with kvm.
|
68
|
+
Please relax your home directory permissions.
|
69
|
+
|
70
|
+
```bash
|
71
|
+
$ chmod o+x $HOME
|
72
|
+
```
|
73
|
+
|
74
|
+
To start libvirt:
|
75
|
+
|
76
|
+
```bash
|
77
|
+
$ sudo systemctl enable libvirtd
|
78
|
+
$ sudo systemctl start libvirtd
|
79
|
+
$ sudo systemctl enable libvirt-guests
|
80
|
+
$ sudo systemctl start libvirt-guests
|
81
|
+
```
|
82
|
+
|
83
|
+
#### Additional information
|
84
|
+
|
85
|
+
You may need to add SELinux label to vagrant standard storage-pool directory
|
86
|
+
and box directory.
|
87
|
+
|
88
|
+
```bash
|
89
|
+
$ sudo yum install policycoreutils-python
|
90
|
+
$ semanage fcontext -a -t virt_image_t "~/.vagrant.d/tmp/storage-pool(/.*)?"
|
91
|
+
$ restorecon -R ~/.vagrant.d/tmp/storage-pool
|
92
|
+
$ semanage fcontext -a -t virt_image_t "~/.vagrant.d/boxes(/.*)?"
|
93
|
+
$ restorecon -R ~/.vagrant.d/boxes
|
94
|
+
```
|
95
|
+
|
96
|
+
Verify that this worked with
|
97
|
+
```bash
|
98
|
+
$ ls -Z ~/.vagrant.d/tmp/
|
99
|
+
$ ls -Z ~/.vagrant.d/
|
100
|
+
```
|
101
|
+
|
102
|
+
Fedora uses PolicyKit to manage access to libvirt,
|
103
|
+
an additional polkit rules file may be required.
|
104
|
+
Following sample configure that user who is in __virt__ group
|
105
|
+
can access libvirt in user privilege.
|
106
|
+
|
107
|
+
/etc/polkit-1/rules.d/10.virt.rules
|
108
|
+
```
|
109
|
+
polkit.addRule(function(action, subject) {
|
110
|
+
polkit.log("action=" + action);
|
111
|
+
polkit.log("subject=" + subject);
|
112
|
+
var now = new Date();
|
113
|
+
polkit.log("now=" + now)
|
114
|
+
if ((action.id == "org.libvirt.unix.manage" || action.id == "org.libvirt.unix.monitor") && subject.isInGroup("virt")) {
|
115
|
+
return polkit.Result.YES;
|
116
|
+
}
|
117
|
+
return null;
|
118
|
+
});
|
119
|
+
```
|
120
|
+
And Polkit user configuration
|
121
|
+
|
122
|
+
```bash
|
123
|
+
$ sudo groupadd virt
|
124
|
+
$ sudo usermod -a -G virt ~~username~~
|
125
|
+
```
|
126
|
+
|
127
|
+
Then restart polkit service
|
128
|
+
```bash
|
129
|
+
$ systemctl restart polkit.service
|
130
|
+
```
|
131
|
+
|
132
|
+
Alternatively, you can use polkit local authority compatibility configuration
|
133
|
+
|
134
|
+
```bash
|
135
|
+
$ sudo yum install -y polkit-pkla-compat
|
136
|
+
```
|
137
|
+
|
138
|
+
/etc/polkit-1/localauthority/50-vagrant-libvirt-access.pkla:
|
139
|
+
```
|
140
|
+
[libvirt Management Access]
|
141
|
+
Identity=unix-group:virt
|
142
|
+
Action=org.libvirt.unix.manage;org.libvirt.unix.monitor
|
143
|
+
ResultAny=yes
|
144
|
+
ResultInactive=yes
|
145
|
+
ResultActive=yes
|
146
|
+
```
|
147
|
+
|
148
|
+
And Polkit user configuration
|
149
|
+
|
150
|
+
```bash
|
151
|
+
$ sudo groupadd virt
|
152
|
+
$ sudo usermod -a -G virt ~~username~~
|
153
|
+
```
|
154
|
+
|
155
|
+
Then restart polkit service
|
156
|
+
```bash
|
157
|
+
$ systemctl restart polkit.service
|
158
|
+
```
|
159
|
+
|
160
|
+
Consult the polkit section of [libvirt document](http://libvirt.org/auth.html#ACL_server_polkit) for details.
|
161
|
+
Here is also a good [reference blog post](https://niranjanmr.wordpress.com/2013/03/20/auth-libvirt-using-polkit-in-fedora-18/)
|
162
|
+
|
163
|
+
###CentOS6/RedHat6 preparation
|
164
|
+
|
165
|
+
You may need to add SELinux label to vagrant standard storage-pool directory
|
166
|
+
and box directory.
|
167
|
+
|
168
|
+
```bash
|
169
|
+
$ sudo yum install policycoreutils-python
|
170
|
+
$ semanage fcontext -a -t virt_image_t "~/.vagrant.d/tmp/storage-pool(/.*)?"
|
171
|
+
$ restorecon -R ~/.vagrant.d/tmp/storage-pool
|
172
|
+
$ semanage fcontext -a -t virt_image_t "~/.vagrant.d/boxes(/.*)?"
|
173
|
+
$ restorecon -R ~/.vagrant.d/boxes
|
174
|
+
```
|
175
|
+
|
176
|
+
Add polkit configuration file to allow non-root user to access libvirt.
|
177
|
+
|
178
|
+
/etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla:
|
179
|
+
```
|
180
|
+
[libvirt Management Access]
|
181
|
+
Identity=unix-user:username
|
182
|
+
Action=org.libvirt.unix.manage
|
183
|
+
ResultAny=yes
|
184
|
+
ResultInactive=yes
|
185
|
+
ResultActive=yes
|
186
|
+
```
|
187
|
+
|
188
|
+
Restart libvirtd
|
189
|
+
|
190
|
+
```bash
|
191
|
+
$ sudo /etc/init.d/libvirtd restart
|
192
|
+
```
|
193
|
+
|
194
|
+
|
195
|
+
### ArchLinux requirements
|
196
|
+
|
197
|
+
This plugin requires
|
198
|
+
|
199
|
+
- For KVM:
|
200
|
+
* `qemu-kvm`,`libvirt`
|
201
|
+
|
202
|
+
- For NFS:
|
203
|
+
* `nfs-utils`
|
204
|
+
|
205
|
+
- For Networking:
|
206
|
+
* `redir` `bridge-utils` `dnsmasq`
|
207
|
+
|
208
|
+
- For `ruby-libvirt` gems installation dependency:
|
209
|
+
* `libvirt-dev`
|
210
|
+
|
211
|
+
Home directory permission is too conservative for Vagrant with kvm.
|
212
|
+
Please relax your home directory permission.
|
213
|
+
|
214
|
+
```bash
|
215
|
+
$ chmod o+x $HOME
|
216
|
+
```
|
217
|
+
|
218
|
+
To use with Vagrant, you may need to configure libvirt for non-root user to run KVM.
|
219
|
+
Consult [ArchLinux Wiki](https://wiki.archlinux.org/index.php/Libvirt#Configuration)
|
220
|
+
for details.
|
221
|
+
|
222
|
+
|
223
|
+
## Install procedure
|
224
|
+
|
225
|
+
As usual, you can install `vagrant-kvm` using `vagrant plugin install` command.
|
226
|
+
```bash
|
227
|
+
$ vagrant plugin install vagrant-kvm
|
228
|
+
```
|
229
|
+
|
data/LICENSE
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
|
-
Copyright (c) 2013 Alex Drahon
|
2
|
+
Copyright (c) 2013,2014 Alex Drahon
|
3
|
+
Copyright (c) 2013,2014 Hiroshi Miura
|
3
4
|
|
4
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
6
|
|
data/README.md
CHANGED
@@ -1,71 +1,95 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/adrahon/vagrant-kvm.png)](https://travis-ci.org/adrahon/vagrant-kvm)
|
2
|
+
|
1
3
|
# Vagrant KVM Provider
|
2
4
|
|
3
5
|
This is a [Vagrant](http://www.vagrantup.com) 1.1+ plugin that adds a KVM
|
4
6
|
provider to Vagrant, allowing Vagrant to control and provision KVM/QEMU VM.
|
5
7
|
|
6
|
-
|
8
|
+
## Requirements
|
7
9
|
|
8
|
-
|
10
|
+
This plugin requires QEMU 1.1+, it has only been tested on Fedora 18+,
|
9
11
|
Debian Wheezy, Ubuntu 12.04(LTS) Precise and Ubuntu 13.04 Raring at the moment.
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
This plugin requires several library and helper utils packages.
|
14
|
+
Consult the [Requirements section in INSTALL.md](https://github.com/adrahon/vagrant-kvm/blob/master/INSTALL.md)
|
15
|
+
|
16
|
+
## Recent changes
|
17
|
+
|
18
|
+
Default image format is now qcow2 instead of sparsed raw image, with qcow2
|
19
|
+
`vagrant-kvm` uses the box volume as a backing volume so that VM creation is
|
20
|
+
a lot faster. In most cases you want to use qcow2.
|
13
21
|
|
14
|
-
|
15
|
-
for Ubuntu 12.04(LTS) at https://launchpad.net/~miurahr/+archive/vagrant
|
22
|
+
OVF boxes conversion as been removed, you should use `vagrant-mutate` instead.
|
16
23
|
|
17
24
|
## Features/Limitations
|
18
25
|
|
19
26
|
* Provides the same workflow as the Vagrant VirtualBox provider.
|
20
|
-
* Uses VirtualBox boxes almost seamlessly (see below).
|
21
27
|
* Uses NFS for sync folders
|
22
28
|
* Only works with 1 VM per Vagrantfile for now
|
23
|
-
*
|
24
|
-
* Requires "libvirt" group membership to run vagrant (Debian/Ubuntu only)
|
29
|
+
* Requires "libvirtd" group membership to run Vagrant (Debian/Ubuntu only)
|
25
30
|
* Requires backporting qemu and libvirt from experimental (Debian) or raring (Ubuntu)
|
31
|
+
* Use qcow2 backing image by default, which should make VM creation very fast
|
26
32
|
|
27
|
-
##
|
33
|
+
## Known issues
|
28
34
|
|
29
|
-
|
30
|
-
|
31
|
-
|
35
|
+
### Ubuntu
|
36
|
+
Some versions of Ubuntu kernel has a bug that will cause vagrant-kvm
|
37
|
+
to fail with a permission error on `vagrant up`. It is a kernel bug with the AppArmor security framework.
|
38
|
+
As a workaround, please run following command to disable access control for libvirt helper.
|
32
39
|
|
33
|
-
```
|
34
|
-
|
35
|
-
...
|
36
|
-
$ vagrant up --provider=kvm
|
37
|
-
...
|
40
|
+
```bash
|
41
|
+
sudo aa-complain /usr/lib/libvirt/virt-aa-helper
|
38
42
|
```
|
39
43
|
|
40
|
-
|
41
|
-
|
44
|
+
### Fedora and Arch
|
45
|
+
With Fedora and Arch, default home directory permissions are set to `drwx------`.
|
46
|
+
Qemu/kvm runs as 'qemu' user by default and cannot access your home directory.
|
42
47
|
|
43
|
-
|
48
|
+
To avoid this, please check and change your home directory and
|
49
|
+
child directories permission to permit qemu user access to `~/.vagrant.d/tmp/storage-pool/`
|
44
50
|
|
45
|
-
|
46
|
-
|
47
|
-
|
51
|
+
```bash
|
52
|
+
$ chmod go+x /home/<your account>
|
53
|
+
```
|
54
|
+
|
55
|
+
Another option is to run qemu/kvm as the root user by changing the
|
56
|
+
configuration in libvirt.
|
48
57
|
|
58
|
+
/etc/libvirt/qemu.conf
|
49
59
|
```
|
50
|
-
|
51
|
-
|
60
|
+
user = "root"
|
61
|
+
group = "root"
|
52
62
|
```
|
53
63
|
|
54
|
-
|
55
|
-
need to change this to `~/.vagrant.d/boxes/precise32/kvm` and change the
|
56
|
-
provider in `metadata.json`. For example:
|
64
|
+
Then restart libvirtd.
|
57
65
|
|
66
|
+
```bash
|
67
|
+
$ sudo systemctl restart libvirtd
|
58
68
|
```
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
69
|
+
|
70
|
+
This may or may not be sufficient to make it work with Fedora, there are still
|
71
|
+
some issues for some users on Fedora 20.
|
72
|
+
|
73
|
+
## Usage
|
74
|
+
|
75
|
+
Install using the standard Vagrant 1.1+ plugin installation command. After
|
76
|
+
installation, use `vagrant up` and specify the `kvm` provider. An example is
|
77
|
+
shown below.
|
78
|
+
|
79
|
+
```bash
|
80
|
+
$ vagrant plugin install vagrant-kvm
|
81
|
+
$ vagrant up --provider=kvm
|
63
82
|
```
|
64
83
|
|
84
|
+
Of course prior to doing this, you'll need to obtain a KVM-compatible
|
85
|
+
box file for Vagrant. You can convert a VirtualBox base box using
|
86
|
+
`vagrant-mutate` https://github.com/sciurus/vagrant-mutate or see the sample
|
87
|
+
box.
|
88
|
+
|
65
89
|
You will need a private network specifying an IP address in your Vagrantfile,
|
66
90
|
the minimum Vagrantfile would then be:
|
67
91
|
|
68
|
-
```
|
92
|
+
```ruby
|
69
93
|
Vagrant.configure("2") do |config|
|
70
94
|
config.vm.box = "precise32"
|
71
95
|
config.vm.network :private_network, ip: "192.168.192.10"
|
@@ -75,49 +99,116 @@ end
|
|
75
99
|
And then run `vagrant up --provider=kvm`.
|
76
100
|
|
77
101
|
If you always use kvm provider as default, please set it in your .bashrc:
|
78
|
-
|
102
|
+
|
103
|
+
```bash
|
79
104
|
export VAGRANT_DEFAULT_PROVIDER=kvm
|
80
105
|
```
|
81
|
-
then you can simply run `vagrant up`
|
106
|
+
then you can simply run `vagrant up` to use the kvm provider.
|
82
107
|
|
83
|
-
##
|
108
|
+
## Configuration
|
84
109
|
|
85
|
-
|
86
|
-
This folder shows the example contents of a box for the `kvm` provider.
|
110
|
+
There are some provider specific parameter to control VM definition.
|
87
111
|
|
88
|
-
|
112
|
+
* `cpu_model` - cpu architecture: 'i686' or 'x86_64': default is x86_64. Note
|
113
|
+
that your base box should specify this.
|
114
|
+
* `core_number` - number of cpu cores.
|
115
|
+
* `memory_size` - memory size such as 512m, 1GiB, 100000KiB, unit is KiB if
|
116
|
+
unspecified.
|
117
|
+
* `gui` - boolean for starting VM with VNC enabled.
|
118
|
+
* `vnc_port` - The port the VNC server listens to. Default is automatic port
|
119
|
+
assignment.
|
120
|
+
* `vnc_autoport` - if true, KVM will automatically assign a port for VNC
|
121
|
+
to listen to. Defaults to false, but the default vnc_port is -1, which results
|
122
|
+
in this flag being automatically turned on by KVM.
|
123
|
+
* `vnc_password ` - A password used to protect the VNC session.
|
124
|
+
* `image_type` - an image format for vm disk: 'raw' or 'qcow2': default is "qcow2"
|
125
|
+
When choosing 'raw', vagrant-kvm always convert box image into storage-pool,
|
126
|
+
which consumes disk space and is a longer process. Recommendation is 'qcow2'.
|
127
|
+
* `machine_type` - The type of machine to boot. Default is pc-1.2.
|
128
|
+
* `network_model` - The model of the network adapter you want to use. Defaults
|
129
|
+
to virtio. Can be set to `:default` if you want to use the KVM default setting.
|
130
|
+
Possible values include: ne2k_isa i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio.
|
131
|
+
* `video_model` - The model of the video adapter. Default to cirrus. Can also be
|
132
|
+
set to vga.
|
133
|
+
* `image_mode` - Possible value are `clone` or `cow`, defaults to `cow`. If set
|
134
|
+
to `clone`, the image disk will be copied rather than use the original box
|
135
|
+
image. This is slower but allows multiple VMs to be booted at the same time.
|
136
|
+
* `force_pause` - use `pause` for `vagrant suspend` instead of `suspend`.
|
137
|
+
It keeps resource online but execution is stopped.
|
138
|
+
When VM has a device that is not supported `hibernate`, automatically use
|
139
|
+
`pause` regardless of this.
|
89
140
|
|
90
|
-
1. VirtualBox box - you need to change the provider to `kvm` in the
|
91
|
-
`metadata.json` file, the box will be converted on the fly.
|
92
|
-
2. "Native" box - you need a box.xml file (libvirt domain format) and a raw
|
93
|
-
image file (you can convert a .vmdk with qemu-img)
|
94
141
|
|
95
|
-
|
96
|
-
make it sparse.
|
97
|
-
You need ```libguestfs-tools``` package
|
98
|
-
in Debian/Ubuntu/Mint, Fedora15 and after, or CentOS/RHEL6.
|
142
|
+
## Comparison with [Vagrant-libvirt](https://github.com/pradels/vagrant-libvirt)
|
99
143
|
|
100
|
-
|
101
|
-
|
102
|
-
|
144
|
+
Vagrant-kvm is a KVM/Qemu provider for single local host.
|
145
|
+
Vagrant-kvm is simple, local host only, qemu/kvm only provider that is
|
146
|
+
intended as an alternative to VirtualBox while keeping the same workflow.
|
103
147
|
|
104
|
-
|
105
|
-
|
148
|
+
Vagrant-libvirt is a libvirt provider to control machines via the libvirt toolkit.
|
149
|
+
Vagrant-libvirt covers a lot more libvirt options, local and remote hosts and multiple hypervisors,
|
150
|
+
such as Xen, LXC and KVM/qemu.
|
106
151
|
|
107
|
-
|
108
|
-
$ tar cvSzf kvm.box ./metadata.json ./Vagrantfile ./box.xml ./box-disk1.img
|
109
|
-
```
|
152
|
+
In early 2014, Varant-libvirt only support kvm/qemu in local host, there is no big feature difference.
|
110
153
|
|
111
|
-
|
112
|
-
For Gentoo, you can use ```emerge libguestfs```.
|
154
|
+
Here are a few difference:
|
113
155
|
|
114
|
-
|
156
|
+
### 1. Travis CI and quality assurance
|
115
157
|
|
158
|
+
Vagrant-kvm tests every pull request and repository with Travis-CI;
|
159
|
+
https://travis-ci.org/adrahon/vagrant-kvm/
|
160
|
+
Vagrant-libvirt does not.
|
116
161
|
|
117
|
-
|
162
|
+
### 2. Copy-on-write
|
118
163
|
|
119
|
-
|
164
|
+
Vagrant-kvm by default uses the qcow2 format
|
165
|
+
and qcow2 disk image backing to create a new volume
|
166
|
+
from the box disk.
|
167
|
+
This makes creating a new vm very fast, with some performance penalties.
|
168
|
+
You can change this through configuration to clone(copy) disk image to pool instead.
|
169
|
+
This will make new vm creation slower, but give you better disk performance.
|
170
|
+
You can also configure vagrant-kvm to use raw images for an additional
|
171
|
+
performance gain.
|
120
172
|
|
121
|
-
|
122
|
-
|
173
|
+
Vagrant-libvirt use qcow2 as disk image.
|
174
|
+
|
175
|
+
### 3. VNC port/password
|
176
|
+
|
177
|
+
Vagrant-kvm allows you to configure how to connect with VNC, which provides virtual guest desktop.
|
178
|
+
Vagrant-libvirt is not.
|
179
|
+
|
180
|
+
### 4. Synced folder
|
181
|
+
|
182
|
+
Vagrant-kvm can provide synced folder with NFS only.
|
183
|
+
We plan to provide virtfs(p9share) to allow sharing local folders
|
184
|
+
without root privilege.
|
185
|
+
|
186
|
+
Vagrant-libvirt provide synced folder with Rsync and NFS.
|
187
|
+
They also plan to support virtfs in future.
|
188
|
+
|
189
|
+
It is neccesary to fix several bugs in libvirt/qemu to enable
|
190
|
+
virtfs feature in both providers.
|
191
|
+
|
192
|
+
### 5. Snapshots via sahara
|
193
|
+
|
194
|
+
Vagrant-kvm plan to support snapshot via sahara.
|
195
|
+
We have already proposed to sahara project to add support
|
196
|
+
and are waiting for review.
|
197
|
+
https://github.com/jedi4ever/sahara/pull/32
|
198
|
+
|
199
|
+
Vagrant-libvirt is supported by sahara.
|
200
|
+
|
201
|
+
### 6. Use boxes from other Vagrant providers via vagrant-mutate
|
202
|
+
|
203
|
+
Both are supported by vagrant-mutate as convert target
|
204
|
+
|
205
|
+
### 7. Architecture
|
206
|
+
|
207
|
+
Vagrant-kvm control kvm/qemu via ruby-libvirt, libvirt and qemu.
|
208
|
+
|
209
|
+
Vagrant-libvirt control machines via fog,
|
210
|
+
a cloud abstraction library in ruby,
|
211
|
+
that is also used by vagrant-aws.
|
212
|
+
A fog library control virtual machines on supported platforms and provide
|
213
|
+
control of qemu/kvm machines through ruby-libvirt and libvirt.
|
123
214
|
|