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

Best way to shutdown VM? #209

Open
kanav99 opened this issue Jan 13, 2021 · 2 comments
Open

Best way to shutdown VM? #209

kanav99 opened this issue Jan 13, 2021 · 2 comments

Comments

@kanav99
Copy link

kanav99 commented Jan 13, 2021

I am writing a wrapper over xhyve in swift, where I have given setuid to the xhyve binary (!!) and run the Ubuntu VM on a button click. Now I want to shut down the VM. Options -

  1. Make a root user and set its ssh shell to poweroff. But this can be exploited by any other applications.
  2. Run kill - nope, because I don't want to give setuid to a binary that can kill
  3. SIGINT - Not graceful
  4. Simulating Ctrl + SysRq + o - how do I do this?

I want to do a safe shutdown - what should be the best way?

@TimDaub
Copy link

TimDaub commented Feb 10, 2021

I'm also wondering how to do this. I usually use halt when I was successful in booting the machine. But for machines that are broken, I always have to shut down the process manually somehow.

@jacobvosmaer
Copy link

Inside a VM I use halt. Outside the VM, you can use SIGTERM. That gets translated into a "power button" press, and that typically triggers an OS shutdown.

xhyve/src/pm.c

Line 273 in 83516a0

power_button = mevent_add(SIGTERM, EVF_SIGNAL,

Note that if the xhyve process runs as root, you need to also send SIGTERM as root.

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

No branches or pull requests

3 participants