xenconfig: support vif bandwidth in sexpr parser and formatter

The xen sexpr config format has long supported specifying vif rate
limiting, e.g.

  (device
    (vif
      (mac '00:16:3e:1b:b1:47')
      (rate '10240KB/s')
      ...
    )
  )

Add support for mapping rate to and from <bandwidth> in the xenconfig
sexpr parser and formatter. rate is mapped to the required 'average'
attribute of the <outbound> element, e.g.

  <interface type='bridge'>
    ...
    <bandwidth>
      <outbound average='10240'/>
    </bandwidth>
  </interface>

Also add unit tests to check the conversion logic.

This patch benefits both the old xen driver and the libxl driver.
Both drivers gain support for vif bandwidth when converting to/from
domXML and xen-sxpr. In addition, the old xen driver will now be
able to handle vif 'rate' setting when communicating with xend.
This commit is contained in:
Jim Fehlig
2016-01-04 17:46:31 -07:00
parent 3d92a000ff
commit 1dd34bbb4b
9 changed files with 186 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)\
(uuid 'b5d70dd2-75cd-aca5-1776-9660b059d8bc')(on_poweroff 'destroy')\
(on_reboot 'restart')(on_crash 'restart')\
(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)\
(usb 1)(parallel none)(serial none)(device_model '/usr/lib64/xen/bin/qemu-dm')\
(vnc 1)(vncunused 0)(vncdisplay 17)(keymap 'ja')(rtc_timeoffset 0)(localtime 0)))\
(localtime 0)\
(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')\
(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(rate '10240KB/s')\
(bridge 'xenbr0')(script 'vif-bridge')(type netfront))))

View File

@@ -0,0 +1,34 @@
<domain type='xen'>
<name>fvtest</name>
<uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
<os>
<type>hvm</type>
<loader>/usr/lib/xen/boot/hvmloader</loader>
<boot dev='hd'/>
</os>
<memory unit='KiB'>409600</memory>
<vcpu>1</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<features>
<acpi/>
</features>
<devices>
<emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
<interface type='bridge'>
<source bridge='xenbr0'/>
<bandwidth>
<outbound average='10240'/>
</bandwidth>
<mac address='00:16:3e:1b:b1:47'/>
<script path='vif-bridge'/>
<model type='netfront'/>
</interface>
<disk type='file'>
<source file='/root/foo.img'/>
<target dev='ioemu:hda'/>
</disk>
<graphics type='vnc' port='5917' keymap='ja'/>
</devices>
</domain>