[libvirt] [PATCH] Fix adding ports to OVS bridges without VLAN tags
Daniel Veillard
veillard at redhat.com
Fri Aug 31 03:23:25 UTC 2012
On Thu, Aug 30, 2012 at 04:38:06PM -0400, Kyle Mestery wrote:
> The introduction of the new VLAN code, along with the fix
> from 5e465df6be8bcb00f0b4bff831e91f4042fae272, caused the
> addition of OVS ports to fail with the following message:
>
> ovs-vsctl: 00002|vsctl|ERR|: missing column name
>
> This fix takes into account the VLAN arguments are optional,
> and correctly sets up the command line to run the "ovs-vsctl"
> command to add ports to the OVS bridge.
>
> Signed-off-by: Kyle Mestery <kmestery at cisco.com>
> CC: Eric Blake <eblake at redhat.com>
> ---
> V2:
> - Use virBufferUse() to check if a buffer is in use. Found
> by Eric Blake.
> ---
> src/util/virnetdevopenvswitch.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
> index 00271a0..764f478 100644
> --- a/src/util/virnetdevopenvswitch.c
> +++ b/src/util/virnetdevopenvswitch.c
> @@ -104,9 +104,15 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
> }
>
> cmd = virCommandNew(OVSVSCTL);
> +
> + virCommandAddArgList(cmd, "--", "--may-exist", "add-port",
> + brname, ifname, NULL);
> +
> + if (virBufferUse(&buf) != 0)
> + virCommandAddArgList(cmd, virBufferCurrentContent(&buf), NULL);
> +
> if (ovsport->profileID[0] == '\0') {
> - virCommandAddArgList(cmd, "--", "--may-exist", "add-port",
> - brname, ifname, virBufferCurrentContent(&buf),
> + virCommandAddArgList(cmd,
> "--", "set", "Interface", ifname, attachedmac_ex_id,
> "--", "set", "Interface", ifname, ifaceid_ex_id,
> "--", "set", "Interface", ifname, vmid_ex_id,
> @@ -114,8 +120,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
> "external-ids:iface-status=active",
> NULL);
> } else {
> - virCommandAddArgList(cmd, "--", "--may-exist", "add-port",
> - brname, ifname, virBufferCurrentContent(&buf),
> + virCommandAddArgList(cmd,
> "--", "set", "Interface", ifname, attachedmac_ex_id,
> "--", "set", "Interface", ifname, ifaceid_ex_id,
> "--", "set", "Interface", ifname, vmid_ex_id,
Okay, ACK,
pushed, thanks !
Still there is something which looks wrong, if we don't have a profileID
why do we end up with "" instead of NULL ? I'm seeing various tests for
profileID[0] over conf/*.c and util/*.c , and that sounds wrong to me.
if there is no data, store NULL ! Then test for profileID instead of
profileID[0]. Then there is no risk of a crash because abscence of data
led to NULL instead of an empty string, the code is more resilient !
I expect a followup patch cleaning this up, but after 0.10.1 ...
thanks !
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
More information about the libvir-list
mailing list