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

Re: [Libguestfs] [PATCH] New API: is-lv: check if a block device is a logical volume (RHBZ#619793)



On 30/07/10 16:40, Richard W.M. Jones wrote:
 From 6280ac9b987c14f89749b4b4fdfec5a647567432 Mon Sep 17 00:00:00 2001
From: Richard Jones<rjones redhat com>
Date: Fri, 30 Jul 2010 16:32:35 +0100
Subject: [PATCH] New API: is-lv: check if a block device is a logical volume (RHBZ#619793)

This adds a new API, guestfs_is_lv (g, device), which returns true iff
the named device is an LVM2 logical volume.

A sample guestfish session:

><fs>  lvs
/dev/vg_f13x64/lv_root
/dev/vg_f13x64/lv_swap
><fs>  list-devices
/dev/vda
><fs>  list-partitions
/dev/vda1
/dev/vda2
><fs>  is-lv /dev/vg_f13x64/lv_root
true
><fs>  is-lv /dev/vg_f13x64/lv_swap
true
><fs>  is-lv /dev/vda
false
><fs>  is-lv /dev/vda1
false
><fs>  is-lv /dev/vda2
false
---
  daemon/lvm.c     |   47 +++++++++++++++++++++++++++++++++++++++++++++++
  src/MAX_PROC_NR  |    2 +-
  src/generator.ml |   10 ++++++++++
  3 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 175b6c5..10b0c0d 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-263
+264
diff --git a/src/generator.ml b/src/generator.ml
index d537945..20f7ac0 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -4953,6 +4953,16 @@ This command deletes the key in key slot C<keyslot>  from the
  encrypted LUKS device C<device>.  C<key>  must be one of the
  I<other>  keys.");

+  ("is_lv", (RBool "lvflag", [Device "device"]), 264, [Optional "lvm2"],
+   [InitBasicFSonLVM, IfAvailable "lvm2", TestOutputTrue (
+      [["is_lv"; "/dev/VG/LV"]]);

This obviously needs to be a real test...

+    InitBasicFSonLVM, IfAvailable "lvm2", TestOutputFalse (
+      [["is_lv"; "/dev/sda1"]])],
+   "test if device is a logical volume",
+   "\
+This command tests whether C<device>  is a logical volume, and
+returns true iff this is the case.");
+
  ]

ACK once the test is added.

Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490


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