19 Star 143 Fork 61

Gitee 极速下载/qemu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.github/workflows
.gitlab-ci.d
.gitlab/issue_templates
accel
audio
authz
backends
block
bsd-user
chardev
common-user
configs
contrib
crypto
disas
docs
dump
ebpf
fpu
fsdev
gdb-xml
gdbstub
host/include
hw
include
io
libdecnumber
linux-headers
linux-user
migration
monitor
nbd
net
pc-bios
plugins
po
python
qapi
qga
installer
vss-win32
channel-posix.c
channel-win32.c
channel.h
commands-bsd.c
commands-common-ssh.c
commands-common-ssh.h
commands-common.h
commands-linux.c
commands-posix-ssh.c
commands-posix.c
commands-win32.c
commands-windows-ssh.c
commands-windows-ssh.h
commands.c
cutils.c
cutils.h
guest-agent-command-state.c
guest-agent-core.h
main.c
meson.build
messages-win32.mc
qapi-schema.json
service-win32.c
service-win32.h
vss-win32.c
vss-win32.h
qobject
qom
replay
roms
scripts
scsi
semihosting
stats
storage-daemon
stubs
subprojects
system
target
tcg
tests
tools
trace
ui
util
.dir-locals.el
.editorconfig
.exrc
.gdbinit
.git-blame-ignore-revs
.gitattributes
.gitignore
.gitlab-ci.yml
.gitmodules
.gitpublish
.mailmap
.patchew.yml
.readthedocs.yml
.travis.yml
COPYING
COPYING.LIB
Kconfig
Kconfig.host
LICENSE
MAINTAINERS
Makefile
README.rst
VERSION
block.c
blockdev-nbd.c
blockdev.c
blockjob.c
configure
cpu-common.c
cpu-target.c
event-loop-base.c
gitdm.config
hmp-commands-info.hx
hmp-commands.hx
iothread.c
job-qmp.c
job.c
meson.build
meson_options.txt
module-common.c
os-posix.c
os-win32.c
page-target.c
page-vary-common.c
page-vary-target.c
pythondeps.toml
qemu-bridge-helper.c
qemu-edid.c
qemu-img-cmds.hx
qemu-img.c
qemu-io-cmds.c
qemu-io.c
qemu-keymap.c
qemu-nbd.c
qemu-options.hx
qemu.nsi
qemu.sasl
replication.c
trace-events
version.rc
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://git.qemu.org/git/qemu.git
克隆/下载
vss-win32.c 4.54 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* QEMU Guest Agent VSS utility functions
*
* Copyright Hitachi Data Systems Corp. 2013
*
* Authors:
* Tomoki Sekiyama <tomoki.sekiyama@hds.com>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#include "qemu/osdep.h"
#include <windows.h>
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "guest-agent-core.h"
#include "vss-win32.h"
#include "vss-win32/requester.h"
#define QGA_VSS_DLL "qga-vss.dll"
static HMODULE provider_lib;
/* Call a function in qga-vss.dll with the specified name */
static HRESULT call_vss_provider_func(const char *func_name)
{
FARPROC WINAPI func;
g_assert(provider_lib);
func = GetProcAddress(provider_lib, func_name);
if (!func) {
char *msg;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(char *)&msg, 0, NULL);
fprintf(stderr, "failed to load %s from %s: %s",
func_name, QGA_VSS_DLL, msg);
LocalFree(msg);
return E_FAIL;
}
return func();
}
/* Check whether this OS version supports VSS providers */
static bool vss_check_os_version(void)
{
OSVERSIONINFO OSver;
OSver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&OSver);
if ((OSver.dwMajorVersion == 5 && OSver.dwMinorVersion >= 2) ||
OSver.dwMajorVersion > 5) {
BOOL wow64 = false;
#ifndef _WIN64
/* Provider doesn't work under WOW64 (32bit agent on 64bit OS) */
if (!IsWow64Process(GetCurrentProcess(), &wow64)) {
fprintf(stderr, "failed to IsWow64Process (Error: %lx\n)\n",
GetLastError());
return false;
}
if (wow64) {
warn_report("Running under WOW64");
}
#endif
return !wow64;
}
return false;
}
/* Load qga-vss.dll */
bool vss_init(bool init_requester)
{
if (!vss_check_os_version()) {
/* Do nothing if OS doesn't support providers. */
fprintf(stderr, "VSS provider is not supported in this OS version: "
"fsfreeze is disabled.\n");
return false;
}
provider_lib = LoadLibraryA(QGA_VSS_DLL);
if (!provider_lib) {
char *msg;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(char *)&msg, 0, NULL);
fprintf(stderr, "failed to load %s: %sfsfreeze is disabled\n",
QGA_VSS_DLL, msg);
LocalFree(msg);
return false;
}
if (init_requester) {
HRESULT hr = call_vss_provider_func("requester_init");
if (FAILED(hr)) {
fprintf(stderr, "fsfreeze is disabled.\n");
vss_deinit(false);
return false;
}
}
return true;
}
/* Unload qga-provider.dll */
void vss_deinit(bool deinit_requester)
{
if (deinit_requester) {
call_vss_provider_func("requester_deinit");
}
FreeLibrary(provider_lib);
provider_lib = NULL;
}
bool vss_initialized(void)
{
return !!provider_lib;
}
int ga_install_vss_provider(void)
{
HRESULT hr;
if (!vss_init(false)) {
fprintf(stderr, "Installation of VSS provider is skipped. "
"fsfreeze will be disabled.\n");
return 0;
}
hr = call_vss_provider_func("COMRegister");
vss_deinit(false);
return SUCCEEDED(hr) ? 0 : EXIT_FAILURE;
}
void ga_uninstall_vss_provider(void)
{
if (!vss_init(false)) {
fprintf(stderr, "Removal of VSS provider is skipped.\n");
return;
}
call_vss_provider_func("COMUnregister");
vss_deinit(false);
}
/* Call VSS requester and freeze/thaw filesystems and applications */
void qga_vss_fsfreeze(int *nr_volume, bool freeze,
strList *mountpoints, Error **errp)
{
const char *func_name = freeze ? "requester_freeze" : "requester_thaw";
QGAVSSRequesterFunc func;
ErrorSet errset = {
.error_setg_win32_wrapper = error_setg_win32_internal,
.errp = errp,
};
g_assert(errp); /* requester.cpp requires it */
func = (QGAVSSRequesterFunc)GetProcAddress(provider_lib, func_name);
if (!func) {
error_setg_win32(errp, GetLastError(), "failed to load %s from %s",
func_name, QGA_VSS_DLL);
return;
}
func(nr_volume, mountpoints, &errset);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/mirrors/qemu.git
git@gitee.com:mirrors/qemu.git
mirrors
qemu
qemu
master

搜索帮助