From 4d47befa91da660e97cb71a63a362b85c9cc7fa4 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 Oct 2013 19:23:33 +0000 Subject: [PATCH] builder: Add -m/--memsize and --smp command line options. (cherry picked from commit 42e445f98692c6344baafaab1da10e821288ac0a) --- builder/builder.ml | 6 ++++-- builder/cmdline.ml | 15 +++++++++++++-- builder/virt-builder.pod | 22 ++++++++++++++++------ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/builder/builder.ml b/builder/builder.ml index f247cd2..2437d56 100644 --- a/builder/builder.ml +++ b/builder/builder.ml @@ -38,9 +38,9 @@ let main () = (* Command line argument parsing - see cmdline.ml. *) let mode, arg, attach, cache, check_signature, curl, debug, delete, edit, fingerprint, - firstboot, run, format, gpg, hostname, install, list_long, mkdirs, + firstboot, run, format, gpg, hostname, install, list_long, memsize, mkdirs, network, output, password_crypto, quiet, root_password, scrub, - scrub_logfile, size, source, sync, upload, writes = + scrub_logfile, size, smp, source, sync, upload, writes = parse_cmdline () in (* Timestamped messages in ordinary, non-debug non-quiet mode. *) @@ -400,6 +400,8 @@ let main () = let g = new G.guestfs () in if debug then g#set_trace true; + (match memsize with None -> () | Some memsize -> g#set_memsize memsize); + (match smp with None -> () | Some smp -> g#set_smp smp); g#set_network network; (* The output disk is being created, so use cache=unsafe here. *) diff --git a/builder/cmdline.ml b/builder/cmdline.ml index 28a1643..97ccd89 100644 --- a/builder/cmdline.ml +++ b/builder/cmdline.ml @@ -120,6 +120,9 @@ let parse_cmdline () = let list_long = ref false in + let memsize = ref None in + let set_memsize arg = memsize := Some arg in + let mkdirs = ref [] in let add_mkdir arg = mkdirs := arg :: !mkdirs in @@ -160,6 +163,9 @@ let parse_cmdline () = let size = ref None in let set_size arg = size := Some (parse_size ~prog arg) in + let smp = ref None in + let set_smp arg = smp := Some arg in + let source = try Sys.getenv "VIRT_BUILDER_SOURCE" with Not_found -> "http://libguestfs.org/download/builder/index.asc" in @@ -234,6 +240,8 @@ let parse_cmdline () = "--long", Arg.Set list_long, ditto; "--no-logfile", Arg.Set scrub_logfile, " " ^ s_"Scrub build log file"; "--long-options", Arg.Unit display_long_options, " " ^ s_"List long options"; + "-m", Arg.Int set_memsize, "mb" ^ " " ^ s_"Set memory size"; + "--memsize", Arg.Int set_memsize, "mb" ^ ditto; "--mkdir", Arg.String add_mkdir, "dir" ^ " " ^ s_"Create directory"; "--network", Arg.Set network, " " ^ s_"Enable appliance network (default)"; "--no-network", Arg.Clear network, " " ^ s_"Disable appliance network"; @@ -251,6 +259,7 @@ let parse_cmdline () = "--run-command", Arg.String add_run_cmd, "cmd+args" ^ " " ^ s_"Run command in disk image"; "--scrub", Arg.String add_scrub, "name" ^ " " ^ s_"Scrub a file"; "--size", Arg.String set_size, "size" ^ " " ^ s_"Set output disk size"; + "--smp", Arg.Int set_smp, "vcpus" ^ " " ^ s_"Set number of vCPUs"; "--source", Arg.Set_string source, "URL" ^ " " ^ s_"Set source URL"; "--no-sync", Arg.Clear sync, " " ^ s_"Do not fsync output file on exit"; "--upload", Arg.String add_upload, "file:dest" ^ " " ^ s_"Upload file to dest"; @@ -300,6 +309,7 @@ read the man page virt-builder(1). let hostname = !hostname in let install = List.rev !install in let list_long = !list_long in + let memsize = !memsize in let mkdirs = List.rev !mkdirs in let network = !network in let output = match !output with "" -> None | s -> Some s in @@ -309,6 +319,7 @@ read the man page virt-builder(1). let scrub = List.rev !scrub in let scrub_logfile = !scrub_logfile in let size = !size in + let smp = !smp in let source = !source in let sync = !sync in let upload = List.rev !upload in @@ -366,6 +377,6 @@ read the man page virt-builder(1). mode, arg, attach, cache, check_signature, curl, debug, delete, edit, fingerprint, - firstboot, run, format, gpg, hostname, install, list_long, mkdirs, + firstboot, run, format, gpg, hostname, install, list_long, memsize, mkdirs, network, output, password_crypto, quiet, root_password, scrub, - scrub_logfile, size, source, sync, upload, writes + scrub_logfile, size, smp, source, sync, upload, writes diff --git a/builder/virt-builder.pod b/builder/virt-builder.pod index cd20043..66ed030 100644 --- a/builder/virt-builder.pod +++ b/builder/virt-builder.pod @@ -366,6 +366,18 @@ the image was built, use this option. See also: L. +=item B<-m> MB + +=item B<--memsize> MB + +Change the amount of memory allocated to I<--run> scripts. Increase +this if you find that I<--run> scripts or the I<--install> option are +running out of memory. + +The default can be found with this command: + + guestfish get-memsize + =item B<--mkdir> DIR Create a directory in the guest. @@ -544,6 +556,10 @@ used. To specify size in bytes, the number must be followed by the lowercase letter I, eg: S>. +=item B<--smp> N + +Enable N E 2 virtual CPUs for I<--run> scripts to use. + =item B<--source> URL Set the source URL to look for templates. If not specified it @@ -1438,12 +1454,6 @@ are actually interpreted by L, not virt-builder. Used to determine the location of the template cache. See L. -=item C - -The size (in megabytes) of the appliance. The default can be found -using the command S>. Increase this if you -find that I<--run> scripts are running out of memory. - =item C Set the default value for the GPG signature fingerprint (see -- 1.8.5.3