|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3/3] libxl: libxl__device_from_disk should retrieve backend from xenstore
... 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@xxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
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
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |