[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] The config of IP address for 'macvtap' network



On 05/15/2012 05:33 AM, Michal Privoznik wrote:
> On 15.05.2012 10:57, Lei Li wrote:
>> Hi guys,
>>
>> I know the macvtap network is supported by libvirt as forward mode
>> 'passthrough', I wonder is there anyway to configure the IP address
>> for its interface?
>>
>> For example, If I create a network as below:
>>
>> <network>
>>   <name>vdsm-testnet</name>
>>   <uuid>31f6b3b3-e959-0dd1-ad3a-bf95db660415</uuid>
>>   <forward dev='eth0.8' mode='passthrough'>
>>     <interface dev='eth0.8'/>
>>   </forward>
>> </network>
>>
>> For now, I have to set the IP address by 'ifconfig eth0.8 XXX.XXX.XXX.XXX'
>> after defining the network.


If only the guest will use the interface, that isn't necessary. As a
matter of fact, once an interface has been assigned to a guest using
macvtap passthrough mode, the host *can't* use the interface (it can
continue to use it in the other macvtap modes, however), so it's
completely pointless to configure an IP address for that interface on
the host.


>>
>> How can I set IP address for this VLAN device 'eth0.8' by libvirt, I mean
>> does libvirt support to assign IP address in this mode now? If does,
>> what is the
>> xml format for it?

A network device being used for a guest macvtap connection only needs an
IP address set on the host if the host will also be using that interface
- the guest does not magically acquire/use the IP address that has been
set on the host, it needs its own IP address, configured on the guest in
the same fashion you would configure any other guest interface (keep in
mind that even in macvtap 'bridge' mode, the host and guest cannot
communicate with each other via a macvtap interface). Otherwise, it's
enough for the interface to be defined on the host (it may also be
necessary for it to be "up" if it's a vlan device - I haven't tried
macvtap with vlans). If you are using RHEL or Fedora, you can do any/all
of that configuration with the virsh iface-define command. For example,
here is the xml file that would define an "eth0.8" interface on a host
(This is *not* the <interface> element of a domain configuration):


<interface type="vlan" name="eth0.8">
  <start mode="none"/>
  <protocol family="ipv4">
    <ip address="192.168.43.1"/>
  </protocol>
  <vlan tag="8">
    <interface name="eth0"/>
  </vlan>
</interface>

To get this defined in the system, you would use:

   virsh iface-define eth0.8.xml

But again, it seems doubtful this is what you really want.

>>
>> It'd appreciate a lot if anybody could read my post and give me some
>> suggestions!
>>
>>
> I suppose adding:
>
>  <ip address='192.168.123.1' netmask='255.255.255.0'/>
>
> into <network/> should work, doesn't it?

No.

The IP address used by the host for that interface (if any) should be
configured in the normal manner of the host system. The IP address used
by any guests using this interface / network based on this interface
should be configured in the guest just as you would any other interface
(if the guest is configured to get its IP address from DHCP, then you
would need to have a DHCP server running *on a different host* connected
to the .8 vlan.

(BTW, note that in passthrough mode, only a single guest can connect to
each physical device, so having a <network> defined for passthrough mode
is mostly only useful if you have a pool of devices available. The way
you have it defined above, only a single guest would be able to use that
network.)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]