[Libguestfs] [PATCH v2 05/11] customize: add support for pvvxsvc
Richard W.M. Jones
rjones at redhat.com
Fri May 20 09:23:06 UTC 2016
On Wed, May 18, 2016 at 02:00:53PM +0200, Cédric Bosdonnat wrote:
> SUSE VMDP comes with a replacement for rhsrvany.exe named pvvxsvc.exe.
> Check for either one of them instead of only rhsrvany.
> ---
> builder/virt-builder.pod | 11 +++++++++--
> customize/firstboot.ml | 36 +++++++++++++++++++++---------------
> customize/virt-customize.pod | 6 ++++++
> sysprep/virt-sysprep.pod | 6 ++++++
> v2v/virt-v2v.pod | 6 ++++++
> 5 files changed, 48 insertions(+), 17 deletions(-)
>
> diff --git a/builder/virt-builder.pod b/builder/virt-builder.pod
> index dc36c13..be5b568 100644
> --- a/builder/virt-builder.pod
> +++ b/builder/virt-builder.pod
> @@ -840,11 +840,12 @@ F<~root/virt-sysprep-firstboot.log>.
> =item Windows
>
> F<rhsrvany.exe>, available from sources at
> -L<https://github.com/rwmjones/rhsrvany>, is installed to run the
> +L<https://github.com/rwmjones/rhsrvany>, or F<pvvxsvc.exe>, available
> +with SUSE VMDP is installed to run the
> first boot scripts. It is required, and the setup of first boot
> scripts will fail if it is not present.
>
> -F<rhsrvany.exe> is copied from the location pointed to by the
> +F<rhsrvany.exe> or F<pvvxsvc.exe> is copied from the location pointed to by the
> C<VIRT_TOOLS_DATA_DIR> environment variable; if not set, a compiled-in
> default will be used (something like F</usr/share/virt-tools>).
>
> @@ -1820,6 +1821,12 @@ I<--firstboot> or I<--firstboot-command> options with Windows guests.
>
> See also: C<https://github.com/rwmjones/rhsrvany>
>
> +=item F<pvvxsvc.exe>
> +
> +This is a Windows binary shipped with SUSE VMDP, used to install a "firstboot"
> +script in Windows guests. It is required if you intend to use the
> +I<--firstboot> or I<--firstboot-command> options with Windows guests.
> +
> =back
>
> =item C<XDG_CACHE_HOME>
> diff --git a/customize/firstboot.ml b/customize/firstboot.ml
> index 4167098..5825a4a 100644
> --- a/customize/firstboot.ml
> +++ b/customize/firstboot.ml
> @@ -185,19 +185,25 @@ module Windows = struct
> try Sys.getenv "VIRT_TOOLS_DATA_DIR"
> with Not_found -> Guestfs_config.datadir // "virt-tools" in
>
> - (* rhsrvany.exe must exist.
> + (* Either rhsrvany.exe or pvvxsvc.exe must exist.
> *
> * (Check also that it's not a dangling symlink but a real file).
> *)
> - let rhsrvany_exe = virt_tools_data_dir // "rhsrvany.exe" in
> - (try
> - let chan = open_in rhsrvany_exe in
> - close_in chan
> - with
> - Sys_error msg ->
> - error (f_"'%s' is missing. This file is required in order to install Windows firstboot scripts. You can get it by building rhsrvany (https://github.com/rwmjones/rhsrvany). Original error: %s")
> - rhsrvany_exe msg
> - );
> + let services = ["rhsrvany.exe"; "pvvxsvc.exe"] in
> + let srvany =
> + try
> + List.find (
> + fun service ->
> + try
> + let chan = open_in (virt_tools_data_dir // service) in
> + close_in chan;
> + true
> + with _ ->
> + false
> + ) services
> + with Not_found ->
> + error (f_"One of rhsrvany.exe or pvvxsvc.exe is missing in %s. One of them is required in order to install Windows firstboot scripts. You can get one by building rhsrvany (https://github.com/rwmjones/rhsrvany)")
> + virt_tools_data_dir in
>
> (* Create a directory for firstboot files in the guest. *)
> let firstboot_dir, firstboot_dir_win =
> @@ -215,8 +221,8 @@ module Windows = struct
>
> g#mkdir_p (firstboot_dir // "scripts");
>
> - (* Copy rhsrvany to the guest. *)
> - g#upload rhsrvany_exe (firstboot_dir // "rhsrvany.exe");
> + (* Copy pvvxsvc or rhsrvany to the guest. *)
> + g#upload (virt_tools_data_dir // srvany) (firstboot_dir // srvany);
>
> (* Write a firstboot.bat control script which just runs the other
> * scripts in the directory. Note we need to use CRLF line endings
> @@ -252,8 +258,8 @@ for %%%%f in (\"%%scripts%%\"\\*.bat) do (
>
> echo uninstalling firstboot service
> rmdir /S /Q \"%%scripts_done%%\"
> -rhsrvany.exe -s firstboot uninstall
> -" firstboot_dir_win in
> +%s -s firstboot uninstall
> +" firstboot_dir_win srvany in
>
> g#write (firstboot_dir // "firstboot.bat") (unix2dos firstboot_script);
>
> @@ -282,7 +288,7 @@ rhsrvany.exe -s firstboot uninstall
> "Start", REG_DWORD 0x2_l;
> "ErrorControl", REG_DWORD 0x1_l;
> "ImagePath",
> - REG_SZ (firstboot_dir_win ^ "\\rhsrvany.exe -s firstboot");
> + REG_SZ (sprintf "%s\\%s -s firstboot" firstboot_dir_win srvany);
> "DisplayName", REG_SZ "Virt tools firstboot service";
> "ObjectName", REG_SZ "LocalSystem" ];
>
> diff --git a/customize/virt-customize.pod b/customize/virt-customize.pod
> index 8fb9931..7654fee 100644
> --- a/customize/virt-customize.pod
> +++ b/customize/virt-customize.pod
> @@ -250,6 +250,12 @@ I<--firstboot> or I<--firstboot-command> options with Windows guests.
>
> See also: C<https://github.com/rwmjones/rhsrvany>
>
> +=item F<pvvxsvc.exe>
> +
> +This is a Windows binary shipped with SUSE VMDP, used to install a "firstboot"
> +script in Windows guests. It is required if you intend to use the
> +I<--firstboot> or I<--firstboot-command> options with Windows guests.
> +
> =back
>
> =back
> diff --git a/sysprep/virt-sysprep.pod b/sysprep/virt-sysprep.pod
> index 4bbba9a..d86b1e4 100644
> --- a/sysprep/virt-sysprep.pod
> +++ b/sysprep/virt-sysprep.pod
> @@ -550,6 +550,12 @@ I<--firstboot> or I<--firstboot-command> options with Windows guests.
>
> See also: C<https://github.com/rwmjones/rhsrvany>
>
> +=item F<pvvxsvc.exe>
> +
> +This is a Windows binary shipped with SUSE VMDP, used to install a "firstboot"
> +script in Windows guests. It is required if you intend to use the
> +I<--firstboot> or I<--firstboot-command> options with Windows guests.
> +
> =back
>
> =back
> diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
> index f8d05ee..c2a2ed2 100644
> --- a/v2v/virt-v2v.pod
> +++ b/v2v/virt-v2v.pod
> @@ -1847,6 +1847,12 @@ script in the guest during conversion of Windows guests.
>
> See also: C<https://github.com/rwmjones/rhsrvany>
>
> +=item F<pvvxsvc.exe>
> +
> +This is a Windows binary shipped with SUSE VMDP, used to install a "firstboot"
> +script in Windows guests. It is required if you intend to use the
> +I<--firstboot> or I<--firstboot-command> options with Windows guests.
> +
> =item F<rhev-apt.exe>
>
> (Optional)
> --
> 2.6.6
Looks good, ACK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org
More information about the Libguestfs
mailing list