From patchwork Fri Jun 7 09:05:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3FE77924 for ; Fri, 7 Jun 2019 09:15:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F6222022C for ; Fri, 7 Jun 2019 09:15:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23ED728B22; Fri, 7 Jun 2019 09:15:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D27D62022C for ; Fri, 7 Jun 2019 09:15:34 +0000 (UTC) Received: from localhost ([::1]:47386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAyD-0004Zl-M6 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:15:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39330) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAoz-00047K-Qw for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAox-0004Fy-7x for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:01 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:38220) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAou-0003sj-0d for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:05:58 -0400 Received: by mail-wm1-x332.google.com with SMTP id t5so1133586wmh.3 for ; Fri, 07 Jun 2019 02:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ngCYt07rD9S6NfmUGM8XQw4uLZvtIN9Vg7GKA5tvoZU=; b=Q8/wb5mWbbg9YxQUW1002d9yliCB1GtRry9dHyWhIdUjJJ7Vgk3twD3KFbhHlrIgth DOz5EGgaTDm6rxzc78rUL7zSI6mba/ocLSz/31tIm8oElVbcnQA/gt6WC5Slms1nWc5r bDK/cXa6DAfbgTDDOu0sF1tBski+OkF+gQcnhnl+T1/omCTzpREQjt8u0P3FLobZtSUb UgVPfbbRpDbvUfg2133r7rAkf3ne0VPPHaTjipPUhRSRjI23uB2SNci3k6RQtlmDHIjL bD8PolZRRycr57MzmIyC/J8RvLZwSeRa1dbR/0zjwPoo0c+qmvJKzd38C9ZYoWzTlBUo HXlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ngCYt07rD9S6NfmUGM8XQw4uLZvtIN9Vg7GKA5tvoZU=; b=EHX8HxACOaCT8VGOZmQFqXIXbud+mi3Nl6oRCITKc+x46+D0hQoqhra5ssa+jZcdGj ibeatbytuICDEurD+SzOzubRqhirLKh+5XvXlil2Soa5CuNDOgRzqwGB1FjVTgDExkbS 2kAkGBBwHcQguG6L8MNgH5ZeQ1bgiT+o97zYszBXU4qQsmbezPO5mGqLLUoTpgrObNRl rc10Wv3je0gBUb2phOX11nwdDvn5I/0IIjEiEqv37F1AZ1N8xq1lsUWg17drhSiutFno rZuN6pvW7Wdul+h4oX4cY4as6V9Mz3FOiVP0zhd1xVn8eqCQdfJ2Q8dAT5I1iUx8qToq mEag== X-Gm-Message-State: APjAAAXT0ZK6Yed8/HB5YKGHX4KJRbCNakxWgiSSIQj9kNUBwN8IQfmo LpIgM+F0Wqmkf3So7ryRKFUe1w== X-Google-Smtp-Source: APXvYqwH99jO3voaQpogWz065ubedl5AqOligoC9Zh+pxu6bLHQOpBKgk6PLM2imPxv1HySo1pvVlA== X-Received: by 2002:a1c:2e09:: with SMTP id u9mr2869870wmu.137.1559898353495; Fri, 07 Jun 2019 02:05:53 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k10sm1244766wmj.37.2019.06.07.02.05.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:52 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1D9B71FF8C; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:00 +0100 Message-Id: <20190607090552.12434-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PULL 01/52] editorconfig: add setting for shell scripts 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: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson diff --git a/.editorconfig b/.editorconfig index df6db65531..a001f340bd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -26,6 +26,10 @@ file_type_emacs = makefile indent_style = space indent_size = 4 +[*.sh] +indent_style = space +indent_size = 4 + [*.{s,S}] indent_style = tab indent_size = 8 From patchwork Fri Jun 7 09:05:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27FCE15E6 for ; Fri, 7 Jun 2019 09:09:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15722288AE for ; Fri, 7 Jun 2019 09:09:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0501028B1C; Fri, 7 Jun 2019 09:09:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5545D288AE for ; Fri, 7 Jun 2019 09:09:39 +0000 (UTC) Received: from localhost ([::1]:47146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAsU-00089h-EI for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:09:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39332) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAoz-00047M-RG for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAox-0004GA-9N for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:01 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:40205) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAot-0003x4-WA for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:05:58 -0400 Received: by mail-wm1-x336.google.com with SMTP id v19so1129291wmj.5 for ; Fri, 07 Jun 2019 02:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cQ0tfgve/Y4PUSaOnIOLkGNDESD+hZVEqLt68K3UEOk=; b=G81clC+6/P6GAgE93dcnmL4e5LVMKsjrJrY4MBsEWmB01u7eYsJW7EtsHx8fzhVbm6 /qUB7f3Ppwh6JuWvf1NXnEJgP8KhdFLymDEmQGH77I/NdjUf6jFgu+V293Eh9VYu5cLs djjxsFxqVOHZPD5OUC8RssqPsMSVpCXOlaJBQ3CecndxUQRf95F7Q8MoJ4AM3BRc9JPv Z7mLpwCcSXP4xfQFhjXDeHaSNdPMVlvPFRUAp76yxRz91S1dICDMYTUL2BTtFd5gQ4YI /lwBqTr8vZ9NNkli82z1uOwWsrnJrXkgBFgSD74Hn1zTO1EyQuf3w8zL1EjrgZxEBJft XvAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cQ0tfgve/Y4PUSaOnIOLkGNDESD+hZVEqLt68K3UEOk=; b=juUy2Zncm+pNe2WuLwhtoUYNwTmKjBcOyu7gyDEDcTSHkCwm6HwMFse5CKs1ocD6uF UzArbuxftmnx9PF/vKCN1XY3TkimnQnMIKqJiwkavjp2wkWjG8Bc7M5z5d3LaCJziXuH Eqx2xfWqbh2aIXcuvmbIgPp9pTptmn5Kk1MXoVeFcUL/wNcMXb0PGSxIId+oAz5PJR0Z CJ0n4WmWSSh5w+f4YhsjQ3VxXGU/Df8bZNHzzOwD9uabKH0GjANqvR89fcKF9cX7UjH2 1Fog0xTQqKo84Z6DBY9rSrnLKdGGJbbzZw08d99EpaBBOQn/igxS1ZuoKRU78htQ0CFF zc2w== X-Gm-Message-State: APjAAAWis6lTZ5rZlI2J2aYg5bYVwaULAkLu2sZVLyz84W9SuVpBS0kJ 3bfp6xYuQ6S4OkVJYZHfIN7JoQ== X-Google-Smtp-Source: APXvYqxCVlz13wYOW5kUYe7r8GvRQScEhevm+lRlkAIevQy3Wq4ptpj8tHG0U0BD8rFt6Vm3hU8S5Q== X-Received: by 2002:a1c:cb43:: with SMTP id b64mr2753473wmg.135.1559898354536; Fri, 07 Jun 2019 02:05:54 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x16sm1209094wmj.4.2019.06.07.02.05.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:53 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 31A421FF8F; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:01 +0100 Message-Id: <20190607090552.12434-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::336 Subject: [Qemu-devel] [PULL 02/52] qemu-io-cmds: use clock_gettime for benchmarking 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: Kevin Wolf , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, "open list:Block layer core" , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The previous use of gettimeofday() ran into undefined behaviour when we ended up doing a div 0 for a very short operation. This is because gettimeofday only works at the microsecond level as well as being prone to discontinuous jumps in system time. Using clock_gettime with CLOCK_MONOTONIC gives greater precision and alleviates some of the potential problems with time jumping around. We could use CLOCK_MONOTONIC_RAW to avoid being tripped up by NTP and adjtime but that is Linux specific so I decided it would do for now. Signed-off-by: Alex Bennée diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 30a7d9a13b..8904733961 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -248,20 +248,21 @@ static void cvtstr(double value, char *str, size_t size) -static struct timeval tsub(struct timeval t1, struct timeval t2) +static struct timespec tsub(struct timespec t1, struct timespec t2) { - t1.tv_usec -= t2.tv_usec; - if (t1.tv_usec < 0) { - t1.tv_usec += 1000000; + t1.tv_nsec -= t2.tv_nsec; + if (t1.tv_nsec < 0) { + t1.tv_nsec += NANOSECONDS_PER_SECOND; t1.tv_sec--; } t1.tv_sec -= t2.tv_sec; return t1; } -static double tdiv(double value, struct timeval tv) +static double tdiv(double value, struct timespec tv) { - return value / ((double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0)); + double seconds = tv.tv_sec + (tv.tv_nsec / 1e9); + return value / seconds; } #define HOURS(sec) ((sec) / (60 * 60)) @@ -274,29 +275,27 @@ enum { VERBOSE_FIXED_TIME = 0x2, }; -static void timestr(struct timeval *tv, char *ts, size_t size, int format) +static void timestr(struct timespec *tv, char *ts, size_t size, int format) { - double usec = (double)tv->tv_usec / 1000000.0; + double frac_sec = tv->tv_nsec / 1e9; if (format & TERSE_FIXED_TIME) { if (!HOURS(tv->tv_sec)) { - snprintf(ts, size, "%u:%02u.%02u", - (unsigned int) MINUTES(tv->tv_sec), - (unsigned int) SECONDS(tv->tv_sec), - (unsigned int) (usec * 100)); + snprintf(ts, size, "%u:%05.2f", + (unsigned int) MINUTES(tv->tv_sec), + SECONDS(tv->tv_sec) + frac_sec); return; } format |= VERBOSE_FIXED_TIME; /* fallback if hours needed */ } if ((format & VERBOSE_FIXED_TIME) || tv->tv_sec) { - snprintf(ts, size, "%u:%02u:%02u.%02u", + snprintf(ts, size, "%u:%02u:%05.2f", (unsigned int) HOURS(tv->tv_sec), (unsigned int) MINUTES(tv->tv_sec), - (unsigned int) SECONDS(tv->tv_sec), - (unsigned int) (usec * 100)); + SECONDS(tv->tv_sec) + frac_sec); } else { - snprintf(ts, size, "0.%04u sec", (unsigned int) (usec * 10000)); + snprintf(ts, size, "%05.2f sec", frac_sec); } } @@ -376,7 +375,7 @@ static void dump_buffer(const void *buffer, int64_t offset, int64_t len) } } -static void print_report(const char *op, struct timeval *t, int64_t offset, +static void print_report(const char *op, struct timespec *t, int64_t offset, int64_t count, int64_t total, int cnt, bool Cflag) { char s1[64], s2[64], ts[64]; @@ -649,7 +648,7 @@ static const cmdinfo_t read_cmd = { static int read_f(BlockBackend *blk, int argc, char **argv) { - struct timeval t1, t2; + struct timespec t1, t2; bool Cflag = false, qflag = false, vflag = false; bool Pflag = false, sflag = false, lflag = false, bflag = false; int c, cnt, ret; @@ -758,13 +757,13 @@ static int read_f(BlockBackend *blk, int argc, char **argv) buf = qemu_io_alloc(blk, count, 0xab); - gettimeofday(&t1, NULL); + clock_gettime(CLOCK_MONOTONIC, &t1); if (bflag) { ret = do_load_vmstate(blk, buf, offset, count, &total); } else { ret = do_pread(blk, buf, offset, count, &total); } - gettimeofday(&t2, NULL); + clock_gettime(CLOCK_MONOTONIC, &t2); if (ret < 0) { printf("read failed: %s\n", strerror(-ret)); @@ -836,7 +835,7 @@ static const cmdinfo_t readv_cmd = { static int readv_f(BlockBackend *blk, int argc, char **argv) { - struct timeval t1, t2; + struct timespec t1, t2; bool Cflag = false, qflag = false, vflag = false; int c, cnt, ret; char *buf; @@ -891,9 +890,9 @@ static int readv_f(BlockBackend *blk, int argc, char **argv) return -EINVAL; } - gettimeofday(&t1, NULL); + clock_gettime(CLOCK_MONOTONIC, &t1); ret = do_aio_readv(blk, &qiov, offset, &total); - gettimeofday(&t2, NULL); + clock_gettime(CLOCK_MONOTONIC, &t2); if (ret < 0) { printf("readv failed: %s\n", strerror(-ret)); @@ -972,7 +971,7 @@ static const cmdinfo_t write_cmd = { static int write_f(BlockBackend *blk, int argc, char **argv) { - struct timeval t1, t2; + struct timespec t1, t2; bool Cflag = false, qflag = false, bflag = false; bool Pflag = false, zflag = false, cflag = false; int flags = 0; @@ -1091,7 +1090,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv) buf = qemu_io_alloc(blk, count, pattern); } - gettimeofday(&t1, NULL); + clock_gettime(CLOCK_MONOTONIC, &t1); if (bflag) { ret = do_save_vmstate(blk, buf, offset, count, &total); } else if (zflag) { @@ -1101,7 +1100,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv) } else { ret = do_pwrite(blk, buf, offset, count, flags, &total); } - gettimeofday(&t2, NULL); + clock_gettime(CLOCK_MONOTONIC, &t2); if (ret < 0) { printf("write failed: %s\n", strerror(-ret)); @@ -1160,7 +1159,7 @@ static const cmdinfo_t writev_cmd = { static int writev_f(BlockBackend *blk, int argc, char **argv) { - struct timeval t1, t2; + struct timespec t1, t2; bool Cflag = false, qflag = false; int flags = 0; int c, cnt, ret; @@ -1213,9 +1212,9 @@ static int writev_f(BlockBackend *blk, int argc, char **argv) return -EINVAL; } - gettimeofday(&t1, NULL); + clock_gettime(CLOCK_MONOTONIC, &t1); ret = do_aio_writev(blk, &qiov, offset, flags, &total); - gettimeofday(&t2, NULL); + clock_gettime(CLOCK_MONOTONIC, &t2); if (ret < 0) { printf("writev failed: %s\n", strerror(-ret)); @@ -1250,15 +1249,15 @@ struct aio_ctx { bool zflag; BlockAcctCookie acct; int pattern; - struct timeval t1; + struct timespec t1; }; static void aio_write_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; - struct timeval t2; + struct timespec t2; - gettimeofday(&t2, NULL); + clock_gettime(CLOCK_MONOTONIC, &t2); if (ret < 0) { @@ -1288,9 +1287,9 @@ out: static void aio_read_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; - struct timeval t2; + struct timespec t2; - gettimeofday(&t2, NULL); + clock_gettime(CLOCK_MONOTONIC, &t2); if (ret < 0) { printf("readv failed: %s\n", strerror(-ret)); @@ -1425,7 +1424,7 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv) return -EINVAL; } - gettimeofday(&ctx->t1, NULL); + clock_gettime(CLOCK_MONOTONIC, &ctx->t1); block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, BLOCK_ACCT_READ); blk_aio_preadv(blk, ctx->offset, &ctx->qiov, 0, aio_read_done, ctx); @@ -1570,7 +1569,7 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv) return -EINVAL; } - gettimeofday(&ctx->t1, NULL); + clock_gettime(CLOCK_MONOTONIC, &ctx->t1); block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, BLOCK_ACCT_WRITE); @@ -1746,7 +1745,7 @@ static const cmdinfo_t discard_cmd = { static int discard_f(BlockBackend *blk, int argc, char **argv) { - struct timeval t1, t2; + struct timespec t1, t2; bool Cflag = false, qflag = false; int c, ret; int64_t offset, bytes; @@ -1787,9 +1786,9 @@ static int discard_f(BlockBackend *blk, int argc, char **argv) return -EINVAL; } - gettimeofday(&t1, NULL); + clock_gettime(CLOCK_MONOTONIC, &t1); ret = blk_pdiscard(blk, offset, bytes); - gettimeofday(&t2, NULL); + clock_gettime(CLOCK_MONOTONIC, &t2); if (ret < 0) { printf("discard failed: %s\n", strerror(-ret)); From patchwork Fri Jun 7 09:05:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 51BC96C5 for ; Fri, 7 Jun 2019 09:07:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4179828A15 for ; Fri, 7 Jun 2019 09:07:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 360D528B1B; Fri, 7 Jun 2019 09:07:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D7E8C28A15 for ; Fri, 7 Jun 2019 09:07:29 +0000 (UTC) Received: from localhost ([::1]:47126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAqJ-0005tg-36 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:07:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39328) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAoz-00047I-Qr for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAox-0004G8-9Y for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:01 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:41279) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAou-0003yc-1U for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:05:58 -0400 Received: by mail-wr1-x436.google.com with SMTP id c2so1337965wrm.8 for ; Fri, 07 Jun 2019 02:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qCnUPR9lwJDCVN+3iAAkawz91A004gE5+vwI6CE6U4k=; b=C1xkaCfPyiVd7QKIq+Jx8gMCa0vNYwcNBA7ZrqE7ZgsLK7JMkxqnA5jF2C3Vniyp8d ryqpI9fQrhCYF3H5/6HQnOzLhUotjJKPhHaqZ2oAJHFNtFekKM52EOveiO203X6t7Mdr aRrB00uqa2/EjDB3C0BHWTFvxCF9/EPilAmexy1ixJHDd8gFVTuxgvVH+bhxOY648sxR wbnxFbEeyTyPwIWCg8kuaaORXl+RJ0VogkU5dySS3x106k9c31GnleOjc+EPXn2OK4m5 DDUtL30zXHlYkmzLkVfRgHLJbPEfUa+Tn4U6OC1y91Tv1RSRFYNH3kANFw7NOxmUHMkc M59g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qCnUPR9lwJDCVN+3iAAkawz91A004gE5+vwI6CE6U4k=; b=n+pA9xHT1JyDQ5JpFfVOglztH856VSAxP1m2t3H7VQ05g6gf0fxGXSVU+GfVqlBX/q TeMCNO8Pbv5olJECX6RRhEM/bPkaeq7w0SCULYkJcTr8EoXWy3jNO7CLCmVuqmcJtzl8 oKWFkWwfRrG7XJPLbLKad4OUWjHtyAOhz5bVvNw+8vFm2rOrx14YrEMPl0mDJJIFsIR3 ogtKiMN+8oXZMLzjGf0Zc517Bw1ZTqSv0KEL2fVHncLG4kUgP/XchTuDb05MtifLujjw PSDloAIgtvlffc/rSpRhnY+jev+qn1QHw/V69eW7dwTiCR+klYH3jABpCNcMo94sOAWz /Ndw== X-Gm-Message-State: APjAAAXtR61z7G03pS+sQSt+7FpylGc/HPj0w6E7meZ40UQz6H0AAuWx KIC+qG51YdWFlecFdhUcZhtoGw== X-Google-Smtp-Source: APXvYqwT8H9WJGY0HE4EzUbc/T3fUIupFXV6MXZk+NelMb9H4/98P61gXcmSUEbwB5A4YAjlhuJT+A== X-Received: by 2002:adf:de8b:: with SMTP id w11mr8791262wrl.134.1559898355024; Fri, 07 Jun 2019 02:05:55 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id f10sm1685621wrg.24.2019.06.07.02.05.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:53 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4444C1FF90; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:02 +0100 Message-Id: <20190607090552.12434-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 Subject: [Qemu-devel] [PULL 03/52] tests/docker: Update the Fedora image to Fedora 30 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: Fam Zheng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Stefano Garzarella Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Philippe Mathieu-Daudé Fedora 30 got released: https://fedoramagazine.org/announcing-fedora-30/ Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Marc-André Lureau Tested-by: Stefano Garzarella Reviewed-by: Stefano Garzarella Message-Id: <20190528153304.27157-1-philmd@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/docker/dockerfiles/fedora.docker b/tests/docker/dockerfiles/fedora.docker index afbba29ada..12c460597e 100644 --- a/tests/docker/dockerfiles/fedora.docker +++ b/tests/docker/dockerfiles/fedora.docker @@ -1,4 +1,4 @@ -FROM fedora:29 +FROM fedora:30 ENV PACKAGES \ bc \ bison \ From patchwork Fri Jun 7 09:05:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 036526C5 for ; Fri, 7 Jun 2019 09:07:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E85D728B18 for ; Fri, 7 Jun 2019 09:07:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCDB728B1D; Fri, 7 Jun 2019 09:07:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8916428B18 for ; Fri, 7 Jun 2019 09:07:17 +0000 (UTC) Received: from localhost ([::1]:47122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAqB-0005qR-I2 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:07:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39280) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAox-000460-9e for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAow-00048s-22 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:05:59 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:38580) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAov-00043s-Ql for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:05:57 -0400 Received: by mail-wr1-x441.google.com with SMTP id d18so1354939wrs.5 for ; Fri, 07 Jun 2019 02:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Iq7Nm46aUE7quvi6VDpmkC4n6wLldVq8o82duiGCIro=; b=q/+e+lioLf77XuvFKi5Ka2COkU5xft+YJvhYyOK6UFRK2pVrQCjd0ehgnnwxsw0yq5 R6to5Z4b7a0sdAd2lPB6nLMveQrZNK8nHopVKh7ZNuNzfMVZWvMZOlOuBwUrT7c3+8Ra jtX0jZuA6zmd1X/PDkrW453Pdn9mZ1QwBl2Xsokbp1YAl7AIKjBDtxCv2vBCZO3qTegf vIL/EKWG21cKusOTPeupgftxhjfDzC8GxSynuKm0MCG9ZgHP6lQsquwU8FCjb5dYwRYd nm80QoatvQHD2bBEvEGRxS3Z9dBKbbmD3Y5m/oKnm5+aFYTiuon0PbQulfGabxtzoaaP 22Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Iq7Nm46aUE7quvi6VDpmkC4n6wLldVq8o82duiGCIro=; b=RQzszi+MaJBBsLCpI9WXXKwPyJJmyEvWrK+vRH/WSjUR0xMasq+zzw6Jlz3B8GcaQ7 D7KT/jp67Bye6HEZOdwEefbCDfNK0Q0WED6EoJHCOVzcxxowtlqbIaD6mYe4hraJHtic qAYEN52LkfdetuiV3/bcCLd2UFq3bbgA7lq+KvEgcVrCmGy7O1U66XKFFIPmtz+MpCjl tPuI06MwcOPP0iNbX2B6XqpJ0RcobyyH6n/EdY1lhmoT6/6SAw9P/23MXL1zKGIlo1St SonqyHh3ka3g2EDrRXjRgUhEcimJ4RySy0oW4tjlEyBYliXDb6ySY4bfOT9yKBZjUzgS 2e3Q== X-Gm-Message-State: APjAAAXN6dx8p0VGEvZedA07X/U46LpTV501b93LuNQtgdtmlRJ3ITHH lhZjipHxsIiWXcHOl8RU/2SO5A== X-Google-Smtp-Source: APXvYqxwoqeoB/TWUxEe2DwhxkUnMF32YqUrgibu7UvFHTD6h3S6XO0UT1qfBQ27MM/dhG8TyJuCGg== X-Received: by 2002:adf:f2c8:: with SMTP id d8mr6262931wrp.221.1559898355776; Fri, 07 Jun 2019 02:05:55 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j7sm1819350wru.54.2019.06.07.02.05.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:53 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 584A01FF91; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:03 +0100 Message-Id: <20190607090552.12434-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 04/52] tests/docker: Update the Fedora cross compile images to 30 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: Fam Zheng , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , qemu-devel@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP While at it remove the bogus :latest tag for cris cross compiler. It tends to break caching and cause confusion. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé diff --git a/tests/docker/dockerfiles/fedora-cris-cross.docker b/tests/docker/dockerfiles/fedora-cris-cross.docker index b168ada615..09e7e449f9 100644 --- a/tests/docker/dockerfiles/fedora-cris-cross.docker +++ b/tests/docker/dockerfiles/fedora-cris-cross.docker @@ -2,7 +2,7 @@ # Cross compiler for cris system tests # -FROM fedora:latest +FROM fedora:30 ENV PACKAGES gcc-cris-linux-gnu RUN dnf install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txt diff --git a/tests/docker/dockerfiles/fedora-i386-cross.docker b/tests/docker/dockerfiles/fedora-i386-cross.docker index eb8108d118..9106cf9ebe 100644 --- a/tests/docker/dockerfiles/fedora-i386-cross.docker +++ b/tests/docker/dockerfiles/fedora-i386-cross.docker @@ -1,4 +1,4 @@ -FROM fedora:29 +FROM fedora:30 ENV PACKAGES \ gcc \ glib2-devel.i686 \ From patchwork Fri Jun 7 09:05:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981099 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D16317D2 for ; Fri, 7 Jun 2019 09:07:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BFA028B18 for ; Fri, 7 Jun 2019 09:07:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1040E28B1C; Fri, 7 Jun 2019 09:07:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A5D6328B1B for ; Fri, 7 Jun 2019 09:07:18 +0000 (UTC) Received: from localhost ([::1]:47124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAqD-0005se-KK for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:07:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39334) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAoz-00047O-RI for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAox-0004Fk-6q for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:01 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:41270) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAov-00045a-R7 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:05:58 -0400 Received: by mail-wr1-x42c.google.com with SMTP id c2so1338018wrm.8 for ; Fri, 07 Jun 2019 02:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rd5+Go34lR5r032gcxkrHBNwDzwFUaH0wsbx46lnxds=; b=KtzQfhuHaLrRhn0hNES7YtosF42tXuzszpjKOXitI2MRSzfro0ec2jJunY0V0Io+2x rBOB+eyYQboGLbfn5Gl6O1EtaOupLR2n5GgEj/5gQcJW/XCTOVUJkgz860SOgA8rOTn2 YVV2viExmPNU4An4LZlx7MI3M2mFGIPloUpylBuH2tVTKPBxXO2VCQVBd44y8sSnro+9 uMMYmsWZ3mqVYP46Hog0rnIpfVxET5C2GHlpr08msI5zPz02pTYaWW+6aDXMnbDq0CLo Eh3af5khAIJVujIAchnB7xnOoSmOS78VEJoonI9S01zc6IAyYCbR0RVE6Y1xy9+iIwrz B4Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rd5+Go34lR5r032gcxkrHBNwDzwFUaH0wsbx46lnxds=; b=gP+l3Zmn9Bppr1h8JgBntSC4HEjZEhecknrjhiBfiQrCvwKFZa9p5MyWaArtz82e3I L6cKln7dcgjNFhur+b8BvchKANWF4+3RR5AEZ/WPjrBBAlh96W2fVw+vqpQJZLELTx8/ lO+TyzTPoy3AY7IZ37lGv6DmXpcwvf4ldN0ysrvcVxv8q6KueaEvsyfU3cEB1eiio4f4 5jvIqccSbHwrqZYhFwgjfDLgsDPvbxkOEkAkr8B0/DLv5e6pxzD0xj4/sE6e9INk1ANw 9cJfu8vXCREDAHQklkVbXleFhXyR9iBPlbQorHp51cFjtoHC8jin4CVMEBshaLzk2z4a H+YA== X-Gm-Message-State: APjAAAVQez0e3w092QHyi4ID/CbIjU4tAvImcE6BaGGpmje8LN7iYg/8 JpMw9ff02Q+a2EKCuaH2DqdOyg== X-Google-Smtp-Source: APXvYqw8bE4o9W+RCod07b72FTGh2ENf3I0AsxGJTeZ6hnOI+Lb6mqoI3hhiMuimRxywUIluzgTnUA== X-Received: by 2002:adf:f8cf:: with SMTP id f15mr18792478wrq.333.1559898356437; Fri, 07 Jun 2019 02:05:56 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y2sm1331087wra.58.2019.06.07.02.05.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:53 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6B5811FF92; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:04 +0100 Message-Id: <20190607090552.12434-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c Subject: [Qemu-devel] [PULL 05/52] tests/docker: Update the Ubuntu image to 19.04 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: Fam Zheng , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , qemu-devel@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This has aged a little and we have a separate LTS image for testing on the older distros. Update it to a more recent release like its Fedora cousin. Besides it is useful to have something with gcc-9 on it for squashing those stringop truncation errors. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson diff --git a/tests/docker/dockerfiles/ubuntu.docker b/tests/docker/dockerfiles/ubuntu.docker index 36e2b17de5..8d256961f0 100644 --- a/tests/docker/dockerfiles/ubuntu.docker +++ b/tests/docker/dockerfiles/ubuntu.docker @@ -1,6 +1,15 @@ -FROM ubuntu:16.04 -RUN echo "deb http://archive.ubuntu.com/ubuntu/ trusty universe multiverse" >> \ - /etc/apt/sources.list +# +# Latest Ubuntu Release +# +# Useful for testing against relatively bleeding edge libraries and +# compilers. We also have seperate recipe for the most recent LTS +# release. +# +# When updating use the full tag not :latest otherwise the build +# system won't pick up that it has changed. +# + +FROM ubuntu:19.04 ENV PACKAGES flex bison \ ccache \ clang \ @@ -21,7 +30,7 @@ ENV PACKAGES flex bison \ libepoxy-dev \ libfdt-dev \ libgbm-dev \ - libgnutls-dev \ + libgnutls28-dev \ libgtk-3-dev \ libibverbs-dev \ libiscsi-dev \ @@ -34,7 +43,7 @@ ENV PACKAGES flex bison \ libnss3-dev \ libnuma-dev \ libpixman-1-dev \ - libpng12-dev \ + libpng-dev \ librados-dev \ librbd-dev \ librdmacm-dev \ From patchwork Fri Jun 7 09:05:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D54A7924 for ; Fri, 7 Jun 2019 09:22:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3E2D28AEC for ; Fri, 7 Jun 2019 09:22:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B806428B00; Fri, 7 Jun 2019 09:22:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DB8728AF7 for ; Fri, 7 Jun 2019 09:22:37 +0000 (UTC) Received: from localhost ([::1]:47430 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB52-0008Bt-6f for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:22:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39333) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAoz-00047N-RE for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAox-0004IL-S6 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:01 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:51071) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAox-00045z-77 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:05:59 -0400 Received: by mail-wm1-x342.google.com with SMTP id c66so1224020wmf.0 for ; Fri, 07 Jun 2019 02:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HdpVihLUIZVvKpgG2IEu5C8IS7kClin1bLgeQxnhXsA=; b=cusWhEk/JWErEovXuSD115Z7CQzBd2TT8ChezGFYSnZTBpAUKPAIHYO8GR5ReYBc4B rAck8troJ7G3+PM8mENsgH16jXhHMdeFQDP0blm/mfUcbKMpbUcZn8U0qzXXC6vKQvyb biN0yoGNj/0KIZXlGMxSHlLmFgOa6orbv075sVmYY5iZejWe2ODuUDnVEngKCBUUxLb/ /wDeseLRvvsKSK0i/1Wwf7D1hrlurY78SsW0FdSPOHQKMn3otCJW+WGpzO18wy3kTGjw R6gAdCFZbA+enBBGLH2Evj2eFbEY/ALNg7pINgcg9Tw2nA5SZm0/SUzZbTtA13ug+pdo YVcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HdpVihLUIZVvKpgG2IEu5C8IS7kClin1bLgeQxnhXsA=; b=hXfB3K/t5VadABYZytvE2FyjoxPr9Mbxf1YaHOG4VIzlfoie9ck/cz4xqkqjA+dzVW sS0FkUs7TwpbI37ool6JSfr0y9WRMUoJJkqSuhn+YcZCMAcFv2jOQ7HFO6YVmDzZhWz0 Q/0bGV9xLDPsZAHPV4q7qIGwTuT2hmfQQV7oLvKLCMhWltOfaSh5luR03qPTFI9hhtZf /pyVQh0XK9po4FBN1+XkLI39i5azXA7m1WQWUcpjVorysFSdNELj91yuy5vTJ7lYRQDv FIsoEPSLZgxrIYCTXqcIqRw4fZdTwciZ0iI4EoYfnPg7lCG/ZuXFBpS3UcIP+/oLbSKW yoDw== X-Gm-Message-State: APjAAAXRdwlz3xH8r0phlsff/jmTR5ZbL8thSuEmTNESVdibWjT6DTxJ Og6AmNrczT6y3eTKsJfwoZhacA== X-Google-Smtp-Source: APXvYqwrIxzQN9tEErYgAPs3VKnrzUNFjRxRUv0fuhGaErKQSDg/x2da/UL3aQX7z0mAj3oXg6lwzA== X-Received: by 2002:a1c:2bc7:: with SMTP id r190mr2776726wmr.174.1559898357213; Fri, 07 Jun 2019 02:05:57 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id p16sm2135625wrg.49.2019.06.07.02.05.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:53 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7DA8D1FF93; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:05 +0100 Message-Id: <20190607090552.12434-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PULL 06/52] .travis.yml: bump gcc sanitiser job to gcc-9 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: Fam Zheng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The toolchain PPA has it so we might as well use it. We currently have to add: -Wno-error=stringop-truncation as there are still strncpy operations in the tree operating on things that haven't been annotated with QEMU_NONSTRING. Signed-off-by: Alex Bennée diff --git a/.travis.yml b/.travis.yml index b053a836a3..f0aa37f2d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -240,8 +240,8 @@ matrix: - ubuntu-toolchain-r-test packages: # Extra toolchains - - gcc-7 - - g++-7 + - gcc-9 + - g++-9 # Build dependencies - libaio-dev - libattr1-dev @@ -270,11 +270,11 @@ matrix: language: generic compiler: none env: - - COMPILER_NAME=gcc CXX=g++-7 CC=gcc-7 - - CONFIG="--cc=gcc-7 --cxx=g++-7 --disable-pie --disable-linux-user" + - COMPILER_NAME=gcc CXX=g++-9 CC=gcc-9 + - CONFIG="--cc=gcc-9 --cxx=g++-9 --disable-pie --disable-linux-user" - TEST_CMD="" before_script: - - ./configure ${CONFIG} --extra-cflags="-g3 -O0 -fsanitize=thread -fuse-ld=gold" || { cat config.log && exit 1; } + - ./configure ${CONFIG} --extra-cflags="-g3 -O0 -Wno-error=stringop-truncation -fsanitize=thread -fuse-ld=gold" || { cat config.log && exit 1; } # Run check-tcg against linux-user From patchwork Fri Jun 7 09:05:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981115 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 925A017D2 for ; Fri, 7 Jun 2019 09:11:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8180528B21 for ; Fri, 7 Jun 2019 09:11:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75C0828B25; Fri, 7 Jun 2019 09:11:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 218EC28B21 for ; Fri, 7 Jun 2019 09:11:46 +0000 (UTC) Received: from localhost ([::1]:47152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAuX-000118-CR for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:11:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39388) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAp1-00047Z-Fg for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAoy-0004Ii-1T for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:03 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:41276) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAox-0004Ct-Ra for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:05:59 -0400 Received: by mail-wr1-x432.google.com with SMTP id c2so1338120wrm.8 for ; Fri, 07 Jun 2019 02:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WAruCVUMvVUZGKjuxI8Kw2Q2uX+I+acKmrGoMuG66f8=; b=yACQQXAmEShz7T8rno6cKs8EZgrltB2s2aGEYSUgVT01Xx5M4SmxLwEbPMdxLvs7jI Wfm4H2sYxkd1XyaeH+JaiN6TaUYmvboJ1ankaxsvTWzmbw1vHHNDpg0mYBVxOAHoIxtI 8y7/XK4dj/mEm8hZWaBtSR+oVPT8rzk3KtARNtURrIavMRjRETGFeeUGc0zuUmF3TaGF 5iPApuy2SxNBHq+zJFGGCyM0FX/m/tBb3Sj8RYIFRgmi1T32DBIAO34ci40UZ9ifySsF 1hnj76vC9TurrDlu5sz9fRkbEWyAZaAndBrpFKTXL7hFnQKVRYNESOPEymKKiIyY+sNV jHlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WAruCVUMvVUZGKjuxI8Kw2Q2uX+I+acKmrGoMuG66f8=; b=jOXT1WIaBGPagKvBqpGXEOBaEo6lFwwqki1HocwgL4/IGFmxo+bvhIHT1DvH7E4wPh 0OM1rFFnvwqg0j01Xn/jSgfEv2kXnzpD5z+3wL5Ls+8XZDg54Uuz4D+Ecm35YPXXwnzI 8niqtLvD2ges5Rzs79AiPDnc18TN1T/a8e2gZoirqGG33v7RpEX6HGhkDFtVLb0WF8Tq 4kwE+oRHoYvRE3tr9WeqKacZ5+5yq+3Se+9iDP9QI0qcvmDaSSju7Ero5/3ODWPvz3Pf ztC/8F4+EcHj+RxIPgpqsV/hcAklDfzCug4mdNOm20p4aF9NSIIie7lGtvUkU2v0wWDQ Y3DA== X-Gm-Message-State: APjAAAXsBusOdqlFjFo+BNIG6DsRAfkkLg3XGMQtW2vY1nv0meD2BWRe WtY9PqV+I8FDotpHYOuf8qciDA== X-Google-Smtp-Source: APXvYqxRsN+YGq3zxo7EWhz/ww0C1kthWqCL7eeOMKVwoP5l8rYoUL9k/jAqlJLrpOXbOj7R16d2vg== X-Received: by 2002:adf:e4d2:: with SMTP id v18mr5887019wrm.189.1559898358300; Fri, 07 Jun 2019 02:05:58 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k10sm1645351wmk.14.2019.06.07.02.05.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:56 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 902DB1FF96; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:06 +0100 Message-Id: <20190607090552.12434-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 Subject: [Qemu-devel] [PULL 07/52] .travis.yml: add clang ubsan job 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: Fam Zheng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We document this on our wiki and we might as well catch it in our CI rather than waiting for it to be picked up on merge: https://wiki.qemu.org/Testing#clang_UBSan Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé diff --git a/.travis.yml b/.travis.yml index f0aa37f2d1..2f1658602e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -152,6 +152,13 @@ matrix: compiler: clang + - env: + - CONFIG="--target-list=${MAIN_SOFTMMU_TARGETS} " + compiler: clang + before_script: + - ./configure ${CONFIG} --extra-cflags="-fsanitize=undefined -Werror" || { cat config.log && exit 1; } + + - env: - CONFIG="--disable-user --target-list-exclude=${MAIN_SOFTMMU_TARGETS}" compiler: clang From patchwork Fri Jun 7 09:05:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC6FE14E5 for ; Fri, 7 Jun 2019 09:25:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D39B628B2C for ; Fri, 7 Jun 2019 09:25:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C79FA28B36; Fri, 7 Jun 2019 09:25:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B5B428B2C for ; Fri, 7 Jun 2019 09:25:45 +0000 (UTC) Received: from localhost ([::1]:47458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB84-0003Md-KL for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:25:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39402) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAp1-00048R-TL for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAp0-0004R1-7Y for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:03 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:40130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAoz-0004ML-W8 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:02 -0400 Received: by mail-wr1-x42b.google.com with SMTP id p11so1344871wre.7 for ; Fri, 07 Jun 2019 02:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+SKipxqDiHRib8HzDeti6YzGOBFsaSaAYfMEIKsinVY=; b=lMYxmG3RToTynruFovsfKYuH3FC/2j3/M00lxPrleLwTPEf/zix0ZGiEQEEUQugjFR DCZWpIF0t4z75WrONvGED/EgGZaaR8+E+ASD19Fkoz1JmB25YLCgA/iCXmA9SKLaCHqH nlo2L8D7Vr2Otp/b7rj0xaXRvcx5fLCig4/gNBqiQhhM5kSrJwxQi0xxRjvlwEwMTlZk 7doSWfbu8RoZvY66xMbWqIuHP4AkHQKO7APVIUfiIISDWuTiExGJdR5ubdBLK+y0RagA duMkWQ0OXY4+SAJSN0eRQsUnVzJUqhteWh8/k8WKGOfpIRSQ97biCNPO0c84vXXcdrAQ q+0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+SKipxqDiHRib8HzDeti6YzGOBFsaSaAYfMEIKsinVY=; b=PweT0xPopbUG1ZnyPVUaW/5Ip2dHiGScki1lTCTlMDnuaOIQ3E9LOMiIZEKPlsTNyT nokwe1Jja29Cj1yR2El/myjXXjQlAbSBqovJKv7lisZ9L4+FNdT4XoxcIfvTUG0W5S7a 5efPRYhZjXe+YdmQi7I7cXWYmIxq742vm75A9C5+smd4StT82Um6lo/Y3HhxUtuM+bTu CnmYeszV65Szo/gzxfoeqQ7Xwe6EKtgxE7AodV13CZd8wgSwrMddMmvxET48tfrdmY+n 3rSh+1+VKYKS6KsQ43rdceSaw+xl8ADAiH4a7NCmE7EdW8agrWjdVAAUVR9vZXDryIg/ 16YQ== X-Gm-Message-State: APjAAAVYhGd7qQnDUqi4Nuoj+Krd1TTkGEIkR3spDTGX9WPQl6O80hwa cwki1ZKPlmFWjc4cHAkEINh7yw== X-Google-Smtp-Source: APXvYqxVwgYs0TG1qlX0mu+HwFknbgr2QWIbk+URE6/vBegD7WbJGmES+6sEBGhc1or12d/Fhzj/Tw== X-Received: by 2002:adf:8183:: with SMTP id 3mr19050280wra.181.1559898360433; Fri, 07 Jun 2019 02:06:00 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id z12sm1046080wrl.37.2019.06.07.02.05.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:57 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A2D501FF98; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:07 +0100 Message-Id: <20190607090552.12434-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b Subject: [Qemu-devel] [PULL 08/52] tests/vm: Use python configured on build 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: Fam Zheng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , qemu-devel@nongnu.org, Wainer dos Santos Moschetta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Wainer dos Santos Moschetta Changed the vm-test makefile to execute python scripts with the interpreter configured on build. This allows to run vm-test targets properly in Linux distros with Python 3 only support. Signed-off-by: Wainer dos Santos Moschetta Message-Id: <20190329210804.22121-2-wainersm@redhat.com> Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index 992d823f6b..6f82676306 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -35,7 +35,7 @@ $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/Makefile.include @mkdir -p $(IMAGES_DIR) $(call quiet-command, \ - $< \ + $(PYTHON) $< \ $(if $(V)$(DEBUG), --debug) \ --image "$@" \ --force \ @@ -46,7 +46,7 @@ $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ # Build in VM $(IMAGE) vm-build-%: $(IMAGES_DIR)/%.img $(call quiet-command, \ - $(SRC_PATH)/tests/vm/$* \ + $(PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(V)$(DEBUG), --debug) \ $(if $(DEBUG), --interactive) \ $(if $(J),--jobs $(J)) \ From patchwork Fri Jun 7 09:05:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBEDA6C5 for ; Fri, 7 Jun 2019 09:11:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA07728B21 for ; Fri, 7 Jun 2019 09:11:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE21228B22; Fri, 7 Jun 2019 09:11:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7253528B25 for ; Fri, 7 Jun 2019 09:11:45 +0000 (UTC) Received: from localhost ([::1]:47150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAuW-0000yo-JW for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:11:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39433) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAp3-00049I-LO for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAp1-0004Yk-Uf for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:05 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:52972) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAp1-0004Og-DP for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:03 -0400 Received: by mail-wm1-x32f.google.com with SMTP id s3so1214914wms.2 for ; Fri, 07 Jun 2019 02:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gEge0ZwKN/zoSSUTfhu4Nam9XSCwRb2HyAYOFmNXZHE=; b=Jrjz6t7ihJQGYki1ve73MhmpkWG8s2o/OEF56FwMl5+iJRn/Xt1XT9hbj7aYWi7l/1 UZxFYIpP23xfa5g0opH03aKtMD+A3aCL2mW5SOUkrsGj4YeaYwx+wHirupLBFOuNJl8f VAshmcxpS8jmcmmTCOlhijPuzv4jUwm4VwRFNVbeAdyVTSU985g4YaGw4cokGclbKJ/T iWpUG9N718ggNYG1SWOQDChZV1ZuqfDPMw0zPn6R1315fP8rY++ibZLdK6IR5Nng8PE5 q4pi5G9gTiBQfZt4VJgmQhDlDNPKRy17b5sJQYxGA8psvc0YSWDI9AAqCj16uJNqkHGq 8vhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gEge0ZwKN/zoSSUTfhu4Nam9XSCwRb2HyAYOFmNXZHE=; b=PF2acfCXT6JJCHCHd3r11xPNbpyiSLrXyfZDgKeWfQF/8Tlw472/tcJXINW9ICLZax LLg/udN5ke362tFQ0XQgKa2m/6Eq/87j69RNSih3N8xjNP+K3dTt5IOdNetLJN7Lrpm1 mmCOOjBs57pGZuYg7utLG2zfo/N+4mxFbiHPA3PyMu9gR9JJ93MKfAIM8c/JUxnLf333 SisY2oFjl2hX1zL28Rx0fa9K+8jTu9iCYS/va7COAr+n4zLumaE6OxkcvRpZ4DFhONe+ dPCdYJcGtHQgx5V6iWHbLVFjcZuHL817lsR1Q7gOIHKc2XIBA4zsWaLjXLjkGC5iA87V 0A1w== X-Gm-Message-State: APjAAAWraZD108u90eZ1eSc3BslB1/C3XgxzjK75ctRcyGEVkxFMMGHU jd1BDxTVqhPUYKl9N5QEScSAUA== X-Google-Smtp-Source: APXvYqwlWPB8tv0hFI3HkiB+5Ws88ifekct7O+nZR8qaFY2DrwuycF5WUOeeUkx+SbL+qReNEL8H+Q== X-Received: by 2002:a1c:9e92:: with SMTP id h140mr2710828wme.82.1559898361131; Fri, 07 Jun 2019 02:06:01 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k2sm1256475wrx.84.2019.06.07.02.05.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:57 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B5D781FF99; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:08 +0100 Message-Id: <20190607090552.12434-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32f Subject: [Qemu-devel] [PULL 09/52] tests/vm: Port basevm to Python 3 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: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Wainer dos Santos Moschetta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Wainer dos Santos Moschetta Fixed tests/vm/basevm.py to run with Python 3: - hashlib.sha1() requires an binary encoded object. - uses floor division ("//") (PEP 238). - decode bytes to unicode when needed. Signed-off-by: Wainer dos Santos Moschetta Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20190329210804.22121-3-wainersm@redhat.com> Signed-off-by: Alex Bennée Tested-by: Philippe Mathieu-Daudé diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 0556bdcf9e..083befce9f 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -85,12 +85,12 @@ class BaseVM(object): if not sha256sum: return True checksum = subprocess.check_output(["sha256sum", fname]).split()[0] - return sha256sum == checksum + return sha256sum == checksum.decode() cache_dir = os.path.expanduser("~/.cache/qemu-vm/download") if not os.path.exists(cache_dir): os.makedirs(cache_dir) - fname = os.path.join(cache_dir, hashlib.sha1(url).hexdigest()) + fname = os.path.join(cache_dir, hashlib.sha1(url.encode()).hexdigest()) if os.path.exists(fname) and check_sha256sum(fname): return fname logging.debug("Downloading %s to %s...", url, fname) @@ -134,7 +134,7 @@ class BaseVM(object): raise NotImplementedError def add_source_dir(self, src_dir): - name = "data-" + hashlib.sha1(src_dir).hexdigest()[:5] + name = "data-" + hashlib.sha1(src_dir.encode()).hexdigest()[:5] tarfile = os.path.join(self._tmpdir, name + ".tar") logging.debug("Creating archive %s for src_dir dir: %s", tarfile, src_dir) subprocess.check_call(["./scripts/archive-source.sh", tarfile], @@ -204,7 +204,7 @@ def parse_args(vmcls): def get_default_jobs(): if kvm_available(vmcls.arch): - return multiprocessing.cpu_count() / 2 + return multiprocessing.cpu_count() // 2 else: return 1 From patchwork Fri Jun 7 09:05:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 014216C5 for ; Fri, 7 Jun 2019 09:14:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E58FF28B2B for ; Fri, 7 Jun 2019 09:14:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8A6128B2C; Fri, 7 Jun 2019 09:14:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7E7AF28830 for ; Fri, 7 Jun 2019 09:14:23 +0000 (UTC) Received: from localhost ([::1]:47372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAx3-0003JB-2A for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:14:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39400) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAp1-00048Q-T0 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAp0-0004Qj-37 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:03 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:37434) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAoz-0004KG-Nk for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:01 -0400 Received: by mail-wr1-x435.google.com with SMTP id v14so1350003wrr.4 for ; Fri, 07 Jun 2019 02:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jMI2SGNeZLWPMTiphBl8d5qoJBryaOiVTeyWEFf0GRk=; b=IjChq4jlAKRwvAQredZdjoabtSchtttqVsl0Qj+mYjguYu7xjuiJoGUZe7O2rmqcmZ EyYwlQOTOMy+JWg7QZ6piVE1sQLBnS9Fj9QtO4Ryfzp1ApwnsaUVHWEZVFv2rgnYA5/I X/eaN5a6L3BqG5FBNJ3SFyXS3LkjyjlKAq77LGNeEakaFiYmqJjM+j0bcC519NopcBeg NcX+WhAEpZW/Rdwj03qADNsKFenNohWSNnw7rncP/UTgjQnUsMyjBRZXkTtLUoQJ3HCD /J160FpaWI5hSvQB+WBEc0lW+DX1R7fGn4NHEtrd5PEb9Kf1bOAP1+8IvS+hOUiAT+z4 qBJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jMI2SGNeZLWPMTiphBl8d5qoJBryaOiVTeyWEFf0GRk=; b=ZtU6KcCWiMdJyRAE1vTVQsxojkjw9WzuI6G15gb6oqMSc0hqzfqGbtAxhuORUXP7Pj dXNFlBV6tpTvVvmNN2L3yygIqnAtbRnyvBvZJsR+LOAKq1AYviBuO604JyNjaYSrCiS3 XIucAYRBbuVfc4IltCDPrbg1XrJyT9yKT3aNYIXnKths4Lncpe1GCiV+jR6kV+zw+yYs bQq8Cc7Tx1LRfcfYOLTF/JuPbW+pcfXjZvoEk3M9T+4xcVG0Z5pawarRpq2TG3sbbfS/ 3waKVkxl9kzH9Orknv34Y3+Jl4UuDRsXzZP0rZPhzCLWPa8gnUT0WD4HG+XqIl5i/gvX +Skg== X-Gm-Message-State: APjAAAVozcKnPzltewOByyYIZHmeaLlf3RIV1+XkEX7hkjbduuQ6fAlI v/ltYuUR2DvrtCIEnJoesc9LIg== X-Google-Smtp-Source: APXvYqw8zDl2ZPcAhoThNQ6HwVwEZKkEhGFei7kK+oMa3YvvD+jZDTVKojR6CFvfJCI7KimCRdJ8Ww== X-Received: by 2002:a05:6000:cf:: with SMTP id q15mr1677853wrx.52.1559898359991; Fri, 07 Jun 2019 02:05:59 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u5sm1515236wmc.32.2019.06.07.02.05.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:57 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C8D5C1FF9A; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:09 +0100 Message-Id: <20190607090552.12434-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 Subject: [Qemu-devel] [PULL 10/52] tests/vm: Fix build-centos docker-based tests run 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: Fam Zheng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , qemu-devel@nongnu.org, Wainer dos Santos Moschetta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Wainer dos Santos Moschetta `make vm-build-centos` run docker-based tests on CentOS. The created containers should have network otherwise some tests fail. Also fixed the BUILD_SCRIPT template to correctly evaluate "V=1" for verbose output. Signed-off-by: Wainer dos Santos Moschetta Message-Id: <20190329210804.22121-5-wainersm@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/centos b/tests/vm/centos index ba133ea429..7417b50af4 100755 --- a/tests/vm/centos +++ b/tests/vm/centos @@ -26,9 +26,9 @@ class CentosVM(basevm.BaseVM): export SRC_ARCHIVE=/dev/vdb; sudo chmod a+r $SRC_ARCHIVE; tar -xf $SRC_ARCHIVE; - make docker-test-block@centos7 V={verbose} J={jobs}; - make docker-test-quick@centos7 V={verbose} J={jobs}; - make docker-test-mingw@fedora V={verbose} J={jobs}; + make docker-test-block@centos7 {verbose} J={jobs} NETWORK=1; + make docker-test-quick@centos7 {verbose} J={jobs} NETWORK=1; + make docker-test-mingw@fedora {verbose} J={jobs} NETWORK=1; """ def _gen_cloud_init_iso(self): From patchwork Fri Jun 7 09:05:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B69C6C5 for ; Fri, 7 Jun 2019 09:15:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A0C028830 for ; Fri, 7 Jun 2019 09:15:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F14DA28B21; Fri, 7 Jun 2019 09:15:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A22EF28830 for ; Fri, 7 Jun 2019 09:15:36 +0000 (UTC) Received: from localhost ([::1]:47388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAyF-0004e1-QB for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:15:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39451) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAp5-00049Q-Bj for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAp2-0004ZE-1x for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:05 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:45939) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAp1-0004QR-MT for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:03 -0400 Received: by mail-wr1-x42e.google.com with SMTP id f9so1329429wre.12 for ; Fri, 07 Jun 2019 02:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7WvYOUS4wxrAh1bmzV9VJwvouE7jKXGGzDv4QIMUl7o=; b=AuZhySanN0DuKNNoWuawG1yC3v+/0sU9fq0vp/OpGHXyXCylI8xUBGQPI+xc78c07e wxXmh5AmId+sCBXrAkOWFzkCYXs10VrVCZbn7rkK3LCN0dOn3Q5fvDyN1Bs1+n0wbIEE jURxIa6jxKmqaufRV2VcRLJ3E8MQDgwva5ynEGtKY2LUFae4El0ckpgRQufPi1HCMcfY 87AApnXe/qXnGdRoLYZVOTd9uowuUSjzOAXTDGlPtCspRcJfWEL6DDuwGLfu9lw8HjqS O2FMhML6ycNwJIz6/jjEh5WAitjP+o33LHIZlYu23O3yQHVJtpvr0gykhWCSvtUByCjo lslg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7WvYOUS4wxrAh1bmzV9VJwvouE7jKXGGzDv4QIMUl7o=; b=YDLG1kcLctB9DLBvF8UZ+9Ftyu1z5LU6ciVmP83rd0ZJDspetJUhfFZq461pLisvad WapsRUo7lvBS9BmyodrgCsoovrzQ5HTjDQ0lOnPjXZLnO1w4t8XHdBdm+//ftLHS9XJx cTZ1HBZ6m4xUCez7FWz7Maf/MNZ32J7MKsTMwr8/JJLnod7vnz2CclWilmmzlinldsiu BfD7CrjQe2a710wgnCMlmEtmCEtYjpGL2Ln1Iw+NfomDADFb0a0DGf/vdSR6Pf2/wzsL r77brKglJQK2McTp81jsjnZLxVeBaJuK08fKI8CwOzVY6PVp+CIhMBrPEKlquWBJhe5j Jelg== X-Gm-Message-State: APjAAAWaIzke28D7cMALxgN3efagHWymbm300Q/Pp4MAXPeeERbvn4M2 McXQTIX3Q8LYy8t2kAY/Q5nS136B6bE= X-Google-Smtp-Source: APXvYqx1qKf/VeuShYsVJfYElUPVcbOt3XQv/QtOhzssJ7wMAnjzmh/+2OHr+XRYf5VLpEbSZL4dSw== X-Received: by 2002:adf:e309:: with SMTP id b9mr729345wrj.135.1559898361592; Fri, 07 Jun 2019 02:06:01 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m17sm1328261wrx.12.2019.06.07.02.05.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:57 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DBAB91FF9B; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:10 +0100 Message-Id: <20190607090552.12434-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e Subject: [Qemu-devel] [PULL 11/52] tests/vm: Add missing variables on help 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: Fam Zheng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , qemu-devel@nongnu.org, Wainer dos Santos Moschetta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Wainer dos Santos Moschetta Added description of variables missing on vm-test help. Signed-off-by: Wainer dos Santos Moschetta Message-Id: <20190329210804.22121-6-wainersm@redhat.com> Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index 6f82676306..c59411bee0 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -21,9 +21,13 @@ vm-test: @echo " vm-clean-all - Clean up VM images" @echo @echo "Special variables:" - @echo " BUILD_TARGET=foo - override the build target" - @echo " TARGET_LIST=a,b,c - Override target list in builds." + @echo " BUILD_TARGET=foo - Override the build target" + @echo " TARGET_LIST=a,b,c - Override target list in builds" @echo ' EXTRA_CONFIGURE_OPTS="..."' + @echo " J=[0..9]* - Override the -jN parameter for make commands" + @echo " DEBUG=1 - Enable verbose output on host and interactive debugging" + @echo " V=1 - Enable verbose ouput on host and guest commands" + @echo " QEMU=/path/to/qemu - Change path to QEMU binary" vm-build-all: $(addprefix vm-build-, $(IMAGES)) From patchwork Fri Jun 7 09:05:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 224FE14C0 for ; Fri, 7 Jun 2019 10:53:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D3ED28B56 for ; Fri, 7 Jun 2019 10:53:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1BEB28B55; Fri, 7 Jun 2019 10:53:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7C21528B55 for ; Fri, 7 Jun 2019 10:53:08 +0000 (UTC) Received: from localhost ([::1]:48286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCUd-00088X-S1 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:53:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50991) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBOM-0007e4-Ai for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZBOK-0000pO-G7 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:34 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:36569) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZBOK-0000lE-8j for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:32 -0400 Received: by mail-wr1-x42c.google.com with SMTP id n4so1476650wrs.3 for ; Fri, 07 Jun 2019 02:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oJrbPHU6QMM17Z/P//VMEjEn9UEe0UK4q9allOg3/go=; b=aEuG+GzNMS4QTFB6KF60Z6oNGIGC5YokL7OlScAPDZ1vFIpphysthLUMfyt3CUp9ha 72G3QpoEfhmjpxwxyvGU8zkZNOpBscbf4yI5vAHBXE8CgKPhJlGAh0e1MNV3nNYvVhR9 jfNMmTwf3QRKLyDWaSWWEbSjFIEF6zmKSZq8nkikJLCwURHbiPTHX+8JYfvFL8thLwE3 MmyAwbcLwWl8iRQEt1t57BC5eB/eKgkCSAoSDqU+EKHcqf5I2p1H7ZYmMyFhLIcXQbM1 jn7HNakEdNSu2RMABuJxvR+ydO00izMXZ5r1613ALvYMacptQbXX4H9GbmpS/lFOAxxc qiTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oJrbPHU6QMM17Z/P//VMEjEn9UEe0UK4q9allOg3/go=; b=iC15ZwkUY6kwL5WY2RmmfsAVcM6x47v7y02lAIHZEx8CTLevPIMwPdqp6/ZK3mOz/l 4Wc7xcaSfr7RIGuVQVbjTdvmT6Qv3ZmbTdu395TrjdmZt+W8N03Uanzel099WO1CrDfd MxMkIAT2n76MDQbt/TyCxFEVbkd/Vzj7Hg8676b1vFmOMicCUBP3K+zPaSyYa9a/z/e5 4xGP8AAUr9vpP3Nfw7guGzPUlULSPHIz8fKMiHoP2elUDspPnmLYH1MKccMMrvZRdXUg eJTcKv54ekIbhF/TY9j+1kX0zhwsFHbj0N5vEAed5fleoI0Ty19ycr+XqIIiy8ZTfscC QovQ== X-Gm-Message-State: APjAAAUK/xj98VNQYyptqKw7V9uF0NZmv9J5PI9cDwUGGluDNMxunjlE 4PbTjySXuD2+Cd2sUKt25rzzvA== X-Google-Smtp-Source: APXvYqzXu68gJ9cQ2zSxQ0MCz9iGNHDpKQQLClmj4OXsPVqHGi3NgU3Hv3TTFevVrn1JbXB+G8upxw== X-Received: by 2002:a5d:6583:: with SMTP id q3mr35571326wru.184.1559900549537; Fri, 07 Jun 2019 02:42:29 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k184sm2078868wmk.0.2019.06.07.02.42.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:42:28 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EEA631FF9C; Fri, 7 Jun 2019 10:05:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:11 +0100 Message-Id: <20190607090552.12434-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c Subject: [Qemu-devel] [PULL 12/52] scripts: use git archive in archive-source 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: Fam Zheng , Thomas Huth , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann Use git archive to create tarballs of qemu and submodules instead of cloning the repository and the submodules. This is a order of magnitude faster because it doesn't fetch the submodules from the internet each time the script runs. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Tested-by: Philippe Mathieu-Daudé Message-Id: <20190520124716.30472-2-kraxel@redhat.com> [AJB: fixed up tabs] Signed-off-by: Alex Bennée diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index 8b89948260..ca94e49978 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -19,16 +19,25 @@ if test $# -lt 1; then fi tar_file=$(realpath "$1") -list_file="${tar_file}.list" -vroot_dir="${tar_file}.vroot" +sub_tdir=$(mktemp -d "${tar_file%.tar}.sub.XXXXXXXX") +sub_file="${sub_tdir}/submodule.tar" # We want a predictable list of submodules for builds, that is # independent of what the developer currently has initialized # in their checkout, because the build environment is completely # different to the host OS. submodules="dtc slirp ui/keycodemapdb tests/fp/berkeley-softfloat-3 tests/fp/berkeley-testfloat-3" +sub_deinit="" -trap "status=$?; rm -rf \"$list_file\" \"$vroot_dir\"; exit \$status" 0 1 2 3 15 +function cleanup() { + local status=$? + rm -rf "$sub_tdir" + if test "$sub_deinit" != ""; then + git submodule deinit $sub_deinit + fi + exit $status +} +trap "cleanup" 0 1 2 3 15 if git diff-index --quiet HEAD -- &>/dev/null then @@ -36,45 +45,26 @@ then else HEAD=$(git stash create) fi -git clone --shared . "$vroot_dir" -test $? -ne 0 && error "failed to clone into '$vroot_dir'" -for sm in $submodules; do - if test -d "$sm/.git" - then - git clone --shared "$sm" "$vroot_dir/$sm" - test $? -ne 0 && error "failed to clone submodule $sm" - fi -done - -cd "$vroot_dir" -test $? -ne 0 && error "failed to change into '$vroot_dir'" - -git checkout $HEAD -test $? -ne 0 && error "failed to checkout $HEAD revision" +git archive --format tar $HEAD > "$tar_file" +test $? -ne 0 && error "failed to archive qemu" for sm in $submodules; do - git submodule update --init $sm - test $? -ne 0 && error "failed to init submodule $sm" + status="$(git submodule status "$sm")" + smhash="${status#[ +-]}" + smhash="${smhash%% *}" + case "$status" in + -*) + sub_deinit="$sub_deinit $sm" + git submodule update --init "$sm" + test $? -ne 0 && error "failed to update submodule $sm" + ;; + +*) + echo "WARNING: submodule $sm is out of sync" + ;; + esac + (cd $sm; git archive --format tar --prefix "$sm/" $smhash) > "$sub_file" + test $? -ne 0 && error "failed to archive submodule $sm ($smhash)" + tar --concatenate --file "$tar_file" "$sub_file" + test $? -ne 0 && error "failed append submodule $sm to $tar_file" done - -if test -n "$submodules"; then - { - git ls-files || error "git ls-files failed" - for sm in $submodules; do - (cd $sm; git ls-files) | sed "s:^:$sm/:" - if test "${PIPESTATUS[*]}" != "0 0"; then - error "git ls-files in submodule $sm failed" - fi - done - } | grep -x -v $(for sm in $submodules; do echo "-e $sm"; done) > "$list_file" -else - git ls-files > "$list_file" -fi - -if test $? -ne 0; then - error "failed to generate list file" -fi - -tar -cf "$tar_file" -T "$list_file" || error "failed to create tar file" - exit 0 From patchwork Fri Jun 7 09:05:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C7956C5 for ; Fri, 7 Jun 2019 09:58:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69FC128734 for ; Fri, 7 Jun 2019 09:58:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DF4C28B3D; Fri, 7 Jun 2019 09:58:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E58ED28734 for ; Fri, 7 Jun 2019 09:58:06 +0000 (UTC) Received: from localhost ([::1]:47696 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBdN-00060g-7R for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:58:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42203) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002FZ-Ak for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004z0-P7 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:36633) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004py-Dg for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wm1-x342.google.com with SMTP id u8so1159985wmm.1 for ; Fri, 07 Jun 2019 02:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OhQM4ORyyZtDRv68wtOcg3+xNW2e7yr94fMwCAempbk=; b=UMd1PW81Nj/a3TRplm/lgKp2JXzvoHSJjTtZll+c7phGlQWKWg5mwWODsWvI8+kmDL IVHMaE9yVLb3cnlOZODLztG3EBldrEDme4wzEaQ6RetdQB3ATrDs8fiX4V74uRIHRQE0 xeDWyFzu8EUy+3VUQlgO19fHB25paTllhKVcUW0B7Gy9n9RMHMb3ExApVE/s9Pi84O/k eiSEk/o+oYhx9bGWDgw6+7R9+FJ25/mbhs0umEPjRB/hJGn6/nZprASBU9zzmmgMLNxf nBrwr1IBKPLeXIGEs3irxDU/JD2l3JZcbEpl5BX4xsuWbHXHZJBlNhAL1asmwwq91I5f Cucg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OhQM4ORyyZtDRv68wtOcg3+xNW2e7yr94fMwCAempbk=; b=DA3MzbaPsaMlAFZI+5j6xevFJ5uOu90sRUB4KMdfZ74Tmy+0xDx6Ty2cVAwn9zcqPk A+6zgfeV3FZ3Cy1wkVFYHdqGw4kbym2dOP9cYhqr3HKG8/RicouxdobG6OBnaxy9NFCw 3mEN7NQDbBHkrzK/BtBnIjrBpeh621lChGMVZEo6W5qFtXDQb+Uee2utX9WlNqifOO5W I0JwRmuAilA5zGxAmR309UunXoVSj9bSl1Dqil+SzxXBW8AYkXbO+E1bdjq9HSR9hN7d qwK9cDOaga1SxNIfLD0xK/r/AZYVvjMTud+aNXTb22RvT1g7m2SXlgjvX4VpLMXdNdCr hh0Q== X-Gm-Message-State: APjAAAWqUVjfrEuv6SoyUvw2AKwLgkFBhjoHzm0lPR8k3xqhpDB4w5lX cMSVKh7PAEdYuh8JGj0Ro8LZAA== X-Google-Smtp-Source: APXvYqwR2WoFhETcC0+cb0jjzvNQM6kyeAStJmVvsXAaTwZHA+AUOXZQkx7HeSKxfucuFyS0geO9yw== X-Received: by 2002:a1c:5412:: with SMTP id i18mr2798141wmb.11.1559898756112; Fri, 07 Jun 2019 02:12:36 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k13sm1066954wmj.10.2019.06.07.02.12.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:32 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0E0901FF87; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:12 +0100 Message-Id: <20190607090552.12434-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PULL 13/52] tests/vm: python3 fixes 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: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann Add proper unicode handling when processing strings. Also need to explicitly say we want int not float. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20190520124716.30472-3-kraxel@redhat.com> [AJB: fix conflicts with tests/vm: Port basevm to Python 3] Signed-off-by: Alex Bennée diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 083befce9f..4847549592 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -73,7 +73,7 @@ class BaseVM(object): "-vnc", "127.0.0.1:0,to=20", "-serial", "file:%s" % os.path.join(self._tmpdir, "serial.out")] if vcpus and vcpus > 1: - self._args += ["-smp", str(vcpus)] + self._args += ["-smp", "%d" % vcpus] if kvm_available(self.arch): self._args += ["-enable-kvm"] else: @@ -85,12 +85,13 @@ class BaseVM(object): if not sha256sum: return True checksum = subprocess.check_output(["sha256sum", fname]).split()[0] - return sha256sum == checksum.decode() + return sha256sum == checksum.decode("utf-8") cache_dir = os.path.expanduser("~/.cache/qemu-vm/download") if not os.path.exists(cache_dir): os.makedirs(cache_dir) - fname = os.path.join(cache_dir, hashlib.sha1(url.encode()).hexdigest()) + fname = os.path.join(cache_dir, + hashlib.sha1(url.encode("utf-8")).hexdigest()) if os.path.exists(fname) and check_sha256sum(fname): return fname logging.debug("Downloading %s to %s...", url, fname) @@ -134,7 +135,7 @@ class BaseVM(object): raise NotImplementedError def add_source_dir(self, src_dir): - name = "data-" + hashlib.sha1(src_dir.encode()).hexdigest()[:5] + name = "data-" + hashlib.sha1(src_dir.encode("utf-8")).hexdigest()[:5] tarfile = os.path.join(self._tmpdir, name + ".tar") logging.debug("Creating archive %s for src_dir dir: %s", tarfile, src_dir) subprocess.check_call(["./scripts/archive-source.sh", tarfile], @@ -256,7 +257,7 @@ def main(vmcls): vm.add_source_dir(args.build_qemu) cmd = [vm.BUILD_SCRIPT.format( configure_opts = " ".join(argv), - jobs=args.jobs, + jobs=int(args.jobs), target=args.build_target, verbose = "V=1" if args.verbose else "")] else: From patchwork Fri Jun 7 09:05:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D1CA1515 for ; Fri, 7 Jun 2019 10:41:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A87728B4D for ; Fri, 7 Jun 2019 10:41:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EE9828B50; Fri, 7 Jun 2019 10:41:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2A1F328B4D for ; Fri, 7 Jun 2019 10:41:53 +0000 (UTC) Received: from localhost ([::1]:48174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCJk-0005op-Bk for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:41:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45085) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB55-0008MV-6M for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB54-0005xj-3M for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:39 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:54297) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB53-0005wn-SU for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:38 -0400 Received: by mail-wm1-x344.google.com with SMTP id g135so1270028wme.4 for ; Fri, 07 Jun 2019 02:22:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K60puiqqk977DMRGqqyet05oJzMhJ6Klb8DUPo/1Vlw=; b=GbiJ4TxkuDOA1cloaOY2UICFfE7xXXjk1cGMBJlz9lpbopmmJ5brGwZtMEpj1+E3RW RNn9dTHlY/10bq/wMimwjAnlbhD765sdE1Tbr65ta8xL6wFMmT5VWYqDNlYQVCzh9dQq wVNZ6Tm/Aze1m1rOh2hmx01OKCRFi8ZsZSc7o+CnttIIEjCRixZlDSQAc+RKbSShVqdC sxo3/weY9ncDjfP4blP+2n7r9uLVULKJqDYKBhOdJneCguPYh/LrbxAbUkC0EZKAPs94 diw0ewizv1XIRfytlerX9aD1eWm5bixaVTP4r4sD/OdZMcMa3wfPy5vgyyOeHV+M+jNU 06RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K60puiqqk977DMRGqqyet05oJzMhJ6Klb8DUPo/1Vlw=; b=s+QaDsT1sRIsP9zsnNi/rpqsDuQOesN6Kx5Oeucc0Qx3xWnIt1IWuNLgyTz0njRb7y fTEUyyB8IddhmbKiekYl+/apwFw18CRg5SDPxfH6TPHN1Lw+o9GiA+tWK+OpLRq1Z81e OQBT6SVS1ZnlWLmrX1RC92/dQzbvf9++bcFB8wI5aDTtJVL97blXyEgzO4HKS7AG40n6 /5hJ7liE/jhBS+DAfsqUjo+JSfF/QKNNdrL4ElV2UEP5KK1V4NzzJaMW7asBotjMSUga BQDOwny7EzT/2WowQH44LeXJSEtHVMMFv6M/8z8861GdlDcG0OlSlWrWtGa0p2mTOu/z Gd3Q== X-Gm-Message-State: APjAAAXQQmsSMTiFyLID02NNN62SzfZUeVpocjV7H9P+IWef2RP2fRqb 6v2ni6i3Jo0GLeCm0wqH0AfY3A== X-Google-Smtp-Source: APXvYqzvF+8YkoM1rf3g6a1r5cnH9j9m5nExakkI6bGkwUy9ILHLYvkIOAOAn2YlrHzK7Z0lvtNclg== X-Received: by 2002:a1c:b189:: with SMTP id a131mr3040412wmf.7.1559899356679; Fri, 07 Jun 2019 02:22:36 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a17sm1159492wrr.80.2019.06.07.02.22.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:35 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 217081FF9D; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:13 +0100 Message-Id: <20190607090552.12434-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PULL 14/52] tests/vm: send proxy environment variables over ssh 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: Fam Zheng , Thomas Huth , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann Packages are fetched via proxy that way, if configured on the host. That might be required to pass firewalls, and it allows to route package downloads through a caching proxy server. Needs AcceptEnv setup in sshd_config on the guest side to work. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé Tested-by: Thomas Huth Message-Id: <20190520124716.30472-4-kraxel@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 4847549592..5e30bac661 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -38,6 +38,13 @@ class BaseVM(object): GUEST_PASS = "qemupass" ROOT_PASS = "qemupass" + envvars = [ + "https_proxy", + "http_proxy", + "ftp_proxy", + "no_proxy", + ] + # The script to run in the guest that builds QEMU BUILD_SCRIPT = "" # The guest name, to be overridden by subclasses @@ -106,6 +113,8 @@ class BaseVM(object): "-o", "UserKnownHostsFile=" + os.devnull, "-o", "ConnectTimeout=1", "-p", self.ssh_port, "-i", self._ssh_key_file] + for var in self.envvars: + ssh_cmd += ['-o', "SendEnv=%s" % var ] if interactive: ssh_cmd += ['-t'] assert not isinstance(cmd, str) From patchwork Fri Jun 7 09:05:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981245 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 837DB14E5 for ; Fri, 7 Jun 2019 09:50:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7081128B20 for ; Fri, 7 Jun 2019 09:50:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64E8F28B3C; Fri, 7 Jun 2019 09:50:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 058E928B20 for ; Fri, 7 Jun 2019 09:50:01 +0000 (UTC) Received: from localhost ([::1]:47638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBVY-00078e-9d for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:50:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42217) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002Ft-Ct for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvR-00050K-1d for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:43592) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004mk-M5 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wr1-x432.google.com with SMTP id r18so1351590wrm.10 for ; Fri, 07 Jun 2019 02:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/mgOWUVQfFqS8c2PmAMUGsA0PAuyGOHp1Inf8fc96Sk=; b=j1d2RMPMtwyfSlpxp7P3wjBaDONJs3e34kgogE6dwdbGCbef3q4rAfnvRSmVj69BMI +e6GxvTwpqSoWRyin6zvftQoPFfwHs4k3ahAI0LkbuwIpkDLuSTixDt2ZNw8TTUWj16e k8PMbxHuxMq4ppH5Qq45R0v/8KGYO7p2gl3bZ/kJqvyDNgefLE9tja5AgrAQ2SrDtPq8 TGhgmQ0Lqyk6dI5zJG0THE4M2jyE/e6XB4IAG8v4y9fdhiIbOLMg6lcg31kqSt8dga2t y+M8GRdhbIBa3z+3DU9BGUO9skOcgJMrn9oj0KkT4Q46oXmiU8RhZs5EX5jYLBnR8k0T yXgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/mgOWUVQfFqS8c2PmAMUGsA0PAuyGOHp1Inf8fc96Sk=; b=txelfEcLP0m0O95/S72VMLFhyrLr4jtB1WR1FuvpeWb00e9NIy5/0TT5ZoEU39jg8I sTeGvdOOzbEn8gDDuUL2xR3FXCwGtfctyS1c3ON9li9l0p+I6mlNNuOMIt0cGdwfpluc os/cR6sNisilSmc8hZRuXi60ltK0SwAXbakBcU2JGxovxICJb105e9YUizgaX/neIOIz EYTp66fO16wur44lJpvmvwh4ILocm/iNcDC4h5DFq+BYoNTEvjfIEZpl6S5WGeJ16jxn exMBuPdZ2XNMZHqpvxHOiM5egKb9hS1XD7lEhzMLISJjTHVSFUDG93migDsx0gxUMdBG JD7A== X-Gm-Message-State: APjAAAWyhRE7owf9aZ+FWhxAIxVX9Sok+tQEcQDBZ5QSeA0hM62M9ewX 6JqRL/Oqn1wWMk1pDnUhyLYH7Q== X-Google-Smtp-Source: APXvYqxAcmyNwdQPMMw70mD9eafnRSjj0zh3ct8AXnziKdiFNtfCm6Tp4C+yF0CgnNN5MPnBpzQ11A== X-Received: by 2002:adf:9267:: with SMTP id 94mr10741052wrj.338.1559898754163; Fri, 07 Jun 2019 02:12:34 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x3sm1654450wrp.78.2019.06.07.02.12.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 34CA01FF9E; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:14 +0100 Message-Id: <20190607090552.12434-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 Subject: [Qemu-devel] [PULL 15/52] tests/vm: use ssh with pty unconditionally 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: Fam Zheng , Thomas Huth , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann Allways ask ssh to run with a pseudo terminal. Not having a terminal causes problems now and then. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20190520124716.30472-5-kraxel@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 5e30bac661..395eefaec9 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -107,16 +107,14 @@ class BaseVM(object): os.rename(fname + ".download", fname) return fname - def _ssh_do(self, user, cmd, check, interactive=False): - ssh_cmd = ["ssh", "-q", + def _ssh_do(self, user, cmd, check): + ssh_cmd = ["ssh", "-q", "-t", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=" + os.devnull, "-o", "ConnectTimeout=1", "-p", self.ssh_port, "-i", self._ssh_key_file] for var in self.envvars: ssh_cmd += ['-o', "SendEnv=%s" % var ] - if interactive: - ssh_cmd += ['-t'] assert not isinstance(cmd, str) ssh_cmd += ["%s@127.0.0.1" % user] + list(cmd) logging.debug("ssh_cmd: %s", " ".join(ssh_cmd)) @@ -128,9 +126,6 @@ class BaseVM(object): def ssh(self, *cmd): return self._ssh_do(self.GUEST_USER, cmd, False) - def ssh_interactive(self, *cmd): - return self._ssh_do(self.GUEST_USER, cmd, False, True) - def ssh_root(self, *cmd): return self._ssh_do("root", cmd, False) @@ -284,9 +279,9 @@ def main(vmcls): return 2 if args.interactive: - if vm.ssh_interactive(*cmd) == 0: + if vm.ssh(*cmd) == 0: return 0 - vm.ssh_interactive() + vm.ssh() return 3 else: if vm.ssh(*cmd) != 0: From patchwork Fri Jun 7 09:05:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15F9F924 for ; Fri, 7 Jun 2019 10:10:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04EE223B24 for ; Fri, 7 Jun 2019 10:10:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDA6E28A93; Fri, 7 Jun 2019 10:10:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D92B23B24 for ; Fri, 7 Jun 2019 10:10:09 +0000 (UTC) Received: from localhost ([::1]:47878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBp3-0007kR-0K for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:10:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45043) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB53-0008Fj-Ar for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB4y-0005oZ-5L for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:37 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:55429) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB4w-0005jC-69 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:31 -0400 Received: by mail-wm1-x329.google.com with SMTP id a15so1265163wmj.5 for ; Fri, 07 Jun 2019 02:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RWdjGRz2IFIKsx2DAAA/Umb0YtSGfkHMorsWs9va5Qs=; b=DeU2pisLAHpKCQTrWMuQukqIVvwYUA7fg1PfI5Nq2L1WDAZUf4w29Lv1uyySkFjoId H1uhokx5DM7zbJC9WU3CPnmJ2cGhrlrHYFyHBF652Wem4XkRcFSNPtVB55DRheDoV7sR u33ARvo8CsPyhgedtCVO22zmNQLkF0oHJmZ2Z8HSn7nU3y4mPmDpLWt5095Fwgts6iuX eWAYChQSLu8N4+1I4KRY3TPDK7UiFW5VFNu2Jzl9M7LQz+f//z67r6peCI5EgMeR7pn2 I1DimVMPGXhiY3MCmG/masM6sdFz6KKtUuN/KdP0kNXPaFI6LRBLncCpSRoVONbCJhEz 67Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RWdjGRz2IFIKsx2DAAA/Umb0YtSGfkHMorsWs9va5Qs=; b=qlIvIDkkaCY8QfV6ye+VesfVsp3e2c3VI3UVUTPn9MjpnYFlGWhRpUYYrqsoRfIlyD yA7mo9znyvc/cXpDLCn62SY/IbDbocjYAC/9W+v3AStOSzbJSwPDEV+/5a5bLDewNLfw dcN8nQj2xUrGR8WDmh3P5RgVyiV/4Vpp03UVBIflS2WSOxETBm/nJy90MOVAgLBEY5I1 zTzTiL9r3s6adjeXCkK1jOZAvI+KdKdi2/wY93Dd8qYWpSM6l/MgJ8oFlXSvaHKSaIMu c+OQtyQVyYVpJ9w6lK06JSArkCVNcdpUtUj5ld1QWsMlUleOhxF2O0whGcFdzWt7I8Kl /PvA== X-Gm-Message-State: APjAAAVQK0uOeH9pgp7gOphoGLMVKcnVuWU+8ApwGcfE8FrEM4Hy+TRv 88rpe8aH2geqE0eYUaccmNSHww== X-Google-Smtp-Source: APXvYqwspIJr8krtcz1k9XUePRTB9nfTtH3nvedd1aFd4ScwI1Oe0dhHPf/pAZjHzxeV4AQXP4xEVQ== X-Received: by 2002:a1c:7e08:: with SMTP id z8mr2745087wmc.36.1559899348675; Fri, 07 Jun 2019 02:22:28 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c14sm1218869wrt.45.2019.06.07.02.22.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 48ADB1FF9F; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:15 +0100 Message-Id: <20190607090552.12434-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 Subject: [Qemu-devel] [PULL 16/52] tests/vm: run test builds on snapshot 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: Fam Zheng , Thomas Huth , Ed Maste , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann The build script doesn't shutdown the guest VMs properly, which results in filesystem corruption and guest boot failures sooner or later. Use the --snapshot to run builds on a snapshot, That way killing the VM doesn't corrupt the base image. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Acked-by: Ed Maste Message-Id: <20190520124716.30472-6-kraxel@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index c59411bee0..276b870216 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -57,6 +57,7 @@ vm-build-%: $(IMAGES_DIR)/%.img $(if $(V),--verbose) \ --image "$<" \ $(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \ + --snapshot \ --build-qemu $(SRC_PATH) -- \ $(if $(TARGET_LIST),--target-list=$(TARGET_LIST)) \ $(if $(EXTRA_CONFIGURE_OPTS),$(EXTRA_CONFIGURE_OPTS)), \ From patchwork Fri Jun 7 09:05:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3938924 for ; Fri, 7 Jun 2019 09:22:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D23BE28AEC for ; Fri, 7 Jun 2019 09:22:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6CDE28B1F; Fri, 7 Jun 2019 09:22:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6C2D328AEC for ; Fri, 7 Jun 2019 09:22:39 +0000 (UTC) Received: from localhost ([::1]:47432 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB54-0008Hk-Oj for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:22:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39454) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAp5-00049e-I7 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAp3-0004bE-I9 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:07 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:39164) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAp1-0004Tt-N9 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:04 -0400 Received: by mail-wm1-x332.google.com with SMTP id z23so1125750wma.4 for ; Fri, 07 Jun 2019 02:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1dKkut+uCfwlAn3zScZi3hqAXXCijPCSIcimV4mZPU4=; b=fQ21quUUtSkH6czkTNF2HL8KksSz6YYwc8GIMCDUXjCPgqAFUiwFbZ9BICRDH1YB6J D1bjOB1iTrT5ntEM7XD/9K9zwWWqhVV+ND7ZwlQsVRK5KQqEbNQrZWIW/K86+OdK5XgF m8+WxuwXN0F+8lOxvPEoylggxPpqEafv/DkeesFSoGw+lLOK6W43olCYe0uSUGTUCDt4 LbZs+2UYdroMh5etp9WeQBCAh8g/1f2KQfzDQFHikggKnuF8v46OxoMAHoA+BTcW7nJK Etl4lwAFZN5SyaYN/EhgcKxznf88TItc4pUXBD2KgL5A/Xv5aMEY/kDq23pwEKCanN/T Z43g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1dKkut+uCfwlAn3zScZi3hqAXXCijPCSIcimV4mZPU4=; b=e73fM+3pZKy+c+uYIrXiGp9s3sz0oNQu7gi1V2dYHUPZJEvdU8DKImDVrhdgDQt/Jn bppl29qEH4dJwgFgnAaKEztePIATqF0TZREP5EJCpwU/07JbuHOFZe/cBPBEvyDMiStX WLT0XrSvScdyZxxLtFidVGzXJt3nXjbK2oDJk0QBUv0Diu6M0os83PHQnUVnI3Vp1KKZ QHeW3RYVUbi5LvB6ea7WOC484aCJCcoSEZFuxb3hbmUtD3UyrFWE7b73m3P5M9ZpOypT 65s/6+P9wd4oUhAFuHA8gyZxVd2pxQDcT5Kmsy5Rk+y0UHJu9ihUmRt3mf3KvBSjBMfb YJhQ== X-Gm-Message-State: APjAAAV4KOcsyKOlti1sVk7hPu5PGvGzB05F07HwFgTPzjp8/O66nYf2 mZ1jY4TmyTBSaJciLIJnQ7RWdA== X-Google-Smtp-Source: APXvYqxMCfe13Ui/4ND/lE/PEt3nd9N3tuL8FNIRUXp7xfjeR+wJtUmscPfwF75RVxUoJa8//y/pFw== X-Received: by 2002:a7b:c144:: with SMTP id z4mr3028525wmi.50.1559898362395; Fri, 07 Jun 2019 02:06:02 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o14sm1312338wrp.77.2019.06.07.02.05.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:58 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5C0FC1FFA3; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:16 +0100 Message-Id: <20190607090552.12434-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PULL 17/52] tests/vm: proper guest shutdown 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: Fam Zheng , Thomas Huth , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann When not running in snapshot mode ask the guest to poweroff and wait for this to finish instead of simply quitting qemu, so the guest can flush pending updates to disk. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20190520124716.30472-7-kraxel@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 395eefaec9..f27178f3c7 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -51,6 +51,8 @@ class BaseVM(object): name = "#base" # The guest architecture, to be overridden by subclasses arch = "#arch" + # command to halt the guest, can be overridden by subclasses + poweroff = "poweroff" def __init__(self, debug=False, vcpus=None): self._guest = None self._tmpdir = os.path.realpath(tempfile.mkdtemp(prefix="vm-test-", @@ -202,6 +204,10 @@ class BaseVM(object): def wait(self): self._guest.wait() + def graceful_shutdown(self): + self.ssh_root(self.poweroff) + self._guest.wait() + def qmp(self, *args, **kwargs): return self._guest.qmp(*args, **kwargs) @@ -278,11 +284,13 @@ def main(vmcls): traceback.print_exc() return 2 - if args.interactive: - if vm.ssh(*cmd) == 0: - return 0 + exitcode = 0 + if vm.ssh(*cmd) != 0: + exitcode = 3 + if exitcode != 0 and args.interactive: vm.ssh() - return 3 - else: - if vm.ssh(*cmd) != 0: - return 3 + + if not args.snapshot: + vm.graceful_shutdown() + + return exitcode From patchwork Fri Jun 7 09:05:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28E746C5 for ; Fri, 7 Jun 2019 10:18:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1732628A5F for ; Fri, 7 Jun 2019 10:18:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B9D528A8F; Fri, 7 Jun 2019 10:18:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A726728A8C for ; Fri, 7 Jun 2019 10:18:11 +0000 (UTC) Received: from localhost ([::1]:47940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBwo-0005WA-Sx for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:18:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42216) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002Fo-CG for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004zE-Rj for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:46952) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004h3-Ez for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wr1-x42b.google.com with SMTP id n4so1339732wrw.13 for ; Fri, 07 Jun 2019 02:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l3qvsmebNFZ5O5OwW5sp1A169mo8OEERmO3Igp6r4L0=; b=lMUN8FsR0cqZW/CU4/NbtsCLcBR8lJnXtHyTldqgblkNKAnHQK2Qty+ilzAsmIvRii itp+rMKzSh8P3cq5hQUkj47H6JdSGbG8OCq4V8aBzqNm0TYQuRiHK0WZiE9vfNqLM9is Zx7E1hFB5isz0bO1hFi/8Fq6mlR14VurwnJe//aP9z/oWbHWzU5MocnriDBDeMwBZwFz W4X9Yi8WLO3In0d8gVQuoP8RjGtOxJJ2y4zuqYRUDi1oQ4+7+fwJNV7mT1w5SK3Eh0GJ dB5Gd6eu0khJ4r3zAjCaXmbc1RGRiGeaAwqtbhnGcU6vQUieAvcnawtzB6v4G883ucq4 Jx7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l3qvsmebNFZ5O5OwW5sp1A169mo8OEERmO3Igp6r4L0=; b=sn2hNQONdnZGEFK1AoPkKQnFOXZWeN6PDWd8Vxglu+bak0iyob82IRgOtGfIhSjAEn R0mo6aEGYZda86pN7DOmWKjCav8Mrgs/tnoFUYZSoYp269bIzcAKYGQREs/ZHMB2ohVU 3IKj5wn68LRk5cKL4/oCQttuAZZt/+DpnoBUK8eMe8cyGJDJlhQg21RLqGi0pUKUDO0O debEVEhhe6B+MXDzOWm7L00WHWxjPATGDVHuJCkHjvwE40ylhcszXa/Ol9sen66ZTmb1 mNBOohUKdQgMAJKpvZxWgO/gmlAjo2drP2gki9YS7NSUhWdgtEWqweYeRKu7gBwc2VU3 dKxA== X-Gm-Message-State: APjAAAWNYRm7F9ybf3DkqF4v/vMQZh1bfvUYiPv6jsX7XHrdmKrDgkBn 3flAPIwWFR0NqDZ4tsDdNM3F/g== X-Google-Smtp-Source: APXvYqwKhnBO6jkYhV8b+fvJ4mHvR5TGh4kJwMZod8JBrtKDYWlWER8YO0sEY7EBi6w1p8Nisus6sw== X-Received: by 2002:adf:d847:: with SMTP id k7mr2611647wrl.144.1559898751374; Fri, 07 Jun 2019 02:12:31 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id f2sm1244110wru.31.2019.06.07.02.12.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:29 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6F82F1FFA5; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:17 +0100 Message-Id: <20190607090552.12434-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b Subject: [Qemu-devel] [PULL 18/52] tests/vm: add vm-boot-{ssh, serial}- 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: Fam Zheng , Thomas Huth , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann For testing/troubleshooting convinience. make vm-boot-serial- Boot guest, with the serial console on stdio. make vm-boot-ssh- Boot guest, login via ssh. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20190520124716.30472-8-kraxel@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index 276b870216..e329129bd6 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -20,6 +20,10 @@ vm-test: @echo " vm-build-all - Build QEMU in all VMs" @echo " vm-clean-all - Clean up VM images" @echo + @echo "For trouble-shooting:" + @echo " vm-boot-serial- - Boot guest, serial console on stdio" + @echo " vm-boot-ssh- - Boot guest and login via ssh" + @echo @echo "Special variables:" @echo " BUILD_TARGET=foo - Override the build target" @echo " TARGET_LIST=a,b,c - Override target list in builds" @@ -63,3 +67,18 @@ vm-build-%: $(IMAGES_DIR)/%.img $(if $(EXTRA_CONFIGURE_OPTS),$(EXTRA_CONFIGURE_OPTS)), \ " VM-BUILD $*") +vm-boot-serial-%: $(IMAGES_DIR)/%.img + qemu-system-x86_64 -enable-kvm -m 4G -smp 2 -nographic \ + -drive if=none,id=vblk,cache=writeback,file="$<" \ + -netdev user,id=vnet \ + -device virtio-blk-pci,drive=vblk \ + -device virtio-net-pci,netdev=vnet \ + || true + +vm-boot-ssh-%: $(IMAGES_DIR)/%.img + $(call quiet-command, \ + $(SRC_PATH)/tests/vm/$* \ + --image "$<" \ + --interactive \ + false, \ + " VM-BOOT-SSH $*") From patchwork Fri Jun 7 09:05:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981313 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44D1514E5 for ; Fri, 7 Jun 2019 10:14:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3293728A8C for ; Fri, 7 Jun 2019 10:14:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26CAE28B44; Fri, 7 Jun 2019 10:14:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CACC728A8F for ; Fri, 7 Jun 2019 10:14:33 +0000 (UTC) Received: from localhost ([::1]:47910 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBtJ-0002md-2k for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:14:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45096) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB55-0008Ns-J7 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB54-0005ye-LE for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:39 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:43671) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB54-0005xM-Ec for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:38 -0400 Received: by mail-wr1-x42b.google.com with SMTP id r18so1383933wrm.10 for ; Fri, 07 Jun 2019 02:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+ZfldLb9B7VeRUSVpRgzD28NkUAhkqFAzhazcc+u144=; b=cmDTJKEtkMzcr6psA3LNpNyRnkhVyJKJ0w9cn2DW2WpQ8eGs94sCcn54vZ+YUuzKbN kPvRiV1ZVUB1ajzcWuYMr0ui24lzQPm6aa42LOEYZr+RBtLeE3mHRM07Ivi6cgJDCoda 3Ev4rKWnwolD2drdnnTvQUIkcxMWp3wrFWFyJfxnmmp9laDFGr8Qc9ynIQWaTNR+f4UO AD+QuGWUmyirmwG52cSmLFfI9yrdJzmB50dIEHXM89C3uK0l6Gv7ZUkZzipzvS3lFdZR ikwo99G/qvY4Q6HTdP+C1o6buLZqqBidXMky+kqpZQZpT9J5r5RqSHWDh+akIvKNQsZY uplQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+ZfldLb9B7VeRUSVpRgzD28NkUAhkqFAzhazcc+u144=; b=mLZvspwwkZ3Evn5kpToRbRkHJS+ruBzsWH0DVTYIvlcLXzxoCmJYx4qYJG31XvL/Df cfmSSn0b3wRy045BJnSZkvdbVzvUZJtgzKXsGNgFKn0408zV43YgVVIs+ykTIIuQEvgX UQMkq7YY216MCwqO1qgdAUOV32xltbX+RuagHeHwNpm3pjKsZqYIANKGERyXhdUdLw+P hOfjcopZpqJGRXobxVGXfgW2iMlzJ+jufkQVS1agijKgu/ozn+j9NojgERgNO4GHzIpe 9QZO94wIfAwV3rXSiPOUxpFFuP+6jyIb9U81eP7rtvScs44VucHZx/tgmubxWGNev/cq b8KQ== X-Gm-Message-State: APjAAAXU2EC4egS53IiyYjdSjB+bmsBJCUbvAJKOe3pU/H7L8CRysv0X PhEme/k1tixUewHdznzwwNyP2w== X-Google-Smtp-Source: APXvYqziNaH+upgth6XvX62bEsM1xfaHdBppgpaQ8sLDBBsXnbybR6lvgm/q1zrc7+VSGiKI6sZcow== X-Received: by 2002:a5d:4f8b:: with SMTP id d11mr16183565wru.264.1559899357141; Fri, 07 Jun 2019 02:22:37 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b136sm1669984wme.30.2019.06.07.02.22.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:35 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 834181FF8C; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:18 +0100 Message-Id: <20190607090552.12434-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b Subject: [Qemu-devel] [PULL 19/52] tests/vm: add DEBUG=1 to help text 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: Fam Zheng , Thomas Huth , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé Tested-by: Thomas Huth Message-Id: <20190520124716.30472-9-kraxel@redhat.com> [AJB: fix minor conflict] Signed-off-by: Alex Bennée diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index e329129bd6..628eecade7 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -25,6 +25,8 @@ vm-test: @echo " vm-boot-ssh- - Boot guest and login via ssh" @echo @echo "Special variables:" + @echo " DEBUG=1 - be verbose, also start interactive" + @echo " shell on build failures" @echo " BUILD_TARGET=foo - Override the build target" @echo " TARGET_LIST=a,b,c - Override target list in builds" @echo ' EXTRA_CONFIGURE_OPTS="..."' From patchwork Fri Jun 7 09:05:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1C8014E5 for ; Fri, 7 Jun 2019 10:08:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FF3423B24 for ; Fri, 7 Jun 2019 10:08:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 938ED28A5F; Fri, 7 Jun 2019 10:08:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 136B323B24 for ; Fri, 7 Jun 2019 10:08:58 +0000 (UTC) Received: from localhost ([::1]:47874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBnp-0006qK-Mv for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:08:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42071) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvK-00029C-9n for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvI-0004iY-B0 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:34 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:51455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvG-0004cS-9I for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:32 -0400 Received: by mail-wm1-x331.google.com with SMTP id f10so1243589wmb.1 for ; Fri, 07 Jun 2019 02:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kc3izJ/caZQgeBSPPI6ZRLJkm9nYRjlGJEG7EHnIId4=; b=jJc79QIPZTrHM+bOGn7gTtdrGaDWYdKKWhSSXjBk45e+POj9mZwUfqpsvWDC0nDprA kgvmXfgF9EKa5Y+o17DW+kHg1yrPDlOFcDphyMgVxuoyRuy4C/bqgtvK4kqMT9xxfqKm 9yZmEELhDJ70LU7zi6FhQVZTOvAnoy5OhI2RGt4+qBo+50lPoSySh/RDBx+Cvsjxvx6w I1PU+5L/jN56YBG+LY4yYe36v1natCkoo4huFxTS+oJ3Kg75qxKNNQm5SKTHaZOm87nq tt8HrYstX0BrP93cbQKPHp3UkJvKEphDdjgOMBMG+PIWMN+9vkeEZ83LRxq972ruz2Je gXHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kc3izJ/caZQgeBSPPI6ZRLJkm9nYRjlGJEG7EHnIId4=; b=YKLodf45iFGEm5CziyjTUWsA8d3Ua5hA1clRje1Osxsfy2BotXNieKEUJAdYYYyofA MAZmujh2TtJ2ckdsaOgMqg/bPe5PYFRREg1SRRRvh5QNbPE8lhx1D9tfpTnxqlXkceh5 3yicmcseD3F2b4s3J5nR8yyzjrxPCTLSnObrOefZLHOaeaHFVD4wbs7WWamjRztvRLrc uYFJmmjTwAhVMriy5srnDFdUE+cJhDKqDYm9hkE9lBApOhwaA2jao7Dd4nbrTxTXrgC8 y0riJdXBmwyCksf1GYOTDLHyan5w67OqWCmZQWQ3yRsU+qn9KMrpEr+h2AOfgO9c8Vqz K/XQ== X-Gm-Message-State: APjAAAXGgky/watNmnfLnsj6vUVQ/gm6m6DpStZd5+WWgVcBEQsUDSw9 7pC3UjuJgqXc6xxTGd34AoUsgA== X-Google-Smtp-Source: APXvYqzRhm00wFYga8gyWrpEAmIz1uNl7twxvBN9fVsHMCa3v/9PUk5wLlPBV6nnxxOij6wQ4x8npg== X-Received: by 2002:a7b:cc81:: with SMTP id p1mr2720909wma.107.1559898747664; Fri, 07 Jun 2019 02:12:27 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s10sm459370wmf.8.2019.06.07.02.12.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:26 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 968991FFA6; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:19 +0100 Message-Id: <20190607090552.12434-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 Subject: [Qemu-devel] [PULL 20/52] tests/vm: serial console support helpers 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: Fam Zheng , Thomas Huth , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann Add a bunch of helpers to talk to the guest using the serial console. Also drop the hard-coded -serial parameter for the vm so QEMUMachine.set_console() actually works. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20190520124716.30472-10-kraxel@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index f27178f3c7..8894267f07 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -2,10 +2,11 @@ # # VM testing base class # -# Copyright 2017 Red Hat Inc. +# Copyright 2017-2019 Red Hat Inc. # # Authors: # Fam Zheng +# Gerd Hoffmann # # This code is licensed under the GPL version 2 or later. See # the COPYING file in the top-level directory. @@ -13,7 +14,9 @@ from __future__ import print_function import os +import re import sys +import socket import logging import time import datetime @@ -79,8 +82,7 @@ class BaseVM(object): "-cpu", "max", "-netdev", "user,id=vnet,hostfwd=:127.0.0.1:0-:22", "-device", "virtio-net-pci,netdev=vnet", - "-vnc", "127.0.0.1:0,to=20", - "-serial", "file:%s" % os.path.join(self._tmpdir, "serial.out")] + "-vnc", "127.0.0.1:0,to=20"] if vcpus and vcpus > 1: self._args += ["-smp", "%d" % vcpus] if kvm_available(self.arch): @@ -162,6 +164,8 @@ class BaseVM(object): logging.debug("QEMU args: %s", " ".join(args)) qemu_bin = os.environ.get("QEMU", "qemu-system-" + self.arch) guest = QEMUMachine(binary=qemu_bin, args=args) + guest.set_machine('pc') + guest.set_console() try: guest.launch() except: @@ -184,6 +188,81 @@ class BaseVM(object): raise Exception("Cannot find ssh port from 'info usernet':\n%s" % \ usernet_info) + def console_init(self, timeout = 120): + vm = self._guest + vm.console_socket.settimeout(timeout) + + def console_log(self, text): + for line in re.split("[\r\n]", text): + # filter out terminal escape sequences + line = re.sub("\x1b\[[0-9;?]*[a-zA-Z]", "", line) + line = re.sub("\x1b\([0-9;?]*[a-zA-Z]", "", line) + # replace unprintable chars + line = re.sub("\x1b", "", line) + line = re.sub("[\x00-\x1f]", ".", line) + if line == "": + continue + # log console line + sys.stderr.write("con recv: %s\n" % line) + + def console_wait(self, expect): + vm = self._guest + output = "" + while True: + try: + chars = vm.console_socket.recv(1024) + except socket.timeout: + sys.stderr.write("console: *** read timeout ***\n") + sys.stderr.write("console: waiting for: '%s'\n" % expect) + sys.stderr.write("console: line buffer:\n") + sys.stderr.write("\n") + self.console_log(output.rstrip()) + sys.stderr.write("\n") + raise + output += chars.decode("latin1") + if expect in output: + break + if "\r" in output or "\n" in output: + lines = re.split("[\r\n]", output) + output = lines.pop() + if self.debug: + self.console_log("\n".join(lines)) + if self.debug: + self.console_log(output) + + def console_send(self, command): + vm = self._guest + if self.debug: + logline = re.sub("\n", "", command) + logline = re.sub("[\x00-\x1f]", ".", logline) + sys.stderr.write("con send: %s\n" % logline) + for char in list(command): + vm.console_socket.send(char.encode("utf-8")) + time.sleep(0.01) + + def console_wait_send(self, wait, command): + self.console_wait(wait) + self.console_send(command) + + def console_ssh_init(self, prompt, user, pw): + sshkey_cmd = "echo '%s' > .ssh/authorized_keys\n" % SSH_PUB_KEY.rstrip() + self.console_wait_send("login:", "%s\n" % user) + self.console_wait_send("Password:", "%s\n" % pw) + self.console_wait_send(prompt, "mkdir .ssh\n") + self.console_wait_send(prompt, sshkey_cmd) + self.console_wait_send(prompt, "chmod 755 .ssh\n") + self.console_wait_send(prompt, "chmod 644 .ssh/authorized_keys\n") + + def console_sshd_config(self, prompt): + self.console_wait(prompt) + self.console_send("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config\n") + for var in self.envvars: + self.console_wait(prompt) + self.console_send("echo 'AcceptEnv %s' >> /etc/ssh/sshd_config\n" % var) + + def print_step(self, text): + sys.stderr.write("### %s ...\n" % text) + def wait_ssh(self, seconds=300): starttime = datetime.datetime.now() endtime = starttime + datetime.timedelta(seconds=seconds) From patchwork Fri Jun 7 09:05:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981349 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CADB14C0 for ; Fri, 7 Jun 2019 10:34:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ACA728B49 for ; Fri, 7 Jun 2019 10:34:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2D5F28B4A; Fri, 7 Jun 2019 10:34:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D9E1428B45 for ; Fri, 7 Jun 2019 10:34:03 +0000 (UTC) Received: from localhost ([::1]:48068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCCA-0008MX-VE for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:34:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45061) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB54-0008IM-2e for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB52-0005vn-5x for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:38 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:35367) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB51-0005ud-Th for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:36 -0400 Received: by mail-wm1-x330.google.com with SMTP id c6so1192313wml.0 for ; Fri, 07 Jun 2019 02:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+eu+J+AReHOJ91tEV+4Y0qnnta+u3KP6te0Wm8mtIjs=; b=kvkb8v3n1wMTsnt8/p2c2ie+j35xWYiKp5s+i4TltGuiugslWamLojffr9Av5iHs5y HbpweHyAPQu4LkKM0wgG1FOmcBglebJp3xDvLGuzjRLS5lYyB/QHT9LEFvHebVA1KzR+ QDHh8rJmXPAHv1Bz4r+YDk5IlLzi3IJ9hQCSbOMlFRyeg1+fsAG1mDgn9A5sxAQKKhKt m5Wl3VQx3nlyMrcxhOpqbs3+M4a7mATLvr4yL6x6HYbtxgn844uNk5M2SrkwSqBR6O3N a1gfCI9V/PpW3gbLPiIodsWQGuizkIX+aBBJp5HO78As6Z4hzU0OcgmCPuCEgLmmRlow qpYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+eu+J+AReHOJ91tEV+4Y0qnnta+u3KP6te0Wm8mtIjs=; b=BDLkqQx6EcqdF51L31Vy6vv7+gs0bFSZRQRHkIjnAZUMC1hjo5xAjV3f1UiKePC8Ix X74rs/Vm6RC1EGvfvAt0EczrDetsha9icaApfu+1D/v8zqiOSjVBk8MrexNqHrYV8s8m bDxrzC/Ei0dvHjxZVHoxpTH+A62gNjkVhUarcXUlGvsk8RebmC0mgXoQJPz3Kt+PmhTZ l6HarZBnoqRj7a4icwRNjiMyxQdhiNzFpfI2VaaB2TFX3SJQF8AC3j3QQZ+/SYY5Oos1 bOhidRxVXYXyFu4jTU6gym5HTPJoN3IvEIAqfdcLkm1BfS/D9rk4VXJnE02RFHKMA3hq UDYQ== X-Gm-Message-State: APjAAAX8RoNa6OWYIzHB+eKRc8l7DWMXnweb0uE8BoJFpnGcssIdf8p2 7MTchC95FfwLfRX5Vz52qz5yig== X-Google-Smtp-Source: APXvYqwMEr/UQDNSyU/f0CJDcX5QETknyuqfBWwqDDmTAcu4PJdMTt2TgCAWHTaxBDmSxZG0+HGwbw== X-Received: by 2002:a1c:480a:: with SMTP id v10mr2899790wma.120.1559899354889; Fri, 07 Jun 2019 02:22:34 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y133sm2528618wmg.5.2019.06.07.02.22.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AA4AB1FFA9; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:20 +0100 Message-Id: <20190607090552.12434-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::330 Subject: [Qemu-devel] [PULL 21/52] tests/vm: openbsd autoinstall, using serial console 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: Fam Zheng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= , Brad Smith Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann Instead of fetching the prebuilt image from patchew download the install iso and prepare the image locally. Install to disk, using the serial console. Create qemu user, configure ssh login. Install packages needed for qemu builds. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20190520124716.30472-11-kraxel@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/openbsd b/tests/vm/openbsd index 2105c01a26..c5f0a15218 100755 --- a/tests/vm/openbsd +++ b/tests/vm/openbsd @@ -2,10 +2,11 @@ # # OpenBSD VM image # -# Copyright 2017 Red Hat Inc. +# Copyright 2017-2019 Red Hat Inc. # # Authors: # Fam Zheng +# Gerd Hoffmann # # This code is licensed under the GPL version 2 or later. See # the COPYING file in the top-level directory. @@ -13,34 +14,165 @@ import os import sys +import socket import subprocess import basevm class OpenBSDVM(basevm.BaseVM): name = "openbsd" arch = "x86_64" + + link = "https://cdn.openbsd.org/pub/OpenBSD/6.5/amd64/install65.iso" + csum = "38d1f8cadd502f1c27bf05c5abde6cc505dd28f3f34f8a941048ff9a54f9f608" + size = "20G" + pkgs = [ + # tools + "git", + "pkgconf", + "bzip2", "xz", + + # gnu tools + "bash", + "gmake", + "gsed", + "bison", + + # libs: usb + "libusb1", + + # libs: crypto + "gnutls", + + # libs: images + "jpeg", + "png", + + # libs: ui + "sdl2", + "gtk+3", + "libxkbcommon", + ] + BUILD_SCRIPT = """ set -e; - rm -rf /var/tmp/qemu-test.* - cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); + rm -rf /home/qemu/qemu-test.* + cd $(mktemp -d /home/qemu/qemu-test.XXXXXX); + mkdir src build; cd src; tar -xf /dev/rsd1c; - ./configure --cc=x86_64-unknown-openbsd6.1-gcc-4.9.4 --python=python2.7 {configure_opts}; - gmake --output-sync -j{jobs} {verbose}; - # XXX: "gmake check" seems to always hang or fail - #gmake --output-sync -j{jobs} check {verbose}; + cd ../build + ../src/configure --cc=cc --python=python3 {configure_opts}; + gmake --output-sync -j{jobs} {target} {verbose}; """ + poweroff = "halt -p" def build_image(self, img): - cimg = self._download_with_cache("http://download.patchew.org/openbsd-6.1-amd64.img.xz", - sha256sum='8c6cedc483e602cfee5e04f0406c64eb99138495e8ca580bc0293bcf0640c1bf') - img_tmp_xz = img + ".tmp.xz" + self.print_step("Downloading install iso") + cimg = self._download_with_cache(self.link, sha256sum=self.csum) img_tmp = img + ".tmp" - sys.stderr.write("Extracting the image...\n") - subprocess.check_call(["cp", "-f", cimg, img_tmp_xz]) - subprocess.check_call(["xz", "-dvf", img_tmp_xz]) + iso = img + ".install.iso" + + self.print_step("Preparing iso and disk image") + subprocess.check_call(["cp", "-f", cimg, iso]) + subprocess.check_call(["qemu-img", "create", "-f", "qcow2", + img_tmp, self.size]) + + self.print_step("Booting installer") + self.boot(img_tmp, extra_args = [ + "-machine", "graphics=off", + "-cdrom", iso + ]) + self.console_init() + self.console_wait_send("boot>", "set tty com0\n") + self.console_wait_send("boot>", "\n") + + # pre-install configuration + self.console_wait_send("(I)nstall", "i\n") + self.console_wait_send("Terminal type", "xterm\n") + self.console_wait_send("System hostname", "openbsd\n") + self.console_wait_send("Which network interface", "vio0\n") + self.console_wait_send("IPv4 address", "dhcp\n") + self.console_wait_send("IPv6 address", "none\n") + self.console_wait_send("Which network interface", "done\n") + self.console_wait_send("DNS domain name", "localnet\n") + self.console_wait("Password for root account") + self.console_send("%s\n" % self.ROOT_PASS) + self.console_wait("Password for root account") + self.console_send("%s\n" % self.ROOT_PASS) + self.console_wait_send("Start sshd(8)", "yes\n") + self.console_wait_send("X Window System", "\n") + self.console_wait_send("xenodm", "\n") + self.console_wait_send("console to com0", "\n") + self.console_wait_send("Which speed", "\n") + + self.console_wait("Setup a user") + self.console_send("%s\n" % self.GUEST_USER) + self.console_wait("Full name") + self.console_send("%s\n" % self.GUEST_USER) + self.console_wait("Password") + self.console_send("%s\n" % self.GUEST_PASS) + self.console_wait("Password") + self.console_send("%s\n" % self.GUEST_PASS) + + self.console_wait_send("Allow root ssh login", "yes\n") + self.console_wait_send("timezone", "UTC\n") + self.console_wait_send("root disk", "\n") + self.console_wait_send("(W)hole disk", "\n") + self.console_wait_send("(A)uto layout", "\n") + self.console_wait_send("Location of sets", "cd0\n") + self.console_wait_send("Pathname to the sets", "\n") + self.console_wait_send("Set name(s)", "\n") + self.console_wait_send("without verification", "yes\n") + + self.print_step("Installation started now, this will take a while") + self.console_wait_send("Location of sets", "done\n") + + self.console_wait("successfully completed") + self.print_step("Installation finished, rebooting") + self.console_wait_send("(R)eboot", "reboot\n") + + # setup qemu user + prompt = "$" + self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_wait_send(prompt, "exit\n") + + # setup root user + prompt = "openbsd#" + self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_sshd_config(prompt) + + # setup virtio-blk #1 (tarfile) + self.console_wait(prompt) + self.console_send("echo 'chmod 666 /dev/rsd1c' >> /etc/rc.local\n") + + # enable w+x for /home + self.console_wait(prompt) + self.console_send("sed -i -e '/home/s/rw,/rw,wxallowed,/' /etc/fstab\n") + + # tweak datasize limit + self.console_wait(prompt) + self.console_send("sed -i -e 's/\\(datasize[^=]*\\)=[^:]*/\\1=infinity/' /etc/login.conf\n") + + # use http (be proxy cache friendly) + self.console_wait(prompt) + self.console_send("sed -i -e 's/https/http/' /etc/installurl\n") + + self.print_step("Configuration finished, rebooting") + self.console_wait_send(prompt, "reboot\n") + self.console_wait("login:") + self.wait_ssh() + + self.print_step("Installing packages") + self.ssh_root_check("pkg_add %s\n" % " ".join(self.pkgs)) + + # shutdown + self.ssh_root(self.poweroff) + self.wait() + if os.path.exists(img): os.remove(img) os.rename(img_tmp, img) + os.remove(iso) + self.print_step("All done") if __name__ == "__main__": sys.exit(basevm.main(OpenBSDVM)) From patchwork Fri Jun 7 09:05:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8DD7C14C0 for ; Fri, 7 Jun 2019 10:29:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B25028B27 for ; Fri, 7 Jun 2019 10:29:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EA9928B44; Fri, 7 Jun 2019 10:29:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC88528B27 for ; Fri, 7 Jun 2019 10:29:28 +0000 (UTC) Received: from localhost ([::1]:48030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZC7j-0004nG-VF for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:29:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45047) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB53-0008GQ-HY for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB51-0005uu-Li for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:37 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:39299) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB51-0005te-De for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:35 -0400 Received: by mail-wm1-x335.google.com with SMTP id z23so1177080wma.4 for ; Fri, 07 Jun 2019 02:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cPFW/NQCTD1YuEWUMaj2AKLzeFOOtVT+5XvLwXo1SAo=; b=z42f2zZG7+J1Td+/0hAcxWML9WeGqhHM790kp0lQP1EmrDG2NhMT/0gGdDrchSbbf5 cz8VyKvaQqJdK94Vep7OO3kzfc2TU/52vbi7F+3Rdg/DC2ICioHM8Fjjx7zW4rQfRd/A zZo+5HiksV0i9BMhNWMLu7Zov6jgE48PffcS7aBlIKr3sEQJlcIA8iAcoSPXb94LAV67 Avl6gZfGJG/2hBkiazYQ7dXltaao5M4zEzBmfQwiJv/jABM3vgR0j8wQtVrA4/Y79fWR eHxbJKmuEXhKCUfFqL73+1zAec7IquM/rbSvhgEzzNcxa0OFsrBlHKk4JQ24YdzzeSnt XoeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cPFW/NQCTD1YuEWUMaj2AKLzeFOOtVT+5XvLwXo1SAo=; b=Hf4hJws+jhLDa2O8Z/o1ZfiyyknAEnM1OLvtU7Ys3uXTvZrBh2kDLetQkISUovUNpq PB5MEkXOMvij0NgzZvGWbNXsIno9k4yzxGvSCj1UW4IajnH4pUTW5T8sFHanuORJGonH KFztt9h9Zif8JF3tDT9YX8qXEM5eV9jZhfoEz2u2ryc9H+9hl3pyys/8U8itJw6y1TRM uxrNPgWlglb7uzi5bY2pOOsAYjBhuxyiBZdQrVStRIadc7BbqmnCJEuIW2FQsMt48vLF FgOOn8rLoUqJ1XmFAyEhiB96rbzvdxoBxXNWqClscXkEPPFI7M8oaJUciZE188bkcxba 1+Qw== X-Gm-Message-State: APjAAAVPuVHmIcqZblu7J+8rr63QMrdLjQ/ukKwDkU4nT42g1zfSYJ+m HuMbxBGXHUczrOoWdCFJxim9AA== X-Google-Smtp-Source: APXvYqwhuh8QM5KLsUZLlMMnNp1mXAzxkVE5z8hFgEmo98PsOUnL5vB0cdATSMTW3Aoj8DiOz7a2Kg== X-Received: by 2002:a1c:f20c:: with SMTP id s12mr3109561wmc.151.1559899354197; Fri, 07 Jun 2019 02:22:34 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id e7sm1250790wmd.0.2019.06.07.02.22.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BDFA71FFAA; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:21 +0100 Message-Id: <20190607090552.12434-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 Subject: [Qemu-devel] [PULL 22/52] tests/vm: freebsd autoinstall, using serial console 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: Fam Zheng , Thomas Huth , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann Instead of fetching the prebuilt image from patchew download the install iso and prepare the image locally. Install to disk, using the serial console. Create qemu user, configure ssh login. Install packages needed for qemu builds. Note that freebsd package downloads are delivered as non-cachable content, so I had to configure squid with "ignore-no-store ignore-private ignore-reload" for pkgmir.geo.freebsd.org to make the caching actually work. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Tested-by: Thomas Huth Message-Id: <20190520124716.30472-12-kraxel@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/freebsd b/tests/vm/freebsd index b0066017a6..eb029bdfed 100755 --- a/tests/vm/freebsd +++ b/tests/vm/freebsd @@ -2,43 +2,202 @@ # # FreeBSD VM image # -# Copyright 2017 Red Hat Inc. +# Copyright 2017-2019 Red Hat Inc. # # Authors: # Fam Zheng +# Gerd Hoffmann # # This code is licensed under the GPL version 2 or later. See # the COPYING file in the top-level directory. # import os +import re import sys +import time +import socket import subprocess import basevm class FreeBSDVM(basevm.BaseVM): name = "freebsd" arch = "x86_64" + + link = "https://download.freebsd.org/ftp/releases/ISO-IMAGES/12.0/FreeBSD-12.0-RELEASE-amd64-disc1.iso.xz" + csum = "1d40015bea89d05b8bd13e2ed80c40b522a9ec1abd8e7c8b80954fb485fb99db" + size = "20G" + pkgs = [ + # build tools + "git", + "pkgconf", + "bzip2", + + # gnu tools + "bash", + "gmake", + "gsed", + "flex", "bison", + + # libs: crypto + "gnutls", + + # libs: images + "jpeg-turbo", + "png", + + # libs: ui + "sdl2", + "gtk3", + "libxkbcommon", + + # libs: opengl + "libepoxy", + "mesa-libs", + ] + BUILD_SCRIPT = """ set -e; - rm -rf /var/tmp/qemu-test.* - cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); + rm -rf /home/qemu/qemu-test.* + cd $(mktemp -d /home/qemu/qemu-test.XXXXXX); + mkdir src build; cd src; tar -xf /dev/vtbd1; - ./configure {configure_opts}; + cd ../build + ../src/configure --python=python3.6 {configure_opts}; gmake --output-sync -j{jobs} {target} {verbose}; """ + def console_boot_serial(self): + self.console_wait_send("Autoboot", "3") + self.console_wait_send("OK", "set console=comconsole\n") + self.console_wait_send("OK", "boot\n") + def build_image(self, img): - cimg = self._download_with_cache("http://download.patchew.org/freebsd-11.1-amd64.img.xz", - sha256sum='adcb771549b37bc63826c501f05121a206ed3d9f55f49145908f7e1432d65891') - img_tmp_xz = img + ".tmp.xz" + self.print_step("Downloading install iso") + cimg = self._download_with_cache(self.link, sha256sum=self.csum) img_tmp = img + ".tmp" - sys.stderr.write("Extracting the image...\n") - subprocess.check_call(["cp", "-f", cimg, img_tmp_xz]) - subprocess.check_call(["xz", "-dvf", img_tmp_xz]) + iso = img + ".install.iso" + iso_xz = iso + ".xz" + + self.print_step("Preparing iso and disk image") + subprocess.check_call(["cp", "-f", cimg, iso_xz]) + subprocess.check_call(["xz", "-dvf", iso_xz]) + subprocess.check_call(["qemu-img", "create", "-f", "qcow2", + img_tmp, self.size]) + + self.print_step("Booting installer") + self.boot(img_tmp, extra_args = [ + "-machine", "graphics=off", + "-cdrom", iso + ]) + self.console_init() + self.console_boot_serial() + self.console_wait_send("Console type", "xterm\n") + + # pre-install configuration + self.console_wait_send("Welcome", "\n") + self.console_wait_send("Keymap Selection", "\n") + self.console_wait_send("Set Hostname", "freebsd\n") + self.console_wait_send("Distribution Select", "\n") + self.console_wait_send("Partitioning", "\n") + self.console_wait_send("Partition", "\n") + self.console_wait_send("Scheme", "\n") + self.console_wait_send("Editor", "f") + self.console_wait_send("Confirmation", "c") + + self.print_step("Installation started now, this will take a while") + + # post-install configuration + self.console_wait("New Password:") + self.console_send("%s\n" % self.ROOT_PASS) + self.console_wait("Retype New Password:") + self.console_send("%s\n" % self.ROOT_PASS) + + self.console_wait_send("Network Configuration", "\n") + self.console_wait_send("IPv4", "y") + self.console_wait_send("DHCP", "y") + self.console_wait_send("IPv6", "n") + self.console_wait_send("Resolver", "\n") + + self.console_wait_send("Time Zone Selector", "a\n") + self.console_wait_send("Confirmation", "y") + self.console_wait_send("Time & Date", "\n") + self.console_wait_send("Time & Date", "\n") + + self.console_wait_send("System Configuration", "\n") + self.console_wait_send("System Hardening", "\n") + + # qemu user + self.console_wait_send("Add User Accounts", "y") + self.console_wait("Username") + self.console_send("%s\n" % self.GUEST_USER) + self.console_wait("Full name") + self.console_send("%s\n" % self.GUEST_USER) + self.console_wait_send("Uid", "\n") + self.console_wait_send("Login group", "\n") + self.console_wait_send("Login group", "\n") + self.console_wait_send("Login class", "\n") + self.console_wait_send("Shell", "\n") + self.console_wait_send("Home directory", "\n") + self.console_wait_send("Home directory perm", "\n") + self.console_wait_send("Use password", "\n") + self.console_wait_send("Use an empty password", "\n") + self.console_wait_send("Use a random password", "\n") + self.console_wait("Enter password:") + self.console_send("%s\n" % self.GUEST_PASS) + self.console_wait("Enter password again:") + self.console_send("%s\n" % self.GUEST_PASS) + self.console_wait_send("Lock out", "\n") + self.console_wait_send("OK", "yes\n") + self.console_wait_send("Add another user", "no\n") + + self.console_wait_send("Final Configuration", "\n") + self.console_wait_send("Manual Configuration", "\n") + self.console_wait_send("Complete", "\n") + + self.print_step("Installation finished, rebooting") + self.console_boot_serial() + + # setup qemu user + prompt = "$" + self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_wait_send(prompt, "exit\n") + + # setup root user + prompt = "root@freebsd:~ #" + self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_sshd_config(prompt) + + # setup serial console + self.console_wait(prompt) + self.console_send("echo 'console=comconsole' >> /boot/loader.conf\n") + + # setup boot delay + self.console_wait(prompt) + self.console_send("echo 'autoboot_delay=1' >> /boot/loader.conf\n") + + # setup virtio-blk #1 (tarfile) + self.console_wait(prompt) + self.console_send("echo 'chmod 666 /dev/vtbd1' >> /etc/rc.local\n") + + self.print_step("Configuration finished, rebooting") + self.console_wait_send(prompt, "reboot\n") + self.console_wait("login:") + self.wait_ssh() + + self.print_step("Installing packages") + self.ssh_root_check("pkg install -y %s\n" % " ".join(self.pkgs)) + + # shutdown + self.ssh_root(self.poweroff) + self.console_wait("Uptime:") + self.wait() + if os.path.exists(img): os.remove(img) os.rename(img_tmp, img) + os.remove(iso) + self.print_step("All done") if __name__ == "__main__": sys.exit(basevm.main(FreeBSDVM)) From patchwork Fri Jun 7 09:05:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981309 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E08D514E5 for ; Fri, 7 Jun 2019 10:11:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCE1728A8C for ; Fri, 7 Jun 2019 10:11:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C07B228A93; Fri, 7 Jun 2019 10:11:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9C56A28A8C for ; Fri, 7 Jun 2019 10:11:24 +0000 (UTC) Received: from localhost ([::1]:47880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBqF-00085o-Rl for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:11:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42226) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002H6-QI for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004zn-Un for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:35408) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004qw-Hz for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wr1-x435.google.com with SMTP id m3so1390662wrv.2 for ; Fri, 07 Jun 2019 02:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FsH9fIoqslU5eUblZQD4hWHct1S0ABTNMLOgnPxlbLE=; b=aWXmPjGBy4Ril9qJecr8mYSOCksXK4aMrQUZ+rnS+4GKeMJdTyJdYGI0FcDR4KnwHG KM5v7XB+1zWm5xtiObxyl8iAob0s1Vu9Qak8sdT1E/DyJMxXGcDEKv/Js4oNDr+G97kB 95wfTfCsLv+vP0Vsk0QWe32KPzaUQLtBlQdk0HF36N7S+K3zTsLmyoc8lfMwXcGCFHQM e3wS9Xttzez9iQJiYYpcMdmFfBjFiVBemzUS3rqcjGxOrxFjuRsF4SFRV738fKePRu66 tP6KalD9v3I1Yylm/3Y+YZGM8KTAgLEtvcT1nul4g7wnKES06n5js1gQjgUi8ZBfFg2v iCHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FsH9fIoqslU5eUblZQD4hWHct1S0ABTNMLOgnPxlbLE=; b=qTl6wWLA5pokSU/9P2UWPrM4a2nCEWtBvy6jab2uYSpGD0wQoyI0TnfSxirJttIFvU rJnLKXK3rxBVDfnJhNtu1SU8579FYkfBqlbn1bjVGyiDosog5aLLJ/PZu7sptNDwPXl1 TzElLjvUcPvbGAhh9DbHd2+fwul6T942XvPkydlfIzziZD+qsnoJdvj9rWlcVQ8XsBC4 pYCM0I4pbtHc1TY0x3oPDa39kgPCqBLhRHwhIQt8BG3UdaqMIXkCzB2BxWDcQSo2ZOm4 V18yULHWZqE73nkFcLM3ETQOoCIz28RWILrX8fbvzRK74Z8gVF6V3/sNrxAG/1Fv6qiu /rYw== X-Gm-Message-State: APjAAAX42ZibPA16XGYhDPbkRz7390+6pd4JsHSZou6PvfLUespy92ns tHzZgJ981uRfQhwA59GCvhjmOw== X-Google-Smtp-Source: APXvYqwZP5JsqRUDTMi4MveI4gn71e5lqk6ykHu2tuveFPjBBVWCDm1OMEPg8qEfZsXUFSaA/xDMHA== X-Received: by 2002:a5d:6748:: with SMTP id l8mr7693721wrw.199.1559898756884; Fri, 07 Jun 2019 02:12:36 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s8sm2078626wra.55.2019.06.07.02.12.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:34 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D208C1FFAB; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:22 +0100 Message-Id: <20190607090552.12434-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 Subject: [Qemu-devel] [PULL 23/52] tests/vm: netbsd autoinstall, using serial console 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: Fam Zheng , Thomas Huth , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Kamil Rytarowski , Gerd Hoffmann , Kamil Rytarowski , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann Instead of fetching the prebuilt image from patchew download the install iso and prepare the image locally. Install to disk, using the serial console. Create qemu user, configure ssh login. Install packages needed for qemu builds. Signed-off-by: Gerd Hoffmann Reviewed-by: Kamil Rytarowski Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20190520124716.30472-13-kraxel@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/netbsd b/tests/vm/netbsd index 4c6624ea5e..6dbfc1b0fb 100755 --- a/tests/vm/netbsd +++ b/tests/vm/netbsd @@ -2,10 +2,11 @@ # # NetBSD VM image # -# Copyright 2017 Red Hat Inc. +# Copyright 2017-2019 Red Hat Inc. # # Authors: # Fam Zheng +# Gerd Hoffmann # # This code is licensed under the GPL version 2 or later. See # the COPYING file in the top-level directory. @@ -13,32 +14,198 @@ import os import sys +import time import subprocess import basevm class NetBSDVM(basevm.BaseVM): name = "netbsd" arch = "x86_64" + + link = "https://cdn.netbsd.org/pub/NetBSD/NetBSD-8.0/images/NetBSD-8.0-amd64.iso" + size = "20G" + pkgs = [ + # tools + "git-base", + "pkgconf", + "xz", + "python37", + + # gnu tools + "bash", + "gmake", + "gsed", + "flex", "bison", + + # libs: crypto + "gnutls", + + # libs: images + "jpeg", + "png", + + # libs: ui + "SDL2", + "gtk3+", + "libxkbcommon", + ] + BUILD_SCRIPT = """ set -e; - rm -rf /var/tmp/qemu-test.* - cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); + rm -rf /home/qemu/qemu-test.* + cd $(mktemp -d /home/qemu/qemu-test.XXXXXX); + mkdir src build; cd src; tar -xf /dev/rld1a; - ./configure --python=python2.7 {configure_opts}; + cd ../build + ../src/configure --python=python3.7 --disable-opengl {configure_opts}; gmake --output-sync -j{jobs} {target} {verbose}; """ + poweroff = "/sbin/poweroff" def build_image(self, img): - cimg = self._download_with_cache("http://download.patchew.org/netbsd-7.1-amd64.img.xz", - sha256sum='b633d565b0eac3d02015cd0c81440bd8a7a8df8512615ac1ee05d318be015732') - img_tmp_xz = img + ".tmp.xz" + cimg = self._download_with_cache(self.link) img_tmp = img + ".tmp" - sys.stderr.write("Extracting the image...\n") - subprocess.check_call(["cp", "-f", cimg, img_tmp_xz]) - subprocess.check_call(["xz", "-dvf", img_tmp_xz]) + iso = img + ".install.iso" + + self.print_step("Preparing iso and disk image") + subprocess.check_call(["cp", "-f", cimg, iso]) + subprocess.check_call(["qemu-img", "create", "-f", "qcow2", + img_tmp, self.size]) + + self.print_step("Booting installer") + self.boot(img_tmp, extra_args = [ + "-device", "VGA", + "-machine", "graphics=off", + "-cdrom", iso + ]) + self.console_init() + self.console_wait("Primary Bootstrap") + + # serial console boot menu output doesn't work for some + # reason, so we have to fly blind ... + for char in list("5consdev com0\n"): + time.sleep(0.2) + self.console_send(char) + self.console_wait("") + self.console_wait_send("> ", "boot\n") + + self.console_wait_send("Terminal type", "xterm\n") + self.console_wait_send("a: Installation messages", "a\n") + self.console_wait_send("b: US-English", "b\n") + self.console_wait_send("a: Install NetBSD", "a\n") + self.console_wait("Shall we continue?") + self.console_wait_send("b: Yes", "b\n") + + self.console_wait_send("a: ld0", "a\n") + self.console_wait_send("a: This is the correct", "a\n") + self.console_wait_send("b: Use the entire disk", "b\n") + self.console_wait("NetBSD bootcode") + self.console_wait_send("a: Yes", "a\n") + self.console_wait_send("b: Use existing part", "b\n") + self.console_wait_send("x: Partition sizes ok", "x\n") + self.console_wait_send("for your NetBSD disk", "\n") + self.console_wait("Shall we continue?") + self.console_wait_send("b: Yes", "b\n") + + self.console_wait_send("b: Use serial port com0", "b\n") + self.console_wait_send("f: Set serial baud rate", "f\n") + self.console_wait_send("a: 9600", "a\n") + self.console_wait_send("x: Exit", "x\n") + + self.console_wait_send("a: Full installation", "a\n") + self.console_wait_send("a: CD-ROM", "a\n") + + self.print_step("Installation started now, this will take a while") + self.console_wait_send("Hit enter to continue", "\n") + + self.console_wait_send("d: Change root password", "d\n") + self.console_wait_send("a: Yes", "a\n") + self.console_wait("New password:") + self.console_send("%s\n" % self.ROOT_PASS) + self.console_wait("New password:") + self.console_send("%s\n" % self.ROOT_PASS) + self.console_wait("Retype new password:") + self.console_send("%s\n" % self.ROOT_PASS) + + self.console_wait_send("o: Add a user", "o\n") + self.console_wait("username") + self.console_send("%s\n" % self.GUEST_USER) + self.console_wait("to group wheel") + self.console_wait_send("a: Yes", "a\n") + self.console_wait_send("a: /bin/sh", "a\n") + self.console_wait("New password:") + self.console_send("%s\n" % self.GUEST_PASS) + self.console_wait("New password:") + self.console_send("%s\n" % self.GUEST_PASS) + self.console_wait("Retype new password:") + self.console_send("%s\n" % self.GUEST_PASS) + + self.console_wait_send("a: Configure network", "a\n") + self.console_wait_send("a: vioif0", "a\n") + self.console_wait_send("Network media type", "\n") + self.console_wait("autoconfiguration") + self.console_wait_send("a: Yes", "a\n") + self.console_wait_send("DNS domain", "localnet\n") + self.console_wait("Are they OK?") + self.console_wait_send("a: Yes", "a\n") + self.console_wait("installed in /etc") + self.console_wait_send("a: Yes", "a\n") + + self.console_wait_send("e: Enable install", "e\n") + proxy = os.environ.get("http_proxy") + if not proxy is None: + self.console_wait_send("f: Proxy", "f\n") + self.console_wait("Proxy") + self.console_send("%s\n" % proxy) + self.console_wait_send("x: Install pkgin", "x\n") + self.console_init(1200) + self.console_wait_send("Hit enter to continue", "\n") + self.console_init() + + self.console_wait_send("g: Enable sshd", "g\n") + self.console_wait_send("x: Finished conf", "x\n") + self.console_wait_send("Hit enter to continue", "\n") + + self.print_step("Installation finished, rebooting") + self.console_wait_send("d: Reboot the computer", "d\n") + + # setup qemu user + prompt = "localhost$" + self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_wait_send(prompt, "exit\n") + + # setup root user + prompt = "localhost#" + self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_sshd_config(prompt) + + # setup virtio-blk #1 (tarfile) + self.console_wait(prompt) + self.console_send("echo 'chmod 666 /dev/rld1a' >> /etc/rc.local\n") + + # turn off mprotect (conflicts with tcg) + self.console_wait(prompt) + self.console_send("echo security.pax.mprotect.enabled=0 >> /etc/sysctl.conf\n") + + self.print_step("Configuration finished, rebooting") + self.console_wait_send(prompt, "reboot\n") + self.console_wait("login:") + self.wait_ssh() + + self.print_step("Installing packages") + self.ssh_root_check("pkgin update\n") + self.ssh_root_check("pkgin -y install %s\n" % " ".join(self.pkgs)) + + # shutdown + self.ssh_root(self.poweroff) + self.console_wait("entering state S5") + self.wait() + if os.path.exists(img): os.remove(img) os.rename(img_tmp, img) + os.remove(iso) + self.print_step("All done") if __name__ == "__main__": sys.exit(basevm.main(NetBSDVM)) From patchwork Fri Jun 7 09:05:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12CA614C0 for ; Fri, 7 Jun 2019 10:32:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0001D28B44 for ; Fri, 7 Jun 2019 10:32:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E883928B47; Fri, 7 Jun 2019 10:32:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 239E628B44 for ; Fri, 7 Jun 2019 10:32:56 +0000 (UTC) Received: from localhost ([::1]:48067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCB5-0007B1-F8 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:32:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51017) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBOO-0007eh-56 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZBOK-0000pE-EC for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:35 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:40436) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZBOK-0000n0-2x for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:32 -0400 Received: by mail-wr1-x429.google.com with SMTP id p11so1460354wre.7 for ; Fri, 07 Jun 2019 02:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JVOhgXHIaUVn4T5e9DUcXx7y+91ycN1+/uDKCNbCA8U=; b=wdgeANDOPJEhycZxsQ1NwHZaIVLNMsWJnBc8qeQCNl1DZmreul7xYDZdu6cjvRX+IH G0bXJo8yQrQVbYDDiMRppMd39Hl2Dx3uWWmpy+vgXy83+YUuTadrV3j5DbXGK2Gm4sv+ oifnyXy09LYTJFOBf/SZeC+yapghwFQPmx8kQ7uRfVtEMOLDccM/e7k4chO8Cu9isQP2 GYB9+PI8kGOY9jJhlzHjkchrJRAMNe2E5Nog96t2FFdv8cqK/ihST+hbq2c4FET5CODI tshV/LCRkYltMywvO/oRPLqneuU4XmV8RqeJP9C95yG/CB5iLXLTfOYhaqKgpeCDCejM 2Jbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JVOhgXHIaUVn4T5e9DUcXx7y+91ycN1+/uDKCNbCA8U=; b=eLzSCj6TjAozpcmvCITg6uYiB0FIxZS0FjMrFUoRj4bptkePzsUEbbk/3cwRLPXvCI xy8rF0H/EH5SzbEmL26T/1as8MfgLZB9s3yWqloSIC+fh/O7ZSXTsTG+CcKAuG6dvUPa HRUM2MZxNfqTRLbMRtxzFh0/jiizbuiG2aKkuifjPAbHgElvgiOcAudiU2IhegvlwesV 1ADPSRqslfIPp3rQZgQ+WBdQARAoX+e49rnEaUI9QZCMTPMrNOovGNxCT0WBl6m+5/gI u2xAOW0WzFzIjGtG2TCangV2KODW6o4JvQUtQQD0ndqsF2K34i/TX8rdHaWRSOmXw44U LZUg== X-Gm-Message-State: APjAAAUU9mYCOiRSJK2F9d7zrVL0mugs1ShgJnn0EyRA/VeS4AOpldf7 XOXsVgtiN0r7V2WAM4g+tocMgQ== X-Google-Smtp-Source: APXvYqyGk12ygyT2zaGO1y0Kss6L9l/tBDd32xcMx3zRzJnX86zfskaTV8IKKjeVAhP1L8jw3HKe4Q== X-Received: by 2002:adf:8183:: with SMTP id 3mr19181524wra.181.1559900550214; Fri, 07 Jun 2019 02:42:30 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h1sm1444762wrt.20.2019.06.07.02.42.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:42:28 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E8BB21FFAC; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:23 +0100 Message-Id: <20190607090552.12434-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PULL 24/52] tests/vm: fedora autoinstall, using serial console 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: Fam Zheng , Thomas Huth , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann Download the install iso and prepare the image locally. Install to disk, using the serial console. Create qemu user, configure ssh login. Install packages needed for qemu builds. Yes, we have docker images for fedora. But for trouble-shooting it might be helpful to have a vm too. When vm builds fail you can use it to figure whenever the vm setup or the guest os is the problem. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20190520124716.30472-14-kraxel@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index 628eecade7..5e37063d32 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -2,7 +2,7 @@ .PHONY: vm-build-all vm-clean-all -IMAGES := ubuntu.i386 freebsd netbsd openbsd centos +IMAGES := ubuntu.i386 freebsd netbsd openbsd centos fedora IMAGES_DIR := $(HOME)/.cache/qemu-vm/images IMAGE_FILES := $(patsubst %, $(IMAGES_DIR)/%.img, $(IMAGES)) @@ -16,6 +16,7 @@ vm-test: @echo " vm-build-netbsd - Build QEMU in NetBSD VM" @echo " vm-build-openbsd - Build QEMU in OpenBSD VM" @echo " vm-build-centos - Build QEMU in CentOS VM, with Docker" + @echo " vm-build-fedora - Build QEMU in Fedora VM" @echo "" @echo " vm-build-all - Build QEMU in all VMs" @echo " vm-clean-all - Clean up VM images" diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 8894267f07..d4b816be14 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -205,7 +205,7 @@ class BaseVM(object): # log console line sys.stderr.write("con recv: %s\n" % line) - def console_wait(self, expect): + def console_wait(self, expect, expectalt = None): vm = self._guest output = "" while True: @@ -214,6 +214,8 @@ class BaseVM(object): except socket.timeout: sys.stderr.write("console: *** read timeout ***\n") sys.stderr.write("console: waiting for: '%s'\n" % expect) + if not expectalt is None: + sys.stderr.write("console: waiting for: '%s' (alt)\n" % expectalt) sys.stderr.write("console: line buffer:\n") sys.stderr.write("\n") self.console_log(output.rstrip()) @@ -222,6 +224,8 @@ class BaseVM(object): output += chars.decode("latin1") if expect in output: break + if not expectalt is None and expectalt in output: + break if "\r" in output or "\n" in output: lines = re.split("[\r\n]", output) output = lines.pop() @@ -229,6 +233,9 @@ class BaseVM(object): self.console_log("\n".join(lines)) if self.debug: self.console_log(output) + if not expectalt is None and expectalt in output: + return False + return True def console_send(self, command): vm = self._guest diff --git a/tests/vm/fedora b/tests/vm/fedora new file mode 100755 index 0000000000..c5621d0832 --- /dev/null +++ b/tests/vm/fedora @@ -0,0 +1,187 @@ +#!/usr/bin/env python +# +# Fedora VM image +# +# Copyright 2019 Red Hat Inc. +# +# Authors: +# Gerd Hoffmann +# +# This code is licensed under the GPL version 2 or later. See +# the COPYING file in the top-level directory. +# + +import os +import re +import sys +import time +import socket +import subprocess +import basevm + +class FedoraVM(basevm.BaseVM): + name = "fedora" + arch = "x86_64" + + base = "http://dl.fedoraproject.org/pub/fedora/linux/releases/30/" + link = base + "Server/x86_64/iso/Fedora-Server-netinst-x86_64-30-1.2.iso" + repo = base + "Server/x86_64/os/" + full = base + "Everything/x86_64/os/" + csum = "5e4eac4566d8c572bfb3bcf54b7d6c82006ec3c6c882a2c9235c6d3494d7b100" + size = "20G" + pkgs = [ + # tools + 'git-core', + 'flex', 'bison', + 'gcc', 'binutils', 'make', + + # perl + 'perl-Test-Harness', + + # libs: usb + '"pkgconfig(libusb-1.0)"', + '"pkgconfig(libusbredirparser-0.5)"', + + # libs: crypto + '"pkgconfig(gnutls)"', + + # libs: ui + '"pkgconfig(sdl2)"', + '"pkgconfig(gtk+-3.0)"', + '"pkgconfig(ncursesw)"', + + # libs: audio + '"pkgconfig(libpulse)"', + '"pkgconfig(alsa)"', + ] + + BUILD_SCRIPT = """ + set -e; + rm -rf /home/qemu/qemu-test.* + cd $(mktemp -d /home/qemu/qemu-test.XXXXXX); + mkdir src build; cd src; + tar -xf /dev/vdb; + cd ../build + ../src/configure --python=python3 {configure_opts}; + gmake --output-sync -j{jobs} {target} {verbose}; + """ + + def build_image(self, img): + self.print_step("Downloading install iso") + cimg = self._download_with_cache(self.link, sha256sum=self.csum) + img_tmp = img + ".tmp" + iso = img + ".install.iso" + + self.print_step("Preparing iso and disk image") + subprocess.check_call(["cp", "-f", cimg, iso]) + subprocess.check_call(["qemu-img", "create", "-f", "qcow2", + img_tmp, self.size]) + + self.print_step("Booting installer") + self.boot(img_tmp, extra_args = [ + "-machine", "graphics=off", + "-cdrom", iso + ]) + self.console_init(300) + self.console_wait("installation process.") + time.sleep(0.3) + self.console_send("\t") + time.sleep(0.3) + self.console_send(" console=ttyS0") + proxy = os.environ.get("http_proxy") + if not proxy is None: + self.console_send(" proxy=%s" % proxy) + self.console_send(" inst.repo=%s" % self.repo) + self.console_send("\n") + + self.console_wait_send("2) Use text mode", "2\n") + + self.console_wait_send("5) [!] Installation Dest", "5\n") + self.console_wait_send("1) [x]", "c\n") + self.console_wait_send("2) [ ] Use All Space", "2\n") + self.console_wait_send("2) [x] Use All Space", "c\n") + self.console_wait_send("1) [ ] Standard Part", "1\n") + self.console_wait_send("1) [x] Standard Part", "c\n") + + self.console_wait_send("7) [!] Root password", "7\n") + self.console_wait("Password:") + self.console_send("%s\n" % self.ROOT_PASS) + self.console_wait("Password (confirm):") + self.console_send("%s\n" % self.ROOT_PASS) + + self.console_wait_send("8) [ ] User creation", "8\n") + self.console_wait_send("1) [ ] Create user", "1\n") + self.console_wait_send("3) User name", "3\n") + self.console_wait_send("ENTER:", "%s\n" % self.GUEST_USER) + self.console_wait_send("4) [ ] Use password", "4\n") + self.console_wait_send("5) Password", "5\n") + self.console_wait("Password:") + self.console_send("%s\n" % self.GUEST_PASS) + self.console_wait("Password (confirm):") + self.console_send("%s\n" % self.GUEST_PASS) + self.console_wait_send("7) Groups", "c\n") + + while True: + good = self.console_wait("3) [x] Installation", + "3) [!] Installation") + self.console_send("r\n") + if good: + break + time.sleep(10) + + while True: + good = self.console_wait("4) [x] Software", + "4) [!] Software") + self.console_send("r\n") + if good: + break + time.sleep(10) + self.console_send("r\n" % self.GUEST_PASS) + + self.console_wait_send("'b' to begin install", "b\n") + + self.print_step("Installation started now, this will take a while") + + self.console_wait_send("Installation complete", "\n") + self.print_step("Installation finished, rebooting") + + # setup qemu user + prompt = " ~]$" + self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_wait_send(prompt, "exit\n") + + # setup root user + prompt = " ~]#" + self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_sshd_config(prompt) + + # setup virtio-blk #1 (tarfile) + self.console_wait(prompt) + self.console_send("echo 'KERNEL==\"vdb\" MODE=\"666\"' >> %s\n" % + "/etc/udev/rules.d/99-qemu.rules") + + self.print_step("Configuration finished, rebooting") + self.console_wait_send(prompt, "reboot\n") + self.console_wait("login:") + self.wait_ssh() + + self.print_step("Installing packages") + self.ssh_root_check("rm -vf /etc/yum.repos.d/fedora*.repo\n") + self.ssh_root_check("echo '[fedora]' >> /etc/yum.repos.d/qemu.repo\n") + self.ssh_root_check("echo 'baseurl=%s' >> /etc/yum.repos.d/qemu.repo\n" % self.full) + self.ssh_root_check("echo 'gpgcheck=0' >> /etc/yum.repos.d/qemu.repo\n") + self.ssh_root_check("dnf install -y %s\n" % " ".join(self.pkgs)) + + # shutdown + self.ssh_root(self.poweroff) + self.console_wait("sleep state S5") + self.wait() + + if os.path.exists(img): + os.remove(img) + os.rename(img_tmp, img) + os.remove(iso) + self.print_step("All done") + +if __name__ == "__main__": + sys.exit(basevm.main(FedoraVM)) From patchwork Fri Jun 7 09:05:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 225B092A for ; Fri, 7 Jun 2019 10:02:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1007228B35 for ; Fri, 7 Jun 2019 10:02:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03AE128B3D; Fri, 7 Jun 2019 10:02:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A86EE28B35 for ; Fri, 7 Jun 2019 10:02:01 +0000 (UTC) Received: from localhost ([::1]:47726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBhA-0000x2-RG for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:02:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42205) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002Fc-BF for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004zZ-Ta for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:54772) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004sg-I6 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wm1-x32a.google.com with SMTP id g135so1234190wme.4 for ; Fri, 07 Jun 2019 02:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gTWlFdlFGB1B/zOTecn3xrnI8T6l9Vt1Y4CtKuUhYu8=; b=SjBnzlGNuYbKNmdtwI+EtCHS2epNn9/bnTSOYbbiJrXuZ4r6YGWsjr3NiHIpSX9X+s 48+I3GTWU5lGNXW+fix8xHX917GJBe3DMRrKc/robCQLklm8B6dIy431i+f2TcwLU5GX KdurOgOybaHxPZYpzXu1kCKjSFdKa4Ui8Tx4DvAce3+sTNnOFvTT4V4yh3iwEubskUR3 elecGW7JGDH8+ZX4ECBwDLbmpCBkj3111TsC6nm7UnCSikm29OCLyox8jVfI/4gd7CLh rp5b4gPaAkJMVVmqWRj8D/YeaczqwxiqP1I+BvjbhYhRoFtofZZPivlP36L5W++uAgid zajA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gTWlFdlFGB1B/zOTecn3xrnI8T6l9Vt1Y4CtKuUhYu8=; b=GGFuy1RYy7FzKi9R/mVp9L1nmSyplKH61AnWonURQxDBR1PZ4fYwVSMDEK7HA6s5dg spTyvEO5qgR1nmWQzPlswBCYVwV6Sq5kl9CTU69GHOtdf2hRmi2PkDMz/7yDXfGocVr7 Y2rrWWgvj/iu+Nfj3Vq77DlYRU5cyboETOAvAG7gN5zi4wboPjaGny5CKprLbCkF4uQl OLDMHuWdpXbnrWiInIYAsWP9Ac8jb8MOoob5FRSiOHcwFMV+ZvQ561aMvoygkvpPFRyG OVOAzSz4CRYe+0OQB5U3DZNZ8cLPoyEEmSU2HnhQSeV17kcaBwXCosedU0RWBVr4M9/+ pG2A== X-Gm-Message-State: APjAAAV0vW4NUisY4T7xvZfPHcOYg7DKw9D69jCKSYeEFW43RBNGssee qxsKNSwvZbxx8+9K/vIf/PFgmw== X-Google-Smtp-Source: APXvYqxQxPzGUHWtbVtkdkKmMn2FldDD0XWXZewge2Pj7EqPZuf0Jt8A8B1i7VrsXP3JBuTuc1rH9Q== X-Received: by 2002:a1c:2bc7:: with SMTP id r190mr2801993wmr.174.1559898757664; Fri, 07 Jun 2019 02:12:37 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a3sm1198915wmb.35.2019.06.07.02.12.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:34 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 07ADF1FFAE; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:24 +0100 Message-Id: <20190607090552.12434-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32a Subject: [Qemu-devel] [PULL 25/52] tests/vm: ubuntu.i386: apt proxy setup 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: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann Configure apt proxy so package downloads can be cached and can pass firewalls. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20190520124716.30472-15-kraxel@redhat.com> Signed-off-by: Alex Bennée diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386 index a22d137e76..b869afd212 100755 --- a/tests/vm/ubuntu.i386 +++ b/tests/vm/ubuntu.i386 @@ -51,6 +51,10 @@ class UbuntuX86VM(basevm.BaseVM): " ssh-authorized-keys:\n", " - %s\n" % basevm.SSH_PUB_KEY, "locale: en_US.UTF-8\n"]) + proxy = os.environ.get("http_proxy") + if not proxy is None: + udata.writelines(["apt:\n", + " proxy: %s" % proxy]) udata.close() subprocess.check_call(["genisoimage", "-output", "cloud-init.iso", "-volid", "cidata", "-joliet", "-rock", From patchwork Fri Jun 7 09:05:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80EE86C5 for ; Fri, 7 Jun 2019 09:58:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FB8B28734 for ; Fri, 7 Jun 2019 09:58:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60E9028B3D; Fri, 7 Jun 2019 09:58:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CEFFA28734 for ; Fri, 7 Jun 2019 09:58:14 +0000 (UTC) Received: from localhost ([::1]:47700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBdW-0006NS-5U for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:58:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42286) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvV-0002HY-Pn for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004zz-WD for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:43837) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004lF-Lt for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wr1-x442.google.com with SMTP id r18so1351564wrm.10 for ; Fri, 07 Jun 2019 02:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R7hQv/k6BU4/ZnGK1cbG5kk+E/CvNF37llrzUvfKDoc=; b=XbG7yfs0OkAkZF/+fRCikzBlFe1VRQRbKYo/xU+YesBY5mjZ+F5kS/AhoAKAQEUHr7 Sk9WfUbnXZpw0nYSruYTH+gtHuQs/3AwRxakncQY17Wat2GGtry6DFJnY9wfa55JlyDb BdGi2E4TQICaEH/4mdzjoiRMLRXuEb7ZmLolAJhKIfzuSWEowkY/rRoq0VfmeSiblyP3 jS3jVvzQfTEqybNstzARnTAwkUjaqwAN67nmlsV7LVt0lOBfwIuKSBS/wSWIzYEs6zCd G+HNU0xjhwGP8ucLHAWiTuWfTrryGP6PAqOl1dxaQwMuOgsg6FIYo7WJzP2nj4kzjKUh aEXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R7hQv/k6BU4/ZnGK1cbG5kk+E/CvNF37llrzUvfKDoc=; b=bL1etqZMgE58MwjV9X4IQP+3UpuHVpwBAiOKAqUmbBzgwTQY2T4+k/dJRwwiIAHJIR Z5/sP8KJMAp+tGkfsHccRaRMhbiH2hlY7lqkV9XTk4cl7Imq9zu1O6R+3e5y+6Osgzai Dp3jdNnZ3SqUd5wUQ2AVyjMoCDPJUQqoW9WDP9bjH5YJUGCUv/RgfUhKyK5ET8KFYj8Y nfmCjUMJIfiFFms+FK6jYMIVnYaBoLwhbx/LKbwt2GkUdO7ZghjWc2oWT6xhpki+HgU7 djQ3lbUuIF5gcPwACqaL7PUV1meQ4IWMs+4OP38l1BbdxbFZ27ORuwc8hEewmirplXG/ wenw== X-Gm-Message-State: APjAAAW0isrZUUmast92Ur4hn39ilRZBBSULbV1r4d0rcX4zLT36kLii 6+EkusbTS/YX5vruKqJtFfTXbw== X-Google-Smtp-Source: APXvYqzql7i3XnQU1dE6IOqwKLd500ddLu5D21U8yg/n4PKdbsChfOZ/Xatfg9V1bCgszkUnpBId4w== X-Received: by 2002:a5d:5283:: with SMTP id c3mr3506792wrv.268.1559898753629; Fri, 07 Jun 2019 02:12:33 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b2sm1567719wrp.72.2019.06.07.02.12.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1EC991FFAF; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:25 +0100 Message-Id: <20190607090552.12434-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PULL 26/52] semihosting: split console_out into string and char versions 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: Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, "open list:ARM" , Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This is ostensibly to avoid the weirdness of len looking like it might come from a guest and sometimes being used. While we are at it fix up the error checking for the arm-linux-user implementation of the API which got flagged up by Coverity (CID 1401700). Signed-off-by: Alex Bennée diff --git a/hw/semihosting/console.c b/hw/semihosting/console.c index 466ea6dade..4a5758972d 100644 --- a/hw/semihosting/console.c +++ b/hw/semihosting/console.c @@ -36,26 +36,24 @@ int qemu_semihosting_log_out(const char *s, int len) /* * A re-implementation of lock_user_string that we can use locally * instead of relying on softmmu-semi. Hopefully we can deprecate that - * in time. We either copy len bytes if specified or until we find a NULL. + * in time. Copy string until we find a 0 or address error. */ -static GString *copy_user_string(CPUArchState *env, target_ulong addr, int len) +static GString *copy_user_string(CPUArchState *env, target_ulong addr) { CPUState *cpu = ENV_GET_CPU(env); - GString *s = g_string_sized_new(len ? len : 128); + GString *s = g_string_sized_new(128); uint8_t c; - bool done; do { if (cpu_memory_rw_debug(cpu, addr++, &c, 1, 0) == 0) { s = g_string_append_c(s, c); - done = len ? s->len == len : c == 0; } else { qemu_log_mask(LOG_GUEST_ERROR, "%s: passed inaccessible address " TARGET_FMT_lx, __func__, addr); - done = true; + break; } - } while (!done); + } while (c!=0); return s; } @@ -68,9 +66,9 @@ static void semihosting_cb(CPUState *cs, target_ulong ret, target_ulong err) } } -int qemu_semihosting_console_out(CPUArchState *env, target_ulong addr, int len) +int qemu_semihosting_console_outs(CPUArchState *env, target_ulong addr) { - GString *s = copy_user_string(env, addr, len); + GString *s = copy_user_string(env, addr); int out = s->len; if (use_gdb_syscalls()) { @@ -82,3 +80,21 @@ int qemu_semihosting_console_out(CPUArchState *env, target_ulong addr, int len) g_string_free(s, true); return out; } + +void qemu_semihosting_console_outc(CPUArchState *env, target_ulong addr) +{ + CPUState *cpu = ENV_GET_CPU(env); + uint8_t c; + + if (cpu_memory_rw_debug(cpu, addr, &c, 1, 0) == 0) { + if (use_gdb_syscalls()) { + gdb_do_syscall(semihosting_cb, "write,2,%x,%x", addr, 1); + } else { + qemu_semihosting_log_out((const char *) &c, 1); + } + } else { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: passed inaccessible address " TARGET_FMT_lx, + __func__, addr); + } +} diff --git a/include/hw/semihosting/console.h b/include/hw/semihosting/console.h index 30e66ae20a..3a4fba7590 100644 --- a/include/hw/semihosting/console.h +++ b/include/hw/semihosting/console.h @@ -10,17 +10,30 @@ #define _SEMIHOST_CONSOLE_H_ /** - * qemu_semihosting_console_out: + * qemu_semihosting_console_outs: * @env: CPUArchState - * @s: host address of guest string - * @len: length of string or 0 (string is null terminated) + * @s: host address of null terminated guest string * - * Send a guest string to the debug console. This may be the remote - * gdb session if a softmmu guest is currently being debugged. + * Send a null terminated guest string to the debug console. This may + * be the remote gdb session if a softmmu guest is currently being + * debugged. * * Returns: number of bytes written. */ -int qemu_semihosting_console_out(CPUArchState *env, target_ulong s, int len); +int qemu_semihosting_console_outs(CPUArchState *env, target_ulong s); + +/** + * qemu_semihosting_console_outc: + * @env: CPUArchState + * @s: host address of null terminated guest string + * + * Send single character from guest memory to the debug console. This + * may be the remote gdb session if a softmmu guest is currently being + * debugged. + * + * Returns: nothing + */ +void qemu_semihosting_console_outc(CPUArchState *env, target_ulong c); /** * qemu_semihosting_log_out: diff --git a/linux-user/arm/semihost.c b/linux-user/arm/semihost.c index 9554102a85..a16b525eec 100644 --- a/linux-user/arm/semihost.c +++ b/linux-user/arm/semihost.c @@ -15,10 +15,35 @@ #include "hw/semihosting/console.h" #include "qemu.h" -int qemu_semihosting_console_out(CPUArchState *env, target_ulong addr, int len) +int qemu_semihosting_console_outs(CPUArchState *env, target_ulong addr) { - void *s = lock_user_string(addr); - len = write(STDERR_FILENO, s, len ? len : strlen(s)); + int len = target_strlen(addr); + void *s; + if (len < 0){ + qemu_log_mask(LOG_GUEST_ERROR, + "%s: passed inaccessible address " TARGET_FMT_lx, + __func__, addr); + return 0; + } + s = lock_user(VERIFY_READ, addr, (long)(len + 1), 1); + g_assert(s); /* target_strlen has already verified this will work */ + len = write(STDERR_FILENO, s, len); unlock_user(s, addr, 0); return len; } + +void qemu_semihosting_console_outc(CPUArchState *env, target_ulong addr) +{ + char c; + + if (get_user_u8(c, addr)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: passed inaccessible address " TARGET_FMT_lx, + __func__, addr); + } else { + if (write(STDERR_FILENO, &c, 1) != 1) { + qemu_log_mask(LOG_UNIMP, "%s: unexpected write to stdout failure", + __func__); + } + } +} diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c index 53e807ab72..8844da8da3 100644 --- a/target/arm/arm-semi.c +++ b/target/arm/arm-semi.c @@ -315,10 +315,10 @@ target_ulong do_arm_semihosting(CPUARMState *env) return set_swi_errno(ts, close(arg0)); } case TARGET_SYS_WRITEC: - qemu_semihosting_console_out(env, args, 1); + qemu_semihosting_console_outc(env, args); return 0xdeadbeef; case TARGET_SYS_WRITE0: - return qemu_semihosting_console_out(env, args, 0); + return qemu_semihosting_console_outs(env, args); case TARGET_SYS_WRITE: GET_ARG(0); GET_ARG(1); From patchwork Fri Jun 7 09:05:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9448F92A for ; Fri, 7 Jun 2019 09:58:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81DE028B3D for ; Fri, 7 Jun 2019 09:58:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7589428B3E; Fri, 7 Jun 2019 09:58:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1A89E28B44 for ; Fri, 7 Jun 2019 09:58:43 +0000 (UTC) Received: from localhost ([::1]:47704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBdy-0006gA-Fn for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:58:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42201) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002FX-AY for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004yE-He for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:51456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004kQ-8j for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wm1-x331.google.com with SMTP id f10so1243927wmb.1 for ; Fri, 07 Jun 2019 02:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=99Dn3AIAE6bUMupx6Zxv5Z+hFUdE7BsSiaYvbx/TT8U=; b=Cet4zqGwxmOsg9wlvbgbB0jSgfw143kcG3Mv7oMA9DzOl4GxtUwDEb6PX6Sg3z5M+z JZf0Uwnz9fxzhft81kDZx9UdVtyRB83w1uBvVm8KnaDrwGEKBSndUQxp/f7w1SPnFAYL iBe3UjrzbHBwmqh9CKW5/gXpDVPh+EIoGyvi4z7H/uMd2pZWvi5RmGOeDZApH59+4iGG 7CnkqWmuehmD4BBuiEHEBnKkpy3bt6tcruNrZLMQtzOE4ISLtIG39GLFX4/GNF18JOel pOtFQRlNDAJTH/gvTMceJX1vXnM9EyXIzGWh0YnPLUH1X50mKbMWgdE9h8EOaeIVqRXB VlBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=99Dn3AIAE6bUMupx6Zxv5Z+hFUdE7BsSiaYvbx/TT8U=; b=H2Er5Ci16YzhMU02tGQX0S9BJDM4hI/7yuxM75aoBW5q3KPg7XqX6LqXknBpUadlcV X3tVgh2Ahj8Puj4zP9Bo80PXhr6/K8OpMIRNstRwApbyTbVx+oL6sxMZjcj09F339ruD 1h1hKargy23Ub8uOmiYN1muoW2Lc8MGECDp13I+QstUzBxk+osox/wa24ERCJFWNIPTn Tu3c1cYT62iHa7fwWLWyIQNiO/+vnRpkwahzLOUQ1QppSGK75Baea2Jg1SOmRpPLrvF+ 2SL/Gbrc2YrtDd2za04Y7EHrRb+yWb/sJME/PouCURHUCzFSnU4yv4kLSOvUstGJmwgl vv2Q== X-Gm-Message-State: APjAAAVWn9uoJnQJSzLTzIGNHONBo19fLqcp7YkQmbs8hwucHvjqyhVW VgrH5q/eLElYinsZsiCBQs2/rw== X-Google-Smtp-Source: APXvYqwTjIomDmqChv3zwEFdhG5z/ke18HDvwWXCELjQ8XLSLdBAO/ekGKrW3DM9bOTVDcIaen+K9w== X-Received: by 2002:a05:600c:20c3:: with SMTP id y3mr3008049wmm.3.1559898753112; Fri, 07 Jun 2019 02:12:33 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j82sm1303398wmj.40.2019.06.07.02.12.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 31EC21FFB1; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:26 +0100 Message-Id: <20190607090552.12434-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 Subject: [Qemu-devel] [PULL 27/52] cputlb: use uint64_t for interim values for unaligned load 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: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , qemu-devel@nongnu.org, Laszlo Ersek , Paolo Bonzini , Igor Mammedov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When running on 32 bit TCG backends a wide unaligned load ends up truncating data before returning to the guest. We specifically have the return type as uint64_t to avoid any premature truncation so we should use the same for the interim types. Fixes: https://bugs.launchpad.net/qemu/+bug/1830872 Fixes: eed5664238e Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Tested-by: Laszlo Ersek Tested-by: Igor Mammedov diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index cdcc377102..b796ab1cbe 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1303,7 +1303,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, && unlikely((addr & ~TARGET_PAGE_MASK) + size - 1 >= TARGET_PAGE_SIZE)) { target_ulong addr1, addr2; - tcg_target_ulong r1, r2; + uint64_t r1, r2; unsigned shift; do_unaligned_access: addr1 = addr & ~(size - 1); From patchwork Fri Jun 7 09:05:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 381CC14E5 for ; Fri, 7 Jun 2019 10:16:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 285A028A5F for ; Fri, 7 Jun 2019 10:16:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C2B128A8F; Fri, 7 Jun 2019 10:16:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A4DD228A5F for ; Fri, 7 Jun 2019 10:16:16 +0000 (UTC) Received: from localhost ([::1]:47938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBux-0004tp-Pa for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:16:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44959) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB4z-00085p-Lh for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB4y-0005ot-8Z for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:33 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:39822) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB4x-0005kB-VX for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:32 -0400 Received: by mail-wr1-x42d.google.com with SMTP id x4so1399585wrt.6 for ; Fri, 07 Jun 2019 02:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PLY1Kb/j4Fld5ce4nXx3RXm9FLwwfldPCHeqmdO//6E=; b=YNkOmvB/xTWtFw4rkS42jDSIJrlEJbuOKbgNlADuND7RbCtN3IBk2ejtX6F/WFImwF gXQxFh71mFN0d4HoUt4/OTsG4AvGHZSIVTZmneqMQTwUubqeyaH/QuW8IdRE575f9sMN jU3IG0CKaz9U7Zr+sfbon1mz4P+lZY7F1QB7rBc7IG+RJFOXVpXzyHn9tW37yk94tE8f gH1NAqujc1Dp9LvuR+skU3MBbw1HZkdQs601CEciZXQY3l4cZOAANoLxcS3FPv4f33HM Hb6abWdPr8wsM7dEy1T3jgxxm7JdhOPHVqIDVr4tJ8EA1YP9AiEfDFmY5zaYqy/LnGvp nPBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PLY1Kb/j4Fld5ce4nXx3RXm9FLwwfldPCHeqmdO//6E=; b=JUcrPMzxUw9yuODjGanG+QvHuXl3WhNLART23IP8d2v3IZQfcxxqfu+bVlxk+cLAxm SMPulgCm8BELZ0OAqXF7I4sKwX4eJ0Vmp3jMNlCVt1PZpfOl8f7fOyUCh4/WRhW3jCyB Ii0xFw5hHS4pmHdeDgMA5G5b4/FSv5ZWCAPSSTisQRvC3OEb6tjs/XrxErzEuXuo5XY0 MLW9vEfLQiiHubJjCqJUjpcZVfAjtMZfHBl+C0HEbAnAptlRBl9bI/TdSyJLP1u9IasW b4N+MG7nx6lyXXftKmfoYlnyd0BNK6IXt1k+XjzrsOgYLwJoxfjsPs0/ebFyw4qmSKOl +OKg== X-Gm-Message-State: APjAAAW88jVQYz6roOSWMaI2sdaOU0ZaZ+F94ZrcUog3hfth23Mww+cc hfvvtkuFqn5NxF06ww7Y2DEqNg== X-Google-Smtp-Source: APXvYqzZbjNlQVTfO9aUjaP5ED/PqHC/QpV2YFt3xobbvwzsciJ4qr9OhL0iA6PIQUqcLwaSiRegDA== X-Received: by 2002:adf:f246:: with SMTP id b6mr8433212wrp.92.1559899349200; Fri, 07 Jun 2019 02:22:29 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x83sm1379571wmb.42.2019.06.07.02.22.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 454781FFB3; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:27 +0100 Message-Id: <20190607090552.12434-29-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d Subject: [Qemu-devel] [PULL 28/52] tests/tcg: better detect truncated reads 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: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If we've truncated a wider read we can detect the condition earlier by looking at the number of zeros we've read. So we don't trip up on cases where we have written zeros to the start of the buffer we also ensure we only start each offset read from the right address. Signed-off-by: Alex Bennée diff --git a/tests/tcg/multiarch/system/memory.c b/tests/tcg/multiarch/system/memory.c index dc1d8a98ff..d124502d73 100644 --- a/tests/tcg/multiarch/system/memory.c +++ b/tests/tcg/multiarch/system/memory.c @@ -208,6 +208,7 @@ static bool read_test_data_u32(int offset) for (i = 0; i < max; i++) { uint8_t b1, b2, b3, b4; + int zeros = 0; word = *ptr++; b1 = word >> 24 & 0xff; @@ -215,6 +216,16 @@ static bool read_test_data_u32(int offset) b3 = word >> 8 & 0xff; b4 = word & 0xff; + zeros += (b1 == 0 ? 1 : 0); + zeros += (b2 == 0 ? 1 : 0); + zeros += (b3 == 0 ? 1 : 0); + zeros += (b4 == 0 ? 1 : 0); + if (zeros > 1) { + ml_printf("Error @ %p, more zeros than expected: %d, %d, %d, %d", + ptr - 1, b1, b2, b3, b4); + return false; + } + if ((b1 < b2 && b1 != 0) || (b2 < b3 && b2 != 0) || (b3 < b4 && b3 != 0)) { @@ -238,6 +249,7 @@ static bool read_test_data_u64(int offset) for (i = 0; i < max; i++) { uint8_t b1, b2, b3, b4, b5, b6, b7, b8; + int zeros = 0; word = *ptr++; b1 = ((uint64_t) (word >> 56)) & 0xff; @@ -249,6 +261,20 @@ static bool read_test_data_u64(int offset) b7 = (word >> 8) & 0xff; b8 = (word >> 0) & 0xff; + zeros += (b1 == 0 ? 1 : 0); + zeros += (b2 == 0 ? 1 : 0); + zeros += (b3 == 0 ? 1 : 0); + zeros += (b4 == 0 ? 1 : 0); + zeros += (b5 == 0 ? 1 : 0); + zeros += (b6 == 0 ? 1 : 0); + zeros += (b7 == 0 ? 1 : 0); + zeros += (b8 == 0 ? 1 : 0); + if (zeros > 1) { + ml_printf("Error @ %p, more zeros than expected: %d, %d, %d, %d, %d, %d, %d, %d", + ptr - 1, b1, b2, b3, b4, b5, b6, b7, b8); + return false; + } + if ((b1 < b2 && b1 != 0) || (b2 < b3 && b2 != 0) || (b3 < b4 && b3 != 0) || @@ -272,7 +298,7 @@ read_ufn read_ufns[] = { read_test_data_u16, read_test_data_u32, read_test_data_u64 }; -bool do_unsigned_reads(void) +bool do_unsigned_reads(int start_off) { int i; bool ok = true; @@ -280,11 +306,11 @@ bool do_unsigned_reads(void) for (i = 0; i < ARRAY_SIZE(read_ufns) && ok; i++) { #if CHECK_UNALIGNED int off; - for (off = 0; off < 8 && ok; off++) { + for (off = start_off; off < 8 && ok; off++) { ok = read_ufns[i](off); } #else - ok = read_ufns[i](0); + ok = read_ufns[i](start_off); #endif } @@ -298,11 +324,11 @@ static bool do_unsigned_test(init_ufn fn) int i; for (i = 0; i < 8 && ok; i++) { fn(i); - ok = do_unsigned_reads(); + ok = do_unsigned_reads(i); } #else fn(0); - return do_unsigned_reads(); + return do_unsigned_reads(0); #endif } From patchwork Fri Jun 7 09:05:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A544214E5 for ; Fri, 7 Jun 2019 09:50:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 933FD289D7 for ; Fri, 7 Jun 2019 09:50:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8789928A18; Fri, 7 Jun 2019 09:50:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 35312289D7 for ; Fri, 7 Jun 2019 09:50:23 +0000 (UTC) Received: from localhost ([::1]:47652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBVu-0007TF-J5 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:50:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42101) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvQ-0002Bt-7S for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvK-0004lL-6K for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:37 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:43834) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvI-0004ef-3m for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:32 -0400 Received: by mail-wr1-x441.google.com with SMTP id r18so1351378wrm.10 for ; Fri, 07 Jun 2019 02:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2ORtsrdcOtlazSV007+SAu/zrWhHGlOaKswTJZUeVrI=; b=pME6FuNHoGE2J2PTCtiwuV1NhW5fxi1kNlW/LBAi2EuD5xjL1kvNapVP738Cmx1Jqr k90bEBqlKktqp35L7KhxZX/kH+QwgubJK9ZUovIDnzJ4w4PHcPjCGENE3eaNXMC7B6rt jr9aDyjMCXfa7NyLBiQN333Et0uyLjmVtnMOMOju5pBiqHVmfLnR+LKxZIOh6TFnaXSc kY0SJhRTl/FamMUOQuHTNArILU/znaClY4yUqNkpxofoFm4/Bm4jaWuKuzQ9CEVDNGKS +UYQmNxal+J1srgTYlRXprygl23dtosZso8lNcHbIW7iSooLDPwlE/K4WLljACzj7LAT +MYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2ORtsrdcOtlazSV007+SAu/zrWhHGlOaKswTJZUeVrI=; b=YLwWqsgoHAAG0shDpPfBwHfDRNsbyXp8/kQFNq8sGkZWRSJ0cZ+EMmpDfcuTymiL5N R63gFO4Jo3V9AI5psMy6oehmDafIWIJuxgh4PeE5wmUIMtNNuR+Z/t/XsWIGtXNLRTJn OJc5I9gkKhkWzC4Ol6vblKqC+VSL9skydrCO0AUlxLPrsBlMNXAjHDtK8grXjuG/QgoZ 4uVKkkA47lizmoH+rpQt4PTnGGI10EgGT9QZYizZtPz84m1PVRUoG3bUJAQkHEID5+0e sEvHngQvEhSPh6WalkREEQBCbgiIZOkWXkzRF48GjFkANNXG58/48rxfmmp5zGybVSMd 9zEw== X-Gm-Message-State: APjAAAXNQQFJ/ExbeBobhnZiLJy71VWpr0x6ZKZOIQcIwikcCSxKBmeS o/KmVvj0Evog9L4h+wdmNpoi4g== X-Google-Smtp-Source: APXvYqyAwtpVI6dmea+QXjJTkNT6NZlz887PO7VFx1qrP5jhtFwNtL4l8L8B/OIvKTVMuGMJ4m6xDw== X-Received: by 2002:a5d:4a0b:: with SMTP id m11mr23256095wrq.251.1559898749728; Fri, 07 Jun 2019 02:12:29 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g5sm1694727wrp.29.2019.06.07.02.12.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 57ACB1FFB4; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:28 +0100 Message-Id: <20190607090552.12434-30-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 29/52] tests/tcg: clean-up VPATH/TESTS for i386 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: Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since we only run build the multiarch tests and we use a fully resolved path for the crt object we don't need the wildcard or VPATH messing about. Signed-off-by: Alex Bennée diff --git a/tests/tcg/i386/Makefile.softmmu-target b/tests/tcg/i386/Makefile.softmmu-target index e1f98177aa..e1d880f9b5 100644 --- a/tests/tcg/i386/Makefile.softmmu-target +++ b/tests/tcg/i386/Makefile.softmmu-target @@ -8,15 +8,10 @@ I386_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/i386/system X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system -# Set search path for all sources -VPATH+=$(I386_SYSTEM_SRC) # These objects provide the basic boot code and helper functions for all tests CRT_OBJS=boot.o -X86_TEST_SRCS=$(wildcard $(I386_SYSTEM_SRC)/*.c) -X86_TESTS = $(patsubst $(I386_SYSTEM_SRC)/%.c, %, $(X86_TEST_SRCS)) - ifeq ($(TARGET_X86_64), y) CRT_PATH=$(X64_SYSTEM_SRC) LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld @@ -26,12 +21,12 @@ CRT_PATH=$(I386_SYSTEM_SRC) CFLAGS+=-m32 LINK_SCRIPT=$(I386_SYSTEM_SRC)/kernel.ld LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_i386 -# FIXME: move to common once x86_64 is bootstrapped -TESTS+=$(X86_TESTS) $(MULTIARCH_TESTS) endif CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc +TESTS+=$(MULTIARCH_TESTS) + # building head blobs .PRECIOUS: $(CRT_OBJS) From patchwork Fri Jun 7 09:05:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9119192A for ; Fri, 7 Jun 2019 09:53:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EC6728B2B for ; Fri, 7 Jun 2019 09:53:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72E1A28B3C; Fri, 7 Jun 2019 09:53:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC5BC28B2B for ; Fri, 7 Jun 2019 09:53:42 +0000 (UTC) Received: from localhost ([::1]:47678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBZ8-0002es-4S for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:53:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42206) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002Fd-BK for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004xS-6K for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:43837) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvJ-0004gb-WB for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:34 -0400 Received: by mail-wr1-x444.google.com with SMTP id r18so1351444wrm.10 for ; Fri, 07 Jun 2019 02:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GG8+B2YKZAzbtPtKRtN7JHzNyOJ/PV6z6R/XdCaBQE8=; b=BY8nIR4+QZBm0/gUj4RmkMPIBhyFVidI/CbukYfiBG8OF8bJu7oL9lqII8cG4jz0ZN pd7zKMh8ib10Ws6kO4504O+Fk20BzOGma8JRe8sNvRD6afoYMtkQeZkQJEj6omIBVwKp sq9jIezfX9jDnN4aJnZL83Mhb8pDQIoQeXhC5tFfbYkMBEyegqjMX4/dns/Jr4mwOD+0 TzdsB2rpgr4WrgzFIurusYtM02FlnkU00lZiUmJkQXojG4HEw3EZJLZOkrSR0dvOcJEx jFplvSGzO/k8db+Yf4Ul6HZ6YEgjimrpv1HsjLu6c5SonVZ4I6Z7qlMqAfOea+QkjMHu auqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GG8+B2YKZAzbtPtKRtN7JHzNyOJ/PV6z6R/XdCaBQE8=; b=iYvNLGFzp6+R3/eVGlxZC2XoWChDX7Ved4kYspeLq7aWW9KQTSNi4zGJ1e8mouMJ0F Gve9/ildtt+xUWfOrbrUY74RjYoGx2S73O+zgvr3NxorOY3/vUzFHIthZC6FnR0oM0mG PDSTYeiP5f+q75rn/L10ohQGsV/9rIKxODMarZcJtd62fSa8Aig9z+kBIknhgkliBbJ4 cQkP0lntMMJC/z23r6X2rYraVH2p3BMT1PEY9JaD7jJvC41dkLuv4a2ajkVDfOazX8yL D27pj0W9J0/btRHFq2RuvzQ6r7DC2S3sgNSWZ8NyCgxZgZYm+b1Pz0s6NlJ7dRTqB8iM 5iQA== X-Gm-Message-State: APjAAAXNhp4zKOZhoHc501LDUNow9mFNGw6JFHetN/N1AU5sHBrZ9OXw OUE6FlEdVsy3XJUc4qzDGKVk/A== X-Google-Smtp-Source: APXvYqxgXmga6zHPsQMYGUTNjOai2Z+t4G2Ji/ILvt7jEzotARh4sFkSh92Y626t/ktn1jiS+TfK0Q== X-Received: by 2002:a5d:4a46:: with SMTP id v6mr32615252wrs.105.1559898750930; Fri, 07 Jun 2019 02:12:30 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 74sm1180468wma.7.2019.06.07.02.12.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:29 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6E0C21FFB5; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:29 +0100 Message-Id: <20190607090552.12434-31-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL 30/52] tests/tcg/x86_64: add a PVH crt.o for x86_64 system tests 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: Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Instead of doing the full real to 64 bit dance we are attempting to leverage Xen's PVH boot spec to go from 32 bit to 64 bit. Signed-off-by: Alex Bennée diff --git a/tests/tcg/i386/Makefile.softmmu-target b/tests/tcg/i386/Makefile.softmmu-target index e1d880f9b5..0a4364868c 100644 --- a/tests/tcg/i386/Makefile.softmmu-target +++ b/tests/tcg/i386/Makefile.softmmu-target @@ -14,6 +14,7 @@ CRT_OBJS=boot.o ifeq ($(TARGET_X86_64), y) CRT_PATH=$(X64_SYSTEM_SRC) +CFLAGS=-march=x86-64 LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64 else diff --git a/tests/tcg/x86_64/system/boot.S b/tests/tcg/x86_64/system/boot.S new file mode 100644 index 0000000000..205cfbd398 --- /dev/null +++ b/tests/tcg/x86_64/system/boot.S @@ -0,0 +1,277 @@ +/* + * x86_64 boot and support code + * + * Copyright 2019 Linaro + * + * This work is licensed under the terms of the GNU GPL, version 3 or later. + * See the COPYING file in the top-level directory. + * + * Unlike the i386 version we instead use Xen's PVHVM booting header + * which should drop us automatically into 32 bit mode ready to go. I've + * nabbed bits of the Linux kernel setup to achieve this. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + + .section .head + +#define ELFNOTE_START(name, type, flags) \ +.pushsection .note.name, flags,@note ; \ + .balign 4 ; \ + .long 2f - 1f /* namesz */ ; \ + .long 4484f - 3f /* descsz */ ; \ + .long type ; \ +1:.asciz #name ; \ +2:.balign 4 ; \ +3: + +#define ELFNOTE_END \ +4484:.balign 4 ; \ +.popsection ; + +#define ELFNOTE(name, type, desc) \ + ELFNOTE_START(name, type, "") \ + desc ; \ + ELFNOTE_END + +#define XEN_ELFNOTE_ENTRY 1 +#define XEN_ELFNOTE_HYPERCALL_PAGE 2 +#define XEN_ELFNOTE_VIRT_BASE 3 +#define XEN_ELFNOTE_PADDR_OFFSET 4 +#define XEN_ELFNOTE_PHYS32_ENTRY 18 + +#define __ASM_FORM(x) x +#define __ASM_FORM_RAW(x) x +#define __ASM_FORM_COMMA(x) x, +#define __ASM_SEL(a,b) __ASM_FORM(b) +#define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(b) +#define _ASM_PTR __ASM_SEL(.long, .quad) + + ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR 0x100000) + ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR _start) + ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY, _ASM_PTR _start) /* entry == virtbase */ + ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0) + + /* + * Entry point for PVH guests. + * + * Xen ABI specifies the following register state when we come here: + * + * - `ebx`: contains the physical memory address where the loader has placed + * the boot start info structure. + * - `cr0`: bit 0 (PE) must be set. All the other writeable bits are cleared. + * - `cr4`: all bits are cleared. + * - `cs `: must be a 32-bit read/execute code segment with a base of ‘0’ + * and a limit of ‘0xFFFFFFFF’. The selector value is unspecified. + * - `ds`, `es`: must be a 32-bit read/write data segment with a base of + * ‘0’ and a limit of ‘0xFFFFFFFF’. The selector values are all + * unspecified. + * - `tr`: must be a 32-bit TSS (active) with a base of '0' and a limit + * of '0x67'. + * - `eflags`: bit 17 (VM) must be cleared. Bit 9 (IF) must be cleared. + * Bit 8 (TF) must be cleared. Other bits are all unspecified. + * + * All other processor registers and flag bits are unspecified. The OS is in + * charge of setting up it's own stack, GDT and IDT. + */ + .code32 + .section .text + +.global _start +_start: + cld + lgdt gdtr + + ljmp $0x8,$.Lloadcs +.Lloadcs: + mov $0x10,%eax + mov %eax,%ds + mov %eax,%es + mov %eax,%fs + mov %eax,%gs + mov %eax,%ss + + /* Enable PAE mode (bit 5). */ + mov %cr4, %eax + btsl $5, %eax + mov %eax, %cr4 + +#define MSR_EFER 0xc0000080 /* extended feature register */ + + /* Enable Long mode. */ + mov $MSR_EFER, %ecx + rdmsr + btsl $8, %eax + wrmsr + + /* Enable paging */ + mov $.Lpml4, %ecx + mov %ecx, %cr3 + + mov %cr0, %eax + btsl $31, %eax + mov %eax, %cr0 + + /* Jump to 64-bit mode. */ + lgdt gdtr64 + ljmp $0x8,$.Lenter64 + + .code64 + .section .text +.Lenter64: + + + // Setup stack ASAP + movq $stack_end,%rsp + + /* don't worry about stack frame, assume everthing is garbage when we return */ + call main + + /* output any non-zero result in eax to isa-debug-exit device */ + test %al, %al + jz 1f + out %ax, $0xf4 + +1: /* QEMU ACPI poweroff */ + mov $0x604,%edx + mov $0x2000,%eax + out %ax,%dx + hlt + jmp 1b + + /* + * Helper Functions + * + * x86_64 calling convention is rdi, rsi, rdx, rcx, r8, r9 + */ + + /* Output a single character to serial port */ + .global __sys_outc +__sys_outc: + pushq %rax + mov %rax, %rdx + out %al,$0xE9 + popq %rax + ret + + /* Interrupt Descriptor Table */ + + .section .data + .align 16 + +idt_00: .int 0, 0 +idt_01: .int 0, 0 +idt_02: .int 0, 0 +idt_03: .int 0, 0 +idt_04: .int 0, 0 +idt_05: .int 0, 0 +idt_06: .int 0, 0 /* intr_6_opcode, Invalid Opcode */ +idt_07: .int 0, 0 +idt_08: .int 0, 0 +idt_09: .int 0, 0 +idt_0A: .int 0, 0 +idt_0B: .int 0, 0 +idt_0C: .int 0, 0 +idt_0D: .int 0, 0 +idt_0E: .int 0, 0 +idt_0F: .int 0, 0 +idt_10: .int 0, 0 +idt_11: .int 0, 0 +idt_12: .int 0, 0 +idt_13: .int 0, 0 +idt_14: .int 0, 0 +idt_15: .int 0, 0 +idt_16: .int 0, 0 +idt_17: .int 0, 0 +idt_18: .int 0, 0 +idt_19: .int 0, 0 +idt_1A: .int 0, 0 +idt_1B: .int 0, 0 +idt_1C: .int 0, 0 +idt_1D: .int 0, 0 +idt_1E: .int 0, 0 +idt_1F: .int 0, 0 + + + /* + * Global Descriptor Table (GDT) + * + * This describes various memory areas (segments) through + * segment descriptors. In 32 bit mode each segment each + * segement is associated with segment registers which are + * implicitly (or explicitly) referenced depending on the + * instruction. However in 64 bit mode selectors are flat and + * segmented addressing isn't used. + */ +gdt: + .short 0 +gdtr: + .short gdt_en - gdt - 1 + .int gdt + + // Code cs: + .short 0xFFFF + .short 0 + .byte 0 + .byte 0x9b + .byte 0xCF + .byte 0 + + // Data ds:, ss:, es:, fs:, and gs: + .short 0xFFFF + .short 0 + .byte 0 + .byte 0x93 + .byte 0xCF + .byte 0 +gdt_en: + +gdt64: + .short 0 +gdtr64: + .short gdt64_en - gdt64 - 1 + .int gdt64 + + // Code + .short 0xFFFF + .short 0 + .byte 0 + .byte 0x9b + .byte 0xAF + .byte 0 + + // Data + .short 0xFFFF + .short 0 + .byte 0 + .byte 0x93 + .byte 0xCF + .byte 0 +gdt64_en: + + .section .bss + .align 16 + +stack: .space 65536 +stack_end: + + .section .data + +.align 4096 +.Lpd: +i = 0 + .rept 512 * 4 + .quad 0x1e7 | (i << 21) + i = i + 1 + .endr + +.align 4096 +.Lpdp: + .quad .Lpd + 7 + 0 * 4096 /* 0-1 GB */ + .quad .Lpd + 7 + 1 * 4096 /* 1-2 GB */ + .quad .Lpd + 7 + 2 * 4096 /* 2-3 GB */ + .quad .Lpd + 7 + 3 * 4096 /* 3-4 GB */ + +.align 4096 +.Lpml4: + .quad .Lpdp + 7 /* 0-512 GB */ diff --git a/tests/tcg/x86_64/system/kernel.ld b/tests/tcg/x86_64/system/kernel.ld new file mode 100644 index 0000000000..49c12b04ae --- /dev/null +++ b/tests/tcg/x86_64/system/kernel.ld @@ -0,0 +1,33 @@ +PHDRS { + text PT_LOAD FLAGS(5); /* R_E */ + note PT_NOTE FLAGS(0); /* ___ */ +} + +SECTIONS { + . = 0x100000; + + .text : { + __load_st = .; + *(.head) + *(.text) + } :text + + .rodata : { + *(.rodata) + } :text + + /* Keep build ID and PVH notes in same section */ + .notes : { + *(.note.*) + } :note + + .data : { + *(.data) + __load_en = .; + } :text + + .bss : { + *(.bss) + __bss_en = .; + } +} From patchwork Fri Jun 7 09:05:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981327 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 127FE14E5 for ; Fri, 7 Jun 2019 10:19:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2B9828A5F for ; Fri, 7 Jun 2019 10:19:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E076F28A8F; Fri, 7 Jun 2019 10:19:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B8A2C28A5F for ; Fri, 7 Jun 2019 10:19:42 +0000 (UTC) Received: from localhost ([::1]:47944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZByH-0006Mv-Rz for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:19:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45107) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB56-0008PH-33 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB55-0005z6-4n for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:40 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:33019) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB54-0005y0-UY for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:39 -0400 Received: by mail-wm1-x32c.google.com with SMTP id h19so3634800wme.0 for ; Fri, 07 Jun 2019 02:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JC3AVXNsquFwiFLInZAwShppokQkGXpbpXxA7+1lbo4=; b=rclwMiRx1mNavkQcbhavQ1UQSYy55qEHbjX3lW0OxhsU0ZE0jf8IzXxdNfcZB8zc+1 b+w9fCDt+a5fGw5uFQDyoT3bQAfv3hPwMhlblUbbndxIuOO3Wpo/r0z/FrRVBZint4/P 9hHlUWMB6RWhjHZTVzWWF61B0+ozOpSNobksTH7UG79OU0gCxjDaDeA9On0XBiTHIsem BmqwNuon8BgeMPQ3pGPb2r5eVwANa40uw8FKkccVrfHIv39LtHKKj90CESM42K5Q5lpg 0YXuwh/mxb5juWxcoFWcEYPtWLXztXWyJ1pty1UBJF5VcxfJLhcqXG9mCS7wQzqE37Ho 2GXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JC3AVXNsquFwiFLInZAwShppokQkGXpbpXxA7+1lbo4=; b=G5lRGG9UDiqA2wWDFsI1gfHvs9ah2mOr8dlYTSvHtN0C2ZYppscszfp3WchZVt6rGX M1zZZV89sfxiJwGub+bWWdXti3TAgcGdAg/hn/fEDYdlWt/WL7SkZ5PVOt78XAdVj1It fUXgG6REYP8RZ9Fl7WLU+eZcgGcnkzz7raRkHGE5Z4AtqlqKmHY6ZMg5okh4NwiL/wgv n16CUPYt4sE+8UWDKfroHXdzTjm01H2c7DPCsmDAZXfwnTKkpNy7Da+sOHFJWeJrz649 bgpjEtHwhZTE6OvLEy+qbQUIg5Vys0f2eU4SHsvcz8WNQ+3UHN8Tm8xL24Lq4c9eXxn1 jbig== X-Gm-Message-State: APjAAAUUSav6NmQ/YCgbHaaScK8mw0L1i/8KD39w0J1EikHPvAtri624 ppVa+DKkmsH0RWmMfDilzNlfga6CZ3E= X-Google-Smtp-Source: APXvYqyNQlUrzrb+WXARXP3Jf6r3bErZHIW9TOeXWSIMKZr/CjkLg5ZH7AINeShhCvNjla/KqJRy+w== X-Received: by 2002:a05:600c:291:: with SMTP id 17mr2858052wmk.32.1559899357794; Fri, 07 Jun 2019 02:22:37 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 88sm1876360wrl.68.2019.06.07.02.22.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:35 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 802B31FFB7; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:30 +0100 Message-Id: <20190607090552.12434-32-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32c Subject: [Qemu-devel] [PULL 31/52] MAINTAINERS: put myself forward for gdbstub 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: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP As I've been reviewing a lot of this recently and I'm going to put together a pull request I'd better keep an eye on it. Philippe has also volunteered to be a reviewer. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé diff --git a/MAINTAINERS b/MAINTAINERS index a96829ea83..9fd93d9c6a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1872,7 +1872,9 @@ F: util/error.c F: util/qemu-error.c GDB stub -S: Orphan +M: Alex Bennée +R: Philippe Mathieu-Daudé +S: Maintained F: gdbstub* F: gdb-xml/ From patchwork Fri Jun 7 09:05:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E895614E5 for ; Fri, 7 Jun 2019 09:50:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9EE5289D7 for ; Fri, 7 Jun 2019 09:50:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB36928A18; Fri, 7 Jun 2019 09:50:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B204289D7 for ; Fri, 7 Jun 2019 09:50:19 +0000 (UTC) Received: from localhost ([::1]:47650 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBVq-0007MG-JH for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:50:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42065) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvK-000292-8p for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvI-0004iI-8n for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:34 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:46959) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvG-0004ag-8v for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:32 -0400 Received: by mail-wr1-x433.google.com with SMTP id n4so1339528wrw.13 for ; Fri, 07 Jun 2019 02:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s5wS2YCmNrWOpRGICG3GBDDb7iKA90ngEqstlnBtJU0=; b=cxnAAiEmIBVJHy3IBBaqTIJXzpehox8BHAdbLUseNY2SHCywMO9iIrziTu0Dg6AvY3 Wo6h1RlO7zmqB2sXZ2+ALwUPUIEJATIIAV+RaO3zhNkCkvTynVVkC+Il2GR+YwloRB3W hPig/QDMKJCH7k94pYk6Tl/3dQJ3Y9ID7ufwxCwHeKFZWq9c2GZLXHoYLRfZY0S7oJ2p /hkkTz4Zv9ir+y/fyKnRv1wrLH6kyxbOLo2k+biq/nIj/i711G+1jHd2nPac8CofQ4kD s3gD/h8klzAOwZtv60oLUWWmb2PS7oWlWWxIZrRfXyPly+yHHywznPvB1yMH8ax9Mqb1 CMMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s5wS2YCmNrWOpRGICG3GBDDb7iKA90ngEqstlnBtJU0=; b=d8ACLAvPMQK4Ms691PrTXEG+jKbiQctFoyXxWAKdbSHfgJepMFymmLaWoOg2rd2/al 9rQPDe37k+M3se8+AZHmS476Z8WvCUu4A5TmcCpdAhsfOBQ6R5BXyT8AJpnug5cQg4+M 9kYjP3wCZcggGD6r1X9cki/ex5pIoAr2T0SLg6d6tON3u2mCcBQG9fqjrQr1aOAk9ldd i7A5G4gX1/hnXsCB7wV6ohnNLX8J+7f1+ovB+XGT32exY6UR2MGm+T56FxeLInedv3Ha gJzeCYhRMsKLLznW+M9fy8LaLBpn4GNewVXgHlPPUivdTQ+KlULLOyG4x2kUC516QPLY kKNQ== X-Gm-Message-State: APjAAAW7bEMrLkplgryLcFRq4EBwugktgaV9Qc+hzGGjYKCAp89SF76x 3DZdu4Oh+AfqwNztnPTZBl2JDw== X-Google-Smtp-Source: APXvYqzlK9QbuCFj6EmFq4Kp9dGsEAcrBarrPAENGrHDo/iXDT0NZfQ/a+wOiMPBR4TXI9dWngNyXw== X-Received: by 2002:a5d:43d0:: with SMTP id v16mr31413845wrr.252.1559898747207; Fri, 07 Jun 2019 02:12:27 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t6sm1552335wmb.29.2019.06.07.02.12.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:26 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 939E21FF8F; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:31 +0100 Message-Id: <20190607090552.12434-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 Subject: [Qemu-devel] [PULL 32/52] cputlb: cast size_t to target_ulong before using for address masks 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: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , qemu-devel@nongnu.org, Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Randrianasulu , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP While size_t is defined to happily access the biggest host object this isn't the case when generating masks for 64 bit guests on 32 bit hosts. Otherwise we end up truncating the address when we fall back to our unaligned helper. Fixes: https://bugs.launchpad.net/qemu/+bug/1831545 Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Tested-by: Andrew Randrianasulu Reviewed-by: Philippe Mathieu-Daudé diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index b796ab1cbe..8f814a1a2c 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1306,7 +1306,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uint64_t r1, r2; unsigned shift; do_unaligned_access: - addr1 = addr & ~(size - 1); + addr1 = addr & ~((target_ulong)size - 1); addr2 = addr1 + size; r1 = full_load(env, addr1, oi, retaddr); r2 = full_load(env, addr2, oi, retaddr); From patchwork Fri Jun 7 09:05:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16772924 for ; Fri, 7 Jun 2019 10:14:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 033AE28A8C for ; Fri, 7 Jun 2019 10:14:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB2BA28A93; Fri, 7 Jun 2019 10:14:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6DC0428A8C for ; Fri, 7 Jun 2019 10:14:35 +0000 (UTC) Received: from localhost ([::1]:47912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBtK-0002ml-R3 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:14:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44992) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB50-00088b-LP for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB4z-0005qW-1k for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:34 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:50305) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB4y-0005of-QU for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:32 -0400 Received: by mail-wm1-x343.google.com with SMTP id c66so1283121wmf.0 for ; Fri, 07 Jun 2019 02:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c76UPtcUyW2+y+2t3rM60+D/f7quHWsTGj5ldY4x42E=; b=b8u1zWcEiK+85KmLg3wHJQct7+7iQkVgwXQYu6+2iwEVJuNIm5aoW9HyMoYMQO1LQE Vy/k1NnQPzj5OoxYAKTL+dFA+lU6CpLqpJ28PIXBKM+zaJteHosQuFGk/pvGLqrjqYAS RLWfkmBfdC7g41j7Ddne28SZ4JCy1jOvtTFnq+gOrU/eHYUuwHBdfukYlpHOIONS7HYQ 061gQkxH1bh7WXRq8j+NpqqaIFDeiEa6/iCP6FgLgRMMdGYUrSp/b0PESSMwsAvGi4lj 0H1vbUUbd/lVWvwkh2B9PVnrKD6nGAh7xxCaS1P6RLPrtp+WfjJTOkEqh6agAk7jc5et lYAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c76UPtcUyW2+y+2t3rM60+D/f7quHWsTGj5ldY4x42E=; b=TP2P+/irmnM9FFU2xkerX5jPy0oqMm0gnI9f4DrHjo9wVwyV5kxiFl9Gozo4ufsjQN zRZj8GJBLPCP1m/1WLU7G2sua8M5/aU3xYFxBO1q/1xv3VoF5yhatcOM7H11faDRMt0A D69u0e70uKDh2ClDJ2K9RYma1TOgRQRmhBKaxoH2+eLBWbQuD6TCqOrWM7BxYEui5DFx MoleSLWIqgdMXpagQEl3RGzC/OA89A4k9LLgEWKcxrRum862/zVCVTsV72PDPQZaB28G /w/JT3eaHTLXT/N947ciETENmHxg981acR8wxemgC6I8eNc1KM5milLDcBdiWoinUstR kyog== X-Gm-Message-State: APjAAAW2cxkhgPrZ8pK74jEDrMZKLXRftFpyo8qskjCd844HmB41fN7N u1KOSdzgds20JFrUjEaQDWsmXQ== X-Google-Smtp-Source: APXvYqzBnoxcwxLwUeuU0BbPHGb+2qP6+AjUDDlhY/204x0A6u6bFa87eQVZF/o3BVRAj+8v/G3oww== X-Received: by 2002:a1c:238e:: with SMTP id j136mr2722100wmj.4.1559899351642; Fri, 07 Jun 2019 02:22:31 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c16sm1465080wrr.53.2019.06.07.02.22.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A741D1FFB8; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:32 +0100 Message-Id: <20190607090552.12434-34-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 33/52] gdbstub: Add infrastructure to parse cmd packets 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-2-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 462f89edfe..09fe5a4b99 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1268,6 +1268,201 @@ out: return res; } +typedef union GdbCmdVariant { + const char *data; + uint8_t opcode; + unsigned long val_ul; + unsigned long long val_ull; + struct { + GDBThreadIdKind kind; + uint32_t pid; + uint32_t tid; + } thread_id; +} GdbCmdVariant; + +static const char *cmd_next_param(const char *param, const char delimiter) +{ + static const char all_delimiters[] = ",;:="; + char curr_delimiters[2] = {0}; + const char *delimiters; + + if (delimiter == '?') { + delimiters = all_delimiters; + } else if (delimiter == '0') { + return strchr(param, '\0'); + } else if (delimiter == '.' && *param) { + return param + 1; + } else { + curr_delimiters[0] = delimiter; + delimiters = curr_delimiters; + } + + param += strcspn(param, delimiters); + if (*param) { + param++; + } + return param; +} + +static int cmd_parse_params(const char *data, const char *schema, + GdbCmdVariant *params, int *num_params) +{ + int curr_param; + const char *curr_schema, *curr_data; + + *num_params = 0; + + if (!schema) { + return 0; + } + + curr_schema = schema; + curr_param = 0; + curr_data = data; + while (curr_schema[0] && curr_schema[1] && *curr_data) { + switch (curr_schema[0]) { + case 'l': + if (qemu_strtoul(curr_data, &curr_data, 16, + ¶ms[curr_param].val_ul)) { + return -EINVAL; + } + curr_param++; + curr_data = cmd_next_param(curr_data, curr_schema[1]); + break; + case 'L': + if (qemu_strtou64(curr_data, &curr_data, 16, + (uint64_t *)¶ms[curr_param].val_ull)) { + return -EINVAL; + } + curr_param++; + curr_data = cmd_next_param(curr_data, curr_schema[1]); + break; + case 's': + params[curr_param].data = curr_data; + curr_param++; + curr_data = cmd_next_param(curr_data, curr_schema[1]); + break; + case 'o': + params[curr_param].opcode = *(uint8_t *)curr_data; + curr_param++; + curr_data = cmd_next_param(curr_data, curr_schema[1]); + break; + case 't': + params[curr_param].thread_id.kind = + read_thread_id(curr_data, &curr_data, + ¶ms[curr_param].thread_id.pid, + ¶ms[curr_param].thread_id.tid); + curr_param++; + curr_data = cmd_next_param(curr_data, curr_schema[1]); + break; + case '?': + curr_data = cmd_next_param(curr_data, curr_schema[1]); + break; + default: + return -EINVAL; + } + curr_schema += 2; + } + + *num_params = curr_param; + return 0; +} + +typedef struct GdbCmdContext { + GDBState *s; + GdbCmdVariant *params; + int num_params; + uint8_t mem_buf[MAX_PACKET_LENGTH]; + char str_buf[MAX_PACKET_LENGTH + 1]; +} GdbCmdContext; + +typedef void (*GdbCmdHandler)(GdbCmdContext *gdb_ctx, void *user_ctx); + +/* + * cmd_startswith -> cmd is compared using startswith + * + * + * schema definitions: + * Each schema parameter entry consists of 2 chars, + * the first char represents the parameter type handling + * the second char represents the delimiter for the next parameter + * + * Currently supported schema types: + * 'l' -> unsigned long (stored in .val_ul) + * 'L' -> unsigned long long (stored in .val_ull) + * 's' -> string (stored in .data) + * 'o' -> single char (stored in .opcode) + * 't' -> thread id (stored in .thread_id) + * '?' -> skip according to delimiter + * + * Currently supported delimiters: + * '?' -> Stop at any delimiter (",;:=\0") + * '0' -> Stop at "\0" + * '.' -> Skip 1 char unless reached "\0" + * Any other value is treated as the delimiter value itself + */ +typedef struct GdbCmdParseEntry { + GdbCmdHandler handler; + const char *cmd; + bool cmd_startswith; + const char *schema; +} GdbCmdParseEntry; + +static inline int startswith(const char *string, const char *pattern) +{ + return !strncmp(string, pattern, strlen(pattern)); +} + +static int process_string_cmd( + GDBState *s, void *user_ctx, const char *data, + const GdbCmdParseEntry *cmds, int num_cmds) + __attribute__((unused)); + +static int process_string_cmd(GDBState *s, void *user_ctx, const char *data, + const GdbCmdParseEntry *cmds, int num_cmds) +{ + int i, schema_len, max_num_params = 0; + GdbCmdContext gdb_ctx; + + if (!cmds) { + return -1; + } + + for (i = 0; i < num_cmds; i++) { + const GdbCmdParseEntry *cmd = &cmds[i]; + g_assert(cmd->handler && cmd->cmd); + + if ((cmd->cmd_startswith && !startswith(data, cmd->cmd)) || + (!cmd->cmd_startswith && strcmp(cmd->cmd, data))) { + continue; + } + + if (cmd->schema) { + schema_len = strlen(cmd->schema); + if (schema_len % 2) { + return -2; + } + + max_num_params = schema_len / 2; + } + + gdb_ctx.params = + (GdbCmdVariant *)alloca(sizeof(*gdb_ctx.params) * max_num_params); + memset(gdb_ctx.params, 0, sizeof(*gdb_ctx.params) * max_num_params); + + if (cmd_parse_params(&data[strlen(cmd->cmd)], cmd->schema, + gdb_ctx.params, &gdb_ctx.num_params)) { + return -1; + } + + gdb_ctx.s = s; + cmd->handler(&gdb_ctx, user_ctx); + return 0; + } + + return -1; +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; From patchwork Fri Jun 7 09:05:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981357 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 605ED1515 for ; Fri, 7 Jun 2019 10:37:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D349289E2 for ; Fri, 7 Jun 2019 10:37:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 406D028B4C; Fri, 7 Jun 2019 10:37:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C5766289E2 for ; Fri, 7 Jun 2019 10:37:11 +0000 (UTC) Received: from localhost ([::1]:48126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCFC-000294-Jy for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:37:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45065) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB54-0008Il-7P for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB52-0005wa-Rc for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:38 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:50984) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB52-0005vD-L5 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:36 -0400 Received: by mail-wm1-x332.google.com with SMTP id c66so1283302wmf.0 for ; Fri, 07 Jun 2019 02:22:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eS4ups5iSOxsrkjwkIPBvVdVBQzJoB39R+u5rhoVXoE=; b=NBfYhjEeUJfiDur2FFm6EDzUu5k9zDTNrQJ6FpxY6Nd/rI4pv+zbhCJCLBX8hF2wCe 39IKy50tnzNg7Hs5yDM6BiWRYcFNqSd86jxZTRDnH70G9HismS/7ZJQxImnnhHolAnJP JC3kiUMJXQojcQlXYMnv6qOd58ekELKshmQjuvPmLLlesO3ugG3jw5FkHJ/o+YbuvhbK 2379wgUdSw1PXnlhbiw+hreF1z+bTcu3xrfhDx76xObY4sBZe/3rDgBg1zIjFIdAHUHu pRD5uRnO7Cg1vPwL7L8GzPFaEcbwPo7FQiQBeJP0jiDo4iYQdXvCBygyFgUJXT+j4zC1 whlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eS4ups5iSOxsrkjwkIPBvVdVBQzJoB39R+u5rhoVXoE=; b=HIj+TwG/KKmOEkltH9A5ShxTAjyhsy5bYfy7ZHtPMpFXl7rokMMQnAr9I0PmEa819S MNdj9GSABXuu9b6KJyXWaYfWIT+y1Et89t1eEtCdKglmc1IuYKfReXPN0o+Gad9M5ZYN AvybXW6ayjLAJkJNo/IEkZoOhfzpFavcMap4ZehXOcBrFbT+GWxj3oZtqqQl4vRwDTxH CYrSHryUI82/VeVXk+arTPUU8eHKDC3vh00Bpd16yt/sqrZujRo3ObhYLIp0NpSj5vub ZZkKCIHx5BQ+JISOIm/F8Rc4rwxUgiRYqcWfRHqi3jtiSTsSeu4d8XaiqW7SXQkVCTke YYQg== X-Gm-Message-State: APjAAAXfF/NikmNn/2aBJKdDeipP6p4h7mvR98BPFadAZJWm7UjUH2zr xsqf3fXZXGbQQ2RGfZT70S2NuA== X-Google-Smtp-Source: APXvYqzkprCY3rOjUeG0tJce/61GGW2ku4O6XhzSiS5Obu+MRl8STiv213P5hWJu5Kb9dApjEUzhhw== X-Received: by 2002:a7b:cae9:: with SMTP id t9mr2900174wml.126.1559899355465; Fri, 07 Jun 2019 02:22:35 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w185sm1405942wma.39.2019.06.07.02.22.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BA75C1FFBA; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:33 +0100 Message-Id: <20190607090552.12434-35-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PULL 34/52] gdbstub: Implement deatch (D pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Message-Id: <20190529064148.19856-3-arilou@gmail.com> Reviewed-by: Alex Bennée Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 09fe5a4b99..120e52f5d2 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1413,11 +1413,6 @@ static inline int startswith(const char *string, const char *pattern) return !strncmp(string, pattern, strlen(pattern)); } -static int process_string_cmd( - GDBState *s, void *user_ctx, const char *data, - const GdbCmdParseEntry *cmds, int num_cmds) - __attribute__((unused)); - static int process_string_cmd(GDBState *s, void *user_ctx, const char *data, const GdbCmdParseEntry *cmds, int num_cmds) { @@ -1463,6 +1458,55 @@ static int process_string_cmd(GDBState *s, void *user_ctx, const char *data, return -1; } +static void run_cmd_parser(GDBState *s, const char *data, + const GdbCmdParseEntry *cmd) +{ + if (!data) { + return; + } + + /* In case there was an error during the command parsing we must + * send a NULL packet to indicate the command is not supported */ + if (process_string_cmd(s, NULL, data, cmd, 1)) { + put_packet(s, ""); + } +} + +static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + GDBProcess *process; + GDBState *s = gdb_ctx->s; + uint32_t pid = 1; + + if (s->multiprocess) { + if (!gdb_ctx->num_params) { + put_packet(s, "E22"); + return; + } + + pid = gdb_ctx->params[0].val_ul; + } + + process = gdb_get_process(s, pid); + gdb_process_breakpoint_remove_all(s, process); + process->attached = false; + + if (pid == gdb_get_cpu_pid(s, s->c_cpu)) { + s->c_cpu = gdb_first_attached_cpu(s); + } + + if (pid == gdb_get_cpu_pid(s, s->g_cpu)) { + s->g_cpu = gdb_first_attached_cpu(s); + } + + if (!s->c_cpu) { + /* No more process attached */ + gdb_syscall_mode = GDB_SYS_DISABLED; + gdb_continue(s); + } + put_packet(s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1477,6 +1521,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) uint8_t *registers; target_ulong addr, len; GDBThreadIdKind thread_kind; + const GdbCmdParseEntry *cmd_parser = NULL; trace_gdbstub_io_command(line_buf); @@ -1577,42 +1622,15 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) error_report("QEMU: Terminated via GDBstub"); exit(0); case 'D': - /* Detach packet */ - pid = 1; - - if (s->multiprocess) { - unsigned long lpid; - if (*p != ';') { - put_packet(s, "E22"); - break; - } - - if (qemu_strtoul(p + 1, &p, 16, &lpid)) { - put_packet(s, "E22"); - break; - } - - pid = lpid; - } - - process = gdb_get_process(s, pid); - gdb_process_breakpoint_remove_all(s, process); - process->attached = false; - - if (pid == gdb_get_cpu_pid(s, s->c_cpu)) { - s->c_cpu = gdb_first_attached_cpu(s); - } - - if (pid == gdb_get_cpu_pid(s, s->g_cpu)) { - s->g_cpu = gdb_first_attached_cpu(s); - } - - if (s->c_cpu == NULL) { - /* No more process attached */ - gdb_syscall_mode = GDB_SYS_DISABLED; - gdb_continue(s); + { + static const GdbCmdParseEntry detach_cmd_desc = { + .handler = handle_detach, + .cmd = "D", + .cmd_startswith = 1, + .schema = "?.l0" + }; + cmd_parser = &detach_cmd_desc; } - put_packet(s, "OK"); break; case 's': if (*p != '\0') { @@ -1985,6 +2003,9 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, buf); break; } + + run_cmd_parser(s, line_buf, cmd_parser); + return RS_IDLE; } From patchwork Fri Jun 7 09:05:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 606DB924 for ; Fri, 7 Jun 2019 10:32:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49C7428B44 for ; Fri, 7 Jun 2019 10:32:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D6CB28B47; Fri, 7 Jun 2019 10:32:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D52D028B44 for ; Fri, 7 Jun 2019 10:32:52 +0000 (UTC) Received: from localhost ([::1]:48065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCB2-00077Y-1N for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:32:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45011) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB51-0008BK-L0 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB50-0005tM-JO for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:35 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:44857) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB50-0005sG-BZ for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:34 -0400 Received: by mail-wr1-x42d.google.com with SMTP id b17so1381957wrq.11 for ; Fri, 07 Jun 2019 02:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rQDbySq2CCG8eAtAG40D7sD3kPayEKRs8iIxX2EaaA8=; b=bWZ2QkibamH6BQ7pb0DJez2s+LOFU1h++u+GAK2JCBKNEI0foUOlCzAFXxiKm/UPaY DfXtliZZymioa5+BM9VpP/k9o/rFLFnHqFV+EViHKdyuPgqKfNCIAUM87SYanmMSL3hr 8QOFamcIqPmFbCLZRV85JBxLOT69Nu37sOOUXDWggy/RuKdL3EWBDCRP3c1Ll+tfa8ci WKI1PDfGE9t2PvUCvcdB9wVkA0ZwOI2euZdoKtNDVM0h/9iUSSznr7MWXw2hJb6S9kRi oobXZCxIsQkW4ST1jvUubiXxqzJoB7P+9Iw4n5kmPCFN5h3ONBIfTXLJ80YfHAOtGnld F7Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rQDbySq2CCG8eAtAG40D7sD3kPayEKRs8iIxX2EaaA8=; b=HvEPm9pIZJUVW1osOuJVxvhM78SI8Yk41ICNDmWgMOF+JfP7XKqga9jw3mmjmU74+f 4cedh93ERKTX/HK92OYbAmVmqk1n2WXULZMxK1MNlohFKxuKm0Oy6IFRf9SMbqvuNtRp pkA88/jaKf0JzoH9mKNKXWrlgVUHK+u3AYUL7c9Q7jx61DcffN9HW0U7x2mLf50LqHf6 MPHC0T/fV5O7qNS+F+O35ZBWma/NcZYb6PX29OIL1OzXtIerhKp+EFQMa+MN4y3GivYd Kqz5MsQM2wll2bccrYDOCy6DriCjdtBrqcfcZMs90ZdYZI8hAsHDlARS+U2PuX/sE7mB UkIg== X-Gm-Message-State: APjAAAU6IZCYIADKfneZODzIbRMKIpJmeJjNTw6fS/t0zkmYGYfUmQUB lTT84IRUCSrQnyA+o9Yzg1jcDw== X-Google-Smtp-Source: APXvYqx8L+fB4OabjWA8AhloysFaJTN/nxZEjM7LNGY1VmmIBy507ZrbPAi1OtjSu5cyqmGd3onWEg== X-Received: by 2002:a5d:6583:: with SMTP id q3mr35496275wru.184.1559899353421; Fri, 07 Jun 2019 02:22:33 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h84sm1575073wmf.43.2019.06.07.02.22.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CD1B51FFBB; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:34 +0100 Message-Id: <20190607090552.12434-36-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d Subject: [Qemu-devel] [PULL 35/52] gdbstub: Implement thread_alive (T pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-4-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 120e52f5d2..ad00f223f2 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1507,6 +1507,30 @@ static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(s, "OK"); } +static void handle_thread_alive(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + CPUState *cpu; + + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (gdb_ctx->params[0].thread_id.kind == GDB_READ_THREAD_ERR) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + cpu = gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[0].thread_id.pid, + gdb_ctx->params[0].thread_id.tid); + if (!cpu) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + put_packet(gdb_ctx->s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1807,17 +1831,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'T': - thread_kind = read_thread_id(p, &p, &pid, &tid); - if (thread_kind == GDB_READ_THREAD_ERR) { - put_packet(s, "E22"); - break; - } - cpu = gdb_get_cpu(s, pid, tid); - - if (cpu != NULL) { - put_packet(s, "OK"); - } else { - put_packet(s, "E22"); + { + static const GdbCmdParseEntry thread_alive_cmd_desc = { + .handler = handle_thread_alive, + .cmd = "T", + .cmd_startswith = 1, + .schema = "t0" + }; + cmd_parser = &thread_alive_cmd_desc; } break; case 'q': From patchwork Fri Jun 7 09:05:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981151 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DA12924 for ; Fri, 7 Jun 2019 09:19:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CD1A28B02 for ; Fri, 7 Jun 2019 09:19:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10FF728B1F; Fri, 7 Jun 2019 09:19:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A5F6128B02 for ; Fri, 7 Jun 2019 09:19:25 +0000 (UTC) Received: from localhost ([::1]:47420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB1w-0006wy-UK for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:19:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39487) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAp8-0004CI-79 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAp5-0004jg-Oz for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:09 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:39156) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAp5-0004Yu-Hq for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:07 -0400 Received: by mail-wm1-x329.google.com with SMTP id z23so1125808wma.4 for ; Fri, 07 Jun 2019 02:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AyGciPWCZWMMprrVh/RGj7LAohHD1vSZk+l1Mlrp9Kw=; b=tFPY1x1JxMmCh30bEtwkP31PhjjlT9UsOl3sHffiKTuVf5HfuE69++inwzaWs7YRa8 DV7Xp1O9gsC6rLNtb4a2wF69pt4BN/s8gTMzQngKksgt96hSdwEtVu8iFwhY6cxD5aw6 lifuuYZWMzWE6s3LmMM5mRYRQiagPM4SSahkNz/eA6LFdahB2L1dCRqk5/hEOCBtpyYG X/neHW5OBgtFwiH5TM/l+qVhR0bSzAZE9TORLBo7ahqavIMWJ3NQ6nlorBEew+r+lhRf qY5ozHcids5OWSVXHXjKy6XFXBSe1TNlrToEHRHTyawhaolBE8rVu2RDWC3IqIHtGRmt ReSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AyGciPWCZWMMprrVh/RGj7LAohHD1vSZk+l1Mlrp9Kw=; b=JJ9fh3x8AprmxW5dsnhhfKc9vyT7/ml+giBGj07Ez9Qkx1/TwPuhvj6dhg2nw0zynx DsSDTu+M8UbfMRMzcnM2Yl+o+8AFFgFurLXrjbuT1ggtuqAgVqoY0uJb6HKULcdLZUVN MIP7fbplBLNqjrOq2QjGhtVd2HOke/m4F0xDpj4M1WlE9LbpHxS9AlHfXWai/ZHZFy3z oHhN24kmVq0mSAZSmS8lE9lHMu/Cl+oUmUiy9JTOVXLmtwy+xfyl/doQRHmPHCNpUm0F DDLaUkZYBLcff6K2pNzj0l6CxIxe9P4rkKPqCQ1f/zhMEP1YsIWEcY25fglHK799093s +21g== X-Gm-Message-State: APjAAAUsXwSTssSg4zI8Jha2Ycx4m7Se3yyb4aCHVUuOWVQD+HWgGItS WnUp2QoH/wdEt1gxwHIHhH5RFA== X-Google-Smtp-Source: APXvYqxHgEEzKukA3R0DJLpsenDZ+Iah1aYkZaf7Kjnkn/LtZ+xzdR/8H1bjDP4Qe1/d+5/gkZY0YA== X-Received: by 2002:a1c:9d86:: with SMTP id g128mr3118884wme.51.1559898363552; Fri, 07 Jun 2019 02:06:03 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b2sm1549046wrp.72.2019.06.07.02.05.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:06:01 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DFF0B1FFBC; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:35 +0100 Message-Id: <20190607090552.12434-37-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 Subject: [Qemu-devel] [PULL 36/52] gdbstub: Implement continue (c pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-5-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index ad00f223f2..c3089a6b5a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1531,6 +1531,16 @@ static void handle_thread_alive(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } +static void handle_continue(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params) { + gdb_set_cpu_pc(gdb_ctx->s, gdb_ctx->params[0].val_ull); + } + + gdb_ctx->s->signal = 0; + gdb_continue(gdb_ctx->s); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1567,13 +1577,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) gdb_breakpoint_remove_all(); break; case 'c': - if (*p != '\0') { - addr = strtoull(p, (char **)&p, 16); - gdb_set_cpu_pc(s, addr); + { + static const GdbCmdParseEntry continue_cmd_desc = { + .handler = handle_continue, + .cmd = "c", + .cmd_startswith = 1, + .schema = "L0" + }; + cmd_parser = &continue_cmd_desc; } - s->signal = 0; - gdb_continue(s); - return RS_IDLE; + break; case 'C': s->signal = gdb_signal_to_target (strtoul(p, (char **)&p, 16)); if (s->signal == -1) From patchwork Fri Jun 7 09:05:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981329 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C5EF4179 for ; Fri, 7 Jun 2019 10:21:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C00928B27 for ; Fri, 7 Jun 2019 10:21:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6027D28B4B; Fri, 7 Jun 2019 10:21:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F0E9C28B27 for ; Fri, 7 Jun 2019 10:21:42 +0000 (UTC) Received: from localhost ([::1]:47962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZC0D-0007hW-Ve for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:21:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45040) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB53-0008FW-91 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB4y-0005oG-1Q for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:37 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:38349) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB4w-0005iY-2Y for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:30 -0400 Received: by mail-wm1-x329.google.com with SMTP id t5so1185482wmh.3 for ; Fri, 07 Jun 2019 02:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EGXlq8sYJb23DS1OyTu+2jMnILwAaOcvzkQgAo0cZYs=; b=XWzJofJLXnCEgbUUrFCam5HYaNJxWOO/HBzfYzerV0Vx0IOq/UQjEDZ9fOHBQ72LZP sFvv5MjQgvYEDrbfow77xk+vkf7WnRGyP3kzoR2YahFocgMYYikSC17DNhzaznl7I+zw vGALIU8Mue+F7yYWKO/L+o6Lk/2bPtFiOYWXljfOzPA9Ix6X8TbGnWqAoWZ3U4wu+hU9 8K9GWq+6AYxYZeIEFYcR7X9Jh7RBO/+plAEfNwBrjtprob9gM/tKaVf61phGYgBNMG9U iTrSZdMlzKip7P9UkdyRmseooy+veUHkIU7wkxoMkAik8JUIFm0YE0t6lrLt/8JhcVg+ VBOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EGXlq8sYJb23DS1OyTu+2jMnILwAaOcvzkQgAo0cZYs=; b=OIwvJG2bIlI0frhAy43TyvhZhtekrxkB3MsbmkBzQPqCsryrMql05Ddr9ei9X1G2WB BaUFSD8G1VOutRO2fQpgiYw3iORojTKLH/HX6S1esgMtxg9+qjW3lPsv/RgBfol5ub7i iwAWYLe3tNOs9WCtI8KLJrOCZ3XEkQ6yp6NTDLPasGnXe5NAhfFlrnFFaTHvDrP23KHT lCEiccQT8t4XTCnMIF6BdyL1adDsYz1gFsgAyD4HB/Vjn61tLEN9pPHk5dJbga8xH6XY x4WQxCnuuD8uh2GBXoowuFuEI/XCkI8RU1RuWfNsHdB7DtnsKUxF2SUrCHqQP4k+K6yC 93cw== X-Gm-Message-State: APjAAAVp2dauSixSYUvW1xjqr9H4YsuYVs9VALBC6JZ4sq9sYzEGBSeO NQ7qofEhx9MyEvyZ4Klm3osf+g== X-Google-Smtp-Source: APXvYqxxu5VOEpq/N+NnxKkALq1qC8lKKIUKcT1X15MbWMnt+AKGjWeyRzgRlWO+gt4F4e/sLarWMQ== X-Received: by 2002:a1c:968c:: with SMTP id y134mr2712946wmd.122.1559899347983; Fri, 07 Jun 2019 02:22:27 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g5sm1720611wrp.29.2019.06.07.02.22.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F39971FFBD; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:36 +0100 Message-Id: <20190607090552.12434-38-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 Subject: [Qemu-devel] [PULL 37/52] gdbstub: Implement continue with signal (C pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-6-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index c3089a6b5a..3425f0674d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1541,6 +1541,25 @@ static void handle_continue(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_continue(gdb_ctx->s); } +static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + unsigned long signal = 0; + + /* + * Note: C sig;[addr] is currently unsupported and we simply + * omit the addr parameter + */ + if (gdb_ctx->num_params) { + signal = gdb_ctx->params[0].val_ul; + } + + gdb_ctx->s->signal = gdb_signal_to_target(signal); + if (gdb_ctx->s->signal == -1) { + gdb_ctx->s->signal = 0; + } + gdb_continue(gdb_ctx->s); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1588,11 +1607,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'C': - s->signal = gdb_signal_to_target (strtoul(p, (char **)&p, 16)); - if (s->signal == -1) - s->signal = 0; - gdb_continue(s); - return RS_IDLE; + { + static const GdbCmdParseEntry cont_with_sig_cmd_desc = { + .handler = handle_cont_with_sig, + .cmd = "C", + .cmd_startswith = 1, + .schema = "l0" + }; + cmd_parser = &cont_with_sig_cmd_desc; + } + break; case 'v': if (strncmp(p, "Cont", 4) == 0) { p += 4; From patchwork Fri Jun 7 09:05:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 703BD14E5 for ; Fri, 7 Jun 2019 09:29:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FA6528B18 for ; Fri, 7 Jun 2019 09:29:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49B9428B2B; Fri, 7 Jun 2019 09:29:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 93BCC28B18 for ; Fri, 7 Jun 2019 09:29:25 +0000 (UTC) Received: from localhost ([::1]:47488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBBc-0006u1-Rr for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:29:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39489) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAp8-0004CJ-9c for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAp5-0004jb-OI for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:10 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:36269) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAp5-0004aA-H3 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:07 -0400 Received: by mail-wr1-x42c.google.com with SMTP id n4so1360614wrs.3 for ; Fri, 07 Jun 2019 02:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ugqvq5hjETyvltT2YWuWOJiTLDqqAsBqsH4ZO7PK4SQ=; b=yNe2eiwuWZwdjdrXOzN+vDRKbzkIyJRZBMgJCFoyI5loICauyVZ+q92+WM2L/NMn/n 8EfnyVHoHnPBUVB/lzt+kmrgqBaK7rh3NWL3BJ4xr2QAu2kdg7vSLmHlpo2PyAghXTNi YGf16aRjGzCJNqDmeZXfS6SWwav/XqSeR0yhGv5H3l7JSidubmQ8c87eyeZa+DZwjS0t xhOirQkGOBQrG756ajz2Ow+wbUmvZJOhqmHZ4pEBKzB4iWOFv4mSBDGzjFn4QnbBlI0t Unm2okZmgNh0iRhP5V/3wnGlVvTXIWOZQZ+h5PxXABKg8QtVFCE+QGj8QB5zGwyFfKst 3Y5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ugqvq5hjETyvltT2YWuWOJiTLDqqAsBqsH4ZO7PK4SQ=; b=NYCpdkTDDA4JxM39UBGmX7Bw3BJU/hBrRkTTHRelBZGRE68158M7bTbJGQ5OXbFK9o JxWTgnzY6Mhcvy+XWwZdJrlWDBrRjyzA84/Ba0XlFjtp8pg2pmy+yy5tZRnBWrWKl/jN XGZfNQNAlClBWp9DNtZS/HtdQStKyJ+R3qAiVl49LTGHzef9Pk0Rh1ZjBkZIZdhhkwIs EYMWrA7PdAnkTOywWlVz61+cSvGJPnbaNPegSubfgASfvjIWii/Bqxyb/dDNzdvKLHyO jK9M9WJ/d4gFjpn3sSzrBmFyVi1O2ZC9eYDIeL33qvVOesgvfGRbxUm8P6fL+3qPuREd ONBg== X-Gm-Message-State: APjAAAUpRx5CAxY+EV0e4lUBGgiPxaES3SgY65b0BQSP7EDU5epRfcDb AulmAKfzCOugOSqXB3uU239iqg== X-Google-Smtp-Source: APXvYqwxlsUhn8GoZeKBE6VH+0ALCX3UdPDJq3f1qepyDm63XtACv1KhcZ53UpOZGQ75/66f4bgqig== X-Received: by 2002:a5d:43d0:: with SMTP id v16mr31389680wrr.252.1559898364026; Fri, 07 Jun 2019 02:06:04 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id z17sm1115720wru.21.2019.06.07.02.05.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:06:01 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 130EF1FF90; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:37 +0100 Message-Id: <20190607090552.12434-39-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c Subject: [Qemu-devel] [PULL 38/52] gdbstub: Implement set_thread (H pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-7-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 3425f0674d..7735c244b3 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1560,6 +1560,51 @@ static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_continue(gdb_ctx->s); } +static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + CPUState *cpu; + + if (gdb_ctx->num_params != 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (gdb_ctx->params[1].thread_id.kind == GDB_READ_THREAD_ERR) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (gdb_ctx->params[1].thread_id.kind != GDB_ONE_THREAD) { + put_packet(gdb_ctx->s, "OK"); + return; + } + + cpu = gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[1].thread_id.pid, + gdb_ctx->params[1].thread_id.tid); + if (!cpu) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + /* + * Note: This command is deprecated and modern gdb's will be using the + * vCont command instead. + */ + switch (gdb_ctx->params[0].opcode) { + case 'c': + gdb_ctx->s->c_cpu = cpu; + put_packet(gdb_ctx->s, "OK"); + break; + case 'g': + gdb_ctx->s->g_cpu = cpu; + put_packet(gdb_ctx->s, "OK"); + break; + default: + put_packet(gdb_ctx->s, "E22"); + break; + } +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1573,7 +1618,6 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) char thread_id[16]; uint8_t *registers; target_ulong addr, len; - GDBThreadIdKind thread_kind; const GdbCmdParseEntry *cmd_parser = NULL; trace_gdbstub_io_command(line_buf); @@ -1836,35 +1880,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "E22"); break; case 'H': - type = *p++; - - thread_kind = read_thread_id(p, &p, &pid, &tid); - if (thread_kind == GDB_READ_THREAD_ERR) { - put_packet(s, "E22"); - break; - } - - if (thread_kind != GDB_ONE_THREAD) { - put_packet(s, "OK"); - break; - } - cpu = gdb_get_cpu(s, pid, tid); - if (cpu == NULL) { - put_packet(s, "E22"); - break; - } - switch (type) { - case 'c': - s->c_cpu = cpu; - put_packet(s, "OK"); - break; - case 'g': - s->g_cpu = cpu; - put_packet(s, "OK"); - break; - default: - put_packet(s, "E22"); - break; + { + static const GdbCmdParseEntry set_thread_cmd_desc = { + .handler = handle_set_thread, + .cmd = "H", + .cmd_startswith = 1, + .schema = "o.t0" + }; + cmd_parser = &set_thread_cmd_desc; } break; case 'T': From patchwork Fri Jun 7 09:05:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED01714C0 for ; Fri, 7 Jun 2019 10:24:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DACBB28B47 for ; Fri, 7 Jun 2019 10:24:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE50828B4B; Fri, 7 Jun 2019 10:24:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 66CF628B47 for ; Fri, 7 Jun 2019 10:24:02 +0000 (UTC) Received: from localhost ([::1]:47982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZC2T-0001Q4-Oa for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:24:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45129) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB56-0008RI-Qz for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB55-0005zq-NQ for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:40 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:40277) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB55-0005yv-Gh for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:39 -0400 Received: by mail-wr1-x431.google.com with SMTP id p11so1397318wre.7 for ; Fri, 07 Jun 2019 02:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cMrj3E5Bd95PqGJENY32z7PQs37HAPouZyZmhNIb23k=; b=tIcOGZZ8/013NtHbCCUeLcIfcab86vNwBY9Ku2yiozOl7Zmo8ObkRNm+umUC0wB4sq mo0Y/lTSlCUDyyWANdrwVGvWnOic1VnJLAgxVL+/cRlpAmp5JvZCxa3QTXJ9qyu4HGZS pLYqcC3D6MgrxVD3Y5+IXqHiI+EZDxInvn7901FErXujILsNhTAHMdaPafyXrJWcD8V+ a+gNbYjpdpuG/kAGLvGu9dRZuZDw0Yu3WVqCq7m4SVyrwGYV6QMYhdclFJ9VF1c/q4sS K/L0nGPZN5I6tiUMW+HO5oS0qsXU/hmyt34OCm5d8o9g0lCQo1CzXy79eE8bN751Pu4H k0qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cMrj3E5Bd95PqGJENY32z7PQs37HAPouZyZmhNIb23k=; b=K09Qjmx/hLkZ2OfsuDnmAaNCte1Muh67OMSx5It/x4zjNva/pzouRrnRuMXGfnJNlk OOVDvyeDRxcRBDTzI2Bi6UHPQ6+xi+33H/8ddJZVWIbac6plqYg9nwsCtpr2TB4j73Db pc7gkf4OKnnfsuQdG68avhrkiv6vfgRkp/Ec3+cl/k+yCmfnWKZ3CroCwewQGo7PQYXX rytGlS2RQTwwdk5FlH2LyFe3VsPKJGAexQ9c2PxYhzvnYzOO5rQubqxEeFwvHjL4LMJc JDQgl5Hg8YPEM/r6fTwLwrTUJvUCrp5Qkd/hW2Q9MQUf6XYuc6a61pBxjSqWkZB1rACM uizQ== X-Gm-Message-State: APjAAAUJxkNbgvbXx/abh7GZXw/qZBIDsWOFCcwxY8+Bh5pxHObKNv3e vyi9XwCZ6vkB6w41/5DbfIU5yg== X-Google-Smtp-Source: APXvYqwK/gbb0dTaAEvNTs4POZ712fOKUn6ZnxyHhMXhYOrA44O7gbThDNeKROW42K4NYCBBdSbERw== X-Received: by 2002:a5d:554b:: with SMTP id g11mr18362010wrw.10.1559899358447; Fri, 07 Jun 2019 02:22:38 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id p2sm1583377wrx.90.2019.06.07.02.22.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:35 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 263A91FFBE; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:38 +0100 Message-Id: <20190607090552.12434-40-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 Subject: [Qemu-devel] [PULL 39/52] gdbstub: Implement breakpoint commands (Z/z pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Message-Id: <20190529064148.19856-8-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 7735c244b3..8416f4c13f 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -950,7 +950,7 @@ static inline int xlat_gdb_type(CPUState *cpu, int gdbtype) } #endif -static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, int type) +static int gdb_breakpoint_insert(int type, target_ulong addr, target_ulong len) { CPUState *cpu; int err = 0; @@ -987,7 +987,7 @@ static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, int type) } } -static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type) +static int gdb_breakpoint_remove(int type, target_ulong addr, target_ulong len) { CPUState *cpu; int err = 0; @@ -1605,6 +1605,52 @@ static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) } } +static void handle_insert_bp(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int res; + + if (gdb_ctx->num_params != 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + res = gdb_breakpoint_insert(gdb_ctx->params[0].val_ul, + gdb_ctx->params[1].val_ull, + gdb_ctx->params[2].val_ull); + if (res >= 0) { + put_packet(gdb_ctx->s, "OK"); + return; + } else if (res == -ENOSYS) { + put_packet(gdb_ctx->s, ""); + return; + } + + put_packet(gdb_ctx->s, "E22"); +} + +static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int res; + + if (gdb_ctx->num_params != 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + res = gdb_breakpoint_remove(gdb_ctx->params[0].val_ul, + gdb_ctx->params[1].val_ull, + gdb_ctx->params[2].val_ull); + if (res >= 0) { + put_packet(gdb_ctx->s, "OK"); + return; + } else if (res == -ENOSYS) { + put_packet(gdb_ctx->s, ""); + return; + } + + put_packet(gdb_ctx->s, "E22"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1860,24 +1906,26 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "OK"); break; case 'Z': + { + static const GdbCmdParseEntry insert_bp_cmd_desc = { + .handler = handle_insert_bp, + .cmd = "Z", + .cmd_startswith = 1, + .schema = "l?L?L0" + }; + cmd_parser = &insert_bp_cmd_desc; + } + break; case 'z': - type = strtoul(p, (char **)&p, 16); - if (*p == ',') - p++; - addr = strtoull(p, (char **)&p, 16); - if (*p == ',') - p++; - len = strtoull(p, (char **)&p, 16); - if (ch == 'Z') - res = gdb_breakpoint_insert(addr, len, type); - else - res = gdb_breakpoint_remove(addr, len, type); - if (res >= 0) - put_packet(s, "OK"); - else if (res == -ENOSYS) - put_packet(s, ""); - else - put_packet(s, "E22"); + { + static const GdbCmdParseEntry remove_bp_cmd_desc = { + .handler = handle_remove_bp, + .cmd = "z", + .cmd_startswith = 1, + .schema = "l?L?L0" + }; + cmd_parser = &remove_bp_cmd_desc; + } break; case 'H': { From patchwork Fri Jun 7 09:05:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD821924 for ; Fri, 7 Jun 2019 10:13:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A73AA28A8C for ; Fri, 7 Jun 2019 10:13:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B2BE28A93; Fri, 7 Jun 2019 10:13:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2C95828A8C for ; Fri, 7 Jun 2019 10:13:08 +0000 (UTC) Received: from localhost ([::1]:47908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBrv-0001yh-4E for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:13:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42202) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002FY-AQ for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004z4-PA for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:54778) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004k3-E7 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wm1-x332.google.com with SMTP id g135so1233880wme.4 for ; Fri, 07 Jun 2019 02:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kno1JHe4Nw5DNpZGIjJXu5QHXO+/4yvTRz2xZM/0txY=; b=fPLuKuwcdE23w8v3w974LXwbmBDbFl9vHRaFOyhB64LpZrwmbgiotLN8rzpwei/E7X 3PGMPiACY9nRuC4TQPl6xwXT9KQNsgyVPdpy1MlsU3MQASr/dx+RxsjFVE/uU30ZAhUZ Ub22ZuVqilQLspgqCtiF1gmDzpEe5zl8zLf4ra003OYL5p2Jmu7tndvgeLG2ore4eUOi kliwv2pqeIzdMtgCdwJjdFNfekbMyVSJNTN+8nQSCsJx0q1BXaYiMCuHWCaoHhKjIUml +MUsy9Xxnq71CJRxbJycVWXpJg93eb3eyszEB6rHD511ekLYXmzC26VzNI+6eRJZ6RdH T4wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kno1JHe4Nw5DNpZGIjJXu5QHXO+/4yvTRz2xZM/0txY=; b=uVDcE5kmJoyLsN0tFkT4pdXw+gfITumk1vwsTKVFyGIUSNY8O36M9ocg41gpl8tbw6 /X2unlqcpR+yoZotST+i4dZ1uh+w1c3CEnRPTSJmUIzux5HLbU65JoDrQPLTYTduZ1+I AfXJ7Ar9R4mbs0nsBNToTXemsWj0WEVrgQGjOnUpt9HIoqEoyFz7DbskX5hHHXCUKWmR 0vD3rY6EHawp7ogqVzZaq7tzwaLyuS6TSvst6RjEGuDLStww177PgyVWtrMN+SdXlEdF kvbeaeryfTOfPuuUeGDb5Kk+wO6cAR9m/syeYglt4ozUylbGn5OWVDnCC59/YND0yN+e GeoA== X-Gm-Message-State: APjAAAXV4ov3aGCzqgFVUsNH08aDRz3mOt3Nmf8RynNirGB56k1GWksu k3Q4HJgy6SpNCetNFR2YyNj//Q== X-Google-Smtp-Source: APXvYqxIVJCusdmG4NH2v23EPCWYMiuYwR5LtbHBIYYDhTvOVXyX19grqrv8I3NsOFNUIczpBESgJQ== X-Received: by 2002:a1c:c305:: with SMTP id t5mr2790706wmf.163.1559898752590; Fri, 07 Jun 2019 02:12:32 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q24sm1211067wmc.43.2019.06.07.02.12.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 39A9D1FFBF; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:39 +0100 Message-Id: <20190607090552.12434-41-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PULL 40/52] gdbstub: Implement set register (P pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Message-Id: <20190529064148.19856-9-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 8416f4c13f..630f931765 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1651,6 +1651,27 @@ static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "E22"); } +static void handle_set_reg(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int reg_size; + + if (!gdb_has_xml) { + put_packet(gdb_ctx->s, "E00"); + return; + } + + if (gdb_ctx->num_params != 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + reg_size = strlen(gdb_ctx->params[1].data) / 2; + hextomem(gdb_ctx->mem_buf, gdb_ctx->params[1].data, reg_size); + gdb_write_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf, + gdb_ctx->params[0].val_ull); + put_packet(gdb_ctx->s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1895,15 +1916,15 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'P': - if (!gdb_has_xml) - goto unknown_command; - addr = strtoull(p, (char **)&p, 16); - if (*p == '=') - p++; - reg_size = strlen(p) / 2; - hextomem(mem_buf, p, reg_size); - gdb_write_register(s->g_cpu, mem_buf, addr); - put_packet(s, "OK"); + { + static const GdbCmdParseEntry set_reg_cmd_desc = { + .handler = handle_set_reg, + .cmd = "P", + .cmd_startswith = 1, + .schema = "L?s0" + }; + cmd_parser = &set_reg_cmd_desc; + } break; case 'Z': { From patchwork Fri Jun 7 09:05:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 859DD924 for ; Fri, 7 Jun 2019 10:10:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F2B423B24 for ; Fri, 7 Jun 2019 10:10:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F46A28A5F; Fri, 7 Jun 2019 10:10:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F321123B24 for ; Fri, 7 Jun 2019 10:10:04 +0000 (UTC) Received: from localhost ([::1]:47876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBox-0007hs-TU for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:10:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44957) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB4z-00085k-LQ for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB4y-0005p9-Au for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:33 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:47043) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB4y-0005mA-1u for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:32 -0400 Received: by mail-wr1-x435.google.com with SMTP id n4so1372140wrw.13 for ; Fri, 07 Jun 2019 02:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6ItlL8HIelf+krBS9v4fi6BpYYbdu3JhklvwiNP6ff4=; b=x+6+TyO88zsLJFCXpdRp1Rjin74r2YvB1iOoyZDly6fqezu/e4E7kbHna2yv+Vrf5s sgg20+w1NSUWgo0ULRwusjZpQ1QoeWgXy0x2Nu2VzM09rfJc8YKKJjFLvIdyuNrLqDMt qeSrlstyvAzaw8Hwq68Nk/oBy9lvLSUBJaih+omjbGTYEsu+tY/Pmvi6KlVrhEXq+Zk6 7EHdURlGF5hiyfXqPv8HwhyUo3F6Ssl4CabFL245heL7rykmEMkIDTxuQbmuVrBa4DLC CZsdouEAgeUKyp80m9xlOFxL7sahcrFtqOVf8DCTFLkajS9yP23oof0zGz41RkMR20p6 4Wog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6ItlL8HIelf+krBS9v4fi6BpYYbdu3JhklvwiNP6ff4=; b=ngpCxVTiHbnyop6F4VE8qLkzxl/szjoIpbPdi9gFZO7M4SeQTkMJ8aOk4ld+26fCHO CWhoURYqhPl6hEKYhSqZw0WVHpGHtVS6Kjy78cF8qfOSiM6JKHjpyH6hzE9oA1fqvLCm DocX0vFAVPt0b/ZjyXXcFB45ax8zs8pARyOUdhqh+pOMYol8Ki+M16bYRNVRest3XYt6 Edx9isZiHfUmuZRfVdIm1jGVoHiU4gQsu3hQxjRfnUZZUOh7Kar0lIJoE9bZtVkvZ9PN nirk36DgANci9BnT7y/tfqpXVmz/DTbGCw0t8FC4YlCjqPAnlaqkN9wn7rzK/dqm5EaW Iy7Q== X-Gm-Message-State: APjAAAVbUYHDQcD9+7h4qXwNAIk7biPvOsdTpxfl7qYm905/mT5zL+HA YSAVscFu7GhsD1mRKy6MwZgWdQ== X-Google-Smtp-Source: APXvYqzaf9hCDHP1+6kqDMmjMqiT+UgNokZ31O4LeagTzC/M9aCe5HZaXoO3uw3flluaGmqwLrSl9A== X-Received: by 2002:a5d:4949:: with SMTP id r9mr16425976wrs.289.1559899350160; Fri, 07 Jun 2019 02:22:30 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id p190sm1254631wmp.48.2019.06.07.02.22.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4C1BA1FFC0; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:40 +0100 Message-Id: <20190607090552.12434-42-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 Subject: [Qemu-devel] [PULL 41/52] gdbstub: Implement get register (p pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Message-Id: <20190529064148.19856-10-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 630f931765..63809b2ab9 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1672,6 +1672,36 @@ static void handle_set_reg(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } +static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int reg_size; + + /* + * Older gdb are really dumb, and don't use 'g' if 'p' is avaialable. + * This works, but can be very slow. Anything new enough to + * understand XML also knows how to use this properly. + */ + if (!gdb_has_xml) { + put_packet(gdb_ctx->s, ""); + return; + } + + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + reg_size = gdb_read_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf, + gdb_ctx->params[0].val_ull); + if (!reg_size) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, reg_size); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1901,18 +1931,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'p': - /* Older gdb are really dumb, and don't use 'g' if 'p' is avaialable. - This works, but can be very slow. Anything new enough to - understand XML also knows how to use this properly. */ - if (!gdb_has_xml) - goto unknown_command; - addr = strtoull(p, (char **)&p, 16); - reg_size = gdb_read_register(s->g_cpu, mem_buf, addr); - if (reg_size) { - memtohex(buf, mem_buf, reg_size); - put_packet(s, buf); - } else { - put_packet(s, "E14"); + { + static const GdbCmdParseEntry get_reg_cmd_desc = { + .handler = handle_get_reg, + .cmd = "p", + .cmd_startswith = 1, + .schema = "L0" + }; + cmd_parser = &get_reg_cmd_desc; } break; case 'P': From patchwork Fri Jun 7 09:05:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEB6D14E5 for ; Fri, 7 Jun 2019 09:46:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B955428B20 for ; Fri, 7 Jun 2019 09:46:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA39F28B2A; Fri, 7 Jun 2019 09:46:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9512828B20 for ; Fri, 7 Jun 2019 09:46:57 +0000 (UTC) Received: from localhost ([::1]:47606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBSa-0003e2-IW for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:46:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42102) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvQ-0002Bu-80 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvL-0004oH-VU for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:38 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:54139) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvI-0004fx-7i for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:34 -0400 Received: by mail-wm1-x330.google.com with SMTP id x15so1233607wmj.3 for ; Fri, 07 Jun 2019 02:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8wBpPG2QSWocir6/2nFFz+iLLwOYsMTxKGDZ5nY+8mc=; b=D0YkxFpd9q8z8zKYTs9lUfAWsuyEf5AM0XbBfwROaurTBdkulw3LIkk1TnYT8nBFLO fZOmtrBYUpAoJHO23ODzUtSaHUky3bGY7wcIwIRRoRcRvyNJJW6x69W0OukndpZYjh9u Qipn1zIyOCz7X0V/goZgt0cyQODV4oBWOEywboz65JaLBuqFWA4ZtQgFQu1XqVHH8o4u PLALjz1JEuiqXPQO2irjvmmcSMDVF050A/yZK4kYKq2US/5HYJ0LbhgIVfZivfaSzRcm wTtsU35ll0AUlMpvsjxUMEdmPD2I0uTusr7iOwX5PRxI69UC9uSFh+jDKYxBd0XOdxE7 HBAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8wBpPG2QSWocir6/2nFFz+iLLwOYsMTxKGDZ5nY+8mc=; b=LS1rCU8jAbU+EdZa584gHjkC4vBe78zatb6Pi1Yyi8Fkw75KbPbtJVWsCD2sLyRmEK 3yAUjm1w3Qdl6Ne5PJ0Ltu2NYNavOU6exUsdGCqn+hSuwq5C08itJQSPYYhlVgB5+UZv Ozl5jChlGsmpRPMWS8iUKhg4AmLFut5MQGyvsTTQn4a+Rn2Fr5gHfN60Rq+9MzV4IjSn XNR/0xHcrGxJu8Nl7kILpPmRK9vGkdfYg5QunXUWTmLRDzCUOYXqJHFdr3F/7Ev/21Xt XODb7PgU9LoUkkzaC1q+WTB9nE/q+9+Vh4L6/sBYwR7KILomsKO6kD6/PHk3hdWnyRRn PCDQ== X-Gm-Message-State: APjAAAVdwm7CGoOkMhOYX0kMT+/xqNysEMyymlRKsT/lwUHRxPzQs2IN KA5BGvzMEr/zyrXfvY+HGmpWVA== X-Google-Smtp-Source: APXvYqzZ1zsQGLO2ue1tyYRvnaFhzXccxF0iWUeGT4dH+LPOc+JrVeb/fIq2jw4ym6g3gMS4enQBqg== X-Received: by 2002:a1c:9e92:: with SMTP id h140mr2735211wme.82.1559898750189; Fri, 07 Jun 2019 02:12:30 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 34sm1732729wre.32.2019.06.07.02.12.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5EA021FFC1; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:41 +0100 Message-Id: <20190607090552.12434-43-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::330 Subject: [Qemu-devel] [PULL 42/52] gdbstub: Implement write memory (M pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-11-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 63809b2ab9..681a0c8550 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1702,6 +1702,31 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } +static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params != 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + /* hextomem() reads 2*len bytes */ + if (gdb_ctx->params[1].val_ull > strlen(gdb_ctx->params[2].data) / 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + hextomem(gdb_ctx->mem_buf, gdb_ctx->params[2].data, + gdb_ctx->params[1].val_ull); + if (target_memory_rw_debug(gdb_ctx->s->g_cpu, gdb_ctx->params[0].val_ull, + gdb_ctx->mem_buf, + gdb_ctx->params[1].val_ull, true)) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + put_packet(gdb_ctx->s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1910,24 +1935,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'M': - addr = strtoull(p, (char **)&p, 16); - if (*p == ',') - p++; - len = strtoull(p, (char **)&p, 16); - if (*p == ':') - p++; - - /* hextomem() reads 2*len bytes */ - if (len > strlen(p) / 2) { - put_packet (s, "E22"); - break; - } - hextomem(mem_buf, p, len); - if (target_memory_rw_debug(s->g_cpu, addr, mem_buf, len, - true) != 0) { - put_packet(s, "E14"); - } else { - put_packet(s, "OK"); + { + static const GdbCmdParseEntry write_mem_cmd_desc = { + .handler = handle_write_mem, + .cmd = "M", + .cmd_startswith = 1, + .schema = "L,L:s0" + }; + cmd_parser = &write_mem_cmd_desc; } break; case 'p': From patchwork Fri Jun 7 09:05:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE9F56C5 for ; Fri, 7 Jun 2019 09:53:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDBF028B2B for ; Fri, 7 Jun 2019 09:53:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B19CE28B3C; Fri, 7 Jun 2019 09:53:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5960728B2B for ; Fri, 7 Jun 2019 09:53:19 +0000 (UTC) Received: from localhost ([::1]:47670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBYk-0002Hn-If for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:53:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42213) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002Fj-CU for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004yK-H9 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:37478) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004u1-8R for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wr1-x42a.google.com with SMTP id v14so1370430wrr.4 for ; Fri, 07 Jun 2019 02:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HpSzE7CRb/eTzWpNX5jhhMANtC+sz7VcxjFAzL6p7RU=; b=EMXahHkm/lYzmnDZ4m+7jNA0Wckplr5O2W/TMPEy5U9x5UeyTxZKGMW6jCQvjD6syn u26n19W82p+tMxMG1xljUy2xVzJNkb5/8HVwwHgmCbgviJ7n3SjUxvYYeMGZYGsvIxAH Caxdcrs9ycDtl14FPmU7pV4pzne9/Hv36XkDnp0djuebva7rPuxOs0B2bsAgqP4i+pjU 6HYAA+Fook6yGgfgccufNBEBMaaqyGipXAhcCEtKIMsHbdGVEphCMi5Vw4GtdkjjafvY n1LrC2cIjVx6MeRzOlqd2nD50Tx+JDiI3fmreDCCaLDH8eiFWH3L0nH4s3b8p7jW4ozn 2Erw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HpSzE7CRb/eTzWpNX5jhhMANtC+sz7VcxjFAzL6p7RU=; b=hJHFkH3w/mWPSkejfg8rFCs3i59qCGIyVYL0g5r11Plt+7GNPKnVpkdHcpiMNqJ/6b u8OIpcHXLYzYAl94ksPacTs7abl+aHxVG9nK03ydrHAk7+VQGE0+yKZJWKsMboQBI2kS pOjb04wsxReOwqDTIv2AEg1ZQ07Ak90RrChQzAnrYVZcrsRNxz3Xp14bIjIWN8yyDRYN hI87mYY/gvJDpW6jmT17lhL5tuhbP7wFVMnP5OFXKGCzB4ONlipbqGwUvCR1HxQPXuDl W4lLqkryccA2jggx1346ELiUcP8mdMitISm3hWaHY0F+g29jVq8nN59ZkrtRXgZXolNg TxIA== X-Gm-Message-State: APjAAAVwtZx1Ky3GXUsCC8E6rdwfyACnRb2RslNPpO6tnAExabCem2Qk Tch1h6bph3j5pHMIlvdVZv0/xQ== X-Google-Smtp-Source: APXvYqyKvdDoTDQUuxjr6ZorstWK2SR9u88SaCpYTKhtO0vdFpjQycjuWYOkUgUrPSh80ySd7WaAmg== X-Received: by 2002:a5d:638e:: with SMTP id p14mr3203837wru.238.1559898758476; Fri, 07 Jun 2019 02:12:38 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u205sm1279667wmu.47.2019.06.07.02.12.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:36 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 713591FFC2; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:42 +0100 Message-Id: <20190607090552.12434-44-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a Subject: [Qemu-devel] [PULL 43/52] gdbstub: Implement read memory (m pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-12-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 681a0c8550..ceaa47d184 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1727,6 +1727,30 @@ static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } +static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params != 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + /* memtohex() doubles the required space */ + if (gdb_ctx->params[1].val_ull > MAX_PACKET_LENGTH / 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (target_memory_rw_debug(gdb_ctx->s->g_cpu, gdb_ctx->params[0].val_ull, + gdb_ctx->mem_buf, + gdb_ctx->params[1].val_ull, false)) { + put_packet(gdb_ctx->s, "E14"); + return; + } + + memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ull); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1916,22 +1940,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "OK"); break; case 'm': - addr = strtoull(p, (char **)&p, 16); - if (*p == ',') - p++; - len = strtoull(p, NULL, 16); - - /* memtohex() doubles the required space */ - if (len > MAX_PACKET_LENGTH / 2) { - put_packet (s, "E22"); - break; - } - - if (target_memory_rw_debug(s->g_cpu, addr, mem_buf, len, false) != 0) { - put_packet (s, "E14"); - } else { - memtohex(buf, mem_buf, len); - put_packet(s, buf); + { + static const GdbCmdParseEntry read_mem_cmd_desc = { + .handler = handle_read_mem, + .cmd = "m", + .cmd_startswith = 1, + .schema = "L,L0" + }; + cmd_parser = &read_mem_cmd_desc; } break; case 'M': From patchwork Fri Jun 7 09:05:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF3B714E5 for ; Fri, 7 Jun 2019 10:07:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD3FC28B45 for ; Fri, 7 Jun 2019 10:07:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1E2A28B49; Fri, 7 Jun 2019 10:07:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1249E28B4A for ; Fri, 7 Jun 2019 10:07:07 +0000 (UTC) Received: from localhost ([::1]:47810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBm6-0004Vz-FE for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:07:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42204) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002Fb-Ad for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004zq-Us for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:42789) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004wN-LI for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wr1-x436.google.com with SMTP id x17so1355992wrl.9 for ; Fri, 07 Jun 2019 02:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IdumfQ3u3Nl836FqdxSsx6BT98OtMa92VXr8v3RCJYs=; b=ST2Qu6Gn1Zt7sndEgUQGFFHhqh44jHqtPgmMJxkDS+tOMLAF+XkdboI9FiUq3eq7hq TmguoDZm0FZ37IORFjPILFWWVt+XuoITMLeckLJ2mhcfv6ZEPMizMEfw5rCqltIci5OL nsfE3ZhrhxAXvNVqkZVH1zK0vbLv3ULliBHPVfbQe9F9ABf7Fvu4ifr3h2X1yK5WMJAW f7rsujrXqX0d+ie4YpNblGoD2OSbSOOw5IbNfVyshtZXHFbq5qi9OuH4kHUDiYvDbX/N NkznSFTniT4THZTqjHYgATglcMN11UXC2qXfm/1gY3VIU5EZQU3hDsh0K2qfa35DUo1o MBdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IdumfQ3u3Nl836FqdxSsx6BT98OtMa92VXr8v3RCJYs=; b=kILc4BjO2yvbNy2sBhXCcvaQd/X/zVyZJzgullkW5Bm+si71d4DL+B6zpgnmYMMBoa DrU79hyZoYfdp+RcUYOc93Ul/alhFe2YZ+e+Iyv+PXQzkIGjGZ6Pa/sn6al7wrcLvBX8 jl3m9OAoLDBRIkxQ8SLabVnLLJ59PQ0LQn13vVb4s4onVMRw8QVc61ODY+3U2ujxoN73 2qf6cyijgFryNKBkSLTbcbgq/Q7U7NT7tBfHfI+T7udbIpxaYzyWjfU/vO2GSxDWqWND fs4BaW2Z+OuG7gtOUq4b4a2DYuoYqClYt3aoXsGnXdberXPSESBYZCZumgiDGcR2Co+8 N2fQ== X-Gm-Message-State: APjAAAXdDW7dezfMw1zjf5pZHMNMUB2pQmVQW037JggERP43cUKkUlcs pX/MPE4EYvISsLvgxGPxTo6wvA== X-Google-Smtp-Source: APXvYqxI2PzZGNCyAKL2h6p2wKPLnoAHYUOhVCIVUvkk4affql3jbrZbxoIbSD2vBDGeK3G6VGDkxQ== X-Received: by 2002:adf:eb43:: with SMTP id u3mr19026914wrn.342.1559898759161; Fri, 07 Jun 2019 02:12:39 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id f2sm2048681wrq.48.2019.06.07.02.12.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:36 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 83CDE1FFC3; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:43 +0100 Message-Id: <20190607090552.12434-45-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 Subject: [Qemu-devel] [PULL 44/52] gdbstub: Implement write all registers (G pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-13-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index ceaa47d184..880bbb469a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1751,6 +1751,29 @@ static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } +static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + target_ulong addr, len; + uint8_t *registers; + int reg_size; + + if (!gdb_ctx->num_params) { + return; + } + + cpu_synchronize_state(gdb_ctx->s->g_cpu); + registers = gdb_ctx->mem_buf; + len = strlen(gdb_ctx->params[0].data) / 2; + hextomem(registers, gdb_ctx->params[0].data, len); + for (addr = 0; addr < gdb_ctx->s->g_cpu->gdb_num_g_regs && len > 0; + addr++) { + reg_size = gdb_write_register(gdb_ctx->s->g_cpu, registers, addr); + len -= reg_size; + registers += reg_size; + } + put_packet(gdb_ctx->s, "OK"); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1762,7 +1785,6 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; - uint8_t *registers; target_ulong addr, len; const GdbCmdParseEntry *cmd_parser = NULL; @@ -1928,16 +1950,15 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, buf); break; case 'G': - cpu_synchronize_state(s->g_cpu); - registers = mem_buf; - len = strlen(p) / 2; - hextomem((uint8_t *)registers, p, len); - for (addr = 0; addr < s->g_cpu->gdb_num_g_regs && len > 0; addr++) { - reg_size = gdb_write_register(s->g_cpu, registers, addr); - len -= reg_size; - registers += reg_size; + { + static const GdbCmdParseEntry write_all_regs_cmd_desc = { + .handler = handle_write_all_regs, + .cmd = "G", + .cmd_startswith = 1, + .schema = "s0" + }; + cmd_parser = &write_all_regs_cmd_desc; } - put_packet(s, "OK"); break; case 'm': { From patchwork Fri Jun 7 09:05:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4ED536C5 for ; Fri, 7 Jun 2019 09:53:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CD7C28B2B for ; Fri, 7 Jun 2019 09:53:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3167028B3C; Fri, 7 Jun 2019 09:53:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CDE2628B37 for ; Fri, 7 Jun 2019 09:53:28 +0000 (UTC) Received: from localhost ([::1]:47674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBYu-0002Xf-5k for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 05:53:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42067) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvK-000299-97 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvI-0004iS-AJ for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:34 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:54136) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvG-0004d1-95 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:32 -0400 Received: by mail-wm1-x32d.google.com with SMTP id x15so1233511wmj.3 for ; Fri, 07 Jun 2019 02:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mKQZU6ogd55Zge5HtRJs79TkvuWBYPKwIchB5EdBCmo=; b=Qggzb5Od3/dWyGwkOoAh+qFgw4boIabzrgi9tfJPj66CYfhxl06rxENpdMtso65NC7 4U1xufQH6hwR7vvZ0l7q01PAgdeNS6enF5kxDgvxO2+fYDn9ofvxMu35L7JREP1FNpO2 RAokO4pYNoF3003yCqNVnbLTelpOWqDISmuIbKG4uSda9vUU9kM+io3WQcNrU9CS+T61 r6xdsCMRtEullg+OsBTcbNA0ZhLo72rJzY4mEM9ZLF8D1Y/JkOWRsmkftCn80WFf47dj 1GxAsNTfJKMil9GWVy7MNlG8dH3yYTUoWhi/cJ3xjUMoppsZ18qVtfrT1t9UGIE4OvLE 9kYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mKQZU6ogd55Zge5HtRJs79TkvuWBYPKwIchB5EdBCmo=; b=K7czF6djdFPvjBg8BMSbEsd3haSK5ITDkcyWEUOkcLU3XNRpzrIx+KUl721mJsqEpq D4tXjqoMNYnY0zCtV4cVAKg/tcAWgTxM7KGB8zKOXGXcCte1b/GMZYoYv/6dh25QXgBM D3LTS8QlIrP2Qot4mlaE1/1P/vPFXETDaPKFP5+KbEJ5lJVA32ll9LQbMlCGpTfzxwD7 NB2SyEAuMQD0LwzUOQLy6/d7yQ6/qvxRbwwlvNZoJMs9PPPL5UeIPRygKIl+4syNviex AiYqy0fFYsCoY3KizIxsnSPQ1HIPj/tp+Qyt25JIvB8bPAd8Lzaopg/1iMWLKDx13cEE YC4A== X-Gm-Message-State: APjAAAV3oiPhW9nrEC2bAfxNT313xkpPUru9gZORD85uwKxlPSzdPkD1 SqkZaXzP6w7mictRH9JgggfRaw== X-Google-Smtp-Source: APXvYqzDdqSZHpuMCqEs7w+gYbkknWsH9jyj7s4SD/479qIHuFStqg955Q6w6Pwo5mKhPxSOKhgLpw== X-Received: by 2002:a7b:cbcb:: with SMTP id n11mr2788771wmi.146.1559898748529; Fri, 07 Jun 2019 02:12:28 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x8sm1348899wmc.5.2019.06.07.02.12.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 964161FFC4; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:44 +0100 Message-Id: <20190607090552.12434-46-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32d Subject: [Qemu-devel] [PULL 45/52] gdbstub: Implement read all registers (g pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-14-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 880bbb469a..b3c5ced80d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1774,6 +1774,21 @@ static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, "OK"); } +static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + target_ulong addr, len; + + cpu_synchronize_state(gdb_ctx->s->g_cpu); + len = 0; + for (addr = 0; addr < gdb_ctx->s->g_cpu->gdb_num_g_regs; addr++) { + len += gdb_read_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf + len, + addr); + } + + memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1781,7 +1796,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) CPUClass *cc; const char *p; uint32_t pid, tid; - int ch, reg_size, type, res; + int ch, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; @@ -1940,14 +1955,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'g': - cpu_synchronize_state(s->g_cpu); - len = 0; - for (addr = 0; addr < s->g_cpu->gdb_num_g_regs; addr++) { - reg_size = gdb_read_register(s->g_cpu, mem_buf + len, addr); - len += reg_size; + { + static const GdbCmdParseEntry read_all_regs_cmd_desc = { + .handler = handle_read_all_regs, + .cmd = "g", + .cmd_startswith = 1 + }; + cmd_parser = &read_all_regs_cmd_desc; } - memtohex(buf, mem_buf, len); - put_packet(s, buf); break; case 'G': { From patchwork Fri Jun 7 09:05:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 057E514E5 for ; Fri, 7 Jun 2019 10:22:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E90C228B45 for ; Fri, 7 Jun 2019 10:22:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD35F28B4B; Fri, 7 Jun 2019 10:22:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7FC9728B4C for ; Fri, 7 Jun 2019 10:22:44 +0000 (UTC) Received: from localhost ([::1]:47972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZC1D-0008Vc-IQ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:22:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44993) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB50-00088e-LP for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB4z-0005rQ-E6 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:34 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:54227) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB4z-0005pc-7z for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:33 -0400 Received: by mail-wm1-x330.google.com with SMTP id x15so1269377wmj.3 for ; Fri, 07 Jun 2019 02:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gr42vRKrUtGXl0PC7wlu1Mzbd+6iYUnnF6QdAndqlX8=; b=d5DsfHhzjtaYyKNtHVkGf4bnxjwVq0P5yRswjrck/XRMWVAYDPbbLpQBkQpYdRLH7k QH2U1DVVNtsEG11zrz6foyBSgOPhsWBqSHoAIZTjSzWFyGXAgIKGGtkymKSnPDBro/Zj fMFOKrO5lJPFMkfscpfnlfBzFVakQVpLRXIeArUUVC4poiht+owWAjTP1oSqknpNERpc ZW6EKhqJy7XS3zdhYNPr/p9+fXX2BTWM8eg70gmwYS6ghXWrtsrcbdDeFEO2qNhQMRc5 Xji7OxADG7OORLOCYhQ3Dp6SYMqg1PMz/zQ1vDCB7FwuoFsjn6ftTMeIV3d4P9Wl9Tiz vg1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gr42vRKrUtGXl0PC7wlu1Mzbd+6iYUnnF6QdAndqlX8=; b=PeAE3+r8x8LduxKAI0Pe8w0CCl65Jt2up/nepHOzgynMu5+Yyld7srLreDPvqCFy1v L52rYbFicD5C3skHAaDzgGNZQts7GxzzfLSVun+z234UBq39OtphiEK8+n2V+TDHyBgd mymIflxnDs39/k3YZrUSFCsz/c2oBvXdTv/x2rGmm0ZwVr9MXcBd8sTzfj8U0/qZZklL 4QCKqag8dCtcsnayRlhQpf+RBceY22v5SbsjchkJ2SoLjtFtoWYgNo8rMQeDgSL8XwpN iWFYwcZb2QYutyt9Ec0GkroHTiyixVPmuwbZKatcCZDkLeYs8oz1s6xZRbX6p2xBRM6P yhIA== X-Gm-Message-State: APjAAAVK7Kb4312w5lh0vN9OJvvSWGgD8oG3qWC7xnFOIMFe93/5m/Y9 KKisLvOmMsAjVVgzwNyOiZ8zwA== X-Google-Smtp-Source: APXvYqwkV/iSmoxaToCtV+B+EAHSy/nXBBCMzL1kiMEp/KdV5QjZ0ZUtbmiez9xmgfK1ti40+HWQMQ== X-Received: by 2002:a7b:c5cd:: with SMTP id n13mr3085392wmk.67.1559899352168; Fri, 07 Jun 2019 02:22:32 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c12sm1223966wmb.1.2019.06.07.02.22.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A886A1FFC5; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:45 +0100 Message-Id: <20190607090552.12434-47-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::330 Subject: [Qemu-devel] [PULL 46/52] gdbstub: Implement file io (F pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Message-Id: <20190529064148.19856-15-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index b3c5ced80d..1871077cd7 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1789,6 +1789,25 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } +static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params >= 2 && gdb_ctx->s->current_syscall_cb) { + target_ulong ret, err; + + ret = (target_ulong)gdb_ctx->params[0].val_ull; + err = (target_ulong)gdb_ctx->params[1].val_ull; + gdb_ctx->s->current_syscall_cb(gdb_ctx->s->c_cpu, ret, err); + gdb_ctx->s->current_syscall_cb = NULL; + } + + if (gdb_ctx->num_params >= 3 && gdb_ctx->params[2].opcode == (uint8_t)'C') { + put_packet(gdb_ctx->s, "T02"); + return; + } + + gdb_continue(gdb_ctx->s); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1930,28 +1949,13 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) return RS_IDLE; case 'F': { - target_ulong ret; - target_ulong err; - - ret = strtoull(p, (char **)&p, 16); - if (*p == ',') { - p++; - err = strtoull(p, (char **)&p, 16); - } else { - err = 0; - } - if (*p == ',') - p++; - type = *p; - if (s->current_syscall_cb) { - s->current_syscall_cb(s->c_cpu, ret, err); - s->current_syscall_cb = NULL; - } - if (type == 'C') { - put_packet(s, "T02"); - } else { - gdb_continue(s); - } + static const GdbCmdParseEntry file_io_cmd_desc = { + .handler = handle_file_io, + .cmd = "F", + .cmd_startswith = 1, + .schema = "L,L,o0" + }; + cmd_parser = &file_io_cmd_desc; } break; case 'g': From patchwork Fri Jun 7 09:05:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3ACE614E5 for ; Fri, 7 Jun 2019 10:28:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2704C28B27 for ; Fri, 7 Jun 2019 10:28:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A20428B44; Fri, 7 Jun 2019 10:28:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AEF8F28B27 for ; Fri, 7 Jun 2019 10:27:59 +0000 (UTC) Received: from localhost ([::1]:48026 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZC6H-0003aA-01 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:27:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45000) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB51-0008AF-6a for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB50-0005sX-1O for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:35 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:35360) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB4z-0005qj-PR for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:33 -0400 Received: by mail-wm1-x329.google.com with SMTP id c6so1192218wml.0 for ; Fri, 07 Jun 2019 02:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s9ykN90cdyqM5hfEHGBlKQoeXXY56iNyeD+K4udZ73Y=; b=vj2US+qPlr/1a88Hkvj1ieEJKJI9eddVak3pwQR7q3BR53iXEv+sKGuzgN+aaPus1E qsE4KSi4C29159YPVRjSp99hoyXU93wXCHoSv1qHOdj5O3m10VXhYfMYmjrfLyOzNTPV 8aWwIp8RU0e5spGoTms1RAb2kr3R3ETJx5k+MaAENiWDQ7tWJkjD31LbPm52moHy3ii1 WUI/z93TrSawfxphGXzlF1rp9xjoIQhGcXZRz1tnAdtMsA0fy02OoIyK/0Cxi5K35JVs 7bjF+iWptPJcngEWmpvpOimgdekQXwM3ptvpozzOZ5bS5aKbJr41USbA5pDhnl7doEko J7BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s9ykN90cdyqM5hfEHGBlKQoeXXY56iNyeD+K4udZ73Y=; b=JlDYFFJZlDeItjgNSM3Np2381BxKktbO0x88UFPj40dvwULhnbeUe0aCf9QvjRhlBS 6LhNogoRBUyRTUeOt3jFX4wk+dNZymUMAp9NsBs7TfP/UY5FNqffBBw90ggymaWcEhn7 SocFQzVDsxHhyQ01IeuOO0omi5GWGaiejzVE+yMbDC3yNupkco9H69AWWj5dRnO74uXT toqxoM91geSiTatXcF42IIlp3V62EJCbeFWdd7aktgNSHbkKZpOc/FPXw11u9a0t5B19 CM+6Qy6qFEcYQfdIFDu5Oz6BLIXkxhAaZ80UqKZDINIlMmm+MO2PQBKimKc+ubEH8gyh Y9rA== X-Gm-Message-State: APjAAAWp6T2ixGfvdWnXIKY7haKYZEzMJItjCjAKDv5kcAHSZKzZPC+b 7i2VXhvPpbzlX3KNeNBGvS7ijA== X-Google-Smtp-Source: APXvYqyU/ikzJVHy/ozLnGPVtC3fRWm82+W3HCUQK465k+CTfa68m8aUUZqnpBCHS3NwrJnsMn8pfg== X-Received: by 2002:a7b:cc0a:: with SMTP id f10mr3064252wmh.81.1559899352706; Fri, 07 Jun 2019 02:22:32 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id n5sm1298995wrj.27.2019.06.07.02.22.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BC2901FFC7; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:46 +0100 Message-Id: <20190607090552.12434-48-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 Subject: [Qemu-devel] [PULL 47/52] gdbstub: Implement step (s pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-16-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 1871077cd7..6fd276892a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1808,6 +1808,16 @@ static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_continue(gdb_ctx->s); } +static void handle_step(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (gdb_ctx->num_params) { + gdb_set_cpu_pc(gdb_ctx->s, (target_ulong)gdb_ctx->params[0].val_ull); + } + + cpu_single_step(gdb_ctx->s->c_cpu, sstep_flags); + gdb_continue(gdb_ctx->s); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1940,13 +1950,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 's': - if (*p != '\0') { - addr = strtoull(p, (char **)&p, 16); - gdb_set_cpu_pc(s, addr); + { + static const GdbCmdParseEntry step_cmd_desc = { + .handler = handle_step, + .cmd = "s", + .cmd_startswith = 1, + .schema = "L0" + }; + cmd_parser = &step_cmd_desc; } - cpu_single_step(s->c_cpu, sstep_flags); - gdb_continue(s); - return RS_IDLE; + break; case 'F': { static const GdbCmdParseEntry file_io_cmd_desc = { From patchwork Fri Jun 7 09:05:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82BD614E5 for ; Fri, 7 Jun 2019 10:28:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 705A928AE7 for ; Fri, 7 Jun 2019 10:28:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61FAD28B27; Fri, 7 Jun 2019 10:28:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF1D428AE7 for ; Fri, 7 Jun 2019 10:28:03 +0000 (UTC) Received: from localhost ([::1]:48028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZC6N-0003bN-84 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:28:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50992) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBOM-0007e6-Ai for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZBOK-0000p1-Ca for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:34 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:34618) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZBOI-0000kf-U0 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:32 -0400 Received: by mail-wr1-x432.google.com with SMTP id e16so1492158wrn.1 for ; Fri, 07 Jun 2019 02:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M703OVi/yb72s+8BEvwBG9PpAye08L3/Z+ktwqLhEVo=; b=wNKSW70yJe2qVnKuyi4yJa7cNgHDjmUiT7ihS42NXa/jcBMGZF9RNsn3LyGd02XuDH g6qyiQKRHbYaR1ya/1oPISQdEyQ3K/vvMrYTIE6eaBNSnsJ/97r/rOfhJdoijiwvVtcf vMbXAGlywIsQklNmpsgZunHpIJWsIRg9SWwYdJKihCtr59+6AKbH8Ct8fKWlZyybn6eQ gN0hZ8VXPxSiwmTFu94rD37h26li9k4/uWgwq5G8/qPBH1J8U9STlHOc4A7DksannE8j B6HBBDIrA9GEbbCA4ZObTzMhN4da56scBbdmFIWp5FgZ3nONaSTWWaM4LBCpyxT4gXzm f1mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M703OVi/yb72s+8BEvwBG9PpAye08L3/Z+ktwqLhEVo=; b=W0nQQbNvkukUlKEK1eTAVEXq39OaTCmnimJFZB9DrRPnpkOuNs/kzLMSjzRTJ/+9Nf TY5d4MByXqE7GLCt9dxxA8ARRBnB7U92A7V8E/lebWJj/lZW38OQa02d1Q3x0wa7cuAC xaQ6a4KIqlkO73WbJOOGKA66WuuG7zwH8SvUF7n9DqzrXjyey2kYxQ5TpS3/SeWjyFXF upF4qfDlsjF1+oPqfAAWtzQ83CfAvHFdAIDBmffb/x+SLbRgSw/GcyzWi9Q+rBLOeQ82 1JO7cYC1G6YKxfOfQSN6TiV38dLZdvqDWgy9cwDCcVnMoOddiYclwL3cVr5r6pQ2ny1A FVjw== X-Gm-Message-State: APjAAAXBoL0aKCGi1CgFxl7jY0/18zm30mQ+JV9TQs6vtRZ/5PGA1QG2 Rdlk8CemrRhwcEN75uQuTI5W7A== X-Google-Smtp-Source: APXvYqyV5iBIGTuRHzSjcVQznLPa9HYLVPN7V3rhrT0s7l+oNlwbkBmuvhpRVxwOG1I8vGhMUA1gcQ== X-Received: by 2002:a5d:4acf:: with SMTP id y15mr19334842wrs.32.1559900549019; Fri, 07 Jun 2019 02:42:29 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o14sm1409185wrp.77.2019.06.07.02.42.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:42:28 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CF4C41FF91; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:47 +0100 Message-Id: <20190607090552.12434-49-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 Subject: [Qemu-devel] [PULL 48/52] gdbstub: Implement v commands with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Message-Id: <20190529064148.19856-17-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 6fd276892a..5a4d10f1c0 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1818,6 +1818,106 @@ static void handle_step(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_continue(gdb_ctx->s); } +static void handle_v_cont_query(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + put_packet(gdb_ctx->s, "vCont;c;C;s;S"); +} + +static void handle_v_cont(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int res; + + if (!gdb_ctx->num_params) { + return; + } + + res = gdb_handle_vcont(gdb_ctx->s, gdb_ctx->params[0].data); + if ((res == -EINVAL) || (res == -ERANGE)) { + put_packet(gdb_ctx->s, "E22"); + } else if (res) { + put_packet(gdb_ctx->s, ""); + } +} + +static void handle_v_attach(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + GDBProcess *process; + CPUState *cpu; + char thread_id[16]; + + pstrcpy(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "E22"); + if (!gdb_ctx->num_params) { + goto cleanup; + } + + process = gdb_get_process(gdb_ctx->s, gdb_ctx->params[0].val_ul); + if (!process) { + goto cleanup; + } + + cpu = get_first_cpu_in_process(gdb_ctx->s, process); + if (!cpu) { + goto cleanup; + } + + process->attached = true; + gdb_ctx->s->g_cpu = cpu; + gdb_ctx->s->c_cpu = cpu; + + gdb_fmt_thread_id(gdb_ctx->s, cpu, thread_id, sizeof(thread_id)); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", + GDB_SIGNAL_TRAP, thread_id); +cleanup: + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + /* Kill the target */ + put_packet(gdb_ctx->s, "OK"); + error_report("QEMU: Terminated via GDBstub"); + exit(0); +} + +static GdbCmdParseEntry gdb_v_commands_table[] = { + /* Order is important if has same prefix */ + { + .handler = handle_v_cont_query, + .cmd = "Cont?", + .cmd_startswith = 1 + }, + { + .handler = handle_v_cont, + .cmd = "Cont", + .cmd_startswith = 1, + .schema = "s0" + }, + { + .handler = handle_v_attach, + .cmd = "Attach;", + .cmd_startswith = 1, + .schema = "l0" + }, + { + .handler = handle_v_kill, + .cmd = "Kill;", + .cmd_startswith = 1 + }, +}; + +static void handle_v_commands(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (!gdb_ctx->num_params) { + return; + } + + if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + gdb_v_commands_table, + ARRAY_SIZE(gdb_v_commands_table))) { + put_packet(gdb_ctx->s, ""); + } +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1825,7 +1925,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) CPUClass *cc; const char *p; uint32_t pid, tid; - int ch, type, res; + int ch, type; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; @@ -1874,66 +1974,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'v': - if (strncmp(p, "Cont", 4) == 0) { - p += 4; - if (*p == '?') { - put_packet(s, "vCont;c;C;s;S"); - break; - } - - res = gdb_handle_vcont(s, p); - - if (res) { - if ((res == -EINVAL) || (res == -ERANGE)) { - put_packet(s, "E22"); - break; - } - goto unknown_command; - } - break; - } else if (strncmp(p, "Attach;", 7) == 0) { - unsigned long pid; - - p += 7; - - if (qemu_strtoul(p, &p, 16, &pid)) { - put_packet(s, "E22"); - break; - } - - process = gdb_get_process(s, pid); - - if (process == NULL) { - put_packet(s, "E22"); - break; - } - - cpu = get_first_cpu_in_process(s, process); - - if (cpu == NULL) { - /* Refuse to attach an empty process */ - put_packet(s, "E22"); - break; - } - - process->attached = true; - - s->g_cpu = cpu; - s->c_cpu = cpu; - - snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, - gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); - - put_packet(s, buf); - break; - } else if (strncmp(p, "Kill;", 5) == 0) { - /* Kill the target */ - put_packet(s, "OK"); - error_report("QEMU: Terminated via GDBstub"); - exit(0); - } else { - goto unknown_command; + { + static const GdbCmdParseEntry v_cmd_desc = { + .handler = handle_v_commands, + .cmd = "v", + .cmd_startswith = 1, + .schema = "s0" + }; + cmd_parser = &v_cmd_desc; } + break; case 'k': /* Kill the target */ error_report("QEMU: Terminated via GDBstub"); From patchwork Fri Jun 7 09:05:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 116EB14C0 for ; Fri, 7 Jun 2019 10:34:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F102228B47 for ; Fri, 7 Jun 2019 10:34:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E44F828B4A; Fri, 7 Jun 2019 10:34:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D0A7028B47 for ; Fri, 7 Jun 2019 10:34:32 +0000 (UTC) Received: from localhost ([::1]:48072 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCCe-0000Jg-7A for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:34:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51016) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBOO-0007eg-57 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZBOK-0000pb-KS for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:35 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:40438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZBOK-0000nO-81 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:42:32 -0400 Received: by mail-wr1-x42b.google.com with SMTP id p11so1460382wre.7 for ; Fri, 07 Jun 2019 02:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/9nbsuRkicfwbawcEcqgdKjR4DdRt7A9xCx1lrYlQew=; b=RVsHSBrZBrST3uK1flZZvG3ufJeKhkPFgtvF+i0oq0VDB6YgJFhhkfZDyAGBi5z3uE c3mI1Tfbd2+lwCbEhHpj8lcHEyq/lMSaDS94Zs6Kv2vEB2By214u2u4DXmtNYD0vmgfq ymz2AA0+nPPtxsMafpKwu36FHLbmhIZ97rC1gDpoPjUbJf4OH+84ZA19JmQ4kkiYcDgT xwR6ITXtxJXowRg4DjBpLK0ttFBN7AIosPB2VMzWXgnrEPOEOnsQD+m+4SMVbcQvK5jf LE7v/KTK9zXI5x7dutwIPx5pSpv/TvDpE5qTlGSz7uoUTW3fkOYHjkvPxzqRI9TygyyO FUrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/9nbsuRkicfwbawcEcqgdKjR4DdRt7A9xCx1lrYlQew=; b=RLcoVUV5E85Ag67W5/nWOTfoBpt75D8TdzoSuZbil0DylPp/3fuaWs3QBtAdZLJlUi 8LN9i4u4P8ZlDhlY1JSXR1QbaGgI5GehL05jKA33DewuiI/ISQXcJl/R2tQmONxMr0A3 EtpPTm7vTC7w2Uid1Oskveh7GkfwXkbkC+tshgx1BvlJWdnnQNEU5fl1QphvinK7WKlj kzZ1ksoEGsZIhtSV0/SirGV/obBm42OB/yE1CN4ZhPS9MCglN8j9lDCIsQb4P8UQe0Xf eXyDVVwRV+oJvKfmixqkr1yfU7hLAS0Zgszkj+ByAJLrI0VqbOKOY8jLXA4S8RDOMJXY JTiQ== X-Gm-Message-State: APjAAAU8mC5GnLlJECp+rKEY6CBIYNKX3UMZyCr05qlXHS/Jq9+8TvPT vqjbSpUVcn3OP0i8ycz6uUOZyw== X-Google-Smtp-Source: APXvYqzHwbkDZ8e7kH2EQgGL80eFz60A0fjBu2dObrDynPaEWjiko0Ms2Mn45hZTVqO7sOSyYc51pA== X-Received: by 2002:adf:e301:: with SMTP id b1mr34318784wrj.304.1559900550729; Fri, 07 Jun 2019 02:42:30 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u25sm1434120wmc.3.2019.06.07.02.42.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:42:28 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E40B61FFC8; Fri, 7 Jun 2019 10:05:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:48 +0100 Message-Id: <20190607090552.12434-50-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b Subject: [Qemu-devel] [PULL 49/52] gdbstub: Implement generic set/query (Q/q pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron The generic set/query packets contains implementation for varioius sub-commands which are required for GDB and also additional commands which are QEMU specific. To see which QEMU specific commands are available use the command gdb> maintenance packet qqemu.Supported Currently the only implemented QEMU specific command is the command that sets the single step behavior. gdb> maintenance packet qqemu.sstepbits Will display the MASK bits used to control the single stepping. gdb> maintenance packet qqemu.sstep Will display the current value of the mask used when single stepping. gdb> maintenance packet Qqemu.sstep:HEX_VALUE Will change the single step mask. Signed-off-by: Jon Doron Message-Id: <20190529064148.19856-18-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 5a4d10f1c0..c45cefd721 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1130,14 +1130,6 @@ static GDBThreadIdKind read_thread_id(const char *buf, const char **end_buf, return GDB_ONE_THREAD; } -static int is_query_packet(const char *p, const char *query, char separator) -{ - unsigned int query_len = strlen(query); - - return strncmp(p, query, query_len) == 0 && - (p[query_len] == '\0' || p[query_len] == separator); -} - /** * gdb_handle_vcont - Parses and handles a vCont packet. * returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if there is @@ -1918,18 +1910,368 @@ static void handle_v_commands(GdbCmdContext *gdb_ctx, void *user_ctx) } } -static int gdb_handle_packet(GDBState *s, const char *line_buf) +static void handle_query_qemu_sstepbits(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), + "ENABLE=%x,NOIRQ=%x,NOTIMER=%x", SSTEP_ENABLE, + SSTEP_NOIRQ, SSTEP_NOTIMER); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_set_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (!gdb_ctx->num_params) { + return; + } + + sstep_flags = gdb_ctx->params[0].val_ul; + put_packet(gdb_ctx->s, "OK"); +} + +static void handle_query_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "0x%x", sstep_flags); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_query_curr_tid(GdbCmdContext *gdb_ctx, void *user_ctx) { CPUState *cpu; GDBProcess *process; + char thread_id[16]; + + /* + * "Current thread" remains vague in the spec, so always return + * the first thread of the current process (gdb returns the + * first thread). + */ + process = gdb_get_cpu_process(gdb_ctx->s, gdb_ctx->s->g_cpu); + cpu = get_first_cpu_in_process(gdb_ctx->s, process); + gdb_fmt_thread_id(gdb_ctx->s, cpu, thread_id, sizeof(thread_id)); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "QC%s", thread_id); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_query_threads(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + char thread_id[16]; + + if (!gdb_ctx->s->query_cpu) { + put_packet(gdb_ctx->s, "l"); + return; + } + + gdb_fmt_thread_id(gdb_ctx->s, gdb_ctx->s->query_cpu, thread_id, + sizeof(thread_id)); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "m%s", thread_id); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); + gdb_ctx->s->query_cpu = + gdb_next_attached_cpu(gdb_ctx->s, gdb_ctx->s->query_cpu); +} + +static void handle_query_first_threads(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + gdb_ctx->s->query_cpu = gdb_first_attached_cpu(gdb_ctx->s); + handle_query_threads(gdb_ctx, user_ctx); +} + +static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + CPUState *cpu; + int len; + + if (!gdb_ctx->num_params || + gdb_ctx->params[0].thread_id.kind == GDB_READ_THREAD_ERR) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + cpu = gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[0].thread_id.pid, + gdb_ctx->params[0].thread_id.tid); + if (!cpu) { + return; + } + + cpu_synchronize_state(cpu); + + if (gdb_ctx->s->multiprocess && (gdb_ctx->s->process_num > 1)) { + /* Print the CPU model and name in multiprocess mode */ + ObjectClass *oc = object_get_class(OBJECT(cpu)); + const char *cpu_model = object_class_get_name(oc); + char *cpu_name = object_get_canonical_path_component(OBJECT(cpu)); + len = snprintf((char *)gdb_ctx->mem_buf, sizeof(gdb_ctx->str_buf) / 2, + "%s %s [%s]", cpu_model, cpu_name, + cpu->halted ? "halted " : "running"); + g_free(cpu_name); + } else { + /* memtohex() doubles the required space */ + len = snprintf((char *)gdb_ctx->mem_buf, sizeof(gdb_ctx->str_buf) / 2, + "CPU#%d [%s]", cpu->cpu_index, + cpu->halted ? "halted " : "running"); + } + trace_gdbstub_op_extra_info((char *)gdb_ctx->mem_buf); + memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +#ifdef CONFIG_USER_ONLY +static void handle_query_offsets(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + TaskState *ts; + + ts = gdb_ctx->s->c_cpu->opaque; + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), + "Text=" TARGET_ABI_FMT_lx ";Data=" TARGET_ABI_FMT_lx + ";Bss=" TARGET_ABI_FMT_lx, + ts->info->code_offset, + ts->info->data_offset, + ts->info->data_offset); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} +#else +static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int len; + + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + len = strlen(gdb_ctx->params[0].data); + if (len % 2) { + put_packet(gdb_ctx->s, "E01"); + return; + } + + len = len / 2; + hextomem(gdb_ctx->mem_buf, gdb_ctx->params[0].data, len); + gdb_ctx->mem_buf[len++] = 0; + qemu_chr_be_write(gdb_ctx->s->mon_chr, gdb_ctx->mem_buf, len); + put_packet(gdb_ctx->s, "OK"); + +} +#endif + +static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) +{ CPUClass *cc; + + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "PacketSize=%x", + MAX_PACKET_LENGTH); + cc = CPU_GET_CLASS(first_cpu); + if (cc->gdb_core_xml_file) { + pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), + ";qXfer:features:read+"); + } + + if (gdb_ctx->num_params && + strstr(gdb_ctx->params[0].data, "multiprocess+")) { + gdb_ctx->s->multiprocess = true; + } + + pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";multiprocess+"); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + GDBProcess *process; + CPUClass *cc; + unsigned long len, total_len, addr; + const char *xml; const char *p; - uint32_t pid, tid; - int ch, type; + + if (gdb_ctx->num_params < 3) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + process = gdb_get_cpu_process(gdb_ctx->s, gdb_ctx->s->g_cpu); + cc = CPU_GET_CLASS(gdb_ctx->s->g_cpu); + if (!cc->gdb_core_xml_file) { + put_packet(gdb_ctx->s, ""); + return; + } + + gdb_has_xml = true; + p = gdb_ctx->params[0].data; + xml = get_feature_xml(gdb_ctx->s, p, &p, process); + if (!xml) { + put_packet(gdb_ctx->s, "E00"); + return; + } + + addr = gdb_ctx->params[1].val_ul; + len = gdb_ctx->params[2].val_ul; + total_len = strlen(xml); + if (addr > total_len) { + put_packet(gdb_ctx->s, "E00"); + return; + } + + if (len > (MAX_PACKET_LENGTH - 5) / 2) { + len = (MAX_PACKET_LENGTH - 5) / 2; + } + + if (len < total_len - addr) { + gdb_ctx->str_buf[0] = 'm'; + len = memtox(gdb_ctx->str_buf + 1, xml + addr, len); + } else { + gdb_ctx->str_buf[0] = 'l'; + len = memtox(gdb_ctx->str_buf + 1, xml + addr, total_len - addr); + } + + put_packet_binary(gdb_ctx->s, gdb_ctx->str_buf, len + 1, true); +} + +static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + put_packet(gdb_ctx->s, GDB_ATTACHED); +} + +static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + put_packet(gdb_ctx->s, "sstepbits;sstep"); +} + +static GdbCmdParseEntry gdb_gen_query_set_common_table[] = { + /* Order is important if has same prefix */ + { + .handler = handle_query_qemu_sstepbits, + .cmd = "qemu.sstepbits", + }, + { + .handler = handle_query_qemu_sstep, + .cmd = "qemu.sstep", + }, + { + .handler = handle_set_qemu_sstep, + .cmd = "qemu.sstep=", + .cmd_startswith = 1, + .schema = "l0" + }, +}; + +static GdbCmdParseEntry gdb_gen_query_table[] = { + { + .handler = handle_query_curr_tid, + .cmd = "C", + }, + { + .handler = handle_query_threads, + .cmd = "sThreadInfo", + }, + { + .handler = handle_query_first_threads, + .cmd = "fThreadInfo", + }, + { + .handler = handle_query_thread_extra, + .cmd = "ThreadExtraInfo,", + .cmd_startswith = 1, + .schema = "t0" + }, +#ifdef CONFIG_USER_ONLY + { + .handler = handle_query_offsets, + .cmd = "Offsets", + }, +#else + { + .handler = handle_query_rcmd, + .cmd = "Rcmd,", + .cmd_startswith = 1, + .schema = "s0" + }, +#endif + { + .handler = handle_query_supported, + .cmd = "Supported:", + .cmd_startswith = 1, + .schema = "s0" + }, + { + .handler = handle_query_supported, + .cmd = "Supported", + .schema = "s0" + }, + { + .handler = handle_query_xfer_features, + .cmd = "Xfer:features:read:", + .cmd_startswith = 1, + .schema = "s:l,l0" + }, + { + .handler = handle_query_attached, + .cmd = "Attached:", + .cmd_startswith = 1 + }, + { + .handler = handle_query_attached, + .cmd = "Attached", + }, + { + .handler = handle_query_qemu_supported, + .cmd = "qemu.Supported", + }, +}; + +static GdbCmdParseEntry gdb_gen_set_table[] = { + /* Order is important if has same prefix */ + { + .handler = handle_set_qemu_sstep, + .cmd = "qemu.sstep:", + .cmd_startswith = 1, + .schema = "l0" + }, +}; + +static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (!gdb_ctx->num_params) { + return; + } + + if (!process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + gdb_gen_query_set_common_table, + ARRAY_SIZE(gdb_gen_query_set_common_table))) { + return; + } + + if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + gdb_gen_query_table, + ARRAY_SIZE(gdb_gen_query_table))) { + put_packet(gdb_ctx->s, ""); + } +} + +static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (!gdb_ctx->num_params) { + return; + } + + if (!process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + gdb_gen_query_set_common_table, + ARRAY_SIZE(gdb_gen_query_set_common_table))) { + return; + } + + if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + gdb_gen_set_table, + ARRAY_SIZE(gdb_gen_set_table))) { + put_packet(gdb_ctx->s, ""); + } +} + +static int gdb_handle_packet(GDBState *s, const char *line_buf) +{ + const char *p; + int ch; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; - target_ulong addr, len; const GdbCmdParseEntry *cmd_parser = NULL; trace_gdbstub_io_command(line_buf); @@ -2131,183 +2473,28 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } break; case 'q': - case 'Q': - /* parse any 'q' packets here */ - if (!strcmp(p,"qemu.sstepbits")) { - /* Query Breakpoint bit definitions */ - snprintf(buf, sizeof(buf), "ENABLE=%x,NOIRQ=%x,NOTIMER=%x", - SSTEP_ENABLE, - SSTEP_NOIRQ, - SSTEP_NOTIMER); - put_packet(s, buf); - break; - } else if (is_query_packet(p, "qemu.sstep", '=')) { - /* Display or change the sstep_flags */ - p += 10; - if (*p != '=') { - /* Display current setting */ - snprintf(buf, sizeof(buf), "0x%x", sstep_flags); - put_packet(s, buf); - break; - } - p++; - type = strtoul(p, (char **)&p, 16); - sstep_flags = type; - put_packet(s, "OK"); - break; - } else if (strcmp(p,"C") == 0) { - /* - * "Current thread" remains vague in the spec, so always return - * the first thread of the current process (gdb returns the - * first thread). - */ - cpu = get_first_cpu_in_process(s, gdb_get_cpu_process(s, s->g_cpu)); - snprintf(buf, sizeof(buf), "QC%s", - gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); - put_packet(s, buf); - break; - } else if (strcmp(p,"fThreadInfo") == 0) { - s->query_cpu = gdb_first_attached_cpu(s); - goto report_cpuinfo; - } else if (strcmp(p,"sThreadInfo") == 0) { - report_cpuinfo: - if (s->query_cpu) { - snprintf(buf, sizeof(buf), "m%s", - gdb_fmt_thread_id(s, s->query_cpu, - thread_id, sizeof(thread_id))); - put_packet(s, buf); - s->query_cpu = gdb_next_attached_cpu(s, s->query_cpu); - } else - put_packet(s, "l"); - break; - } else if (strncmp(p,"ThreadExtraInfo,", 16) == 0) { - if (read_thread_id(p + 16, &p, &pid, &tid) == GDB_READ_THREAD_ERR) { - put_packet(s, "E22"); - break; - } - cpu = gdb_get_cpu(s, pid, tid); - if (cpu != NULL) { - cpu_synchronize_state(cpu); - - if (s->multiprocess && (s->process_num > 1)) { - /* Print the CPU model and name in multiprocess mode */ - ObjectClass *oc = object_get_class(OBJECT(cpu)); - const char *cpu_model = object_class_get_name(oc); - char *cpu_name = - object_get_canonical_path_component(OBJECT(cpu)); - len = snprintf((char *)mem_buf, sizeof(buf) / 2, - "%s %s [%s]", cpu_model, cpu_name, - cpu->halted ? "halted " : "running"); - g_free(cpu_name); - } else { - /* memtohex() doubles the required space */ - len = snprintf((char *)mem_buf, sizeof(buf) / 2, - "CPU#%d [%s]", cpu->cpu_index, - cpu->halted ? "halted " : "running"); - } - trace_gdbstub_op_extra_info((char *)mem_buf); - memtohex(buf, mem_buf, len); - put_packet(s, buf); - } - break; - } -#ifdef CONFIG_USER_ONLY - else if (strcmp(p, "Offsets") == 0) { - TaskState *ts = s->c_cpu->opaque; - - snprintf(buf, sizeof(buf), - "Text=" TARGET_ABI_FMT_lx ";Data=" TARGET_ABI_FMT_lx - ";Bss=" TARGET_ABI_FMT_lx, - ts->info->code_offset, - ts->info->data_offset, - ts->info->data_offset); - put_packet(s, buf); - break; - } -#else /* !CONFIG_USER_ONLY */ - else if (strncmp(p, "Rcmd,", 5) == 0) { - int len = strlen(p + 5); - - if ((len % 2) != 0) { - put_packet(s, "E01"); - break; - } - len = len / 2; - hextomem(mem_buf, p + 5, len); - mem_buf[len++] = 0; - qemu_chr_be_write(s->mon_chr, mem_buf, len); - put_packet(s, "OK"); - break; - } -#endif /* !CONFIG_USER_ONLY */ - if (is_query_packet(p, "Supported", ':')) { - snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH); - cc = CPU_GET_CLASS(first_cpu); - if (cc->gdb_core_xml_file != NULL) { - pstrcat(buf, sizeof(buf), ";qXfer:features:read+"); - } - - if (strstr(p, "multiprocess+")) { - s->multiprocess = true; - } - pstrcat(buf, sizeof(buf), ";multiprocess+"); - - put_packet(s, buf); - break; - } - if (strncmp(p, "Xfer:features:read:", 19) == 0) { - const char *xml; - target_ulong total_len; - - process = gdb_get_cpu_process(s, s->g_cpu); - cc = CPU_GET_CLASS(s->g_cpu); - if (cc->gdb_core_xml_file == NULL) { - goto unknown_command; - } - - gdb_has_xml = true; - p += 19; - xml = get_feature_xml(s, p, &p, process); - if (!xml) { - snprintf(buf, sizeof(buf), "E00"); - put_packet(s, buf); - break; - } - - if (*p == ':') - p++; - addr = strtoul(p, (char **)&p, 16); - if (*p == ',') - p++; - len = strtoul(p, (char **)&p, 16); - - total_len = strlen(xml); - if (addr > total_len) { - snprintf(buf, sizeof(buf), "E00"); - put_packet(s, buf); - break; - } - if (len > (MAX_PACKET_LENGTH - 5) / 2) - len = (MAX_PACKET_LENGTH - 5) / 2; - if (len < total_len - addr) { - buf[0] = 'm'; - len = memtox(buf + 1, xml + addr, len); - } else { - buf[0] = 'l'; - len = memtox(buf + 1, xml + addr, total_len - addr); - } - put_packet_binary(s, buf, len + 1, true); - break; + { + static const GdbCmdParseEntry gen_query_cmd_desc = { + .handler = handle_gen_query, + .cmd = "q", + .cmd_startswith = 1, + .schema = "s0" + }; + cmd_parser = &gen_query_cmd_desc; } - if (is_query_packet(p, "Attached", ':')) { - put_packet(s, GDB_ATTACHED); - break; + break; + case 'Q': + { + static const GdbCmdParseEntry gen_set_cmd_desc = { + .handler = handle_gen_set, + .cmd = "Q", + .cmd_startswith = 1, + .schema = "s0" + }; + cmd_parser = &gen_set_cmd_desc; } - /* Unrecognised 'q' command. */ - goto unknown_command; - + break; default: - unknown_command: /* put empty packet */ buf[0] = '\0'; put_packet(s, buf); From patchwork Fri Jun 7 09:05:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E5BF14C0 for ; Fri, 7 Jun 2019 10:23:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1B4128B3C for ; Fri, 7 Jun 2019 10:23:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E60BF28B4C; Fri, 7 Jun 2019 10:23:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 802B128B49 for ; Fri, 7 Jun 2019 10:23:54 +0000 (UTC) Received: from localhost ([::1]:47980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZC2L-0001HI-LO for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:23:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44947) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB4z-00084G-76 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB4y-0005oO-2c for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:33 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34825) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB4w-0005hl-3g for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:30 -0400 Received: by mail-wr1-x442.google.com with SMTP id m3so1422062wrv.2 for ; Fri, 07 Jun 2019 02:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6p4AOuc6tSqUtkly1124rR3i8VzgPPw2QQg37+GiwQw=; b=LGGWbPMPy8kvNxxFhLdei3Ebzjt4NHqzX2b2XzS7za1J/oD6Tk4l+OzLzOQsiguEpG JOwErwhTsNXNb2C1PjsdqZ1/+4Y6FULvLUuXS4uIZ5JLtS1azzUfxedKJ4Sk0CMPaTr3 8DQHLLpI2CY/6ssbU3Rk3UPJ/agK5pi3hWS5dEvHnMZMDvm/DQB7wtTqFGJgPsk7K9Rj ZyUwGLf0vfBzOj5JRljOVGnraSjHGQoAhBSk0BIdV9cEf6Oy/CCIwAIC97V4D/wFoGed zYPUyCbZGFQM85si4qZg0HTP8dLtnySezCHjHO6CE5Fh933s8btVADuPircn7aIlKBSw W5Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6p4AOuc6tSqUtkly1124rR3i8VzgPPw2QQg37+GiwQw=; b=HTBvGzcT1fwczs3qyzGn8YywKf15Tpalyxht/AvK4oyccvzY587H8HB2R/u2vd8m5O lGU9/CKStkWErepgFpxx6586kh7gsgiraoLuFbKcmgQRQ0xof243dIi6OUoAlZC3Br3t hyRpXIwZHLaXsfo7nb9BZ205ZTU5SfhgPaxWfcbp2JjXOpHrbMHF07EikkUYukUa9DDi lUBKdawKyII1f+2hDNLQY1A8FDrhinNBuzCBwHaZxSk4iJp3/JPBW5z+P07SEWaS6UgK EDzS83jLWZ0XgcdqH9Tqrscj5tbNOP2BA6RDMleF0QKNlNz0AC9RoYtB9ZHcp7Tlxo1N //Dg== X-Gm-Message-State: APjAAAVkIAQPMkSAOcEQaYW/xWqS2HizJFTFv3XAqnBzcG4JIqj+rq0i SuyNVEG+UGd4mKYSfdeje1IBDA== X-Google-Smtp-Source: APXvYqwJOk+pkqh43h4lliU9+sRXjy17u5gICefpxIC/iMlyBgzv02nKsZaOEQATWvjcfN4U6gmKoA== X-Received: by 2002:adf:dc43:: with SMTP id m3mr15729283wrj.279.1559899347429; Fri, 07 Jun 2019 02:22:27 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q20sm4023504wra.36.2019.06.07.02.22.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:26 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 02AF11FFC9; Fri, 7 Jun 2019 10:05:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:49 +0100 Message-Id: <20190607090552.12434-51-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PULL 50/52] gdbstub: Implement target halted (? pkt) with new infra 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Note: The user-mode thread-id has been correctly reported since bd88c780e6 Signed-off-by: Jon Doron Message-Id: <20190529064148.19856-19-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index c45cefd721..26c0c30682 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2265,13 +2265,29 @@ static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx) } } +static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + char thread_id[16]; + + gdb_fmt_thread_id(gdb_ctx->s, gdb_ctx->s->c_cpu, thread_id, + sizeof(thread_id)); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", + GDB_SIGNAL_TRAP, thread_id); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); + /* + * Remove all the breakpoints when this query is issued, + * because gdb is doing an initial connect and the state + * should be cleaned up. + */ + gdb_breakpoint_remove_all(); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { const char *p; int ch; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; - char thread_id[16]; const GdbCmdParseEntry *cmd_parser = NULL; trace_gdbstub_io_command(line_buf); @@ -2283,15 +2299,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "OK"); break; case '?': - /* TODO: Make this return the correct value for user-mode. */ - snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, - gdb_fmt_thread_id(s, s->c_cpu, thread_id, sizeof(thread_id))); - put_packet(s, buf); - /* Remove all the breakpoints when this query is issued, - * because gdb is doing and initial connect and the state - * should be cleaned up. - */ - gdb_breakpoint_remove_all(); + { + static const GdbCmdParseEntry target_halted_cmd_desc = { + .handler = handle_target_halt, + .cmd = "?", + .cmd_startswith = 1 + }; + cmd_parser = &target_halted_cmd_desc; + } break; case 'c': { From patchwork Fri Jun 7 09:05:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981293 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3EDC92A for ; Fri, 7 Jun 2019 10:02:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9300A28B3C for ; Fri, 7 Jun 2019 10:02:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 877BA28B3E; Fri, 7 Jun 2019 10:02:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2339928B3C for ; Fri, 7 Jun 2019 10:02:55 +0000 (UTC) Received: from localhost ([::1]:47736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBi2-0001e2-Gt for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:02:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42199) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvT-0002FK-A0 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvQ-0004yo-Nd for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:43 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:35286) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvQ-0004oP-CM for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:40 -0400 Received: by mail-wm1-x330.google.com with SMTP id c6so1161751wml.0 for ; Fri, 07 Jun 2019 02:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nMFCZfwkMlDoG7F9uNweZDiNnzGq2iNoqNGA+iU0AVQ=; b=OclLWVAtK+ADY39NWGpm9RLDld2yzN2AgU9shKcm6B/5ibkaTGyxl45lqCZQdxWImG PROEd8OsxTfmUQ99KUqhIGdYoZfwsjSvHA5hcxnoqORP7aE6l/tSWqgNYf0yWbn+ghdw jv2m6p+lGlbmBg3EG7TiJU390nTVHRgBBeXdEnYDGRDruZMlX/zYHq6xU2iBYC7PMOIS ZmQ7Ehi8avrySxFxWNOhGIb3Hqpztw85225mbMw9UMS5asTj0DTrSeuEqwtSVybpEgvw A8dYTrImri1rVl8gKoSViMmpMs97pt7pYqtbeOq6H7PDD1240Qyyn2YD6EGGxinFRv5k OrmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nMFCZfwkMlDoG7F9uNweZDiNnzGq2iNoqNGA+iU0AVQ=; b=gY8MceA7xXltdJdbW9IjteO+17Sp6H40bKKR6/S24wxAPYZCubN+NTdK+69BX3Bz+E RXTTALFKz3ZegjHuM2TlLI04c3zWcannWhahSp0EIrFqzIsoFyUIT+o5pU/j4wkBxVGl UHErbKh8mxpm2vgMl3EL2s0Iw7l5wsuhyPxxO1sS9qNLoFREr8HelXIpgWPFRlCslSEK e0dDSYN3MjVAmzVDTrtg0rpxSvD7b1k9+kdlP7/F79ciS7iula/YIIMHjG4FRBPdSGYd R0z4ecokWK5V+sj1CmCwT6+QC+dib52cn4hWb/uaPwaVqpNm//1TJ8HJxIjyloJW8LDz sb3g== X-Gm-Message-State: APjAAAXGRpIs2vWYU/iOBbRMxlaMztOiot1u2zfTGqPg5yzDowvOA/4v zQ9hrW1Ty/rSgnUN+lGShnwwk5Lyio0= X-Google-Smtp-Source: APXvYqzYu35bnL68b4gaK9vDVkpMbmdZoWjH9ckS6+4cMZH2gEMVjq2hyanBkfu6PHCUT6Vg/JspSw== X-Received: by 2002:a7b:c144:: with SMTP id z4mr3054998wmi.50.1559898755657; Fri, 07 Jun 2019 02:12:35 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l1sm1523446wmg.13.2019.06.07.02.12.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:32 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1543F1FFCA; Fri, 7 Jun 2019 10:05:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:50 +0100 Message-Id: <20190607090552.12434-52-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::330 Subject: [Qemu-devel] [PULL 51/52] gdbstub: Clear unused variables in gdb_handle_packet 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Signed-off-by: Jon Doron Reviewed-by: Alex Bennée Message-Id: <20190529064148.19856-20-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 26c0c30682..12671e6e11 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2284,17 +2284,11 @@ static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) static int gdb_handle_packet(GDBState *s, const char *line_buf) { - const char *p; - int ch; - uint8_t mem_buf[MAX_PACKET_LENGTH]; - char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; const GdbCmdParseEntry *cmd_parser = NULL; trace_gdbstub_io_command(line_buf); - p = line_buf; - ch = *p++; - switch(ch) { + switch (line_buf[0]) { case '!': put_packet(s, "OK"); break; @@ -2511,8 +2505,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) break; default: /* put empty packet */ - buf[0] = '\0'; - put_packet(s, buf); + put_packet(s, ""); break; } From patchwork Fri Jun 7 09:05:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10981375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C5D092A for ; Fri, 7 Jun 2019 10:44:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38DB028B52 for ; Fri, 7 Jun 2019 10:44:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CA5B28B53; Fri, 7 Jun 2019 10:44:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.47]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B31E528B51 for ; Fri, 7 Jun 2019 10:44:46 +0000 (UTC) Received: from localhost ([::1]:48206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCMX-0000uz-U4 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Jun 2019 06:44:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45145) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB57-0008Sl-HN for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB56-00060X-Am for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:41 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:50988) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB56-0005zW-3w for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:40 -0400 Received: by mail-wm1-x336.google.com with SMTP id c66so1283495wmf.0 for ; Fri, 07 Jun 2019 02:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nOqWwiE90nOP0TqVRDm/szto9/dNBu2y2hfwpJ0rtGA=; b=i2LxqWcZ7DwLaQImdxxzvQ28zftWMViFa8EQUTDemYH6FXhhiitHW6BUSTJB/DC80l /e6bhOy9L8nSLPXfnZJL9JTUPPTHLXbzyEBLNOArHrhSfHC+lhAf9VVH/g7C/GhAuqum zTWTO0kV3mcuub+w0d9b/WUR65oinfwxyUZ+LhQwPxpQJ48bjF87dD1t3p8XkrydxH23 HpxlXpfwCHuRpROg8lKaoHTiV0VjvHZAkjIp9RPGjhiWs3RxAyIWiwouUYIk8NmNeYxQ F5cO5ThlzCHBrD0d+gJOkz7wgV080FaaIqCW2k7FEyCO+I8RAUC22w1d5eCA2wgqx/B8 Sb3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nOqWwiE90nOP0TqVRDm/szto9/dNBu2y2hfwpJ0rtGA=; b=g3+gx7sEKmhg1fGUuOlHnaP17AM4Nuo9ih9EqOvxSpstRc7H+oFi2RNbZWd7KCk7R7 GcEM6aD/D5T6V6qG3r+SqXIQXGRVKpFZBGlgFhld0LTEyJ0XB5oZiF03tzC9tiCGrIpT SdKLRo1PwNW4bG/xn6OfB3YjyWACXz2KlCFoJ1dWkJha1yB4QoL1nxR3QlzrzNAS5RKb Cl1IfrIhpB+nH60ETELyQYh9NJ4GbFVwX3FgT79n42exFk3+r90w5d+1Z3qgwHg/yhkv crPnTlU0+Wy54CgwPUsJcxQbD23K+ZGkVhduYeaFPl40EPfdfdrTgV1C9+EEK77f365E lGFA== X-Gm-Message-State: APjAAAXRZ6jtyf3ELtMmMsPIPjA97Mlny6C4elQ4pmCh3MkxhxeyJRNc f7vJL6GB5wIxbcnFUvXRhapwEQ== X-Google-Smtp-Source: APXvYqy3osjV1AzqBhJFNAl9SCEzXrCOnllGEpCB/ZLGL/9fUWkVthbXYrlq0i7kFTED3NRR9wu8Pw== X-Received: by 2002:a1c:b757:: with SMTP id h84mr3064686wmf.127.1559899358974; Fri, 07 Jun 2019 02:22:38 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a19sm1282324wmm.46.2019.06.07.02.22.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:35 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 280DC1FFCB; Fri, 7 Jun 2019 10:05:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:51 +0100 Message-Id: <20190607090552.12434-53-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::336 Subject: [Qemu-devel] [PULL 52/52] gdbstub: Implement qemu physical memory mode 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jon Doron Add a new query/set which changes the memory GDB sees to physical memory only. gdb> maint packet qqemu.PhyMemMode will reply the current phy_mem_mode state (1 for enabled, 0 for disabled) gdb> maint packet Qqemu.PhyMemMode:1 Will make GDB read/write only to physical memory, set to 0 to disable Signed-off-by: Jon Doron Message-Id: <20190529064148.19856-21-arilou@gmail.com> Signed-off-by: Alex Bennée diff --git a/gdbstub.c b/gdbstub.c index 12671e6e11..14a9c22f5a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -46,11 +46,27 @@ #define GDB_ATTACHED "1" #endif +#ifndef CONFIG_USER_ONLY +static int phy_memory_mode; +#endif + static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, uint8_t *buf, int len, bool is_write) { - CPUClass *cc = CPU_GET_CLASS(cpu); + CPUClass *cc; +#ifndef CONFIG_USER_ONLY + if (phy_memory_mode) { + if (is_write) { + cpu_physical_memory_write(addr, buf, len); + } else { + cpu_physical_memory_read(addr, buf, len); + } + return 0; + } +#endif + + cc = CPU_GET_CLASS(cpu); if (cc->memory_rw_debug) { return cc->memory_rw_debug(cpu, addr, buf, len, is_write); } @@ -2132,8 +2148,36 @@ static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user_ctx) { - put_packet(gdb_ctx->s, "sstepbits;sstep"); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "sstepbits;sstep"); +#ifndef CONFIG_USER_ONLY + pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";PhyMemMode"); +#endif + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +#ifndef CONFIG_USER_ONLY +static void handle_query_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, + void *user_ctx) +{ + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "%d", phy_memory_mode); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (!gdb_ctx->params[0].val_ul) { + phy_memory_mode = 0; + } else { + phy_memory_mode = 1; + } + put_packet(gdb_ctx->s, "OK"); } +#endif static GdbCmdParseEntry gdb_gen_query_set_common_table[] = { /* Order is important if has same prefix */ @@ -2215,6 +2259,12 @@ static GdbCmdParseEntry gdb_gen_query_table[] = { .handler = handle_query_qemu_supported, .cmd = "qemu.Supported", }, +#ifndef CONFIG_USER_ONLY + { + .handler = handle_query_qemu_phy_mem_mode, + .cmd = "qemu.PhyMemMode", + }, +#endif }; static GdbCmdParseEntry gdb_gen_set_table[] = { @@ -2225,6 +2275,14 @@ static GdbCmdParseEntry gdb_gen_set_table[] = { .cmd_startswith = 1, .schema = "l0" }, +#ifndef CONFIG_USER_ONLY + { + .handler = handle_set_qemu_phy_mem_mode, + .cmd = "qemu.PhyMemMode:", + .cmd_startswith = 1, + .schema = "l0" + }, +#endif }; static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx)