Discussion:
[libvirt] [PATCH v3 2/3] qemu: check memory-backend-memfd.hugetlb capability
m***@redhat.com
2018-11-15 11:55:52 UTC
Permalink
From: Marc-André Lureau <***@redhat.com>

QEMU 3.1 should only expose the property if the host is actually
capable of creating hugetable-backed memfd. However, it may fail
at runtime depending on requested "hugetlbsize".

Reviewed-by: John Ferlan <***@redhat.com>
Signed-off-by: Marc-André Lureau <***@redhat.com>
Signed-off-by: John Ferlan <***@redhat.com>
---
src/qemu/qemu_capabilities.c | 8 ++
src/qemu/qemu_capabilities.h | 1 +
.../caps_2.12.0.aarch64.replies | 94 ++++++++++++---
.../caps_2.12.0.aarch64.xml | 3 +-
.../caps_2.12.0.ppc64.replies | 90 +++++++++++---
.../caps_2.12.0.ppc64.xml | 3 +-
.../caps_2.12.0.s390x.replies | 98 ++++++++++++----
.../caps_2.12.0.s390x.xml | 3 +-
.../caps_2.12.0.x86_64.replies | 110 +++++++++++++-----
.../caps_2.12.0.x86_64.xml | 3 +-
.../caps_3.0.0.ppc64.replies | 90 +++++++++++---
.../qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 3 +-
.../caps_3.0.0.riscv32.replies | 86 +++++++++++---
.../caps_3.0.0.riscv32.xml | 1 +
.../caps_3.0.0.riscv64.replies | 86 +++++++++++---
.../caps_3.0.0.riscv64.xml | 1 +
.../caps_3.0.0.s390x.replies | 98 ++++++++++++----
.../qemucapabilitiesdata/caps_3.0.0.s390x.xml | 4 +-
.../caps_3.0.0.x86_64.replies | 110 +++++++++++++-----
.../caps_3.0.0.x86_64.xml | 3 +-
20 files changed, 718 insertions(+), 177 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 5d15e6d3fb..eab2444c5d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -510,6 +510,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"blockdev",
"vfio-ap",
"memory-backend-memfd",
+ "memory-backend-memfd.hugetlb",
);


@@ -1358,6 +1359,10 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsMemoryBackendFile[] =
{ "discard-data", QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD },
};

+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsMemoryBackendMemfd[] = {
+ { "hugetlb", QEMU_CAPS_OBJECT_MEMORY_MEMFD_HUGETLB },
+};
+
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsSPAPRMachine[] = {
{ "cap-hpt-max-page-size", QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE },
{ "cap-htm", QEMU_CAPS_MACHINE_PSERIES_CAP_HTM },
@@ -1367,6 +1372,9 @@ static virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
{ "memory-backend-file", virQEMUCapsObjectPropsMemoryBackendFile,
ARRAY_CARDINALITY(virQEMUCapsObjectPropsMemoryBackendFile),
QEMU_CAPS_OBJECT_MEMORY_FILE },
+ { "memory-backend-memfd", virQEMUCapsObjectPropsMemoryBackendMemfd,
+ ARRAY_CARDINALITY(virQEMUCapsObjectPropsMemoryBackendMemfd),
+ QEMU_CAPS_OBJECT_MEMORY_FILE },
{ "spapr-machine", virQEMUCapsObjectPropsSPAPRMachine,
ARRAY_CARDINALITY(virQEMUCapsObjectPropsSPAPRMachine),
-1 },
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index a14aa0b7fc..c60bfa5a85 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -494,6 +494,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
QEMU_CAPS_BLOCKDEV, /* -blockdev and blockdev-add are supported */
QEMU_CAPS_DEVICE_VFIO_AP, /* -device vfio-ap */
QEMU_CAPS_OBJECT_MEMORY_MEMFD, /* -object memory-backend-memfd */
+ QEMU_CAPS_OBJECT_MEMORY_MEMFD_HUGETLB, /* -object memory-backend-memfd.hugetlb */

QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.replies b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.replies
index 4208a66156..2cd6705d78 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.replies
@@ -5403,13 +5403,71 @@
{
"execute": "qom-list-properties",
"arguments": {
- "typename": "spapr-machine"
+ "typename": "memory-backend-memfd"
},
"id": "libvirt-31"
}

{
- "id": "libvirt-31",
+ "return": [
+ {
+ "name": "policy",
+ "type": "HostMemPolicy"
+ },
+ {
+ "name": "share",
+ "type": "bool"
+ },
+ {
+ "name": "host-nodes",
+ "type": "int"
+ },
+ {
+ "name": "prealloc",
+ "type": "bool"
+ },
+ {
+ "name": "dump",
+ "type": "bool"
+ },
+ {
+ "name": "size",
+ "type": "int"
+ },
+ {
+ "name": "merge",
+ "type": "bool"
+ },
+ {
+ "name": "seal",
+ "type": "bool"
+ },
+ {
+ "name": "hugetlbsize",
+ "type": "int"
+ },
+ {
+ "name": "hugetlb",
+ "type": "bool"
+ },
+ {
+ "name": "type",
+ "type": "string"
+ }
+ ],
+ "id": "libvirt-31"
+}
+
+{
+ "execute": "qom-list-properties",
+ "arguments": {
+ "typename": "spapr-machine"
+ },
+ "id": "libvirt-32"
+}
+
+{
+ "id": "libvirt-32",
"error": {
"class": "DeviceNotFound",
"desc": "Class 'spapr-machine' not found"
@@ -5418,7 +5476,7 @@

{
"execute": "query-machines",
- "id": "libvirt-32"
+ "id": "libvirt-33"
}

{
@@ -5715,12 +5773,12 @@
"cpu-max": 1
}
],
- "id": "libvirt-32"
+ "id": "libvirt-33"
}

{
"execute": "query-cpu-definitions",
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
@@ -5896,35 +5954,35 @@
"static": false
}
],
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
"execute": "query-tpm-models",
- "id": "libvirt-34"
+ "id": "libvirt-35"
}

{
"return": [
],
- "id": "libvirt-34"
+ "id": "libvirt-35"
}

{
"execute": "query-tpm-types",
- "id": "libvirt-35"
+ "id": "libvirt-36"
}

{
"return": [
"emulator"
],
- "id": "libvirt-35"
+ "id": "libvirt-36"
}

{
"execute": "query-command-line-options",
- "id": "libvirt-36"
+ "id": "libvirt-37"
}

{
@@ -7085,12 +7143,12 @@
"option": "drive"
}
],
- "id": "libvirt-36"
+ "id": "libvirt-37"
}

{
"execute": "query-migrate-capabilities",
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
@@ -7152,12 +7210,12 @@
"capability": "dirty-bitmaps"
}
],
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
"execute": "query-qmp-schema",
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
@@ -18525,12 +18583,12 @@
"meta-type": "object"
}
],
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
"execute": "query-gic-capabilities",
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
@@ -18546,7 +18604,7 @@
"kernel": false
}
],
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml
index 20b683aad9..4254018d4c 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml
@@ -163,9 +163,10 @@
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
<flag name='memory-backend-memfd'/>
+ <flag name='memory-backend-memfd.hugetlb'/>
<version>2011090</version>
<kvmVersion>0</kvmVersion>
- <microcodeVersion>344910</microcodeVersion>
+ <microcodeVersion>345725</microcodeVersion>
<package>v2.12.0-rc0</package>
<arch>aarch64</arch>
<cpu type='kvm' name='pxa262'/>
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.replies b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.replies
index bd28546275..d8aef1e9d1 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.replies
@@ -5458,11 +5458,69 @@
{
"execute": "qom-list-properties",
"arguments": {
- "typename": "spapr-machine"
+ "typename": "memory-backend-memfd"
},
"id": "libvirt-32"
}

