Class: QEMU::Command
- Inherits:
-
Object
- Object
- QEMU::Command
- Defined in:
- lib/qemu/command.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#alsa_adc_dev ⇒ Object
Returns the value of attribute alsa_adc_dev.
-
#alsa_dac_dev ⇒ Object
Returns the value of attribute alsa_dac_dev.
-
#audio_driver ⇒ Object
Returns the value of attribute audio_driver.
-
#disks ⇒ Object
readonly
Returns the value of attribute disks.
-
#mac_address ⇒ Object
Returns the value of attribute mac_address.
-
#memory ⇒ Object
Returns the value of attribute memory.
-
#monitor ⇒ Object
Returns the value of attribute monitor.
-
#name ⇒ Object
Returns the value of attribute name.
-
#sound_hardware ⇒ Object
Returns the value of attribute sound_hardware.
-
#telnet_port ⇒ Object
Returns the value of attribute telnet_port.
-
#vde_options ⇒ Object
Returns the value of attribute vde_options.
-
#vnc ⇒ Object
Returns the value of attribute vnc.
Instance Method Summary collapse
- #command ⇒ Object
- #command_arguments ⇒ Object
- #command_env ⇒ Object
- #daemon ⇒ Object
- #qemu_monitor ⇒ Object
- #run ⇒ Object
Instance Attribute Details
#alsa_adc_dev ⇒ Object
Returns the value of attribute alsa_adc_dev.
72 73 74 |
# File 'lib/qemu/command.rb', line 72 def alsa_adc_dev @alsa_adc_dev end |
#alsa_dac_dev ⇒ Object
Returns the value of attribute alsa_dac_dev.
72 73 74 |
# File 'lib/qemu/command.rb', line 72 def alsa_dac_dev @alsa_dac_dev end |
#audio_driver ⇒ Object
Returns the value of attribute audio_driver.
67 68 69 |
# File 'lib/qemu/command.rb', line 67 def audio_driver @audio_driver end |
#disks ⇒ Object (readonly)
Returns the value of attribute disks.
12 13 14 |
# File 'lib/qemu/command.rb', line 12 def disks @disks end |
#mac_address ⇒ Object
Returns the value of attribute mac_address.
45 46 47 |
# File 'lib/qemu/command.rb', line 45 def mac_address @mac_address end |
#memory ⇒ Object
Returns the value of attribute memory.
10 11 12 |
# File 'lib/qemu/command.rb', line 10 def memory @memory end |
#monitor ⇒ Object
Returns the value of attribute monitor.
54 55 56 |
# File 'lib/qemu/command.rb', line 54 def monitor @monitor end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/qemu/command.rb', line 4 def name @name end |
#sound_hardware ⇒ Object
Returns the value of attribute sound_hardware.
66 67 68 |
# File 'lib/qemu/command.rb', line 66 def sound_hardware @sound_hardware end |
#telnet_port ⇒ Object
Returns the value of attribute telnet_port.
55 56 57 |
# File 'lib/qemu/command.rb', line 55 def telnet_port @telnet_port end |
#vde_options ⇒ Object
Returns the value of attribute vde_options.
47 48 49 |
# File 'lib/qemu/command.rb', line 47 def @vde_options end |
#vnc ⇒ Object
Returns the value of attribute vnc.
52 53 54 |
# File 'lib/qemu/command.rb', line 52 def vnc @vnc end |
Instance Method Details
#command ⇒ Object
102 103 104 |
# File 'lib/qemu/command.rb', line 102 def command "/usr/bin/kvm" end |
#command_arguments ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/qemu/command.rb', line 74 def command_arguments [].tap do |args| args << "-m" << "#{memory}m" if memory disks.each_with_index do |disk, index| args << "-drive" << disk.qemu_drive(index) end args << "-net" << "nic,macaddr=#{mac_address}" unless .empty? args << "-net" << "vde," + .map { |k,v| "#{k}=#{v}" }.join(',') end if vnc args << "-vnc" << vnc else args << "-nographic" end args << "-monitor" << monitor if monitor args << "-soundhw" << sound_hardware if sound_hardware end end |
#command_env ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/qemu/command.rb', line 94 def command_env {}.tap do |env| env["QEMU_AUDIO_DRV"] = audio_driver env["QEMU_ALSA_DAC_DEV"] = alsa_dac_dev if alsa_dac_dev env["QEMU_ALSA_ADC_DEV"] = alsa_adc_dev if alsa_adc_dev end end |
#daemon ⇒ Object
111 112 113 |
# File 'lib/qemu/command.rb', line 111 def daemon @daemon ||= Daemon.new :command => command, :name => name, :arguments => command_arguments, :env => command_env end |
#qemu_monitor ⇒ Object
62 63 64 |
# File 'lib/qemu/command.rb', line 62 def qemu_monitor @qemu_monitor ||= QEMU::Monitor.new :port => telnet_port if telnet_port end |
#run ⇒ Object
106 107 108 109 |
# File 'lib/qemu/command.rb', line 106 def run shell_env = command_env.map { |k,v| "#{k}=#{v}" }.join(' ') system "#{shell_env} #{command} #{command_arguments.join(' ')}" end |