* How to get the real device in guest os after attached a disk?
@ 2012-07-17 3:40 Wangpan
2012-07-17 11:56 ` Stefan Hajnoczi
0 siblings, 1 reply; 4+ messages in thread
From: Wangpan @ 2012-07-17 3:40 UTC (permalink / raw)
To: kvm
Hi all,
I have a question as the subject above, the reason I want to know this is that, if I attach some disks on the guest,
for example, I specified /dev/vdc&/dev/vdd(target device) at the cmd line by using 'virsh attach-disk', but they may be /dev/vdb&/dev/vdc in the guest os,
so if the guest user want to detach the /dev/vdb(guest device), he\she will be confused with the two target devices /dev/vdb&/dev/vdc,
because he\she doesn't know the corresponding relation of the guest device and target device,
he\she may detach an error device /dev/vdd(target device) which corresponding to /dev/vdc(guest device).
Could anyone give me some idea?
Thanks in advance.
Best Regards
Wangpan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to get the real device in guest os after attached a disk?
2012-07-17 3:40 How to get the real device in guest os after attached a disk? Wangpan
@ 2012-07-17 11:56 ` Stefan Hajnoczi
2012-07-18 4:01 ` Wangpan
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2012-07-17 11:56 UTC (permalink / raw)
To: Wangpan; +Cc: kvm, Ryan Harper, libvir-list
On Tue, Jul 17, 2012 at 4:40 AM, Wangpan <hzwangpan@corp.netease.com> wrote:
> I have a question as the subject above, the reason I want to know this is that, if I attach some disks on the guest,
> for example, I specified /dev/vdc&/dev/vdd(target device) at the cmd line by using 'virsh attach-disk', but they may be /dev/vdb&/dev/vdc in the guest os,
> so if the guest user want to detach the /dev/vdb(guest device), he\she will be confused with the two target devices /dev/vdb&/dev/vdc,
> because he\she doesn't know the corresponding relation of the guest device and target device,
> he\she may detach an error device /dev/vdd(target device) which corresponding to /dev/vdc(guest device).
>
> Could anyone give me some idea?
You can use the virtio-blk serial or file system/volume labels to
distinguish them.
For libvirt disk <serial> information, see the Domain XML documentation:
http://libvirt.org/formatdomain.html#elementsDisks
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re: How to get the real device in guest os after attached a disk?
2012-07-17 11:56 ` Stefan Hajnoczi
@ 2012-07-18 4:01 ` Wangpan
2012-07-18 8:21 ` Stefan Hajnoczi
0 siblings, 1 reply; 4+ messages in thread
From: Wangpan @ 2012-07-18 4:01 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: kvm, Ryan Harper, libvir-list
Thanks Stefan,
But how can I get the serial info in the guest os?
I have tried 'hdparm', 'sdparm', 'lshw', 'smartctl' and failed finally.
for example,
root@debian:~# hdparm -i /dev/vdc
/dev/vdb:
HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device
HDIO_GET_IDENTITY failed: Inappropriate ioctl for device
The XML be attached is:
<disk type='block' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source dev='/dev/nbd1'/>
<target dev='vdc' bus='virtio'/>
<serial>WD-WMAP9A966149</serial>
<alias name='virtio-disk2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
</disk>
The kernel info:
root@debian:~# uname -a
Linux debian 2.6.32-5-amd64 #1 SMP Mon Jan 16 16:22:28 UTC 2012 x86_64 GNU/Linux
>On Tue, Jul 17, 2012 at 4:40 AM, Wangpan <hzwangpan@corp.netease.com> wrote:
>> I have a question as the subject above, the reason I want to know this is that, if I attach some disks on the guest,
>> for example, I specified /dev/vdc&/dev/vdd(target device) at the cmd line by using 'virsh attach-disk', but they may be /dev/vdb&/dev/vdc in the guest os,
>> so if the guest user want to detach the /dev/vdb(guest device), he\she will be confused with the two target devices /dev/vdb&/dev/vdc,
>> because he\she doesn't know the corresponding relation of the guest device and target device,
>> he\she may detach an error device /dev/vdd(target device) which corresponding to /dev/vdc(guest device).
>>
>> Could anyone give me some idea?
>
>You can use the virtio-blk serial or file system/volume labels to
>distinguish them.
>
>For libvirt disk <serial> information, see the Domain XML documentation:
>http://libvirt.org/formatdomain.html#elementsDisks
>
>Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re: How to get the real device in guest os after attached a disk?
2012-07-18 4:01 ` Wangpan
@ 2012-07-18 8:21 ` Stefan Hajnoczi
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2012-07-18 8:21 UTC (permalink / raw)
To: Wangpan; +Cc: kvm, Ryan Harper, libvir-list
On Wed, Jul 18, 2012 at 5:01 AM, Wangpan <hzwangpan@corp.netease.com> wrote:
> But how can I get the serial info in the guest os?
General documentation on persistent block device naming (just grabbed
the first useful link of Google):
https://wiki.archlinux.org/index.php/Persistent_block_device_naming
If your guest is recent enough it will automatically show the
virtio-blk device in /dev/disk/by-id.
If not, you may be able to check /sys/block/vda/serial yourself. If
that file is not present either your guest doesn't support virtio-blk
serial: either upgrade to a newer guest OS version or use one of the
other persistent naming mechanisms explained in the link above.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-18 8:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-17 3:40 How to get the real device in guest os after attached a disk? Wangpan
2012-07-17 11:56 ` Stefan Hajnoczi
2012-07-18 4:01 ` Wangpan
2012-07-18 8:21 ` Stefan Hajnoczi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.