+{
+ "return": [
+ {
+ "name": "policy",
+ "type": "HostMemPolicy"
+ },
+ {
+ "name": "share",
+ "type": "bool"
+ },
+ {
+ "name": "host-nodes",
+ "type": "int"
+ },
+ {
+ "name": "prealloc",
+ "type": "bool"
+ },
+ {
+ "name": "dump",
+ "type": "bool"
+ },
+ {
+ "name": "size",
+ "type": "int"
+ },
+ {
+ "name": "merge",
+ "type": "bool"
+ },
+ {
+ "name": "seal",
+ "type": "bool"
+ },
+ {
+ "name": "hugetlbsize",
+ "type": "int"
+ },
+ {
+ "name": "hugetlb",
+ "type": "bool"
+ },
+ {
+ "name": "type",
+ "type": "string"
+ }
+ ],
+ "id": "libvirt-32"
+}
+
+{
+ "execute": "qom-list-properties",
+ "arguments": {
+ "typename": "spapr-machine"
+ },
+ "id": "libvirt-33"
+}
+
{
"return": [
{
@@ -5621,12 +5679,12 @@
"type": "bool"
}
],
- "id": "libvirt-32"
+ "id": "libvirt-33"
}

{
"execute": "query-machines",
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
@@ -5764,12 +5822,12 @@
"cpu-max": 1
}
],
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
"execute": "query-cpu-definitions",
- "id": "libvirt-34"
+ "id": "libvirt-35"
}

{
@@ -7965,35 +8023,35 @@
"static": false
}
],
- "id": "libvirt-34"
+ "id": "libvirt-35"
}

{
"execute": "query-tpm-models",
- "id": "libvirt-35"
+ "id": "libvirt-36"
}

{
"return": [
],
- "id": "libvirt-35"
+ "id": "libvirt-36"
}

{
"execute": "query-tpm-types",
- "id": "libvirt-36"
+ "id": "libvirt-37"
}

{
"return": [
"emulator"
],
- "id": "libvirt-36"
+ "id": "libvirt-37"
}

{
"execute": "query-command-line-options",
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
@@ -9149,12 +9207,12 @@
"option": "drive"
}
],
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
"execute": "query-migrate-capabilities",
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
@@ -9216,12 +9274,12 @@
"capability": "dirty-bitmaps"
}
],
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
"execute": "query-qmp-schema",
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
@@ -20589,7 +20647,7 @@
"meta-type": "object"
}
],
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
index 3a63c369a4..0cbc6e3119 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
@@ -161,9 +161,10 @@
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
<flag name='memory-backend-memfd'/>
+ <flag name='memory-backend-memfd.hugetlb'/>
<version>2011090</version>
<kvmVersion>0</kvmVersion>
- <microcodeVersion>425694</microcodeVersion>
+ <microcodeVersion>426509</microcodeVersion>
<package>v2.12.0-rc0</package>
<arch>ppc64</arch>
<cpu type='kvm' name='default'/>
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.replies b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.replies
index f98afbceae..b5a14b5916 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.replies
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.replies
@@ -3818,13 +3818,71 @@
{
"execute": "qom-list-properties",
"arguments": {
- "typename": "spapr-machine"
+ "typename": "memory-backend-memfd"
},
"id": "libvirt-31"
}

{
- "id": "libvirt-31",
+ "return": [
+ {
+ "name": "policy",
+ "type": "HostMemPolicy"
+ },
+ {
+ "name": "share",
+ "type": "bool"
+ },
+ {
+ "name": "host-nodes",
+ "type": "int"
+ },
+ {
+ "name": "prealloc",
+ "type": "bool"
+ },
+ {
+ "name": "dump",
+ "type": "bool"
+ },
+ {
+ "name": "size",
+ "type": "int"
+ },
+ {
+ "name": "merge",
+ "type": "bool"
+ },
+ {
+ "name": "seal",
+ "type": "bool"
+ },
+ {
+ "name": "hugetlbsize",
+ "type": "int"
+ },
+ {
+ "name": "hugetlb",
+ "type": "bool"
+ },
+ {
+ "name": "type",
+ "type": "string"
+ }
+ ],
+ "id": "libvirt-31"
+}
+
+{
+ "execute": "qom-list-properties",
+ "arguments": {
+ "typename": "spapr-machine"
+ },
+ "id": "libvirt-32"
+}
+
+{
+ "id": "libvirt-32",
"error": {
"class": "DeviceNotFound",
"desc": "Class 'spapr-machine' not found"
@@ -3833,7 +3891,7 @@

{
"execute": "query-machines",
- "id": "libvirt-32"
+ "id": "libvirt-33"
}

{
@@ -3891,12 +3949,12 @@
"alias": "s390-ccw-virtio"
}
],
- "id": "libvirt-32"
+ "id": "libvirt-33"
}

{
"execute": "query-cpu-definitions",
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
@@ -4431,35 +4489,35 @@
"migration-safe": true
}
],
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
"execute": "query-tpm-models",
- "id": "libvirt-34"
+ "id": "libvirt-35"
}

{
"return": [
],
- "id": "libvirt-34"
+ "id": "libvirt-35"
}

{
"execute": "query-tpm-types",
- "id": "libvirt-35"
+ "id": "libvirt-36"
}

{
"return": [
"emulator"
],
- "id": "libvirt-35"
+ "id": "libvirt-36"
}

{
"execute": "query-command-line-options",
- "id": "libvirt-36"
+ "id": "libvirt-37"
}

{
@@ -5584,12 +5642,12 @@
"option": "drive"
}
],
- "id": "libvirt-36"
+ "id": "libvirt-37"
}

{
"execute": "query-migrate-capabilities",
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
@@ -5651,12 +5709,12 @@
"capability": "dirty-bitmaps"
}
],
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
"execute": "query-qmp-schema",
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
@@ -17024,7 +17082,7 @@
"meta-type": "object"
}
],
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
@@ -17035,7 +17093,7 @@
"name": "host"
}
},
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
@@ -17073,7 +17131,7 @@
}
}
},
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
@@ -17087,11 +17145,11 @@
}
}
},
- "id": "libvirt-40"
+ "id": "libvirt-41"
}

{
- "id": "libvirt-40",
+ "id": "libvirt-41",
"error": {
"class": "GenericError",
"desc": "Property '.migratable' not found"
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml
index f8f4266d50..a1789808b9 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml
@@ -129,9 +129,10 @@
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
<flag name='memory-backend-memfd'/>
+ <flag name='memory-backend-memfd.hugetlb'/>
<version>2012000</version>
<kvmVersion>0</kvmVersion>
- <microcodeVersion>374287</microcodeVersion>
+ <microcodeVersion>375102</microcodeVersion>
<package></package>
<arch>s390x</arch>
<hostCPU type='kvm' model='z14-base' migratability='no'>
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies
index e0b6d2f937..675b85b43d 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies
@@ -4816,13 +4816,71 @@
{
"execute": "qom-list-properties",
"arguments": {
- "typename": "spapr-machine"
+ "typename": "memory-backend-memfd"
},
"id": "libvirt-36"
}

{
- "id": "libvirt-36",
+ "return": [
+ {
+ "name": "policy",
+ "type": "HostMemPolicy"
+ },
+ {
+ "name": "share",
+ "type": "bool"
+ },
+ {
+ "name": "host-nodes",
+ "type": "int"
+ },
+ {
+ "name": "prealloc",
+ "type": "bool"
+ },
+ {
+ "name": "dump",
+ "type": "bool"
+ },
+ {
+ "name": "size",
+ "type": "int"
+ },
+ {
+ "name": "merge",
+ "type": "bool"
+ },
+ {
+ "name": "seal",
+ "type": "bool"
+ },
+ {
+ "name": "hugetlbsize",
+ "type": "int"
+ },
+ {
+ "name": "hugetlb",
+ "type": "bool"
+ },
+ {
+ "name": "type",
+ "type": "string"
+ }
+ ],
+ "id": "libvirt-36"
+}
+
+{
+ "execute": "qom-list-properties",
+ "arguments": {
+ "typename": "spapr-machine"
+ },
+ "id": "libvirt-37"
+}
+
+{
+ "id": "libvirt-37",
"error": {
"class": "DeviceNotFound",
"desc": "Class 'spapr-machine' not found"
@@ -4831,7 +4889,7 @@

{
"execute": "query-machines",
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
@@ -5030,12 +5088,12 @@
"cpu-max": 255
}
],
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
"execute": "query-cpu-definitions",
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
@@ -5549,12 +5607,12 @@
"migration-safe": true
}
],
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
"execute": "query-tpm-models",
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
@@ -5562,12 +5620,12 @@
"tpm-crb",
"tpm-tis"
],
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
"execute": "query-tpm-types",
- "id": "libvirt-40"
+ "id": "libvirt-41"
}

