From: Nikolay Ivanets <stenavin(a)gmail.com>
This patch adds '--blocksize' command line option for virt-get-kernel
tool. This option allows specifying disk sector size as described in
'guestfs_add_drive_opts' libguestfs API.
---
get-kernel/get_kernel.ml | 22 ++++++++++++----------
get-kernel/virt-get-kernel.pod | 8 ++++++++
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/get-kernel/get_kernel.ml b/get-kernel/get_kernel.ml
index ab6b2d55e..d29d0ef7f 100644
--- a/get-kernel/get_kernel.ml
+++ b/get-kernel/get_kernel.ml
@@ -26,6 +26,7 @@ module G = Guestfs
open Printf
let parse_cmdline () =
+ let blocksize = ref 0 in
let domain = ref None in
let file = ref None in
let libvirturi = ref "" in
@@ -52,14 +53,14 @@ let parse_cmdline () =
prefix := Some p in
let argspec = [
- [ S 'a'; L"add" ], Getopt.String (s_"file",
set_file), s_"Add disk image file";
- [ S 'c'; L"connect" ], Getopt.Set_string (s_"uri",
libvirturi), s_"Set libvirt URI";
- [ S 'd'; L"domain" ], Getopt.String (s_"domain",
set_domain), s_"Set libvirt guest name";
- [ L"format" ], Getopt.Set_string (s_"format", format),
s_"Format of input disk";
- [ S 'o'; L"output" ], Getopt.Set_string
(s_"directory", output), s_"Output directory";
- [ L"unversioned-names" ], Getopt.Set unversioned,
- s_"Use unversioned names for
files";
- [ L"prefix" ], Getopt.String (s_"prefix", set_prefix),
s_"Prefix for files";
+ [ S 'a'; L"add" ], Getopt.String (s_"file", set_file),
s_"Add disk image file";
+ [ L"blocksize" ], Getopt.Set_int ("512|4096", blocksize),
s_"Set disk sector size";
+ [ S 'c'; L"connect" ], Getopt.Set_string (s_"uri",
libvirturi), s_"Set libvirt URI";
+ [ S 'd'; L"domain" ], Getopt.String (s_"domain",
set_domain), s_"Set libvirt guest name";
+ [ L"format" ], Getopt.Set_string (s_"format", format),
s_"Format of input disk";
+ [ S 'o'; L"output" ], Getopt.Set_string (s_"directory",
output), s_"Output directory";
+ [ L"unversioned-names" ], Getopt.Set unversioned, s_"Use unversioned
names for files";
+ [ L"prefix" ], Getopt.String (s_"prefix", set_prefix),
s_"Prefix for files";
] in
let usage_msg =
sprintf (f_"\
@@ -102,9 +103,10 @@ read the man page virt-get-kernel(1).
fun g ->
let { URI.path; protocol; server; username; password } = uri in
let format = match !format with "auto" -> None | s -> Some s in
+ let blocksize = match !blocksize with 0 -> None | i -> Some i in
g#add_drive
- ~readonly:true ?format ~protocol ?server ?username ?secret:password
- path
+ ~readonly:true ?blocksize ?format ~protocol ?server ?username
+ ?secret:password path
in
(* Dereference the rest of the args. *)
diff --git a/get-kernel/virt-get-kernel.pod b/get-kernel/virt-get-kernel.pod
index 990d6a91f..748398dce 100644
--- a/get-kernel/virt-get-kernel.pod
+++ b/get-kernel/virt-get-kernel.pod
@@ -44,6 +44,14 @@ force a particular format use the I<--format> option.
Add a remote disk. The URI format is compatible with guestfish.
See L<guestfish(1)/ADDING REMOTE STORAGE>.
+=item B<--blocksize 512>
+
+=item B<--blocksize 4096>
+
+This parameter sets the sector size of the disk image added with I<-a>
+option and is ignored for libvirt guest added with I<-d> option. See
+also L<guestfs(3)/guestfs_add_drive_opts>.
+
=item B<--colors>
=item B<--colours>
--
2.17.2