This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 1459091 - virsh domiflist return NULL for the vhostuser interface name and source
virsh domiflist return NULL for the vhostuser interface name and source
Status: VERIFIED
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.4
x86_64 Linux
unspecified Severity high
: rc
: ---
Assigned To: Michal Privoznik
chhu
: Upstream
Depends On:
Blocks: 1473046 1397940
  Show dependency treegraph
 
Reported: 2017-06-06 05:19 EDT by chhu
Modified: 2017-09-28 02:37 EDT (History)
6 users (show)

See Also:
Fixed In Version: libvirt-3.7.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description chhu 2017-06-06 05:19:36 EDT
Description of problem:
virsh domiflist return NULL for the vhostuser interface name and source

Version-Release number of selected component (if applicable):
libvirt-3.2.0-7.el7.x86_64
qemu-kvm-rhev-2.9.0-7.el7.x86_64
kernel-3.10.0-677.el7.x86_64

Test steps:
1. Prepare guest with xml:

  <memoryBacking>
    <hugepages>
      <page size='2048' unit='KiB'/>
    </hugepages>
  </memoryBacking>
  ......
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid'>Broadwell</model>
    ......
    <feature policy='require' name='abm'/>
    <numa>
      <cell id='0' cpus='0-1' memory='1048576' unit='KiB' memAccess='shared'/>
    </numa>
  </cpu>
  ......
    <interface type='vhostuser'>
      <mac address='52:54:01:93:55b'/>
      <source type='unix' path='/var/run/openvswitch/vhost-user1' mode='client'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>

2. Start the guests with vhostuser interface
#virsh start r7-4t1
Domain r7-4t1 started

#virsh list --all
 Id    Name                           State
----------------------------------------------------
 6     r7-4t1                         running

#virsh dumpxml r7-4t1| grep interface -A 10
    <interface type='vhostuser'>
      <mac address='52:54:01:93:55b'/>
      <source type='unix' path='/var/run/openvswitch/vhost-user1' mode='client'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>

#ps -ef|grep qemu-kvm| grep vhost
qemu       7408      1  0 May22 ?        00:03:12 /usr/libexec/qemu-kvm -name guest=r7-4t1,debug-threads=on
-S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-8-r7-4t1/master-key.aes
-machine pc-i440fx-rhel7.4.0,accel=kvm,usb=off,dump-guest-core=off
......
-chardev socket,id=charnet0,path=/var/run/openvswitch/vhost-user1 -netdev vhost-user,chardev=charnet0,id=hostnet0
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:01:93:55b,bus=pci.0,addr=0x8 -chardev pty,id=charserial0
......

3. Check the virsh domiflist: no Interface is listed
#virsh domiflist r7-4t1
Interface  Type       Source     Model       MAC
-------------------------------------------------------
-          vhostuser  -          virtio      52:54:01:93:55b

4. Can't get the network statistics by `virsh domifstat <domain> <interface>`
#virsh domifstat r7-4t1 vhostuser1
error: Failed to get interface stats r7-4t1 vhostuser1
error: invalid argument: invalid path, 'vhostuser1' is not a known interface

# virsh domifstat r7-4t1 vhostuser
error: Failed to get interface stats r7-4t1 vhostuser
error: invalid argument: invalid path, 'vhostuser' is not a known interface

#virsh domifstat r7-4t1 eth0
error: Failed to get interface stats r7-4t1 eth0
error: invalid argument: invalid path, 'eth0' is not a known interface


Actual results:
In step3, the virsh domiflist return NULL for the vhostuser interface name and source

