Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to replace kexec for vmtype #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ This provider exposes quite a few provider-specific configuration options:
* `cpus` - The number of CPUs to give the VM
* `xhyve_binary` - use a custom xhyve version
* kernel_command - send a custom kernel boot command
* `vmtype` - The type of VM (kexec or fbsd)

These can be set like typical provider-specific configuration:

Expand All @@ -78,6 +79,7 @@ Vagrant.configure("2") do |config|
config.vm.provider :xhyve do |xhyve|
xhyve.cpus = 2
xhyve.memory = "1G"
xhyve.vmtype = "kexec"
xhyve.xhyve_binary = "/Applications/Docker.app/Contents/MacOS/com.docker.hyperkit"
xhyve.kernel_command = "root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap acpi=off console=ttyS0 LANG=en_GB.UTF-8" # example for a CentOS installed in a LVM filesystem
end
Expand Down
9 changes: 9 additions & 0 deletions lib/vagrant-xhyve/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class Config < Vagrant.plugin("2", :config)
# @return [String]
attr_accessor :memory

# The type of VM that is going to run
#
# The two posible types are: kexec or fbsd
# kexec -> linux
# fbsd -> FreeBSD
attr_accessor :vmtype


# The path to the xhyve binary if you don't want to
# use the one bundled with xhyve-ruby
Expand Down Expand Up @@ -47,6 +54,7 @@ class Config < Vagrant.plugin("2", :config)
def initialize(region_specific=false)
@cpus = UNSET_VALUE
@memory = UNSET_VALUE
@vmtype = UNSET_VALUE
@xhyve_binary = UNSET_VALUE
@mac = UNSET_VALUE
@uuid = UNSET_VALUE
Expand All @@ -68,6 +76,7 @@ def finalize!

@cpus = 1 if @cpus == UNSET_VALUE
@memory = 1024 if @memory == UNSET_VALUE
@vmtype = "kexec" if @vmtype == UNSET_VALUE
@xhyve_binary = nil if @xhyve_binary == UNSET_VALUE
@kernel_command = %Q{"earlyprintk=serial console=ttyS0 root=/dev/vda1 ro"} if @kernel_command == UNSET_VALUE
# Mark that we finalized
Expand Down
3 changes: 2 additions & 1 deletion lib/vagrant-xhyve/util/vagrant-xhyve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def options
:mac => @mac,
:ip => ip,
:binary => @binary
:vmtype => @vmtype
}
end

Expand All @@ -51,7 +52,7 @@ def build_command
"#{build_block_device_parameter}",
'-s', '31,lpc',
'-l', "#{@serial},stdio",
'-f', "kexec,#{@kernel},#{@initrd},'#{@cmdline}'"
'-f', "#{@vmtype},#{@kernel},#{@initrd},'#{@cmdline}'"
].join(' ')
end

Expand Down
3 changes: 2 additions & 1 deletion vendor/xhyve-ruby/lib/xhyve/guest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def initialize(**opts)
@binary = opts[:binary] || BINARY_PATH
@command = build_command
@mac = find_mac
@vmtype = opts[:vmtype] || 'kexec'
end

def start
Expand Down Expand Up @@ -81,7 +82,7 @@ def build_command
"#{"#{@blockdevs.each_with_index.map { |p, i| "-s #{PCI_BASE + i},virtio-blk,#{p}" }.join(' ')}" unless @blockdevs.empty? }",
'-s', '31,lpc',
'-l', "#{@serial},stdio",
'-f' "kexec,#{@kernel},#{@initrd},'#{@cmdline}'"
'-f' "#{@vmtype},#{@kernel},#{@initrd},'#{@cmdline}'"
].join(' ')
end
end
Expand Down