qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Jason Wang <jasowang@redhat.com>,
	qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] net: Allow hubports to connect to other netdevs
Date: Mon, 15 Jan 2018 18:36:18 +0100	[thread overview]
Message-ID: <848373da-2010-d38b-fd88-91cd61dec91e@redhat.com> (raw)
In-Reply-To: <73e534aa-ba61-e3ca-6730-3382f1c1ce1a@redhat.com>

On 15.01.2018 08:40, Jason Wang wrote:
> 
> On 2018年01月10日 22:32, Thomas Huth wrote:
>> QEMU can emulate hubs to connect NICs and netdevs. This is currently
>> primarily used for the mis-named 'vlan' feature of the networking
>> subsystem. Now the 'vlan' feature has been marked as deprecated, since
>> its name is rather confusing and the users often rather mis-configure
>> their network when trying to use it. But while the 'vlan' parameter
>> should be removed at one point in time, the basic idea of emulating
>> a hub in QEMU is still good: It's useful for bundling up the output of
>> multiple NICs into one single l2tp netdev for example.
>>
>> Now to be able to use the hubport feature without 'vlan's, there is one
>> missing piece: The possibility to connect a hubport to a netdev, too.
>> This patch adds this possibility by introducing a new "netdev=..."
>> parameter to the hubports.
[...]
>> @@ -286,12 +287,32 @@ int net_init_hubport(const Netdev *netdev, const
>> char *name,
>>                        NetClientState *peer, Error **errp)
>>   {
>>       const NetdevHubPortOptions *hubport;
>> +    NetClientState *hubncs;
>>         assert(netdev->type == NET_CLIENT_DRIVER_HUBPORT);
>>       assert(!peer);
>>       hubport = &netdev->u.hubport;
>>   -    net_hub_add_port(hubport->hubid, name);
>> +    hubncs = net_hub_add_port(hubport->hubid, name);
>> +    if (!hubncs) {
>> +        error_setg(errp, "failed to add port to hub %i with id '%s'",
>> +                   hubport->hubid, name);
>> +        return -1;
>> +    }
>> +
>> +    if (hubport->has_netdev) {
>> +        NetClientState *hubpeer;
>> +
>> +        hubpeer = qemu_find_netdev(hubport->netdev);
>> +        if (!hubpeer) {
>> +            error_setg(errp, "netdev '%s' not found", hubport->netdev);
>> +            return -1;
>> +        }
>> +        assert(!hubncs->peer && !hubpeer->peer);
>> +        hubncs->peer = hubpeer;
>> +        hubpeer->peer = hubncs;
>> +    }
>> +
> 
> Instead of open coding here, maybe you can pass peer to
> net_hub_port_new() and let qemu_new_net_client() do this for you.

Sure. I'll send a v2.

> And since it was a hub, do we need to send to its netdev too inside
> net_hub_receive()?

I currently don't think so, but I'll check again...

 Thomas

  reply	other threads:[~2018-01-15 17:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10 14:32 [Qemu-devel] [PATCH] net: Allow hubports to connect to other netdevs Thomas Huth
2018-01-10 14:47 ` Paolo Bonzini
2018-01-10 15:06   ` Thomas Huth
2018-01-15  7:40 ` Jason Wang
2018-01-15 17:36   ` Thomas Huth [this message]
2018-01-15 18:06     ` Thomas Huth
2018-01-16  5:54       ` Jason Wang

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=848373da-2010-d38b-fd88-91cd61dec91e@redhat.com \
    --to=thuth@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=pbonzini@redhat.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).