Skip to content

Commit f698988

Browse files
sarika-pf9Omkar Deshpande
authored andcommitted
made fstrim optional
1 parent e23f51e commit f698988

6 files changed

Lines changed: 110 additions & 2 deletions

File tree

.github/workflows/build-rpm.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Build virt-v2v RPM 2.7.17
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build-rpm:
9+
runs-on: ubuntu-latest
10+
container:
11+
image: fedora:42
12+
13+
steps:
14+
- name: Install git first
15+
run: dnf install -y git
16+
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
22+
- name: Install build dependencies
23+
run: |
24+
dnf install -y rpm-build rpmdevtools git sqlite perl-hivex \
25+
autoconf automake libtool
26+
dnf builddep -y virt-v2v
27+
28+
- name: Setup rpmbuild tree under /root
29+
run: |
30+
rpmdev-setuptree
31+
mkdir -p /root/rpmbuild/{SPECS,SOURCES,BUILD,BUILDROOT,RPMS,SRPMS}
32+
33+
- name: Build patched tarball (autoreconf + make dist)
34+
working-directory: ${{ github.workspace }}
35+
run: |
36+
autoreconf -fiv
37+
./configure
38+
make dist
39+
40+
- name: Verify tarball name
41+
working-directory: ${{ github.workspace }}
42+
run: |
43+
ls -lh virt-v2v-2.7.13.tar.gz
44+
45+
- name: Download & extract upstream SRPM
46+
run: |
47+
cd /root
48+
dnf download --source virt-v2v \
49+
--enablerepo=fedora-source \
50+
--enablerepo=updates-source \
51+
--skip-unavailable
52+
53+
mkdir -p /tmp/srpm-extract
54+
cd /tmp/srpm-extract
55+
rpm2cpio /root/virt-v2v-*.src.rpm | cpio -idmv
56+
57+
# Move spec and sources to build tree
58+
mv virt-v2v.spec /root/rpmbuild/SPECS/
59+
cp *.keyring /root/rpmbuild/SOURCES/ 2>/dev/null || true
60+
cp *.sig /root/rpmbuild/SOURCES/ 2>/dev/null || true
61+
62+
- name: Copy patched tarball to SOURCES
63+
run: |
64+
cp /__w/virt-v2v/virt-v2v/virt-v2v-2.7.13.tar.gz /root/rpmbuild/SOURCES/
65+
66+
- name: Patch spec file
67+
run: |
68+
SPEC_FILE="/root/rpmbuild/SPECS/virt-v2v.spec"
69+
70+
# 1. Disable GPG checks
71+
sed -i 's/^\([[:space:]]*\)%{gpgverify}/#\1%{gpgverify}/' $SPEC_FILE
72+
sed -i 's/%global verify_tarball_signature 1/%global verify_tarball_signature 0/' $SPEC_FILE || true
73+
74+
# 2. Force Version to 2.7.13
75+
sed -i 's/^Version:.*/Version: 2.7.13/' $SPEC_FILE
76+
sed -i 's/^Release:.*/Release: 1.fc42/' $SPEC_FILE
77+
78+
# 3. Remove files that are missing in our build (oVirt support)
79+
sed -i '/virt-v2v-open/d' $SPEC_FILE
80+
sed -i '/virt-v2v-output-ovirt/d' $SPEC_FILE
81+
82+
- name: Build RPM (With Ignore Unpackaged Files)
83+
run: |
84+
cd /root/rpmbuild/SPECS
85+
# Added _unpackaged_files_terminate_build 0 to ignore the extra RHV man page
86+
rpmbuild -bb \
87+
--define "_topdir /root/rpmbuild" \
88+
--define "_unpackaged_files_terminate_build 0" \
89+
--nocheck \
90+
virt-v2v.spec
91+
92+
- name: Upload built RPMs
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: virt-v2v-2.7.13-rpm
96+
path: /root/rpmbuild/RPMS/x86_64/*.rpm

convert/convert.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type options = {
3838
root_choice : root_choice;
3939
static_ips : static_ip list;
4040
customize_ops : Customize_cmdline.ops;
41+
no_fstrim : bool;
4142
}
4243

4344
(* Mountpoint stats, used for free space estimation. *)
@@ -111,8 +112,11 @@ let rec convert input_disks options source =
111112
* because unused blocks are marked in the overlay and thus do
112113
* not have to be copied.
113114
*)
114-
message (f_"Mapping filesystem data to avoid copying unused and blank areas");
115-
do_fstrim g inspect;
115+
if not options.no_fstrim then (
116+
message (f_"Mapping filesystem data to avoid copying unused and blank areas");
117+
do_fstrim g inspect
118+
) else
119+
message (f_"Skipping fstrim (--no-fstrim specified)");
116120

117121
(* Check (fsck) the filesystems after conversion. *)
118122
g#umount_all ();

convert/convert.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type options = {
2424
root_choice : Types.root_choice; (** [--root] option *)
2525
static_ips : Types.static_ip list; (** [--mac :ip:] option *)
2626
customize_ops : Customize_cmdline.ops; (** virt-customize options *)
27+
no_fstrim : bool; (** [--no-fstrim] option *)
2728
}
2829

2930
val convert : NBD_URI.t list -> options -> Types.source ->

in-place/in_place.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ let rec main () =
146146
let set_root_choice = Types.set_root_choice root_choice in
147147

148148
(* Other options that we handle here. *)
149+
let no_fstrim = ref false in
149150
let print_source = ref false in
150151

151152
let input_modes =
@@ -180,6 +181,8 @@ let rec main () =
180181
s_"Map network ‘in’ to ‘out’";
181182
[ S 'O' ], Getopt.String ("output.xml", set_output_xml_option),
182183
s_"Set the output filename";
184+
[ L"no-fstrim" ], Getopt.Set no_fstrim,
185+
s_"Don't trim filesystems before conversion";
183186
[ L"print-source" ], Getopt.Set print_source,
184187
s_"Print source and stop";
185188
[ L"root" ], Getopt.String ("ask|... ", set_root_choice),
@@ -239,6 +242,7 @@ read the man page virt-v2v-in-place(1).
239242
let customize_ops = get_customize_ops () in
240243
let input_conn = !input_conn in
241244
let input_mode = !input_mode in
245+
let no_fstrim = !no_fstrim in
242246
let output_xml = !output_xml in
243247
let print_source = !print_source in
244248
let root_choice = !root_choice in
@@ -305,6 +309,7 @@ read the man page virt-v2v-in-place(1).
305309
root_choice;
306310
static_ips;
307311
customize_ops;
312+
no_fstrim;
308313
} in
309314

310315
(* Before starting the input module, check there is sufficient

inspector/inspector.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ read the man page virt-v2v-inspector(1).
280280
root_choice;
281281
static_ips;
282282
customize_ops;
283+
no_fstrim = false;
283284
} in
284285

285286
(* Before starting the input module, check there is sufficient

v2v/v2v.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ read the man page virt-v2v(1).
423423
root_choice;
424424
static_ips;
425425
customize_ops;
426+
no_fstrim = false;
426427
} in
427428

428429
(* Before starting the input module, check there is sufficient

0 commit comments

Comments
 (0)