Class: VagrantPlugins::HYPERKIT::Util::XhyveGuest

Inherits:
Xhyve::Guest
  • Object
show all
Defined in:
lib/vagrant-hyperkit/util/vagrant-hyperkit.rb

Overview

TODO: send all this upstream

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ XhyveGuest

Returns a new instance of XhyveGuest.



9
10
11
12
13
14
# File 'lib/vagrant-hyperkit/util/vagrant-hyperkit.rb', line 9

def initialize(**opts)
  super.tap do |s|
    @pid = opts.fetch(:pid, nil)
    @mac = opts[:mac] unless opts[:mac].nil?
  end
end

Instance Method Details

#build_block_device_parameterObject



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vagrant-hyperkit/util/vagrant-hyperkit.rb', line 65

def build_block_device_parameter
  block_device_parameter = ""
  @blockdevs.each_with_index.map do |p, i|
    if p.include? "qcow"
      block_device_parameter << "-s #{PCI_BASE + i},virtio-blk,file://#{p},format\=qcow "
    else
      block_device_parameter << "-s #{PCI_BASE + i},virtio-blk,#{p} "
    end
  end
  block_device_parameter
end

#build_commandObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/vagrant-hyperkit/util/vagrant-hyperkit.rb', line 42

def build_command
  cmd = [
    "sudo",
    "#{@binary}",
    "#{'-A' if @acpi}",
    '-U', @uuid,
    '-m', @memory,
    '-c', @processors,
    '-s', '0:0,hostbridge',
    "#{"-s #{PCI_BASE - 2}:0,virtio-net,en0" if @networking }" ,
    "#{build_block_device_parameter}",
    '-s', '31,lpc',
    '-l', "#{@serial},stdio",
    '-f', "kexec,#{@kernel},#{@initrd},'#{@cmdline}'"
  ].join(' ')

  cmd
end

#logObject



61
62
63
# File 'lib/vagrant-hyperkit/util/vagrant-hyperkit.rb', line 61

def log
  @logger ||= Log4r::Logger.new("vagrant_hyperkit::vagrant_hyperkit")
end

#optionsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vagrant-hyperkit/util/vagrant-hyperkit.rb', line 21

def options
  {
    :pid => @pid,
    :kernel => @kernel,
    :initrd => @initrd,
    :cmdline => @cmdline,
    :blockdevs => @blockdevs,
    :memory => @memory,
    :processors => @processors,
    :uuid => @uuid,
    :serial => @serial,
    :acpi => @acpi,
    :networking => @networking,
    :foreground => @foreground,
    :command => @command,
    :mac => @mac,
    :ip => ip,
    :binary => @binary
  }
end

#startObject



16
17
18
19
# File 'lib/vagrant-hyperkit/util/vagrant-hyperkit.rb', line 16

def start
  return @pid if running?
  super
end