opennebula-4.12.1-runasuser.diff
opennebula-4.12.1-runasuser/src/tm/TransferManager.cc 2015-10-10 09:52:48.332082925 -0500 | ||
---|---|---|
397 | 397 |
<< vm->get_hostname() << ":" |
398 | 398 |
<< vm->get_remote_system_dir() << "/disk." << disk_id << " " |
399 | 399 |
<< vm->get_oid() << " " |
400 |
<< vm->get_ds_id() |
|
400 |
<< vm->get_ds_id() << " " |
|
401 |
<< (vm->get_oid() + 131072) << " " |
|
402 |
<< (vm->get_oid() + 131072) |
|
401 | 403 |
<< endl; |
402 | 404 |
} |
403 | 405 |
else if ( type == "FS" ) |
... | ... | |
428 | 430 |
<< vm->get_hostname() << ":" |
429 | 431 |
<< vm->get_remote_system_dir() << "/disk." << disk_id << " " |
430 | 432 |
<< vm->get_oid() << " " |
431 |
<< vm->get_ds_id() |
|
433 |
<< vm->get_ds_id() << " " |
|
434 |
<< (vm->get_oid() + 131072) << " " |
|
435 |
<< (vm->get_oid() + 131072) |
|
432 | 436 |
<< endl; |
433 | 437 |
} |
434 | 438 |
else |
... | ... | |
479 | 483 |
xfr << vm->get_hostname() << ":" |
480 | 484 |
<< vm->get_remote_system_dir() << "/disk." << disk_id << " " |
481 | 485 |
<< vm->get_oid() << " " |
482 |
<< ds_id |
|
486 |
<< ds_id << " " |
|
487 |
<< (vm->get_oid() + 131072) << " " |
|
488 |
<< (vm->get_oid() + 131072) |
|
483 | 489 |
<< endl; |
484 | 490 |
} |
485 | 491 | |
... | ... | |
536 | 542 |
<< vm->get_hostname() << ":" |
537 | 543 |
<< base_dst.str() << " " |
538 | 544 |
<< vm->get_oid() << " " |
539 |
<< ds_id |
|
545 |
<< ds_id << " " |
|
546 |
<< (vm->get_oid() + 131072) << " " |
|
547 |
<< (vm->get_oid() + 131072) |
|
540 | 548 |
<< endl; |
541 | 549 | |
542 | 550 |
return base_dst.str(); |
opennebula-4.12.1-runasuser/src/tm_mad/common/mkimage 2015-10-10 09:52:48.332082925 -0500 | ||
---|---|---|
31 | 31 |
VMID=$4 |
32 | 32 |
DSID=$5 |
33 | 33 | |
34 |
VMUID="$6" |
|
35 |
VMGID="$7" |
|
36 | ||
34 | 37 |
if [ -z "${ONE_LOCATION}" ]; then |
35 | 38 |
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh |
39 |
KVMRC=/var/lib/one/remotes/vmm/kvm/kvmrc |
|
36 | 40 |
else |
37 | 41 |
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh |
42 |
KVMRC=$ONE_LOCATION/var/remotes/vmm/kvm/kvmrc |
|
38 | 43 |
fi |
39 | 44 | |
40 | 45 |
. $TMCOMMON |
46 |
. $KVMRC |
|
41 | 47 | |
42 | 48 |
#------------------------------------------------------------------------------- |
43 | 49 |
# Set dst path and dir |
... | ... | |
51 | 57 |
#------------------------------------------------------------------------------- |
52 | 58 |
ssh_make_path $DST_HOST $DST_DIR |
53 | 59 | |
54 |
CREATE_IMAGE="$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M"
|
|
60 |
CREATE_IMAGE="$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=$[${SIZE} * 1024 * 1024 - 1]"
|
|
55 | 61 |
MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE $SIZE` |
56 | 62 | |
57 | 63 |
MKSCRIPT=$(cat <<EOF |
58 | 64 |
set -e |
59 | 65 |
export PATH=/usr/sbin:/sbin:\$PATH |
60 | 66 |
$CREATE_IMAGE |
67 |
sudo chmod 600 $DST_PATH |
|
61 | 68 |
$MKFS_CMD |
69 |
VMUID="${VMUID}" |
|
70 |
VMGID="${VMGID}" |
|
71 |
if [ -z "\${VMUID}" -o -z "\${VMGID}" ]; then |
|
72 |
eval "\$(virsh -c $LIBVIRT_URI dumpxml one-$VMID | grep '<label>+.*:+.*</label>' | sed 's@.*<label>\(.*\)</label>@\1@;s@^+@VMUID=@;s@:+@; VMGID=@')" |
|
73 |
fi |
|
74 |
if [ -n "\${VMUID}" -a -n "\${VMGID}" ]; then |
|
75 |
sudo chown "\${VMUID}:\${VMGID}" $DST_PATH |
|
76 |
fi |
|
62 | 77 |
EOF |
63 | 78 |
) |
64 | 79 |
opennebula-4.12.1-runasuser/src/tm_mad/common/mkswap 2015-10-10 09:52:48.333082925 -0500 | ||
---|---|---|
29 | 29 |
VMID=$3 |
30 | 30 |
DSID=$4 |
31 | 31 | |
32 |
CMD="`dirname $0`/mkimage $SIZE swap $DST $VMID $DSID" |
|
32 |
VMUID="$5" |
|
33 |
VMGID="$6" |
|
34 | ||
35 |
CMD="`dirname $0`/mkimage $SIZE swap $DST $VMID $DSID $VMUID $VMGID" |
|
33 | 36 |
`$CMD` |
opennebula-4.12.1-runasuser/src/tm_mad/qcow2/clone 2015-10-10 09:52:48.333082925 -0500 | ||
---|---|---|
30 | 30 |
VMID=$3 |
31 | 31 |
DSID=$4 |
32 | 32 | |
33 |
VMUID="$5" |
|
34 |
VMGID="$6" |
|
35 | ||
33 | 36 |
if [ -z "${ONE_LOCATION}" ]; then |
34 | 37 |
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh |
35 | 38 |
else |
... | ... | |
57 | 60 |
#------------------------------------------------------------------------------- |
58 | 61 |
# Clone (cp) SRC into DST |
59 | 62 |
#------------------------------------------------------------------------------- |
63 |
if [ -n "${VMUID}" -a -n "${VMGID}" ]; then |
|
64 |
ADD_CMD=" && sudo chown ${VMUID}:${VMGID} $DST_PATH" |
|
65 |
fi |
|
66 | ||
60 | 67 |
case $SRC in |
61 | 68 |
http://*) |
62 | 69 |
log "Downloading $SRC into $DST_PATH" |
63 | 70 |
ssh_exec_and_log $DST_HOST \ |
64 |
"$WGET -O $DST_PATH $SRC" \ |
|
71 |
"$WGET -O $DST_PATH $SRC${ADD_CMD}" \
|
|
65 | 72 |
"Error downloading $SRC" |
66 | 73 |
;; |
67 | 74 | |
68 | 75 |
*) |
69 | 76 |
log "Cloning $SRC_PATH in $DST" |
70 | 77 | |
71 |
CLONE_CMD="cd $DST_DIR; rm -f $DST_PATH; $QEMU_IMG create -b $SRC_PATH -f qcow2 $DST_PATH"
|
|
78 |
CLONE_CMD="cd $DST_DIR && rm -f $DST_PATH && $QEMU_IMG create -b $SRC_PATH -f qcow2 $DST_PATH${ADD_CMD}"
|
|
72 | 79 |
ssh_exec_and_log "$DST_HOST" "$CLONE_CMD" "Error copying $SRC to $DST" |
73 | 80 |
;; |
74 | 81 |
esac |
opennebula-4.12.1-runasuser/src/tm_mad/shared/clone 2015-10-10 09:52:48.333082925 -0500 | ||
---|---|---|
30 | 30 |
VMID=$3 |
31 | 31 |
DSID=$4 |
32 | 32 | |
33 |
VMUID=$5 |
|
34 |
VMGID=$6 |
|
35 | ||
33 | 36 |
if [ -z "${ONE_LOCATION}" ]; then |
34 | 37 |
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh |
35 | 38 |
else |
... | ... | |
62 | 65 |
# Clone (cp) SRC into DST |
63 | 66 |
#------------------------------------------------------------------------------- |
64 | 67 | |
68 |
if [ -n "${VMUID}" -a -n "${VMGID}" ]; then |
|
69 |
ADD_CMD=" && sudo chown ${VMUID}:${VMGID} ${DST_PATH}" |
|
70 |
fi |
|
71 | ||
65 | 72 |
case $SRC in |
66 | 73 |
http://*) |
67 | 74 |
log "Downloading $SRC into $DST_PATH" |
68 | 75 |
ssh_exec_and_log $DST_HOST \ |
69 |
"$WGET -O $DST_PATH $SRC" \ |
|
76 |
"$WGET -O $DST_PATH $SRC${ADD_CMD}" \
|
|
70 | 77 |
"Error downloading $SRC" |
71 | 78 |
;; |
72 | 79 | |
73 | 80 |
*) |
74 | 81 |
log "Cloning $SRC_PATH in $DST" |
75 | 82 |
ssh_exec_and_log $DST_HOST \ |
76 |
"cd $DST_DIR; cp $SRC_PATH $DST_PATH" \
|
|
83 |
"cd $DST_DIR && cp $SRC_PATH $DST_PATH${ADD_CMD}" \
|
|
77 | 84 |
"Error copying $SRC to $DST" |
78 | 85 |
;; |
79 | 86 |
esac |
opennebula-4.12.1-runasuser/src/tm_mad/shared/ln 2015-10-10 09:52:48.333082925 -0500 | ||
---|---|---|
64 | 64 |
log "Linking $SRC_PATH in $DST" |
65 | 65 | |
66 | 66 |
ssh_exec_and_log $DST_HOST \ |
67 |
"cd $DST_DIR; rm -f $DST_PATH ; ln -s $SRC_PATH $DST_PATH" \
|
|
67 |
"cd $DST_DIR && rm -f $DST_PATH && ln -s $SRC_PATH $DST_PATH" \
|
|
68 | 68 |
"Error linking $SRC to $DST" |
69 | 69 | |
70 | 70 |
exit 0 |
opennebula-4.12.1-runasuser/src/tm_mad/ssh/mv 2015-10-10 09:52:48.333082925 -0500 | ||
---|---|---|
71 | 71 |
ssh_exec_and_log "$DST_HOST" "rm -rf '$DST_PATH'" \ |
72 | 72 |
"Error removing target path to prevent overwrite errors" |
73 | 73 | |
74 |
TAR_COPY="$SSH $SRC_HOST '$TAR -C $SRC_DS_DIR --sparse -cf - $SRC_VM_DIR'" |
|
75 |
TAR_COPY="$TAR_COPY | $SSH $DST_HOST '$TAR -C $DST_DIR --sparse -xf -'" |
|
74 |
TAR_COPY="$SSH $SRC_HOST '$SUDO $TAR -C $SRC_DS_DIR --sparse -cf - $SRC_VM_DIR | $SSH $DST_HOST '\''$SUDO $TAR -C $DST_DIR --sparse -xf -'\'''" |
|
76 | 75 | |
77 | 76 |
exec_and_log "eval $TAR_COPY" "Error copying disk directory to target host" |
78 | 77 |
opennebula-4.12.1-runasuser/src/vmm/LibVirtDriverKVM.cc 2015-10-10 09:52:48.334082925 -0500 | ||
---|---|---|
209 | 209 |
<< "' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>" |
210 | 210 |
<< endl; |
211 | 211 | |
212 |
/* Domain user information */ |
|
213 |
file << "\t<seclabel type='static' model='dac'>" << endl; |
|
214 |
file << "\t\t<label>+" << (vm->get_oid() + 131072) << ":+" << (vm->get_oid() + 131072) << "</label>" << endl; |
|
215 |
file << "\t</seclabel>" << endl; |
|
216 | ||
212 | 217 |
// ------------------------------------------------------------------------ |
213 | 218 |
// Domain name |
214 | 219 |
// ------------------------------------------------------------------------ |
opennebula-4.12.1-runasuser/src/vmm_mad/remotes/kvm/restore 2015-12-09 10:40:24.127476035 -0600 | ||
---|---|---|
20 | 20 |
source $(dirname $0)/../../scripts_common.sh |
21 | 21 | |
22 | 22 |
file=$1 |
23 |
oid="$4" |
|
24 |
if [ -z "${oid}" ]; then |
|
25 |
oid='0' |
|
26 |
fi |
|
27 |
vmuid=$[131072+$oid] |
|
28 |
vmgid="${vmuid}" |
|
23 | 29 | |
24 |
exec_and_log "virsh --connect $LIBVIRT_URI restore $file" \ |
|
30 |
# Update any newly restored VMs with the appropriate security label |
|
31 |
exec_and_log " |
|
32 |
eval EDITOR=\"sed -i 's@<label>.*</label>@<label>+$vmuid:+$vmgid</label>@'\" virsh --connect $LIBVIRT_URI save-image-edit $file || true; |
|
33 |
virsh --connect $LIBVIRT_URI restore $file |
|
34 |
" \ |
|
25 | 35 |
"Could not restore from $file" |
26 | 36 | |
27 | 37 |
rm "$file" |
opennebula-4.12.1-runasuser/src/vmm_mad/remotes/kvm/save 2015-12-09 15:44:17.058537328 -0600 | ||
---|---|---|
31 | 31 |
fi |
32 | 32 | |
33 | 33 |
touch $file |
34 |
chmod 666 $file
|
|
34 |
chmod 600 $file
|
|
35 | 35 | |
36 | 36 |
exec_and_log "virsh --connect $LIBVIRT_URI save $deploy_id $file" \ |
37 | 37 |
"Could not save $deploy_id to $file" |