{
@@ -5575,12 +5633,12 @@
"passthrough",
"emulator"
],
- "id": "libvirt-40"
+ "id": "libvirt-41"
}

{
"execute": "query-command-line-options",
- "id": "libvirt-41"
+ "id": "libvirt-42"
}

{
@@ -6867,12 +6925,12 @@
"option": "drive"
}
],
- "id": "libvirt-41"
+ "id": "libvirt-42"
}

{
"execute": "query-migrate-capabilities",
- "id": "libvirt-42"
+ "id": "libvirt-43"
}

{
@@ -6934,12 +6992,12 @@
"capability": "dirty-bitmaps"
}
],
- "id": "libvirt-42"
+ "id": "libvirt-43"
}

{
"execute": "query-qmp-schema",
- "id": "libvirt-43"
+ "id": "libvirt-44"
}

{
@@ -18307,7 +18365,7 @@
"meta-type": "object"
}
],
- "id": "libvirt-43"
+ "id": "libvirt-44"
}

{
@@ -18318,7 +18376,7 @@
"name": "host"
}
},
- "id": "libvirt-44"
+ "id": "libvirt-45"
}

{
@@ -18508,7 +18566,7 @@
}
}
},
- "id": "libvirt-44"
+ "id": "libvirt-45"
}

{
@@ -18700,7 +18758,7 @@
}
}
},
- "id": "libvirt-45"
+ "id": "libvirt-46"
}

{
@@ -18955,7 +19013,7 @@
}
}
},
- "id": "libvirt-45"
+ "id": "libvirt-46"
}

{
@@ -18969,7 +19027,7 @@
}
}
},
- "id": "libvirt-46"
+ "id": "libvirt-47"
}

{
@@ -19159,7 +19217,7 @@
}
}
},
- "id": "libvirt-46"
+ "id": "libvirt-47"
}

{
@@ -19351,7 +19409,7 @@
}
}
},
- "id": "libvirt-47"
+ "id": "libvirt-48"
}

{
@@ -19606,12 +19664,12 @@
}
}
},
- "id": "libvirt-47"
+ "id": "libvirt-48"
}

{
"execute": "query-sev-capabilities",
- "id": "libvirt-48"
+ "id": "libvirt-49"
}

{
@@ -19621,7 +19679,7 @@
"cert-chain": "AQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAA",
"pdh": "AQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAA"
},
- "id": "libvirt-48"
+ "id": "libvirt-49"
}

{
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
index e53f7621c0..73df166bc7 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
@@ -204,9 +204,10 @@
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
<flag name='memory-backend-memfd'/>
+ <flag name='memory-backend-memfd.hugetlb'/>
<version>2011090</version>
<kvmVersion>0</kvmVersion>
- <microcodeVersion>413556</microcodeVersion>
+ <microcodeVersion>414371</microcodeVersion>
<package>v2.12.0-rc0</package>
<arch>x86_64</arch>
<hostCPU type='kvm' model='base' migratability='yes'>
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.replies b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.replies
index eb57c77a90..aff01371a3 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.replies
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.replies
@@ -5541,11 +5541,69 @@
{
"execute": "qom-list-properties",
"arguments": {
- "typename": "spapr-machine"
+ "typename": "memory-backend-memfd"
},
"id": "libvirt-32"
}

+{
+ "return": [
+ {
+ "name": "policy",
+ "type": "HostMemPolicy"
+ },
+ {
+ "name": "share",
+ "type": "bool"
+ },
+ {
+ "name": "host-nodes",
+ "type": "int"
+ },
+ {
+ "name": "prealloc",
+ "type": "bool"
+ },
+ {
+ "name": "dump",
+ "type": "bool"
+ },
+ {
+ "name": "size",
+ "type": "int"
+ },
+ {
+ "name": "merge",
+ "type": "bool"
+ },
+ {
+ "name": "seal",
+ "type": "bool"
+ },
+ {
+ "name": "hugetlbsize",
+ "type": "int"
+ },
+ {
+ "name": "hugetlb",
+ "type": "bool"
+ },
+ {
+ "name": "type",
+ "type": "string"
+ }
+ ],
+ "id": "libvirt-32"
+}
+
+{
+ "execute": "qom-list-properties",
+ "arguments": {
+ "typename": "spapr-machine"
+ },
+ "id": "libvirt-33"
+}
+
{
"return": [
{
@@ -5714,12 +5772,12 @@
"type": "bool"
}
],
- "id": "libvirt-32"
+ "id": "libvirt-33"
}

{
"execute": "query-machines",
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
@@ -5862,12 +5920,12 @@
"cpu-max": 1
}
],
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
"execute": "query-cpu-definitions",
- "id": "libvirt-34"
+ "id": "libvirt-35"
}

{
@@ -8063,35 +8121,35 @@
"static": false
}
],
- "id": "libvirt-34"
+ "id": "libvirt-35"
}

{
"execute": "query-tpm-models",
- "id": "libvirt-35"
+ "id": "libvirt-36"
}

{
"return": [
],
- "id": "libvirt-35"
+ "id": "libvirt-36"
}

{
"execute": "query-tpm-types",
- "id": "libvirt-36"
+ "id": "libvirt-37"
}

{
"return": [
"emulator"
],
- "id": "libvirt-36"
+ "id": "libvirt-37"
}

{
"execute": "query-command-line-options",
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
@@ -9221,12 +9279,12 @@
"option": "drive"
}
],
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
"execute": "query-migrate-capabilities",
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
@@ -9296,12 +9354,12 @@
"capability": "late-block-activate"
}
],
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
"execute": "query-qmp-schema",
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
@@ -21460,7 +21518,7 @@
"meta-type": "object"
}
],
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml
index 93b04260da..7a8a4c782d 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml
@@ -161,9 +161,10 @@
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
<flag name='memory-backend-memfd'/>
+ <flag name='memory-backend-memfd.hugetlb'/>
<version>2012050</version>
<kvmVersion>0</kvmVersion>
- <microcodeVersion>444131</microcodeVersion>
+ <microcodeVersion>444946</microcodeVersion>
<package>v2.12.0-1689-g518d23a</package>
<arch>ppc64</arch>
<cpu type='kvm' name='default'/>
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.replies b/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.replies
index 3e8d136a32..663b4a49c0 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.replies
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.replies
@@ -1734,13 +1734,71 @@
{
"execute": "qom-list-properties",
"arguments": {
- "typename": "spapr-machine"
+ "typename": "memory-backend-memfd"
},
"id": "libvirt-27"
}

