Received: from eggs.gnu.org ([2001:4830:134:3::10]:56354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfRoU-000086-3x for qemu-devel@nongnu.org; Thu, 01 Sep 2016 09:13:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfRoO-0008SF-1q for qemu-devel@nongnu.org; Thu, 01 Sep 2016 09:13:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfRoN-0008Rb-Qe for qemu-devel@nongnu.org; Thu, 01 Sep 2016 09:13:43 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7951E389ACA for ; Thu, 1 Sep 2016 13:13:41 +0000 (UTC) Received: from [10.36.116.60] (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u81DDdSi030169 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 1 Sep 2016 09:13:41 -0400 References: <1472717449-12501-1-git-send-email-lvivier@redhat.com> From: Thomas Huth Message-ID: <0ffc0106-51f4-e80e-1883-c536ab504cef@redhat.com> Date: Thu, 1 Sep 2016 15:13:39 +0200 MIME-Version: 1.0 In-Reply-To: <1472717449-12501-1-git-send-email-lvivier@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] spapr: implement H_CHANGE_LOGICAL_LAN_MAC h_call List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On 01.09.2016 10:10, Laurent Vivier wrote: > Since kernel v4.0, linux uses H_CHANGE_LOGICAL_LAN_MAC to change lively > the MAC address of an ibmveth interface. >=20 > As QEMU doesn't implement this h_call, we can't change anymore the > MAC address of an spapr-vlan interface. >=20 > Signed-off-by: Laurent Vivier > --- > hw/net/spapr_llan.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) >=20 > diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c > index b273eda..4bb95a5 100644 > --- a/hw/net/spapr_llan.c > +++ b/hw/net/spapr_llan.c > @@ -106,6 +106,7 @@ typedef struct VIOsPAPRVLANDevice { > VIOsPAPRDevice sdev; > NICConf nicconf; > NICState *nic; > + MACAddr perm_mac; > bool isopen; > hwaddr buf_list; > uint32_t add_buf_ptr, use_buf_ptr, rx_bufs; > @@ -316,6 +317,10 @@ static void spapr_vlan_reset(VIOsPAPRDevice *sdev) > spapr_vlan_reset_rx_pool(dev->rx_pool[i]); > } > } > + > + memcpy(&dev->nicconf.macaddr.a, &dev->perm_mac.a, > + sizeof(dev->nicconf.macaddr.a)); > + qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.ma= caddr.a); > } > =20 > static void spapr_vlan_realize(VIOsPAPRDevice *sdev, Error **errp) > @@ -324,6 +329,8 @@ static void spapr_vlan_realize(VIOsPAPRDevice *sdev= , Error **errp) > =20 > qemu_macaddr_default_if_unset(&dev->nicconf.macaddr); > =20 > + memcpy(&dev->perm_mac.a, &dev->nicconf.macaddr.a, sizeof(dev->perm= _mac.a)); > + > dev->nic =3D qemu_new_nic(&net_spapr_vlan_info, &dev->nicconf, > object_get_typename(OBJECT(sdev)), sdev->q= dev.id, dev); > qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.ma= caddr.a); > @@ -756,6 +763,27 @@ static target_ulong h_multicast_ctrl(PowerPCCPU *c= pu, sPAPRMachineState *spapr, > return H_SUCCESS; > } > =20 > +static target_ulong h_change_logical_lan_mac(PowerPCCPU *cpu, > + sPAPRMachineState *spapr, > + target_ulong opcode, > + target_ulong *args) > +{ > + target_ulong reg =3D args[0]; > + target_ulong macaddr =3D args[1]; > + VIOsPAPRDevice *sdev =3D spapr_vio_find_by_reg(spapr->vio_bus, reg= ); > + VIOsPAPRVLANDevice *dev =3D VIO_SPAPR_VLAN_DEVICE(sdev); > + int i; As an additional sanity check, you could test whether the MAC address is a proper unicast address, i.e. that the broadcast bit is not set. > + for (i =3D 0; i < ETH_ALEN; i++) { > + dev->nicconf.macaddr.a[ETH_ALEN - i - 1] =3D macaddr & 0xff; > + macaddr >>=3D 8; > + } > + > + qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.ma= caddr.a); > + > + return H_SUCCESS; > +} > + > static Property spapr_vlan_properties[] =3D { > DEFINE_SPAPR_PROPERTIES(VIOsPAPRVLANDevice, sdev), > DEFINE_NIC_PROPERTIES(VIOsPAPRVLANDevice, nicconf), > @@ -854,6 +882,8 @@ static void spapr_vlan_register_types(void) > spapr_register_hypercall(H_ADD_LOGICAL_LAN_BUFFER, > h_add_logical_lan_buffer); > spapr_register_hypercall(H_MULTICAST_CTRL, h_multicast_ctrl); > + spapr_register_hypercall(H_CHANGE_LOGICAL_LAN_MAC, > + h_change_logical_lan_mac); > type_register_static(&spapr_vlan_info); > } Patch looks basically fine to me. One more thought though: What about migration? Don't we need to migrate the perm_mac array, too, or is this already covered by the dev->nicconf.macaddr array? Thomas