Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
2ef66625
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2ef66625
编写于
6月 07, 2013
作者:
A
Andreas Färber
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virtio-serial-port: Convert to QOM realize/unrealize
Signed-off-by:
N
Andreas Färber
<
afaerber@suse.de
>
上级
0399a381
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
44 deletion
+43
-44
hw/char/virtio-console.c
hw/char/virtio-console.c
+13
-15
hw/char/virtio-serial-bus.c
hw/char/virtio-serial-bus.c
+26
-25
include/hw/virtio/virtio-serial.h
include/hw/virtio/virtio-serial.h
+4
-4
未找到文件。
hw/char/virtio-console.c
浏览文件 @
2ef66625
...
...
@@ -126,14 +126,16 @@ static void chr_event(void *opaque, int event)
}
}
static
int
virtconsole_initfn
(
VirtIOSerialPort
*
port
)
static
void
virtconsole_realize
(
DeviceState
*
dev
,
Error
**
errp
)
{
VirtConsole
*
vcon
=
VIRTIO_CONSOLE
(
port
);
VirtIOSerialPortClass
*
k
=
VIRTIO_SERIAL_PORT_GET_CLASS
(
port
);
VirtIOSerialPort
*
port
=
VIRTIO_SERIAL_PORT
(
dev
);
VirtConsole
*
vcon
=
VIRTIO_CONSOLE
(
dev
);
VirtIOSerialPortClass
*
k
=
VIRTIO_SERIAL_PORT_GET_CLASS
(
dev
);
if
(
port
->
id
==
0
&&
!
k
->
is_console
)
{
error_report
(
"Port number 0 on virtio-serial devices reserved for virtconsole devices for backward compatibility."
);
return
-
1
;
error_setg
(
errp
,
"Port number 0 on virtio-serial devices reserved "
"for virtconsole devices for backward compatibility."
);
return
;
}
if
(
vcon
->
chr
)
{
...
...
@@ -141,19 +143,15 @@ static int virtconsole_initfn(VirtIOSerialPort *port)
qemu_chr_add_handlers
(
vcon
->
chr
,
chr_can_read
,
chr_read
,
chr_event
,
vcon
);
}
return
0
;
}
static
int
virtconsole_exitfn
(
VirtIOSerialPort
*
port
)
static
void
virtconsole_unrealize
(
DeviceState
*
dev
,
Error
**
errp
)
{
VirtConsole
*
vcon
=
VIRTIO_CONSOLE
(
port
);
VirtConsole
*
vcon
=
VIRTIO_CONSOLE
(
dev
);
if
(
vcon
->
watch
)
{
g_source_remove
(
vcon
->
watch
);
}
return
0
;
}
static
Property
virtconsole_properties
[]
=
{
...
...
@@ -167,8 +165,8 @@ static void virtconsole_class_init(ObjectClass *klass, void *data)
VirtIOSerialPortClass
*
k
=
VIRTIO_SERIAL_PORT_CLASS
(
klass
);
k
->
is_console
=
true
;
k
->
init
=
virtconsole_initfn
;
k
->
exit
=
virtconsole_exitfn
;
k
->
realize
=
virtconsole_realize
;
k
->
unrealize
=
virtconsole_unrealize
;
k
->
have_data
=
flush_buf
;
k
->
set_guest_connected
=
set_guest_connected
;
dc
->
props
=
virtconsole_properties
;
...
...
@@ -191,8 +189,8 @@ static void virtserialport_class_init(ObjectClass *klass, void *data)
DeviceClass
*
dc
=
DEVICE_CLASS
(
klass
);
VirtIOSerialPortClass
*
k
=
VIRTIO_SERIAL_PORT_CLASS
(
klass
);
k
->
init
=
virtconsole_initfn
;
k
->
exit
=
virtconsole_exitfn
;
k
->
realize
=
virtconsole_realize
;
k
->
unrealize
=
virtconsole_unrealize
;
k
->
have_data
=
flush_buf
;
k
->
set_guest_connected
=
set_guest_connected
;
dc
->
props
=
virtserialport_properties
;
...
...
hw/char/virtio-serial-bus.c
浏览文件 @
2ef66625
...
...
@@ -808,13 +808,14 @@ static void remove_port(VirtIOSerial *vser, uint32_t port_id)
send_control_event
(
vser
,
port
->
id
,
VIRTIO_CONSOLE_PORT_REMOVE
,
1
);
}
static
int
virtser_port_qdev_init
(
DeviceState
*
qdev
)
static
void
virtser_port_device_realize
(
DeviceState
*
dev
,
Error
**
errp
)
{
VirtIOSerialPort
*
port
=
DO_UPCAST
(
VirtIOSerialPort
,
dev
,
q
dev
);
VirtIOSerialPort
*
port
=
VIRTIO_SERIAL_PORT
(
dev
);
VirtIOSerialPortClass
*
vsc
=
VIRTIO_SERIAL_PORT_GET_CLASS
(
port
);
VirtIOSerialBus
*
bus
=
DO_UPCAST
(
VirtIOSerialBus
,
qbus
,
qdev
->
parent_bus
);
int
ret
,
max_nr_ports
;
VirtIOSerialBus
*
bus
=
VIRTIO_SERIAL_BUS
(
qdev_get_parent_bus
(
dev
)
);
int
max_nr_ports
;
bool
plugging_port0
;
Error
*
err
=
NULL
;
port
->
vser
=
bus
->
vser
;
port
->
bh
=
qemu_bh_new
(
flush_queued_data_bh
,
port
);
...
...
@@ -829,9 +830,9 @@ static int virtser_port_qdev_init(DeviceState *qdev)
plugging_port0
=
vsc
->
is_console
&&
!
find_port_by_id
(
port
->
vser
,
0
);
if
(
find_port_by_id
(
port
->
vser
,
port
->
id
))
{
error_
report
(
"virtio-serial-bus: A port already exists at id %u"
,
port
->
id
);
return
-
1
;
error_
setg
(
errp
,
"virtio-serial-bus: A port already exists at id %u"
,
port
->
id
);
return
;
}
if
(
port
->
id
==
VIRTIO_CONSOLE_BAD_ID
)
{
...
...
@@ -840,22 +841,24 @@ static int virtser_port_qdev_init(DeviceState *qdev)
}
else
{
port
->
id
=
find_free_port_id
(
port
->
vser
);
if
(
port
->
id
==
VIRTIO_CONSOLE_BAD_ID
)
{
error_report
(
"virtio-serial-bus: Maximum port limit for this device reached"
);
return
-
1
;
error_setg
(
errp
,
"virtio-serial-bus: Maximum port limit for "
"this device reached"
);
return
;
}
}
}
max_nr_ports
=
tswap32
(
port
->
vser
->
config
.
max_nr_ports
);
if
(
port
->
id
>=
max_nr_ports
)
{
error_
report
(
"virtio-serial-bus: Out-of-range port id specified, max. allowed: %u"
,
max_nr_ports
-
1
);
return
-
1
;
error_
setg
(
errp
,
"virtio-serial-bus: Out-of-range port id specified, "
"max. allowed: %u"
,
max_nr_ports
-
1
);
return
;
}
ret
=
vsc
->
init
(
port
);
if
(
ret
)
{
return
ret
;
vsc
->
realize
(
dev
,
&
err
);
if
(
err
!=
NULL
)
{
error_propagate
(
errp
,
err
);
return
;
}
port
->
elem
.
out_num
=
0
;
...
...
@@ -868,14 +871,12 @@ static int virtser_port_qdev_init(DeviceState *qdev)
/* Send an update to the guest about this new port added */
virtio_notify_config
(
VIRTIO_DEVICE
(
port
->
vser
));
return
ret
;
}
static
int
virtser_port_qdev_exit
(
DeviceState
*
qdev
)
static
void
virtser_port_device_unrealize
(
DeviceState
*
dev
,
Error
**
errp
)
{
VirtIOSerialPort
*
port
=
DO_UPCAST
(
VirtIOSerialPort
,
dev
,
q
dev
);
VirtIOSerialPortClass
*
vsc
=
VIRTIO_SERIAL_PORT_GET_CLASS
(
port
);
VirtIOSerialPort
*
port
=
VIRTIO_SERIAL_PORT
(
dev
);
VirtIOSerialPortClass
*
vsc
=
VIRTIO_SERIAL_PORT_GET_CLASS
(
dev
);
VirtIOSerial
*
vser
=
port
->
vser
;
qemu_bh_delete
(
port
->
bh
);
...
...
@@ -883,10 +884,9 @@ static int virtser_port_qdev_exit(DeviceState *qdev)
QTAILQ_REMOVE
(
&
vser
->
ports
,
port
,
next
);
if
(
vsc
->
exit
)
{
vsc
->
exit
(
port
);
if
(
vsc
->
unrealize
)
{
vsc
->
unrealize
(
dev
,
errp
);
}
return
0
;
}
static
void
virtio_serial_device_realize
(
DeviceState
*
dev
,
Error
**
errp
)
...
...
@@ -971,10 +971,11 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp)
static
void
virtio_serial_port_class_init
(
ObjectClass
*
klass
,
void
*
data
)
{
DeviceClass
*
k
=
DEVICE_CLASS
(
klass
);
k
->
init
=
virtser_port_qdev_init
;
set_bit
(
DEVICE_CATEGORY_INPUT
,
k
->
categories
);
k
->
bus_type
=
TYPE_VIRTIO_SERIAL_BUS
;
k
->
exit
=
virtser_port_qdev_exit
;
k
->
realize
=
virtser_port_device_realize
;
k
->
unrealize
=
virtser_port_device_unrealize
;
k
->
unplug
=
qdev_simple_unplug_cb
;
k
->
props
=
virtser_props
;
}
...
...
include/hw/virtio/virtio-serial.h
浏览文件 @
2ef66625
...
...
@@ -81,15 +81,15 @@ typedef struct VirtIOSerialPortClass {
bool
is_console
;
/*
* The per-port (or per-app)
init
function that's called when a
* The per-port (or per-app)
realize
function that's called when a
* new device is found on the bus.
*/
int
(
*
init
)(
VirtIOSerialPort
*
port
)
;
DeviceRealize
realize
;
/*
* Per-port
exit
function that's called when a port gets
* Per-port
unrealize
function that's called when a port gets
* hot-unplugged or removed.
*/
int
(
*
exit
)(
VirtIOSerialPort
*
port
)
;
DeviceUnrealize
unrealize
;
/* Callbacks for guest events */
/* Guest opened/closed device. */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录