This patch resurrects
11a63a166. The previous patch had a bug that
wrong "physical-device" was written to xenstore causing block script
execution fail. This patch fixes that problem.
Following configurations have been tested:
1. Raw file and PV
2. Raw file and HVM
3. Block device and PV
4. Block device and HVM
Creation / destruction / local migration all worked.
Original commit message from
11a63a166:
Modify libxl and hotplug script to allow raw format file to use phy
backend.
The block script now tests the path and determine the actual type of
file (block device or regular file) then use the actual type to
determine which branch to run.
With these changes, plus the current ordering of backend preference (phy
> qdisk > tap), we will use phy backend for raw format file by default.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING')
+p=$(xenstore_read "$XENBUS_PATH/params")
+mode=$(xenstore_read "$XENBUS_PATH/mode")
+if [ -b "$p" ]; then
+ truetype="phy"
+elif [ -f "$p" ]; then
+ truetype="file"
+fi
case "$command" in
add)
exit 0
fi
- if [ -n "$t" ]
- then
- p=$(xenstore_read "$XENBUS_PATH/params")
- mode=$(xenstore_read "$XENBUS_PATH/mode")
- fi
FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id")
FRONTEND_UUID=$(xenstore_read_default \
"/local/domain/$FRONTEND_ID/vm" 'unknown')
- case $t in
+ case $truetype in
phy)
dev=$(expand_dev $p)
;;
remove)
- case $t in
+ case $truetype in
phy)
exit 0
;;
if (!disk->script &&
disk->backend_domid == LIBXL_TOOLSTACK_DOMID) {
int major, minor;
- libxl__device_physdisk_major_minor(dev, &major, &minor);
- flexarray_append_pair(back, "physical-device",
- libxl__sprintf(gc, "%x:%x", major, minor));
+ if (!libxl__device_physdisk_major_minor(dev, &major, &minor))
+ flexarray_append_pair(back, "physical-device",
+ libxl__sprintf(gc, "%x:%x", major, minor));
}
assert(device->backend_kind == LIBXL__DEVICE_KIND_VBD);
struct stat buf;
if (stat(physpath, &buf) < 0)
return -1;
+ if (!S_ISBLK(buf.st_mode))
+ return -1;
*major = major(buf.st_rdev);
*minor = minor(buf.st_rdev);
return 0;
int libxl__try_phy_backend(mode_t st_mode)
{
- if (!S_ISBLK(st_mode)) {
- return 0;
+ if (S_ISBLK(st_mode) || S_ISREG(st_mode)) {
+ return 1;
}
- return 1;
+ return 0;
}
#define EXT_SHIFT 28