All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
	jfehlig@suse.com, Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 3/3] libxl: libxl__device_from_disk should retrieve backend from xenstore
Date: Mon, 9 Feb 2015 13:21:08 +0000	[thread overview]
Message-ID: <1423488068-31268-4-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1423488068-31268-1-git-send-email-wei.liu2@citrix.com>

... if backend is not set by caller.

Also change the function to use "goto" idiom while I was there.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
---
 tools/libxl/libxl.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 01a2d11..56c2e09 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2285,12 +2285,24 @@ int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int devid;
+    int rc;
 
     devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
     if (devid==-1) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Invalid or unsupported"
                " virtual disk identifier %s", disk->vdev);
-        return ERROR_INVAL;
+        rc = ERROR_INVAL;
+        goto out;
+    }
+
+    if (disk->backend == LIBXL_DISK_BACKEND_UNKNOWN) {
+        char *be_path;
+
+        be_path = GCSPRINTF("/local/domain/%u/backend/vbd/%u/%d",
+                            disk->backend_domid,
+                            domid, devid);
+        rc = libxl__disk_backend_from_xs_be(gc, be_path, disk);
+        if (rc) goto out;
     }
 
     device->backend_domid = disk->backend_domid;
@@ -2309,14 +2321,17 @@ int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
         default:
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend type: %d\n",
                        disk->backend);
-            return ERROR_INVAL;
+            rc = ERROR_INVAL;
+            goto out;
     }
 
     device->domid = domid;
     device->devid = devid;
     device->kind  = LIBXL__DEVICE_KIND_VBD;
 
-    return 0;
+    rc = 0;
+out:
+    return rc;
 }
 
 /* Specific function called directly only by local disk attach,
-- 
1.9.1

  parent reply	other threads:[~2015-02-09 13:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-09 13:21 [PATCH 0/3] Misc patches for libxl_device_disk functions Wei Liu
2015-02-09 13:21 ` [PATCH 1/3] libxl, xl: don't init/dispose when not necessary Wei Liu
2015-02-09 13:23   ` Wei Liu
2015-02-09 14:36     ` Wei Liu
2015-02-10 10:54   ` Ian Jackson
2015-02-10 11:39     ` Wei Liu
2015-02-09 13:21 ` [PATCH 2/3] libxl: factor out libxl__disk_backend_from_xs_be Wei Liu
2015-02-10 10:56   ` Ian Jackson
2015-02-10 11:39     ` Wei Liu
2015-02-09 13:21 ` Wei Liu [this message]
2015-02-10 11:01   ` [PATCH 3/3] libxl: libxl__device_from_disk should retrieve backend from xenstore Ian Jackson
2015-02-10 11:49     ` Wei Liu
2015-02-11 17:18       ` Jim Fehlig
2015-02-12 18:35         ` Ian Jackson
2015-02-23 15:13         ` Wei Liu
2015-02-26 23:49           ` Jim Fehlig
2015-03-06 13:04             ` Wei Liu

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=1423488068-31268-4-git-send-email-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jfehlig@suse.com \
    --cc=xen-devel@lists.xen.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.