Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
6be94596
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看板
提交
6be94596
编写于
8月 11, 2014
作者:
T
Taowei
提交者:
Michal Privoznik
8月 15, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vbox: Rewrite vboxDomainUpdateDeviceFlags
Since vboxDomainAttachDeviceImple not used in vbox_tmpl.c, it has been deleted.
上级
58776877
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
215 deletion
+18
-215
src/vbox/vbox_common.c
src/vbox/vbox_common.c
+16
-0
src/vbox/vbox_tmpl.c
src/vbox/vbox_tmpl.c
+0
-215
src/vbox/vbox_uniformed_api.h
src/vbox/vbox_uniformed_api.h
+2
-0
未找到文件。
src/vbox/vbox_common.c
浏览文件 @
6be94596
...
...
@@ -4163,3 +4163,19 @@ int vboxDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
return
vboxDomainAttachDeviceImpl
(
dom
,
xml
,
0
);
}
int
vboxDomainUpdateDeviceFlags
(
virDomainPtr
dom
,
const
char
*
xml
,
unsigned
int
flags
)
{
virCheckFlags
(
VIR_DOMAIN_AFFECT_CURRENT
|
VIR_DOMAIN_AFFECT_LIVE
|
VIR_DOMAIN_AFFECT_CONFIG
,
-
1
);
if
(
flags
&
VIR_DOMAIN_AFFECT_CONFIG
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"cannot modify the persistent configuration of a domain"
));
return
-
1
;
}
return
vboxDomainAttachDeviceImpl
(
dom
,
xml
,
1
);
}
src/vbox/vbox_tmpl.c
浏览文件 @
6be94596
...
...
@@ -1451,221 +1451,6 @@ _vboxAttachDrivesOld(virDomainDefPtr def ATTRIBUTE_UNUSED,
#endif
/* VBOX_API_VERSION >= 4000000 */
static
int
vboxDomainAttachDeviceImpl
(
virDomainPtr
dom
,
const
char
*
xml
,
int
mediaChangeOnly
ATTRIBUTE_UNUSED
)
{
VBOX_OBJECT_CHECK
(
dom
->
conn
,
int
,
-
1
);
IMachine
*
machine
=
NULL
;
vboxIID
iid
=
VBOX_IID_INITIALIZER
;
PRUint32
state
=
MachineState_Null
;
virDomainDefPtr
def
=
NULL
;
virDomainDeviceDefPtr
dev
=
NULL
;
nsresult
rc
;
if
(
VIR_ALLOC
(
def
)
<
0
)
return
ret
;
if
(
VIR_STRDUP
(
def
->
os
.
type
,
"hvm"
)
<
0
)
goto
cleanup
;
dev
=
virDomainDeviceDefParse
(
xml
,
def
,
data
->
caps
,
data
->
xmlopt
,
VIR_DOMAIN_XML_INACTIVE
);
if
(
dev
==
NULL
)
goto
cleanup
;
vboxIIDFromUUID
(
&
iid
,
dom
->
uuid
);
rc
=
VBOX_OBJECT_GET_MACHINE
(
iid
.
value
,
&
machine
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_NO_DOMAIN
,
"%s"
,
_
(
"no domain with matching uuid"
));
goto
cleanup
;
}
if
(
machine
)
{
machine
->
vtbl
->
GetState
(
machine
,
&
state
);
if
((
state
==
MachineState_Running
)
||
(
state
==
MachineState_Paused
))
{
rc
=
VBOX_SESSION_OPEN_EXISTING
(
iid
.
value
,
machine
);
}
else
{
rc
=
VBOX_SESSION_OPEN
(
iid
.
value
,
machine
);
}
if
(
NS_SUCCEEDED
(
rc
))
{
rc
=
data
->
vboxSession
->
vtbl
->
GetMachine
(
data
->
vboxSession
,
&
machine
);
if
(
NS_SUCCEEDED
(
rc
)
&&
machine
)
{
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_DISK
)
{
#if VBOX_API_VERSION < 3001000
const
char
*
src
=
virDomainDiskGetSource
(
dev
->
data
.
disk
);
int
type
=
virDomainDiskGetType
(
dev
->
data
.
disk
);
if
(
dev
->
data
.
disk
->
device
==
VIR_DOMAIN_DISK_DEVICE_CDROM
)
{
if
(
type
==
VIR_STORAGE_TYPE_FILE
&&
src
)
{
IDVDDrive
*
dvdDrive
=
NULL
;
/* Currently CDROM/DVD Drive is always IDE
* Secondary Master so neglecting the following
* parameter dev->data.disk->bus
*/
machine
->
vtbl
->
GetDVDDrive
(
machine
,
&
dvdDrive
);
if
(
dvdDrive
)
{
IDVDImage
*
dvdImage
=
NULL
;
PRUnichar
*
dvdfileUtf16
=
NULL
;
vboxIID
dvduuid
=
VBOX_IID_INITIALIZER
;
vboxIID
dvdemptyuuid
=
VBOX_IID_INITIALIZER
;
VBOX_UTF8_TO_UTF16
(
src
,
&
dvdfileUtf16
);
data
->
vboxObj
->
vtbl
->
FindDVDImage
(
data
->
vboxObj
,
dvdfileUtf16
,
&
dvdImage
);
if
(
!
dvdImage
)
{
data
->
vboxObj
->
vtbl
->
OpenDVDImage
(
data
->
vboxObj
,
dvdfileUtf16
,
dvdemptyuuid
.
value
,
&
dvdImage
);
}
if
(
dvdImage
)
{
rc
=
dvdImage
->
vtbl
->
imedium
.
GetId
((
IMedium
*
)
dvdImage
,
&
dvduuid
.
value
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"can't get the uuid of the file to "
"be attached to cdrom: %s, rc=%08x"
),
src
,
(
unsigned
)
rc
);
}
else
{
/* unmount the previous mounted image */
dvdDrive
->
vtbl
->
Unmount
(
dvdDrive
);
rc
=
dvdDrive
->
vtbl
->
MountImage
(
dvdDrive
,
dvduuid
.
value
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"could not attach the file to cdrom: %s, rc=%08x"
),
src
,
(
unsigned
)
rc
);
}
else
{
ret
=
0
;
DEBUGIID
(
"CD/DVD Image UUID:"
,
dvduuid
.
value
);
}
}
VBOX_MEDIUM_RELEASE
(
dvdImage
);
}
vboxIIDUnalloc
(
&
dvduuid
);
VBOX_UTF16_FREE
(
dvdfileUtf16
);
VBOX_RELEASE
(
dvdDrive
);
}
}
else
if
(
type
==
VIR_STORAGE_TYPE_BLOCK
)
{
}
}
else
if
(
dev
->
data
.
disk
->
device
==
VIR_DOMAIN_DISK_DEVICE_FLOPPY
)
{
if
(
type
==
VIR_STORAGE_TYPE_FILE
&&
src
)
{
IFloppyDrive
*
floppyDrive
;
machine
->
vtbl
->
GetFloppyDrive
(
machine
,
&
floppyDrive
);
if
(
floppyDrive
)
{
rc
=
floppyDrive
->
vtbl
->
SetEnabled
(
floppyDrive
,
1
);
if
(
NS_SUCCEEDED
(
rc
))
{
IFloppyImage
*
floppyImage
=
NULL
;
PRUnichar
*
fdfileUtf16
=
NULL
;
vboxIID
fduuid
=
VBOX_IID_INITIALIZER
;
vboxIID
fdemptyuuid
=
VBOX_IID_INITIALIZER
;
VBOX_UTF8_TO_UTF16
(
src
,
&
fdfileUtf16
);
rc
=
data
->
vboxObj
->
vtbl
->
FindFloppyImage
(
data
->
vboxObj
,
fdfileUtf16
,
&
floppyImage
);
if
(
!
floppyImage
)
{
data
->
vboxObj
->
vtbl
->
OpenFloppyImage
(
data
->
vboxObj
,
fdfileUtf16
,
fdemptyuuid
.
value
,
&
floppyImage
);
}
if
(
floppyImage
)
{
rc
=
floppyImage
->
vtbl
->
imedium
.
GetId
((
IMedium
*
)
floppyImage
,
&
fduuid
.
value
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"can't get the uuid of the file to be "
"attached to floppy drive: %s, rc=%08x"
),
src
,
(
unsigned
)
rc
);
}
else
{
rc
=
floppyDrive
->
vtbl
->
MountImage
(
floppyDrive
,
fduuid
.
value
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"could not attach the file to floppy drive: %s, rc=%08x"
),
src
,
(
unsigned
)
rc
);
}
else
{
ret
=
0
;
DEBUGIID
(
"attached floppy, UUID:"
,
fduuid
.
value
);
}
}
VBOX_MEDIUM_RELEASE
(
floppyImage
);
}
vboxIIDUnalloc
(
&
fduuid
);
VBOX_UTF16_FREE
(
fdfileUtf16
);
}
VBOX_RELEASE
(
floppyDrive
);
}
}
else
if
(
type
==
VIR_STORAGE_TYPE_BLOCK
)
{
}
}
#else
/* VBOX_API_VERSION >= 3001000 */
#endif
/* VBOX_API_VERSION >= 3001000 */
}
else
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_NET
)
{
}
else
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_HOSTDEV
)
{
if
(
dev
->
data
.
hostdev
->
mode
==
VIR_DOMAIN_HOSTDEV_MODE_SUBSYS
)
{
if
(
dev
->
data
.
hostdev
->
source
.
subsys
.
type
==
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB
)
{
}
}
}
else
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_FS
&&
dev
->
data
.
fs
->
type
==
VIR_DOMAIN_FS_TYPE_MOUNT
)
{
PRUnichar
*
nameUtf16
;
PRUnichar
*
hostPathUtf16
;
PRBool
writable
;
VBOX_UTF8_TO_UTF16
(
dev
->
data
.
fs
->
dst
,
&
nameUtf16
);
VBOX_UTF8_TO_UTF16
(
dev
->
data
.
fs
->
src
,
&
hostPathUtf16
);
writable
=
!
dev
->
data
.
fs
->
readonly
;
#if VBOX_API_VERSION < 4000000
rc
=
machine
->
vtbl
->
CreateSharedFolder
(
machine
,
nameUtf16
,
hostPathUtf16
,
writable
);
#else
/* VBOX_API_VERSION >= 4000000 */
rc
=
machine
->
vtbl
->
CreateSharedFolder
(
machine
,
nameUtf16
,
hostPathUtf16
,
writable
,
PR_FALSE
);
#endif
/* VBOX_API_VERSION >= 4000000 */
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"could not attach shared folder '%s', rc=%08x"
),
dev
->
data
.
fs
->
dst
,
(
unsigned
)
rc
);
}
else
{
ret
=
0
;
}
VBOX_UTF16_FREE
(
nameUtf16
);
VBOX_UTF16_FREE
(
hostPathUtf16
);
}
machine
->
vtbl
->
SaveSettings
(
machine
);
VBOX_RELEASE
(
machine
);
}
VBOX_SESSION_CLOSE
();
}
}
cleanup:
vboxIIDUnalloc
(
&
iid
);
virDomainDefFree
(
def
);
virDomainDeviceDefFree
(
dev
);
return
ret
;
}
static
int
vboxDomainUpdateDeviceFlags
(
virDomainPtr
dom
,
const
char
*
xml
,
unsigned
int
flags
)
{
virCheckFlags
(
VIR_DOMAIN_AFFECT_CURRENT
|
VIR_DOMAIN_AFFECT_LIVE
|
VIR_DOMAIN_AFFECT_CONFIG
,
-
1
);
if
(
flags
&
VIR_DOMAIN_AFFECT_CONFIG
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"cannot modify the persistent configuration of a domain"
));
return
-
1
;
}
return
vboxDomainAttachDeviceImpl
(
dom
,
xml
,
1
);
}
static
int
vboxDomainDetachDevice
(
virDomainPtr
dom
,
const
char
*
xml
)
{
VBOX_OBJECT_CHECK
(
dom
->
conn
,
int
,
-
1
);
...
...
src/vbox/vbox_uniformed_api.h
浏览文件 @
6be94596
...
...
@@ -527,6 +527,8 @@ int vboxConnectNumOfDefinedDomains(virConnectPtr conn);
int
vboxDomainAttachDevice
(
virDomainPtr
dom
,
const
char
*
xml
);
int
vboxDomainAttachDeviceFlags
(
virDomainPtr
dom
,
const
char
*
xml
,
unsigned
int
flags
);
int
vboxDomainUpdateDeviceFlags
(
virDomainPtr
dom
,
const
char
*
xml
,
unsigned
int
flags
);
/* Version specified functions for installing uniformed API */
void
vbox22InstallUniformedAPI
(
vboxUniformedAPI
*
pVBoxAPI
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录