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

feat: Please add an option to kill the VM from the command line #1195

Closed
popey opened this issue May 10, 2024 · 5 comments
Closed

feat: Please add an option to kill the VM from the command line #1195

popey opened this issue May 10, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@popey
Copy link
Collaborator

popey commented May 10, 2024

Expected behavior

Sometimes I would like to kill the VM I started without using extreme prejudice (killall). This is especially useful when running quickemu with a headless guest.

Actual behavior

I brutally kill things for fun using sudo killall which my mum says is a bad thing to do.

Thanks

@philclifford
Copy link
Contributor

philclifford commented May 10, 2024

Non-brutes might connect to the monitor with something like socat -,echo=0,icanon=0 unix-connect:alpine-latest/alpine-latest-monitor.socket and type system_powerdown (or if feeling suddenly brutal then quit)

It should be easy enough to wrap that behaviour into a quickemu option.
I'd go for something where you could chose 3 options:

  • restart - sends system_reset
  • shutdown - sends system_powerdown or
  • kill - sends quit (and if that fails kill the pid)

Would that seem OK to you ?

@philclifford
Copy link
Contributor

philclifford commented May 10, 2024

hang on - quickemu --vm alpine-latest.conf --monitor-cmd system-powerdown used to be a way to do that I think. It's an option example in the man page, but now tries to run the vm again using the same disk and fails (if the vm is up). Maybe this missing feature is a bug...

@flexiondotorg flexiondotorg added enhancement New feature or request good first issue Good for newcomers labels May 10, 2024
@popey
Copy link
Collaborator Author

popey commented May 10, 2024

Already tried this.

I spun up a VM and then just manually connected to the VM using the monitor with netcat and qemu recognises but simply ignores the system_powerdown command. I think it's broken in Qemu https://gitlab.com/qemu-project/qemu/-/issues/1410

So, quickemu knows the pid, and could implement a --kill which just kill -9's the vm

@philclifford
Copy link
Contributor

curious: system_powerdown works fine here (I tried all three options before suggesting with expected results - on 22.04 not 24.04 though ...)

looking at Martin's PR I see what's changed and broken --monitor-cmd : the disk image check always happens so it tries to check an in-use image and fails.

@popey
Copy link
Collaborator Author

popey commented May 11, 2024

FWIW, I also tested with Alpine Linux, thinking this was simpler. I can't get any distro to power off using the qemu monitor command system_powerdown

@flexiondotorg flexiondotorg self-assigned this May 11, 2024
philclifford pushed a commit to philclifford/quickemu that referenced this issue May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Done
Development

No branches or pull requests

3 participants