From 625bbecc441ae9844f4d3ecd92b1bc69ff89c472 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 30 Jan 2013 19:37:33 +0000 Subject: [PATCH] On rmvm, do not destroy CDs On storage block device creation, disable cache for new disks but enable cache for non-detached qcow2 for read cache benefit at the host layer git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15022 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/kvm.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index cc40295b1..bf9ab3857 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -514,6 +514,8 @@ sub build_diskstruct { $tdiskhash->{device}='disk'; $tdiskhash->{driver}->{name}='qemu'; $tdiskhash->{driver}->{type}=$disks{$_}->{format}; + $tdiskhash->{driver}->{cache}="none"; #in this scenario, making a brand new vm, there is not much the hypervisor cache can do for us that the + #guest cannot do for itself $tdiskhash->{source}->{file}=$_; $tdiskhash->{target}->{dev} = $disks{$_}->{device}; if ($disks{$_} =~ /^vd/) { @@ -1489,6 +1491,8 @@ sub rmvm { my @purgedisks = $deadman->findnodes("/domain/devices/disk/source"); my $disk; foreach $disk (@purgedisks) { + my $disktype = $disk->parentNode()->getAttribute("device"); + if ($disktype eq "cdrom") { next; } my $file = $disk->getAttribute("file"); my $vol = $hypconn->get_storage_volume_by_path($file); if ($vol) { @@ -1613,6 +1617,7 @@ sub chvm { } elsif ($suffix =~ /vd/) { $bus='virtio'; } + #when creating a new disk not cloned from anything, disable cache as copy on write content similarity is a lost cause... my $xml = ""; if ($currstate eq 'on') { #attempt live attach eval { @@ -2101,6 +2106,12 @@ sub clone_vm_from_master { } my $newfilename=$newvol->get_path(); $disk->findnodes("./source")->[0]->setAttribute("file"=>$newfilename); + if (not $detach) { #if we are a copied image, enable writethrough cache in order to reduce trips out to disk + #but if the format is not qcow2, still leave it at 'none' + my $type = $disk->findnodes("./driver")->[0]->getAttribute("type"); + if ($type eq "qcow2") { $disk->findnodes("./driver")->[0]->setAttribute("cache"=>"writethrough"); } + } + } my $textxml=$newnodexml->toString(); $updatetable->{kvm_nodedata}->{$node}->{xml}=$textxml;