tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Specifying names for tap interfaces



Greg Troxel wrote:
   Linux does this by passing the name of the tap interface Qemu has to
   create, so when the interface is created its name is known and can be
   used outside of Qemu.

   From what I see, NetBSD has the option to fetch the name of the
   interface created, using the TAPGIFNAME ioctl, but this is not really
   helpful because we create the interface from Qemu, but the scripts
   that attach the network interface are launched from the toolstack
   (xl).

   Will it be possible to provide a TAPSIFNAME ioctl to set the name of
   the created interface? I will start looking into this, but I would
   also like some feedback.

So you basically want to have

   in dom0, have xl tell qemu to make an interface for the guest, and to
   name it /dev/tap-NNN where xl chooses that

Well in Linux you can give any name to tap interfaces so Xen is currently using vif2.0-emu for Linux specific reasons.

Anything that we can control, like tap-%domid.%devid would be good though. It doesn't have to follow any specific nomenclature, but it will be good to be able to specify two integers, one that corresponds to the domain id, and another one that identifies the specific network card inside that domain.

   have qemu create a tap and arrange the name

Yes, basically to have a ioctl to be able to specify the name.

   have xl in the dom0 bridge tapNNN to whatever

Yes, hotplug scripts are launched directly from xl in new versions, so xl decides the name and passes it to both Qemu and hotplug scripts.


and the problem with just using what tap picks is that there's no
communication path from qemu create back to xl?

No, not really. Another option is to try to fetch the name from Qemu and pass it to the hotplug script. But this will require changes on both the Qemu and the xl side, and I think it will be more complicated. Apart from the fact than having this functionality might be interesting to other users.

Does qemu use /dev/tap, which picks a name, or by finding a /dev/tapN to
open and then using create?

Qemu opens /dev/tap and creates a new /dev/tapX, then fetches the name of this interface using the TAPGIFNAME. In the past, Qemu had a parameter that you could use to set the bridge Qemu has to pass to the hotplug script, but this is no longer present, and the script Qemu calls after creating the interface only knows the name of the newly created interface, which is not really helpful, and it's not used in Linux because all hotplug scripts are launched from xl.

Or is the problem that you need arbitrary names, rather than just to
have xl be able to pick something?

Not really arbitrary, as explained before, something like tap-%d.%d should be ok.

A few thoughts, not particularly coherent:

   qemu could be given a name and then create a symlink from that name to
   whatever tap chooses.  or use mknod to make the name actually be the
   special file.

Yes, but the interface name will still be tap%d, and brconfig will fail to add that interface.

   TAPSIFNAME seems tricky, because it seems to be about controlling the
   whole name, whereas tap seems to be tapN for some (printed
   representation of) number N, correpsonding to character special file
   (169,N).  So is this just about choosing N, or choosing the rest of
   the interface name?

I think that one way or another we need to be able to choose a tap name at creation, either the whole name, or just a number appended to tap-. Wouldn't it be possible to create a network interface with a random name, that still points to (169,N), even if N is not part of the name?

   Or is it that choosing N is sufficient, but you'd like to be able to
   do TAPSIFNAME on /dev/tap?  That seems awkward, because as I read the
   code the interface is created on open, so it would have to swap the
   softc, essentially closing the current tap and opening a new one.


Overall, it seems easiest to teach qemu to use 'ifconfig tapN create' as
an alternative to clone/set-name.

I'm not really sure using an external command is better than performing a set of ioctls, it's much more trickier to catch errors, and I would say that overall I doubt Qemu developers would ever agree to switching from using /dev/tap to ifconfig.

Thanks for the thoughts, Roger.


Home | Main Index | Thread Index | Old Index