Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
qemu: handle unix sockets conditions
Browse files Browse the repository at this point in the history
(Not-so-)gracefully...
  • Loading branch information
gderosa committed Nov 27, 2013
1 parent 76a8cb9 commit a631509
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions modules/qemu/controller/virtualization/qemu.rb
Expand Up @@ -6,6 +6,12 @@ class OnBoard

class Controller < Sinatra::Base

before do
if request.path_info =~ /^\/virtualization\/qemu/
Virtualization::QEMU.cleanup
end
end

get '/virtualization/qemu.:format' do
format(
:module => 'qemu',
Expand Down
15 changes: 15 additions & 0 deletions modules/qemu/lib/onboard/virtualization/qemu/instance.rb
Expand Up @@ -273,6 +273,19 @@ def prepare_pci_passthrough
end

def start(*opts)
# WARNING: opts is also a sugar method of this class...

QEMU.cleanup

# Circumvent a possible QEMU bug (as of 1.6.1) when a USB device
# is passed-through. (assertion failed)
unless opts.include? :paused
if @config.cmd['opts']['-loadvm']
start :paused, *opts
drives # a way to wait for QMP/Monitor sockets ready
resume
end
end

# Auto-update from previous versions' configs
# which didn't use QMP.
Expand Down Expand Up @@ -395,6 +408,8 @@ def drives
@cache['block_json'] ||= @qmp.execute 'query-block'
qmp_data = JSON.load @cache['block_json']
qmp_return = qmp_data['return']

return {} unless qmp_return

# Compatibility with the old return value of this method
# (which has been based on "human-redable" monitor...)
Expand Down
3 changes: 2 additions & 1 deletion modules/qemu/lib/onboard/virtualization/qemu/monitor/qmp.rb
Expand Up @@ -28,7 +28,8 @@ def execute(command, arguments={})
sleep pause
retry
else
raise
LOGGER.error $!
return JSON.dump({'error' => {'message' => $!}})
end
end
end
Expand Down

0 comments on commit a631509

Please sign in to comment.