Skip to contentSkip to conversation

RFC: libxl: Change hotplug script interface to use physical-device-path

PATCH New Ian Jackson 1 participant 1 message Mar 3, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RFC: libxl: Change hotplug script interface to use physical-device-path

* Change block-common.sh on Linux to write physical-device-path with the path of the device node, rather than physical-device with its major:minor numbers.

* Have the libxl Linux hotplug script scheduler convert this, by reading physical-device-path and writing physical-device. This happens just when we have decided that there is no more script to run.

* When libxl itself writes the device to xenstore, have it write physical-device-path. On Linux this will be converted to physical-device by the new code discussed above.

* Add a note about libxl__device_physdisk_major_minor's poor error handling.

* Add an xxx about the fact that the sharing check in tools/hotplug/Linux/block needs adjusting. Note that WITHOUT THIS OTHER FIX THE CHANGE TO BLOCK-COMMON.SH IS BROKEN. This is one reason this patch is RFC.

* Untested. That is the other reason this patch is RFC. (I have checked that it does compile.)

I wasn't able to find a document describing the hotplug script interface (!) so this patch does not contain docs hunks.

CC George Dunlap <[email protected]>
CC Roger Pau Monne <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/hotplug/Linux/block-common.sh |   19 +++-------
 tools/libxl/libxl.c                 |    5 +--
 tools/libxl/libxl_internal.h        |    1 +
 tools/libxl/libxl_linux.c           |   70 ++++++++++++++++++++++++++++++++++-
 4 files changed, 75 insertions(+), 20 deletions(-)
tools/hotplug/Linux/block-common.sh +5 -14
index ee95009..560f189 100644
@@ -50,23 +50,14 @@ device_major_minor()
 
 
 ##
-# Write physical-device = MM,mm to the store, where MM and mm are the major 
-# and minor numbers of device respectively.
+# Write physical-device-path = "$1"
 #
-# @param device The device from which major and minor numbers are read, which
-#               will be written into the store.
+# @param device The device which will be written into the store.
 #
 write_dev() {
-  local mm
-  
-  mm=$(device_major_minor "$1")
- 
-  if [ -z $mm ]
-  then
-    fatal "Backend device does not exist"
-  fi
- 
-  xenstore_write "$XENBUS_PATH/physical-device" "$mm"
+  xxx check_sharing in block needs fixing too
+
+  xenstore_write "$XENBUS_PATH/physical-device-path" "$1"
 
   success
 }
tools/libxl/libxl.c +1 -4
index 4cdc169..0bcfada 100644
@@ -2450,10 +2450,7 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
                  */
                 if (!disk->script &&
                     disk->backend_domid == LIBXL_TOOLSTACK_DOMID) {
-                    int major, minor;
-                    if (!libxl__device_physdisk_major_minor(dev, &major, &minor))
-                        flexarray_append_pair(back, "physical-device",
-                                              GCSPRINTF("%x:%x", major, minor));
+                    flexarray_append_pair(back, "physical-device-path", dev);
                 }
 
                 assert(device->backend_kind == LIBXL__DEVICE_KIND_VBD);
tools/libxl/libxl_internal.h +1 -0
index 005fe53..ada5f40 100644
@@ -1154,6 +1154,7 @@ _hidden char *libxl__device_disk_string_of_format(libxl_disk_format format);
 _hidden int libxl__device_disk_set_backend(libxl__gc*, libxl_device_disk*);
 
 _hidden int libxl__device_physdisk_major_minor(const char *physpath, int *major, int *minor);
+    /* xxx libxl__device_physdisk_major_minor has irregular error handling */
 _hidden int libxl__device_disk_dev_number(const char *virtpath,
                                           int *pdisk, int *ppartition);
 
tools/libxl/libxl_linux.c +68 -2

83 lines not on this page · raw message

Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel