[PATCHv2 0/9] new virNetworkUpdate API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



=====

Changes from V1:

1) implemented Eric's suggested change to make "command"
   a separate arg rather than squeezing it into the flags

2) already pushed the first two ACKed patches (not directly related to
   new API

3) added new patch at the end implementing updates of dhcp host
   entries.


This patchset implements a new API function called virNetworkUpdate
which enables updating certain parts of a libvirt network's definition
without the need to destroy/re-start the network. This is especially
useful, for example, to add/remove hosts from the dhcp static hosts
table, or change portgroup settings.

This was previously discussed in this thread:

 https://www.redhat.com/archives/libvir-list/2012-August/msg01535.html

continuing here in September:

 https://www.redhat.com/archives/libvir-list/2012-September/msg00328.html

with the final form here:

 https://www.redhat.com/archives/libvir-list/2012-September/msg00465.html

In short, the single function has a "section" specifier which tells
the part of the network definition to be updated, a "parentIndex" that
gives the index of the *parent* element containing this section (when
there are multiples - in particular in the case of the <ip> element),
and a fully formed XML element which will be added as-is in the case
of VIR_NETWORK_UPDATE_ADD_* (after checking for a duplicate), used to
search for the specific element to delete in case of
VIR_NETWORK_UPDATE_DELETE, and used both to find the existing element
and replace its current contents in the case of VIR_UPDATE_EXISTING
(this implies that you can't change the change the attribute used for
indexing, e.g. the name of a portgroup, or mac address of a dhcp host
entry).

An example of use: to add a dhcp host entry to network "net", you would do this:

   virNetworkUpdate(net, VIR_NETWORK_UPDATE_COMMAND_ADD_LAST,
                    VIR_NETWORK_SECTION_IP_DHCP_HOST, -1,
                    "<host mac='00:11:22:33:44:55' ip='192.168.122.5'/>",
                    VIR_NETWORK_UPDATE_AFFECT_LIVE
                    | VIR_NETWORK_UPDATE_AFFECT_CONFIG);

To delete that same entry:

   virNetworkUpdate(net, VIR_NETWORK_UPDATE_COMMAND_DELETE,
                     VIR_NETWORK_SECTION_IP_DHCP_HOST, -1,
                    "<host mac='00:11:22:33:44:55'/>",
                    VIR_NETWORK_UPDATE_AFFECT_LIVE
                    | VIR_NETWORK_UPDATE_AFFECT_CONFIG);

If you wanted to force any of these to affect the dhcp host list in
the 3rd <ip> element of the network, you would replace "-1" with "2".

Another example: to modify the portgroup named "engineering" (e.g. to
increase the inbound average bandwidth from 1000 to 2000):

    virNetworkUpdate(net, VIR_NETWORK_UPDATE_COMMAND_MODIFY,
                     VIR_NETWORK_SECTION_PORTGROUP, -1,
                     "<portgroup name='engineering' default='yes'>"
                     "  <virtualport type='802.1Qbh'>"
                     "    <parameters profileid='test'/>"
                     "  </virtualport>"
                     "  <bandwidth>"
                     "    <inbound average='2000' peak='5000' burst='5120'/>"
                     "    <outbound average='1000' peak='5000' burst='5120'/>"
                     "  </bandwidth>"
                     "</portgroup>",
                     VIR_NETWORK_UPDATE_LIVE | VIR_NETWORK_UPDATE_CONFIG)

(note that parentIndex is irrelevant for PORTGROUP, since they are in
the toplevel of <network>, so there aren't multiple instances of
parents. In such cases, the caller *must* set parentIndex to -1 or 0 -
any other value indicates that they don't understand the purpose/usage
of parentIndex, so it must result in an error. Also note that the
above function would fail if it couldn't find an existing portgroup
with name='engineering' (i.e. it wouldn't automatically add a new one).)

Adding support for each of the different sections has been reduced to
a single function that handles the update of a virNetworkDef; all the
logic to determine which virNetworkDef (def or newDef) and to
restart/SIGHUP the appropriate daemons is in higher levels and is 100%
complete. The low level functions aren't yet finished, although the
function for IP_DHCP_HOST is nearly done.

As usual, several of the patches are re-factoring existing code, and a
couple are bugfixes that are only peripherally related:

1/9+2/9 - actual API
3/9 - utility functions to simplify API implementation
4/9 - framework for backend that updates the virNetworkDef
5/9 - refactoring in bridge_driver
6/9 - virNetworkUpdate for bridge_driver
7/9 - virNetworkUpdate for test_driver
8/9 - simple troubleshooting aid - restart dnsmasq/radvd
      when libvirtd is restarted (if its process is missing).
9/9 - implement backend for VIR_NETWORK_SECTION_IP_DHCP_HOST

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]