thanks for your reply ŁĄ<br><br>The second solution you mentioned may be difficult , because when I assign the ethX to the VM, the X in the 'ethX' is random (the  'X' in the host may be different in the VM),I don't know it before I boot the VM . so maybe I couldn't edit the guest correctly before booting VM.<br>
<br>The first solution :<br>The network card's MAC address I can know and assign an fixed  IP <span>in advance</span> , but for the VFs , before I create the VF by "modprobe igb/ixgbe max_vfs=num1,num2" ,I couldn't know the MAC address before either,the MAC address generated randomly too.<br>
So maybe I should edit the DHCP server configure file after creating the VFs.<br><br>At first , I want to make the ethX name eth0, in that case, I can edit the guest before booting the VM ,and I also can use the DHCP to dynamicly assign an ip to the VM without editing the DHCP server configure file . but because of unknowing the MAC address , I don't know how to  use udev to bind the netword card or VF to eth0 ?<br>
<br>I <span id="tran_3_1">decided</span> <span id="tran_3_2">to first</span> <span id="tran_3_3"></span>try the first solution you mentioned.<br><br>best regards,<br>qinguan<br><br><br><br><div class="gmail_quote">2011/5/8 Richard W.M. Jones <span dir="ltr"><<a href="mailto:rjones@redhat.com">rjones@redhat.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Sat, May 07, 2011 at 11:24:23PM +0800, guan qin wrote:<br>
> So how can I assign an ip to the VM when assign the NIC or VF to the<br>
> VM<br>
<br>
</div>It doesn't work like this.<br>
<br>
Just like with real hardware, all the virtual hardware has is a MAC<br>
address.  The (real or virtual) machine has to use some other method<br>
to get an IP address and hostname after it has booted.  As with real<br>
machines, either it does that using DHCP, or it has the IP address<br>
hard-coded somewhere on disk.<br>
<br>
The best solution is to create a separate DHCP service which assigns a<br>
specific IP address to the known MAC address of the NIC/VF.  You can<br>
get the MAC address using "virsh dumpxml".<br>
<br>
Another solution would be to edit the guest before booting it and give<br>
it the address you want it to have.  eg for RHEL and Fedora guests:<br>
<br>
  guestfish -i -d MyGuest -- \<br>
      upload - /etc/sysconfig/network-scripts/ifcfg-eth0 <<_EOF<br>
  DEVICE=eth0<br>
  IPADDR=192.168.1.2<br>
  NETMASK=255.255.255.0<br>
  NETWORK=192.168.1.0<br>
  BROADCAST=192.168.1.255<br>
  ONBOOT=yes<br>
  _EOF<br>
<br>
Rich.<br>
<font color="#888888"><br>
--<br>
Richard Jones, Virtualization Group, Red Hat <a href="http://people.redhat.com/%7Erjones%0Avirt-p2v" target="_blank">http://people.redhat.com/~rjones<br>
virt-p2v</a> converts physical machines to virtual machines.  Boot with a<br>
live CD or over the network (PXE) and turn machines into Xen guests.<br>
<a href="http://et.redhat.com/%7Erjones/virt-p2v" target="_blank">http://et.redhat.com/~rjones/virt-p2v</a><br>
</font></blockquote></div><br>