From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XP0Q7-0002bi-8q for qemu-devel@nongnu.org; Tue, 02 Sep 2014 22:35:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XP0Q0-0001nn-Oa for qemu-devel@nongnu.org; Tue, 02 Sep 2014 22:35:39 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:59353) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XP0Pz-0001mK-R0 for qemu-devel@nongnu.org; Tue, 02 Sep 2014 22:35:32 -0400 From: "Gonglei (Arei)" Date: Wed, 3 Sep 2014 02:35:02 +0000 Message-ID: <33183CC9F5247A488A2544077AF1902086DC0CCE@SZXEMA503-MBS.china.huawei.com> References: <1409392827-9372-1-git-send-email-arei.gonglei@huawei.com> <1409392827-9372-3-git-send-email-arei.gonglei@huawei.com> <1409553800.708.3.camel@nilsson.home.kraxel.org> <33183CC9F5247A488A2544077AF1902086DBEA84@SZXEMA503-MBS.china.huawei.com> <20140902180012.GQ32084@thinpad.lan.raisama.net> In-Reply-To: <20140902180012.GQ32084@thinpad.lan.raisama.net> Content-Language: zh-CN Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH v6 02/27] bootindex: add del_boot_device_path function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: "chenliang (T)" , "Huangweidong (C)" , "mst@redhat.com" , "aik@ozlabs.ru" , "hutao@cn.fujitsu.com" , "qemu-devel@nongnu.org" , "armbru@redhat.com" , Gerd Hoffmann , "akong@redhat.com" , "agraf@suse.de" , "aliguori@amazon.com" , Luonengjun , "Huangpeng (Peter)" , "hani@linux.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" , "lcapitulino@redhat.com" , "kwolf@redhat.com" , "peter.crosthwaite@xilinx.com" , "imammedo@redhat.com" , "afaerber@suse.de" Hi, > From: Eduardo Habkost [mailto:ehabkost@redhat.com] > Sent: Wednesday, September 03, 2014 2:00 AM > Subject: Re: [PATCH v6 02/27] bootindex: add del_boot_device_path functio= n > Importance: High >=20 > On Mon, Sep 01, 2014 at 06:47:13AM +0000, Gonglei (Arei) wrote: > > > From: Gerd Hoffmann [mailto:kraxel@redhat.com] > > > Sent: Monday, September 01, 2014 2:43 PM > > > Subject: Re: [PATCH v6 02/27] bootindex: add del_boot_device_path > function > > > Importance: High > > > > > > Hi, > > > > > > > +static bool is_same_fw_dev_path(DeviceState *src, DeviceState *dst= ) > > > > +{ > > > > + bool ret =3D false; > > > > + char *devpath_src =3D qdev_get_fw_dev_path(src); > > > > + char *devpath_dst =3D qdev_get_fw_dev_path(dst); > > > > + > > > > + if (!strcmp(devpath_src, devpath_dst)) { > > > > + ret =3D true; > > > > + } > > > > + > > > > + g_free(devpath_src); > > > > + g_free(devpath_dst); > > > > + return ret; > > > > +} > > > > + > > > > +void del_boot_device_path(DeviceState *dev) > > > > +{ > > > > + FWBootEntry *i; > > > > + > > > > + assert(dev !=3D NULL); > > > > + > > > > + /* remove all entries of the assigned device */ > > > > + QTAILQ_FOREACH(i, &fw_boot_order, link) { > > > > + if (i->dev =3D=3D NULL) { > > > > + continue; > > > > + } > > > > + if ((i->dev =3D=3D dev || is_same_fw_dev_path(i->dev, dev)= )) { > > > > > > Why this is needed? Is there any case where i-->dev !=3D dev but > > > is_same_fw_dev_path() returns true? > > > > > Yes, it is needed. At present, the virito-net-pci device > > compliance with this situation. > > > > Please see the qom path about virtio-net-pci and virtio-net device: > > > > id: null, /machine/peripheral/nic1/virtio-backend > > id: nic1, /machine/peripheral/nic1 >=20 > And why exactly is the caller passing a different pointer to > del_boot_device_path()? Why not simply change the caller to pass the > same pointer to add_boot_device_path() and del_boot_device_path()? >=20 1. When we want to create a virtio-net device, we must use '-device virtio-= net-pci'. This device is a pci device, and virtio-net-device is its child: object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL)= ; 2. Both virtio-net-pci and virtio-net-device own bootindex property because= they include "DEFINE_NIC_PROPERTIES(VirtIONetPCI, vdev.nic_conf)". 3. Only virtio-net-device will call add_boot_device_path() in virtio_net_de= vice_realize(), which use its own pointer, but not virtio-net-pci's pointer: add_boot_device_path(n->nic_conf.bootindex, dev, "/ethernet-phy@0"); 4. When we hotplug the virtio-net-pci device, only pass virtio-net-pci's po= inter to=20 del_boot_device_path(). But virtio-net-pci !=3D virtio-net-device, so I add= a function named is_same_fw_dev_path() to handle this situation.=20 Best regards, -Gonglei