NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: port-xen/48220: xentools-4.1: xl has problems with file/vnd based disks
The following reply was made to PR port-xen/48220; it has been noted by GNATS.
From: Toby Karyadi <toby.karyadi%gmail.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: port-xen/48220: xentools-4.1: xl has problems with file/vnd based
disks
Date: Thu, 19 Sep 2013 14:46:18 -0400
This is a multi-part message in MIME format.
--------------090406040207000003080209
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Here are the patches.
--------------090406040207000003080209
Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
name="patch-libxl_z0-vbd_dtor_fix"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="patch-libxl_z0-vbd_dtor_fix"
This patch corrects libxl__device_destroy() to also handle the case when the
device is already in the XenbusStateClosing state, by adding watch on this
device and letting the caller, libxl__devices_destroy() wait until the device
closes. This would allow xenbackendd to properly call the 'block' script to
undo the vnd device.
--- libxl/libxl_device.c.orig 2013-04-23 12:44:20.000000000 -0400
+++ libxl/libxl_device.c 2013-08-07 23:02:09.000000000 -0400
@@ -249,7 +249,18 @@ int libxl__device_destroy(libxl_ctx *ctx
if (!state)
goto out;
- if (atoi(state) != 4) {
+ switch (atoi(state)) {
+ case 4: /* XenbusStateConnected */
+ break;
+ case 5: /* XenbusStateClosing */
+ /* When the device is already 'closing', skip the code below that
+ * begins at the retry_transaction label that changes the state to
+ * the 'closing' state. If it is not a forced destroy, a watch needs
+ * to be added so that the current device will be waited upon by
+ * libxl__devices_destroy() so that proper cleanup, e.g. by
+ * xenbackendd, can occur. */
+ goto wait;
+ default: /* Presumed 6, XenbusStateClosed */
libxl__device_destroy_tapdisk(&gc, be_path);
xs_rm(ctx->xsh, XBT_NULL, be_path);
goto out;
@@ -267,12 +278,14 @@ retry_transaction:
goto out;
}
}
+
+wait:
if (!force) {
xs_watch(ctx->xsh, state_path, be_path);
rc = 1;
} else {
- xs_rm(ctx->xsh, XBT_NULL, be_path);
- }
+ xs_rm(ctx->xsh, XBT_NULL, be_path);
+ }
out:
libxl__free_all(&gc);
return rc;
--------------090406040207000003080209
Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
name="patch-libxl_z1-vnd_support"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="patch-libxl_z1-vnd_support"
This patch adds support to 'xl' so that it will properly setup a vnd device
for each file based disk defined in the domU configuration file. This would
provide the same behavior in dealing with file based disk as in 'xm' for
NetBSD. This patch won't be needed for xentools >= 4.2, but file based disk
needs to be described as a 'phy' device with a 'script' argument.
Without this patch, xl delegates dealing with file based disk to blktap, and
since it does not exist on NetBSD, it then tries to use qemu-dm, which also
does not work for file based disk on NetBSD, and the domain would just hang.
--- libxl/libxl.h.orig 2011-10-20 13:05:42.000000000 -0400
+++ libxl/libxl.h 2012-05-08 02:17:57.000000000 -0400
@@ -185,6 +185,9 @@
DISK_BACKEND_PHY,
DISK_BACKEND_TAP,
DISK_BACKEND_QDISK,
+#if defined(__NetBSD__)
+ DISK_BACKEND_VND,
+#endif
} libxl_disk_backend;
typedef enum {
--- libxl/libxl.c.orig 2013-04-23 12:44:20.000000000 -0400
+++ libxl/libxl.c 2013-08-08 14:05:30.000000000 -0400
@@ -955,7 +955,21 @@ int libxl_device_disk_add(libxl_ctx *ctx
device.kind = DEVICE_VBD;
switch (disk->backend) {
- case DISK_BACKEND_PHY:
+#if defined(__NetBSD__)
+ case DISK_BACKEND_VND:
+ /* Use bogus device; block script must redefine */
+ major = 2; minor = 12; /* /dev/zero char device */
+
+ flexarray_append(back, "physical-device");
+ flexarray_append(back, libxl__sprintf(&gc, "%x:%x", major,
minor));
+
+ flexarray_append(back, "params");
+ flexarray_append(back, disk->pdev_path);
+
+ device.backend_kind = DEVICE_VBD;
+ break;
+#endif
+ case DISK_BACKEND_PHY:
libxl__device_physdisk_major_minor(disk->pdev_path, &major,
&minor);
flexarray_append(back, "physical-device");
flexarray_append(back, libxl__sprintf(&gc, "%x:%x", major,
minor));
@@ -1059,8 +1073,19 @@ int libxl_device_disk_del(libxl_ctx *ctx
devid = libxl__device_disk_dev_number(disk->vdev);
device.backend_domid = disk->backend_domid;
device.backend_devid = devid;
+#if defined(__NetBSD__)
+ switch (disk->backend) {
+ case DISK_BACKEND_PHY:
+ case DISK_BACKEND_VND:
+ device.backend_kind = DEVICE_VBD;
+ break;
+ default:
+ device.backend_kind = DEVICE_TAP;
+ }
+#else
device.backend_kind =
(disk->backend == DISK_BACKEND_PHY) ? DEVICE_VBD : DEVICE_TAP;
+#endif
device.domid = disk->domid;
device.devid = devid;
device.kind = DEVICE_VBD;
@@ -1078,6 +1103,9 @@ char * libxl_device_disk_local_attach(li
char *ret = NULL;
switch (disk->backend) {
+#if defined(__NetBSD__)
+ case DISK_BACKEND_VND:
+#endif
case DISK_BACKEND_PHY:
if (disk->format != DISK_FORMAT_RAW) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "physical block device must"
--- libxl/libxl_device.c.orig 2012-05-28 00:55:38.000000000 -0400
+++ libxl/libxl_device.c 2012-05-27 23:55:47.000000000 -0400
@@ -139,6 +139,9 @@
case DISK_BACKEND_QDISK: return "qdisk";
case DISK_BACKEND_TAP: return "tap";
case DISK_BACKEND_PHY: return "phy";
+#if defined(__NetBSD__)
+ case DISK_BACKEND_VND: return "file";
+#endif
default: return NULL;
}
}
--- libxl/libxl_dm.c.orig 2011-10-20 13:05:42.000000000 -0400
+++ libxl/libxl_dm.c 2012-05-08 02:17:01.000000000 -0400
@@ -845,6 +845,9 @@
ret = 1;
goto out;
+#if defined(__NetBSD__)
+ case DISK_BACKEND_VND:
+#endif
case DISK_BACKEND_PHY:
case DISK_BACKEND_UNKNOWN:
break;
--- libxl/xl_cmdimpl.c.orig 2011-10-20 13:05:43.000000000 -0400
+++ libxl/xl_cmdimpl.c 2012-05-27 14:39:08.000000000 -0400
@@ -484,7 +484,11 @@
}else if ( !strcmp(tok, "file") ) {
state = DSTATE_PHYSPATH;
disk->format = DISK_FORMAT_RAW;
+#if defined(__NetBSD__)
+ disk->backend = DISK_BACKEND_VND;
+#else
disk->backend = DISK_BACKEND_TAP;
+#endif
}else if ((!strcmp(tok, "tap")) ||
(!strcmp(tok, "tap2"))) {
state = DSTATE_TAP;
@@ -4432,7 +4436,11 @@
if (!strcmp(tok, "phy")) {
disk.backend = DISK_BACKEND_PHY;
} else if (!strcmp(tok, "file")) {
+#if defined(__NetBSD__)
+ disk.backend = DISK_BACKEND_VND;
+#else
disk.backend = DISK_BACKEND_TAP;
+#endif
} else if (!strcmp(tok, "tap")) {
tok = strtok(NULL, ":");
if (!strcmp(tok, "aio")) {
--------------090406040207000003080209--
Home |
Main Index |
Thread Index |
Old Index