<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 26, 2016 at 1:51 PM, Michal Privoznik <span dir="ltr"><<a href="mailto:mprivozn@redhat.com" target="_blank">mprivozn@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 26.01.2016 14:35, Andrei Perietanu wrote:<br>
> On Tue, Jan 26, 2016 at 12:39 PM, Michal Privoznik <<a href="mailto:mprivozn@redhat.com">mprivozn@redhat.com</a>><br>
> wrote:<br>
><br>
>> On 26.01.2016 12:30, Andrei Perietanu wrote:<br>
>>> Hi all,<br>
>>><br>
>>> I am running KVM on a 3.18 kernel. The system runs and Atom processor<br>
>> with<br>
>>> 2Gb RAM.<br>
>>><br>
>>> Using KVM you obviously can over allocate your resources: say you have 4<br>
>>> guests each configured with 1GB ram. Running all four at the same time,<br>
>>> depending on the workload, can crash the system - I get a kernel trace<br>
>> when<br>
>>> this happens.<br>
>>><br>
>>> But let's consider a simpler case: one guest with 1.5 Gb RAM, ubuntu<br>
>> 14.03.<br>
>>> During the installation the system will again crash.<br>
>>> The memory statistics (top or proc/meminfo) will show that the FreeMemory<br>
>>> goes down to 12Mb when this happens - which kind of makes sense<br>
>> considering<br>
>>> the host will require some RAM to run.<br>
>>><br>
>>> But the question is: does libvirt offer any way to prevent this from<br>
>>> happening?<br>
>>><br>
>>> Some way of not allowing the user to start a guest unless you have enough<br>
>>> free memory. I know how much ram each guest has configured but that is<br>
>> not<br>
>>> enough. I need to know how much the system has available, and just<br>
>> reading<br>
>>> the free memory statistic does not help much since that is only a<br>
>> snapshot<br>
>>> - when running a guest you can have 1gb free now, and 10 mb free 2 min<br>
>>> later.<br>
>>><br>
>>> Any ideas?<br>
>><br>
>> There is one option I see, use -mem-prealloc. Either you can passthrough<br>
>> it onto qemu commandline [1] or use locked memoryBacking [2]. I advocate<br>
>> for the latter though. Not only it will allocate all the memory at qemu<br>
>> startup it will also lock it so it won't get swapped off.<br>
>><br>
>> Michal<br>
>><br>
>> 1: <a href="http://libvirt.org/drvqemu.html#qemucommand" rel="noreferrer" target="_blank">http://libvirt.org/drvqemu.html#qemucommand</a><br>
>> 2: <a href="http://libvirt.org/formatdomain.html#elementsMemoryBacking" rel="noreferrer" target="_blank">http://libvirt.org/formatdomain.html#elementsMemoryBacking</a><br>
>><br>
><br>
> I tried memoryBacking: I added this to the domain xml:<br>
> <memoryBacking><br>
>   <locked/><br>
> </memoryBacking><br>
><br>
> And got an error when attempting to start the vm: memory locking no<br>
> supported by QEMU binary.<br>
><br>
> Aside from that I don't really understand how this helps solve my issue -<br>
> if you don't mind going a bit into details I'd appreciate it.<br>
><br>
<br>
</div></div>Well, it will make qemu to allocate all its memory on the start. So<br>
either the allocation would be successful and domain will run or it<br>
won't and qemu will die immediately.<br>
<br>
On the other hand, your kernel is heavily broken too. Instead of<br>
crashing at OOM it should kill a process (usually the one that's<br>
consuming the most memory => qemu in this case).<br>
<span class="HOEnZb"><font color="#888888"><br>
Michal<br>
</font></span></blockquote></div>Sorry, I said crashing; I meant it spits out a kernel trace. You can still use the system after it happens. I just want to prevent from happening in the first place.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Andrei</div></div>

<br>

        
        
        


<p><img src="http://www.klasonline.com/klas_telecom_email_sig_1_01.jpg"></p><p><span style="font-family:Arial;font-size:x-small">The information
transmitted is intended only for the person or entity to which it is
addressed and may contain confidential and/or privileged material.
Any review, retransmission, dissemination or other use of or taking
of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. If you
receive this in error please contact the sender and delete the
material from any computer immediately. It is the policy of Klas
 Limited to disavow the sending of offensive material and should
you consider that the material contained in the message is offensive
you should contact the sender immediately and also your I.T. Manager.</span></p><p><span style="font-family:Arial;font-size:x-small">Klas Telecom
Inc., a Virginia Corporation with offices at 1101 30th St. NW,
Washington, DC 20007.</span></p>
<p>
<font color="#000000"><font face="Arial"><font size="1">Klas Limited
(Company Number 163303) trading as Klas Telecom, an Irish Limited
Liability Company, with its registered office at Fourth Floor, One
Kilmainham Square, Inchicore Road, Kilmainham, Dublin 8, Ireland.</font></font></font></p>