Report graphics port after resolving (#1622)

Allow libvirt to start the domain before reading back the XML to
retrieve the port assigned automatically for subsequent graphics access
when autoport is enabled.

Fixes: #992
This commit is contained in:
Darragh Bailey
2022-10-01 14:59:36 +01:00
committed by GitHub
parent 7813ad3740
commit 54853d1d3d
5 changed files with 56 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
allow(logger).to receive(:debug)
allow(logger).to receive(:info)
allow(ui).to receive(:info)
allow(libvirt_domain).to receive(:xml_desc).and_return(domain_xml)
@@ -162,6 +163,28 @@ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
end
end
context 'graphics' do
context 'autoport not disabled' do
let(:test_file) { 'existing.xml' }
let(:launched_domain_xml) {
new_xml = domain_xml.dup
new_xml.gsub!(/graphics type='vnc' port='-1'/m, "graphics type='vnc' port='5900'")
new_xml
}
it 'should retrieve the port from XML' do
expect(ui).to_not receive(:warn)
expect(connection).to_not receive(:define_domain)
expect(libvirt_domain).to receive(:xml_desc).and_return(domain_xml, launched_domain_xml)
expect(libvirt_domain).to receive(:autostart=)
expect(domain).to receive(:start)
expect(ui).to receive(:info).with(' -- Graphics Port: 5900')
expect(subject.call(env)).to be_nil
end
end
end
context 'nvram' do
context 'when being added to existing' do
let(:vagrantfile_providerconfig) do