[libvirt] [PATCH] Error out on missing address in 'server' type interface

It was possible to add the following interface: <interface type='server'> <source port='5558'/> </interface> Resulting in: error: internal error Process exited while reading console log output: char device redirected to /dev/pts/4 2014-08-15T05:59:17.348271Z qemu-kvm: -netdev socket,listen=(null):5558,id=hostnet0: Device 'socket' could not be initialized We already do this check for NET_TYPE_CLIENT and NET_TYPE_MCAST, do it also for NET_TYPE_SERVER. https://bugzilla.redhat.com/show_bug.cgi?id=1130390 --- src/conf/domain_conf.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5c762fa..7ea628c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7118,13 +7118,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, } if (address == NULL) { - if (def->type == VIR_DOMAIN_NET_TYPE_CLIENT || - def->type == VIR_DOMAIN_NET_TYPE_MCAST) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No <source> 'address' attribute " - "specified with socket interface")); - goto error; - } + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No <source> 'address' attribute " + "specified with socket interface")); + goto error; } else { def->data.socket.address = address; address = NULL; -- 1.8.5.5

On Fri, Aug 15, 2014 at 10:21:36AM +0200, Ján Tomko wrote:
It was possible to add the following interface: <interface type='server'> <source port='5558'/> </interface>
Resulting in: error: internal error Process exited while reading console log output: char device redirected to /dev/pts/4 2014-08-15T05:59:17.348271Z qemu-kvm: -netdev socket,listen=(null):5558,id=hostnet0: Device 'socket' could not be initialized
We already do this check for NET_TYPE_CLIENT and NET_TYPE_MCAST, do it also for NET_TYPE_SERVER.
https://bugzilla.redhat.com/show_bug.cgi?id=1130390 --- src/conf/domain_conf.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5c762fa..7ea628c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7118,13 +7118,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, }
if (address == NULL) { - if (def->type == VIR_DOMAIN_NET_TYPE_CLIENT || - def->type == VIR_DOMAIN_NET_TYPE_MCAST) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No <source> 'address' attribute " - "specified with socket interface")); - goto error; - } + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No <source> 'address' attribute " + "specified with socket interface")); + goto error; } else {
You could've removed the else to clean it up a bit. ACK either way. Martin

On 08/15/2014 04:21 PM, Ján Tomko wrote:
It was possible to add the following interface: <interface type='server'> <source port='5558'/> </interface>
Resulting in: error: internal error Process exited while reading console log output: char device redirected to /dev/pts/4 2014-08-15T05:59:17.348271Z qemu-kvm: -netdev socket,listen=(null):5558,id=hostnet0: Device 'socket' could not be initialized
We already do this check for NET_TYPE_CLIENT and NET_TYPE_MCAST, do it also for NET_TYPE_SERVER.
https://bugzilla.redhat.com/show_bug.cgi?id=1130390 --- src/conf/domain_conf.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5c762fa..7ea628c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7118,13 +7118,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, }
if (address == NULL) { - if (def->type == VIR_DOMAIN_NET_TYPE_CLIENT || - def->type == VIR_DOMAIN_NET_TYPE_MCAST) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No <source> 'address' attribute " - "specified with socket interface")); - goto error; - } + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No <source> 'address' attribute " + "specified with socket interface")); + goto error; } else { def->data.socket.address = address; address = NULL; I think domaincommon.rng should have a sync change, address element is a mandatory in client and mcast type. Is it necessary?
participants (3)
-
jiahu
-
Ján Tomko
-
Martin Kletzander