From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TXuuS-0004vz-Pc for qemu-devel@nongnu.org; Mon, 12 Nov 2012 09:22:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TXuuP-0003pI-LT for qemu-devel@nongnu.org; Mon, 12 Nov 2012 09:22:44 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:64449) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TXuuP-0003mX-FP for qemu-devel@nongnu.org; Mon, 12 Nov 2012 09:22:41 -0500 Received: by mail-pa0-f45.google.com with SMTP id fb10so4204030pad.4 for ; Mon, 12 Nov 2012 06:22:41 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 12 Nov 2012 15:22:06 +0100 Message-Id: <1352730127-32685-7-git-send-email-pbonzini@redhat.com> In-Reply-To: <1352730127-32685-1-git-send-email-pbonzini@redhat.com> References: <1352730127-32685-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 6/7] nbd: disallow nbd-server-add before nbd-server-start List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com It works nicely with the QMP commands, but it adds useless complication with HMP. In particular, see the following: (qemu) nbd_server_add -w scsi0-hd0 (qemu) nbd_server_start -a localhost:10809 NBD server already exporting device scsi0-hd0 Signed-off-by: Paolo Bonzini --- blockdev-nbd.c | 5 +++++ 1 file modificato, 5 inserzioni(+) diff --git a/blockdev-nbd.c b/blockdev-nbd.c index e362572..d1721a3 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -82,6 +82,11 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable, NBDExport *exp; NBDCloseNotifier *n; + if (server_fd == -1) { + error_setg(errp, "NBD server not running"); + return; + } + if (nbd_export_find(device)) { error_setg(errp, "NBD server already exporting device '%s'", device); return; -- 1.7.12.1