Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
9ccdbb5d
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9ccdbb5d
编写于
5月 06, 2009
作者:
D
Daniel Veillard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* src/vbox/vbox_XPCOMCGlue.[ch]: improve VirtualBox path detection
patch by Pritesh Kothari Daniel
上级
840955ff
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
15 deletion
+61
-15
ChangeLog
ChangeLog
+5
-0
src/vbox/vbox_XPCOMCGlue.c
src/vbox/vbox_XPCOMCGlue.c
+54
-14
src/vbox/vbox_XPCOMCGlue.h
src/vbox/vbox_XPCOMCGlue.h
+2
-1
未找到文件。
ChangeLog
浏览文件 @
9ccdbb5d
Wed May 6 15:22:08 CEST 2009 Daniel Veillard <veillard@redhat.com>
* src/vbox/vbox_XPCOMCGlue.[ch]: improve VirtualBox path detection
patch by Pritesh Kothari
Tue May 5 10:20:27 EDT 2009 Cole Robinson <crobinso@redhat.com>
* src/qemu_driver.c: Don't throw away StartVM errors when
...
...
src/vbox/vbox_XPCOMCGlue.c
浏览文件 @
9ccdbb5d
...
...
@@ -36,6 +36,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <dlfcn.h>
#include "vbox_XPCOMCGlue.h"
...
...
@@ -61,41 +62,72 @@
/** The dlopen handle for VBoxXPCOMC. */
void
*
g_hVBoxXPCOMC
=
NULL
;
/** The last load error. */
char
g_szVBoxErrMsg
[
256
];
/** Pointer to the VBoxXPCOMC function table. */
PCVBOXXPCOM
g_pVBoxFuncs
=
NULL
;
/** Pointer to VBoxGetXPCOMCFunctions for the loaded VBoxXPCOMC so/dylib/dll. */
PFNVBOXGETXPCOMCFUNCTIONS
g_pfnGetFunctions
=
NULL
;
/**
* Wrapper for setting g_szVBoxErrMsg. Can be an empty stub.
*
* @param fAlways When 0 the g_szVBoxErrMsg is only set if empty.
* @param pszFormat The format string.
* @param ... The arguments.
*/
static
void
setErrMsg
(
int
fAlways
,
const
char
*
pszFormat
,
...)
{
#ifndef LIBVIRT_VERSION
if
(
fAlways
||
!
g_szVBoxErrMsg
[
0
])
{
va_list
va
;
va_start
(
va
,
pszFormat
);
vsnprintf
(
g_szVBoxErrMsg
,
sizeof
(
g_szVBoxErrMsg
),
pszFormat
,
va
);
va_end
(
va
);
}
#else
/* libvirt */
(
void
)
fAlways
;
(
void
)
pszFormat
;
#endif
/* libvirt */
}
/**
* Try load VBoxXPCOMC.so/dylib/dll from the specified location and resolve all
* the symbols we need.
*
* @returns 0 on success, -1 on failure.
* @param pszHome The director where to try load VBoxXPCOMC from. Can be NULL.
* @param fSetAppHome Whether to set the VBOX_APP_HOME env.var. or not (boolean).
* @param pszHome The director where to try load VBoxXPCOMC from. Can
* be NULL.
* @param fSetAppHome Whether to set the VBOX_APP_HOME env.var. or not
* (boolean).
*/
static
int
tryLoadOne
(
const
char
*
pszHome
,
int
fSetAppHome
)
{
size_t
cchHome
=
pszHome
?
strlen
(
pszHome
)
:
0
;
size_t
cbBufNeeded
;
char
sz
Buf
[
4096
];
char
sz
Name
[
4096
];
int
rc
=
-
1
;
/*
* Construct the full name.
*/
cbBufNeeded
=
cchHome
+
sizeof
(
"/"
DYNLIB_NAME
);
if
(
cbBufNeeded
>
sizeof
(
sz
Buf
))
if
(
cbBufNeeded
>
sizeof
(
sz
Name
))
{
setErrMsg
(
1
,
"path buffer too small: %u bytes needed"
,
(
unsigned
)
cbBufNeeded
);
return
-
1
;
}
if
(
cchHome
)
{
memcpy
(
sz
Buf
,
pszHome
,
cchHome
);
sz
Buf
[
cchHome
]
=
'/'
;
memcpy
(
sz
Name
,
pszHome
,
cchHome
);
sz
Name
[
cchHome
]
=
'/'
;
cchHome
++
;
}
memcpy
(
&
sz
Buf
[
cchHome
],
DYNLIB_NAME
,
sizeof
(
DYNLIB_NAME
));
memcpy
(
&
sz
Name
[
cchHome
],
DYNLIB_NAME
,
sizeof
(
DYNLIB_NAME
));
/*
* Try load it by that name, setting the VBOX_APP_HOME first (for now).
...
...
@@ -108,7 +140,7 @@ static int tryLoadOne(const char *pszHome, int fSetAppHome)
else
unsetenv
(
"VBOX_APP_HOME"
);
}
g_hVBoxXPCOMC
=
dlopen
(
sz
Buf
,
RTLD_NOW
|
RTLD_LOCAL
);
g_hVBoxXPCOMC
=
dlopen
(
sz
Name
,
RTLD_NOW
|
RTLD_LOCAL
);
if
(
g_hVBoxXPCOMC
)
{
PFNVBOXGETXPCOMCFUNCTIONS
pfnGetFunctions
;
...
...
@@ -120,15 +152,21 @@ static int tryLoadOne(const char *pszHome, int fSetAppHome)
if
(
g_pVBoxFuncs
)
{
g_pfnGetFunctions
=
pfnGetFunctions
;
r
c
=
0
;
r
eturn
0
;
}
/* bail out */
setErrMsg
(
1
,
"%.80s: pfnGetFunctions(%#x) failed"
,
szName
,
VBOX_XPCOMC_VERSION
);
}
if
(
rc
!=
0
)
{
dlclose
(
g_hVBoxXPCOMC
);
g_hVBoxXPCOMC
=
NULL
;
}
else
setErrMsg
(
1
,
"dlsym(%.80s/%.32s): %.128s"
,
szName
,
VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME
,
dlerror
()
);
dlclose
(
g_hVBoxXPCOMC
)
;
g_hVBoxXPCOMC
=
NULL
;
}
else
setErrMsg
(
0
,
"dlopen(%.80s): %.160s"
,
szName
,
dlerror
());
return
rc
;
}
...
...
@@ -156,6 +194,7 @@ int VBoxCGlueInit(void)
/*
* Try the known standard locations.
*/
g_szVBoxErrMsg
[
0
]
=
'\0'
;
#if defined(__gnu__linux__) || defined(__linux__)
if
(
tryLoadOne
(
"/opt/VirtualBox"
,
1
)
==
0
)
return
0
;
...
...
@@ -201,5 +240,6 @@ void VBoxCGlueTerm(void)
}
g_pVBoxFuncs
=
NULL
;
g_pfnGetFunctions
=
NULL
;
memset
(
g_szVBoxErrMsg
,
0
,
sizeof
(
g_szVBoxErrMsg
));
}
src/vbox/vbox_XPCOMCGlue.h
浏览文件 @
9ccdbb5d
...
...
@@ -29,6 +29,7 @@
#ifndef ___VBoxXPCOMC_cglue_h
#define ___VBoxXPCOMC_cglue_h
/* This has to be the oldest version we support. */
#include "vbox_CAPI_v2_2.h"
#ifdef __cplusplus
...
...
@@ -39,7 +40,7 @@ extern "C" {
extern
void
*
g_hVBoxXPCOMC
;
/** The last load error. */
extern
char
g_szVBoxErrMsg
[
256
];
/** Pointer to the VBoxXPCOMC function table.
*/
/** Pointer to the VBoxXPCOMC function table. */
extern
PCVBOXXPCOM
g_pVBoxFuncs
;
/** Pointer to VBoxGetXPCOMCFunctions for the loaded VBoxXPCOMC so/dylib/dll. */
extern
PFNVBOXGETXPCOMCFUNCTIONS
g_pfnGetFunctions
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录