qemu 0.4 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,14 @@ module QEMU
6
6
  end
7
7
  end
8
8
 
9
+ class Hash
10
+
11
+ def to_command(separator = ',')
12
+ map { |k,v| "#{k}=#{v}" }.join separator
13
+ end
14
+
15
+ end
16
+
9
17
  require 'qemu/version'
10
18
  require 'qemu/logger'
11
19
 
@@ -84,7 +84,7 @@ module QEMU
84
84
  [].tap do |args|
85
85
  args << "-enable-kvm"
86
86
 
87
- args << "-m" << "#{memory}m" if memory
87
+ args << "-m" << memory.to_s if memory
88
88
  disks.each_with_index do |disk, index|
89
89
  args << "-drive" << disk.qemu_drive(index)
90
90
  end
@@ -130,7 +130,7 @@ module QEMU
130
130
  def daemon
131
131
  @daemon ||=
132
132
  begin
133
- QEMU.logger.debug "Prepare daemon with '#{command_arguments}'"
133
+ QEMU.logger.debug "Prepare daemon with '#{command_arguments.join(' ')}'"
134
134
  Daemon.new :command => command, :name => name, :arguments => command_arguments, :env => command_env
135
135
  end
136
136
  end
@@ -16,7 +16,11 @@ module QEMU
16
16
 
17
17
  def command(command)
18
18
  telnet.tap do |telnet|
19
- telnet.cmd command
19
+ QEMU.logger.debug "Send monitor command '#{command}'"
20
+
21
+ response = telnet.cmd(command)
22
+ QEMU.logger.debug "Receive '#{response}'"
23
+
20
24
  telnet.close
21
25
  end
22
26
  end
@@ -33,5 +37,21 @@ module QEMU
33
37
  command "loadvm #{name}"
34
38
  end
35
39
 
40
+ def device_add(driver, options = {})
41
+ command "device_add #{driver},#{options.to_command}"
42
+ end
43
+
44
+ def device_del(id)
45
+ command "device_del #{id}"
46
+ end
47
+
48
+ def drive_add(name, options = {})
49
+ command "drive_add #{name} #{options.to_command}"
50
+ end
51
+
52
+ def drive_del(name)
53
+ command "drive_del #{name}"
54
+ end
55
+
36
56
  end
37
57
  end
@@ -1,3 +1,3 @@
1
1
  module QEMU
2
- VERSION = "0.4"
2
+ VERSION = "1.0"
3
3
  end
@@ -35,4 +35,20 @@ describe QEMU::Command do
35
35
  end
36
36
 
37
37
  end
38
+
39
+ describe "#command_arguments" do
40
+
41
+ it "should include -m with memory size" do
42
+ subject.memory = 800
43
+ subject.command_arguments.should include("-m", "800")
44
+ end
45
+
46
+ it "should not include -m when no memory is specified" do
47
+ subject.memory = nil
48
+ subject.command_arguments.should_not include("-m")
49
+ end
50
+
51
+
52
+ end
53
+
38
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qemu
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '1.0'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-05-11 00:00:00.000000000 Z
13
+ date: 2015-03-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -180,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
180
  version: '0'
181
181
  segments:
182
182
  - 0
183
- hash: -2999335787885187271
183
+ hash: -2707032454598879538
184
184
  required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  none: false
186
186
  requirements:
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  segments:
191
191
  - 0
192
- hash: -2999335787885187271
192
+ hash: -2707032454598879538
193
193
  requirements: []
194
194
  rubyforge_project:
195
195
  rubygems_version: 1.8.23