add rhel6.1 support

This commit is contained in:
Edison Su 2011-07-29 20:05:01 -07:00
parent 7d5a2f61bb
commit 8bcad6960c
5 changed files with 41 additions and 24 deletions

View File

@ -3473,22 +3473,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
/*online snapshot supported by enhanced qemu-kvm*/
private boolean isSnapshotSupported() {
File f =new File("/usr/bin/cloud-qemu-system-x86_64");
if (f.exists()) {
return true;
}
f = new File("/usr/libexec/cloud-qemu-kvm");
if (f.exists()) {
return true;
String result = executeBashScript("qemu-img --help|grep convert |grep snapshot");
if (result != null) {
return false;
} else {
return true;
}
f = new File("/usr/bin/cloud-qemu-img");
if (f.exists()) {
return true;
}
return false;
}
private Pair<Double, Double> getNicStats(String nicName) {

View File

@ -256,7 +256,10 @@ class networkConfigRedhat(serviceCfgBase, networkConfigBase):
self.syscfg.svo.stopService("NetworkManager")
self.syscfg.svo.disableService("NetworkManager")
cfo = configFileOps("/etc/sysconfig/network", self)
cfo.addEntry("NOZEROCONF", "yes")
cfo.save()
if not bash("service network restart").isSuccess():
raise CloudInternalException("Can't restart network")

View File

@ -29,6 +29,16 @@ usage() {
#set -x
qemu_img="cloud-qemu-img"
which $qemu_img
if [ $? -gt 0 ]
then
which qemu-img
if [ $? -eq 0 ]
then
qemu_img="qemu-img"
fi
fi
verify_cksum() {
@ -108,7 +118,7 @@ create_from_snapshot() {
local tmpltfs=$3
local tmpltname=$4
cloud-qemu-img convert -f qcow2 -O qcow2 -s $snapshotName $tmpltImg /$tmpltfs/$tmpltname >& /dev/null
$qemu_img convert -f qcow2 -O qcow2 -s $snapshotName $tmpltImg /$tmpltfs/$tmpltname >& /dev/null
if [ $? -gt 0 ]
then
printf "Failed to create template /$tmplfs/$tmpltname from snapshot $snapshotName on disk $tmpltImg "

View File

@ -32,6 +32,17 @@ usage() {
exit 2
}
qemu_img="cloud-qemu-img"
which $qemu_img
if [ $? -gt 0 ]
then
which qemu-img
if [ $? -eq 0 ]
then
qemu_img="qemu-img"
fi
fi
create_snapshot() {
local disk=$1
local snapshotname=$2
@ -44,13 +55,13 @@ create_snapshot() {
return $failed
fi
cloud-qemu-img snapshot -c $snapshotname $disk
$qemu_img snapshot -c $snapshotname $disk
if [ $? -gt 0 ]
then
failed=2
printf "***Failed to create snapshot $snapshotname for path $disk\n" >&2
cloud-qemu-img snapshot -d $snapshotname $disk
$qemu_img snapshot -d $snapshotname $disk
if [ $? -gt 0 ]
then
@ -83,7 +94,7 @@ destroy_snapshot() {
return $failed
fi
cloud-qemu-img snapshot -d $snapshotname $disk
$qemu_img snapshot -d $snapshotname $disk
if [ $? -gt 0 ]
then
failed=2
@ -98,7 +109,7 @@ rollback_snapshot() {
local snapshotname=$2
local failed=0
qemu-img snapshot -a $snapshotname $disk
$qemu_img snapshot -a $snapshotname $disk
if [ $? -gt 0 ]
then
@ -125,14 +136,14 @@ backup_snapshot() {
fi
# Does the snapshot exist?
cloud-qemu-img snapshot -l $disk|grep -w "$snapshotname" >& /dev/null
$qemu_img snapshot -l $disk|grep -w "$snapshotname" >& /dev/null
if [ $? -gt 0 ]
then
printf "there is no $snapshotname on disk $disk" >&2
return 1
fi
cloud-qemu-img convert -f qcow2 -O qcow2 -s $snapshotname $disk $destPath/$destName >& /dev/null
$qemu_img convert -f qcow2 -O qcow2 -s $snapshotname $disk $destPath/$destName >& /dev/null
if [ $? -gt 0 ]
then
printf "Failed to backup $snapshotname for disk $disk to $destPath" >&2

View File

@ -1582,10 +1582,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
// Specify RAW format makes it unusable for snapshots.
privateTemplate.setFormat(ImageFormat.RAW);
}
Transaction txn = Transaction.currentTxn();
String checkSum = getChecksum(secondaryStorageHost.getId(), answer.getPath());
Transaction txn = Transaction.currentTxn();
txn.start();
privateTemplate.setChecksum(checkSum);
_templateDao.update(templateId, privateTemplate);