[libvirt] [PATCH] Allow no <source> for bridge interfaces

# HG changeset patch # User john.levon@sun.com # Date 1233586907 28800 # Node ID 68087e3caf39c74797720bde71a8df524ec036c8 # Parent aa50ca252e1419f30eb0e16204b48db42d92c785 Allow no <source> for bridge interfaces Historically, it was allowed to specify a bridge interface without a specific bridge source, in which case xend would choose one. Keep compatible with this behaviour. Signed-off-by: John Levon <john.levon@sun.com> diff --git a/src/domain_conf.c b/src/domain_conf.c --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -962,13 +962,10 @@ virDomainNetDefParseXML(virConnectPtr co break; case VIR_DOMAIN_NET_TYPE_BRIDGE: - if (bridge == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", - _("No <source> 'dev' attribute specified with <interface type='bridge'/>")); - goto error; - } - def->data.bridge.brname = bridge; - bridge = NULL; + if (bridge != NULL) { + def->data.bridge.brname = bridge; + bridge = NULL; + } if (script != NULL) { def->data.bridge.script = script; script = NULL; @@ -2920,8 +2917,9 @@ virDomainNetDefFormat(virConnectPtr conn break; case VIR_DOMAIN_NET_TYPE_BRIDGE: - virBufferEscapeString(buf, " <source bridge='%s'/>\n", - def->data.bridge.brname); + if (def->data.bridge.brname) + virBufferEscapeString(buf, " <source bridge='%s'/>\n", + def->data.bridge.brname); if (def->data.bridge.ipaddr) virBufferVSprintf(buf, " <ip address='%s'/>\n", def->data.bridge.ipaddr); diff --git a/src/xend_internal.c b/src/xend_internal.c --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -5149,7 +5149,8 @@ xenDaemonFormatSxprNet(virConnectPtr con switch (def->type) { case VIR_DOMAIN_NET_TYPE_BRIDGE: - virBufferVSprintf(buf, "(bridge '%s')", def->data.bridge.brname); + if (def->data.bridge.brname) + virBufferVSprintf(buf, "(bridge '%s')", def->data.bridge.brname); if (def->data.bridge.script) script = def->data.bridge.script;

On Mon, Feb 02, 2009 at 07:01:50AM -0800, john.levon@sun.com wrote:
# HG changeset patch # User john.levon@sun.com # Date 1233586907 28800 # Node ID 68087e3caf39c74797720bde71a8df524ec036c8 # Parent aa50ca252e1419f30eb0e16204b48db42d92c785 Allow no <source> for bridge interfaces
Historically, it was allowed to specify a bridge interface without a specific bridge source, in which case xend would choose one. Keep compatible with this behaviour.
Signed-off-by: John Levon <john.levon@sun.com>
ACK in principle, but this will allow the QEMU, OpenVZ & Xen XM drivers to potentially de-reference NULL when using the resulting parsed config since they assume that brname is compulsory for type=bridge. Dainel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Tue, Feb 03, 2009 at 02:27:31PM +0000, Daniel P. Berrange wrote:
Allow no <source> for bridge interfaces
Historically, it was allowed to specify a bridge interface without a specific bridge source, in which case xend would choose one. Keep compatible with this behaviour.
ACK in principle, but this will allow the QEMU, OpenVZ & Xen XM drivers to potentially de-reference NULL when using the resulting parsed config since they assume that brname is compulsory for type=bridge.
I'll fix them up. Should the first two throw an error back? I'll also add a comment explaining why we let it through. regards john

On Tue, Feb 03, 2009 at 03:44:03PM +0000, John Levon wrote:
On Tue, Feb 03, 2009 at 02:27:31PM +0000, Daniel P. Berrange wrote:
Allow no <source> for bridge interfaces
Historically, it was allowed to specify a bridge interface without a specific bridge source, in which case xend would choose one. Keep compatible with this behaviour.
ACK in principle, but this will allow the QEMU, OpenVZ & Xen XM drivers to potentially de-reference NULL when using the resulting parsed config since they assume that brname is compulsory for type=bridge.
I'll fix them up. Should the first two throw an error back? I'll also add a comment explaining why we let it through.
Yeah, they don't support the idea of a 'default' bridge - its just a (bad) artifact of Xen's vif-bridge script that really shouldn't be used if you want reliable guest configs. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (3)
-
Daniel P. Berrange
-
John Levon
-
john.levon@sun.com