automatically starting KVM

To run KVM virtual machines it seems to be recommended to un virsh which requires XML. Just having XML isn't necessarily a bad thing (XML is great for machine=>machine communication) but apparently you have to edit it yourself! I've editited XML by hand before and written scripts to do it back when I was working on clustering software which also had the flaw of requiring XML but provided no automated way of creating it. Getting KVM working from the command line is easy enough (for definitions of easy that include a 500 character command). But how do you start it on boot and keep it running? I'm currently using screen to manage KVM sessions and it's not that difficult to script screen to start on boot, but it's a little ugly. Any better ideas? PS A recent update to Xen on Debian resulted in SATA disks not working correctly on one of my systems. If we weren't going to move LUV hosting to another location then I'd convert the LUV server to KVM to avoid the risk of SAS disks having a similar issue. -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/

On Thu, Dec 24, 2015 at 01:07:50PM +1100, Russell Coker via luv-main wrote:
I've editited XML by hand before and written scripts to do it back when I was working on clustering software which also had the flaw of requiring XML but provided no automated way of creating it.
virsh has many subcommands for manipulating the XML files, as well as just editing them in $EDITOR
Getting KVM working from the command line is easy enough (for definitions of easy that include a 500 character command). But how do you start it on boot and keep it running?
on debian, install the libvirt packages libvirt-bin, libvirt-clients, libvirt-daemon, libvirt-daemon-system and libvirt-doc would be similar on other distros. craig -- craig sanders <cas@taz.net.au>

Russell Coker via luv-main <luv-main@luv.asn.au> wrote:
To run KVM virtual machines it seems to be recommended to un virsh which requires XML.
I've run kvm guests directly, without virsh installed, while also managing them from the console. Thus, whether you actually need virsh depends on your requirements and environment.

On Wed, 23 Dec 2015 21:18:39 -0500 Jason White via luv-main <luv-main@luv.asn.au> wrote:
Russell Coker via luv-main <luv-main@luv.asn.au> wrote:
To run KVM virtual machines it seems to be recommended to un virsh which requires XML.
I've run kvm guests directly, without virsh installed, while also managing them from the console. Thus, whether you actually need virsh depends on your requirements and environment.
What you are saying is true, But inmho, virsh give you far more control over the VM (eg: snapshots, connecting devices live etc). While you may be able to do the same without virsh, using it to me is much easier, specially if you are doing it remotely. Cheers, Daniel
_______________________________________________ luv-main mailing list luv-main@luv.asn.au http://lists.luv.asn.au/listinfo/luv-main
-- dan062 <dan062@yahoo.com.au>

On 24/12/15 13:07, Russell Coker via luv-main wrote:
To run KVM virtual machines it seems to be recommended to un virsh which requires XML. Just having XML isn't necessarily a bad thing (XML is great for machine=>machine communication) but apparently you have to edit it yourself!
There's virt-console - obviously not the sort of thing you can do automation with, but it will let you quickly build and manage VMs, and gives you access to the most important settings. I'm not doing anything out of the ordinary with my home VMs and I don't think I've ever needed to manually adjust any of the XML files that it has generated. I can't really see a lot of reason to not use libvirt. It gives you a widely-supported interface, so that any code you write to control your VMs will also work if you use Xen, ESX, Virtualbox or even LXC (amongst others), as well as a good range of languages to write interfaces in. I did a quick apt-cache search for kvm and python/ruby and only found libraries that used libvirt, and no kvm-specific libs. While I'm sure there's someone out there who is writing APIs to control kvm directly in those languages, if people are only bothering to package the libvirt interfaces, it suggests to me that's where the support lies. Cheers, Paul

Russell Coker via luv-main <luv-main@luv.asn.au> writes:
Getting KVM working from the command line is easy enough (for definitions of easy that include a 500 character command). But how do you start it on boot and keep it running?
The same way you start any daemon? i.e. in rc.local, or sysvinit, or daemontools, or a systemd unit, or whatever.
I'm currently using screen to manage KVM sessions and it's not that difficult to script screen to start on boot, but it's a little ugly. Any better ideas?
I assume the implicit difference is that you want to interact with the KVM instance over stdio afterward --- in which case, tell KVM to connect stdio to a FIFO. An easy way to see how this is done is to look at an existing virtd instance, the exact KVM command is in /var/log/libvirt/qemu/<container>.log or so. IIRC it's kinda icky. Hrm... this bit? -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/vapid.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control Or is that the Alt+3 bit of kvm -curses? I also see this: -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 There's also a -serial stdio, but I had trouble using it the other day (I fell back to -nographics, which treats ^A specially.)
participants (6)
-
Craig Sanders
-
Dan062
-
Jason White
-
Paul Dwerryhouse
-
Russell Coker
-
trentbuck@gmail.com