Merge lp:~rconradharris/nova/bug705790 into lp:~hudson-openstack/nova/trunk

Proposed by Rick Harris
Status: Merged
Approved by: Jay Pipes
Approved revision: 602
Merged at revision: 602
Proposed branch: lp:~rconradharris/nova/bug705790
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 81 lines (+38/-1)
2 files modified
nova/virt/xenapi/vm_utils.py (+30/-1)
nova/virt/xenapi_conn.py (+8/-0)
To merge this branch: bzr merge lp:~rconradharris/nova/bug705790
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Ed Leafe (community) Approve
Devin Carlen (community) Approve
Josh Kearney (community) Approve
Review via email: mp+47116@code.launchpad.net

Description of the change

This patch adds two flags:

--xenapi_remap_vbd_dev
--xenapi_remap_vbd_dev_prefix

If the plugged-in VBD dev is wrong, these configs let your remap it on the fly. This works around a bug in Ubuntu Maverick: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/684875

To post a comment you must log in.
Revision history for this message
Josh Kearney (jk0) wrote :

lgtm - can't wait to get this in!

review: Approve
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Ed Leafe (ed-leafe) wrote :

Lines 49-50 should be changed to use mapping instead of positional formatting:

LOG.debug(_('VBD %(vbd)s plugged into wrong dev, remapping to %(dev)s') % locals())

Otherwise, lgtm.

review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Ed Leafe (ed-leafe) wrote :

The revision looks great.

review: Approve
Revision history for this message
Jay Pipes (jaypipes) wrote :

lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/virt/xenapi/vm_utils.py'
2--- nova/virt/xenapi/vm_utils.py 2011-01-17 19:32:34 +0000
3+++ nova/virt/xenapi/vm_utils.py 2011-01-21 22:18:26 +0000
4@@ -22,6 +22,7 @@
5 import os
6 import pickle
7 import re
8+import time
9 import urllib
10 from xml.dom import minidom
11
12@@ -589,6 +590,27 @@
13 return None
14
15
16+def remap_vbd_dev(dev):
17+ """Return the appropriate location for a plugged-in VBD device
18+
19+ Ubuntu Maverick moved xvd? -> sd?. This is considered a bug and will be
20+ fixed in future versions:
21+ https://bugs.launchpad.net/ubuntu/+source/linux/+bug/684875
22+
23+ For now, we work around it by just doing a string replace.
24+ """
25+ # NOTE(sirp): This hack can go away when we pull support for Maverick
26+ should_remap = FLAGS.xenapi_remap_vbd_dev
27+ if not should_remap:
28+ return dev
29+
30+ old_prefix = 'xvd'
31+ new_prefix = FLAGS.xenapi_remap_vbd_dev_prefix
32+ remapped_dev = dev.replace(old_prefix, new_prefix)
33+
34+ return remapped_dev
35+
36+
37 def with_vdi_attached_here(session, vdi, read_only, f):
38 this_vm_ref = get_this_vm_ref(session)
39 vbd_rec = {}
40@@ -611,7 +633,13 @@
41 LOG.debug(_('Plugging VBD %s ... '), vbd)
42 session.get_xenapi().VBD.plug(vbd)
43 LOG.debug(_('Plugging VBD %s done.'), vbd)
44- return f(session.get_xenapi().VBD.get_device(vbd))
45+ orig_dev = session.get_xenapi().VBD.get_device(vbd)
46+ LOG.debug(_('VBD %s plugged as %s'), vbd, orig_dev)
47+ dev = remap_vbd_dev(orig_dev)
48+ if dev != orig_dev:
49+ LOG.debug(_('VBD %(vbd)s plugged into wrong dev, '
50+ 'remapping to %(dev)s') % locals())
51+ return f(dev)
52 finally:
53 LOG.debug(_('Destroying VBD for VDI %s ... '), vdi)
54 vbd_unplug_with_retry(session, vbd)
55@@ -624,6 +652,7 @@
56 DEVICE_DETACH_REJECTED. For reasons which I don't understand, we're
57 seeing the device still in use, even when all processes using the device
58 should be dead."""
59+ # FIXME(sirp): We can use LoopingCall here w/o blocking sleep()
60 while True:
61 try:
62 session.get_xenapi().VBD.unplug(vbd)
63
64=== modified file 'nova/virt/xenapi_conn.py'
65--- nova/virt/xenapi_conn.py 2011-01-18 22:55:03 +0000
66+++ nova/virt/xenapi_conn.py 2011-01-21 22:18:26 +0000
67@@ -109,6 +109,14 @@
68 flags.DEFINE_string('iqn_prefix',
69 'iqn.2010-10.org.openstack',
70 'IQN Prefix')
71+# NOTE(sirp): This is a work-around for a bug in Ubuntu Maverick, when we pull
72+# support for it, we should remove this
73+flags.DEFINE_bool('xenapi_remap_vbd_dev', False,
74+ 'Used to enable the remapping of VBD dev '
75+ '(Works around an issue in Ubuntu Maverick)')
76+flags.DEFINE_string('xenapi_remap_vbd_dev_prefix', 'sd',
77+ 'Specify prefix to remap VBD dev to '
78+ '(ex. /dev/xvdb -> /dev/sdb)')
79
80
81 def get_connection(_):