Mykola Ivanets
2020-Feb-17 16:00 UTC
[Libguestfs] [PATCH] virt-get-kernel: add '--blocksize' option support
From: Nikolay Ivanets <stenavin@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
Richard W.M. Jones
2020-Feb-17 18:04 UTC
Re: [Libguestfs] [PATCH] virt-get-kernel: add '--blocksize' option support
Thanks - I pushed this. It needed a small change (not actually a fix) to the man page so that the regular expression in podcheck.pl matched the new =item. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Reasonably Related Threads
- [PATCH 1/3] get-kernel: split command line handling in own function
- [PATCH 3/3] get-kernel: add --prefix
- [PATCH] (Almost) new tool: virt-get-kernel
- [PATCH 2/3] get-kernel: add --unversioned-names
- [PATCH v2 2/3] mllib: Use L"..." and S '...' for long and short options.