[libvirt] [PATCH 1/2] Add support for preallocated memory - parse xml

Daniel P. Berrange berrange at redhat.com
Tue Jun 28 09:49:16 UTC 2016


On Thu, Jun 23, 2016 at 01:25:28PM +0100, Jaroslav Safka wrote:
> Add three new elements in memoryBacking and
> enable their parsing.
> (without converting to argv yet)
> 
> <memoryBacking>
>   <source type="file|anonymous"/>
>   <access Mode="shared|private"/>
>   <allocation mode="immediate|ondemand"/>
> </memoryBacking>

This is all fine since it matches what we discussed previously in
the context of Nova. For benefit of others, here is the thinking
behind this.

QEMU has ability to map guest memory anonymously (the default) or
via a file. Libvirt only exposes the ability to use a file when
dealing with huge pages. Nova wants ability to use a file with
non-hugepage memory, eg a plain /dev/shm file.

IOW, huge pages implies source type=file, but source type=file
does not imply huge pages - it could be /dev/hugepages or /dev/shm

Requiring anonymous with hugepages is an error scenario.

When configuring NUMA we have ability to mark the memory as shared,
vs private. eg

    <numa>
      ...
      <cell id='1' cpus='4-7' memory='512000' unit='KiB' memAccess='shared'/>
      ...
    </numa>

The <access mode=shared|private> gives us ability to control this
for the VM as a whole, without defining NUMA.  The per-cell
setting should override this if present. Conversely, <cell> with no
memAccess attribute should use the <access mode=> top level setting.

Finally QEMU has ability to allocate guest pages on-demand (when
the guest first touches a page) or immediate (guaranteed fully
reserved upfront). Use of huge pages implies "immediate" mode
since huge pages are not swappable or overcommittable.  In the
non-huge page case though, we don't have a way to request
immedate allocate, so this is adding it.

Requiring allocate=ondemand in combination with hugepages is
an error scenario.


> ---
>  docs/schemas/domaincommon.rng                      | 45 +++++++++++++++++
>  src/conf/domain_conf.c                             | 59 +++++++++++++++++++++-
>  src/conf/domain_conf.h                             | 31 ++++++++++++

Also need to update docs/formatdomain.html.in to document this.


>  .../qemuxml2argv-memorybacking-set.args            | 22 ++++++++
>  .../qemuxml2argv-memorybacking-set.xml             | 32 ++++++++++++
>  .../qemuxml2argv-memorybacking-unset.args          | 22 ++++++++
>  .../qemuxml2argv-memorybacking-unset.xml           | 32 ++++++++++++
>  .../qemuxml2xmlout-memorybacking-set.xml           | 40 +++++++++++++++
>  .../qemuxml2xmlout-memorybacking-unset.xml         | 40 +++++++++++++++
>  tests/qemuxml2xmltest.c                            |  3 ++

The QEMU test suite additions should be in the patch that adds the
code to the QEMU driver.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list