mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Add support for clock setup (#1047)
This adds support for setting clock offset and timers. See https://libvirt.org/formatdomain.html#elementsTime for more info.
This commit is contained in:
@@ -27,7 +27,9 @@ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
|
||||
|
||||
allow(connection).to receive(:servers).and_return(servers)
|
||||
allow(servers).to receive(:get).and_return(domain)
|
||||
|
||||
expect(logger).to receive(:info)
|
||||
expect(ui).to_not receive(:error)
|
||||
end
|
||||
|
||||
context 'default config' do
|
||||
@@ -164,5 +166,66 @@ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'clock_timers' do
|
||||
let(:test_file) { 'clock_timer_rtc.xml' }
|
||||
|
||||
before do
|
||||
allow(libvirt_domain).to receive(:xml_desc).and_return(domain_xml)
|
||||
|
||||
allow(libvirt_domain).to receive(:max_memory).and_return(512*1024)
|
||||
allow(libvirt_domain).to receive(:num_vcpus).and_return(1)
|
||||
end
|
||||
|
||||
context 'timers unchanged' do
|
||||
let(:vagrantfile_providerconfig) do
|
||||
<<-EOF
|
||||
libvirt.clock_timer(:name => "rtc")
|
||||
EOF
|
||||
end
|
||||
|
||||
it 'should not modify the domain' do
|
||||
expect(logger).to_not receive(:debug).with('clock timers config changed')
|
||||
expect(servers).to_not receive(:create)
|
||||
expect(libvirt_domain).to receive(:autostart=)
|
||||
expect(domain).to receive(:start)
|
||||
|
||||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'timers added' do
|
||||
let(:vagrantfile_providerconfig) do
|
||||
<<-EOF
|
||||
libvirt.clock_timer(:name => "rtc")
|
||||
libvirt.clock_timer(:name => "tsc")
|
||||
EOF
|
||||
end
|
||||
|
||||
it 'should modify the domain' do
|
||||
expect(libvirt_domain).to receive(:undefine)
|
||||
expect(logger).to receive(:debug).with('clock timers config changed')
|
||||
expect(servers).to receive(:create).with(xml: match(/<clock offset='utc'>\s*<timer name='rtc'\/>\s*<timer name='tsc'\/>\s*<\/clock>/))
|
||||
expect(libvirt_domain).to receive(:autostart=)
|
||||
expect(domain).to receive(:start)
|
||||
|
||||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'timers removed' do
|
||||
let(:updated_test_file) { 'default.xml' }
|
||||
|
||||
it 'should modify the domain' do
|
||||
expect(libvirt_domain).to receive(:undefine)
|
||||
expect(logger).to receive(:debug).with('clock timers config changed')
|
||||
expect(servers).to receive(:create).with(xml: match(/<clock offset='utc'>\s*<\/clock>/))
|
||||
expect(libvirt_domain).to receive(:autostart=)
|
||||
expect(domain).to receive(:start)
|
||||
|
||||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
50
spec/unit/action/start_domain_spec/clock_timer_rtc.xml
Normal file
50
spec/unit/action/start_domain_spec/clock_timer_rtc.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<domain xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0' type=''>
|
||||
<name/>
|
||||
<title/>
|
||||
<description/>
|
||||
<uuid/>
|
||||
<memory/>
|
||||
<vcpu>1</vcpu>
|
||||
|
||||
|
||||
<cpu mode='host-model'>
|
||||
<model fallback='allow'/>
|
||||
</cpu>
|
||||
|
||||
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
<kernel/>
|
||||
<initrd/>
|
||||
<cmdline/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<pae/>
|
||||
</features>
|
||||
<clock offset='utc'>
|
||||
<timer name='rtc'/>
|
||||
</clock>
|
||||
<devices>
|
||||
|
||||
|
||||
<serial type='pty'>
|
||||
<target port='0'/>
|
||||
</serial>
|
||||
<console type='pty'>
|
||||
<target port='0'/>
|
||||
</console>
|
||||
|
||||
|
||||
<input bus='ps2' type='mouse'/>
|
||||
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
||||
<video>
|
||||
<model heads='1' type='cirrus' vram='9216'/>
|
||||
</video>
|
||||
|
||||
|
||||
</devices>
|
||||
|
||||
</domain>
|
||||
Reference in New Issue
Block a user