Fedora Linux Support Community & Resources Center
  #1  
Old 8th December 2012, 04:35 PM
globe5 Offline
Registered User
 
Join Date: Sep 2012
Location: Sofia
Posts: 3
linuxchrome
how to fix device mapping for guest virtual machine (qemu/KVM)

Hi all,

I am running Fedora16 as a home server and I use it as s virtualization host. On that machine I have several virtual guests, running Fedora, Oracle Linux and Windows.

host machine: c4.c4.lan
oel6 machine: node01.c4.lan

One of the virtual guests is Oracle Linux 6.0 and I use it mainly for Oracle database server.
It has two LVM VGs - one for / fs and for swap(vg_node01), the other VG is for oracle's home and data filesystems(vg_ora).
The disks containing these VGs are named /dev/sda and /dev/sdb (or at least used to be).

I decided to install Oracle ASM instance on it and presented it 8 logical volumes from the host machine to emulate scsi disks. The procedure I've done this is:

Code:
[root@c4 ~]# lvcreate -L 2G -n virtdisks_node01_asm1 vg_c4
  Logical volume "virtdisks_node01_asm1" created
virsh # attach-disk node01 /dev/mapper/vg_c4-virtdisks_node01_asm1 sdc --persistent
Disk attached successfully
The above I've repeated for the rest of LVs (8 total) and I am able to query them using virsh:

Code:
virsh # domblkinfo node01 sdc
Capacity:       2147483648
Allocation:     2147483648
Physical:       2147483648
The thing is that when the virtual machine got rebooted, the block devices are assigned with different device names (/dev/sd*). However, if I query the qemu's domain (node01) xml config file, I can see that the naming conventions are correct (reflecting how do I want them):

Code:
[root@c4 11.2.0.3]# virsh dumpxml node01
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/vg_c4/virtmachines'/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/vg_c4/virtmachines_1'/>
      <target dev='hdb' bus='ide'/>
      <alias name='ide0-0-1'/>
      <address type='drive' controller='0' bus='0' unit='1'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/mapper/vg_c4-virtdisks_node01_asm1'/>
      <target dev='sdc' bus='scsi'/>
      <alias name='scsi0-0-2'/>
      <address type='drive' controller='0' bus='0' unit='2'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/mapper/vg_c4-virtdisks_node01_asm2'/>
      <target dev='sdd' bus='scsi'/>
      <alias name='scsi0-0-3'/>
      <address type='drive' controller='0' bus='0' unit='3'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/mapper/vg_c4-virtdisks_node01_asm3'/>
      <target dev='sde' bus='scsi'/>
      <alias name='scsi0-0-4'/>
      <address type='drive' controller='0' bus='0' unit='4'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/mapper/vg_c4-virtdisks_node01_asm4'/>
      <target dev='sdf' bus='scsi'/>
      <alias name='scsi0-0-5'/>
      <address type='drive' controller='0' bus='0' unit='5'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/mapper/vg_c4-virtdisks_node01_asm5'/>
      <target dev='sdg' bus='scsi'/>
      <alias name='scsi0-0-6'/>
      <address type='drive' controller='0' bus='0' unit='6'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/mapper/vg_c4-virtdisks_node01_asm6'/>
      <target dev='sdh' bus='scsi'/>
      <alias name='scsi1-0-0'/>
      <address type='drive' controller='1' bus='0' unit='0'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/mapper/vg_c4-virtdisks_node01_asm7'/>
      <target dev='sdi' bus='scsi'/>
      <alias name='scsi1-0-1'/>
      <address type='drive' controller='1' bus='0' unit='1'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/mapper/vg_c4-virtdisks_node01_asm8'/>
      <target dev='sdj' bus='scsi'/>
      <alias name='scsi1-0-2'/>
      <address type='drive' controller='1' bus='0' unit='2'/>
    </disk>

However, this is how I see the block devices from virtual guest's perspective:

