From patchwork Thu Sep 22 10:13:15 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: 76734 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp2512225qgf; Thu, 22 Sep 2016 03:17:08 -0700 (PDT) X-Received: by 10.55.102.15 with SMTP id a15mr1060367qkc.90.1474539428737; Thu, 22 Sep 2016 03:17:08 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id q8si611470qtb.102.2016.09.22.03.17.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 22 Sep 2016 03:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; 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 208.118.235.17 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]:36007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn140-00010M-9r for patch@linaro.org; Thu, 22 Sep 2016 06:17:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn11V-000849-4R for qemu-devel@nongnu.org; Thu, 22 Sep 2016 06:14:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn11S-0006pu-Vy for qemu-devel@nongnu.org; Thu, 22 Sep 2016 06:14:32 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:37118) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn11S-0006pj-Lr for qemu-devel@nongnu.org; Thu, 22 Sep 2016 06:14:30 -0400 Received: by mail-wm0-f54.google.com with SMTP id b130so139479286wmc.0 for ; Thu, 22 Sep 2016 03:14: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=nyu+bQc15ZzePe4k1/9Sr5MiNLwNhBQfrj5esaYGXPY=; b=D+wsJ7uxu/29+lLdJKFNVERtzmcufFfnR7UEDjgy2RZsuadN68NvQsm4PpO3n4LF8p pNc5nBXUu8NIVP5m4ziF5M6d1tmKqVBkWj0WJaioKUC26uXvsqXoptgIkfV/zGqchJii kLC17y9GN5DENs0as/hJSuLVMpEXGoHg/ek4w= 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=d16Mqp25cIS5GruWFsfJ/VixuB7dVnSD7GPHYVjvnBGnTwt6lJm0cA4Q0EtcixGzq4 cuQY3YFXd1EbqoLVZCW/hAGA4JO7ZBauS6epgkbAeHUB+92Jikm5mULlqp1EfjCY1/z+ bHZmO5cttv7bdrcvk5imqRLyeGEWODbKIms42rsnGh2QKt7P6FNimU6nmgWQw1RVbrHn Fo7Mwm7cBtJO6ORwd8Fzbpf7VEoiMw1XRaRWiMwBnsS3qiqgsrXyhQmt0XZbuv4BW/f+ 0cNzcAkd7Dl3jzrpdSWQQ+5tvcC/KxIia2QWnEpsRT2uCm88jlzdslvzYPABHEU5nfxz ZDMQ== X-Gm-Message-State: AE9vXwMfbZHNSoR3sU81X4WcJ7/6XtEP5qHMF+giZFu/+LYBmUXjaeIPItzI2Tk7+27CE5TH X-Received: by 10.28.2.85 with SMTP id 82mr7072895wmc.23.1474539210095; Thu, 22 Sep 2016 03:13:30 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t202sm36820014wmt.22.2016.09.22.03.13.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 03:13:25 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 0F6033E02BC; Thu, 22 Sep 2016 11:13:23 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org, pbonzini@redhat.com, cota@braap.org, stefanha@redhat.com, kwolf@redhat.com Date: Thu, 22 Sep 2016 11:13:15 +0100 Message-Id: <20160922101316.13064-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160922101316.13064-1-alex.bennee@linaro.org> References: <20160922101316.13064-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] [fuzzy] X-Received-From: 74.125.82.54 Subject: [Qemu-devel] [PATCH v2 8/9] 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 , 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; }