Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm starting a xen domU using xm create config.cfg. Within the config file are a number of physical block devices (LVs) which are added to the guest and can be accessed fine when it boots. However, at a point in the future I need to be able to hot unplug one of these disks using the xm block-detach command. This command, however, requires the vbd id of the device to be detached and I can't find a way to find the device id for a particular disk 'plugged in' at start up. Any help is much appreciated!

share|improve this question

4 Answers 4

I'm not aware of any "good" way to correlate the output of xm block-list <dom> to the physical devices in dom0. Possibly the best you can do is parse the DevController entries from xend.log, which detail the VBD's frontend and backend names at the point of creation. It's certainly not foolproof though and should be used with caution.

share|improve this answer
    
Interesting. Thanks for the suggestion - will take a look. One thought that just struck me is that possibly the block-list rows are in the same order that the disks are listed in the original configuration file - in which case it may be simple enough to work out which id refers to which device after all. –  Joe Jun 21 '10 at 15:54
    
In my experience block-list does return the same order as the domain's config file is parsed. However I'm not sure what happens once you've added and removed a few BDs over time. Additionally there's no guarantee that the config won't have changed since the domU was booted, so it's probably not safe to rely upon. –  Dan Carley Jun 21 '10 at 16:24
up vote 2 down vote accepted

Eventually did this using the fact that block-list lists the devices in the order that they were added to guest. As long as one stores this order, it's possible to scrape the vbd id from this list and then detach it from the domU later.

share|improve this answer

Start with

#> xm block-list playground
Vdev  BE handle state evt-ch ring-ref BE-path
51713    0    0     4      8      8     /local/domain/0/backend/vbd/10/51713  
51714    0    0     4      9      9     /local/domain/0/backend/vbd/10/51714  
51729    0    0     4      10     10    /local/domain/0/backend/vbd/10/51729  
51730    0    0     4      11     11    /local/domain/0/backend/vbd/10/51730

Then use xenstore-ls (or xsls). You'll get something like this:

...
51729 = ""
 domain = "playground"
 frontend = "/local/domain/10/device/vbd/51729"
 uuid = "da5b1321-249e-c7a6-6ba8-5f5a01fe3b85"
 dev = "xvdb1"
 state = "4"
 params = "/dev/sde1"
 mode = "w"
 online = "1"
 frontend-id = "10"
 type = "phy"
 physical-device = "fd:11"
 hotplug-status = "connected"
 feature-barrier = "1"
 sectors = "2097152"
 info = "0"
 sector-size = "512"
...

In the case above, you can see that the virtual block device /local/domain/10/device/vbd/51729 maps to the physical device /dev/sde1

share|improve this answer

You can try: xm block-list --long <dom>

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.