I'm trying to learn Qemu-KVM in order to extend them for a monitoring application. I can see that the general control flow in qemu/kvm-all.c is:
kvm_init() :
kvm_ioctl(s, KVM_CREATE_VM, 0);
kvm_init_vcpu() : kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index);
kvm_cpu_exec() :
do {
kvm_vcpu_ioctl(env, KVM_RUN, 0);
switch (run->exit_reason) { // giving control to Qemu
case KVM_EXIT_IO:
case KVM_EXIT_MMIO:
... // omitted
} while();
What I can't see yet is when (what KVM functions in the source code) return to (or call) Qemu (user space) to handle KVM exit ?
In fact, what I found is that Qemu simply waits (blocked) for kvm_vcpu_ioctl(env, KVM_RUN, 0) to return.
So this is when KVM returns back the control to Qemu.
Related
I have C+ program that compiles to web assebmbly using the emscripten system. I would like to clean up some things, flush files, etc etc. when he page running the program is closed.
in main there is:
emscripten_set_main_loop_arg(onMainLoopTick, arg, 0, 1);
Currently when the page closes the "process" is simply exited and does not continue after the "loop simulator". I figure I need to get an event from the page that will block the main thread until the C++ code process it and cleans up it's mess.
What event should I forward to C++ and how should I use it ?
The first things to know is that there is no native library nor APIs for WebAssembly (I mean..yet, as of MVP. There are native features like threads coming as post-MVP feature). What is means that all system libraries in C++ are implemented by importing emulated JavaScript functions. So if you are looking for native features like detecting closing events, you should check if there is JS/HTML5 APIs that do the similar things.
To see how it works, open generated .wast file and search for import instructions and generated JS files. Also, you may want to search on Emscripten repo directly to check if there is JS/HTML5 bindings available on C++ side, as their documentation is quite large and hard to look through.
Sticking to the point, the HTML5 events that are fired when closing are beforeunload and unload. I would prefer using beforeunload event. Emscripten provides em_beforeunload_callback callback function type and emscripten_set_beforeunload_callback to register in html5.h bindings.
Otherwise, you use them directly. For example:
In C++:
void EMSCRIPTEN_KEEPALIVE clean_stuff() {
// Clean up the mess...
// You should use EMSCRIPTEN_KEEPALIVE or
// add it to EXPORTED_FUNCTIONS in emcc compilation options
// to make it callable in JS side.
}
In JS:
window.addEventListener("beforeunload", function (event) {
// Exported functions are prefixed by an underscore
Module._clean_stuff();
});
I am calling an external utility (advzip) from a code to run asynchronous recompression on written data. I use boost::process::spawn to do that:
// std::string f;
auto p=boost::process::search_path("advzip");
if(p.empty()) return;
boost::process::spawn(p,"-q","-z","-2",f);
These subprocesses, however, stay around in zombie state - after they've completed their work - which is not supposed to happen as per boost::process::spawn documentation. Am I doing something wrong?
I am using boost 1.65, running under Ubuntu 18.04.
Is it possible at all, or traces are part of the API which is not avalible from background Worker?
Consider this code:
public class Main extends Sprite {
public function Main(container : DisplayObjectContainer = null)
{
if(Worker.current.isPrimordial) {
trace("isPrimordial");
var m_worker : Worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes);
m_worker.start();
}
else {
trace("is NOT Primordial");
}
}
The string "is NOT Primordial" does not appear, however I do see that m_worker.state is "WorkerState.RUNNING".
Some UPDATE: The main thread works and racts to events, however it appears like the backgroung worker does not start until I desconnect the debugger.
And if it is possible, how do I setup the fdb to show these logs?
PS. Im using flash standalone debug player 13 with latest FDT and Apache Flex 4.12.1 SDK.
Ok, so the results for now are:
The background thread (Worker) can write traces with no problems at all if the debugger is not attached, for example if we are using flashlog.txt for the output (output to file).
What is required is: flash debug player (me used v. 14 stand alone and firefox versions).
The setup for using text file as output discussed here:
http://helpx.adobe.com/flash-player/kb/configure-debugger-version-flash-player.html
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7fc9.html
Correct location of mm.cfg on modern operating systems (and not on Win95!) discussed here:
https://forums.adobe.com/thread/1218258
For me the output to file started to work only after the flashlog.txt file was created by some 3rd party tool (I used Vizzy), but probably it is a permission problem of flasho n windows 8 and the file just can be created manually.
Detailed discussion of the flash traces topic (althoug a little old, but mostly still relevant) is here:
See trace() of Flash when running in browser
Thanks everyone for help.
Create a static Log class that output it's log to trace. Use this log class in your main thread and in your worker. Only the main thread log definition will be used allowing to trace from anywhere.
I am using Free Pascal (Lazarus) to develop a simple server daemon. The problem I am facing is that the TEventLog component does not write to the systemlog.
I use the following code:
EventLog1.LogType := ltSystem;
EventLog1.Active := True;
EventLog1.Log('Application has started!');
Instead of writing to systemlog it creates a file with the name as the executable and writes there.
Is there any other way I can write to the system log ? Is openlog defined in any unit I can use ?
(Assuming you use a *nix and the most recent 2.6.2 version).
No, libc log* functions seem only declared in the implementation of eventlog. Maybe they are in unit libc, but that is mostly unsupported, and linux/32bit only.
Check some assumptions:
Is active false before you set logtype, otherwise the active:=true might not recheck it.
you want to write system log, do you have enough privileges for that?
Do you see anything with strace/ktrace/truss ?
I have a full screen AS3 game maby with Adobe AIR that runs in Windows 7.
In this game it may not be easy to exit (think about kiosk mode, only exit by pressing esc and enter a password).
Now I want this game to run in Windows 8. The game is working like expected but the anoying things are these edge gestures/hot corners (left, top, right, bottom) and the shortcuts.
I've read articles but none helped me. People talk about registery edits, but I dont get this working + the user needs to restart his/hers computer.
I want to open my game, turn off gestures/hot corners and when the game closes the gestures/hot corners need to come back available again.
I have seen some applications doing the same what I want to accomplish.
I found this so I am able to detect the gestures. But how to ignore they're actions?
I also read ASUS Smart Gestures but this is for the touch-pad.
And I have tried Classic Shell but I need to disable the edge gestures/hot corners without such programs, just on-the-fly.
I also found this but I don't know how to implement this.
HRESULT SetTouchDisableProperty(HWND hwnd, BOOL fDisableTouch)
{
IPropertyStore* pPropStore;
HRESULT hrReturnValue = SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&pPropStore));
if (SUCCEEDED(hrReturnValue))
{
PROPVARIANT var;
var.vt = VT_BOOL;
var.boolVal = fDisableTouch ? VARIANT_TRUE : VARIANT_FALSE;
hrReturnValue = pPropStore->SetValue(PKEY_EdgeGesture_DisableTouchWhenFullscreen, var);
pPropStore->Release();
}
return hrReturnValue;
}
Does anyone know how I can do this? Or point me into the right direction?
I have tried some in C# and C++, but I aint a skilled C#/C++ developer. Also the game is made in AS3 so it will be hard to implement this in C#/C++.
I work on the Lenovo aio (All in one) with Windows 8.
I am making a kiosk application for windows 8 using C#,
I succesfully disabled the swipe gestures by killing the explorer process
when the program starts up. I don't know how it's done in C++
but in C# it's like this.
var explorers = Process.GetProcessesByName("explorer");
foreach (var explorer in explorers) {
explorer.Kill();
}
On the closing event of my program I just start the process again.
Process.Start("explorer.exe");
Before this works you might have to edit your register to prevent explorer
from restarting after you kill it.
In regedit go to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
Set the AutoRestartShell to 0.
(as long as your running off AIR - which it sounds like) You can use AIR 2.0's NativeProcess to execute it.
From there I can think of two solutions:
If there are command line options in Classic Shell, call it from within your AS3 and toggle the gestures on/off through it.
Write a C++ application that toggles the gestures on/off manually.
If you can get that example working in C++, add a bit to the C++ to handle a on/off command line argument and call the C++ exe on initialization and exit of your AS3 application to toggle.
I don't have C++ installed here (at work), but it looks like that C++ function just requires the window handle of your application (hWnd). This tutorial should get you compiled and running, but the window handle you see there will be for the C++ application's window.
Accessing the flash window's handle will be slightly more difficult:
for a direct solution; you'll need to use .NET - Process.MainWindowHandle,
or alternatively without .NET -
How to get main window handle from process id?
Either way you'll need to use the Process name or ID to identify it as your AS3 process.
This solution also depends on your ability to install things other than the AIR app on the client PC. (ie .NET runtimes, C++ runtimes, Classic Shell installer)
I'm trying to do the same thing. The C++ below disables Win8 Gestures on every running application/window. As JonoRR mentioned, the next step would be calling it only on the HWND you would like to target. If the targeted application is closed, then re-opened, the gestures will return.
#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <propsys.h>
#include <propkey.h>
using namespace std;
HWND windowHandle;
HRESULT SetTouchDisableProperty(HWND hwnd, BOOL fDisableTouch)
{
IPropertyStore* pPropStore;
HRESULT hrReturnValue = SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&pPropStore));
if (SUCCEEDED(hrReturnValue))
{
PROPVARIANT var;
var.vt = VT_BOOL;
var.boolVal = fDisableTouch ? VARIANT_TRUE : VARIANT_FALSE;
hrReturnValue = pPropStore->SetValue(PKEY_EdgeGesture_DisableTouchWhenFullscreen, var);
pPropStore->Release();
}
return hrReturnValue;
}
BOOL CALLBACK MyEnumProc(HWND hWnd, LPARAM lParam)
{
TCHAR title[500];
ZeroMemory(title, sizeof(title));
GetWindowText(hWnd, title, sizeof(title)/sizeof(title[0]));
SetTouchDisableProperty(hWnd,true);
_tprintf(_T("Value is %s\n"), title);
return TRUE;
}
int _tmain(int argc, _TCHAR* argv[])
{
EnumWindows(MyEnumProc, 0);
return 0;
}
The answer below is based on Dovogja's brilliant answer, but it uses a batch file to do it. This way you just have to launch with a launch.bat
Windows charms bar is operated by explorer.exe. So if your app can run without it then you can hack around it by first disabling the autorestart of explorer.exe via (run as administrator):
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AutoRestartShell" /t REG_DWORD /d 0
Then the lines below represent my launch.bat - which works in the end as expected:
;; kill explorer (this disables all windows functionalities
taskkill /f /im explorer.exe
;; start your kiosk app - should block the batch execution (so explorer.exe doesn't get executed at the end)
"\path\to\your\app.exe"
;; after you close both the app window and the opened chrome window relaunch explorer.exe to give back the functionality to windows
explorer.exe
I use the approach outlined above to let a keyboardless kiosk app run. Because with a keyboard you can still close the app with alt+f4.