aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-10-22 12:52:58 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2016-10-24 15:27:21 +0200
commitc39860e6dc90f6ee2e82ee078f978c5d7f3df86a (patch)
tree7af723a578b9f33ee172254b20fd9bbdd519cd0c /net
parent5d300164d00cf9d37a4481831d2c993255dfa0e8 (diff)
char: replace qemu_chr_claim/release with qemu_chr_fe_init/deinit
Now that all front end use qemu_chr_fe_init(), we can move chardev claiming in init(), and add a function deinit() to release the chardev and cleanup handlers. The qemu_chr_fe_claim_no_fail() for property are gone, since the property will raise an error instead. In other cases, where there is already an error path, an error is raised instead. Finally, other cases are handled by &error_abort in qemu_chr_fe_init(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20161022095318.17775-19-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/colo-compare.c20
-rw-r--r--net/filter-mirror.c20
-rw-r--r--net/slirp.c1
-rw-r--r--net/vhost-user.c8
4 files changed, 8 insertions, 41 deletions
diff --git a/net/colo-compare.c b/net/colo-compare.c
index 63d92cb9da..308368164c 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -590,12 +590,6 @@ static int find_and_check_chardev(CharDriverState **chr,
return 1;
}
- if (qemu_chr_fe_claim(*chr) < 0) {
- error_setg(errp, "chardev \"%s\" cannot be claimed",
- chr_name);
- return 1;
- }
-
return 0;
}
@@ -707,17 +701,9 @@ static void colo_compare_finalize(Object *obj)
{
CompareState *s = COLO_COMPARE(obj);
- if (s->chr_pri_in.chr) {
- qemu_chr_fe_set_handlers(&s->chr_pri_in, NULL, NULL, NULL, NULL, NULL);
- qemu_chr_fe_release(s->chr_pri_in.chr);
- }
- if (s->chr_sec_in.chr) {
- qemu_chr_fe_set_handlers(&s->chr_sec_in, NULL, NULL, NULL, NULL, NULL);
- qemu_chr_fe_release(s->chr_sec_in.chr);
- }
- if (s->chr_out.chr) {
- qemu_chr_fe_release(s->chr_out.chr);
- }
+ qemu_chr_fe_deinit(&s->chr_pri_in);
+ qemu_chr_fe_deinit(&s->chr_sec_in);
+ qemu_chr_fe_deinit(&s->chr_out);
g_queue_free(&s->conn_list);
diff --git a/net/filter-mirror.c b/net/filter-mirror.c
index 12d79cd987..1864c818d5 100644
--- a/net/filter-mirror.c
+++ b/net/filter-mirror.c
@@ -175,22 +175,15 @@ static void filter_mirror_cleanup(NetFilterState *nf)
{
MirrorState *s = FILTER_MIRROR(nf);
- if (s->chr_out.chr) {
- qemu_chr_fe_release(s->chr_out.chr);
- }
+ qemu_chr_fe_deinit(&s->chr_out);
}
static void filter_redirector_cleanup(NetFilterState *nf)
{
MirrorState *s = FILTER_REDIRECTOR(nf);
- if (s->chr_in.chr) {
- qemu_chr_fe_set_handlers(&s->chr_in, NULL, NULL, NULL, NULL, NULL);
- qemu_chr_fe_release(s->chr_in.chr);
- }
- if (s->chr_out.chr) {
- qemu_chr_fe_release(s->chr_out.chr);
- }
+ qemu_chr_fe_deinit(&s->chr_in);
+ qemu_chr_fe_deinit(&s->chr_out);
}
static void filter_mirror_setup(NetFilterState *nf, Error **errp)
@@ -211,11 +204,6 @@ static void filter_mirror_setup(NetFilterState *nf, Error **errp)
return;
}
- if (qemu_chr_fe_claim(chr) != 0) {
- error_setg(errp, QERR_DEVICE_IN_USE, s->outdev);
- return;
- }
-
qemu_chr_fe_init(&s->chr_out, chr, errp);
}
@@ -254,7 +242,6 @@ static void filter_redirector_setup(NetFilterState *nf, Error **errp)
return;
}
- qemu_chr_fe_claim_no_fail(chr);
if (!qemu_chr_fe_init(&s->chr_in, chr, errp)) {
return;
}
@@ -271,7 +258,6 @@ static void filter_redirector_setup(NetFilterState *nf, Error **errp)
"OUT Device '%s' not found", s->outdev);
return;
}
- qemu_chr_fe_claim_no_fail(chr);
if (!qemu_chr_fe_init(&s->chr_out, chr, errp)) {
return;
}
diff --git a/net/slirp.c b/net/slirp.c
index f9f6fc6b0b..0e675354a4 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -774,7 +774,6 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str,
fwd->port = port;
fwd->slirp = s->slirp;
- qemu_chr_fe_claim_no_fail(fwd->hd.chr);
qemu_chr_fe_set_handlers(&fwd->hd, guestfwd_can_read, guestfwd_read,
NULL, fwd, NULL);
}
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 357b500d82..140a4e0bde 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -150,10 +150,8 @@ static void vhost_user_cleanup(NetClientState *nc)
g_free(s->vhost_net);
s->vhost_net = NULL;
}
- if (nc->queue_index == 0 && s->chr.chr) {
- qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, NULL, NULL, NULL);
- qemu_chr_fe_release(s->chr.chr);
- s->chr.chr = NULL;
+ if (nc->queue_index == 0) {
+ qemu_chr_fe_deinit(&s->chr);
}
qemu_purge_queued_packets(nc);
@@ -297,8 +295,6 @@ static CharDriverState *net_vhost_claim_chardev(
return NULL;
}
- qemu_chr_fe_claim_no_fail(chr);
-
return chr;
}