From nobody Tue Apr 23 17:27:38 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1682711873; cv=none; d=zohomail.com; s=zohoarc; b=ExTtET2YQD/koyw/Oz+wsDx9CCY3jStrkqdOJWj9f7DM2G1GRtknMRthX1QxHbTen1vZl8G6Dp++v82X1Uz/ruNauFf66Lk6cd2+/x3Gf9VkBbJPZhVHc6JLHKrWULRmSawoT/br6pxcaB0AB1j0yaPRAuT+NkKWuaB1sIiySys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682711873; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pViZm+PVxNshEHLakMdDyYDGsVbM9wNfQLiOfbCRRYw=; b=cPsWxT3w+bxqr/GghYLy7osjSvl9I6oRQU6m+Y/aweVFTA91ubDK6tBD6liBUemTmXUyCQ6w1n833xsJl8YqJJ20FNlTwIpyZojQMrylglQKDJf2W4HZ8BnBgHCOqomgPMYLv5lVfNnF6YV1R0W9pKZA4VAJu0vMEaYF360nRxk= 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 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 1682711873369405.69152766377033; Fri, 28 Apr 2023 12:57:53 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-315-L1q25GGyP2KNBoNcmLYmUg-1; Fri, 28 Apr 2023 15:57:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 819D2A0F388; Fri, 28 Apr 2023 19:57:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DE3D35443; Fri, 28 Apr 2023 19:57:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 609141946A49; Fri, 28 Apr 2023 19:57:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 937A31946A4F for ; Fri, 28 Apr 2023 19:57:42 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 839822166BA0; Fri, 28 Apr 2023 19:57:42 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B34A2166B5E for ; Fri, 28 Apr 2023 19:57:42 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E43C384CC40 for ; Fri, 28 Apr 2023 19:57:42 +0000 (UTC) Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-199-HY1H1GgmOCex6spBOSD5mw-1; Fri, 28 Apr 2023 15:57:40 -0400 Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-18f16a2c329so13594734fac.0 for ; Fri, 28 Apr 2023 12:57:40 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([179.111.98.125]) by smtp.gmail.com with ESMTPSA id e6-20020a056870a60600b0017aafd12843sm9167706oam.32.2023.04.28.12.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Apr 2023 12:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682711872; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=pViZm+PVxNshEHLakMdDyYDGsVbM9wNfQLiOfbCRRYw=; b=BiyBkEbzsIU1tVaPHCbWug+4+JdBtxQ7b/WOjf8hjmyjsHBGCz/prOsJNa+ZgV8f87aNIm WoAcG/fwgEhV4rO8BjgYXSPdu79E2TMg5VLc0d6/On/ZEe8tk7tKDYblNMrhQ+6VyKVUlX V0ijKNpJMz8oM+52PMEAdE1ur5tXJbg= X-MC-Unique: L1q25GGyP2KNBoNcmLYmUg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: HY1H1GgmOCex6spBOSD5mw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682711859; x=1685303859; 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=EErBp31BqoqT1pbAT2AaerLaPOz4sEhbt38V+HpsqkHHPH4mpx99t5dJJRql70WJwM rHlfCMU1PfQ0sMh/8HwOnxBc9TnP366R3OKzZJTE3M28bdAnHe+lJFwdeurXDxR+NaGr Mb+ENXfh+Z2oX6lZO5/dwMv8pY/Vlijuk8AoA3w27IL4zDjKvOyP9EhlwVBsevWOyun0 JOx6eruDSAbwh3FSzheVHvJbVUG70Ejw5FL0eK9eCTi6DCbv/mUZ09ZVndz2KMTItgyn RzgUqrNlyMHh4ByHSVwgiLjWDsSogUJ5OQhNVjvdY+gwxmKsqfyMpfX3coa+DYPDUXez ovuw== X-Gm-Message-State: AC+VfDw39yTlg4MiM6JHfeXEmfjfqOQelYgMJze0Q1dIfrdXf1oBHIIq Uv2bngo9lZLg4bjHIy6955UItE0bUrV1uG940js= X-Google-Smtp-Source: ACHHUZ75dCP69aPx9e55GP+xA3CQAgM7Bsv91kDcm+S8VG9oPzIpgNbNglF9c/QJNUrCVRZM816vfQ== X-Received: by 2002:a05:6870:5b0a:b0:184:3a8c:87f7 with SMTP id ds10-20020a0568705b0a00b001843a8c87f7mr3098922oab.15.1682711859125; Fri, 28 Apr 2023 12:57:39 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 1/1] cpu_riscv64.c: add update() implementation Date: Fri, 28 Apr 2023 16:57:28 -0300 Message-Id: <20230428195728.334324-2-dbarboza@ventanamicro.com> In-Reply-To: <20230428195728.334324-1-dbarboza@ventanamicro.com> References: <20230428195728.334324-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dbarboza@ventanamicro.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: ventanamicro.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682711874349100001 Content-Type: text/plain; charset="utf-8"; x-default="true" 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