qemu 0.4 → 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/qemu.rb +8 -0
- data/lib/qemu/command.rb +2 -2
- data/lib/qemu/monitor.rb +21 -1
- data/lib/qemu/version.rb +1 -1
- data/spec/qemu/command_spec.rb +16 -0
- metadata +4 -4
    
        data/lib/qemu.rb
    CHANGED
    
    
    
        data/lib/qemu/command.rb
    CHANGED
    
    | @@ -84,7 +84,7 @@ module QEMU | |
| 84 84 | 
             
                  [].tap do |args|
         | 
| 85 85 | 
             
                    args << "-enable-kvm"
         | 
| 86 86 |  | 
| 87 | 
            -
                    args << "-m" <<  | 
| 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
         | 
    
        data/lib/qemu/monitor.rb
    CHANGED
    
    | @@ -16,7 +16,11 @@ module QEMU | |
| 16 16 |  | 
| 17 17 | 
             
                def command(command)
         | 
| 18 18 | 
             
                  telnet.tap do |telnet|
         | 
| 19 | 
            -
                     | 
| 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
         | 
    
        data/lib/qemu/version.rb
    CHANGED
    
    
    
        data/spec/qemu/command_spec.rb
    CHANGED
    
    | @@ -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 | 
            +
              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:  | 
| 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: - | 
| 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: - | 
| 192 | 
            +
                  hash: -2707032454598879538
         | 
| 193 193 | 
             
            requirements: []
         | 
| 194 194 | 
             
            rubyforge_project: 
         | 
| 195 195 | 
             
            rubygems_version: 1.8.23
         |