From patchwork Fri Oct 19 13:31:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 192728 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 A74252C008F for ; Sat, 20 Oct 2012 01:40:41 +1100 (EST) Received: from localhost ([::1]:38220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPChq-0006OD-Kk for incoming@patchwork.ozlabs.org; Fri, 19 Oct 2012 09:33:42 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPCh8-0004st-NU for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:33:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TPCh4-0006Ij-6A for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:32:58 -0400 Received: from mail-da0-f45.google.com ([209.85.210.45]:53210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPCh4-00061I-0E for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:32:54 -0400 Received: by mail-da0-f45.google.com with SMTP id n15so238415dad.4 for ; Fri, 19 Oct 2012 06:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=2NoExA7YTzvuMDSQ6H74tQR+7arp3dqtyHbxNt3WoV4=; b=DvgTxnKATGF4ekWrdWTIdw/ykyYgX0KHgkhVrHCINEOESRxcTBZTGL29GnaxDSElel icZtEwf/0qWhtP88/V8N9fKyvGXEEAfZvtZD5/XvqV+sN7MsAiwb4kUgK2S0l0TLBnTD ofJR/XGtMWsYMEK+K3wzgRaAkFukirdsdG8iGR3uoOMuqDnbC0TpcPkXCyoLn90d/yAn FEWGiXfC1D6+QQ+wAv7WzLhONJogNZkN9kEH/PEYCSb3ngQT3x6hGXHuEhQMDr7B3YF2 LBJseb3osStbYTZTH7+n3oHvj/YPZ5aKObryOLNnNB2a7NNiF8DvyshuNvRildiNxmqE 0kHQ== Received: by 10.66.75.162 with SMTP id d2mr3965584paw.27.1350653573672; Fri, 19 Oct 2012 06:32:53 -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 kr4sm1240726pbc.76.2012.10.19.06.32.49 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Oct 2012 06:32:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 19 Oct 2012 15:31:44 +0200 Message-Id: <1350653528-5834-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1350653528-5834-1-git-send-email-pbonzini@redhat.com> References: <1350653528-5834-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.210.45 Subject: [Qemu-devel] [PATCH 05/29] migration: avoid using error_is_set and thus relying on errp != NULL 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 The migration code is using errp to detect "internal" errors, this means that it relies on errp being non-NULL. No impact so far because our only QMP clients (the QMP marshaller and HMP) never pass a NULL Error **. But if we had others, this patch would make sure that migration can work with a NULL Error **. 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; }