From: Stefan Hajnoczi <stefanha@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 3/4] net: Reject non-netdevs in qmp_netdev_del()
Date: Thu, 1 Nov 2012 12:10:17 +0100 [thread overview]
Message-ID: <1351768218-21466-4-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1351768218-21466-1-git-send-email-stefanha@redhat.com>
The netdev_del command crashes when given a -net device, because it
calls qemu_opts_del(NULL).
Check that this is a -netdev before attempting to delete it and the
QemuOpts.
Note the subtle change from qemu_find_opts_err("netdev", errp) to
qemu_find_opts_err("netdev", NULL). Since "netdev" is a built in
options group and we don't check for NULL return anyway, there's no use
in passing errp here.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
net.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/net.c b/net.c
index ae4bc0d..e8ae13e 100644
--- a/net.c
+++ b/net.c
@@ -827,6 +827,7 @@ exit_err:
void qmp_netdev_del(const char *id, Error **errp)
{
NetClientState *nc;
+ QemuOpts *opts;
nc = qemu_find_netdev(id);
if (!nc) {
@@ -834,8 +835,14 @@ void qmp_netdev_del(const char *id, Error **errp)
return;
}
+ opts = qemu_opts_find(qemu_find_opts_err("netdev", NULL), id);
+ if (!opts) {
+ error_setg(errp, "Device '%s' is not a netdev", id);
+ return;
+ }
+
qemu_del_net_client(nc);
- qemu_opts_del(qemu_opts_find(qemu_find_opts_err("netdev", errp), id));
+ qemu_opts_del(opts);
}
void print_net_client(Monitor *mon, NetClientState *nc)
--
1.7.12.1
next prev parent reply other threads:[~2012-11-01 11:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-01 11:10 [Qemu-devel] [PULL 1.3 0/4] Net patches Stefan Hajnoczi
2012-11-01 11:10 ` [Qemu-devel] [PATCH 1/4] e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty Stefan Hajnoczi
2012-11-01 11:10 ` [Qemu-devel] [PATCH 2/4] net: use "socket" model name for UDP sockets Stefan Hajnoczi
2012-11-01 11:10 ` Stefan Hajnoczi [this message]
2012-11-01 11:10 ` [Qemu-devel] [PATCH 4/4] e1000: pre-initialize RAH/RAL registers Stefan Hajnoczi
2012-11-01 19:33 ` [Qemu-devel] [PULL 1.3 0/4] Net patches Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351768218-21466-4-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).