Received: from eggs.gnu.org ([2001:4830:134:3::10]:42558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUDNT-0005bB-AV for qemu-devel@nongnu.org; Mon, 01 Aug 2016 09:35:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUDNP-0002Cl-0u for qemu-devel@nongnu.org; Mon, 01 Aug 2016 09:35:31 -0400 From: Alberto Garcia In-Reply-To: <1468502894-18098-3-git-send-email-kwolf@redhat.com> References: <1468502894-18098-1-git-send-email-kwolf@redhat.com> <1468502894-18098-3-git-send-email-kwolf@redhat.com> Date: Mon, 01 Aug 2016 15:35:13 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 02/11] block: Accept node-name for block-commit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: mreitz@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org On Thu 14 Jul 2016 03:28:05 PM CEST, Kevin Wolf wrote: > - blk = blk_by_name(device); > - if (!blk) { > - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, > - "Device '%s' not found", device); > + bs = qmp_get_root_bs(device, &local_err); > + if (!bs) { > + bs = bdrv_lookup_bs(device, device, NULL); > + if (!bs) { > + error_free(local_err); > + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, > + "Device '%s' not found", device); > + } else { > + error_propagate(errp, local_err); > + } > return; It seems that you're calling bdrv_lookup_bs() here twice, once in qmp_get_root_bs() and then again directly. If the purpose is to see whether the error is "device not found" or "device is not a root node" I think the code would be clearer if you do everything here. On a related note, you're keeping the DeviceNotFound error here, but not in block-stream. Wouldn't it be better to keep both APIs consistent? Berto