Allow serials to be disabled (#1453)

Facilitate disabling serial devices by allowing for the configuration to
explicitly set serials to an empty array and ignoring adding the default
serial if this is the case.
This commit is contained in:
Darragh Bailey
2022-02-21 16:12:03 +00:00
committed by GitHub
parent 23ddab1dcf
commit 192a9e00df
2 changed files with 13 additions and 7 deletions

View File

@@ -341,7 +341,7 @@ module VagrantPlugins
# Use Qemu agent to get ip address
@qemu_use_agent = UNSET_VALUE
@serials = []
@serials = UNSET_VALUE
end
def boot(device)
@@ -701,6 +701,8 @@ module VagrantPlugins
end
def serial(options={})
@serials = [] if @serials == UNSET_VALUE
options = {
:type => "pty",
:source => nil,
@@ -965,7 +967,7 @@ module VagrantPlugins
@qemu_use_agent = false if @qemu_use_agent == UNSET_VALUE
@serials = [{:type => 'pty', :source => nil}] if @serials == []
@serials = [{:type => 'pty', :source => nil}] if @serials == UNSET_VALUE
end
def validate(machine)
@@ -1061,11 +1063,13 @@ module VagrantPlugins
c.merge!(other.qemu_env) if other.qemu_env != UNSET_VALUE
result.qemu_env = c
if serials != UNSET_VALUE
s = serials.dup
s += other.serials
result.serials = s
end
end
end
private

View File

@@ -164,6 +164,7 @@
<target port='<%= port %>'/>
</serial>
<%- end -%>
<%- unless @serials.empty? -%>
<%- console_log = @serials.first -%>
<console type='<%= console_log[:type] %>'>
<%- unless console_log[:source].nil? -%>
@@ -171,6 +172,7 @@
<%- end -%>
<target port='0'/>
</console>
<%- end -%>
<%- @channels.each do |channel| -%>
<channel type='<%= channel[:type] %>' >
<%-if channel[:source_mode] or channel[:source_path] -%>