[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] conf: do not format redirfilter element if it do not have sub-element



When set a redirfilter element without sub-element, libvirt will
format it like this:

    <redirfilter>
    </redirfilter>

Just drop this element if it do not have any sub-element.

Signed-off-by: Luyao Huang <lhuang redhat com>
---
 src/conf/domain_conf.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index bfdc94e..1034466 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -20596,6 +20596,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++) {
-- 
1.8.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]