[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1 of 2] hotplug: add hotplug-status disconnected
# HG changeset patch # User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> # Date 1316186985 -7200 # Node ID 00949e363f6f2c70001da548403475628df93b97 # Parent 63e254468d6e8d81baeafaed68f05791dc21eb4e hotplug: add hotplug-status disconnected Added hotplug-status disconnected when vbd are removed. Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> diff -r 63e254468d6e -r 00949e363f6f tools/hotplug/Linux/block --- a/tools/hotplug/Linux/block Wed Sep 14 14:18:40 2011 +0200 +++ b/tools/hotplug/Linux/block Fri Sep 16 17:29:45 2011 +0200 @@ -321,6 +321,7 @@ mount it read-write in a guest domain." remove) case $t in phy) + xenstore_write "$XENBUS_PATH/hotplug-status" "disconnected" exit 0 ;; @@ -329,6 +330,7 @@ mount it read-write in a guest domain." node=$(xenstore_read "$XENBUS_PATH/node") losetup -d "$node" release_lock "block" + xenstore_write "$XENBUS_PATH/hotplug-status" "disconnected" exit 0 ;; diff -r 63e254468d6e -r 00949e363f6f tools/hotplug/NetBSD/block --- a/tools/hotplug/NetBSD/block Wed Sep 14 14:18:40 2011 +0200 +++ b/tools/hotplug/NetBSD/block Fri Sep 16 17:29:45 2011 +0200 @@ -19,7 +19,7 @@ error() { xpath=$1 xstatus=$2 -xtype=$(xenstore-read "$xpath/type") +xtype=$3 xparams=$(xenstore-read "$xpath/params") case $xstatus in @@ -38,6 +38,8 @@ 6) echo "unknown type $xtype" >&2 ;; esac + echo xenstore-write $xpath/hotplug-status disconnected + xenstore-write $xpath/hotplug-status disconnected xenstore-rm $xpath exit 0 ;; diff -r 63e254468d6e -r 00949e363f6f tools/xenbackendd/xenbackendd.c --- a/tools/xenbackendd/xenbackendd.c Wed Sep 14 14:18:40 2011 +0200 +++ b/tools/xenbackendd/xenbackendd.c Fri Sep 16 17:29:45 2011 +0200 @@ -89,15 +89,15 @@ dodebug(const char *fmt, ...) } static void -doexec(const char *cmd, const char *arg1, const char *arg2) +doexec(const char *cmd, const char *arg1, const char *arg2, const char *arg3) { - dodebug("exec %s %s %s", cmd, arg1, arg2); + dodebug("exec %s %s %s %s", cmd, arg1, arg2, arg3); switch(vfork()) { case -1: dolog(LOG_ERR, "can't vfork: %s", strerror(errno)); break; case 0: - execl(cmd, cmd, arg1, arg2, NULL); + execl(cmd, cmd, arg1, arg2, arg3, NULL); dolog(LOG_ERR, "can't exec %s: %s", cmd, strerror(errno)); exit(EXIT_FAILURE); /* NOTREACHED */ @@ -145,11 +145,14 @@ xen_setup(void) int main(int argc, char * const argv[]) { + struct stat stab; char **vec; unsigned int num; char *s; int state; char *sstate; + char *stype; + char *params; char *p; char buf[80]; int type; @@ -169,7 +172,7 @@ main(int argc, char * const argv[]) log_file = optarg; break; case 'p': - pidfile = pidfile; + pidfile = optarg; case 's': vbd_script = optarg; break; @@ -297,11 +300,38 @@ main(int argc, char * const argv[]) strerror(errno)); goto next2; } - doexec(s, vec[XS_WATCH_PATH], sstate); + doexec(s, vec[XS_WATCH_PATH], sstate, NULL); break; case DEVTYPE_VBD: - doexec(vbd_script, vec[XS_WATCH_PATH], sstate); + /* check if given file is a block device or a raw image */ + snprintf(buf, sizeof(buf), "%s/params", vec[XS_WATCH_PATH]); + params = xs_read(xs, XBT_NULL, buf, 0); + if(params == NULL) { + dolog(LOG_ERR, + "Failed to read %s (%s)", buf, strerror(errno)); + goto next2; + } + if (stat(params, &stab) < 0) { + dolog(LOG_ERR, + "Failed to get info about %s (%s)", params, + strerror(errno)); + goto next3; + } + stype = NULL; + if (S_ISBLK(stab.st_mode)) + stype = "phy"; + if (S_ISREG(stab.st_mode)) + stype = "file"; + if (stype == NULL) { + dolog(LOG_ERR, + "Failed to attach %s (not a block device or raw image)", + params, strerror(errno)); + goto next3; + } + doexec(vbd_script, vec[XS_WATCH_PATH], sstate, stype); +next3: + free(params); break; default: _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |