diff mbox

[v4,09/10] qemu-ga: install Windows VSS provider on `qemu-ga -s install'

Message ID 20130606150657.10486.19314.stgit@hds.com
State New
Headers show

Commit Message

Tomoki Sekiyama June 6, 2013, 3:06 p.m. UTC
Register QGA VSS provider library into Windows when qemu-ga is installed as
Windows service ('-s install' option). It is deregistered when the service
is uninstalled ('-s uninstall' option).

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
---
 qga/main.c |    8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Laszlo Ersek July 1, 2013, 2:50 p.m. UTC | #1
On 06/06/13 17:06, Tomoki Sekiyama wrote:
> Register QGA VSS provider library into Windows when qemu-ga is installed as
> Windows service ('-s install' option). It is deregistered when the service
> is uninstalled ('-s uninstall' option).
> 
> Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
> ---
>  qga/main.c |    8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/qga/main.c b/qga/main.c
> index 8bcedaf..739b958 100644
> --- a/qga/main.c
> +++ b/qga/main.c
> @@ -1058,8 +1058,16 @@ int main(int argc, char **argv)
>                  fixed_state_dir = (state_dir == dfl_pathnames.state_dir) ?
>                                    NULL :
>                                    state_dir;
> +#ifdef HAS_VSS_SDK
> +                if (FAILED(COMRegister())) {
> +                    return EXIT_FAILURE;
> +                }

COMRegister() seems to print error messages on failure, OK.

> +#endif
>                  return ga_install_service(path, log_filepath, fixed_state_dir);

Shouldn't you call COMUnregister() if ga_install_service() fails?
Otherwise we might end up with a half-installed service (COM app catalog
entry for VSS provider: yes, VSS provider DLL: yes, VSS client / qemu-ga
service: no).

>              } else if (strcmp(service, "uninstall") == 0) {
> +#ifdef HAS_VSS_SDK
> +                COMUnregister();
> +#endif
>                  return ga_uninstall_service();
>              } else {
>                  printf("Unknown service command.\n");
> 
> 

This seems OK; there isn't much to do (non-interactively) when a
destructor fails.

Thanks,
Laszlo
Tomoki Sekiyama July 1, 2013, 5:59 p.m. UTC | #2
On 7/1/13 10:50 , "Laszlo Ersek" <lersek@redhat.com> wrote:

>On 06/06/13 17:06, Tomoki Sekiyama wrote:
>>+#ifdef HAS_VSS_SDK
>> +                if (FAILED(COMRegister())) {
>> +                    return EXIT_FAILURE;
>> +                }
>
>COMRegister() seems to print error messages on failure, OK.
>
>> +#endif
>>                  return ga_install_service(path, log_filepath,
>>fixed_state_dir);
>
>Shouldn't you call COMUnregister() if ga_install_service() fails?
>Otherwise we might end up with a half-installed service (COM app catalog
>entry for VSS provider: yes, VSS provider DLL: yes, VSS client / qemu-ga
>service: no).

Agreed. I will fix this.

Thanks,
Tomoki Sekiyama
diff mbox

Patch

diff --git a/qga/main.c b/qga/main.c
index 8bcedaf..739b958 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -1058,8 +1058,16 @@  int main(int argc, char **argv)
                 fixed_state_dir = (state_dir == dfl_pathnames.state_dir) ?
                                   NULL :
                                   state_dir;
+#ifdef HAS_VSS_SDK
+                if (FAILED(COMRegister())) {
+                    return EXIT_FAILURE;
+                }
+#endif
                 return ga_install_service(path, log_filepath, fixed_state_dir);
             } else if (strcmp(service, "uninstall") == 0) {
+#ifdef HAS_VSS_SDK
+                COMUnregister();
+#endif
                 return ga_uninstall_service();
             } else {
                 printf("Unknown service command.\n");