Skip to contentSkip to conversation

qga: added another non-interactive gspawn() helper file.

PATCH Applied Denis V. Lunev 4 participants 4 messages Nov 25, 2015 – Nov 27, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qga: added another non-interactive gspawn() helper file.

From: Yuri Pudgorodskiy <[email protected]>

With previous commit we added gspawn-win64-helper-console.exe, required for gspawn() mingw implementation. Unfortunatly when running as a service without interactive desktop, gspawn() also requires another helper app.

Added gspawn-win64-helper.exe and gspawn-win32-helper.exe for corresponding architectures.

---
 qga/installer/qemu-ga.wxs | 7 +++++++
 1 file changed, 7 insertions(+)
qga/installer/qemu-ga.wxs +7 -0
index f25afdd..7c59972 100644
@@ -95,11 +95,17 @@
           <Component Id="gspawn-helper-console" Guid="{446185B3-87BE-43D2-96B8-0FEFD9E8696D}">
             <File Id="gspawn-win32-helper-console.exe" Name="gspawn-win32-helper-console.exe" Source="$(var.Mingw_bin)/gspawn-win32-helper-console.exe" KeyPath="yes" DiskId="1"/>
           </Component>
+          <Component Id="gspawn-helper" Guid="{CD67A5A3-2DB1-4DA1-A67A-8D71E797B466}"> 
+            <File Id="gspawn-win32-helper.exe" Name="gspawn-win32-helper.exe" Source="$(var.Mingw_bin)/gspawn-win32-helper.exe" KeyPath="yes" DiskId="1"/>
+          </Component>
           <?endif?>
           <?if $(var.Arch) = "64"?>
           <Component Id="gspawn-helper-console" Guid="{9E615A9F-349A-4992-A5C2-C10BAD173660}">
             <File Id="gspawn-win64-helper-console.exe" Name="gspawn-win64-helper-console.exe" Source="$(var.Mingw_bin)/gspawn-win64-helper-console.exe" KeyPath="yes" DiskId="1"/>
           </Component>
+          <Component Id="gspawn-helper" Guid="{D201AD22-1846-4E4F-B6E1-C7A908ED2457}">
+            <File Id="gspawn-win64-helper.exe" Name="gspawn-win64-helper.exe" Source="$(var.Mingw_bin)/gspawn-win64-helper.exe" KeyPath="yes" DiskId="1"/>
+          </Component>
           <?endif?>
           <Component Id="iconv" Guid="{35EE3558-D34B-4F0A-B8BD-430FF0775246}">
             <File Id="iconv.dll" Name="iconv.dll" Source="$(var.Mingw_bin)/iconv.dll" KeyPath="yes" DiskId="1"/>
@@ -159,6 +165,7 @@
       <ComponentRef Id="qga_vss_tlb" />
       <?endif?>
       <ComponentRef Id="gspawn-helper-console" />
+      <ComponentRef Id="gspawn-helper" />
       <ComponentRef Id="iconv" />
       <ComponentRef Id="libgcc_arch_lib" />
       <ComponentRef Id="libglib" />
Signature · 1 line
2.1.4
Applied
#1 lore raw

Quoting Denis V. Lunev (2015-11-25 13:02:26)

Quoted 7 lines

From: Yuri Pudgorodskiy <[email protected]>

With previous commit we added gspawn-win64-helper-console.exe, required for gspawn() mingw implementation. Unfortunatly when running as a service without interactive desktop, gspawn() also requires another helper app.

Quoted 6 lines

Added gspawn-win64-helper.exe and gspawn-win32-helper.exe for corresponding architectures.

Thanks, applied to qga tree with minor whitespace fixup:

https://github.com/mdroth/qemu/commits/qga

I noticed something testing this though: if we run qemu-ga from a console, then exec something like ipconfig with
capture-output: true, qemu-ga returns that output via guest-exec-status.

If we run it as a service however, there's no output.

