From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447127845132.44700887945157; Wed, 30 Oct 2019 07:52:07 -0700 (PDT) Received: from localhost ([::1]:41166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpKO-00077f-6T for importer@patchew.org; Wed, 30 Oct 2019 10:52:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35234) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIN-0004xC-DL for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIL-0007CU-GF for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:49:59 -0400 Received: from mail-eopbgr800135.outbound.protection.outlook.com ([40.107.80.135]:59246 helo=NAM03-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIJ-0006yI-Ij for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:49:56 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB5054.namprd03.prod.outlook.com (52.132.170.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Wed, 30 Oct 2019 14:49:48 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FeivO/zey5xOeKh8CPLZ5VCD+D10ofJ8oC6THE8wED+7zYGbryJuQegM0EAJ+a0/INoPVKDcnDJM4LHcMfN9UbD6IbfLsg5AWwyIN64PlBZixK2ojxMBLoStWXoCnEvmg7gHnvurVAD4XqTVx+8pc8rtYTruaIuFgGhjDHUfXNZU5GUwOlTHAMAvg+ewcXGpwk7PkN6Z1Mxn0rmc5TdSTZCRL+A7ZctOSVrxD9ypITxFKXrZOvffp42MZ/RQlY/gDGGCIKKQsH0ogWrvVfnmDheg8xekqX/mer8fgpLep47N4SFqxi/6umBOYPj5ET6oT5uzI98wGbvODHv3y2/2aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kHDy7oLagDPsTTssPObcI3Mh/tWmTTBlEyX4WTYnM0U=; b=eqO76XPjhFix8E9RwzBGrjnYK8yRJFYCMJK+1Zjm8zHywdtiQrIKvGog4p5wZZUSbAQADihjTqADUfkVggVBnkGzqWkqF6o/NhD0vAkwvUJ1HAdDZ0f++SwSkEIQn3P9eb3Ii3kuEed19PDa5wdYgeaTsP1SKpC1Vq6Fc5FQVanTKsb7yoG1WiungX50k6V/YjWXyGz9jhQDAMCOoYlkjz0icfMGmYqewXqT2Oue5GVfLPLhoOJ5VhVEBabPXAZUI5q26macsFNar/u/a93GKqYcolWrr642M7uNe/2MgI9YuIN+GO4hnpMlm1QfCC47Xb18Dy6LE6+z4Lw9ngM2Vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kHDy7oLagDPsTTssPObcI3Mh/tWmTTBlEyX4WTYnM0U=; b=oot7G9yyVUgiErkY7yfiq3I9dV7jW5++y6rLmAw9FAsJbwHsFWXJrvPjuYgooCigEQ/m4jDGW10shf9XkWufMVtgRudP8MCY/bvQ+yVm+D2IyHYW4W/aO1lKCJG4NU9FUKu2ya6Dl6MevwPcrUee4L3ANroJgKO5qXRGZQY2U6U= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 01/20] softmmu: split off vl.c:main() into main.c Thread-Topic: [PATCH v4 01/20] softmmu: split off vl.c:main() into main.c Thread-Index: AQHVjzFGdffDW1ST1UKR7oDR1Qob0Q== Date: Wed, 30 Oct 2019 14:49:48 +0000 Message-ID: <20191030144926.11873-2-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 163b8c42-1166-4855-ae45-08d75d486950 x-ms-traffictypediagnostic: MN2PR03MB5054: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(346002)(136003)(39860400002)(189003)(199004)(2501003)(36756003)(476003)(86362001)(88552002)(386003)(256004)(316002)(14444005)(5640700003)(1076003)(99286004)(6916009)(75432002)(486006)(786003)(11346002)(6506007)(4326008)(54906003)(186003)(2906002)(66946007)(26005)(6116002)(14454004)(446003)(2616005)(6512007)(305945005)(71200400001)(478600001)(71190400001)(81166006)(102836004)(66556008)(64756008)(50226002)(8676002)(81156014)(66446008)(6436002)(2351001)(25786009)(5660300002)(66066001)(52116002)(66476007)(6486002)(3846002)(8936002)(7736002)(76176011); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB5054; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6zS2Ne2O2x6ri3i+vzS/dbJ/8g92zEuxWHNcnkP1MMdxDMx8yG3Tl6J0ND17KBIocJJMobhb3hw7Gc17iLtIemKEydfYT/ge9dttqS9QXpLTiDcg0BCeybxFPabTZqD5kGJ76dyijOPgGZf0P8P4eFxFpD5TTQsIRpC/f8OqY2Wr3aUOlApPcEx/pXlvsbu34Dnb9l2InyOEOL7S/8DEHJyv/73M9u3QYkNQgcbrJcs/KpR/vzRY6GbGtSR2CeOZ3jsQ0u0r1nTyd2fZnEbQE4zo1qZZgJo7SVvm6Tkp7hDIkGybqcSIglE2vyKV009VpMu1zvFJlzYoln5UX8Sy+FyrwOvaWenGcWgz4kHxS1/FH8+w38OMQ+KvJBSDeuqkNLY+fqwSJiC6+EIHbEW4P1ILin4khMMUagdRbWOCxlxBSAla9TtkeOM3ZBfv8qSn Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 163b8c42-1166-4855-ae45-08d75d486950 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:48.4067 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: yGmn3YZs621L/1gaZA3wpBqA5Kb7RSI2aiTWqR1JJAd8DBlW8zEPOO9Ip1RlDYmx X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB5054 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.80.135 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: "Oleinik, Alexander" , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik A program might rely on functions implemented in vl.c, but implement its own main(). By placing main into a separate source file, there are no complaints about duplicate main()s when linking against vl.o. For example, the virtual-device fuzzer uses a main() provided by libfuzzer, and needs to perform some initialization before running the softmmu initialization. Now, main simply calls three vl.c functions which handle the guest initialization, main loop and cleanup. Signed-off-by: Alexander Oleinik --- Makefile | 1 + Makefile.objs | 2 ++ include/sysemu/sysemu.h | 4 ++++ main.c | 52 +++++++++++++++++++++++++++++++++++++++++ vl.c | 36 +++++++--------------------- 5 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 main.c diff --git a/Makefile b/Makefile index 0e994a275d..d2b2ecd3c4 100644 --- a/Makefile +++ b/Makefile @@ -474,6 +474,7 @@ $(SOFTMMU_ALL_RULES): $(crypto-obj-y) $(SOFTMMU_ALL_RULES): $(io-obj-y) $(SOFTMMU_ALL_RULES): config-all-devices.mak $(SOFTMMU_ALL_RULES): $(edk2-decompressed) +$(SOFTMMU_ALL_RULES): $(softmmu-main-y) =20 .PHONY: $(TARGET_DIRS_RULES) # The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that diff --git a/Makefile.objs b/Makefile.objs index 11ba1a36bd..9ff9b0c6f9 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -86,6 +86,8 @@ common-obj-$(CONFIG_FDT) +=3D device_tree.o # qapi =20 common-obj-y +=3D qapi/ + +softmmu-main-y =3D main.o endif =20 ####################################################################### diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 44f18eb739..03f9838b81 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -114,6 +114,10 @@ QemuOpts *qemu_get_machine_opts(void); =20 bool defaults_enabled(void); =20 +void main_loop(void); +void qemu_init(int argc, char **argv, char **envp); +void qemu_cleanup(void); + extern QemuOptsList qemu_legacy_drive_opts; extern QemuOptsList qemu_common_drive_opts; extern QemuOptsList qemu_drive_opts; diff --git a/main.c b/main.c new file mode 100644 index 0000000000..ecd6389424 --- /dev/null +++ b/main.c @@ -0,0 +1,52 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "sysemu/sysemu.h" + +#ifdef CONFIG_SDL +#if defined(__APPLE__) || defined(main) +#include +int main(int argc, char **argv) +{ + return qemu_main(argc, argv, NULL); +} +#undef main +#define main qemu_main +#endif +#endif /* CONFIG_SDL */ + +#ifdef CONFIG_COCOA +#undef main +#define main qemu_main +#endif /* CONFIG_COCOA */ + +int main(int argc, char **argv, char **envp) +{ + qemu_init(argc, argv, envp); + main_loop(); + qemu_cleanup(); + + return 0; +} diff --git a/vl.c b/vl.c index c389d24b2c..472f09e12a 100644 --- a/vl.c +++ b/vl.c @@ -36,25 +36,6 @@ #include "sysemu/seccomp.h" #include "sysemu/tcg.h" =20 -#ifdef CONFIG_SDL -#if defined(__APPLE__) || defined(main) -#include -int qemu_main(int argc, char **argv, char **envp); -int main(int argc, char **argv) -{ - return qemu_main(argc, argv, NULL); -} -#undef main -#define main qemu_main -#endif -#endif /* CONFIG_SDL */ - -#ifdef CONFIG_COCOA -#undef main -#define main qemu_main -#endif /* CONFIG_COCOA */ - - #include "qemu/error-report.h" #include "qemu/sockets.h" #include "sysemu/accel.h" @@ -1797,7 +1778,7 @@ static bool main_loop_should_exit(void) return false; } =20 -static void main_loop(void) +void main_loop(void) { #ifdef CONFIG_PROFILER int64_t ti; @@ -2824,7 +2805,7 @@ static void user_register_global_props(void) global_init_func, NULL, NULL); } =20 -int main(int argc, char **argv, char **envp) +void qemu_init(int argc, char **argv, char **envp) { int i; int snapshot, linux_boot; @@ -3404,7 +3385,7 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_watchdog: if (watchdog) { error_report("only one watchdog option may be given"); - return 1; + exit(1); } watchdog =3D optarg; break; @@ -4440,7 +4421,7 @@ int main(int argc, char **argv, char **envp) if (vmstate_dump_file) { /* dump and exit */ dump_vmstate_json_to_file(vmstate_dump_file); - return 0; + exit(0); } =20 if (incoming) { @@ -4457,8 +4438,11 @@ int main(int argc, char **argv, char **envp) accel_setup_post(current_machine); os_setup_post(); =20 - main_loop(); + return; +} =20 +void qemu_cleanup(void) +{ gdbserver_cleanup(); =20 /* @@ -4495,6 +4479,4 @@ int main(int argc, char **argv, char **envp) qemu_chr_cleanup(); user_creatable_cleanup(); /* TODO: unref root container, check all devices are ok */ - - return 0; } --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447576941868.998531001682; Wed, 30 Oct 2019 07:59:36 -0700 (PDT) Received: from localhost ([::1]:41244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpRf-00025z-IJ for importer@patchew.org; Wed, 30 Oct 2019 10:59:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35277) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIO-0004z9-Pf for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIN-0007G8-DG for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:00 -0400 Received: from mail-eopbgr800133.outbound.protection.outlook.com ([40.107.80.133]:23904 helo=NAM03-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIL-00079I-GW for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:49:59 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB5054.namprd03.prod.outlook.com (52.132.170.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Wed, 30 Oct 2019 14:49:49 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gdQRAugi9BWauQuqTMa630JbhazlYNDtOIutEUCBiUlOrup1nyXkGJEOv5wCa9pOXPDlHiiX6aQ8MVyChIztkfdRl/yhI/P78vArvKDUuUweEodw8kJzDqiYSU2BqYyZMzgxqiXX5nZiWEw65/syZV86AoIk7maXpES3ZkDevkw/0d/S9dHprL2Usc+S5Sd93tmC/WZMmKUmjQJCLfrs0CfGx8z/uf3b0BFMQYuKciPJYyxgKFalyhj5cG0RvZJBqw9iDXpUkiP3HdWM48RuAQccPDnQDQOJus7xjr4xP4VqtEY69IMvsJjga0LIZWnbLYLKjpImCwrng26r3xcNYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PpESagooz8Rx7YOjPk5Zy9ZiVnAxx4OSyKaptouZ02k=; b=PB7j+ExEsHv5dinxih2+yojWxnLwRzbosypX/74w1gDQrikZiMIIfUzyW/4nImuXFTR/x4OOXhSE06bcflCe/p0lLL25XsqZG1U1v9XZCf9OOiHIPBPpABF4rDz4ZUeGDme1r607RpG71v6ib9SPGheQHNFpRfKySa/B2npNBeef3mGSAD6Y4ZaNsUrGrZR9UT/Al4Djwtsr4kO7+/t1AwRe/amXHAV+64ICWUGE9V5Uk+5XePRD8dBM3nbZaw+NtLvBmvOaBipPpRbgveJQgPsS4ddadRV7O6kWnJabvfTBFV9lC/cj1r/OEkLjslOzGvUeYAx0aD7Kw9XdAtHMwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PpESagooz8Rx7YOjPk5Zy9ZiVnAxx4OSyKaptouZ02k=; b=tn5PJcPV7di0sGdcEqqKihTrKIPWlol4UxSvT2+eSsLRiHo12uDNUHBLqridHe0i7Q6ENDYpL/OfADlB7KsAEC5Ip45WCFpX7FpEd100nExG4x/yt8z4W3fyIud/vBllJVSV6dU6v6bZtuhiB9hZ7C+4uP/JMT9JA8cJ2gnhH7E= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 02/20] libqos: Rename i2c_send and i2c_recv Thread-Topic: [PATCH v4 02/20] libqos: Rename i2c_send and i2c_recv Thread-Index: AQHVjzFHKtTntWy9IE2rN5j43JMd3w== Date: Wed, 30 Oct 2019 14:49:49 +0000 Message-ID: <20191030144926.11873-3-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 45b378fc-c008-4b1a-dc53-08d75d4869e1 x-ms-traffictypediagnostic: MN2PR03MB5054: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:345; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(346002)(136003)(39860400002)(189003)(199004)(2501003)(36756003)(476003)(86362001)(88552002)(386003)(256004)(316002)(5640700003)(1076003)(99286004)(6916009)(75432002)(486006)(786003)(11346002)(6506007)(4326008)(54906003)(186003)(2906002)(66946007)(26005)(6116002)(14454004)(446003)(2616005)(6512007)(305945005)(71200400001)(478600001)(71190400001)(81166006)(102836004)(66556008)(64756008)(50226002)(8676002)(81156014)(66446008)(6436002)(2351001)(25786009)(5660300002)(66066001)(52116002)(66476007)(6486002)(3846002)(8936002)(7736002)(76176011); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB5054; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 4Xf3N7l3iLAm+Go5xFpOmGBjVe+Z1eF8GODP68scW/n3MPAtkcIsC/ZHnBiUzWr3G+gZOc68KVK7+HiTZfc/Zn9tIqmTAR7LocwkH+qxHGN9rfALuR4Ij1OJAIzYTiLLlAElm8cuIOpPyXxhDaeiqpsE3g3vgx2YkLrTxhflXhgOBAhHrz8wpD1v+Ul6rd6x9s/q0ZGpA2VSGRrRQtqj88EyB+Z758DI0cIqQkSgjR5Bbt6YNgVumGpiSr297j2+VZ2RlpHtc+vbfkH9nhbg9cPpXOAQYeVXAAaXQ2uIAjYMGrbgf6S899Y03Qy5PNRjEq4EA++SbjHA81lkqXq5xnfnuovPsq7NN8TXGhe/e7LXKiBA6y34eIcll7ymeY2CY37GatBLc5zr0gmBc6m7zhQQWvejL/3F/FSKyplKoQXiWpiCkaya79qMq6HkE/kY Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 45b378fc-c008-4b1a-dc53-08d75d4869e1 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:49.3731 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: /Zqa5ZTHyFyVB40JSb5Rx3/l86hJUaMq20+cSeuo7uFLH5BgiBYKLoYxpzeLYjYR X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB5054 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.80.133 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: Laurent Vivier , "Oleinik, Alexander" , Thomas Huth , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik The names i2c_send and i2c_recv collide with functions defined in hw/i2c/core.c. This causes an error when linking against libqos and softmmu simultaneously (for example when using qtest inproc). Rename the libqos functions to avoid this. Signed-off-by: Alexander Oleinik Reviewed-by: Stefan Hajnoczi --- tests/libqos/i2c-imx.c | 8 ++++---- tests/libqos/i2c-omap.c | 8 ++++---- tests/libqos/i2c.c | 10 +++++----- tests/libqos/i2c.h | 4 ++-- tests/pca9552-test.c | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/libqos/i2c-imx.c b/tests/libqos/i2c-imx.c index f33ece55a3..42ebf8ba3a 100644 --- a/tests/libqos/i2c-imx.c +++ b/tests/libqos/i2c-imx.c @@ -37,7 +37,7 @@ static void imx_i2c_set_slave_addr(IMXI2C *s, uint8_t add= r, (addr << 1) | (direction =3D=3D IMX_I2C_READ ? 1 : 0)); } =20 -static void imx_i2c_send(I2CAdapter *i2c, uint8_t addr, +static void qimx_i2c_send(I2CAdapter *i2c, uint8_t addr, const uint8_t *buf, uint16_t len) { IMXI2C *s =3D container_of(i2c, IMXI2C, parent); @@ -97,7 +97,7 @@ static void imx_i2c_send(I2CAdapter *i2c, uint8_t addr, g_assert((status & I2SR_IBB) =3D=3D 0); } =20 -static void imx_i2c_recv(I2CAdapter *i2c, uint8_t addr, +static void qimx_i2c_recv(I2CAdapter *i2c, uint8_t addr, uint8_t *buf, uint16_t len) { IMXI2C *s =3D container_of(i2c, IMXI2C, parent); @@ -202,8 +202,8 @@ void imx_i2c_init(IMXI2C *s, QTestState *qts, uint64_t = addr) =20 s->obj.get_driver =3D imx_i2c_get_driver; =20 - s->parent.send =3D imx_i2c_send; - s->parent.recv =3D imx_i2c_recv; + s->parent.send =3D qimx_i2c_send; + s->parent.recv =3D qimx_i2c_recv; s->parent.qts =3D qts; } =20 diff --git a/tests/libqos/i2c-omap.c b/tests/libqos/i2c-omap.c index 9ae8214fa8..5f4d79f87c 100644 --- a/tests/libqos/i2c-omap.c +++ b/tests/libqos/i2c-omap.c @@ -50,7 +50,7 @@ static void omap_i2c_set_slave_addr(OMAPI2C *s, uint8_t a= ddr) g_assert_cmphex(data, =3D=3D, addr); } =20 -static void omap_i2c_send(I2CAdapter *i2c, uint8_t addr, +static void qomap_i2c_send(I2CAdapter *i2c, uint8_t addr, const uint8_t *buf, uint16_t len) { OMAPI2C *s =3D container_of(i2c, OMAPI2C, parent); @@ -94,7 +94,7 @@ static void omap_i2c_send(I2CAdapter *i2c, uint8_t addr, g_assert((data & OMAP_I2C_CON_STP) =3D=3D 0); } =20 -static void omap_i2c_recv(I2CAdapter *i2c, uint8_t addr, +static void qomap_i2c_recv(I2CAdapter *i2c, uint8_t addr, uint8_t *buf, uint16_t len) { OMAPI2C *s =3D container_of(i2c, OMAPI2C, parent); @@ -182,8 +182,8 @@ void omap_i2c_init(OMAPI2C *s, QTestState *qts, uint64_= t addr) s->obj.get_driver =3D omap_i2c_get_driver; s->obj.start_hw =3D omap_i2c_start_hw; =20 - s->parent.send =3D omap_i2c_send; - s->parent.recv =3D omap_i2c_recv; + s->parent.send =3D qomap_i2c_send; + s->parent.recv =3D qomap_i2c_recv; s->parent.qts =3D qts; } =20 diff --git a/tests/libqos/i2c.c b/tests/libqos/i2c.c index 156114e745..38f800dbab 100644 --- a/tests/libqos/i2c.c +++ b/tests/libqos/i2c.c @@ -10,12 +10,12 @@ #include "libqos/i2c.h" #include "libqtest.h" =20 -void i2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len) +void qi2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len) { i2cdev->bus->send(i2cdev->bus, i2cdev->addr, buf, len); } =20 -void i2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len) +void qi2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len) { i2cdev->bus->recv(i2cdev->bus, i2cdev->addr, buf, len); } @@ -23,8 +23,8 @@ void i2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t = len) void i2c_read_block(QI2CDevice *i2cdev, uint8_t reg, uint8_t *buf, uint16_t len) { - i2c_send(i2cdev, ®, 1); - i2c_recv(i2cdev, buf, len); + qi2c_send(i2cdev, ®, 1); + qi2c_recv(i2cdev, buf, len); } =20 void i2c_write_block(QI2CDevice *i2cdev, uint8_t reg, @@ -33,7 +33,7 @@ void i2c_write_block(QI2CDevice *i2cdev, uint8_t reg, uint8_t *cmd =3D g_malloc(len + 1); cmd[0] =3D reg; memcpy(&cmd[1], buf, len); - i2c_send(i2cdev, cmd, len + 1); + qi2c_send(i2cdev, cmd, len + 1); g_free(cmd); } =20 diff --git a/tests/libqos/i2c.h b/tests/libqos/i2c.h index 945b65b34c..c65f087834 100644 --- a/tests/libqos/i2c.h +++ b/tests/libqos/i2c.h @@ -47,8 +47,8 @@ struct QI2CDevice { void *i2c_device_create(void *i2c_bus, QGuestAllocator *alloc, void *addr); void add_qi2c_address(QOSGraphEdgeOptions *opts, QI2CAddress *addr); =20 -void i2c_send(QI2CDevice *dev, const uint8_t *buf, uint16_t len); -void i2c_recv(QI2CDevice *dev, uint8_t *buf, uint16_t len); +void qi2c_send(QI2CDevice *dev, const uint8_t *buf, uint16_t len); +void qi2c_recv(QI2CDevice *dev, uint8_t *buf, uint16_t len); =20 void i2c_read_block(QI2CDevice *dev, uint8_t reg, uint8_t *buf, uint16_t len); diff --git a/tests/pca9552-test.c b/tests/pca9552-test.c index 4b800d3c3e..d80ed93cd3 100644 --- a/tests/pca9552-test.c +++ b/tests/pca9552-test.c @@ -32,22 +32,22 @@ static void receive_autoinc(void *obj, void *data, QGue= stAllocator *alloc) =20 pca9552_init(i2cdev); =20 - i2c_send(i2cdev, ®, 1); + qi2c_send(i2cdev, ®, 1); =20 /* PCA9552_LS0 */ - i2c_recv(i2cdev, &resp, 1); + qi2c_recv(i2cdev, &resp, 1); g_assert_cmphex(resp, =3D=3D, 0x54); =20 /* PCA9552_LS1 */ - i2c_recv(i2cdev, &resp, 1); + qi2c_recv(i2cdev, &resp, 1); g_assert_cmphex(resp, =3D=3D, 0x55); =20 /* PCA9552_LS2 */ - i2c_recv(i2cdev, &resp, 1); + qi2c_recv(i2cdev, &resp, 1); g_assert_cmphex(resp, =3D=3D, 0x55); =20 /* PCA9552_LS3 */ - i2c_recv(i2cdev, &resp, 1); + qi2c_recv(i2cdev, &resp, 1); g_assert_cmphex(resp, =3D=3D, 0x54); } =20 --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447256471991.7647246248541; Wed, 30 Oct 2019 07:54:16 -0700 (PDT) Received: from localhost ([::1]:41186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpMV-0002Je-7N for importer@patchew.org; Wed, 30 Oct 2019 10:54:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35266) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIO-0004yo-JU for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIN-0007GR-HK for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:00 -0400 Received: from mail-eopbgr800135.outbound.protection.outlook.com ([40.107.80.135]:59246 helo=NAM03-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIN-0006yI-CN for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:49:59 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB5054.namprd03.prod.outlook.com (52.132.170.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Wed, 30 Oct 2019 14:49:50 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JmcJj5CwNyMXgWLpy1TH9ntD9IOHs+/zEVVaVzW/GBFAtl9D2QsL9+UnwEItr848fEytPZbD9h8jqF0N/NUOC8D0syTBQ77iIxf6kD21Rsml6rfw6JaT62dQMg4UnyVmcIw3ky/B99USxzv/H2bqE8f0eUPhgb85/9j8j2BvBfBRB379O/LTYfmNPIdnYrD9dYne2XB+a6UoY42z8MEilbJasSp7zdvSk4tyAXZiz8TcwzvLTBY5aleBw2gqn0m/PZlWPVqYtTzgMsEpjshnQUU0VP2Iv3RO+Wy7gxP/h5ViAuNVl9+qQ9FfbwSY/FCq+9m0Zab4xwcReIbrQFL/Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lleTwPEOmuHOWv76TpWtzEsR9UFaj3k2JZLSUUeFIic=; b=QhnCpfXh6hwNYnGNDgDrBxwRYeV1NW6YHb4BXDAfx3ewTzLyOWaoy5YsUet19tUR6pV1wmm70v9RLLQpJLcvTvTVB8o91PzHjWThsmIxsqWgATjz31ExikUFtLjOv9drGdn4FLtDVkt8Rl4UMZygBSYPofGM7rf0HYpNmnPfaKjwhx+Xdpp/iREU1fE6rFVOljhCC9PX130qft25O6WacjwbJmfbMrejj4FyHPH+Fewk2UaZVYkJTEQhi4W84SrLuCs7mzR18PyNA5m35H6sskcn/utGNFjwGLopctLoSQZzsPWjz36AuQpJzSOK3ufo2lD7wTu0xCrGO4Icg8mN+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lleTwPEOmuHOWv76TpWtzEsR9UFaj3k2JZLSUUeFIic=; b=hY0ePSQPZIV1GT0B/q3+ajdLAPjyz7D4LCFdnRdKhzb5tx59MgJpglVb80loQAX7NGcdxPXmSEMPgXcWjQunEecwVvLHofxcpZNFiIzFv1+tYskQrEorZYrk7e6lfXftnJ6hfiYshWjn/T5Gxsv10NdpQFDmCD1Y1p9XG3y4KJM= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 03/20] fuzz: Add FUZZ_TARGET module type Thread-Topic: [PATCH v4 03/20] fuzz: Add FUZZ_TARGET module type Thread-Index: AQHVjzFID0ZPgf5TxkC2vVrePjdmBQ== Date: Wed, 30 Oct 2019 14:49:50 +0000 Message-ID: <20191030144926.11873-4-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 188ca41e-31cb-4f08-5da0-08d75d486a68 x-ms-traffictypediagnostic: MN2PR03MB5054: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:229; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(346002)(136003)(39860400002)(189003)(199004)(2501003)(36756003)(476003)(86362001)(88552002)(386003)(256004)(316002)(14444005)(5640700003)(1076003)(99286004)(6916009)(75432002)(486006)(786003)(11346002)(6506007)(4326008)(186003)(2906002)(66946007)(26005)(6116002)(14454004)(446003)(2616005)(6512007)(305945005)(71200400001)(478600001)(71190400001)(81166006)(102836004)(66556008)(64756008)(50226002)(8676002)(81156014)(66446008)(6436002)(2351001)(25786009)(5660300002)(66066001)(52116002)(66476007)(6486002)(3846002)(8936002)(7736002)(4744005)(76176011); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB5054; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: t4+Vspu2zSf7iy6QjuVEMJCcGu2+3WsuqxZGNVIml2CsY4vFzPr3Ipj2hvuPI7Y3ANzlpqi5jidpS3dPxmRWVg2h0PNl1EJvlk5ZOMliGkuNProkiY4ouzbViV5nt7tu6fV5gSDvjZdSOGJH6OqJZlDdAE5Jz1HMH+BLY19ZoxwgywMBnTjRQR+mZEleaQX3ZOfwNArhPLoMHMRKrzreWOVFF1o3M9cMSlVQpVxMMMiyQFVcDOFEP7UHRb3mmpJ+n+isvbYXKyeiWZV8FVmeb6vUOOnuFnPXFh8atTV7cehrzZbXT2QvyarrAXoG5SS5pGi8BHhI0Do3yWkwDJRqehz+vm3lHt21o5e5UQz541b4iWP8ECd/MmDu9t8Sc8bhO+1MT99BxiuTmIIkaBO1L+Tq4PqEBYUKCBBMvCUTQZMEQsKyihwBVg5j0yyb2zil Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 188ca41e-31cb-4f08-5da0-08d75d486a68 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:50.3236 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: srohzds1C8ZuD8m49eGswqRIC/F0Bd4pn7uMdMAJiMGAUMKoyNRDaUQFz2c9hcco X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB5054 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.80.135 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik Signed-off-by: Alexander Oleinik Reviewed-by: Darren Kenny Reviewed-by: Stefan Hajnoczi --- include/qemu/module.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/qemu/module.h b/include/qemu/module.h index 65ba596e46..684753d808 100644 --- a/include/qemu/module.h +++ b/include/qemu/module.h @@ -46,6 +46,7 @@ typedef enum { MODULE_INIT_TRACE, MODULE_INIT_XEN_BACKEND, MODULE_INIT_LIBQOS, + MODULE_INIT_FUZZ_TARGET, MODULE_INIT_MAX } module_init_type; =20 @@ -56,7 +57,8 @@ typedef enum { #define xen_backend_init(function) module_init(function, \ MODULE_INIT_XEN_BACKEND) #define libqos_init(function) module_init(function, MODULE_INIT_LIBQOS) - +#define fuzz_target_init(function) module_init(function, \ + MODULE_INIT_FUZZ_TARGET) #define block_module_load_one(lib) module_load_one("block-", lib) #define ui_module_load_one(lib) module_load_one("ui-", lib) #define audio_module_load_one(lib) module_load_one("audio-", lib) --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15724474639431013.2259407696309; Wed, 30 Oct 2019 07:57:43 -0700 (PDT) Received: from localhost ([::1]:41216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpPq-0007Vd-DU for importer@patchew.org; Wed, 30 Oct 2019 10:57:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35286) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIP-0004zT-1B for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIN-0007Gl-OP for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:00 -0400 Received: from mail-eopbgr800133.outbound.protection.outlook.com ([40.107.80.133]:23904 helo=NAM03-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIN-00079I-Il for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:49:59 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB5054.namprd03.prod.outlook.com (52.132.170.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Wed, 30 Oct 2019 14:49:51 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dRuHoDrbYWkf/Mg3/XLjRB8YbG1Qxtsy9ePrVHOesezX/s05jcwlI7IPpWol8LCJWkKJr0XmEWOP66noGFtRj857dpVPauz9up8oa8B9pEvDIOSKj2keSmD+b3sPw2qXLoLzL5673eOFDexhnoNbHh5/YG23+B7dQCYuIXIO5eFnEz6HMoBNU9PMGqLch/Ns7c4wfB3y6pD+56UiGOwvCqe6BTNrigWIvZ6aUHZQZicwBX7bq4kmrtWyDVlleDDONccXck4fagasVDZfHOZJxSNi67CQNfgQRDhqTCRy7RwF5gWC16VLjq5EhU9BwcuVMpTFXfuCCGnLu1xvqLQHXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DyTLxcwPUri6KyiHEnlfaVVxabER7ITxYC5q2iw6ErU=; b=CyxRuzQKZUK/acqRMY4hk8JUMQnr+r0Uwd/sd0JmUp3XzMJp/Ow4+d4kFAQ9pTI3xBMy6Ct1YgX12jw1swHekpzpJyenQqp5yCIQvg6cQQXKTU7ANwFNS6+1/et+0CEPwUvsIHVa/2dym1sYcFSkfgeTuXJjxsyhHVddH2jxgcaO/yAo95cgk3Dr/xgoCFT2PQvJcPZZBFKaYz2SYe65GDSxiP+Gb93Pr3zb0YrqMNhDBI4Lx7g2XFOzsrQipTOVvwSwnohYrMmbCOdd+cT05pa6k+dzpUuKEruyI/6AN8IO4emAAuPeyL7VfbuUYYvFIevOxgT7BYAi4fwZ7Nq7Gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DyTLxcwPUri6KyiHEnlfaVVxabER7ITxYC5q2iw6ErU=; b=act9dtTfOr6WNPcpj6X8+WI6lTi+ptRDErffA8noACGvzTIV9JY9HSqShhEO6HGjkVMqRU8DrcpAZlPG2qizHO9+N/OadNJvm/UK32LWLFgsINQ0MXPUXjKO3arEdQNl0d6N1fRj68QKkKavia8YEDJmYDIKIgvRklLZJ8XWEmc= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 04/20] qtest: add qtest_server_send abstraction Thread-Topic: [PATCH v4 04/20] qtest: add qtest_server_send abstraction Thread-Index: AQHVjzFIpASyVcuc7k24aWX+rvoPGw== Date: Wed, 30 Oct 2019 14:49:51 +0000 Message-ID: <20191030144926.11873-5-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1d944365-7338-4fd8-82c1-08d75d486afd x-ms-traffictypediagnostic: MN2PR03MB5054: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(346002)(136003)(39860400002)(189003)(199004)(2501003)(36756003)(476003)(86362001)(88552002)(386003)(256004)(316002)(5640700003)(1076003)(99286004)(6916009)(75432002)(486006)(786003)(11346002)(6506007)(4326008)(54906003)(186003)(2906002)(66946007)(26005)(6116002)(14454004)(446003)(2616005)(6512007)(305945005)(71200400001)(478600001)(71190400001)(81166006)(102836004)(66556008)(64756008)(50226002)(8676002)(81156014)(66446008)(6436002)(2351001)(25786009)(5660300002)(66066001)(52116002)(66476007)(6486002)(3846002)(8936002)(7736002)(76176011); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB5054; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: HRCoxCCkRdtv+jq1S3b2u1rbgkpKHdkYpL3nyFxp0TQ31qUuq4aJkdidDbyicj9M7V3f/DcEKlp8M52UWz5OVNvUlIUJyDt9tvjkWkTWJjLyioyXTEKepeMpFWHhUKTAj1tG3pykg8TcSk32ahzNTq5BFFhkUzLLRQgSHkvKaQ/ETytG00h2v7HNF3W167VcswWNBlUyD8tps9zQxnAvETaRui5tmdbyfqJy6Gyo+7eS26oZk6QgEI9Nqo0gfen+4JnC+WM7951W2bzfn6ORnNvnJ4WNBviEHZqxQSFfwXHfGQxIWfUgy/blm/p0uX4cbAN1yGJaPv2M+jNPNHDcvmmCJRGI4mcS2XGl58XGnDubWfycl1NcY/mm89jjd8nkpmnKFGpmiOp3vwTTCr5TXsjIXEMGqVMpH3kudSgWM33Nh9mnL9MDyiaAHIW9UYVl Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 1d944365-7338-4fd8-82c1-08d75d486afd X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:51.2650 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: pUtDrmhE9EinycPjtC3eBHzlkNTFG3rKXu08dhPqLqTe5WnUw1cldsGLdfU/gaRE X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB5054 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.80.133 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: Laurent Vivier , "Oleinik, Alexander" , Thomas Huth , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik qtest_server_send is a function pointer specifying the handler used to transmit data to the qtest client. In the standard configuration, this calls the CharBackend handler, but now it is possible for other types of handlers, e.g direct-function calls if the qtest client and server exist within the same process (inproc) Signed-off-by: Alexander Oleinik Reviewed-by: Stefan Hajnoczi --- include/sysemu/qtest.h | 3 +++ qtest.c | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h index 5ed09c80b1..fda7000d2c 100644 --- a/include/sysemu/qtest.h +++ b/include/sysemu/qtest.h @@ -26,4 +26,7 @@ bool qtest_driver(void); =20 void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Er= ror **errp); =20 +void qtest_server_set_tx_handler(void (*send)(void *, const char *, size_t= ), + void *opaque); + #endif diff --git a/qtest.c b/qtest.c index 8b50e2783e..ae7e6d779d 100644 --- a/qtest.c +++ b/qtest.c @@ -42,6 +42,8 @@ static GString *inbuf; static int irq_levels[MAX_IRQ]; static qemu_timeval start_time; static bool qtest_opened; +static void (*qtest_server_send)(void*, const char*, size_t); +static void *qtest_server_send_opaque; =20 #define FMT_timeval "%ld.%06ld" =20 @@ -228,8 +230,9 @@ static void GCC_FMT_ATTR(1, 2) qtest_log_send(const cha= r *fmt, ...) va_end(ap); } =20 -static void do_qtest_send(CharBackend *chr, const char *str, size_t len) +static void qtest_server_char_be_send(void *opaque, const char *str, size_= t len) { + CharBackend* chr =3D (CharBackend *)opaque; qemu_chr_fe_write_all(chr, (uint8_t *)str, len); if (qtest_log_fp && qtest_opened) { fprintf(qtest_log_fp, "%s", str); @@ -238,7 +241,7 @@ static void do_qtest_send(CharBackend *chr, const char = *str, size_t len) =20 static void qtest_send(CharBackend *chr, const char *str) { - do_qtest_send(chr, str, strlen(str)); + qtest_server_send(qtest_server_send_opaque, str, strlen(str)); } =20 static void GCC_FMT_ATTR(2, 3) qtest_sendf(CharBackend *chr, @@ -783,6 +786,16 @@ void qtest_server_init(const char *qtest_chrdev, const= char *qtest_log, Error ** qemu_chr_fe_set_echo(&qtest_chr, true); =20 inbuf =3D g_string_new(""); + + if (!qtest_server_send) { + qtest_server_set_tx_handler(qtest_server_char_be_send, &qtest_chr); + } +} + +void qtest_server_set_tx_handler(void (*send)(void*, const char*, size_t),= void *opaque) +{ + qtest_server_send =3D send; + qtest_server_send_opaque =3D opaque; } =20 bool qtest_driver(void) --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447914658414.0284006641456; Wed, 30 Oct 2019 08:05:14 -0700 (PDT) Received: from localhost ([::1]:41344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpX7-0008Ed-54 for importer@patchew.org; Wed, 30 Oct 2019 11:05:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35307) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIP-00050E-HU for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIN-0007Gv-Rh for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:01 -0400 Received: from mail-eopbgr800135.outbound.protection.outlook.com ([40.107.80.135]:59246 helo=NAM03-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIN-0006yI-Mj for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:49:59 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB5054.namprd03.prod.outlook.com (52.132.170.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Wed, 30 Oct 2019 14:49:52 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L3tqH1q4vAvdlOF3x0ImVSly7Dsjy/kP6X97ScsKFRCX6oyukvD4CdaVgZmyslukOtkNmpqGWH63Jrit43cFWVvwBsnEgVG1kmr5FMNIaKWHrp8QHjhmt4d3z7nd3x5FcKVmosjio+fQsrgjW6T1ns6h0yRHNQxodeQ3MaQQnP/UdHtTuTg6eLe+VX+2kz3C8ktrnGjgKapSZ2swFq4A9RaGJPrVcz+dX+2Z5WmVTPQ9Tqhkxk8xP9OXEB+ZRLq+gUtuStdseXLNPm0HhxKXiTtY2CmO2qumLKJslVh6gqT8MzamLbnUbU/nEYa2rQVcapRcRDK0sRS44cgIicBZkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A1JxxlXgRErwgkLWh3FvRbtEg2H/TM+rNQ2wfM/68go=; b=dALZBlyzB07osX8BlU/WdbDW4BcRCrd4/tw7VYAGuiGMQ4rG4znukMSR8nwdwb7/WmiElxbVyhGTeAabbGZ8CZPgKUPwEt4xlu5hFGGk+Vu55esqQQTcO0KQTC3PhDxt4kqcRVwtk4lH/ZYmeHifuuDn48smd9DdGq1oekH/YIakhmoyVwWzw1KU/6DMbXO301EuVAxMOStkKFzjUQrjlURUujI7zFSmMM++75PKN9Uafg31q7KSdUGczYIeKaRwi9PQsZkW3yXKMvtaUEojf4Gf1drE1HzMnv+FiLekQIko67Jxa+08EZUzF36x34/mtZU/UD89mZtHN9bD/bNV0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A1JxxlXgRErwgkLWh3FvRbtEg2H/TM+rNQ2wfM/68go=; b=nmJyd6jh5YpTHGJ6aggp7LBS+WFTeTQaqx8U8pSdIamEv5lwHelTpVnymnnfdR9Eh7vBSQgr3HIouQIhjpSzeUPAMWOw3FN8OrHG84Mid/ajTJhJfxbGPfPdEKzResD1QXlelYXp805vabreRO8SHfwaWxMmRIrx2cFQ/ZRDhrM= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 05/20] libqtest: Add a layer of abstraciton to send/recv Thread-Topic: [PATCH v4 05/20] libqtest: Add a layer of abstraciton to send/recv Thread-Index: AQHVjzFJVwQsnl1HE0isDTNe7F+n/Q== Date: Wed, 30 Oct 2019 14:49:52 +0000 Message-ID: <20191030144926.11873-6-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: da08934a-7fd5-4588-2a73-08d75d486b8d x-ms-traffictypediagnostic: MN2PR03MB5054: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:81; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(346002)(136003)(39860400002)(189003)(199004)(2501003)(36756003)(476003)(86362001)(88552002)(386003)(256004)(316002)(5640700003)(1076003)(99286004)(6916009)(75432002)(486006)(786003)(11346002)(6506007)(4326008)(54906003)(186003)(2906002)(66946007)(26005)(6116002)(14454004)(446003)(2616005)(6512007)(305945005)(71200400001)(478600001)(71190400001)(81166006)(102836004)(66556008)(64756008)(50226002)(8676002)(81156014)(66446008)(6436002)(2351001)(25786009)(5660300002)(66066001)(52116002)(66476007)(6486002)(3846002)(8936002)(7736002)(76176011); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB5054; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8Lv8+TaIkkm4WT/UAs6z1ZRBvNxFiKMXA/yNftKeXzyYJXDZMF61p7gYq8plvbaxDl6KdyhY0CTaJHETlmK7HSQ2QHiQtEr9t8YO2BjXLs7ltifTvvTqOByYPC6xOAN62l8pljsI3MUfVufQb6SrAiN3PiyKfnFroEpwZD7/AbXb2qFrOhjyeGowrchbyQcw+K6WuZ9ar8hHB2mo4MlMbY/Uvkr8jKOSBsiMUBWc7TtouIR3ETZ6+VzlfL9CzFROBG1jl7hBKfwZOeiia2+iu8TMPyV8cJgY13NU5tQOJSMOW2pCFF1dqhkDn1sycX2B8GOmlCrEb6tOUkNRZTsfSHHKGtb5LGiXqJ6R6R1qnx9cQhG7WFyQPu3JA3Ampdxi0yNbTBo764GWtHlLjBh3W8TMhd/gBXTtYUVS0bpDxBRUuji6iYGUrlY1z8qYG5Jp Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: da08934a-7fd5-4588-2a73-08d75d486b8d X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:52.1645 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: x7wSOKO7BZ2pM24lO50dLhFpMXldVUYX9hmERQmI4B2oXCDRpAWO4cd1PzQFzCd+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB5054 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.80.135 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: Laurent Vivier , "Oleinik, Alexander" , Thomas Huth , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik This makes it simple to swap the transport functions for qtest commands to and from the qtest client. For example, now it is possible to directly pass qtest commands to a server handler that exists within the same process, without the standard way of writing to a file descriptor. Signed-off-by: Alexander Oleinik Reviewed-by: Stefan Hajnoczi --- tests/libqtest.c | 56 +++++++++++++++++++++++++++++++++++++++--------- tests/libqtest.h | 1 - 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 3706bccd8d..822bfe208b 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -35,6 +35,13 @@ #define SOCKET_TIMEOUT 50 #define SOCKET_MAX_FDS 16 =20 + +typedef struct QTestClientTransportOps { + void (*send)(QTestState* , const char*, size_t); + + GString* (*recv_line)(QTestState *); +} QTestTransportOps; + struct QTestState { int fd; @@ -45,6 +52,7 @@ struct QTestState bool big_endian; bool irq_level[MAX_IRQ]; GString *rx; + QTestTransportOps ops; }; =20 static GHookList abrt_hooks; @@ -52,6 +60,18 @@ static struct sigaction sigact_old; =20 static int qtest_query_target_endianness(QTestState *s); =20 +static void qtest_client_socket_send(QTestState*, + const char *buf, size_t size); +static void socket_send(int fd, const char *buf, size_t size); + +static GString *qtest_client_socket_recv_line(QTestState *); + +static void qtest_client_set_tx_handler(QTestState *s, + void (*send)(QTestState*, const char *, size_t)); +static void qtest_client_set_rx_handler(QTestState *s, + GString * (*recv)(QTestState *)); + + static int init_socket(const char *socket_path) { struct sockaddr_un addr; @@ -234,6 +254,9 @@ QTestState *qtest_init_without_qmp_handshake(const char= *extra_args) sock =3D init_socket(socket_path); qmpsock =3D init_socket(qmp_socket_path); =20 + qtest_client_set_rx_handler(s, qtest_client_socket_recv_line); + qtest_client_set_tx_handler(s, qtest_client_socket_send); + qtest_add_abrt_handler(kill_qemu_hook_func, s); =20 command =3D g_strdup_printf("exec %s " @@ -360,6 +383,7 @@ void qtest_quit(QTestState *s) g_free(s); } =20 + static void socket_send(int fd, const char *buf, size_t size) { size_t offset; @@ -379,22 +403,23 @@ static void socket_send(int fd, const char *buf, size= _t size) } } =20 -static void socket_sendf(int fd, const char *fmt, va_list ap) +static void qtest_client_socket_send(QTestState *s, + const char *buf, size_t size) { - gchar *str =3D g_strdup_vprintf(fmt, ap); - size_t size =3D strlen(str); - - socket_send(fd, str, size); - g_free(str); + socket_send(s->fd, buf, size); } =20 static void GCC_FMT_ATTR(2, 3) qtest_sendf(QTestState *s, const char *fmt,= ...) { va_list ap; - va_start(ap, fmt); - socket_sendf(s->fd, fmt, ap); + gchar *str =3D g_strdup_vprintf(fmt, ap); va_end(ap); + + size_t size =3D strlen(str); + + s->ops.send(s, str, size); + g_free(str); } =20 /* Sends a message and file descriptors to the socket. @@ -431,7 +456,7 @@ static void socket_send_fds(int socket_fd, int *fds, si= ze_t fds_num, g_assert_cmpint(ret, >, 0); } =20 -static GString *qtest_recv_line(QTestState *s) +static GString *qtest_client_socket_recv_line(QTestState *s) { GString *line; size_t offset; @@ -468,7 +493,7 @@ static gchar **qtest_rsp(QTestState *s, int expected_ar= gs) int i; =20 redo: - line =3D qtest_recv_line(s); + line =3D s->ops.recv_line(s); words =3D g_strsplit(line->str, " ", 0); g_string_free(line, TRUE); =20 @@ -1336,3 +1361,14 @@ void qmp_assert_error_class(QDict *rsp, const char *= class) =20 qobject_unref(rsp); } + +static void qtest_client_set_tx_handler(QTestState *s, + void (*send)(QTestState*, const char*, size_t)) +{ + s->ops.send =3D send; +} +static void qtest_client_set_rx_handler(QTestState *s, + GString* (*recv)(QTestState *)) +{ + s->ops.recv_line =3D recv; +} diff --git a/tests/libqtest.h b/tests/libqtest.h index c9e21e05b3..31267fc915 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -728,5 +728,4 @@ bool qtest_probe_child(QTestState *s); * Set expected exit status of the child. */ void qtest_set_expected_status(QTestState *s, int status); - #endif --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15724472557444.086253218183515; Wed, 30 Oct 2019 07:54:15 -0700 (PDT) Received: from localhost ([::1]:41188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpMU-0002N1-IE for importer@patchew.org; Wed, 30 Oct 2019 10:54:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35303) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIP-000502-DD for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIO-0007H9-23 for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:01 -0400 Received: from mail-eopbgr800133.outbound.protection.outlook.com ([40.107.80.133]:23904 helo=NAM03-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIN-00079I-TW for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:00 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB5054.namprd03.prod.outlook.com (52.132.170.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Wed, 30 Oct 2019 14:49:53 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nrx3GZeaMMuzXrZO2E2L99uE2nVSsDw/MGygl6q4h+doj9WRdYxqg2KLNKIvyBOB6IgxXVkQbkvhs+nTkCJPMuF1548FLi0i7IRqiM6xl96UMn6VPjZn5XylooV3O9Ld7j+Kse+0/ngaP9XgjkhnWZY0o8PeqU9VA107VHiuPa8lJ6JXAqoQ8/AkGr4yjP4lN2oW2DAaGMqjEzlkOXfG2OMCihj8nq4TNvbSiIK5CmrZ83MioQ04VQMOwW+M9u4IvozzbiIHv1GniPlQgAXbLWlK397afq9vBR/wzXf5Gt2+KUqjbnDVsX3gUA+svVAA1AqgPd/pxWr1+dYQOpPalQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ImLy9FMlqKl3hHhCtlXcmui/XhpdIZAb8SKftD2NrAo=; b=S744nIWGoc4cpdKGJw5vU3h92TXhcPflGt0PBvQfJyNtkNKnLnWsKJqdG9MPuf6Lme87HIyAhil1LY5gTjzG4JLK3LGesuaTWh72HC4+4fFXoLboyRmtrbaStJasY2l4CZr4WA+HHwxakHAQRu+rk3agiqHxCpoPnAQtM+Px5sD8N8tNoLzgZIYfHEaCw0HUa1OqIJRBL81WubN7XcZR/MbPCdATfZ0ZvIxsNEDL5kG2/UWySC1POSs/zEqPYEGNtEPl3Ripd1m4thrkN5tIiiGy3yKKvHTmUzEV0X5FJk4O/fF7IvAm9E+2ybFmvkwZ7xyACz5oI5gGjOwYFtDjyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ImLy9FMlqKl3hHhCtlXcmui/XhpdIZAb8SKftD2NrAo=; b=5s5tgxIWWeEqOiz2xdbq6CEQuY6R67FRuamhft9QVT6hBEf614c+LJpmU/eTaLJvk4qb10V/777qY3VS8LD4Sxv5v4ZP3pxSzu/u4YUcR9XizU+DQIL2jijhJouiUYw+2yRNN9s7agLDnKr/+wuvw+T30fczRg87/sdpxguHTfc= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 06/20] module: check module wasn't already initialized Thread-Topic: [PATCH v4 06/20] module: check module wasn't already initialized Thread-Index: AQHVjzFJwDtTDBvtp0WSvkX0SfACaA== Date: Wed, 30 Oct 2019 14:49:52 +0000 Message-ID: <20191030144926.11873-7-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 434adcd3-ce44-40da-1183-08d75d486bf8 x-ms-traffictypediagnostic: MN2PR03MB5054: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4303; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(346002)(136003)(39860400002)(189003)(199004)(2501003)(36756003)(476003)(86362001)(88552002)(386003)(256004)(316002)(5640700003)(1076003)(99286004)(6916009)(75432002)(486006)(786003)(11346002)(6506007)(4326008)(186003)(2906002)(66946007)(26005)(6116002)(14454004)(446003)(2616005)(6512007)(305945005)(71200400001)(478600001)(71190400001)(81166006)(102836004)(66556008)(64756008)(50226002)(8676002)(81156014)(66446008)(6436002)(2351001)(25786009)(5660300002)(66066001)(52116002)(66476007)(6486002)(3846002)(8936002)(7736002)(76176011); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB5054; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ZzT/A5W4/HpScmVIee3553F/A59L0BV8ESLlaeE968X83/Qc0rDKx8YjtOanoctNqCxmI2qA8R4YWxwGG/1yXxRb4A/Q+YRqYKWw0842encx8IoZrb2NCUwSyk5BJ5Y4VyRMQqaKF0Au33jPsnzUd5VOqG8AR+e5ud429dmlvmskb4glja+ksvi3eFdgLT1ZIyad5U0G3ygAFC+6weNBospklvuzCBgLiygkVhAFTqKMC+y/WDBLz42CeFHqSBEyuUaT0IMkbJMwb/bC4Fo0/Bpp3VM3zqmhFnk5SzvsCuuT1FWXix8PhofhjtWj2ZeU0q3cIIn2JssAZRoWOMwVGOUlsZFAMYyt/h2vSDzk5/atCn8E8BrrWU6VCUT8sVRdn2s8PL0WRG24+tSjJvE3UtrI0L7RIM4x5kC1A70pvoWoVhNJtJ/rJJrA+Ovrqcbo Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 434adcd3-ce44-40da-1183-08d75d486bf8 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:52.9810 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: yJdT9Kj+qTlloBHjvzK4qKUBWdhSK2SsqJu87Fiezco3/GHdxqa45uFVwqRO/95X X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB5054 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.80.133 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik The virtual-device fuzzer must initialize QOM, prior to running vl:qemu_init, so that it can use the qos_graph to identify the arguments required to initialize a guest for libqos-assisted fuzzing. This change prevents errors when vl:qemu_init tries to (re)initialize the previously initialized QOM module. Signed-off-by: Alexander Oleinik Reviewed-by: Darren Kenny Reviewed-by: Stefan Hajnoczi --- util/module.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/module.c b/util/module.c index e9fe3e5422..841e490e06 100644 --- a/util/module.c +++ b/util/module.c @@ -30,6 +30,7 @@ typedef struct ModuleEntry typedef QTAILQ_HEAD(, ModuleEntry) ModuleTypeList; =20 static ModuleTypeList init_type_list[MODULE_INIT_MAX]; +static bool modules_init_done[MODULE_INIT_MAX]; =20 static ModuleTypeList dso_init_list; =20 @@ -91,11 +92,17 @@ void module_call_init(module_init_type type) ModuleTypeList *l; ModuleEntry *e; =20 + if (modules_init_done[type]) { + return; + } + l =3D find_type(type); =20 QTAILQ_FOREACH(e, l, node) { e->init(); } + + modules_init_done[type] =3D true; } =20 #ifdef CONFIG_MODULES --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447128402695.7301836963627; Wed, 30 Oct 2019 07:52:08 -0700 (PDT) Received: from localhost ([::1]:41168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpKQ-0007D3-OW for importer@patchew.org; Wed, 30 Oct 2019 10:52:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35298) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIP-0004zq-Al for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIO-0007HN-66 for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:01 -0400 Received: from mail-eopbgr800135.outbound.protection.outlook.com ([40.107.80.135]:59246 helo=NAM03-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIO-0006yI-0i for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:00 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB5054.namprd03.prod.outlook.com (52.132.170.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Wed, 30 Oct 2019 14:49:54 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YwrvYwz0RflHopOb81XsYsRHyfNGLnlWtL0SHIIzBHk3m8K5lxTpsHSJugQKdiRxGC+ucPPpP7jmEPYx9gpDz09J8vhh1CUeeKAwtYtO5ZApbApPrYkQ/2/q/lwmonAJMv2SiSrUIbrNgeb2lWv4sYF4miCtebJInp7MDk1kvpHYoDFgNbCRpCnhHUk9makfmQ7YQracUnfizKj+hiOz2vWSwKOsndz6I89AmaLdeJHzL1QbajbTAsaL8gVn3kyYNUUwDxzaQ5iLlBZOVRHRXw78QYgrqUnlSAC/EXQ4KqCMcXCJiEh96tLTCzJlyefZHk2+SjkWe84CCRSRJrRPdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4vkgg6G2jw3pa+m976iYaDVjzs3SekCfHBaK5tycshc=; b=Xxw3z8ZnarN79gt3NsN+8jOa4le1+E6vCKtxKVNKf1gIMi/vghl0IrVgf18fLceiJSHFv693F6pQrGJR+mzf0mA49CJAPPDR6tVKMbK7iL2QnX6M1oAYCIFr55Zo57VxnDSlvzoZoKGncou5+MAMktcNDDCvATEMngLtMQif6/O8kDmSIezojqA4UmT+v+1q0ZyEklbGgyo6kjyZiQF/oSrTuxWNxr7j3wuYf3fQYzH9kuFD6vYo3P4g0YJ/8n8qEMwHg6TsB+rkp22L3khOGvtZgCDKGTPX1GLHCx2Mmx7PjTR7r9+lshKNUZG96ilWHBecoDdT+eDtCtMNvgV0ZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4vkgg6G2jw3pa+m976iYaDVjzs3SekCfHBaK5tycshc=; b=rJte0x4QiBZm+Dj0d3EuTuIddgrSCvWuKtun/0dPCbHjQtFJM7JJeSiiDyKvMQ5zocYdc70xx/IYCeW5ALkRxLxcdd32jpiRNtQUDfKBYnt3PGqK6d0Cr9On//nNp6c+87fGbN2br8UndqYXUMzClt2pbrMKW7RpKCcNpJIZHl8= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 07/20] qtest: add in-process incoming command handler Thread-Topic: [PATCH v4 07/20] qtest: add in-process incoming command handler Thread-Index: AQHVjzFKbb9pV5wyeUGaibJAvE3cXQ== Date: Wed, 30 Oct 2019 14:49:53 +0000 Message-ID: <20191030144926.11873-8-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7f2ee95b-342c-47ee-c03b-08d75d486c9e x-ms-traffictypediagnostic: MN2PR03MB5054: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1824; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(346002)(136003)(39860400002)(189003)(199004)(2501003)(36756003)(476003)(86362001)(88552002)(386003)(256004)(316002)(5640700003)(1076003)(99286004)(6916009)(75432002)(486006)(786003)(11346002)(6506007)(4326008)(54906003)(186003)(2906002)(66946007)(26005)(6116002)(14454004)(446003)(2616005)(6512007)(305945005)(71200400001)(478600001)(71190400001)(81166006)(102836004)(66556008)(64756008)(50226002)(8676002)(81156014)(66446008)(6436002)(2351001)(25786009)(5660300002)(66066001)(52116002)(66476007)(6486002)(3846002)(8936002)(7736002)(76176011); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB5054; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PNtWIXtsiLeKQPby8RBM4cpkiYnbODYSYJLCZLAFmL/+4UfkFWgpO4JNYrm9SwdAasqVR1CmWXTft38y41GaOdiCVc35IsDG5CQLKEA3jO8VSscNYF0MvF3OZNudDZZgn3fd9TQrajtWM6ExbJN74IBdISdXwgrLpqeJV0hoR5WCiHykT2HNhC7C0oesYlSJJFg7aUkXZOVsRZ7N8eJDSkbrj/xladgJYTniJxwjiwcVt+TwBYn5YHkgDkTHZEfNkI9n7dzhLQz1Uk/IMd2wLkOWTyqQG85+q7L3T+XbaMFnxoAzL/YmL61zmAPiFs/hD5LGJTv6MaZak/FA19Sbfrn5d+LumSYyrnmB4pX7vjn2hUqWFNr2qz6cuzkmxA8P8FGpejaijdsY2Vs0q3fLXVfpyYRzV9kBB05rQwovl3adpXimbdo6MCJ7zpObawaL Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 7f2ee95b-342c-47ee-c03b-08d75d486c9e X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:54.0214 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 2P0sUQmrqZTXQv3ijDym2KhCK7Y8PSa2k96CJgbl0mqtlyxcmO31wrdvA1EvrSOp X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB5054 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.80.135 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: Laurent Vivier , "Oleinik, Alexander" , Thomas Huth , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik The handler allows a qtest client to send commands to the server by directly calling a function, rather than using a file/CharBackend Signed-off-by: Alexander Oleinik --- include/sysemu/qtest.h | 1 + qtest.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h index fda7000d2c..3f365522d5 100644 --- a/include/sysemu/qtest.h +++ b/include/sysemu/qtest.h @@ -28,5 +28,6 @@ void qtest_server_init(const char *qtest_chrdev, const ch= ar *qtest_log, Error ** =20 void qtest_server_set_tx_handler(void (*send)(void *, const char *, size_t= ), void *opaque); +void qtest_server_inproc_recv(void *opaque, const char *buf, size_t size); =20 #endif diff --git a/qtest.c b/qtest.c index ae7e6d779d..9fbfa0f08f 100644 --- a/qtest.c +++ b/qtest.c @@ -802,3 +802,16 @@ bool qtest_driver(void) { return qtest_chr.chr !=3D NULL; } + +void qtest_server_inproc_recv(void *dummy, const char *buf, size_t size) +{ + static GString *gstr; + if (!gstr) { + gstr =3D g_string_new(NULL); + } + g_string_append(gstr, buf); + if (gstr->str[gstr->len - 1] =3D=3D '\n') { + qtest_process_inbuf(NULL, gstr); + g_string_free(gstr, true); + } +} --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447694582319.3012003099326; Wed, 30 Oct 2019 08:01:34 -0700 (PDT) Received: from localhost ([::1]:41300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpTZ-00049a-7H for importer@patchew.org; Wed, 30 Oct 2019 11:01:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35312) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIP-00050O-KY for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIO-0007Hu-CK for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:01 -0400 Received: from mail-eopbgr800133.outbound.protection.outlook.com ([40.107.80.133]:23904 helo=NAM03-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIO-00079I-7H for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:00 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB5054.namprd03.prod.outlook.com (52.132.170.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Wed, 30 Oct 2019 14:49:54 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ecfaSHLJt2CURlWJqMsQsGw8exX3XcFhCFdUXfgzOrOKJAaDfgH0fO2zLvQcZlm5iBQ2vYovS1mSecsP/DRNZc2THVccSwCYlirltB+qwZ+Kzn1WFzqCutvP5o9AW3M1XVU8MxaJgo+XCN7hdwJ2GpjEgzAiaw/Vxay6gdftG0Xykrf9UuIOEQh0kSPf8jzHi8/pWvqGPKsJ6TrDQov5Dofoa0SJKOhNk049QyU5OqdQ+crig7fPfPFmPv1AyIfJnEOGuGD5g5vndHdOrTGmdsjMher/esW6WItw8MZ+5SVVgCK5mlOTdldIwwoCzexVPikKOMGQ9fIBSucu8Qfpyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xGhDICg0i0yiAmYx6RdhRfwFQpxKfFEBTDkOM/PVokM=; b=ZVjGHnZ60RBeRSCckKz5zEA5ue7R506OBuOer1qkbHTw66o2oSUiuwTCxfEr+UGPPY8TR1Gepooj1RR1q8t4I+J7qI8AfwLg5pOP4WEyO4ibp7yEUjgecT9UDtuTqF6Iyec5kZaV1eH6CVJKvfiLzJR4goYTToKYOc9yXzZX4Xejg2jdbgkHgWsVZbQh8Z7CPrrKV7nD0XscNZCVs/5ILLKem3pJ5Ck/NOkylzMOO/2FpzmaHXYnP71lIVuGQVcs9zmOV5dFGCJBt07rxHVVgzofPM8r+jYNIckWu6FGk4XwNq31SqMkCqn2aCnWUcWcMRN01jowOjBuH1YaUxTObA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xGhDICg0i0yiAmYx6RdhRfwFQpxKfFEBTDkOM/PVokM=; b=TaHvtkrjPEJTSKkPiVrx3izfG+OsiYulKxYaCkgLryY7AoxQLh7iR6CgQUtfUCh3X8iZetob/iyLstKQvqDUc0CEfnmajX8pvRp+TvcMf+iTl5oQk0IYrLbp7Jv9zJHNkchqzvN6HAt60Ren3iE2pDc/u5ByiDnXupfeDaXugbw= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 08/20] tests: provide test variables to other targets Thread-Topic: [PATCH v4 08/20] tests: provide test variables to other targets Thread-Index: AQHVjzFKWc/rcZWvH0iPIgR45s9YjQ== Date: Wed, 30 Oct 2019 14:49:54 +0000 Message-ID: <20191030144926.11873-9-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e5656aff-6c64-47d5-e376-08d75d486d11 x-ms-traffictypediagnostic: MN2PR03MB5054: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(346002)(136003)(39860400002)(189003)(199004)(2501003)(36756003)(476003)(86362001)(88552002)(386003)(256004)(316002)(14444005)(5640700003)(1076003)(99286004)(6916009)(75432002)(486006)(786003)(11346002)(6506007)(4326008)(186003)(2906002)(66946007)(26005)(6116002)(14454004)(446003)(2616005)(6512007)(305945005)(71200400001)(478600001)(71190400001)(81166006)(102836004)(66556008)(64756008)(50226002)(8676002)(81156014)(66446008)(6436002)(2351001)(25786009)(5660300002)(66066001)(52116002)(66476007)(6486002)(3846002)(8936002)(7736002)(76176011); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB5054; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: QGnd6nrzhoyCO4NRaZ5ECOP5pYwQm8lSzHfPgLae3MkH6MyaDs2VaUD/njwwuz17d8jqhBMuGdPXE09tRvHCxow9XPhurVqoUbQm4u9tfNC3X4pB+izuKlLO4VANAaSvb7QA8VNACzVNh7cUeHhQex5pKXYY2aDZJl0bD9USj825Wh5UhejgQ1gA06NY90Q4HIx3tpN0ZzA+YQ04+rKuYzjUPIROSURRUJooDsnVdXlYRbPyURWujyp2l/q8d6ogfd2tCzYMJBuGlYOPPHVJ9szkA32JMQX5nzSGpxAk5CuGYMFirUuNqqaN5deH+sm5vXDK9UB4fFCCnY8XKbYAxn5gJ7+Ksfe54ZDLC8A6g9zNvOB92M4uRwtH2adIjemYo0D7whGNeYeNWHu96vm3IqaBfQEjkqU1Xnm18/WudRDpzj4RAnxse6CuMzMETDbU Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: e5656aff-6c64-47d5-e376-08d75d486d11 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:54.8340 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: WrY8ITreqGbRG6Yi1rtw2iDKZVEFg3HHeRphcaH20x6NJKiy4DrkTL7UfRrJqPzn X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB5054 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.80.133 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik Before, when tests/Makefile.include was included, the contents would be ignored if config-host.mak was defined. Moving the ifneq responsible for this allows a target to depend on both testing-related and host-related objects. For example the virtual-device fuzzer relies on both libqtest/libqos objects and softmmu objects. Signed-off-by: Alexander Oleinik Reviewed-by: Darren Kenny --- tests/Makefile.include | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 34ec03391c..67853d10c3 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -27,7 +27,6 @@ check-help: @echo "Default options are -k and (for $(MAKE) V=3D1) --verbose; they can= be" @echo "changed with variable GTESTER_OPTIONS." =20 -ifneq ($(wildcard config-host.mak),) export SRC_PATH =20 # TODO don't duplicate $(SRC_PATH)/Makefile's qapi-py here @@ -873,6 +872,8 @@ tests/test-qga$(EXESUF): tests/test-qga.o $(qtest-obj-y) =20 SPEED =3D quick =20 +ifneq ($(wildcard config-host.mak),) + # gtester tests, possibly with verbose output # do_test_tap runs all tests, even if some of them fail, while do_test_hum= an # stops at the first failure unless -k is given on the command line --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447256826678.6689483845108; Wed, 30 Oct 2019 07:54:16 -0700 (PDT) Received: from localhost ([::1]:41190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpMU-0002Pv-JU for importer@patchew.org; Wed, 30 Oct 2019 10:54:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35285) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIP-0004zS-2F for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIN-0007GD-DV for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:00 -0400 Received: from mail-eopbgr690115.outbound.protection.outlook.com ([40.107.69.115]:23033 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIN-0007Ax-4z for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:49:59 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:49:55 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PF8vblMSb/2W+DVHWpMYuVS1vj0FKPjWhl+FJl2QNFbuGbsoxcRhGX9qtsVLt4V4NnzwyMx+90xxWpr51SnQaBOSFYzz3meIuCeRBd+jVGoak8mGS/kie/0hnH80sDPSU25JnjPrjXHCVEnGsc3SneXR46YCaQ8TJHmcsWU8MOWT4elWB1JnN4ZXWWbPOix7MJliWGDAnil0XPNpaolaHraFFOhtjtSYgMFy+BJRfvYPQ/ncrWlqhGk4mcLmSo8iH8hYIYg2rxxeGpGRDHcyA5eHMZ+M3jhg3bXh4Oc4XJm/gLvrzFm2cRqswg9x44aVbjkn+vIWFivR2wowhfhjWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XlohKFEeNPENybhHei2e0FVYkxQgsNZXNNMup9nrD+A=; b=OnI7PdMDzPDFrOl3OIfdpP5oFGUc/wmlv1LmetNDfqtoV+HidkDOXS8iMgkJmt4qu0r0cLl4XXPqac6lePaPUOq941ht+Y2PCiwHFQ8m30iiX1L4K6gJBtAUQw0u36nSgqInTDP+lhMdi9F336ZdVjNKj7km6Nx6atKCvLsHSFa+cmOUg/UBD/4XMgWUn0gxLL1Zcu54LFwd1gaOdGD3wDLmWnFy66cQmunsL2xhPfSiqHBExGR3dC71IvPs71z2mL8v6PnJZf9VKJ/MHtTT1XBT0s8QiyHDZJa8jX1tp8DcpKBpWPch9zaP3VQ+sx4gVs1Znm0vU2/6Zj0oPCk5fw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XlohKFEeNPENybhHei2e0FVYkxQgsNZXNNMup9nrD+A=; b=fvsM6xvUZr6chT0VgreWo8wxeEMyXb8OlzTw44oS/fPBVWpsdOQsAscZ+7Y3ChtCVUANI/W/R6Bp0dBG6bUvRzdVFYVU1CfhUWyA9yyRif8ZpKmlk4/nUCSRIl1ZPQ1vOC5h2S49mwEnMIeM96pjy6IXZbY5KMkOr2F8ww263h0= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 09/20] libqos: split qos-test and libqos makefile vars Thread-Topic: [PATCH v4 09/20] libqos: split qos-test and libqos makefile vars Thread-Index: AQHVjzFLUjZTO9knKEKo+uppkwfcLA== Date: Wed, 30 Oct 2019 14:49:55 +0000 Message-ID: <20191030144926.11873-10-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d0119ee4-4a0d-4630-4f9c-08d75d486d90 x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2150; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(25786009)(6436002)(75432002)(8936002)(6512007); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2eCn3HtlvBMeL9xFdUL/GCnG4J8NDdugo1mPEdL8clOvtHku9gWe1JkjKHA+wF5pL/Ny4oDQdeGhm8REzmt84yxb2NnMuqa9LVuN49/NCt8oKWXUD3CVXpZ/56eDjfn2FSVpKsIgNqDRFn7YtEMTHDmGEOT8QTNhjKN55us5sG3yd6XP0bm2TuUAxdIeuQB4OmOzBr+NzwycCPbQ9xQ2EqG1hBG5Brl1m6lT81u1JhXMbtryV9z87JBGL/961X453hoNJfekrdN0nqee3TwEwVVMcxoVhFTDczLbVHsigQf6C1+nox2RKBHVHRLKfnsDRk12qoIpmFuMmPB3VcW4kWF0amJXAEUrv0k/hJX9++i/XKGRM4SsbmqaAwqv7McWPg6yj6xF4x6B1HxS61dlR85s2n0NWbk13YS8zPqWAm5bVL0fO+iNpbM5BF6yighb Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: d0119ee4-4a0d-4630-4f9c-08d75d486d90 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:55.5765 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: aYGGPht1AQlJDhYPPHSpjTQw6TUz2qV2+t847U9qc+SctwU0D+vF+nOMwJ6OfTu3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.115 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik Most qos-related objects were specified in the qos-test-obj-y variable. qos-test-obj-y also included qos-test.o which defines a main(). This made it difficult to repurpose qos-test-obj-y to link anything beside tests/qos-test against libqos. This change separates objects that are libqos-specific and ones that are qos-test specific into different variables. Signed-off-by: Alexander Oleinik Reviewed-by: Darren Kenny --- tests/Makefile.include | 71 +++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 67853d10c3..1517c4817e 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -699,52 +699,53 @@ tests/test-crypto-block$(EXESUF): tests/test-crypto-b= lock.o $(test-crypto-obj-y) =20 libqgraph-obj-y =3D tests/libqos/qgraph.o =20 -libqos-obj-y =3D $(libqgraph-obj-y) tests/libqos/pci.o tests/libqos/fw_cfg= .o -libqos-obj-y +=3D tests/libqos/malloc.o -libqos-obj-y +=3D tests/libqos/libqos.o -libqos-spapr-obj-y =3D $(libqos-obj-y) tests/libqos/malloc-spapr.o +libqos-core-obj-y =3D $(libqgraph-obj-y) tests/libqos/pci.o tests/libqos/f= w_cfg.o +libqos-core-obj-y +=3D tests/libqos/malloc.o +libqos-core-obj-y +=3D tests/libqos/libqos.o +libqos-spapr-obj-y =3D $(libqos-core-obj-y) tests/libqos/malloc-spapr.o libqos-spapr-obj-y +=3D tests/libqos/libqos-spapr.o libqos-spapr-obj-y +=3D tests/libqos/rtas.o libqos-spapr-obj-y +=3D tests/libqos/pci-spapr.o -libqos-pc-obj-y =3D $(libqos-obj-y) tests/libqos/pci-pc.o +libqos-pc-obj-y =3D $(libqos-core-obj-y) tests/libqos/pci-pc.o libqos-pc-obj-y +=3D tests/libqos/malloc-pc.o tests/libqos/libqos-pc.o libqos-pc-obj-y +=3D tests/libqos/ahci.o libqos-usb-obj-y =3D $(libqos-spapr-obj-y) $(libqos-pc-obj-y) tests/libqos= /usb.o =20 # Devices -qos-test-obj-y =3D tests/qos-test.o $(libqgraph-obj-y) -qos-test-obj-y +=3D $(libqos-pc-obj-y) $(libqos-spapr-obj-y) -qos-test-obj-y +=3D tests/libqos/e1000e.o -qos-test-obj-y +=3D tests/libqos/i2c.o -qos-test-obj-y +=3D tests/libqos/i2c-imx.o -qos-test-obj-y +=3D tests/libqos/i2c-omap.o -qos-test-obj-y +=3D tests/libqos/sdhci.o -qos-test-obj-y +=3D tests/libqos/tpci200.o -qos-test-obj-y +=3D tests/libqos/virtio.o -qos-test-obj-$(CONFIG_VIRTFS) +=3D tests/libqos/virtio-9p.o -qos-test-obj-y +=3D tests/libqos/virtio-balloon.o -qos-test-obj-y +=3D tests/libqos/virtio-blk.o -qos-test-obj-y +=3D tests/libqos/virtio-mmio.o -qos-test-obj-y +=3D tests/libqos/virtio-net.o -qos-test-obj-y +=3D tests/libqos/virtio-pci.o -qos-test-obj-y +=3D tests/libqos/virtio-pci-modern.o -qos-test-obj-y +=3D tests/libqos/virtio-rng.o -qos-test-obj-y +=3D tests/libqos/virtio-scsi.o -qos-test-obj-y +=3D tests/libqos/virtio-serial.o +libqos-obj-y =3D $(libqgraph-obj-y) +libqos-obj-y +=3D $(libqos-pc-obj-y) $(libqos-spapr-obj-y) +libqos-obj-y +=3D tests/libqos/e1000e.o +libqos-obj-y +=3D tests/libqos/i2c.o +libqos-obj-y +=3D tests/libqos/i2c-imx.o +libqos-obj-y +=3D tests/libqos/i2c-omap.o +libqos-obj-y +=3D tests/libqos/sdhci.o +libqos-obj-y +=3D tests/libqos/tpci200.o +libqos-obj-y +=3D tests/libqos/virtio.o +libqos-obj-$(CONFIG_VIRTFS) +=3D tests/libqos/virtio-9p.o +libqos-obj-y +=3D tests/libqos/virtio-balloon.o +libqos-obj-y +=3D tests/libqos/virtio-blk.o +libqos-obj-y +=3D tests/libqos/virtio-mmio.o +libqos-obj-y +=3D tests/libqos/virtio-net.o +libqos-obj-y +=3D tests/libqos/virtio-pci.o +libqos-obj-y +=3D tests/libqos/virtio-pci-modern.o +libqos-obj-y +=3D tests/libqos/virtio-rng.o +libqos-obj-y +=3D tests/libqos/virtio-scsi.o +libqos-obj-y +=3D tests/libqos/virtio-serial.o =20 # Machines -qos-test-obj-y +=3D tests/libqos/aarch64-xlnx-zcu102-machine.o -qos-test-obj-y +=3D tests/libqos/arm-imx25-pdk-machine.o -qos-test-obj-y +=3D tests/libqos/arm-n800-machine.o -qos-test-obj-y +=3D tests/libqos/arm-raspi2-machine.o -qos-test-obj-y +=3D tests/libqos/arm-sabrelite-machine.o -qos-test-obj-y +=3D tests/libqos/arm-smdkc210-machine.o -qos-test-obj-y +=3D tests/libqos/arm-virt-machine.o -qos-test-obj-y +=3D tests/libqos/arm-xilinx-zynq-a9-machine.o -qos-test-obj-y +=3D tests/libqos/ppc64_pseries-machine.o -qos-test-obj-y +=3D tests/libqos/x86_64_pc-machine.o +libqos-obj-y +=3D tests/libqos/aarch64-xlnx-zcu102-machine.o +libqos-obj-y +=3D tests/libqos/arm-imx25-pdk-machine.o +libqos-obj-y +=3D tests/libqos/arm-n800-machine.o +libqos-obj-y +=3D tests/libqos/arm-raspi2-machine.o +libqos-obj-y +=3D tests/libqos/arm-sabrelite-machine.o +libqos-obj-y +=3D tests/libqos/arm-smdkc210-machine.o +libqos-obj-y +=3D tests/libqos/arm-virt-machine.o +libqos-obj-y +=3D tests/libqos/arm-xilinx-zynq-a9-machine.o +libqos-obj-y +=3D tests/libqos/ppc64_pseries-machine.o +libqos-obj-y +=3D tests/libqos/x86_64_pc-machine.o =20 # Tests +qos-test-obj-y =3D tests/qos-test.o qos-test-obj-y +=3D tests/ac97-test.o qos-test-obj-y +=3D tests/ds1338-test.o qos-test-obj-y +=3D tests/e1000-test.o @@ -776,7 +777,7 @@ check-unit-y +=3D tests/test-qgraph$(EXESUF) tests/test-qgraph$(EXESUF): tests/test-qgraph.o $(libqgraph-obj-y) =20 check-qtest-generic-y +=3D tests/qos-test$(EXESUF) -tests/qos-test$(EXESUF): $(qos-test-obj-y) +tests/qos-test$(EXESUF): $(qos-test-obj-y) $(libqos-obj-y) =20 tests/qmp-test$(EXESUF): tests/qmp-test.o tests/qmp-cmd-test$(EXESUF): tests/qmp-cmd-test.o --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572448071491408.8782059765806; Wed, 30 Oct 2019 08:07:51 -0700 (PDT) Received: from localhost ([::1]:41376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpZe-0001qs-8R for importer@patchew.org; Wed, 30 Oct 2019 11:07:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35358) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIR-00052Y-2n for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIO-0007I4-Hk for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:02 -0400 Received: from mail-eopbgr800135.outbound.protection.outlook.com ([40.107.80.135]:59246 helo=NAM03-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIO-0006yI-BM for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:00 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB5054.namprd03.prod.outlook.com (52.132.170.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Wed, 30 Oct 2019 14:49:56 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dXlayDltMn/kCSydVI+ZUqt0O8UAwO59782LX7tWWORltYKti4VjCpoIt3dICfdnDz3TFwBLLkPrvaFBZJ7RiyQ4t2/TSC+Va/18/aNfACeSN4TEpX/o1vCVH8tCcmLrAO/Q7YieIDcGom5BqaY10v2dY7ZYTZ695gsp/uGrUNRddiLBEsdqS3WyQsPwiUNTd/fxRaSJXwAtgRDT9KkOE5IQ2ooKzIGQufkBUkFXcwT1nXQRmfeTratHbVnJcO92mqbiyjdOdAaZF1Q8qT5jHW/G9vN3JU8AQ3XUYbkshMK+2D4pWMYqko/aGAwl2fXksCatPD+iWdFIEJ9nCi0haA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V9T/dDNyviwcPhgBIk7eJ6pidTIJm05I1fA/CvUnnZw=; b=cIW+M/dT9IwXjEsldthrVrjFWAixu5CVaMzHSFhMVW3fDHn2w+g57pY2HR90TZZ4MjLArvbwx1qtGs56iANEtI1EbQuMRRUAhwrOUehYx7bLr+Q2/3NG/UYke1bpomjE0DIsxB1IP3aEzu9IY7qagAmX03wEqoRaeCOg7Irz8TDP7axvTJlPRdaXuq8/UGEdHUiBwJyODizWNpV7J0ROMqeXMqaeb51ag9nxkNcoaZbCFLcE4oavB7MHuQD6GBJK4RriSXITuWPpNqAJFHYx2dQLWyDttN1iHIeCLXEP7NmECrGwlTfs/uKbpwxKKeczNua64luufcbX3vuhhFJoyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V9T/dDNyviwcPhgBIk7eJ6pidTIJm05I1fA/CvUnnZw=; b=ODeS/a2JLbCebyEF+D/lH4GlvAFFQk+QGRweAnjqLgyPrZz5CBwyjZyJgnnQdZzfrA14Jz735QD2vip2A9p0cx60F2Cak0RTNwMssMApIKub9kZOvcNuupMUoxvfQdJEKsPQveSxL1sucPbhIPXNTRFFOvfBKsvDysyBEFJvX38= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 10/20] libqos: move useful qos-test funcs to qos_external Thread-Topic: [PATCH v4 10/20] libqos: move useful qos-test funcs to qos_external Thread-Index: AQHVjzFL0KZhv7FtpkGReI4t3z43QQ== Date: Wed, 30 Oct 2019 14:49:56 +0000 Message-ID: <20191030144926.11873-11-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1a2a1361-f224-4efc-ee5c-08d75d486e23 x-ms-traffictypediagnostic: MN2PR03MB5054: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(346002)(136003)(39860400002)(189003)(199004)(2501003)(36756003)(476003)(86362001)(6306002)(88552002)(386003)(256004)(316002)(14444005)(5640700003)(1076003)(99286004)(6916009)(75432002)(486006)(786003)(11346002)(6506007)(4326008)(54906003)(186003)(2906002)(66946007)(26005)(6116002)(14454004)(446003)(2616005)(6512007)(305945005)(71200400001)(478600001)(71190400001)(81166006)(102836004)(66556008)(64756008)(50226002)(8676002)(81156014)(66446008)(30864003)(6436002)(2351001)(25786009)(5660300002)(66066001)(52116002)(66476007)(6486002)(3846002)(8936002)(7736002)(76176011)(2004002); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB5054; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: sougyyVk1fFYrsjB2YPENHYiB26CBkr7uRTq33tk2Dzoil0jjRrBd9wzNunzSXmqSGHGBUw4jU6frlgEnl6l890i4cSVya26tU4SiYZy30I2u3XUoZRhgdWMrYjcLmunfEeKRgvU7F3TVfecA05/pkk9bW55hEqsNM6inN/ZzcjrX/KHdnrT7Vhgkrt/7o4u7CWUPb05gANbADN1AZltKqN/bgiEJ3vHk4aXQbqemJJZpI7wnwm/S1OGU5Z52DM0wNT/ifHxe0m7jnIlsFlCIJ9FJV0+td1OZ3H2+M4eA5c2SUlwPrqOqO5HhCJU6gnzep1kLtlvXLb84pL2/3JvpyzPzCaSGH8hE1yXbCM41+X3xXJtquWxfUEFwClZhzMEZbC63KgVvkVJMPH//4hf+nbdYASUKBIyB21xSWfdUYNXsqp1Q9Qsvu9MF9tRLAtkhm8OvDhfJvyodH6+Xda7rSJwr9HMefTr32JAyFbdyIA= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 1a2a1361-f224-4efc-ee5c-08d75d486e23 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:56.6019 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: K6GX8AsV8geYhfEomnEfSH41/83n7H2j46NRE+Y5vNNdULO+IJlBpwqbSrtbd2US X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB5054 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.80.135 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: Laurent Vivier , "Oleinik, Alexander" , Thomas Huth , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik The moved functions are not specific to qos-test and might be useful elsewhere. For example the virtual-device fuzzer makes use of them for qos-assisted fuzz-targets. Signed-off-by: Alexander Oleinik Reviewed-by: Stefan Hajnoczi --- tests/Makefile.include | 1 + tests/libqos/qos_external.c | 168 ++++++++++++++++++++++++++++++++++++ tests/libqos/qos_external.h | 28 ++++++ tests/qos-test.c | 140 ++---------------------------- 4 files changed, 202 insertions(+), 135 deletions(-) create mode 100644 tests/libqos/qos_external.c create mode 100644 tests/libqos/qos_external.h diff --git a/tests/Makefile.include b/tests/Makefile.include index 1517c4817e..2cccc05ae1 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -714,6 +714,7 @@ libqos-usb-obj-y =3D $(libqos-spapr-obj-y) $(libqos-pc-= obj-y) tests/libqos/usb.o # Devices libqos-obj-y =3D $(libqgraph-obj-y) libqos-obj-y +=3D $(libqos-pc-obj-y) $(libqos-spapr-obj-y) +libqos-obj-y +=3D tests/libqos/qos_external.o libqos-obj-y +=3D tests/libqos/e1000e.o libqos-obj-y +=3D tests/libqos/i2c.o libqos-obj-y +=3D tests/libqos/i2c-imx.o diff --git a/tests/libqos/qos_external.c b/tests/libqos/qos_external.c new file mode 100644 index 0000000000..398556dde0 --- /dev/null +++ b/tests/libqos/qos_external.c @@ -0,0 +1,168 @@ +/* + * libqos driver framework + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" +#include +#include "libqtest.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qbool.h" +#include "qapi/qmp/qstring.h" +#include "qemu/module.h" +#include "qapi/qmp/qlist.h" +#include "libqos/malloc.h" +#include "libqos/qgraph.h" +#include "libqos/qgraph_internal.h" +#include "libqos/qos_external.h" + + + +void apply_to_node(const char *name, bool is_machine, bool is_abstract) +{ + char *machine_name =3D NULL; + if (is_machine) { + const char *arch =3D qtest_get_arch(); + machine_name =3D g_strconcat(arch, "/", name, NULL); + name =3D machine_name; + } + qos_graph_node_set_availability(name, true); + if (is_abstract) { + qos_delete_cmd_line(name); + } + g_free(machine_name); +} + +/** + * apply_to_qlist(): using QMP queries QEMU for a list of + * machines and devices available, and sets the respective node + * as true. If a node is found, also all its produced and contained + * child are marked available. + * + * See qos_graph_node_set_availability() for more info + */ +void apply_to_qlist(QList *list, bool is_machine) +{ + const QListEntry *p; + const char *name; + bool abstract; + QDict *minfo; + QObject *qobj; + QString *qstr; + QBool *qbool; + + for (p =3D qlist_first(list); p; p =3D qlist_next(p)) { + minfo =3D qobject_to(QDict, qlist_entry_obj(p)); + qobj =3D qdict_get(minfo, "name"); + qstr =3D qobject_to(QString, qobj); + name =3D qstring_get_str(qstr); + + qobj =3D qdict_get(minfo, "abstract"); + if (qobj) { + qbool =3D qobject_to(QBool, qobj); + abstract =3D qbool_get_bool(qbool); + } else { + abstract =3D false; + } + + apply_to_node(name, is_machine, abstract); + qobj =3D qdict_get(minfo, "alias"); + if (qobj) { + qstr =3D qobject_to(QString, qobj); + name =3D qstring_get_str(qstr); + apply_to_node(name, is_machine, abstract); + } + } +} + +QGuestAllocator *get_machine_allocator(QOSGraphObject *obj) +{ + return obj->get_driver(obj, "memory"); +} + +/** + * allocate_objects(): given an array of nodes @arg, + * walks the path invoking all constructors and + * passing the corresponding parameter in order to + * continue the objects allocation. + * Once the test is reached, return the object it consumes. + * + * Since the machine and QEDGE_CONSUMED_BY nodes allocate + * memory in the constructor, g_test_queue_destroy is used so + * that after execution they can be safely free'd. (The test's + * ->before callback is also welcome to use g_test_queue_destroy). + * + * Note: as specified in walk_path() too, @arg is an array of + * char *, where arg[0] is a pointer to the command line + * string that will be used to properly start QEMU when executing + * the test, and the remaining elements represent the actual objects + * that will be allocated. + */ +void *allocate_objects(QTestState *qts, char **path, QGuestAllocator **p_a= lloc) +{ + int current =3D 0; + QGuestAllocator *alloc; + QOSGraphObject *parent =3D NULL; + QOSGraphEdge *edge; + QOSGraphNode *node; + void *edge_arg; + void *obj; + + node =3D qos_graph_get_node(path[current]); + g_assert(node->type =3D=3D QNODE_MACHINE); + + obj =3D qos_machine_new(node, qts); + qos_object_queue_destroy(obj); + + alloc =3D get_machine_allocator(obj); + if (p_alloc) { + *p_alloc =3D alloc; + } + + for (;;) { + if (node->type !=3D QNODE_INTERFACE) { + qos_object_start_hw(obj); + parent =3D obj; + } + + /* follow edge and get object for next node constructor */ + current++; + edge =3D qos_graph_get_edge(path[current - 1], path[current]); + node =3D qos_graph_get_node(path[current]); + + if (node->type =3D=3D QNODE_TEST) { + g_assert(qos_graph_edge_get_type(edge) =3D=3D QEDGE_CONSUMED_B= Y); + return obj; + } + + switch (qos_graph_edge_get_type(edge)) { + case QEDGE_PRODUCES: + obj =3D parent->get_driver(parent, path[current]); + break; + + case QEDGE_CONSUMED_BY: + edge_arg =3D qos_graph_edge_get_arg(edge); + obj =3D qos_driver_new(node, obj, alloc, edge_arg); + qos_object_queue_destroy(obj); + break; + + case QEDGE_CONTAINS: + obj =3D parent->get_device(parent, path[current]); + break; + } + } +} + diff --git a/tests/libqos/qos_external.h b/tests/libqos/qos_external.h new file mode 100644 index 0000000000..7b44930c55 --- /dev/null +++ b/tests/libqos/qos_external.h @@ -0,0 +1,28 @@ +/* + * libqos driver framework + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#ifndef QOS_EXTERNAL_H +#define QOS_EXTERNAL_H +#include "libqos/qgraph.h" + +void apply_to_node(const char *name, bool is_machine, bool is_abstract); +void apply_to_qlist(QList *list, bool is_machine); +QGuestAllocator *get_machine_allocator(QOSGraphObject *obj); +void *allocate_objects(QTestState *qts, char **path, QGuestAllocator **p_a= lloc); + +#endif diff --git a/tests/qos-test.c b/tests/qos-test.c index fd70d73ea5..9d02b83e24 100644 --- a/tests/qos-test.c +++ b/tests/qos-test.c @@ -27,65 +27,11 @@ #include "libqos/malloc.h" #include "libqos/qgraph.h" #include "libqos/qgraph_internal.h" +#include "libqos/qos_external.h" =20 static char *old_path; =20 -static void apply_to_node(const char *name, bool is_machine, bool is_abstr= act) -{ - char *machine_name =3D NULL; - if (is_machine) { - const char *arch =3D qtest_get_arch(); - machine_name =3D g_strconcat(arch, "/", name, NULL); - name =3D machine_name; - } - qos_graph_node_set_availability(name, true); - if (is_abstract) { - qos_delete_cmd_line(name); - } - g_free(machine_name); -} =20 -/** - * apply_to_qlist(): using QMP queries QEMU for a list of - * machines and devices available, and sets the respective node - * as true. If a node is found, also all its produced and contained - * child are marked available. - * - * See qos_graph_node_set_availability() for more info - */ -static void apply_to_qlist(QList *list, bool is_machine) -{ - const QListEntry *p; - const char *name; - bool abstract; - QDict *minfo; - QObject *qobj; - QString *qstr; - QBool *qbool; - - for (p =3D qlist_first(list); p; p =3D qlist_next(p)) { - minfo =3D qobject_to(QDict, qlist_entry_obj(p)); - qobj =3D qdict_get(minfo, "name"); - qstr =3D qobject_to(QString, qobj); - name =3D qstring_get_str(qstr); - - qobj =3D qdict_get(minfo, "abstract"); - if (qobj) { - qbool =3D qobject_to(QBool, qobj); - abstract =3D qbool_get_bool(qbool); - } else { - abstract =3D false; - } - - apply_to_node(name, is_machine, abstract); - qobj =3D qdict_get(minfo, "alias"); - if (qobj) { - qstr =3D qobject_to(QString, qobj); - name =3D qstring_get_str(qstr); - apply_to_node(name, is_machine, abstract); - } - } -} =20 /** * qos_set_machines_devices_available(): sets availability of qgraph @@ -129,10 +75,6 @@ static void qos_set_machines_devices_available(void) qobject_unref(response); } =20 -static QGuestAllocator *get_machine_allocator(QOSGraphObject *obj) -{ - return obj->get_driver(obj, "memory"); -} =20 static void restart_qemu_or_continue(char *path) { @@ -159,78 +101,6 @@ void qos_invalidate_command_line(void) old_path =3D NULL; } =20 -/** - * allocate_objects(): given an array of nodes @arg, - * walks the path invoking all constructors and - * passing the corresponding parameter in order to - * continue the objects allocation. - * Once the test is reached, return the object it consumes. - * - * Since the machine and QEDGE_CONSUMED_BY nodes allocate - * memory in the constructor, g_test_queue_destroy is used so - * that after execution they can be safely free'd. (The test's - * ->before callback is also welcome to use g_test_queue_destroy). - * - * Note: as specified in walk_path() too, @arg is an array of - * char *, where arg[0] is a pointer to the command line - * string that will be used to properly start QEMU when executing - * the test, and the remaining elements represent the actual objects - * that will be allocated. - */ -static void *allocate_objects(QTestState *qts, char **path, QGuestAllocato= r **p_alloc) -{ - int current =3D 0; - QGuestAllocator *alloc; - QOSGraphObject *parent =3D NULL; - QOSGraphEdge *edge; - QOSGraphNode *node; - void *edge_arg; - void *obj; - - node =3D qos_graph_get_node(path[current]); - g_assert(node->type =3D=3D QNODE_MACHINE); - - obj =3D qos_machine_new(node, qts); - qos_object_queue_destroy(obj); - - alloc =3D get_machine_allocator(obj); - if (p_alloc) { - *p_alloc =3D alloc; - } - - for (;;) { - if (node->type !=3D QNODE_INTERFACE) { - qos_object_start_hw(obj); - parent =3D obj; - } - - /* follow edge and get object for next node constructor */ - current++; - edge =3D qos_graph_get_edge(path[current - 1], path[current]); - node =3D qos_graph_get_node(path[current]); - - if (node->type =3D=3D QNODE_TEST) { - g_assert(qos_graph_edge_get_type(edge) =3D=3D QEDGE_CONSUMED_B= Y); - return obj; - } - - switch (qos_graph_edge_get_type(edge)) { - case QEDGE_PRODUCES: - obj =3D parent->get_driver(parent, path[current]); - break; - - case QEDGE_CONSUMED_BY: - edge_arg =3D qos_graph_edge_get_arg(edge); - obj =3D qos_driver_new(node, obj, alloc, edge_arg); - qos_object_queue_destroy(obj); - break; - - case QEDGE_CONTAINS: - obj =3D parent->get_device(parent, path[current]); - break; - } - } -} =20 /* The argument to run_one_test, which is the test function that is regist= ered * with GTest, is a vector of strings. The first item is the initial comm= and @@ -239,14 +109,14 @@ static void *allocate_objects(QTestState *qts, char *= *path, QGuestAllocator **p_ */ static char **current_path; =20 -const char *qos_get_current_command_line(void) +void *qos_allocate_objects(QTestState *qts, QGuestAllocator **p_alloc) { - return current_path[0]; + return allocate_objects(qts, current_path + 1, p_alloc); } =20 -void *qos_allocate_objects(QTestState *qts, QGuestAllocator **p_alloc) +const char *qos_get_current_command_line(void) { - return allocate_objects(qts, current_path + 1, p_alloc); + return current_path[0]; } =20 /** --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447792674163.25762577079138; Wed, 30 Oct 2019 08:03:12 -0700 (PDT) Received: from localhost ([::1]:41326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpV9-0006Fe-6E for importer@patchew.org; Wed, 30 Oct 2019 11:03:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35306) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIP-00050A-Fp for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIN-0007H3-W8 for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:01 -0400 Received: from mail-eopbgr690115.outbound.protection.outlook.com ([40.107.69.115]:23033 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIN-0007Ax-Om for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:49:59 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:49:57 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gk9XJGQhe2HsG7t7VfXJ+uA965Yxde4MT7Ognxv3t4p1b/OqryHAY8+P2PAG1LuzLKg+My2ltJduTSp4vF1NUdzgstAJAOqzEHSeYKdlo1e7qIDSP6D2cU3TVsuYYPUzt1ViYyriLzAnf1MUEJT5/VZE62TYuPYuimJBe0k+EcUGjZzLbwEgY+i8uiVtwbppyfz8QEguDnPRcGrT4MZuC125vLqKXonRk+5LVbT8E8xI5rg+5EZ/HlROrl4Vralgujp/f/GaRar7OFMgdvy+zMO9GYcG6Jzz6SkKJHLGrxDhfs8Kejlh/J/sLzPjbN1od4oBa3u7gP1/b7z+l0TwoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n5sgL4kkRD77xB+hq+p0VcS0k4XgsH5CHmlSdf6ZUvc=; b=V60MDBT13JpKtIe041pJ3IRIy88S9lUa2ZE585+ngTWE79utYkbHXuk3TwLjCl051DWNIm5z5y9LlyfVZL61NL4z89KVdO5zt+HyfcSTiPH++YoZ5JWpgNx2NNEiVPPyc9AUAGqKw5revWn3bdcur3ieHON7+qDTMgHuOeZVPuW0U8WiTapFS45jwzGVyKLgjX7IG4AZAafqbjH0opavHSe3YiLMNCZr3SLaKVPs2ttED14NBG9KTo/lhDu63ES6N/3+tqx6ma9+0WqklsexDzdMPDK2aUg4CLKTvhRGFzUD2P7ImqtdsjMiQJaz5Knjy3T4CBEMqjXbAOTlGhcBBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n5sgL4kkRD77xB+hq+p0VcS0k4XgsH5CHmlSdf6ZUvc=; b=IPYQVNVxDzKWUKebDj8THxCYy3B1njjTycwvOZb1SjY1b7trmca21E+B30C9YP7ZcUDKrG9Ro+NQYayIVTWxV8VVISb4mAfHjjeih/nqka2wXJSDuZh64FsHDbkUPkwcfpnXTgmhBZDhH1E51TDM/f6klTRhzZFY3ApOxBlbS3s= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 11/20] libqtest: make qtest_bufwrite send "atomic" Thread-Topic: [PATCH v4 11/20] libqtest: make qtest_bufwrite send "atomic" Thread-Index: AQHVjzFMkTj1zf9vkEGJEPFn4TIi9A== Date: Wed, 30 Oct 2019 14:49:57 +0000 Message-ID: <20191030144926.11873-12-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b2bea292-7ee6-4e83-ec6f-08d75d486eb8 x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:449; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(4744005)(25786009)(6436002)(54906003)(75432002)(8936002)(6512007); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: phr6d/yQ94mvtM1pM4XiSiIm0jpAdYg7qnXbaLE7nSRyLcLiNIHg01Z14OcPCdnyf36/si1gdXl50soeuJ0U9rxpcjbH9Do7RC6q8JSFGO2GascBmSM8EAlQJYuQar5GLQX1v+iWUPfAvrlsQqLRHdicdpdcSeRNxoS3dU3r5GEkcG2+UzOyeEJL7nwW2bR1OamDgTqxqR4dFYqhVnIrvPcaFk4BadJZTpHnqQPazbAouawCbxSmaqWUccONWGBJS6nIIwAeZWcXciCTnd/hCv+PL4H8SAiPtLamVVQsmU8rm2INQLnve4CD6rTdiaKqr5kchichzx/O+Y6wq7XKuiciVm3V4U7rXRzPj79NMJmqVNc8X0KKZZ8V5zrGCYKP4R1KtTwOfjOpCq20XmR8Zkgh7U01A7A45rqBCnSjAK0O5oZfJhtCYK06jYUDYThU Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: b2bea292-7ee6-4e83-ec6f-08d75d486eb8 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:57.5614 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: rBXU/zUltKb0n4EV9GvYsm47Tqi9vhBo5HPWVKCJk5qbTx/nXX62FNFdhXVuWGBs X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.115 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: Laurent Vivier , "Oleinik, Alexander" , Thomas Huth , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik When using qtest "in-process" communication, qtest_sendf directly calls a function in the server (qtest.c). Combining the contents of the subsequent socket_sends into the qtest_sendf, makes it so the server can immediately handle the command, without building a local buffer and waiting for a newline. Signed-off-by: Alexander Oleinik --- tests/libqtest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 822bfe208b..ff3153daf2 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1083,8 +1083,8 @@ void qtest_bufwrite(QTestState *s, uint64_t addr, con= st void *data, size_t size) =20 bdata =3D g_base64_encode(data, size); qtest_sendf(s, "b64write 0x%" PRIx64 " 0x%zx ", addr, size); - socket_send(s->fd, bdata, strlen(bdata)); - socket_send(s->fd, "\n", 1); + s->ops.send(s, bdata, strlen(bdata)); + s->ops.send(s, "\n", 1); qtest_rsp(s, 0); g_free(bdata); } --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447207172938.2112873240486; Wed, 30 Oct 2019 07:53:27 -0700 (PDT) Received: from localhost ([::1]:41184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpLh-00018s-My for importer@patchew.org; Wed, 30 Oct 2019 10:53:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35361) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIR-00052t-8B for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIP-0007Ji-QH for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:03 -0400 Received: from mail-eopbgr690115.outbound.protection.outlook.com ([40.107.69.115]:23033 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIP-0007Ax-GQ for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:01 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:49:58 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JkHb5aC16jE5C+9jBmrXqRxVDkso0Tgk/Z0hQ/B6RLYaz4Fe5uJVH/GLfpjNWCHSiQfO5YW/qsEdXm30k5lY7Xlza8IBddOjW5wCGD5jQ6lLQ3O4mf2LwNTMgkBJ84g9P9+vKTPInLGniiLnx2gGehVGmHpgfQ+uj3UROreMy6+A551x20UuK/gdsVEdQVG5oyixJf+wWWkBNNcCYXHViH3mtmuEOKUbfPyVWf8eBLFuw6JneY3Fy70BVFt4GZwAReA9yRZXghfEgB9IWilYrqmVTqLSfwqQMXl1m/+0LjHxFgl8xJi3rlbZp7WOSoplgX2eUgsCXnmAO2MRBAxnaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l4k01TjyloxFs5+fi5Uc8/v+PfVMYbJjMeZc7qNSdqk=; b=FGf/jxVQ8eqEfL5mGvpD1tP965McCklApCf1VZya/mXVy7SO5Pk9oh63R+D3cOw2HI6H0slrql39Ca4q+gGQGLwBtf7OYqIlMaEz9bkVRlkJg+87dx5+SjS6VZaadltzXbQQEh9gx2wlo3jUV+inHwqddtHs/SAAqUIv46qmOOz1tTJKIFLJWuK2z4f8S1642SbzKtFbxlTJ9x53nFhkTlgDpWwplEZfjT2DCC51pO2T1ebwBazFBbFeHIlG4UUxorVYa6MQq3eKJ7H8wMNZMgZ8ivUGl2lUQ5KQJXJzhfdaH6aUzOvxY04KkMcwyHrpdMk9l4UnjqR7v89zsknsxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l4k01TjyloxFs5+fi5Uc8/v+PfVMYbJjMeZc7qNSdqk=; b=aoxAV7VbhJUag6oaPeJPQgY7NZi6be3ELL7TdeJeMCBPyY/4U78e89+Gzojz8Oumpqbd7oiEe2pRYW0fAy1KOlss0ReP9e3Ge+kWV/EKL/JX5hvjn7Do/x4MZojkvW/HtsHUUx8RVst+BtBIlWH0BZijrzNPoDEIVTsu4RoqfVU= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 12/20] libqtest: add in-process qtest.c tx/rx handlers Thread-Topic: [PATCH v4 12/20] libqtest: add in-process qtest.c tx/rx handlers Thread-Index: AQHVjzFMZCJi/x3SAU+2TC4zQBE0Lg== Date: Wed, 30 Oct 2019 14:49:58 +0000 Message-ID: <20191030144926.11873-13-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a09f1917-1b77-430f-fbd2-08d75d486f4e x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:115; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(14444005)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(25786009)(6436002)(54906003)(75432002)(8936002)(6512007); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +KzMUN2eplcH97fOgj53ccGAiDl2tNDmT9E9TnyKpHEITBIEjzhQalI9yXoD8a3zbkGAFqslCOLSDx94T0aYXwyYqrnr/5w70+mDyjgRLbFKE5mrFnOHuT7JeoacIdQQraNPfLwIoivbcCFF1NxN7gfWvOQcxYt9SyUxJQKY/5KdDl0v+ZTJgxjAH4bcOVPuR8q5AUiYSFnz3Ns7mrnS6IlnJ4ZiJgF5NucatqUUx+zoOswWPru9SUZQwpGUCT6aQIb4ul2qaQ3coNTSa+MOUVbd1BmxEexnVNNBH/QikhAQPsfbtSsDiLO0ikt96EZh0RVbU2+cnvQ2mT5/5vCBcLKSlx6xABmAzpAOKK1Wofr9HIajG/gp92J1Bz5v1pCqZ2yEtK3G3f+OsW/KOc5d+oBFxwOuLsAZIpuioi9b0qQdZYSklKNDGDOQiAK41zb1 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: a09f1917-1b77-430f-fbd2-08d75d486f4e X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:58.5768 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BjZgNZz2hDAYig3e6H48ame8bciwuikilDLwF1ORJhQHVW12Jy8UR86AHI6AUuXO X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.115 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: Laurent Vivier , "Oleinik, Alexander" , Thomas Huth , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik Signed-off-by: Alexander Oleinik --- There's a particularily ugly line here: qtest_client_set_tx_handler(qts, (void (*)(QTestState *s, const char*, size_t)) send); Since qtest.c has no knowledge of the QTestState, I'm not sure how to avoid doing this, without adding back the *opaque that was present in v3. qtest.c | 2 +- tests/libqtest.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/libqtest.h | 5 +++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/qtest.c b/qtest.c index 9fbfa0f08f..f817a5d789 100644 --- a/qtest.c +++ b/qtest.c @@ -812,6 +812,6 @@ void qtest_server_inproc_recv(void *dummy, const char *= buf, size_t size) g_string_append(gstr, buf); if (gstr->str[gstr->len - 1] =3D=3D '\n') { qtest_process_inbuf(NULL, gstr); - g_string_free(gstr, true); + g_string_truncate(gstr, 0); } } diff --git a/tests/libqtest.c b/tests/libqtest.c index ff3153daf2..6143af33da 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -71,6 +71,7 @@ static void qtest_client_set_tx_handler(QTestState *s, static void qtest_client_set_rx_handler(QTestState *s, GString * (*recv)(QTestState *)); =20 +static GString *recv_str; =20 static int init_socket(const char *socket_path) { @@ -486,6 +487,7 @@ static GString *qtest_client_socket_recv_line(QTestStat= e *s) return line; } =20 + static gchar **qtest_rsp(QTestState *s, int expected_args) { GString *line; @@ -1372,3 +1374,50 @@ static void qtest_client_set_rx_handler(QTestState *= s, { s->ops.recv_line =3D recv; } + +static GString *qtest_client_inproc_recv_line(QTestState *s) +{ + GString *line; + size_t offset; + char *eol; + + eol =3D strchr(recv_str->str, '\n'); + offset =3D eol - recv_str->str; + line =3D g_string_new_len(recv_str->str, offset); + g_string_erase(recv_str, 0, offset + 1); + return line; +} + +QTestState *qtest_inproc_init(bool log, const char* arch, + void (*send)(void*, const char*, size_t)) +{ + QTestState *qts; + qts =3D g_new(QTestState, 1); + qts->wstatus =3D 0; + for (int i =3D 0; i < MAX_IRQ; i++) { + qts->irq_level[i] =3D false; + } + + qtest_client_set_rx_handler(qts, qtest_client_inproc_recv_line); + /* Re-cast the send pointer, since qtest.c should need to know about + * QTestState + */ + qtest_client_set_tx_handler(qts, + (void (*)(QTestState *s, const char*, size_t)) send); + + qts->big_endian =3D qtest_query_target_endianness(qts); + gchar *bin_path =3D g_strconcat("/qemu-system-", arch, NULL); + setenv("QTEST_QEMU_BINARY", bin_path, 0); + g_free(bin_path); + + return qts; +} + +void qtest_client_inproc_recv(void *opaque, const char *str, size_t len) +{ + if (!recv_str) { + recv_str =3D g_string_new(NULL); + } + g_string_append_len(recv_str, str, len); + return; +} diff --git a/tests/libqtest.h b/tests/libqtest.h index 31267fc915..7251de4ba9 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -728,4 +728,9 @@ bool qtest_probe_child(QTestState *s); * Set expected exit status of the child. */ void qtest_set_expected_status(QTestState *s, int status); + + +QTestState *qtest_inproc_init(bool log, const char* arch, + void (*send)(void*, const char*, size_t)); +void qtest_client_inproc_recv(void *opaque, const char *str, size_t len); #endif --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447986539422.694805837275; Wed, 30 Oct 2019 08:06:26 -0700 (PDT) Received: from localhost ([::1]:41360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpYH-0000tT-3T for importer@patchew.org; Wed, 30 Oct 2019 11:06:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35365) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIR-00053j-JP for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIQ-0007KN-CB for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:03 -0400 Received: from mail-eopbgr690115.outbound.protection.outlook.com ([40.107.69.115]:23033 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIQ-0007Ax-4Q for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:02 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:49:59 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:49:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ob/O8ADCS1WReBZ6hk3CNr5k21el4oQUy2NFEpLdVDyLUMF1PceElcwsI9kCOVOt+lLj+Rbwe1Y/0MXh/z7ZWEITDIm67eKI5iAkX43Hb1BUKOhfqKZ8MA6coHOsy4MKWxyick1bkhAQJRmBfr50khWgPq4bpWAdnNfJInFWfVnVkVjBJyP50ipqd5RN1qVIxg/WJ070idupoIVezrYm++qF30ioqpp/dqG1BqTHllOXxt7ELGqCRT/uVT2exqih/pfMDhynzevVuV/5sfhgo4YWPyx47qWVcCOmJjaA3XAQgu2vTpoKWKuIzQl3bOifmaEC3o9Q0pfECpIdq7fGOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5A2jXiUgW+IZC2QLmA+Q4LR+o2sg3npX/gkaI/Li8WI=; b=GTRBDNDjDMK4gg/gQdOGtDiQM6YzcxrMjwGSeNeC2aySteVOku+G1G3xT9wTJ6hJN/64op4J+dedPabGdRGu2vdfj19jKQoBv4jxjXlJKVe1tS7AMdmld8Q0LuM91IhaZEyRMULnwJ/aL5ESiiyzTcJMDPSogqBas1K2eKyL5WFW8BmMbeWb8Ue9qtwQIE2dfqs6zO1rwdWK8GhDYMPREKxY0+sUGSFrRrgFPsVlbfNBdsT8iu3H+V84N6cR21qjCiE06Imi8lEdAcMxswHwZ+4yKks73FteZRJwWX51BxFKqCcfsQ9Ov1zzqZfrBTt5Sm+kNjdBfnL+pyDDO5dUgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5A2jXiUgW+IZC2QLmA+Q4LR+o2sg3npX/gkaI/Li8WI=; b=yE9Ny86WoBg4KQ4tgKwQCXDmYE8OKvANE2UiFi+WZYep6528BSTtIbsMfukMwtLCWbeBYIRb85Jx/A5pa7pfJ50wG+bcGL/erGniDeuD0daJrYdopGLIeqmrQVpKcBHmkd9f20AMGY7bM4Zb3lhg1X/s8+Zk0/Zd9D8s/oq4uxs= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 13/20] fuzz: add configure flag --enable-fuzzing Thread-Topic: [PATCH v4 13/20] fuzz: add configure flag --enable-fuzzing Thread-Index: AQHVjzFNJM1RkEcEfUWq2jVZP3MbOA== Date: Wed, 30 Oct 2019 14:49:59 +0000 Message-ID: <20191030144926.11873-14-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 41e83748-740c-4189-fbd7-08d75d486fc8 x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:962; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(25786009)(6436002)(75432002)(8936002)(6512007); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Yw9hg+ho3XUeN1xXcvCfU+Xi88MEUV1+7loj2vTmXhIftp0tEKDApT+uSIMUYz2hxU4Mnn/IGDNGa44Iz2lfvDHEqpmqx6VLfKwyxJPobi4/1X63KgayM1o1Z/Y9Q+N4Ae/S5HOMEqby0iqwBRvrbVaRCBOyBs8GpMbQblEY093K2z1bhdo5xB246Kf2J8AKd0oW6C1bArSuPQklUrN+0pQtnw8JNa8vW/5yft/AtD2kT5KKODj909vEZ0hHh/jPgs9FLFVFVRPaCnb1adB0gDXmVaAar/6X6taI1e3ocift+zo51Xq8zoM4SclouOs8sDEdjELyNhBxrGKIgjxi6XkPdEFsIGeU1t1xnN0RusHg115IHgvS95BswpTRYa4iKyUIU98kmyfrqSs1MXNHSRogNMaqcLsBBR2FDUWQbuuvV5+dih68tUsiSAmxYjv7 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 41e83748-740c-4189-fbd7-08d75d486fc8 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:49:59.2694 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: kltoLeTetWkMHfB/yULXqN7mkg883N2P+QiIa6lDVDTUJHlM8RB6V31qcI8CyROB X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.115 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik Signed-off-by: Alexander Oleinik Reviewed-by: Stefan Hajnoczi --- configure | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/configure b/configure index 3be9e92a24..aeca632dd9 100755 --- a/configure +++ b/configure @@ -501,6 +501,7 @@ libxml2=3D"" debug_mutex=3D"no" libpmem=3D"" default_devices=3D"yes" +fuzzing=3D"no" =20 supported_cpu=3D"no" supported_os=3D"no" @@ -630,6 +631,15 @@ int main(void) { return 0; } EOF } =20 +write_c_fuzzer_skeleton() { + cat > $TMPC < +#include +int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); +int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; } +EOF +} + if check_define __linux__ ; then targetos=3D"Linux" elif check_define _WIN32 ; then @@ -1532,6 +1542,10 @@ for opt do ;; --disable-xkbcommon) xkbcommon=3Dno ;; + --enable-fuzzing) fuzzing=3Dyes + ;; + --disable-fuzzing) fuzzing=3Dno + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -5911,6 +5925,15 @@ EOF fi fi =20 +########################################## +# checks for fuzzer +if test "$fuzzing" =3D "yes" ; then + write_c_fuzzer_skeleton + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=3Daddress,fuzzer" ""; th= en + have_fuzzer=3Dyes + fi +fi + ########################################## # check for libpmem =20 @@ -6491,6 +6514,7 @@ echo "capstone $capstone" echo "libpmem support $libpmem" echo "libudev $libudev" echo "default devices $default_devices" +echo "fuzzing support $fuzzing" =20 if test "$supported_cpu" =3D "no"; then echo @@ -7327,6 +7351,16 @@ fi if test "$sheepdog" =3D "yes" ; then echo "CONFIG_SHEEPDOG=3Dy" >> $config_host_mak fi +if test "$fuzzing" =3D "yes" ; then + if test "$have_fuzzer" =3D "yes"; then + FUZZ_LDFLAGS=3D" -fsanitize=3Daddress,fuzzer" + FUZZ_CFLAGS=3D" -fsanitize=3Daddress,fuzzer" + CFLAGS=3D" -fsanitize=3Daddress" + else + error_exit "Your compiler doesn't support -fsanitize=3Daddress,fuzzer" + exit 1 + fi +fi =20 if test "$tcg_interpreter" =3D "yes"; then QEMU_INCLUDES=3D"-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" @@ -7409,6 +7443,11 @@ if test "$libudev" !=3D "no"; then echo "CONFIG_LIBUDEV=3Dy" >> $config_host_mak echo "LIBUDEV_LIBS=3D$libudev_libs" >> $config_host_mak fi +if test "$fuzzing" !=3D "no"; then + echo "CONFIG_FUZZ=3Dy" >> $config_host_mak + echo "FUZZ_CFLAGS=3D$FUZZ_CFLAGS" >> $config_host_mak + echo "FUZZ_LDFLAGS=3D$FUZZ_LDFLAGS" >> $config_host_mak +fi =20 # use included Linux headers if test "$linux" =3D "yes" ; then --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447468680761.4960596854244; Wed, 30 Oct 2019 07:57:48 -0700 (PDT) Received: from localhost ([::1]:41218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpPv-0007ee-H2 for importer@patchew.org; Wed, 30 Oct 2019 10:57:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35383) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIS-00055L-Pr for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIQ-0007L5-Ve for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:04 -0400 Received: from mail-eopbgr690115.outbound.protection.outlook.com ([40.107.69.115]:23033 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIQ-0007Ax-NH for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:02 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:50:01 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:50:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cf05BglszHyI4mb7vhkgvxuQFuur2t/Ua07H7lDw4DKp2nd3P+clRC3CrEuiDt+0m+Gzl/k7gz+xY148ZopafBXHlaald/WxZG1c7r+cjPzirVabx5aqHgpdG7JUnEz4N+K457reJ/yqFoQmg09pX9Ct4Ms/yf03EQ8SbPduYzu6NnJ4gj3hjRX/CWGJbRiC6n5HpG583jPqrYBIDMejbkodvJjsgblt4+nlgTUuc9bhVxj+6l8M+wYpoVhO3fw9y8qX2Fwo13Bv5FTGoHDkTuw6JN6pRXjzqaH/2wSPf00NG1YrsW9e8yL3kInlpC/cDM4voIQy4FOm0Ib2TuDKuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jJ17ZiTE2b8h25fImaMDbzCOeEifhFpxfARBLfnLWlY=; b=LMt5uYrz3HAVafC+hSTeDrBVJhCgrmlv/Mf9q+qQ0WOkaDhYikcMPviwBRhPsYTlj2eX0BJtudcEEeraXMcfOOXYOBkd+ZVfOL1mwyGuQ9Z0Sx8F8b1uSn99FQghvX+KdyMLnUAoQanjB8S+Sk0AbZUMEUbJsyVRCciDyKdFgfAgcTzWiBt5qSAGqppKGBux0jf5bHRVFw7wB+19pmJBYlm9tRpHRCq2nOS4dgQOsPOYrWBnnCQxRLdSHHGOtuP1SEwMAkgenHH7SGo9qwTf4cNlv1WEIZDlsX/M/XJJiK0VpL1xvvuVPRc4JkcAHt+Quf3l64fhBdRGEvNiNUjWAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jJ17ZiTE2b8h25fImaMDbzCOeEifhFpxfARBLfnLWlY=; b=uw3j91G70nHx/q8l24FW0b8htD57ONSClZtbHu039Ap4Xzy7PurB5YREpHm3KpoTor+kW3O5aRcMRfOobo9F5lDX8GXyYNqBrUHudUdCXNmdCAbEYMg5VbxDuHUxupv7BGZwcbPFxVFYVYqNXRQUoo01qCZM+w44VOYpF50qW6A= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 14/20] fuzz: Add target/fuzz makefile rules Thread-Topic: [PATCH v4 14/20] fuzz: Add target/fuzz makefile rules Thread-Index: AQHVjzFNDXmvrhggW0qT5Z69BlHFkQ== Date: Wed, 30 Oct 2019 14:50:00 +0000 Message-ID: <20191030144926.11873-15-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ae0e0d7e-b3b2-471c-7196-08d75d48703a x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1728; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(25786009)(6436002)(75432002)(8936002)(6512007); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: vuJW+RKhf2s4DeuSzcAvK/qBEf91uQSEatAPFYWsC98e9N2k4kWpyVvYMrnXbxYaxeMzAsr4fGYljCUWzhUgr+W2ZQIC1pfPV2AXoc7FE7qnZr+5SMvoBByRYhxHCIr/ST3xLunbF5TBRXoKNuzxVfyNBztLv/Z9YM67eNiWLRfXeyZFSGPh8aU9iDw38ouQiqnkmHxzT79U+Cx996UD+kga4er+43/tOspNHxtJwVlnTAJNkokiEbVYGDFcF7wRaIgSAyF5os1cKPrMrDlTBVYI17mDQU4+AXkE+QMjpLKZcheSF3vuG9K1YUZ/FPb56zNRdjP3KiV0GmHfYiQmXe0jaMSA26KkxaD2HxFgn1Kj8Woxd0/2QGtZpWXKy2SXdBdZiBe3EoEnpU/57Qm6SntT8LJZXjSEAxRpIfARq58aUeC6m4i4wefRcteK9Yqo Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: ae0e0d7e-b3b2-471c-7196-08d75d48703a X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:50:00.0190 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: f1pHInRuntGzmrzOdlBMCl8H/QotWaF86CnXUTSBmJl1wTaEIjnPOHZBokXp5Mn/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.115 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik Signed-off-by: Alexander Oleinik Reviewed-by: Darren Kenny --- Makefile | 15 ++++++++++++++- Makefile.objs | 4 +++- Makefile.target | 18 +++++++++++++++++- tests/fuzz/Makefile.include | 4 ++++ 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 tests/fuzz/Makefile.include diff --git a/Makefile b/Makefile index d2b2ecd3c4..571f5562c9 100644 --- a/Makefile +++ b/Makefile @@ -464,7 +464,7 @@ config-host.h-timestamp: config-host.mak qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@= ") =20 -TARGET_DIRS_RULES :=3D $(foreach t, all clean install, $(addsuffix /$(t), = $(TARGET_DIRS))) +TARGET_DIRS_RULES :=3D $(foreach t, all fuzz clean install, $(addsuffix /$= (t), $(TARGET_DIRS))) =20 SOFTMMU_ALL_RULES=3D$(filter %-softmmu/all, $(TARGET_DIRS_RULES)) $(SOFTMMU_ALL_RULES): $(authz-obj-y) @@ -476,6 +476,15 @@ $(SOFTMMU_ALL_RULES): config-all-devices.mak $(SOFTMMU_ALL_RULES): $(edk2-decompressed) $(SOFTMMU_ALL_RULES): $(softmmu-main-y) =20 +SOFTMMU_FUZZ_RULES=3D$(filter %-softmmu/fuzz, $(TARGET_DIRS_RULES)) +$(SOFTMMU_FUZZ_RULES): $(authz-obj-y) +$(SOFTMMU_FUZZ_RULES): $(block-obj-y) +$(SOFTMMU_FUZZ_RULES): $(chardev-obj-y) +$(SOFTMMU_FUZZ_RULES): $(crypto-obj-y) +$(SOFTMMU_FUZZ_RULES): $(io-obj-y) +$(SOFTMMU_FUZZ_RULES): config-all-devices.mak +$(SOFTMMU_FUZZ_RULES): $(edk2-decompressed) + .PHONY: $(TARGET_DIRS_RULES) # The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that # $(dir $@) yields the sub-directory, and $(notdir $@) yields the sub-goal @@ -526,6 +535,9 @@ subdir-slirp: slirp/all $(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \ $(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY)) =20 +$(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \ + $(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY)) + ROM_DIRS =3D $(addprefix pc-bios/, $(ROMS)) ROM_DIRS_RULES=3D$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS))) # Only keep -O and -g cflags @@ -535,6 +547,7 @@ $(ROM_DIRS_RULES): =20 .PHONY: recurse-all recurse-clean recurse-install recurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS)) +recurse-fuzz: $(addsuffix /fuzz, $(TARGET_DIRS) $(ROM_DIRS)) recurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS)) recurse-install: $(addsuffix /install, $(TARGET_DIRS)) $(addsuffix /install, $(TARGET_DIRS)): all diff --git a/Makefile.objs b/Makefile.objs index 9ff9b0c6f9..5478a554f6 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -86,10 +86,12 @@ common-obj-$(CONFIG_FDT) +=3D device_tree.o # qapi =20 common-obj-y +=3D qapi/ +softmmu-obj-y =3D main.o =20 -softmmu-main-y =3D main.o endif =20 + + ####################################################################### # Target-independent parts used in system and user emulation common-obj-y +=3D cpus-common.o diff --git a/Makefile.target b/Makefile.target index ca3d14efe1..cddc8e4306 100644 --- a/Makefile.target +++ b/Makefile.target @@ -202,7 +202,7 @@ endif COMMON_LDADDS =3D ../libqemuutil.a =20 # build either PROG or PROGW -$(QEMU_PROG_BUILD): $(all-obj-y) $(COMMON_LDADDS) +$(QEMU_PROG_BUILD): $(all-obj-y) $(COMMON_LDADDS) $(softmmu-obj-y) $(call LINK, $(filter-out %.mak, $^)) ifdef CONFIG_DARWIN $(call quiet-command,Rez -append $(SRC_PATH)/pc-bios/qemu.rsrc -o $@,"REZ= ","$(TARGET_DIR)$@") @@ -227,6 +227,22 @@ ifdef CONFIG_TRACE_SYSTEMTAP rm -f *.stp endif =20 +ifdef CONFIG_FUZZ +include $(SRC_PATH)/tests/fuzz/Makefile.include +include $(SRC_PATH)/tests/Makefile.include + +fuzz: fuzz-vars +fuzz-vars: QEMU_CFLAGS :=3D $(FUZZ_CFLAGS) $(QEMU_CFLAGS) +fuzz-vars: QEMU_LDFLAGS :=3D $(FUZZ_LDFLAGS) $(QEMU_LDFLAGS) +fuzz-vars: $(QEMU_PROG_FUZZ) +dummy :=3D $(call unnest-vars,, fuzz-obj-y) + + +$(QEMU_PROG_FUZZ): config-devices.mak $(all-obj-y) $(COMMON_LDADDS) $(fuzz= -obj-y) + $(call LINK, $(filter-out %.mak, $^)) + +endif + install: all ifneq ($(PROGS),) $(call install-prog,$(PROGS),$(DESTDIR)$(bindir)) diff --git a/tests/fuzz/Makefile.include b/tests/fuzz/Makefile.include new file mode 100644 index 0000000000..324e6c1433 --- /dev/null +++ b/tests/fuzz/Makefile.include @@ -0,0 +1,4 @@ +# QEMU_PROG_FUZZ=3Dqemu-fuzz-$(TARGET_NAME)$(EXESUF) +fuzz-obj-y =3D $(libqos-obj-y) +fuzz-obj-y +=3D tests/libqtest.o + --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447466797482.7368695440356; Wed, 30 Oct 2019 07:57:46 -0700 (PDT) Received: from localhost ([::1]:41214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpPr-0007Uv-Dv for importer@patchew.org; Wed, 30 Oct 2019 10:57:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35412) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIW-000571-1N for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIT-0007N2-0I for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:07 -0400 Received: from mail-eopbgr690101.outbound.protection.outlook.com ([40.107.69.101]:31361 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIS-0007LI-5z for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:04 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:50:01 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:50:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iP9W5aOeo8XtIGZWwY24d9FLajcvmKkqtIwzaBQlXMEN+EQLvfdZEELImM99ZGbRqBb1ox3TGaZtn6h8CaaSdythHZZNJsGhJjLerbhl7Hq1+kUUHDpFXhptRFW5j+7wFyyy4Q6lP1D0R4fLJU+fHkHKMCbqsvNmCjUH3f2CNNXtmD84oQ23MZtIW2UMFJUVB8RI/l0OjLmRRF0Ol8bYyk2pZ55FWgpBOFQPzC1Sa58mS77cpvpZkrkPmDxRg96aKgD7WYUPWODb9GIb3ITn2J0zR4XdSUIWdhZvNY9ObvHp/gtXv18t/bM/d6zcaPgYcsqBUGuZeIe5JdukqHpR5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DCYM1YkE/sLSoqw8gf/IFf74ztBP1BgoWkVkRs8e7KA=; b=DJxkmKrOWm+rjC1hLaDHH8+f6Mkyd8BveO9nqVcct5wp2YBi33IZSiJ8VC7niAkvsxzOXEqQ/OXktO5Wc6vNhXbr98rBEfHZEGlHnxh6nTkUieKHU/qmXFPUh8q4tpg0JUCiD0Jhs//h/D/NjEXmxmdItU1Q/mSdvPXAbw63+tnldQjub3Ptww/L9Em0coizbjWBsXO6bnsSiq8fCQPv+RK99scwu6k3RW1TPvlGVw6GJ3MU2LAaAeg6r/G9oz4INrLHNhZgXvfaisQGK9YrvkEsy8fNxnDG7GHK4X7CyzBmQw046XvU0suxVs4ypoOa9q3oms0atdrK9sMeUCA+3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DCYM1YkE/sLSoqw8gf/IFf74ztBP1BgoWkVkRs8e7KA=; b=pM3hs4KmlPp5b0yEyIXKC8ebqkjOQOoSc8pd9O9qm+8Bw5qRIvyGuwwVG6jVyJBCF6Gnefy51n2OvewUgCOeRUToF8zWMDGpejxwnCEYjbxvLy1qB3phnpIPhP8CZdkAeFOs9xkCc1rrA13ejp/uzs294bfMw5gYciWhu/y7VyM= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 15/20] fuzz: add fuzzer skeleton Thread-Topic: [PATCH v4 15/20] fuzz: add fuzzer skeleton Thread-Index: AQHVjzFOZqFs6T13M0yTJWMjIF12kA== Date: Wed, 30 Oct 2019 14:50:00 +0000 Message-ID: <20191030144926.11873-16-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6661ea61-efe7-4e63-ebde-08d75d4870a9 x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2089; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(14444005)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(25786009)(6436002)(75432002)(8936002)(6512007); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qFffnGe3QE1n1LvlYO/Fiyuc4BTMbdu4gVn1UHqWMzCN1wfRtrqtPlzC++tJdiLnY5FSEoz4eKjFCTHSP7Uc9uETamRSDseb36cqO3fOKxgNghH58nLb348uabTMcnZcuWnroCs+1zOsejcxBuxSkhtJNm2evPWQ9qFJs0tGj7Q0n1HzyeM9UuAM7EttlQ/f/5Mkzueu/jSbGawgrMlTDJuDd4Fylva0Gh+HIJA3jAbD+hrG1h2L+hfPJ9GnHcs1sedtRpO5lYplhdTcwxj8xQ+d0lbKO9lpEi/Md5/lpbdOSeciMqwKKj++fYAd3lRZ1cmCrz9q8FzxvXbAUxMCHwt7+TG4/GoyM2IoOaHBBP1dqtIfdpq8+Qb10B4kikr+kYNRmt4xChEKJXrTVdP5N2eKvOEEXrJRSe0Gof6GTBVJdKNse0Wxsrfvd/JefNZs Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 6661ea61-efe7-4e63-ebde-08d75d4870a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:50:00.7475 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: XXueM/A0QIrFZcX3XnwHrprZ+zcyTv7ZB51hssQU2QjLYkd46raKI/SeXy1kNZHf X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.101 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik tests/fuzz/fuzz.c serves as the entry point for the virtual-device fuzzer. Namely, libfuzzer invokes the LLVMFuzzerInitialize and LLVMFuzzerTestOneInput functions, both of which are defined in this file. This change adds a "FuzzTarget" struct, along with the fuzz_add_target function, which should be used to define new fuzz targets. Signed-off-by: Alexander Oleinik --- tests/fuzz/Makefile.include | 4 +- tests/fuzz/fuzz.c | 177 ++++++++++++++++++++++++++++++++++++ tests/fuzz/fuzz.h | 66 ++++++++++++++ 3 files changed, 245 insertions(+), 2 deletions(-) create mode 100644 tests/fuzz/fuzz.c create mode 100644 tests/fuzz/fuzz.h diff --git a/tests/fuzz/Makefile.include b/tests/fuzz/Makefile.include index 324e6c1433..b415b056b0 100644 --- a/tests/fuzz/Makefile.include +++ b/tests/fuzz/Makefile.include @@ -1,4 +1,4 @@ -# QEMU_PROG_FUZZ=3Dqemu-fuzz-$(TARGET_NAME)$(EXESUF) +QEMU_PROG_FUZZ=3Dqemu-fuzz-$(TARGET_NAME)$(EXESUF) fuzz-obj-y =3D $(libqos-obj-y) fuzz-obj-y +=3D tests/libqtest.o - +fuzz-obj-y +=3D tests/fuzz/fuzz.o diff --git a/tests/fuzz/fuzz.c b/tests/fuzz/fuzz.c new file mode 100644 index 0000000000..0e38f81c48 --- /dev/null +++ b/tests/fuzz/fuzz.c @@ -0,0 +1,177 @@ +/* + * fuzzing driver + * + * Copyright Red Hat Inc., 2019 + * + * Authors: + * Alexander Bulekov + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" + +#include +#include +#include + + +#include "tests/libqtest.h" +#include "sysemu/qtest.h" +#include "fuzz.h" +#include "tests/libqos/qgraph.h" +#include "sysemu/runstate.h" +#include "sysemu/sysemu.h" +#include "qemu/main-loop.h" + +typedef struct FuzzTargetState { + FuzzTarget *target; + QSLIST_ENTRY(FuzzTargetState) target_list; +} FuzzTargetState; + +typedef QSLIST_HEAD(, FuzzTargetState) FuzzTargetList; + +static const char *fuzz_arch =3D TARGET_NAME; + +static FuzzTargetList *fuzz_target_list; +static FuzzTarget *fuzz_target; +static QTestState *fuzz_qts; + + + +void flush_events(QTestState *s) +{ + int i =3D 10; + while (g_main_context_pending(NULL) && i-- > 0) { + main_loop_wait(false); + } +} + +static QTestState *qtest_setup(void) +{ + qtest_server_set_tx_handler(&qtest_client_inproc_recv, NULL); + return qtest_inproc_init(false, fuzz_arch, &qtest_server_inproc_recv); +} + +void fuzz_add_target(FuzzTarget *target) +{ + FuzzTargetState *tmp; + FuzzTargetState *target_state; + if (!fuzz_target_list) { + fuzz_target_list =3D g_new0(FuzzTargetList, 1); + } + + QSLIST_FOREACH(tmp, fuzz_target_list, target_list) { + if (g_strcmp0(tmp->target->name, target->name) =3D=3D 0) { + fprintf(stderr, "Error: Fuzz target name %s already in use\n", + target->name); + abort(); + } + } + target_state =3D g_new0(FuzzTargetState, 1); + target_state->target =3D g_new0(FuzzTarget, 1); + *(target_state->target) =3D *target; + QSLIST_INSERT_HEAD(fuzz_target_list, target_state, target_list); +} + + + +static void usage(char *path) +{ + printf("Usage: %s --fuzz-target=3DFUZZ_TARGET [LIBFUZZER ARGUMENTS]\n"= , path); + printf("where FUZZ_TARGET is one of:\n"); + FuzzTargetState *tmp; + if (!fuzz_target_list) { + fprintf(stderr, "Fuzz target list not initialized\n"); + abort(); + } + QSLIST_FOREACH(tmp, fuzz_target_list, target_list) { + printf(" %s : %s\n", tmp->target->name, + tmp->target->description); + } + exit(0); +} + +static FuzzTarget *fuzz_get_target(char* name) +{ + FuzzTargetState *tmp; + if (!fuzz_target_list) { + fprintf(stderr, "Fuzz target list not initialized\n"); + abort(); + } + + QSLIST_FOREACH(tmp, fuzz_target_list, target_list) { + if (strcmp(tmp->target->name, name) =3D=3D 0) { + return tmp->target; + } + } + return NULL; +} + + +/* Executed for each fuzzing-input */ +int LLVMFuzzerTestOneInput(const unsigned char *Data, size_t Size) +{ + if (fuzz_target->fuzz) { + fuzz_target->fuzz(fuzz_qts, Data, Size); + } + return 0; +} + +/* Executed once, prior to fuzzing */ +int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp) +{ + + char *target_name; + + /* Initialize qgraph and modules */ + qos_graph_init(); + module_call_init(MODULE_INIT_FUZZ_TARGET); + module_call_init(MODULE_INIT_QOM); + module_call_init(MODULE_INIT_LIBQOS); + + if (*argc <=3D 1) { + usage(**argv); + } + + /* Identify the fuzz target */ + target_name =3D (*argv)[1]; + if (!strstr(target_name, "--fuzz-target=3D")) { + usage(**argv); + } + + target_name +=3D strlen("--fuzz-target=3D"); + + fuzz_target =3D fuzz_get_target(target_name); + if (!fuzz_target) { + usage(**argv); + } + + fuzz_qts =3D qtest_setup(); + + if (!fuzz_target) { + fprintf(stderr, "Error: Fuzz fuzz_target name %s not found\n", + target_name); + usage(**argv); + } + + if (fuzz_target->pre_vm_init) { + fuzz_target->pre_vm_init(); + } + + /* Run QEMU's softmmu main with the fuzz-target dependent arguments */ + char *init_cmdline =3D fuzz_target->get_init_cmdline(fuzz_target); + + wordexp_t result; + wordexp(init_cmdline, &result, 0); + + qemu_init(result.we_wordc, result.we_wordv, NULL); + + if (fuzz_target->pre_fuzz) { + fuzz_target->pre_fuzz(fuzz_qts); + } + + return 0; +} diff --git a/tests/fuzz/fuzz.h b/tests/fuzz/fuzz.h new file mode 100644 index 0000000000..b569b622d7 --- /dev/null +++ b/tests/fuzz/fuzz.h @@ -0,0 +1,66 @@ +/* + * fuzzing driver + * + * Copyright Red Hat Inc., 2019 + * + * Authors: + * Alexander Bulekov + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef FUZZER_H_ +#define FUZZER_H_ + +#include "qemu/osdep.h" +#include "qemu/units.h" +#include "qapi/error.h" +#include "exec/memory.h" +#include "tests/libqtest.h" + + +typedef struct FuzzTarget { + const char *name; /* command-line option(FUZZ_TARGET) for the = target */ + const char *description; /* help text */ + + + /* returns the arg-list that is passed to qemu/softmmu init() */ + char* (*get_init_cmdline)(struct FuzzTarget *); + + /* + * will run once, prior to running qemu/softmmu init. + * eg: set up shared-memory for communication with the child-process + */ + void(*pre_vm_init)(void); + + /* + * will run once, prior to to the fuzz-loop. + * eg: detect the memory map + */ + void(*pre_fuzz)(QTestState *); + + /* + * accepts and executes an input from libfuzzer. this is repeatedly + * executed during the fuzzing loop. Its should handle setup, input + * execution and cleanup + */ + void(*fuzz)(QTestState *, const unsigned char *, size_t); + +} FuzzTarget; + +void flush_events(QTestState *); +void reboot(QTestState *); + +/* + * makes a copy of *target and adds it to the target-list. + * i.e. fine to set up target on the caller's stack + */ +void fuzz_add_target(FuzzTarget *target); + +int LLVMFuzzerTestOneInput(const unsigned char *Data, size_t Size); +int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp); + +#endif + --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572448154711980.8567852150404; Wed, 30 Oct 2019 08:09:14 -0700 (PDT) Received: from localhost ([::1]:41398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpaw-0002pV-MO for importer@patchew.org; Wed, 30 Oct 2019 11:09:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35411) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIW-000570-12 for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIT-0007OV-Vi for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:07 -0400 Received: from mail-eopbgr690101.outbound.protection.outlook.com ([40.107.69.101]:31361 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIT-0007LI-CY for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:05 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:50:01 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:50:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hr6qXNrdZ93U1onJChglBO7j0lyb4m6T3/rjebyMlwLmmhtzBgoTwOpOfpvvaomsyYgf8y+4buczOW9+DF7rpk9Kw84hn+qRKLnHqZWbr2swcv2TrondKKTexTjGl47KNLyJPOAbmqyGb648nwE4T8CsoUhnpSl0c6vVHOknEqV9wYrZulRbd0t1mcqz06sngi83iKKCmDHm4d3xh4/Z5aItYEayoFT72CJ92QdzUTZ8aIg27KYOJJy+YLYofiQF+5bsrt8wLsNA3nhriof9QPm2Uol1x6gHD2AUcjPw+byDYpUvCxeng2ItY+G6Fjw5jNBsxD71jPFp7eVfSiG9yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qsBYMFD3vAUiN8ycxdIET3yF+IDjHC9rD1PQp2Z6cxA=; b=SeFUhjmTafd98MEJ91qGGX0owtUG39Ckkzz3VbFQ9Rsz9cLx86HhQUvKTW7mO/BQiacJtVlevnvMgwKRTC34rSy8IGO8aS4jX8tGFJBalLrloS2a9OV5aiF8oX3Dx1S75EawYCuBkuKQP7hC6JZ5T01nDEFepE1E6EYmT4zHO7+Hj0WmmkGAscRs7wXS6ALdiHpL7wJRvjom3LolXr2vpE7tkXfSapj+odspUitY9MdatUJbaST6xdx8B4uAib96gQKA8rzULdJbFzPDxhQ3qXX/2bcNnfJNvLONmQHCUuq0dEylHD0a86ImvjFPz9LLyOeyvovolbl2BxnDVRTVUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qsBYMFD3vAUiN8ycxdIET3yF+IDjHC9rD1PQp2Z6cxA=; b=YwL5qJIdN/wiCSXc/MF4xN3gzJjWEe8YGqHxgfeQ5EDBAAAXAjs2IOXbFUT2ZlMIfIoYupaboIGSRv7+rJ08gqq6XPa+uJz8gt0IdH+srXB8FFm+LrVZT/2vggaprrnYSrWzXfYPlh/Kt8IbTzeLm+t90urJE6zK8WkmVRGymBQ= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 16/20] fuzz: add support for fork-based fuzzing. Thread-Topic: [PATCH v4 16/20] fuzz: add support for fork-based fuzzing. Thread-Index: AQHVjzFOh7bxt3iDm0CreiaspQc+BQ== Date: Wed, 30 Oct 2019 14:50:01 +0000 Message-ID: <20191030144926.11873-17-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6f8e5541-362e-4aee-64d4-08d75d48712b x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(979002)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(25786009)(6436002)(54906003)(75432002)(8936002)(6512007)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ZRh9AocM2/YDzfcc3f0cl5sN/OiPmBgzgJqIqBoaEL83B+k8hQ1VCxUmfyEkLJ4KflNAgAiX19wDs30vI/fB9gCQE+FmN+oSQJn+rOlKKDslhWva0Zi9hlPagRK8DANSn1zuvv3QvTcrFpSqRPF9wXZgqag+lhflqbWNdXjsQEnnXoIsTHmo5DnXrr/9qWywZR0YBsbiaLIMBsnALqiFucjRahfI/yX7ZTtxAIWRVD7fmP3fA9hIspqbSWgEOgL4dXgA4yi4fEtvnylVlu2IHeZeeLR0g3a5KvIs1bUlSs50CMK4gM39JqhWDnJkicCFEdPhivRfoLfYnHfQXld6/4+gjmsmKDa7rzU4zAa05qipbuKGhpH+2Lgdf6SMxL9X280HRYU84nYpRphCm82iEEUxayW5ol2VTpmWgRGbfrZa+GR7OsXzUsm/fs2c9Tdq Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 6f8e5541-362e-4aee-64d4-08d75d48712b X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:50:01.5861 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 0+ZAC7J3Z3fNlHiwfwteyHYz4YNAlbAnGshecdF5A4oT73WhO1UZhBs4AtwrGWNH X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.101 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: "Oleinik, Alexander" , Richard Henderson , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik fork() is a simple way to ensure that state does not leak in between fuzzing runs. Unfortunately, the fuzzer mutation engine relies on bitmaps which contain coverage information for each fuzzing run, and these bitmaps should be copied from the child to the parent(where the mutation occurs). These bitmaps are created through compile-time instrumentation and they are not shared with fork()-ed processes, by default. To address this, we create a shared memory region, adjust its size and map it _over_ the counter region. Furthermore, libfuzzer doesn't generally expose the globals that specify the location of the counters/coverage bitmap. As a workaround, we rely on a custom linker script which forces all of the bitmaps we care about to be placed in a contiguous region, which is easy to locate and mmap over. Signed-off-by: Alexander Oleinik --- exec.c | 12 +++++++-- tests/fuzz/Makefile.include | 3 +++ tests/fuzz/fork_fuzz.c | 51 +++++++++++++++++++++++++++++++++++++ tests/fuzz/fork_fuzz.h | 23 +++++++++++++++++ tests/fuzz/fork_fuzz.ld | 37 +++++++++++++++++++++++++++ 5 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 tests/fuzz/fork_fuzz.c create mode 100644 tests/fuzz/fork_fuzz.h create mode 100644 tests/fuzz/fork_fuzz.ld diff --git a/exec.c b/exec.c index 91c8b79656..b15207b00c 100644 --- a/exec.c +++ b/exec.c @@ -35,6 +35,7 @@ #include "sysemu/kvm.h" #include "sysemu/sysemu.h" #include "sysemu/tcg.h" +#include "sysemu/qtest.h" #include "qemu/timer.h" #include "qemu/config-file.h" #include "qemu/error-report.h" @@ -2266,8 +2267,15 @@ static void ram_block_add(RAMBlock *new_block, Error= **errp, bool shared) if (new_block->host) { qemu_ram_setup_dump(new_block->host, new_block->max_length); qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_HUG= EPAGE); - /* MADV_DONTFORK is also needed by KVM in absence of synchronous M= MU */ - qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_DON= TFORK); + /* + * MADV_DONTFORK is also needed by KVM in absence of synchronous M= MU + * Configure it unless the machine is a qtest server, in which cas= e it + * may be forked, for fuzzing purposes + */ + if (!qtest_enabled()) { + qemu_madvise(new_block->host, new_block->max_length, + QEMU_MADV_DONTFORK); + } ram_block_notify_add(new_block->host, new_block->max_length); } } diff --git a/tests/fuzz/Makefile.include b/tests/fuzz/Makefile.include index b415b056b0..687dacce04 100644 --- a/tests/fuzz/Makefile.include +++ b/tests/fuzz/Makefile.include @@ -2,3 +2,6 @@ QEMU_PROG_FUZZ=3Dqemu-fuzz-$(TARGET_NAME)$(EXESUF) fuzz-obj-y =3D $(libqos-obj-y) fuzz-obj-y +=3D tests/libqtest.o fuzz-obj-y +=3D tests/fuzz/fuzz.o +fuzz-obj-y +=3D tests/fuzz/fork_fuzz.o + +FUZZ_LDFLAGS +=3D -Xlinker -T$(SRC_PATH)/tests/fuzz/fork_fuzz.ld diff --git a/tests/fuzz/fork_fuzz.c b/tests/fuzz/fork_fuzz.c new file mode 100644 index 0000000000..4c4d00b034 --- /dev/null +++ b/tests/fuzz/fork_fuzz.c @@ -0,0 +1,51 @@ +/* + * Fork-based fuzzing helpers + * + * Copyright Red Hat Inc., 2019 + * + * Authors: + * Alexander Bulekov + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "fork_fuzz.h" + +uintptr_t feature_shm; + +void counter_shm_init(void) +{ + int fd =3D shm_open("/qemu-fuzz-cntrs", O_CREAT | O_RDWR, S_IRUSR | S_= IWUSR); + if (fd =3D=3D -1) { + perror("Error: "); + exit(1); + } + if (ftruncate(fd, &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START) =3D= =3D -1) { + perror("Error: "); + exit(1); + } + /* Copy what's in the counter region to the shm.. */ + void *rptr =3D mmap(NULL , + &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START, + PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + memcpy(rptr, + &__FUZZ_COUNTERS_START, + &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START); + + munmap(rptr, &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START); + + /* And map the shm over the counter region */ + rptr =3D mmap(&__FUZZ_COUNTERS_START, + &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START, + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0); + if (!rptr) { + perror("Error: "); + exit(1); + } + return; +} + + diff --git a/tests/fuzz/fork_fuzz.h b/tests/fuzz/fork_fuzz.h new file mode 100644 index 0000000000..9ecb8b58ef --- /dev/null +++ b/tests/fuzz/fork_fuzz.h @@ -0,0 +1,23 @@ +/* + * Fork-based fuzzing helpers + * + * Copyright Red Hat Inc., 2019 + * + * Authors: + * Alexander Bulekov + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef FORK_FUZZ_H +#define FORK_FUZZ_H + +extern uint8_t __FUZZ_COUNTERS_START; +extern uint8_t __FUZZ_COUNTERS_END; + +void counter_shm_init(void); + +#endif + diff --git a/tests/fuzz/fork_fuzz.ld b/tests/fuzz/fork_fuzz.ld new file mode 100644 index 0000000000..51ba3717c4 --- /dev/null +++ b/tests/fuzz/fork_fuzz.ld @@ -0,0 +1,37 @@ +/* We adjust linker script modification to place all of the stuff that nee= ds to + * persist across fuzzing runs into a contiguous seciton of memory. Then, = it is + * easy to re-map the counter-related memory as shared. +*/ + +SECTIONS +{ + .data.fuzz_start : ALIGN(4K) + { + __FUZZ_COUNTERS_START =3D .; + __start___sancov_cntrs =3D .; + *(_*sancov_cntrs); + __stop___sancov_cntrs =3D .; + + /* Lowest stack counter */ + *(__sancov_lowest_stack); + + /* Coverage counters. They're not necessary for fuzzing, but are use= ful + * for analyzing the fuzzing performance + */ + __start___llvm_prf_cnts =3D .; + *(*llvm_prf_cnts); + __stop___llvm_prf_cnts =3D .; + } + .data.fuzz_ordered : + { + /* Internal Libfuzzer TracePC object which contains the ValueProfile= Map */ + FuzzerTracePC*(.bss); + } + .data.fuzz_end : ALIGN(4K) + { + __FUZZ_COUNTERS_END =3D .; + } +} +/* Dont overwrite the SECTIONS in the default linker script. Instead inser= t the + * above into the default script */ +INSERT AFTER .data; --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572448273874275.34624551210186; Wed, 30 Oct 2019 08:11:13 -0700 (PDT) Received: from localhost ([::1]:41406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpcs-000439-NP for importer@patchew.org; Wed, 30 Oct 2019 11:11:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35454) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIa-0005DM-6W for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIY-0007Vr-4R for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:12 -0400 Received: from mail-eopbgr690101.outbound.protection.outlook.com ([40.107.69.101]:31361 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIW-0007LI-2U for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:10 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:50:02 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:50:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DIw66mkJNBoFRYHhqAImxwssNd30o7vOu7yOAOBJsrOWfewQSG6YDvDiFVUKeXHQO7K0eK5SyMSHZssO+0ioIEt2/PqbSTv7W1K1C/ACHkXNfvWfJFnehMwBZ1wzQSpBJc3MdArmeaBqp0efpi3GuJL2OZio74n6wNt8g42Dyp50BYpHTQlpCzB7IZI4vL1PQTwiqzg9xZjQ0Gm0hyyMUD1jkXD+bWBPCm5aQxOcA81Eh4nT6mbZNZ1MSt9+FquG4eyo1M+fOGu2BHX+TKsHCLcUBcyE1Tyy4+smvqkCvEOt0kTBmbg0BxqVfQZeIwknaZOqQZ+GavTaWDzJhSHpgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gAXQz6h6/9X+7GuJ+xQZdaSXny03a0CEDwVmzS5Zeuw=; b=TQeo4XTukJPzw/bZeqVw4HsIhWhFjyyOwo/67JgmGatgBJZEonGHmQVmjJCcyAfGAhURpiQAx83/xCp/b0yfUnHUdbPRQeMuhSHtX6UYSYIBFLKOBmyvcFFDsyFluX+yNLQWIRU/dBWoe9UokHDhvU0iHTg27EcWraovNFgT5Mv0YAxjlclf0FG+x08bgJoMfxBx1aXkJzWX4Gm8crn8vis/34tWch+/N3pkF6lufu1T5l//gpbnhfSZBF8wPaGyu7ds5z5dkbHg2WNfrxVIPMlqQOY8nfu6XRQ8PuZ/j2B004xSvF7lsZEQ8eYNzcW5bjgs3VueniOo8ZmKp+Aq4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gAXQz6h6/9X+7GuJ+xQZdaSXny03a0CEDwVmzS5Zeuw=; b=rgnH2FQXiI7XfjAgNpIJ26JoMPaZ7D1WWFo9ZO4EEK+z9va1Um3cduiXJStq/Ojq/TMyLObsYfrid51bS2g8DWeaYWhzxung4FiUnli3ss+Zn0a9QJ8swFlcgjCCbo+pKWHUuy5ic44YfDw33K3NAtnRlCO0DpBkbdNu4jay4mE= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 17/20] fuzz: add support for qos-assisted fuzz targets Thread-Topic: [PATCH v4 17/20] fuzz: add support for qos-assisted fuzz targets Thread-Index: AQHVjzFPm98fTh6hukadTxKDl351sg== Date: Wed, 30 Oct 2019 14:50:02 +0000 Message-ID: <20191030144926.11873-18-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 649fa142-78aa-4e34-c950-08d75d48719b x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:632; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(14444005)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(25786009)(6436002)(75432002)(8936002)(6512007)(6306002)(2004002); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: yZcDE+JZEjWJyCM5sGOjhmg6ywULBMOgENnEqvwD9FDI9RCm9y8lGRU6aC4CvbIucTHVm+ZMJuJ4CRzsYIlguqc50mYEnNvHD2QWrrlrNqNekcFXoF8EYE1dyIT7U66remmFzZdZeq5blSxvTJIMxdUtK4Xy2e06vguvyVjO+O1Qxm1nXFG+PZxRCewG1HwVvGoMs91sYWKPrn4S5LCPd9Vu7GNaQi0yXGKDZNvB9eLYZg9wXqlK2g1KHYKg02Lij2hdW5T45L1+XdIART2UZaR0nDHcwQJ00TktQtghixSVWncv4OEsmgLOOnTkC1WqY8RtGYWc8fE3jQ10bodJ2ED4Z0M3OK0xAUStCBkoNAwHUBR4pqreRDA2gG+NESM8p7AGAZfQofPL96Ctv0KZFnV6cTJumM1oty8jZ4qRLjLvYD+732u/FGtjMPZ02uaeHRCiI5ZYgjxDJp6qxFFnfbS0MCzyBxCaRoVhXAtUpm8= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 649fa142-78aa-4e34-c950-08d75d48719b X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:50:02.3956 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: S2rBck+0L8gCyYRwBSmCGOXb+rW02CWbwgYBYjz0hxMyUYLpYI0KWeH36sJEpyQn X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.101 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik Signed-off-by: Alexander Oleinik --- tests/fuzz/qos_fuzz.c | 232 ++++++++++++++++++++++++++++++++++++++++++ tests/fuzz/qos_fuzz.h | 33 ++++++ 2 files changed, 265 insertions(+) create mode 100644 tests/fuzz/qos_fuzz.c create mode 100644 tests/fuzz/qos_fuzz.h diff --git a/tests/fuzz/qos_fuzz.c b/tests/fuzz/qos_fuzz.c new file mode 100644 index 0000000000..07015da4ca --- /dev/null +++ b/tests/fuzz/qos_fuzz.c @@ -0,0 +1,232 @@ +/* + * QOS-assisted fuzzing helpers + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" +#include "qemu/units.h" +#include "qapi/error.h" +#include "qemu-common.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" +#include "sysemu/sysemu.h" +#include "qemu/main-loop.h" + +#include + +#include "libqos/malloc.h" +#include "libqos/qgraph.h" +#include "libqos/qgraph_internal.h" + +#include "fuzz.h" +#include "qos_fuzz.h" +#include "tests/libqos/qgraph.h" +#include "tests/libqos/qos_external.h" +#include "tests/libqtest.h" + +#include "qapi/qapi-commands-machine.h" +#include "qapi/qapi-commands-qom.h" +#include "qapi/qmp/qlist.h" + + +void *fuzz_qos_obj; +QGuestAllocator *fuzz_qos_alloc; + +static const char *fuzz_target_name; +static char **fuzz_path_vec; + +/* + * Replaced the qmp commands with direct qmp_marshal calls. + * Probably there is a better way to do this + */ +static void qos_set_machines_devices_available(void) +{ + QDict *req =3D qdict_new(); + QObject *response; + QDict *args =3D qdict_new(); + QList *lst; + Error *err =3D NULL; + + qmp_marshal_query_machines(NULL, &response, &err); + assert(!err); + lst =3D qobject_to(QList, response); + apply_to_qlist(lst, true); + + qobject_unref(response); + + + qdict_put_str(req, "execute", "qom-list-types"); + qdict_put_str(args, "implements", "device"); + qdict_put_bool(args, "abstract", true); + qdict_put_obj(req, "arguments", (QObject *) args); + + qmp_marshal_qom_list_types(args, &response, &err); + assert(!err); + lst =3D qobject_to(QList, response); + apply_to_qlist(lst, false); + qobject_unref(response); + qobject_unref(req); +} + +static char **current_path; + +void *qos_allocate_objects(QTestState *qts, QGuestAllocator **p_alloc) +{ + return allocate_objects(qts, current_path + 1, p_alloc); +} + +static char *qos_build_main_args() +{ + char **path =3D fuzz_path_vec; + QOSGraphNode *test_node; + GString *cmd_line =3D g_string_new(path[0]); + void *test_arg; + + /* Before test */ + current_path =3D path; + test_node =3D qos_graph_get_node(path[(g_strv_length(path) - 1)]); + test_arg =3D test_node->u.test.arg; + if (test_node->u.test.before) { + test_arg =3D test_node->u.test.before(cmd_line, test_arg); + } + /* Prepend the arguments that we need */ + g_string_prepend(cmd_line, + "qemu-system-i386 -display none -machine accel=3Dqtest -m 64 "= ); + return cmd_line->str; +} + +/* + * This function is largely a copy of qos-test.c:walk_path. Since walk_path + * is itself a callback, its a little annoying to add another argument/lay= er of + * indirection + */ +static void walk_path(QOSGraphNode *orig_path, int len) +{ + QOSGraphNode *path; + QOSGraphEdge *edge; + + /* etype set to QEDGE_CONSUMED_BY so that machine can add to the comma= nd line */ + QOSEdgeType etype =3D QEDGE_CONSUMED_BY; + + /* twice QOS_PATH_MAX_ELEMENT_SIZE since each edge can have its arg */ + char **path_vec =3D g_new0(char *, (QOS_PATH_MAX_ELEMENT_SIZE * 2)); + int path_vec_size =3D 0; + + char *after_cmd, *before_cmd, *after_device; + GString *after_device_str =3D g_string_new(""); + char *node_name =3D orig_path->name, *path_str; + + GString *cmd_line =3D g_string_new(""); + GString *cmd_line2 =3D g_string_new(""); + + path =3D qos_graph_get_node(node_name); /* root */ + node_name =3D qos_graph_edge_get_dest(path->path_edge); /* machine nam= e */ + + path_vec[path_vec_size++] =3D node_name; + path_vec[path_vec_size++] =3D qos_get_machine_type(node_name); + + for (;;) { + path =3D qos_graph_get_node(node_name); + if (!path->path_edge) { + break; + } + + node_name =3D qos_graph_edge_get_dest(path->path_edge); + + /* append node command line + previous edge command line */ + if (path->command_line && etype =3D=3D QEDGE_CONSUMED_BY) { + g_string_append(cmd_line, path->command_line); + g_string_append(cmd_line, after_device_str->str); + g_string_truncate(after_device_str, 0); + } + + path_vec[path_vec_size++] =3D qos_graph_edge_get_name(path->path_e= dge); + /* detect if edge has command line args */ + after_cmd =3D qos_graph_edge_get_after_cmd_line(path->path_edge); + after_device =3D qos_graph_edge_get_extra_device_opts(path->path_e= dge); + before_cmd =3D qos_graph_edge_get_before_cmd_line(path->path_edge); + edge =3D qos_graph_get_edge(path->name, node_name); + etype =3D qos_graph_edge_get_type(edge); + + if (before_cmd) { + g_string_append(cmd_line, before_cmd); + } + if (after_cmd) { + g_string_append(cmd_line2, after_cmd); + } + if (after_device) { + g_string_append(after_device_str, after_device); + } + } + + path_vec[path_vec_size++] =3D NULL; + g_string_append(cmd_line, after_device_str->str); + g_string_free(after_device_str, true); + + g_string_append(cmd_line, cmd_line2->str); + g_string_free(cmd_line2, true); + + /* + * here position 0 has /, position 1 has . + * The path must not have the , qtest_add_data_func adds it. + */ + path_str =3D g_strjoinv("/", path_vec + 1); + + /* Check that this is the test we care about: */ + char *test_name =3D strrchr(path_str, '/') + 1; + if (strcmp(test_name, fuzz_target_name) =3D=3D 0) { + /* + * put arch/machine in position 1 so run_one_test can do its work + * and add the command line at position 0. + */ + path_vec[1] =3D path_vec[0]; + path_vec[0] =3D g_string_free(cmd_line, false); + + fuzz_path_vec =3D path_vec; + } else { + g_free(path_vec); + } + + g_free(path_str); +} + +static char *qos_get_cmdline(FuzzTarget *t) +{ + /* + * Set a global variable that we use to identify the qos_path for our + * fuzz_target + */ + fuzz_target_name =3D t->name; + qos_set_machines_devices_available(); + qos_graph_foreach_test_path(walk_path); + return qos_build_main_args(); +} + +void fuzz_add_qos_target( + FuzzTarget *fuzz_opts, + const char *interface, + QOSGraphTestOptions *opts + ) +{ + qos_add_test(fuzz_opts->name, interface, NULL, opts); + fuzz_opts->get_init_cmdline =3D qos_get_cmdline; + fuzz_add_target(fuzz_opts); +} + +void qos_init_path(QTestState *s) +{ + fuzz_qos_obj =3D qos_allocate_objects(s , &fuzz_qos_alloc); +} diff --git a/tests/fuzz/qos_fuzz.h b/tests/fuzz/qos_fuzz.h new file mode 100644 index 0000000000..6c280f07c5 --- /dev/null +++ b/tests/fuzz/qos_fuzz.h @@ -0,0 +1,33 @@ +/* + * QOS-assisted fuzzing helpers + * + * Copyright Red Hat Inc., 2019 + * + * Authors: + * Alexander Bulekov + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef _QOS_FUZZ_H_ +#define _QOS_FUZZ_H_ + +#include "tests/fuzz/fuzz.h" +#include "tests/libqos/qgraph.h" + +int qos_fuzz(const unsigned char *Data, size_t Size); +void qos_setup(void); + +extern void *fuzz_qos_obj; +extern QGuestAllocator *fuzz_qos_alloc; + +void fuzz_add_qos_target( + FuzzTarget *fuzz_opts, + const char *interface, + QOSGraphTestOptions *opts + ); + +void qos_init_path(QTestState *); + +#endif --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447397301663.976907200156; Wed, 30 Oct 2019 07:56:37 -0700 (PDT) Received: from localhost ([::1]:41212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpOi-0005ny-E5 for importer@patchew.org; Wed, 30 Oct 2019 10:56:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35456) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIa-0005DW-Ah for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIY-0007Yx-OH for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:12 -0400 Received: from mail-eopbgr690101.outbound.protection.outlook.com ([40.107.69.101]:31361 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIY-0007LI-FX for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:10 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:50:03 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:50:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P44/py842djBbbLPuJiwNxVkIfN+EarDn9Mm0gtAk4Cw6G68kdh9IepAtnGO+5PveDK6oUnFhcb2IBl4pxW9h+Kptn1UWbtwk0r78Vfj7xukQEr7cpgMyN+2VkAIBUxKbtE6ehXY9H7hVjllX1UFuekmiF/ZCphxl3L0Pph+uVzrvUOWgGLicI922pneBOp4S1gcjrLmJBUcWkCR5RhNA6R/xDOmawJgE3YCN2I7Ci1LY6IXSS3cSra2l/fU5bpQ6JrepzdJLgAYDy7p9LSNSDDz/JZE2zXVVnyEbiYgXM95/JNeZcNQUfMJEGgymNLeMVqi2GEjUsSlGP5Kej+cPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6yd4RODbJ1CStSUav0f9/4+GsLSsR7kjibJSDJuOuW4=; b=BXwIFnZrX5T8A775Xa+PFJu48+GS460EDAtEbe+lSgngu2zWHaLfUTyw210jAUFUzj2AFD9g/rx7eN1F6A5diQxjencVCQj9lY9n5148iVb+r3zKkVkjD4AklD91IHOnYM1qbq3q5JzuxHh6LZMas8V+VBAzCfqzjhbM8CGf/+4SIlF6OBfIrB3z/t3wDRU14bqewoHe14pI4imVEXuE/HxeF3lJq6MK8Z1HUNwznZ1knZJQb5L+CeAI9ptsUeB9DK4rE4ZZwx3sN/yuJFfBbNVKXDJWIJJUiOhnMHUiu7ygmaSkQkSI0ejavOBpbNvqGhorA/8GSjqEpGvmOsYm6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6yd4RODbJ1CStSUav0f9/4+GsLSsR7kjibJSDJuOuW4=; b=pxvAqlJyIoDxUCFh34yxWW64S82+8101xpf8OzmodOAP/GBlel4jw9r0UT7+BvA4ZGvtKNDYjLuifo8gScG4jIRhzh3FVrnYAnI2x27mASq+Es6P+dgRtA3DQRUtsuKVJhtc3xxUr+vmjnsCBH070s/p8Q4lbFPj90JJq2jt8yY= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 18/20] fuzz: add i440fx fuzz targets Thread-Topic: [PATCH v4 18/20] fuzz: add i440fx fuzz targets Thread-Index: AQHVjzFPTzlG7xKuq0qOEmhu25uEHg== Date: Wed, 30 Oct 2019 14:50:03 +0000 Message-ID: <20191030144926.11873-19-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3380d3c1-8017-49c3-9954-08d75d487219 x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3276; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(25786009)(6436002)(75432002)(8936002)(6512007); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: b0WuG9XZ7jUQjXixmsuNUD8Z0UQ20ivpQGSoA9/a3jLYUXPZKit751OefouUaI8NNTfxqnocJBwfSO2Jk4eT1hEvvQcapoPRggduDjt+UVCmKnvMzVQ2+Nh9UAX7hk3aNvHdzjmAlS5S4njQOjuLvwbM/72WUklDCGGhucmn3pbhfA8O9rE3TfVEmQyuB+OOFjfQ0UFh0fv9HWk/AA4sr2/5yrWh9Jz3uNHwCchcf7/5Z1z8gShZhsPzEJT6FzhMSCIQEusBQ6kToQechCkGmwleh7BTuZeVcs47GVt+ABSD7UYevjx86DTYDFgPM8APqGr5IG4g46Fkn/LIbjPE3Hdnq3EkJzP5qZ8Mym2TxSwSfbjMcDDB49eEVAWnNLvme7mVs0LNOyGcV6BFGF2+mVPq8RyiFCYbe0FiAoA800d5nz9wpGcKb9oT/r/MfTYL Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 3380d3c1-8017-49c3-9954-08d75d487219 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:50:03.1622 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: PJrBrBmfGnsfvDTiyKC7IBC3AhiaxtOMovXHqmVC0NXPgZxgi60eSeOIcgQhr4J9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.101 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik These three targets should simply fuzz reads/writes to a couple ioports, but they mostly serve as examples of different ways to write targets. They demonstrate using qtest and qos for fuzzing, as well as using rebooting and forking to reset state, or not resetting it at all. Signed-off-by: Alexander Oleinik Reviewed-by: Stefan Hajnoczi --- tests/fuzz/Makefile.include | 3 + tests/fuzz/i440fx_fuzz.c | 176 ++++++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 tests/fuzz/i440fx_fuzz.c diff --git a/tests/fuzz/Makefile.include b/tests/fuzz/Makefile.include index 687dacce04..37d6821bee 100644 --- a/tests/fuzz/Makefile.include +++ b/tests/fuzz/Makefile.include @@ -3,5 +3,8 @@ fuzz-obj-y =3D $(libqos-obj-y) fuzz-obj-y +=3D tests/libqtest.o fuzz-obj-y +=3D tests/fuzz/fuzz.o fuzz-obj-y +=3D tests/fuzz/fork_fuzz.o +fuzz-obj-y +=3D tests/fuzz/qos_fuzz.o + +fuzz-obj-y +=3D tests/fuzz/i440fx_fuzz.o =20 FUZZ_LDFLAGS +=3D -Xlinker -T$(SRC_PATH)/tests/fuzz/fork_fuzz.ld diff --git a/tests/fuzz/i440fx_fuzz.c b/tests/fuzz/i440fx_fuzz.c new file mode 100644 index 0000000000..7304465b42 --- /dev/null +++ b/tests/fuzz/i440fx_fuzz.c @@ -0,0 +1,176 @@ +/* + * I440FX Fuzzing Target + * + * Copyright Red Hat Inc., 2019 + * + * Authors: + * Alexander Bulekov + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include "fuzz.h" +#include "tests/libqtest.h" +#include "fuzz/qos_fuzz.h" +#include "fuzz/fork_fuzz.h" +#include "qemu/main-loop.h" +#include "tests/libqos/pci.h" +#include "tests/libqos/pci-pc.h" + + +#define I440FX_PCI_HOST_BRIDGE_CFG 0xcf8 +#define I440FX_PCI_HOST_BRIDGE_DATA 0xcfc + +enum action_id { + WRITEB, + WRITEW, + WRITEL, + READB, + READW, + READL, + ACTION_MAX +}; + +static void i440fx_fuzz_qtest(QTestState *s, + const unsigned char *Data, size_t Size) { + typedef struct QTestFuzzAction { + uint32_t value; + uint8_t id; + uint8_t addr; + } QTestFuzzAction; + QTestFuzzAction a; + + while (Size >=3D sizeof(a)) { + memcpy(&a, Data, sizeof(a)); + uint16_t addr =3D a.addr % 2 ? I440FX_PCI_HOST_BRIDGE_CFG : + I440FX_PCI_HOST_BRIDGE_DATA; + switch (a.id % ACTION_MAX) { + case WRITEB: + qtest_outb(s, addr, (uint8_t)a.value); + break; + case WRITEW: + qtest_outw(s, addr, (uint16_t)a.value); + break; + case WRITEL: + qtest_outl(s, addr, (uint32_t)a.value); + break; + case READB: + qtest_inb(s, addr); + break; + case READW: + qtest_inw(s, addr); + break; + case READL: + qtest_inl(s, addr); + break; + } + Size -=3D sizeof(a); + Data +=3D sizeof(a); + } + flush_events(s); +} + +static void i440fx_fuzz_qos(QTestState *s, + const unsigned char *Data, size_t Size) { + + typedef struct QOSFuzzAction { + uint32_t value; + int devfn; + uint8_t offset; + uint8_t id; + } QOSFuzzAction; + + static QPCIBus *bus; + if (!bus) { + bus =3D qpci_new_pc(s, fuzz_qos_alloc); + } + + QOSFuzzAction a; + while (Size >=3D sizeof(a)) { + memcpy(&a, Data, sizeof(a)); + switch (a.id % ACTION_MAX) { + case WRITEB: + bus->config_writeb(bus, a.devfn, a.offset, (uint8_t)a.value); + break; + case WRITEW: + bus->config_writew(bus, a.devfn, a.offset, (uint16_t)a.value); + break; + case WRITEL: + bus->config_writel(bus, a.devfn, a.offset, (uint32_t)a.value); + break; + case READB: + bus->config_readb(bus, a.devfn, a.offset); + break; + case READW: + bus->config_readw(bus, a.devfn, a.offset); + break; + case READL: + bus->config_readl(bus, a.devfn, a.offset); + break; + } + Size -=3D sizeof(a); + Data +=3D sizeof(a); + } + flush_events(s); +} + +static void i440fx_fuzz_qos_fork(QTestState *s, + const unsigned char *Data, size_t Size) { + if (fork() =3D=3D 0) { + i440fx_fuzz_qos(s, Data, Size); + _Exit(0); + } else { + wait(NULL); + } +} + +static const char *i440fx_qtest_argv =3D "qemu_system_i386 -machine accel= =3Dqtest" + "-m 0 -display none"; +static char *i440fx_argv(FuzzTarget *t) +{ + return (char *)i440fx_qtest_argv; +} + +static void fork_init(void) +{ + counter_shm_init(); +} + +static void register_pci_fuzz_targets(void) +{ + /* Uses simple qtest commands and reboots to reset state */ + fuzz_add_target(&(FuzzTarget){ + .name =3D "i440fx-qtest-reboot-fuzz", + .description =3D "Fuzz the i440fx using raw qtest commands= and" + "rebooting after each run", + .get_init_cmdline =3D i440fx_argv, + .fuzz =3D i440fx_fuzz_qtest}); + + /* Uses libqos and forks to prevent state leakage */ + fuzz_add_qos_target(&(FuzzTarget){ + .name =3D "i440fx-qos-fork-fuzz", + .description =3D "Fuzz the i440fx using raw qtest commands= and" + "rebooting after each run", + .pre_vm_init =3D &fork_init, + .fuzz =3D i440fx_fuzz_qos_fork,}, + "i440FX-pcihost", + &(QOSGraphTestOptions){} + ); + + /* Uses libqos. Doesn't do anything to reset state. Note that if we we= re to + reboot after each run, we would also have to redo the qos-related + initialization (qos_init_path) */ + fuzz_add_qos_target(&(FuzzTarget){ + .name =3D "i440fx-qos-noreset-fuzz", + .description =3D "Fuzz the i440fx using raw qtest commands= and" + "rebooting after each run", + .fuzz =3D i440fx_fuzz_qos,}, + "i440FX-pcihost", + &(QOSGraphTestOptions){} + ); +} + +fuzz_target_init(register_pci_fuzz_targets); --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572448452174565.6781162287917; Wed, 30 Oct 2019 08:14:12 -0700 (PDT) Received: from localhost ([::1]:41414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpfm-0006kh-U4 for importer@patchew.org; Wed, 30 Oct 2019 11:14:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35463) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIa-0005ED-Mh for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIZ-0007b8-AP for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:12 -0400 Received: from mail-eopbgr690101.outbound.protection.outlook.com ([40.107.69.101]:31361 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIZ-0007LI-2S for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:11 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:50:04 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:50:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iYkqUazOdJvSlFE5zdfWk8NnZNbtfMwMNBKM+SiisGyPIaiUGFC8Yi5pvBrW0hW085wv64gDgGsZmAdIv/EZIxcVBMWr/hTp6afMczldoFEV+yNjIyae0DKXvJssuWLaLNb6d10zKTqlTzWe7tTPycPfyFZbvHOInR06AhdlBkVPfJ7kr0RcI3l7azHS0Ve7qS+s4gYBKfk+c7WdzVZ0V9YNl7ZQBfTpHA09VJlSnscJ/w9kKCYkQajjIstpCVmrMaXV2z7RWpF8Ym12DUxgcFHgtEPMtJ30Q14b5Wn0t5lTpr51N2dS/Rlcd60qFnsiScCtqfMFEmP5bQUemCmAow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DOAMPPdrRQbGjSlUjPItffV6O2I9QkC8bplzLpjAKw4=; b=lWnTE5tfnkfpkoULYzA1VhLomz+oYBxndASObwb5mP7139wDoi8lpntjsASjT/Wy4wfV+qhDCDgN+Q7+v1145hdFz8vA/aYTT093JvD41nf4DQTLxMMq5FLsJnoPDdpTl4GY6iomp0hyPORx32PQ08P8ZqpMwblfXXY9+3S+UoXKupdIqoW+iszgZ+Z6pgQrFvIhM/4sC019zqoXdB1O0sKV9XGEqo+Vz7FAsDa1wumTeiJ3tSPMgukwo8AN8WJ5dHY62/qOH7dZFTth8IWB7wkpEuX5RbtKfvFb6W2MygtYSYVZL/viAH1Ma+z789brnWaAAfInDVkedxd/i+f6Ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DOAMPPdrRQbGjSlUjPItffV6O2I9QkC8bplzLpjAKw4=; b=fkfB29I0nYD6oL8x9OCnpX3XFSDMUDqu+zaASTMI+thi5c3yuilGVtYRGgvexKduYUqTcnLkP7fdWD5Dw1u3r8UAz1aeoQ90wb9x+F0yj8rggzRC9tNz3uowQNFs5JJ3dbOm5CGvXgH5aar6sBt3oVTm4vUmEDhDYeiZowYMvsg= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 19/20] fuzz: add virtio-net fuzz target Thread-Topic: [PATCH v4 19/20] fuzz: add virtio-net fuzz target Thread-Index: AQHVjzFQK2GnRCGfJUGvHuDknq5Dsg== Date: Wed, 30 Oct 2019 14:50:03 +0000 Message-ID: <20191030144926.11873-20-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 77e0003b-1c3e-4bb1-b437-08d75d487287 x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:281; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(25786009)(6436002)(75432002)(8936002)(6512007); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: z0OFBYJ8ML9ye6TO6oFhUqPXoZkYuqwO80Thre5WpwIvKVc5+j0D9eXVf7LJgQMazoy4b3oDFl/f6RvOJ7J5oFOx0L5gBDIXlj4pT+aeU8e6ZKzhMmy0hUqR5A6RD2duA9HnFVt40mElbAYwvYOrR165vMrAmKRPF5Tn278bSo1+uYfJ7Gesrs/ujWa6tcQ00ufNXlMVLSyYJNO9QTK5IJ9sz78FwFjfnOqi83H6nm3So0542ohU9FwJsZ4kD7xHHGMFPiV4VFz8NNE5qqtdDziEUzmMcMGwAUNvmjA2ReCsa2nR8wL9J6DgTei6K2R89TEfTo6QZy/SH9JmjNIATtkTcnzLfEm413pp1DuJqgdzRYmyjWGEPy2eaoCrd7BXr+P01u1pJJTKHmCLnccSZmCTYv8iGfVoGxWSxInknN28BKIphePeGhXwJFIo3/Hc Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 77e0003b-1c3e-4bb1-b437-08d75d487287 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:50:03.8767 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: P4omgZEY+NVmb7Tx7LTGkbkc4yN+PPy84BpKamt4xvV92/TFmrjUPF55IMkz4C7m X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.101 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik The virtio-net fuzz target feeds inputs to all three virtio-net virtqueues, and uses forking to avoid leaking state between fuzz runs. Signed-off-by: Alexander Oleinik --- tests/fuzz/Makefile.include | 1 + tests/fuzz/virtio_net_fuzz.c | 123 +++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 tests/fuzz/virtio_net_fuzz.c diff --git a/tests/fuzz/Makefile.include b/tests/fuzz/Makefile.include index 37d6821bee..f1d9b46b1c 100644 --- a/tests/fuzz/Makefile.include +++ b/tests/fuzz/Makefile.include @@ -6,5 +6,6 @@ fuzz-obj-y +=3D tests/fuzz/fork_fuzz.o fuzz-obj-y +=3D tests/fuzz/qos_fuzz.o =20 fuzz-obj-y +=3D tests/fuzz/i440fx_fuzz.o +fuzz-obj-y +=3D tests/fuzz/virtio_net_fuzz.o =20 FUZZ_LDFLAGS +=3D -Xlinker -T$(SRC_PATH)/tests/fuzz/fork_fuzz.ld diff --git a/tests/fuzz/virtio_net_fuzz.c b/tests/fuzz/virtio_net_fuzz.c new file mode 100644 index 0000000000..0543cfd32a --- /dev/null +++ b/tests/fuzz/virtio_net_fuzz.c @@ -0,0 +1,123 @@ +/* + * virtio-net Fuzzing Target + * + * Copyright Red Hat Inc., 2019 + * + * Authors: + * Alexander Bulekov + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include "fuzz.h" +#include "fork_fuzz.h" +#include "qos_fuzz.h" +#include "tests/libqtest.h" +#include "tests/libqos/virtio-net.h" + + +static void virtio_net_fuzz_multi(QTestState *s, + const unsigned char *Data, size_t Size) +{ + typedef struct vq_action { + uint8_t queue; + uint8_t length; + uint8_t write; + uint8_t next; + bool kick; + } vq_action; + + uint64_t req_addr[10]; + int reqi =3D 0; + uint32_t free_head =3D 0; + + QGuestAllocator *t_alloc =3D fuzz_qos_alloc; + + QVirtioNet *net_if =3D fuzz_qos_obj; + QVirtioDevice *dev =3D net_if->vdev; + QVirtQueue *q; + vq_action vqa; + int iters =3D 0; + while (true) { + if (Size < sizeof(vqa)) { + break; + } + memcpy(&vqa, Data, sizeof(vqa)); + vqa =3D *((vq_action *)Data); + Data +=3D sizeof(vqa); + Size -=3D sizeof(vqa); + + q =3D net_if->queues[vqa.queue % 3]; + + vqa.length =3D vqa.length >=3D Size ? Size : vqa.length; + + req_addr[reqi] =3D guest_alloc(t_alloc, vqa.length); + qtest_memwrite(s, req_addr[reqi], Data, vqa.length); + if (iters =3D=3D 0) { + free_head =3D qvirtqueue_add(s, q, req_addr[reqi], vqa.length, + vqa.write, vqa.next); + } else { + qvirtqueue_add(s, q, + req_addr[reqi], vqa.length, vqa.write , vqa.next); + } + iters++; + reqi++; + if (iters =3D=3D 10) { + break; + } + Data +=3D vqa.length; + Size -=3D vqa.length; + } + if (iters) { + qvirtqueue_kick(s, dev, q, free_head); + qtest_clock_step_next(s); + for (int i =3D 0; i < reqi; i++) { + guest_free(t_alloc, req_addr[i]); + } + } +} + +static int *sv; + +static void *virtio_net_test_setup_socket(GString *cmd_line, void *arg) +{ + if (!sv) { + sv =3D g_new(int, 2); + int ret =3D socketpair(PF_UNIX, SOCK_STREAM, 0, sv); + fcntl(sv[0], F_SETFL, O_NONBLOCK); + g_assert_cmpint(ret, !=3D, -1); + } + g_string_append_printf(cmd_line, " -netdev socket,fd=3D%d,id=3Dhs0 ", = sv[1]); + return arg; +} + +static void virtio_net_fork_fuzz(QTestState *s, + const unsigned char *Data, size_t Size) +{ + if (fork() =3D=3D 0) { + virtio_net_fuzz_multi(s, Data, Size); + flush_events(s); + _Exit(0); + } else { + wait(NULL); + } +} + +static void register_virtio_net_fuzz_targets(void) +{ + fuzz_add_qos_target(&(FuzzTarget){ + .name =3D "virtio-net-fork-fuzz", + .description =3D "Fuzz the virtio-net virtual queues, fork= ing" + "for each fuzz run", + .pre_vm_init =3D &counter_shm_init, + .pre_fuzz =3D &qos_init_path, + .fuzz =3D virtio_net_fork_fuzz,}, + "virtio-net", + &(QOSGraphTestOptions){.before =3D virtio_net_test_setup_s= ocket} + ); +} + +fuzz_target_init(register_virtio_net_fuzz_targets); --=20 2.23.0 From nobody Tue May 7 07:46:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572447606124331.0337132977834; Wed, 30 Oct 2019 08:00:06 -0700 (PDT) Received: from localhost ([::1]:41262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpS7-0002pU-Qf for importer@patchew.org; Wed, 30 Oct 2019 11:00:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35477) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPpIb-0005Fk-J8 for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPpIZ-0007cj-UX for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:13 -0400 Received: from mail-eopbgr690101.outbound.protection.outlook.com ([40.107.69.101]:31361 helo=NAM04-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPpIZ-0007LI-LR for qemu-devel@nongnu.org; Wed, 30 Oct 2019 10:50:11 -0400 Received: from MN2PR03MB4800.namprd03.prod.outlook.com (20.179.82.78) by MN2PR03MB4959.namprd03.prod.outlook.com (52.132.168.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Wed, 30 Oct 2019 14:50:04 +0000 Received: from MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66]) by MN2PR03MB4800.namprd03.prod.outlook.com ([fe80::344f:b88:26f0:9f66%7]) with mapi id 15.20.2387.028; Wed, 30 Oct 2019 14:50:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kpU1GqgDlZA6s8XakcUL8TDbE4Eq67h1ZOGHoKtrcqtbq2P85bXExXfR1NUD7ZL0wtJarf96rpwn6Qsdy0XytElC9sKFQmOXL+cv8R45Jwdrxh31g54UxhAkpumrqOJRcgJD/au+alze7Fxkgl+hDmmWm+bdBIRCSS0rjgegcnVGCGdEFvNtPSERogyMCHPUNCK4D0EynbkZeHXrGtEG2qt5R4GVYy89Is60u1wPEd7nV536AzSZoYi7wRRm3eb6a2CnAs0NVyNecuyDsrQsRJiBuhhkRmyM+e4Vs69QHjyh0TcH5i8JoUqe5JK2GpFcPGkWpY5tXTu1SGm021gONA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I06QdC9/KgefgXf1SpYRHXJIr+nmQABh4Rg+kqbv7cg=; b=Yf+0kDaciLzskgNcFHxDzhAsZr3LaIz+IcqyVE2G2t5yRzpZR7JLIAFVifgPjp0tIlxE4FOMisfkTEGIjwJWLO5OGWpjs2k2bsWr0K2iw/nrOJfMmByYAmiEU5yF88FqtIzOqSQT+Z7OLvsSiwFjvknq5rlkWvS2udDZuINZAE7jxedUOtxClehFzvBySaa3xKzaye01FjNT/BBpZZsebPZTI2hsrnai+zTFp7GmaT3Ing+WR1XMKzaio9B46uDCWkxzAx6POhu9Y7cMFjUTXRuRsdsrTQYSB1lY/6PWc8Lf/VKvhEr6AMcYnLIRIYzu796DBhW/N7Q9uXJkCVSaJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bu.edu; dmarc=pass action=none header.from=bu.edu; dkim=pass header.d=bu.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bushare.onmicrosoft.com; s=selector2-bushare-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I06QdC9/KgefgXf1SpYRHXJIr+nmQABh4Rg+kqbv7cg=; b=YHvTGJt51qOGZ+pIH+CgnKMDm0j5pnemHa2IXstheKKQb3K6A3W+aL4N5dX1EwqJjNh7EplhL7d6uNQb6IJ28At61uZbGExt7oBYim4wW5KJOvQt/JggQeY2oS/ZpZ/zPglxSetUcwE2Qxzs9S3Zt+hMissK+OSHz/yobd28vlM= From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Subject: [PATCH v4 20/20] fuzz: add documentation to docs/devel/ Thread-Topic: [PATCH v4 20/20] fuzz: add documentation to docs/devel/ Thread-Index: AQHVjzFQWDhlqlxcSEW7sNPvkYqX2w== Date: Wed, 30 Oct 2019 14:50:04 +0000 Message-ID: <20191030144926.11873-21-alxndr@bu.edu> References: <20191030144926.11873-1-alxndr@bu.edu> In-Reply-To: <20191030144926.11873-1-alxndr@bu.edu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.23.0 x-originating-ip: [128.197.127.33] x-clientproxiedby: DM5PR08CA0048.namprd08.prod.outlook.com (2603:10b6:4:60::37) To MN2PR03MB4800.namprd03.prod.outlook.com (2603:10b6:208:101::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alxndr@bu.edu; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2245822d-984b-48b8-8e76-08d75d4872ef x-ms-traffictypediagnostic: MN2PR03MB4959: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 02065A9E77 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(346002)(136003)(199004)(189003)(102836004)(386003)(6506007)(66946007)(66446008)(64756008)(66476007)(2616005)(186003)(2351001)(446003)(26005)(36756003)(66556008)(3846002)(6116002)(14444005)(2501003)(14454004)(11346002)(66066001)(256004)(4326008)(6916009)(305945005)(1076003)(6486002)(486006)(5660300002)(71190400001)(50226002)(71200400001)(476003)(86362001)(88552002)(7736002)(52116002)(76176011)(2906002)(478600001)(99286004)(786003)(316002)(8676002)(81166006)(5640700003)(81156014)(25786009)(6436002)(75432002)(8936002)(6512007); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR03MB4959; H:MN2PR03MB4800.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 4EnLwVTB5qZsTQrCiyGRGhI6Zld5G1A68NyMqmFsOyojZhhdGqSJdJTLsGpowOtyzyTGeXiPC63Btl5RX00U6H9zGgRxEW2/qWzpUbYSOGj/E9H19yXEhbv9QrNpiWTYfowVnldNxxY5akzDhZ++xsdjEHc6kHI/Obd+RkNyv5nF4WRQKBrnqXbwxUBSs1ahPFPqP7LPxS2QL/YJ57u+uuwGGOtMTE2sh2fxshsUUegrWoBMNDPkRP6DcHIKIS7qZYK+B5RMBNYRGBuZamLdVugsQOkr4MDw7PmsWOaep/3aEKesHkuZl6ScJPdI34p2zzMeZoXZfFgc6O/ReeAXLrpYtFa9hNFkE7rKhijjWoD2Bf5wD33liWc6YGJ5VJexLNk1cs2oO0/LLd0OLOeh/Ffc5efcGLkNUDxucECLrFSaGWvdxsXflG/pmWc4tI0r Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 2245822d-984b-48b8-8e76-08d75d4872ef X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 14:50:04.5474 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d57d32cc-c121-488f-b07b-dfe705680c71 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: aiXRw5pqhj3KISAZF3O0YKCUmO534x5dnOm5L2Lifv6KgfqxN2JlZng4OugYr97z X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4959 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.101 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: "Oleinik, Alexander" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bushare.onmicrosoft.com) Content-Type: text/plain; charset="utf-8" From: Alexander Oleinik Signed-off-by: Alexander Oleinik --- docs/devel/fuzzing.txt | 119 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 docs/devel/fuzzing.txt diff --git a/docs/devel/fuzzing.txt b/docs/devel/fuzzing.txt new file mode 100644 index 0000000000..825ff0af51 --- /dev/null +++ b/docs/devel/fuzzing.txt @@ -0,0 +1,119 @@ +=3D Fuzzing =3D + +=3D=3D Introduction =3D=3D + +This document describes the virtual-device fuzzing infrastructure in QEMU = and +how to use it to implement additional fuzzers. + +=3D=3D Basics =3D=3D + +Fuzzing operates by passing inputs to an entry point/target function. The +fuzzer tracks the code coverage triggered by the input. Based on these +findings, the fuzzer mutates the input and repeats the fuzzing.=20 + +To fuzz QEMU, we rely on libfuzzer. Unlike other fuzzers such as AFL, libf= uzzer +is an _in-process_ fuzzer. For the developer, this means that it is their +responsibility to ensure that state is reset between fuzzing-runs. + +=3D=3D Building the fuzzers =3D=3D + +NOTE: If possible, build a 32-bit binary. When forking, the 32-bit fuzzer = is +much faster, since the page-map has a smaller size. This is due to the fac= t that +AddressSanitizer mmaps ~20TB of memory, as part of its detection. This res= ults +in a large page-map, and a much slower fork(). O + +To build the fuzzers, install a recent version of clang: +Configure with (substitute the clang binaries with the version you install= ed): + + CC=3Dclang-8 CXX=3Dclang++-8 /path/to/configure --enable-fuzzing + +Fuzz targets are built similarly to system/softmmu: + + make i386-softmmu/fuzz + +This builds ./i386-softmmu/qemu-fuzz-i386 + +The first option to this command is: --fuzz_taget=3DFUZZ_NAME +To list all of the available fuzzers run qemu-fuzz-i386 with no arguments. + +eg: + ./i386-softmmu/qemu-fuzz-i386 --fuzz-target=3Dvirtio-net-fork-fuzz + +Internally, libfuzzer parses all arguments that do not begin with "--". +Information about these is available by passing -help=3D1 + +Now the only thing left to do is wait for the fuzzer to trigger potential +crashes. + +=3D=3D Adding a new fuzzer =3D=3D +Coverage over virtual devices can be improved by adding additional fuzzers= .=20 +Fuzzers are kept in tests/fuzz/ and should be added to +tests/fuzz/Makefile.include + +Fuzzers can rely on both qtest and libqos to communicate with virtual devi= ces. + +1. Create a new source file. For example ``tests/fuzz/fuzz-foo-device.c``. + +2. Write the fuzzing code using the libqtest/libqos API. See existing fuzz= ers +for reference. + +3. Register the fuzzer in ``tests/fuzz/Makefile.include`` by appending the +corresponding object to fuzz-obj-y + +Fuzzers can be more-or-less thought of as special qtest programs which can +modify the qtest commands and/or qtest command arguments based on inputs +provided by libfuzzer. Libfuzzer passes a byte array and length. Commonly = the +fuzzer loops over the byte-array interpreting it as a list of qtest comman= ds, +addresses, or values. + + +=3D Implmentation Details =3D + +=3D=3D The Fuzzer's Lifecycle =3D=3D + +The fuzzer has two entrypoints that libfuzzer calls. libfuzzer provides it= 's +own main(), which performs some setup, and calls the entrypoints: + +LLVMFuzzerInitialize: called prior to fuzzing. Used to initialize all of t= he +necessary state + +LLVMFuzzerTestOneInput: called for each fuzzing run. Processes the input a= nd +resets the state at the end of each run. + +In more detail: + +LLVMFuzzerInitialize parses the arguments to the fuzzer (must start with t= wo +dashes, so they are ignored by libfuzzer main()). Currently, the arguments +select the fuzz target. Then, the qtest client is initialized. If the targ= et +requires qos, qgraph is set up and the QOM/LIBQOS modules are initailized. +Then the QGraph is walked and the QEMU cmd_line is determined and saved. + +After this, the vl.c:real_main is called to set up the guest. After this, = the +fuzzer saves the initial vm/device state to ram, after which the initiliza= tion +is complete. + +LLVMFuzzerTestOneInput: Uses qtest/qos functions to act based on the fuzz +input. It is also responsible for manually calling the main loop/main_loop= _wait +to ensure that bottom halves are executed. Finally, it calls reset() which +restores state from the ramfile and/or resets the guest. + + +Since the same process is reused for many fuzzing runs, QEMU state needs to +be reset at the end of each run. There are currently two implemented +options for resetting state:=20 +1. Reboot the guest between runs. + Pros: Straightforward and fast for simple fuzz targets.=20 + Cons: Depending on the device, does not reset all device state. If the + device requires some initialization prior to being ready for fuzzing + (common for QOS-based targets), this initialization needs to be done af= ter + each reboot. + Example target: i440fx-qtest-reboot-fuzz +2. Run each test case in a separate forked process and copy the coverage + information back to the parent. This is fairly similar to AFL's "deferr= ed" + fork-server mode [3] + Pros: Relatively fast. Devices only need to be initialized once. No need + to do slow reboots or vmloads. + Cons: Not officially supported by libfuzzer. Does not work well for dev= ices + that rely on dedicated threads. + Example target: virtio-net-fork-fuzz + --=20 2.23.0