From: Ian Jackson Subject: [OSSTEST PATCH 10/24] LVM: Break out lv_create Date: Fri, 13 Nov 2015 12:03:38 +0000 Message-ID: <1447416232-12699-11-git-send-email-ian.jackson@eu.citrix.com> References: <1447416232-12699-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZxD5P-0001Vp-W9 for xen-devel@lists.xenproject.org; Fri, 13 Nov 2015 12:04:12 +0000 In-Reply-To: <1447416232-12699-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Robert Ho , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org We are going to want to reuse this. lv_create doesn't (want to) take a $gho, but the $vg and $lv names directly (so that callers can use it when they don't have a suitable $gho whose $gho->{Lvdev} they want to use). In the one existing call site we pass $gho->{Vg} and $gho->{Lv} so that the effect is the same. There is a minor functional change: $gho->{Lvdev} has been put through lv_dev_mapper. But we don't care about that in lv_create (since the LVM operations, and dd, are perfectly happy to use the `real', non-/dev/mapper, names). So we can just use /dev/$vg/$lv. Signed-off-by: Ian Jackson Signed-off-by: Robert Ho Tested-by: Robert Ho Acked-by: Ian Campbell --- v17: Discuss change to /dev/$vg/$lv from $gho->{Lvdev}. v14: New patch v15: Change some trivial typo, so to resolve conflicts with production tree. --- Osstest/TestSupport.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index b70f19f..b507ada 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -63,7 +63,7 @@ BEGIN { target_install_packages target_install_packages_norec target_jobdir target_extract_jobdistpath_subdir target_extract_jobdistpath - lv_dev_mapper + lv_create lv_dev_mapper poll_loop tcpconnect await_tcp contents_make_cpio file_simple_write_contents @@ -713,6 +713,15 @@ sub poll_loop ($$$&) { logm("$what: ok. (${waited}s)"); } +sub lv_create ($$$$) { + my ($ho, $vg, $lv, $mb) = @_; + my $lvdev = "/dev/$vg/$lv"; + target_cmd_root($ho, "lvremove -f $lvdev ||:"); + target_cmd_root($ho, "lvcreate -L ${mb}M -n $lv $vg"); + target_cmd_root($ho, "dd if=/dev/zero of=$lvdev count=10"); + return $lvdev; +} + sub lv_dev_mapper ($$) { my ($vg,$lv) = @_; $vg =~ s/-/--/g; @@ -1692,9 +1701,7 @@ sub prepareguest ($$$$$$) { sub prepareguest_part_lvmdisk ($$$) { my ($ho, $gho, $disk_mb) = @_; - target_cmd_root($ho, "lvremove -f $gho->{Lvdev} ||:"); - target_cmd_root($ho, "lvcreate -L ${disk_mb}M -n $gho->{Lv} $gho->{Vg}"); - target_cmd_root($ho, "dd if=/dev/zero of=$gho->{Lvdev} count=10"); + lv_create($ho, $gho->{Vg}, $gho->{Lv}, $disk_mb); } sub make_vhd ($$$) { -- 1.7.10.4