Class: Libvirt::Spec::Domain::OSBooting

Inherits:
Object
  • Object
show all
Defined in:
lib/libvirt/spec/domain/os_booting.rb

Overview

The OS booting section of a domain specification indicates to libvirt how to configure the virtual machine to boot. There are three main ways to configure booting. Each hypervisor supports one or more of the following:

  1. BIOS bootloader
  2. Host bootloader
  3. Direct kernel boot

TODO: Host bootloader and direct kernel bootloader options.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (OSBooting) initialize

A new instance of OSBooting



29
30
31
# File 'lib/libvirt/spec/domain/os_booting.rb', line 29

def initialize
  @boot = []
end

Instance Attribute Details

- (Object) arch

Returns the value of attribute arch



15
16
17
# File 'lib/libvirt/spec/domain/os_booting.rb', line 15

def arch
  @arch
end

- (Object) boot

Returns the value of attribute boot



17
18
19
# File 'lib/libvirt/spec/domain/os_booting.rb', line 17

def boot
  @boot
end

- (Object) bootloader

Host bootloader configuration options



21
22
23
# File 'lib/libvirt/spec/domain/os_booting.rb', line 21

def bootloader
  @bootloader
end

- (Object) bootloader_args

Returns the value of attribute bootloader_args



22
23
24
# File 'lib/libvirt/spec/domain/os_booting.rb', line 22

def bootloader_args
  @bootloader_args
end

- (Object) bootmenu_enabled

Returns the value of attribute bootmenu_enabled



18
19
20
# File 'lib/libvirt/spec/domain/os_booting.rb', line 18

def bootmenu_enabled
  @bootmenu_enabled
end

- (Object) cmdline

Returns the value of attribute cmdline



27
28
29
# File 'lib/libvirt/spec/domain/os_booting.rb', line 27

def cmdline
  @cmdline
end

- (Object) initrd

Returns the value of attribute initrd



26
27
28
# File 'lib/libvirt/spec/domain/os_booting.rb', line 26

def initrd
  @initrd
end

- (Object) kernel

Direct kernel boot



25
26
27
# File 'lib/libvirt/spec/domain/os_booting.rb', line 25

def kernel
  @kernel
end

- (Object) loader

Part of the BIOS bootloader



16
17
18
# File 'lib/libvirt/spec/domain/os_booting.rb', line 16

def loader
  @loader
end

- (Object) type

Returns the value of attribute type



14
15
16
# File 'lib/libvirt/spec/domain/os_booting.rb', line 14

def type
  @type
end

Instance Method Details

- (Object) to_xml(parent = Nokogiri::XML::Builder.new)

Convert just the OS booting section to its XML representation.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/libvirt/spec/domain/os_booting.rb', line 40

def to_xml(parent=Nokogiri::XML::Builder.new)
  parent.os do |os|
    # Build the arguments for the OS booting type
    type_args = [type]
    type_args << { :arch => arch } if arch

    # Setup the specification
    os.type_ *type_args
    os.loader loader if loader
    os.bootmenu(:enable => bootmenu_enabled ? 'yes' : 'no') if !bootmenu_enabled.nil?

    # Boot order for BIOS booting
    boot.each { |dev| os.boot :dev => dev } if boot.is_a?(Array)

    # Host bootloader configuration options
    os.bootloader bootloader if bootloader
    os.bootloader_args bootloader_args if bootloader_args

    # Direct kernel boot options
    os.kernel kernel if kernel
    os.initrd initrd if initrd
    os.cmdline cmdline if cmdline
  end

  parent.to_xml
end