Re: [libvirt] [PATCH] qemu: update netdevs of the same mac addrs correctly

2015-06-14 Thread zhang bo
On 2015/6/15 8:27, zhang bo wrote:

 ping 
 
 On 2015/6/8 16:25, zhang bo wrote:
 
 If a guest has multiple network devices with the same MAC address,
 when we online update the second device, libvirtd always updates
 the first one.

 commit def31e4c forgot to fix the online updating scenario. We need to
 use virDomainNetFindIdx() to find the correct network device.

 Signed-off-by: Zhou Yimin zhouyi...@huawei.com
 Signed-off-by: Zhang Bo oscar.zhan...@huawei.com
 ---
  src/qemu/qemu_hotplug.c | 23 +++
  1 file changed, 7 insertions(+), 16 deletions(-)

 
 
 


Sorry for mistakenly ping :) 
ACKed at https://www.redhat.com/archives/libvir-list/2015-June/msg00585.html

-- 
Oscar
oscar.zhan...@huawei.com  

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: update netdevs of the same mac addrs correctly

2015-06-14 Thread zhang bo
ping 

On 2015/6/8 16:25, zhang bo wrote:

 If a guest has multiple network devices with the same MAC address,
 when we online update the second device, libvirtd always updates
 the first one.
 
 commit def31e4c forgot to fix the online updating scenario. We need to
 use virDomainNetFindIdx() to find the correct network device.
 
 Signed-off-by: Zhou Yimin zhouyi...@huawei.com
 Signed-off-by: Zhang Bo oscar.zhan...@huawei.com
 ---
  src/qemu/qemu_hotplug.c | 23 +++
  1 file changed, 7 insertions(+), 16 deletions(-)
 
 diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
 index 94ebe35..d455bd6 100644
 --- a/src/qemu/qemu_hotplug.c
 +++ b/src/qemu/qemu_hotplug.c
 @@ -2052,20 +2052,6 @@ int qemuDomainAttachHostDevice(virConnectPtr conn,
  return -1;
  }
  
 -static virDomainNetDefPtr *qemuDomainFindNet(virDomainObjPtr vm,
 - virDomainNetDefPtr dev)
 -{
 -size_t i;
 -
 -for (i = 0; i  vm-def-nnets; i++) {
 -if (virMacAddrCmp(vm-def-nets[i]-mac, dev-mac) == 0)
 -return vm-def-nets[i];
 -}
 -
 -return NULL;
 -}
 -
 -
  static int
  qemuDomainChangeNetBridge(virDomainObjPtr vm,
virDomainNetDefPtr olddev,
 @@ -2195,7 +2181,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
  virDomainDeviceDefPtr dev)
  {
  virDomainNetDefPtr newdev = dev-data.net;
 -virDomainNetDefPtr *devslot = qemuDomainFindNet(vm, newdev);
 +virDomainNetDefPtr *devslot = NULL;
  virDomainNetDefPtr olddev;
  int oldType, newType;
  bool needReconnect = false;
 @@ -2205,8 +2191,13 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
  bool needReplaceDevDef = false;
  bool needBandwidthSet = false;
  int ret = -1;
 +int changeidx = -1;
 +
 +if ((changeidx = virDomainNetFindIdx(vm-def, newdev))  0)
 +goto cleanup;
 +devslot = vm-def-nets[changeidx];
  
 -if (!devslot || !(olddev = *devslot)) {
 +if (!(olddev = *devslot)) {
  virReportError(VIR_ERR_OPERATION_FAILED, %s,
 _(cannot find existing network device to modify));
  goto cleanup;



-- 
Oscar
oscar.zhan...@huawei.com  

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list