<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<STYLE type=text/css> <!--@import url(scrollbar.css); --></STYLE>

<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<STYLE>                   body{FONT-SIZE:12pt; FONT-FAMILY:宋体,serif;}         </STYLE>

<META name=GENERATOR content="MSHTML 8.00.7600.16385"><BASE 
target=_blank></HEAD>
<BODY 
style="LINE-HEIGHT: 1.3; BORDER-RIGHT-WIDTH: 0px; MARGIN: 12px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" 
marginheight="0" marginwidth="0">
<DIV><FONT color=#000000 size=3 face=宋体>Hi <FONT size=2 
face=Verdana>sahid, </FONT></FONT></DIV>
<DIV>I have tested `scp -l xxx src dst` (local scp copy) and 
believe that the `-l` option is invalid in this situation,</DIV>
<DIV>it seems that `-l` only valid in remote copy.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV align=left><FONT color=#c0c0c0 size=2 face=Verdana>2014-02-17</FONT></DIV>
<DIV align=left><FONT size=2 face=Verdana>
<HR style="WIDTH: 122px; HEIGHT: 2px" id=SignNameHR align=left SIZE=2>
</FONT></DIV>
<DIV align=left><FONT color=#c0c0c0 size=2 face=Verdana><SPAN 
id=_FlashSignName>Wangpan</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Verdana>
<HR>
</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>发件人:</STRONG>sahid 
<sahid.ferdjaoui@cloudwatt.com></FONT></DIV>
<DIV><FONT size=2 
face=Verdana><STRONG>发送时间:</STRONG>2014-02-14 17:58</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>主题:</STRONG>Re: [openstack-dev] [nova] 
Should we limit the disk IO bandwidth in copy_image while creating new 
instance?</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>收件人:</STRONG>"OpenStack Development 
Mailing List (not for usage 
questions)"<openstack-dev@lists.openstack.org></FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>抄送:</STRONG></FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana>
<DIV>It could be a good idea but as Sylvain said how to configure this? Then, what about using scp instead of rsync for a local copy? </DIV>
<DIV> </DIV>
<DIV>----- Original Message ----- </DIV>
<DIV>From: "Wangpan" <hzwangpan@corp.netease.com> </DIV>
<DIV>To: "OpenStack Development Mailing List" <openstack-dev@lists.openstack.org> </DIV>
<DIV>Sent: Friday, February 14, 2014 4:52:20 AM </DIV>
<DIV>Subject: [openstack-dev] [nova] Should we limit the disk IO bandwidth in    copy_image while creating new instance? </DIV>
<DIV> </DIV>
<DIV>Currently nova doesn't limit the disk IO bandwidth in copy_image() method while creating a new instance, so the other instances on this host may be affected by this high disk IO consuming operation, and some time-sensitive business(e.g RDS instance with heartbeat) may be switched between master and slave. </DIV>
<DIV> </DIV>
<DIV>So can we use the `rsync --bwlimit=${bandwidth} src dst` command instead of `cp src dst` while copy_image in create_image() of libvirt driver, the remote image copy operation also can be limited by `rsync --bwlimit=${bandwidth}` or `scp -l=${bandwidth}`, this parameter ${bandwidth} can be a new configuration in nova.conf which allow cloud admin to config it, it's default value is 0 which means no limitation, then the instances on this host will be not affected while a new instance with not cached image is creating. </DIV>
<DIV> </DIV>
<DIV>the example codes: </DIV>
<DIV>nova/virt/libvit/utils.py: </DIV>
<DIV>diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py </DIV>
<DIV>index e926d3d..5d7c935 100644 </DIV>
<DIV>--- a/nova/virt/libvirt/utils.py </DIV>
<DIV>+++ b/nova/virt/libvirt/utils.py </DIV>
<DIV>@@ -473,7 +473,10 @@ def copy_image(src, dest, host=None): </DIV>
<DIV>         # sparse files.  I.E. holes will not be written to DEST, </DIV>
<DIV>         # rather recreated efficiently.  In addition, since </DIV>
<DIV>         # coreutils 8.11, holes can be read efficiently too. </DIV>
<DIV>-        execute('cp', src, dest) </DIV>
<DIV>+        if CONF.mbps_in_copy_image > 0: </DIV>
<DIV>+            execute('rsync', '--bwlimit=%s' % CONF.mbps_in_copy_image * 1024, src, dest) </DIV>
<DIV>+        else: </DIV>
<DIV>+            execute('cp', src, dest) </DIV>
<DIV>     else: </DIV>
<DIV>         dest = "%s:%s" % (host, dest) </DIV>
<DIV>         # Try rsync first as that can compress and create sparse dest files. </DIV>
<DIV>@@ -484,11 +487,22 @@ def copy_image(src, dest, host=None): </DIV>
<DIV>             # Do a relatively light weight test first, so that we </DIV>
<DIV>             # can fall back to scp, without having run out of space </DIV>
<DIV>             # on the destination for example. </DIV>
<DIV>-            execute('rsync', '--sparse', '--compress', '--dry-run', src, dest) </DIV>
<DIV>+            if CONF.mbps_in_copy_image > 0: </DIV>
<DIV>+                execute('rsync', '--sparse', '--compress', '--dry-run', </DIV>
<DIV>+                        '--bwlimit=%s' % CONF.mbps_in_copy_image * 1024, src, dest) </DIV>
<DIV>+            else: </DIV>
<DIV>+                execute('rsync', '--sparse', '--compress', '--dry-run', src, dest) </DIV>
<DIV>         except processutils.ProcessExecutionError: </DIV>
<DIV>-            execute('scp', src, dest) </DIV>
<DIV>+            if CONF.mbps_in_copy_image > 0: </DIV>
<DIV>+                execute('scp', '-l', '%s' % CONF.mbps_in_copy_image * 1024 * 8, src, dest) </DIV>
<DIV>+            else: </DIV>
<DIV>+                execute('scp', src, dest) </DIV>
<DIV>         else: </DIV>
<DIV>-            execute('rsync', '--sparse', '--compress', src, dest) </DIV>
<DIV>+            if CONF.mbps_in_copy_image > 0: </DIV>
<DIV>+                execute('rsync', '--sparse', '--compress', </DIV>
<DIV>+                        '--bwlimit=%s' % CONF.mbps_in_copy_image * 1024, src, dest) </DIV>
<DIV>+            else: </DIV>
<DIV>+                execute('rsync', '--sparse', '--compress', src, dest) </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>2014-02-14 </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Wangpan </DIV>
<DIV>_______________________________________________ </DIV>
<DIV>OpenStack-dev mailing list </DIV>
<DIV>OpenStack-dev@lists.openstack.org </DIV>
<DIV>http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev </DIV>
<DIV> </DIV>
<DIV>_______________________________________________ </DIV>
<DIV>OpenStack-dev mailing list </DIV>
<DIV>OpenStack-dev@lists.openstack.org </DIV>
<DIV>http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev </DIV></FONT></DIV></BODY></HTML>