From patchwork Wed Oct 3 14:36:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 188807 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3963C2C00CF for ; Thu, 4 Oct 2012 01:27:42 +1000 (EST) Received: from localhost ([::1]:57463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJQ5Y-0005zU-0y for incoming@patchwork.ozlabs.org; Wed, 03 Oct 2012 10:38:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJQ4t-0004EP-DB for qemu-devel@nongnu.org; Wed, 03 Oct 2012 10:37:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJQ4s-0000Gr-0c for qemu-devel@nongnu.org; Wed, 03 Oct 2012 10:37:35 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:35087) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJQ4r-0000GD-Qk for qemu-devel@nongnu.org; Wed, 03 Oct 2012 10:37:33 -0400 Received: by padfb10 with SMTP id fb10so6493677pad.4 for ; Wed, 03 Oct 2012 07:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=JUuJb5s/EcPukcFkX7p+7qlncMUetMJxaeJF1BCL3Bw=; b=z5Lb1I/akCYQN8jlYwayp6ETtE2Ugl70PtX2PdBX8OQ98ZuvmGZRnSA3vFVzjUz9bA 6uawK9xxqXzn9lcwJ59uHoFgXCUf5iZLh69lAM7Qu+wBvxwEGD9w/gCkH7if3EsEASRM BPFFp7GTJ7xuvhmY1JvkVegJetDcuNndXu8x+K2yinIMcfl748sLuxcFrauViP23csmf jJ8wvEPKkJM7VGnm7cHxc36rgw84o9Ux+SZFJt7WtuNVHDeEpGQYXcHSqPC2ErjVTG0A +OmjPUp0JVc4csZnJdvqbqHXPIpJs3kx/eXxZwUkp8W51KqTlpVzb8sTJOR+GxGsB78C BX3g== Received: by 10.68.197.104 with SMTP id it8mr13548451pbc.167.1349275053086; Wed, 03 Oct 2012 07:37:33 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id i1sm2566228pay.26.2012.10.03.07.37.30 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 03 Oct 2012 07:37:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2012 16:36:52 +0200 Message-Id: <1349275025-5093-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1349275025-5093-1-git-send-email-pbonzini@redhat.com> References: <1349275025-5093-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.220.45 Cc: lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH 05/18] migration: avoid using error_is_set X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Paolo Bonzini --- migration-tcp.c | 8 +++++--- migration.c | 13 +++++++------ 2 file modificati, 12 inserzioni(+), 9 rimozioni(-) diff --git a/migration-tcp.c b/migration-tcp.c index a15c2b8..78337a3 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -71,14 +71,16 @@ static void tcp_wait_for_connect(int fd, void *opaque) int tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp) { + Error *local_err = NULL; + s->get_error = socket_errno; s->write = socket_write; s->close = tcp_close; - s->fd = inet_nonblocking_connect(host_port, tcp_wait_for_connect, s, - errp); - if (error_is_set(errp)) { + s->fd = inet_nonblocking_connect(host_port, tcp_wait_for_connect, s, &local_err); + if (local_err != NULL) { migrate_fd_error(s); + error_propagate(errp, local_err); return -1; } diff --git a/migration.c b/migration.c index 22a05c4..8a04174 100644 --- a/migration.c +++ b/migration.c @@ -481,6 +481,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, bool has_inc, bool inc, bool has_detach, bool detach, Error **errp) { + Error *local_err = NULL; MigrationState *s = migrate_get_current(); MigrationParams params; const char *p; @@ -506,7 +507,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, s = migrate_init(¶ms); if (strstart(uri, "tcp:", &p)) { - ret = tcp_start_outgoing_migration(s, p, errp); + ret = tcp_start_outgoing_migration(s, p, &local_err); #if !defined(WIN32) } else if (strstart(uri, "exec:", &p)) { ret = exec_start_outgoing_migration(s, p); @@ -520,11 +521,11 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, return; } - if (ret < 0) { - if (!error_is_set(errp)) { - DPRINTF("migration failed: %s\n", strerror(-ret)); - /* FIXME: we should return meaningful errors */ - error_set(errp, QERR_UNDEFINED_ERROR); + if (ret < 0 || local_err) { + if (!local_err) { + error_set_errno(errp, -ret, QERR_UNDEFINED_ERROR); + } else { + error_propagate(errp, local_err); } return; }