{
- "id": "libvirt-27",
+ "return": [
+ {
+ "name": "policy",
+ "type": "HostMemPolicy"
+ },
+ {
+ "name": "share",
+ "type": "bool"
+ },
+ {
+ "name": "host-nodes",
+ "type": "int"
+ },
+ {
+ "name": "prealloc",
+ "type": "bool"
+ },
+ {
+ "name": "dump",
+ "type": "bool"
+ },
+ {
+ "name": "size",
+ "type": "int"
+ },
+ {
+ "name": "merge",
+ "type": "bool"
+ },
+ {
+ "name": "seal",
+ "type": "bool"
+ },
+ {
+ "name": "hugetlbsize",
+ "type": "int"
+ },
+ {
+ "name": "hugetlb",
+ "type": "bool"
+ },
+ {
+ "name": "type",
+ "type": "string"
+ }
+ ],
+ "id": "libvirt-27"
+}
+
+{
+ "execute": "qom-list-properties",
+ "arguments": {
+ "typename": "spapr-machine"
+ },
+ "id": "libvirt-28"
+}
+
+{
+ "id": "libvirt-28",
"error": {
"class": "DeviceNotFound",
"desc": "Class 'spapr-machine' not found"
@@ -1749,7 +1807,7 @@

{
"execute": "query-machines",
- "id": "libvirt-28"
+ "id": "libvirt-29"
}

{
@@ -1786,23 +1844,23 @@
"cpu-max": 1
}
],
- "id": "libvirt-28"
+ "id": "libvirt-29"
}

{
"execute": "query-tpm-models",
- "id": "libvirt-29"
+ "id": "libvirt-30"
}

{
"return": [
],
- "id": "libvirt-29"
+ "id": "libvirt-30"
}

{
"execute": "query-tpm-types",
- "id": "libvirt-30"
+ "id": "libvirt-31"
}

{
@@ -1810,12 +1868,12 @@
"passthrough",
"emulator"
],
- "id": "libvirt-30"
+ "id": "libvirt-31"
}

{
"execute": "query-command-line-options",
- "id": "libvirt-31"
+ "id": "libvirt-32"
}

{
@@ -2940,12 +2998,12 @@
"option": "drive"
}
],
- "id": "libvirt-31"
+ "id": "libvirt-32"
}

{
"execute": "query-migrate-capabilities",
- "id": "libvirt-32"
+ "id": "libvirt-33"
}

{
@@ -3015,12 +3073,12 @@
"capability": "late-block-activate"
}
],
- "id": "libvirt-32"
+ "id": "libvirt-33"
}

{
"execute": "query-qmp-schema",
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
@@ -14695,5 +14753,5 @@
"meta-type": "object"
}
],
- "id": "libvirt-33"
+ "id": "libvirt-34"
}
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml b/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml
index 57096e735e..634d76ef26 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml
@@ -101,6 +101,7 @@
<flag name='tpm-emulator'/>
<flag name='egl-headless'/>
<flag name='memory-backend-memfd'/>
+ <flag name='memory-backend-memfd.hugetlb'/>
<version>3000000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>0</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.replies b/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.replies
index 3631193566..cc66c232ab 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.replies
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.replies
@@ -1734,13 +1734,71 @@
{
"execute": "qom-list-properties",
"arguments": {
- "typename": "spapr-machine"
+ "typename": "memory-backend-memfd"
},
"id": "libvirt-27"
}

{
- "id": "libvirt-27",
+ "return": [
+ {
+ "name": "policy",
+ "type": "HostMemPolicy"
+ },
+ {
+ "name": "share",
+ "type": "bool"
+ },
+ {
+ "name": "host-nodes",
+ "type": "int"
+ },
+ {
+ "name": "prealloc",
+ "type": "bool"
+ },
+ {
+ "name": "dump",
+ "type": "bool"
+ },
+ {
+ "name": "size",
+ "type": "int"
+ },
+ {
+ "name": "merge",
+ "type": "bool"
+ },
+ {
+ "name": "seal",
+ "type": "bool"
+ },
+ {
+ "name": "hugetlbsize",
+ "type": "int"
+ },
+ {
+ "name": "hugetlb",
+ "type": "bool"
+ },
+ {
+ "name": "type",
+ "type": "string"
+ }
+ ],
+ "id": "libvirt-27"
+}
+
+{
+ "execute": "qom-list-properties",
+ "arguments": {
+ "typename": "spapr-machine"
+ },
+ "id": "libvirt-28"
+}
+
+{
+ "id": "libvirt-28",
"error": {
"class": "DeviceNotFound",
"desc": "Class 'spapr-machine' not found"
@@ -1749,7 +1807,7 @@

{
"execute": "query-machines",
- "id": "libvirt-28"
+ "id": "libvirt-29"
}

{
@@ -1786,23 +1844,23 @@
"cpu-max": 1
}
],
- "id": "libvirt-28"
+ "id": "libvirt-29"
}

{
"execute": "query-tpm-models",
- "id": "libvirt-29"
+ "id": "libvirt-30"
}

{
"return": [
],
- "id": "libvirt-29"
+ "id": "libvirt-30"
}

{
"execute": "query-tpm-types",
- "id": "libvirt-30"
+ "id": "libvirt-31"
}

{
@@ -1810,12 +1868,12 @@
"passthrough",
"emulator"
],
- "id": "libvirt-30"
+ "id": "libvirt-31"
}

{
"execute": "query-command-line-options",
- "id": "libvirt-31"
+ "id": "libvirt-32"
}

{
@@ -2940,12 +2998,12 @@
"option": "drive"
}
],
- "id": "libvirt-31"
+ "id": "libvirt-32"
}

{
"execute": "query-migrate-capabilities",
- "id": "libvirt-32"
+ "id": "libvirt-33"
}

{
@@ -3015,12 +3073,12 @@
"capability": "late-block-activate"
}
],
- "id": "libvirt-32"
+ "id": "libvirt-33"
}

{
"execute": "query-qmp-schema",
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
@@ -14695,5 +14753,5 @@
"meta-type": "object"
}
],
- "id": "libvirt-33"
+ "id": "libvirt-34"
}
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml
index e88c69b2c7..d042eda06c 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml
@@ -101,6 +101,7 @@
<flag name='tpm-emulator'/>
<flag name='egl-headless'/>
<flag name='memory-backend-memfd'/>
+ <flag name='memory-backend-memfd.hugetlb'/>
<version>3000000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>0</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.replies b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.replies
index 0560835b9f..3bcdfce293 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.replies
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.replies
@@ -3978,13 +3978,71 @@
{
"execute": "qom-list-properties",
"arguments": {
- "typename": "spapr-machine"
+ "typename": "memory-backend-memfd"
},
"id": "libvirt-32"
}

{
- "id": "libvirt-32",
+ "return": [
+ {
+ "name": "policy",
+ "type": "HostMemPolicy"
+ },
+ {
+ "name": "share",
+ "type": "bool"
+ },
+ {
+ "name": "host-nodes",
+ "type": "int"
+ },
+ {
+ "name": "prealloc",
+ "type": "bool"
+ },
+ {
+ "name": "dump",
+ "type": "bool"
+ },
+ {
+ "name": "size",
+ "type": "int"
+ },
+ {
+ "name": "merge",
+ "type": "bool"
+ },
+ {
+ "name": "seal",
+ "type": "bool"
+ },
+ {
+ "name": "hugetlbsize",
+ "type": "int"
+ },
+ {
+ "name": "hugetlb",
+ "type": "bool"
+ },
+ {
+ "name": "type",
+ "type": "string"
+ }
+ ],
+ "id": "libvirt-32"
+}
+
+{
+ "execute": "qom-list-properties",
+ "arguments": {
+ "typename": "spapr-machine"
+ },
+ "id": "libvirt-33"
+}
+
+{
+ "id": "libvirt-33",
"error": {
"class": "DeviceNotFound",
"desc": "Class 'spapr-machine' not found"
@@ -3993,7 +4051,7 @@

{
"execute": "query-machines",
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
@@ -4056,12 +4114,12 @@
"cpu-max": 248
}
],
- "id": "libvirt-33"
+ "id": "libvirt-34"
}