Code:
[root@node01 ~]# fdisk -l |grep /dev/sd
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/sda: 2147 MB, 2147483648 bytes
/dev/sda1               1        1009     2095662   83  Linux
Disk /dev/sdb: 2147 MB, 2147483648 bytes
/dev/sdb1               1        1009     2095662   83  Linux
Disk /dev/sdc: 2147 MB, 2147483648 bytes
/dev/sdc1               1        1009     2095662   83  Linux
Disk /dev/sdd: 2147 MB, 2147483648 bytes
/dev/sdd1               1        1009     2095662   83  Linux
Disk /dev/sde: 1073 MB, 1073741824 bytes
/dev/sde1               1        1011     1048376+  83  Linux
Disk /dev/sdf: 1073 MB, 1073741824 bytes
/dev/sdf1               1        1011     1048376+  83  Linux
Disk /dev/sdh: 1073 MB, 1073741824 bytes
/dev/sdh1               1        1011     1048376+  83  Linux
Disk /dev/dm-1 doesn't contain a valid partition table
Disk /dev/sdg: 1073 MB, 1073741824 bytes
/dev/sdg1               1        1011     1048376+  83  Linux
Disk /dev/sdj: 21.5 GB, 21474836480 bytes
/dev/sdj1               2       20480    20970496   8e  Linux LVM
Disk /dev/sdi: 21.5 GB, 21474836480 bytes
/dev/sdi1   *           1          64      512000   83  Linux
/dev/sdi2              64        2611    20458496   8e  Linux LVM
Disk /dev/dm-2 doesn't contain a valid partition table
Disk /dev/dm-3 doesn't contain a valid partition table
Disk /dev/dm-4 doesn't contain a valid partition table
Disk /dev/dm-5 doesn't contain a valid partition table
[root@node01 ~]#

I need to make those LVs presented from the host machine as scsi disks to the guests machine with target device names as I've written them into the guest XML file.

I don't know how to achieve that, please help, anyone?

Many thanks in advance!
Reply With Quote
  #2  
Old 8th December 2012, 04:56 PM
stevea Online
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,988
linuxfirefox
Re: how to fix device mapping for guest virtual machine (qemu/KVM)

I' m confused. It looks like they are showing up properly named - no ?

Quote:
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/mapper/vg_c4-virtdisks_node01_asm5'/>
<target dev='sdg' bus='scsi'/>
<alias name='scsi0-0-6'/>
<address type='drive' controller='0' bus='0' unit='6'/>
</disk>
Quote:
Disk /dev/sdg: 1073 MB, 1073741824 bytes
/dev/sdg1 1 1011 1048376+ 83 Linux
__________________
None are more hopelessly enslaved than those who falsely believe they are free.
Johann Wolfgang von Goethe
Reply With Quote
  #3  
Old 8th December 2012, 05:56 PM
globe5 Offline
Registered User
 
Join Date: Sep 2012
Location: Sofia
Posts: 3
linuxchrome
Re: how to fix device mapping for guest virtual machine (qemu/KVM)

Quote:
Originally Posted by stevea View Post
I' m confused. It looks like they are showing up properly named - no ?
Hi stevea, thanks for the follow-up.

Some of the devices got their names properly, some are not. For example these:

Code:
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/vg_c4/virtmachines'/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
    </disk>
The LV '/dev/vg_c4/virtmachines' should have device name /dev/hda, but actually is named as:

Code:
Disk /dev/sdj: 21.5 GB, 21474836480 bytes
/dev/sdj1               2       20480    20970496   8e  Linux LVM
and respectively:

Code:
 <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/vg_c4/virtmachines_1'/>
      <target dev='hdb' bus='ide'/>
      <alias name='ide0-0-1'/>
      <address type='drive' controller='0' bus='0' unit='1'/>
    </disk>
is shown as:

Code:
Disk /dev/sdi: 21.5 GB, 21474836480 bytes
/dev/sdi1   *           1          64      512000   83  Linux
/dev/sdi2              64        2611    20458496   8e  Linux LVM

As you can see I've named the ASM LVs as target device names sdc to sdj (8 total - first four should be 2GB disks(sdc,sdd,sde,sdf) and the rest four 1GB (sdg,sdh,sdi,sdj) and thus I expect my virtual machine to see them that way:

/dev/hda (first 21.5GB disk)
/dev/hdb (second 21.5GB disk)
/dev/sdc - /dev/sdf - four 2GB disks
/dev/sdg - /dev/sdj - four 1GB disks

but this is not the case.

Any ideas?

Thanks!

---------- Post added at 06:56 PM ---------- Previous post was at 06:12 PM ----------

Update

I've been advised not to use scsi emulation with KVM, but instead to use virtio_blk emulation.
So I did and "converted" the disks to virtio as editing the guest machine XML config file for all ASM disks like this:

old:
Code:
<disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/mapper/vg_c4-virtdisks_node01_asm1'/>
      <target dev='sdc' bus='scsi'/>
      <address type='drive' controller='0' bus='0' unit='2'/>
    </disk>
new:
Code:
<disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/mapper/vg_c4-virtdisks_node01_asm1'/>
      <target dev='vdc' bus='virtio'/>
    </disk>
After guest machine reboot this is how the devices got renamed:

