From patchwork Mon Nov 12 14:22:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 198398 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 DA6B42C0080 for ; Tue, 13 Nov 2012 01:24:01 +1100 (EST) Received: from localhost ([::1]:38287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TXuvd-0007zL-QG for incoming@patchwork.ozlabs.org; Mon, 12 Nov 2012 09:23:57 -0500 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) 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=MT970E6s0laGG98Lm1x11SDcM7aC0Qg7f+obJVzzK00=; b=M7uux1IjWrfYVDtRzx0TlCcPcJr5+YYGcxgl8n5Hvb/PUpfdgFx7LwJe+yfgRlOaBb 2IKKE9TQqRLLWl6K/YBTDPId1093MmqN1JJY6qWn4pghKvCivkUBR/OJNRmPSLcRLbbM s6Htme3B+MYlMFpaU6C24Losf7h0QoGkwhoQ0vddHxCFbdrMflkOWRWbRrnWwZKbGnFs 1Ps0gZx7dLgUIOXaVzeFThVVTxQRW4s4b7les0okNvgEdGIACLZ0iWecRjU38nLX+AP7 7qsTRtjcum5vtffuTqv6dCzDw4NoL5/QyVSjTQ+k/CZOSdmYq/uyiVUlqwWAn0Cemn8R uFrg== Received: by 10.68.226.132 with SMTP id rs4mr20234172pbc.162.1352730161150; Mon, 12 Nov 2012 06:22:41 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id vo8sm4271417pbc.16.2012.11.12.06.22.37 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Nov 2012 06:22:39 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 12 Nov 2012 15:22:06 +0100 Message-Id: <1352730127-32685-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1352730127-32685-1-git-send-email-pbonzini@redhat.com> References: <1352730127-32685-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.45 Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 6/7] nbd: disallow nbd-server-add before nbd-server-start 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 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;