{
"execute": "query-cpu-definitions",
- "id": "libvirt-34"
+ "id": "libvirt-35"
}

{
@@ -4612,35 +4670,35 @@
"migration-safe": true
}
],
- "id": "libvirt-34"
+ "id": "libvirt-35"
}

{
"execute": "query-tpm-models",
- "id": "libvirt-35"
+ "id": "libvirt-36"
}

{
"return": [
],
- "id": "libvirt-35"
+ "id": "libvirt-36"
}

{
"execute": "query-tpm-types",
- "id": "libvirt-36"
+ "id": "libvirt-37"
}

{
"return": [
"emulator"
],
- "id": "libvirt-36"
+ "id": "libvirt-37"
}

{
"execute": "query-command-line-options",
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
@@ -5800,12 +5858,12 @@
"option": "drive"
}
],
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
"execute": "query-migrate-capabilities",
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
@@ -5875,12 +5933,12 @@
"capability": "late-block-activate"
}
],
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
"execute": "query-qmp-schema",
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
@@ -17555,7 +17613,7 @@
"meta-type": "object"
}
],
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
@@ -17566,7 +17624,7 @@
"name": "host"
}
},
- "id": "libvirt-40"
+ "id": "libvirt-41"
}

{
@@ -17608,7 +17666,7 @@
}
}
},
- "id": "libvirt-40"
+ "id": "libvirt-41"
}

{
@@ -17622,11 +17680,11 @@
}
}
},
- "id": "libvirt-41"
+ "id": "libvirt-42"
}

{
- "id": "libvirt-41",
+ "id": "libvirt-42",
"error": {
"class": "GenericError",
"desc": "Property '.migratable' not found"
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml
index 3b5f9818a5..79de349da1 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml
@@ -130,9 +130,11 @@
<flag name='tpm-emulator'/>
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
+ <flag name='memory-backend-memfd'/>
+ <flag name='memory-backend-memfd.hugetlb'/>
<version>3000000</version>
<kvmVersion>0</kvmVersion>
- <microcodeVersion>387601</microcodeVersion>
+ <microcodeVersion>388416</microcodeVersion>
<package></package>
<arch>s390x</arch>
<hostCPU type='kvm' model='z14-base' migratability='no'>
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.replies
index 17edb990e1..f5bbe5c650 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.replies
@@ -4928,13 +4928,71 @@
{
"execute": "qom-list-properties",
"arguments": {
- "typename": "spapr-machine"
+ "typename": "memory-backend-memfd"
},
"id": "libvirt-36"
}

{
- "id": "libvirt-36",
+ "return": [
+ {
+ "name": "policy",
+ "type": "HostMemPolicy"
+ },
+ {
+ "name": "share",
+ "type": "bool"
+ },
+ {
+ "name": "host-nodes",
+ "type": "int"
+ },
+ {
+ "name": "prealloc",
+ "type": "bool"
+ },
+ {
+ "name": "dump",
+ "type": "bool"
+ },
+ {
+ "name": "size",
+ "type": "int"
+ },
+ {
+ "name": "merge",
+ "type": "bool"
+ },
+ {
+ "name": "seal",
+ "type": "bool"
+ },
+ {
+ "name": "hugetlbsize",
+ "type": "int"
+ },
+ {
+ "name": "hugetlb",
+ "type": "bool"
+ },
+ {
+ "name": "type",
+ "type": "string"
+ }
+ ],
+ "id": "libvirt-36"
+}
+
+{
+ "execute": "qom-list-properties",
+ "arguments": {
+ "typename": "spapr-machine"
+ },
+ "id": "libvirt-37"
+}
+
+{
+ "id": "libvirt-37",
"error": {
"class": "DeviceNotFound",
"desc": "Class 'spapr-machine' not found"
@@ -4943,7 +5001,7 @@

{
"execute": "query-machines",
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
@@ -5152,12 +5210,12 @@
"cpu-max": 255
}
],
- "id": "libvirt-37"
+ "id": "libvirt-38"
}

{
"execute": "query-cpu-definitions",
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
@@ -5594,12 +5652,12 @@
"migration-safe": true
}
],
- "id": "libvirt-38"
+ "id": "libvirt-39"
}

{
"execute": "query-tpm-models",
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
@@ -5607,12 +5665,12 @@
"tpm-crb",
"tpm-tis"
],
- "id": "libvirt-39"
+ "id": "libvirt-40"
}

{
"execute": "query-tpm-types",
- "id": "libvirt-40"
+ "id": "libvirt-41"
}

{
@@ -5620,12 +5678,12 @@
"passthrough",
"emulator"
],
- "id": "libvirt-40"
+ "id": "libvirt-41"
}

{
"execute": "query-command-line-options",
- "id": "libvirt-41"
+ "id": "libvirt-42"
}

{
@@ -6924,12 +6982,12 @@
"option": "drive"
}
],
- "id": "libvirt-41"
+ "id": "libvirt-42"
}

{
"execute": "query-migrate-capabilities",
- "id": "libvirt-42"
+ "id": "libvirt-43"
}

{
@@ -6999,12 +7057,12 @@
"capability": "late-block-activate"
}
],
- "id": "libvirt-42"
+ "id": "libvirt-43"
}

{
"execute": "query-qmp-schema",
- "id": "libvirt-43"
+ "id": "libvirt-44"
}

{
@@ -18884,7 +18942,7 @@
"meta-type": "object"
}
],
- "id": "libvirt-43"
+ "id": "libvirt-44"
}

{
@@ -18895,7 +18953,7 @@
"name": "host"
}
},
- "id": "libvirt-44"
+ "id": "libvirt-45"
}

{
@@ -19088,7 +19146,7 @@
}
}
},
- "id": "libvirt-44"
+ "id": "libvirt-45"
}

{
@@ -19283,7 +19341,7 @@
}
}
},
- "id": "libvirt-45"
+ "id": "libvirt-46"
}

{
@@ -19546,7 +19604,7 @@
}
}
},
- "id": "libvirt-45"
+ "id": "libvirt-46"
}

{
@@ -19560,7 +19618,7 @@
}
}
},
- "id": "libvirt-46"
+ "id": "libvirt-47"
}

{
@@ -19753,7 +19811,7 @@
}
}
},
- "id": "libvirt-46"
+ "id": "libvirt-47"
}

{
@@ -19948,7 +20006,7 @@
}
}
},
- "id": "libvirt-47"
+ "id": "libvirt-48"
}

{
@@ -20211,16 +20269,16 @@
}
}
},
- "id": "libvirt-47"
+ "id": "libvirt-48"
}

{
"execute": "query-sev-capabilities",
- "id": "libvirt-48"
+ "id": "libvirt-49"
}

