Skip to content

Commit ab2acfc

Browse files
committed
maintenance: remove unused code from stream_vdi
The code to extract vdis from geneva / zurich releases has been unused for years Signed-off-by: Pau Ruiz Safont <[email protected]>
1 parent 7670247 commit ab2acfc

File tree

1 file changed

+0
-71
lines changed

1 file changed

+0
-71
lines changed

ocaml/xapi/stream_vdi.ml

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -554,74 +554,3 @@ let recv_all refresh_session ifd (__context : Context.t) rpc session_id vsn
554554
let has_inline_checksums = vsn.Importexport.export_vsn > 0 in
555555
recv_all_vdi refresh_session ifd __context rpc session_id
556556
~has_inline_checksums ~force
557-
558-
(** Receive a set of VDIs split into chunks in a tar format created out of a Zurich/Geneva
559-
exported VM. Each chunk has been independently compressed.*)
560-
let recv_all_zurich refresh_session ifd (__context : Context.t) rpc session_id
561-
prefix_vdis =
562-
TaskHelper.set_cancellable ~__context ;
563-
TaskHelper.set_description ~__context "Importing Virtual Machine" ;
564-
let progress = new_progress_record __context prefix_vdis in
565-
(* The next header in the sequence *)
566-
let hdr = ref None in
567-
let next () =
568-
hdr :=
569-
try Some (Tar_unix.get_next_header ifd) with
570-
| Tar.Header.End_of_stream ->
571-
None
572-
| e ->
573-
raise e
574-
in
575-
next () ;
576-
let recv_one ifd (__context : Context.t) (prefix, vdi_ref, _size) =
577-
(* Open this VDI and stream in all the blocks. Return when hdr represents
578-
a chunk which is not part of this VDI or the end of stream is reached. *)
579-
with_open_vdi __context rpc session_id vdi_ref `RW [Unix.O_WRONLY] 0o644
580-
(fun ofd _ ->
581-
let rec stream_from (last_suffix : string) =
582-
match !hdr with
583-
| Some hdr ->
584-
refresh_session () ;
585-
let file_name = hdr.Tar.Header.file_name in
586-
let length = hdr.Tar.Header.file_size in
587-
if Astring.String.is_prefix ~affix:prefix file_name then (
588-
let suffix =
589-
String.sub file_name (String.length prefix)
590-
(String.length file_name - String.length prefix)
591-
in
592-
if suffix <= last_suffix then (
593-
error
594-
"Expected VDI chunk suffix to have increased under \
595-
lexicograpic ordering; last = %s; this = %s"
596-
last_suffix suffix ;
597-
raise (Failure "Invalid XVA file")
598-
) ;
599-
debug "Decompressing %Ld bytes from %s\n" length file_name ;
600-
Gzip.Default.decompress ofd (fun zcat_in ->
601-
Tar_helpers.copy_n ifd zcat_in length
602-
) ;
603-
Tar_helpers.skip ifd (Tar.Header.compute_zero_padding_length hdr) ;
604-
(* XXX: this is totally wrong: *)
605-
made_progress __context progress length ;
606-
next () ;
607-
stream_from suffix
608-
)
609-
| None ->
610-
(* Since we don't count uncompressed bytes we aren't sure if we've
611-
really finished unfortunately. We can at least check to see if we
612-
were cancelled... *)
613-
TaskHelper.exn_if_cancelling ~__context ;
614-
()
615-
in
616-
stream_from "" ; Unixext.fsync ofd
617-
)
618-
in
619-
( try for_each_vdi __context (recv_one ifd __context) prefix_vdis
620-
with Unix.Unix_error (Unix.EIO, _, _) ->
621-
raise
622-
(Api_errors.Server_error (Api_errors.vdi_io_error, ["Device I/O error"]))
623-
) ;
624-
if !hdr <> None then (
625-
error "Failed to import XVA; some chunks were not processed." ;
626-
raise (Failure "Some XVA data not processed")
627-
)

0 commit comments

Comments
 (0)