From nobody Sun Nov 24 07:58:49 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=1724831838; cv=none; d=zohomail.com; s=zohoarc; b=O0G3/fU4qYuGsR7HCwGPz7SmfRqZ2MAPNn7W7380VIXbNOTAXoENN5AZNov4rVkBE9b0Upgq58mHCm+JYH7mItwTBklTe6wAfPB9dO+w6fxDKHrqK44gdzWzWBQROY1++oNBgNvT5SWRpAKG3HkpFCCNYOrszQfs9K3+E3WxOlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724831838; h=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=19Zh4Zt/ZVNN5Ajo9sSQWEIPYsVM5bJD7k1vakhLQ/o=; b=KzI9BLfp4Nwi+mvfqoZGCEXsGT6UfG9woE5y3MEDtbf0QxPQ5wYmaBKVkw72j2k88Kva6utTrtJ9vfBncI8JSZjLKLOXYkNmfCpmplXfaV+beivfxdn0dbI47gPSZUsY/VuLb1AvcHqWW03MjHxOQl57wauClYsLrkUJQJisA1U= 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 1724831838237517.9947854300916; Wed, 28 Aug 2024 00:57:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjDXs-0003ZX-Rv; Wed, 28 Aug 2024 03:56:48 -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 1sjDXs-0003WP-0w for qemu-devel@nongnu.org; Wed, 28 Aug 2024 03:56:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sjDXq-00062z-Cx for qemu-devel@nongnu.org; Wed, 28 Aug 2024 03:56:47 -0400 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-56-QUjmGGYVMUeqQvgCgYAPQw-1; Wed, 28 Aug 2024 03:56:43 -0400 Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-7b696999c65so5398011a12.3 for ; Wed, 28 Aug 2024 00:56:42 -0700 (PDT) Received: from localhost.localdomain ([115.96.157.236]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2d8445fbf0dsm1013534a91.19.2024.08.28.00.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 00:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724831805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=19Zh4Zt/ZVNN5Ajo9sSQWEIPYsVM5bJD7k1vakhLQ/o=; b=MhYmjhv010YmAqOdtuZBh+yIscWMJonTqbY36dn1vSzwLzB9yxQNswh+Ml+0uTKGVYQEiV jOV3lNNhC0bbuPMykIwbVRHFKquaFYzARHJie/7TS7db1pMVyS/Gu0VsafPVuCKnEXHBse IHh+GuAIpfTSAHQYcFM9tTA1Kuiq4Ww= X-MC-Unique: QUjmGGYVMUeqQvgCgYAPQw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724831802; x=1725436602; 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=19Zh4Zt/ZVNN5Ajo9sSQWEIPYsVM5bJD7k1vakhLQ/o=; b=p4RR/PfaeGZIsbYCENZHVhqaBzLgVGnERCP+ZrVwlBkv9CHoGJjuELvuD1wScILQEA FKxZNm5fU3sYx1JtANIAIpzoQJSFLuRgO4Wr5tMrknPaQimNcyaOLykglf3vVH2G66rV LiXRtpkTDKKGnI4ow/VqHKcBab+Nlml0nSfI5mg/XxTvrHGQ7843GTRXb+rdvvRgS76Q gj3zFYfcvL4fO9AsJPFi1syg9ailLBfHZYJSARxTvzb2mSat6x/harDDyCpWVtTHZiTi gXSCiY0UbUBPrqZDP5yN82KkNw5ne86yNNESWA1Ty5khVq17NC8oNWl5XsaORXfhVH4T dbbw== X-Forwarded-Encrypted: i=1; AJvYcCVAdLOprADfMHP3xLH9vcFcl1bVRQOqheuCysv2Z0NYLwD4DDo6+vjyZKqG6N5avyVapOEuuTcyUhap@nongnu.org X-Gm-Message-State: AOJu0YxH1v8H+FuOl1m/SX0PTZpKpdBdOGoG+vRpfWgy8/f45DgSl5J3 yBJ9xP5pnX/pBbC10VIOE5dZXMpfG3KH6I4BLoJhTzwSBoieJkDyz3O1v/Bsk4Dv/5OJFCt6Uk7 hcKdrYWgoddiwcue4RQkw1tzrq5r1SKNf1q0ZaFbtwlj/D5x5bX0S X-Received: by 2002:a05:6a21:3409:b0:1c4:d4b2:ffe6 with SMTP id adf61e73a8af0-1ccd288d5d0mr1009068637.19.1724831801978; Wed, 28 Aug 2024 00:56:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/HVRKqcTrIT/WM260RBM0Z07SE8tr4atgSV/pWEwV/3FDxDJ6N7qyGLfHX0GADHsgfQ5siA== X-Received: by 2002:a05:6a21:3409:b0:1c4:d4b2:ffe6 with SMTP id adf61e73a8af0-1ccd288d5d0mr1009052637.19.1724831801581; Wed, 28 Aug 2024 00:56:41 -0700 (PDT) From: Ani Sinha To: Paolo Bonzini Cc: Ani Sinha , qemu-trivial@nongnu.org, zhao1.liu@intel.com, armbru@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: [PATCH v5 1/2] kvm: replace fprintf with error_report()/printf() in kvm_init() Date: Wed, 28 Aug 2024 13:26:28 +0530 Message-ID: <20240828075630.7754-2-anisinha@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240828075630.7754-1-anisinha@redhat.com> References: <20240828075630.7754-1-anisinha@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.133.124; envelope-from=anisinha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1724831839677116600 Content-Type: text/plain; charset="utf-8" error_report() is more appropriate for error situations. Replace fprintf wi= th error_report() and error_printf() as appropriate. Cosmetic. No functional change. CC: qemu-trivial@nongnu.org CC: zhao1.liu@intel.com CC: armbru@redhat.com Reviewed-by: Zhao Liu Signed-off-by: Ani Sinha Reviewed-by: Markus Armbruster --- accel/kvm/kvm-all.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) changelog: v2: fix a bug. v3: replace one instance of error_report() with error_printf(). added tags. v4: changes suggested by Markus. v5: more changes from Markus's comments on v4. diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 75d11a07b2..fcc157f0e6 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2427,7 +2427,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; } @@ -2437,13 +2437,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 @@ -2488,26 +2488,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; @@ -2526,9 +2522,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); } } @@ -2542,8 +2538,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.42.0 From nobody Sun Nov 24 07:58:49 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=1724831857; cv=none; d=zohomail.com; s=zohoarc; b=XOeAoZRYADuXgpqXcm32Ge0WXvt9T72ILN+4GK/CJYp3rWN/sShj7hdruhKNttP93KhztpUgnt2Mijdn2uqMyxh6afXvR0W/hs8Ci8wDQUMxiR9TAwB0OV2dYPntQN/fDv1N+VAm0RjWw8JI6kNoNLvaHOJRCFohcrY3eerKpN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724831857; h=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=zYl3uaCkxHjT2nDUPL1WDle3wL/fOkENv7M02v+JPJY=; b=VBUirlUTOOJR51TzON6cvcAw0Y0g1Q8R3JRMFJM+7Qg04HEljLJZ1KHSqfzOShnjVhlBOGhAKC0OmVL2X6u+wYRPJ47Sy3WgS99vg5pFWOdaUxzFny5A6nyFPdJuEUm5LGMgPWelMj2OPnJqxiYMq3Dnmb5XFMNmBdn5+1RSOdk= 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 1724831857065732.0815158193275; Wed, 28 Aug 2024 00:57:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjDXx-0003qd-2j; Wed, 28 Aug 2024 03:56:53 -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 1sjDXv-0003kd-Ha for qemu-devel@nongnu.org; Wed, 28 Aug 2024 03:56:51 -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 1sjDXt-00063P-TH for qemu-devel@nongnu.org; Wed, 28 Aug 2024 03:56:51 -0400 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-79-_kZeOcCDNsGjIvYf3daHUA-1; Wed, 28 Aug 2024 03:56:46 -0400 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-2d441cdb503so7307789a91.1 for ; Wed, 28 Aug 2024 00:56:46 -0700 (PDT) Received: from localhost.localdomain ([115.96.157.236]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2d8445fbf0dsm1013534a91.19.2024.08.28.00.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 00:56:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724831809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zYl3uaCkxHjT2nDUPL1WDle3wL/fOkENv7M02v+JPJY=; b=gKUQIaDN87zxthEiqYIYbBSEqQwloMn60Fxtbv0sMIJcszFEEOSQ+clgybuHEzIg4/7+H3 ZYfi4q+Ha/a/sd47dDjGFccjOJapRZdxtbGi3tgoPVeksH3AaoCT75laGVjhpApjv8RRoT dFgocKvPQShPJBMqkjozIto3vxE8yn8= X-MC-Unique: _kZeOcCDNsGjIvYf3daHUA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724831805; x=1725436605; 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=zYl3uaCkxHjT2nDUPL1WDle3wL/fOkENv7M02v+JPJY=; b=R9fwfj+XcjCkDROh6dLjyiWbidr68apeoNtQjBRdBzLo9tx+X6s6d8zM72HfObphmI LoD2bpQBVIjzTDU2D9eOXD1gbzRrCnFlmXoI5rxlz11U6FBZsQlCHYFa1pCGKBmnSjTq w7fLbKg+xZu76TFANWnDfxYDoUAQYD6iF8GQgSm/WjyE8LkdNLBaKqr1vU9FCCOGmEd+ 7bQZ/5I/2hQkRZOLPBDzSHnc9wD4WNJczHPoziyyaKj/1epONuz8JKqQDf5wWgnvUICP miAHAWNvlQVN4gb2owo4jeDvThwKGTQazy7GhvDteaCDbjyX8mspJmYn9cHKPkEBefyr LPxA== X-Forwarded-Encrypted: i=1; AJvYcCWDjak40Hq1V/VqiPEZAb0Oz1X3sY7jn7jdVJWtbcEcvUvY8l/f/oDxTfEyMW+72sW7BmDo2S/DFx4P@nongnu.org X-Gm-Message-State: AOJu0YzOXaFBb7N/QrxJU0/k00qgnWJ/corloWLap+kKhis5lOWYvuH9 IpZgoJEi77+rZCbUuHoW5iUsUIIqBVAc1oP0lka2FngqAQluFh7yMYLK1Q4WuWdTpW0dpO5yRA9 j5kO6AKOwy+QJYcbykF0hquN5MdRAUVqF/dHi/Oyl3+tSNOfPqUUR X-Received: by 2002:a17:90a:7408:b0:2d3:cc3e:4d6d with SMTP id 98e67ed59e1d1-2d646b91092mr14510028a91.9.1724831805447; Wed, 28 Aug 2024 00:56:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnS9wmiNKpmg/gLxiSQVdrbd8UyjUO09X7ptuxTKXWPb9mBB1kZo5ol5VgojZc/qD+8UvY6w== X-Received: by 2002:a17:90a:7408:b0:2d3:cc3e:4d6d with SMTP id 98e67ed59e1d1-2d646b91092mr14510013a91.9.1724831805035; Wed, 28 Aug 2024 00:56:45 -0700 (PDT) From: Ani Sinha To: Paolo Bonzini Cc: Ani Sinha , zhao1.liu@intel.com, cfontana@suse.de, armbru@redhat.com, qemu-trivial@nongnu.org, kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: [PATCH v5 2/2] kvm: refactor core virtual machine creation into its own function Date: Wed, 28 Aug 2024 13:26:29 +0530 Message-ID: <20240828075630.7754-3-anisinha@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240828075630.7754-1-anisinha@redhat.com> References: <20240828075630.7754-1-anisinha@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=anisinha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1724831859018116600 Content-Type: text/plain; charset="utf-8" Refactoring the core logic around KVM_CREATE_VM into its own separate funct= ion so that it can be called from other functions in future patches. There is no functional change in this patch. CC: pbonzini@redhat.com CC: zhao1.liu@intel.com CC: cfontana@suse.de CC: armbru@redhat.com CC: qemu-trivial@nongnu.org Reviewed-by: Zhao Liu Reviewed-by: Claudio Fontana Signed-off-by: Ani Sinha --- accel/kvm/kvm-all.c | 86 ++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 33 deletions(-) v2: s/fprintf/warn_report as suggested by zhao v3: s/warn_report/error_report. function names adjusted to conform to other names. fprintf -> error_report() moved to its own patch. v4: added tags and rebased. v5: rebased. diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index fcc157f0e6..cf3d820b94 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2385,6 +2385,57 @@ uint32_t kvm_dirty_ring_size(void) return kvm_state->kvm_dirty_ring_size; } =20 +static int kvm_create_vm(MachineState *ms, KVMState *s, int type) +{ + int ret; + + do { + ret =3D kvm_ioctl(s, KVM_CREATE_VM, type); + } while (ret =3D=3D -EINTR); + + if (ret < 0) { + error_report("ioctl(KVM_CREATE_VM) failed: %s", strerror(-ret)); + +#ifdef TARGET_S390X + if (ret =3D=3D -EINVAL) { + 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) { + error_printf("PPC KVM module is not loaded. Try modprobe kvm_%= s.\n", + (type =3D=3D 2) ? "pr" : "hv"); + } +#endif + } + + return ret; +} + +static int kvm_machine_type(MachineState *ms) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + int type; + + if (object_property_find(OBJECT(current_machine), "kvm-type")) { + g_autofree char *kvm_type; + kvm_type =3D object_property_get_str(OBJECT(current_machine), + "kvm-type", + &error_abort); + type =3D mc->kvm_type(ms, kvm_type); + } else if (mc->kvm_type) { + type =3D mc->kvm_type(ms, NULL); + } else { + type =3D kvm_arch_get_default_type(ms); + } + return type; +} + static int kvm_init(MachineState *ms) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); @@ -2467,45 +2518,14 @@ static int kvm_init(MachineState *ms) } s->as =3D g_new0(struct KVMAs, s->nr_as); =20 - if (object_property_find(OBJECT(current_machine), "kvm-type")) { - g_autofree char *kvm_type =3D object_property_get_str(OBJECT(curre= nt_machine), - "kvm-type", - &error_abort); - type =3D mc->kvm_type(ms, kvm_type); - } else if (mc->kvm_type) { - type =3D mc->kvm_type(ms, NULL); - } else { - type =3D kvm_arch_get_default_type(ms); - } - + type =3D kvm_machine_type(ms); if (type < 0) { ret =3D -EINVAL; goto err; } =20 - do { - ret =3D kvm_ioctl(s, KVM_CREATE_VM, type); - } while (ret =3D=3D -EINTR); - + ret =3D kvm_create_vm(ms, s, type); if (ret < 0) { - error_report("ioctl(KVM_CREATE_VM) failed: %s", strerror(-ret)); - -#ifdef TARGET_S390X - if (ret =3D=3D -EINVAL) { - 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) { - error_printf("PPC KVM module is not loaded. Try modprobe kvm_%= s.\n", - (type =3D=3D 2) ? "pr" : "hv"); - } -#endif goto err; } =20 --=20 2.42.0