Skip to contentSkip to conversation

qemu-ga: Prevent QEMU-GA VSS provider from being unregistered on reinstall

PATCH Superseded Leonid Bloch 2 participants 11 messages Aug 3, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 qemu-ga: Prevent QEMU-GA VSS provider from being unregistered on reinstall

Contrary to the first version of this patch, this time the MajorUpgrade element is used both to handle the detection of previously installed versions for upgrade, and to prevent downgrading without manual un-installation of the older version.

The property REINSTALLMODE had to be set to "amus", which contrary to the default "omus" makes all the files to be reinstalled during upgrade, regardless of their version. This is because the RemoveExistingProducts element is now placed automatically, after InstallValidate, and thus can not be placed in the very beginning of the installation sequence, as was the case in the previous version of this patch.

Leonid Bloch (1):
qemu-ga: Prevent QEMU-GA VSS provider from being unregistered on
reinstall

 qga/installer/qemu-ga.wxs | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
Signature · 1 line
2.4.3
#1 lore raw

PATCH v2 1/1 qemu-ga: Prevent QEMU-GA VSS provider from being unregistered on reinstall

Previously, running the .msi would unregister the QEMU GA VSS service if QEMU GA was already installed on the machine, and then register it only if QEMU GA was NOT previously installed. This behavior caused the service to be registered only after the INITIAL installation, and any subsequent run of the .msi (to redo, repair, or upgrade the installation) ended in the service being unregistered.

Now, the VSS service is still unregistered if QEMU GA is already installed (so that a fix or an update could be performed) but then it is registered again (if the GA is not being uninstalled) thus finishing the repair/upgrade correctly. Additionally, downgrading is now prevented. If a user would like to downgrade a version, he/she must uninstall the newer version first.

---
 qga/installer/qemu-ga.wxs | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
qga/installer/qemu-ga.wxs +5 -9
index 2c43f1b..968cc26 100644
@@ -58,13 +58,9 @@
       />
     <Media Id="1" Cabinet="qemu_ga.$(env.QEMU_GA_VERSION).cab" EmbedCab="yes" />
     <Property Id="WHSLogo">1</Property>
-    <Property Id="PREVIOUSVERSIONSINSTALLED" />
-    <Upgrade Id="{EB6B8302-C06E-4bec-ADAC-932C68A3A98D}">
-      <UpgradeVersion
-        Minimum="1.0.0.0" Maximum="$(env.QEMU_GA_VERSION)"
-        Property="PREVIOUSVERSIONSINSTALLED"
-        IncludeMinimum="yes" IncludeMaximum="no" />
-    </Upgrade>
+    <MajorUpgrade
+      DowngradeErrorMessage="Error: A newer version of QEMU guest agent is already installed."
+      />
 
     <Directory Id="TARGETDIR" Name="SourceDir">
       <Directory Id="$(var.GaProgramFilesFolder)" Name="QEMU Guest Agent">
@@ -110,6 +106,7 @@
     </Directory>
 
     <Property Id="cmd" Value="cmd.exe"/>
+    <Property Id="REINSTALLMODE" Value="amus"/>
 
     <?ifdef var.InstallVss ?>
     <CustomAction Id="RegisterCom"
@@ -135,10 +132,9 @@
     </Feature>
 
     <InstallExecuteSequence>
-      <RemoveExistingProducts Before="InstallInitialize" />
       <?ifdef var.InstallVss ?>
-      <Custom Action="RegisterCom" After="InstallServices">NOT Installed</Custom>
       <Custom Action="UnRegisterCom" After="StopServices">Installed</Custom>
+      <Custom Action="RegisterCom" After="InstallServices">NOT REMOVE</Custom>
       <?endif?>
     </InstallExecuteSequence>
   </Product>
Signature · 1 line
2.4.3
#2 lore raw
In reply to Leonid Bloch

Hi Leonid

Quoted 1 line · Leonid Bloch

The property REINSTALLMODE had to be set to "amus", which contrary to the default "omus" makes all the files to be reinstalled during upgrade, regardless of their version. This is because the RemoveExistingProducts element is now placed automatically, after InstallValidate, and thus can not be placed in the very beginning of the installation sequence, as was the case in the previous version of this patch.

Sorry I don't understand the REINSTALLMODE change. Could you clarify what's the issue hit during install/update if you remove it? Furthermore, that comment should be in the commit message, not in the cover letter (a single patch can do without cover letter imho)

thanks

Signature · 1 line
Marc-André Lureau
#3 lore raw

Hi Marc-André,

When REINSTALLMODE is at its default value, during an update the files that didn't change from the previous version are not copied to the install location. But the RemoveExistingProducts element deletes them from there, and so some files are missing, until the .msi is re-run, to "repair" the installation.

