<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 26, 2016 at 12:39 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"><span class="">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 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 when<br>
> this happens.<br>
><br>
> But let's consider a simpler case: one guest with 1.5 Gb RAM, ubuntu 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 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 not<br>
> enough. I need to know how much the system has available, and just reading<br>
> the free memory statistic does not help much since that is only a 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>
</span>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>
</blockquote></div><br></div><div class="gmail_extra">I tried memoryBacking: I added this to the domain xml:</div><div class="gmail_extra"><memoryBacking></div><div class="gmail_extra">  <locked/></div><div class="gmail_extra"></memoryBacking></div><div class="gmail_extra"><br></div><div class="gmail_extra">And got an error when attempting to start the vm: memory locking no supported by QEMU binary. </div><div class="gmail_extra"><br></div><div class="gmail_extra">Aside from that I don't really understand how this helps solve my issue - if you don't mind going a bit into details I'd appreciate it.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks!</div><div class="gmail_extra">Andrei</div><div class="gmail_extra"><br></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>