From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K8m7a-0003Ah-LE for qemu-devel@nongnu.org; Tue, 17 Jun 2008 21:05:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K8m7X-00037M-S4 for qemu-devel@nongnu.org; Tue, 17 Jun 2008 21:05:58 -0400 Received: from [199.232.76.173] (port=47688 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K8m7X-000376-Mh for qemu-devel@nongnu.org; Tue, 17 Jun 2008 21:05:55 -0400 Received: from main.gmane.org ([80.91.229.2]:39288 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K8m7X-0000gx-DU for qemu-devel@nongnu.org; Tue, 17 Jun 2008 21:05:55 -0400 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1K8m7R-0006DD-IN for qemu-devel@nongnu.org; Wed, 18 Jun 2008 01:05:49 +0000 Received: from 204.147.152.1 ([204.147.152.1]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 18 Jun 2008 01:05:49 +0000 Received: from void by 204.147.152.1 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 18 Jun 2008 01:05:49 +0000 From: "consul" Date: Tue, 17 Jun 2008 18:05:35 -0700 Message-ID: Sender: news Subject: [Qemu-devel] Preliminary qemu-ifup support for windows Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Is anybody interested in supporting qemu-ifup/down scripts on Windows hosts? Here is a quick and dirty hack allowing to run vbscripts on qemu startup and shutdown. For start I have scripts that enable/disable the TAP0 device when qemu starts and exits, removing the notification icon from the taskbar when qemu is not running. I know, this can be done other ways, but it still nice to have the icons available, when needed, and scripts can do more than that. I still have not yet figured out how to turn the notification icon off when the qemu is connected and running, except manually refreshing the network connections window, any idea? Here is my hack: $ svn diff Index: vl.c =================================================================== --- vl.c (revision 4744) +++ vl.c (working copy) @@ -8680,6 +8680,8 @@ } } } +#else + run_script("cscript qemu-ifdown.vbs"); #endif return 0; } Index: tap-win32.c =================================================================== --- tap-win32.c (revision 4744) +++ tap-win32.c (working copy) @@ -659,11 +659,23 @@ tap_win32_free_buffer(s->handle, buf); } } +void run_script(char *script){ + STARTUPINFO sinfo; + PROCESS_INFORMATION pinfo; + memset(&sinfo,0,sizeof(sinfo)); + sinfo.cb = sizeof(sinfo); + sinfo.wShowWindow = SW_HIDE; + sinfo.dwFlags = STARTF_USESHOWWINDOW; + CreateProcess(0,script,0,0,0,0,0,0,&sinfo,&pinfo); + WaitForSingleObject(pinfo.hProcess,INFINITE); + CloseHandle(pinfo.hThread); + CloseHandle(pinfo.hProcess); +} int tap_win32_init(VLANState *vlan, const char *ifname) { TAPState *s; - + run_script("cscript qemu-ifup.vbs"); s = qemu_mallocz(sizeof(TAPState)); if (!s) return -1; Index: sysemu.h =================================================================== --- sysemu.h (revision 4744) +++ sysemu.h (working copy) @@ -69,6 +69,7 @@ /* TAP win32 */ int tap_win32_init(VLANState *vlan, const char *ifname); +void run_script(char *script); /* SLIRP */ void do_info_slirp(void); -------------- And here is a sample qemu_ifup.vbs script (substitute "Disa&ble" for "En&able" for ifdown) set sh = createobject("wscript.shell") Dim obj 'As Shell Dim f 'As Folder Dim itm 'As ShellFolderItem Dim ix 'As ShellFolderItem Dim net 'As Folder Dim v 'As FolderItemVerb Set obj = CreateObject("shell.application") Set f = obj.Namespace(3) For Each itm In f.Items If itm.Name = "Network Connections" Then Set net = itm.GetFolder For Each ix In net.Items If ix.Name = "TAP0" Then For Each v In ix.Verbs If v.Name = "En&able" Then v.DoIt End If Next Exit For End If Next Exit For End If Next WScript.Sleep 1000