From nobody Sat Feb 7 04:26:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1645518405; cv=none; d=zohomail.com; s=zohoarc; b=FWpcXX+N23AcWGDXpmibEIzr0sD9a+e87gdjmylQt5/8XLm9kep+9nCEmkM7dxMi2YP852IqzFhO6Nzi20LxqKKIKQyg3D7D+GgzQYMYVfkvwL6XRcDYOd0mVwi6p3xriZgg9zhAECgdIP71qZOarIib6+Na/c0qov/rTiAcvCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645518405; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=sby1kMZ4CmWp6NwkUzP51lga1WUSCtLJJ2N/D2qsR/8=; b=T3FSqLe41h4tlYvAgXc4xv0LpsH55CfyJnVZWGQnhwjEtleWOEWYTe9yhRG21pTAi3GiG1ijJ/DrX4UZFgMisphcfVpsZbG74vWnBWThDuF7YcCbcgoS5+9+sCHzFGry7+VY3W4aEx62xL0i7q/90hRpCx4l6h0Dqp02tqKqz38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1645518405630120.23762966810841; Tue, 22 Feb 2022 00:26:45 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-hSztzpZuMEiAAb3z9OoIcA-1; Tue, 22 Feb 2022 03:26:40 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C68846D4E8; Tue, 22 Feb 2022 08:26:35 +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 5D7116F975; Tue, 22 Feb 2022 08:26:35 +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 3ACE31809C98; Tue, 22 Feb 2022 08:26:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21M8QXaM007088 for ; Tue, 22 Feb 2022 03:26:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 088A07B6C0; Tue, 22 Feb 2022 08:26:33 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 585877B6C1; Tue, 22 Feb 2022 08:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645518404; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sby1kMZ4CmWp6NwkUzP51lga1WUSCtLJJ2N/D2qsR/8=; b=FadiYnwDUAl+8+1LbxU2zSw7DShryNNibAwz0tNAEY6DR8h/oiJZsODbObCmZXeQWwZdSD 4klqATndE56H4kXXZZpyQSeEcp20RgaLnuabzIJohH2dc6kj6mkhbGBBkzkjCWh68RHu1q U/lWqQzbGpQvc71OtLsdUSe2OkAqo6k= X-MC-Unique: hSztzpZuMEiAAb3z9OoIcA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu: Don't ignore failure when building default memory backend Date: Tue, 22 Feb 2022 09:26:07 +0100 Message-Id: <305ba662673301087b68b9bcf02c5a869ef160ea.1645518367.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: chas@chasmo.org 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645518406598100001 Content-Type: text/plain; charset="utf-8" When building the default memory backend (which has id=3D'pc.ram') and no guest NUMA is configured then qemuBuildMemCommandLineMemoryDefaultBackend() is called. However, its return value is ignored which means that on invalid configuration (e.g. when non-existent hugepage size was requested) an error is reported into the logs but QEMU is started anyway. And while QEMU does error out its error message doesn't give much clue what's going on: qemu-system-x86_64: Memory backend 'pc.ram' not found While at it, introduce a test case. While I could chose a nice looking value (e.g. 4MiB) that's exactly what I wanted to avoid, because while such value might not be possible on x84_64 it may be possible on other arches (e.g. ppc is notoriously known for supporting wide range of HP sizes). Let's stick with obviously wrong value of 5MiB. Reported-by: Charles Polisher Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 5 ++-- .../hugepages-default-5M.x86_64-latest.err | 1 + .../qemuxml2argvdata/hugepages-default-5M.xml | 27 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/hugepages-default-5M.x86_64-late= st.err create mode 100644 tests/qemuxml2argvdata/hugepages-default-5M.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2c963a7297..c836799888 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7369,8 +7369,9 @@ qemuBuildMemCommandLine(virCommand *cmd, * regular memory because -mem-path and -mem-prealloc are obsolete. * However, if domain has one or more NUMA nodes then there is no * default RAM and we mustn't generate the memory object. */ - if (!virDomainNumaGetNodeCount(def->numa)) - qemuBuildMemCommandLineMemoryDefaultBackend(cmd, def, priv, de= faultRAMid); + if (!virDomainNumaGetNodeCount(def->numa) && + qemuBuildMemCommandLineMemoryDefaultBackend(cmd, def, priv, de= faultRAMid) < 0) + return -1; } else { /* * Add '-mem-path' (and '-mem-prealloc') parameter here if diff --git a/tests/qemuxml2argvdata/hugepages-default-5M.x86_64-latest.err = b/tests/qemuxml2argvdata/hugepages-default-5M.x86_64-latest.err new file mode 100644 index 0000000000..bf5e54c9e4 --- /dev/null +++ b/tests/qemuxml2argvdata/hugepages-default-5M.x86_64-latest.err @@ -0,0 +1 @@ +internal error: Unable to find any usable hugetlbfs mount for 5120 KiB diff --git a/tests/qemuxml2argvdata/hugepages-default-5M.xml b/tests/qemuxm= l2argvdata/hugepages-default-5M.xml new file mode 100644 index 0000000000..280ea4bb71 --- /dev/null +++ b/tests/qemuxml2argvdata/hugepages-default-5M.xml @@ -0,0 +1,27 @@ + + NonExistentPageSize + 21433e10-aea8-434a-8f81-55781c2e9035 + 4194304 + 4194304 + + + + + + 2 + + hvm + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 9c5c394e03..a32c5a8250 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1270,6 +1270,7 @@ mymain(void) DO_TEST("hugepages-default", QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("hugepages-default-2M", QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("hugepages-default-system-size", QEMU_CAPS_OBJECT_MEMORY_FILE); + DO_TEST_CAPS_LATEST_FAILURE("hugepages-default-5M"); DO_TEST_PARSE_ERROR_NOCAPS("hugepages-default-1G-nodeset-2M"); DO_TEST("hugepages-nodeset", QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST_PARSE_ERROR("hugepages-nodeset-nonexist", --=20 2.34.1