automatically starting KVM

Trent W. Buck trentbuck at gmail.com
Tue Dec 29 14:19:56 AEDT 2015


Russell Coker via luv-main
<luv-main at 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.)



More information about the luv-main mailing list