From 8a7acc07c5ff9dd576d65a5a926cc8865bd83d50e4ca4859bf8e0e52f84fb54e Mon Sep 17 00:00:00 2001 From: Charles Arnold Date: Wed, 16 Sep 2009 22:29:21 +0000 Subject: [PATCH 1/7] - bnc#513921 - Xen doesn't work get an eror when starting the install processes or starting a pervious installed DomU 20125-xc-parse-tuple-fix.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=16 --- 20125-xc-parse-tuple-fix.patch | 45 ++++++++++++++++++++++++++++++++++ xen.changes | 7 ++++++ xen.spec | 2 +- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 20125-xc-parse-tuple-fix.patch diff --git a/20125-xc-parse-tuple-fix.patch b/20125-xc-parse-tuple-fix.patch new file mode 100644 index 0000000..45e18bc --- /dev/null +++ b/20125-xc-parse-tuple-fix.patch @@ -0,0 +1,45 @@ +# HG changeset patch +# User Keir Fraser +# Date 1251297719 -3600 +# Node ID ed672a604cc7d0acb9418b29cdc3d65ea84543e8 +# Parent 71389988f5d4e6417f7da1d86da984acd5118efc +xend: Do not pass pointer to a 16-bit domid_t to PyArg_ParseTuple() +when it expects a full integer. + +Signed-off-by: Keir Fraser + +diff -r 71389988f5d4 -r ed672a604cc7 tools/python/xen/lowlevel/xc/xc.c +--- a/tools/python/xen/lowlevel/xc/xc.c Wed Aug 26 15:35:14 2009 +0100 ++++ b/tools/python/xen/lowlevel/xc/xc.c Wed Aug 26 15:41:59 2009 +0100 +@@ -654,10 +654,9 @@ + static PyObject *pyxc_get_device_group(XcObject *self, + PyObject *args) + { +- domid_t domid; + uint32_t bdf = 0; + uint32_t max_sdevs, num_sdevs; +- int seg, bus, dev, func, rc, i; ++ int domid, seg, bus, dev, func, rc, i; + PyObject *Pystr; + char *group_str; + char dev_str[9]; +@@ -812,7 +811,7 @@ + static PyObject *pyxc_dom_set_policy_cpuid(XcObject *self, + PyObject *args) + { +- domid_t domid; ++ int domid; + + if ( !PyArg_ParseTuple(args, "i", &domid) ) + return NULL; +@@ -828,9 +827,8 @@ + static PyObject *pyxc_dom_set_cpuid(XcObject *self, + PyObject *args) + { +- domid_t domid; + PyObject *sub_input, *config; +- unsigned int input[2]; ++ unsigned int domid, input[2]; + char *regs[4], *regs_transform[4]; + + if ( !PyArg_ParseTuple(args, "IIOO", &domid, diff --git a/xen.changes b/xen.changes index a09f056..10a35cc 100644 --- a/xen.changes +++ b/xen.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Sep 15 09:32:59 MDT 2009 - jfehlig@novell.com + +- bnc#513921 - Xen doesn't work get an eror when starting the + install processes or starting a pervious installed DomU + 20125-xc-parse-tuple-fix.patch + ------------------------------------------------------------------- Mon Aug 24 10:31:36 MDT 2009 - carnold@novell.com diff --git a/xen.spec b/xen.spec index 9822c7b..ac1adef 100644 --- a/xen.spec +++ b/xen.spec @@ -176,7 +176,7 @@ Patch450: disable_emulated_device.diff Patch500: hv_tools.patch Patch501: hv_xen_base.patch Patch502: hv_xen_extension.patch -Patch503: hv_win7_eoi_bug.patch +Patch503: hv_win7_eoi_bug.patch Patch999: tmp_build.patch Url: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/ BuildRoot: %{_tmppath}/%{name}-%{version}-build From 89e0f7ea01455990d919869d2bffb33adfbed6b05138cf7797a88ee6d7249683 Mon Sep 17 00:00:00 2001 From: Charles Arnold Date: Mon, 21 Sep 2009 20:39:38 +0000 Subject: [PATCH 2/7] Include 20125-xc-parse-tuple-fix.patch in spec file. OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=17 --- xen.spec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen.spec b/xen.spec index ac1adef..7d8c942 100644 --- a/xen.spec +++ b/xen.spec @@ -1,5 +1,5 @@ # -# spec file for package xen (Version 3.4.1_19718_02) +# spec file for package xen (Version 3.4.1_19718_03) # # Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -37,7 +37,7 @@ BuildRequires: glibc-32bit glibc-devel-32bit %if %{?with_kmp}0 BuildRequires: kernel-source kernel-syms module-init-tools xorg-x11 %endif -Version: 3.4.1_19718_02 +Version: 3.4.1_19718_03 Release: 1 License: GPL v2 only Group: System/Kernel @@ -79,6 +79,7 @@ Patch5: 20077-x86-runstate-cswitch-out.patch Patch6: 20078-x86_64-branch-emulation.patch Patch7: 20101-hvm-no-compat-virt-start.patch Patch8: 20112-x86-dom0-boot-run-timers.patch +Patch9: 20125-xc-parse-tuple-fix.patch # Our patches Patch100: xen-config.diff Patch101: xend-config.diff @@ -519,6 +520,7 @@ Authors: %patch6 -p1 %patch7 -p1 %patch8 -p1 +%patch9 -p1 %patch100 -p1 %patch101 -p1 %patch102 -p1 From 4cd9a5333f41e25ca389e06ff65b0882006af7744bbc9bd27086c803c9eb6027 Mon Sep 17 00:00:00 2001 From: Charles Arnold Date: Fri, 25 Sep 2009 21:00:16 +0000 Subject: [PATCH 3/7] Updated patches from Kong Wei OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=18 --- bdrv_open2_fix_flags.patch | 2 +- ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bdrv_open2_fix_flags.patch b/bdrv_open2_fix_flags.patch index aa6ae44..497d403 100644 --- a/bdrv_open2_fix_flags.patch +++ b/bdrv_open2_fix_flags.patch @@ -19,7 +19,7 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/block.c - RDONLY as fallback */ if (!(flags & BDRV_O_FILE)) - open_flags = BDRV_O_RDWR | (flags & BDRV_O_CACHE_MASK); -+ open_flags = flags & BDRV_O_CACHE_MASK; ++ open_flags = flags; else open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); + if (!(open_flags & BDRV_O_RDWR)) diff --git a/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch b/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch index 63d06d1..5b63f5e 100644 --- a/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch +++ b/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch @@ -26,7 +26,7 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/block-qcow2.c for (i = 0; i < j; i++) - free_any_clusters(bs, old_cluster[i], 1); -+ free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1); ++ free_any_clusters(bs, be64_to_cpu(old_cluster[i]) & ~QCOW_OFLAG_COPIED, 1); ret = 0; err: From ca881773dc8b6b41047a01032758dcccef9cb3dcbca2ec326151f3644158d47b Mon Sep 17 00:00:00 2001 From: Charles Arnold Date: Fri, 25 Sep 2009 21:48:45 +0000 Subject: [PATCH 4/7] - Add temporary workaround for race between xend writing and qemu-dm reading from xenstore. The issue is preventing PV domUs from booting as they have no backend console. qemu-retry-be-status.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=19 --- qemu-retry-be-status.patch | 40 ++++++++++++++++++++++++++++++++++++++ xen.changes | 8 ++++++++ xen.spec | 2 ++ 3 files changed, 50 insertions(+) create mode 100644 qemu-retry-be-status.patch diff --git a/qemu-retry-be-status.patch b/qemu-retry-be-status.patch new file mode 100644 index 0000000..a215846 --- /dev/null +++ b/qemu-retry-be-status.patch @@ -0,0 +1,40 @@ +Index: xen-3.4.1-testing/tools/ioemu-remote/hw/xen_backend.c +=================================================================== +--- xen-3.4.1-testing.orig/tools/ioemu-remote/hw/xen_backend.c ++++ xen-3.4.1-testing/tools/ioemu-remote/hw/xen_backend.c +@@ -377,8 +377,12 @@ static int xen_be_try_init(struct XenDev + int rc = 0; + + if (!xendev->online) { +- xen_be_printf(xendev, 1, "not online\n"); +- return -1; ++ sleep(3); ++ xenstore_read_be_int(xendev, "online", &xendev->online); ++ if (!xendev->online) { ++ xen_be_printf(xendev, 1, "not online\n"); ++ return -1; ++ } + } + + if (xendev->ops->init) +Index: xen-3.4.1-testing/tools/ioemu-remote/hw/xen_console.c +=================================================================== +--- xen-3.4.1-testing.orig/tools/ioemu-remote/hw/xen_console.c ++++ xen-3.4.1-testing/tools/ioemu-remote/hw/xen_console.c +@@ -196,9 +196,14 @@ static int con_init(struct XenDevice *xe + + type = xenstore_read_str(con->console, "type"); + if (!type || 0 != strcmp(type, "ioemu")) { +- xen_be_printf(xendev, 1, "not for me (type=%s)\n", type); +- return -1; ++ sleep(3); ++ type = xenstore_read_str(con->console, "type"); ++ if (!type || 0 != strcmp(type, "ioemu")) { ++ xen_be_printf(xendev, 1, "not for me (type=%s)\n", type); ++ return -1; ++ } + } ++ qemu_free(type); + + if (!serial_hds[con->xendev.dev]) + xen_be_printf(xendev, 1, "WARNING: serial line %d not configured\n", diff --git a/xen.changes b/xen.changes index 10a35cc..a3a5c03 100644 --- a/xen.changes +++ b/xen.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Fri Sep 25 15:08:12 MDT 2009 - jfehlig@novell.com + +- Add temporary workaround for race between xend writing and + qemu-dm reading from xenstore. The issue is preventing PV + domUs from booting as they have no backend console. + qemu-retry-be-status.patch + ------------------------------------------------------------------- Tue Sep 15 09:32:59 MDT 2009 - jfehlig@novell.com diff --git a/xen.spec b/xen.spec index 7d8c942..dcd70ed 100644 --- a/xen.spec +++ b/xen.spec @@ -170,6 +170,7 @@ Patch404: pvdrv_emulation_control.patch Patch405: blktap-pv-cdrom.patch Patch406: network-nat-open-SuSEfirewall2-FORWARD.patch Patch407: ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch +Patch408: qemu-retry-be-status.patch %if %{?with_kmp}0 Patch450: disable_emulated_device.diff %endif @@ -602,6 +603,7 @@ Authors: %patch405 -p1 %patch406 -p1 %patch407 -p1 +%patch408 -p1 %if %{?with_kmp}0 %patch450 -p1 %endif From 5ae0b92ca434577a47ce00224f5b980eb21eed890b7dfebfdbcac74a2ea19d0d Mon Sep 17 00:00:00 2001 From: Charles Arnold Date: Fri, 25 Sep 2009 21:54:51 +0000 Subject: [PATCH 5/7] - bnc#520234 - npiv does not work with XEN Update block-npiv - bnc#496033 - Support for creating NPIV ports without starting vm block-npiv-common.sh block-npiv-vport Update block-npiv - bnc#500043 - Fix access to NPIV disk from HVM vm Update xen-qemu-iscsi-fix.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=20 --- block-npiv | 199 +------------------------------- block-npiv-common.sh | 238 +++++++++++++++++++++++++++++++++++++++ block-npiv-vport | 79 +++++++++++++ xen-qemu-iscsi-fix.patch | 6 +- xen.changes | 8 ++ xen.spec | 6 +- 6 files changed, 333 insertions(+), 203 deletions(-) create mode 100644 block-npiv-common.sh create mode 100644 block-npiv-vport diff --git a/block-npiv b/block-npiv index 34c4792..9f69bac 100644 --- a/block-npiv +++ b/block-npiv @@ -3,209 +3,12 @@ # Usage: block-npiv [add npiv | remove dev] dir=$(dirname "$0") +. "$dir/block-npiv-common.sh" . "$dir/block-common.sh" #set -x #command=$1 -# Look for the NPIV vport with the WWPN -# $1 contains the WWPN (assumes it does not contain a leading "0x") -find_vhost() -{ - unset vhost - - # look in upstream locations - for fchost in /sys/class/fc_vports/* ; do - if test -e $fchost/port_name ; then - wwpn=`cat $fchost/port_name | sed -e s/^0x//` - if test $wwpn = $1 ; then - # Note: makes the assumption the vport will always have an scsi_host child - vhost=`ls -d $fchost/device/host*` - vhost=`basename $vhost` - return - fi - fi - done - - # look in vendor-specific locations - - # Emulex - just looks like another scsi_host - so look at fc_hosts... - for fchost in /sys/class/fc_host/* ; do - if test -e $fchost/port_name ; then - wwpn=`cat $fchost/port_name | sed -e s/^0x//` - if test $wwpn = $1 ; then - # Note: makes the assumption the vport will always have an scsi_host child - vhost=`basename $fchost` - return - fi - fi - done -} - - -# Create a NPIV vport on the fabric w/ FABRICNM, with WWPN,WWNN -# $1 contains FABRICNM -# $2 contains the VPORT WWPN -# $3 contains the VPORT WWNN -# (assumes no name contains a leading "0x") -create_vport() -{ - # find a base adapter with npiv support that is on the right fabric - - # Look via upstream interfaces - for fchost in /sys/class/fc_host/* ; do - if test -e $fchost/vport_create ; then - # is the link up, w/ NPIV support ? - pstate=`cat $fchost/port_state` - ptype=`cat $fchost/port_type | cut -c 1-5` - fname=`cat $fchost/fabric_name | sed -e s/^0x//` - if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then - vmax=`cat $fchost/max_npiv_vports` - vinuse=`cat $fchost/npiv_vports_inuse` - avail=`expr $vmax - $vinuse` - if [ $avail -gt 0 ] ; then - # create the vport - echo $2":"$3 > $fchost/vport_create - if [ $? -eq 0 ] ; then - return 0 - fi - # failed - so we'll just look for the next adapter - fi - fi - fi - done - - # Look in vendor-specific locations - - # Emulex: interfaces mirror upstream, but are under adapter scsi_host - for shost in /sys/class/scsi_host/* ; do - if [ -e $shost/vport_create ] ; then - fchost=`ls -d $shost/device/fc_host*` - # is the link up, w/ NPIV support ? - pstate=`cat $fchost/port_state` - ptype=`cat $fchost/port_type | cut -c 1-5` - fname=`cat $fchost/fabric_name | sed -e s/^0x//` - if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then - vmax=`cat $shost/max_npiv_vports` - vinuse=`cat $shost/npiv_vports_inuse` - avail=`expr $vmax - $vinuse` - if [ $avail -gt 0 ] ; then - # create the vport - echo $2":"$3 > $shost/vport_create - if [ $? -eq 0 ] ; then - return 0 - fi - # failed - so we'll just look for the next adapter - fi - fi - fi - done - - return 1 -} - - -# Look for the LUN on the indicated scsi_host (which is an NPIV vport) -# $1 is the scsi_host name (normalized to simply the hostX name) -# $2 is the WWPN of the tgt port the lun is on -# Note: this implies we don't support a multipath'd lun, or we -# are explicitly identifying a "path" -# $3 is the LUN number of the scsi device -find_sdev() -{ - unset dev - hostno=${1/*host/} - for sdev in /sys/class/scsi_device/${hostno}:*:$3 ; do - if test -e $sdev/device/../fc_trans*/port_name ; then - tgtwwpn=`cat $sdev/device/../fc_trans*/port_name | sed -e s/^0x//` - if test $tgtwwpn = $2 ; then - if test -e $sdev/device/block* ; then - dev=`readlink $sdev/device/block*` - dev=${dev##*/} - return - fi - fi - fi - done -} - - -# Look for the NPIV vhost based on a scsi "sdX" name -# $1 is the "sdX" name -find_vhost_from_dev() -{ - unset vhost - hostno=`readlink /sys/block/$1/device` - hostno=${hostno##*/} - hostno=${hostno%%:*} - if test -z "$hostno" ; then return; fi - vhost="host"$hostno -} - - -# We're about to terminate a vhost based on a scsi device -# Flush all nodes on that vhost as they are about to go away -# $1 is the vhost -flush_nodes_on_vhost() -{ - if test ! -x /sbin/blockdev ; then return; fi - hostno=${1/*host/} - for sdev in /sys/class/scsi_device/${hostno}:* ; do - if test -e $sdev/device/block* ; then - dev=`readlink $sdev/device/block*` - dev=${dev##*/} - dev="/dev/"$dev - if test -n "$dev"; then - blockdev --flushbufs $dev - fi - fi - done -} - - -# Terminate a NPIV vhost -# $1 is vhost -delete_vhost() -{ - # use upstream interface - for vport in /sys/class/fc_vports/* ; do - if test -e $vport/device/$1 ; then - if test -e $vport/vport_delete ; then - echo "1" > $vport/vport_delete - if test $? -ne 0 ; then exit 6; fi - sleep 4 - return - fi - fi - done - - # use vendor specific interface - - # Emulex - if test -e /sys/class/fc_host/$1/device/../scsi_host*/lpfc_drvr_version ; then - shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` - vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` - vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` - echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete - if test $? -ne 0 ; then exit 6; fi - sleep 4 - return - fi - - # Qlogic - if test -e /sys/class/fc_host/$1/device/../scsi_host*/driver_version ; then - shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` - vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` - vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` - echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete - if test $? -ne 0 ; then exit 6; fi - sleep 4 - return - fi - - exit 6 -} - case "$command" in add) # Params is one big arg, with fields separated by hyphens: diff --git a/block-npiv-common.sh b/block-npiv-common.sh new file mode 100644 index 0000000..5a3d805 --- /dev/null +++ b/block-npiv-common.sh @@ -0,0 +1,238 @@ + + +# Look for the NPIV vport with the WWPN +# $1 contains the WWPN (assumes it does not contain a leading "0x") +find_vhost() +{ + unset vhost + + # look in upstream locations + for fchost in /sys/class/fc_vports/* ; do + if test -e $fchost/port_name ; then + wwpn=`cat $fchost/port_name | sed -e s/^0x//` + if test $wwpn = $1 ; then + # Note: makes the assumption the vport will always have an scsi_host child + vhost=`ls -d $fchost/device/host*` + vhost=`basename $vhost` + return + fi + fi + done + + # look in vendor-specific locations + + # Emulex - just looks like another scsi_host - so look at fc_hosts... + for fchost in /sys/class/fc_host/* ; do + if test -e $fchost/port_name ; then + wwpn=`cat $fchost/port_name | sed -e s/^0x//` + if test $wwpn = $1 ; then + # Note: makes the assumption the vport will always have an scsi_host child + vhost=`basename $fchost` + return + fi + fi + done +} + + +# Create a NPIV vport on the fabric w/ FABRICNM, with WWPN,WWNN +# $1 contains FABRICNM +# $2 contains the VPORT WWPN +# $3 contains the VPORT WWNN +# (assumes no name contains a leading "0x") +create_vport() +{ + # find a base adapter with npiv support that is on the right fabric + + # Look via upstream interfaces + for fchost in /sys/class/fc_host/* ; do + if test -e $fchost/vport_create ; then + # is the link up, w/ NPIV support ? + pstate=`cat $fchost/port_state` + ptype=`cat $fchost/port_type | cut -c 1-5` + fname=`cat $fchost/fabric_name | sed -e s/^0x//` + if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then + vmax=`cat $fchost/max_npiv_vports` + vinuse=`cat $fchost/npiv_vports_inuse` + avail=`expr $vmax - $vinuse` + if [ $avail -gt 0 ] ; then + # create the vport + echo $2":"$3 > $fchost/vport_create + if [ $? -eq 0 ] ; then + return 0 + fi + # failed - so we'll just look for the next adapter + fi + fi + fi + done + + # Look in vendor-specific locations + + # Emulex: interfaces mirror upstream, but are under adapter scsi_host + for shost in /sys/class/scsi_host/* ; do + if [ -e $shost/vport_create ] ; then + fchost=`ls -d $shost/device/fc_host*` + # is the link up, w/ NPIV support ? + pstate=`cat $fchost/port_state` + ptype=`cat $fchost/port_type | cut -c 1-5` + fname=`cat $fchost/fabric_name | sed -e s/^0x//` + if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then + vmax=`cat $shost/max_npiv_vports` + vinuse=`cat $shost/npiv_vports_inuse` + avail=`expr $vmax - $vinuse` + if [ $avail -gt 0 ] ; then + # create the vport + echo $2":"$3 > $shost/vport_create + if [ $? -eq 0 ] ; then + return 0 + fi + # failed - so we'll just look for the next adapter + fi + fi + fi + done + + return 1 +} + + +# Look for the LUN on the indicated scsi_host (which is an NPIV vport) +# $1 is the scsi_host name (normalized to simply the hostX name) +# $2 is the WWPN of the tgt port the lun is on +# Note: this implies we don't support a multipath'd lun, or we +# are explicitly identifying a "path" +# $3 is the LUN number of the scsi device +find_sdev() +{ + unset dev + hostno=${1/*host/} + for sdev in /sys/class/scsi_device/${hostno}:*:$3 ; do + if test -e $sdev/device/../fc_trans*/target${hostno}*/port_name ; then + tgtwwpn=`cat $sdev/device/../fc_trans*/target${hostno}*/port_name | sed -e s/^0x//` + if test $tgtwwpn = $2 ; then + if test -e $sdev/device/block* ; then + dev=`ls $sdev/device/block*` + dev=${dev##*/} + return + fi + fi + fi + done +} + + +# Look for the NPIV vhost based on a scsi "sdX" name +# $1 is the "sdX" name +find_vhost_from_dev() +{ + unset vhost + hostno=`readlink /sys/block/$1/device` + hostno=${hostno##*/} + hostno=${hostno%%:*} + if test -z "$hostno" ; then return; fi + vhost="host"$hostno +} + + +# We're about to terminate a vhost based on a scsi device +# Flush all nodes on that vhost as they are about to go away +# $1 is the vhost +flush_nodes_on_vhost() +{ + if test ! -x /sbin/blockdev ; then return; fi + hostno=${1/*host/} + for sdev in /sys/class/scsi_device/${hostno}:* ; do + if test -e $sdev/device/block* ; then + dev=`ls $sdev/device/block*` + dev="/dev/"$dev + if test -n "$dev"; then + blockdev --flushbufs $dev + fi + fi + done +} + + +# Terminate a NPIV vhost +# $1 is vhost +delete_vhost() +{ + # use upstream interface + for vport in /sys/class/fc_vports/* ; do + if test -e $vport/device/$1 ; then + if test -e $vport/vport_delete ; then + echo "1" > $vport/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + fi + done + + # use vendor specific interface + + # Emulex + if test -e /sys/class/fc_host/$1/device/../scsi_host*/lpfc_drvr_version ; then + shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` + vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` + vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` + echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + + # Qlogic + if test -e /sys/class/fc_host/$1/device/../scsi_host*/driver_version ; then + shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` + vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` + vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` + echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + + exit 6 +} + + +vport_status() +{ + # Look via upstream interfaces + for fchost in /sys/class/fc_host/* ; do + if test -e $fchost/vport_create ; then + vport_status_display $fchost $fchost + fi + done + + # Look in vendor-specific locations + + # Emulex: interfaces mirror upstream, but are under adapter scsi_host + for shost in /sys/class/scsi_host/* ; do + if [ -e $shost/vport_create ] ; then + fchost=`ls -d $shost/device/fc_host*` + vport_status_display $fchost $shost + fi + done + + return 0 +} + + +vport_status_display() +{ + echo + echo "fc_host: " $2 + echo "port_state: " `cat $1/port_state` + echo "port_type: " `cat $1/port_type` + echo "fabric_name: " `cat $1/fabric_name` + echo "max_npiv_vports: " `cat $2/max_npiv_vports` + echo "npiv_vports_inuse: " `cat $2/npiv_vports_inuse` + echo "modeldesc: " `cat $2/modeldesc` + echo "speed: " `cat $1/speed` + + return 0 +} + diff --git a/block-npiv-vport b/block-npiv-vport new file mode 100644 index 0000000..cab127b --- /dev/null +++ b/block-npiv-vport @@ -0,0 +1,79 @@ +#!/bin/bash + +# Usage: block-npiv-vport [create npivargs | delete vportwwpn | status] + +dir=$(dirname "$0") +. "$dir/block-npiv-common.sh" + +#set -x +command=$1 +params=$2 + +case "$command" in + create) + # Params is one big arg, with fields separated by hyphens: + # FABRIC-VPWWPN-VPWWNN-TGTWWPN-LUN# + # arg 2 - Fabric Name + # arg 3 - VPORT's WWPN + # arg 4 - VPORT's WWNN + # arg 5 - Target's WWPN + # arg 6 - LUN # on Target + # no wwn contains a leading 0x - it is a 16 character hex value + # You may want to optionally pick a specific adapter ? + NPIVARGS=$params; + LUN=${NPIVARGS##*-*-*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $LUN = $NPIVARGS ; then exit 1; fi + TGTWWPN=${NPIVARGS##*-*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $TGTWWPN = $NPIVARGS ; then exit 1; fi + VPORTWWNN=${NPIVARGS##*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $VPORTWWNN = $NPIVARGS ; then exit 1; fi + VPORTWWPN=${NPIVARGS##*-}; NPIVARGS=${NPIVARGS%-*} + if test $VPORTWWPN = $NPIVARGS ; then exit 1; fi + FABRICNM=$NPIVARGS + + # Ensure we compare everything using lower-case hex characters + TGTWWPN=`echo $TGTWWPN | tr A-Z a-z` + VPORTWWPN=`echo $VPORTWWPN | tr A-Z a-z` + VPORTWWNN=`echo $VPORTWWNN | tr A-Z a-z` + FABRICNM=`echo $FABRICNM | tr A-Z a-z` + + find_vhost $VPORTWWPN + if test -z "$vhost" ; then + create_vport $FABRICNM $VPORTWWPN $VPORTWWNN + if [ $? -ne 0 ] ; then exit 2; fi + sleep 8 + find_vhost $VPORTWWPN + if test -z "$vhost" ; then exit 3; fi + fi + + exit 0 + ;; + + delete) + # Params is VPORT's WWPN + # no wwn contains a leading 0x - it is a 16 character hex value + VPORTWWPN=$params + + # Ensure we compare everything using lower-case hex characters + VPORTWWPN=`echo $VPORTWWPN | tr A-Z a-z` + + find_vhost $VPORTWWPN + if test -z "$vhost" ; then exit 4; fi + delete_vhost $vhost + + exit 0 + ;; + + status) + vport_status + + exit 0 + ;; + + *) + echo "Usage: block-npiv-vport [create npivargs | delete vportwwpn | status]" + + exit 1 + ;; +esac + diff --git a/xen-qemu-iscsi-fix.patch b/xen-qemu-iscsi-fix.patch index 2a0e983..5bf0307 100644 --- a/xen-qemu-iscsi-fix.patch +++ b/xen-qemu-iscsi-fix.patch @@ -31,12 +31,12 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/xenstore.c continue; + + free(params); -+ if (!strcmp(drv,"iscsi")) ++ if (!strcmp(drv,"iscsi") || !strcmp(drv, "npiv")) + { + if (pasprintf(&buf, "%s/node", bpath) == -1) + continue; + -+ /* wait for block-iscsi script to complete and populate the ++ /* wait for block-[iscsi|npiv] script to complete and populate the + * node entry. try 30 times (30 secs) */ + for (j = 0; j < 30; j++) { + params = xs_read(xsh, XBT_NULL, buf, &len); @@ -45,7 +45,7 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/xenstore.c + sleep(1); + } + if (params == NULL) { -+ fprintf(stderr, "qemu: iscsi device not found -- timed out \n"); ++ fprintf(stderr, "qemu: %s device not found -- timed out \n", drv); + continue; + } + } diff --git a/xen.changes b/xen.changes index a3a5c03..2594ec3 100644 --- a/xen.changes +++ b/xen.changes @@ -5,6 +5,14 @@ Fri Sep 25 15:08:12 MDT 2009 - jfehlig@novell.com qemu-dm reading from xenstore. The issue is preventing PV domUs from booting as they have no backend console. qemu-retry-be-status.patch +- bnc#520234 - npiv does not work with XEN + Update block-npiv +- bnc#496033 - Support for creating NPIV ports without starting vm + block-npiv-common.sh + block-npiv-vport + Update block-npiv +- bnc#500043 - Fix access to NPIV disk from HVM vm + Update xen-qemu-iscsi-fix.patch ------------------------------------------------------------------- Tue Sep 15 09:32:59 MDT 2009 - jfehlig@novell.com diff --git a/xen.spec b/xen.spec index dcd70ed..c3419b2 100644 --- a/xen.spec +++ b/xen.spec @@ -56,7 +56,9 @@ Source9: xmexample.domUloader Source10: xmexample.disks Source11: block-nbd Source12: block-iscsi -Source13: block-npiv +Source13: block-npiv-common.sh +Source14: block-npiv +Source15: block-npiv-vport Source16: xmclone.sh Source17: xend-relocation.sh Source18: init.xen_loop @@ -735,7 +737,7 @@ rm -f $RPM_BUILD_ROOT/etc/xen/examples/*nbd install -m644 %SOURCE9 %SOURCE10 $RPM_BUILD_ROOT/etc/xen/examples/ # scripts rm -f $RPM_BUILD_ROOT/etc/xen/scripts/block-*nbd -install -m755 %SOURCE11 %SOURCE12 %SOURCE13 %SOURCE16 %SOURCE17 $RPM_BUILD_ROOT/etc/xen/scripts/ +install -m755 %SOURCE11 %SOURCE12 %SOURCE13 %SOURCE14 %SOURCE15 %SOURCE16 %SOURCE17 $RPM_BUILD_ROOT/etc/xen/scripts/ ln -s /etc/xen/scripts/vm-monitor $RPM_BUILD_ROOT/etc/xen/scripts/set-lock # Xen API remote authentication files install -d $RPM_BUILD_ROOT/etc/pam.d From 6de5f9f31ca2e802b09eb1342497efc2b25cb732ab21dbfa49361267e802c68f Mon Sep 17 00:00:00 2001 From: OBS User autobuild Date: Sat, 26 Sep 2009 22:20:06 +0000 Subject: [PATCH 6/7] checked in OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=21 --- 20125-xc-parse-tuple-fix.patch | 45 ---- bdrv_open2_fix_flags.patch | 2 +- block-npiv | 199 ++++++++++++++- block-npiv-common.sh | 238 ------------------ block-npiv-vport | 79 ------ ...7615-qcow2-fix-alloc_cluster_link_l2.patch | 2 +- qemu-retry-be-status.patch | 40 --- xen-qemu-iscsi-fix.patch | 6 +- xen.changes | 23 -- xen.spec | 16 +- 10 files changed, 208 insertions(+), 442 deletions(-) delete mode 100644 20125-xc-parse-tuple-fix.patch delete mode 100644 block-npiv-common.sh delete mode 100644 block-npiv-vport delete mode 100644 qemu-retry-be-status.patch diff --git a/20125-xc-parse-tuple-fix.patch b/20125-xc-parse-tuple-fix.patch deleted file mode 100644 index 45e18bc..0000000 --- a/20125-xc-parse-tuple-fix.patch +++ /dev/null @@ -1,45 +0,0 @@ -# HG changeset patch -# User Keir Fraser -# Date 1251297719 -3600 -# Node ID ed672a604cc7d0acb9418b29cdc3d65ea84543e8 -# Parent 71389988f5d4e6417f7da1d86da984acd5118efc -xend: Do not pass pointer to a 16-bit domid_t to PyArg_ParseTuple() -when it expects a full integer. - -Signed-off-by: Keir Fraser - -diff -r 71389988f5d4 -r ed672a604cc7 tools/python/xen/lowlevel/xc/xc.c ---- a/tools/python/xen/lowlevel/xc/xc.c Wed Aug 26 15:35:14 2009 +0100 -+++ b/tools/python/xen/lowlevel/xc/xc.c Wed Aug 26 15:41:59 2009 +0100 -@@ -654,10 +654,9 @@ - static PyObject *pyxc_get_device_group(XcObject *self, - PyObject *args) - { -- domid_t domid; - uint32_t bdf = 0; - uint32_t max_sdevs, num_sdevs; -- int seg, bus, dev, func, rc, i; -+ int domid, seg, bus, dev, func, rc, i; - PyObject *Pystr; - char *group_str; - char dev_str[9]; -@@ -812,7 +811,7 @@ - static PyObject *pyxc_dom_set_policy_cpuid(XcObject *self, - PyObject *args) - { -- domid_t domid; -+ int domid; - - if ( !PyArg_ParseTuple(args, "i", &domid) ) - return NULL; -@@ -828,9 +827,8 @@ - static PyObject *pyxc_dom_set_cpuid(XcObject *self, - PyObject *args) - { -- domid_t domid; - PyObject *sub_input, *config; -- unsigned int input[2]; -+ unsigned int domid, input[2]; - char *regs[4], *regs_transform[4]; - - if ( !PyArg_ParseTuple(args, "IIOO", &domid, diff --git a/bdrv_open2_fix_flags.patch b/bdrv_open2_fix_flags.patch index 497d403..aa6ae44 100644 --- a/bdrv_open2_fix_flags.patch +++ b/bdrv_open2_fix_flags.patch @@ -19,7 +19,7 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/block.c - RDONLY as fallback */ if (!(flags & BDRV_O_FILE)) - open_flags = BDRV_O_RDWR | (flags & BDRV_O_CACHE_MASK); -+ open_flags = flags; ++ open_flags = flags & BDRV_O_CACHE_MASK; else open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); + if (!(open_flags & BDRV_O_RDWR)) diff --git a/block-npiv b/block-npiv index 9f69bac..34c4792 100644 --- a/block-npiv +++ b/block-npiv @@ -3,12 +3,209 @@ # Usage: block-npiv [add npiv | remove dev] dir=$(dirname "$0") -. "$dir/block-npiv-common.sh" . "$dir/block-common.sh" #set -x #command=$1 +# Look for the NPIV vport with the WWPN +# $1 contains the WWPN (assumes it does not contain a leading "0x") +find_vhost() +{ + unset vhost + + # look in upstream locations + for fchost in /sys/class/fc_vports/* ; do + if test -e $fchost/port_name ; then + wwpn=`cat $fchost/port_name | sed -e s/^0x//` + if test $wwpn = $1 ; then + # Note: makes the assumption the vport will always have an scsi_host child + vhost=`ls -d $fchost/device/host*` + vhost=`basename $vhost` + return + fi + fi + done + + # look in vendor-specific locations + + # Emulex - just looks like another scsi_host - so look at fc_hosts... + for fchost in /sys/class/fc_host/* ; do + if test -e $fchost/port_name ; then + wwpn=`cat $fchost/port_name | sed -e s/^0x//` + if test $wwpn = $1 ; then + # Note: makes the assumption the vport will always have an scsi_host child + vhost=`basename $fchost` + return + fi + fi + done +} + + +# Create a NPIV vport on the fabric w/ FABRICNM, with WWPN,WWNN +# $1 contains FABRICNM +# $2 contains the VPORT WWPN +# $3 contains the VPORT WWNN +# (assumes no name contains a leading "0x") +create_vport() +{ + # find a base adapter with npiv support that is on the right fabric + + # Look via upstream interfaces + for fchost in /sys/class/fc_host/* ; do + if test -e $fchost/vport_create ; then + # is the link up, w/ NPIV support ? + pstate=`cat $fchost/port_state` + ptype=`cat $fchost/port_type | cut -c 1-5` + fname=`cat $fchost/fabric_name | sed -e s/^0x//` + if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then + vmax=`cat $fchost/max_npiv_vports` + vinuse=`cat $fchost/npiv_vports_inuse` + avail=`expr $vmax - $vinuse` + if [ $avail -gt 0 ] ; then + # create the vport + echo $2":"$3 > $fchost/vport_create + if [ $? -eq 0 ] ; then + return 0 + fi + # failed - so we'll just look for the next adapter + fi + fi + fi + done + + # Look in vendor-specific locations + + # Emulex: interfaces mirror upstream, but are under adapter scsi_host + for shost in /sys/class/scsi_host/* ; do + if [ -e $shost/vport_create ] ; then + fchost=`ls -d $shost/device/fc_host*` + # is the link up, w/ NPIV support ? + pstate=`cat $fchost/port_state` + ptype=`cat $fchost/port_type | cut -c 1-5` + fname=`cat $fchost/fabric_name | sed -e s/^0x//` + if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then + vmax=`cat $shost/max_npiv_vports` + vinuse=`cat $shost/npiv_vports_inuse` + avail=`expr $vmax - $vinuse` + if [ $avail -gt 0 ] ; then + # create the vport + echo $2":"$3 > $shost/vport_create + if [ $? -eq 0 ] ; then + return 0 + fi + # failed - so we'll just look for the next adapter + fi + fi + fi + done + + return 1 +} + + +# Look for the LUN on the indicated scsi_host (which is an NPIV vport) +# $1 is the scsi_host name (normalized to simply the hostX name) +# $2 is the WWPN of the tgt port the lun is on +# Note: this implies we don't support a multipath'd lun, or we +# are explicitly identifying a "path" +# $3 is the LUN number of the scsi device +find_sdev() +{ + unset dev + hostno=${1/*host/} + for sdev in /sys/class/scsi_device/${hostno}:*:$3 ; do + if test -e $sdev/device/../fc_trans*/port_name ; then + tgtwwpn=`cat $sdev/device/../fc_trans*/port_name | sed -e s/^0x//` + if test $tgtwwpn = $2 ; then + if test -e $sdev/device/block* ; then + dev=`readlink $sdev/device/block*` + dev=${dev##*/} + return + fi + fi + fi + done +} + + +# Look for the NPIV vhost based on a scsi "sdX" name +# $1 is the "sdX" name +find_vhost_from_dev() +{ + unset vhost + hostno=`readlink /sys/block/$1/device` + hostno=${hostno##*/} + hostno=${hostno%%:*} + if test -z "$hostno" ; then return; fi + vhost="host"$hostno +} + + +# We're about to terminate a vhost based on a scsi device +# Flush all nodes on that vhost as they are about to go away +# $1 is the vhost +flush_nodes_on_vhost() +{ + if test ! -x /sbin/blockdev ; then return; fi + hostno=${1/*host/} + for sdev in /sys/class/scsi_device/${hostno}:* ; do + if test -e $sdev/device/block* ; then + dev=`readlink $sdev/device/block*` + dev=${dev##*/} + dev="/dev/"$dev + if test -n "$dev"; then + blockdev --flushbufs $dev + fi + fi + done +} + + +# Terminate a NPIV vhost +# $1 is vhost +delete_vhost() +{ + # use upstream interface + for vport in /sys/class/fc_vports/* ; do + if test -e $vport/device/$1 ; then + if test -e $vport/vport_delete ; then + echo "1" > $vport/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + fi + done + + # use vendor specific interface + + # Emulex + if test -e /sys/class/fc_host/$1/device/../scsi_host*/lpfc_drvr_version ; then + shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` + vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` + vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` + echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + + # Qlogic + if test -e /sys/class/fc_host/$1/device/../scsi_host*/driver_version ; then + shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` + vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` + vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` + echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + + exit 6 +} + case "$command" in add) # Params is one big arg, with fields separated by hyphens: diff --git a/block-npiv-common.sh b/block-npiv-common.sh deleted file mode 100644 index 5a3d805..0000000 --- a/block-npiv-common.sh +++ /dev/null @@ -1,238 +0,0 @@ - - -# Look for the NPIV vport with the WWPN -# $1 contains the WWPN (assumes it does not contain a leading "0x") -find_vhost() -{ - unset vhost - - # look in upstream locations - for fchost in /sys/class/fc_vports/* ; do - if test -e $fchost/port_name ; then - wwpn=`cat $fchost/port_name | sed -e s/^0x//` - if test $wwpn = $1 ; then - # Note: makes the assumption the vport will always have an scsi_host child - vhost=`ls -d $fchost/device/host*` - vhost=`basename $vhost` - return - fi - fi - done - - # look in vendor-specific locations - - # Emulex - just looks like another scsi_host - so look at fc_hosts... - for fchost in /sys/class/fc_host/* ; do - if test -e $fchost/port_name ; then - wwpn=`cat $fchost/port_name | sed -e s/^0x//` - if test $wwpn = $1 ; then - # Note: makes the assumption the vport will always have an scsi_host child - vhost=`basename $fchost` - return - fi - fi - done -} - - -# Create a NPIV vport on the fabric w/ FABRICNM, with WWPN,WWNN -# $1 contains FABRICNM -# $2 contains the VPORT WWPN -# $3 contains the VPORT WWNN -# (assumes no name contains a leading "0x") -create_vport() -{ - # find a base adapter with npiv support that is on the right fabric - - # Look via upstream interfaces - for fchost in /sys/class/fc_host/* ; do - if test -e $fchost/vport_create ; then - # is the link up, w/ NPIV support ? - pstate=`cat $fchost/port_state` - ptype=`cat $fchost/port_type | cut -c 1-5` - fname=`cat $fchost/fabric_name | sed -e s/^0x//` - if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then - vmax=`cat $fchost/max_npiv_vports` - vinuse=`cat $fchost/npiv_vports_inuse` - avail=`expr $vmax - $vinuse` - if [ $avail -gt 0 ] ; then - # create the vport - echo $2":"$3 > $fchost/vport_create - if [ $? -eq 0 ] ; then - return 0 - fi - # failed - so we'll just look for the next adapter - fi - fi - fi - done - - # Look in vendor-specific locations - - # Emulex: interfaces mirror upstream, but are under adapter scsi_host - for shost in /sys/class/scsi_host/* ; do - if [ -e $shost/vport_create ] ; then - fchost=`ls -d $shost/device/fc_host*` - # is the link up, w/ NPIV support ? - pstate=`cat $fchost/port_state` - ptype=`cat $fchost/port_type | cut -c 1-5` - fname=`cat $fchost/fabric_name | sed -e s/^0x//` - if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then - vmax=`cat $shost/max_npiv_vports` - vinuse=`cat $shost/npiv_vports_inuse` - avail=`expr $vmax - $vinuse` - if [ $avail -gt 0 ] ; then - # create the vport - echo $2":"$3 > $shost/vport_create - if [ $? -eq 0 ] ; then - return 0 - fi - # failed - so we'll just look for the next adapter - fi - fi - fi - done - - return 1 -} - - -# Look for the LUN on the indicated scsi_host (which is an NPIV vport) -# $1 is the scsi_host name (normalized to simply the hostX name) -# $2 is the WWPN of the tgt port the lun is on -# Note: this implies we don't support a multipath'd lun, or we -# are explicitly identifying a "path" -# $3 is the LUN number of the scsi device -find_sdev() -{ - unset dev - hostno=${1/*host/} - for sdev in /sys/class/scsi_device/${hostno}:*:$3 ; do - if test -e $sdev/device/../fc_trans*/target${hostno}*/port_name ; then - tgtwwpn=`cat $sdev/device/../fc_trans*/target${hostno}*/port_name | sed -e s/^0x//` - if test $tgtwwpn = $2 ; then - if test -e $sdev/device/block* ; then - dev=`ls $sdev/device/block*` - dev=${dev##*/} - return - fi - fi - fi - done -} - - -# Look for the NPIV vhost based on a scsi "sdX" name -# $1 is the "sdX" name -find_vhost_from_dev() -{ - unset vhost - hostno=`readlink /sys/block/$1/device` - hostno=${hostno##*/} - hostno=${hostno%%:*} - if test -z "$hostno" ; then return; fi - vhost="host"$hostno -} - - -# We're about to terminate a vhost based on a scsi device -# Flush all nodes on that vhost as they are about to go away -# $1 is the vhost -flush_nodes_on_vhost() -{ - if test ! -x /sbin/blockdev ; then return; fi - hostno=${1/*host/} - for sdev in /sys/class/scsi_device/${hostno}:* ; do - if test -e $sdev/device/block* ; then - dev=`ls $sdev/device/block*` - dev="/dev/"$dev - if test -n "$dev"; then - blockdev --flushbufs $dev - fi - fi - done -} - - -# Terminate a NPIV vhost -# $1 is vhost -delete_vhost() -{ - # use upstream interface - for vport in /sys/class/fc_vports/* ; do - if test -e $vport/device/$1 ; then - if test -e $vport/vport_delete ; then - echo "1" > $vport/vport_delete - if test $? -ne 0 ; then exit 6; fi - sleep 4 - return - fi - fi - done - - # use vendor specific interface - - # Emulex - if test -e /sys/class/fc_host/$1/device/../scsi_host*/lpfc_drvr_version ; then - shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` - vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` - vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` - echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete - if test $? -ne 0 ; then exit 6; fi - sleep 4 - return - fi - - # Qlogic - if test -e /sys/class/fc_host/$1/device/../scsi_host*/driver_version ; then - shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` - vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` - vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` - echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete - if test $? -ne 0 ; then exit 6; fi - sleep 4 - return - fi - - exit 6 -} - - -vport_status() -{ - # Look via upstream interfaces - for fchost in /sys/class/fc_host/* ; do - if test -e $fchost/vport_create ; then - vport_status_display $fchost $fchost - fi - done - - # Look in vendor-specific locations - - # Emulex: interfaces mirror upstream, but are under adapter scsi_host - for shost in /sys/class/scsi_host/* ; do - if [ -e $shost/vport_create ] ; then - fchost=`ls -d $shost/device/fc_host*` - vport_status_display $fchost $shost - fi - done - - return 0 -} - - -vport_status_display() -{ - echo - echo "fc_host: " $2 - echo "port_state: " `cat $1/port_state` - echo "port_type: " `cat $1/port_type` - echo "fabric_name: " `cat $1/fabric_name` - echo "max_npiv_vports: " `cat $2/max_npiv_vports` - echo "npiv_vports_inuse: " `cat $2/npiv_vports_inuse` - echo "modeldesc: " `cat $2/modeldesc` - echo "speed: " `cat $1/speed` - - return 0 -} - diff --git a/block-npiv-vport b/block-npiv-vport deleted file mode 100644 index cab127b..0000000 --- a/block-npiv-vport +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash - -# Usage: block-npiv-vport [create npivargs | delete vportwwpn | status] - -dir=$(dirname "$0") -. "$dir/block-npiv-common.sh" - -#set -x -command=$1 -params=$2 - -case "$command" in - create) - # Params is one big arg, with fields separated by hyphens: - # FABRIC-VPWWPN-VPWWNN-TGTWWPN-LUN# - # arg 2 - Fabric Name - # arg 3 - VPORT's WWPN - # arg 4 - VPORT's WWNN - # arg 5 - Target's WWPN - # arg 6 - LUN # on Target - # no wwn contains a leading 0x - it is a 16 character hex value - # You may want to optionally pick a specific adapter ? - NPIVARGS=$params; - LUN=${NPIVARGS##*-*-*-*-}; NPIVARGS=${NPIVARGS%-*} - if test $LUN = $NPIVARGS ; then exit 1; fi - TGTWWPN=${NPIVARGS##*-*-*-}; NPIVARGS=${NPIVARGS%-*} - if test $TGTWWPN = $NPIVARGS ; then exit 1; fi - VPORTWWNN=${NPIVARGS##*-*-}; NPIVARGS=${NPIVARGS%-*} - if test $VPORTWWNN = $NPIVARGS ; then exit 1; fi - VPORTWWPN=${NPIVARGS##*-}; NPIVARGS=${NPIVARGS%-*} - if test $VPORTWWPN = $NPIVARGS ; then exit 1; fi - FABRICNM=$NPIVARGS - - # Ensure we compare everything using lower-case hex characters - TGTWWPN=`echo $TGTWWPN | tr A-Z a-z` - VPORTWWPN=`echo $VPORTWWPN | tr A-Z a-z` - VPORTWWNN=`echo $VPORTWWNN | tr A-Z a-z` - FABRICNM=`echo $FABRICNM | tr A-Z a-z` - - find_vhost $VPORTWWPN - if test -z "$vhost" ; then - create_vport $FABRICNM $VPORTWWPN $VPORTWWNN - if [ $? -ne 0 ] ; then exit 2; fi - sleep 8 - find_vhost $VPORTWWPN - if test -z "$vhost" ; then exit 3; fi - fi - - exit 0 - ;; - - delete) - # Params is VPORT's WWPN - # no wwn contains a leading 0x - it is a 16 character hex value - VPORTWWPN=$params - - # Ensure we compare everything using lower-case hex characters - VPORTWWPN=`echo $VPORTWWPN | tr A-Z a-z` - - find_vhost $VPORTWWPN - if test -z "$vhost" ; then exit 4; fi - delete_vhost $vhost - - exit 0 - ;; - - status) - vport_status - - exit 0 - ;; - - *) - echo "Usage: block-npiv-vport [create npivargs | delete vportwwpn | status]" - - exit 1 - ;; -esac - diff --git a/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch b/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch index 5b63f5e..63d06d1 100644 --- a/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch +++ b/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch @@ -26,7 +26,7 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/block-qcow2.c for (i = 0; i < j; i++) - free_any_clusters(bs, old_cluster[i], 1); -+ free_any_clusters(bs, be64_to_cpu(old_cluster[i]) & ~QCOW_OFLAG_COPIED, 1); ++ free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1); ret = 0; err: diff --git a/qemu-retry-be-status.patch b/qemu-retry-be-status.patch deleted file mode 100644 index a215846..0000000 --- a/qemu-retry-be-status.patch +++ /dev/null @@ -1,40 +0,0 @@ -Index: xen-3.4.1-testing/tools/ioemu-remote/hw/xen_backend.c -=================================================================== ---- xen-3.4.1-testing.orig/tools/ioemu-remote/hw/xen_backend.c -+++ xen-3.4.1-testing/tools/ioemu-remote/hw/xen_backend.c -@@ -377,8 +377,12 @@ static int xen_be_try_init(struct XenDev - int rc = 0; - - if (!xendev->online) { -- xen_be_printf(xendev, 1, "not online\n"); -- return -1; -+ sleep(3); -+ xenstore_read_be_int(xendev, "online", &xendev->online); -+ if (!xendev->online) { -+ xen_be_printf(xendev, 1, "not online\n"); -+ return -1; -+ } - } - - if (xendev->ops->init) -Index: xen-3.4.1-testing/tools/ioemu-remote/hw/xen_console.c -=================================================================== ---- xen-3.4.1-testing.orig/tools/ioemu-remote/hw/xen_console.c -+++ xen-3.4.1-testing/tools/ioemu-remote/hw/xen_console.c -@@ -196,9 +196,14 @@ static int con_init(struct XenDevice *xe - - type = xenstore_read_str(con->console, "type"); - if (!type || 0 != strcmp(type, "ioemu")) { -- xen_be_printf(xendev, 1, "not for me (type=%s)\n", type); -- return -1; -+ sleep(3); -+ type = xenstore_read_str(con->console, "type"); -+ if (!type || 0 != strcmp(type, "ioemu")) { -+ xen_be_printf(xendev, 1, "not for me (type=%s)\n", type); -+ return -1; -+ } - } -+ qemu_free(type); - - if (!serial_hds[con->xendev.dev]) - xen_be_printf(xendev, 1, "WARNING: serial line %d not configured\n", diff --git a/xen-qemu-iscsi-fix.patch b/xen-qemu-iscsi-fix.patch index 5bf0307..2a0e983 100644 --- a/xen-qemu-iscsi-fix.patch +++ b/xen-qemu-iscsi-fix.patch @@ -31,12 +31,12 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/xenstore.c continue; + + free(params); -+ if (!strcmp(drv,"iscsi") || !strcmp(drv, "npiv")) ++ if (!strcmp(drv,"iscsi")) + { + if (pasprintf(&buf, "%s/node", bpath) == -1) + continue; + -+ /* wait for block-[iscsi|npiv] script to complete and populate the ++ /* wait for block-iscsi script to complete and populate the + * node entry. try 30 times (30 secs) */ + for (j = 0; j < 30; j++) { + params = xs_read(xsh, XBT_NULL, buf, &len); @@ -45,7 +45,7 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/xenstore.c + sleep(1); + } + if (params == NULL) { -+ fprintf(stderr, "qemu: %s device not found -- timed out \n", drv); ++ fprintf(stderr, "qemu: iscsi device not found -- timed out \n"); + continue; + } + } diff --git a/xen.changes b/xen.changes index 2594ec3..a09f056 100644 --- a/xen.changes +++ b/xen.changes @@ -1,26 +1,3 @@ -------------------------------------------------------------------- -Fri Sep 25 15:08:12 MDT 2009 - jfehlig@novell.com - -- Add temporary workaround for race between xend writing and - qemu-dm reading from xenstore. The issue is preventing PV - domUs from booting as they have no backend console. - qemu-retry-be-status.patch -- bnc#520234 - npiv does not work with XEN - Update block-npiv -- bnc#496033 - Support for creating NPIV ports without starting vm - block-npiv-common.sh - block-npiv-vport - Update block-npiv -- bnc#500043 - Fix access to NPIV disk from HVM vm - Update xen-qemu-iscsi-fix.patch - -------------------------------------------------------------------- -Tue Sep 15 09:32:59 MDT 2009 - jfehlig@novell.com - -- bnc#513921 - Xen doesn't work get an eror when starting the - install processes or starting a pervious installed DomU - 20125-xc-parse-tuple-fix.patch - ------------------------------------------------------------------- Mon Aug 24 10:31:36 MDT 2009 - carnold@novell.com diff --git a/xen.spec b/xen.spec index c3419b2..9822c7b 100644 --- a/xen.spec +++ b/xen.spec @@ -1,5 +1,5 @@ # -# spec file for package xen (Version 3.4.1_19718_03) +# spec file for package xen (Version 3.4.1_19718_02) # # Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -37,7 +37,7 @@ BuildRequires: glibc-32bit glibc-devel-32bit %if %{?with_kmp}0 BuildRequires: kernel-source kernel-syms module-init-tools xorg-x11 %endif -Version: 3.4.1_19718_03 +Version: 3.4.1_19718_02 Release: 1 License: GPL v2 only Group: System/Kernel @@ -56,9 +56,7 @@ Source9: xmexample.domUloader Source10: xmexample.disks Source11: block-nbd Source12: block-iscsi -Source13: block-npiv-common.sh -Source14: block-npiv -Source15: block-npiv-vport +Source13: block-npiv Source16: xmclone.sh Source17: xend-relocation.sh Source18: init.xen_loop @@ -81,7 +79,6 @@ Patch5: 20077-x86-runstate-cswitch-out.patch Patch6: 20078-x86_64-branch-emulation.patch Patch7: 20101-hvm-no-compat-virt-start.patch Patch8: 20112-x86-dom0-boot-run-timers.patch -Patch9: 20125-xc-parse-tuple-fix.patch # Our patches Patch100: xen-config.diff Patch101: xend-config.diff @@ -172,7 +169,6 @@ Patch404: pvdrv_emulation_control.patch Patch405: blktap-pv-cdrom.patch Patch406: network-nat-open-SuSEfirewall2-FORWARD.patch Patch407: ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch -Patch408: qemu-retry-be-status.patch %if %{?with_kmp}0 Patch450: disable_emulated_device.diff %endif @@ -180,7 +176,7 @@ Patch450: disable_emulated_device.diff Patch500: hv_tools.patch Patch501: hv_xen_base.patch Patch502: hv_xen_extension.patch -Patch503: hv_win7_eoi_bug.patch +Patch503: hv_win7_eoi_bug.patch Patch999: tmp_build.patch Url: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/ BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -523,7 +519,6 @@ Authors: %patch6 -p1 %patch7 -p1 %patch8 -p1 -%patch9 -p1 %patch100 -p1 %patch101 -p1 %patch102 -p1 @@ -605,7 +600,6 @@ Authors: %patch405 -p1 %patch406 -p1 %patch407 -p1 -%patch408 -p1 %if %{?with_kmp}0 %patch450 -p1 %endif @@ -737,7 +731,7 @@ rm -f $RPM_BUILD_ROOT/etc/xen/examples/*nbd install -m644 %SOURCE9 %SOURCE10 $RPM_BUILD_ROOT/etc/xen/examples/ # scripts rm -f $RPM_BUILD_ROOT/etc/xen/scripts/block-*nbd -install -m755 %SOURCE11 %SOURCE12 %SOURCE13 %SOURCE14 %SOURCE15 %SOURCE16 %SOURCE17 $RPM_BUILD_ROOT/etc/xen/scripts/ +install -m755 %SOURCE11 %SOURCE12 %SOURCE13 %SOURCE16 %SOURCE17 $RPM_BUILD_ROOT/etc/xen/scripts/ ln -s /etc/xen/scripts/vm-monitor $RPM_BUILD_ROOT/etc/xen/scripts/set-lock # Xen API remote authentication files install -d $RPM_BUILD_ROOT/etc/pam.d From f6f3ce5586b8db69eb63ec6ae54c831486ba01348114a7af4f7695191d82c87f Mon Sep 17 00:00:00 2001 From: OBS User buildservice-autocommit Date: Sat, 26 Sep 2009 22:20:08 +0000 Subject: [PATCH 7/7] Updating link to change in openSUSE:Factory/xen revision 80.0 OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=bab18b4d77fe039fab5382a8e1a339f4 --- 20125-xc-parse-tuple-fix.patch | 45 ++++ bdrv_open2_fix_flags.patch | 2 +- block-npiv | 199 +-------------- block-npiv-common.sh | 238 ++++++++++++++++++ block-npiv-vport | 79 ++++++ ...7615-qcow2-fix-alloc_cluster_link_l2.patch | 2 +- qemu-retry-be-status.patch | 40 +++ xen-qemu-iscsi-fix.patch | 6 +- xen.changes | 23 ++ xen.spec | 16 +- 10 files changed, 442 insertions(+), 208 deletions(-) create mode 100644 20125-xc-parse-tuple-fix.patch create mode 100644 block-npiv-common.sh create mode 100644 block-npiv-vport create mode 100644 qemu-retry-be-status.patch diff --git a/20125-xc-parse-tuple-fix.patch b/20125-xc-parse-tuple-fix.patch new file mode 100644 index 0000000..45e18bc --- /dev/null +++ b/20125-xc-parse-tuple-fix.patch @@ -0,0 +1,45 @@ +# HG changeset patch +# User Keir Fraser +# Date 1251297719 -3600 +# Node ID ed672a604cc7d0acb9418b29cdc3d65ea84543e8 +# Parent 71389988f5d4e6417f7da1d86da984acd5118efc +xend: Do not pass pointer to a 16-bit domid_t to PyArg_ParseTuple() +when it expects a full integer. + +Signed-off-by: Keir Fraser + +diff -r 71389988f5d4 -r ed672a604cc7 tools/python/xen/lowlevel/xc/xc.c +--- a/tools/python/xen/lowlevel/xc/xc.c Wed Aug 26 15:35:14 2009 +0100 ++++ b/tools/python/xen/lowlevel/xc/xc.c Wed Aug 26 15:41:59 2009 +0100 +@@ -654,10 +654,9 @@ + static PyObject *pyxc_get_device_group(XcObject *self, + PyObject *args) + { +- domid_t domid; + uint32_t bdf = 0; + uint32_t max_sdevs, num_sdevs; +- int seg, bus, dev, func, rc, i; ++ int domid, seg, bus, dev, func, rc, i; + PyObject *Pystr; + char *group_str; + char dev_str[9]; +@@ -812,7 +811,7 @@ + static PyObject *pyxc_dom_set_policy_cpuid(XcObject *self, + PyObject *args) + { +- domid_t domid; ++ int domid; + + if ( !PyArg_ParseTuple(args, "i", &domid) ) + return NULL; +@@ -828,9 +827,8 @@ + static PyObject *pyxc_dom_set_cpuid(XcObject *self, + PyObject *args) + { +- domid_t domid; + PyObject *sub_input, *config; +- unsigned int input[2]; ++ unsigned int domid, input[2]; + char *regs[4], *regs_transform[4]; + + if ( !PyArg_ParseTuple(args, "IIOO", &domid, diff --git a/bdrv_open2_fix_flags.patch b/bdrv_open2_fix_flags.patch index aa6ae44..497d403 100644 --- a/bdrv_open2_fix_flags.patch +++ b/bdrv_open2_fix_flags.patch @@ -19,7 +19,7 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/block.c - RDONLY as fallback */ if (!(flags & BDRV_O_FILE)) - open_flags = BDRV_O_RDWR | (flags & BDRV_O_CACHE_MASK); -+ open_flags = flags & BDRV_O_CACHE_MASK; ++ open_flags = flags; else open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); + if (!(open_flags & BDRV_O_RDWR)) diff --git a/block-npiv b/block-npiv index 34c4792..9f69bac 100644 --- a/block-npiv +++ b/block-npiv @@ -3,209 +3,12 @@ # Usage: block-npiv [add npiv | remove dev] dir=$(dirname "$0") +. "$dir/block-npiv-common.sh" . "$dir/block-common.sh" #set -x #command=$1 -# Look for the NPIV vport with the WWPN -# $1 contains the WWPN (assumes it does not contain a leading "0x") -find_vhost() -{ - unset vhost - - # look in upstream locations - for fchost in /sys/class/fc_vports/* ; do - if test -e $fchost/port_name ; then - wwpn=`cat $fchost/port_name | sed -e s/^0x//` - if test $wwpn = $1 ; then - # Note: makes the assumption the vport will always have an scsi_host child - vhost=`ls -d $fchost/device/host*` - vhost=`basename $vhost` - return - fi - fi - done - - # look in vendor-specific locations - - # Emulex - just looks like another scsi_host - so look at fc_hosts... - for fchost in /sys/class/fc_host/* ; do - if test -e $fchost/port_name ; then - wwpn=`cat $fchost/port_name | sed -e s/^0x//` - if test $wwpn = $1 ; then - # Note: makes the assumption the vport will always have an scsi_host child - vhost=`basename $fchost` - return - fi - fi - done -} - - -# Create a NPIV vport on the fabric w/ FABRICNM, with WWPN,WWNN -# $1 contains FABRICNM -# $2 contains the VPORT WWPN -# $3 contains the VPORT WWNN -# (assumes no name contains a leading "0x") -create_vport() -{ - # find a base adapter with npiv support that is on the right fabric - - # Look via upstream interfaces - for fchost in /sys/class/fc_host/* ; do - if test -e $fchost/vport_create ; then - # is the link up, w/ NPIV support ? - pstate=`cat $fchost/port_state` - ptype=`cat $fchost/port_type | cut -c 1-5` - fname=`cat $fchost/fabric_name | sed -e s/^0x//` - if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then - vmax=`cat $fchost/max_npiv_vports` - vinuse=`cat $fchost/npiv_vports_inuse` - avail=`expr $vmax - $vinuse` - if [ $avail -gt 0 ] ; then - # create the vport - echo $2":"$3 > $fchost/vport_create - if [ $? -eq 0 ] ; then - return 0 - fi - # failed - so we'll just look for the next adapter - fi - fi - fi - done - - # Look in vendor-specific locations - - # Emulex: interfaces mirror upstream, but are under adapter scsi_host - for shost in /sys/class/scsi_host/* ; do - if [ -e $shost/vport_create ] ; then - fchost=`ls -d $shost/device/fc_host*` - # is the link up, w/ NPIV support ? - pstate=`cat $fchost/port_state` - ptype=`cat $fchost/port_type | cut -c 1-5` - fname=`cat $fchost/fabric_name | sed -e s/^0x//` - if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then - vmax=`cat $shost/max_npiv_vports` - vinuse=`cat $shost/npiv_vports_inuse` - avail=`expr $vmax - $vinuse` - if [ $avail -gt 0 ] ; then - # create the vport - echo $2":"$3 > $shost/vport_create - if [ $? -eq 0 ] ; then - return 0 - fi - # failed - so we'll just look for the next adapter - fi - fi - fi - done - - return 1 -} - - -# Look for the LUN on the indicated scsi_host (which is an NPIV vport) -# $1 is the scsi_host name (normalized to simply the hostX name) -# $2 is the WWPN of the tgt port the lun is on -# Note: this implies we don't support a multipath'd lun, or we -# are explicitly identifying a "path" -# $3 is the LUN number of the scsi device -find_sdev() -{ - unset dev - hostno=${1/*host/} - for sdev in /sys/class/scsi_device/${hostno}:*:$3 ; do - if test -e $sdev/device/../fc_trans*/port_name ; then - tgtwwpn=`cat $sdev/device/../fc_trans*/port_name | sed -e s/^0x//` - if test $tgtwwpn = $2 ; then - if test -e $sdev/device/block* ; then - dev=`readlink $sdev/device/block*` - dev=${dev##*/} - return - fi - fi - fi - done -} - - -# Look for the NPIV vhost based on a scsi "sdX" name -# $1 is the "sdX" name -find_vhost_from_dev() -{ - unset vhost - hostno=`readlink /sys/block/$1/device` - hostno=${hostno##*/} - hostno=${hostno%%:*} - if test -z "$hostno" ; then return; fi - vhost="host"$hostno -} - - -# We're about to terminate a vhost based on a scsi device -# Flush all nodes on that vhost as they are about to go away -# $1 is the vhost -flush_nodes_on_vhost() -{ - if test ! -x /sbin/blockdev ; then return; fi - hostno=${1/*host/} - for sdev in /sys/class/scsi_device/${hostno}:* ; do - if test -e $sdev/device/block* ; then - dev=`readlink $sdev/device/block*` - dev=${dev##*/} - dev="/dev/"$dev - if test -n "$dev"; then - blockdev --flushbufs $dev - fi - fi - done -} - - -# Terminate a NPIV vhost -# $1 is vhost -delete_vhost() -{ - # use upstream interface - for vport in /sys/class/fc_vports/* ; do - if test -e $vport/device/$1 ; then - if test -e $vport/vport_delete ; then - echo "1" > $vport/vport_delete - if test $? -ne 0 ; then exit 6; fi - sleep 4 - return - fi - fi - done - - # use vendor specific interface - - # Emulex - if test -e /sys/class/fc_host/$1/device/../scsi_host*/lpfc_drvr_version ; then - shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` - vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` - vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` - echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete - if test $? -ne 0 ; then exit 6; fi - sleep 4 - return - fi - - # Qlogic - if test -e /sys/class/fc_host/$1/device/../scsi_host*/driver_version ; then - shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` - vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` - vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` - echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete - if test $? -ne 0 ; then exit 6; fi - sleep 4 - return - fi - - exit 6 -} - case "$command" in add) # Params is one big arg, with fields separated by hyphens: diff --git a/block-npiv-common.sh b/block-npiv-common.sh new file mode 100644 index 0000000..5a3d805 --- /dev/null +++ b/block-npiv-common.sh @@ -0,0 +1,238 @@ + + +# Look for the NPIV vport with the WWPN +# $1 contains the WWPN (assumes it does not contain a leading "0x") +find_vhost() +{ + unset vhost + + # look in upstream locations + for fchost in /sys/class/fc_vports/* ; do + if test -e $fchost/port_name ; then + wwpn=`cat $fchost/port_name | sed -e s/^0x//` + if test $wwpn = $1 ; then + # Note: makes the assumption the vport will always have an scsi_host child + vhost=`ls -d $fchost/device/host*` + vhost=`basename $vhost` + return + fi + fi + done + + # look in vendor-specific locations + + # Emulex - just looks like another scsi_host - so look at fc_hosts... + for fchost in /sys/class/fc_host/* ; do + if test -e $fchost/port_name ; then + wwpn=`cat $fchost/port_name | sed -e s/^0x//` + if test $wwpn = $1 ; then + # Note: makes the assumption the vport will always have an scsi_host child + vhost=`basename $fchost` + return + fi + fi + done +} + + +# Create a NPIV vport on the fabric w/ FABRICNM, with WWPN,WWNN +# $1 contains FABRICNM +# $2 contains the VPORT WWPN +# $3 contains the VPORT WWNN +# (assumes no name contains a leading "0x") +create_vport() +{ + # find a base adapter with npiv support that is on the right fabric + + # Look via upstream interfaces + for fchost in /sys/class/fc_host/* ; do + if test -e $fchost/vport_create ; then + # is the link up, w/ NPIV support ? + pstate=`cat $fchost/port_state` + ptype=`cat $fchost/port_type | cut -c 1-5` + fname=`cat $fchost/fabric_name | sed -e s/^0x//` + if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then + vmax=`cat $fchost/max_npiv_vports` + vinuse=`cat $fchost/npiv_vports_inuse` + avail=`expr $vmax - $vinuse` + if [ $avail -gt 0 ] ; then + # create the vport + echo $2":"$3 > $fchost/vport_create + if [ $? -eq 0 ] ; then + return 0 + fi + # failed - so we'll just look for the next adapter + fi + fi + fi + done + + # Look in vendor-specific locations + + # Emulex: interfaces mirror upstream, but are under adapter scsi_host + for shost in /sys/class/scsi_host/* ; do + if [ -e $shost/vport_create ] ; then + fchost=`ls -d $shost/device/fc_host*` + # is the link up, w/ NPIV support ? + pstate=`cat $fchost/port_state` + ptype=`cat $fchost/port_type | cut -c 1-5` + fname=`cat $fchost/fabric_name | sed -e s/^0x//` + if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then + vmax=`cat $shost/max_npiv_vports` + vinuse=`cat $shost/npiv_vports_inuse` + avail=`expr $vmax - $vinuse` + if [ $avail -gt 0 ] ; then + # create the vport + echo $2":"$3 > $shost/vport_create + if [ $? -eq 0 ] ; then + return 0 + fi + # failed - so we'll just look for the next adapter + fi + fi + fi + done + + return 1 +} + + +# Look for the LUN on the indicated scsi_host (which is an NPIV vport) +# $1 is the scsi_host name (normalized to simply the hostX name) +# $2 is the WWPN of the tgt port the lun is on +# Note: this implies we don't support a multipath'd lun, or we +# are explicitly identifying a "path" +# $3 is the LUN number of the scsi device +find_sdev() +{ + unset dev + hostno=${1/*host/} + for sdev in /sys/class/scsi_device/${hostno}:*:$3 ; do + if test -e $sdev/device/../fc_trans*/target${hostno}*/port_name ; then + tgtwwpn=`cat $sdev/device/../fc_trans*/target${hostno}*/port_name | sed -e s/^0x//` + if test $tgtwwpn = $2 ; then + if test -e $sdev/device/block* ; then + dev=`ls $sdev/device/block*` + dev=${dev##*/} + return + fi + fi + fi + done +} + + +# Look for the NPIV vhost based on a scsi "sdX" name +# $1 is the "sdX" name +find_vhost_from_dev() +{ + unset vhost + hostno=`readlink /sys/block/$1/device` + hostno=${hostno##*/} + hostno=${hostno%%:*} + if test -z "$hostno" ; then return; fi + vhost="host"$hostno +} + + +# We're about to terminate a vhost based on a scsi device +# Flush all nodes on that vhost as they are about to go away +# $1 is the vhost +flush_nodes_on_vhost() +{ + if test ! -x /sbin/blockdev ; then return; fi + hostno=${1/*host/} + for sdev in /sys/class/scsi_device/${hostno}:* ; do + if test -e $sdev/device/block* ; then + dev=`ls $sdev/device/block*` + dev="/dev/"$dev + if test -n "$dev"; then + blockdev --flushbufs $dev + fi + fi + done +} + + +# Terminate a NPIV vhost +# $1 is vhost +delete_vhost() +{ + # use upstream interface + for vport in /sys/class/fc_vports/* ; do + if test -e $vport/device/$1 ; then + if test -e $vport/vport_delete ; then + echo "1" > $vport/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + fi + done + + # use vendor specific interface + + # Emulex + if test -e /sys/class/fc_host/$1/device/../scsi_host*/lpfc_drvr_version ; then + shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` + vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` + vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` + echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + + # Qlogic + if test -e /sys/class/fc_host/$1/device/../scsi_host*/driver_version ; then + shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` + vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` + vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` + echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + + exit 6 +} + + +vport_status() +{ + # Look via upstream interfaces + for fchost in /sys/class/fc_host/* ; do + if test -e $fchost/vport_create ; then + vport_status_display $fchost $fchost + fi + done + + # Look in vendor-specific locations + + # Emulex: interfaces mirror upstream, but are under adapter scsi_host + for shost in /sys/class/scsi_host/* ; do + if [ -e $shost/vport_create ] ; then + fchost=`ls -d $shost/device/fc_host*` + vport_status_display $fchost $shost + fi + done + + return 0 +} + + +vport_status_display() +{ + echo + echo "fc_host: " $2 + echo "port_state: " `cat $1/port_state` + echo "port_type: " `cat $1/port_type` + echo "fabric_name: " `cat $1/fabric_name` + echo "max_npiv_vports: " `cat $2/max_npiv_vports` + echo "npiv_vports_inuse: " `cat $2/npiv_vports_inuse` + echo "modeldesc: " `cat $2/modeldesc` + echo "speed: " `cat $1/speed` + + return 0 +} + diff --git a/block-npiv-vport b/block-npiv-vport new file mode 100644 index 0000000..cab127b --- /dev/null +++ b/block-npiv-vport @@ -0,0 +1,79 @@ +#!/bin/bash + +# Usage: block-npiv-vport [create npivargs | delete vportwwpn | status] + +dir=$(dirname "$0") +. "$dir/block-npiv-common.sh" + +#set -x +command=$1 +params=$2 + +case "$command" in + create) + # Params is one big arg, with fields separated by hyphens: + # FABRIC-VPWWPN-VPWWNN-TGTWWPN-LUN# + # arg 2 - Fabric Name + # arg 3 - VPORT's WWPN + # arg 4 - VPORT's WWNN + # arg 5 - Target's WWPN + # arg 6 - LUN # on Target + # no wwn contains a leading 0x - it is a 16 character hex value + # You may want to optionally pick a specific adapter ? + NPIVARGS=$params; + LUN=${NPIVARGS##*-*-*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $LUN = $NPIVARGS ; then exit 1; fi + TGTWWPN=${NPIVARGS##*-*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $TGTWWPN = $NPIVARGS ; then exit 1; fi + VPORTWWNN=${NPIVARGS##*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $VPORTWWNN = $NPIVARGS ; then exit 1; fi + VPORTWWPN=${NPIVARGS##*-}; NPIVARGS=${NPIVARGS%-*} + if test $VPORTWWPN = $NPIVARGS ; then exit 1; fi + FABRICNM=$NPIVARGS + + # Ensure we compare everything using lower-case hex characters + TGTWWPN=`echo $TGTWWPN | tr A-Z a-z` + VPORTWWPN=`echo $VPORTWWPN | tr A-Z a-z` + VPORTWWNN=`echo $VPORTWWNN | tr A-Z a-z` + FABRICNM=`echo $FABRICNM | tr A-Z a-z` + + find_vhost $VPORTWWPN + if test -z "$vhost" ; then + create_vport $FABRICNM $VPORTWWPN $VPORTWWNN + if [ $? -ne 0 ] ; then exit 2; fi + sleep 8 + find_vhost $VPORTWWPN + if test -z "$vhost" ; then exit 3; fi + fi + + exit 0 + ;; + + delete) + # Params is VPORT's WWPN + # no wwn contains a leading 0x - it is a 16 character hex value + VPORTWWPN=$params + + # Ensure we compare everything using lower-case hex characters + VPORTWWPN=`echo $VPORTWWPN | tr A-Z a-z` + + find_vhost $VPORTWWPN + if test -z "$vhost" ; then exit 4; fi + delete_vhost $vhost + + exit 0 + ;; + + status) + vport_status + + exit 0 + ;; + + *) + echo "Usage: block-npiv-vport [create npivargs | delete vportwwpn | status]" + + exit 1 + ;; +esac + diff --git a/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch b/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch index 63d06d1..5b63f5e 100644 --- a/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch +++ b/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch @@ -26,7 +26,7 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/block-qcow2.c for (i = 0; i < j; i++) - free_any_clusters(bs, old_cluster[i], 1); -+ free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1); ++ free_any_clusters(bs, be64_to_cpu(old_cluster[i]) & ~QCOW_OFLAG_COPIED, 1); ret = 0; err: diff --git a/qemu-retry-be-status.patch b/qemu-retry-be-status.patch new file mode 100644 index 0000000..a215846 --- /dev/null +++ b/qemu-retry-be-status.patch @@ -0,0 +1,40 @@ +Index: xen-3.4.1-testing/tools/ioemu-remote/hw/xen_backend.c +=================================================================== +--- xen-3.4.1-testing.orig/tools/ioemu-remote/hw/xen_backend.c ++++ xen-3.4.1-testing/tools/ioemu-remote/hw/xen_backend.c +@@ -377,8 +377,12 @@ static int xen_be_try_init(struct XenDev + int rc = 0; + + if (!xendev->online) { +- xen_be_printf(xendev, 1, "not online\n"); +- return -1; ++ sleep(3); ++ xenstore_read_be_int(xendev, "online", &xendev->online); ++ if (!xendev->online) { ++ xen_be_printf(xendev, 1, "not online\n"); ++ return -1; ++ } + } + + if (xendev->ops->init) +Index: xen-3.4.1-testing/tools/ioemu-remote/hw/xen_console.c +=================================================================== +--- xen-3.4.1-testing.orig/tools/ioemu-remote/hw/xen_console.c ++++ xen-3.4.1-testing/tools/ioemu-remote/hw/xen_console.c +@@ -196,9 +196,14 @@ static int con_init(struct XenDevice *xe + + type = xenstore_read_str(con->console, "type"); + if (!type || 0 != strcmp(type, "ioemu")) { +- xen_be_printf(xendev, 1, "not for me (type=%s)\n", type); +- return -1; ++ sleep(3); ++ type = xenstore_read_str(con->console, "type"); ++ if (!type || 0 != strcmp(type, "ioemu")) { ++ xen_be_printf(xendev, 1, "not for me (type=%s)\n", type); ++ return -1; ++ } + } ++ qemu_free(type); + + if (!serial_hds[con->xendev.dev]) + xen_be_printf(xendev, 1, "WARNING: serial line %d not configured\n", diff --git a/xen-qemu-iscsi-fix.patch b/xen-qemu-iscsi-fix.patch index 2a0e983..5bf0307 100644 --- a/xen-qemu-iscsi-fix.patch +++ b/xen-qemu-iscsi-fix.patch @@ -31,12 +31,12 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/xenstore.c continue; + + free(params); -+ if (!strcmp(drv,"iscsi")) ++ if (!strcmp(drv,"iscsi") || !strcmp(drv, "npiv")) + { + if (pasprintf(&buf, "%s/node", bpath) == -1) + continue; + -+ /* wait for block-iscsi script to complete and populate the ++ /* wait for block-[iscsi|npiv] script to complete and populate the + * node entry. try 30 times (30 secs) */ + for (j = 0; j < 30; j++) { + params = xs_read(xsh, XBT_NULL, buf, &len); @@ -45,7 +45,7 @@ Index: xen-3.4.1-testing/tools/ioemu-remote/xenstore.c + sleep(1); + } + if (params == NULL) { -+ fprintf(stderr, "qemu: iscsi device not found -- timed out \n"); ++ fprintf(stderr, "qemu: %s device not found -- timed out \n", drv); + continue; + } + } diff --git a/xen.changes b/xen.changes index a09f056..2594ec3 100644 --- a/xen.changes +++ b/xen.changes @@ -1,3 +1,26 @@ +------------------------------------------------------------------- +Fri Sep 25 15:08:12 MDT 2009 - jfehlig@novell.com + +- Add temporary workaround for race between xend writing and + qemu-dm reading from xenstore. The issue is preventing PV + domUs from booting as they have no backend console. + qemu-retry-be-status.patch +- bnc#520234 - npiv does not work with XEN + Update block-npiv +- bnc#496033 - Support for creating NPIV ports without starting vm + block-npiv-common.sh + block-npiv-vport + Update block-npiv +- bnc#500043 - Fix access to NPIV disk from HVM vm + Update xen-qemu-iscsi-fix.patch + +------------------------------------------------------------------- +Tue Sep 15 09:32:59 MDT 2009 - jfehlig@novell.com + +- bnc#513921 - Xen doesn't work get an eror when starting the + install processes or starting a pervious installed DomU + 20125-xc-parse-tuple-fix.patch + ------------------------------------------------------------------- Mon Aug 24 10:31:36 MDT 2009 - carnold@novell.com diff --git a/xen.spec b/xen.spec index 9822c7b..c3419b2 100644 --- a/xen.spec +++ b/xen.spec @@ -1,5 +1,5 @@ # -# spec file for package xen (Version 3.4.1_19718_02) +# spec file for package xen (Version 3.4.1_19718_03) # # Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -37,7 +37,7 @@ BuildRequires: glibc-32bit glibc-devel-32bit %if %{?with_kmp}0 BuildRequires: kernel-source kernel-syms module-init-tools xorg-x11 %endif -Version: 3.4.1_19718_02 +Version: 3.4.1_19718_03 Release: 1 License: GPL v2 only Group: System/Kernel @@ -56,7 +56,9 @@ Source9: xmexample.domUloader Source10: xmexample.disks Source11: block-nbd Source12: block-iscsi -Source13: block-npiv +Source13: block-npiv-common.sh +Source14: block-npiv +Source15: block-npiv-vport Source16: xmclone.sh Source17: xend-relocation.sh Source18: init.xen_loop @@ -79,6 +81,7 @@ Patch5: 20077-x86-runstate-cswitch-out.patch Patch6: 20078-x86_64-branch-emulation.patch Patch7: 20101-hvm-no-compat-virt-start.patch Patch8: 20112-x86-dom0-boot-run-timers.patch +Patch9: 20125-xc-parse-tuple-fix.patch # Our patches Patch100: xen-config.diff Patch101: xend-config.diff @@ -169,6 +172,7 @@ Patch404: pvdrv_emulation_control.patch Patch405: blktap-pv-cdrom.patch Patch406: network-nat-open-SuSEfirewall2-FORWARD.patch Patch407: ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch +Patch408: qemu-retry-be-status.patch %if %{?with_kmp}0 Patch450: disable_emulated_device.diff %endif @@ -176,7 +180,7 @@ Patch450: disable_emulated_device.diff Patch500: hv_tools.patch Patch501: hv_xen_base.patch Patch502: hv_xen_extension.patch -Patch503: hv_win7_eoi_bug.patch +Patch503: hv_win7_eoi_bug.patch Patch999: tmp_build.patch Url: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/ BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -519,6 +523,7 @@ Authors: %patch6 -p1 %patch7 -p1 %patch8 -p1 +%patch9 -p1 %patch100 -p1 %patch101 -p1 %patch102 -p1 @@ -600,6 +605,7 @@ Authors: %patch405 -p1 %patch406 -p1 %patch407 -p1 +%patch408 -p1 %if %{?with_kmp}0 %patch450 -p1 %endif @@ -731,7 +737,7 @@ rm -f $RPM_BUILD_ROOT/etc/xen/examples/*nbd install -m644 %SOURCE9 %SOURCE10 $RPM_BUILD_ROOT/etc/xen/examples/ # scripts rm -f $RPM_BUILD_ROOT/etc/xen/scripts/block-*nbd -install -m755 %SOURCE11 %SOURCE12 %SOURCE13 %SOURCE16 %SOURCE17 $RPM_BUILD_ROOT/etc/xen/scripts/ +install -m755 %SOURCE11 %SOURCE12 %SOURCE13 %SOURCE14 %SOURCE15 %SOURCE16 %SOURCE17 $RPM_BUILD_ROOT/etc/xen/scripts/ ln -s /etc/xen/scripts/vm-monitor $RPM_BUILD_ROOT/etc/xen/scripts/set-lock # Xen API remote authentication files install -d $RPM_BUILD_ROOT/etc/pam.d