[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
events.

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.

------------------>8-----------------------------------------------
#!/bin/bash

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

DOM="$1"

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

tmp="`mktemp`"

# 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
                        continue
                fi

                # store info for afterwards
                front="`xl domname $frontend`"
                bridge="`xenstore-read 
/local/domain/$DOMID/backend/vif/$frontend/$vif/bridge`"
                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
fi

# 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
------------------>8-----------------------------------------------

thx,

Jason.

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-users

 


Rackspace

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