From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 10/11] block: Relax bdrv_lookup_bs constraints.
Date: Fri, 14 Feb 2014 18:29:32 +0100 [thread overview]
Message-ID: <1392398973-15092-11-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1392398973-15092-1-git-send-email-stefanha@redhat.com>
From: Benoît Canet <benoit.canet@irqsave.net>
The following patch will reuse bdrv_lookup_bs in order to open images by
references so the rules of usage of bdrv_lookup_bs must be relaxed a bit.
Signed-off-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/block.c b/block.c
index 636aa11..ba2aecf 100644
--- a/block.c
+++ b/block.c
@@ -3574,30 +3574,26 @@ BlockDriverState *bdrv_lookup_bs(const char *device,
{
BlockDriverState *bs = NULL;
- if ((!device && !node_name) || (device && node_name)) {
- error_setg(errp, "Use either device or node-name but not both");
- return NULL;
- }
-
if (device) {
bs = bdrv_find(device);
- if (!bs) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
- return NULL;
+ if (bs) {
+ return bs;
}
-
- return bs;
}
- bs = bdrv_find_node(node_name);
+ if (node_name) {
+ bs = bdrv_find_node(node_name);
- if (!bs) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, node_name);
- return NULL;
+ if (bs) {
+ return bs;
+ }
}
- return bs;
+ error_setg(errp, "Cannot find device=%s nor node_name=%s",
+ device ? device : "",
+ node_name ? node_name : "");
+ return NULL;
}
BlockDriverState *bdrv_next(BlockDriverState *bs)
--
1.8.5.3
next prev parent reply other threads:[~2014-02-14 17:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-14 17:29 [Qemu-devel] [PULL 00/11] Block patches Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 01/11] sdhci: Drop unnecessary #include Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 02/11] blockdev: Remove 'type' parameter from blockdev_init() Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 03/11] block: Add notes to iSCSI's .bdrv_open and .bdrv_reopen_prepare Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 04/11] block: Don't throw away errno via error_setg Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 05/11] block: qemu-iotests - fix test 070 (vhdx) Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 06/11] block: qemu-iotests - add vhdx log replay tests for qemu-img Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 07/11] qemu-iotests: Don't run 005 on vmdk split formats Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 08/11] block: mirror - use local_err to avoid NULL errp Stefan Hajnoczi
2014-02-14 17:29 ` [Qemu-devel] [PULL 09/11] blockdev: Fix wrong usage of QDECREF causing snapshoted quorum to crash on close Stefan Hajnoczi
2014-02-14 17:29 ` Stefan Hajnoczi [this message]
2014-02-14 17:29 ` [Qemu-devel] [PULL 11/11] block: Open by reference will try device then node_name Stefan Hajnoczi
2014-02-15 16:37 ` [Qemu-devel] [PULL 00/11] Block patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1392398973-15092-11-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@amazon.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).