Bug 1482146

Summary: Failed to run VM with disk image located at /dev/shm
Product: [Fedora] Fedora Reporter: Gal Ben Haim <gbenhaim>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 26CC: agedosier, berrange, bkorren, clalancette, crobinso, eedri, itamar, laine, libvirt-maint, mprivozn, pkrempa, veillard, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-04 15:10:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Complete libvirt log none

Description Gal Ben Haim 2017-08-16 14:51:16 UTC
Created attachment 1314227 [details]
Complete libvirt log

Description of problem:

When trying to run a VM with disk image located at /dev/shm, and connection type qemu:///system, I'm getting the following error:

-bash-4.4$ virsh -c qemu:///system create dom.xml 
error: Failed to create domain from dom.xml
error: internal error: Process exited prior to exec: libvirt: QEMU Driver error : Unable to stat /dev/shm/test-with-virsh/centos-7.3.img: No such file or directory

domain xml:

<domain type='kvm'>
  <name>demo2</name>
  <uuid>4dea24b3-1d52-d8f3-2516-782e98a23fa0</uuid>
  <memory>4096</memory>
  <vcpu>1</vcpu>
  <os>
    <type arch="x86_64">hvm</type>
  </os>
  <clock sync="localtime"/>
  <devices>
    <emulator>/usr/bin/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <source file='/dev/shm/test-with-virsh/centos-7.3.img'/>
      <target dev='hda'/>
    </disk>
    <console type='pty'>
      <source path='/dev/pts/4'/>
      <target port='0'/>
    </console>
  </devices>
</domain>

Relevant part from libvirt's log:

error: 2017-08-16 13:34:45.865+0000: 329: debug : virEventPollCalculateTimeout:338 : Calculate expiry of 2 timers
2017-08-16 13:34:45.865+0000: 329: debug : virEventPollCalculateTimeout:346 : Got a timeout scheduled for 1502890490865
Failed to create domain from dom.xml
error: 2017-08-16 13:34:45.865+0000: 329: debug : virEventPollCalculateTimeout:359 : Schedule timeout then=1502890490865 now=1502890485865
internal error: Process exited prior to exec: libvirt: QEMU Driver error : Unable to stat /dev/shm/test-with-virsh/centos-7.3.img: No such file or directory

Complete libvirt log:

attached


Version-Release number of selected component (if applicable):

libvirt-3.2.1-4.fc26.x86_64
qemu-kvm-2.9.0-3.fc26.x86_64

How reproducible:

Run a VM with disk image on /dev/shm and connection type qemu:///system


Actual results:

VM doesn't start

Expected results:

VM should start

Additional info:

Comment 1 Cole Robinson 2017-08-16 22:45:23 UTC
Probably due to some incomplete interaction with the fs namespace stuff, ccing Michal

Comment 2 Michal Privoznik 2017-08-17 10:34:03 UTC
This is fixed upstream for a while now:

commit a7cc039dc796f541793955598377807af48341fb
Author:     Michal Privoznik <mprivozn>
AuthorDate: Thu Apr 27 16:29:21 2017 +0200
Commit:     Michal Privoznik <mprivozn>
CommitDate: Wed May 3 17:23:03 2017 +0200

    qemuDomainBuildNamespace: Move /dev/* mountpoints later
    
    When setting up mount namespace for a qemu domain the following
    steps are executed:
    
    1) get list of mountpoints under /dev/
    2) move them to /var/run/libvirt/qemu/$domName.ext
    3) start constructing new device tree under /var/run/libvirt/qemu/$domName.dev
    4) move the mountpoint of the new device tree to /dev
    5) restore original mountpoints from step 2)
    
    Note the problem with this approach is that if some device in step
    3) requires access to a mountpoint from step 2) it will fail as
    the mountpoint is not there anymore. For instance consider the
    following domain disk configuration:
    
        <disk type='file' device='disk'>
          <driver name='qemu' type='raw'/>
          <source file='/dev/shm/vhostmd0'/>
          <target dev='vdb' bus='virtio'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
        </disk>
    
    In this case operation fails as we are unable to create vhostmd0
    in the new device tree because after step 2) there is no /dev/shm
    anymore. Leave aside fact that we shouldn't try to create devices
    living in other mountpoints. That's a separate bug that will be
    addressed later.
    
    Currently, the order described above is rearranged to:
    
    1) get list of mountpoints under /dev/
    2) start constructing new device tree under /var/run/libvirt/qemu/$domName.dev
    3) move them to /var/run/libvirt/qemu/$domName.ext
    4) move the mountpoint of the new device tree to /dev
    5) restore original mountpoints from step 3)
    
    Signed-off-by: Michal Privoznik <mprivozn>
    Reviewed-by: Cedric Bosdonnat <cbosdonnat>

The 3.3.0 release should work. Also, this is the same bug as bug 1449510 which is for RHEL.

Comment 3 Fedora Update System 2017-09-16 19:17:54 UTC
libvirt-3.2.1-6.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-ff7b30a42d

Comment 4 Fedora Update System 2017-09-17 10:53:30 UTC
libvirt-3.2.1-6.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-ff7b30a42d

Comment 5 Fedora Update System 2017-10-12 02:53:43 UTC
libvirt-3.2.1-6.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.