[libvirt] [PATCH 1/3] Add support for preallocated fd memory

Martin Kletzander mkletzan at redhat.com
Fri Nov 25 14:51:23 UTC 2016


On Tue, Nov 01, 2016 at 12:11:14PM +0000, Jaroslav Safka wrote:
>This first change introduces xml parsing support for preallocated
>shared file descriptor based memory backing.
>It allows vhost-user to be used without hugepages.
>
>New xml elements:
><memoryBacking>
>  <source type='file|anonymous'/>
>  <access mode='shared|private'/>
>  <allocation mode='immediate|ondemand'/>
></memoryBacking>
>---
> docs/schemas/domaincommon.rng                      |  30 +++++
> src/conf/domain_conf.c                             | 138 ++++++++++++++++-----
> src/conf/domain_conf.h                             |  33 +++++
> .../qemuxml2xmlout-memorybacking-set.xml           |  40 ++++++
> .../qemuxml2xmlout-memorybacking-unset.xml         |  40 ++++++
> tests/qemuxml2xmltest.c                            |   3 +
> 6 files changed, 251 insertions(+), 33 deletions(-)
> create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-memorybacking-set.xml
> create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-memorybacking-unset.xml
>

Tests will fail after this patch, the source files for the tests are missing.

>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index 03506cb..97ef769 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -830,6 +830,21 @@ VIR_ENUM_IMPL(virDomainDiskMirrorState, VIR_DOMAIN_DISK_MIRROR_STATE_LAST,
>               "abort",
>               "pivot")
>
>+VIR_ENUM_IMPL(virDomainMemorySource, VIR_DOMAIN_MEMORY_SOURCE_LAST,
>+              "none",
>+              "file",
>+              "anonymous")
>+
>+VIR_ENUM_IMPL(virDomainMemoryAccess, VIR_DOMAIN_MEMORY_ACCESS_LAST,
>+              "none",
>+              "shared",
>+              "private")
>+

This is the same as virNumaMemAccess from numa_conf.c, you should change that
one to this type so it's not duplicated.

>+VIR_ENUM_IMPL(virDomainMemoryAllocation, VIR_DOMAIN_MEMORY_ALLOCATION_LAST,
>+              "none",
>+              "immediate",
>+              "ondemand")
>+
> VIR_ENUM_IMPL(virDomainLoader,
>               VIR_DOMAIN_LOADER_TYPE_LAST,
>               "rom",
>diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
>index 24aa79c..f50b575 100644
>--- a/src/conf/domain_conf.h
>+++ b/src/conf/domain_conf.h
>@@ -567,6 +567,32 @@ typedef enum {
>     VIR_DOMAIN_DISK_MIRROR_STATE_LAST
> } virDomainDiskMirrorState;
>
>+# define VIR_DOMAIN_MEMORY_DEFAULT_PATH "/var/lib/libvirt/qemu"
>+

This is wrong.  You should use domain's priv->libDir which is per-domain
directory which is properly labelled and configurable.  Also it is
handled so that it works on upgrades, etc.

>+typedef enum {
>+    VIR_DOMAIN_MEMORY_SOURCE_NONE = 0,  /* No memory source defined */
>+    VIR_DOMAIN_MEMORY_SOURCE_FILE,      /* Memory source is set as file */
>+    VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS, /* Memory source is set as anonymous */
>+
>+    VIR_DOMAIN_MEMORY_SOURCE_LAST,
>+} virDomainMemorySource;
>+
>+typedef enum {
>+    VIR_DOMAIN_MEMORY_ACCESS_NONE = 0,  /*  No memory access defined */
>+    VIR_DOMAIN_MEMORY_ACCESS_SHARED,    /* Memory access is set as shared */
>+    VIR_DOMAIN_MEMORY_ACCESS_PRIVATE,   /* Memory access is set as private */
>+
>+    VIR_DOMAIN_MEMORY_ACCESS_LAST,
>+} virDomainMemoryAccess;
>+

Same here for the virNumaMemAccess, of course.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161125/fc8cdd89/attachment-0001.sig>


More information about the libvir-list mailing list