On Tue, Jul 20, 2010 at 06:53:27PM +0300, Michael Goldish wrote: > On 07/20/2010 04:44 PM, Amos Kong wrote: > > On Tue, Jul 20, 2010 at 01:19:39PM +0300, Michael Goldish wrote: > >> > > > > Michael, > > > > Thanks for your comments. Let's simplify this method together. I would produce a v2 later basing on our discussion. > >>> + def get_ifname(self, nic_index=0): > >>> + """ > >>> + Return the ifname of tap device for the guest nic. > >>> + > >>> + @param nic_index: Index of the NIC > >>> + """ > >>> + > >>> + nics = kvm_utils.get_sub_dict_names(self.params, "nics") > >>> + nic_name = nics[nic_index] > >>> + nic_params = kvm_utils.get_sub_dict(self.params, nic_name) > >>> + if nic_params.get("nic_ifname"): > >>> + return nic_params.get("nic_ifname") > >>> + else: > >>> + return "%s_%s_%s" % (nic_params.get("nic_model"), > >>> + nic_index, self.vnc_port) > >> > >> What's the purpose of this string? > > > > Just avoid repeated ifname. The vnc_port is unique for each VM, nic_index is unique for each nic of one VM. > > self.instance should also be unique, though it's quite long. qemu can only receive 15 chars as ifname, instance is too long. if the prefix of two instance are same, the actual ifnames will not be unique. linux-user/syscall.c: #define IFNAMSIZ 16 net/tap-linux.c: int tap_open(... ... if (ifname[0] != '\0') pstrcpy(ifr.ifr_name, IFNAMSIZ, ifname); else pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d"); -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html