vagrant-kvm 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +62 -0
- data/lib/vagrant-kvm/action.rb +5 -1
- data/lib/vagrant-kvm/action/check_kvm.rb +1 -1
- data/lib/vagrant-kvm/action/import.rb +30 -0
- data/lib/vagrant-kvm/driver/driver.rb +103 -45
- data/lib/vagrant-kvm/version.rb +1 -1
- data/locales/en.yml +2 -0
- data/spec/test_files/box-disk1.img +0 -0
- data/spec/test_files/box.xml +10 -22
- data/spec/vagrant-kvm/config_spec.rb +25 -0
- data/spec/vagrant-kvm/driver/driver_spec.rb +39 -11
- data/spec/vagrant-kvm/util/vm_definition_spec.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9a60c53d1481a84c960b7f3abef307b431ceadb
|
4
|
+
data.tar.gz: 51c04fe1ec462079d8d7711d101544227a418c14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40ce772d899d500bebfbc56f639936a1028c1c7e5bf22f5fc481734e95920702cf14498da92bbc2846933ad8e33e72d63678803c0a4f83f33d433cef9af368d8
|
7
|
+
data.tar.gz: 4ca877c4945e9e8fc67a1c28259c805afbfbf349ed06338ead92855039a069997176d1739770b9ac0b797402f3591444bf9ce6d5f34630a7a0c29ffa7a95be9b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
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
|
+
|
1
8
|
# 0.1.5 (March 22, 2014)
|
2
9
|
|
3
10
|
* Change default box format to qcow2 [GH-63]
|
data/README.md
CHANGED
@@ -32,6 +32,68 @@ OVF boxes conversion as been removed, you should use `vagrant-mutate` instead.
|
|
32
32
|
|
33
33
|
## Known issues
|
34
34
|
|
35
|
+
### Vagrant 1.5 migration
|
36
|
+
|
37
|
+
Vagrant 1.5 changes a structure of user boxes directories.
|
38
|
+
vagrant-KVM handle box directory as libvirt/qemu temporary spool,
|
39
|
+
but Vagrant 1.5 changes it at first time launched.
|
40
|
+
|
41
|
+
If you got `Call to virStoragePoolCreate failed: cannot open path` error, or
|
42
|
+
`Your vagrant-kvm environment should be fixed. see README`,
|
43
|
+
please follow the instructions bellow.
|
44
|
+
|
45
|
+
1. Upgrade vagrant-kvm to vagrant-kvm 0.1.6 or after
|
46
|
+
|
47
|
+
2. Clear all vagrant storage pool definitions
|
48
|
+
|
49
|
+
3. restart libvirt daemon
|
50
|
+
|
51
|
+
#### how to clear storage pool
|
52
|
+
|
53
|
+
```bash
|
54
|
+
$ sudo -i
|
55
|
+
# ls /etc/libvirt/storage/vagrant*
|
56
|
+
/etc/libvirt/storage/vagrant_1000_archlinux-x86_64-20140325.xml
|
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
|
70
|
+
```
|
71
|
+
|
72
|
+
alternative way:
|
73
|
+
|
74
|
+
* open virt-manager
|
75
|
+
* connect to localhost
|
76
|
+
* right click connection and open details
|
77
|
+
* click storage tab
|
78
|
+
* right click each 'vagrant*' storage pool and delete it.
|
79
|
+
|
80
|
+
#### how to restart libvirt daemon
|
81
|
+
|
82
|
+
Ubuntu/Debian
|
83
|
+
```bash
|
84
|
+
$ sudo service libvirt-bin restart
|
85
|
+
```
|
86
|
+
|
87
|
+
Fedora/CentOS/SuSE/Arch previous versions
|
88
|
+
```bash
|
89
|
+
$ sudo service libvirtd restart
|
90
|
+
```
|
91
|
+
|
92
|
+
Fedora/CentOS/SuSE/Arch recent versions
|
93
|
+
```bash
|
94
|
+
$ sudo systemctl restart libvirtd
|
95
|
+
```
|
96
|
+
|
35
97
|
### Ubuntu
|
36
98
|
Some versions of Ubuntu kernel has a bug that will cause vagrant-kvm
|
37
99
|
to fail with a permission error on `vagrant up`. It is a kernel bug with the AppArmor security framework.
|
data/lib/vagrant-kvm/action.rb
CHANGED
@@ -260,7 +260,11 @@ module VagrantPlugins
|
|
260
260
|
b.use Call, Created do |env, b2|
|
261
261
|
# If the VM is NOT created yet, then do the setup steps
|
262
262
|
if !env[:result]
|
263
|
-
|
263
|
+
if Vagrant::VERSION < "1.5.0"
|
264
|
+
b2.use CheckBox
|
265
|
+
else
|
266
|
+
b2.use HandleBox
|
267
|
+
end
|
264
268
|
b2.use SetName
|
265
269
|
b2.use Import
|
266
270
|
b2.use MatchMACAddress
|
@@ -12,7 +12,7 @@ module VagrantPlugins
|
|
12
12
|
# set-up and the driver is ready to function. If not, then an
|
13
13
|
# exception will be raised which will break us out of execution
|
14
14
|
# of the middleware sequence.
|
15
|
-
|
15
|
+
env[:machine].provider.driver.verify!
|
16
16
|
|
17
17
|
# Carry on.
|
18
18
|
@app.call(env)
|
@@ -43,6 +43,16 @@ module VagrantPlugins
|
|
43
43
|
box_file = @env[:machine].box.directory.join("box.xml").to_s
|
44
44
|
raise Errors::KvmBadBoxFormat unless File.file?(box_file)
|
45
45
|
|
46
|
+
# check pool migration neccesary?
|
47
|
+
if @env[:machine].provider.driver.pool_migrate
|
48
|
+
@env[:ui].output "Your vagrant-kvm environment should be fixed. see README"
|
49
|
+
end
|
50
|
+
|
51
|
+
# repair directories permission
|
52
|
+
home_path = File.expand_path("../../", @env[:tmp_path])
|
53
|
+
boxes_path = File.expand_path("../boxes/", @env[:tmp_path])
|
54
|
+
repair_permissions!(home_path, boxes_path)
|
55
|
+
|
46
56
|
# import box volume
|
47
57
|
volume_name = import_volume(storage_path, box_file, args)
|
48
58
|
|
@@ -118,6 +128,26 @@ module VagrantPlugins
|
|
118
128
|
new_disk
|
119
129
|
end
|
120
130
|
|
131
|
+
# Repairs $HOME an $HOME/.vagrangt.d/boxes permissions.
|
132
|
+
#
|
133
|
+
# work around for
|
134
|
+
# https://github.com/adrahon/vagrant-kvm/issues/193
|
135
|
+
# https://github.com/adrahon/vagrant-kvm/issues/163
|
136
|
+
# https://github.com/adrahon/vagrant-kvm/issues/130
|
137
|
+
#
|
138
|
+
def repair_permissions!(home_path, boxes_path)
|
139
|
+
# check pathes
|
140
|
+
[home_path, boxes_path].each do |d|
|
141
|
+
s = File::Stat.new(d)
|
142
|
+
@logger.debug("#{d} permission: #{s.mode}")
|
143
|
+
if (s.mode & 1 == 0)
|
144
|
+
@env[:ui].info I18n.t("vagrant_kvm.repair_permission",:directory => d,
|
145
|
+
:old_mode => sprintf("%o",s.mode), :new_mode => sprintf("%o", s.mode|1))
|
146
|
+
File.chmod(s.mode | 1, d)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
121
151
|
def recover(env)
|
122
152
|
if env[:machine].provider.state.id != :not_created
|
123
153
|
return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError)
|
@@ -36,40 +36,20 @@ module VagrantPlugins
|
|
36
36
|
# KVM support status
|
37
37
|
attr_reader :kvm
|
38
38
|
|
39
|
-
|
39
|
+
# Vagrant 1.5.x pool migration
|
40
|
+
attr_reader :pool_migrate
|
41
|
+
|
42
|
+
def initialize(uuid=nil)
|
40
43
|
@logger = Log4r::Logger.new("vagrant::provider::kvm::driver")
|
41
44
|
@uuid = uuid
|
42
45
|
# This should be configurable
|
43
46
|
@pool_name = "vagrant"
|
44
47
|
@network_name = "vagrant"
|
48
|
+
@pool_migrate = false
|
45
49
|
|
46
50
|
load_kvm_module!
|
47
|
-
|
48
|
-
|
49
|
-
begin
|
50
|
-
@conn = conn || Libvirt::open('qemu:///system')
|
51
|
-
rescue Libvirt::Error => e
|
52
|
-
if e.libvirt_code == 5
|
53
|
-
# can't connect to hypervisor
|
54
|
-
raise Vagrant::Errors::KvmNoConnection
|
55
|
-
else
|
56
|
-
raise e
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
@version = read_version
|
61
|
-
if @conn.version.to_i < 1001000
|
62
|
-
raise Errors::KvmInvalidVersion,
|
63
|
-
:actual => @version, :required => ">= 1.1.0"
|
64
|
-
end
|
65
|
-
|
66
|
-
# Get storage pool if it exists
|
67
|
-
begin
|
68
|
-
@pool = @conn.lookup_storage_pool_by_name(@pool_name)
|
69
|
-
@logger.info("Init storage pool #{@pool_name}")
|
70
|
-
rescue Libvirt::RetrieveError
|
71
|
-
# storage pool doesn't exist yet
|
72
|
-
end
|
51
|
+
connect_libvirt_qemu!
|
52
|
+
init_storage_pool!
|
73
53
|
|
74
54
|
if @uuid
|
75
55
|
# Verify the VM exists, and if it doesn't, then don't worry
|
@@ -174,11 +154,11 @@ module VagrantPlugins
|
|
174
154
|
@logger.info("Importing VM #{@name}")
|
175
155
|
# create vm definition from xml
|
176
156
|
definition = File.open(definition) { |f| Util::VmDefinition.new(f.read) }
|
177
|
-
|
157
|
+
volume_path = lookup_volume_path_by_name(volume_name)
|
178
158
|
args = {
|
179
159
|
:image_type => "qcow2",
|
180
160
|
:qemu_bin => "/usr/bin/qemu",
|
181
|
-
:disk =>
|
161
|
+
:disk => volume_path,
|
182
162
|
:name => @name
|
183
163
|
}.merge(args)
|
184
164
|
definition.update(args)
|
@@ -235,12 +215,13 @@ module VagrantPlugins
|
|
235
215
|
# Storage pool doesn't exist so we create it
|
236
216
|
# create dir if it doesn't exist
|
237
217
|
# if we let libvirt create the dir it is owned by root
|
238
|
-
pool_path =
|
239
|
-
|
240
|
-
|
218
|
+
pool_path = File.join(base_path, "/storage-pool")
|
219
|
+
FileUtils.mkpath(pool_path) unless Dir.exists?(pool_path)
|
220
|
+
init_storage_directory(
|
241
221
|
:pool_path => pool_path,
|
242
222
|
:pool_name => @pool_name,
|
243
223
|
:owner => uid, :group=>gid, :mode=>'755')
|
224
|
+
init_storage_pool!
|
244
225
|
end
|
245
226
|
|
246
227
|
def init_storage_directory(args={})
|
@@ -263,8 +244,29 @@ module VagrantPlugins
|
|
263
244
|
</target>
|
264
245
|
</pool>
|
265
246
|
EOF
|
266
|
-
|
267
|
-
|
247
|
+
# create transient pool
|
248
|
+
#
|
249
|
+
# WARN:
|
250
|
+
# vagrant-kvm 0.1.5 uses
|
251
|
+
# pool = @conn.define_storage_pool_xml(storage_pool_xml)
|
252
|
+
# that made 'pesistent' storage pool
|
253
|
+
# this caused problem when following sinario:
|
254
|
+
#
|
255
|
+
# 1. user use vagrant-kvm 0.1.5 with vagrant-1.4.x
|
256
|
+
# 2. user upgrade vagrant 1.5.x
|
257
|
+
# 3. user upgrade vagrant 0.1.5.1 and after
|
258
|
+
#
|
259
|
+
# vagrant-kvm 0.1.5 don't work with vagrant 1.5.x
|
260
|
+
# previous synario can be happned on many user.
|
261
|
+
#
|
262
|
+
# We use transient pool instead of persistent one
|
263
|
+
# in vagrant-kvm 0.1.5.x, 0.1.6 and after
|
264
|
+
#
|
265
|
+
# Pools defined here will be removed after system reboot.
|
266
|
+
#
|
267
|
+
pool = @conn.create_storage_pool_xml(storage_pool_xml)
|
268
|
+
pool.build unless pool.active?
|
269
|
+
#XXX use? pool.build(Libvirt::StoragePool::BUILD_NO_OVERWRITE)
|
268
270
|
@logger.info("Creating storage pool #{args[:pool_name]} in #{args[:pool_path]}")
|
269
271
|
end
|
270
272
|
pool.create unless pool.active?
|
@@ -272,9 +274,27 @@ module VagrantPlugins
|
|
272
274
|
pool
|
273
275
|
end
|
274
276
|
|
277
|
+
def check_migrate_box_storage_pool
|
278
|
+
# Migration to new pool directory structure in vagrant 1.5.x
|
279
|
+
# delete if created with <vagrant-1.4.x
|
280
|
+
if Vagrant::VERSION >= "1.5.0"
|
281
|
+
begin
|
282
|
+
if @pool && @pool.persistent?
|
283
|
+
# pool was made by vagrant-kvm-0.1.5 and before
|
284
|
+
# vagrant-kvm-0.1.5 NOT working in vagrant 1.5.x
|
285
|
+
# so need migrate
|
286
|
+
@pool_migrate = true
|
287
|
+
end
|
288
|
+
rescue Libvirt::RetrieveError
|
289
|
+
@logger.info("fail to retrieve storage pool")
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
275
294
|
def free_storage_pool(pool_name)
|
276
295
|
begin
|
277
296
|
pool = @conn.lookup_storage_pool_by_name(pool_name)
|
297
|
+
# XXX check reference counter for parallel action?
|
278
298
|
pool.destroy
|
279
299
|
pool.free
|
280
300
|
rescue Libvirt::RetrieveError
|
@@ -282,6 +302,11 @@ module VagrantPlugins
|
|
282
302
|
end
|
283
303
|
end
|
284
304
|
|
305
|
+
def lookup_volume_path_by_name(volume_name)
|
306
|
+
volume = @pool.lookup_volume_by_name(volume_name)
|
307
|
+
volume.path
|
308
|
+
end
|
309
|
+
|
285
310
|
# Returns a list of network interfaces of the VM.
|
286
311
|
#
|
287
312
|
# @return [Hash]
|
@@ -324,17 +349,6 @@ module VagrantPlugins
|
|
324
349
|
VM_STATE[state]
|
325
350
|
end
|
326
351
|
|
327
|
-
# Return the qemu version
|
328
|
-
#
|
329
|
-
# @return [String] of the form "1.2.2"
|
330
|
-
def read_version
|
331
|
-
# libvirt returns a number like 1002002 for version 1.2.2
|
332
|
-
maj = @conn.version / 1000000
|
333
|
-
min = (@conn.version - maj*1000000) / 1000
|
334
|
-
rel = @conn.version % 1000
|
335
|
-
"#{maj}.#{min}.#{rel}"
|
336
|
-
end
|
337
|
-
|
338
352
|
def read_mac_address
|
339
353
|
domain = @conn.lookup_domain_by_uuid(@uuid)
|
340
354
|
definition = Util::VmDefinition.new(domain.xml_desc)
|
@@ -494,6 +508,18 @@ module VagrantPlugins
|
|
494
508
|
end
|
495
509
|
|
496
510
|
private
|
511
|
+
|
512
|
+
# Return the qemu version
|
513
|
+
#
|
514
|
+
# @return [String] of the form "1.2.2"
|
515
|
+
def read_version
|
516
|
+
# libvirt returns a number like 1002002 for version 1.2.2
|
517
|
+
maj = @conn.version / 1000000
|
518
|
+
min = (@conn.version - maj*1000000) / 1000
|
519
|
+
rel = @conn.version % 1000
|
520
|
+
"#{maj}.#{min}.#{rel}"
|
521
|
+
end
|
522
|
+
|
497
523
|
def load_kvm_module!
|
498
524
|
@logger.info("Check KVM kernel modules")
|
499
525
|
kvm = File.readlines('/proc/modules').any? { |line| line =~ /kvm_(intel|amd)/ }
|
@@ -511,6 +537,38 @@ module VagrantPlugins
|
|
511
537
|
raise Errors::VagrantKVMError, "KVM is unavailable" unless kvm
|
512
538
|
true
|
513
539
|
end
|
540
|
+
|
541
|
+
def connect_libvirt_qemu!
|
542
|
+
# Open a connection to the qemu driver
|
543
|
+
begin
|
544
|
+
@conn = Libvirt::open('qemu:///system')
|
545
|
+
rescue Libvirt::Error => e
|
546
|
+
if e.libvirt_code == 5
|
547
|
+
# can't connect to hypervisor
|
548
|
+
raise Vagrant::Errors::KvmNoConnection
|
549
|
+
else
|
550
|
+
raise e
|
551
|
+
end
|
552
|
+
end
|
553
|
+
|
554
|
+
@version = read_version
|
555
|
+
if @conn.version.to_i < 1001000
|
556
|
+
raise Errors::KvmInvalidVersion,
|
557
|
+
:actual => @version, :required => ">= 1.1.0"
|
558
|
+
end
|
559
|
+
end
|
560
|
+
|
561
|
+
def init_storage_pool!
|
562
|
+
# Get storage pool if it exists
|
563
|
+
begin
|
564
|
+
@pool = @conn.lookup_storage_pool_by_name(@pool_name)
|
565
|
+
# this is happen when user has already used vagrant-kvm 0.1.5 and after
|
566
|
+
# check neccesity of migration
|
567
|
+
check_migrate_box_storage_pool
|
568
|
+
rescue Libvirt::RetrieveError
|
569
|
+
# storage pool doesn't exist yet
|
570
|
+
end
|
571
|
+
end
|
514
572
|
end
|
515
573
|
end
|
516
574
|
end
|
data/lib/vagrant-kvm/version.rb
CHANGED
data/locales/en.yml
CHANGED
Binary file
|
data/spec/test_files/box.xml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
<domain type='kvm'
|
2
|
-
<name>
|
1
|
+
<domain type='kvm'>
|
2
|
+
<name>test_base</name>
|
3
3
|
<memory unit='KiB'>524288</memory>
|
4
4
|
<currentMemory unit='KiB'>524288</currentMemory>
|
5
5
|
<vcpu placement='static'>1</vcpu>
|
@@ -15,20 +15,21 @@
|
|
15
15
|
<clock offset='utc'/>
|
16
16
|
<on_poweroff>destroy</on_poweroff>
|
17
17
|
<on_reboot>restart</on_reboot>
|
18
|
-
<on_crash>
|
18
|
+
<on_crash>destroy</on_crash>
|
19
19
|
<devices>
|
20
20
|
<emulator>/usr/bin/kvm</emulator>
|
21
21
|
<disk type='file' device='disk'>
|
22
22
|
<driver name='qemu' type='qcow2'/>
|
23
|
-
<source file='
|
23
|
+
<source file='box-disk1.img'/>
|
24
24
|
<target dev='vda' bus='virtio'/>
|
25
|
-
<
|
26
|
-
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
|
25
|
+
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
27
26
|
</disk>
|
28
27
|
<controller type='usb' index='0'>
|
29
|
-
<alias name='usb0'/>
|
30
28
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
31
29
|
</controller>
|
30
|
+
<controller type='ide' index='0'>
|
31
|
+
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
32
|
+
</controller>
|
32
33
|
<controller type='virtio-serial' index='0'>
|
33
34
|
<alias name='virtio-serial0'/>
|
34
35
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
|
@@ -36,39 +37,26 @@
|
|
36
37
|
<interface type='network'>
|
37
38
|
<mac address='08:00:27:30:3b:ea'/>
|
38
39
|
<source network='vagrant'/>
|
39
|
-
<target dev='vnet0'/>
|
40
40
|
<model type='virtio'/>
|
41
|
-
<alias name='net0'/>
|
42
41
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
43
42
|
</interface>
|
44
43
|
<serial type='pty'>
|
45
|
-
<source path='/dev/pts/1'/>
|
46
44
|
<target port='0'/>
|
47
|
-
<alias name='serial0'/>
|
48
45
|
</serial>
|
49
|
-
<console type='pty'
|
50
|
-
<source path='/dev/pts/1'/>
|
46
|
+
<console type='pty'>
|
51
47
|
<target type='serial' port='0'/>
|
52
|
-
<alias name='serial0'/>
|
53
48
|
</console>
|
54
49
|
<input type='mouse' bus='ps2'/>
|
55
50
|
<graphics type='vnc' port='5900' autoport='no' listen='0.0.0.0'>
|
56
51
|
<listen type='address' address='0.0.0.0'/>
|
57
52
|
</graphics>
|
58
|
-
<sound model='ich6'>
|
59
|
-
<alias name='sound0'/>
|
60
|
-
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
61
|
-
</sound>
|
62
53
|
<video>
|
63
54
|
<model type='cirrus' vram='9216' heads='1'/>
|
64
|
-
<alias name='video0'/>
|
65
55
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
66
56
|
</video>
|
67
57
|
<memballoon model='virtio'>
|
68
|
-
<
|
69
|
-
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
|
58
|
+
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
|
70
59
|
</memballoon>
|
71
60
|
</devices>
|
72
61
|
<seclabel type='none'/>
|
73
62
|
</domain>
|
74
|
-
|
@@ -2,6 +2,31 @@ require 'spec_helper'
|
|
2
2
|
require "vagrant-kvm/config"
|
3
3
|
|
4
4
|
describe VagrantPlugins::ProviderKvm::Config do
|
5
|
+
describe "#image_type" do
|
6
|
+
it "defaults to qcow2" do
|
7
|
+
should_default(:image_type, 'qcow2')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#image_backing" do
|
12
|
+
it "default to true" do
|
13
|
+
subject.finalize!
|
14
|
+
subject.image_backing.should be_true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#cpu_model" do
|
19
|
+
it "default to x86-64" do
|
20
|
+
should_default(:cpu_model, 'x86_64')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#core_number" do
|
25
|
+
it "default to 1" do
|
26
|
+
should_default(:core_number, 1)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
5
30
|
describe "#machine_type" do
|
6
31
|
it "defaults to pc-1.2" do
|
7
32
|
should_default(:machine_type, "pc-1.2")
|
@@ -5,28 +5,56 @@ module VagrantPlugins
|
|
5
5
|
module Driver
|
6
6
|
describe Driver do
|
7
7
|
let(:xml) { test_file "box.xml" }
|
8
|
-
let(:
|
8
|
+
let(:name) { 'spec-test' }
|
9
|
+
let(:disk_name) { 'spec-test' }
|
10
|
+
let(:box_path) { test_file "box-disk1.img" }
|
11
|
+
let(:box_pool) { test_file "" }
|
12
|
+
let(:capacity) { {:size=>256, :unit=>'KB'} }
|
13
|
+
let(:image_path) { '/tmp/pool-storage/box-disk1.img' }
|
14
|
+
let(:image_type) { 'qcow2' }
|
15
|
+
let(:uid) { 1000 }
|
16
|
+
let(:gid) { 1000 }
|
9
17
|
|
10
18
|
before do
|
11
19
|
described_class.any_instance.stub(:load_kvm_module!) { true }
|
20
|
+
described_class.any_instance.stub(:lookup_volume_path_by_name) { "/tmp/pool-storage/box-disk1.img" }
|
12
21
|
end
|
13
22
|
|
14
23
|
describe "#import" do
|
15
|
-
|
16
|
-
# driver class.
|
17
|
-
let(:volume) { double(path: "foo") }
|
18
|
-
let(:pool) { double(refresh: nil, lookup_volume_by_name: volume) }
|
19
|
-
let(:domain) { double(uuid: "abc") }
|
20
|
-
let(:conn) { double(version: 1000000000,
|
21
|
-
lookup_storage_pool_by_name: pool,
|
22
|
-
define_domain_xml: domain) }
|
24
|
+
|
23
25
|
subject do
|
24
|
-
described_class.new(nil
|
26
|
+
described_class.new(nil)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "does not raise exeption" do
|
30
|
+
expect do
|
31
|
+
subject.set_name(name)
|
32
|
+
end.to_not raise_exception
|
33
|
+
end
|
34
|
+
|
35
|
+
it "does not raise execption" do
|
36
|
+
expect do
|
37
|
+
subject.init_storage("/tmp", uid, gid)
|
38
|
+
end.to_not raise_exception
|
39
|
+
end
|
40
|
+
|
41
|
+
it "does not raise exception" do
|
42
|
+
expect do
|
43
|
+
subject.init_storage("/tmp", uid, gid)
|
44
|
+
subject.create_volume(
|
45
|
+
:disk_name => disk_name,
|
46
|
+
:capacity => capacity,
|
47
|
+
:path => image_path,
|
48
|
+
:image_type => image_type,
|
49
|
+
:box_path => box_path,
|
50
|
+
:backing => true)
|
51
|
+
end.to_not raise_exception
|
25
52
|
end
|
26
53
|
|
27
54
|
it "does not raise exception" do
|
28
55
|
expect do
|
29
|
-
subject.
|
56
|
+
subject.set_name(name)
|
57
|
+
subject.import(xml, disk_name)
|
30
58
|
end.to_not raise_exception
|
31
59
|
end
|
32
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-kvm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Drahon
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-libvirt
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- vagrant-kvm.gemspec
|
106
106
|
- spec/acceptance/vagrant-kvm_spec.rb
|
107
107
|
- spec/test_files/box.xml
|
108
|
+
- spec/test_files/box-disk1.img
|
108
109
|
- spec/fedora/50-vagrant-libvirt-access.pkla
|
109
110
|
- spec/fedora/10.virt.rules
|
110
111
|
- spec/vagrant-kvm/errors_spec.rb
|