# with qemu-ga started via console
{'execute':'guest-exec','arguments':{'path':'/Windows/System32/ipconfig.exe',
'capture-output':true}}
{"return": {"pid": 1644}}
{'execute':'guest-exec-status','arguments':{'pid':1644}}
{"return": {"exitcode": 0, "out-data":
"DQpXaW5kb3dzIElQIENvbmZpZ3VyYXRpb24NCg0KDQpFdGhlcm5ldCBhZGFwdGVyIExvY2FsIEFyZWEgQ29ubmVjdGlvbiAyOg0KDQogICBDb25uZWN0aW9uLXNwZWNpZmljIEROUyBTdWZmaXggIC4gOiANCiAgIExpbmstbG9jYWwgSVB2NiBBZGRyZXNzIC4gLiAuIC4gLiA6IGZlODA6OjMwMDU6NmRjOjNjNmE6NTQ2NCUxNA0KICAgSVB2NCBBZGRyZXNzLiAuIC4gLiAuIC4gLiAuIC4gLiAuIDogMTkyLjE2OC4xMjIuMTQNCiAgIFN1Ym5ldCBNYXNrIC4gLiAuIC4gLiAuIC4gLiAuIC4gLiA6IDI1NS4yNTUuMjU1LjANCiAgIERlZmF1bHQgR2F0ZXdheSAuIC4gLiAuIC4gLiAuIC4gLiA6IDE5Mi4xNjguMTIyLjENCg0KVHVubmVsIGFkYXB0ZXIgaXNhdGFwLns3Q0Q3OTAwQy05NThCLTRBRUMtQkUwRC0yMTNERjM1NjQ2MEZ9Og0KDQogICBNZWRpYSBTdGF0ZSAuIC4gLiAuIC4gLiAuIC4gLiAuIC4gOiBNZWRpYSBkaXNjb25uZWN0ZWQNCiAgIENvbm5lY3Rpb24tc3BlY2lmaWMgRE5TIFN1ZmZpeCAgLiA6IA0KDQpUdW5uZWwgYWRhcHRlciBMb2NhbCBBcmVhIENvbm5lY3Rpb24qIDExOg0KDQogICBNZWRpYSBTdGF0ZSAuIC4gLiAuIC4gLiAuIC4gLiAuIC4gOiBNZWRpYSBkaXNjb25uZWN0ZWQNCiAgIENvbm5lY3Rpb24tc3BlY2lmaWMgRE5TIFN1ZmZpeCAgLiA6IA0K",
"exited": true}}
# wtih qemu-ga started via windows service
{'execute':'guest-exec','arguments':{'path':'/Windows/System32/ipconfig.exe',
'capture-output':true}}
{"return": {"pid": 1176}}
{'execute':'guest-exec-status','arguments':{'pid':1176}}
{"return": {"exitcode": 0, "exited": true}}

Is this expected?

Quoted 37 lines
---
 qga/installer/qemu-ga.wxs | 7 +++++++
 1 file changed, 7 insertions(+)
qga/installer/qemu-ga.wxs +7 -0
index f25afdd..7c59972 100644
@@ -95,11 +95,17 @@
           <Component Id="gspawn-helper-console" Guid="{446185B3-87BE-43D2-96B8-0FEFD9E8696D}">
             <File Id="gspawn-win32-helper-console.exe" Name="gspawn-win32-helper-console.exe" Source="$(var.Mingw_bin)/gspawn-win32-helper-console.exe" KeyPath="yes" DiskId="1"/>
           </Component>
+          <Component Id="gspawn-helper" Guid="{CD67A5A3-2DB1-4DA1-A67A-8D71E797B466}"> 
+            <File Id="gspawn-win32-helper.exe" Name="gspawn-win32-helper.exe" Source="$(var.Mingw_bin)/gspawn-win32-helper.exe" KeyPath="yes" DiskId="1"/>
+          </Component>
           <?endif?>
           <?if $(var.Arch) = "64"?>
           <Component Id="gspawn-helper-console" Guid="{9E615A9F-349A-4992-A5C2-C10BAD173660}">
             <File Id="gspawn-win64-helper-console.exe" Name="gspawn-win64-helper-console.exe" Source="$(var.Mingw_bin)/gspawn-win64-helper-console.exe" KeyPath="yes" DiskId="1"/>
           </Component>
+          <Component Id="gspawn-helper" Guid="{D201AD22-1846-4E4F-B6E1-C7A908ED2457}">
+            <File Id="gspawn-win64-helper.exe" Name="gspawn-win64-helper.exe" Source="$(var.Mingw_bin)/gspawn-win64-helper.exe" KeyPath="yes" DiskId="1"/>
+          </Component>
           <?endif?>
           <Component Id="iconv" Guid="{35EE3558-D34B-4F0A-B8BD-430FF0775246}">
             <File Id="iconv.dll" Name="iconv.dll" Source="$(var.Mingw_bin)/iconv.dll" KeyPath="yes" DiskId="1"/>
@@ -159,6 +165,7 @@
       <ComponentRef Id="qga_vss_tlb" />
       <?endif?>
       <ComponentRef Id="gspawn-helper-console" />
+      <ComponentRef Id="gspawn-helper" />
       <ComponentRef Id="iconv" />
       <ComponentRef Id="libgcc_arch_lib" />
       <ComponentRef Id="libglib" />
Signature · 1 line
2.1.4
#2 lore raw
Quoted 34 lines · Michael Roth

