<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>RE: [Libvir] PATCH: Create a logfile for each QEMU vm</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>"If QEMU fails during startup" ... please tell me how to start QEMU as a service!<BR>
<BR>
Thanks, smoyer<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: libvir-list-bounces@redhat.com on behalf of Daniel P. Berrange<BR>
Sent: Tue 5/15/2007 6:27 PM<BR>
To: Mark McLoughlin<BR>
Cc: libvir-list@redhat.com<BR>
Subject: Re: [Libvir] PATCH: Create a logfile for each QEMU vm<BR>
<BR>
On Tue, May 15, 2007 at 06:37:40PM +0100, Daniel P. Berrange wrote:<BR>
> On Tue, May 15, 2007 at 05:15:04PM +0100, Daniel P. Berrange wrote:<BR>
> > On Tue, May 15, 2007 at 05:09:56PM +0100, Mark McLoughlin wrote:<BR>
> > > On Tue, 2007-05-15 at 17:04 +0100, Daniel P. Berrange wrote:<BR>
> > ><BR>
> > > > For every VM we start it will create a logfile<BR>
> > > ><BR>
> > > >   /etc/libvirt/qemu/logs/[vmname].log<BR>
> > ><BR>
> > >   Why not /var/log? /etc/ isn't the place for this kind of stuff, surely.<BR>
> ><BR>
> > True - though we'd have to code different behaviour when running as an<BR>
> > unprivileged user. Shouldn't complicate things too much i guess.<BR>
><BR>
> Attached a new version which does this. If using qemu:///system they get<BR>
> put into /var/log/libvirt/qemu, while if using qemu://session they go into<BR>
> $HOME/.libvirt/qemu/log<BR>
<BR>
Ok, attached is my final version.<BR>
<BR>
 - qemu:///system per-VM logs are created in /var/log/libvirt/qemu/[vmname].log<BR>
<BR>
 - qemu:///session per-VM logs are created in $HOME/.libvirt/qemu/log/[vmname].log<BR>
<BR>
 - The exact QEMU command line argv is logged in aforementioned files<BR>
<BR>
 - All data written to stderr/out by QEMU is logged in aforementioned files<BR>
<BR>
 - There is a qemudValidateConfig() method we call before starting a VM which<BR>
   checks the path for kernel, initrd, each disk, and any script given for<BR>
   a network device setup.<BR>
<BR>
 - The horrible 'End-of-file while reading PTY startup output' is replaced<BR>
   with less horrible 'QEMU quit during console startup'. Though I might<BR>
   reword that a little more<BR>
<BR>
 - If QEMU fails during startup, we capture the contents of stderr and<BR>
   include them in the libvirt error message reported. I'm not entirely<BR>
   happy with this because this can make messages quite verbose, but at<BR>
   the same time we really need to feed this info back to the user. This<BR>
   is even more important with remote management where there's no easy<BR>
   access to log files.<BR>
<BR>
So, here's some examples:<BR>
<BR>
<BR>
 - Starting a guest with mem set to 8 G - in this case QEMU provides zero<BR>
   useful error message, so we get the generic:<BR>
<BR>
    # virsh --connect qemu:///system start wizz<BR>
    libvir: QEMU error : internal error QEMU shutdown while reading console startup output<BR>
    error: Failed to start domain wizz<BR>
<BR>
 - Starting a guest with mem set to 1.9 G - this this case there is not<BR>
   enough free ram:<BR>
<BR>
   # virsh --connect qemu:///system start wizz<BR>
   libvir: QEMU error : internal error QEMU shutdown while reading console startup output<BR>
   You do not have enough space in '/dev/shm' for the 1503 MB of QEMU virtual RAM.<BR>
   To have more space available provided you have enough RAM and swap, do as root:<BR>
   umount /dev/shm<BR>
   mount -t tmpfs -o size=1519m none /dev/shm<BR>
   Or disable the accelerator module with -no-kqemu<BR>
   error: Failed to start domain wizz<BR>
<BR>
 - Starting a guest with a disk which doesn't exist:<BR>
<BR>
   # virsh --connect qemu:///system start wizz<BR>
   libvir: QEMU error : internal error Cannot access disk hda at /home/berrange/src/xen/virtinst--devel/demo2: No such file or directory<BR>
   error: Failed to start domain wizz<BR>
<BR>
<BR>
<BR>
Regards,<BR>
Dan.<BR>
--<BR>
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|<BR>
|=-           Perl modules: <A HREF="http://search.cpan.org/~danberr/">http://search.cpan.org/~danberr/</A>              -=|<BR>
|=-               Projects: <A HREF="http://freshmeat.net/~danielpb/">http://freshmeat.net/~danielpb/</A>               -=|<BR>
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=|<BR>
<BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>