qemu 2.11 need a power of 2 cache size.

"
Parameter 'xbzrle_cache_size' expects is invalid,
it should be bigger than target page size and a power of two
"

roundup to near power of 2 value
---
 PVE/QemuMigrate.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 937a855..6b49684 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -691,6 +691,8 @@ sub phase2 {
     # set cachesize to 10% of the total memory
     my $memory =  $conf->{memory} || $defaults->{memory};
     my $cachesize = int($memory * 1048576 / 10);
+    $cachesize = round_powerof2($cachesize);
+
     $self->log('info', "set cachesize: $cachesize");
     eval {
        PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-cache-size", 
value => int($cachesize));
@@ -1031,4 +1033,10 @@ sub final_cleanup {
     # nothing to do
 }
 
+sub round_powerof2 {
+ local $_ = (shift)-1;
+ my $num = (2**int(log($_)/log(2)))-1;
+ return ++($_ |= $num);
+}
+
 1;
-- 
2.11.0

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to