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
=== modified file 'nova/virt/xenapi/vm_utils.py'
--- nova/virt/xenapi/vm_utils.py 2011-01-17 19:32:34 +0000
+++ nova/virt/xenapi/vm_utils.py 2011-01-21 22:18:26 +0000
@@ -22,6 +22,7 @@
22import os22import os
23import pickle23import pickle
24import re24import re
25import time
25import urllib26import urllib
26from xml.dom import minidom27from xml.dom import minidom
2728
@@ -589,6 +590,27 @@
589 return None590 return None
590591
591592
593def remap_vbd_dev(dev):
594 """Return the appropriate location for a plugged-in VBD device
595
596 Ubuntu Maverick moved xvd? -> sd?. This is considered a bug and will be
597 fixed in future versions:
598 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/684875
599
600 For now, we work around it by just doing a string replace.
601 """
602 # NOTE(sirp): This hack can go away when we pull support for Maverick
603 should_remap = FLAGS.xenapi_remap_vbd_dev
604 if not should_remap:
605 return dev
606
607 old_prefix = 'xvd'
608 new_prefix = FLAGS.xenapi_remap_vbd_dev_prefix
609 remapped_dev = dev.replace(old_prefix, new_prefix)
610
611 return remapped_dev
612
613
592def with_vdi_attached_here(session, vdi, read_only, f):614def with_vdi_attached_here(session, vdi, read_only, f):
593 this_vm_ref = get_this_vm_ref(session)615 this_vm_ref = get_this_vm_ref(session)
594 vbd_rec = {}616 vbd_rec = {}
@@ -611,7 +633,13 @@
611 LOG.debug(_('Plugging VBD %s ... '), vbd)633 LOG.debug(_('Plugging VBD %s ... '), vbd)
612 session.get_xenapi().VBD.plug(vbd)634 session.get_xenapi().VBD.plug(vbd)
613 LOG.debug(_('Plugging VBD %s done.'), vbd)635 LOG.debug(_('Plugging VBD %s done.'), vbd)
614 return f(session.get_xenapi().VBD.get_device(vbd))636 orig_dev = session.get_xenapi().VBD.get_device(vbd)
637 LOG.debug(_('VBD %s plugged as %s'), vbd, orig_dev)
638 dev = remap_vbd_dev(orig_dev)
639 if dev != orig_dev:
640 LOG.debug(_('VBD %(vbd)s plugged into wrong dev, '
641 'remapping to %(dev)s') % locals())
642 return f(dev)
615 finally:643 finally:
616 LOG.debug(_('Destroying VBD for VDI %s ... '), vdi)644 LOG.debug(_('Destroying VBD for VDI %s ... '), vdi)
617 vbd_unplug_with_retry(session, vbd)645 vbd_unplug_with_retry(session, vbd)
@@ -624,6 +652,7 @@
624 DEVICE_DETACH_REJECTED. For reasons which I don't understand, we're652 DEVICE_DETACH_REJECTED. For reasons which I don't understand, we're
625 seeing the device still in use, even when all processes using the device653 seeing the device still in use, even when all processes using the device
626 should be dead."""654 should be dead."""
655 # FIXME(sirp): We can use LoopingCall here w/o blocking sleep()
627 while True:656 while True:
628 try:657 try:
629 session.get_xenapi().VBD.unplug(vbd)658 session.get_xenapi().VBD.unplug(vbd)
630659
=== modified file 'nova/virt/xenapi_conn.py'
--- nova/virt/xenapi_conn.py 2011-01-18 22:55:03 +0000
+++ nova/virt/xenapi_conn.py 2011-01-21 22:18:26 +0000
@@ -109,6 +109,14 @@
109flags.DEFINE_string('iqn_prefix',109flags.DEFINE_string('iqn_prefix',
110 'iqn.2010-10.org.openstack',110 'iqn.2010-10.org.openstack',
111 'IQN Prefix')111 'IQN Prefix')
112# NOTE(sirp): This is a work-around for a bug in Ubuntu Maverick, when we pull
113# support for it, we should remove this
114flags.DEFINE_bool('xenapi_remap_vbd_dev', False,
115 'Used to enable the remapping of VBD dev '
116 '(Works around an issue in Ubuntu Maverick)')
117flags.DEFINE_string('xenapi_remap_vbd_dev_prefix', 'sd',
118 'Specify prefix to remap VBD dev to '
119 '(ex. /dev/xvdb -> /dev/sdb)')
112120
113121
114def get_connection(_):122def get_connection(_):