From nobody Sun May 5 15:48:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1514959573717935.4539093520482; Tue, 2 Jan 2018 22:06:13 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB9E74A6F3; Wed, 3 Jan 2018 06:06:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB7D95D965; Wed, 3 Jan 2018 06:06:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4C782180121C; Wed, 3 Jan 2018 06:06:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w036675U002112 for ; Wed, 3 Jan 2018 01:06:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id ECA7964451; Wed, 3 Jan 2018 06:06:07 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-45.brq.redhat.com [10.40.204.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EC6F649AD for ; Wed, 3 Jan 2018 06:06:03 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 3 Jan 2018 07:06:01 +0100 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] qemuBuildMemPathStr: Forbid memoryBacking/access for non-numa case X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 03 Jan 2018 06:06:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1448149 If a domain has no numa nodes, that means we don't put any memory-backend-file onto the qemu command line. That in turn means we can't set access=3D'shared'. Therefore, we should produce an error instead of ignoring the setting silently. Signed-off-by: Michal Privoznik --- diff to v2: - switched from check at cmd line generation to validation callback (as requested in review). src/qemu/qemu_domain.c | 29 ++++++++- tests/qemuxml2argvdata/hugepages-memaccess3.xml | 87 +++++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 3 + 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/hugepages-memaccess3.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 43bd0fff4..70fb40650 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3997,6 +3997,30 @@ qemuDomainDeviceDefValidateController(const virDomai= nControllerDef *controller, } =20 =20 +static int +qemuDomainDeviceDefValidateMemory(const virDomainMemoryDef *memory ATTRIBU= TE_UNUSED, + const virDomainDef *def) +{ + const long system_page_size =3D virGetSystemPageSizeKB(); + + /* We can't guarantee any other mem.access + * if no guest NUMA nodes are defined. */ + if (def->mem.nhugepages !=3D 0 && + def->mem.hugepages[0].size !=3D system_page_size && + virDomainNumaGetNodeCount(def->numa) =3D=3D 0 && + def->mem.access !=3D VIR_DOMAIN_MEMORY_ACCESS_DEFAULT && + def->mem.access !=3D VIR_DOMAIN_MEMORY_ACCESS_PRIVATE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("memory access mode '%s' not supported " + "without guest numa node"), + virDomainMemoryAccessTypeToString(def->mem.access)); + return -1; + } + + return 0; +} + + static int qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, const virDomainDef *def, @@ -4052,6 +4076,10 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef= *dev, qemuCaps); break; =20 + case VIR_DOMAIN_DEVICE_MEMORY: + ret =3D qemuDomainDeviceDefValidateMemory(dev->data.memory, def); + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -4063,7 +4091,6 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef = *dev, case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: - case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_IOMMU: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LAST: diff --git a/tests/qemuxml2argvdata/hugepages-memaccess3.xml b/tests/qemuxm= l2argvdata/hugepages-memaccess3.xml new file mode 100644 index 000000000..8ec38d802 --- /dev/null +++ b/tests/qemuxml2argvdata/hugepages-memaccess3.xml @@ -0,0 +1,87 @@ + + fedora + 63840878-0deb-4095-97e6-fc444d9bc9fa + 4194304 + 4194304 + + + + + 4 + + hvm + + + + + + + + + + + + + + + + destroy + restart + destroy + + + + + + /usr/bin/qemu-system-x86_64 + + + + + +
+ + +
+ + + +
+ + +
+ + +
+ + + + + + + + + + + +
+ + + + + + + + + +