Revision 40086e5c src/tm_mad/qcow2/cpds

View differences:

src/tm_mad/qcow2/cpds
74 74

  
75 75
DST_PATH="${SRC_DS_PATH}${DST_ARG_PATH##$DST_DS_PATH}"
76 76

  
77
if [ "$CLONE" != "YES" ]; then
78
    SRC_PATH="$DISK_SRC"
79
fi
80

  
81 77
if [ "$SNAP_ID" != "-1" ]; then
78
    [ "$CLONE" != "YES" ] && SRC_PATH="$DISK_SRC"
82 79
    SRC_PATH="$SRC_PATH.snap/$(($SNAP_ID+1))"
83 80
fi
84 81

  
85 82
#-------------------------------------------------------------------------------
86 83
# Move the image back to the datastore
87 84
#-------------------------------------------------------------------------------
88
CPSCRIPT=$(cat <<EOF
85

  
86
CPDS_CMD=$(cat <<EOF
89 87
SRC_READLN=\$($READLINK -f $SRC_PATH)
90 88
DST_READLN=\$($READLINK -f $DST_PATH)
91 89

  
......
97 95
EOF
98 96
)
99 97

  
98
# TODO: after taking a snapshot, if you try to save the current state, and if
99
# cache='none', it will fail, as the changes are not commited to the image. This
100
# happens even after running 'sync' inside the guest and in the hypervisor. A
101
# solution that does work is to run:
102
#
103
#     $ touch $DST_PATH
104
#     $ virsh blockcopy --domain $DEPLOY_ID $TARGET $DST_PATH --wait --verbose
105
#
106
# However this is in turn problematic because there is no easy way to tell if the
107
# global configuration for taking snapshot is live, detach or suspend. If it's
108
# live, and the VM is running, the virsh blockcopy can be run, otherwise it should
109
# never be run. If we can detect this configuration parameter in this script, and
110
# check with libvirt if the vm is running, we should have all the information we
111
# need to do choose whether to run the blockcopy or not.
112

  
100 113
log "Copying $SRC_PATH to datastore as $DST_PATH"
101 114

  
102
ssh_exec_and_log $SRC_HOST "$CPSCRIPT" "Could not move image $DST_PATH"
115
ssh_exec_and_log $SRC_HOST "$CPDS_CMD" "Could not move image $DST_PATH"
103 116

  
104 117
exit 0

Also available in: Unified diff