From patchwork Fri Sep 30 21:31:02 2016 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: 77188 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp517768qgf; Fri, 30 Sep 2016 14:46:47 -0700 (PDT) X-Received: by 10.55.25.211 with SMTP id 80mr9307052qkz.230.1475272007443; Fri, 30 Sep 2016 14:46:47 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b139si817785qka.131.2016.09.30.14.46.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 30 Sep 2016 14:46:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bq5dn-0003Io-00 for patch@linaro.org; Fri, 30 Sep 2016 17:46:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bq5P0-0006X4-19 for qemu-devel@nongnu.org; Fri, 30 Sep 2016 17:31:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bq5Oy-0006aI-MP for qemu-devel@nongnu.org; Fri, 30 Sep 2016 17:31:29 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:36226) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bq5Oy-0006a7-C8 for qemu-devel@nongnu.org; Fri, 30 Sep 2016 17:31:28 -0400 Received: by mail-wm0-x233.google.com with SMTP id k125so48663641wma.1 for ; Fri, 30 Sep 2016 14:31: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=nyu+bQc15ZzePe4k1/9Sr5MiNLwNhBQfrj5esaYGXPY=; b=BU/JLHmqkxJoGmKT+a/TKF84n+a1dltBO8uIb7BfKJbMvWudcdXSWHoOMgSQ9NTrot Kb7pKoooOEuVveAFkhK+6wzYfDP1i4UiHwUkKUpZAOd24gqCWwMGehFgisJGRfbFmLJR k/rZe9p9wjsAaczkTPzpEudGVA0KwuOxSInUI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nyu+bQc15ZzePe4k1/9Sr5MiNLwNhBQfrj5esaYGXPY=; b=RmpGPFfu6WjTskFcSAQkGmxRzTCbDfpAS403LDX9PqvcXLus2oVGoThhTZwaL5Btb1 eGQzjvVx3waQah22bujn6iCPWZ+kGgh4Iub1ujfJgRUuMXmUlH6Qe8Vz/nlST7LuFDKZ Riqm4ZLxKZZAw1W6kr1jrQqVoqfRnN7v/rueIe+KPzTBB4am+gfXES04yP/Bze7AfaPQ 7Ft3VwCeDlCyRxdlLfyPbS/6onl0q+3fnyW48dxS9GOqD+Z4qumPoidp+L7xHrHa6EyT v1/L8+kXD1zMX4zjmfT5o7FlK1SRzN9l2TEFfm7VZkqtX04fCm9u0YsQ1KlI91n3WCD8 JGcQ== X-Gm-Message-State: AA6/9Rm3wtMbmTPZgTLDANH8L60n9lseZOAWmUmr144OD0LljZPWT5tzJjs+MSmcTnV5O7vB X-Received: by 10.28.210.70 with SMTP id j67mr6325382wmg.10.1475271087702; Fri, 30 Sep 2016 14:31:27 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m75sm6072124wmi.0.2016.09.30.14.31.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Sep 2016 14:31:23 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 400543E0507; Fri, 30 Sep 2016 22:31:18 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org, pbonzini@redhat.com Date: Fri, 30 Sep 2016 22:31:02 +0100 Message-Id: <20160930213106.20186-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160930213106.20186-1-alex.bennee@linaro.org> References: <20160930213106.20186-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::233 Subject: [Qemu-devel] [PATCH v3 11/15] qga/command: use QEMU atomic primitives X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mttcg@listserver.greensocs.com, peter.maydell@linaro.org, claudio.fontana@huawei.com, nikunj@linux.vnet.ibm.com, jan.kiszka@siemens.com, mark.burton@greensocs.com, a.rigo@virtualopensystems.com, Michael Roth , cota@braap.org, serge.fdrv@gmail.com, bobby.prani@gmail.com, rth@twiddle.net, =?UTF-8?q?Alex=20Benn=C3=A9e?= , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The guest client's use of the glib's g_atomic primitives causes newer GCC's to barf when built on Travis. As QEMU has its own primitives with well understood semantics we might as well use them. The use of atomics was a little inconsistent so I've also ensure the values are correctly set with atomic primitives at the same time. I also made the usage of bool consistent while I was at it. Signed-off-by: Alex Bennée --- qga/commands.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) -- 2.9.3 diff --git a/qga/commands.c b/qga/commands.c index 50fd26a..edd3e83 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -16,6 +16,7 @@ #include "qapi/qmp/qerror.h" #include "qemu/base64.h" #include "qemu/cutils.h" +#include "qemu/atomic.h" /* Maximum captured guest-exec out_data/err_data - 16MB */ #define GUEST_EXEC_MAX_OUTPUT (16*1024*1024) @@ -82,7 +83,7 @@ struct GuestExecIOData { guchar *data; gsize size; gsize length; - gint closed; + bool closed; bool truncated; const char *name; }; @@ -93,7 +94,7 @@ struct GuestExecInfo { int64_t pid_numeric; gint status; bool has_output; - gint finished; + bool finished; GuestExecIOData in; GuestExecIOData out; GuestExecIOData err; @@ -156,13 +157,13 @@ GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **err) ges = g_new0(GuestExecStatus, 1); - bool finished = g_atomic_int_get(&gei->finished); + bool finished = atomic_mb_read(&gei->finished); /* need to wait till output channels are closed * to be sure we captured all output at this point */ if (gei->has_output) { - finished = finished && g_atomic_int_get(&gei->out.closed); - finished = finished && g_atomic_int_get(&gei->err.closed); + finished = finished && atomic_mb_read(&gei->out.closed); + finished = finished && atomic_mb_read(&gei->err.closed); } ges->exited = finished; @@ -264,7 +265,7 @@ static void guest_exec_child_watch(GPid pid, gint status, gpointer data) (int32_t)gpid_to_int64(pid), (uint32_t)status); gei->status = status; - gei->finished = true; + atomic_mb_set(&gei->finished, true); g_spawn_close_pid(pid); } @@ -320,7 +321,7 @@ static gboolean guest_exec_input_watch(GIOChannel *ch, done: g_io_channel_shutdown(ch, true, NULL); g_io_channel_unref(ch); - g_atomic_int_set(&p->closed, 1); + atomic_mb_set(&p->closed, true); g_free(p->data); return false; @@ -374,7 +375,7 @@ static gboolean guest_exec_output_watch(GIOChannel *ch, close: g_io_channel_shutdown(ch, true, NULL); g_io_channel_unref(ch); - g_atomic_int_set(&p->closed, 1); + atomic_mb_set(&p->closed, true); return false; }