{
- "id": "libvirt-48",
+ "id": "libvirt-49",
"error": {
"class": "GenericError",
"desc": "SEV feature is not available"
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
index 689135a41c..ffe3e06236 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
@@ -206,9 +206,10 @@
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
<flag name='memory-backend-memfd'/>
+ <flag name='memory-backend-memfd.hugetlb'/>
<version>3000000</version>
<kvmVersion>0</kvmVersion>
- <microcodeVersion>425157</microcodeVersion>
+ <microcodeVersion>425972</microcodeVersion>
<package>v3.0.0</package>
<arch>x86_64</arch>
<hostCPU type='kvm' model='base' migratability='yes'>
--
2.19.1.708.g4ede3d42df
m***@redhat.com
2018-11-15 11:55:51 UTC
Permalink
From: Marc-André Lureau <***@redhat.com>

Check availability of "-object memory-backend-memfd".

Reviewed-by: John Ferlan <***@redhat.com>
Signed-off-by: Marc-André Lureau <***@redhat.com>
Signed-off-by: John Ferlan <***@redhat.com>
---
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml | 1 +
10 files changed, 11 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2ca5af3297..5d15e6d3fb 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -509,6 +509,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"vfio-pci.display",
"blockdev",
"vfio-ap",
+ "memory-backend-memfd",
);


@@ -1094,6 +1095,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{ "mch", QEMU_CAPS_DEVICE_MCH },
{ "sev-guest", QEMU_CAPS_SEV_GUEST },
{ "vfio-ap", QEMU_CAPS_DEVICE_VFIO_AP },
+ { "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD },
};

static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 6bb9a2c8f0..a14aa0b7fc 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -493,6 +493,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
QEMU_CAPS_VFIO_PCI_DISPLAY, /* -device vfio-pci.display */
QEMU_CAPS_BLOCKDEV, /* -blockdev and blockdev-add are supported */
QEMU_CAPS_DEVICE_VFIO_AP, /* -device vfio-ap */
+ QEMU_CAPS_OBJECT_MEMORY_MEMFD, /* -object memory-backend-memfd */

QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml
index 7bf1fab8cb..20b683aad9 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml
@@ -162,6 +162,7 @@
<flag name='tpm-emulator'/>
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
+ <flag name='memory-backend-memfd'/>
<version>2011090</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>344910</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
index 8b8d8859c1..3a63c369a4 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
@@ -160,6 +160,7 @@
<flag name='machine.pseries.cap-htm'/>
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
+ <flag name='memory-backend-memfd'/>
<version>2011090</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>425694</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml
index 79320d5229..f8f4266d50 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml
@@ -128,6 +128,7 @@
<flag name='tpm-emulator'/>
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
+ <flag name='memory-backend-memfd'/>
<version>2012000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>374287</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
index fcf94ab720..e53f7621c0 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
@@ -203,6 +203,7 @@
<flag name='sev-guest'/>
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
+ <flag name='memory-backend-memfd'/>
<version>2011090</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>413556</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml
index a1e2ae6556..93b04260da 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml
@@ -160,6 +160,7 @@
<flag name='machine.pseries.cap-htm'/>
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
+ <flag name='memory-backend-memfd'/>
<version>2012050</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>444131</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml b/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml
index 254a4cf3d8..57096e735e 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml
@@ -100,6 +100,7 @@
<flag name='chardev-fd-pass'/>
<flag name='tpm-emulator'/>
<flag name='egl-headless'/>
+ <flag name='memory-backend-memfd'/>
<version>3000000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>0</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml
index e7ab79e006..e88c69b2c7 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml
@@ -100,6 +100,7 @@
<flag name='chardev-fd-pass'/>
<flag name='tpm-emulator'/>
<flag name='egl-headless'/>
+ <flag name='memory-backend-memfd'/>
<version>3000000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>0</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
index 7ceea6b738..689135a41c 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
@@ -205,6 +205,7 @@
<flag name='usb-storage.werror'/>
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>
+ <flag name='memory-backend-memfd'/>
<version>3000000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>425157</microcodeVersion>
--
2.19.1.708.g4ede3d42df
Michal Privoznik
2018-11-15 13:55:31 UTC
Permalink
Post by m***@redhat.com
Check availability of "-object memory-backend-memfd".
---
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml | 1 +
10 files changed, 11 insertions(+)
This is missing tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml change.

Michal
Marc-André Lureau
2018-11-15 21:01:23 UTC
Permalink
Post by Michal Privoznik
Post by m***@redhat.com
Check availability of "-object memory-backend-memfd".
---
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml | 1 +
tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml | 1 +
10 files changed, 11 insertions(+)
This is missing tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml change.
oh snap, I lost the race, rebasing again.
thanks
Post by Michal Privoznik
Michal
m***@redhat.com
2018-11-15 11:55:53 UTC
Permalink
From: Marc-André Lureau <***@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 <***@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 @@
&lt;/hugepages&gt;
&lt;nosharepages/&gt;
&lt;locked/&gt;
- &lt;source type="file|anonymous"/&gt;
+ &lt;source type="file|anonymous|memfd"/&gt;
&lt;access mode="shared|private"/&gt;
&lt;allocation mode="immediate|ondemand"/&gt;
&lt;discard/&gt;
@@ -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")

VIR_ENUM_IMPL(virDomainMemoryAllocation, VIR_DOMAIN_MEMORY_ALLOCATION_LAST,
"none",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c167f8c43c..467785cd83 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -607,6 +607,7 @@ 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_MEMFD, /* Memory source is set as memfd */

VIR_DOMAIN_MEMORY_SOURCE_LAST,
} virDomainMemorySource;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d543ada2a1..5b13e3fd86 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3114,6 +3114,26 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
}


+static int
+qemuBuildMemoryBackendPropsShare(virJSONValuePtr props,
+ virDomainMemoryAccess memAccess)
+{
+ switch (memAccess) {
+ case VIR_DOMAIN_MEMORY_ACCESS_SHARED:
+ return virJSONValueObjectAdd(props, "b:share", true, NULL);
+
+ case VIR_DOMAIN_MEMORY_ACCESS_PRIVATE:
+ return virJSONValueObjectAdd(props, "b:share", false, NULL);
+
+ case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT:
+ case VIR_DOMAIN_MEMORY_ACCESS_LAST:
+ break;
+ }
+
+ return 0;
+}
+
+
/**
* qemuBuildMemoryBackendProps:
* @backendProps: [out] constructed object
@@ -3133,7 +3153,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
* configuration value of 1 is returned. This behaviour can be suppressed by
* setting @force to true in which case 0 would be returned.
*
- * Then, if one of the two memory-backend-* should be used, the @qemuCaps is
+ * Then, if one of the three memory-backend-* should be used, the @qemuCaps is
* consulted to check if qemu does support it.
*
* Returns: 0 on success,
@@ -3259,7 +3279,19 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
if (!(props = virJSONValueNewObject()))
return -1;

- if (useHugepage || mem->nvdimmPath || memAccess ||
+ if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_MEMFD) {
+ backendType = "memory-backend-memfd";
+
+ if (useHugepage &&
+ (virJSONValueObjectAdd(props, "b:hugetlb", useHugepage, NULL) < 0 ||
+ virJSONValueObjectAdd(props, "U:hugetlbsize", pagesize << 10, NULL) < 0)) {
+ goto cleanup;
+ }
+
+ if (qemuBuildMemoryBackendPropsShare(props, memAccess) < 0)
+ goto cleanup;
+
+ } else if (useHugepage || mem->nvdimmPath || memAccess ||
def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {

if (mem->nvdimmPath) {
@@ -3297,21 +3329,8 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
goto cleanup;
}

- switch (memAccess) {
- case VIR_DOMAIN_MEMORY_ACCESS_SHARED:
- if (virJSONValueObjectAdd(props, "b:share", true, NULL) < 0)
- goto cleanup;
- break;
-
- case VIR_DOMAIN_MEMORY_ACCESS_PRIVATE:
- if (virJSONValueObjectAdd(props, "b:share", false, NULL) < 0)
- goto cleanup;
- break;
-
- case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT:
- case VIR_DOMAIN_MEMORY_ACCESS_LAST:
- break;
- }
+ if (qemuBuildMemoryBackendPropsShare(props, memAccess) < 0)
+ goto cleanup;
} else {
backendType = "memory-backend-ram";
}
@@ -3341,7 +3360,9 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
if (!needHugepage && !mem->sourceNodes && !nodeSpecified &&
!mem->nvdimmPath &&
memAccess == VIR_DOMAIN_MEMORY_ACCESS_DEFAULT &&
- def->mem.source != VIR_DOMAIN_MEMORY_SOURCE_FILE && !force) {
+ def->mem.source != VIR_DOMAIN_MEMORY_SOURCE_FILE &&
+ def->mem.source != VIR_DOMAIN_MEMORY_SOURCE_MEMFD &&
+ !force) {
/* report back that using the new backend is not necessary
* to achieve the desired configuration */
ret = 1;
@@ -3359,6 +3380,12 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
_("this qemu doesn't support the "
"memory-backend-ram object"));
goto cleanup;
+ } else if (STREQ(backendType, "memory-backend-memory") &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("this qemu doesn't support the "
+ "memory-backend-memfd object"));
+ goto cleanup;
}

