From: Marek Marczykowski <marmarek@mimuw.edu.pl>
To: xen-devel@lists.xensource.com
Cc: marmarek@mimuw.edu.pl
Subject: [PATCH 10 of 10] libxl: "script:" prefix in block device description to setup vbd by hotplug scripts
Date: Fri, 03 Jun 2011 00:35:40 +0200 [thread overview]
Message-ID: <1e3bf3cb3944402e01c5.1307054140@devel14> (raw)
In-Reply-To: <patchbomb.1307054130@devel14>
# HG changeset patch
# User Marek Marczykowski <marmarek@mimuw.edu.pl>
# Date 1306963204 -7200
# Node ID 1e3bf3cb3944402e01c57c400a02fe4293153458
# Parent 10bdf8aa5b8a1cb2178f2b9cbcc9ce2fd5644403
libxl: "script:" prefix in block device description to setup vbd by hotplug scripts
Implements old behaviour of block-attach - only write parameters to xenstore
and left all work for hotplug scripts. Allows to directly reuse xen block
scripts (and maybe some custom ones). Example use:
xl block-attach vm "script:nbd 1.1.1.1 9999" xvdg w
Signed-off-by: Marek Marczykowski <marmarek@mimuw.edu.pl>
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -896,6 +896,13 @@
}
}
+ if (disk->backend == DISK_BACKEND_SCRIPT) {
+ delimiter = strchr(file_name, ':');
+ if (!delimiter)
+ return ERROR_INVAL;
+ return 0;
+ }
+
if ( stat(file_name, &stat_buf) != 0 ) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to stat %s", file_name);
return ERROR_INVAL;
@@ -965,6 +972,24 @@
device.backend_kind = DEVICE_VBD;
break;
+ case DISK_BACKEND_SCRIPT:
+ {
+ char *delimiter;
+ backend_type = libxl__strdup(&gc, disk->pdev_path);
+ delimiter = strchr(backend_type, ':');
+ if (!delimiter) {
+ rc = ERROR_FAIL;
+ goto out_free;
+ }
+ *delimiter = '\0';
+ flexarray_append(back, "params");
+ flexarray_append(back, delimiter+1);
+ flexarray_append(back, "scripted");
+ flexarray_append(back, "1");
+
+ device.backend_kind = DEVICE_VBD;
+ }
+ break;
case DISK_BACKEND_TAP:
if (libxl__blktap_enabled(&gc) && disk->format != DISK_FORMAT_EMPTY) {
const char *dev = libxl__blktap_devpath(&gc,
@@ -1060,7 +1085,7 @@
device.backend_domid = disk->backend_domid;
device.backend_devid = devid;
device.backend_kind =
- (disk->backend == DISK_BACKEND_PHY) ? DEVICE_VBD : DEVICE_TAP;
+ (disk->backend == DISK_BACKEND_PHY || disk->backend == DISK_BACKEND_SCRIPT) ? DEVICE_VBD : DEVICE_TAP;
device.domid = disk->domid;
device.devid = devid;
device.kind = DEVICE_VBD;
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -185,6 +185,7 @@
DISK_BACKEND_PHY,
DISK_BACKEND_TAP,
DISK_BACKEND_QDISK,
+ DISK_BACKEND_SCRIPT,
} libxl_disk_backend;
typedef enum {
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -139,6 +139,7 @@
case DISK_BACKEND_QDISK: return "qdisk";
case DISK_BACKEND_TAP: return "tap";
case DISK_BACKEND_PHY: return "phy";
+ case DISK_BACKEND_SCRIPT: return "script";
default: return NULL;
}
}
diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -282,6 +282,8 @@
if (!strcmp(s, "phy")) {
*backend = DISK_BACKEND_PHY;
+ } else if (!strcmp(s, "script")) {
+ *backend = DISK_BACKEND_SCRIPT;
} else if (!strcmp(s, "file")) {
*backend = DISK_BACKEND_TAP;
} else if (!strcmp(s, "tap")) {
@@ -553,8 +555,13 @@
disk->domid = domid;
be_path = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/backend", diskpath));
disk->pdev_path = strdup(libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/params", be_path)));
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/type", be_path));
- libxl_string_to_backend(ctx, val, &(disk->backend));
+ val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/scripted", be_path));
+ if (val && atoi(val))
+ disk->backend = DISK_BACKEND_SCRIPT;
+ else {
+ val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/type", be_path));
+ libxl_string_to_backend(ctx, val, &(disk->backend));
+ }
disk->vdev = strdup(libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/dev", be_path)));
val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/removable", be_path));
disk->unpluggable = !strcmp(val, "1");
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -481,6 +481,10 @@
state = DSTATE_PHYSPATH;
disk->format = DISK_FORMAT_RAW;
disk->backend = DISK_BACKEND_PHY;
+ }else if ( !strcmp(tok, "script") ) {
+ state = DSTATE_PHYSPATH;
+ disk->format = DISK_FORMAT_RAW;
+ disk->backend = DISK_BACKEND_SCRIPT;
}else if ( !strcmp(tok, "file") ) {
state = DSTATE_PHYSPATH;
disk->format = DISK_FORMAT_RAW;
@@ -4435,6 +4439,8 @@
tok = strtok(argv[optind+1], ":");
if (!strcmp(tok, "phy")) {
disk.backend = DISK_BACKEND_PHY;
+ } else if (!strcmp(tok, "script")) {
+ disk.backend = DISK_BACKEND_SCRIPT;
} else if (!strcmp(tok, "file")) {
disk.backend = DISK_BACKEND_TAP;
} else if (!strcmp(tok, "tap")) {
next prev parent reply other threads:[~2011-06-02 22:35 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-02 22:35 [PATCH 00 of 10] A bunch of fixes (and one feature) for libxl Marek Marczykowski
2011-06-02 22:35 ` [PATCH 01 of 10] libxl: Remove frontend and backend devices from xenstore after destroy Marek Marczykowski
2011-06-03 8:03 ` Ian Campbell
2011-06-03 23:30 ` Marek Marczykowski
2011-06-04 6:46 ` Ian Campbell
2011-06-02 22:35 ` [PATCH 02 of 10] libxl: Do not start stubdom when not needed Marek Marczykowski
2011-06-03 8:03 ` Ian Campbell
2011-06-02 22:35 ` [PATCH 03 of 10] libxl: Accept disk name in libxl_devid_to_device_disk Marek Marczykowski
2011-06-03 8:08 ` Ian Campbell
2011-06-02 22:35 ` [PATCH 04 of 10] libxl: Allocate memory for strings in libxl_device_disk Marek Marczykowski
2011-06-03 8:10 ` Ian Campbell
2011-06-02 22:35 ` [PATCH 05 of 10] libxl: Set libxl_device_nic->domid when looking up by devid Marek Marczykowski
2011-06-03 8:11 ` Ian Campbell
2011-06-03 23:24 ` Marek Marczykowski
2011-06-04 6:47 ` Ian Campbell
2011-06-02 22:35 ` [PATCH 06 of 10] xl: Allocate memory for libxl_device_nic string members Marek Marczykowski
2011-06-03 8:13 ` Ian Campbell
2011-06-02 22:35 ` [PATCH 07 of 10] xl: Fix 'script' param parsing in network-attach Marek Marczykowski
2011-06-03 8:16 ` Ian Campbell
2011-06-03 23:49 ` Marek Marczykowski
2011-06-04 8:25 ` Ian Campbell
2011-06-02 22:35 ` [PATCH 08 of 10] xen.lowlevel.xl: Return None on empty domain name Marek Marczykowski
2011-06-03 8:22 ` Ian Campbell
2011-06-02 22:35 ` [PATCH 09 of 10] libxl: Do not SEGV when no 'removable' disk parameter in xenstore Marek Marczykowski
2011-06-02 22:35 ` Marek Marczykowski [this message]
2011-06-03 8:24 ` [PATCH 10 of 10] libxl: "script:" prefix in block device description to setup vbd by hotplug scripts Ian Campbell
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=1e3bf3cb3944402e01c5.1307054140@devel14 \
--to=marmarek@mimuw.edu.pl \
--cc=xen-devel@lists.xensource.com \
/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).