In the previous version of this patch this was not needed, as RemoveExistingProducts was placed right at the beginning of the install sequence, and after it finished, it "looked like" no installation was there, so all the files were treated as new, and thus copied (same behavior). But using MajorUpgrade sets RemoveExistingProducts after InstallValidate, and so I needed to change the value of REINSTALLMODE, to force all the files to be copied anyway.

The cover letter was to explain the differences of this patch from the previous version of it (imho, the commit message should not refer to older versions of the patch that will never be pulled). That's why the REINSTALLMODE was mentioned only in the cover letter, and not in the commit message - it is just a different means to achieve the same result as in the previous patch. Of course, if you consider it to be more fitting, I can reword the commit message to go into these details.

Thanks!
Leonid.

Quoted 21 lines · Marc-André Lureau

Hi Leonid

Quoted 1 line · Leonid Bloch

The property REINSTALLMODE had to be set to "amus", which contrary to

the default "omus" makes all the files to be reinstalled during upgrade, regardless of their version. This is because the RemoveExistingProducts element is now placed automatically, after InstallValidate, and thus can not be placed in the very beginning of the installation sequence, as was the case in the previous version of this patch.

Sorry I don't understand the REINSTALLMODE change. Could you clarify what's the issue hit during install/update if you remove it? Furthermore, that comment should be in the commit message, not in the cover letter (a single patch can do without cover letter imho)

thanks

--
Marc-André Lureau

#4 lore raw

Hi

Quoted 7 lines · Leonid Bloch

Hi Marc-André,

When REINSTALLMODE is at its default value, during an update the files that didn't change from the previous version are not copied to the install location. But the RemoveExistingProducts element deletes them from there, and so some files are missing, until the .msi is re-run, to "repair" the installation.

yes, but if you remove that RemoveExistingProducts too, then what fails?

Quoted 8 lines

In the previous version of this patch this was not needed, as RemoveExistingProducts was placed right at the beginning of the install sequence, and after it finished, it "looked like" no installation was there, so all the files were treated as new, and thus copied (same behavior). But using MajorUpgrade sets RemoveExistingProducts after InstallValidate, and so I needed to change the value of REINSTALLMODE, to force all the files to be copied anyway.

Quoted 7 lines

The cover letter was to explain the differences of this patch from the previous version of it (imho, the commit message should not refer to older versions of the patch that will never be pulled). That's why the REINSTALLMODE was mentioned only in the cover letter, and not in the commit message - it is just a different means to achieve the same result as in the previous patch. Of course, if you consider it to be more fitting, I can reword the commit message to go into these details.

