From patchwork Wed Sep 18 23:19:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151285 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A4A616B1 for ; Wed, 18 Sep 2019 23:21:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 504DC218AF for ; Wed, 18 Sep 2019 23:21:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="xlGKAd2s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 504DC218AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjGJ-0002AD-QR for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:21:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33143) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjET-0000DR-Lh for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjER-0002SR-T6 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:33 -0400 Received: from mail-eopbgr710125.outbound.protection.outlook.com ([40.107.71.125]:35255 helo=NAM05-BY2-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 1iAjER-0002RC-Lq for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I/NhWbLUxcywtGtl1ZFbYtQzBToJMNwDHKgSPj1m3p34MKVKDJrjxA4jIxlhdDjdJM7+GZt4Xrtd5z35SoksVdToswA0im3YrxygwEOIWOHK/4YT2ElIqUL+oQmPp6KPoBX6gOF7JCLGSnkR/sT4OUIWowQFPJIe30dfiS6zP9N6M5gLsz3jXKO9QDT9xGn8Xs3YzVsSIG68Cs4Jey4sNq8DcbHDjow2X+W2olOQV6Y1HK2NzX8gbG8Q0MdwreNvb7KHjURpsJ3+oiomdwFoEbsOXAWzKqArBNkeRmZdeF9rwfcQJL/x2334SdY7I6sUZuShKR9rXzdunU75IchwbA== 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=TTTSY45zl8aDnZ4fQRRsQ4KW1PyknjWwSKAD4E24ht8=; b=ibJDgF5Dc3v9wTUpHnihojsktHOg9WlZ6ewLXt4fjmz6MfiqMnhjqC4PrL5F9TZnEhNuH9VXQRutrB4drsDPWYE5XN30FWN1RkVWhBlQz3FAgrCQ7xx1Vg/FQCBpGqiqXggi/pJG2nNGeuyLfNA8YoKRn61OAKFfM2Umi7jY0gEITKSb2yP/Asl0Je0ERovfKd3akvFdoEEv7s9JXe3JOUvS8aF/3erPmipI6btFGRPeU4hXgtMgn8jRMceKciADT+uLLl4rNJpmOJKqMp/S8JheseHw+ZJ7tD4vF3sugzbBUEUaGk1MHsSa3FPKs5a5ijwDS3ygFQWHhvh9of3O5A== 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=TTTSY45zl8aDnZ4fQRRsQ4KW1PyknjWwSKAD4E24ht8=; b=xlGKAd2sTylvKY4VMFUeQRoz9Xp0d7p4sfKykqkG8OAC5dGVllmqn68c0QKnJBE3h6/6VJwdOFijjCOrIgaB9i2O2FoXchy0k6ELiB+amY0InWnD8dpYj1TyKRvt/Ot/ELfjbiBHUPaZG+JKwgJfwt7FzD3r7B8ChAf4pGTerW0= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:28 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:28 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 01/22] softmmu: split off vl.c:main() into main.c Thread-Index: AQHVbneErncWI2VHukm8RkgqcYgDRQ== Date: Wed, 18 Sep 2019 23:19:28 +0000 Message-ID: <20190918231846.22538-2-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: cd0ec660-50e9-4a65-86de-08d73c8ea6e3 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 8paaOiuIrRVDNYkldxa9AsBIHHDkCNTHTpyFekBQRclB0x01adgTFJJdzIEm99Zy/WnQA9zJqP8Lzf6Jxw6W8p/QpLLCgWQpWNnOuuG3fxE/rjqUNdBJOpZtJYo1Ep8LQStah5LQgBBiajQrT34M+9M28qPsPDddqlfK3gUPYM1y3R6T3CLRjD4l0j9AZrXtoYFm48IwHgqrRSJlxmFHORvwJzP8xmmgSmLz8IOGe5JK0wFmWl3B/rrUpaPGDmkfhH4m6X370qg27G/O//Afz8OSYEnqd3CAZ4OQWfBSQM9Im60XdzpIJf/PX+lEkWIpNGMvjbInSkIZDpfyklZpQqIW9NyTLvHQ5AndEi+OZ5WA0OeRcTxndraEt7PNndmuy+Lip6EWY17MytWZwEM24868J179ggR3yOlCnEqpZ84= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: cd0ec660-50e9-4a65-86de-08d73c8ea6e3 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:28.1565 (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: TjyfWHuw4Z8i3UOATN4drJFaQVU8Ht9kIZLXgRXJzmXSF/iqVWOnVxCsgZJNTNvp X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.71.125 Subject: [Qemu-devel] [PATCH v3 01/22] softmmu: split off vl.c:main() into main.c 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 | 29 +++++++++++++++++++++++++++++ vl.c | 25 +++++++------------------ 5 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 main.c diff --git a/Makefile b/Makefile index b3528617e4..f628783571 100644 --- a/Makefile +++ b/Makefile @@ -463,6 +463,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) .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 6a143dcd57..bb1cfa05ef 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -86,6 +86,8 @@ common-obj-$(CONFIG_FDT) += device_tree.o # qapi common-obj-y += qapi/ + +softmmu-main-y = main.o endif ####################################################################### diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 44f18eb739..aa204ebbb0 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -114,6 +114,10 @@ QemuOpts *qemu_get_machine_opts(void); bool defaults_enabled(void); +void main_loop(void); +int 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..279275069d --- /dev/null +++ b/main.c @@ -0,0 +1,29 @@ +#include "qemu/osdep.h" +#include "sysemu/sysemu.h" + +#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 */ + +int main(int argc, char **argv, char **envp) +{ + int ret = qemu_init(argc, argv, envp); + if (ret != 0) { + return ret; + } + + main_loop(); + + qemu_cleanup(); + + return 0; +} diff --git a/vl.c b/vl.c index 630f5c5e9c..327510c81f 100644 --- a/vl.c +++ b/vl.c @@ -36,18 +36,6 @@ #include "sysemu/seccomp.h" #include "sysemu/tcg.h" -#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 @@ -1794,7 +1782,7 @@ static bool main_loop_should_exit(void) return false; } -static void main_loop(void) +void main_loop(void) { #ifdef CONFIG_PROFILER int64_t ti; @@ -2869,7 +2857,7 @@ static void user_register_global_props(void) global_init_func, NULL, NULL); } -int main(int argc, char **argv, char **envp) +int qemu_init(int argc, char **argv, char **envp) { int i; int snapshot, linux_boot; @@ -4468,7 +4456,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); } if (incoming) { @@ -4485,8 +4473,11 @@ int main(int argc, char **argv, char **envp) accel_setup_post(current_machine); os_setup_post(); - main_loop(); + return 0; +} +void qemu_cleanup() +{ gdbserver_cleanup(); /* @@ -4522,6 +4513,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; } From patchwork Wed Sep 18 23:19:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151287 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F947112B for ; Wed, 18 Sep 2019 23:21:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2645A218AF for ; Wed, 18 Sep 2019 23:21:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="Jfmc51CA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2645A218AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjGK-0002Bt-Ae for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:21:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33166) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEU-0000EH-Gk for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjET-0002Sz-1h for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:34 -0400 Received: from mail-eopbgr710132.outbound.protection.outlook.com ([40.107.71.132]:6167 helo=NAM05-BY2-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 1iAjES-0002SZ-Qx for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jPXFaLuNygN6D90VdJwygU1lCtkka+tBJH8bPCeGeIC2JTGjZDLj8kI8+hENlrFDfHWYYE8kSjy5FHMfNtoOm1/JWCQDpxZyt3eRTwjEDhdHcsFsdDn8ZciI1ZpGWhs8CjFgoDZGEfHuXKDDEcK4tYPdlmqvFEToxM6CYkfjj9YGzq8wMHT5N3iLbFc7vMj4lEltlfV/R5xpKgNKpigIBPZ8onNqnvsxNCsjrQ56Gqp0F0AW4Kz7lDVGF6J59GtEwg2Rs9vADjChR7aPipKEjq/s0fsxAo4Jsm9LVNvMU5pWKXaICOHlmmdz6/s6E2zS/9D/Q86S95z3TK2XsJuc7g== 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=Kl6Xg8KiK7uFnKscaFCU1OMZ+semD7ioC/jr93Z9oxI=; b=nnc3gno1byPOXL8KeoSpzp5y9WhmWixOKIXjw1YOgbO93NMoZANIsQI9wUcK7tbghvc1eOzt05Ag20wKP+FLT9ii9HLnIqic3+VHk39VzurI63jhzcmrYahvJwwY6spJEIn2DDlLFwubheiKLPPjeGTo2sQ12fbM2tznhwtgexmhzKnqbwKojKK7DvKh4OenBtEjZhw5Mn+dsnb1cF55CiUKbQiZ2M9mGjAT31TDFxZxqkcJlCNLBcenDrQW99iOypFvKf0ML3iksKdHvnp4Fh1KXnpsA2fYIH/wzxdPTZXGK7hfQQAOEjAuCQqevT58+4RwXzUFm8+Zsmf4GBmRPg== 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=Kl6Xg8KiK7uFnKscaFCU1OMZ+semD7ioC/jr93Z9oxI=; b=Jfmc51CAQBGEa0lSrBv40hAwI+2gDUgxl7QoxDLCjtwDqRraFr85sPEWF0SrFBSliLNr/S6aQ4Gam7YQKoIP9sdeGyPvvfxLEHWemnmEvWOkafW99Fh3gfekg0mlz30KsXhIReKkBC4CW2C1STmkYmAFNxONX58qIPSG1ptg7bY= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:29 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:29 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 02/22] libqos: Rename i2c_send and i2c_recv Thread-Index: AQHVbneFFU4BDIDh4Ea8xDc1OfLEzA== Date: Wed, 18 Sep 2019 23:19:29 +0000 Message-ID: <20190918231846.22538-3-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 6d2e1845-4e67-4268-e6d5-08d73c8ea7b8 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:345; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: L4cOTt4pbalqapFCPhPxedE2eVXGupmQ1kL7KziHv/YQjH1r61JVv9XDy0g/B+j3PJ2cCNNBuK6mpo5bL0E2gLatAQmSnPybxn6J0jNWVPEoygy+kFowVOOyxz1xcxh2ISB/x6PIgFAqDOdrWnRLHhyiveT+SVqFmSsojT5SN7Sc/Z6tQbwun+TxnlFog9uOmH/Sfs6W8e9NyqZAAYe9I8SpXnJL/qsoEyU2cDVASgiebVCc5e6oVIZq4+YNZqFCzqnQ95gWv4vBO51RZq4LdmjiAVESNgKjroltuLX7lF6LkEhaDnyoPIdWTkA2jk81Ft8/XMlei4/dKdZeg+S+FjYHz/K95bZ93OCC/8fDGMhjfw8WvnPMVDTd2Ot5XzitjvOhodjAbkiRmoBjgfkDB7kSXOgHgCyQQantrzVMyTA= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 6d2e1845-4e67-4268-e6d5-08d73c8ea7b8 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:29.6718 (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: ZR/fT+0ZAvV7YRVmcrd2xo56cWm1T1aCS/ESkU3DlMfELeajQ1br9fWsR4+qsQ5P X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.71.132 Subject: [Qemu-devel] [PATCH v3 02/22] libqos: Rename i2c_send and i2c_recv 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 , Thomas Huth , "Oleinik, Alexander" , "bsd@redhat.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Acked-by: Thomas Huth 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..c1dcc9fb1d 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 addr, (addr << 1) | (direction == IMX_I2C_READ ? 1 : 0)); } -static void imx_i2c_send(I2CAdapter *i2c, uint8_t addr, +static void imx_i2c_test_send(I2CAdapter *i2c, uint8_t addr, const uint8_t *buf, uint16_t len) { IMXI2C *s = container_of(i2c, IMXI2C, parent); @@ -97,7 +97,7 @@ static void imx_i2c_send(I2CAdapter *i2c, uint8_t addr, g_assert((status & I2SR_IBB) == 0); } -static void imx_i2c_recv(I2CAdapter *i2c, uint8_t addr, +static void imx_i2c_test_recv(I2CAdapter *i2c, uint8_t addr, uint8_t *buf, uint16_t len) { IMXI2C *s = container_of(i2c, IMXI2C, parent); @@ -202,8 +202,8 @@ void imx_i2c_init(IMXI2C *s, QTestState *qts, uint64_t addr) s->obj.get_driver = imx_i2c_get_driver; - s->parent.send = imx_i2c_send; - s->parent.recv = imx_i2c_recv; + s->parent.send = imx_i2c_test_send; + s->parent.recv = imx_i2c_test_recv; s->parent.qts = qts; } diff --git a/tests/libqos/i2c-omap.c b/tests/libqos/i2c-omap.c index 9ae8214fa8..284f765a3b 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 addr) g_assert_cmphex(data, ==, addr); } -static void omap_i2c_send(I2CAdapter *i2c, uint8_t addr, +static void omap_i2c_test_send(I2CAdapter *i2c, uint8_t addr, const uint8_t *buf, uint16_t len) { OMAPI2C *s = 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) == 0); } -static void omap_i2c_recv(I2CAdapter *i2c, uint8_t addr, +static void omap_i2c_test_recv(I2CAdapter *i2c, uint8_t addr, uint8_t *buf, uint16_t len) { OMAPI2C *s = container_of(i2c, OMAPI2C, parent); @@ -182,8 +182,8 @@ void omap_i2c_init(OMAPI2C *s, QTestState *qts, uint64_t addr) s->obj.get_driver = omap_i2c_get_driver; s->obj.start_hw = omap_i2c_start_hw; - s->parent.send = omap_i2c_send; - s->parent.recv = omap_i2c_recv; + s->parent.send = omap_i2c_test_send; + s->parent.recv = omap_i2c_test_recv; s->parent.qts = qts; } diff --git a/tests/libqos/i2c.c b/tests/libqos/i2c.c index 156114e745..b96a37b69b 100644 --- a/tests/libqos/i2c.c +++ b/tests/libqos/i2c.c @@ -10,12 +10,12 @@ #include "libqos/i2c.h" #include "libqtest.h" -void i2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len) +void i2c_test_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len) { i2cdev->bus->send(i2cdev->bus, i2cdev->addr, buf, len); } -void i2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len) +void i2c_test_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); + i2c_test_send(i2cdev, ®, 1); + i2c_test_recv(i2cdev, buf, len); } 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 = g_malloc(len + 1); cmd[0] = reg; memcpy(&cmd[1], buf, len); - i2c_send(i2cdev, cmd, len + 1); + i2c_test_send(i2cdev, cmd, len + 1); g_free(cmd); } diff --git a/tests/libqos/i2c.h b/tests/libqos/i2c.h index 945b65b34c..9a4d6579a2 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); -void i2c_send(QI2CDevice *dev, const uint8_t *buf, uint16_t len); -void i2c_recv(QI2CDevice *dev, uint8_t *buf, uint16_t len); +void i2c_test_send(QI2CDevice *dev, const uint8_t *buf, uint16_t len); +void i2c_test_recv(QI2CDevice *dev, uint8_t *buf, uint16_t len); 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..9844177d79 100644 --- a/tests/pca9552-test.c +++ b/tests/pca9552-test.c @@ -32,22 +32,22 @@ static void receive_autoinc(void *obj, void *data, QGuestAllocator *alloc) pca9552_init(i2cdev); - i2c_send(i2cdev, ®, 1); + i2c_test_send(i2cdev, ®, 1); /* PCA9552_LS0 */ - i2c_recv(i2cdev, &resp, 1); + i2c_test_recv(i2cdev, &resp, 1); g_assert_cmphex(resp, ==, 0x54); /* PCA9552_LS1 */ - i2c_recv(i2cdev, &resp, 1); + i2c_test_recv(i2cdev, &resp, 1); g_assert_cmphex(resp, ==, 0x55); /* PCA9552_LS2 */ - i2c_recv(i2cdev, &resp, 1); + i2c_test_recv(i2cdev, &resp, 1); g_assert_cmphex(resp, ==, 0x55); /* PCA9552_LS3 */ - i2c_recv(i2cdev, &resp, 1); + i2c_test_recv(i2cdev, &resp, 1); g_assert_cmphex(resp, ==, 0x54); } From patchwork Wed Sep 18 23:19:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151293 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C05B112B for ; Wed, 18 Sep 2019 23:25:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E696D218AF for ; Wed, 18 Sep 2019 23:25:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="Yf6jOXMn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E696D218AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjJn-0006E9-3k for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:25:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33180) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEV-0000Ec-1j for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjET-0002Tl-TS for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:34 -0400 Received: from mail-eopbgr710132.outbound.protection.outlook.com ([40.107.71.132]:6167 helo=NAM05-BY2-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 1iAjET-0002SZ-CY for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BPi2eE2uIjIs0bwDpol2tHf14LaqtaREnmRad69uQd/GGjeS558wGi6VtJOZFXo8To3G5WEqjt+U9vJsFvyPnMV6/GtQflA06QvE5pr4WU9avr5ORRty1+fxdmrXFcYdoBEObU1iTdxgh1RS5SJ5oBoMLWgFg2ju8DuqUoJj79E1tczv7c/Iw6GLGJQNFl5yw8kctp4MprwV2zWZxOk966Q92GmZSVmWvYlIcRnEKcIrDiq/4xQKLxwTZ+Jam8y0hfcgcAywzheJ/X0LlqEc735kbRrHlZHdxZbE9RA4PXy8UOeKMuqtkryT8j0pUeGwE4TGsE4aM7/XThMpNrGa2A== 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=BGLjoyRkxM+RA9W3RsLlnf2NA1JAxArFta6ypbMhKok=; b=iFHl3LSx/shUSwC2Th0Ab+FWYXhrd1Ej9wLEklSc5Z0jKYS+D56qhuAfTJY5Ifg8+0Ek555Jk92OVOWjQ+yhOGVBoMvlj19s3UXe0gynoS+wfBaDEdw9bsOiTYvfYK6PO0ilrtFu+higMkWycF4pQNxB5OYuJJRa4up1T9+cHZEfI/WJmI9q6oD6xx4rj1wlbUTF4PQCeqdHFDska0GypOG3fBa7EIxU7xfSr2X8ejWeU+/wtQcGThVqHc/ug7u2O0L/S3hH5JarCyUfipQSUWmUqsV486o1jVQnxA6Pj0P69tERVxXStJy4UDHPlQX7+jxLx7aibSJd9fAbU2EraQ== 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=BGLjoyRkxM+RA9W3RsLlnf2NA1JAxArFta6ypbMhKok=; b=Yf6jOXMnZbDO0F2biEXsgYMJx2TYAPgQpjnXs3KrEwO38gu6+K7d2PMUOXGN5KM33WVeS1KDe0/TZ9+R1lTd2ytiOGQJr0gcW4bcdxSUcNAWDduB980fqKbfoLk2FMpUfdcsnfXwogMEJClBGK5PidqLyuvy1WVhn57aLUC7wQ8= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:30 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:30 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 03/22] fuzz: Add FUZZ_TARGET module type Thread-Index: AQHVbneFfSE2l4yKnUCWrum04P7nlg== Date: Wed, 18 Sep 2019 23:19:30 +0000 Message-ID: <20190918231846.22538-4-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 927b65ea-ba9c-46ca-7864-08d73c8ea85d x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:229; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(14444005)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(4744005)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: tSzEEyzjpDX+Bzgvf3h9ttb6xZIGyqupsQpUe+6whi91mm4NEiA8v94So14+77riw7imeqvc+RP6AVdvj9KeCuGUdvSJqI52gFOM7jWUGi/28h5um+VabpNjYwyqo4TIx3ZCc4PcawGXvIvWn5GxFWoi2qIhcBaa3bx2Nj1uvgzjSAyxvNWGPa+zD8KP7OYBXUfUK2Qa1aJj+bZTJi1hVLESkH1Q5juVFZFLqN0nzWx80updzMAEcOc0cVCVsxa+EuPYWHQnF9shvLpBWVOMa2i2sYoQxmSiYS9uvtC5yeiQhWTtdfOLekeFGtOmyN8sn6Vq+s3MPkAJ2EfqCtbVdMSTv8oiQcmA49U70WdIjiT4RBODUNyvdlki9htp3heY8ciKynde1ruVfIqyiVgkUVpEC66si2WcHaaxCFd3lFE= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 927b65ea-ba9c-46ca-7864-08d73c8ea85d X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:30.6094 (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: yIZJUf++m7Opd+sXFAszFjbkSY/LEXDX2z/bq5wODKEoX8BoxYUxFKczr/AkhDMM X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.71.132 Subject: [Qemu-devel] [PATCH v3 03/22] fuzz: Add FUZZ_TARGET module type 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexander Oleinik 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; @@ -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) From patchwork Wed Sep 18 23:19:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151299 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2706C112B for ; Wed, 18 Sep 2019 23:27:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E22E3218AF for ; Wed, 18 Sep 2019 23:27:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="0Dptc4Q3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E22E3218AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjMF-0001VM-Ou for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:27:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33194) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEV-0000FN-LF for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEU-0002U7-BT for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:35 -0400 Received: from mail-eopbgr710132.outbound.protection.outlook.com ([40.107.71.132]:6167 helo=NAM05-BY2-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 1iAjEU-0002SZ-4x for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CqYmcOFpUJUXLr3thaHsHP0N9/JD/rkW7723NAlQRaRiOcrbmKcd4eNrrLNojuj6eMDvjBul9nIeChSRRE4h8keHBxGTeKGPwsqNpmzMVXRADfaYuBtkWvZyl4qHLhzCz+cHYIq5sf+aThjSQGBBtUD8x6DNfrUlnh2ZwoHP13IhZldR1MqJfZaGtUhFuO8XQjP7B4i2+4Ex6ShhYaOwe3fWXA79SsT4TzJ3Q6Nr/9g+f+51zf34pxov76jt/ZwNeGlEewbiERipPd8Arp+z10eSGSRDJG7h7W7li78a715Vbl0RnyHXpvikQxzJ/LnzWrZYu2zV1OK6ZQOancnOlw== 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=H8J8YnIhyLbBKPhiXZHVbhgPfNPSO/Ewl+judJpegH4=; b=UAEVFbY06P3oTZJT94mXSrq3VAhwmDRiFoKIDb2LV9GHxgf3Hw1rIIXSNEy1a/he4B1Y9Yf6vCWNr4MVeV6lsTJYpxbKbbNUBEjxwlzS+gd2zqqG9IM79sM2clGOqOJtSD74rqdA0V3QUvGUzGjcb9Og1b3GZX8k2PycXf962Qypx9eJRJ18xXcRWsBzhnt0zgWNrfGYlK0X+37Tc8gYrbt1avRlQPkS4tzHcL4pYMNn83sukPN1YdFG8t7qNfvV9e6lydOHdzSvtE0UF/Bn4MccqK8sOAIzQK6GW820AYiqlfLlVNpKwG76ftk2BBhS+4YzR6erzcfTBkYl3KGNiQ== 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=H8J8YnIhyLbBKPhiXZHVbhgPfNPSO/Ewl+judJpegH4=; b=0Dptc4Q3GAsn4BBiYoz+avUvsv2ZhG7CP+ajIw4q7CkwLmVjggXDoxq17mj0MTF/VFve6od40nQNGLl42XGtTCOJ7EffAyiwEe8s+LKSkOtMzRS+51rlK5WwgU3L18MulTNpNUXStfZvp9uk1RuvVmcJk1x/DO6G3ndbH7BX754= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:31 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:31 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 04/22] qtest: add qtest_server_send abstraction Thread-Index: AQHVbneGCY8YhbIzf0iyqWM37iID8w== Date: Wed, 18 Sep 2019 23:19:31 +0000 Message-ID: <20190918231846.22538-5-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 6dff444d-7eff-4e78-fd0e-08d73c8ea8fe x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(979002)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: TQBRupeNsL1VObYFz4Y4c1s9rznakhTRSG60EpJfj2Gn5bLp8kvWZix9pC9sGUbD/4petXuTSH4sobp1RAs2fMLg07tSjjt1TEs/um7Oin63LzH85bIVwTfd0BxJDgoDuEYe65EFICnLUH//4pWgCUPKkqQrcAboXciFgdUYHi50zbtybn+o5W/6hO/5Ilef/cUyAMGcxdFKPidwWE6KR1KlYv1mHZiPVmO1TAIhniIQvz4jUhYXnhhW2KvHkpJrx50U3gnnWMy0OXezzJ+Gt2vmz4xYZ+vl+NbX6diQ/Prni2GR2VHjLSBH6KLlcUkl+FTpKW+y6UgvqHX02Z5vGmylVw6DjI80pZLg5y6Mjo12dgrtxXEA0qf0/eCwWajqUMm0T/XDoBn1blVdPfXg73poJeeDkePiqGvv5tx16G0= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 6dff444d-7eff-4e78-fd0e-08d73c8ea8fe X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:31.6239 (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: hEym71XIE92pUcQ1Nf4f/GOzJq/vG8KEJMwDi6fLH5XV3OCSlJW3HI8XBNR2fL0y X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.71.132 Subject: [Qemu-devel] [PATCH v3 04/22] qtest: add qtest_server_send abstraction 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 , Thomas Huth , "Oleinik, Alexander" , "bsd@redhat.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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); void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Error **errp); +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; #define FMT_timeval "%ld.%06ld" @@ -228,8 +230,9 @@ static void GCC_FMT_ATTR(1, 2) qtest_log_send(const char *fmt, ...) va_end(ap); } -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 = (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) 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)); } 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); inbuf = 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 = send; + qtest_server_send_opaque = opaque; } bool qtest_driver(void) From patchwork Wed Sep 18 23:19:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151291 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C71DD16B1 for ; Wed, 18 Sep 2019 23:25:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9CA8A218AF for ; Wed, 18 Sep 2019 23:25:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="q2sXyTsB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CA8A218AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjJm-0006Do-P8 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:25:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33214) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEW-0000GK-KZ for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEU-0002Ub-RH for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:36 -0400 Received: from mail-eopbgr710132.outbound.protection.outlook.com ([40.107.71.132]:6167 helo=NAM05-BY2-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 1iAjEU-0002SZ-JN for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SHTy4WhzBrsbqx4tFlnabG+bj/4kvjLCodgwpKZneBGE3sI96ySWdZpJNXx7fFpdf6PQN/L6D2PdHWuo4IfAWBQ3We/FjpTCZqp3i1/fl92ojaUip4ERsmoJHcKTcxYmJ30hbp3EjnnJRYEi+F8ERbtmh5PnXoQAK2RVTlkOWvMMuhpMRGK91uBCpyBdIc3BgTaXQBnmZO513ALqmrI3416L95zWWZIkUMI3DAaLgZKskLrYQozLfiG+j5XomG3p94MrE7+PVfcNI9Lk2R6e2UCy0SQ2n5/Hf4GaTI2+68eFTeKnM/V/ZeBlkDJAxG7F5b8V8XJRJD5A9/gRKvJTfA== 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=VT+9bNaJb5U/5qjKkIuVId2sNqiXfCsoNNkJNF9cROM=; b=mfWQWvggHZit4fYqkNH0sZMpbYY+ZVv3/r4xrRAcav1GG/BRmzjld4+83bDcQWg4G3jb5k1kWlJi6tlfO8fE37/Eq9AYxUg/ZVqWRRgfq8sFggRmewTzpR1bdVP7KezIdC4m0M4HHG1tx9paDyIpIngOPWOwpmViWmr9V+poQsSLS6jklUd9AOPsAfJP4htBKYbC2ea5kGb4NYMBacOZPAHgMd3M5QSpTHka0pXvdvv7Lzw7UeWtLsoHvX+0Wm9OT3icD+lkMQNw84qiLgrcs2XSKWS4KlxMT5HjT0xStcjuvpM3PUkxuJem9C4j/cHTx155XThH5p3tg/rXb2UMuw== 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=VT+9bNaJb5U/5qjKkIuVId2sNqiXfCsoNNkJNF9cROM=; b=q2sXyTsB93zVpd9V/sAqllEQA72amUg2pekG4Z7Udrr5sN3VyBgZDv56sIkiJZvQxfrxyFxk7vLGKrqRxbIybpqGEQY2dEZHngN8w8kdpO+yu3NnJaWfhCpdNBvfc97gt3Ox7JFThHIt4JpeWK9wmcmZMYhG3n3LSe+/a3fS/iA= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:32 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:32 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 05/22] libqtest: Add a layer of abstraciton to send/recv Thread-Index: AQHVbneHp+c4RlezBUGXNefN9Lzx6g== Date: Wed, 18 Sep 2019 23:19:32 +0000 Message-ID: <20190918231846.22538-6-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 61bedc98-488c-41f4-4134-08d73c8ea991 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:81; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Ss5Ty4LCveZQDBkvOrxDU359eszrbLiO1kk0S4bzbGEJiv9z6TiDbeW66mEFD0UrGU37mydeV0vRpzWTOzsKlB4VoG8R5wvVGHdSPwOjQTfsDz7KuP80X+nEMgfbR1ARemgzllA9Rwd2VcAYGiQzK7qrLV3AxWEtFIgmyn2JS2AVczAdi/WJg/naZH01io3y/FvEeQGCYBB/tX2nvDN5fAeX0pHo5N9GLmM8NQNbsKFgN/rx85FG7VjKvPjSv3eYv/KpSbk5HPqsgcTFr8px58I9EdIq1tpDIxsmIFgqgXFX82Zg6mReukQrJP86jG55aacEA6UVlgQc3sOu3OGL545f5F0oDplEiFspMW2ZAMJqN5CjEMur+9iPFuqO/Mn+HqaRHZuY3kKJxc4Faj/NCQbAP9MheJgoFE9xCcUHT18= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 61bedc98-488c-41f4-4134-08d73c8ea991 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:32.7694 (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: TP2qhLR81rhovJeZgLWpcJ8nsQqU958T6ABvNrKjZf3erfWEPbxtYfBwZxoZ3LR2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.71.132 Subject: [Qemu-devel] [PATCH v3 05/22] libqtest: Add a layer of abstraciton to send/recv 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 , Thomas Huth , "Oleinik, Alexander" , "bsd@redhat.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 | 64 +++++++++++++++++++++++++++++++++++++++--------- tests/libqtest.h | 1 - 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 4a7556462d..19feea9e17 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -35,6 +35,15 @@ #define SOCKET_TIMEOUT 50 #define SOCKET_MAX_FDS 16 + +typedef struct QTestClientTransportOps { + void (*send)(void* , const char*, size_t); + void *send_opaque; + + GString* (*recv_line)(void *); + void *recv_line_opaque; +} QTestTransportOps; + struct QTestState { int fd; @@ -45,13 +54,28 @@ struct QTestState bool big_endian; bool irq_level[MAX_IRQ]; GString *rx; + QTestTransportOps ops; }; static GHookList abrt_hooks; static struct sigaction sigact_old; +static GString *recv_str; static int qtest_query_target_endianness(QTestState *s); +static void qtest_client_socket_send(void *opaque, + 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(void *); +static GString *qtest_client_inproc_recv_line(void *); + +static void qtest_client_set_tx_handler(QTestState *s, + void (*send)(void *, const char *, size_t), void *opaque); +static void qtest_client_set_rx_handler(QTestState *s, + GString * (*recv)(void *), void *opaque); + + static int init_socket(const char *socket_path) { struct sockaddr_un addr; @@ -234,6 +258,9 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args) sock = init_socket(socket_path); qmpsock = init_socket(qmp_socket_path); + qtest_client_set_rx_handler(s, qtest_client_socket_recv_line, s); + qtest_client_set_tx_handler(s, qtest_client_socket_send, &(s->fd)); + qtest_add_abrt_handler(kill_qemu_hook_func, s); command = g_strdup_printf("exec %s " @@ -360,8 +387,9 @@ void qtest_quit(QTestState *s) g_free(s); } -static void socket_send(int fd, const char *buf, size_t size) +static void qtest_client_socket_send(void *opaque, const char *buf, size_t size) { + int fd = *((int *)opaque); size_t offset; offset = 0; @@ -379,22 +407,22 @@ static void socket_send(int fd, const char *buf, size_t size) } } -static void socket_sendf(int fd, const char *fmt, va_list ap) +static void socket_send(int fd, const char *buf, size_t size) { - gchar *str = g_strdup_vprintf(fmt, ap); - size_t size = strlen(str); - - socket_send(fd, str, size); - g_free(str); + qtest_client_socket_send(&fd, buf, size); } 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 = g_strdup_vprintf(fmt, ap); va_end(ap); + + size_t size = strlen(str); + + s->ops.send(s, str, size); + g_free(str); } /* Sends a message and file descriptors to the socket. @@ -431,8 +459,9 @@ static void socket_send_fds(int socket_fd, int *fds, size_t fds_num, g_assert_cmpint(ret, >, 0); } -static GString *qtest_recv_line(QTestState *s) +static GString *qtest_client_socket_recv_line(void* opaque) { + QTestState *s = opaque; GString *line; size_t offset; char *eol; @@ -468,7 +497,7 @@ static gchar **qtest_rsp(QTestState *s, int expected_args) int i; redo: - line = qtest_recv_line(s); + line = s->ops.recv_line(s->ops.recv_line_opaque); words = g_strsplit(line->str, " ", 0); g_string_free(line, TRUE); @@ -1327,3 +1356,16 @@ void qmp_assert_error_class(QDict *rsp, const char *class) qobject_unref(rsp); } + +static void qtest_client_set_tx_handler(QTestState *s, + void (*send)(void*, const char*, size_t), void *opaque) +{ + s->ops.send = send; + s->ops.send_opaque = opaque; +} +static void qtest_client_set_rx_handler(QTestState *s, + GString* (*recv)(void *), void *opaque) +{ + s->ops.recv_line = recv; + s->ops.recv_line_opaque = opaque; +} diff --git a/tests/libqtest.h b/tests/libqtest.h index a177e502d9..40fa235a52 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -716,5 +716,4 @@ bool qtest_probe_child(QTestState *s); * Set expected exit status of the child. */ void qtest_set_expected_status(QTestState *s, int status); - #endif From patchwork Wed Sep 18 23:19:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151311 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F6721599 for ; Wed, 18 Sep 2019 23:34:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 42299218AE for ; Wed, 18 Sep 2019 23:34:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="uC7Z3DMG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42299218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjSb-0007YP-Ut for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:34:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33251) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEZ-0000Ki-02 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEX-0002Wu-Om for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:38 -0400 Received: from mail-eopbgr710122.outbound.protection.outlook.com ([40.107.71.122]:60960 helo=NAM05-BY2-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 1iAjEX-0002W9-I9 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bqcIvrsCplMpGpool0fD0awgBogdj3yqkrGr0YDqOqFZbrqbmQHM6AdmRPcVQTAsxRh/3WkhP5OKxm+lcRyfz7Oqb+cGrfv6TVxmHjsVL34Ha7x82dyEnCR5C9tuMgzPkliKE9MpLlxchlm1oBvmsig/Lxw4PmTmAtE9NiNRKjYk19COGZd/+DjE1SBMO1wRlttsOzF6ERLxS4cZUpZXguJx8tKqXRm/4udyLcU9uhrLrSs4KEKaOML+bbUxM9AcNU/vwNM4Cs2ZHhwKSB1m65pJgGXI4xlizG4uYodOUAr2sQ5Fy73+sbqoAQDOA7rI7pcECqfxIFLWLeusHQqK1w== 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=4INRMKvq6QfTgbFoOAKvbfjGL71Nt5vhan5vvp8Ebqs=; b=YTz/xgmiK2Bj07IzvArypUkbNsd/llwqwUtelt8sOI5tbzplHjqgfGFun64vifF22mQOFRLp0tYHRRY0KXSMpxl2dz+CF2JR72GSkxHPzkp0kJhA2iIj9RILy8ezf78/ZZZXQLaIt2dzbtCtei3QUEAWjijGOocEcNYpJ8S8GA6KTU4qHkIOUDtNVguEx3aomx8VlQJnsoy16lnuDZMUvRjZWCW+o9B71S77XLNKkDka3dp65e61z8JxKz0vOhFUpjPSInCjfCnkU74FrS+mGzpiCBBCjUSsvPpftesH+Efn2dTTZ0qLDPG+jzNR+zVvjyyp7fHsiv3kPFY3/sPWVw== 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=4INRMKvq6QfTgbFoOAKvbfjGL71Nt5vhan5vvp8Ebqs=; b=uC7Z3DMGb/O8srEWECGXny/diT9NP9yumOaIJV2B+/bF+BbPbMLThVByAVd3+c1tq/0tCUlZbIz7krAe1m62zhTtpBo1Eo2m7a55lWFBslpbvA7xGUvN+gvC3JgnhZRIZSzODwz64uqsBc5sYPcvHheOzhhxnoqAAoMsGKXetuQ= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:34 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:34 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 06/22] fuzz: add configure flag --enable-fuzzing Thread-Index: AQHVbneHyovnzJrtBU6Jp3gZ4trMkg== Date: Wed, 18 Sep 2019 23:19:33 +0000 Message-ID: <20190918231846.22538-7-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 363a8246-6dd2-4112-43cd-08d73c8eaa2f x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1303; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Lo67xPj/J4LLbtU2Xq3uRdvD/QdYop8px4vgLy0plxlqrlISY1LkGwpdAbEGPp7/9+Ni9nP+owu+gabkmckkRYvIU3F7i1jENh6eumnhPCVYqcSyT5dlyL5WLROGp+DM6ph0mHPpWYihHis4FHniJ55vvzZEao8OZx7tK+xqa7hmqznqyX8nIGReljhs3Pi6lRv6/gG3K8Qz2lOhcERTVaYmeT3JAQN65Oe+bb7HqzLvz7oFATzm6OkW76RgvKmO1o99mNgDaj0qRADy/hzB87impUXQNSIEZcWN01dVv8VjLgiKaOcdElYh8Y4kcxeVm/Oe3fMMcLmv/bRUPKKOwYBYj/lGP/aLULf0MC0b/jHupTzxylv9s++Fa5mtey228cq+5QJWjK5RP3+Qxrv8Sl08MfqwJzcM/u5Ubszz2Dw= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 363a8246-6dd2-4112-43cd-08d73c8eaa2f X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:33.6010 (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: EimLHxeIyuKFqpi9Aiwr4kLk8xyNhBgvy0WrcFGrVSgOeVKTKYGYyWgsR6UCsGEC X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.71.122 Subject: [Qemu-devel] [PATCH v3 06/22] fuzz: add configure flag --enable-fuzzing 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexander Oleinik --- configure | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/configure b/configure index 30aad233d1..775f46f55a 100755 --- a/configure +++ b/configure @@ -498,6 +498,7 @@ libxml2="" debug_mutex="no" libpmem="" default_devices="yes" +fuzzing="no" supported_cpu="no" supported_os="no" @@ -1521,6 +1522,8 @@ for opt do ;; --disable-libpmem) libpmem=no ;; + --enable-fuzzing) fuzzing=yes + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -6429,6 +6432,7 @@ echo "capstone $capstone" echo "libpmem support $libpmem" echo "libudev $libudev" echo "default devices $default_devices" +echo "fuzzing support $fuzzing" if test "$supported_cpu" = "no"; then echo @@ -7258,6 +7262,10 @@ fi if test "$sheepdog" = "yes" ; then echo "CONFIG_SHEEPDOG=y" >> $config_host_mak fi +if test "$fuzzing" = "yes" ; then + FUZZ_LDFLAGS=" -fsanitize=address,fuzzer" + FUZZ_CFLAGS=" -fsanitize=address,fuzzer" +fi if test "$tcg_interpreter" = "yes"; then QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" @@ -7339,6 +7347,11 @@ if test "$libudev" != "no"; then echo "CONFIG_LIBUDEV=y" >> $config_host_mak echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak fi +if test "$fuzzing" != "no"; then + echo "CONFIG_FUZZ=y" >> $config_host_mak + echo "FUZZ_CFLAGS=$FUZZ_CFLAGS" >> $config_host_mak + echo "FUZZ_LDFLAGS=$FUZZ_LDFLAGS" >> $config_host_mak +fi # use included Linux headers if test "$linux" = "yes" ; then From patchwork Wed Sep 18 23:19:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151305 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5CC914E5 for ; Wed, 18 Sep 2019 23:30:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BAB97218AE for ; Wed, 18 Sep 2019 23:30:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="DdhzLdWT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BAB97218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjOt-0004E0-89 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:30:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33240) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEY-0000Io-As for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEX-0002WS-2A for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:38 -0400 Received: from mail-eopbgr680129.outbound.protection.outlook.com ([40.107.68.129]:42238 helo=NAM04-BN3-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 1iAjEW-0002Vm-Sc for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=do1fiXYn9zn7VH8g0T5kLXVmZ2nhZfXRNgiJjY+Trtgu/qHp5cgB25nQQHC+jVfRtelHahTrsL9PBGeKyWI1JTe49hYTjG8NRLlGtAnV/cEFuRb6Jv0JLKTf+s/nkO4ZyV82gIe/09enAEfyt1YJDLFx6W25H75Nan/Avn9bk+FjqrWYXgWR5+CNKMV+tyz3BNgSvMbzAlK9a7UrG5kzg2A38Qpq7IhssM8x3ryppJAe389iI1oM6cyScxG2WHF/FICnYXUgX5h5BR0VPkemkhW9+28GITuuIi4ffceSS/QblJt4jmosDuAdPzBP49W75ljTvtPIgmVGc+xUyHu8mA== 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=2izqZJkASHESNPbDHoHBQTjXBKSGF86bMlZIo/9vuKo=; b=gqpLAaemrmcuVPscUB0GqnX6JL+lKsgZ6vYZtAPav9o2FtDMYaZXJFx5INky9o/RgV2UaYjOEdkadV2bF4yn/FK9kR4Dpp9NHWmk+Ay8KyS71+tPFXXhBPph0aHNWaeiIhYdXxQLNHZvV4Yh0Uxwi2YSdN/Ee4cYJ+W+A01X8aomnXPJU13+5b6oGG/W/chme4+YbD3lOHXzRJCzyQ8l0NpkAGSjrE+uQ80ynoFqTTMBZ4XmjigQO1RHZ5ch/4327JLvo1qdb/M9V+2uvVc7nRlzDJ3aJ/JV4VBqWYMd6gZqZ8EOMue37OQea+Q+UVVSbEK1E0bAoYQevXnIjNiIWg== 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=2izqZJkASHESNPbDHoHBQTjXBKSGF86bMlZIo/9vuKo=; b=DdhzLdWTYYnAuxIMRjAzR8m0oFE8X66uBkskEDodwFp3eP+8u2CFA31CdrebV3+EoTbA28J5Nzw7mjy2ZolxhAbsevOEfFGDAElZH7Q1W79YoZwSRoeD1F/mOBRrB822lzZp5eK0B0NriSyFKRQ2iOECsgAmf3UpvuFZIHOkm9w= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB2695.namprd03.prod.outlook.com (10.173.43.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.15; Wed, 18 Sep 2019 23:19:35 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:34 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 07/22] fuzz: Add target/fuzz makefile rules Thread-Index: AQHVbneI23stXmJTGUWQ3vuiIwgZRA== Date: Wed, 18 Sep 2019 23:19:34 +0000 Message-ID: <20190918231846.22538-8-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: e130272c-1c22-49ec-a276-08d73c8eaab5 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB2695; x-ms-traffictypediagnostic: CY4PR03MB2695: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1227; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(396003)(366004)(136003)(376002)(346002)(199004)(189003)(2501003)(36756003)(86362001)(316002)(2351001)(6916009)(3846002)(6486002)(6506007)(6436002)(76176011)(386003)(52116002)(88552002)(75432002)(2906002)(99286004)(5660300002)(5640700003)(6116002)(6512007)(4326008)(25786009)(7736002)(186003)(50226002)(305945005)(102836004)(66476007)(446003)(26005)(2616005)(476003)(66446008)(478600001)(71190400001)(14454004)(64756008)(71200400001)(66066001)(14444005)(786003)(8676002)(54906003)(1076003)(486006)(11346002)(66556008)(66946007)(8936002)(81166006)(81156014)(256004); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB2695; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Crnj6rxPqUIODn02d6jFUmV5lN2PpVnYGnR20NyhCcxVN4RfGjNJ346Ex6jV3Ui8Yg0BCsfStNrh20F1JMRTPQUpsdVOZ4hWuvYboV+aDIUXBg/C6D3Akka/2hISkaiaQIB5FoSudcoNZUokRHZiWwglgn7cqHgDubyu9//tmEO6R02PwbiOGRRY6a8ihOANqb3oSJ5e8oCtHvlzsTk6iCp3P6dMYPYUS4k05ybwIPtGUMWp83xV5568bqF9ltErg8r+e9ME666NbH8rbkTAYoGmZxj6NHCTsOdduzzA1YrZqyXYUoGnRCy/6v6Nj+Qt/ZswrE5nYvvRYN87GPkMVjH8IThMMpjjt26opIu+kd1RY+4WU3F53tdJhlNpuH5+oaWpzASqcuFtKc0mxt7QfHTOluiG37gZ+ummbHZ+cEQ= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: e130272c-1c22-49ec-a276-08d73c8eaab5 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:34.4976 (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: gcyRLXctN6SFZU/sNV1rWI9YRnXffjBgb7qf00JZFnN+pDOHA33njmps/a5C/zGb X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB2695 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.68.129 Subject: [Qemu-devel] [PATCH v3 07/22] fuzz: Add target/fuzz makefile rules 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexander Oleinik --- Note that with this you cannot configure with --enable-fuzzing to build /all targets. Even if you could, you would need to clean all of the *.o between builds, since fuzzing adds instrumentation CFLAGS. Makefile | 15 ++++++++++++++- Makefile.target | 16 ++++++++++++++++ tests/fuzz/Makefile.include | 4 ++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/fuzz/Makefile.include diff --git a/Makefile b/Makefile index f628783571..3a43492340 100644 --- a/Makefile +++ b/Makefile @@ -453,7 +453,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","$@") -TARGET_DIRS_RULES := $(foreach t, all clean install, $(addsuffix /$(t), $(TARGET_DIRS))) +TARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), $(TARGET_DIRS))) SOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES)) $(SOFTMMU_ALL_RULES): $(authz-obj-y) @@ -465,6 +465,15 @@ $(SOFTMMU_ALL_RULES): config-all-devices.mak $(SOFTMMU_ALL_RULES): $(edk2-decompressed) $(SOFTMMU_ALL_RULES): $(softmmu-main-y) +SOFTMMU_FUZZ_RULES=$(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 @@ -511,6 +520,9 @@ subdir-slirp: slirp/all $(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \ $(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY)) +$(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \ + $(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY)) + ROM_DIRS = $(addprefix pc-bios/, $(ROMS)) ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS))) # Only keep -O and -g cflags @@ -520,6 +532,7 @@ $(ROM_DIRS_RULES): .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.target b/Makefile.target index 5e916230c4..6065989964 100644 --- a/Makefile.target +++ b/Makefile.target @@ -227,6 +227,22 @@ ifdef CONFIG_TRACE_SYSTEMTAP rm -f *.stp endif +ifdef CONFIG_FUZZ +include $(SRC_PATH)/tests/fuzz/Makefile.include +include $(SRC_PATH)/tests/Makefile.include + +fuzz: fuzz-vars +fuzz-vars: QEMU_CFLAGS := $(FUZZ_CFLAGS) $(QEMU_CFLAGS) +fuzz-vars: QEMU_LDFLAGS := $(FUZZ_LDFLAGS) $(QEMU_LDFLAGS) +fuzz-vars: $(QEMU_PROG_FUZZ) +dummy := $(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=qemu-fuzz-$(TARGET_NAME)$(EXESUF) +fuzz-obj-y = $(libqos-obj-y) +fuzz-obj-y += tests/libqtest.o + From patchwork Wed Sep 18 23:19:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151289 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2609316B1 for ; Wed, 18 Sep 2019 23:21:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F03F9218AF for ; Wed, 18 Sep 2019 23:21:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="H8HIecMM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F03F9218AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjGk-0002o8-L9 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:21:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33243) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEY-0000J0-EX for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEX-0002Wh-D5 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:38 -0400 Received: from mail-eopbgr680129.outbound.protection.outlook.com ([40.107.68.129]:42238 helo=NAM04-BN3-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 1iAjEX-0002Vm-85 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XDWVh8CLMuXnqwEQaUph15SOI9eV5uq87I7YpyKmGa6Tu04TOvSYReIh+vGwWeYogr47Ddpyig6Ph0LSAiXStq8EedViwMyK0sx3y1wOaAby0zxrTUy44OASWAs44NHr6VMXT9Z4tKp7Otcfew8E3cglQa0Fsi2KZASnENM9AdYbYSdVW/E6Y4VhKp5bYNLXRyVdjoUXPhh8UXJv5n6UXJ14EL8Wo53Q8JwbTTTA8D8XWEfq+5OBYQLgX9uzL9H/FakVVLqLMlr8YvTNYnAmhhcQI02N4StoQS7jdEIzIxHygF8/dr29wGPv4OG9COKJJDLA+59Ks8lVv+/LYDS2BA== 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=pgJ+FDSetf9Xbcixba+4dxJmPzmsrIkckesKqeaQtJM=; b=fM1kmZNk9XZ9hmOykZOfny64wdG2DcQqsLSgGFBZcGSk3N49YkvPwnbyywZgNDGnrJVsSlTOQ3WgeM2cNZ9T+FDmjsSKmDvpy2NeMBI+UvRFkKD5SY+FSebHXUYN8UmTUTFOUceN6ggsD9FNweI59BfmSO3AZc+nn5QkTZJmQwsTYYrNo4FUR5S0z3LK48ewSh2Voh6ghzzVvBBVBcUDicK69U673MRkwLJq88F0UugmowAtNuJPrdws1KWK2OqNDKDnpXHvKJBMXWFYWD1Q5HBztFEXALDvTU6PyAEN9izo7Dy17KQ2hxb0hIADp+YG7VGdFOmBdd3F8P7kDQkqeQ== 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=pgJ+FDSetf9Xbcixba+4dxJmPzmsrIkckesKqeaQtJM=; b=H8HIecMMQ5EGkzmgbcxRIdyHUcDIxKc4aBeHu7YwcOTQD/2WeFdh/NZqkB7hoW6WUxwLGsrAzLdqPOxTlH/+GyAye+kqB1XoKctMZFVM2lSv+q3DxKC3L/8KcQ2VNSdTbsRKduyrGKuAufbcNsHXhlhHNGHgnV53IoATbMLbqYM= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB2695.namprd03.prod.outlook.com (10.173.43.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.15; Wed, 18 Sep 2019 23:19:35 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:35 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 08/22] module: check module wasn't already initialized Thread-Index: AQHVbneIl3rR1NcDEEWCktt8ha+RNw== Date: Wed, 18 Sep 2019 23:19:35 +0000 Message-ID: <20190918231846.22538-9-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 00b2fcf6-8c94-466a-b300-08d73c8eab3b x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB2695; x-ms-traffictypediagnostic: CY4PR03MB2695: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4303; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(396003)(366004)(136003)(376002)(346002)(199004)(189003)(2501003)(36756003)(86362001)(316002)(2351001)(6916009)(3846002)(6486002)(6506007)(6436002)(76176011)(386003)(52116002)(88552002)(75432002)(2906002)(99286004)(5660300002)(5640700003)(6116002)(6512007)(4326008)(25786009)(7736002)(186003)(50226002)(305945005)(102836004)(66476007)(446003)(26005)(2616005)(476003)(66446008)(478600001)(71190400001)(14454004)(64756008)(71200400001)(66066001)(786003)(8676002)(54906003)(1076003)(486006)(11346002)(66556008)(66946007)(8936002)(81166006)(81156014)(256004); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB2695; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: jxR9/qZ+6YW4O01lbq39j//hbCfjMWQVCzafJnOpwdbmIudLMGSmTmW0jX+l+o+g+5PS3SstrECLqXlBabA9ZjhcmiC3giPgqyFuhCenZ2QSitH3f+jjsbxQAFIW/tgfpTTNwObvzqKmt9x77PQeU9Gno8iaIGhA+HvdOIFjLdQkXfWH1P99pBXnIes5Ic2Bm7VU260ZbP997X0seJ32fRmh7k6iVMfBcoq0QXBRZuEHQM+vsvw77aXlhiyUqF5dFC8CfqQ9XhdfGGwPbHiVv0RNNZ7Dl5jnvq86VDx6jrJRrGBit7Tv2vktJiII10rs9U8RfJPADPzXsLAjTbF/kn6A2U3JiVeX18A7wQwfmCBUzbxLaTczzVA8D2ge+Bg+T5fmMqmnSBr5AqxMfz1ue5Ez+f6MkAI5h2gTRlyKPTQ= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 00b2fcf6-8c94-466a-b300-08d73c8eab3b X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:35.4202 (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: AJcXg6hiMwN8+nR9XNh0/TVNgLPjNVWEFMgpmsifVocpgz+/RIszQ1gb5DjVtzQ5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB2695 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.68.129 Subject: [Qemu-devel] [PATCH v3 08/22] module: check module wasn't already initialized 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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: 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; static ModuleTypeList init_type_list[MODULE_INIT_MAX]; +static bool modules_init_done[MODULE_INIT_MAX]; static ModuleTypeList dso_init_list; @@ -91,11 +92,17 @@ void module_call_init(module_init_type type) ModuleTypeList *l; ModuleEntry *e; + if (modules_init_done[type]) { + return; + } + l = find_type(type); QTAILQ_FOREACH(e, l, node) { e->init(); } + + modules_init_done[type] = true; } #ifdef CONFIG_MODULES From patchwork Wed Sep 18 23:19:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151317 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1AE614ED for ; Wed, 18 Sep 2019 23:36:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77B95218AE for ; Wed, 18 Sep 2019 23:36:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="zaIlNaeW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77B95218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjVK-0001zO-N5 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:36:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33258) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEZ-0000Lt-D7 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEY-0002XF-62 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:39 -0400 Received: from mail-eopbgr710122.outbound.protection.outlook.com ([40.107.71.122]:60960 helo=NAM05-BY2-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 1iAjEY-0002W9-07 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MEcXUriOPOWyKbLNAjQIMk5VnwoDg7E55ZPC2/z9nQlkuzrxNu5wadTf1DvDVhygxI87N9ULfjeB98sF7303MU/a33bNjgNBPICAWLiMkTuJ559k4AB11L/VHpSZzy2S18cUo3rY4+86nAj2+BsA9S52dWVWUxdBybkarmZWrIViGHg2HxqbdWQ5P9rTjp1hyzuUmQGa18vKRds91BNKHhroab7ac9JSGL9dmBThQUJ4874VLMc5u9ZZusM2u4W+gWVv9zf9aKwIHny4yiVqO2uCxOhRCcradrBD1bCdYdj+6Ku87Ax8g8PNVoFSLZ3e+7mLi5c6b+kSMcEP8CVbWw== 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=qs2vUqlO63W35R2m/O8qs57+ehV/lp7PFr/ov71kVxk=; b=aj+A09g/BxUldwGnSSO468GYmsUP5uCrB3Py06wz2xMnnAcO46hLXe1IgwMucVHegTOihandiv4tppOyCvk2O4DdPWzulXFiqCihMeT+8X3VBJ4ayh1ZmgO6fYo0c1nmmpMipOwxstXNak24SZNMfdg7dvda+086V4PYGffKGMXAdheIo1lZ7+IN3bTRfk4WB4DZxSVocKj6wn1FgHB0c56mtzBun8+QS29tfr9TuTfX3pR0OrfvsdmRNvSOTLJlH6cxx1aeOtO2i845hGuCtGIqCz9sNOohojQePWPxhOT4DDnxNt17C+ZTDx/TGcHmg1ClDNndHjho8hmXZhIisA== 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=qs2vUqlO63W35R2m/O8qs57+ehV/lp7PFr/ov71kVxk=; b=zaIlNaeWIi8OvLaYy+TbVsmsrjqSvt1w6nB8iS3DZcyt7ri/ZCybrm/Snvp4ZU8Okeozk9SaQlx05GsTyvsB2YsgqyQcGTtMeHAxsjoT0zAojuA9kI3YxN/vebTH39AqEqrQF6bdr3bP2E2xAOPHFqQA0lncuUEAtJNq78WwNX0= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:36 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:36 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 09/22] qtest: add in-process incoming command handler Thread-Index: AQHVbneJ6g+hm7m5kkefZGXqJWfgrg== Date: Wed, 18 Sep 2019 23:19:36 +0000 Message-ID: <20190918231846.22538-10-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 85cbcc6a-6042-4cb3-67e5-08d73c8eabd0 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1303; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 0YlgB73ZfATC3tssbe/fu7pBSVVo6/PDy25K1LmGymXDWl9rI+9RCQGPYpP6bjyt/nbp7knOPHUhgqxcojetl2AOEbpGq0sbGkzeVrly4C2bc1H/4rezz/JlHvp7jvE5sh+s/p3709XKxL+3JEEhcEkpoDt7RSW8zCLjKQ5dCRzkRASWGi0+IUxXN71KdjBs2daqkOEK/V+EhRF1FuWG152MHXPnsKcvyZEC9ZVEWQV8+ARj5AsF6BYmxMxrLtXahlUm/KzYcHg05YSLtMuIaVZ87dfdpWbimClQ6VXFDlyUuhK1MeYUzsvlDuAIWb89lGIDIsHXXDJonVtk5Dc3Id/7Ddvs/nRvkw27/keXmEtnsk4TZaACOxwDZA7fs2q8OG+uxampO2ei9E0hcDuTpFCXk8G3rxJwikjX/30v28U= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 85cbcc6a-6042-4cb3-67e5-08d73c8eabd0 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:36.5097 (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: /3OM6nuzWFodOowKKntfBURVZ1Tv+i6zfslOOugx9FZjU7uuNVaCm5rCspncYFha X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.71.122 Subject: [Qemu-devel] [PATCH v3 09/22] qtest: add in-process incoming command handler 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 , Thomas Huth , "Oleinik, Alexander" , "bsd@redhat.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Stefan Hajnoczi --- include/sysemu/qtest.h | 1 + qtest.c | 7 +++++++ 2 files changed, 8 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 char *qtest_log, Error ** 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); #endif diff --git a/qtest.c b/qtest.c index ae7e6d779d..44a916485f 100644 --- a/qtest.c +++ b/qtest.c @@ -802,3 +802,10 @@ bool qtest_driver(void) { return qtest_chr.chr != NULL; } + +void qtest_server_inproc_recv(void *opaque, const char *buf, size_t size) +{ + GString *gstr = g_string_new_len(buf, size); + qtest_process_inbuf(NULL, gstr); + g_string_free(gstr, true); +} From patchwork Wed Sep 18 23:19:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151319 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26BAC14DB for ; Wed, 18 Sep 2019 23:38:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF743218AE for ; Wed, 18 Sep 2019 23:38:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="QomFLKn/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF743218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjWX-00039v-6F for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:38:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33282) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEa-0000OI-KH for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEZ-0002Zf-HU for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:40 -0400 Received: from mail-eopbgr710133.outbound.protection.outlook.com ([40.107.71.133]:31520 helo=NAM05-BY2-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 1iAjEZ-0002XS-9f for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C308pU3/eCfvuQm0zabaV03ZlNS4h65N/Kbb+/0arHO3u3JutIvXyzkuolm+STLx7hWcOZ6J+8tsSturU12LhdLYztsT94nha+iyYieTSr2+exvhXXuKNe1zI+fq4wRVoCpDke3Bg4cffc1s/jkNXkY1ZsP54Mv682ySZDO+4i49uWaN/7otMS08FbwELTCxB01rRLam2k8o2wd96W2DzLQCebVXOD2lcOttXgxEZLPpRh0hYJal4Ai0WyLqDby4DFKT7c1N0+cQITlR66uGavsDCiJqmA1pOC2XpaEUEqv8UnPfB1jUTV+mHJGFodW3Lwp7nGT834iMq4M4+aJiIg== 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=/p1QzYibvxgsgwaKeWSS4iZiMu6nVwgS1ce72zdQKN8=; b=KOMFpfkDqnK/omwJye5rEU04ujMaOK6Lbh+aebOfaAR2EsGqP4SFA2qdrkMhuBA4OrWu6z7ObsYwEh9ZTehfDoDcDPiw8+HbCJ2iGp7GTDvYgRKWnPXaOeS63ol8HU13u8Q38Iy7vzQbmessYs6GyJjC3Bc+g4JKpbsqds0kqdoLz/JgKuC31VuLiGECrYqmCOpvmK2x4YCe1Im/ns7AkwOluRBZYRI9eYErwOEMIxDEb/YgjLXkUuGAI0ZXykAwTgTHgXYhE2PQdB0TzopnDPm9M8xqw08dAees0YkTLqI13bKK43gyQPk/MyhZh6KOyD0u8hZIiwO1LfqUjwmRCQ== 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=/p1QzYibvxgsgwaKeWSS4iZiMu6nVwgS1ce72zdQKN8=; b=QomFLKn/tWKlTLquVQ5orS03fPSYaEO6RPTYM1dpBcR6QJMYUCNKtPzNX9aFE3Qur8I2u5y0rWlj9iUc3qVISUcYDSrYLpn6Ij9pMFRlt6bJpypkR9lsPp8d13/Mb/uZSYp6L3wzETC+315dK49/mKryn/SCsMRoSkEniCOfPks= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:37 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:37 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 10/22] tests: provide test variables to other targets Thread-Index: AQHVbneK1DI7wM20KUi8FpcmDyQxBg== Date: Wed, 18 Sep 2019 23:19:37 +0000 Message-ID: <20190918231846.22538-11-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 6cb57690-b2ce-4584-c529-08d73c8eac7a x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(14444005)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 2Dt4xdyyGNelqVHsP2gzH9Eh2aektxmPrp1l0wAkciqH6v9sH3RTKbTmsfQxVTLJeASNSbndfyu2dy7EU6qrxyKxTw7b4NZ8gP0OKMsMwrpl3llz40I0wMxAQ2bNvM9XgOsJp4szJtAL6ij56PyQ4rLVnO991LfA1mWlrUtdes3HdwfoCR4xWsGDzf8brhNa+XLvKnCmHAQFzxGvDzcveJVBbEzBBPt7xBE07NYIyyJLN6J2qbsGV58BcY1ABFKQU9/N+StjTGjyBU1IKSE/yoGJn7u10B/53tQM4yOQ1afhJKj0R6InPUXO0b1pw/jnfxfngQj8jb+5CbOAgSKTGkq0FIu2xXx77I14Al+kqLmdhnCB63K3AiE0o/XNSGflkh6KS8xsQAL0w51Ep3piUrRLPTv7AAu6n2oCLOiY0mM= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 6cb57690-b2ce-4584-c529-08d73c8eac7a X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:37.5582 (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: ln3VSPqwd7jg+767FgqotgSwC8iINl3/HTFdGE0QaIwZaDRrPNHNGJH7o8Q/NwJK X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.71.133 Subject: [Qemu-devel] [PATCH v3 10/22] tests: provide test variables to other targets 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- tests/Makefile.include | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index b39860a8d0..a9b3c36259 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -27,7 +27,6 @@ check-help: @echo "Default options are -k and (for $(MAKE) V=1) --verbose; they can be" @echo "changed with variable GTESTER_OPTIONS." -ifneq ($(wildcard config-host.mak),) export SRC_PATH # TODO don't duplicate $(SRC_PATH)/Makefile's qapi-py here @@ -860,6 +859,8 @@ tests/test-qga$(EXESUF): tests/test-qga.o $(qtest-obj-y) SPEED = quick +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_human # stops at the first failure unless -k is given on the command line From patchwork Wed Sep 18 23:19:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151301 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7777112B for ; Wed, 18 Sep 2019 23:27:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BDCBA218AF for ; Wed, 18 Sep 2019 23:27:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="NGZUiBMf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BDCBA218AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjMG-0001Uy-Dt for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:27:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33295) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEb-0000PT-H0 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEa-0002a2-0o for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:41 -0400 Received: from mail-eopbgr710133.outbound.protection.outlook.com ([40.107.71.133]:31520 helo=NAM05-BY2-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 1iAjEZ-0002XS-PE for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HvIs9TGto3nXa9MQGYqeMOcqn03d+Rb18VDd+1inUFHfzet2Ngz+X3ifQfzDLp0pEMENwXXa1BAvyzppWix2xXfGcseZ4jRnN0q4fItlGBxdQmGrmczvtDK5y4WcYVXleOPTuWGwv85lgaNlGCcBVkJH9+Yu9ET+a48YfKNJdz4lgeTQzV+owoVRgx7HPGRpYnrQLaVjqNqQO3cH5URkfR6QJTayS/vDGwGBK1HjFDWXgkOJ9lI7mk7DcOUbkvCf3DMkauclVrkr1FqSQpLIwV+reXvQiSC3KXIywmZzWRork4AeQuF2G3m+VXJIZ6WGEgtktmQx5CgO79S74LTD4w== 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=2sfnJq6ByXF9F31MH8yL3+7KkAM2NItGiWj53YvImZA=; b=ERkRbGG9hkOz+B5rnaV6C+RWrCPSZzqxj4iKCwGnqASLmgcpb+JeWyOZiOVui7PqD2eNMFKwDfkfdhtLtrzY72QT5ebH9IrloyZySI8ZP8iM43kLhaLLo1DbO3dMVCWT7mrm/5yGIYfcFEr6ywnjCudRXIZwR7kiFnyRyHqGH00JpqoLXFSjYr+/13iFk8wWxVi+S/yAw5ALxUZ7q5GUYBok6rEjc4ElYdcCKaPeLsQd2vVpnZqJg2Tx4cgShTcK12a6BPtulLyepj2ynSWR33UfPxcCKYXt4dMdN0Wq01BpnOvHMsjylNtEJ3xj2KBHfp640WJGQ4dvSM6rQ/ANvg== 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=2sfnJq6ByXF9F31MH8yL3+7KkAM2NItGiWj53YvImZA=; b=NGZUiBMfbz/R6fbTKU+436Wi9GNGylI9z7xQwzGshIxN56oWAkF2F2EHZHmc9DalDDLQD7Q9KIgjCNWALh5lcr19NFrjJcg5NvT5LgmxAPfaw7tdiEP14dGIwDGHTX+6CWhkdkxVv8hg5mjFZxTZi91p04TiuI6d1X62QmtELd0= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:38 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:38 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 11/22] libqos: split qos-test and libqos makefile vars Thread-Index: AQHVbneK8atkP2NG50ioy6pVD31Geg== Date: Wed, 18 Sep 2019 23:19:38 +0000 Message-ID: <20190918231846.22538-12-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 6d088dde-b377-4d88-3473-08d73c8ead14 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2150; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: TKiUTbioU8HHb5TS8OzblQqlvt/GrgBxYLei87tOJb51LupwoKx/4JIOvkft29a2AMRAKc80bGOOi7AJ8LAUSwIIL8fEDWDvgCaYAlNZSimjsFrAWMLs4+SqtjaHwPHwvaCPqVmYWm2AiwwK3lIDpkj4AE3JIaGbLB3vJVlEK1zQaK/q3/3VLs1Dmil029Ee8wp0S9p6f43tKAZA8ze57qr7AQypsMkiUMTBxtM8ST0bMJwfmPUqsPT0HGWInQIuc0QCSBZI73teRwVN6jjoddCIdIfaLM/2+lUKCkCLFIQEp+YyCUHl7gy1AKvIwjZ7nJYa4HJGhz3r2VMEOIdapGUCvQ6chaVgFyBqt/WUdeL5YvHQ2NoPGoSivBdLeVdq1GKtMHw7GTbErB2nKGxB2nFAo0H6R5AJtzc5KLt6EE4= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 6d088dde-b377-4d88-3473-08d73c8ead14 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:38.4968 (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: rjEoljEKcpB/sbaVDQJ5MnEnVFihmKIjouB9hwvNqOpf9WpgHNLmtdL1fRwkV+1p X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.71.133 Subject: [Qemu-devel] [PATCH v3 11/22] libqos: split qos-test and libqos makefile vars 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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: Thomas Huth --- tests/Makefile.include | 70 ++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index a9b3c36259..da665ca7eb 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -687,51 +687,53 @@ tests/test-crypto-block$(EXESUF): tests/test-crypto-block.o $(test-crypto-obj-y) libqgraph-obj-y = tests/libqos/qgraph.o -libqos-obj-y = $(libqgraph-obj-y) tests/libqos/pci.o tests/libqos/fw_cfg.o -libqos-obj-y += tests/libqos/malloc.o -libqos-obj-y += tests/libqos/libqos.o -libqos-spapr-obj-y = $(libqos-obj-y) tests/libqos/malloc-spapr.o +libqos-core-obj-y = $(libqgraph-obj-y) tests/libqos/pci.o tests/libqos/fw_cfg.o +libqos-core-obj-y += tests/libqos/malloc.o +libqos-core-obj-y += tests/libqos/libqos.o +libqos-spapr-obj-y = $(libqos-core-obj-y) tests/libqos/malloc-spapr.o libqos-spapr-obj-y += tests/libqos/libqos-spapr.o libqos-spapr-obj-y += tests/libqos/rtas.o libqos-spapr-obj-y += tests/libqos/pci-spapr.o -libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o +libqos-pc-obj-y = $(libqos-core-obj-y) tests/libqos/pci-pc.o libqos-pc-obj-y += tests/libqos/malloc-pc.o tests/libqos/libqos-pc.o libqos-pc-obj-y += tests/libqos/ahci.o libqos-usb-obj-y = $(libqos-spapr-obj-y) $(libqos-pc-obj-y) tests/libqos/usb.o # Devices -qos-test-obj-y = tests/qos-test.o $(libqgraph-obj-y) -qos-test-obj-y += $(libqos-pc-obj-y) $(libqos-spapr-obj-y) -qos-test-obj-y += tests/libqos/e1000e.o -qos-test-obj-y += tests/libqos/i2c.o -qos-test-obj-y += tests/libqos/i2c-imx.o -qos-test-obj-y += tests/libqos/i2c-omap.o -qos-test-obj-y += tests/libqos/sdhci.o -qos-test-obj-y += tests/libqos/tpci200.o -qos-test-obj-y += tests/libqos/virtio.o -qos-test-obj-$(CONFIG_VIRTFS) += tests/libqos/virtio-9p.o -qos-test-obj-y += tests/libqos/virtio-balloon.o -qos-test-obj-y += tests/libqos/virtio-blk.o -qos-test-obj-y += tests/libqos/virtio-mmio.o -qos-test-obj-y += tests/libqos/virtio-net.o -qos-test-obj-y += tests/libqos/virtio-pci.o -qos-test-obj-y += tests/libqos/virtio-rng.o -qos-test-obj-y += tests/libqos/virtio-scsi.o -qos-test-obj-y += tests/libqos/virtio-serial.o +libqos-obj-y = $(libqos-core-obj-y) +libqos-obj-y += $(libqgraph-obj-y) +libqos-obj-y += $(libqos-pc-obj-y) $(libqos-spapr-obj-y) +libqos-obj-y += tests/libqos/e1000e.o +libqos-obj-y += tests/libqos/i2c.o +libqos-obj-y += tests/libqos/i2c-imx.o +libqos-obj-y += tests/libqos/i2c-omap.o +libqos-obj-y += tests/libqos/sdhci.o +libqos-obj-y += tests/libqos/tpci200.o +libqos-obj-y += tests/libqos/virtio.o +libqos-obj-$(CONFIG_VIRTFS) += tests/libqos/virtio-9p.o +libqos-obj-y += tests/libqos/virtio-balloon.o +libqos-obj-y += tests/libqos/virtio-blk.o +libqos-obj-y += tests/libqos/virtio-mmio.o +libqos-obj-y += tests/libqos/virtio-net.o +libqos-obj-y += tests/libqos/virtio-pci.o +libqos-obj-y += tests/libqos/virtio-rng.o +libqos-obj-y += tests/libqos/virtio-scsi.o +libqos-obj-y += tests/libqos/virtio-serial.o # Machines -qos-test-obj-y += tests/libqos/aarch64-xlnx-zcu102-machine.o -qos-test-obj-y += tests/libqos/arm-imx25-pdk-machine.o -qos-test-obj-y += tests/libqos/arm-n800-machine.o -qos-test-obj-y += tests/libqos/arm-raspi2-machine.o -qos-test-obj-y += tests/libqos/arm-sabrelite-machine.o -qos-test-obj-y += tests/libqos/arm-smdkc210-machine.o -qos-test-obj-y += tests/libqos/arm-virt-machine.o -qos-test-obj-y += tests/libqos/arm-xilinx-zynq-a9-machine.o -qos-test-obj-y += tests/libqos/ppc64_pseries-machine.o -qos-test-obj-y += tests/libqos/x86_64_pc-machine.o +libqos-obj-y += tests/libqos/aarch64-xlnx-zcu102-machine.o +libqos-obj-y += tests/libqos/arm-imx25-pdk-machine.o +libqos-obj-y += tests/libqos/arm-n800-machine.o +libqos-obj-y += tests/libqos/arm-raspi2-machine.o +libqos-obj-y += tests/libqos/arm-sabrelite-machine.o +libqos-obj-y += tests/libqos/arm-smdkc210-machine.o +libqos-obj-y += tests/libqos/arm-virt-machine.o +libqos-obj-y += tests/libqos/arm-xilinx-zynq-a9-machine.o +libqos-obj-y += tests/libqos/ppc64_pseries-machine.o +libqos-obj-y += tests/libqos/x86_64_pc-machine.o # Tests +qos-test-obj-y = tests/qos-test.o qos-test-obj-y += tests/ac97-test.o qos-test-obj-y += tests/ds1338-test.o qos-test-obj-y += tests/e1000-test.o @@ -763,7 +765,7 @@ check-unit-y += tests/test-qgraph$(EXESUF) tests/test-qgraph$(EXESUF): tests/test-qgraph.o $(libqgraph-obj-y) check-qtest-generic-y += tests/qos-test$(EXESUF) -tests/qos-test$(EXESUF): $(qos-test-obj-y) +tests/qos-test$(EXESUF): $(qos-test-obj-y) $(libqos-obj-y) tests/qmp-test$(EXESUF): tests/qmp-test.o tests/qmp-cmd-test$(EXESUF): tests/qmp-cmd-test.o From patchwork Wed Sep 18 23:19:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151323 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F1FB14DB for ; Wed, 18 Sep 2019 23:41:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C8132218AE for ; Wed, 18 Sep 2019 23:41:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="6GPZrRNH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8132218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjZy-0005Ti-1G for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:41:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33323) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEd-0000Sa-QC for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEb-0002b3-Jf for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:43 -0400 Received: from mail-eopbgr700132.outbound.protection.outlook.com ([40.107.70.132]:29345 helo=NAM04-SN1-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 1iAjEb-0002aR-8h for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gQnnJGHWM8AkQT47FzzVvfHwdFDRci21096smhJjxDF3R9r8n6yacatHp1hoI0LKafXNZgWBxdFxXpXMphHNKTU+BBTStr7gMd6GeJe7ivelmqZeno4vqvrvEtMDHJ8NkOoqNZPsVguP4Y8m7ZtPDzaaMfYJ4ROyp1KJD02R7e2D0PEAWRoQ0kD3HKctc+X2HgFsPw+YwcBVnOnvSm3q8DdzUinX/zXYhwCgVEqG+daal8jJQQtrB2foox4UAhrJVSsMGXCD5obWTjv5nDKX9jNnXRl52ZEHW2xSZchTMzorV3arZa7YW0W2QoC26YeuRP+h8yGBAvYBye6hnQKZCg== 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=V202iJQp77pChCocg07QgPebNBz9532Mcc0r1oChQpw=; b=WDakjJGaHmYiw3GL7TPOcJ34kimNO4LL7q+dBT9j0PrZqR9+v8WPX8Rb3bJThBuDOSiGOyphxaQR6oGDHY0djpD2HKqzCE4vcydPAzK2PFZywdju0X1J9eubSfxxidjcgCpvdmDo3kBxpuomAl3IKl4uQ470qX89W3QAjd0UkZIpUXWTh53iny8Z54g+fRerZ2W7MBodxBB3sHUh3quEdkgJ833g3BxafWuoxB8AO+qBnrmucXqFAQY//z3HHJicLufxLokF0iyVpJzatrNrUUX+syamhyTwsurw5KTL6zi2I0rWRdIDBamqCG1jAvErXnLHiqvS3qZmHCmTeOG2iw== 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=V202iJQp77pChCocg07QgPebNBz9532Mcc0r1oChQpw=; b=6GPZrRNHWD3CaxbQPEsaVfsk57u04gJTxFkVIOYmE+//bJvApZ6bOIsnYy+hSs60XCrzWIm7zs/yzZc7m56LL0dV6jqcRmrufHR8ZViM32Fdq5yslNa4zOgYj/6ATrzywtg3yGbQkkAdUSqmUGjxw0ETTCtwkGItWA0g790tQHw= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:39 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:39 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 12/22] libqos: move useful qos-test funcs to qos_external Thread-Index: AQHVbneLLqfcLBcduEiaVsWLhAfCLQ== Date: Wed, 18 Sep 2019 23:19:39 +0000 Message-ID: <20190918231846.22538-13-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 313c0602-24cf-41d5-7c4f-08d73c8eadb6 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(14444005)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(30864003)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: GsTuX2PKo39tKF55JvfRRZ1XOeLOOMsMRWhXdLMHYkPDw+qEImk4rwj+HeQIpu12JLjCHkNES17YB6n/EgGBkFtuIyFwyUcR6byYKEerkW3nOWc9aRP0vtUQp3cW43tSFQbdDbic/SBlgsjT5vQCon1zaUd6zkvINQ0yASeXgTLtnizJaQZEceviA0xnJVALtBB+A2y8hMbn+5NkgRf0UaNd8SxTuF8pmXeIcWz8raDmjjNt23vt5J8Zm9FJul+r8UdEDRWNp457Ve99+EkXWBWNpzeD9T3/BHHgYaeb0yix5tgfAkUcZ9UIneNOnYoQijep8/fb5KwAhEEGI/+eqx7MOEjlViZ5QDkU6SsuC5Aw6wL+X4003lzeal0aMK0264QLQuZ32qJXoEGe8DXka+C66Y9LfFIs1rbhRkh69rQ= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 313c0602-24cf-41d5-7c4f-08d73c8eadb6 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:39.5304 (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: e198AlPuVHnsEdSmefjJ7okoON9Ekwn3f3N028KcIsIc//9USTdCnenfjq7YSXEv X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.132 Subject: [Qemu-devel] [PATCH v3 12/22] libqos: move useful qos-test funcs to qos_external 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 , Thomas Huth , "Oleinik, Alexander" , "bsd@redhat.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 | 151 ++++++++++++++++++++++++++++++++++++ tests/libqos/qos_external.h | 10 +++ tests/qos-test.c | 140 ++------------------------------- 4 files changed, 167 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 da665ca7eb..5d4d12503a 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -703,6 +703,7 @@ libqos-usb-obj-y = $(libqos-spapr-obj-y) $(libqos-pc-obj-y) tests/libqos/usb.o libqos-obj-y = $(libqos-core-obj-y) libqos-obj-y += $(libqgraph-obj-y) libqos-obj-y += $(libqos-pc-obj-y) $(libqos-spapr-obj-y) +libqos-obj-y += tests/libqos/qos_external.o libqos-obj-y += tests/libqos/e1000e.o libqos-obj-y += tests/libqos/i2c.o libqos-obj-y += 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..81d1a50c8c --- /dev/null +++ b/tests/libqos/qos_external.c @@ -0,0 +1,151 @@ + +#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 = NULL; + if (is_machine) { + const char *arch = qtest_get_arch(); + machine_name = g_strconcat(arch, "/", name, NULL); + name = 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 = qlist_first(list); p; p = qlist_next(p)) { + minfo = qobject_to(QDict, qlist_entry_obj(p)); + qobj = qdict_get(minfo, "name"); + qstr = qobject_to(QString, qobj); + name = qstring_get_str(qstr); + + qobj = qdict_get(minfo, "abstract"); + if (qobj) { + qbool = qobject_to(QBool, qobj); + abstract = qbool_get_bool(qbool); + } else { + abstract = false; + } + + apply_to_node(name, is_machine, abstract); + qobj = qdict_get(minfo, "alias"); + if (qobj) { + qstr = qobject_to(QString, qobj); + name = 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_alloc) +{ + int current = 0; + QGuestAllocator *alloc; + QOSGraphObject *parent = NULL; + QOSGraphEdge *edge; + QOSGraphNode *node; + void *edge_arg; + void *obj; + + node = qos_graph_get_node(path[current]); + g_assert(node->type == QNODE_MACHINE); + + obj = qos_machine_new(node, qts); + qos_object_queue_destroy(obj); + + alloc = get_machine_allocator(obj); + if (p_alloc) { + *p_alloc = alloc; + } + + for (;;) { + if (node->type != QNODE_INTERFACE) { + qos_object_start_hw(obj); + parent = obj; + } + + /* follow edge and get object for next node constructor */ + current++; + edge = qos_graph_get_edge(path[current - 1], path[current]); + node = qos_graph_get_node(path[current]); + + if (node->type == QNODE_TEST) { + g_assert(qos_graph_edge_get_type(edge) == QEDGE_CONSUMED_BY); + return obj; + } + + switch (qos_graph_edge_get_type(edge)) { + case QEDGE_PRODUCES: + obj = parent->get_driver(parent, path[current]); + break; + + case QEDGE_CONSUMED_BY: + edge_arg = qos_graph_edge_get_arg(edge); + obj = qos_driver_new(node, obj, alloc, edge_arg); + qos_object_queue_destroy(obj); + break; + + case QEDGE_CONTAINS: + obj = 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..1c5bbae814 --- /dev/null +++ b/tests/libqos/qos_external.h @@ -0,0 +1,10 @@ +#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_alloc); + +#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" static char *old_path; -static void apply_to_node(const char *name, bool is_machine, bool is_abstract) -{ - char *machine_name = NULL; - if (is_machine) { - const char *arch = qtest_get_arch(); - machine_name = g_strconcat(arch, "/", name, NULL); - name = 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 - */ -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 = qlist_first(list); p; p = qlist_next(p)) { - minfo = qobject_to(QDict, qlist_entry_obj(p)); - qobj = qdict_get(minfo, "name"); - qstr = qobject_to(QString, qobj); - name = qstring_get_str(qstr); - - qobj = qdict_get(minfo, "abstract"); - if (qobj) { - qbool = qobject_to(QBool, qobj); - abstract = qbool_get_bool(qbool); - } else { - abstract = false; - } - - apply_to_node(name, is_machine, abstract); - qobj = qdict_get(minfo, "alias"); - if (qobj) { - qstr = qobject_to(QString, qobj); - name = qstring_get_str(qstr); - apply_to_node(name, is_machine, abstract); - } - } -} /** * qos_set_machines_devices_available(): sets availability of qgraph @@ -129,10 +75,6 @@ static void qos_set_machines_devices_available(void) qobject_unref(response); } -static QGuestAllocator *get_machine_allocator(QOSGraphObject *obj) -{ - return obj->get_driver(obj, "memory"); -} static void restart_qemu_or_continue(char *path) { @@ -159,78 +101,6 @@ void qos_invalidate_command_line(void) old_path = NULL; } -/** - * 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, QGuestAllocator **p_alloc) -{ - int current = 0; - QGuestAllocator *alloc; - QOSGraphObject *parent = NULL; - QOSGraphEdge *edge; - QOSGraphNode *node; - void *edge_arg; - void *obj; - - node = qos_graph_get_node(path[current]); - g_assert(node->type == QNODE_MACHINE); - - obj = qos_machine_new(node, qts); - qos_object_queue_destroy(obj); - - alloc = get_machine_allocator(obj); - if (p_alloc) { - *p_alloc = alloc; - } - - for (;;) { - if (node->type != QNODE_INTERFACE) { - qos_object_start_hw(obj); - parent = obj; - } - - /* follow edge and get object for next node constructor */ - current++; - edge = qos_graph_get_edge(path[current - 1], path[current]); - node = qos_graph_get_node(path[current]); - - if (node->type == QNODE_TEST) { - g_assert(qos_graph_edge_get_type(edge) == QEDGE_CONSUMED_BY); - return obj; - } - - switch (qos_graph_edge_get_type(edge)) { - case QEDGE_PRODUCES: - obj = parent->get_driver(parent, path[current]); - break; - - case QEDGE_CONSUMED_BY: - edge_arg = qos_graph_edge_get_arg(edge); - obj = qos_driver_new(node, obj, alloc, edge_arg); - qos_object_queue_destroy(obj); - break; - - case QEDGE_CONTAINS: - obj = parent->get_device(parent, path[current]); - break; - } - } -} /* The argument to run_one_test, which is the test function that is registered * with GTest, is a vector of strings. The first item is the initial command @@ -239,14 +109,14 @@ static void *allocate_objects(QTestState *qts, char **path, QGuestAllocator **p_ */ static char **current_path; -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); } -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]; } /** From patchwork Wed Sep 18 23:19:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151297 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DC9716B1 for ; Wed, 18 Sep 2019 23:25:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D77BD218AF for ; Wed, 18 Sep 2019 23:25:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="7LdTycAG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D77BD218AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjKJ-0006uu-GZ for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:25:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33314) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEd-0000Rj-43 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEb-0002bE-VE for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:42 -0400 Received: from mail-eopbgr700132.outbound.protection.outlook.com ([40.107.70.132]:29345 helo=NAM04-SN1-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 1iAjEb-0002aR-Pb for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h4qeWoB1OpF/5GzBvzWq7gFVjZFv7H0q7h87gByYWUft7ZTGfTA6MznJl7FiyrRb+sAYeB1JumYVg/1AYt37hp1FoT9f7tPD5th9Z5xcCvWXC9Ih+tcAC8a7ZLpxmzNxdY5PogjQCZ6PYcaEhOAokAhKxQm7s+jWuSseKVd5uEDzc3aBTbsLHdHSEvSr2XlQPJOzZ/tkVaa8KKy/UwQ6TfpTiMPG3RzyVqKNnqECUSrMtt1WBaO40fGfWosX+ecX4ZYoQdmo6oY39zivTNNB9QMW4nsnHt79Is7zRz2Arvao0+Z4tutGyFWYHsjPImYMKx9qXRxX/PSjCPDAzknPSw== 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=MDCO4pOny31wEpw6FlNn2VBGyWJRAg3gdX7mjAe1vXw=; b=VcQoN4d+jMug9FbNm4yRn9f7lTO3THAsVBjvHuwhogWcs8Xfd64kT1/TmSukuZa3Wt25JQbn0OBqJbWnM1uwdSf8Gxnsfk6/6ptXNQ0ehXQk7RYfqaRWaZfIULnIc6cEWBluPwzR7C1FmorB6QSmQhEI/OIux5PKLrJfZg4Ibl8/YxKvupljL3J/9Gopdl0/w246PLtUdaDu8SZ/sPEUP1HY7+ubsqQOEJVGAbTABmR91Ph+EZzAfuJUBjOeoHym+yQ68MfHjCSnT00AoWFXgguzT/sjv0novzvdcbiRqQfKs7YFmwAofHaUAcPgo7blPXEhB3jJrj495dRqaNytow== 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=MDCO4pOny31wEpw6FlNn2VBGyWJRAg3gdX7mjAe1vXw=; b=7LdTycAG410FKPr/JnpiYL81EMkz7FcyWaU1lYFdGEkVBo8Fpb/UlFsCuXn7SbyFRqYzFSez1EoAU3LPYcgfNOJ7GhxHenNoTe1fl5IUjVkzAeEYfSnICkNGD26kDEnfh8e9bzb+MioqI3/04/aveQzmjtFve03UpZvKnAB/Ztk= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:40 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:40 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 13/22] libqtest: make qtest_bufwrite send "atomic" Thread-Index: AQHVbneLvcrhrDR470+fVESmeJqVGQ== Date: Wed, 18 Sep 2019 23:19:40 +0000 Message-ID: <20190918231846.22538-14-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: d6d27b62-48e4-45cc-f006-08d73c8eae4d x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:449; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(4744005)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 6Hkadz7XWYL0CKtHr7xpwVQ3lzVaiUmyKGJ91+ooa8MGVwdfVGbSJ5csqzWak6sH4SUGLYOs99lkefpLqRD4yB1KdZXBeTdT+suVmZCZ7NGfzrzdSxTc6x4xchuWBRimonEnpzr6O/bZl3scg9+0bPnF7BYSDfvYg+36LY3jUTkiCj8RPjoCcUhiLqCWkslcsth8b6wgefSr3XLiIb48DIcv4fRp6DY89Ji7QyKp1WEXC5vMzRZF1ngwj1LognQE17Zz6xMbKQ8+y4LRq4n064a05NsQgDdlkdA16h3hzKnfnpFpbT7ATOtBJFAShDlPpoKXd0eNzvY0sfpKxSKrYPRxyUmtMceTLSGmMuqc+OdJiA5xB5DxlALAKc1Qw8M3f27XEXb2Tll2ZAiOLvcWGa10CaL1P7pojR6Wvg6sLC4= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: d6d27b62-48e4-45cc-f006-08d73c8eae4d X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:40.5339 (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: +e21NMDT4a9E8cDy7puQWIfI6X0T52WptCoB0imRdBmdNxIzzAI9w8lhjtLka/zR X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.132 Subject: [Qemu-devel] [PATCH v3 13/22] libqtest: make qtest_bufwrite send "atomic" 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 , Thomas Huth , "Oleinik, Alexander" , "bsd@redhat.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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, 1 insertion(+), 3 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 19feea9e17..d770462869 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1086,9 +1086,7 @@ void qtest_bufwrite(QTestState *s, uint64_t addr, const void *data, size_t size) gchar *bdata; bdata = 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); + qtest_sendf(s, "b64write 0x%" PRIx64 " 0x%zx %s\n", addr, size, bdata); qtest_rsp(s, 0); g_free(bdata); } From patchwork Wed Sep 18 23:19:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151321 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 495F114DB for ; Wed, 18 Sep 2019 23:40:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 142B1218AE for ; Wed, 18 Sep 2019 23:40:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="YENhJ99D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 142B1218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjYS-0004Ts-2G for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:40:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33341) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEe-0000Tv-Ov for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEd-0002cU-Cw for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:44 -0400 Received: from mail-eopbgr700101.outbound.protection.outlook.com ([40.107.70.101]:49633 helo=NAM04-SN1-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 1iAjEd-0002bn-7N for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JCCNtlROGkUtPHU2ZrFRO2erDb1nC2h4CmBOp9lwrC4O7hFIq48fCdfXbEixzpHs+pCanXrDJg1cnaLfLiI3TB0xk8HaiBnNtsTA9We+qEglpSBlwvZ8lz2y2OZcRQiTy22wMqBvSK6SoIF0lEX9SjSEyZM79ueUB5h/BDWqF1l7lv5zCjiy8w/HU+1Qb8ua1cTbYUFx3JokOzjekPY0dG3QnXZy+1+FYkOSWrwnKsquYPLGS1C5lYTpR+aYUzrOWXzYCeRB6nXzJALLhk4pCYkYLRDwhEmQzsNVR2QnqM3Gaqfnk6/m/k75KzuchdIKKJQYSD9VSASAixNvN5fkfA== 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=Lc2CkDJQcimdztENGOPGbCknWpSubB8TVQhQIzeytxU=; b=ImA9Q5E8iLhj7/f9+Hk8RDtT7S6MHSo81rKIh6OtHb+BrahL1jG4CgILG9miGQpu6RHw3dcgKsIhsFtal8xw8tZYkUWb+DRgqeLKbD6bobM9y0igTnu11qF2WJYOryr7M8WyceSuVEU78TlmxdQl23hk2jZWqlpf2vYksrn7njRukiovYXHENhyofpe+WppYko5WZwDeCr4gD+Tmto1xwmZhpjKxI0JiGzYMaPlYglYTjs7uZvmbwNFlQpMvd/4PHw5Hofe9YLWyTTzCLWVVkfnXvwUSGCzaAQGOFpjdV1IWgMgwydPi+qKQ3qNmumAIKm06VqGxvPHVt+//fU3RCQ== 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=Lc2CkDJQcimdztENGOPGbCknWpSubB8TVQhQIzeytxU=; b=YENhJ99DEclITEk6nYKQzXh64l0Rr+3W+P0hhN9NNQ0Da2bpMcfqlgpYVCnwNLvdSIZQYmFZFdk/wB5IfFVeD914GQFUN+ldyECquWystWeuNbUo6/fx7mtpyjdFtu+Y79I4E4IED9WDQqwAtdwoGXhWDAD5Z9dTliPLw48n6XM= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:41 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:41 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 14/22] libqtest: add in-process qtest.c tx/rx handlers Thread-Index: AQHVbneM5DHTVNsf2EWK27C25kPhHA== Date: Wed, 18 Sep 2019 23:19:41 +0000 Message-ID: <20190918231846.22538-15-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: daacef9f-c631-40af-40b6-08d73c8eaeec x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:130; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: E0EPodqjCzPuxjT7tzn6n/VV7DDniVYADVshCxBnOUPOKr8Q1SdvF7z+DKC2rQikeN8vvlj35oHpL18Ho+FOTrshohEpO7Mh1BpUDSQPXmFo3tEgtfRa/t69u1FgYPHlgkZM8GsLvYgDR8rQ88ass7p2idtF4kjQX5O4UW8WOAuEXTxv+6bHUqDVD46t2OJDTA+EpnszThPvQ1zRGQ95J8zDnwiSYbD+8fZgq1ZjnqpWoT0nHJS3N/398/woMsv9IjcSod5qgVegAoku/4OIDmL/Bnetj9wq8yNOHoPaJH9hUtkguwLxnL2tbDS/7yBqDCaWdMoP3suVx3/+0KYeAtjn+4dItNk9ZoIiWQ80g5ABhsbzotgogYQiNGrHMKqn0lw0SM4B6GiUXDqswRv2vWuwyVwRMkXnLg1EMiTKvI8= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: daacef9f-c631-40af-40b6-08d73c8eaeec X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:41.5635 (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: G7Kp5974IpaOhcQHYennV0UWEi8nENBL27p1jrSsNXk33olXoFo4IBxT9qrK+61F X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.101 Subject: [Qemu-devel] [PATCH v3 14/22] libqtest: add in-process qtest.c tx/rx handlers 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 , Thomas Huth , "Oleinik, Alexander" , "bsd@redhat.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexander Oleinik Reviewed-by: Stefan Hajnoczi --- tests/libqtest.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tests/libqtest.h | 5 +++++ 2 files changed, 51 insertions(+) diff --git a/tests/libqtest.c b/tests/libqtest.c index d770462869..fc10322d52 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -60,6 +60,7 @@ struct QTestState static GHookList abrt_hooks; static struct sigaction sigact_old; static GString *recv_str; +static const char *qtest_arch; static int qtest_query_target_endianness(QTestState *s); @@ -490,6 +491,7 @@ static GString *qtest_client_socket_recv_line(void* opaque) return line; } + static gchar **qtest_rsp(QTestState *s, int expected_args) { GString *line; @@ -830,6 +832,9 @@ char *qtest_hmp(QTestState *s, const char *fmt, ...) const char *qtest_get_arch(void) { + if (qtest_arch) { + return qtest_arch; + } const char *qemu = qtest_qemu_binary(); const char *end = strrchr(qemu, '/'); @@ -1367,3 +1372,44 @@ static void qtest_client_set_rx_handler(QTestState *s, s->ops.recv_line = recv; s->ops.recv_line_opaque = opaque; } + +static GString *qtest_client_inproc_recv_line(void* opaque) +{ + GString *line; + size_t offset; + char *eol; + + eol = strchr(recv_str->str, '\n'); + offset = eol - recv_str->str; + line = 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 = g_new(QTestState, 1); + qts->wstatus = 0; + for (int i = 0; i < MAX_IRQ; i++) { + qts->irq_level[i] = false; + } + + qtest_client_set_rx_handler(qts, qtest_client_inproc_recv_line, qts); + qtest_client_set_tx_handler(qts, send, NULL); + + qts->big_endian = qtest_query_target_endianness(qts); + qtest_arch = arch; + + return qts; +} + +void qtest_client_inproc_recv(void *opaque, const char *str, size_t len) +{ + if (!recv_str) { + recv_str = g_string_new(NULL); + } + g_string_append_len(recv_str, str, len); + return; +} diff --git a/tests/libqtest.h b/tests/libqtest.h index 40fa235a52..453bd8998f 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -716,4 +716,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 From patchwork Wed Sep 18 23:19:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151309 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F314F14E5 for ; Wed, 18 Sep 2019 23:31:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C8229218AE for ; Wed, 18 Sep 2019 23:31:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="5sJbO1ij" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8229218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjQ5-0005BU-Ka for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:31:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33343) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEe-0000UG-W3 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEd-0002d2-OZ for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:44 -0400 Received: from mail-eopbgr700101.outbound.protection.outlook.com ([40.107.70.101]:49633 helo=NAM04-SN1-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 1iAjEd-0002bn-Ib for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KlzHei6JJAIz8XHbV/URPV3b3v1UWWn3j/uoq9IQWSZNUHGGXa47lyVmMoIY8boII6QQG01RO/3ns6CYOJVMyUa4fS7/NoEGAP4t98D3xC4eoDmbCFbfMUzf93sZexOhLNn1/h/wNBL4tTT9qH58eHSZJ+ymHf3lQwGDlHHqaBj1/dQQD9wRDePonEVO+Ld9t7Jc+Jl3qHxmr9wIO5fbZSNc2urgz4qpyqXMeXQQvuPWls6QRpxCPLz9UQrSs1NzKCtNxfHGEXzpxcsPqg6N9J9jIP+dwyruQBD9ZohvpXMT4TKMWkAjaSjE9ViD6bbyB6DOXcucrf3zMPANtOFuqg== 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=EpkEAhjUBJN5+ZVIUazlzofX3SXyUQXSnl7WITZRu5o=; b=D8BbI6u83e8qOQQwJaPs5dufvLRgbsVa17NHN3p0H+kJs3MhOgsEBN0AyJSKsdLvf1sF7iEEUrpZLFgFmfLm3eCDODbWtv1/QX5bug0lplNzriRmpiSHXVkIHqYri8QYwT7olGmjXGYtmouEAdQ/UHJR5mlb62O8m6YD5VColw6Edxli589gLeI8O6B3DdhRkab7NCkBWl+cCmeiEmVK+bCSXnjwNyBj9edQzKqLmy4rIJOg04SGlmYqUQ+sbMGTSI6wfM2xHidSKT3RAs9WYXWdANIXd1u7mrOYY3s331608OTiFdq2OdL7kPmt9S3i5OQiTycZ/w/iutmpQYmVBQ== 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=EpkEAhjUBJN5+ZVIUazlzofX3SXyUQXSnl7WITZRu5o=; b=5sJbO1ijFi9qfGsMkIG7YdUbwnfHoVeLjopYMMgxPeoHb0qNSqJK8fHqrhwuukwo81xOARgw5zYw0Dz3pgxX2HX/cYS5OdJJyUudgsJZ06oePnQ13UCoPE/a1jl4fZQMy+C+nclqRSLUDGnpIFonYkMgFK8X/K/oMCFEGlpn32k= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:42 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:42 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 15/22] fuzz: Add target/fuzz makefile rules Thread-Index: AQHVbneNYJpjK54Mx0qJT8VRNItNog== Date: Wed, 18 Sep 2019 23:19:42 +0000 Message-ID: <20190918231846.22538-16-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: b6b284d7-6e57-4b1a-8542-08d73c8eaf75 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:397; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: TWNa7U1KOptnJPi74njIVYP8eLNvo6knUBJIuT948IIbnpvfh2lLkN3WoWo7G2T/9EQbrZmqBFepxTIPCf378EPGUfHYXmbLBugU4C3UyptznwrAJmvcktjGSJmu5Hyyz3bphTiMi+lzbk6LUMN5KyDlKVG59CJ7Me8alH7QRj0GAhHRNsQerD33cC3UoyB6PmdBLSSydTOTDOc5tw0Y1fs2pcHwpNvN5oKL3zM0PQmv2SvSdPcg7vm4HHbIcv6lmXc6UslyO86mY29DQkzuL57bXSLz+WaDjCpjDc8gLTScNDfJxgY1aRKS/1vzR8qoKjEhBT6n29rlGCp/U75izdLUQehJN9Z38XdgX7p+I+aI6xehKUmBBUTVKX1YNAtENx4pammuOt1wD/MuUBy8MQfjkvht7FCXVCcIVI9kATQ= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: b6b284d7-6e57-4b1a-8542-08d73c8eaf75 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:42.5470 (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: eEfQ/hLjObUl/r6F64Ipb1TXfcHAoxoVRTU1ds0DmKr5pP2mb+B9RQJyMqhPZ+hG X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.101 Subject: [Qemu-devel] [PATCH v3 15/22] fuzz: Add target/fuzz makefile rules 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexander Oleinik --- Makefile | 12 +++++++++++- Makefile.objs | 6 +++++- Makefile.target | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3a43492340..5e5033a500 100644 --- a/Makefile +++ b/Makefile @@ -426,6 +426,7 @@ dummy := $(call unnest-vars,, \ qom-obj-y \ io-obj-y \ common-obj-y \ + softmmu-obj-y \ common-obj-m \ ui-obj-y \ ui-obj-m \ @@ -463,7 +464,16 @@ $(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) +$(SOFTMMU_ALL_RULES): $(softmmu-obj-y) + +SOFTMMU_FUZZ_RULES=$(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) SOFTMMU_FUZZ_RULES=$(filter %-softmmu/fuzz, $(TARGET_DIRS_RULES)) $(SOFTMMU_FUZZ_RULES): $(authz-obj-y) diff --git a/Makefile.objs b/Makefile.objs index bb1cfa05ef..99ea6b66de 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -87,9 +87,13 @@ common-obj-$(CONFIG_FDT) += device_tree.o common-obj-y += qapi/ -softmmu-main-y = main.o endif +ifneq ($(CONFIG_FUZZ),y) +softmmu-obj-y = main.o +endif + + ####################################################################### # Target-independent parts used in system and user emulation common-obj-y += cpus-common.o diff --git a/Makefile.target b/Makefile.target index 6065989964..f3efe3debd 100644 --- a/Makefile.target +++ b/Makefile.target @@ -194,6 +194,7 @@ all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) $(chardev-obj-y) all-obj-$(CONFIG_USER_ONLY) += $(crypto-user-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y) +all-obj-$(CONFIG_SOFTMMU) += $(softmmu-obj-y) ifdef CONFIG_SOFTMMU $(QEMU_PROG_BUILD): config-devices.mak From patchwork Wed Sep 18 23:19:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151327 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B767914ED for ; Wed, 18 Sep 2019 23:44:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 753C021848 for ; Wed, 18 Sep 2019 23:44:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="3/el18BB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 753C021848 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjcw-0007hX-MA for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:44:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33377) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEi-0000Z1-Ey for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEg-0002hR-Ls for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:48 -0400 Received: from mail-eopbgr700099.outbound.protection.outlook.com ([40.107.70.99]:57953 helo=NAM04-SN1-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 1iAjEg-0002fm-Ez for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bHgl8A/u4+7JfnSWzpNhQpfZWcl6h5WaRNHGcZUOGAeDSJ8C9z4I8y3MJehujTnU0CD6Gt4je8JAwiOTlMJoWf7eOlpiQN+MJBl9lku0NEAlDkSKk5F9zvJSyaqS6ckzVehhWBUNVFWYw4rvlcBbUCIsPfrEwl6/jW7KZRCfajcjYBcy3Kd1JZ2VpJBOtbeHBaWDLJoRMD3+9VD5EN1xYwk4JZ1hM4G8Zb4gyD5IV2uB55RPKz5/o4Xldj4ty2bJw6QKkyCwvkgcBrH38GcBHtu5bWAqEUNZ4aHsFiwTp/JtvfUBbEbxEHTuVcOj9waGBcfAan5MSEdSnmtfrc53Kw== 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=69ahgLwP1KKvLigotiQVJE9rboGJ+71jKBnrGIWB8No=; b=GwtRKol5H5/AUex9ZKMbQj0/qBlS1RRpcSw//Lx4NVYq3pdbRf8ZDVru848UNnG7zzelI1DaETiKtuJ+Nt2pKIQvn2kinf7SD802GgnATX8JadxM080f5Bx8nlthrlOZRL6kye6jz/LYW8y4oi7a5MZEFR/oguC8HcBlAzX3OWML6JS/PsPYFXfTbw7acniaHYkBp5TDsjic2f5TSWtA1+5FSSjjH5NooT0mFlB8ZyDFUeP05nZiX57Tu64DVy0gV6y5rQh7zwb8ErRyKlmvzoYo3BwhebfneVZ6zP63qLyi6a4N3fU1nhQf2FjOnL4Ya0h4DZh9tToG9hMPza6Qng== 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=69ahgLwP1KKvLigotiQVJE9rboGJ+71jKBnrGIWB8No=; b=3/el18BBLmOzQVYES0weCOOu8r11QoZk9h7+hRnZLHMKfI6NPkxcohjAxAeBFMPashuWsyqgmLglk24UwpKKMO6bwt2yHxBFhETFneEHejfPWaZGmfsvdOYze6KVPtpHfM9EYyXgz5lXznmybH5jecgkp8F3Yxr1MiNhXgaTHm8= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:43 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:43 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 16/22] fuzz: add fuzzer skeleton Thread-Index: AQHVbneNlE8fR7mgcUOLZqeMV0v7RQ== Date: Wed, 18 Sep 2019 23:19:43 +0000 Message-ID: <20190918231846.22538-17-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 6b7b05ea-507e-4cf6-3e2b-08d73c8eb011 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1201; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 4SoPupVyY1DUzUBiE9IBgR2DGcbYK06JANxynqLRzaUoWONY4pn5l0W24x1h3ngcUuS62kf793fijFnx/dMPxfINaTTDFoIGptWL6JM3Uf+JoXK5YWS9bVjahSb5RwmloHfyDKxHGidImiaKg6yl2afrUbMnhijFyeiRevYJF1oBJ/gpCdspS/TvrGS10RRGYM7NObwRkkGieDib0tJcxEQtQm8HYRgUSoM0Wbq/PmyUiv7nH+7PKaORlwXLxYogMFWBjCDlMh+saJRICEftIUWUMkplTJijgZYjJXuRg9ZwKAxpxpVi8KbbJ1tjXN6pspEpxBVBo3LjMTSbDUcxfIJA6h5B4a6kfTBQglc+SlskhUVYp6UOAkYfu9+KtI/Un+pWf8f7ASyQ/B1b19S2XgcX3ei0KcFMIqYCnWAgQmw= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 6b7b05ea-507e-4cf6-3e2b-08d73c8eb011 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:43.4856 (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: MOBXxMqhQz7Zlpt48lSeNA6xkkMKyvOEnhTfhW5DzYBVvilwthaPAwyhpSK5edg6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.99 Subject: [Qemu-devel] [PATCH v3 16/22] fuzz: add fuzzer skeleton 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 | 179 ++++++++++++++++++++++++++++++++++++ tests/fuzz/fuzz.h | 30 ++++++ 3 files changed, 211 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=qemu-fuzz-$(TARGET_NAME)$(EXESUF) +QEMU_PROG_FUZZ=qemu-fuzz-$(TARGET_NAME)$(EXESUF) fuzz-obj-y = $(libqos-obj-y) fuzz-obj-y += tests/libqtest.o - +fuzz-obj-y += tests/fuzz/fuzz.o diff --git a/tests/fuzz/fuzz.c b/tests/fuzz/fuzz.c new file mode 100644 index 0000000000..833f436731 --- /dev/null +++ b/tests/fuzz/fuzz.c @@ -0,0 +1,179 @@ +#include "qemu/osdep.h" + +#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" + +typedef struct FuzzTargetState { + FuzzTarget *target; + QSLIST_ENTRY(FuzzTargetState) target_list; +} FuzzTargetState; + +typedef QSLIST_HEAD(, FuzzTargetState) FuzzTargetList; + +static const char *fuzz_arch = TARGET_NAME; + +static FuzzTargetList *fuzz_target_list; +static FuzzTarget *fuzz_target; +static QTestState *fuzz_qts; +static bool trace; + + +void set_fuzz_target_args(int argc, char **argv) +{ + if (fuzz_target) { + fuzz_target->main_argc = argc; + fuzz_target->main_argv = argv; + } +} + +void reboot(QTestState *s) +{ + qemu_system_reset(SHUTDOWN_CAUSE_GUEST_RESET); +} + +static QTestState *qtest_setup(void) +{ + qtest_server_set_tx_handler(&qtest_client_inproc_recv, NULL); + return qtest_inproc_init(trace, fuzz_arch, &qtest_server_inproc_recv); +} + +void fuzz_add_target(const char *name, const char *description, + FuzzTarget *target) +{ + FuzzTargetState *tmp; + FuzzTargetState *target_state; + if (!fuzz_target_list) { + fuzz_target_list = g_new0(FuzzTargetList, 1); + } + + QSLIST_FOREACH(tmp, fuzz_target_list, target_list) { + if (g_strcmp0(tmp->target->name->str, name) == 0) { + fprintf(stderr, "Error: Fuzz target name %s already in use\n", + name); + abort(); + } + } + target_state = g_new0(FuzzTargetState, 1); + target_state->target = g_new0(FuzzTarget, 1); + *(target_state->target) = *target; + target_state->target->name = g_string_new(name); + target_state->target->description = g_string_new(description); + QSLIST_INSERT_HEAD(fuzz_target_list, target_state, target_list); +} + + +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 (g_strcmp0(tmp->target->name->str, name) == 0) { + break; + } + } + return tmp->target; +} + + +static void usage(char *path) +{ + printf("Usage: %s --FUZZ_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->str, + tmp->target->description->str); + } + exit(0); +} + + +/* 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, *trace_qtest; + + /* --trace is useful for outputting a log of qtest commands that trigger + * a crash. The log can can then be replayed with a simple qtest script. */ + if (*argc > 2) { + trace_qtest = (*argv)[2]; + if (strcmp(trace_qtest, "--trace") == 0) { + trace = true; + } + } + + /* 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 <= 1) { + usage(**argv); + } + + /* Identify the fuzz target */ + target_name = (*argv)[1]; + target_name += 2; + fuzz_target = fuzz_get_target(target_name); + + fuzz_qts = qtest_setup(void); + + if (!fuzz_target) { + fprintf(stderr, "Error: Fuzz fuzz_target name %s not found\n", + target_name); + usage(**argv); + } + + if (fuzz_target->pre_main) { + fuzz_target->pre_main(); + } + + if (trace) { + printf("### cmd_line: "); + for (int i = 0; i < (fuzz_target->main_argc); i++) { + printf("%s ", ((fuzz_target->main_argv))[i]); + } + printf("\n"); + } + + /* Run QEMU's softmmu main with the calculated arguments*/ + qemu_init(fuzz_target->main_argc, fuzz_target->main_argv, NULL); + + /* If configured, this is a good spot to set up snapshotting */ + if (fuzz_target->pre_fuzz) { + fuzz_target->pre_fuzz(fuzz_qts); + } + + if (trace) { + printf("### END INITIALIZATION\n"); + } + + return 0; +} diff --git a/tests/fuzz/fuzz.h b/tests/fuzz/fuzz.h new file mode 100644 index 0000000000..73af029c82 --- /dev/null +++ b/tests/fuzz/fuzz.h @@ -0,0 +1,30 @@ +#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 { + GString *name; + GString *description; + void(*pre_main)(void); + void(*pre_fuzz)(QTestState *); + void(*fuzz)(QTestState *, const unsigned char *, size_t); + int main_argc; + char **main_argv; +} FuzzTarget; + +void set_fuzz_target_args(int argc, char **argv); +void reboot(QTestState *); +void fuzz_add_target(const char *name, const char *description, FuzzTarget + *target); + +int LLVMFuzzerTestOneInput(const unsigned char *Data, size_t Size); +int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp); + +#endif + From patchwork Wed Sep 18 23:19:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151325 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0505D14ED for ; Wed, 18 Sep 2019 23:43:08 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD946218AE for ; Wed, 18 Sep 2019 23:43:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="2/g8zcsC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD946218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjbH-0006lV-27 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:43:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33381) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEi-0000Zm-PW for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEh-0002i2-25 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:48 -0400 Received: from mail-eopbgr700099.outbound.protection.outlook.com ([40.107.70.99]:57953 helo=NAM04-SN1-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 1iAjEg-0002fm-RS for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oR1sVxy8t701HxUHbGmda8HRk0nBF6O3nj5dhe2yNPt4KjjpaFCJEw2PCQBtFfeciDcrb/MgwCSz/L5043fjyVfFZb7eD3xU/kRaWetmxYmIAP3P9py4BlLEi4zg6T83tD/6kSESMexPbAW1H7HzmeVlOZzg8g/Anunz44XNCKkXJmyuF7xXKmfyP+Y8CFdHdhswEUxiTVvVC/TQlmXj6C2BjpMf/LU9KNOyIjgUckE30LWMypzCctZoWq5oe5Yz4dx4x8W1PGcEI3d2kay/2V932WTfU+m4mMP5kLsrFqoPUrGEECOCfn9KMyCZ5oO7qJP9Manz1rxLGsinUcgjag== 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=81e6ejmRqzYfhpK9hF3JafBxA8nvMvSc9hbwmPnDi9A=; b=FMSjlAvXCBpX+65vyLZnzEHB6qvKfLmBYw59irqIEMrUU4gci/8kOJ+DsiORs3Epa9huxTebYcYTqlnWxIj4ZHxGY5xdEGdEpF7t85w1iK+VGSbzHpvaaEYvoiX3iryn/KsLv7zpZHZ7fkLvdSIgZoApSapUzjMm37c1tRvfvedS9+6lIpbyvn0bSImAkGJP63aYDONdrVlvvno1zlG69TR5n3f4uaHj6OJVkCy1rIQa7wcDrMBEVravsMTF4xMPtKQWieK52TxcDJhXOnzJcdUVhufXOfNGW0I7VKiMGtVuvuIim3aTIpAy1+i1f0788mx2FsVCBFLLbN2BaFjvew== 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=81e6ejmRqzYfhpK9hF3JafBxA8nvMvSc9hbwmPnDi9A=; b=2/g8zcsC54QGHn0EgTZQzOvoG3R2FarbIO2jvN/kCal9OfLjyO4lY1Po0ptzBQp5ttnfaBAZAaumZ4pWQsetPVOjSNF5j8r51LZjMIzQi/wK52mV86WclRymDPpkFdLmhHqiCU+5H3BPYrcymFSkmprkq6bfTbVrev2IJ823ew4= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:45 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:44 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 17/22] fuzz: add support for fork-based fuzzing. Thread-Index: AQHVbneO8lKIXFBEJ0KI61E+89ePjQ== Date: Wed, 18 Sep 2019 23:19:44 +0000 Message-ID: <20190918231846.22538-18-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 3ab2e414-c393-417c-7df1-08d73c8eb0a5 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: vRLpUpo2fFhwAmf5jY8ltfIEgw6Fn57qEOTwNEGzX6MLwnFw/tbyT4aL79/UpOkz2Zbrit9r2NB1aBqbhIeqD5cFheEX7RfC5/OhSD30IeW7TfWZU/HFchpXfiqWfEJ8aWoVpQGHiVcNwJS7Y53whXrAl5g/lbPt/6BwnBaO2Fx/LtREyo6JCazKQXnkxf5OmqIAN0wj2WWt6YzmHEH1fPOKNJiLfR3fz6K/0YqlKpmztwRg8iEcamxxeY/HMVA/W3owwZUXIRYUrI28D18f09JTh2SCPM5LCPKfYyEmv0YAOdjrlZ4/0yAExlCghnxBf7Nk+nNfwjTk4svELPuxFv6q3A20n9PIF/8kD3i3Dx+hZVXETv5JakPDV9ZjuhD6UsBVNaQCpDiK7p2ijWJ9rC3Hele2Aol1/cQywSfL+vw= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 3ab2e414-c393-417c-7df1-08d73c8eb0a5 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:44.4132 (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: GwWLjh3RikBZCe7vKJcF/E00tSsfzGTQJsyoFvhpNb3XPjOAD5zIAyglwidQIWcW X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.99 Subject: [Qemu-devel] [PATCH v3 17/22] fuzz: add support for fork-based fuzzing. 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: "pbonzini@redhat.com" , "bsd@redhat.com" , Richard Henderson , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 there seems to be no simple way to re-map them as shared memory. As a workaround, we use a linker script modification to place all of the bitmaps together and add some markers around them which we can observe from our code. Then, we map shared memory and copy the bimaps to the SHM (in the child) and out of the SHM(in the parent) after each fuzzing run. Ram blocks are marked as DONTFORK in exec.c, which breaks this approach. For now, avoid this with an #ifdef. Signed-off-by: Alexander Oleinik --- exec.c | 2 ++ tests/fuzz/Makefile.include | 3 +++ tests/fuzz/fork_fuzz.c | 27 ++++++++++++++++++++++ tests/fuzz/fork_fuzz.h | 12 ++++++++++ tests/fuzz/fork_fuzz.ld | 46 +++++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+) 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 235d6bc883..d3838f4ea4 100644 --- a/exec.c +++ b/exec.c @@ -2295,7 +2295,9 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared) qemu_ram_setup_dump(new_block->host, new_block->max_length); qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_HUGEPAGE); /* MADV_DONTFORK is also needed by KVM in absence of synchronous MMU */ +#ifndef CONFIG_FUZZ /* This conflicts with fork-based fuzzing */ qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_DONTFORK); +#endif 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=qemu-fuzz-$(TARGET_NAME)$(EXESUF) fuzz-obj-y = $(libqos-obj-y) fuzz-obj-y += tests/libqtest.o fuzz-obj-y += tests/fuzz/fuzz.o +fuzz-obj-y += tests/fuzz/fork_fuzz.o + +FUZZ_LDFLAGS += -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..26d0b4b42e --- /dev/null +++ b/tests/fuzz/fork_fuzz.c @@ -0,0 +1,27 @@ +#include "qemu/osdep.h" +#include "fork_fuzz.h" + +uintptr_t feature_shm; + +void counter_shm_init(void) +{ + feature_shm = (uintptr_t)mmap(NULL, + &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START, + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); + return; +} + +void counter_shm_store(void) +{ + memcpy((void *)feature_shm, + &__FUZZ_COUNTERS_START, + &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START); +} + +void counter_shm_load(void) +{ + memcpy(&__FUZZ_COUNTERS_START, + (void *)feature_shm, + &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START); +} + diff --git a/tests/fuzz/fork_fuzz.h b/tests/fuzz/fork_fuzz.h new file mode 100644 index 0000000000..b5f8b35015 --- /dev/null +++ b/tests/fuzz/fork_fuzz.h @@ -0,0 +1,12 @@ +#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); +void counter_shm_store(void); +void counter_shm_load(void); + +#endif + diff --git a/tests/fuzz/fork_fuzz.ld b/tests/fuzz/fork_fuzz.ld new file mode 100644 index 0000000000..ba0ba79570 --- /dev/null +++ b/tests/fuzz/fork_fuzz.ld @@ -0,0 +1,46 @@ +/* We adjust linker script modification to place all of the stuff that needs to + * persist across fuzzing runs into a contiguous seciton of memory. Then, it is + * easy to copy it to and from shared memory. + * + * Total Size : A5A00 + * Sancov counters: B26F + * Coverage counters: 56D60 + * TracePC Object: 43C00 +*/ + +SECTIONS +{ + .data.fuzz_start : ALIGN(4K) + { + __FUZZ_COUNTERS_START = .; + } + .data.fuzz_ordered : + { + /* Internal Libfuzzer TracePC object which contains the ValueProfileMap. + * Not optimal that we have to copy the rest of the TracePC object. + * */ + __start___sancov_cntrs = .; + *(__sancov_cntrs*) + __stop___sancov_cntrs = .; + } + .data.fuzz_unordered : + { + /* Coverage counters. They're not necessary for fuzzing, but are useful + * for analyzing the fuzzing performance + * */ + __start___llvm_prf_cnts = .; + *(*llvm_prf_cnts); + __stop___llvm_prf_cnts = .; + + /* Lowest stack counter */ + *(__sancov_lowest_stack); + /* Internal Libfuzzer TracePC object which contains the ValueProfileMap. + * Not optimal that we have to copy the rest of the TracePC object. + * */ + *FuzzerTracePC*(.bss._ZN6fuzzer*) + __FUZZ_COUNTERS_END = .; + } +} +/* Dont overwrite the SECTIONS in the default linker script. Instead insert the + * above into the default script */ +INSERT AFTER .data; From patchwork Wed Sep 18 23:19:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151303 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03D7D112B for ; Wed, 18 Sep 2019 23:27:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD9A2218AF for ; Wed, 18 Sep 2019 23:27:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="r4N4yViS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD9A2218AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjMb-0001zP-P5 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:27:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33380) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEi-0000ZZ-Mx for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEh-0002iJ-DW for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:48 -0400 Received: from mail-eopbgr700099.outbound.protection.outlook.com ([40.107.70.99]:57953 helo=NAM04-SN1-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 1iAjEh-0002fm-7V for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HVQvNNvQQv0DjXO1UjCdlq7rZoNagScwcFwOMCX0eJ4ywSi/h9LgAPjdHA/vVdjchhyOT8HDK8p6Mysxcq0ujTdad2mFLUC2RboVV394Pf4TxW26rmAO5gazQMTogZrqSZBA+G2ZMiqIaIvisX7Cosw48Gx95qp4MTV4DqAtlEc0iUKq0yirRDlammroiaoZGggRwDFwZ9zTNphiAtk6LSS+30Wyfi43iiGiVLCXukTD9k95d9+G7Hd/uA3B5wq2bVtjgKnAgA4G22s43Mi6qrlIxbpKwnbC9C6quYs+9mQEqvtmPTUQp0XMfylPX0zMsw5rBAfqJm8WphTB4ila4g== 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=Wl9Ilmoqy23y3NtKqm9lMSKbV+7IZFTK9QJyJ/i2mBM=; b=GyGGGhFY3B10f/W5ZPUj6czAsnpIsnILs9AptKRSuLv4053GdkPlHaIj52bR6BE6d7i19FWJGZG41G+O2rVkAjJe7wEM9oRZhh58Q9XIeDMvMYWeU4/34S+vZPDUhrgAIn6wYXNteHjIqvQN2iXURVgUbo9OBzSo5wY5imbouj1OvTllg2NSYhbQ/e1xMsn3md62o/by9A14YZce6eEalR2COv4ubVahuC9NfAKGFb35bQF8yVdGEb+JP75fNF1mla1NzVSJk7CXaZLZOqgZw7AamBXbQbZ1dluPdNiczDioHmS85U+MdNVx7pEaftRBl1lABdBQyqgrprMazrsZPQ== 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=Wl9Ilmoqy23y3NtKqm9lMSKbV+7IZFTK9QJyJ/i2mBM=; b=r4N4yViSVm29TGCTppq36f3oUnOaRjRsX0auBiZJAsA6cRV5wBlnLw5HFSrfHXBz9ls5dDMOhtPurr7hY/zm8PkcRpGRz75ebU5j1bkGMZzH3evb3of5tMYwGylnuQpXvH6LNx0ARjew3R/AiRml6glUZWl0VU8neqN9WVg1u2w= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:45 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:45 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 18/22] fuzz: expose fuzz target name Thread-Index: AQHVbneO3sQ55jcPO0e0ifKPRYeJHg== Date: Wed, 18 Sep 2019 23:19:45 +0000 Message-ID: <20190918231846.22538-19-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 92a69b34-9bd0-4f99-7502-08d73c8eb11c x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4714; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: L2Pg+DuhoYoZjpOcIBn70LPHp2/ZtA/3dUC6RorVzySJFLRsQKrr/rVUKL8rzdFaSrpChVq9/TTghix0MVJ9Gw4QmXg40rfuILTBAJXzRlkWML5vFP2uRSEgwp7HQbWck4/qZTCMrpYt7pRXpsRQSJJcRjTPcBf1XTwcUK63IgZC6UGpGU1SdOQ32UK8hg5XrGjPm7q5evXOrAGa7UiRd+xvjkoY2YAgMaAiC2j5G4hcDTXX+zM6NPGcZgYJ/gC046iGcllzX+tJWEKTr4ptN9QhqcCSsXtIfZrpyy5Bv+ZaRJlqxTKZDk7c52Q1SrgUF4o831jb8vJqDzQ+rEBXgiFJrHX1vo4gukSj1tFZx+MKJyh2EGPeA1PwBchM8bJxzzoKedP59Fe2XihSNvOkYmfSkbQMN5rm8uoHdsLYfqs= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 92a69b34-9bd0-4f99-7502-08d73c8eb11c X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:45.3148 (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: hTDBQUdQwjYRk1m2zwquRC/L4kf4C9r366y/G/QIpf0nBdrBBs/HDBvmNaQw5cGY X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.99 Subject: [Qemu-devel] [PATCH v3 18/22] fuzz: expose fuzz target name 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is needed for the qos-assisted fuzzers which walk the qos tree and need a way to check if the current path matches the name of the fuzz target. Signed-off-by: Alexander Oleinik --- tests/fuzz/fuzz.c | 3 +++ tests/fuzz/fuzz.h | 1 + 2 files changed, 4 insertions(+) diff --git a/tests/fuzz/fuzz.c b/tests/fuzz/fuzz.c index 833f436731..d44dab7360 100644 --- a/tests/fuzz/fuzz.c +++ b/tests/fuzz/fuzz.c @@ -33,6 +33,9 @@ void set_fuzz_target_args(int argc, char **argv) fuzz_target->main_argv = argv; } } +char *get_fuzz_target_name(void){ + return fuzz_target->name->str; +} void reboot(QTestState *s) { diff --git a/tests/fuzz/fuzz.h b/tests/fuzz/fuzz.h index 73af029c82..d9d0bf11a8 100644 --- a/tests/fuzz/fuzz.h +++ b/tests/fuzz/fuzz.h @@ -19,6 +19,7 @@ typedef struct FuzzTarget { } FuzzTarget; void set_fuzz_target_args(int argc, char **argv); +char *get_fuzz_target_name(void); void reboot(QTestState *); void fuzz_add_target(const char *name, const char *description, FuzzTarget *target); From patchwork Wed Sep 18 23:19:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151295 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F303D112B for ; Wed, 18 Sep 2019 23:25:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B97C0218AF for ; Wed, 18 Sep 2019 23:25:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="kp5ZsuvG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B97C0218AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjJt-0006Md-Tb for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:25:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33400) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEj-0000b6-TR for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEh-0002ia-Vs for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:49 -0400 Received: from mail-eopbgr700099.outbound.protection.outlook.com ([40.107.70.99]:57953 helo=NAM04-SN1-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 1iAjEh-0002fm-QH for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XzP4mBA/FBJgqORvvbsh6JFiIchBtDgRHNKAw5G1iWvE1mHfRkJ+iOQHwpLwXVg5w2ZjH0ADpwVsLpodE+5IDYPr5JRv2fMOmLA0symTvrD+zTJkVImsBuQrvGlAtBoGMJymsCkShkwdVzdJJuTQXaiqIWTY5hdMkrefsowvo5V3fcwVe25S48mutdPPqL/+zEz/zgg67JVHRwxV3pcs8Oy2HeBcJWyVWMGFzTyyPfa+2dDBZ7dk5ps6ZH51zIFYazEv9Cevt7b/BcDsJguK3IoatkVOQ1YIrSZdviPMD//qUFSweXG1rw818lomryW2jaHkOBJ8OjJYx4C0NSPLjw== 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=zY9UORQvxGmDQrQOP5oxJUKIsHyBDXXdgY5bwuNdkhI=; b=HfzVgpkgDiUD7O7HIOHt7fhQCilh+rFdIIi0c74QjPySEw84UEqu52/ZYxpuwbZg2+U2JNJrpjwHmsp08yDGsWIu1JshNsnBeGA4S495FJWmt0EHAZ9BBEfWRI5PVdvQSg4WtvEIjf/vHQBjok7UifC5HBRA8O6CdtR/xs4JpAnZFrJSAgDLbuwJdGO9aa/WDI4PiVsCZ3pJhJQrkKOSs7to0mVlEm9n7NNgt77uVSA11T0mtNGSx7GGkbPgS0GJIJUCAtGJ3RKkSq9Qttrh7BZHrcfMEsVInTa5MmsqmWoGWjDID16ST/nPZv945L/Mtv1mOi9T1O38ibkjlhQG5Q== 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=zY9UORQvxGmDQrQOP5oxJUKIsHyBDXXdgY5bwuNdkhI=; b=kp5ZsuvGHvn356bf7lSmZ+aJx9SZAXSdh8vEn8CxymK1CuJ1Hxg88A4KldASdNfEWvUEr7r8wL8oZUU2V76n242SH/mgAeB+r+TCfPqFDawrdd5y0oH8BFcjesKo7xr32JGmhF6o9B2AFaDmO5m8OnCOxy7wJgTBeXDJSohnorU= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:46 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:46 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 19/22] fuzz: add support for qos-assisted fuzz targets Thread-Index: AQHVbnePnuUAaE8OSkmnvUPaB22v4Q== Date: Wed, 18 Sep 2019 23:19:46 +0000 Message-ID: <20190918231846.22538-20-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 8e1acde4-107c-46ad-6eda-08d73c8eb1be x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:295; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(14444005)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: o3ciTkwwKUzQD1fBlZhViDhfPBhNzIsbigLSM/DgibhHgX5b9oWqAlBaUBSO+iBOkj2FEcr/Cyg8F2jL+kWl8dhjS6PyTudpcji0TVltqpDJk6aVn3jpgNiDBsZaL1wLk+reFXM0Tuw+l7LMqz0afF+ZZW5p7lKv1sGX4OmKO5U5X9qW2rcFpSZJLfGyaP+V768C4gbMk3ebZoUC1fM92Kb13OLdf8Ihttpu7aEPR3C+/D5QurvFqEYRI6zzU1WEXA8hUjmJ8+WQcxIhq4HLUuH09hHvwL8tm6jVQlEJK6ZGkeE2Q79oOu/8Uslb9JuhyHMvF40EXqOsoEpk+vobSEvDWI1Brb+rHdYfawA+g4qFqwG5O6/vVdDv+uXJcg4YUI9GtjGBd1Y3l+oWy7YaDpryYaaWfPAKSB6L7MjX1oU= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 8e1acde4-107c-46ad-6eda-08d73c8eb1be X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:46.2773 (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: OOh0d1FeC8Rmv31I4UHmVusv60mfXKIJAIiXa6EpdsX4QVXnkv1QglEIlf7zlpR8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.99 Subject: [Qemu-devel] [PATCH v3 19/22] fuzz: add support for qos-assisted fuzz targets 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexander Oleinik --- tests/fuzz/qos_fuzz.c | 212 ++++++++++++++++++++++++++++++++++++++++++ tests/fuzz/qos_fuzz.h | 19 ++++ 2 files changed, 231 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..b08c8b37ba --- /dev/null +++ b/tests/fuzz/qos_fuzz.c @@ -0,0 +1,212 @@ +#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" + +/* + * 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 = qdict_new(); + QObject *response; + QDict *args = qdict_new(); + QList *lst; + Error *err = NULL; + + qmp_marshal_query_machines(NULL, &response, &err); + assert(!err); + lst = 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 = qobject_to(QList, response); + apply_to_qlist(lst, false); + qobject_unref(response); + qobject_unref(req); +} + +void *fuzz_qos_obj; +QGuestAllocator *fuzz_qos_alloc; + +static char **fuzz_path_vec; +static char **current_path; + + +void *qos_allocate_objects(QTestState *qts, QGuestAllocator **p_alloc) +{ + return allocate_objects(qts, current_path + 1, p_alloc); +} + + +static void qos_build_main_args() +{ + char **path = fuzz_path_vec; + QOSGraphNode *test_node; + GString *cmd_line = g_string_new(path[0]); + void *test_arg; + + /* Before test */ + current_path = path; + test_node = qos_graph_get_node(path[(g_strv_length(path) - 1)]); + test_arg = test_node->u.test.arg; + if (test_node->u.test.before) { + test_arg = 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=qtest -m 128 "); + wordexp_t result; + wordexp(cmd_line->str, &result, 0); + set_fuzz_target_args(result.we_wordc, result.we_wordv); + + g_string_free(cmd_line, true); +} + +/* + * 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/layer 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 command line */ + QOSEdgeType etype = QEDGE_CONSUMED_BY; + + /* twice QOS_PATH_MAX_ELEMENT_SIZE since each edge can have its arg */ + char **path_vec = g_new0(char *, (QOS_PATH_MAX_ELEMENT_SIZE * 2)); + int path_vec_size = 0; + + char *after_cmd, *before_cmd, *after_device; + GString *after_device_str = g_string_new(""); + char *node_name = orig_path->name, *path_str; + + GString *cmd_line = g_string_new(""); + GString *cmd_line2 = g_string_new(""); + + path = qos_graph_get_node(node_name); /* root */ + node_name = qos_graph_edge_get_dest(path->path_edge); /* machine name */ + + path_vec[path_vec_size++] = node_name; + path_vec[path_vec_size++] = qos_get_machine_type(node_name); + + for (;;) { + path = qos_graph_get_node(node_name); + if (!path->path_edge) { + break; + } + + node_name = qos_graph_edge_get_dest(path->path_edge); + + /* append node command line + previous edge command line */ + if (path->command_line && etype == 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++] = qos_graph_edge_get_name(path->path_edge); + /* detect if edge has command line args */ + after_cmd = qos_graph_edge_get_after_cmd_line(path->path_edge); + after_device = qos_graph_edge_get_extra_device_opts(path->path_edge); + before_cmd = qos_graph_edge_get_before_cmd_line(path->path_edge); + edge = qos_graph_get_edge(path->name, node_name); + etype = 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++] = 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 = g_strjoinv("/", path_vec + 1); + + /* Check that this is the test we care about: */ + char *test_name = strrchr(path_str, '/') + 1; + if (strcmp(test_name, get_fuzz_target_name()) == 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] = path_vec[0]; + path_vec[0] = g_string_free(cmd_line, false); + + fuzz_path_vec = path_vec; + } else { + g_free(path_vec); + } + + g_free(path_str); +} + +void fuzz_add_qos_target(const char *name, + const char *description, + const char *interface, + QOSGraphTestOptions *opts, + FuzzTarget *fuzz_opts + ) +{ + qos_add_test(name, interface, NULL, opts); + fuzz_add_target(name, description, fuzz_opts); +} + +/* Do what is normally done in qos_test.c:main */ +void qos_setup(void){ + qos_set_machines_devices_available(); + qos_graph_foreach_test_path(walk_path); + qos_build_main_args(); +} + +void qos_init_path(QTestState *s) +{ + fuzz_qos_obj = 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..4ae775972a --- /dev/null +++ b/tests/fuzz/qos_fuzz.h @@ -0,0 +1,19 @@ +#ifndef _QOS_FUZZ_H_ +#define _QOS_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(const char *name, + const char *description, + const char *interface, + QOSGraphTestOptions *opts, + FuzzTarget *fuzz_opts); + +void qos_init_path(QTestState *); +#endif From patchwork Wed Sep 18 23:19:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151307 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 901E1112B for ; Wed, 18 Sep 2019 23:31:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 65A6C218AE for ; Wed, 18 Sep 2019 23:31:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="fShz5ApA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65A6C218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjPe-0004n7-Df for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:31:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33405) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEj-0000bI-Vv for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEi-0002ir-Ch for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:49 -0400 Received: from mail-eopbgr700099.outbound.protection.outlook.com ([40.107.70.99]:57953 helo=NAM04-SN1-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 1iAjEi-0002fm-5T for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m/aq8fHSkG8u+nu8+bdM3QUgzQc76XyZF8/cVZBFh/91xXzJHFaEABTPA/Txn54/aWVdGLUBN4H/O9864QK9hW0hbjXd6QimrNhBz82tESyeDRPRr+h5uRfU1RjojhQuuSw2ZK6ttKOjAsZEVt23c8aIpDlk/4KXNXO64zS9wQIM6yFu08yCW8YRJcUXk0DIe/4DTNerEHtw2LamV7fi4BATryYjwVIkKyPGKzAAAxwavl9ZfoVSBzUm9RV3rOPwpzfyJ36K/xQSrSWMVcamORTdt2rXvEIB8iAAKLgwDNcHsIjtW02vrF7fBUxolRmRxiTSDJ8LL1LZyl+Rox5f3g== 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=p6ZesvWEygiaQIocLMsVJpfvQ9+yaIZ4TexpfQD12OI=; b=WolBjTo0C5bh+h1/HjgwPEFrdCplkwC5VguGcRwmpu2B2vN2zmtvBw1FluxMJs2r2XJvfbQH66Zf5u3QWBqRBUjgeujzmsx75jhsWXnqsvXfmbg6Xatcn7KtFJZnAEHHaSSNDLOgzRqPpJAEU6eu5WzdJaf44kEXbtVC1r4A+fPu32ticaGM8wtyHehEu00ezROs4NSjNIqPRkSH3Zcq8tUvTTydAUq9FmSaYCmCchU8n6GUbMztxBWdDLD+HH2ab4Xcha01xvh3SLn/ShutaxwMrGHB3GxzmJaQqxuz9H+0npM5HeEIvkqoLWhKFMUhcc9k7rgA2x8r4pZoMJbRgw== 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=p6ZesvWEygiaQIocLMsVJpfvQ9+yaIZ4TexpfQD12OI=; b=fShz5ApATosY+uUjvJw4uZJ7zVBOuorq+26GoUoBEXpfJ0JvmYd9Q3Hgh8O8sxXQpzANLIMdO7FwZHe/94wNC3X5wyO+ZJi26VZwDKKDXUtKAsoKeySJ0Lj0C4McsSo3V1qEf6or311dVAPqpnqIMtk49yv5D5EnbDFc74+c/zQ= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:47 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:47 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 20/22] fuzz: add i440fx fuzz targets Thread-Index: AQHVbnePWtatfk9UsEqKSplQiZtFcw== Date: Wed, 18 Sep 2019 23:19:47 +0000 Message-ID: <20190918231846.22538-21-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: ba506178-4ec1-4e02-6e0c-08d73c8eb243 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3276; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(1496009)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: V+yBaU5eyWnotseTuIW/FRSDZ76FoB7Has6Apy5khnCHWZ1FfhUwKwBqiNH0Bc90iGPPIegW1tNpQCw0Nr5gtuAmf8mNVv5CE7Md/lwDnUBKFhyfd1X34pCBuPg6amgvnIQYUeLcTgjWdqa0yfu01CX89sLwU5pysxjTI8lcy9fFGyXwxStAha7HHJMLMr+JPMAxeLJruV8POv/u6lL7xQgJlL7Hobb0/t+HPqHCXuyeC7cwyXBFEdu48XOmcVPpKtBRlOz+kugyAILFiY/rNh/B2SuKXEmywbFJSOIPZTz9SeO9fH4LbR9ocQBcXy3/e+Lgvd2NQKq3HsNDP7vnaRPd/mSRXjRHN9AZvnoqa/T9eBr/qe70uXjQFH2tkPIBJK3eeNautQMsKxXdr6ytCHpdqWpa/ml6cS/hdq5c2hk= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: ba506178-4ec1-4e02-6e0c-08d73c8eb243 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:47.1180 (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: j8zsjnjqtm0bN0QrBGZWIG32eELOWF6AQ68zdq+uefpvvuuoO3Y9gBIRWb7x7Qr8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.99 Subject: [Qemu-devel] [PATCH v3 20/22] fuzz: add i440fx fuzz targets 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- tests/fuzz/Makefile.include | 3 + tests/fuzz/i440fx_fuzz.c | 158 ++++++++++++++++++++++++++++++++++++ 2 files changed, 161 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 = $(libqos-obj-y) fuzz-obj-y += tests/libqtest.o fuzz-obj-y += tests/fuzz/fuzz.o fuzz-obj-y += tests/fuzz/fork_fuzz.o +fuzz-obj-y += tests/fuzz/qos_fuzz.o + +fuzz-obj-y += tests/fuzz/i440fx_fuzz.o FUZZ_LDFLAGS += -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..9079c40f55 --- /dev/null +++ b/tests/fuzz/i440fx_fuzz.c @@ -0,0 +1,158 @@ +#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" + +enum action_id { + WRITEB, + WRITEW, + WRITEL, + READB, + READW, + READL, +}; + +static void i440fx_fuzz_qtest(QTestState *s, + const unsigned char *Data, size_t Size) { + + typedef struct QTestFuzzAction { + uint8_t id; + uint8_t addr; + uint32_t value; + } QTestFuzzAction; + QTestFuzzAction *a = (QTestFuzzAction *)Data; + while (Size >= sizeof(QTestFuzzAction)) { + uint16_t addr = a->addr % 2 ? 0xcf8 : 0xcfc; + switch (a->id) { + 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; + } + a++; + Size -= sizeof(QTestFuzzAction); + } + qtest_clock_step_next(s); + main_loop_wait(true); + reboot(s); +} + +static void i440fx_fuzz_qos(QTestState *s, + const unsigned char *Data, size_t Size) { + + typedef struct QOSFuzzAction { + uint8_t id; + int devfn; + uint8_t offset; + uint32_t value; + } QOSFuzzAction; + + QOSFuzzAction *a = (QOSFuzzAction *)Data; + static QPCIBus *bus; + if (!bus) { + bus = qpci_new_pc(s, fuzz_qos_alloc); + } + + while (Size >= sizeof(QOSFuzzAction)) { + switch (a->id) { + 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; + } + a++; + Size -= sizeof(QOSFuzzAction); + } + qtest_clock_step_next(s); + main_loop_wait(true); +} + +static void i440fx_fuzz_qos_fork(QTestState *s, + const unsigned char *Data, size_t Size) { + if (fork() == 0) { + i440fx_fuzz_qos(s, Data, Size); + counter_shm_store(); + _Exit(0); + } else { + wait(NULL); + counter_shm_load(); + } +} + +static void fork_init(QTestState *s) +{ + counter_shm_init(); +} +static const char *i440fx_qtest_argv[] = {"qemu_system_i386", "-machine", "accel=qtest"}; + +static void register_pci_fuzz_targets(void) +{ + /* Uses simple qtest commands and reboots to reset state */ + fuzz_add_target("i440fx-qtest-reboot-fuzz", + "Fuzz the i440fx using raw qtest commands and rebooting" + "after each run", + &(FuzzTarget){ + .fuzz = i440fx_fuzz_qtest, + .main_argc = 3, + .main_argv = (char **)i440fx_qtest_argv, + }); + + /* Uses libqos and forks to prevent state leakage */ + fuzz_add_qos_target("i440fx-qos-fork-fuzz", + "Fuzz the i440fx using qos helpers and forking" + "for each run", + "i440FX-pcihost", + &(QOSGraphTestOptions){}, + &(FuzzTarget){ + .pre_main = &qos_setup, + .pre_fuzz = &fork_init, + .fuzz = &i440fx_fuzz_qos_fork + }); + + /* Uses libqos. Doesn't do anything to reset state. Note that if we were to + reboot after each run, we would also have to redo the qos-related + initialization (qos_init_path) */ + fuzz_add_qos_target("i440fx-qos-nocleanup-fuzz", + "Fuzz the i440fx using qos helpers. No cleanup done after each run", + "i440FX-pcihost", + &(QOSGraphTestOptions){}, + &(FuzzTarget){ + .pre_main = &qos_setup, + .fuzz = &i440fx_fuzz_qos + }); +} + +fuzz_target_init(register_pci_fuzz_targets); From patchwork Wed Sep 18 23:19:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151313 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01BC61599 for ; Wed, 18 Sep 2019 23:34:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA4A0218AE for ; Wed, 18 Sep 2019 23:34:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="z5NZaE43" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA4A0218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjTB-00084o-EP for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:34:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33421) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEl-0000cj-4L for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEj-0002jg-N2 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:51 -0400 Received: from mail-eopbgr700101.outbound.protection.outlook.com ([40.107.70.101]:46848 helo=NAM04-SN1-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 1iAjEj-0002jO-Gj for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fVxBvzw1CFXugJwvoby/fjVvJjt8kKENGixGkl4jooolO//bNNay6qrqSSqfjuS85X1wTADOYiAeM/gY+K5xASbLzLo4seXhVheNNDOzILPgDGzXvNNaD53AUIiLJJVsfkmgd9nwG61NOwKRnWp1JwVPwisZ7FGDKiVYGPCqlI5OFiU7ba7NtfHqRAbKFjNSTFenbLCA8LIxfdYq+7YWap8fhIABcNFuFK3V9hJlHBb15NvTlDdGE6jbmF9GKzBRjF6EdgkdBT7A4SKZBD2QVgLlLBPS6w5HGgwq9d9KW793VnPENbuxkPlipfuSNzz2Qh/uzKGSvq8GK45L1UqQyw== 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=NaAtYseh65x/d3UGsiucJwoWC+0RpGRuZP8OwLHMaOo=; b=RV92n9MHI4BgrHD8zmPdKy0sdW2K8mKTauLpJHsXyhQqjZr9L20BE9z4UfR6q/yDN/PGi0mIGas9BG57wLnxVhDn8uizsqUPSkJelMEuJR1O5MrVrLi+m7fyzQ6U3GnjcvajWmIqjHmBNE+/qe4N+1fZ5e0AIU5WpR0mPp80cy+h4W3JzTEs13ej7LInUUifsNETiEwStHnpWlB5utMZqJ8w/a0FqMbi/HZiO2xGmGKKATB2Yayugvwu3fh1x25r6f5UTtIGZjPePmKw/ROeQffL4+Hn1jUMrNNz70XFvmZfZwswhnCz9aiZFFLiQJ1kfTqcfVnC4qDeT1k92lw+Hg== 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=NaAtYseh65x/d3UGsiucJwoWC+0RpGRuZP8OwLHMaOo=; b=z5NZaE43DUYGLysH1BdSROYQ5PNOtzIO6ETx8jT8W6IGb4vmFMPkaYOMqlcaw2w3KboChUkTSyBgEUdk3eb3n1IA/twczsFN4wAUF08MAhl8Mdepx+d8VBNkxnQk0scXomj3ZTP5WliHA/zjT9vzBQ0bAsYO7a1dQHJ+BFmzpUM= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:48 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:48 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 21/22] fuzz: add virtio-net fuzz target Thread-Index: AQHVbneQEdirmkkfcka7ttB8S+fEzw== Date: Wed, 18 Sep 2019 23:19:47 +0000 Message-ID: <20190918231846.22538-22-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 46c9f0af-c71f-4fc5-428f-08d73c8eb2b8 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:216; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(1496009)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: IeeJr64xWsQNtzLTIcmVxYdomAv2rwgKm6CqI44IB8ynuQqJUMh1L0oKM0a4QnESD5FwQXk08ApOOKyDX55wqyztX1E1OYliMRafGUFpJsbiYOvQEHluP5c2fLiZ1oHnPR5/w707pFTPPAhScvYQiOQaCkB0Q0LCYfyymjmcPrumWv3hy4fj5vgtLsohsDkoYSDuQKnvZUR5HUzJFD94YhIBR0QAD+lCieGw5u+Xh5SXy1BAcp79A/kDIOA673xdIO428mq69aCRJyqQV9ochVV8ePYzyeRD8fBRY6F6geuey+NF8cwVT2AeHkZRzED50nzlF/Ke7I8kty/OmZIjcGdEOmuaNNS7yhAiYeuQNSAGmagvWBlN9ErCDQJ6X3SxYbRNlTDO7rak/A8gl1FILBgxhvW0obcf1V4OE3i0g1U= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 46c9f0af-c71f-4fc5-428f-08d73c8eb2b8 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:47.9236 (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: ahqQ96lOMiWjXGaBG+jerGEw8C4m23TxWBYOwK1SjSOKV6TZIBfzF8joCfsI5NzD X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.101 Subject: [Qemu-devel] [PATCH v3 21/22] fuzz: add virtio-net fuzz target 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 | 120 +++++++++++++++++++++++++++++++++++ 2 files changed, 121 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 += tests/fuzz/fork_fuzz.o fuzz-obj-y += tests/fuzz/qos_fuzz.o fuzz-obj-y += tests/fuzz/i440fx_fuzz.o +fuzz-obj-y += tests/fuzz/virtio_net_fuzz.o FUZZ_LDFLAGS += -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..2f6e14b06d --- /dev/null +++ b/tests/fuzz/virtio_net_fuzz.c @@ -0,0 +1,120 @@ +#include "qemu/osdep.h" + +#include "qemu/main-loop.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_ctrl_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 = 0; + uint32_t free_head = 0; + + QGuestAllocator *t_alloc = fuzz_qos_alloc; + + QVirtioNet *net_if = fuzz_qos_obj; + QVirtioDevice *dev = net_if->vdev; + QVirtQueue *q; + vq_action vqa; + int iters = 0; + while (true) { + if (Size < sizeof(vqa)) { + break; + } + vqa = *((vq_action *)Data); + Data += sizeof(vqa); + Size -= sizeof(vqa); + + q = net_if->queues[vqa.queue % 3]; + + vqa.length = vqa.length >= Size ? Size : vqa.length; + + req_addr[reqi] = guest_alloc(t_alloc, vqa.length); + qtest_memwrite(s, req_addr[reqi], Data, vqa.length); + if (iters == 0) { + free_head = 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 == 10) { + break; + } + Data += vqa.length; + Size -= vqa.length; + } + if (iters) { + qvirtqueue_kick(s, dev, q, free_head); + qtest_clock_step_next(s); + main_loop_wait(false); + for (int i = 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 = g_new(int, 2); + int ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sv); + fcntl(sv[0], F_SETFL, O_NONBLOCK); + g_assert_cmpint(ret, !=, -1); + } + g_string_append_printf(cmd_line, " -netdev socket,fd=%d,id=hs0 ", sv[1]); + return arg; +} + +static void virtio_net_fork_fuzz(QTestState *s, + const unsigned char *Data, size_t Size) +{ + if (fork() == 0) { + virtio_net_ctrl_fuzz_multi(s, Data, Size); + counter_shm_store(); + _Exit(0); + } else { + wait(NULL); + counter_shm_load(); + } +} + +static void fork_init(QTestState *s) +{ + qos_init_path(s); + counter_shm_init(); +} + +static void register_virtio_net_fuzz_targets(void) +{ + fuzz_add_qos_target("virtio-net-fork-fuzz", + "Fuzz the virtio-net virtual queues, forking for each fuzz run", + "virtio-net", + &(QOSGraphTestOptions){.before = virtio_net_test_setup_socket}, + &(FuzzTarget){ + .pre_main = &qos_setup, + .pre_fuzz = &fork_init, + .fuzz = &virtio_net_fork_fuzz + }); +} + +fuzz_target_init(register_virtio_net_fuzz_targets); From patchwork Wed Sep 18 23:19:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Bulekov X-Patchwork-Id: 11151315 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1968B14DB for ; Wed, 18 Sep 2019 23:35:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2E7E218AE for ; Wed, 18 Sep 2019 23:35:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bushare.onmicrosoft.com header.i=@bushare.onmicrosoft.com header.b="qnF6ANOe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2E7E218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bu.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjTd-00008A-JP for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Sep 2019 19:35:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33429) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjEl-0000dh-Qs for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjEk-0002k6-2n for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:51 -0400 Received: from mail-eopbgr700101.outbound.protection.outlook.com ([40.107.70.101]:46848 helo=NAM04-SN1-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 1iAjEj-0002jO-Sa for qemu-devel@nongnu.org; Wed, 18 Sep 2019 19:19:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hYktvPTje5lD0QP/psbpddcqAcLPqCvjq3r/LgzMHtumYkebWraHLF8zpKL6ZCTXNLCGQeUpO1D72k+zdgxYW+vOmGcbs6rJLKSqX35p4Pcm5F6iQktxG3Q+AdrxOwL4W+Qsec7M6Z8keX90kQx9AiXTIrUfnB1wVH16RStUNP2eWymJze1CqHOiFmbUeTS6SZj0ZZ47CuChaq1OuWaLzWiVzhORHVBxtDCPcLWKZo/D79kyfKdrOaQ6HR5B34O61Bb0L2+U0Zafg8dWUQdKvsReylRY5XzykgHvuUKxoTJepwTL4TXiQ0GAE7/GQdED6A8bEz3x3SbFuyRTwq7QPw== 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=35WXf4PmtsVb8aeIi7GRO2/t/g9rmSMUSEvk+8j9sBw=; b=FXdaFH/U/gLc5Lg0uw9uD1DmbdTtb+iO8fQY9l7fbaeKzJVmboFsAhv3SaLc2uXM1COBh55x7VcuXI8/sL/sjT9Qpgk6esyvfSH6+1ADo/mIzqxyOLGC5KIqSBocASyiLBrRSEFHVVov9JpI2y1dBIXc0S9vfukTjmzAvrPKj96947712y6odHLNZNYXi7lj+igS/VF3WDea7i/NpLI93Z2JjOJDlLRXWzlt5c7E+uJeAHe79jJL71E+gMmENKd2dkbP2/NQoJTgW4BzUFm1HjWCN4qPB91fAcX7b2ADLNAuZ3HACrgLAIGOG7HDB76tN6yZ8bCY+Xj827L7mOQ3vg== 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=35WXf4PmtsVb8aeIi7GRO2/t/g9rmSMUSEvk+8j9sBw=; b=qnF6ANOebTq1bahkdZNZXYyHALkYBr6yio+eXmvrkg1br4AORLSQGWk25Q9mqctJ271it/t7p1RJXTitmugve+K4ALEJQ+tQjFDaDLOJtiVJr3ai7rCSYNxyKPw8VIIvJ2cmcM1onhVfLYPtxdFhz0tBTUgOWdDe2IRtz2RDKfY= Received: from CY4PR03MB2872.namprd03.prod.outlook.com (10.175.118.17) by CY4PR03MB3016.namprd03.prod.outlook.com (10.175.117.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 18 Sep 2019 23:19:48 +0000 Received: from CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107]) by CY4PR03MB2872.namprd03.prod.outlook.com ([fe80::6d88:c5bd:41ad:b107%3]) with mapi id 15.20.2263.023; Wed, 18 Sep 2019 23:19:48 +0000 From: "Oleinik, Alexander" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 22/22] fuzz: add documentation to docs/devel/ Thread-Index: AQHVbneQioRrB1GE6EuvuszSk8W0eA== Date: Wed, 18 Sep 2019 23:19:48 +0000 Message-ID: <20190918231846.22538-23-alxndr@bu.edu> References: <20190918231846.22538-1-alxndr@bu.edu> In-Reply-To: <20190918231846.22538-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: BL0PR02CA0124.namprd02.prod.outlook.com (2603:10b6:208:35::29) To CY4PR03MB2872.namprd03.prod.outlook.com (2603:10b6:903:134::17) 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: 56310e6f-1920-474e-7eec-08d73c8eb333 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR03MB3016; x-ms-traffictypediagnostic: CY4PR03MB3016: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(1496009)(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(199004)(189003)(66066001)(86362001)(52116002)(478600001)(2616005)(7736002)(71190400001)(8676002)(36756003)(71200400001)(14454004)(54906003)(316002)(786003)(6486002)(14444005)(81156014)(75432002)(256004)(6436002)(305945005)(6916009)(6512007)(5640700003)(386003)(486006)(26005)(11346002)(186003)(102836004)(99286004)(76176011)(66946007)(446003)(476003)(66476007)(66556008)(64756008)(66446008)(6506007)(5660300002)(4326008)(2501003)(2351001)(6116002)(81166006)(50226002)(25786009)(1076003)(2906002)(88552002)(8936002)(3846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB3016; H:CY4PR03MB2872.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: bu.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: NyrKd7o9S7+bH8WqH5RtDCeaWcAGazSpjOF8AmGoizS11PZxbxKDy1IXQ3/KHPmq7+ihtitPUpd8Sgn8BjLix6ll5xHmK/eyEICHehEB1IgosWegIc2FfX+5evGKLZFo2Vt4jFNaMNOeTzsQLf77zTE6VTwlWnuDQUwxlPi7nfobcHN1bxL3mfHBA1wWHP7dk4DATqmcyL7cyUOmdxK7Fux9DTjRO20ziD5SxLivykmv0GfSUrsEBegodcYNWu9FuLz3OovlbGBvwn1XM9ZCDW/4dn0wiRFXMWCcNoY0qF/0TB55amc+zbHITOkhCG4nw5mWvQnDXwkWbeUgiubxEU3lMcYKY15EsKR0m7K+yw6uqhPHdpYBy6/PfxCLstnxU7We603/W1lzRAR/u6BYLT9NfteehR+yKakalY/vXio= MIME-Version: 1.0 X-OriginatorOrg: bu.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 56310e6f-1920-474e-7eec-08d73c8eb333 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 23:19:48.6853 (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: OQzuZP61t8A29U8h4vtmo2MkbBndbWoCKDo2isD8iD9Qc3RIcxqgQgLW7puLuOaJ X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3016 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.101 Subject: [Qemu-devel] [PATCH v3 22/22] fuzz: add documentation to docs/devel/ 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: "pbonzini@redhat.com" , "bsd@redhat.com" , "stefanha@redhat.com" , "Oleinik, Alexander" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexander Oleinik --- docs/devel/fuzzing.txt | 114 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 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..53a1f858f5 --- /dev/null +++ b/docs/devel/fuzzing.txt @@ -0,0 +1,114 @@ += Fuzzing = + +== Introduction == + +This document describes the virtual-device fuzzing infrastructure in QEMU and +how to use it to implement additional fuzzers. + +== Basics == + +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. + +To fuzz QEMU, we rely on libfuzzer. Unlike other fuzzers such as AFL, libfuzzer +is an _in-process_ fuzzer. For the developer, this means that it is their +responsibility to ensure that state is reset between fuzzing-runs. + +== Building the fuzzers == + +NOTE: If possible, build a 32-bit binary. When forking, the page map ends up +being much smaller. On 64-bit AddressSanitizer consumes 20 Terabytes of virtual +memory. + +To build the fuzzers, install a recent version of clang: +Configure with (substitute the clang binaries with the version you installed): + + CC=clang-8 CXX=clang++-8 /path/to/configure --enable-fuzzing + +Fuzz targets are built similarily to system/softmmu: + + make i386-softmmu/fuzz + +This builds ./i386-softmmu/qemu-fuzz-i386 + +The first option to this command is: --FUZZER_NAME +To list all of the available fuzzers run qemu-fuzz-i386 with no arguments. + +Libfuzzer parses all arguments that do not begin with "--". Information about +these is available by passing -help=1 + +Now the only thing left to do is wait for the fuzzer to trigger potential +crashes. + +== Adding a new fuzzer == +Coverage over virtual devices can be improved by adding additional fuzzers. +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 devices. + +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 fuzzers +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 commands, +addresses, or values. + + += Implmentation Details = + +== The Fuzzer's Lifecycle == + +The fuzzer has two entrypoints that libfuzzer calls. + +LLVMFuzzerInitialize: called prior to fuzzing. Used to initialize all of the +necessary state + +LLVMFuzzerTestOneInput: called for each fuzzing run. Processes the input and +resets the state at the end of each run. + +In more detail: + +LLVMFuzzerInitialize parses the arguments to the fuzzer (must start with two +dashes, so they are ignored by libfuzzer main()). Currently, the arguments +select the fuzz target. Then, the qtest client is initialized. If the target +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 initilization +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: +1. Reboot the guest between runs. + Pros: Straightforward and fast for simple fuzz targets. + 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 after + each reboot. + Example target: --virtio-net-ctrl-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 "deferred" + 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 and the implementation is very + flimsy. Does not work well for devices that rely on dedicated threads. + Example target: --qtest-fork-fuzz +