From: "consul" <void@aleksoft.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Preliminary qemu-ifup support for windows
Date: Tue, 17 Jun 2008 18:05:35 -0700 [thread overview]
Message-ID: <g39n11$a35$1@ger.gmane.org> (raw)
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
reply other threads:[~2008-06-18 1:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='g39n11$a35$1@ger.gmane.org' \
--to=void@aleksoft.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).