]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Avoid formatting empty redirfilter element
authorLuyao Huang <lhuang@redhat.com>
Fri, 22 May 2015 09:26:29 +0000 (17:26 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 26 May 2015 23:52:26 +0000 (19:52 -0400)
If the redirfilter has no usbdev sub-elements, then do not format anything
rather than formatting an empty pair of elements:

    <redirfilter>
    </redirfilter>

Signed-off-by: Luyao Huang <lhuang@redhat.com>
src/conf/domain_conf.c

index 0a3a6245ae0bf1b63080bc777aee871df9be90b2..6e5742509cf04bc1d5d62b907f9cb34824cbae84 100644 (file)
@@ -20626,6 +20626,10 @@ virDomainRedirFilterDefFormat(virBufferPtr buf,
 {
     size_t i;
 
+    /* no need format an empty redirfilter */
+    if (filter->nusbdevs == 0)
+        return 0;
+
     virBufferAddLit(buf, "<redirfilter>\n");
     virBufferAdjustIndent(buf, 2);
     for (i = 0; i < filter->nusbdevs; i++) {