mirror of
https://github.com/libvirt/libvirt.git
synced 2026-08-11 13:34:45 -05:00
conf: Increase virNetDevBandwidthParse intelligence
There's this function virNetDevBandwidthParse which parses the
bandwidth XML snippet. But it's not clever much. For the
following XML it allocates the virNetDevBandwidth structure even
though it's completely empty:
<bandwidth>
</bandwidth>
Later in the code there are some places where we check if
bandwidth was set or not. And since we obtained pointer from the
parsing function we think that it is when in fact it isn't.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
@@ -43,6 +43,7 @@ struct testSetStruct {
|
||||
|
||||
#define PARSE(xml, var) \
|
||||
do { \
|
||||
int rc; \
|
||||
xmlDocPtr doc; \
|
||||
xmlXPathContextPtr ctxt = NULL; \
|
||||
\
|
||||
@@ -54,11 +55,12 @@ struct testSetStruct {
|
||||
&ctxt))) \
|
||||
goto cleanup; \
|
||||
\
|
||||
(var) = virNetDevBandwidthParse(ctxt->node, \
|
||||
VIR_DOMAIN_NET_TYPE_NETWORK); \
|
||||
rc = virNetDevBandwidthParse(&(var), \
|
||||
ctxt->node, \
|
||||
VIR_DOMAIN_NET_TYPE_NETWORK); \
|
||||
xmlFreeDoc(doc); \
|
||||
xmlXPathFreeContext(ctxt); \
|
||||
if (!(var)) \
|
||||
if (rc < 0) \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
@@ -127,9 +129,7 @@ mymain(void)
|
||||
|
||||
DO_TEST_SET(NULL, NULL);
|
||||
|
||||
DO_TEST_SET(("<bandwidth/>"),
|
||||
(TC " qdisc del dev eth0 root\n"
|
||||
TC " qdisc del dev eth0 ingress\n"));
|
||||
DO_TEST_SET("<bandwidth/>", NULL);
|
||||
|
||||
DO_TEST_SET(("<bandwidth>"
|
||||
" <inbound average='1024'/>"
|
||||
|
||||
Reference in New Issue
Block a user