ret = 0;
@@ -7566,7 +7593,8 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,

if (virDomainNumatuneHasPerNodeBinding(def->numa) &&
!(virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE))) {
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE) ||
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Per-node memory binding is not supported "
"with this QEMU"));
@@ -7592,7 +7620,8 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
* need to check which approach to use */
for (i = 0; i < ncells; i++) {
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE) ||
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD)) {

if ((rc = qemuBuildMemoryCellBackendStr(def, cfg, i, priv,
&nodeBackends[i])) < 0)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c374219aab..0f3f4948b8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3951,7 +3951,8 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,


static int
-qemuDomainDefValidateMemory(const virDomainDef *def)
+qemuDomainDefValidateMemory(const virDomainDef *def,
+ virQEMUCapsPtr qemuCaps)
{
const long system_page_size = virGetSystemPageSizeKB();
const virDomainMemtune *mem = &def->mem;
@@ -3973,6 +3974,13 @@ qemuDomainDefValidateMemory(const virDomainDef *def)
return -1;
}

+ if (mem->source == VIR_DOMAIN_MEMORY_SOURCE_MEMFD &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_MEMFD_HUGETLB)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("hugepages is not support with memfd memory source"));
+ return -1;
+ }
+
/* We can't guarantee any other mem.access
* if no guest NUMA nodes are defined. */
if (mem->hugepages[0].size != system_page_size &&
@@ -4112,7 +4120,7 @@ qemuDomainDefValidate(const virDomainDef *def,
if (qemuDomainDefValidateFeatures(def, qemuCaps) < 0)
goto cleanup;

- if (qemuDomainDefValidateMemory(def) < 0)
+ if (qemuDomainDefValidateMemory(def, qemuCaps) < 0)
goto cleanup;

ret = 0;
diff --git a/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args b/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
new file mode 100644
index 0000000000..d0f4057e01
--- /dev/null
+++ b/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
@@ -0,0 +1,34 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name guest=instance-00000092,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-instance-00000092/master-key.aes \
+-machine pc-i440fx-wily,accel=kvm,usb=off,dump-guest-core=off \
+-m 14336 \
+-mem-prealloc \
+-realtime mlock=off \
+-smp 8,sockets=1,cores=8,threads=1 \
+-object memory-backend-memfd,id=ram-node0,hugetlb=yes,hugetlbsize=2097152,\
+share=yes,size=15032385536,host-nodes=3,policy=preferred \
+-numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
+-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
+resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/memfd-memory-numa.xml b/tests/qemuxml2argvdata/memfd-memory-numa.xml
new file mode 100644
index 0000000000..8416a990fa
--- /dev/null
+++ b/tests/qemuxml2argvdata/memfd-memory-numa.xml
@@ -0,0 +1,36 @@
+ <domain type='kvm' id='56'>
+ <name>instance-00000092</name>
+ <uuid>126f2720-6f8e-45ab-a886-ec9277079a67</uuid>
+ <memory unit='KiB'>14680064</memory>
+ <currentMemory unit='KiB'>14680064</currentMemory>
+ <memoryBacking>
+ <hugepages>
+ <page size="2" unit="M"/>
+ </hugepages>
+ <source type='memfd'/>
+ <access mode='shared'/>
+ <allocation mode='immediate'/>
+ </memoryBacking>
+ <numatune>
+ <memnode cellid='0' mode='preferred' nodeset='3'/>
+ </numatune>
+ <vcpu placement='static'>8</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc-i440fx-wily'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu>
+ <topology sockets='1' cores='8' threads='1'/>
+ <numa>
+ <cell id='0' cpus='0-7' memory='14680064' unit='KiB'/>
+ </numa>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <memballoon model='virtio'/>
+ </devices>
+ </domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 39a7f1f53c..d3b71d39df 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2952,6 +2952,8 @@ mymain(void)
DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_OBJECT_MEMORY_FILE,
QEMU_CAPS_KVM);

+ DO_TEST_CAPS_LATEST("memfd-memory-numa");
+
DO_TEST("cpu-check-none", QEMU_CAPS_KVM);
DO_TEST("cpu-check-partial", QEMU_CAPS_KVM);
DO_TEST("cpu-check-full", QEMU_CAPS_KVM);
--
2.19.1.708.g4ede3d42df
Michal Privoznik
2018-11-15 13:55:19 UTC
Permalink
Post by m***@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.
---
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 @@
@@ -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
Michal Privoznik
2018-11-15 13:55:16 UTC
Permalink
Hi,
This is an alternative series from "[PATCH 0/5] Use memfd if
possible". Instead of automatically using memfd for anonymous memory
when available (as suggested by Daniel), it introduces the "memfd"
memory backing type.
Although using memfd transparently when possible is a good idea, it is
a source of various complications for migration & save/restore. This
could eventually be challenged in a different series.
The first two patches have been modified and reviewed by John
Ferlan. Hopefully they can be merged early, regardless of the last
patch outcome, to avoid the painful rebase conflicts due to
capabilities checks introduction.
Thanks :)
- rebased, to fix capabilities check and ping the series
qemu: add memory-backend-memfd capability check
qemu: check memory-backend-memfd.hugetlb capability
qemu: add memfd source type
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_capabilities.c | 10 ++
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_command.c | 69 +++++++----
src/qemu/qemu_domain.c | 12 +-
.../caps_2.12.0.aarch64.replies | 94 ++++++++++++---
.../caps_2.12.0.aarch64.xml | 4 +-
.../caps_2.12.0.ppc64.replies | 90 +++++++++++---
.../caps_2.12.0.ppc64.xml | 4 +-
.../caps_2.12.0.s390x.replies | 98 ++++++++++++----
.../caps_2.12.0.s390x.xml | 4 +-
.../caps_2.12.0.x86_64.replies | 110 +++++++++++++-----
.../caps_2.12.0.x86_64.xml | 4 +-
.../caps_3.0.0.ppc64.replies | 90 +++++++++++---
.../qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 4 +-
.../caps_3.0.0.riscv32.replies | 86 +++++++++++---
.../caps_3.0.0.riscv32.xml | 2 +
.../caps_3.0.0.riscv64.replies | 86 +++++++++++---
.../caps_3.0.0.riscv64.xml | 2 +
.../caps_3.0.0.s390x.replies | 98 ++++++++++++----
.../qemucapabilitiesdata/caps_3.0.0.s390x.xml | 4 +-
.../caps_3.0.0.x86_64.replies | 110 +++++++++++++-----
.../caps_3.0.0.x86_64.xml | 4 +-
.../memfd-memory-numa.x86_64-latest.args | 34 ++++++
tests/qemuxml2argvdata/memfd-memory-numa.xml | 36 ++++++
tests/qemuxml2argvtest.c | 2 +
29 files changed, 869 insertions(+), 204 deletions(-)
create mode 100644 tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/memfd-memory-numa.xml
I've did the review and all three patches look good to me. I've fixed
all the issues I've found and I'm keeping them in a local branch of mine
to give others some time to raise their concerns should they have some.