Yes, I would document the REINSTALLMODE change (if it's necessary in the end).

Signature · 1 line
Marc-André Lureau
#5 lore raw
Quoted 5 lines · Marc-André Lureau

Hi

Quoted 2 lines · Leonid Bloch

Hi Marc-André,

Quoted 7 lines
Quoted 5 lines

When REINSTALLMODE is at its default value, during an update the files that didn't change from the previous version are not copied to the install location. But the RemoveExistingProducts element deletes them from there, and so some files are missing, until the .msi is re-run, to "repair" the installation.

yes, but if you remove that RemoveExistingProducts too, then what fails?

Only the manual call for RemoveExistingProducts is removed. MajorUpgrade places it automatically in the InstallExecuteSequence table.

Quoted 17 lines
Quoted 9 lines

In the previous version of this patch this was not needed, as RemoveExistingProducts was placed right at the beginning of the install sequence, and after it finished, it "looked like" no installation was there, so all the files were treated as new, and thus copied (same behavior). But using MajorUpgrade sets RemoveExistingProducts after InstallValidate, and so I needed to change the value of REINSTALLMODE, to force all the files to be copied anyway.

Quoted 7 lines

The cover letter was to explain the differences of this patch from the previous version of it (imho, the commit message should not refer to older versions of the patch that will never be pulled). That's why the REINSTALLMODE was mentioned only in the cover letter, and not in the commit message - it is just a different means to achieve the same result as in the previous patch. Of course, if you consider it to be more fitting, I can reword the commit message to go into these details.

Quoted 1 line

Yes, I would document the REINSTALLMODE change (if it's necessary in the end).

OK. Will do.

Quoted 3 lines

--
Marc-André Lureau

#6 lore raw

Hi

Quoted 5 lines · Leonid Bloch
Quoted 2 lines

yes, but if you remove that RemoveExistingProducts too, then what fails?

Only the manual call for RemoveExistingProducts is removed. MajorUpgrade places it automatically in the InstallExecuteSequence table.

I think the root of the problem is that the wxs doesn't follow the "component rules": "qemu_ga" shouldn't contain various libs and executable. Instead, each file should have its own component. Then I think RemoveExistingProducts would actually remove only the components that are to be upgraded. And that REINSTALLMODE trick wouldn't be necessary. I would fix to follow the principles recommended here:
https://msdn.microsoft.com/en-us/library/aa368269%28VS.85%29.aspx.

Signature · 1 line
Marc-André Lureau
#7 lore raw

Hi,

Quoted 10 lines · Marc-André Lureau

Hi

Quoted 5 lines · Leonid Bloch
Quoted 2 lines

yes, but if you remove that RemoveExistingProducts too, then what fails?

Only the manual call for RemoveExistingProducts is removed. MajorUpgrade places it automatically in the InstallExecuteSequence table.

Quoted 7 lines

I think the root of the problem is that the wxs doesn't follow the "component rules": "qemu_ga" shouldn't contain various libs and executable. Instead, each file should have its own component. Then I think RemoveExistingProducts would actually remove only the components that are to be upgraded. And that REINSTALLMODE trick wouldn't be necessary. I would fix to follow the principles recommended here:
https://msdn.microsoft.com/en-us/library/aa368269%28VS.85%29.aspx.

You are right, however here, the goal is just to install one single file - qemu_ga.exe, and 6--8 libs to support it. All into a single directory. No complicated scenarios or databases to retain. In such a case, don't you think that it will actually be safer and more robust to just reinstall everything upon upgrade? It's not a problem to wrap each file in its own "Component", but it will add unnecessary clutter to a code that does something extremely simple, imho.

Quoted 3 lines

--
Marc-André Lureau

Leonid.

#8 lore raw

Hi

Quoted 7 lines · Leonid Bloch
Quoted 7 lines

I think the root of the problem is that the wxs doesn't follow the "component rules": "qemu_ga" shouldn't contain various libs and executable. Instead, each file should have its own component. Then I think RemoveExistingProducts would actually remove only the components that are to be upgraded. And that REINSTALLMODE trick wouldn't be necessary. I would fix to follow the principles recommended here:
https://msdn.microsoft.com/en-us/library/aa368269%28VS.85%29.aspx.

Quoted 7 lines

You are right, however here, the goal is just to install one single file - qemu_ga.exe, and 6--8 libs to support it. All into a single directory. No complicated scenarios or databases to retain. In such a case, don't you think that it will actually be safer and more robust to just reinstall everything upon upgrade? It's not a problem to wrap each file in its own "Component", but it will add unnecessary clutter to a code that does something extremely simple, imho.

I am a little bit scared by the other kind of problem Windows Installer might have when you don't follow the component rules, crippling the wxs with tricks/workaround like this one. I think it will make maintainance and upgrade easier to follow recommendations.

Signature · 1 line
Marc-André Lureau
#9 lore raw

Hi,

Quoted 15 lines · Marc-André Lureau
Quoted 7 lines
Quoted 7 lines

I think the root of the problem is that the wxs doesn't follow the "component rules": "qemu_ga" shouldn't contain various libs and executable. Instead, each file should have its own component. Then I think RemoveExistingProducts would actually remove only the components that are to be upgraded. And that REINSTALLMODE trick wouldn't be necessary. I would fix to follow the principles recommended here:
https://msdn.microsoft.com/en-us/library/aa368269%28VS.85%29.aspx.

Quoted 7 lines

You are right, however here, the goal is just to install one single file - qemu_ga.exe, and 6--8 libs to support it. All into a single directory. No complicated scenarios or databases to retain. In such a case, don't you think that it will actually be safer and more robust to just reinstall everything upon upgrade? It's not a problem to wrap each file in its own "Component", but it will add unnecessary clutter to a code that does something extremely simple, imho.

Quoted 4 lines

I am a little bit scared by the other kind of problem Windows Installer might have when you don't follow the component rules, crippling the wxs with tricks/workaround like this one. I think it will make maintainance and upgrade easier to follow recommendations.

I understand your concerns. I have made a separate Component for each file, but REINSTALLMODE still needs to be set to "amus" for the files to be copied correctly. This is because all the files are removed during RemoveExistingProducts, but unless REINSTALLMODE is set to "amus", the files that were identical before the upgrade are not copied. Now this is not a trick or a workaround, and the updated WXS also follows recommendations regarding components and GUID formatting (changed that also, since your concerns regarding Windows Installer are justified). Sending the patches shortly.

Quoted 2 lines

--
Marc-André Lureau

Thanks for your remarks!
Leonid.

#10 lore raw

Hi

Quoted 5 lines · Leonid Bloch

I understand your concerns. I have made a separate Component for each file, but REINSTALLMODE still needs to be set to "amus" for the files to be copied correctly. This is because all the files are removed during RemoveExistingProducts, but unless REINSTALLMODE is set to "amus", the files that were identical before the upgrade are not

Well, for the upgrade from a wxs not following component rule to one which follows it will probably need such trick. But later on, it could/should be removed.

Quoted 4 lines

copied. Now this is not a trick or a workaround, and the updated WXS also follows recommendations regarding components and GUID formatting (changed that also, since your concerns regarding Windows Installer are justified). Sending the patches shortly.

thanks

Signature · 1 line
Marc-André Lureau