Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update driver.rb stop method to wait for response after send shutdown (only control port) #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sekizsonsuz
Copy link

@sekizsonsuz sekizsonsuz commented Jul 7, 2024

Added wait for prompt "(qemu) " text on QEMU Monitor console when stopping vm after send shutdown command.

Only control_port implementation (which need to be used in Windows) is changed. I don't have a Mac to test it so didn't touch Mac/Unix socket implementation.
Same solution may work on Mac/Unix socket implementation.

I used IO Class, gets Method with sep (Separator) Argument.

https://ruby-doc.org/3.2.2/IO.html#method-i-gets

I was having this error every time I stop (halt) machine:

==> default: Stopping the instance...
C:/Users/user/.vagrant.d/gems/3.1.3/gems/vagrant-qemu-0.3.6/lib/vagrant-qemu/driver.rb:142:in read': 
An existing connection was forcibly closed by the remote host. (Errno::ECONNRESET)
        from C:/Users/user/.vagrant.d/gems/3.1.3/gems/vagrant-qemu-0.3.6/lib/vagrant-qemu/driver.rb:142:in block in stop'
        from C:/Vagrant/embedded/mingw64/lib/ruby/3.1.0/socket.rb:659:in tcp'
        from C:/Users/user/.vagrant.d/gems/3.1.3/gems/vagrant-qemu-0.3.6/lib/vagrant-qemu/driver.rb:139:in stop'
        from C:/Users/user/.vagrant.d/gems/3.1.3/gems/vagrant-qemu-0.3.6/lib/vagrant-qemu/action/stop_instance.rb:16:in call'

I used "(qemu) " as prompt text (with an ending space) because qemu monitor source code also use same text:

https://github.com/qemu/qemu/blob/master/monitor/hmp.c#L57

readline_start(mon->rs, "(qemu) ", 0, monitor_command_cb, NULL);

Tested with:
vagrant 2.3.8
vagrant-qemu 0.3.6
host windows 11
qemu MINGW64 mingw-w64-x86_64-qemu 9.0.0-1
vagrantfile centos-7 example in project readme

add wait for prompt on QEMU Monitor console when stopping vm (only windows implementation is changed)
@sekizsonsuz sekizsonsuz changed the title Update driver.rb stop method to wait for response after send shutdown (only windows) Update driver.rb stop method to wait for response after send shutdown (only control port) Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant