diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 264a6a9bce1..314ab431d62 100755 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -2218,20 +2218,22 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe private String copy_vhd_to_secondarystorage(Connection conn, String mountpoint, String vdiuuid, String sruuid, int wait) { String results = callHostPluginAsync(conn, "vmopspremium", "copy_vhd_to_secondarystorage", wait, "mountpoint", mountpoint, "vdiuuid", vdiuuid, "sruuid", sruuid); - + String errMsg = null; if (results == null || results.isEmpty()) { - String msg = "copy_vhd_to_secondarystorage return null"; - s_logger.warn(msg); - throw new CloudRuntimeException(msg); - } - String[] tmp = results.split("#"); - String status = tmp[0]; - if (status.equals("0")) { - return tmp[1]; + errMsg = "copy_vhd_to_secondarystorage return null"; } else { - s_logger.warn(tmp[1]); - throw new CloudRuntimeException(tmp[1]); + String[] tmp = results.split("#"); + String status = tmp[0]; + if (status.equals("0")) { + return tmp[1]; + } else { + errMsg = tmp[1]; + } } + String source = vdiuuid + ".vhd"; + killCopyProcess(conn, source); + s_logger.warn(errMsg); + throw new CloudRuntimeException(errMsg); } String upgradeSnapshot(Connection conn, String templatePath, String snapshotPath) { diff --git a/scripts/vm/hypervisor/xenserver/copy_vhd_to_secondarystorage.sh b/scripts/vm/hypervisor/xenserver/copy_vhd_to_secondarystorage.sh index a50078d0b9a..cb37f21f939 100755 --- a/scripts/vm/hypervisor/xenserver/copy_vhd_to_secondarystorage.sh +++ b/scripts/vm/hypervisor/xenserver/copy_vhd_to_secondarystorage.sh @@ -67,6 +67,7 @@ vhdfile=$localmp/${vdiuuid}.vhd if [ $type == "nfs" -o $type == "ext" ]; then dd if=/var/run/sr-mount/$sruuid/${vdiuuid}.vhd of=$vhdfile bs=2M if [ $? -ne 0 ]; then + rm -f $vhdfile echo "8#failed to copy /var/run/sr-mount/$sruuid/${vdiuuid}.vhd to secondarystorage" cleanup exit 0 @@ -88,10 +89,17 @@ elif [ $type == "lvmoiscsi" -o $type == "lvm" -o $type == "lvmohba" ]; then size=$((size>>21)) size=$((size+1)) dd if=/dev/VG_XenStorage-$sruuid/VHD-$vdiuuid of=$vhdfile bs=2M count=$size + if [ $? -ne 0 ]; then + rm -f $vhdfile + echo "8#failed to copy /dev/VG_XenStorage-$sruuid/VHD-$vdiuuid to secondarystorage" + cleanup + exit 0 + fi #in byte unit size=$((size<<21)) vhd-util modify -s $size -n $vhdfile if [ $? -ne 0 ]; then + rm -f $vhdfile echo "11#failed to change $vhdfile physical size" cleanup exit 0