My main concern was that we would be exposing memory backend to users by
giving them a config knob that could be set to enforce memfd usage. But
I don't think there is any other way, esp. since memory backends are not
real backends (one can't migrate a domain that was started with one to
another one).

ACK series

Michal
Marc-André Lureau
2018-11-16 08:43:02 UTC
Permalink
Hi
Post by Michal Privoznik
Hi,
This is an alternative series from "[PATCH 0/5] Use memfd if
possible". Instead of automatically using memfd for anonymous memory
when available (as suggested by Daniel), it introduces the "memfd"
memory backing type.
Although using memfd transparently when possible is a good idea, it is
a source of various complications for migration & save/restore. This
could eventually be challenged in a different series.
The first two patches have been modified and reviewed by John
Ferlan. Hopefully they can be merged early, regardless of the last
patch outcome, to avoid the painful rebase conflicts due to
capabilities checks introduction.
Thanks :)
- rebased, to fix capabilities check and ping the series
qemu: add memory-backend-memfd capability check
qemu: check memory-backend-memfd.hugetlb capability
qemu: add memfd source type
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_capabilities.c | 10 ++
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_command.c | 69 +++++++----
src/qemu/qemu_domain.c | 12 +-
.../caps_2.12.0.aarch64.replies | 94 ++++++++++++---
.../caps_2.12.0.aarch64.xml | 4 +-
.../caps_2.12.0.ppc64.replies | 90 +++++++++++---
.../caps_2.12.0.ppc64.xml | 4 +-
.../caps_2.12.0.s390x.replies | 98 ++++++++++++----
.../caps_2.12.0.s390x.xml | 4 +-
.../caps_2.12.0.x86_64.replies | 110 +++++++++++++-----
.../caps_2.12.0.x86_64.xml | 4 +-
.../caps_3.0.0.ppc64.replies | 90 +++++++++++---
.../qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 4 +-
.../caps_3.0.0.riscv32.replies | 86 +++++++++++---
.../caps_3.0.0.riscv32.xml | 2 +
.../caps_3.0.0.riscv64.replies | 86 +++++++++++---
.../caps_3.0.0.riscv64.xml | 2 +
.../caps_3.0.0.s390x.replies | 98 ++++++++++++----
.../qemucapabilitiesdata/caps_3.0.0.s390x.xml | 4 +-
.../caps_3.0.0.x86_64.replies | 110 +++++++++++++-----
.../caps_3.0.0.x86_64.xml | 4 +-
.../memfd-memory-numa.x86_64-latest.args | 34 ++++++
tests/qemuxml2argvdata/memfd-memory-numa.xml | 36 ++++++
tests/qemuxml2argvtest.c | 2 +
29 files changed, 869 insertions(+), 204 deletions(-)
create mode 100644 tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/memfd-memory-numa.xml
I've did the review and all three patches look good to me. I've fixed
all the issues I've found and I'm keeping them in a local branch of mine
to give others some time to raise their concerns should they have some.
My main concern was that we would be exposing memory backend to users by
giving them a config knob that could be set to enforce memfd usage. But
I don't think there is any other way, esp. since memory backends are not
real backends (one can't migrate a domain that was started with one to
another one).
ACK series
Ok
Thank you Michal!
Michal Privoznik
2018-11-16 12:40:13 UTC
Permalink
Post by Marc-André Lureau
Hi
Post by Michal Privoznik
I've did the review and all three patches look good to me. I've fixed
all the issues I've found and I'm keeping them in a local branch of mine
to give others some time to raise their concerns should they have some.
My main concern was that we would be exposing memory backend to users by
giving them a config knob that could be set to enforce memfd usage. But
I don't think there is any other way, esp. since memory backends are not
real backends (one can't migrate a domain that was started with one to
another one).
ACK series
Ok
Thank you Michal!
I've pushed these. Thank you for your contribution.

Michal

Michal Privoznik
2018-11-15 13:55:14 UTC
Permalink
Post by m***@redhat.com
QEMU 3.1 should only expose the property if the host is actually
capable of creating hugetable-backed memfd. However, it may fail
at runtime depending on requested "hugetlbsize".
---
src/qemu/qemu_capabilities.c | 8 ++
src/qemu/qemu_capabilities.h | 1 +
.../caps_2.12.0.aarch64.replies | 94 ++++++++++++---
.../caps_2.12.0.aarch64.xml | 3 +-
.../caps_2.12.0.ppc64.replies | 90 +++++++++++---
.../caps_2.12.0.ppc64.xml | 3 +-
.../caps_2.12.0.s390x.replies | 98 ++++++++++++----
.../caps_2.12.0.s390x.xml | 3 +-
.../caps_2.12.0.x86_64.replies | 110 +++++++++++++-----
.../caps_2.12.0.x86_64.xml | 3 +-
.../caps_3.0.0.ppc64.replies | 90 +++++++++++---
.../qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 3 +-
.../caps_3.0.0.riscv32.replies | 86 +++++++++++---
.../caps_3.0.0.riscv32.xml | 1 +
.../caps_3.0.0.riscv64.replies | 86 +++++++++++---
.../caps_3.0.0.riscv64.xml | 1 +
.../caps_3.0.0.s390x.replies | 98 ++++++++++++----
.../qemucapabilitiesdata/caps_3.0.0.s390x.xml | 4 +-
.../caps_3.0.0.x86_64.replies | 110 +++++++++++++-----
.../caps_3.0.0.x86_64.xml | 3 +-
20 files changed, 718 insertions(+), 177 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 5d15e6d3fb..eab2444c5d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -510,6 +510,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"blockdev",
"vfio-ap",
"memory-backend-memfd",
+ "memory-backend-memfd.hugetlb",
);
@@ -1358,6 +1359,10 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsMemoryBackendFile[] =
{ "discard-data", QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD },
};
+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsMemoryBackendMemfd[] = {
+ { "hugetlb", QEMU_CAPS_OBJECT_MEMORY_MEMFD_HUGETLB },
+};
+
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsSPAPRMachine[] = {
{ "cap-hpt-max-page-size", QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE },
{ "cap-htm", QEMU_CAPS_MACHINE_PSERIES_CAP_HTM },
@@ -1367,6 +1372,9 @@ static virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
{ "memory-backend-file", virQEMUCapsObjectPropsMemoryBackendFile,
ARRAY_CARDINALITY(virQEMUCapsObjectPropsMemoryBackendFile),
QEMU_CAPS_OBJECT_MEMORY_FILE },
+ { "memory-backend-memfd", virQEMUCapsObjectPropsMemoryBackendMemfd,
+ ARRAY_CARDINALITY(virQEMUCapsObjectPropsMemoryBackendMemfd),
+ QEMU_CAPS_OBJECT_MEMORY_FILE },
This needs to be QEMU_CAPS_OBJECT_MEMORY_MEMFD. This is conditional
capability, which means "memory-backend-memfd" object props will be
queried on if this capability is set. And since there are qemus which do
support memory-backend-file and do not support memory-backend-memfd this
would try to query the props even if it shouldn't.
Post by m***@redhat.com
{ "spapr-machine", virQEMUCapsObjectPropsSPAPRMachine,
ARRAY_CARDINALITY(virQEMUCapsObjectPropsSPAPRMachine),
-1 },
Michal
Loading...