qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yuri Benditovich <yuri.benditovich@daynix.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Yan Vugenfirer <yan@daynix.com>,
	Andrew Melnichenko <andrew@daynix.com>,
	qemu-devel@nongnu.org,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [PATCH] hmp: Changed hmp_netdev_add() using qmp_marshal_netdev_add()
Date: Tue, 24 Nov 2020 13:36:53 +0200	[thread overview]
Message-ID: <CAOEp5Oe18jtsgHVqwtm+-sqspD6KoJTOO9nNPmcWS++AVGjXKQ@mail.gmail.com> (raw)
In-Reply-To: <87lferm4x5.fsf@dusky.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 2870 bytes --]

Please confirm that this patch is intended to solve only the problem with
hmp (and disallow duplicated ids)
With it the netdev that was added from qemu's command line and was deleted
(for example by hmp) still can't be created, correct?

On Tue, Nov 24, 2020 at 12:21 PM Markus Armbruster <armbru@redhat.com>
wrote:

> Markus Armbruster <armbru@redhat.com> writes:
>
> > This means commit 08712fcb85 "net: Track netdevs in NetClientState
> > rather than QemuOpt" didn't actually replace QemuOpts completely.
> >
> > This affects QMP:
> >
> >     $ socat "READLINE,history=$HOME/.qmp_history,prompt=QMP>"
> UNIX-CONNECT:$HOME/work/images/test-qmp
> >     {"QMP": {"version": {"qemu": {"micro": 92, "minor": 1, "major": 5},
> "package": "v5.2.0-rc2-19-gff85db769f-dirty"}, "capabilities": ["oob"]}}
> >     QMP>{ "execute": "qmp_capabilities", "arguments": { "enable":
> ["oob"] } }
> >     {"return": {}}
> >     QMP>{"execute": "netdev_add", "arguments": {"type": "user",
> "id":"net0"}}
> >     {"return": {}}
> >     QMP>{"execute": "netdev_add", "arguments": {"type": "user",
> "id":"net0"}}
> >     {"return": {}}
> >
> > Results in two netdevs called "net0".  Needs fixing.
>
> Here's my attempt.  If it looks good to you, I'll post it as a proper
> patch.
>
>
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index a6a6684df1..8bc6b7bcc6 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -1638,9 +1638,7 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict)
>      }
>
>      netdev_add(opts, &err);
> -    if (err) {
> -        qemu_opts_del(opts);
> -    }
> +    qemu_opts_del(opts);
>
>  out:
>      hmp_handle_error(mon, err);
> diff --git a/net/net.c b/net/net.c
> index 794c652282..eb743aca23 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -978,6 +978,7 @@ static int (* const
> net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
>  static int net_client_init1(const Netdev *netdev, bool is_netdev, Error
> **errp)
>  {
>      NetClientState *peer = NULL;
> +    NetClientState *nc;
>
>      if (is_netdev) {
>          if (netdev->type == NET_CLIENT_DRIVER_NIC ||
> @@ -1005,6 +1006,12 @@ static int net_client_init1(const Netdev *netdev,
> bool is_netdev, Error **errp)
>          }
>      }
>
> +    nc = qemu_find_netdev(netdev->id);
> +    if (nc) {
> +        error_setg(errp, "Duplicate ID '%s'", netdev->id);
> +        return -1;
> +    }
> +
>      if (net_client_init_fun[netdev->type](netdev, netdev->id, peer, errp)
> < 0) {
>          /* FIXME drop when all init functions store an Error */
>          if (errp && !*errp) {
> @@ -1015,8 +1022,6 @@ static int net_client_init1(const Netdev *netdev,
> bool is_netdev, Error **errp)
>      }
>
>      if (is_netdev) {
> -        NetClientState *nc;
> -
>          nc = qemu_find_netdev(netdev->id);
>          assert(nc);
>          nc->is_netdev = true;
> --
> 2.26.2
>
>

[-- Attachment #2: Type: text/html, Size: 4036 bytes --]

  reply	other threads:[~2020-11-24 11:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16  3:55 [PATCH] hmp: Changed hmp_netdev_add() using qmp_marshal_netdev_add() andrew
2020-11-20 11:05 ` Andrew Melnichenko
2020-11-20 12:58   ` Markus Armbruster
2020-11-21 15:24     ` Yuri Benditovich
2020-11-21 15:31       ` Yuri Benditovich
2020-11-22 10:17         ` Andrew Melnichenko
2020-11-22 16:16           ` Yuri Benditovich
2020-11-23  9:25           ` Markus Armbruster
2020-11-23 14:32             ` Eric Blake
2020-11-23 15:35             ` Yuri Benditovich
2020-11-23 21:57               ` Yuri Benditovich
2020-11-24  8:55               ` Markus Armbruster
2020-11-24 10:21                 ` Markus Armbruster
2020-11-24 11:36                   ` Yuri Benditovich [this message]
2020-11-24 13:22                     ` Markus Armbruster
2020-11-24 13:36                       ` Markus Armbruster
2020-11-24 14:03                         ` Yuri Benditovich
2020-11-24 15:45                           ` Markus Armbruster
2020-11-25  8:54                             ` Yuri Benditovich
2020-11-25 10:27                               ` Markus Armbruster
2020-11-24 14:49                         ` Eric Blake
2020-11-24 15:32                           ` Markus Armbruster

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=CAOEp5Oe18jtsgHVqwtm+-sqspD6KoJTOO9nNPmcWS++AVGjXKQ@mail.gmail.com \
    --to=yuri.benditovich@daynix.com \
    --cc=andrew@daynix.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yan@daynix.com \
    /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).