WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] The attached patch allows external devices to migrate. T

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] The attached patch allows external devices to migrate. The patch
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 21 Apr 2006 16:42:20 +0000
Delivery-date: Fri, 21 Apr 2006 09:48:28 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 6af7b456e6845ca14362a9e0553d6a6722ba7b6e
# Parent  42358db788fdbf648e9595ed468e7089077fd3a1
The attached patch allows external devices to migrate. The patch
contains code that allows to at least detect local migration of a
virtual machine and handles this for the virtual TPM (results in a no-op
for local migr.). If migration of a virtual machine with attached vTPM
to another machine is attempted, XenD will return an error.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>

diff -r 42358db788fd -r 6af7b456e684 tools/examples/Makefile
--- a/tools/examples/Makefile   Fri Apr 21 10:44:54 2006 +0100
+++ b/tools/examples/Makefile   Fri Apr 21 11:54:12 2006 +0100
@@ -28,9 +28,11 @@ XEN_SCRIPTS += block-enbd block-nbd
 XEN_SCRIPTS += block-enbd block-nbd
 XEN_SCRIPTS += vtpm vtpm-delete
 XEN_SCRIPTS += xen-hotplug-cleanup
+XEN_SCRIPTS += external-device-migrate
 XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh
 XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh
 XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh vtpm-hotplug-common.sh
+XEN_SCRIPT_DATA += vtpm-migration.sh
 
 XEN_HOTPLUG_DIR = /etc/hotplug
 XEN_HOTPLUG_SCRIPTS = xen-backend.agent
diff -r 42358db788fd -r 6af7b456e684 tools/examples/vtpm-common.sh
--- a/tools/examples/vtpm-common.sh     Fri Apr 21 10:44:54 2006 +0100
+++ b/tools/examples/vtpm-common.sh     Fri Apr 21 11:54:12 2006 +0100
@@ -46,6 +46,12 @@ if [ -z "$VTPM_IMPL_DEFINED" ]; then
                true
        }
        function vtpm_delete() {
+               true
+       }
+       function vtpm_migrate() {
+               echo "Error: vTPM migration accross machines not implemented."
+       }
+       function vtpm_migrate_recover() {
                true
        }
 fi
@@ -300,3 +306,62 @@ function vtpm_delete_instance () {
 
        release_lock vtpmdb
 }
+
+# Determine whether the given address is local to this machine
+# Return values:
+#  "-1" : the given machine name is invalid
+#  "0"  : this is not an address of this machine
+#  "1"  : this is an address local to this machine
+function isLocalAddress() {
+       local addr=$(ping $1 -c 1 |  \
+                    gawk '{ print substr($3,2,length($3)-2); exit }')
+       if [ "$addr" == "" ]; then
+               echo "-1"
+               return
+       fi
+       local res=$(ifconfig | grep "inet addr" |  \
+                  gawk -vaddr=$addr               \
+                  '{                              \
+                     if ( addr == substr($2, 6)) {\
+                       print "1";                 \
+                     }                            \
+                  }'                              \
+                 )
+       if [ "$res" == "" ]; then
+               echo "0"
+               return
+       fi
+       echo "1"
+}
+
+# Perform a migration step. This function differentiates between migration
+# to the local host or to a remote machine.
+# Parameters:
+# 1st: destination host to migrate to
+# 2nd: name of the domain to migrate
+# 3rd: the migration step to perform
+function vtpm_migration_step() {
+       local instance=$(vtpmdb_find_instance $2)
+       if [ "$instance" == "" ]; then
+               echo "Error: Translation of domain name ($2) to instance 
failed. Check /etc/xen/vtpm.db"
+               log err "Error during translation of domain name"
+       else
+               res=$(isLocalAddress $1)
+               if [ "$res" == "0" ]; then
+                       vtpm_migrate $1 $2 $3
+               fi
+       fi
+}
+
+# Recover from migration due to an error. This function differentiates
+# between migration to the local host or to a remote machine.
+# Parameters:
+# 1st: destination host the migration was going to
+# 2nd: name of the domain that was to be migrated
+# 3rd: the last successful migration step that was done
+function vtpm_recover() {
+       res=$(isLocalAddress $1)
+       if [ "$res" == "0" ]; then
+               vtpm_migrate_recover $1 $2 $3
+       fi
+}
diff -r 42358db788fd -r 6af7b456e684 tools/examples/external-device-migrate
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/examples/external-device-migrate    Fri Apr 21 11:54:12 2006 +0100
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+# Copyright (c) 2005 IBM Corporation
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+
+
+# This script is called by XenD for migration of external devices
+# It does not handle the migration of those devices itself, but
+# passes the requests on to further applications
+# It handles the low-level command line parsing and some of the
+# synchronization
+
+dir=$(dirname "$0")
+. "$dir/logging.sh"
+
+
+function usage() {
+       echo " Pass the following command line paremeters to the script:"
+       echo ""
+       echo "-step <n>     : n-th migration step"
+       echo "-host <host>  : the destination host"
+       echo "-domname <domain name> : name of the domain that is migrating"
+       echo "-type <device type>    : the type of device that is migrating"
+       echo "-recover               : indicates recovery request; an error"
+       echo "                         occurred during migration"
+       echo "-help                  : display this help screen"
+}
+
+while [ 1 ]; do
+       if [ "$1" == "-step" ]; then
+               shift
+               step=$1
+       elif [ "$1" == "-host" ]; then
+               shift
+               host=$1
+       elif [ "$1" == "-domname" ]; then
+               shift
+               domname=$1
+       elif [ "$1" == "-type" ]; then
+               shift
+               typ=$1
+       elif [ "$1" == "-recover" ]; then
+               recover=1
+       elif [ "$1" == "-help" ]; then
+               usage
+               exit
+       else
+               break
+       fi
+       shift
+done
+
+if [ "$step"    == "" -o \
+     "$host"    == "" -o \
+     "$typ"     == "" -o \
+     "$domname" == "" ]; then
+       echo "Error: Parameter(s) missing (-step/-host/-type/-domname)"
+set
+       echo ""
+       echo "$0 --help for usage."
+       exit
+fi
+
+. "$dir/$typ-migration.sh"
+
+if [ "$recover" == "1" ]; then
+       func="$typ"_recover
+       eval $func $host $domname $step
+else
+       func="$typ"_migration_step
+       eval $func $host $domname $step
+fi
diff -r 42358db788fd -r 6af7b456e684 tools/examples/vtpm-migration.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/examples/vtpm-migration.sh  Fri Apr 21 11:54:12 2006 +0100
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2005 IBM Corporation
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+
+dir=$(dirname "$0")
+. "$dir/vtpm-common.sh"

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] The attached patch allows external devices to migrate. The patch, Xen patchbot -unstable <=