summaryrefslogtreecommitdiff
path: root/net/vhost-user.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-10-22 12:52:55 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2016-10-24 15:27:21 +0200
commit5345fdb4467816c44f6752b3a1f4e73aa25919f9 (patch)
tree9930cf4370d2325d113408f7b314cd77aa43f8a3 /net/vhost-user.c
parentfbf3cc3a67a7131e258764aa1f19d5324e9e9f7a (diff)
downloadqemu-5345fdb4467816c44f6752b3a1f4e73aa25919f9.tar.gz
char: use qemu_chr_fe* functions with CharBackend argument
This also switches from qemu_chr_add_handlers() to qemu_chr_fe_set_handlers(). Note that qemu_chr_fe_set_handlers() now takes the focus when fe_open (qemu_chr_add_handlers() did take the focus) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20161022095318.17775-16-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'net/vhost-user.c')
-rw-r--r--net/vhost-user.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 45782470e8..8b7e98d5b9 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -78,7 +78,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[])
s = DO_UPCAST(VhostUserState, nc, ncs[i]);
options.net_backend = ncs[i];
- options.opaque = s->chr.chr;
+ options.opaque = &s->chr;
options.busyloop_timeout = 0;
net = vhost_net_init(&options);
if (!net) {
@@ -151,7 +151,7 @@ static void vhost_user_cleanup(NetClientState *nc)
s->vhost_net = NULL;
}
if (s->chr.chr) {
- qemu_chr_add_handlers(s->chr.chr, NULL, NULL, NULL, NULL);
+ qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, NULL, NULL, NULL);
qemu_chr_fe_release(s->chr.chr);
s->chr.chr = NULL;
}
@@ -187,7 +187,7 @@ static gboolean net_vhost_user_watch(GIOChannel *chan, GIOCondition cond,
{
VhostUserState *s = opaque;
- qemu_chr_fe_disconnect(s->chr.chr);
+ qemu_chr_fe_disconnect(&s->chr);
return FALSE;
}
@@ -197,6 +197,7 @@ static void net_vhost_user_event(void *opaque, int event)
const char *name = opaque;
NetClientState *ncs[MAX_QUEUE_NUM];
VhostUserState *s;
+ CharDriverState *chr;
Error *err = NULL;
int queues;
@@ -206,13 +207,14 @@ static void net_vhost_user_event(void *opaque, int event)
assert(queues < MAX_QUEUE_NUM);
s = DO_UPCAST(VhostUserState, nc, ncs[0]);
- trace_vhost_user_event(s->chr.chr->label, event);
+ chr = qemu_chr_fe_get_driver(&s->chr);
+ trace_vhost_user_event(chr->label, event);
switch (event) {
case CHR_EVENT_OPENED:
- s->watch = qemu_chr_fe_add_watch(s->chr.chr, G_IO_HUP,
+ s->watch = qemu_chr_fe_add_watch(&s->chr, G_IO_HUP,
net_vhost_user_watch, s);
if (vhost_user_start(queues, ncs) < 0) {
- qemu_chr_fe_disconnect(s->chr.chr);
+ qemu_chr_fe_disconnect(&s->chr);
return;
}
qmp_set_link(name, true, &err);
@@ -255,6 +257,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
nc->queue_index = i;
s = DO_UPCAST(VhostUserState, nc, nc);
+
if (!qemu_chr_fe_init(&s->chr, chr, &err)) {
error_report_err(err);
return -1;
@@ -263,12 +266,12 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
s = DO_UPCAST(VhostUserState, nc, nc0);
do {
- if (qemu_chr_wait_connected(chr, &err) < 0) {
+ if (qemu_chr_fe_wait_connected(&s->chr, &err) < 0) {
error_report_err(err);
return -1;
}
- qemu_chr_add_handlers(chr, NULL, NULL,
- net_vhost_user_event, nc0->name);
+ qemu_chr_fe_set_handlers(&s->chr, NULL, NULL,
+ net_vhost_user_event, nc0->name, NULL);
} while (!s->started);
assert(s->vhost_net);