|
|
384b531 |
From 5cfe8a0e678468318d8af403c197367979ba62a0 Mon Sep 17 00:00:00 2001
|
|
|
384b531 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
384b531 |
Date: Tue, 22 Oct 2013 22:28:27 +0100
|
|
|
384b531 |
Subject: [PATCH] builder: Add --no-sync option to avoid sync on exit.
|
|
|
384b531 |
|
|
|
384b531 |
(cherry picked from commit 3f46a92ed5737bb8d75630a39729f95bc96417f6)
|
|
|
384b531 |
---
|
|
|
384b531 |
builder/builder.ml | 5 +++--
|
|
|
384b531 |
builder/cmdline.ml | 6 +++++-
|
|
|
384b531 |
builder/virt-builder.pod | 17 +++++++++++++++++
|
|
|
384b531 |
3 files changed, 25 insertions(+), 3 deletions(-)
|
|
|
384b531 |
|
|
|
384b531 |
diff --git a/builder/builder.ml b/builder/builder.ml
|
|
|
384b531 |
index 477fc3e..7a46174 100644
|
|
|
384b531 |
--- a/builder/builder.ml
|
|
|
384b531 |
+++ b/builder/builder.ml
|
|
|
384b531 |
@@ -38,7 +38,7 @@ let main () =
|
|
|
384b531 |
attach, cache, check_signature, curl, debug, delete, edit, fingerprint,
|
|
|
384b531 |
firstboot, run, format, gpg, hostname, install, list_long, network, output,
|
|
|
384b531 |
password_crypto, quiet, root_password, scrub, scrub_logfile, size, source,
|
|
|
384b531 |
- upload =
|
|
|
384b531 |
+ sync, upload =
|
|
|
384b531 |
parse_cmdline () in
|
|
|
384b531 |
|
|
|
384b531 |
(* Timestamped messages in ordinary, non-debug non-quiet mode. *)
|
|
|
384b531 |
@@ -727,7 +727,8 @@ exec >>%s 2>&1
|
|
|
384b531 |
* and therefore bypasses the host cache). In general you should not
|
|
|
384b531 |
* use cache=none.
|
|
|
384b531 |
*)
|
|
|
384b531 |
- Fsync.file output;
|
|
|
384b531 |
+ if sync then
|
|
|
384b531 |
+ Fsync.file output;
|
|
|
384b531 |
|
|
|
384b531 |
(* Now that we've finished the build, don't delete the output file on
|
|
|
384b531 |
* exit.
|
|
|
384b531 |
diff --git a/builder/cmdline.ml b/builder/cmdline.ml
|
|
|
384b531 |
index 780e171..41d2a64 100644
|
|
|
384b531 |
--- a/builder/cmdline.ml
|
|
|
384b531 |
+++ b/builder/cmdline.ml
|
|
|
384b531 |
@@ -161,6 +161,8 @@ let parse_cmdline () =
|
|
|
384b531 |
with Not_found -> "http://libguestfs.org/download/builder/index.asc" in
|
|
|
384b531 |
let source = ref source in
|
|
|
384b531 |
|
|
|
384b531 |
+ let sync = ref true in
|
|
|
384b531 |
+
|
|
|
384b531 |
let upload = ref [] in
|
|
|
384b531 |
let add_upload arg =
|
|
|
384b531 |
let i =
|
|
|
384b531 |
@@ -232,6 +234,7 @@ let parse_cmdline () =
|
|
|
384b531 |
"--scrub", Arg.String add_scrub, "name" ^ " " ^ s_"Scrub a file";
|
|
|
384b531 |
"--size", Arg.String set_size, "size" ^ " " ^ s_"Set output disk size";
|
|
|
384b531 |
"--source", Arg.Set_string source, "URL" ^ " " ^ s_"Set source URL";
|
|
|
384b531 |
+ "--no-sync", Arg.Clear sync, " " ^ s_"Do not fsync output file on exit";
|
|
|
384b531 |
"--upload", Arg.String add_upload, "file:dest" ^ " " ^ s_"Upload file to dest";
|
|
|
384b531 |
"-v", Arg.Set debug, " " ^ s_"Enable debugging messages";
|
|
|
384b531 |
"--verbose", Arg.Set debug, ditto;
|
|
|
384b531 |
@@ -287,6 +290,7 @@ read the man page virt-builder(1).
|
|
|
384b531 |
let scrub_logfile = !scrub_logfile in
|
|
|
384b531 |
let size = !size in
|
|
|
384b531 |
let source = !source in
|
|
|
384b531 |
+ let sync = !sync in
|
|
|
384b531 |
let upload = List.rev !upload in
|
|
|
384b531 |
|
|
|
384b531 |
(* Check options. *)
|
|
|
384b531 |
@@ -343,4 +347,4 @@ read the man page virt-builder(1).
|
|
|
384b531 |
attach, cache, check_signature, curl, debug, delete, edit, fingerprint,
|
|
|
384b531 |
firstboot, run, format, gpg, hostname, install, list_long, network, output,
|
|
|
384b531 |
password_crypto, quiet, root_password, scrub, scrub_logfile, size, source,
|
|
|
384b531 |
- upload
|
|
|
384b531 |
+ sync, upload
|
|
|
384b531 |
diff --git a/builder/virt-builder.pod b/builder/virt-builder.pod
|
|
|
384b531 |
index 094b327..c3ea581 100644
|
|
|
384b531 |
--- a/builder/virt-builder.pod
|
|
|
384b531 |
+++ b/builder/virt-builder.pod
|
|
|
384b531 |
@@ -410,6 +410,23 @@ You don't have a host network (eg. in secure/restricted environments).
|
|
|
384b531 |
|
|
|
384b531 |
=back
|
|
|
384b531 |
|
|
|
384b531 |
+=item B<--no-sync>
|
|
|
384b531 |
+
|
|
|
384b531 |
+Do not sync the output file on exit.
|
|
|
384b531 |
+
|
|
|
384b531 |
+Virt-builder fsync's the output file or disk image when it exits.
|
|
|
384b531 |
+
|
|
|
384b531 |
+The reason is that qemu/KVM's default caching mode is C<none> or
|
|
|
384b531 |
+C<directsync>, both of which bypass the host page cache. Therefore
|
|
|
384b531 |
+these would not work correctly if you immediately started the guest
|
|
|
384b531 |
+after running virt-builder - they would not see the complete output
|
|
|
384b531 |
+file. (Note that you should not use these caching modes - they are
|
|
|
384b531 |
+fundamentally broken for this and other reasons.)
|
|
|
384b531 |
+
|
|
|
384b531 |
+If you are not using these broken caching modes, you can use
|
|
|
384b531 |
+I<--no-sync> to avoid this unnecessary sync and gain considerable
|
|
|
384b531 |
+extra performance.
|
|
|
384b531 |
+
|
|
|
384b531 |
=item B<--notes> os-version
|
|
|
384b531 |
|
|
|
384b531 |
List any notes associated with this guest, then exit (this does not do
|
|
|
384b531 |
--
|
|
|
384b531 |
1.8.3.1
|
|
|
384b531 |
|