August 9, 201411 yr I created two scripts for stopping and starting libvirt with the array. They can be placed in /boot/config/plugins/ powerdown/rc.unRAID.d if you have powerdown or apcupsd plugins installed or directly in /etc/rc.d/rc.unRAID.d K00libvirt.sh #!/bin/bash # Stop libvirt and all domains /etc/rc.d/rc.libvirt stop S00libvirt.sh #!/bin/bash # Start or Restart libvirt and all domains set to autostart # It will move original libvirt files for you to new location if new location doesn't exist. # If you change location it will change symlink but you'll have to move the folder there yourself. # Change LVDIR=/etc/libvirt for basic startup and no persistant storage. Requires reboot if previously symlinked. # Change LVDIR=/your/own/path ie /mnt/cache/.libvirt and domains definitions and autostarts will survive reboot. # Make sure your path is cache only or hidden if on the cache drive. # From the command line you can use "virsh define your-vm.xml" to define VM's and "virsh autostart your-vm.xml" to set autostart for VM. LVDIR=/mnt/cache/.libvirt if [ -f /var/run/libvirt/libvirtd.pid ];then /etc/rc.d/rc.libvirt stop fi if [ $LVDIR != "/etc/libvirt" ];then if [ ! -L /etc/libvirt ];then if [ ! -e $LVDIR ];then mv /etc/libvirt $LVDIR else rm -r /etc/libvirt fi fi ln -sfT $LVDIR /etc/libvirt fi /etc/rc.d/rc.libvirt start EDIT: I changed my scripts a bit and symlinked the /etc/libvirt to my domain drive (could use cache drive if you wanted). After its started you can use virsh define your-domain-name.xml or just place your-domain-name.xml in your new .../libvirt/qemu location and virsh autostart your-domain-name virsh autostart won't work if you make the location the flash drive since virsh autostart creates a folder /libvirt/qemu/autostart and then symlinks domain from /libvirt/qemu. You can't make symlinks on fat32 file system. But you could probably just have a copy in both locations and it would work. I did this because I needed to edit some conf files in libvirt for remote domain management. If you uncomment "#listen_tcp = 1" in libvirtd.conf you can use tcp locally from another computer to manage your domains. Right now I'm using virt-manager on my laptop and webvirtmgr installed on unraid. Plus its useful for changing conf files for video card pass-through. EDIT2 updated script
August 11, 201411 yr I created two scripts for stopping and starting libvirt with the array. They can be placed in /boot/config/plugins/ powerdown/rc.unRAID.d if you have powerdown or apcupsd plugins installed or directly in /etc/rc.d/rc.unRAID.d K00libvirt.sh #!/bin/bash # Stop libvirt and all domains /etc/rc.d/rc.libvirt stop S00libvirt.sh #!/bin/bash # Start or Restart libvirt and all domains set to autostart # It will move original libvirt files for you to new location if new location doesn't exist. # If you change location it will change symlink but you'll have to move the folder there yourself. # Change LVDIR=/etc/libvirt for basic startup and no persistant storage. Requires reboot if previously symlinked. # Change LVDIR=/your/own/path ie /mnt/cache/.libvirt and domains definitions and autostarts will survive reboot. # Make sure your path is cache only or hidden if on the cache drive. # From the command line you can use "virsh define your-vm.xml" to define VM's and "virsh autostart your-vm.xml" to set autostart for VM. LVDIR=/mnt/cache/.libvirt if [ -f /var/run/libvirt/libvirtd.pid ];then /etc/rc.d/rc.libvirt stop fi if [ $LVDIR != "/etc/libvirt" ];then if [ ! -L /etc/libvirt ];then if [ ! -e $LVDIR ];then mv /etc/libvirt $LVDIR else rm -r /etc/libvirt fi fi ln -sfT $LVDIR /etc/libvirt fi /etc/rc.d/rc.libvirt start EDIT: I changed my scripts a bit and symlinked the /etc/libvirt to my domain drive (could use cache drive if you wanted). After its started you can use virsh define your-domain-name.xml or just place your-domain-name.xml in your new .../libvirt/qemu location and virsh autostart your-domain-name virsh autostart won't work if you make the location the flash drive since virsh autostart creates a folder /libvirt/qemu/autostart and then symlinks domain from /libvirt/qemu. You can't make symlinks on fat32 file system. But you could probably just have a copy in both locations and it would work. I did this because I needed to edit some conf files in libvirt for remote domain management. If you uncomment "#listen_tcp = 1" in libvirtd.conf you can use tcp locally from another computer to manage your domains. Right now I'm using virt-manager on my laptop and webvirtmgr installed on unraid. Plus its useful for changing conf files for video card pass-through. EDIT2 updated script +1 Dmacias - You are the man. Gonna set this up today. thx for figuring all that out!
August 12, 201411 yr Right now I'm using virt-manager on my laptop and webvirtmgr installed on unraid. Plus its useful for changing conf files for video card pass-through. Great job! You are welcome to contribute to the way you have done this when everything is tested. //Peter
August 13, 201411 yr I created two scripts for stopping and starting libvirt with the array. They can be placed in /boot/config/plugins/ powerdown/rc.unRAID.d if you have powerdown or apcupsd plugins installed or directly in /etc/rc.d/rc.unRAID.d K00libvirt.sh #!/bin/bash # Stop libvirt and all domains /etc/rc.d/rc.libvirt stop S00libvirt.sh #!/bin/bash # Start or Restart libvirt and all domains set to autostart # It will move original libvirt files for you to new location if new location doesn't exist. # If you change location it will change symlink but you'll have to move the folder there yourself. # Change LVDIR=/etc/libvirt for basic startup and no persistant storage. Requires reboot if previously symlinked. # Change LVDIR=/your/own/path ie /mnt/cache/.libvirt and domains definitions and autostarts will survive reboot. # Make sure your path is cache only or hidden if on the cache drive. # From the command line you can use "virsh define your-vm.xml" to define VM's and "virsh autostart your-vm.xml" to set autostart for VM. LVDIR=/mnt/cache/.libvirt if [ -f /var/run/libvirt/libvirtd.pid ];then /etc/rc.d/rc.libvirt stop fi if [ $LVDIR != "/etc/libvirt" ];then if [ ! -L /etc/libvirt ];then if [ ! -e $LVDIR ];then mv /etc/libvirt $LVDIR else rm -r /etc/libvirt fi fi ln -sfT $LVDIR /etc/libvirt fi /etc/rc.d/rc.libvirt start EDIT: I changed my scripts a bit and symlinked the /etc/libvirt to my domain drive (could use cache drive if you wanted). After its started you can use virsh define your-domain-name.xml or just place your-domain-name.xml in your new .../libvirt/qemu location and virsh autostart your-domain-name virsh autostart won't work if you make the location the flash drive since virsh autostart creates a folder /libvirt/qemu/autostart and then symlinks domain from /libvirt/qemu. You can't make symlinks on fat32 file system. But you could probably just have a copy in both locations and it would work. I did this because I needed to edit some conf files in libvirt for remote domain management. If you uncomment "#listen_tcp = 1" in libvirtd.conf you can use tcp locally from another computer to manage your domains. Right now I'm using virt-manager on my laptop and webvirtmgr installed on unraid. Plus its useful for changing conf files for video card pass-through. EDIT2 updated script Awesome scripts dmacias! I am also looking forward to seeing how you got virt-manager up and working when you're ready to share. Question about the autostart .xml; to remove them from autostarting on boot, is it as simple as deleting the .xml file from /libvirt/qemu/autostart? or is there a virsh command that will do this?
August 14, 201411 yr I created two scripts for stopping and starting libvirt with the array. They can be placed in /boot/config/plugins/ powerdown/rc.unRAID.d if you have powerdown or apcupsd plugins installed or directly in /etc/rc.d/rc.unRAID.d K00libvirt.sh #!/bin/bash # Stop libvirt and all domains /etc/rc.d/rc.libvirt stop S00libvirt.sh #!/bin/bash # Start or Restart libvirt and all domains set to autostart # It will move original libvirt files for you to new location if new location doesn't exist. # If you change location it will change symlink but you'll have to move the folder there yourself. # Change LVDIR=/etc/libvirt for basic startup and no persistant storage. Requires reboot if previously symlinked. # Change LVDIR=/your/own/path ie /mnt/cache/.libvirt and domains definitions and autostarts will survive reboot. # Make sure your path is cache only or hidden if on the cache drive. # From the command line you can use "virsh define your-vm.xml" to define VM's and "virsh autostart your-vm.xml" to set autostart for VM. LVDIR=/mnt/cache/.libvirt if [ -f /var/run/libvirt/libvirtd.pid ];then /etc/rc.d/rc.libvirt stop fi if [ $LVDIR != "/etc/libvirt" ];then if [ ! -L /etc/libvirt ];then if [ ! -e $LVDIR ];then mv /etc/libvirt $LVDIR else rm -r /etc/libvirt fi fi ln -sfT $LVDIR /etc/libvirt fi /etc/rc.d/rc.libvirt start EDIT: I changed my scripts a bit and symlinked the /etc/libvirt to my domain drive (could use cache drive if you wanted). After its started you can use virsh define your-domain-name.xml or just place your-domain-name.xml in your new .../libvirt/qemu location and virsh autostart your-domain-name virsh autostart won't work if you make the location the flash drive since virsh autostart creates a folder /libvirt/qemu/autostart and then symlinks domain from /libvirt/qemu. You can't make symlinks on fat32 file system. But you could probably just have a copy in both locations and it would work. I did this because I needed to edit some conf files in libvirt for remote domain management. If you uncomment "#listen_tcp = 1" in libvirtd.conf you can use tcp locally from another computer to manage your domains. Right now I'm using virt-manager on my laptop and webvirtmgr installed on unraid. Plus its useful for changing conf files for video card pass-through. EDIT2 updated script Awesome scripts dmacias! I am also looking forward to seeing how you got virt-manager up and working when you're ready to share. Question about the autostart .xml; to remove them from autostarting on boot, is it as simple as deleting the .xml file from /libvirt/qemu/autostart? or is there a virsh command that will do this? Yes, if created with "virsh autostart" it's just a symlink to the xml in /libvirt/qemu. You can just delete them in autostart. For virt-manager it's as simple as uncommenting the "listen_tcp = 1" in libvirtd.conf then restarting libvert. You can either start and stop the array if using the scripts or run "/etc/rc.d/rc.libvirt restart". Then connect to unraid with virt-manager through tcp connection using, well root is all I tested but maybe other user creds work. What I was working on was maybe a plugin for webvirtmgr to run on unraid. It's a python based libvirt manager. You just connect to your unraid server on whatever port you run it on. I have it working but just have to finish a plugin and figure how to daemonize it, maybe with python daemon. Edit. I also use VM Manager on android. But it's not very sophisticated. So if someone knows a better android app let me know.
August 14, 201411 yr So... I noticed that the /libvirt/qemu folders were on both my cache drive and disk 1 drive by mistake. I forgot to make the libvirt folder cache only. I changed the folder settings to cache only and I decided to delete the contents of the libvirt/qemu folder of disk 1 (without making a backup of the files first... ). I restarted and figured that the libvirt files would be linked to the cache drive now; however, it would seem that I deleted the contents and they do not come back on a reboot. I get this message on a reboot: Aug 14 10:41:55 Pithos rc.unRAID[7081][7089]: 2014-08-14 15:41:55.955+0000: 7172: error : main:1261 : Can't load config file: Failed to open file '/etc/libvirt/libvirtd.conf': No such file or directory: /etc/libvirt/libvirtd.conf How do I get those files back?
August 14, 201411 yr OK, I installed unRAID on a new flash drive and copied the libvirt folder back to my original flash drive. Everything seems to be working again.
August 14, 201411 yr You could have changed the script to lvdir=/etc/libvirt and rebooted. Then it wouldn't remove it on boot. I think I modify it to copy those files if they don't exist first
September 25, 201411 yr Can't seem to get this to work. Using KVM to run a Windows 8.1 Virtual Machine. -Have latest version of Powerdown installed -Copied scripts and placed K00libvirt.sh S00libvirt.sh in /boot/config/plugins/ powerdown/rc.unRAID.d -Created Cache only share /mnt/cache/.libvirt -Edited changed lvdir=/mnt/cache/.libvirt -ran Virsh define /mnt/cache/Win81.xml (this is where my domain file is stored) Not seeing any new files in /mnt/cache/.libvirt and the VM doesn't autostart (put vfio-bind command in my go script) Any help or thoughts are greatly appreciated, trying to make this VM more wife friendly if I'm not home and she ever needs to restart the server which is doubling as a Win 8.1 desktop at the moment..
September 25, 201411 yr Check out the virtman.plg I put together in the webvirtmgr thread. http://lime-technology.com/forum/index.php?topic=35136.0#
September 26, 201411 yr Yes I created a small image on the unraid flash drive and mount to the default location for libvirt (/etc/libvirt ). All your xml files, storage locations and libvirt conf files will be saved to this image and reloaded on boot. Also on libvirt or array stop and restart.
September 27, 201411 yr If I have WebVirtMgr installed and set to autostart my VM, will that work? Or do I need to do it via the script? I did put the kill script into /boot/config/plugins/powerdown/rc.unRAID.d/
September 28, 201411 yr If I have WebVirtMgr installed and set to autostart my VM, will that work? Or do I need to do it via the script? I did put the kill script into /boot/config/plugins/powerdown/rc.unRAID.d/ No if you reboot it will be lost. You have to have the virtman plg installed too or symlink /etc/libvirt to another location via a script. Just not to the flash drive. The vm xml files are stored in /etc/libvirt/qemu with a symlink in /etc/libvirt/qemu/auto.
September 28, 201411 yr No if you reboot it will be lost. You have to have the virtman plg installed too or symlink /etc/libvirt to another location via a script. Just not to the flash drive. The vm xml files are stored in /etc/libvirt/qemu with a symlink in /etc/libvirt/qemu/auto. Oh, sorry. I do have virtman as well as WebVirtMgr installed. I did end up rebooting just to try it and my VM did auto-start. Do you have the array auto-start as well?
September 28, 201411 yr That's included with beta 9 libvirt auto starts/stops with the array. I believe in beta 10 that won't be the case and I have an updated version for beta 10. If you edit any files manually in /etc/libvirt you have to restart libvirt for changes to take effect. If you edit through webvirtmgr you just have to restart the edited vm.
September 28, 201411 yr No if you reboot it will be lost. You have to have the virtman plg installed too or symlink /etc/libvirt to another location via a script. Just not to the flash drive. The vm xml files are stored in /etc/libvirt/qemu with a symlink in /etc/libvirt/qemu/auto. Oh, sorry. I do have virtman as well as WebVirtMgr installed. I did end up rebooting just to try it and my VM did auto-start. Do you have the array auto-start as well? You'll need to remove virtman then add the virtMan plugin for beta 10. It's uses a different repo and name. Just copy and paste in plugin menu/install plugin, then install https://raw.githubusercontent.com/dmacias72/virtMan/master/virtMan.plg
September 28, 201411 yr You'll need to remove virtman then add the virtMan plugin for beta 10. It's uses a different repo and name. Just copy and paste in plugin menu/install plugin, then install https://raw.githubusercontent.com/dmacias72/virtMan/master/virtMan.plg You mean remove the current "Libvirt Support" from the Plugins directory, then reinstall it? I've rebooted in b10 w/o any issues. (just fyi)
September 28, 201411 yr You'll need to remove virtman then add the virtMan plugin for beta 10. It's uses a different repo and name. Just copy and paste in plugin menu/install plugin, then install https://raw.githubusercontent.com/dmacias72/virtMan/master/virtMan.plg You mean remove the current "Libvirt Support" from the Plugins directory, then reinstall it? I've rebooted in b10 w/o any issues. (just fyi) Yes but reinstall from the virtMan link. I included instructions in the webvirtmgr thread too. The previous version didn't have any array event start/stop. unRAID had it built in. In version 10 it was removed. Which makes sense for those that don't run vm's, don't want libvirt running. Just like I don't use docker and don't want it running.
September 28, 201411 yr I assume this is ok.. I clicked the remove, then installed using the URL in the plugin install box. Directory already existed. /usr/local/sbin/plugin install https://raw.githubusercontent.com/dmacias72/virtMan/master/virtMan.plg 2>&1 plugin: installing: https://raw.githubusercontent.com/dmacias72/virtMan/master/virtMan.plg plugin: downloading https://raw.githubusercontent.com/dmacias72/virtMan/master/virtMan.plg Warning: mkdir(): File exists in /usr/local/emhttp/plugins/plgMan/plugin on line 146 plugin: creating: /boot/config/plugins/virtMan/virtMan-2014.09.28.tar.gz - downloading from URL "https://github.com/dmacias72/virtMan/archive/2014.09.28.tar.gz" Warning: mkdir(): File exists in /usr/local/emhttp/plugins/plgMan/plugin on line 146 plugin: running: 'anonymous' mv: cannot move '/boot/config/plugins/virtman' to a subdirectory of itself, '/boot/config/plugins/virtMan/virtman' mv: '/boot/config/plugins/virtMan/virtman.img' and '/boot/config/plugins/virtMan/virtMan.img' are the same file mv: '/boot/config/plugins/virtMan/virtman.cfg' and '/boot/config/plugins/virtMan/virtMan.cfg' are the same fileplugin: installed Edit Sorry if I'm dense... This will allow me to remove my libvir start line from my go script? # Startup libvirt for beta 10 /etc/rc.d/rc.libvirt start
Archived
This topic is now archived and is closed to further replies.