2

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!

Zoredache
  • 128,755
  • 40
  • 271
  • 413
Joe
  • 344
  • 7
  • 23

4 Answers4

2

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.

Dan Carley
  • 25,189
  • 5
  • 52
  • 70
  • 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
2

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.

Joe
  • 344
  • 7
  • 23
2

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

ukautz
  • 414
  • 2
  • 2
0

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

jscott
  • 24,204
  • 8
  • 77
  • 99