From nobody Sun Nov 24 02:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728059803; cv=none; d=zohomail.com; s=zohoarc; b=l4aoHdX/QgOZtzU3wYQtt6hnuUqNFzTd+fPoG4RtkKvKv92iZ3y51WxpTSquhSdKrkyJlYZA0FxNcNaGhDSQOej8iBU0OmlBflT4Trvqu+lVlP7BY3Ezvr81GvqQipo5vrpfEa6vDr2hjpkorDkA8Lx03pqfeZV4VxB3xFxzLLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728059803; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VosZkryxUSxT370xwj32ayTSBQobfpGY1xY5tUlU3gw=; b=I3XcrMevq1A/AKkjd5kwz1RLTmLhIRBzAAvdZPIyAEDQXQX01qUhsBCQQBUI4U8ZdSIm8Lrq2xdWt4Vgdhv0gmokiINWCbPuDc96u10rzMGivr+o4DeSygh8k4G0TZ7+z7fLs9GN0b0Z3LgcBA+8dNKxB9wt3CNUJsjrlqP0mvQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728059803952475.50507791294035; Fri, 4 Oct 2024 09:36:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlGw-0007qs-6m; Fri, 04 Oct 2024 12:35:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swlGS-0006XT-Nt for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swlGR-0006Aj-2v for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:34:48 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-13-YKKkqwU5NXi5AJ4fNLf0bg-1; Fri, 04 Oct 2024 12:34:45 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37cd1fb9497so1690843f8f.1 for ; Fri, 04 Oct 2024 09:34:45 -0700 (PDT) Received: from avogadro.local ([151.95.43.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f86a20537sm19461625e9.15.2024.10.04.09.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 09:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728059686; h=from:from: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; bh=VosZkryxUSxT370xwj32ayTSBQobfpGY1xY5tUlU3gw=; b=hWQ5WpX6frtRSEyuvimQhoQozNTFDRq84nPQAZdJoKNlwpZAKXCz33/rVl6bfRSRlCLpZ/ aqThmZVDiMS1GKGT/MPK8D7aedzRZOdsfWpPHtd/157FmycGgSsFfOw6qdF5D5bwNihHSj Mkl04oovAtBmm6hUw3Xl9iLAV1W26W8= X-MC-Unique: YKKkqwU5NXi5AJ4fNLf0bg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059683; x=1728664483; 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=VosZkryxUSxT370xwj32ayTSBQobfpGY1xY5tUlU3gw=; b=emg1tQSiKlHmgYUV4vW4TEPlDFZe/Ieglz9M26bGbxU3rypXXXDyB6+vAWoiR/30di n2jEJN5u8bQd+vyGTPZdGnHPXChjFs/ntwEuiTwJwqP2L4167zTLbvT6uGjUw8Us3sNX rbKDQ9QkOQSr4XkXmbpPrAd7/TAhwIeWsSwIlRRolkNsUQzSWO6xJ7yqkpArF2YJBi2Q g+GpbNdnoOew34VVmC17YKz+JZxOxCHacFZqT1/+MWsLxKiSKXmPtMraetl39vZCWNqm TZ3GicL4CQJX1LPTbEaloNy+XYlsyroQdhPakOB3rV0PFLp6hqgatV5+AtCwyuqblM8I MRcA== X-Gm-Message-State: AOJu0Yz7abFnhxGUbeb6flQlQSM74X8WesratHErS0M5lqAfgE1Lqt6O eJapycKiaAxCkyDdD4AWtaRLPhUACEzpUeNBW4yqXJM7gSeAO91yaCL7pFV5kSRW/O6uMXuXGDR LGa/NTI0YhJXODLERdg1xq1z2db+GOHPtjM1+2F1YeGL1+j36SgYwm33dUJrYjNDadwdTWuxQjM gQY4NkdUZn0FGwWUXFGHzu8vfbt3AiFlQUfPouUdc= X-Received: by 2002:adf:e412:0:b0:37c:fee5:bfc7 with SMTP id ffacd0b85a97d-37d049ef115mr5009002f8f.15.1728059683289; Fri, 04 Oct 2024 09:34:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHt/dY/luTgOjLNty7OoWj/vwXkvJeOQCoUWpgNv4LcozFxRBS5GCivVI8McZeiBBDzVYoZLQ== X-Received: by 2002:adf:e412:0:b0:37c:fee5:bfc7 with SMTP id ffacd0b85a97d-37d049ef115mr5008985f8f.15.1728059682812; Fri, 04 Oct 2024 09:34:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Ani Sinha , qemu-trivial@nongnu.org, zhao1.liu@intel.com, armbru@redhat.com Subject: [PULL 08/23] kvm: replace fprintf with error_report()/printf() in kvm_init() Date: Fri, 4 Oct 2024 18:34:00 +0200 Message-ID: <20241004163415.951106-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241004163415.951106-1-pbonzini@redhat.com> References: <20241004163415.951106-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.146, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728059805910116600 Content-Type: text/plain; charset="utf-8" From: Ani Sinha error_report() is more appropriate for error situations. Replace fprintf wi= th error_report() and error_printf() as appropriate. Some improvement in error reporting also happens as a part of this change. For example: From: $ ./qemu-system-x86_64 --accel kvm Could not access KVM kernel module: No such file or directory To: $ ./qemu-system-x86_64 --accel kvm qemu-system-x86_64: --accel kvm: Could not access KVM kernel module: No suc= h file or directory CC: qemu-trivial@nongnu.org CC: zhao1.liu@intel.com CC: armbru@redhat.com Reviewed-by: Zhao Liu Reviewed-by: Markus Armbruster Signed-off-by: Ani Sinha Link: https://lore.kernel.org/r/20240828124539.62672-1-anisinha@redhat.com Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index fe4cd721d9b..4c920b7bfe7 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2423,7 +2423,7 @@ static int kvm_init(MachineState *ms) QLIST_INIT(&s->kvm_parked_vcpus); s->fd =3D qemu_open_old(s->device ?: "/dev/kvm", O_RDWR); if (s->fd =3D=3D -1) { - fprintf(stderr, "Could not access KVM kernel module: %m\n"); + error_report("Could not access KVM kernel module: %m"); ret =3D -errno; goto err; } @@ -2433,13 +2433,13 @@ static int kvm_init(MachineState *ms) if (ret >=3D 0) { ret =3D -EINVAL; } - fprintf(stderr, "kvm version too old\n"); + error_report("kvm version too old"); goto err; } =20 if (ret > KVM_API_VERSION) { ret =3D -EINVAL; - fprintf(stderr, "kvm version not supported\n"); + error_report("kvm version not supported"); goto err; } =20 @@ -2484,26 +2484,22 @@ static int kvm_init(MachineState *ms) } while (ret =3D=3D -EINTR); =20 if (ret < 0) { - fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -ret, - strerror(-ret)); + error_report("ioctl(KVM_CREATE_VM) failed: %s", strerror(-ret)); =20 #ifdef TARGET_S390X if (ret =3D=3D -EINVAL) { - fprintf(stderr, - "Host kernel setup problem detected. Please verify:\n"= ); - fprintf(stderr, "- for kernels supporting the switch_amode or" - " user_mode parameters, whether\n"); - fprintf(stderr, - " user space is running in primary address space\n"); - fprintf(stderr, - "- for kernels supporting the vm.allocate_pgste sysctl= , " - "whether it is enabled\n"); + error_printf("Host kernel setup problem detected." + " Please verify:\n"); + error_printf("- for kernels supporting the" + " switch_amode or user_mode parameters, whether"); + error_printf(" user space is running in primary address space\= n"); + error_printf("- for kernels supporting the vm.allocate_pgste" + " sysctl, whether it is enabled\n"); } #elif defined(TARGET_PPC) if (ret =3D=3D -EINVAL) { - fprintf(stderr, - "PPC KVM module is not loaded. Try modprobe kvm_%s.\n", - (type =3D=3D 2) ? "pr" : "hv"); + error_printf("PPC KVM module is not loaded. Try modprobe kvm_%= s.\n", + (type =3D=3D 2) ? "pr" : "hv"); } #endif goto err; @@ -2522,9 +2518,9 @@ static int kvm_init(MachineState *ms) nc->name, nc->num, soft_vcpus_limit); =20 if (nc->num > hard_vcpus_limit) { - fprintf(stderr, "Number of %s cpus requested (%d) exceeds " - "the maximum cpus supported by KVM (%d)\n", - nc->name, nc->num, hard_vcpus_limit); + error_report("Number of %s cpus requested (%d) exceeds " + "the maximum cpus supported by KVM (%d)", + nc->name, nc->num, hard_vcpus_limit); exit(1); } } @@ -2538,8 +2534,8 @@ static int kvm_init(MachineState *ms) } if (missing_cap) { ret =3D -EINVAL; - fprintf(stderr, "kvm does not support %s\n%s", - missing_cap->name, upgrade_note); + error_report("kvm does not support %s", missing_cap->name); + error_printf("%s", upgrade_note); goto err; } =20 --=20 2.46.1