Received: from eggs.gnu.org ([208.118.235.92]:46865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQKIS-00028z-8v for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:52:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQKIR-0001ne-8B for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:52:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48085) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQKIQ-0001nX-Ud for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:52:07 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9MFq6Vl008764 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 22 Oct 2012 11:52:06 -0400 From: Markus Armbruster References: <1350653528-5834-1-git-send-email-pbonzini@redhat.com> <1350653528-5834-9-git-send-email-pbonzini@redhat.com> Date: Mon, 22 Oct 2012 17:52:04 +0200 In-Reply-To: <1350653528-5834-9-git-send-email-pbonzini@redhat.com> (Paolo Bonzini's message of "Fri, 19 Oct 2012 15:31:47 +0200") Message-ID: <87r4oqbj2z.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 08/29] migration (outgoing): add error propagation for all protocols List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org Paolo Bonzini writes: > Error propagation is already there for socket backends. Add it to other > protocols, simplifying code that tests for errors that will never happen. > With all protocols understanding Error, the code can be simplified > further by removing the return value. > > Unfortunately, the quality of error messages varies depending > on where the error is detected, because no Error is passed to the > NonBlockingConnectHandler. Thus, the exact error message still cannot > be sent to the user if the OS reports it asynchronously via SO_ERROR. > If NonBlockingConnectHandler received an Error**, we could for > example report the error class and/or message via a new field of the > query-migration command even if it is reported asynchronously. > > Before: > > (qemu) migrate fd:ffff > migrate: An undefined error has occurred > (qemu) info migrate > (qemu) > > After: > > (qemu) migrate fd:ffff > migrate: File descriptor named 'ffff' has not been found > (qemu) info migrate > capabilities: xbzrle: off > Migration status: failed > total time: 0 milliseconds [...] > diff --git a/migration-fd.c b/migration-fd.c > index 7335167..a7c800a 100644 > --- a/migration-fd.c > +++ b/migration-fd.c > @@ -73,30 +73,19 @@ static int fd_close(MigrationState *s) > return 0; > } > > -int fd_start_outgoing_migration(MigrationState *s, const char *fdname) > +void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp) > { > - s->fd = monitor_get_fd(cur_mon, fdname, NULL); > + s->fd = monitor_get_fd(cur_mon, fdname, errp); > if (s->fd == -1) { > - DPRINTF("fd_migration: invalid file descriptor identifier\n"); > - goto err_after_get_fd; > - } > - > - if (fcntl(s->fd, F_SETFL, O_NONBLOCK) == -1) { > - DPRINTF("Unable to set nonblocking mode on file descriptor\n"); > - goto err_after_open; > + return; > } > > + fcntl(s->fd, F_SETFL, O_NONBLOCK); Sure this can't fail? > s->get_error = fd_errno; > s->write = fd_write; > s->close = fd_close; > > migrate_fd_connect(s); > - return 0; > - > -err_after_open: > - close(s->fd); > -err_after_get_fd: > - return -1; > } > > static void fd_accept_incoming_migration(void *opaque) [...]