On 03/15/2013 03:48 PM, Gene Czarcinski wrote:
On 03/15/2013 02:10 PM, Gene Czarcinski wrote:
This patch adds support for adding a static route for
a network.  The "via" specifies the gateway's IP
address.  Both IPv4 and IPv6 static routes are
supported although it is expected that this
functionality will have more use with IPv6.

Extensive tests are done to validate that the input
definitions are correct.  For example, for a static
route ip definition, the address must be for a network
and not a host.  Additional checks are added to ensure
that the specified gateway has a network defined on
this bridge.

Whan a static route is added to a bridge, there is a slight
possibility that the gateway address will be incorrect.  If
this is handled as an error, that bridge becomes unusable and
can only be recovered by rebooting.  If the error is
ignored, then that network can be destroyed and the network
definition file edited to correct the problem.  Unfortunately,
the error message only appears in syslog.  However, with
the checks performed when the network definition file is parsed,
it is unlikely that this condition will ever occur.

The command used is of the following form:

ip route add <address>/<prefix> via <gateway> dev <virbr-bridge> \
proto static metric 1
When you examine that part of the patch in virNetworkIPdefParseXML() in network_conf.c, you will nitice that I have added a large number of tests/check that the data entered is valid. These checks and the associated error messages are intended for the situation where you are using virsh net-edit. As such, I believe these are quite good with respect to providing some guidance to the user.

Unfortuately, these same parse function is used by libvert without virsh and, when that occurs and the network definition (xml) file is found to be flawed, libvert will ignore that network definition. Better diagnostics and recovery is needed here but (currently) it is not clear how to provide it.

It would be nice if there was some way to "force" virsh net-edit to edit the xml file regardless of errors which could then be corrected as if a good file was being edited and bad configuration was entered. [any suggestions welcome]

OK, I believe I have found a way to get things correct and NOT require a libvirtd restart. It does not ijvolve code but instead uses a process of existing functions.

Assume you have a network such as net3 defined (there is a net3.xml file) but the network does not show up in a net-list but you know it is there. OK, simply use:
         virsh net-define /etc/libvirt/qemu/networks/net3.xml
If the network definition is good, it will be loaded. If it is not, there a diagnostic message will be issued pointing to the error. Use vi to correct the error and then run net-define again. Repeat until the network is defined.

This was obvious after I realized what I could do but not so obvious before that. I am going to add some documentation in the docs/formatnetwork.html.in file to describe this process.

Question: should some additional diagnostic messaging be issued when net-edit, net-start, net-destroy, etc. to use net-define or net-create to determine the problem with the network (xml) definition file.

Gene

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

Reply via email to