[PATCH] util: Remove '\n' from vhostuser ifname

Yalei Li posted 1 patch 3 years, 1 month ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/tencent_BF51CD26C1B1043E7CEA25D25EF7696F560A@qq.com
src/util/virnetdevopenvswitch.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] util: Remove '\n' from vhostuser ifname
Posted by Yalei Li 3 years, 1 month ago
When deleting the vhostuserclient interface, OVS prompts that the interface does not exist,
Through the XML file, I found that the "target dev" has a '\n', results in an XML parsing error.

XML file:

<target dev='vm-20ac9c030a47
'/>

That is because 'ovs-vsctl' returns a newline result, always come with a '\n',
and the vircommandrun function puts it in ifname.

So virNetDevOpenvswitchGetVhostuserIfname should remove '\n' from ifname.

Signed-off-by: Yalei Li <liyl43@chinatelecom.cn>
---
 src/util/virnetdevopenvswitch.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index f9b3369b2a..bd840bd3b7 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -575,6 +575,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path,
         return 0;
     }
 
+    virStringTrimOptionalNewline(*ifname);
     if (virNetDevOpenvswitchMaybeUnescapeReply(*ifname) < 0) {
         VIR_FREE(*ifname);
         return -1;
-- 
2.27.0

Re: [PATCH] util: Remove '\n' from vhostuser ifname
Posted by Michal Privoznik 3 years, 1 month ago
On 2/5/21 4:10 AM, Yalei Li wrote:
> When deleting the vhostuserclient interface, OVS prompts that the interface does not exist,
> Through the XML file, I found that the "target dev" has a '\n', results in an XML parsing error.
> 
> XML file:
> 
> <target dev='vm-20ac9c030a47
> '/>
> 
> That is because 'ovs-vsctl' returns a newline result, always come with a '\n',
> and the vircommandrun function puts it in ifname.
> 
> So virNetDevOpenvswitchGetVhostuserIfname should remove '\n' from ifname.
> 
> Signed-off-by: Yalei Li <liyl43@chinatelecom.cn>
> ---
>   src/util/virnetdevopenvswitch.c | 1 +
>   1 file changed, 1 insertion(+)

Oh sorry, I saw you posted this two weeks ago and had it marked for 
review but then got distracted. I've added Daniel's reviewed by tag, 
added mine and pushed.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Congratulations on your first libvirt contribution!

Michal