提交 f3e098f3 编写于 作者: D Daniel P. Berrange

Fix network hotplug to use device_add in QEMU

The initial boot of VMs uses -device for NICs where available. The
corresponding monitor command is device_add, but the network hotplug
code was still using device_del by mistake.

* src/qemu/qemu_driver.c: Use device_add for NIC hotplug where
  available
上级 9417eb03
...@@ -7112,10 +7112,21 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn, ...@@ -7112,10 +7112,21 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
close(tapfd); close(tapfd);
tapfd = -1; tapfd = -1;
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
if (!(nicstr = qemuBuildNicDevStr(net, vlan)))
goto try_remove;
} else {
if (!(nicstr = qemuBuildNicStr(net, NULL, vlan))) if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
goto try_remove; goto try_remove;
}
qemuDomainObjEnterMonitorWithDriver(driver, vm); qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
if (qemuMonitorAddDevice(priv->mon, nicstr) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm);
goto try_remove;
}
} else {
if (qemuMonitorAddPCINetwork(priv->mon, nicstr, if (qemuMonitorAddPCINetwork(priv->mon, nicstr,
&guestAddr) < 0) { &guestAddr) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm); qemuDomainObjExitMonitorWithDriver(driver, vm);
...@@ -7123,6 +7134,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn, ...@@ -7123,6 +7134,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
} }
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
memcpy(&net->info.addr.pci, &guestAddr, sizeof(guestAddr)); memcpy(&net->info.addr.pci, &guestAddr, sizeof(guestAddr));
}
qemuDomainObjExitMonitorWithDriver(driver, vm); qemuDomainObjExitMonitorWithDriver(driver, vm);
ret = 0; ret = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册