[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xend: Support "bootloader" mode for "drbd:" devices



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1252050130 -3600
# Node ID f9ce5858f7eae84bec34aa10d3585c7e6f6ca6c9
# Parent  b4b79f3e3118353579374c2a1908556ebb9e7281
xend: Support "bootloader" mode for "drbd:" devices

To be able to use "bootloader" on drbd devices the following changes
need to be made:

*) Translation of devicename

_parse_uname which is used by blkdev_uname_to_file which is again used
by _configureBootloader in XendDomainInfo needs to be able to resolve
drbd resources to the corresponding blockdevice to feed to the
configured bootloader.

*) Activation of drbd device

If the drbd device isn't in Primary mode when the bootloader tries to
fetch the kernel and initrd, the start of the DomU will fail. To
prevent this the given drbd device will be made Primary before the
bootloader gets executed.

A note on the naming of drbd resouces: drbd uses mostly resource names
in it's userland tools. Because of that drbd VBDs, if configured with
the "drbd:" type, should always use the drbd resource name as
suggested by the drbd documentation at
http://www.drbd.org/users-guide-emb/s-xen-configure-domu.html. My
patches assume that the VBDs are named accordingly.

Signed-off-by: Michael Renner <michael.renner@xxxxxxxxxxx>
---
 tools/python/xen/util/blkif.py          |   11 ++++++++++-
 tools/python/xen/xend/XendDomainInfo.py |   10 ++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff -r b4b79f3e3118 -r f9ce5858f7ea tools/python/xen/util/blkif.py
--- a/tools/python/xen/util/blkif.py    Fri Sep 04 08:34:45 2009 +0100
+++ b/tools/python/xen/util/blkif.py    Fri Sep 04 08:42:10 2009 +0100
@@ -75,8 +75,17 @@ def _parse_uname(uname):
     fn = taptype = None
     if uname.find(":") != -1:
         (typ, fn) = uname.split(":", 1)
-        if typ in ("phy", "drbd") and not fn.startswith("/"):
+
+        if typ == "phy" and not fn.startswith("/"):
             fn = "/dev/%s" %(fn,)
+
+        if typ == "drbd":
+            if not fn.startswith("drbd"):
+                (drbdadmstdin, drbdadmstdout) = os.popen2(["/sbin/drbdadm", 
"sh-dev", fn])
+                fn = drbdadmstdout.readline().strip()
+            else:
+                fn = "/dev/%s" %(fn,)
+               
         if typ == "tap":
             (taptype, fn) = fn.split(":", 1)
     return (fn, taptype)
diff -r b4b79f3e3118 -r f9ce5858f7ea tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Fri Sep 04 08:34:45 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Fri Sep 04 08:42:10 2009 +0100
@@ -2994,6 +2994,16 @@ class XendDomainInfo:
             disk = devinfo[1]['uname']
 
             fn = blkdev_uname_to_file(disk)
+
+            # If this is a drbd volume, check if we need to activate it
+            if disktype.find(":") != -1:
+                (disktype, diskname) = disk.split(':', 1)
+                if disktype == 'drbd':
+                    (drbdadmstdin, drbdadmstdout) = 
os.popen2(["/sbin/drbdadm", "state", diskname])
+                    (state, junk) = drbdadmstdout.readline().split('/', 1)
+                    if state == 'Secondary':
+                        os.system('/sbin/drbdadm primary ' + diskname)
+
             taptype = blkdev_uname_to_taptype(disk)
             mounted = devtype in ['tap', 'tap2'] and taptype != 'aio' and 
taptype != 'sync' and not os.stat(fn).st_rdev
             if mounted:

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.