From nobody Tue Sep 9 23:58:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1737559078439367.1120005883856; Wed, 22 Jan 2025 07:17:58 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3B4B4149C; Wed, 22 Jan 2025 10:17:57 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B14401533; Wed, 22 Jan 2025 10:17:15 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 00A7F142C; Wed, 22 Jan 2025 10:17:11 -0500 (EST) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 501F1142D for ; Wed, 22 Jan 2025 10:17:11 -0500 (EST) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-21619108a6bso122140505ad.3 for ; Wed, 22 Jan 2025 07:17:11 -0800 (PST) Received: from grind.. ([191.202.238.10]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21c2d402f7dsm96059215ad.216.2025.01.22.07.17.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 07:17:09 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1737559030; x=1738163830; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pViZm+PVxNshEHLakMdDyYDGsVbM9wNfQLiOfbCRRYw=; b=MLmqFpat+wbx8qtL/sS/WWKQVQbc/iGF5r34XdI1TpKh0UrShipLKG4vlK/hATB1YT 8ykINDztrnqlZx2oRqa8Ss520RxjdlR18AMQ0siOZ8yV/5vWac3WEhSdODdmjWxBB9nx wme0NLAOo1ovZtYuOaZClBROYT4fDrv0gWnXSaCKpOjd8dJsvGgOjybENGp3EEty7/fZ YCH/TbYNvgT0ME18W/K/5JFWJI4As6WZZPmIVAxhvDLxzN0J7jAWB0Cu6LezjDSETRgU 7jw1GCbIhoTcD2ecbVdiqD2z0R9ncT/sIJtA+MDAJpkyFyJD2N9cG8j6Cx0tVzEE9FzV hHgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737559030; x=1738163830; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pViZm+PVxNshEHLakMdDyYDGsVbM9wNfQLiOfbCRRYw=; b=CXaHg+TBSsm0Mbl0DLgaMvEuY5/KIRPbyEyiiJ91NDNrLhUAVO0vTADbsnxLXaU9sC 7wxTE/68poitBkpRjYPpU8R7Uxsd9pqEmM78krG/vszPuRk1zi2cPnFRMGvM5Yt3YZRT do1AWaTm7f+qPJBoQqaMSqzT89QweXLlDqDVJ3ZvvIk1o3rB9NLwIo/05TM9aDIiEi8y Ud+C/qDQ2X556KcNgtdV1dRCNgLb/yesyOaZQjGqspHna7F6VVxXLNqM1cgszl3nBuFA nwwWyOXoqz4iKBtKMd72Hbdr4ALCfV9u+5sraTfBjh2ITy5XPyE7A3ReyUtqPhEE6EHN UnnA== X-Gm-Message-State: AOJu0YyCQkmKXmgio+STCtqkq8Jdm2pbXd5CILXkMOglOk7ehzOo6T+n 4h1nEsDlW82ylQue7+87keHiQ7cMXA2Sz1p8G2yysjVggEi9wyekUZjjRsxEXcMbxL/0bdkQKwo s X-Gm-Gg: ASbGncu+UQCQUZccignQJzrZH0ZzYGrEttCzoa/ytaxIBha3LGMgX/Ii1RDQ1wFc84d MfuWpo8hcXCWhRhKA7S8byxMmPRz0qavxU2OAMy8pHF8DqS+uzrprH4YD+UTaFogqN+duApy0oq 7a53XCFnhz4moKCCj+PzjdVJHRHqsnIypk//8P4eVTmqUOFlN3L5NDkexo8tFTpJu9OBhaRlW3+ oS9OPc6V12eCDy/xSplpVyHyWMov3gZypD9xAII4kcv3zb3NpP/K/2SbpouVjfSW1dbzg92 X-Google-Smtp-Source: AGHT+IEBYBW5opppozWvdmV+fPmtZUFysS1PMAHOChltfCajvBlgQXJUyNAHryyxYMOFAhiILhL50g== X-Received: by 2002:a17:902:db07:b0:215:b9a7:5282 with SMTP id d9443c01a7336-21c3554b516mr316469355ad.26.1737559029808; Wed, 22 Jan 2025 07:17:09 -0800 (PST) From: Daniel Henrique Barboza To: devel@lists.libvirt.org Subject: [PATCH v2 1/1] cpu_riscv64.c: add update() implementation Date: Wed, 22 Jan 2025 12:16:59 -0300 Message-ID: <20250122151702.95617-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250122151702.95617-1-dbarboza@ventanamicro.com> References: <20250122151702.95617-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CFXLWDO32CIEWQF6UNY5L3PDETVHEXHY X-Message-ID-Hash: CFXLWDO32CIEWQF6UNY5L3PDETVHEXHY X-MailFrom: dbarboza@ventanamicro.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: dbarboza@ventanamicro.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1737559081826019000 Content-Type: text/plain; charset="utf-8" At this moment it is not possible to launch a 'riscv64' domain if a CPU definition is presented in the domain. For example, adding this CPU definition: rv64 Will trigger the following error: $ sudo ./run tools/virsh start riscv-virt1 error: Failed to start domain 'riscv-virt1' error: this function is not supported by the connection driver: cannot update guest CPU for riscv64 architecture The error comes from virCPUUpdate(), via qemuProcessUpdateGuestCPU(), and it's caused by the absence of the 'update' API in the existing RISC-V driver. Add an 'update' API impl to the RISC-V driver to allow for CPU definitions to be declared in RISC-V domains. This API was copied from the ARM driver (virCPUarmUpdate()) since it's a good enough implementation to get us going. Signed-off-by: Daniel Henrique Barboza --- po/POTFILES | 1 + src/cpu/cpu_riscv64.c | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/po/POTFILES b/po/POTFILES index b122f02818..5d6ec195b4 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -70,6 +70,7 @@ src/cpu/cpu.c src/cpu/cpu_arm.c src/cpu/cpu_map.c src/cpu/cpu_ppc64.c +src/cpu/cpu_riscv64.c src/cpu/cpu_s390.c src/cpu/cpu_x86.c src/datatypes.c diff --git a/src/cpu/cpu_riscv64.c b/src/cpu/cpu_riscv64.c index c44bdeb291..4cb795f849 100644 --- a/src/cpu/cpu_riscv64.c +++ b/src/cpu/cpu_riscv64.c @@ -46,6 +46,32 @@ virCPURiscv64ValidateFeatures(virCPUDef *cpu G_GNUC_UNUS= ED) } =20 =20 +static int +virCPURiscv64Update(virCPUDef *guest, + const virCPUDef *host, + bool relative) +{ + g_autoptr(virCPUDef) updated =3D virCPUDefCopyWithoutModel(guest); + + if (!relative || guest->mode !=3D VIR_CPU_MODE_HOST_MODEL) + return 0; + + if (!host) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unknown host CPU model")); + return -1; + } + + updated->mode =3D VIR_CPU_MODE_CUSTOM; + virCPUDefCopyModel(updated, host, true); + + virCPUDefStealModel(guest, updated, false); + guest->mode =3D VIR_CPU_MODE_CUSTOM; + guest->match =3D VIR_CPU_MATCH_EXACT; + + return 0; +} + struct cpuArchDriver cpuDriverRiscv64 =3D { .name =3D "riscv64", .arch =3D archs, @@ -54,6 +80,6 @@ struct cpuArchDriver cpuDriverRiscv64 =3D { .decode =3D NULL, .encode =3D NULL, .baseline =3D NULL, - .update =3D NULL, + .update =3D virCPURiscv64Update, .validateFeatures =3D virCPURiscv64ValidateFeatures, }; --=20 2.40.0