Add action to resolve disk settings (#1502)

With multi volume boxes, need to ensure that disk settings such as the
device assigned are resolved dynamically once it has been established
which devices have already been assigned to the box volumes on either
initial creation or subsequent boots.

Otherwise users are forced to always explicitly define the device for
additional storage instead of having it be automatically assigned the
next available device.

Consequently previous changes have broken the ability for machines
with additional storage to be halted and restarted correctly.

Include an integration test that for additional storage checks that the
machine can be stopped and started again.

Fixes: #1490
This commit is contained in:
Darragh Bailey
2022-06-02 19:09:18 +01:00
committed by GitHub
parent d1232f0c20
commit 37597e22f9
20 changed files with 986 additions and 256 deletions

View File

@@ -21,8 +21,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
let(:domain_volume) { instance_double(::Fog::Libvirt::Compute::Volume) }
let(:domain_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), domain_xml_file)) }
let(:storage_pool_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), storage_pool_xml_file)) }
let(:libvirt_storage_pool) { double('storage_pool') }
describe '#call' do
before do
@@ -39,15 +37,17 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
env[:domain_name] = "vagrant-test_default"
env[:box_volumes] = []
env[:box_volumes].push({
env[:domain_volumes] = []
env[:domain_volumes].push({
:device=>'vda',
:bus=>'virtio',
:cache=>'default',
:absolute_path=>'/var/lib/libvirt/images/vagrant-test_default.img',
:path=>"/test/box.img",
:name=>"test_vagrant_box_image_1.1.1_0.img",
:name=>'test_vagrant_box_image_1.1.1_0.img',
:virtual_size=> ByteNumber.new(5),
:pool=>'default',
})
# should be ignored for system session and used for user session
allow(Process).to receive(:uid).and_return(9999)
allow(Process).to receive(:gid).and_return(9999)
end
context 'connection => qemu:///system' do
@@ -57,103 +57,50 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
allow(machine.provider_config).to receive(:qemu_use_session).and_return(false)
end
context 'default pool' do
it 'should execute correctly' do
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
expect(volumes).to_not receive(:create) # additional disks only
it 'should execute correctly' do
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
expect(volumes).to_not receive(:create) # additional disks only
expect(subject.call(env)).to be_nil
expect(subject.call(env)).to be_nil
end
context 'additional disks' do
let(:disks) do
[
:device => 'vdb',
:cache => 'default',
:bus => 'virtio',
:type => 'qcow2',
:absolute_path => '/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2',
:virtual_size => ByteNumber.new(20*1024*1024*1024),
:pool => 'default',
]
end
context 'with no box' do
let(:storage_pool_xml_file) { 'default_system_storage_pool.xml' }
let(:vagrantfile) do
<<-EOF
Vagrant.configure('2') do |config|
config.vm.define :test
end
EOF
end
before do
env[:disks] = disks
end
it 'should query for the storage pool path' do
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
expect(servers).to receive(:create).and_return(machine)
context 'volume create failed' do
it 'should raise an exception' do
expect(volumes).to receive(:create).and_raise(Libvirt::Error)
expect(subject.call(env)).to be_nil
expect{ subject.call(env) }.to raise_error(VagrantPlugins::ProviderLibvirt::Errors::FogCreateDomainVolumeError)
end
end
context 'additional disks' do
let(:vagrantfile_providerconfig) do
<<-EOF
libvirt.storage :file, :size => '20G'
EOF
end
context 'volume create succeeded' do
let(:domain_xml_file) { 'additional_disks_domain.xml' }
context 'volume create failed' do
it 'should raise an exception' do
expect(volumes).to receive(:create).and_raise(Libvirt::Error)
expect{ subject.call(env) }.to raise_error(VagrantPlugins::ProviderLibvirt::Errors::FogCreateDomainVolumeError)
end
end
context 'volume create succeeded' do
let(:domain_xml_file) { 'additional_disks_domain.xml' }
it 'should complete' do
expect(volumes).to receive(:create).with(
hash_including(
:path => "/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2",
:owner => 0,
:group => 0,
:pool_name => "default",
)
it 'should complete' do
expect(volumes).to receive(:create).with(
hash_including(
:path => "/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2",
:owner => 0,
:group => 0,
:pool_name => "default",
)
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
expect(subject.call(env)).to be_nil
end
end
end
context 'with custom disk device setting' do
let(:domain_xml_file) { 'custom_disk_settings.xml' }
let(:vagrantfile_providerconfig) {
<<-EOF
libvirt.disk_device = 'sda'
EOF
}
it 'should set the domain device' do
expect(ui).to receive(:info).with(/ -- Image\(sda\):.*/)
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
expect(subject.call(env)).to be_nil
end
end
context 'with two domain disks' do
let(:domain_xml_file) { 'two_disk_settings.xml' }
let(:domain_volume_2) { double('domain_volume 2') }
before do
expect(volumes).to receive(:all).and_return([domain_volume])
expect(volumes).to receive(:all).and_return([domain_volume_2])
expect(domain_volume_2).to receive(:pool_name).and_return('default')
expect(domain_volume_2).to receive(:path).and_return('/var/lib/libvirt/images/vagrant-test_default_1.img')
env[:box_volumes].push({
:path=>"/test/box_1.img",
:name=>"test_vagrant_box_image_1.1.1_1.img",
:virtual_size=> ByteNumber.new(5),
})
end
it 'should correctly assign device entries' do
expect(ui).to receive(:info).with(/ -- Image\(vda\):.*/)
expect(ui).to receive(:info).with(/ -- Image\(vdb\):.*/)
)
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
expect(subject.call(env)).to be_nil
@@ -161,19 +108,48 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
end
end
context 'no default pool' do
let(:vagrantfile) do
<<-EOF
Vagrant.configure('2') do |config|
config.vm.define :test
end
EOF
context 'with custom disk device setting' do
let(:domain_xml_file) { 'custom_disk_settings.xml' }
before do
env[:domain_volumes][0][:device] = 'sda'
end
it 'should raise an exception' do
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(nil)
it 'should set the domain device' do
expect(ui).to receive(:info).with(/ -- Image\(sda\):.*/)
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
expect{ subject.call(env) }.to raise_error(VagrantPlugins::ProviderLibvirt::Errors::NoStoragePool)
expect(subject.call(env)).to be_nil
end
end
context 'with two domain disks' do
let(:domain_xml_file) { 'two_disk_settings.xml' }
let(:domain_volume_2) { double('domain_volume 2') }
before do
expect(volumes).to receive(:all).with(name: 'vagrant-test_default.img').and_return([domain_volume])
expect(volumes).to receive(:all).with(name: 'vagrant-test_default_1.img').and_return([domain_volume_2])
expect(domain_volume_2).to receive(:pool_name).and_return('default')
env[:domain_volumes].push({
:device=>'vdb',
:bus=>'virtio',
:cache=>'default',
:absolute_path=>'/var/lib/libvirt/images/vagrant-test_default_1.img',
:path=>"/test/box_1.img",
:name=>"test_vagrant_box_image_1.1.1_1.img",
:virtual_size=> ByteNumber.new(5),
:pool=>'default',
})
end
it 'should list multiple device entries' do
expect(ui).to receive(:info).with(/ -- Image\(vda\):.*/)
expect(ui).to receive(:info).with(/ -- Image\(vdb\):.*/)
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
expect(subject.call(env)).to be_nil
end
end
end
@@ -183,59 +159,53 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
allow(machine.provider_config).to receive(:qemu_use_session).and_return(true)
end
context 'default pool' do
it 'should execute correctly' do
expect(servers).to receive(:create).and_return(machine)
it 'should execute correctly' do
expect(servers).to receive(:create).and_return(machine)
expect(subject.call(env)).to be_nil
expect(subject.call(env)).to be_nil
end
context 'additional disks' do
let(:vagrantfile_providerconfig) do
<<-EOF
libvirt.qemu_use_session = true
EOF
end
context 'with no box' do
let(:storage_pool_xml_file) { 'default_user_storage_pool.xml' }
let(:vagrantfile) do
<<-EOF
Vagrant.configure('2') do |config|
config.vm.define :test
config.vm.provider :libvirt do |libvirt|
#{vagrantfile_providerconfig}
end
end
EOF
end
let(:disks) do
[
:device => 'vdb',
:cache => 'default',
:bus => 'virtio',
:type => 'qcow2',
:absolute_path => '/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2',
:virtual_size => ByteNumber.new(20*1024*1024*1024),
:pool => 'default',
]
end
it 'should query for the storage pool path' do
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
before do
expect(Process).to receive(:uid).and_return(9999).at_least(:once)
expect(Process).to receive(:gid).and_return(9999).at_least(:once)
env[:disks] = disks
end
context 'volume create succeeded' do
it 'should complete' do
expect(volumes).to receive(:create).with(
hash_including(
:path => "/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2",
:owner => 9999,
:group => 9999,
:pool_name => "default",
)
)
expect(servers).to receive(:create).and_return(machine)
expect(subject.call(env)).to be_nil
end
end
context 'additional disks' do
let(:vagrantfile_providerconfig) do
<<-EOF
libvirt.qemu_use_session = true
libvirt.storage :file, :size => '20G'
EOF
end
context 'volume create succeeded' do
it 'should complete' do
expect(volumes).to receive(:create).with(
hash_including(
:path => "/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2",
:owner => 9999,
:group => 9999,
:pool_name => "default",
)
)
expect(servers).to receive(:create).and_return(machine)
expect(subject.call(env)).to be_nil
end
end
end
end
end
end

View File

@@ -145,7 +145,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::DestroyDomain do
let(:domain_xml_file) { 'box_multiple_disks_and_additional_and_custom_disks_no_aliases.xml' }
it 'only destroys expected disks' do
expect(ui).to receive(:warn).with(/Destroying machine that was originally created without device aliases.*/)
expect(ui).to receive(:warn).with(/Machine that was originally created without device aliases.*/)
expect(ui).to receive(:warn).with(/Unexpected number of volumes detected/)
expect(ui).to receive(:warn).with(/box metadata not available to get volume list during destroy, assuming inferred list/)
domain_disks.each do |disk, name|
@@ -172,7 +172,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::DestroyDomain do
end
it 'only destroys expected disks' do
expect(ui).to receive(:warn).with(/Destroying machine that was originally created without device aliases.*/)
expect(ui).to receive(:warn).with(/Machine that was originally created without device aliases.*/)
expect(ui).to receive(:warn).with(/Unexpected number of volumes detected/)
domain_disks.each do |disk, name|
expect(disk).to receive(:name).and_return(name).at_least(:once)

View File

@@ -59,6 +59,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
allow(volumes).to receive(:all).and_return(all)
allow(env[:ui]).to receive(:clear_line)
env[:machine].provider_config.disk_device = 'vda'
end
context 'when one disk in metadata.json' do
@@ -86,7 +87,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
:path=>"/test/box.img",
:name=>"test_vagrant_box_image_1.1.1_box.img",
:virtual_size=>byte_number_5G,
:format=>"qcow2"
:format=>"qcow2",
:device=>'vda',
}
]
)
@@ -115,7 +117,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
:path=>"/test/box.img",
:name=>"test_vagrant_box_image_0_#{box_mtime.to_i}_box.img",
:virtual_size=>byte_number_5G,
:format=>"qcow2"
:format=>"qcow2",
:device=>'vda',
}
]
)
@@ -124,7 +127,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
context 'When config.machine_virtual_size is set and smaller than box_virtual_size' do
before do
allow(env[:machine]).to receive_message_chain("provider_config.machine_virtual_size").and_return(1)
env[:machine].provider_config.machine_virtual_size = 1
end
it 'should warning must be raise' do
expect(ui).to receive(:warn).with("Ignoring requested virtual disk size of '1' as it is below\nthe minimum box image size of '5'.")
@@ -135,7 +138,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
:path=>"/test/box.img",
:name=>"test_vagrant_box_image_1.1.1_box.img",
:virtual_size=>byte_number_5G,
:format=>"qcow2"
:format=>"qcow2",
:device=>'vda',
}
]
)
@@ -144,7 +148,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
context 'When config.machine_virtual_size is set and higher than box_virtual_size' do
before do
allow(env[:machine]).to receive_message_chain("provider_config.machine_virtual_size").and_return(20)
env[:machine].provider_config.machine_virtual_size = 20
end
it 'should be use' do
expect(ui).to receive(:info).with("Created volume larger than box defaults, will require manual resizing of\nfilesystems to utilize.")
@@ -155,7 +159,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
:path=>"/test/box.img",
:name=>"test_vagrant_box_image_1.1.1_box.img",
:virtual_size=>byte_number_20G,
:format=>"qcow2"
:format=>"qcow2",
:device=>'vda',
}
]
)
@@ -246,7 +251,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
:path=>"/test/box.img",
:name=>"test_vagrant_box_image_1.1.1_send_box_name.img",
:virtual_size=>byte_number_5G,
:format=>"qcow2"
:format=>"qcow2",
:device=>'vda',
},
{
:path=>"/test/disk.qcow2",

View File

@@ -0,0 +1,361 @@
# frozen_string_literal: true
require 'spec_helper'
require 'fog/libvirt/models/compute/volume'
require 'vagrant-libvirt/action/resolve_disk_settings'
describe VagrantPlugins::ProviderLibvirt::Action::ResolveDiskSettings do
subject { described_class.new(app, env) }
include_context 'unit'
include_context 'libvirt'
let(:servers) { double('servers') }
let(:volumes) { double('volumes') }
let(:domain_volume) { instance_double(::Fog::Libvirt::Compute::Volume) }
let(:libvirt_storage_pool) { double('storage_pool') }
let(:domain_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), domain_xml_file)) }
let(:storage_pool_xml) do
File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), storage_pool_xml_file))
end
before do
allow(logger).to receive(:info)
allow(logger).to receive(:debug)
end
describe '#call' do
before do
allow(connection).to receive(:volumes).and_return(volumes)
allow(volumes).to receive(:all).and_return([domain_volume])
allow(domain_volume).to receive(:pool_name).and_return('default')
allow(domain_volume).to receive(:path).and_return('/var/lib/libvirt/images/vagrant-test_default.img')
end
context 'when vm box is in use' do
context 'when box metadata is available' do
let(:box_volumes) do
[
{
path: '/test/box.img',
name: 'test_vagrant_box_image_1.1.1_box.img',
},
]
end
before do
env[:domain_name] = 'vagrant-test_default'
env[:box_volumes] = box_volumes
end
it 'should populate domain volume' do
expect(subject.call(env)).to be_nil
expect(env[:domain_volumes]).to match(
[
hash_including(
device: 'vda',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default.img'
),
]
)
end
context 'when additional storage specified' do
let(:vagrantfile_providerconfig) do
<<-EOF
libvirt.storage :file, :size => '20G'
EOF
end
it 'should use the next device for storage' do
expect(subject.call(env)).to be_nil
expect(env[:disks]).to match(
[
hash_including(
device: 'vdb',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2'
),
]
)
end
end
context 'when custom disk device setting' do
before do
machine.provider_config.disk_device = 'sda'
end
it 'should set the domain device' do
expect(subject.call(env)).to be_nil
expect(env[:domain_volumes]).to match(
[
hash_including(
device: 'sda',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default.img'
),
]
)
end
context 'when additional storage specified' do
let(:vagrantfile_providerconfig) do
<<-EOF
libvirt.storage :file, :size => '20G'
EOF
end
it 'should use the next custom disk device for storage' do
expect(subject.call(env)).to be_nil
expect(env[:disks]).to match(
[
hash_including(
device: 'sdb',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default-sdb.qcow2'
),
]
)
end
end
end
context 'when multiple box volumes' do
let(:box_volumes) do
[
{
path: '/test/box.img',
name: 'test_vagrant_box_image_1.1.1_box.img',
},
{
path: '/test/box_2.img',
name: 'test_vagrant_box_image_1.1.1_box_2.img',
},
]
end
it 'should populate all domain volumes' do
expect(subject.call(env)).to be_nil
expect(env[:domain_volumes]).to match(
[
hash_including(
device: 'vda',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default.img'
),
hash_including(
device: 'vdb',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default.img'
),
]
)
end
context 'when additional storage specified' do
let(:vagrantfile_providerconfig) do
<<-EOF
libvirt.storage :file, :size => '20G'
EOF
end
it 'should use the next device for storage' do
expect(subject.call(env)).to be_nil
expect(env[:disks]).to match(
[
hash_including(
device: 'vdc',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default-vdc.qcow2'
),
]
)
end
end
end
end
context 'when box metadata is not available' do
let(:domain_xml_file) { 'default_domain.xml' }
before do
expect(libvirt_client).to receive(:lookup_domain_by_uuid).and_return(libvirt_domain)
expect(libvirt_domain).to receive(:xml_desc).and_return(domain_xml)
end
it 'should query the domain xml' do
expect(subject.call(env)).to be_nil
expect(env[:domain_volumes]).to match(
[
hash_including(
device: 'vda',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default.img'
),
]
)
end
context 'when multiple volumes in domain config' do
let(:domain_xml_file) { 'multi_volume_box.xml' }
it 'should populate domain volumes with devices' do
expect(subject.call(env)).to be_nil
expect(env[:domain_volumes]).to match(
[
hash_including(
device: 'vda',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default.img'
),
hash_including(
device: 'vdb',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default_1.img'
),
hash_including(
device: 'vdc',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default_2.img'
),
]
)
end
context 'when additional storage in domain config' do
let(:domain_xml_file) { 'multi_volume_box_additional_storage.xml' }
let(:vagrantfile_providerconfig) do
<<-EOF
libvirt.storage :file, :size => '20G'
libvirt.storage :file, :size => '20G'
EOF
end
it 'should populate disks with devices' do
expect(subject.call(env)).to be_nil
expect(env[:disks]).to match(
[
hash_including(
device: 'vdd',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default-vdd.qcow2'
),
hash_including(
device: 'vde',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default-vde.qcow2'
),
]
)
end
end
end
context 'when no aliases available' do
let(:domain_xml_file) { 'default_no_aliases.xml' }
it 'should assume a single box volume' do
expect(subject.call(env)).to be_nil
expect(env[:domain_volumes]).to match(
[
hash_including(
device: 'vda',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default.img'
),
]
)
end
context 'when additional storage and a custom disk device attached' do
let(:domain_xml_file) { 'multi_volume_box_additional_and_custom_no_aliases.xml' }
let(:vagrantfile_providerconfig) do
<<-EOF
libvirt.storage :file, :size => '20G'
libvirt.storage :file, :size => '20G'
EOF
end
it 'should detect the domain volumes and disks while ignoring the last one' do
expect(subject.call(env)).to be_nil
expect(env[:domain_volumes]).to match(
[
hash_including(
device: 'vda',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default.img'
),
hash_including(
device: 'vdb',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default_1.img'
),
hash_including(
device: 'vdc',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default_2.img'
),
]
)
expect(env[:disks]).to match(
[
hash_including(
device: 'vdd',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default-vdd.qcow2'
),
hash_including(
device: 'vde',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default-vde.qcow2'
),
]
)
end
end
end
end
context 'no default pool' do
let(:domain_xml_file) { 'default_domain.xml' }
let(:vagrantfile) do
<<-EOF
Vagrant.configure('2') do |config|
config.vm.define :test
end
EOF
end
it 'should raise an exception' do
expect(libvirt_client).to receive(:lookup_domain_by_uuid).and_return(libvirt_domain)
expect(libvirt_domain).to receive(:xml_desc).and_return(domain_xml)
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(nil)
expect { subject.call(env) }.to raise_error(VagrantPlugins::ProviderLibvirt::Errors::NoStoragePool)
end
end
end
context 'when no box defined' do
let(:domain_xml_file) { 'default_domain.xml' }
let(:storage_pool_xml_file) { 'default_system_storage_pool.xml' }
let(:vagrantfile) do
<<-EOF
Vagrant.configure('2') do |config|
config.vm.define :test
config.vm.provider :libvirt do |libvirt|
libvirt.storage :file, :size => '20G'
end
end
EOF
end
it 'should query for domain name and storage pool path' do
expect(libvirt_client).to receive(:lookup_domain_by_uuid).and_return(libvirt_domain)
expect(libvirt_domain).to receive(:xml_desc).and_return(domain_xml)
expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
expect(subject.call(env)).to be_nil
expect(env[:disks]).to match(
[
hash_including(
device: 'vda',
cache: 'default',
bus: 'virtio',
path: 'vagrant-test_default-vda.qcow2',
absolute_path: '/var/lib/libvirt/images/vagrant-test_default-vda.qcow2',
size: '20G',
pool: 'default'
),
]
)
end
end
end
end

