From nobody Thu May 2 03:32:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1486402430990650.3261493525274; Mon, 6 Feb 2017 09:33:50 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16HU5G8047971; Mon, 6 Feb 2017 12:30:06 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v16HU4Q0026460 for ; Mon, 6 Feb 2017 12:30:04 -0500 Received: from inaba.usersys.redhat.com ([10.34.129.229]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16HU2Ii031235 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 6 Feb 2017 12:30:03 -0500 From: Andrea Bolognani To: libvir-list@redhat.com Date: Mon, 6 Feb 2017 18:29:59 +0100 Message-Id: <1486402199-13957-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Forbid without 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In order for memory locking to work, the hard limit on memory locking (and usage) has to be set appropriately by the user. The documentation mentions the requirement already: with this patch, it's going to be enforced by runtime checks as well. Note that this will make existing guests that don't satisfy the requirement disappear; that said, such guests have never been able to start in the first place. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1316774 --- src/qemu/qemu_domain.c | 20 ++++++++++++++++= ++++ tests/qemuxml2argvdata/qemuxml2argv-mlock-on.xml | 3 +++ ....xml =3D> qemuxml2argv-mlock-without-hardlimit.xml} | 0 tests/qemuxml2argvtest.c | 1 + 4 files changed, 24 insertions(+) copy tests/qemuxml2argvdata/{qemuxml2argv-mlock-on.xml =3D> qemuxml2argv-m= lock-without-hardlimit.xml} (100%) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c6ce090..bb29cfe 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2629,6 +2629,23 @@ qemuDomainDefVcpusPostParse(virDomainDefPtr def) =20 =20 static int +qemuDomainDefMemoryLockingPostParse(virDomainDefPtr def) +{ + /* Memory locking can only work properly if the memory locking limit + * for the QEMU process has been raised appropriately: the default one + * is extrememly low, so there's no way the guest will fit in there */ + if (def->mem.locked && !virMemoryLimitIsSet(def->mem.hard_limit)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Setting requires " + " to be set as well")); + return -1; + } + + return 0; +} + + +static int qemuDomainDefPostParse(virDomainDefPtr def, virCapsPtr caps, unsigned int parseFlags, @@ -2692,6 +2709,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, if (qemuDomainDefVcpusPostParse(def) < 0) goto cleanup; =20 + if (qemuDomainDefMemoryLockingPostParse(def) < 0) + goto cleanup; + ret =3D 0; cleanup: virObjectUnref(qemuCaps); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mlock-on.xml b/tests/qemux= ml2argvdata/qemuxml2argv-mlock-on.xml index 20a5eaa..2046663 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-mlock-on.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-mlock-on.xml @@ -3,6 +3,9 @@ c7a5fdbd-edaf-9455-926a-d65c16db1809 219136 219136 + + 256000 + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-mlock-on.xml b/tests/qemux= ml2argvdata/qemuxml2argv-mlock-without-hardlimit.xml similarity index 100% copy from tests/qemuxml2argvdata/qemuxml2argv-mlock-on.xml copy to tests/qemuxml2argvdata/qemuxml2argv-mlock-without-hardlimit.xml diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3532cb5..9b2fec5 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2129,6 +2129,7 @@ mymain(void) DO_TEST_FAILURE("mlock-on", NONE); DO_TEST("mlock-off", QEMU_CAPS_REALTIME_MLOCK); DO_TEST("mlock-unsupported", NONE); + DO_TEST_PARSE_ERROR("mlock-without-hardlimit", NONE); =20 DO_TEST_PARSE_ERROR("pci-bridge-negative-index-invalid", QEMU_CAPS_DEVICE_PCI_BRIDGE); --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list