DeeR Posted March 11, 2019 Share Posted March 11, 2019 Hi all, Is there a way to schedule a script run when a specific VM starts up ? Quote Link to comment
JonathanM Posted March 11, 2019 Share Posted March 11, 2019 Yes. Parse the output of virsh list and when the VM in question changes to running, run the desired action. Probably need to think through timing and retriggering. There may be other better methods, but it's definitely possible to accomplish what you want, given the tools available right now. Quote Link to comment
DeeR Posted March 12, 2019 Author Share Posted March 12, 2019 Hi Jonathanm Thanks for the reply, could you give me abit more detail into how to parse the virsh list? Is there an unraidy way? Or just a cron a script ? That checks previous state, etc.. Quote Link to comment
JesterEE Posted May 19, 2019 Share Posted May 19, 2019 I had the same question when Googling around today. After reading @jonathanm's response, I investigated and found this: https://libvirt.org/hooks.html which looks promising! I am interested in the possibility of releasing hardware from other processes (i.e. dockers) I want to provide to a VM, but leave available when not in use. I don't have an UnRaid server (contemplating the migration) so I am interested if this works with the current build of the OS. Care to check and report back @DeeR? -JesterEE Quote Link to comment
Goobaroo Posted August 25, 2021 Share Posted August 25, 2021 This isn't the most elegant solution but it works for me. I wanted to run a script when my VM started up to switch the scaling_governor from ondemand to performance when my gaming VM was running. I took @JonathanMs suggestion to use virsh list. Then setup a User Script to run every 5 minutes. If all the settings are already right, it does nothing, otherwise it will update the system. You can see the script here: https://github.com/Goobaroo/unraid-setCPUgovernor Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.