[libvirt] [PATCH v3 3/3] qemu: add memfd source type

Michal Privoznik mprivozn at redhat.com
Thu Nov 15 13:55:19 UTC 2018


On 11/15/2018 12:55 PM, marcandre.lureau at redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau at redhat.com>
> 
> Add a new memoryBacking source type "memfd", supported by QEMU (when
> the capability is available).
> 
> A memfd is a specialized anonymous memory kind. As such, an anonymous
> source type could be automatically using a memfd. However, there are
> some complications when migrating from different memory backends in
> qemu (mainly due to the internal object naming at this point, but
> there could be more). For now, it is simpler and safer to simply
> introduce a new source type "memfd". Eventually, the "anonymous" type
> could learn to use memfd transparently in a separate change.
> 
> The main benefits are that it doesn't need to create filesystem files,
> and it also enforces sealing, providing a bit more safety.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
> ---
>  docs/formatdomain.html.in                     |  9 +--
>  docs/schemas/domaincommon.rng                 |  1 +
>  src/conf/domain_conf.c                        |  3 +-
>  src/conf/domain_conf.h                        |  1 +
>  src/qemu/qemu_command.c                       | 69 +++++++++++++------
>  src/qemu/qemu_domain.c                        | 12 +++-
>  .../memfd-memory-numa.x86_64-latest.args      | 34 +++++++++
>  tests/qemuxml2argvdata/memfd-memory-numa.xml  | 36 ++++++++++
>  tests/qemuxml2argvtest.c                      |  2 +
>  9 files changed, 140 insertions(+), 27 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
>  create mode 100644 tests/qemuxml2argvdata/memfd-memory-numa.xml
> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index 295f9ff93e..e7f4ad4060 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -1126,7 +1126,7 @@
>      </hugepages>
>      <nosharepages/>
>      <locked/>
> -    <source type="file|anonymous"/>
> +    <source type="file|anonymous|memfd"/>
>      <access mode="shared|private"/>
>      <allocation mode="immediate|ondemand"/>
>      <discard/>
> @@ -1177,9 +1177,10 @@
>          suitable for the specific environment at the same time to mitigate
>          the risks described above. <span class="since">Since 1.0.6</span></dd>
>         <dt><code>source</code></dt>
> -       <dd>Using the <code>type</code> attribute, it's possible to provide
> -         "file" to utilize file memorybacking or keep the default
> -         "anonymous".</dd>
> +       <dd>Using the <code>type</code> attribute, it's possible to
> +       provide "file" to utilize file memorybacking or keep the
> +       default "anonymous". <span class="since">Since 4.10.0</span>,
> +       you may choose "memfd" backing. (QEMU/KVM only)</dd>
>         <dt><code>access</code></dt>
>         <dd>Using the <code>mode</code> attribute, specify if the memory is
>           to be "shared" or "private". This can be overridden per numa node by
> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
> index cad189513a..bfa76c4db3 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -655,6 +655,7 @@
>                    <choice>
>                      <value>file</value>
>                      <value>anonymous</value>
> +                    <value>memfd</value>
>                    </choice>
>                  </attribute>
>                </element>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 6c15781dc0..bc82dc3504 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -898,7 +898,8 @@ VIR_ENUM_IMPL(virDomainDiskMirrorState, VIR_DOMAIN_DISK_MIRROR_STATE_LAST,
>  VIR_ENUM_IMPL(virDomainMemorySource, VIR_DOMAIN_MEMORY_SOURCE_LAST,
>                "none",
>                "file",
> -              "anonymous")
> +              "anonymous",
> +	      "memfd")

Ah, we don't use TABs rather spaces.

Michal




More information about the libvir-list mailing list