Quoting Denis V. Lunev (2015-11-25 13:02:26)

Quoted 7 lines

From: Yuri Pudgorodskiy <[email protected]>

With previous commit we added gspawn-win64-helper-console.exe, required for gspawn() mingw implementation. Unfortunatly when running as a service without interactive desktop, gspawn() also requires another helper app.

Quoted 6 lines

Added gspawn-win64-helper.exe and gspawn-win32-helper.exe for corresponding architectures.

Thanks, applied to qga tree with minor whitespace fixup:

https://github.com/mdroth/qemu/commits/qga

I noticed something testing this though: if we run qemu-ga from a console, then exec something like ipconfig with
capture-output: true, qemu-ga returns that output via guest-exec-status.

If we run it as a service however, there's no output.

# with qemu-ga started via console
{'execute':'guest-exec','arguments':{'path':'/Windows/System32/ipconfig.exe',
'capture-output':true}}
{"return": {"pid": 1644}}
{'execute':'guest-exec-status','arguments':{'pid':1644}}
{"return": {"exitcode": 0, "out-data":
"DQpXaW5kb3dzIElQIENvbmZpZ3VyYXRpb24NCg0KDQpFdGhlcm5ldCBhZGFwdGVyIExvY2FsIEFyZWEgQ29ubmVjdGlvbiAyOg0KDQogICBDb25uZWN0aW9uLXNwZWNpZmljIEROUyBTdWZmaXggIC4gOiANCiAgIExpbmstbG9jYWwgSVB2NiBBZGRyZXNzIC4gLiAuIC4gLiA6IGZlODA6OjMwMDU6NmRjOjNjNmE6NTQ2NCUxNA0KICAgSVB2NCBBZGRyZXNzLiAuIC4gLiAuIC4gLiAuIC4gLiAuIDogMTkyLjE2OC4xMjIuMTQNCiAgIFN1Ym5ldCBNYXNrIC4gLiAuIC4gLiAuIC4gLiAuIC4gLiA6IDI1NS4yNTUuMjU1LjANCiAgIERlZmF1bHQgR2F0ZXdheSAuIC4gLiAuIC4gLiAuIC4gLiA6IDE5Mi4xNjguMTIyLjENCg0KVHVubmVsIGFkYXB0ZXIgaXNhdGFwLns3Q0Q3OTAwQy05NThCLTRBRUMtQkUwRC0yMTNERjM1NjQ2MEZ9Og0KDQogICBNZWRpYSBTdGF0ZSAuIC4gLiAuIC4gLiAuIC4gLiAuIC4gOiBNZWRpYSBkaXNjb25uZWN0ZWQNCiAgIENvbm5lY3Rpb24tc3BlY2lmaWMgRE5TIFN1ZmZpeCAgLiA6IA0KDQpUdW5uZWwgYWRhcHRlciBMb2NhbCBBcmVhIENvbm5lY3Rpb24qIDExOg0KDQogICBNZWRpYSBTdGF0ZSAuIC4gLiAuIC4gLiAuIC4gLiAuIC4gOiBNZWRpYSBkaXNjb25uZWN0ZWQNCiAgIENvbm5lY3Rpb24tc3BlY2lmaWMgRE5TIFN1ZmZpeCAgLiA6IA0K",
"exited": true}}
Quoted 9 lines
# wtih qemu-ga started via windows service
{'execute':'guest-exec','arguments':{'path':'/Windows/System32/ipconfig.exe',
'capture-output':true}}
{"return": {"pid": 1176}}
{'execute':'guest-exec-status','arguments':{'pid':1176}}
{"return": {"exitcode": 0, "exited": true}}

Is this expected?

No, we want to fix it somehow - but not now, because the whole picture is not clear yet. Looks like when running gspawn() from a win32 service, some win32 processes open its own console and write stdout to it instead of parent's fd inherited from gspawn-helper.

Not sure whether it can be corrected without patching gspawn() and gspawn-helper code or not. If so, we may consider implementing platform-specific version of guest-exec using win32 api.

Right now the best what can be suggested, it is a workaround: usage of redirection on guest side.

Executing 3 commands in a row do a trick

cmd /c ipconfig >out.txt
cmd /c type out.txt
cmd /c del out.txt

but looks ugly and error-prone.

One more pity notice, it seems that gspawn-helper does incorrect quoting:

cmd /c echo "hello"

produces \"hello\" output instead of expected "hello".
Again, quoting issue may be another point for implementing better win32-specific guest-exec.

I'll share my visions on this problem later after some experiments.

#3 lore raw
Quoted 65 lines · Yuri Pudgorodskiy
Quoted 39 lines · Michael Roth

