Repository navigation
Conversation
A VPC has no rate of its own: the public NICs of its virtual routers take the rate of the first guest network offering found on the router (in no particular order), and changing it means changing network offerings and rebuilding the routers. createVPC and updateVPC get a networkrate parameter (Mbps, 0 = unlimited), stored as a VPC detail. getNetworkRate() uses it for the public NICs of the VPC's routers ahead of the network offering rule. updateVPC applies a changed rate to the running KVM routers at once: UpdateVmNicCommand gets an optional rate, and the KVM agent updates the live interface's bandwidth. Stopped routers, and routers on other hypervisors, take it at their next start. Root admins can set any rate. Other callers can set 1 up to the new account-scoped setting vpc.max.network.rate; with its default of 0 they cannot set a rate at all, so nothing changes for existing clouds. The domain XML parser now also reads a NIC's link state, so a rate update does not bring a NIC that was set down back up.
UpdateVmNicCommand rebuilds the interface XML from the parsed domain and hands it to updateDeviceFlags(). The parser ignored <rom bar='off'/>, which virtual router NICs always have, so the rebuilt XML asked libvirt to turn the ROM BAR back on, and libvirt refused: "Operation not supported: cannot modify network device rom bar setting". The parser now keeps it.
A failed live apply leaves the new rate stored. Skipping an unchanged rate meant a retry never reached the routers, so a repeated updateVPC now applies it again.
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
LibvirtVMDef writes version-dependent device XML (NIC bandwidth, packed virtqueues, ...) from static versions that were only set when a VM was defined. After an agent restart, and before the first VM start on the host, they were 0, so XML built in that window silently lost those parts: a plugged NIC came up without its rate limit or packed virtqueues, and a live NIC update (UpdateVmNicCommand) failed because libvirt refuses to change the driver options or the bandwidth it no longer saw. The versions are now handed to LibvirtVMDef when the agent reads them at configure time.
- The rate is applied to the routers after the VPC is updated and restarted, and a router it could not be applied to no longer fails the update half way: the update is saved, and the error names the routers, which get the rate at their next start or when the update is repeated. Routers that are starting or migrating are reported too, as they can keep their old rate. - The routers get the rate the public NIC actually has, from the network model, so a VPC networkrate of 0 is unlimited there as on every other NIC (-1), which XenServer needs. - A root admin can set networkrate=-1 to return a VPC to the rate of its network offering. - networkrate is at most 16777215 Mbps, the highest every hypervisor can turn into kilobytes per second without overflowing. - vpc.max.network.rate is a system setting, which a domain admin cannot raise for an account of the domain. - A networkrate-only update no longer calls the Netris provider's VPC update.
The live update writes the NIC back as the domain XML parser read it, which keeps only what the bridge VIF driver writes. Other drivers add more, like an Open vSwitch port and its VLAN tag, which the update would drop or libvirt would refuse to change. Such NICs get the new rate at the VM's next start. getInterface() also skips NICs the parser gives no MAC address, like direct and vhost-user ones, instead of failing on them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
networkrateparameter (Mbps) tocreateVPCandupdateVPCand returns it in the VPC response. The rate is stored as the VPC detailnetworkrateand is used for the public NICs of the VPC's routers ahead of the network offering's rate; 0 is unlimited, like an offering rate of 0, and a root admin can set -1 to return the VPC to its offering's rate. A new system settingvpc.max.network.rate, set per account, caps what a non-root caller may set: the default 0 means they cannot set a rate, and a value must be between 1 and the cap. Every caller is limited to 16777215 Mbps, the most every hypervisor can turn into kilobytes per second.updateVPCapplies a new rate to running KVM routers live, after the rest of the update is saved:UpdateVmNicCommandcarries an optional rate, and the KVM wrapper reads the running NIC's XML, sets the new<bandwidth>and writes it back withupdateDeviceFlags(LIVE). Routers it cannot reach, or that are starting or migrating, are named in an error while the update stays saved; repeating it with the same rate retries them, and they get it at their next start anyway. libvirt refuses the live update when anything else in the NIC differs from the running device, which exposed two existing agent bugs on that path, both fixed here: the domain XML parser dropped the NIC's<rom bar='off'/>, andLibvirtVMDefonly learned the libvirt and QEMU versions when a VM was defined, so after an agent restart the rebuilt XML lacked<bandwidth>and driver options; the agent now reads the versions at configure time. The live update is limited to NICs of the bridge VIF driver, as the parsed NIC lacks what other drivers add, such as an Open vSwitch port. Unit tests cover validation, storage, the applied rate, the error path and the KVM side.