Bug 1350772
| Summary: | Memory locking is not required for non-KVM ppc64 guests | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Andrea Bolognani <abologna> |
| Component: | libvirt | Assignee: | Andrea Bolognani <abologna> |
| Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 7.3 | CC: | abologna, dgibson, dyuan, dzheng, gsun, jsuchane, rbalakri, rjones |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | ppc64le | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | libvirt-2.0.0-2.el7 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | 1293024 | Environment: | |
| Last Closed: | 2016-11-03 18:47:43 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
Andrea Bolognani
2016-06-28 11:07:28 UTC
I just realized that the original report was about this failure happening on a x86_64 host. In the case of TCG guests, regardless of the host architecture, it's my understanding that memory locking should not be required. David, can you please confirm that? (In reply to Andrea Bolognani from comment #1) > I just realized that the original report was about this > failure happening on a x86_64 host. That's not (really) right. It was actually launching an L2 guest inside an L1 host, where: L2 guest (ppc64) - failed because of memory locking L1 guest (ppc64) - running OK L0 host (x86-64) In this case I'm only doing nested virt while waiting for IBM to send me some POWER hardware. Ha ha, not really. (In reply to Richard W.M. Jones from comment #2) > > I just realized that the original report was about this > > failure happening on a x86_64 host. > > That's not (really) right. It was actually launching an L2 > guest inside an L1 host, where: > > L2 guest (ppc64) - failed because of memory locking > L1 guest (ppc64) - running OK > L0 host (x86-64) > > In this case I'm only doing nested virt while waiting for > IBM to send me some POWER hardware. Ha ha, not really. Of course the first ppc64 guest (L1) had to be using TCG because the architecture mismatch. But was it started by libvirt? And if so, was it the user daemon or the system one? (In reply to Andrea Bolognani from comment #3) > (In reply to Richard W.M. Jones from comment #2) > > > I just realized that the original report was about this > > > failure happening on a x86_64 host. > > > > That's not (really) right. It was actually launching an L2 > > guest inside an L1 host, where: > > > > L2 guest (ppc64) - failed because of memory locking > > L1 guest (ppc64) - running OK > > L0 host (x86-64) > > > > In this case I'm only doing nested virt while waiting for > > IBM to send me some POWER hardware. Ha ha, not really. > > Of course the first ppc64 guest (L1) had to be using TCG > because the architecture mismatch. For sure. > But was it started by > libvirt? And if so, was it the user daemon or the system > one? Yes, libvirt, and using the system connection. However I am not clear if the *L2* guest would be using TCG, or whether qemu emulates enough of POWER that it can emulate KVM too (albeit really slowly, of course). For example if you run an L2 guest on x86-64, even without nested KVM, the L2 guest will use (emulated, very slow) KVM because qemu-system-x86_64 running the L1 guest can emulate AMD's virt extensions. (In reply to Richard W.M. Jones from comment #4) > > > > I just realized that the original report was about this > > > > failure happening on a x86_64 host. > > > > > > That's not (really) right. It was actually launching an L2 > > > guest inside an L1 host, where: > > > > > > L2 guest (ppc64) - failed because of memory locking > > > L1 guest (ppc64) - running OK > > > L0 host (x86-64) > > > > > > In this case I'm only doing nested virt while waiting for > > > IBM to send me some POWER hardware. Ha ha, not really. > > > > Of course the first ppc64 guest (L1) had to be using TCG > > because the architecture mismatch. > > For sure. > > > But was it started by > > libvirt? And if so, was it the user daemon or the system > > one? > > Yes, libvirt, and using the system connection. The system daemon, running as root, was able to raise the locked memory limit, hence why you didn't run into any error. So it all checks out :) This BZ is about teaching libvirt that TCG guests don't need to lock memory, which would make you able to run TCG guests, either on x86_64 or ppc64, from the user daemon. Assuming David confirms that TCG doesn't need to lock memory, that is :) > However I am not clear if the *L2* guest would be using TCG, > or whether qemu emulates enough of POWER that it can emulate > KVM too (albeit really slowly, of course). For example if you > run an L2 guest on x86-64, even without nested KVM, the > L2 guest will use (emulated, very slow) KVM because qemu-system-x86_64 > running the L1 guest can emulate AMD's virt extensions. I think the L2 guest will not be able to use kvm_hv, but will fall back to kvm_pr instead. > In the case of TCG guests, regardless of the host > architecture, it's my understanding that memory locking > should not be required. > David, can you please confirm that? That's correct, unless you're using VFIO devices with TCG, in which case they will need their own memlock quota, as usual. [Richard] > However I am not clear if the *L2* guest would be using TCG, > or whether qemu emulates enough of POWER that it can emulate > KVM too (albeit really slowly, of course). For example if you > run an L2 guest on x86-64, even without nested KVM, the > L2 guest will use (emulated, very slow) KVM because qemu-system-x86_64 > running the L1 guest can emulate AMD's virt extensions. [Andrea] > I think the L2 guest will not be able to use kvm_hv, but > will fall back to kvm_pr instead. The L2 guest could be using either KVM PR or TCG, I'm not sure. The L1 guest is a PAPR (paravirtualized) guest, which runs with the HV (hypervisor mode) bit *off*. This has to be the case, because we don't support emulating a bare metal Power machine with full HV mode emulation in qemu. There are patches gradually on the way to add that a new "powernv" machine type which will emulate bare metal, but they're not in yet. Using KVM HV requires a host running in hypervisor mode. Since the L1 guest is not in hypervisor mode, it won't even attempt to use KVM HV. KVM PR could work for the L2 guest, however, RHEL by default won't load the KVM PR module. So if L1 is RHEL, and you haven't manually loaded the module, I'd expect the L2 guest to be running under TCG instead. All of which underscores the basic problem here: it's not easy for libvirt to tell what emulation mode a guest will run in until it's running, which is a problem if we need to conditionally adjust the locked memory limit beforehand. I don't have any good ideas about how to deal with that. As check in our CI jobs, the memory lock problem failed with:
libvirt 1.3.5-1.el7
kernel 3.10.0-327.el7
qemu-kvm-rhev 2.6.0-6.el7
Now retest with qemu-kvm-rhev updated
packages:
libvirt-1.3.5-1.el7.ppc64le
qemu-kvm-rhev-2.6.0-10.el7.ppc64le
kernel-3.10.0-327.el7.ppc64le
steps:
# useradd new_user
# su - new_user
$ virsh list --all
Id Name State
----------------------------------------------------
- avocado-vt-vm1 shut off
$ virsh dumpxml avocado-vt-vm1
<domain type='kvm'>
<name>avocado-vt-vm1</name>
<uuid>1c2363d5-90da-4f59-b1f8-25fbb4bec2d8</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='ppc64le' machine='pseries-rhel7.3.0'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/tmp/autotest.img'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:f4:85:91'/>
<source bridge='virbr0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
<address type='spapr-vio' reg='0x30000000'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
<address type='spapr-vio' reg='0x30000000'/>
</console>
<input type='keyboard' bus='usb'/>
<input type='mouse' bus='usb'/>
<graphics type='vnc' port='-1' autoport='yes'>
<listen type='address'/>
</graphics>
<video>
<model type='vga' vram='16384' heads='1' primary='yes'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
<panic model='pseries'/>
</devices>
</domain>
$ virsh start avocado-vt-vm1
error: Failed to start domain avocado-vt-vm1
error: Failed to connect socket to '/home/new_user/.cache/libvirt/virtlogd-sock': Connection refused
some problem with virtlogd, as on x86_64 this works, start virtlogd under this user to workaround this
$ virtlogd --daemon
$ virsh start avocado-vt-vm1
error: Failed to start domain avocado-vt-vm1
error: internal error: /usr/libexec/qemu-bridge-helper --use-vnet --br=virbr0 --fd=24: failed to communicate with bridge helper: Transport endpoint is not connected
stderr=libvirt: error : internal error: cannot apply process capabilities -1
another problem with qemu-bridge-helper failed, will file separate bug for this.
The memory lock problem can't be reproduced with qemu-kvm-rhev-2.6.0-10.el7.ppc64le
stderr=libvirt: error : internal error: cannot apply process capabilities -1 is likely to be bug 1351995 (ie. a completely different thing) (In reply to Richard W.M. Jones from comment #9) > stderr=libvirt: error : internal error: cannot apply process capabilities -1 > is likely to be bug 1351995 (ie. a completely different thing) Yeah, I already checked on Friday that that was the case. Didn't get around to update the BZ though. As checked in CI job for 2.0.0-1, with audit 2.6.2-1 which fixed bug in comment #8, now the bug is reproduced with packages: libvirt 2.0.0-1.el7 kernel 3.10.0-327.el7 qemu-kvm-rhev 2.6.0-11.el7 A fix for this issue has been posted upstream. https://www.redhat.com/archives/libvir-list/2016-July/msg00072.html The fix has been committed upstream.
commit cd89d3451b8efcfed05ff1f4a91d9b252dbe26bc
Author: Andrea Bolognani <abologna>
Date: Wed Jun 29 10:22:32 2016 +0200
qemu: Memory locking is only required for KVM guests on ppc64
Due to the way the hardware works, KVM on ppc64 always requires
memory locking; however, that is not the case for non-KVM ppc64
guests, eg. ppc64 guests that are running on x86_64 with TCG.
Only require memory locking for ppc64 guests if they are using
KVM or, as it's the case for all architectures, they have host
devices assigned using VFIO.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1350772
v2.0.0-37-gcd89d34
*Packages used to reproduce: qemu-kvm-rhev-2.6.0-11.el7.ppc64le libvirt-2.0.0-1.el7.ppc64le kernel-3.10.0-327.el7.ppc64le *Reproduced with 2 scenarios: 1. Non-root user start guest on PPC host Steps: # useradd dzheng # su - dzheng $ virsh define /tmp/rpm/libvirt/guest.xml Domain avocado-vt-vm1 defined from /tmp/rpm/libvirt/guest.xml $ virsh list --all Id Name State ---------------------------------------------------- - avocado-vt-vm1 shut off $ virsh start avocado-vt-vm1 error: Failed to start domain avocado-vt-vm1 error: internal error: Process exited prior to exec: libvirt: error : cannot limit locked memory to 20971520: Operation not permitted 2. libguestfs-test-tool Install libvirt, qemu-kvm-rhev, and libguestfs packages. # systemctl restart libvirtd Log on as root again # ulimit -l 64 # su - dzheng $ ulimit -l 64 $ /usr/bin/libguestfs-test-tool ... Original error from libvirt: internal error: Process exited prior to exec: libvirt: error : cannot limit locked memory to 18874368: Operation not permitted [code=1 int1=-1] libguestfs-test-tool: failed to launch appliance See attachment (ulimit_64_dzheng_qemu_11_fail.libguestfs.log) As workaround, Log on as root # ulimit -l unlimited # su - dzheng $ ulimit -l unlimited $ /usr/bin/libguestfs-test-tool ... libguestfs: appliance is up Guest launched OK. ... ===== TEST FINISHED OK ===== See attachment (ulimit_unlimited_dzheng_qemu_11_pass.libguestfs.log) Created attachment 1179117 [details]
libguestfs-test-tool fail output with qemu-kvm-rhev-2.6.0-11.el7
Created attachment 1179118 [details]
libguestfs-test-tool pass output with qemu-kvm-rhev-2.6.0-11.el7 unlimited work around
(In reply to Dan Zheng from comment #16) > *Packages used to reproduce: > > qemu-kvm-rhev-2.6.0-11.el7.ppc64le > libvirt-2.0.0-1.el7.ppc64le > kernel-3.10.0-327.el7.ppc64le The fix has been included in libvirt-2.0.0-2.el7, so the version you're using is too old... Or are you creating a baseline for testing the fix? Andrea, Yes. comment 16 is just to reproduce the issue. And I did upgrade qemu to qemu-kvm-rhev-2.6.0-13.el7.ppc64le, but libvirt is still libvirt-2.0.0-1.el7 without upgrade. Then the scenarios in comment 16 can pass without your new codes. So I am thinking about what the scenario is to prove your codes required and take effect. BTW, it is hard for me to run a virt-install --arch ppc64le ... on a x86_host for the scenario used in the beginning of the bug because I can not setup TCG using downstream packages, I think. Any other suggestion? (In reply to Dan Zheng from comment #20) > Andrea, > Yes. comment 16 is just to reproduce the issue. And I did upgrade qemu to > qemu-kvm-rhev-2.6.0-13.el7.ppc64le, but libvirt is still libvirt-2.0.0-1.el7 > without upgrade. Then the scenarios in comment 16 can pass without your new > codes. So I am thinking about what the scenario is to prove your codes > required and take effect. Scenario 1 failed outright; scenario 2 failed until you used a workaround. Those are the failures you're looking for. You either need to keep qemu-kvm-rhev at version 2.6.0-11.el7, or run $ ulimit -l 64 to make sure your memory locking limit is very low; additionaly, you need to make sure that the guest XML starts with <domain type='qemu'> which tells libvirt to use TCG instead of KVM. After you've done this, scenario 1 should fail with libvirt-2.0.0-1.el7 and succeed with libvirt-2.0.0-2.el7. Not sure if there's a way to force libguestfs-test-tool to use TCG in order to test scenario 2... Rich? :) > BTW, it is hard for me to run a virt-install --arch ppc64le ... on a > x86_host for the scenario used in the beginning of the bug because I can not > setup TCG using downstream packages, I think. Any other suggestion? We don't ship qemu-system-ppc64 on x86_64, so running ppc64 guests on x86_64 hosts is not a relevant use case for downstream. No need to test it. (In reply to Richard W.M. Jones from comment #22) > Yes: http://libguestfs.org/guestfs.3.html#force_tcg Sweet! Thank you :) *Packages used to reproduce: qemu-kvm-rhev-2.6.0-13.el7.ppc64le libvirt-2.0.0-2.el7.ppc64le kernel-3.10.0-461.el7.ppc64le libguestfs-1.32.6-1.el7.ppc64le Scenario 1. Non-root user start guest on PPC host Steps: # useradd dzheng # su - dzheng Edit guest.xml to make sure <domain type='qemu'> $ virsh define /tmp/rpm/libvirt/guest.xml Domain guest1 defined from /tmp/rpm/libvirt/guest.xml $ ulimit -l 64 $ ulimit -l 64 $ virsh start avocado-vt-vm1 $ virsh list --all Id Name State ---------------------------------------------------- 3 guest1 running User can log on the guest. --- With libvirt-2.0.0-1.el7.ppc64le, scenario 1 can be reproduced with same error message as comment 16. Pass. ******************************************************* Scenario 2. libguestfs-test-tool # su - dzheng $ ulimit -l 64 $ export LIBGUESTFS_BACKEND_SETTINGS=force_tcg $ /usr/bin/libguestfs-test-tool [ 1.913667] Rebooting in 1 seconds..libguestfs: error: appliance closed the connection unexpectedly, see earlier error messages libguestfs: child_cleanup: 0x1000f300340: child process died libguestfs: error: guestfs_launch failed, see earlier error messages libguestfs-test-tool: failed to launch appliance $ ulimit -l 65536 Same error message. -- With libvirt-2.0.0-1.el7.ppc64le, same error message. See attachment libguestfs-test-tool-tcg-64-fail.log Created attachment 1180943 [details]
libguestfs-test-tool fail output with qemu-kvm-rhev-2.6.0-13.el7
Okay, there is a different bug that causes libguestfs-test-tool to fail in this situation - I've just filed it as Bug 1350772. So I think it's fair to ignore the libguestfs-test-tool failure for the moment, and just test that a regular libvirt TCG guest can be started by an unprivileged user with low memory locking limit. What kind of OS is installed in the avocado-vt-vm1 guest you tested in Comment 24? According to my tests for Bug 1350772, it would have to be something oldish in order to boot in TCG mode... Andrea, The OS in avocado-vt-vm1 is Red Hat Enterprise Linux Server release 7.2 (Maipo), kernel 3.10.0-327.3.1.el7.ppc64le Any other information you want? That explains it - RHEL 7.2 guests can boot fine on the POWER 7 processor that TCG emulates by default. No more information needed from my side, and I think the bug can be moved to VERIFIED now. Based on above comment 28, I move it to verified now. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2016-2577.html |