View File

@@ -0,0 +1,43 @@
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>vagrant-test_default</name>
<title></title>
<description>Source: /rootpath/Vagrantfile</description>
<uuid></uuid>
<memory>524288</memory>
<vcpu>1</vcpu>
<cpu mode='host-model'>
<model fallback='allow'></model>
</cpu>
<os>
<type>hvm</type>
<kernel></kernel>
<initrd></initrd>
<cmdline></cmdline>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'>
</clock>
<devices>
<disk type='file' device='disk'>
<alias name='ua-box-volume-0'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
<video>
<model type='cirrus' vram='16384' heads='1'/>
</video>
</devices>
</domain>

View File

@@ -0,0 +1,42 @@
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>vagrant-test_default</name>
<title></title>
<description>Source: /rootpath/Vagrantfile</description>
<uuid></uuid>
<memory>524288</memory>
<vcpu>1</vcpu>
<cpu mode='host-model'>
<model fallback='allow'></model>
</cpu>
<os>
<type>hvm</type>
<kernel></kernel>
<initrd></initrd>
<cmdline></cmdline>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'>
</clock>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
<video>
<model type='cirrus' vram='16384' heads='1'/>
</video>
</devices>
</domain>

View File

@@ -0,0 +1,55 @@
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>vagrant-test_default</name>
<title></title>
<description>Source: /rootpath/Vagrantfile</description>
<uuid></uuid>
<memory>524288</memory>
<vcpu>1</vcpu>
<cpu mode='host-model'>
<model fallback='allow'></model>
</cpu>
<os>
<type>hvm</type>
<kernel></kernel>
<initrd></initrd>
<cmdline></cmdline>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'>
</clock>
<devices>
<disk type='file' device='disk'>
<alias name='ua-box-volume-0'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<alias name='ua-box-volume-1'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default_1.img'/>
<target dev='vdb' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<alias name='ua-box-volume-2'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default_2.img'/>
<target dev='vdc' bus='virtio'/>
</disk>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
<video>
<model type='cirrus' vram='16384' heads='1'/>
</video>
</devices>
</domain>

