vagrant-kvm 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/CHANGELOG.md +0 -7
- data/DEVELOPMENT.md +69 -0
- data/INSTALL.md +1 -1
- data/README.md +61 -47
- data/bin/package.sh +83 -0
- data/install.rb +7 -0
- data/lib/vagrant-kvm/action.rb +23 -31
- data/lib/vagrant-kvm/action/customize.rb +44 -0
- data/lib/vagrant-kvm/action/import.rb +52 -23
- data/lib/vagrant-kvm/action/init_storage_pool.rb +5 -4
- data/lib/vagrant-kvm/action/network.rb +127 -30
- data/lib/vagrant-kvm/action/{prepare_gui.rb → prepare_kvmconfig.rb} +4 -1
- data/lib/vagrant-kvm/action/prepare_nfs_settings.rb +16 -23
- data/lib/vagrant-kvm/action/set_name.rb +27 -3
- data/lib/vagrant-kvm/action/share_folders.rb +4 -5
- data/lib/vagrant-kvm/cap/mount_p9.rb +40 -0
- data/lib/vagrant-kvm/config.rb +73 -1
- data/lib/vagrant-kvm/driver/driver.rb +303 -117
- data/lib/vagrant-kvm/errors.rb +4 -4
- data/lib/vagrant-kvm/plugin.rb +12 -2
- data/lib/vagrant-kvm/provider.rb +2 -19
- data/lib/vagrant-kvm/synced_folder.rb +57 -0
- data/lib/vagrant-kvm/util/network_definition.rb +30 -3
- data/lib/vagrant-kvm/util/vm_definition.rb +110 -11
- data/lib/vagrant-kvm/version.rb +1 -1
- data/locales/en.yml +5 -3
- data/locales/ja.yml +11 -4
- data/spec/vagrant-kvm/config_spec.rb +6 -0
- data/spec/vagrant-kvm/driver/driver_spec.rb +4 -3
- data/spec/vagrant-kvm/util/vm_definition_spec.rb +4 -8
- data/templates/libvirt_domain.erb +29 -3
- data/vagrant-kvm.gemspec +3 -3
- metadata +21 -9
- data/lib/vagrant-kvm/action/prune_nfs_exports.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79770b8d1889daab867e796d16fe319c0c0eca24
|
4
|
+
data.tar.gz: db7ef74f5ec15c7fa3c931a4a54723bc890742b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72729349c6a2aa2c1b529cbb49c4c1ffcf89e6533eacb5e668e539ac8c974d35b22c2cba0ee1916f2b7bee57e2b93efd57757c04f4aaf7e5f77e64ec7bd86d5b
|
7
|
+
data.tar.gz: fbec7423931ee5a19a2d09501eb1c7cd42b1bf50f3ceabfbd7049c40b2f1dd0aa45c771018e894b181a44fe4668cea0a16cc4a83c294c83825dd0ee0e7e81011
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
# 0.1.6 (April, ?, 2014)
|
2
|
-
|
3
|
-
* Support Vagrant 1.5.x[GH-188][GH-187][GH-186][GH-174]
|
4
|
-
* Handle Vagrant 1.5 migration with box folder structure change
|
5
|
-
* Document vagrant-1.4 to 1.5 migration [GH-189]
|
6
|
-
* Fix spec test error
|
7
|
-
|
8
1
|
# 0.1.5 (March 22, 2014)
|
9
2
|
|
10
3
|
* Change default box format to qcow2 [GH-63]
|
data/DEVELOPMENT.md
CHANGED
@@ -59,6 +59,13 @@ There are two `Vagrantfile` to help developers.
|
|
59
59
|
- `spec/fedora/Vagrantfile` make an alternative environment on Fedora guest.
|
60
60
|
|
61
61
|
|
62
|
+
## Tests
|
63
|
+
|
64
|
+
We use Rspec and Travis-CI for continous integration and unit test.
|
65
|
+
|
66
|
+
Tests are located in `spec` directory.
|
67
|
+
Every PR should be tested and passes Travis-CI test before merging.
|
68
|
+
|
62
69
|
## Specs
|
63
70
|
|
64
71
|
To run specs, you first need to add and prepare the Vagrant box which will be used.
|
@@ -80,6 +87,68 @@ When you're done, feel free to remove the box.
|
|
80
87
|
$ bundle exec rake box:remove
|
81
88
|
```
|
82
89
|
|
90
|
+
## Milestones and versions
|
91
|
+
|
92
|
+
### Milestones
|
93
|
+
We set milestones for future releases. Vagrant-KVM is under active development and still in development status. The next several milestones are targeted to implement new features such as support of new vagrant versions, multi-vm support, virtfs support, and so on.
|
94
|
+
|
95
|
+
### Versions
|
96
|
+
|
97
|
+
We use (major).(minor).(patchlevel) versioning.
|
98
|
+
In development status, major version is 0.
|
99
|
+
When Implementing major features, we increment minor version such as 0.2.0.
|
100
|
+
|
101
|
+
When it reaches beta status, it may be 0.9.x.
|
102
|
+
|
103
|
+
When it reaches production status, it become 1.0.0.
|
104
|
+
|
105
|
+
Before 0.9.x, APIs, configuration parameters and other behaviors will be changed without caution or migration pass.
|
106
|
+
|
107
|
+
## Branches
|
108
|
+
|
109
|
+
We basically use `master` branch for development in 0.x series.
|
110
|
+
It is an exception when we need to release interim release to previous version that includes only single or some fixes. When necessary we make `-maint` branch such as `v0.1.5-maint`.
|
111
|
+
It becomes next release and planed version is incremented.
|
112
|
+
|
113
|
+
Here is an example.
|
114
|
+
|
115
|
+
We have released v0.1.5 in March, 2014. We started development for v0.1.6 to add more feature and merged several changes just after releasing v0.1.5. We found v0.1.5 is not working with Vagrant 1.5 that is released in March, 2014. Because it is not welcome to wait to a normal v0.1.6 release for Vagrant 1.5 support, we decided to release interim fix release as v0.1.6.
|
116
|
+
We start release branch 'v0.1.5-maint' for v0.1.6 release.
|
117
|
+
The release number of new features on `master` is changed to v0.1.7 not v0.1.6.
|
118
|
+
|
119
|
+
|
120
|
+
### How To Contribute
|
121
|
+
|
122
|
+
* Clone: git clone git://github.com/adrahon/vagrant-kvm.git
|
123
|
+
|
124
|
+
* Get Setup
|
125
|
+
|
126
|
+
* Create a topic branch: git checkout -b awesome_feature
|
127
|
+
|
128
|
+
* Hack and Commit away.
|
129
|
+
|
130
|
+
* Keep up to date: git fetch && git rebase origin/master
|
131
|
+
|
132
|
+
* Test with Rspec
|
133
|
+
|
134
|
+
Once you’re ready:
|
135
|
+
|
136
|
+
* Fork the project on GitHub
|
137
|
+
|
138
|
+
* Add your repository as a remote: git remote add your_remote your_repo
|
139
|
+
|
140
|
+
* (Optional) setup Travis-CI for your repository
|
141
|
+
|
142
|
+
* Push up your branch: git push your_remote awesome_feature
|
143
|
+
|
144
|
+
* (Optional) check your Travis score whether passed
|
145
|
+
|
146
|
+
* Create a Pull Request for the topic branch, asking for review.
|
147
|
+
|
148
|
+
* Check your PR is passed on Travis
|
149
|
+
|
150
|
+
* If not, fix your commit and push to your repository: git push your_remote awesome_feature
|
151
|
+
|
83
152
|
## Travis-CI
|
84
153
|
|
85
154
|
TBD
|
data/INSTALL.md
CHANGED
@@ -89,7 +89,7 @@ and box directory.
|
|
89
89
|
$ sudo yum install policycoreutils-python
|
90
90
|
$ semanage fcontext -a -t virt_image_t "~/.vagrant.d/tmp/storage-pool(/.*)?"
|
91
91
|
$ restorecon -R ~/.vagrant.d/tmp/storage-pool
|
92
|
-
$ semanage fcontext -a -t
|
92
|
+
$ semanage fcontext -a -t virt_context_t "~/.vagrant.d/boxes(/.*)?"
|
93
93
|
$ restorecon -R ~/.vagrant.d/boxes
|
94
94
|
```
|
95
95
|
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Vagrant KVM Provider
|
4
4
|
|
5
|
-
This is a [Vagrant](http://www.vagrantup.com) 1.
|
5
|
+
This is a [Vagrant](http://www.vagrantup.com) 1.4+ plugin that adds a KVM
|
6
6
|
provider to Vagrant, allowing Vagrant to control and provision KVM/QEMU VM.
|
7
7
|
|
8
8
|
## Requirements
|
@@ -19,15 +19,22 @@ Default image format is now qcow2 instead of sparsed raw image, with qcow2
|
|
19
19
|
`vagrant-kvm` uses the box volume as a backing volume so that VM creation is
|
20
20
|
a lot faster. In most cases you want to use qcow2.
|
21
21
|
|
22
|
-
OVF boxes conversion
|
22
|
+
OVF boxes conversion has been removed, you should use `vagrant-mutate` instead.
|
23
|
+
|
24
|
+
Synced folders are now provided by a QEMU/KVM Virtfs in default.
|
25
|
+
You can also use NFS for file share using `type: "nfs"` option.
|
26
|
+
|
27
|
+
There was a known libvirt bug in Ubuntu host:
|
28
|
+
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/943680
|
29
|
+
It was solved in Ubuntu 14.04(Trusty) and a backported libvirt provided by PPA above.
|
23
30
|
|
24
31
|
## Features/Limitations
|
25
32
|
|
26
33
|
* Provides the same workflow as the Vagrant VirtualBox provider.
|
27
|
-
* Uses
|
34
|
+
* Uses Virtfs for sync folders
|
28
35
|
* Only works with 1 VM per Vagrantfile for now
|
29
36
|
* Requires "libvirtd" group membership to run Vagrant (Debian/Ubuntu only)
|
30
|
-
* Requires backporting qemu and libvirt from experimental (Debian) or
|
37
|
+
* Requires backporting qemu and libvirt from experimental (Debian) or trusty (Ubuntu)
|
31
38
|
* Use qcow2 backing image by default, which should make VM creation very fast
|
32
39
|
|
33
40
|
## Known issues
|
@@ -38,62 +45,60 @@ Vagrant 1.5 changes a structure of user boxes directories.
|
|
38
45
|
vagrant-KVM handle box directory as libvirt/qemu temporary spool,
|
39
46
|
but Vagrant 1.5 changes it at first time launched.
|
40
47
|
|
41
|
-
|
42
|
-
|
43
|
-
please follow the instructions bellow.
|
48
|
+
Unfortunately vagrant-KVM 0.1.5 does not run on Vagrant-1.5.x.
|
49
|
+
Users who interested in vagrant-kvm 0.1.5 may use with Vagrant 1.4.x.
|
44
50
|
|
45
|
-
|
51
|
+
This caused problem when following sinario:
|
46
52
|
|
47
|
-
|
53
|
+
1. user use vagrant-kvm 0.1.5 with vagrant-1.4.x
|
54
|
+
2. user upgrade vagrant 1.5.x
|
55
|
+
3. user upgrade vagrant 0.1.5.1 and after
|
48
56
|
|
49
|
-
|
57
|
+
We use transient pool instead of persistent one
|
58
|
+
in vagrant-kvm 0.1.5.x, 0.1.6 and after
|
59
|
+
Pools defined by vagrant-kvm will be removed after system reboot.
|
60
|
+
|
61
|
+
We recommend to use following combinations.
|
62
|
+
|
63
|
+
- Vagrant 1.3.x or before, and Vagrant-KVM 0.1.4
|
64
|
+
|
65
|
+
- Vagrant 1.5.x or after, and Vagrant-KVM 0.1.5.1 or after
|
66
|
+
|
67
|
+
If you are joining test for vagrant-kvm or other reasons you use vagrant-kvm 0.1.5 with vagrant 1.4.x,
|
68
|
+
you got `Call to virStoragePoolCreate failed: cannot open path` error, please follow the instructions below.
|
69
|
+
Please take care when running commands as root.
|
50
70
|
|
51
|
-
|
71
|
+
1. Upgrade vagrant-kvm to vagrant-kvm 0.1.5.1 or after
|
72
|
+
|
73
|
+
2. Clear all storage definitions.
|
52
74
|
|
53
75
|
```bash
|
54
|
-
$ sudo
|
55
|
-
|
56
|
-
/etc/libvirt/storage/
|
57
|
-
/etc/libvirt/storage/vagrant_1000_centos-6.5-20140316.xml
|
58
|
-
/etc/libvirt/storage/vagrant_1000_centos-6.5-20140324.xml
|
59
|
-
/etc/libvirt/storage/vagrant_1000_vagrant-kvm.xml
|
60
|
-
/etc/libvirt/storage/vagrant.xml
|
61
|
-
# rm -i /etc/libvirt/storage/vagrant*
|
62
|
-
rm: remove regular file ‘/etc/libvirt/storage/vagrant_1000_archlinux-x86_64-20140325.xml’? y
|
63
|
-
rm: remove regular file ‘/etc/libvirt/storage/vagrant_1000_centos-6.5-20140316.xml’? y
|
64
|
-
rm: remove regular file ‘/etc/libvirt/storage/vagrant_1000_centos-6.5-20140324.xml’? y
|
65
|
-
rm: remove regular file ‘/etc/libvirt/storage/vagrant_1000_vagrant-kvm.xml’? y
|
66
|
-
rm: remove regular file ‘/etc/libvirt/storage/vagrant.xml’? y
|
67
|
-
# ls /etc/libvirt/storage/vagrant*
|
68
|
-
ls: cannot access /etc/libvirt/storage/vagrant*: No such file or directory
|
69
|
-
# exit
|
76
|
+
$ sudo ls /etc/libvirt/storage/vagrant*
|
77
|
+
$ sudo rm /etc/libvirt/storage/vagrant*
|
78
|
+
$ sudo ls /etc/libvirt/storage/vagrant*
|
70
79
|
```
|
71
80
|
|
72
81
|
alternative way:
|
73
82
|
|
74
83
|
* open virt-manager
|
75
84
|
* connect to localhost
|
76
|
-
* right click
|
85
|
+
* right click and open details
|
77
86
|
* click storage tab
|
78
|
-
* right click
|
87
|
+
* right click 'vagrant*' storage pool and delete it.
|
79
88
|
|
80
|
-
|
89
|
+
3. restart libvirt daemon
|
81
90
|
|
82
91
|
Ubuntu/Debian
|
83
92
|
```bash
|
84
93
|
$ sudo service libvirt-bin restart
|
85
94
|
```
|
86
95
|
|
87
|
-
Fedora/CentOS/SuSE/Arch
|
88
|
-
```bash
|
89
|
-
$ sudo service libvirtd restart
|
90
|
-
```
|
91
|
-
|
92
|
-
Fedora/CentOS/SuSE/Arch recent versions
|
96
|
+
Fedora/CentOS/SuSE/Arch
|
93
97
|
```bash
|
94
98
|
$ sudo systemctl restart libvirtd
|
95
99
|
```
|
96
100
|
|
101
|
+
|
97
102
|
### Ubuntu
|
98
103
|
Some versions of Ubuntu kernel has a bug that will cause vagrant-kvm
|
99
104
|
to fail with a permission error on `vagrant up`. It is a kernel bug with the AppArmor security framework.
|
@@ -129,8 +134,8 @@ Then restart libvirtd.
|
|
129
134
|
$ sudo systemctl restart libvirtd
|
130
135
|
```
|
131
136
|
|
132
|
-
|
133
|
-
|
137
|
+
Another option is to specify an existing local storage pool with the
|
138
|
+
`storage-pool` option for the KVM provider in your Vagrantfile (see below).
|
134
139
|
|
135
140
|
## Usage
|
136
141
|
|
@@ -171,11 +176,13 @@ then you can simply run `vagrant up` to use the kvm provider.
|
|
171
176
|
|
172
177
|
There are some provider specific parameter to control VM definition.
|
173
178
|
|
174
|
-
* `cpu_model` - cpu architecture: 'i686' or '
|
179
|
+
* `cpu_model` - cpu architecture: 'i686' or 'x86\_64': default is x86\_64. Note
|
175
180
|
that your base box should specify this.
|
176
181
|
* `core_number` - number of cpu cores.
|
177
182
|
* `memory_size` - memory size such as 512m, 1GiB, 100000KiB, unit is KiB if
|
178
183
|
unspecified.
|
184
|
+
* `storage_pool` - specify an existing local storage pool to use instead of
|
185
|
+
vagrant's own.
|
179
186
|
* `gui` - boolean for starting VM with VNC enabled.
|
180
187
|
* `vnc_port` - The port the VNC server listens to. Default is automatic port
|
181
188
|
assignment.
|
@@ -189,16 +196,23 @@ in this flag being automatically turned on by KVM.
|
|
189
196
|
* `machine_type` - The type of machine to boot. Default is pc-1.2.
|
190
197
|
* `network_model` - The model of the network adapter you want to use. Defaults
|
191
198
|
to virtio. Can be set to `:default` if you want to use the KVM default setting.
|
192
|
-
Possible values include:
|
199
|
+
Possible values include: ne2k\_isa i82551 i82557b i82559er ne2k\_pci pcnet rtl8139 e1000 virtio.
|
193
200
|
* `video_model` - The model of the video adapter. Default to cirrus. Can also be
|
194
201
|
set to vga.
|
195
202
|
* `image_mode` - Possible value are `clone` or `cow`, defaults to `cow`. If set
|
196
203
|
to `clone`, the image disk will be copied rather than use the original box
|
197
204
|
image. This is slower but allows multiple VMs to be booted at the same time.
|
205
|
+
* `customize` - Customize virtual machine with virsh command. Similar functionality with virtualbox provider.
|
206
|
+
* `disk_bus` - disk interface to show virtual disk to guest: 'virtio' or 'sata', 'scsi'
|
207
|
+
A box, which is 'mutate'-ed from virtualbox/vmware box, may specify sata/ide for disk bus.
|
208
|
+
It may be useful to specify 'virtio' for performance, even when box defaults disk bus as sata/ide/scsi.
|
209
|
+
* `seclabel` - enables security labelling using selinux, apparmor, dac... based on the host distribution if set to `on`
|
198
210
|
* `force_pause` - use `pause` for `vagrant suspend` instead of `suspend`.
|
199
211
|
It keeps resource online but execution is stopped.
|
200
212
|
When VM has a device that is not supported `hibernate`, automatically use
|
201
213
|
`pause` regardless of this.
|
214
|
+
* `virtio_rng` - boolean for optional virtio device of random number generator.
|
215
|
+
QEMU 1.3.0 and after support this device. default `false`
|
202
216
|
|
203
217
|
|
204
218
|
## Comparison with [Vagrant-libvirt](https://github.com/pradels/vagrant-libvirt)
|
@@ -211,7 +225,7 @@ Vagrant-libvirt is a libvirt provider to control machines via the libvirt toolki
|
|
211
225
|
Vagrant-libvirt covers a lot more libvirt options, local and remote hosts and multiple hypervisors,
|
212
226
|
such as Xen, LXC and KVM/qemu.
|
213
227
|
|
214
|
-
In early 2014,
|
228
|
+
In early 2014, Vagrant-libvirt only supports kvm/qemu in local host, there is no big feature difference.
|
215
229
|
|
216
230
|
Here are a few difference:
|
217
231
|
|
@@ -237,7 +251,7 @@ Vagrant-libvirt use qcow2 as disk image.
|
|
237
251
|
### 3. VNC port/password
|
238
252
|
|
239
253
|
Vagrant-kvm allows you to configure how to connect with VNC, which provides virtual guest desktop.
|
240
|
-
Vagrant-libvirt
|
254
|
+
Vagrant-libvirt does not.
|
241
255
|
|
242
256
|
### 4. Synced folder
|
243
257
|
|
@@ -248,12 +262,12 @@ without root privilege.
|
|
248
262
|
Vagrant-libvirt provide synced folder with Rsync and NFS.
|
249
263
|
They also plan to support virtfs in future.
|
250
264
|
|
251
|
-
It is neccesary to fix several bugs in libvirt/qemu to enable
|
265
|
+
It is neccesary to fix several bugs in libvirt/qemu to enable the
|
252
266
|
virtfs feature in both providers.
|
253
267
|
|
254
268
|
### 5. Snapshots via sahara
|
255
269
|
|
256
|
-
Vagrant-kvm
|
270
|
+
Vagrant-kvm plans to support snapshot via sahara.
|
257
271
|
We have already proposed to sahara project to add support
|
258
272
|
and are waiting for review.
|
259
273
|
https://github.com/jedi4ever/sahara/pull/32
|
@@ -266,11 +280,11 @@ Both are supported by vagrant-mutate as convert target
|
|
266
280
|
|
267
281
|
### 7. Architecture
|
268
282
|
|
269
|
-
Vagrant-kvm
|
283
|
+
Vagrant-kvm controls kvm/qemu via ruby-libvirt, libvirt and qemu.
|
270
284
|
|
271
|
-
Vagrant-libvirt
|
285
|
+
Vagrant-libvirt controls machines via fog,
|
272
286
|
a cloud abstraction library in ruby,
|
273
287
|
that is also used by vagrant-aws.
|
274
|
-
|
288
|
+
The fog library controls virtual machines on supported platforms and provides
|
275
289
|
control of qemu/kvm machines through ruby-libvirt and libvirt.
|
276
290
|
|
data/bin/package.sh
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
error() {
|
4
|
+
local msg="${1}"
|
5
|
+
echo "${msg}"
|
6
|
+
exit 1
|
7
|
+
}
|
8
|
+
|
9
|
+
usage() {
|
10
|
+
echo "Usage: ${0} NAME IMAGE"
|
11
|
+
echo
|
12
|
+
echo "Package a kvm qcow2 image into a kvm vagrant reusable box"
|
13
|
+
echo "It uses virt-install to do so"
|
14
|
+
}
|
15
|
+
|
16
|
+
if [ -z "$2" ]; then
|
17
|
+
usage
|
18
|
+
exit 1
|
19
|
+
fi
|
20
|
+
|
21
|
+
# defaults for virtual server
|
22
|
+
NAME="$1"
|
23
|
+
RAM=2048
|
24
|
+
VCPUS=2
|
25
|
+
|
26
|
+
IMG=$(readlink -e $2)
|
27
|
+
IMG_BASENAME=$(basename $IMG)
|
28
|
+
IMG_DIR=$(dirname $IMG)
|
29
|
+
|
30
|
+
# Create stuff in tmp dir
|
31
|
+
TMP_DIR=$IMG_DIR/_tmp_package
|
32
|
+
mkdir -p $TMP_DIR
|
33
|
+
|
34
|
+
# We move the image to the tempdir
|
35
|
+
# ensure that it's moved back again
|
36
|
+
# and the tmp dir removed
|
37
|
+
trap "mv $TMP_DIR/$IMG_BASENAME $IMG_DIR; rm -rf $TMP_DIR" EXIT
|
38
|
+
|
39
|
+
mv $IMG $TMP_DIR
|
40
|
+
IMG=$TMP_DIR/$IMG_BASENAME
|
41
|
+
|
42
|
+
cd $TMP_DIR
|
43
|
+
|
44
|
+
# generate box.xml
|
45
|
+
|
46
|
+
virt-install \
|
47
|
+
--print-xml \
|
48
|
+
--dry-run \
|
49
|
+
--import \
|
50
|
+
--name $NAME \
|
51
|
+
--ram $RAM --vcpus=$VCPUS \
|
52
|
+
--disk path="$IMG",bus=virtio,format=qcow2 \
|
53
|
+
-w network=default,model=virtio > box.xml
|
54
|
+
|
55
|
+
# extract the mac for the Vagrantfile
|
56
|
+
MAC=$(cat box.xml | grep 'mac address' | cut -d\' -f2 | tr -d :)
|
57
|
+
IMG_ABS_PATH=$(cat box.xml | grep 'source file' | cut -d\' -f2)
|
58
|
+
|
59
|
+
# replace the absolute image path
|
60
|
+
sed -i "s#$IMG_ABS_PATH#$IMG_BASENAME#" box.xml
|
61
|
+
|
62
|
+
# Hmm. When not starting the vm (--print-xml) the memory attribute in
|
63
|
+
# the XML is missing the unit, which causes an exception in vagrant-kvm
|
64
|
+
|
65
|
+
# add the memory unit
|
66
|
+
sed -i "s/<memory>/<memory unit='KiB'>/" box.xml
|
67
|
+
|
68
|
+
cat > metadata.json <<EOF
|
69
|
+
{
|
70
|
+
"provider": "kvm"
|
71
|
+
}
|
72
|
+
EOF
|
73
|
+
|
74
|
+
cat > Vagrantfile <<EOF
|
75
|
+
Vagrant.configure("2") do |config|
|
76
|
+
config.vm.base_mac = "$MAC"
|
77
|
+
end
|
78
|
+
EOF
|
79
|
+
|
80
|
+
tar cvzf $NAME.box --totals ./metadata.json ./Vagrantfile ./box.xml ./$IMG_BASENAME
|
81
|
+
mv $NAME.box $IMG_DIR
|
82
|
+
|
83
|
+
echo "$IMG_DIR/$NAME.box created"
|
data/install.rb
ADDED
data/lib/vagrant-kvm/action.rb
CHANGED
@@ -13,28 +13,21 @@ module VagrantPlugins
|
|
13
13
|
# a bootup (i.e. not saved).
|
14
14
|
def self.action_boot
|
15
15
|
Vagrant::Action::Builder.new.tap do |b|
|
16
|
-
b.use Network
|
17
16
|
b.use Provision
|
18
17
|
b.use Vagrant::Action::Builtin::HandleForwardedPortCollisions
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
else
|
24
|
-
#FIXME
|
25
|
-
b.use PrepareNFSValidIds
|
26
|
-
b.use SyncedFolderCleanup
|
27
|
-
b.use SyncedFolders
|
28
|
-
b.use PrepareNFSSettings
|
29
|
-
end
|
18
|
+
b.use PrepareNFSValidIds
|
19
|
+
b.use SyncedFolderCleanup
|
20
|
+
b.use SyncedFolders
|
21
|
+
b.use PrepareNFSSettings
|
30
22
|
b.use SetHostname
|
31
|
-
|
23
|
+
b.use Customize, "pre-boot"
|
32
24
|
b.use ForwardPorts
|
33
25
|
b.use Boot
|
34
26
|
if Vagrant::VERSION >= "1.3.0"
|
35
27
|
b.use WaitForCommunicator, [:running]
|
36
28
|
end
|
37
29
|
b.use ShareFolders
|
30
|
+
b.use Customize, "post-boot"
|
38
31
|
end
|
39
32
|
end
|
40
33
|
|
@@ -54,13 +47,11 @@ module VagrantPlugins
|
|
54
47
|
b3.use ConfigValidate
|
55
48
|
b3.use EnvSet, :force_halt => true
|
56
49
|
b3.use action_halt
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
b3.use SyncedFolderCleanup
|
63
|
-
end
|
50
|
+
b3.use PrepareNFSSettings
|
51
|
+
b3.use PrepareNFSValidIds
|
52
|
+
b3.use SyncedFolderCleanup
|
53
|
+
b3.use PrepareNFSSettings
|
54
|
+
b3.use InitStoragePool
|
64
55
|
b3.use Destroy
|
65
56
|
else
|
66
57
|
b3.use MessageWillNotDestroy
|
@@ -108,13 +99,10 @@ module VagrantPlugins
|
|
108
99
|
|
109
100
|
b2.use SetupPackageFiles
|
110
101
|
b2.use action_halt
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
b2.use PrepareNFSValidIds
|
116
|
-
b2.use SyncedFolderCleanup
|
117
|
-
end
|
102
|
+
b2.use PrepareNFSSettings
|
103
|
+
b2.use PrepareNFSValidIds
|
104
|
+
b2.use SyncedFolderCleanup
|
105
|
+
b2.use PrepareNFSSettings
|
118
106
|
b2.use Export
|
119
107
|
b2.use PackageVagrantfile
|
120
108
|
b2.use Package
|
@@ -226,7 +214,7 @@ module VagrantPlugins
|
|
226
214
|
|
227
215
|
# The VM is not saved, so we must have to boot it up
|
228
216
|
# like normal. Boot!
|
229
|
-
b4.use
|
217
|
+
b4.use PrepareKvmConfig
|
230
218
|
b4.use action_boot
|
231
219
|
end
|
232
220
|
end
|
@@ -254,7 +242,6 @@ module VagrantPlugins
|
|
254
242
|
def self.action_up
|
255
243
|
Vagrant::Action::Builder.new.tap do |b|
|
256
244
|
b.use CheckKvm
|
257
|
-
b.use SetName
|
258
245
|
b.use ConfigValidate
|
259
246
|
b.use InitStoragePool
|
260
247
|
b.use Call, Created do |env, b2|
|
@@ -266,8 +253,13 @@ module VagrantPlugins
|
|
266
253
|
b2.use HandleBox
|
267
254
|
end
|
268
255
|
b2.use SetName
|
256
|
+
b2.use Customize, "pre-import"
|
257
|
+
# we need to init storage again after driver is reloaded
|
258
|
+
# XXX there must be a better way
|
259
|
+
b2.use InitStoragePool
|
269
260
|
b2.use Import
|
270
261
|
b2.use MatchMACAddress
|
262
|
+
b2.use Network
|
271
263
|
end
|
272
264
|
end
|
273
265
|
b.use action_start
|
@@ -282,6 +274,7 @@ module VagrantPlugins
|
|
282
274
|
autoload :CheckKvm, action_root.join("check_kvm")
|
283
275
|
autoload :CheckRunning, action_root.join("check_running")
|
284
276
|
autoload :ClearForwardedPorts, action_root.join("clear_forwarded_ports")
|
277
|
+
autoload :Customize, action_root.join("customize")
|
285
278
|
autoload :Created, action_root.join("created")
|
286
279
|
autoload :Destroy, action_root.join("destroy")
|
287
280
|
autoload :DestroyConfirm, action_root.join("destroy_confirm")
|
@@ -300,10 +293,9 @@ module VagrantPlugins
|
|
300
293
|
autoload :Network, action_root.join("network")
|
301
294
|
autoload :PackageVagrantfile, action_root.join("package_vagrantfile")
|
302
295
|
autoload :Package, action_root.join("package")
|
303
|
-
autoload :
|
296
|
+
autoload :PrepareKvmConfig, action_root.join("prepare_kvmconfig")
|
304
297
|
autoload :PrepareNFSSettings, action_root.join("prepare_nfs_settings")
|
305
298
|
autoload :PrepareNFSValidIds, action_root.join("prepare_nfs_valid_ids")
|
306
|
-
autoload :PruneNFSExports, action_root.join("prune_nfs_exports")
|
307
299
|
autoload :ResetImagePermission, action_root.join("reset_image_permission")
|
308
300
|
autoload :Resume, action_root.join("resume")
|
309
301
|
autoload :ResumeNetwork, action_root.join("resume_network")
|