[Libguestfs] [PATCH v2v v2 1/2] v2v: windows: Add a helper function for installing Powershell firstboot scripts.

Pino Toscano ptoscano at redhat.com
Thu Apr 25 14:26:53 UTC 2019


On Tuesday, 16 April 2019 10:55:39 CEST Richard W.M. Jones wrote:
> +(* Unfortunately Powershell scripts cannot be directly executed
> + * (unless some system config changes are made which for other
> + * reasons we don't want to do) and so we have to run this via
> + * a regular batch file.
> + *)
> +let install_firstboot_powershell g { Types.i_windows_systemroot; i_root }
> +                                 filename code =
> +  let tempdir = sprintf "%s/Temp" i_windows_systemroot in
> +  g#mkdir_p tempdir;
> +  let code = String.concat "\r\n" code ^ "\r\n" in

The Firstboot module uses String.unix2dos to convert the script to the
proper newline style for Windows.  What about assuming that 'code' is a
single Unix-style string with the whole script, calling String.unix2dos,
instead of taking the list of lines?  Mostly for consistency, so
everything that writes files on Windows uses String.unix2dos.

> +  (* Powershell interpreter.  Should we check this exists? XXX *)
> +  let ps_exe =
> +    i_windows_systemroot ^
> +    "\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" in

According to the Interweb, it looks like this location was kept even
for PowerShell 2.0+ for "compatibility".

OTOH the comment raises another concern: what about old Windows versions
without PowerShell?  Most probably virt-v2v needs to report that to the
user (a warning, perhaps) so they know that the static IPs (specified
on the command line) cannot be preserved anyway.  Otherwise, the
conversion will work fine, and the user realize that this did not work
only when booting the converted Windows.

Maybe add a simple is_powershell_available helper to this (Windows)
module?

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190425/8f82874f/attachment.sig>


More information about the Libguestfs mailing list