Implement vm.storagecache and vm.storageformat
It has been requested to make these tunables available since different storage schemes can benefit greatly from them
This commit is contained in:
		| @@ -191,7 +191,7 @@ vmmaster => { | ||||
|     } | ||||
| }, | ||||
| vm => { | ||||
|     cols => [qw(node mgr host migrationdest storage storagemodel cfgstore memory cpus nics nicmodel bootorder clockoffset virtflags master vncport textconsole powerstate beacon datacenter cluster guestostype othersettings vidmodel vidproto vidpassword comments disable)], | ||||
|     cols => [qw(node mgr host migrationdest storage storagemodel storagecache storageformat cfgstore memory cpus nics nicmodel bootorder clockoffset virtflags master vncport textconsole powerstate beacon datacenter cluster guestostype othersettings vidmodel vidproto vidpassword comments disable)], | ||||
|     keys => [qw(node)], | ||||
|     tablespace =>'XCATTBS32K', | ||||
|     table_desc => 'Virtualization parameters', | ||||
| @@ -230,6 +230,8 @@ vm => { | ||||
| 	'vidproto' => "Request a specific protocol for remote video access be set up.  For example, spice in KVM.", | ||||
| 	'vidmodel' => "Model of video adapter to provide to guest.  For example, qxl in KVM", | ||||
| 	'vidpassword' => "Password to use instead of temporary random tokens for VNC and SPICE access", | ||||
|     'storagecache' => "Select caching scheme to employ.  E.g. KVM understands 'none', 'writethrough' and 'writeback'", | ||||
|     'storageformat' => "Select disk format to use by default (e.g. raw versus qcow2)", | ||||
|     } | ||||
| }, | ||||
| hypervisor => { | ||||
| @@ -2236,6 +2238,14 @@ my @nodeattrs = ( | ||||
|                  tabentry => 'vm.storagemodel', | ||||
|                  access_tabentry => 'vm.node=attr:node', | ||||
|                 }, | ||||
|                 {attr_name => 'vmstoragecache', | ||||
|                  tabentry => 'vm.storagecache', | ||||
|                  access_tabentry => 'vm.node=attr:node', | ||||
|                 }, | ||||
|                 {attr_name => 'vmstorageformat', | ||||
|                  tabentry => 'vm.storageformat', | ||||
|                  access_tabentry => 'vm.node=attr:node', | ||||
|                 }, | ||||
|                 {attr_name => 'vmcfgstore', | ||||
|                  tabentry => 'vm.cfgstore', | ||||
|                  access_tabentry => 'vm.node=attr:node', | ||||
|   | ||||
| @@ -26,7 +26,7 @@ sub grab_table_data{ #grab table data relevent to VM guest nodes | ||||
|   if ($vpdtab) { | ||||
|       $cfghash->{vpd} = $vpdtab->getNodesAttribs($noderange,['uuid']); | ||||
|   } | ||||
|   $cfghash->{vm} = $vmtab->getNodesAttribs($noderange,['node','host','migrationdest','cfgstore','storage','vidmodel','vidproto','vidpassword','storagemodel','memory','cpus','nics','nicmodel','bootorder','virtflags','datacenter','guestostype','othersettings','master']); | ||||
|   $cfghash->{vm} = $vmtab->getNodesAttribs($noderange,['node','host','migrationdest','cfgstore','storage','storagecache','storageformat','vidmodel','vidproto','vidpassword','storagemodel','memory','cpus','nics','nicmodel','bootorder','virtflags','datacenter','guestostype','othersettings','master']); | ||||
|   my $mactab = xCAT::Table->new("mac",-create=>1); | ||||
|   my $nrtab= xCAT::Table->new("noderes",-create=>1); | ||||
|   $cfghash->{mac} = $mactab->getAllNodeAttribs(['mac'],1); | ||||
|   | ||||
| @@ -488,6 +488,10 @@ sub build_diskstruct { | ||||
|       $cdhash->{target}->{dev}='hdc'; | ||||
|       push @returns,$cdhash; | ||||
|     } | ||||
|     my $cachemethod = "none"; | ||||
|     if ( $confdata->{vm}->{$node}->[0]->{storagecache}) { | ||||
|         $cachemethod = $confdata->{vm}->{$node}->[0]->{storagecache}; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     if (defined $confdata->{vm}->{$node}->[0]->{storage}) { | ||||
| @@ -530,8 +534,7 @@ 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->{driver}->{cache}=$cachemethod; | ||||
|                     $tdiskhash->{source}->{file}=$_; | ||||
|                     $tdiskhash->{target}->{dev} = $disks{$_}->{device}; | ||||
|                     if ($disks{$_} =~ /^vd/) { | ||||
| @@ -1209,13 +1212,17 @@ sub createstorage { | ||||
|     #my $diskstruct = shift; | ||||
|     my $node = $cfginfo->{node}; | ||||
|     my @flags = split /,/,$cfginfo->{virtflags}; | ||||
|     my $format; | ||||
|     foreach (@flags) { | ||||
|         if (/^imageformat=(.*)\z/) { | ||||
|             $imgfmt=$1; | ||||
|             $format=$1; | ||||
|         } elsif (/^clonemethod=(.*)\z/) { | ||||
|             $clonemethod=$1; | ||||
|         } | ||||
|     } | ||||
|     if ($cfginfo->{storageformat}) { | ||||
|         $format = $cfginfo->{storageformat}; | ||||
|     } | ||||
|     my $mountpath; | ||||
|     my $pathappend; | ||||
|  | ||||
| @@ -1242,7 +1249,7 @@ sub createstorage { | ||||
|     if ($filename =~ /^nfs:/ or $filename =~ /^dir:/ or $filename =~ /^lvm:/) { #libvirt storage pool to be used for this | ||||
|         my @sizes = split /,/,$size; | ||||
|         foreach (@sizes) { | ||||
|             get_filepath_by_url(url=>$filename,dev=>$prefix.shift(@suffixes),create=>$_, force=>$force); | ||||
|             get_filepath_by_url(url=>$filename,dev=>$prefix.shift(@suffixes),create=>$_, force=>$force, format=>$format); | ||||
|         } | ||||
|     }else{ | ||||
|         oldCreateStorage($filename, $mastername, $size, $cfginfo, $force); | ||||
| @@ -1653,6 +1660,15 @@ sub chvm { | ||||
|                 $suffix=$1; | ||||
|                 $format='raw'; | ||||
|             } | ||||
|             if ($confdata->{vm}->{$node}->[0]->{storageformat}) { | ||||
|                 $format = $confdata->{vm}->{$node}->[0]->{storageformat}; | ||||
|             } | ||||
|     	    #when creating a new disk not cloned from anything, disable cache as copy on write content similarity is a lost cause... | ||||
|             my $cachemode = 'none'; | ||||
|             #unless user knows better | ||||
|             if ($confdata->{vm}->{$node}->[0]->{storagecache}) { | ||||
|                 $cachemode = $confdata->{vm}->{$node}->[0]->{storagecache}; | ||||
|             } | ||||
|             my $bus; | ||||
|             if ($suffix =~ /^sd/) { | ||||
|                 $bus='scsi'; | ||||
| @@ -1661,8 +1677,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 = "<disk type='file' device='disk'><driver name='qemu' type='$format' cache='none'/><source file='$_'/><target dev='$suffix' bus='$bus'/></disk>"; | ||||
|             my $xml = "<disk type='file' device='disk'><driver name='qemu' type='$format' cache='$cachemode'/><source file='$_'/><target dev='$suffix' bus='$bus'/></disk>"; | ||||
|             if ($currstate eq 'on') { #attempt live attach | ||||
|               eval { | ||||
|               $dom->attach_device($xml); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user