From nobody Tue Feb 10 00:58:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@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 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613735083; cv=none; d=zohomail.com; s=zohoarc; b=BWeTa2QFNX0hGSuzi0nlh5sqmiECUqVrqPCTxtDKdWyCNWtCfPfhXE9bpvw3B3UqOIOsaA5h2jur3b/mfanMHRChrcw/MPVsWFr6HceKdXqu5RQ8bVl3TfRL8HQKNicajDX20QzlwU4pCEbfT+ftFVPKdubPocdv1PH1cGqv+r0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613735083; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=98X4DsBNdk1BN09KWcHx0mE3/gzzTZdKxOLSGajyIeI=; b=gXYMI5Q6Zg88yt0zFo/dAaDdHx8boFMETN6ucoF2IWR3RbRPBq6ofT6zgm9fYbblP4bP9ED3l2aHZFawp8eJ+g/dhYesfGOJEsVq/Eot/MTrUZ9mTXN1fGktAjWuhLX9O4nB7GyBxxkw2HvcMeGr8oUbFMHDJv0/XfsGttQAr58= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1613735083223380.3453129967901; Fri, 19 Feb 2021 03:44:43 -0800 (PST) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-508-JNFrtoNHNFObkRrlhZYfIQ-1; Fri, 19 Feb 2021 06:44:38 -0500 Received: by mail-wr1-f69.google.com with SMTP id f5so2347099wro.7 for ; Fri, 19 Feb 2021 03:44:38 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id w81sm11424135wmb.3.2021.02.19.03.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Feb 2021 03:44:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613735082; 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=98X4DsBNdk1BN09KWcHx0mE3/gzzTZdKxOLSGajyIeI=; b=VZxd9Mx9ED8MOgtOUbEKBRL/xmatQvWi6LkfLk5R6JIuVPbN+gL+/7T+gyCX2DjxB1DU3u PuM1MsrdP/YMXbZ4VUsrDSQAg1O35wID3mrz1vQOQH5dm0rAMfVDD07a1nqwl0gOo1m1GT sqXJcJ7oNDK7DF4MIGomvV9t5MkVrZY= X-MC-Unique: JNFrtoNHNFObkRrlhZYfIQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=98X4DsBNdk1BN09KWcHx0mE3/gzzTZdKxOLSGajyIeI=; b=Wcyw//f63HFpp+9JDqES3ZlNsE9/npwkme03QEZmtCd3eRntK/n34cKxgZGyJ6vlnZ LKTwYC2YmNFsDfSQm4DoCxPZMNUd+/rB/nB7Ippz/iBAwAAOcSRiLoVW4Mh7Cjioj9ry /v4i7HH9W8kRT6IIDfoVVZauEk1H1Wh5z7iICIroZXqCdLhyq+OdMJiMy4fbRYw6IKzi rux1PzS3AbT2022x9JiCFJWf+nOnPf/wuBOaepLESUP+ZEi1XhbaiWXSj2djBuxe755A nxxYsP6gOJYHQROHnyOIDTmZGqFwf1SYhHNg6P5YidVJwPzJ7GLVrLaxKp8fIAEJHwKa K1XQ== X-Gm-Message-State: AOAM533p2cY1nIom38p8n0EAbb4T4m+IPtFhoBbO0eiP/LrxKCsKAO78 G1J+60bcUa669GocA4NUtxYDvmW9jSXyz2UspiTNa7zoZUzasMht49uNMREYZeLaCZKQ2p6QCUg XLha8SyTPECFcvQ== X-Received: by 2002:adf:b357:: with SMTP id k23mr8694367wrd.354.1613735077421; Fri, 19 Feb 2021 03:44:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8BoyDIy3MZrDx4a9/uBNg8Gu4uQrRfjBpdhkb1HenxWvZ3lMMW1roaXGxl/Jsmb64BZpXBA== X-Received: by 2002:adf:b357:: with SMTP id k23mr8694350wrd.354.1613735077292; Fri, 19 Feb 2021 03:44:37 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Radoslaw Biernacki , Paolo Bonzini , qemu-s390x@nongnu.org, Greg Kurz , Marcel Apfelbaum , qemu-arm@nongnu.org, Cornelia Huck , Aleksandar Rikalo , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , Huacai Chen , Aurelien Jarno , Richard Henderson , "Edgar E. Iglesias" , Christian Borntraeger , Leif Lindholm , Alistair Francis , Thomas Huth , Peter Maydell , Eduardo Habkost , Jiaxun Yang , Halil Pasic , David Hildenbrand , qemu-ppc@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= , David Gibson , Mark Cave-Ayland , kvm@vger.kernel.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/7] accel/kvm: Check MachineClass kvm_type() return value Date: Fri, 19 Feb 2021 12:44:22 +0100 Message-Id: <20210219114428.1936109-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210219114428.1936109-1-philmd@redhat.com> References: <20210219114428.1936109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) MachineClass::kvm_type() can return -1 on failure. Document it, and add a check in kvm_init(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/boards.h | 3 ++- accel/kvm/kvm-all.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index a46dfe5d1a6..68d3d10f6b0 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -127,7 +127,8 @@ typedef struct { * implement and a stub device is required. * @kvm_type: * Return the type of KVM corresponding to the kvm-type string option or - * computed based on other criteria such as the host kernel capabilitie= s. + * computed based on other criteria such as the host kernel capabilities + * (which can't be negative), or -1 on error. * @numa_mem_supported: * true if '--numa node.mem' option is supported and false otherwise * @smp_parse: diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 84c943fcdb2..b069938d881 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2057,6 +2057,12 @@ static int kvm_init(MachineState *ms) "kvm-type", &error_abort); type =3D mc->kvm_type(ms, kvm_type); + if (type < 0) { + ret =3D -EINVAL; + fprintf(stderr, "Failed to detect kvm-type for machine '%s'\n", + mc->name); + goto err; + } } =20 do { --=20 2.26.2