<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">在 2015年3月23日,下午3:18,Dietmar Maurer <<a href="mailto:dietmar@proxmox.com" class="">dietmar@proxmox.com</a>> 写道:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">We do not use TC to rate limit qemu network devices (we use qemu internal rate</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">limit features).</span></div></blockquote></div><br class=""><div class="">hi,</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>i see those code, use tc for rate limit also?</div><div class="">———</div><div class="">QemuServer.pm</div><div class="">———</div><div class=""><div class="">……</div><div class="">Ignore content</div><div class="">……</div></div><div class=""><div class=""> die "internal error" if $opt !~ m/net(\d+)/;</div><div class=""> my $iface = "tap${vmid}i$1";</div><div class=""><br class=""></div><div class=""> if (&$safe_num_ne($oldnet->{rate}, $newnet->{rate})) {</div><div class=""> PVE::Network::tap_rate_limit($iface, $newnet->{rate});</div><div class=""> }</div></div><div class=""><div class="">……</div><div class="">Ignore content</div><div class="">……</div></div><div class="">———</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">———</div><div class="">Network.pm</div><div class="">———</div></div><div class=""><div class="">sub setup_tc_rate_limit {</div><div class=""> my ($iface, $rate, $burst, $debug) = @_;</div><div class=""><br class=""></div><div class=""> system("/sbin/tc class del dev $iface parent 1: classid 1:1 >/dev/null 2>&1");</div><div class=""> system("/sbin/tc filter del dev $iface parent ffff: protocol ip prio 50 estimator 1sec 8sec >/dev/null 2>&1”);</div><div class="">……</div><div class="">Ignore content</div><div class="">……</div><div class=""> system("/sbin/tc class ls dev $iface");</div><div class=""> system("/sbin/tc filter ls dev $iface parent ffff:");</div><div class=""> }</div><div class="">}</div></div><div class=""><br class=""></div><div class=""><div class="">sub tap_rate_limit {</div><div class=""> my ($iface, $rate) = @_;</div><div class=""><br class=""></div><div class=""> my $debug = 0;</div><div class=""> $rate = int($rate*1024*1024);</div><div class=""> my $burst = 1024*1024;</div><div class=""><br class=""></div><div class=""> setup_tc_rate_limit($iface, $rate, $burst, $debug);</div><div class="">}</div></div><div class=""><br class=""></div></body></html>