WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Support "bootloader" mode for "drbd:" devices

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] Support "bootloader" mode for "drbd:" devices
From: Michael Renner <michael.renner@xxxxxxxxxxx>
Date: Thu, 03 Sep 2009 15:16:56 +0200
Delivery-date: Thu, 03 Sep 2009 06:17:31 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Preisvergleich Internet Services AG
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)
There's a bit of glue missing in xend to support the "bootloader" stanza in Guests which use a "drbd:" device as their bootdevice.

This patch extends and supersedes Bug #1438.


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


*) 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 resouces 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.


The patches need some revising since I'm neither very fluent in Python nor familiar with the error handling infrastructure in xend.


subprocess has been replaced by os.popen2 and os.system per comment from Masaki Kanno in #1506.


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 <at> geizhals.at>


best regards,
Michael Renner


--

Geizhals(R) - Preisvergleich
Preisvergleich Internet Services AG
Obere Donaustrasse 63/2
A-1020 Wien
Tel: +43 1 5811609/87
Fax: +43 1 5811609/55

Handelsgericht Wien | FN 197241K | Firmensitz Wien
--- a/tools/python/xen/xend/XendDomainInfo.py   2009-08-06 15:57:25.000000000 
+0200
+++ b/tools/python/xen/xend/XendDomainInfo.py   2009-09-03 11:57:03.000000000 
+0200
@@ -2894,6 +2893,15 @@
             disk = devinfo[1]['uname']
 
             fn = blkdev_uname_to_file(disk)
+
+            # If this is a drbd volume, check if we need to activate it
+            (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 == 'tap' and taptype != 'aio' and taptype != 
'sync' and not os.stat(fn).st_rdev
             if mounted:
--- a/tools/python/xen/util/blkif.py    2009-08-06 15:57:25.000000000 +0200
+++ b/tools/python/xen/util/blkif.py    2009-09-03 12:46:33.000000000 +0200
@@ -75,8 +75,17 @@
     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)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Support "bootloader" mode for "drbd:" devices, Michael Renner <=