Code:
[root@node01 ~]# fdisk -l |grep /dev/
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/sda: 21.5 GB, 21474836480 bytes
/dev/sda1   *           1          64      512000   83  Linux
/dev/sda2              64        2611    20458496   8e  Linux LVM
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
/dev/sdb1               2       20480    20970496   8e  Linux LVM
Disk /dev/vda: 2147 MB, 2147483648 bytes
/dev/vda1               1        1009     2095662   83  Linux
Disk /dev/vdb: 2147 MB, 2147483648 bytes
/dev/vdb1               1        1009     2095662   83  Linux
Disk /dev/vdc: 2147 MB, 2147483648 bytes
/dev/vdc1               1        1009     2095662   83  Linux
Disk /dev/vdd: 2147 MB, 2147483648 bytes
/dev/vdd1               1        1009     2095662   83  Linux
Disk /dev/vde: 1073 MB, 1073741824 bytes
Disk /dev/dm-1 doesn't contain a valid partition table
/dev/vde1               1        1011     1048376+  83  Linux
Disk /dev/vdf: 1073 MB, 1073741824 bytes
/dev/vdf1               1        1011     1048376+  83  Linux
Disk /dev/vdg: 1073 MB, 1073741824 bytes
/dev/vdg1               1        1011     1048376+  83  Linux
Disk /dev/vdh: 1073 MB, 1073741824 bytes
/dev/vdh1               1        1011     1048376+  83  Linux
Disk /dev/dm-0: 4227 MB, 4227858432 bytes
Disk /dev/dm-2 doesn't contain a valid partition table
Disk /dev/dm-3 doesn't contain a valid partition table
Disk /dev/dm-4 doesn't contain a valid partition table
Disk /dev/dm-5 doesn't contain a valid partition table
Disk /dev/dm-1: 16.7 GB, 16710107136 bytes
Disk /dev/dm-2: 5368 MB, 5368709120 bytes
Disk /dev/dm-3: 5368 MB, 5368709120 bytes
Disk /dev/dm-4: 5368 MB, 5368709120 bytes
Disk /dev/dm-5: 5268 MB, 5268045824 bytes
[root@node01 ~]#
Also, you might notice that disks /dev/sda and /dev/sdb (previously /dev/sdj and /dev/sdi) have shown up - without messing up with their <disk> XML directive. Obviously the naming is controlled somewhere else, but not on the XML file or at least I don't know how and where.

Two questions arose observing the above output:

1. Why is the XML directive 'target dev=name' not working?
2. If one decides to add/reorganize/drop a disk, does this mean that he can expect again change in the naming conventions?

Can someone spread some light please?

Thanks in advance!
Reply With Quote
  #4  
Old 8th December 2012, 06:43 PM
stevea Online
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,988
linuxfirefox
Re: how to fix device mapping for guest virtual machine (qemu/KVM)

Well - I can understand what is happening, but I have no idea how to force the device naming from KVM.

Ultimately KVM just provides virtual hardware for the guest. It cannot force the guest to name the hardware devices in any way that I can imagine. Normally the kernel (guest for example) will examine th disk controllers in PCI bus order and then examine each drive on each contreoller and name (scsi, sata, ide) sda, sdb, sdc, in bus:drive order. The virtio will name the drives vda, vdb, .. .in order.

So I don't believe that kvm has the ability to force the guest to use a specific device name.

It might be interesting to change the 'target dev=' field and see if the guest observes the name or else the 'controller= bus= unit=' order. Id wager the guest ignores target dev=


--

Obviously you can manage this in the target by using mknod in a startup script or probably by configuring udev.


sorry I don't have more,
-S
__________________
None are more hopelessly enslaved than those who falsely believe they are free.
Johann Wolfgang von Goethe
Reply With Quote
Reply

Tags
device, fix, guest, machine, mapping, qemu or kvm, virtual

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't create virtual machine with QEMU/KVM tridc Using Fedora 1 10th November 2010 06:39 PM
Problem with QEMU and Virtual Machine Manager after updates, guest machine slow otnateos Using Fedora 6 12th April 2008 04:29 PM
Virtual Machine Manager vs. QEMU early-ehlinger Using Fedora 2 8th February 2008 02:58 PM
Using Ctrl+Alt+2 for QEMU Monitor on guest virtual machines urcabraz Servers & Networking 1 1st July 2007 04:10 AM
Xen QEMU virtual machine stuff Saint Mike Using Fedora 0 13th July 2006 06:15 AM


Current GMT-time: 07:26 (Sunday, 23-11-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Wangkui Travel Photos on Instagram - Castelo Branco - Fleron