From nobody Sat May 18 06:50:40 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=1626690528; cv=none; d=zohomail.com; s=zohoarc; b=c+YBxqNFF7VPgYPI5Ihx2FH/Z1TjLR+Vxvqo4+cvidd2f+7v9Je4+i5SirdTpmYGQjPRsXzbLGAd/+EjMKcePBVEMEMxJxSpZHqfKYCQNHSly3yJ4SMYPnP4AE8lhz/j3n1GmOHM4lIH9G/6BSP3Zd6nvKHU65xA28XTIzhRriI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626690528; 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=iXyUdxjLrFQMcQ2tdQFKYQ2gZH4g3u7zcAqocSfF5XQ=; b=GSpgOnHeGZw660Hgx3FvPq1nDCWkIjC1COqDgCFYoAUoeln7XZrP4r9I109icQZEXlZHzcgD5u612xHc5adzu5w7RTReiY3w1SU4jwTjJtf91D8o6HelBho9WOB8kTQzagcgvSmmPVtepJbNislmtwA5md6EgUGqzyDQGfOzuY8= 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 162669052838169.87507003339385; Mon, 19 Jul 2021 03:28:48 -0700 (PDT) Received: from localhost ([::1]:38540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5QVz-0007fy-8V for importer@patchew.org; Mon, 19 Jul 2021 06:28:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5QU6-0005Y0-DE for qemu-devel@nongnu.org; Mon, 19 Jul 2021 06:26:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5QU4-00070w-Q2 for qemu-devel@nongnu.org; Mon, 19 Jul 2021 06:26:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-255-NWK2z930M8mWn1AMgfFOaA-1; Mon, 19 Jul 2021 06:26:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1FA41100C660; Mon, 19 Jul 2021 10:26:45 +0000 (UTC) Received: from thuth.com (ovpn-112-201.ams2.redhat.com [10.36.112.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FD805D6A1; Mon, 19 Jul 2021 10:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626690407; 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=iXyUdxjLrFQMcQ2tdQFKYQ2gZH4g3u7zcAqocSfF5XQ=; b=e+obH9YFINMYyzaJ3nJQBKwgNs4SAK5LfYrTORmy1N5NjtmIQSmHAweJqEdk7Oj3/XIBDk KM/xBVSLLi4/s/9J4COc9TvMYRXkdznUCHyCWj2XKTtieet2OruIn9Ac2Ey665j0SfgaG0 dZ9qpm3GI55HfdfZ0ueE8MK4rJSyJc8= X-MC-Unique: NWK2z930M8mWn1AMgfFOaA-1 From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 1/5] ci: build & store windows installer Date: Mon, 19 Jul 2021 12:26:36 +0200 Message-Id: <20210719102640.2610368-2-thuth@redhat.com> In-Reply-To: <20210719102640.2610368-1-thuth@redhat.com> References: <20210719102640.2610368-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=thuth@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.466, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fleytman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626690528811100002 Content-Type: text/plain; charset="utf-8" From: Gerd Hoffmann Build windows installer for qemu in gitlab CI, store the result as artifact. Signed-off-by: Gerd Hoffmann Reviewed-by: Willian Rampazzo Reviewed-by: Thomas Huth Message-Id: <20210623091137.1156959-2-kraxel@redhat.com> Signed-off-by: Thomas Huth --- .gitlab-ci.d/crossbuild-template.yml | 5 +++++ .gitlab-ci.d/crossbuilds.yml | 6 ++++++ tests/docker/dockerfiles/fedora-win64-cross.docker | 1 + 3 files changed, 12 insertions(+) diff --git a/.gitlab-ci.d/crossbuild-template.yml b/.gitlab-ci.d/crossbuild= -template.yml index 1be541174c..7d3ad00a1e 100644 --- a/.gitlab-ci.d/crossbuild-template.yml +++ b/.gitlab-ci.d/crossbuild-template.yml @@ -11,6 +11,11 @@ i386-softmmu microblaze-softmmu mips-softmmu mipsel-softmmu mips64-softmmu ppc-softmmu sh4-softmmu xtensa-softmmu" - make -j$(expr $(nproc) + 1) all check-build $MAKE_CHECK_ARGS + - if grep -q "EXESUF=3D.exe" config-host.mak; + then make installer; + version=3D"$(git describe --match v[0-9]*)"; + mv -v qemu-setup*.exe qemu-setup-${version}.exe; + fi =20 # Job to cross-build specific accelerators. # diff --git a/.gitlab-ci.d/crossbuilds.yml b/.gitlab-ci.d/crossbuilds.yml index 6b3865c9e8..4ff3aa3cfc 100644 --- a/.gitlab-ci.d/crossbuilds.yml +++ b/.gitlab-ci.d/crossbuilds.yml @@ -160,6 +160,9 @@ cross-win32-system: job: win32-fedora-cross-container variables: IMAGE: fedora-win32-cross + artifacts: + paths: + - build/qemu-setup*.exe =20 cross-win64-system: extends: .cross_system_build_job @@ -167,6 +170,9 @@ cross-win64-system: job: win64-fedora-cross-container variables: IMAGE: fedora-win64-cross + artifacts: + paths: + - build/qemu-setup*.exe =20 cross-amd64-xen-only: extends: .cross_accel_build_job diff --git a/tests/docker/dockerfiles/fedora-win64-cross.docker b/tests/doc= ker/dockerfiles/fedora-win64-cross.docker index ff706040c4..d3f13666e8 100644 --- a/tests/docker/dockerfiles/fedora-win64-cross.docker +++ b/tests/docker/dockerfiles/fedora-win64-cross.docker @@ -13,6 +13,7 @@ ENV PACKAGES \ hostname \ make \ meson \ + mingw32-nsis \ mingw64-bzip2 \ mingw64-curl \ mingw64-glib2 \ --=20 2.27.0 From nobody Sat May 18 06:50:40 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=1626690611; cv=none; d=zohomail.com; s=zohoarc; b=bPkjLmT5iQ2neW+XrVM8LsVoiM96OL4oNj3+Rnozry8ZARFNRgYGlffvl1+kR4b4k3eY8pBqN1cR4vuVx0YTIsDIRp2dsl20u+pYNhRU7qIfBtoPenZx3cC1CsDloCx75noP6+ZWuk7uDucpmf/aRXumacuBhzQtKoCzeoH4YLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626690611; 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=yp2MDUFKVC0UtKu1gfR6e6LJG7KmgqHUZ4LPZeQDsZg=; b=W6J+lsp2TnZTPQFGVVc7j6nolGsPfUIVdFEbKTiE/0waYxUym+IrWdWrk481jicRvvpYhM/n696UwpBsBfq16jH04mK4zYZRtx0iBOv3UHmtKa4h3DginATkc2wesLYVqcL9nyqX8vY/qcZFQzlxZlspNBR3GEtOsBPIS81Oot8= 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 1626690611176234.71880993762272; Mon, 19 Jul 2021 03:30:11 -0700 (PDT) Received: from localhost ([::1]:42964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5QXK-0002Cj-4u for importer@patchew.org; Mon, 19 Jul 2021 06:30:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5QU7-0005av-Ig for qemu-devel@nongnu.org; Mon, 19 Jul 2021 06:26:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35341) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5QU5-00073T-Uk for qemu-devel@nongnu.org; Mon, 19 Jul 2021 06:26:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-365-IkDeR5hWOOaV-yc7SJFGPQ-1; Mon, 19 Jul 2021 06:26:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8EFA510C1ADC; Mon, 19 Jul 2021 10:26:46 +0000 (UTC) Received: from thuth.com (ovpn-112-201.ams2.redhat.com [10.36.112.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A2865D6A1; Mon, 19 Jul 2021 10:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626690409; 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=yp2MDUFKVC0UtKu1gfR6e6LJG7KmgqHUZ4LPZeQDsZg=; b=XWHnka7QX5f8Q0bZKsK+ZEbS6jKK2BsZRJ2hMh6qN1EdlZ4UzDjdWlWLS/Oe5bGRIt4SCR RDMR36grckp/LMIBj5OtcO3oFSLQ0qSNQDkZ9MnrmpUwKp1uQy8fkiNQm7C7qROGQBLQzE eSy80mBzltbdH3YJl5bC2nQLXNcb4qU= X-MC-Unique: IkDeR5hWOOaV-yc7SJFGPQ-1 From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 2/5] configure: Fix endianess test with LTO Date: Mon, 19 Jul 2021 12:26:37 +0200 Message-Id: <20210719102640.2610368-3-thuth@redhat.com> In-Reply-To: <20210719102640.2610368-1-thuth@redhat.com> References: <20210719102640.2610368-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=thuth@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.466, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fleytman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626690613279100001 Content-Type: text/plain; charset="utf-8" If a user is trying to compile QEMU with link-time optimization enabled by running the configure script like this: .../configure --extra-cflags=3D"-flto" then the endianess test is failing since the magic values do not show up in the intermediate object files there. If the host is a big endian machine (like s390x), the QEMU binary is then unusable since the corresponding variable "bigendian" is pre-initialized with "no". To fix this issue, we should rather create a full binary and look for the magic strings there instead. And we really should not continue the build if the endianess check failed, to make it clear right from the start that something went wrong here, thus let's also add some "exit 1" statements here after emitting the error message. Message-Id: <20210715083928.933806-1-thuth@redhat.com> Reviewed-by: Richard Henderson Signed-off-by: Thomas Huth --- configure | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 49b5481139..63f38fa94c 100755 --- a/configure +++ b/configure @@ -2365,24 +2365,27 @@ feature_not_found() { # --- # big/little endian test cat > $TMPC << EOF +#include short big_endian[] =3D { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; short little_endian[] =3D { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41= , 0, }; -extern int foo(short *, short *); -int main(int argc, char *argv[]) { - return foo(big_endian, little_endian); +int main(int argc, char *argv[]) +{ + return printf("%s %s\n", (char *)big_endian, (char *)little_endian); } EOF =20 -if compile_object ; then - if strings -a $TMPO | grep -q BiGeNdIaN ; then +if compile_prog ; then + if strings -a $TMPE | grep -q BiGeNdIaN ; then bigendian=3D"yes" - elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then + elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then bigendian=3D"no" else echo big/little test failed + exit 1 fi else echo big/little test failed + exit 1 fi =20 ########################################## --=20 2.27.0 From nobody Sat May 18 06:50:40 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=1626690696; cv=none; d=zohomail.com; s=zohoarc; b=KkYGnL+UgiXtzYPSfi7HXXNTK3WgPqKjYA1PU0wobyP8OVlL7xiyZQaojjQTUsLJfuS+CJPnx7YOHzJcJZfb7zlMQVNHZX/6msH9NmoHuCP0Rx3HWTNHEeveCs24iw2pBpFU+ZlocSp30UwZ1UhZlxK7bgFIrG2LOvk4JnAT92s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626690696; 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=xVmNYp/5hjpvm/fZA1nMnL7SUHmjYy3vIxeWcP9vyZQ=; b=hUW6ECrox7vrvfr347LEoCEEx4DJP8I6QFR+KcbE3zpKWEYb9a5jKDOS5cFA36Yd0Fykp5dG7Q2OWryQKntc9az9DYRoYiH8L1RyTm4wiFb8xD/0eJu85qMhl/uKGLe6atCo+vexLnmk1AA2cI1MyDppsnFUDLJJPM/If6R4YrM= 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 1626690696626464.14383999485904; Mon, 19 Jul 2021 03:31:36 -0700 (PDT) Received: from localhost ([::1]:46366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5QYh-0004UE-Lw for importer@patchew.org; Mon, 19 Jul 2021 06:31:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5QUB-0005lc-Ak for qemu-devel@nongnu.org; Mon, 19 Jul 2021 06:26:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36929) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5QU9-0007AO-GQ for qemu-devel@nongnu.org; Mon, 19 Jul 2021 06:26:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-399-r_V6fOWrNKyKqYBy3CYPug-1; Mon, 19 Jul 2021 06:26:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F3D7C804141; Mon, 19 Jul 2021 10:26:47 +0000 (UTC) Received: from thuth.com (ovpn-112-201.ams2.redhat.com [10.36.112.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id E392F5D6A1; Mon, 19 Jul 2021 10:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626690413; 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=xVmNYp/5hjpvm/fZA1nMnL7SUHmjYy3vIxeWcP9vyZQ=; b=aFnlDdfpYnFDczhRC+2bXj++pdaL2GMwtECY47J1kAFjS3vIBXNhmySjO8kx+NA8FVTr5+ xoNFs2EDg2YTpGbGqoHGf02Fvn77uA7Uh1Q0Qu/IF81tpAjcff45F+eyKSGYSEIFPXUsew pI9lVWByqDSfU1TnRWGhG2TkUZrTB4U= X-MC-Unique: r_V6fOWrNKyKqYBy3CYPug-1 From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 3/5] hw/net/vmxnet3: Do not abort if the guest is trying to use an invalid TX queue Date: Mon, 19 Jul 2021 12:26:38 +0200 Message-Id: <20210719102640.2610368-4-thuth@redhat.com> In-Reply-To: <20210719102640.2610368-1-thuth@redhat.com> References: <20210719102640.2610368-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=thuth@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.466, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fleytman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626690697893100003 Content-Type: text/plain; charset="utf-8" QEMU should never abort just because the guest is doing something odd. Let's simply log the error and ignore the bad transmit queue instead. Buglink: https://bugs.launchpad.net/qemu/+bug/1926111 Message-Id: <20210715103755.1035566-1-thuth@redhat.com> Reviewed-by: Richard Henderson Signed-off-by: Thomas Huth --- hw/net/vmxnet3.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index eff299f629..f6bd8c53b1 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -23,6 +23,7 @@ #include "net/checksum.h" #include "sysemu/sysemu.h" #include "qemu/bswap.h" +#include "qemu/log.h" #include "qemu/module.h" #include "hw/pci/msix.h" #include "hw/pci/msi.h" @@ -1093,8 +1094,12 @@ vmxnet3_io_bar0_write(void *opaque, hwaddr addr, int tx_queue_idx =3D VMW_MULTIREG_IDX_BY_ADDR(addr, VMXNET3_REG_TXPROD, VMXNET3_REG_ALIGN); - assert(tx_queue_idx <=3D s->txq_num); - vmxnet3_process_tx_queue(s, tx_queue_idx); + if (tx_queue_idx <=3D s->txq_num) { + vmxnet3_process_tx_queue(s, tx_queue_idx); + } else { + qemu_log_mask(LOG_GUEST_ERROR, "vmxnet3: Illegal TX queue %d/%= d\n", + tx_queue_idx, s->txq_num); + } return; } =20 --=20 2.27.0 From nobody Sat May 18 06:50:40 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=1626690802; cv=none; d=zohomail.com; s=zohoarc; b=IZ8H7Db/76j4CcnQiGmNeNn2DTsgBpuflwKBdemm6u4yo6l2+5LELlZDXl2tt0+0rUKe2NK2qLhrtbtecYVSY7PJvvoNyIjSrZnU4A+1j3VXp8fLeBmpXO8FVv9AMriZdQACnlTSyZyG8yZeL0gJI7J2eQVnNtPxUA54NnN9ERA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626690802; 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=K/XzqQivXMgR7242lB3IzydHkbbJMWsu4GMJHjtzP/U=; b=fkLBzbgqDAP0ripfxZwueYXd3Nc6Ciwka0VFw/v48X6hsqyWrzO7RJkHeI1cnB7Tj7Y4vm21n7WLI3gUpZkdyQCdoqM+UL8yjKA0yLuu1JUevKxtP8uEKbaXO1iRyqprdWx30/zp0aAsEndwF991c89CpbuzzjhRS5hakjzwFXQ= 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 1626690802813747.0159347914292; Mon, 19 Jul 2021 03:33:22 -0700 (PDT) Received: from localhost ([::1]:48546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5QaP-00064x-C2 for importer@patchew.org; Mon, 19 Jul 2021 06:33:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5QUC-0005qa-Oe for qemu-devel@nongnu.org; Mon, 19 Jul 2021 06:26:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5QUA-0007Bm-NU for qemu-devel@nongnu.org; Mon, 19 Jul 2021 06:26:56 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-154-pR5WyMmWMlyGdI7ksP6-WQ-1; Mon, 19 Jul 2021 06:26:50 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75193804142; Mon, 19 Jul 2021 10:26:49 +0000 (UTC) Received: from thuth.com (ovpn-112-201.ams2.redhat.com [10.36.112.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54D5B5D6A1; Mon, 19 Jul 2021 10:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626690414; 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=K/XzqQivXMgR7242lB3IzydHkbbJMWsu4GMJHjtzP/U=; b=APK8yLnfDYJSYt+U+Sk+NzEebxr5nHY5E7KUU6mL5vjL/b07B3XcTXEd0I9k/e38jAQrD7 sa2GCAMDjSvE2c3+QGn3b67zA7+WWicYgfJPteXXuOz+HwnTBEI4k55RtN9GurOyCL3AMZ cFXGEtGMdS3IAEx0tma/P63rz3BkRzM= X-MC-Unique: pR5WyMmWMlyGdI7ksP6-WQ-1 From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 4/5] hw/net/net_tx_pkt: Fix crash detected by fuzzer Date: Mon, 19 Jul 2021 12:26:39 +0200 Message-Id: <20210719102640.2610368-5-thuth@redhat.com> In-Reply-To: <20210719102640.2610368-1-thuth@redhat.com> References: <20210719102640.2610368-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=thuth@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.466, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fleytman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626690803628100001 QEMU currently crashes when it's started like this: cat << EOF | ./qemu-system-i386 -device vmxnet3 -nodefaults -qtest stdio outl 0xcf8 0x80001014 outl 0xcfc 0xe0001000 outl 0xcf8 0x80001018 outl 0xcf8 0x80001004 outw 0xcfc 0x7 outl 0xcf8 0x80001083 write 0x0 0x1 0xe1 write 0x1 0x1 0xfe write 0x2 0x1 0xbe write 0x3 0x1 0xba writeq 0xe0001020 0xefefff5ecafe0000 writeq 0xe0001020 0xffff5e5ccafe0002 EOF It hits this assertion: qemu-system-i386: ../qemu/hw/net/net_tx_pkt.c:453: net_tx_pkt_reset: Assertion `pkt->raw' failed. This happens because net_tx_pkt_init() is called with max_frags =3D=3D 0 and thus the allocation p->raw =3D g_new(struct iovec, max_frags); results in a NULL pointer that causes the assert(pkt->raw); in net_tx_pkt_reset() to fail later. To fix this issue we can check that max_raw_frags was not zero before asserting that pkt->raw is a non-NULL pointer. Buglink: https://bugs.launchpad.net/qemu/+bug/1890157 Message-Id: <20210715193219.1132571-1-thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pankaj Gupta Signed-off-by: Thomas Huth --- hw/net/net_tx_pkt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 1f9aa59eca..1cb1125d9f 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -450,11 +450,13 @@ void net_tx_pkt_reset(struct NetTxPkt *pkt) pkt->payload_len =3D 0; pkt->payload_frags =3D 0; =20 - assert(pkt->raw); - for (i =3D 0; i < pkt->raw_frags; i++) { - assert(pkt->raw[i].iov_base); - pci_dma_unmap(pkt->pci_dev, pkt->raw[i].iov_base, pkt->raw[i].iov_= len, - DMA_DIRECTION_TO_DEVICE, 0); + if (pkt->max_raw_frags > 0) { + assert(pkt->raw); + for (i =3D 0; i < pkt->raw_frags; i++) { + assert(pkt->raw[i].iov_base); + pci_dma_unmap(pkt->pci_dev, pkt->raw[i].iov_base, + pkt->raw[i].iov_len, DMA_DIRECTION_TO_DEVICE, 0); + } } pkt->raw_frags =3D 0; =20 --=20 2.27.0 From nobody Sat May 18 06:50:40 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=1626690613; cv=none; d=zohomail.com; s=zohoarc; b=nXUoL/2k3NZWlKieUzIUsOcibU4VwDGNBgWcd7aBZcAIFMckxDentp7NYm/hmyTuYVA/uNcV0IdWeVzWqPgMawJ8ag+8IJkLn7n9rSzQ89vwAUvK6wbedZg/Y9opyhXMBbNMJZcQ6HPStXxTW0Kfk/CaMXY9uquo0qboPk2NHrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626690613; 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=B2OAVnRwwwSr9Io2bWjzudEj/UWqQOvmvbBv9SS+/Lk=; b=QlKPGOVaSwQTlo2LSuU5UHSr/OtCeQ8sBSEccqMLkvWw2OhLvGh2X1ygb8XTvfpU5e1kgdCpEm2V8gwxOYhhPaYcSs+7ZLODcKH1KElm0ogzUpwn4d/VI2gOh/xyrf6Kht1/3+byzaWZaebx9+kZJ0ccbp6FKOlf6OpyB9TZ6us= 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 1626690613917945.5869412391743; Mon, 19 Jul 2021 03:30:13 -0700 (PDT) Received: from localhost ([::1]:43096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5QXM-0002I4-Ub for importer@patchew.org; Mon, 19 Jul 2021 06:30:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5QUC-0005o0-70 for qemu-devel@nongnu.org; Mon, 19 Jul 2021 06:26:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5QUA-0007BO-4Z for qemu-devel@nongnu.org; Mon, 19 Jul 2021 06:26:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211-yOIE5GPWOUKfWUgpRWasRQ-1; Mon, 19 Jul 2021 06:26:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF26D8030B5; Mon, 19 Jul 2021 10:26:50 +0000 (UTC) Received: from thuth.com (ovpn-112-201.ams2.redhat.com [10.36.112.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id A667A5D6A1; Mon, 19 Jul 2021 10:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626690413; 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=B2OAVnRwwwSr9Io2bWjzudEj/UWqQOvmvbBv9SS+/Lk=; b=KbAlJoJSlpsLKz8bVN9TwUmMv4J05bHrDeniQ2nWUKzQWZaHuc7/qHoHkvgRWSFvdIjvnG VP7JQkL7rPf5AIJe5150qVQD74uGdRF8WonyaIfVEXWSVeFKIMTvmmxboBItrQIb1bQw4M UKA+6S/xJ9wH3J2JKP3SZT28u8sSBaI= X-MC-Unique: yOIE5GPWOUKfWUgpRWasRQ-1 From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 5/5] hw/ide: Fix crash when plugging a piix3-ide device into the x-remote machine Date: Mon, 19 Jul 2021 12:26:40 +0200 Message-Id: <20210719102640.2610368-6-thuth@redhat.com> In-Reply-To: <20210719102640.2610368-1-thuth@redhat.com> References: <20210719102640.2610368-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=thuth@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.466, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fleytman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626690615430100003 Content-Type: text/plain; charset="utf-8" QEMU currently crashes when the user tries to do something like: qemu-system-x86_64 -M x-remote -device piix3-ide This happens because the "isabus" variable is not initialized with the x-remote machine yet. Add a proper check for this condition and propagate the error to the caller, so we can fail there gracefully. Message-Id: <20210416125256.2039734-1-thuth@redhat.com> Reviewed-by: John Snow Signed-off-by: Thomas Huth --- hw/ide/ioport.c | 16 ++++++++++------ hw/ide/piix.c | 22 +++++++++++++++++----- hw/isa/isa-bus.c | 14 ++++++++++---- include/hw/ide/internal.h | 2 +- include/hw/isa/isa.h | 13 ++++++++----- 5 files changed, 46 insertions(+), 21 deletions(-) diff --git a/hw/ide/ioport.c b/hw/ide/ioport.c index b613ff3bba..e6caa537fa 100644 --- a/hw/ide/ioport.c +++ b/hw/ide/ioport.c @@ -50,15 +50,19 @@ static const MemoryRegionPortio ide_portio2_list[] =3D { PORTIO_END_OF_LIST(), }; =20 -void ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2) +int ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2) { + int ret; + /* ??? Assume only ISA and PCI configurations, and that the PCI-ISA bridge has been setup properly to always register with ISA. */ - isa_register_portio_list(dev, &bus->portio_list, - iobase, ide_portio_list, bus, "ide"); + ret =3D isa_register_portio_list(dev, &bus->portio_list, + iobase, ide_portio_list, bus, "ide"); =20 - if (iobase2) { - isa_register_portio_list(dev, &bus->portio2_list, - iobase2, ide_portio2_list, bus, "ide"); + if (ret =3D=3D 0 && iobase2) { + ret =3D isa_register_portio_list(dev, &bus->portio2_list, + iobase2, ide_portio2_list, bus, "id= e"); } + + return ret; } diff --git a/hw/ide/piix.c b/hw/ide/piix.c index b9860e35a5..d3e738320b 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -26,6 +26,7 @@ #include "qemu/osdep.h" #include "hw/pci/pci.h" #include "migration/vmstate.h" +#include "qapi/error.h" #include "qemu/module.h" #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" @@ -123,7 +124,8 @@ static void piix_ide_reset(DeviceState *dev) pci_conf[0x20] =3D 0x01; /* BMIBA: 20-23h */ } =20 -static void pci_piix_init_ports(PCIIDEState *d) { +static int pci_piix_init_ports(PCIIDEState *d) +{ static const struct { int iobase; int iobase2; @@ -132,24 +134,30 @@ static void pci_piix_init_ports(PCIIDEState *d) { {0x1f0, 0x3f6, 14}, {0x170, 0x376, 15}, }; - int i; + int i, ret; =20 for (i =3D 0; i < 2; i++) { ide_bus_new(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2); - ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, - port_info[i].iobase2); + ret =3D ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, + port_info[i].iobase2); + if (ret) { + return ret; + } ide_init2(&d->bus[i], isa_get_irq(NULL, port_info[i].isairq)); =20 bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus =3D &d->bus[i]; ide_register_restart_cb(&d->bus[i]); } + + return 0; } =20 static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) { PCIIDEState *d =3D PCI_IDE(dev); uint8_t *pci_conf =3D dev->config; + int rc; =20 pci_conf[PCI_CLASS_PROG] =3D 0x80; // legacy ATA mode =20 @@ -158,7 +166,11 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error= **errp) =20 vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d); =20 - pci_piix_init_ports(d); + rc =3D pci_piix_init_ports(d); + if (rc) { + error_setg_errno(errp, -rc, "Failed to realize %s", + object_get_typename(OBJECT(dev))); + } } =20 int pci_piix3_xen_ide_unplug(DeviceState *dev, bool aux) diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index 7820068e6e..cffaa35e9c 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -131,13 +131,17 @@ void isa_register_ioport(ISADevice *dev, MemoryRegion= *io, uint16_t start) isa_init_ioport(dev, start); } =20 -void isa_register_portio_list(ISADevice *dev, - PortioList *piolist, uint16_t start, - const MemoryRegionPortio *pio_start, - void *opaque, const char *name) +int isa_register_portio_list(ISADevice *dev, + PortioList *piolist, uint16_t start, + const MemoryRegionPortio *pio_start, + void *opaque, const char *name) { assert(piolist && !piolist->owner); =20 + if (!isabus) { + return -ENODEV; + } + /* START is how we should treat DEV, regardless of the actual contents of the portio array. This is how the old code actually handled e.g. the FDC device. */ @@ -145,6 +149,8 @@ void isa_register_portio_list(ISADevice *dev, =20 portio_list_init(piolist, OBJECT(dev), pio_start, opaque, name); portio_list_add(piolist, isabus->address_space_io, start); + + return 0; } =20 static void isa_device_init(Object *obj) diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 2d09162eeb..79172217cc 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -624,7 +624,7 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, IDED= riveKind kind, int chs_trans, Error **errp); void ide_init2(IDEBus *bus, qemu_irq irq); void ide_exit(IDEState *s); -void ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); +int ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); void ide_register_restart_cb(IDEBus *bus); =20 void ide_exec_cmd(IDEBus *bus, uint32_t val); diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index ddaae89a85..d4417b34b6 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -132,12 +132,15 @@ void isa_register_ioport(ISADevice *dev, MemoryRegion= *io, uint16_t start); * @portio: the ports, sorted by offset. * @opaque: passed into the portio callbacks. * @name: passed into memory_region_init_io. + * + * Returns: 0 on success, negative error code otherwise (e.g. if the + * ISA bus is not available) */ -void isa_register_portio_list(ISADevice *dev, - PortioList *piolist, - uint16_t start, - const MemoryRegionPortio *portio, - void *opaque, const char *name); +int isa_register_portio_list(ISADevice *dev, + PortioList *piolist, + uint16_t start, + const MemoryRegionPortio *portio, + void *opaque, const char *name); =20 static inline ISABus *isa_bus_from_device(ISADevice *d) { --=20 2.27.0