All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit.canet@irqsave.net>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, "Benoît Canet" <benoit.canet@irqsave.net>,
	"Benoit Canet" <benoit@irqsave.net>,
	mreitz@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] block: Relax bdrv_lookup_bs constraints.
Date: Wed, 12 Feb 2014 17:15:06 +0100	[thread overview]
Message-ID: <1392221707-12916-2-git-send-email-benoit.canet@irqsave.net> (raw)
In-Reply-To: <1392221707-12916-1-git-send-email-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>
---
 block.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/block.c b/block.c
index 3843f59..5ca901b 100644
--- a/block.c
+++ b/block.c
@@ -3579,30 +3579,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.3.2

  reply	other threads:[~2014-02-12 16:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12 16:15 [Qemu-devel] [PATCH 0/2] Make open by reference use id then node-name Benoît Canet
2014-02-12 16:15 ` Benoît Canet [this message]
2014-02-13 18:53   ` [Qemu-devel] [PATCH 1/2] block: Relax bdrv_lookup_bs constraints Max Reitz
2014-02-12 16:15 ` [Qemu-devel] [PATCH 2/2] block: Open by reference will try device then node_name Benoît Canet
2014-02-13 18:54   ` Max Reitz
2014-02-14  9:57 ` [Qemu-devel] [PATCH 0/2] Make open by reference use id then node-name Kevin Wolf
2014-02-14 16:03 ` Stefan Hajnoczi

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=1392221707-12916-2-git-send-email-benoit.canet@irqsave.net \
    --to=benoit.canet@irqsave.net \
    --cc=benoit@irqsave.net \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.