Skip to content

Commit

Permalink
maintenance: remove unused code from stream_vdi (#6054)
Browse files Browse the repository at this point in the history
The code to extract vdis from geneva / zurich releases has been unused
for years

This comment was amusing:
```
                (* XXX: this is totally wrong: *)
```
  • Loading branch information
lindig authored Oct 14, 2024
2 parents bb41b46 + ab2acfc commit 97565ca
Showing 1 changed file with 0 additions and 71 deletions.
71 changes: 0 additions & 71 deletions ocaml/xapi/stream_vdi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -554,74 +554,3 @@ let recv_all refresh_session ifd (__context : Context.t) rpc session_id vsn
let has_inline_checksums = vsn.Importexport.export_vsn > 0 in
recv_all_vdi refresh_session ifd __context rpc session_id
~has_inline_checksums ~force

(** Receive a set of VDIs split into chunks in a tar format created out of a Zurich/Geneva
exported VM. Each chunk has been independently compressed.*)
let recv_all_zurich refresh_session ifd (__context : Context.t) rpc session_id
prefix_vdis =
TaskHelper.set_cancellable ~__context ;
TaskHelper.set_description ~__context "Importing Virtual Machine" ;
let progress = new_progress_record __context prefix_vdis in
(* The next header in the sequence *)
let hdr = ref None in
let next () =
hdr :=
try Some (Tar_unix.get_next_header ifd) with
| Tar.Header.End_of_stream ->
None
| e ->
raise e
in
next () ;
let recv_one ifd (__context : Context.t) (prefix, vdi_ref, _size) =
(* Open this VDI and stream in all the blocks. Return when hdr represents
a chunk which is not part of this VDI or the end of stream is reached. *)
with_open_vdi __context rpc session_id vdi_ref `RW [Unix.O_WRONLY] 0o644
(fun ofd _ ->
let rec stream_from (last_suffix : string) =
match !hdr with
| Some hdr ->
refresh_session () ;
let file_name = hdr.Tar.Header.file_name in
let length = hdr.Tar.Header.file_size in
if Astring.String.is_prefix ~affix:prefix file_name then (
let suffix =
String.sub file_name (String.length prefix)
(String.length file_name - String.length prefix)
in
if suffix <= last_suffix then (
error
"Expected VDI chunk suffix to have increased under \
lexicograpic ordering; last = %s; this = %s"
last_suffix suffix ;
raise (Failure "Invalid XVA file")
) ;
debug "Decompressing %Ld bytes from %s\n" length file_name ;
Gzip.Default.decompress ofd (fun zcat_in ->
Tar_helpers.copy_n ifd zcat_in length
) ;
Tar_helpers.skip ifd (Tar.Header.compute_zero_padding_length hdr) ;
(* XXX: this is totally wrong: *)
made_progress __context progress length ;
next () ;
stream_from suffix
)
| None ->
(* Since we don't count uncompressed bytes we aren't sure if we've
really finished unfortunately. We can at least check to see if we
were cancelled... *)
TaskHelper.exn_if_cancelling ~__context ;
()
in
stream_from "" ; Unixext.fsync ofd
)
in
( try for_each_vdi __context (recv_one ifd __context) prefix_vdis
with Unix.Unix_error (Unix.EIO, _, _) ->
raise
(Api_errors.Server_error (Api_errors.vdi_io_error, ["Device I/O error"]))
) ;
if !hdr <> None then (
error "Failed to import XVA; some chunks were not processed." ;
raise (Failure "Some XVA data not processed")
)

0 comments on commit 97565ca

Please sign in to comment.