<div dir="ltr"><div><div><div>Hi there,<br><br></div>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.<br>
</div>Here is the output of original drbd-overview:<br> 1:r0/0 Connected Primary/Secondary UpToDate/UpToDate A r----- <br> 2:Antras-drbd0/0 Connected Secondary/Primary UpToDate/UpToDate A r----- _Antras vda virtio <br>
3:Svarainis-drbd0/0 Connected Primary/Secondary UpToDate/UpToDate A r----- *Svarainis vda virtio <br> 4:Svarainis-drbd1/0 Connected Primary/Secondary UpToDate/UpToDate A r-----<br><br></div>Here is the patch I suggest:<br>
<div><br>--- ./drbd-overview.orig 2013-05-20 10:38:00.790616544 +0300<br>+++ ./drbd-overview.new 2013-05-20 10:37:29.207518963 +0300<br>@@ -216,7 +216,7 @@<br> # parent<br> $_ = <V>;<br>
close(V) or warn "virsh dumpxml exit code: $?\n";<br>- for (m{<disk\ [^>]*>.*</disk>}gs) {<br>+ for (m{<disk\ [^>]*>.*?</disk>}gs) {<br> m{<source\ dev='/dev/drbd([^']+)'/>} or next;<br>
my $dev = $1;<br> if ($dev !~ /^\d+$/) {<br><br></div><div>And here is the output fixed drbd-overview:<br> 1:r0/0 Connected Primary/Secondary UpToDate/UpToDate A r----- <br>
2:Antras-drbd0/0 Connected Secondary/Primary UpToDate/UpToDate A r----- _Antras vda virtio <br> 3:Svarainis-drbd0/0 Connected Primary/Secondary UpToDate/UpToDate A r----- *Svarainis vda virtio <br> 4:Svarainis-drbd1/0 Connected Primary/Secondary UpToDate/UpToDate A r----- *Svarainis vdb virtio <br>
<br></div><div>Notice the 4th line. Previously it didn't provide any associations with virtual machines, now it provides correct one.<br></div><div>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.<br>
<br></div><div>Regards,<br></div><div>Liutauras<br></div></div>