Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "CA-61230: use the standard upstream backend/hotplug-status=co…

…nnected signal when connecting VBD and VIF devices."

I suspect this has exposed a race in the VIF hotplug scripts (and possibly VBD ones too).

This reverts commit 87075cf.
  • Loading branch information...
commit 1faef0e1be44d8fe90b96eed630d112ffa0f46ca 1 parent faf18f2
@djs55 djs55 authored
View
2  ocaml/xenops/device.ml
@@ -742,7 +742,7 @@ let request_closure ~xs (x: device) =
)
)
-let unplug_watch ~xs (x: device) = Watch.map (fun () -> "") (Watch.key_to_disappear (Hotplug.connected_node ~xs x))
+let unplug_watch ~xs (x: device) = Watch.map (fun () -> "") (Watch.key_to_disappear (Hotplug.status_node x))
let error_watch ~xs (x: device) = Watch.value_to_appear (error_path_of_device ~xs x)
let clean_shutdown ~xs (x: device) =
View
11 ocaml/xenops/hotplug.ml
@@ -61,6 +61,9 @@ let get_private_data_path_of_device (x: device) =
let get_hotplug_path (x: device) =
sprintf "%s/hotplug/%s/%d" (get_private_path x.frontend.domid) (string_of_kind x.backend.kind) x.backend.devid
+(* The path in xenstore written to by the hotplug scripts *)
+let status_node (x: device) = get_hotplug_path x ^ "/hotplug"
+
(* The path in xenstore written to by the frontend hotplug scripts *)
let frontend_status_node (x: device) =
sprintf "%s/frontend/%s/%d/hotplug" (get_private_path x.frontend.domid) (string_of_kind x.frontend.kind) x.frontend.devid
@@ -89,7 +92,7 @@ let blkback_error_node ~xs (x: device) =
(ie not an API-initiated hotunplug; this is start of day) then we check the state
of the backend hotplug scripts. *)
let device_is_online ~xs (x: device) =
- let backend_hotplug () = try xs.Xs.read (connected_node ~xs x) = "connected" with Xb.Noent -> false
+ let backend_hotplug () = try xs.Xs.read (status_node x) = "online" with Xb.Noent -> false
and backend_shutdown () = try ignore(xs.Xs.read (backend_shutdown_done_path_of_device ~xs x)); true with Xb.Noent -> false
and backend_request () = try ignore(xs.Xs.read (backend_shutdown_request_path_of_device ~xs x)); true with Xb.Noent -> false in
@@ -101,7 +104,7 @@ let device_is_online ~xs (x: device) =
then not(backend_shutdown ())
else backend_hotplug ()
-(* Poll a device to see whether it has hotplug-status = connected *)
+(* Poll a device (vif) to see whether it has hotplug-status = connected *)
let device_is_connected ~xs (x: device) =
try
let path = connected_node ~xs x in
@@ -113,7 +116,7 @@ let wait_for_plug ~xs (x: device) =
try
Stats.time_this "udev backend add event"
(fun () ->
- ignore(Watch.wait_for ~xs ~timeout:hotplug_timeout (Watch.value_to_appear (connected_node ~xs x)));
+ ignore(Watch.wait_for ~xs ~timeout:hotplug_timeout (Watch.value_to_appear (status_node x)));
);
debug "Synchronised ok with hotplug script: %s" (string_of_device x)
with Watch.Timeout _ ->
@@ -124,7 +127,7 @@ let wait_for_unplug ~xs (x: device) =
try
Stats.time_this "udev backend remove event"
(fun () ->
- ignore(Watch.wait_for ~xs ~timeout:hotplug_timeout (Watch.key_to_disappear (connected_node ~xs x)));
+ ignore(Watch.wait_for ~xs ~timeout:hotplug_timeout (Watch.key_to_disappear (status_node x)));
);
debug "Synchronised ok with hotplug script: %s" (string_of_device x)
with Watch.Timeout _ ->
View
83 scripts/block
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+TYPE=`echo ${XENBUS_PATH} | cut -f 2 -d '/'`
+DOMID=`echo ${XENBUS_PATH} | cut -f 3 -d '/'`
+DEVID=`echo ${XENBUS_PATH} | cut -f 4 -d '/'`
+
+DEVNAME=$TYPE-$DOMID-$DEVID
+
+SYSFS_PATH=/sys/devices/xen-backend/$DEVNAME
+
+XAPI=/xapi/${DOMID}/hotplug/${TYPE}/${DEVID}
+
+HOTPLUG="${XAPI}/hotplug"
+
+KTHREAD_PID="${XENBUS_PATH}/kthread-pid"
+
+PAUSE="${XENBUS_PATH}/pause"
+PAUSE_DONE="${XENBUS_PATH}/pause-done"
+
+SHUTDOWN="${XENBUS_PATH}/shutdown-request"
+SHUTDOWN_DONE="${XENBUS_PATH}/shutdown-done"
+
+syslog ()
+{
+ logger -pdaemon.info -tscripts-block -- "$DEVNAME[$ACTION]: $*"
+}
+
+case "$ACTION" in
+add)
+ syslog "writing $HOTPLUG = online"
+ xenstore write "$HOTPLUG" "online"
+
+ # RUNNING (1<<0)
+ # PAUSE_DONE (1<<1)
+ # SHUTDOWN_DONE (1<<2)
+ # PAUSE_REQUEST (1<<3)
+ # SHUTDOWN_REQUEST (1<<4)
+
+ # echo $(((1<<1) | (1<<3))) > $SYSFS_PATH/queue_events # unpaused|paused
+ ;;
+
+change)
+ if pid=$(xenstore read "$KTHREAD_PID" 2>/dev/null)
+ then
+ state=running
+ else
+ state=stopped
+ fi
+
+ syslog "kthread-pid = '$pid'"
+
+ case "$state" in
+ stopped)
+ if xenstore exists "$PAUSE"
+ then
+ syslog "writing $PAUSE_DONE"
+ xenstore write "$PAUSE_DONE" ""
+ fi
+ if xenstore exists "$SHUTDOWN"
+ then
+ syslog "writing $SHUTDOWN_DONE"
+ xenstore write "$SHUTDOWN_DONE" ""
+ fi
+ ;;
+ running)
+ if xenstore exists "$PAUSE_DONE"
+ then
+ syslog "removing $PAUSE_DONE"
+ xenstore rm "$PAUSE_DONE"
+ fi
+ if xenstore exists "$SHUTDOWN_DONE"
+ then
+ syslog "WARNING: queue restart in shutdown state."
+ fi
+ ;;
+ esac
+ ;;
+
+remove)
+ syslog "removing $HOTPLUG"
+ xenstore rm "$HOTPLUG"
+ ;;
+esac
View
10 scripts/vif
@@ -221,7 +221,6 @@ esac
XAPI=/xapi/${DOMID}/hotplug/vif/${DEVID}
HOTPLUG=/xapi/${DOMID}/hotplug/vif/${DEVID}
PRIVATE=/xapi/${DOMID}/private/vif/${DEVID}
-HOTPLUG_STATUS="${XENBUS_PATH}/hotplug-status"
logger -t scripts-vif "Called as \"$@\" domid:$DOMID devid:$DEVID mode:$NETWORK_MODE"
case "${ACTION}" in
@@ -238,12 +237,11 @@ online)
add_to_bridge
handle_promiscuous
- # only for the benefit of xenrt test case, see CA-61528
xenstore-write "${HOTPLUG}/vif" "${dev}"
xenstore-write "${HOTPLUG}/hotplug" "online"
- logger -t script-vif "${dev}: writing ${HOTPLUG_STATUS}=connected"
- xenstore-write "${HOTPLUG_STATUS}" "connected"
+ # xs-xen.pq.hq:91e986b8e49f netback-wait-for-hotplug
+ xenstore-write "/local/domain/0/backend/vif/${DOMID}/${DEVID}/hotplug-status" "connected"
call_hook_script $DOMID "${ACTION}"
fi
;;
@@ -256,12 +254,8 @@ add)
remove)
if [ "${TYPE}" = "vif" ] ;then
- # only for the benefit of xenrt test case, see CA-61528
xenstore-rm "${HOTPLUG}/hotplug"
-
call_hook_script $DOMID "${ACTION}"
- logger -t script-vif "${dev}: removing ${HOTPLUG_STATUS}"
- xenstore-rm "${HOTPLUG_STATUS}"
fi
logger -t scripts-vif "${dev} has been removed"
remove_from_bridge
Please sign in to comment.
Something went wrong with that request. Please try again.