Hi
On Tue, Sep 11, 2018 at 5:36 PM John Ferlan <jferlan(a)redhat.com> wrote:
Commit 82327038 moved a couple of checks out of the XML parser
into the domain validation; however, those checks seem to be more
useful as hypervisor specific checks rather than the more general
domain conf checks (nothing in the docs indicate a specific error).
Fortunately only QEMU was processing the memoryBacking, thus
add the changes to qemuDomainDefValidateMemory and change the
code a bit to make usage of the similar deref to def->mem and
the mem->nhugepages filter.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
---
src/conf/domain_conf.c | 14 --------------
src/qemu/qemu_domain.c | 27 ++++++++++++++++++++++-----
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7e14cea128..cbc3497c47 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6182,20 +6182,6 @@ virDomainDefMemtuneValidate(const virDomainDef *def)
if (mem->nhugepages == 0)
return 0;
That check could be removed now.
- if (mem->allocation == VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("hugepages are not allowed with memory "
- "allocation ondemand"));
- return -1;
- }
-
- if (mem->source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("hugepages are not allowed with anonymous "
- "memory source"));
- return -1;
- }
-
for (i = 0; i < mem->nhugepages; i++) {
size_t j;
ssize_t nextBit;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5329899b13..30fd21dcdf 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3953,18 +3953,35 @@ static int
qemuDomainDefValidateMemory(const virDomainDef *def)
{
const long system_page_size = virGetSystemPageSizeKB();
+ const virDomainMemtune *mem = &(def->mem);
+
extra parenthesis?
+ if (mem->nhugepages == 0)
+ return 0;
+
+ if (mem->allocation == VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("hugepages are not allowed with memory "
+ "allocation ondemand"));
+ return -1;
+ }
+
+ if (mem->source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("hugepages are not allowed with anonymous "
+ "memory source"));
+ return -1;
+ }
/* We can't guarantee any other mem.access
* if no guest NUMA nodes are defined. */
- if (def->mem.nhugepages != 0 &&
- def->mem.hugepages[0].size != system_page_size &&
+ if (mem->hugepages[0].size != system_page_size &&
virDomainNumaGetNodeCount(def->numa) == 0 &&
- def->mem.access != VIR_DOMAIN_MEMORY_ACCESS_DEFAULT &&
- def->mem.access != VIR_DOMAIN_MEMORY_ACCESS_PRIVATE) {
+ mem->access != VIR_DOMAIN_MEMORY_ACCESS_DEFAULT &&
+ mem->access != VIR_DOMAIN_MEMORY_ACCESS_PRIVATE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("memory access mode '%s' not supported "
"without guest numa node"),
- virDomainMemoryAccessTypeToString(def->mem.access));
+ virDomainMemoryAccessTypeToString(mem->access));
return -1;
}
--
looks good otherwise
Reviewed-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
2.17.1
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
--
Marc-André Lureau