Quoting Denis V. Lunev (2015-11-25 13:02:26)

Quoted 7 lines

From: Yuri Pudgorodskiy <[email protected]>

With previous commit we added gspawn-win64-helper-console.exe, required for gspawn() mingw implementation. Unfortunatly when running as a service without interactive desktop, gspawn() also requires another helper app.

Quoted 6 lines

Added gspawn-win64-helper.exe and gspawn-win32-helper.exe for corresponding architectures.

Thanks, applied to qga tree with minor whitespace fixup:

https://github.com/mdroth/qemu/commits/qga

I noticed something testing this though: if we run qemu-ga from a console, then exec something like ipconfig with
capture-output: true, qemu-ga returns that output via guest-exec-status.

If we run it as a service however, there's no output.

# with qemu-ga started via console
{'execute':'guest-exec','arguments':{'path':'/Windows/System32/ipconfig.exe', 

'capture-output':true}}
{"return": {"pid": 1644}}
{'execute':'guest-exec-status','arguments':{'pid':1644}}
{"return": {"exitcode": 0, "out-data":
"DQpXaW5kb3dzIElQIENvbmZpZ3VyYXRpb24NCg0KDQpFdGhlcm5ldCBhZGFwdGVyIExvY2FsIEFyZWEgQ29ubmVjdGlvbiAyOg0KDQogICBDb25uZWN0aW9uLXNwZWNpZmljIEROUyBTdWZmaXggIC4gOiANCiAgIExpbmstbG9jYWwgSVB2NiBBZGRyZXNzIC4gLiAuIC4gLiA6IGZlODA6OjMwMDU6NmRjOjNjNmE6NTQ2NCUxNA0KICAgSVB2NCBBZGRyZXNzLiAuIC4gLiAuIC4gLiAuIC4gLiAuIDogMTkyLjE2OC4xMjIuMTQNCiAgIFN1Ym5ldCBNYXNrIC4gLiAuIC4gLiAuIC4gLiAuIC4gLiA6IDI1NS4yNTUuMjU1LjANCiAgIERlZmF1bHQgR2F0ZXdheSAuIC4gLiAuIC4gLiAuIC4gLiA6IDE5Mi4xNjguMTIyLjENCg0KVHVubmVsIGFkYXB0ZXIgaXNhdGFwLns3Q0Q3OTAwQy05NThCLTRBRUMtQkUwRC0yMTNERjM1NjQ2MEZ9Og0KDQogICBNZWRpYSBTdGF0ZSAuIC4gLiAuIC4gLiAuIC4gLiAuIC4gOiBNZWRpYSBkaXNjb25uZWN0ZWQNCiAgIENvbm5lY3Rpb24tc3BlY2lmaWMgRE5TIFN1ZmZpeCAgLiA6IA0KDQpUdW5uZWwgYWRhcHRlciBMb2NhbCBBcmVhIENvbm5lY3Rpb24qIDExOg0KDQogICBNZWRpYSBTdGF0ZSAuIC4gLiAuIC4gLiAuIC4gLiAuIC4gOiBNZWRpYSBkaXNjb25uZWN0ZWQNCiAgIENvbm5lY3Rpb24tc3BlY2lmaWMgRE5TIFN1ZmZpeCAgLiA6IA0K",

"exited": true}}

# wtih qemu-ga started via windows service
{'execute':'guest-exec','arguments':{'path':'/Windows/System32/ipconfig.exe', 
Quoted 7 lines

'capture-output':true}}
{"return": {"pid": 1176}} {'execute':'guest-exec-status','arguments':{'pid':1176}} {"return": {"exitcode": 0, "exited": true}}

Is this expected?

No, we want to fix it somehow - but not now, because the whole picture is not clear yet. Looks like when running gspawn() from a win32 service, some win32 processes open its own console and write stdout to it instead of parent's fd inherited from gspawn-helper.

Not sure whether it can be corrected without patching gspawn() and gspawn-helper code or not. If so, we may consider implementing platform-specific version of guest-exec using win32 api.

Right now the best what can be suggested, it is a workaround: usage of redirection on guest side.

Executing 3 commands in a row do a trick

cmd /c ipconfig >out.txt
cmd /c type out.txt
cmd /c del out.txt

but looks ugly and error-prone.

Quoted 10 lines

One more pity notice, it seems that gspawn-helper does incorrect quoting:

cmd /c echo "hello"

produces \"hello\" output instead of expected "hello".
Again, quoting issue may be another point for implementing better win32-specific guest-exec.

I'll share my visions on this problem later after some experiments.

no

for me this smells like GLIB bug which should
be addressed separately.

Den