35 lines
1.6 KiB
Diff
35 lines
1.6 KiB
Diff
|
From 089d9a235e0e8a959c6d85004e24f2cdb37681b4 Mon Sep 17 00:00:00 2001
|
||
|
From: Thorsten Bolten <t.bolten@gmx.de>
|
||
|
Date: Sat, 6 Apr 2024 10:41:20 -0400
|
||
|
Subject: [PATCH] -o rhv-upload: Add O_TRUNC to truncate JSON file if it exists
|
||
|
|
||
|
Fixes: https://github.com/libguestfs/virt-v2v/issues/46
|
||
|
Thanks: Nir Soffer
|
||
|
---
|
||
|
output/output_rhv_upload.ml | 5 +++--
|
||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/output/output_rhv_upload.ml b/output/output_rhv_upload.ml
|
||
|
index f8bff24f..d6fde169 100644
|
||
|
--- a/output/output_rhv_upload.ml
|
||
|
+++ b/output/output_rhv_upload.ml
|
||
|
@@ -269,7 +269,7 @@ See also the virt-v2v-output-rhv(1) manual.");
|
||
|
("rhv_disk_uuids", JSON.List ids) :: json_params
|
||
|
in
|
||
|
let precheck_json = dir // "v2vprecheck.json" in
|
||
|
- let fd = Unix.openfile precheck_json [O_WRONLY; O_CREAT] 0o600 in
|
||
|
+ let fd = Unix.openfile precheck_json [O_WRONLY; O_CREAT; O_TRUNC] 0o600 in
|
||
|
if Python_script.run_command ~stdout_fd:fd
|
||
|
precheck_script json_params [] <> 0 then
|
||
|
error (f_"failed server prechecks, see earlier errors");
|
||
|
@@ -395,7 +395,8 @@ See also the virt-v2v-output-rhv(1) manual.");
|
||
|
|
||
|
(* Start the transfer. *)
|
||
|
let transfer_json = dir // sprintf "v2vtransfer%d.json" i in
|
||
|
- let fd = Unix.openfile transfer_json [O_WRONLY; O_CREAT] 0o600 in
|
||
|
+ let fd =
|
||
|
+ Unix.openfile transfer_json [O_WRONLY; O_CREAT; O_TRUNC] 0o600 in
|
||
|
if Python_script.run_command ~stdout_fd:fd
|
||
|
transfer_script json_params [] <> 0 then
|
||
|
error (f_"failed to start transfer, see earlier errors");
|