[DRBD-user] drbd-overview fix to display multiple drbd devices in single kvm virtual host

Liutauras Adomaitis liutauras.adomaitis at gmail.com
Mon May 20 09:48:00 CEST 2013

Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.


Hi there,

this is my first post. I would like to share my fix for drbd-overview perl
script. The problem I am trying to solve is that if a KVM virtual machine
is using 2 drbd devices, drbd-overview doesn't show second device as used
by any virtual machine.
Here is the output of original drbd-overview:
  1:r0/0               Connected Primary/Secondary UpToDate/UpToDate A
r-----
  2:Antras-drbd0/0     Connected Secondary/Primary UpToDate/UpToDate A
r----- _Antras    vda virtio
  3:Svarainis-drbd0/0  Connected Primary/Secondary UpToDate/UpToDate A
r----- *Svarainis vda virtio
  4:Svarainis-drbd1/0  Connected Primary/Secondary UpToDate/UpToDate A
r-----

Here is the patch I suggest:

--- ./drbd-overview.orig        2013-05-20 10:38:00.790616544 +0300
+++ ./drbd-overview.new 2013-05-20 10:37:29.207518963 +0300
@@ -216,7 +216,7 @@
                # parent
                $_ = <V>;
                close(V) or warn "virsh dumpxml exit code: $?\n";
-               for (m{<disk\ [^>]*>.*</disk>}gs) {
+               for (m{<disk\ [^>]*>.*?</disk>}gs) {
                        m{<source\ dev='/dev/drbd([^']+)'/>} or next;
                        my $dev = $1;
                        if ($dev !~ /^\d+$/) {

And here is the output fixed drbd-overview:
  1:r0/0               Connected Primary/Secondary UpToDate/UpToDate A
r-----
  2:Antras-drbd0/0     Connected Secondary/Primary UpToDate/UpToDate A
r----- _Antras    vda virtio
  3:Svarainis-drbd0/0  Connected Primary/Secondary UpToDate/UpToDate A
r----- *Svarainis vda virtio
  4:Svarainis-drbd1/0  Connected Primary/Secondary UpToDate/UpToDate A
r----- *Svarainis vdb virtio

Notice the 4th line. Previously it didn't provide any associations with
virtual machines, now it provides correct one.
I am not a perl expert, nor even a beginner, so feel free to improve the
fix. Didn't test it more extensively, so don't know what it will show with
different virsh configs.

Regards,
Liutauras
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linbit.com/pipermail/drbd-user/attachments/20130520/398ce0c3/attachment.htm>


More information about the drbd-user mailing list