Expected results:
In step3, the virsh domiflist return the vhostuser interface name and source
Comment 2 Mehdi ABAAKOUK 2017-06-06 05:49:40 EDT
I'm guessing this commit is missing: http://libvirt.org/git/?p=libvirt.git;a=commit;h=57b5e27d3d74f8dbb77ac909b405d99d555eca46
Comment 3 Jaroslav Suchanek 2017-06-06 06:37:35 EDT
(In reply to Mehdi ABAAKOUK from comment #2)
> I'm guessing this commit is missing:
> http://libvirt.org/git/?p=libvirt.git;a=commit;
> h=57b5e27d3d74f8dbb77ac909b405d99d555eca46

Build libvirt-3.2.0-7.el7 contains that commit. Something else might be missing.
Comment 4 Jaroslav Suchanek 2017-06-07 10:10:25 EDT
Per comment https://bugzilla.redhat.com/show_bug.cgi?id=1397940#c10 I am
moving this one to rhel-7.5.
Comment 5 Michal Privoznik 2017-06-07 11:42:09 EDT
Patches proposed upstream:

https://www.redhat.com/archives/libvir-list/2017-June/msg00392.html
Comment 6 Michal Privoznik 2017-06-08 09:24:44 EDT
I've pushed patches online:

commit f3908d8557dc609e2262099d76c57b0bcc4b0917
Author:     Michal Privoznik <mprivozn@redhat.com>
AuthorDate: Thu Jun 8 14:58:22 2017 +0200
Commit:     Michal Privoznik <mprivozn@redhat.com>
CommitDate: Thu Jun 8 15:02:23 2017 +0200

    virNetDevOpenvswitchGetVhostuserIfname: Fix off by one error
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1459091
    
    We try to get the last element of the passed path by calling
    strrch(path, '/'). However, the pointer that strrchr() returns
    points at the slash, We want string that starts right after that.
    
    Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

commit 2a13a0a103340878b05a5ae0b9f454721f67dbb3
Author:     Michal Privoznik <mprivozn@redhat.com>
AuthorDate: Wed Jun 7 15:43:58 2017 +0200
Commit:     Michal Privoznik <mprivozn@redhat.com>
CommitDate: Thu Jun 8 15:02:22 2017 +0200

    qemu: Query for vhostuser iface names at runtime
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1459091
    
    Currently, we are querying for vhostuser interface name in post
    parse callback. At that time interface might not yet exist.
    However, it has to exist when starting domain. Therefore it makes
    more sense to query its name at that point. This partially
    reverts 57b5e27.
    
    Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

v3.4.0-66-gf3908d855
Comment 8 yalzhang@redhat.com 2017-09-27 22:16:15 EDT
Test on libvirt-3.7.0-2.el7.x86_64, the result is as expected, set this bug to be verified.


1. start the guest with vhostuser interface without <target dev=...> element, check the xml

# virsh dumpxml vhost1 --inactive | grep /interface -B5
    <interface type='vhostuser'>
      <mac address='52:54:00:93:51:db'/>
      <source type='unix' path='/var/run/openvswitch/vhost-user1' mode='client'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

<== no <target dev=...> set in inactive xml

# virsh dumpxml vhost1 | grep /interface -B7
    <interface type='vhostuser'>
      <mac address='52:54:00:93:51:db'/>
      <source type='unix' path='/var/run/openvswitch/vhost-user1' mode='client'/>
      <target dev='vhost-user1'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

<== the "<target dev='vhost-user1'/>" will generate automatically in the active xml

2. domiflist get the interface name

# virsh domiflist vhost1
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vhost-user1 vhostuser  -          virtio      52:54:00:93:51:db

# virsh domiflist vhost1 --inactive
Interface  Type       Source     Model       MAC
-------------------------------------------------------
-          vhostuser  -          virtio      52:54:00:93:51:db


3. set <target dev> in xml

# virsh dumpxml vhost1 --inactive | grep /interface -B6
    <interface type='vhostuser'>
      <mac address='52:54:00:93:51:db'/>
      <source type='unix' path='/var/run/openvswitch/vhost-user1' mode='client'/>
      <target dev='blah'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

<=== set <target dev='blah'/> in xml

# virsh dumpxml vhost1  | grep /interface -B7
    <interface type='vhostuser'>
      <mac address='52:54:00:93:51:db'/>
      <source type='unix' path='/var/run/openvswitch/vhost-user1' mode='client'/>
      <target dev='vhost-user1'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

<=== when the vm start, the target dev will be override


4. check by domiflist for the interface name

# virsh domiflist vhost1
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vhost-user1 vhostuser  -          virtio      52:54:00:93:51:db

# virsh domiflist vhost1 --inactive
Interface  Type       Source     Model       MAC
-------------------------------------------------------
blah       vhostuser  -          virtio      52:54:00:93:51:db


# virsh domifstat vhost1  blah
error: Failed to get interface stats vhost1 blah
error: invalid argument: invalid path, 'blah' is not a known interface

# virsh domifstat vhost1  vhost-user1
vhost-user1 rx_bytes 132144
vhost-user1 rx_packets 1375
vhost-user1 rx_drop 0
vhost-user1 tx_bytes 133096
vhost-user1 tx_packets 1387
vhost-user1 tx_errs 0
vhost-user1 tx_drop 0

Note You need to log in before you can comment on or make changes to this bug.