<meta http-equiv="Content-Type" content="text/html; charset=GB18030"><div>On Thu, Jan 06, 2022 at 07:44:25PM +0800, Xiong¡£ wrote:</div><div>> Dear sir: <br>>     I want to hook mmap system call in qemu, and I use<br>> libvirt to passthrough the environment argument like this:<br>>  <qemu:commandline><br>>    <qemu:env name='LD_PRELOAD' value='/glibcHookMMAP.so'/><br>>  </qemu:commandline><br>> But it failed. I can hardly find out what is the matter!<br>> The log in libvirt like this:ERROR: ld.so: object<br>> '/glibcHookMMAP.so' from LD_PRELOAD cannot be preloaded<br>> (cannot open shared object file): ignored.    Firstly,<br>> I think it's the problem of authority. But the file<br>> glibcHookMMAP.so has been done with command `chmod 777`.<br>> My environment is as follows: Ubuntu 18.04.2 Linux<br>> 5.4.0-92 libvirt 4.0.0 qemu 2.11.1<br><br>On Thu, Jan 06, 2022 at 09:47:25PM +0800, Daniel P. Berrang¨¦¡£ wrote:<br>> Aside from normal file permissions, the other likely problem on Ubuntu<br>> will be AppArmor policy. It likely won't allow QEMU to load files from<br>> the / directory - if you put your .so in /usr/local/lib it might<br>> work.<br></div><div><br></div><div>On Thu, Jan 07, 2022 at 09:27:25AM +0800, Xiong¡£ wrote:</div><div>> I have a try, but it does not work and makes the same warning:</div><div>> ld.so: object '/usr/local/lib/glibcHookMMAP.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.</div><div>> However, I use qemu command directly and it works. Command is like this:</div><div>> sudo LD_PRELOAD=/usr/local/lib/glibcHookMMAP.so qemu-system-x86_64 -enable-kvm ...(other args).</div><div>> After that, I get print information with my hook program. And I think the problem is in passing the environment args in libvirt.</div><div><br></div><div>Sorry, I find out what's the matter. The AppArmor policy limits the libvirt, and modifing configuration works.</div><div>Thank you for your advise!</div>