LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Certification (https://www.linuxquestions.org/questions/linux-certification-46/)
-   -   KVM permission issues during chapter 2 of Michael Jang's RHCSA/RHCE book (https://www.linuxquestions.org/questions/linux-certification-46/kvm-permission-issues-during-chapter-2-of-michael-jangs-rhcsa-rhce-book-4175422643/)

Garagegoblin 08-17-2012 12:34 PM

KVM permission issues during chapter 2 of Michael Jang's RHCSA/RHCE book
 
This is my first post so please bare with me. But I am currently studying for the RHCSA (which is why I chose to post this in this sub-forum). Also I was told by the author he helps on here. Anyhow. Chapter two of his book he deletes the /var/lib/libvirt/images and replaces it with a link to /home/(myusername)/KVM. But during the creation of my VM it says permission denied for the server1.example.com.img I have gone through and made sure I gave rwx permissions to all users with chmod 777 and looked over permissions everywhere I can think of. Any ideas or suggestions would be greatly helpful. I will post some information to hopefully help here.

[root@localhost ~]# ls -l /var/lib/libvirt/images
lrwxrwxrwx. 1 root root 16 Aug 17 12:20 /var/lib/libvirt/images -> /home/smitty/KVM

[root@localhost ~]# ls -l /var/lib/libvirt/images/server1.example.com.img
-rwxrwxrwx. 1 root root 12884901888 Aug 17 13:13 /var/lib/libvirt/images/server1.example.com.img

custangro 08-17-2012 02:03 PM

Quote:

Originally Posted by Garagegoblin (Post 4756911)
This is my first post so please bare with me. But I am currently studying for the RHCSA (which is why I chose to post this in this sub-forum). Also I was told by the author he helps on here. Anyhow. Chapter two of his book he deletes the /var/lib/libvirt/images and replaces it with a link to /home/(myusername)/KVM. But during the creation of my VM it says permission denied for the server1.example.com.img I have gone through and made sure I gave rwx permissions to all users with chmod 777 and looked over permissions everywhere I can think of. Any ideas or suggestions would be greatly helpful. I will post some information to hopefully help here.

[root@localhost ~]# ls -l /var/lib/libvirt/images
lrwxrwxrwx. 1 root root 16 Aug 17 12:20 /var/lib/libvirt/images -> /home/smitty/KVM

[root@localhost ~]# ls -l /var/lib/libvirt/images/server1.example.com.img
-rwxrwxrwx. 1 root root 12884901888 Aug 17 13:13 /var/lib/libvirt/images/server1.example.com.img

SELinux is the problem. What is the Context of /home/smitty/KVM?

Code:

ls -lZ /home/smitty/KVM
NOTE: I think Jang just suggested that you move it...you don't have to (unless you have a space problem)

-C

Garagegoblin 08-17-2012 02:06 PM

[root@localhost ~]# ls -lZ /home/smitty/KVM/
-rwxrwxrwx. root root system_u:object_r:virt_image_t:s0 server1.example.com.img

You are correct it was a suggestion, but my home directory had 100Gb so thought it was a good idea since that was my largest partition. Thank you for the help BTW.

custangro 08-17-2012 02:09 PM

Quote:

Originally Posted by Garagegoblin (Post 4756984)
[root@localhost ~]# ls -lZ /home/smitty/KVM/
-rwxrwxrwx. root root system_u:object_r:virt_image_t:s0 server1.example.com.img

You are correct it was a suggestion, but my home directory had 100Gb so thought it was a good idea since that was my largest partition. Thank you for the help BTW.

Those contexts look right (off the top of my head)...

Try this..

Code:

restorecon -F -R /home/smitty/KVM
ls -lZ /home/smitty/KVM/

-C

Garagegoblin 08-17-2012 02:11 PM

[root@localhost ~]# restorecon -F -R /home/smitty/KVM/
[root@localhost ~]# ls -lZ /home/smitty/KVM/
-rwxrwxrwx. root root unconfined_u:object_r:user_home_t:s0 server1.example.com.img

---------- Post added 08-17-12 at 07:12 PM ----------

Here is the error I get from the KVM during the creation.

Unable to complete install: 'internal error Process exited while reading console log output: char device redirected to /dev/pts/1
qemu-kvm: -drive file=/var/lib/libvirt/images/server1.example.com.img,if=none,id=drive-virtio-disk0,format=raw,cache=none: could not open disk image /var/lib/libvirt/images/server1.example.com.img: Permission denied

custangro 08-17-2012 02:23 PM

Quote:

Originally Posted by Garagegoblin (Post 4756991)
[root@localhost ~]# restorecon -F -R /home/smitty/KVM/
[root@localhost ~]# ls -lZ /home/smitty/KVM/
-rwxrwxrwx. root root unconfined_u:object_r:user_home_t:s0 server1.example.com.img

---------- Post added 08-17-12 at 07:12 PM ----------

Here is the error I get from the KVM during the creation.

Unable to complete install: 'internal error Process exited while reading console log output: char device redirected to /dev/pts/1
qemu-kvm: -drive file=/var/lib/libvirt/images/server1.example.com.img,if=none,id=drive-virtio-disk0,format=raw,cache=none: could not open disk image /var/lib/libvirt/images/server1.example.com.img: Permission denied

Okay now try setting the context...

Code:

cd /home/smitty
semanage fcontext -a -t virt_image_t  KVM
 restorecon -R -v  KVM

If there is anything inside of /home/smitty/KVM you have to do the same commands on those files/directories as well.

--C

Garagegoblin 08-17-2012 02:27 PM

semanage is not showing as an available command. Is there a package that is needed for this?

custangro 08-17-2012 02:38 PM

Quote:

Originally Posted by Garagegoblin (Post 4757008)
semanage is not showing as an available command. Is there a package that is needed for this?

I don't know the package off the top of my head...but you can do this...

Code:

yum provides \*/*bin/semanage
It will show you what packages to install.

--C

Garagegoblin 08-17-2012 02:55 PM

found the package needed, this is the output.

<code>
[root@localhost smitty]# semanage fcontext -a -t virt_image_t KVM restorecon -R -v KVM
/usr/sbin/semanage: bad option
</code>

custangro 08-17-2012 03:04 PM

Quote:

Originally Posted by Garagegoblin (Post 4757020)
found the package needed, this is the output.

<code>
[root@localhost smitty]# semanage fcontext -a -t virt_image_t KVM restorecon -R -v KVM
/usr/sbin/semanage: bad option
</code>

Try it with a semicolon or an &&

This...

Code:

semanage fcontext -a -t virt_image_t KVM ; restorecon -R -v KVM
OR this...

Code:

semanage fcontext -a -t virt_image_t KVM && restorecon -R -v KVM

Then what is the ouput of...

Code:

ls -lZ KVM
and...

Code:

ls -lZ KVM/*
--C

Garagegoblin 08-17-2012 03:09 PM

Code:

[root@localhost smitty]# semanage fcontext -a -t virt_image_t KVM && restorecon -R -v KVM
restorecon reset /home/smitty/KVM/server1.example.com.img context system_u:object_r:virt_image_t:s0->system_u:object_r:user_home_t:s0
[root@localhost smitty]# semanage fcontext -a -t virt_image_t KVM/server1.example.com.img && restorecon -R -v KVM/server1.example.com.img
[root@localhost smitty]# ls -lZ KVM
-rwxrwxrwx. root root system_u:object_r:user_home_t:s0 server1.example.com.img
[root@localhost smitty]# ls -lZ KVM/*
-rwxrwxrwx. root root system_u:object_r:user_home_t:s0 KVM/server1.example.com.img

Still fails during setup of VM.

stef80 08-17-2012 03:59 PM

Try installing "setroubleshoot-server" package, restart auditd and rsyslog services and watch /var/log/messages for SE Linux errors/violations. It should list errors in more readable form.

Other option is creating LVM based guests. You create LV ... say 10 gigs and call it lv_server1 (or whatever you want) and install guest on it (format: raw, cache: none). It should give you better performance then image based guest. Also, Virt-manager can manage your Volume Group as a storage pool (you must add it first) so you can create LVs for guests directly from Virt-manager.

custangro 08-17-2012 04:21 PM

Quote:

Originally Posted by Garagegoblin (Post 4757028)
Code:

[root@localhost smitty]# semanage fcontext -a -t virt_image_t KVM && restorecon -R -v KVM
restorecon reset /home/smitty/KVM/server1.example.com.img context system_u:object_r:virt_image_t:s0->system_u:object_r:user_home_t:s0
[root@localhost smitty]# semanage fcontext -a -t virt_image_t KVM/server1.example.com.img && restorecon -R -v KVM/server1.example.com.img
[root@localhost smitty]# ls -lZ KVM
-rwxrwxrwx. root root system_u:object_r:user_home_t:s0 server1.example.com.img
[root@localhost smitty]# ls -lZ KVM/*
-rwxrwxrwx. root root system_u:object_r:user_home_t:s0 KVM/server1.example.com.img

Still fails during setup of VM.

I would remove the "server1.example.com.img" THEN do these commands...

Code:

semanage fcontext -a -t virt_image_t KVM && restorecon -R -v KVM
Then try again.

I agree with stef80 ...would like to see what the logs look like.

stef80 08-17-2012 04:31 PM

Maybe this would work better:
Code:

semanage fcontext -a -t virt_image_t "KVM(/.*)?" && restorecon -R -v KVM

custangro 08-17-2012 04:33 PM

Quote:

Originally Posted by stef80 (Post 4757078)
Maybe this would be better:
Code:

semanage fcontext -a -t virt_image_t KVM\(*\)? && restorecon -R -v KVM

^ Actually that's more elegant. Yes try that.


Still probably need to install those SELinux debugging tools...if you're studying for the RHCSA; you're going to need it eventually anyway :-)

-C


All times are GMT -5. The time now is 09:58 PM.