View File

@@ -0,0 +1,67 @@
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>vagrant-test_default</name>
<title></title>
<description>Source: /rootpath/Vagrantfile</description>
<uuid></uuid>
<memory>524288</memory>
<vcpu>1</vcpu>
<cpu mode='host-model'>
<model fallback='allow'></model>
</cpu>
<os>
<type>hvm</type>
<kernel></kernel>
<initrd></initrd>
<cmdline></cmdline>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'>
</clock>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default_1.img'/>
<target dev='vdb' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default_2.img'/>
<target dev='vdc' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default-vdd.qcow2'/>
<target dev='vdd' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default-vde.qcow2'/>
<target dev='vde' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default-vdf.qcow2'/>
<target dev='vdf' bus='virtio'/>
</disk>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
<video>
<model type='cirrus' vram='16384' heads='1'/>
</video>
</devices>
</domain>

View File

@@ -0,0 +1,67 @@
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>vagrant-test_default</name>
<title></title>
<description>Source: /rootpath/Vagrantfile</description>
<uuid></uuid>
<memory>524288</memory>
<vcpu>1</vcpu>
<cpu mode='host-model'>
<model fallback='allow'></model>
</cpu>
<os>
<type>hvm</type>
<kernel></kernel>
<initrd></initrd>
<cmdline></cmdline>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'>
</clock>
<devices>
<disk type='file' device='disk'>
<alias name='ua-box-volume-0'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<alias name='ua-box-volume-1'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default_1.img'/>
<target dev='vdb' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<alias name='ua-box-volume-2'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default_2.img'/>
<target dev='vdc' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<alias name='ua-disk-volume-0'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default-vdd.qcow2'/>
<target dev='vdd' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<alias name='ua-disk-volume-1'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default-vde.qcow2'/>
<target dev='vde' bus='virtio'/>
</disk>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
<video>
<model type='cirrus' vram='16384' heads='1'/>
</video>
</devices>
</domain>

View File

@@ -62,13 +62,13 @@ describe 'templates/domain' do
:dev => 'vda',
:cache => 'unsafe',
:bus => domain.disk_bus,
:path => '/var/lib/libvirt/images/test.qcow2'
:absolute_path => '/var/lib/libvirt/images/test.qcow2'
})
domain.domain_volumes.push({
:dev => 'vdb',
:cache => 'unsafe',
:bus => domain.disk_bus,
:path => '/var/lib/libvirt/images/test2.qcow2'
:absolute_path => '/var/lib/libvirt/images/test2.qcow2'
})
domain.storage(:file, path: 'test-disk1.qcow2')
domain.storage(:file, path: 'test-disk2.qcow2', io: 'threads', copy_on_read: 'on', discard: 'unmap', detect_zeroes: 'on')