提交 798461a1 编写于 作者: Z zhang bo 提交者: John Ferlan

qemu: update netdevs of the same mac addrs correctly

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: NZhou Yimin <zhouyimin@huawei.com>
Signed-off-by: NZhang Bo <oscar.zhangbo@huawei.com>
上级 785a8940
...@@ -2052,20 +2052,6 @@ int qemuDomainAttachHostDevice(virConnectPtr conn, ...@@ -2052,20 +2052,6 @@ int qemuDomainAttachHostDevice(virConnectPtr conn,
return -1; 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 static int
qemuDomainChangeNetBridge(virDomainObjPtr vm, qemuDomainChangeNetBridge(virDomainObjPtr vm,
virDomainNetDefPtr olddev, virDomainNetDefPtr olddev,
...@@ -2195,7 +2181,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, ...@@ -2195,7 +2181,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
virDomainDeviceDefPtr dev) virDomainDeviceDefPtr dev)
{ {
virDomainNetDefPtr newdev = dev->data.net; virDomainNetDefPtr newdev = dev->data.net;
virDomainNetDefPtr *devslot = qemuDomainFindNet(vm, newdev); virDomainNetDefPtr *devslot = NULL;
virDomainNetDefPtr olddev; virDomainNetDefPtr olddev;
int oldType, newType; int oldType, newType;
bool needReconnect = false; bool needReconnect = false;
...@@ -2205,8 +2191,13 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, ...@@ -2205,8 +2191,13 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
bool needReplaceDevDef = false; bool needReplaceDevDef = false;
bool needBandwidthSet = false; bool needBandwidthSet = false;
int ret = -1; 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", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("cannot find existing network device to modify")); _("cannot find existing network device to modify"));
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册