[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-users] reboot driver domains with auto-reconnect?

reply-to-self update.  ;-)

On Mon, Apr 16, 2018 at 03:58:59PM +0000, Jason Cooper wrote:
> My current dilemma is that I would like to be able to reboot these mini
> VMs for kernel updates, etc.  When this happens, I'd like the previously
> connected VMs to reconnect to the new instance.

Here's the script, to be executed on Dom0, that attempts to do the
reboot of a driver domain, and then re-attach the previously attached
vifs.  I'm only concerned about vifs for now.  vbds will come later.

The reboot portion sucks, I despise random sleeps.  I'd like to trigger
on a xenbus variable to indicate the VM is ready to receive attach

Also, the client VM to the driver-domain needs hotplug enabled, which
makes sense.

Occassionally, I'll get a stale vif in the client VM.  Usually this is
when I was debugging something else, and just needed to reboot the
driver-domain.  I'm hoping those won't occur once I nail down a proper
reboot sequence.  I'll see if I can catch the 'timeout waiting for vif
to detach' error message, which maybe related.


if [ $# -ne 1 ]; then
        echo >&2 "Usage: ${0##*/} domain"
        exit 1


# get the domain id
DOMID="`xl domid $DOM`"
[[ "$DOMID" =~ (^[0-9]+$) ]] || exit 1


# loop through frontends
while read frontend <&4; do
        while read vif <&5; do
                if [ "x$vif" = "x" ]; then
                        # stale frontend
                        echo >&2 "WARN: stale frontend ($frontend), removing"
                        xenstore-rm /local/domain/$DOMID/backend/vif/$frontend

                # store info for afterwards
                front="`xl domname $frontend`"
                echo "$front bridge=$bridge backend=$DOM" >>"$tmp"

                # remove the vif
                xl -f network-detach $front $vif
        done 5< <(xenstore-list /local/domain/$DOMID/backend/vif/$frontend)
done 4< <(xenstore-list /local/domain/$DOMID/backend/vif)

# reboot the domain
xl destroy $DOM || exit 2
sleep 2
xl create -c $DOM || exit 3

if ! [ -e "$tmp" ]; then
        exit 0

# reattach everything
while read ln <&4; do
        echo >&2 "re-attach [$ln]"
        xl network-attach $ln || exit 4
done 4< <(cat $tmp)

rm -f $tmp



Xen-users mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.