From: Peter Krempa Date: Tue, 26 Apr 2016 12:04:49 +0000 (+0200) Subject: qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainAttachNetDevice X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0a2cfaf3b1dedf3ebad20494b6ad3a67a8aad222;p=libvirt.git qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainAttachNetDevice --- diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index c1536bd375..61cd25c7b6 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -814,7 +814,6 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, char *netstr = NULL; virNetDevVPortProfilePtr vport = NULL; int ret = -1; - virDevicePCIAddress guestAddr; int vlan; bool releaseaddr = false; bool iface_connected = false; @@ -949,10 +948,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, goto cleanup; } - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { - if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0) - goto cleanup; - } + if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0) + goto cleanup; if (qemuDomainMachineIsS390CCW(vm->def) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { @@ -964,15 +961,13 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtio-s390 net device cannot be hotplugged.")); goto cleanup; - } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) && - virDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0) { + } else if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0) { goto cleanup; } releaseaddr = true; - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { vlan = -1; } else { vlan = qemuDomainNetVLAN(net); @@ -998,8 +993,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, goto cleanup; } - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { if (!(netstr = qemuBuildHostNetStr(net, driver, ',', -1, tapfdName, tapfdSize, @@ -1014,8 +1008,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, } qemuDomainObjEnterMonitor(driver, vm); - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { if (qemuMonitorAddNetdev(priv->mon, netstr, tapfd, tapfdName, tapfdSize, vhostfd, vhostfdName, vhostfdSize) < 0) { @@ -1040,32 +1033,15 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, for (i = 0; i < vhostfdSize; i++) VIR_FORCE_CLOSE(vhostfd[i]); - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { - if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0, - vhostfdSize, priv->qemuCaps))) - goto try_remove; - } else { - if (!(nicstr = qemuBuildNicStr(net, NULL, vlan))) - goto try_remove; - } + if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0, + vhostfdSize, priv->qemuCaps))) + goto try_remove; qemuDomainObjEnterMonitor(driver, vm); - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { - if (qemuMonitorAddDevice(priv->mon, nicstr) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); - virDomainAuditNet(vm, NULL, net, "attach", false); - goto try_remove; - } - } else { - guestAddr = net->info.addr.pci; - if (qemuMonitorAddPCINetwork(priv->mon, nicstr, - &guestAddr) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); - virDomainAuditNet(vm, NULL, net, "attach", false); - goto try_remove; - } - net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; - memcpy(&net->info.addr.pci, &guestAddr, sizeof(guestAddr)); + if (qemuMonitorAddDevice(priv->mon, nicstr) < 0) { + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + virDomainAuditNet(vm, NULL, net, "attach", false); + goto try_remove; } if (qemuDomainObjExitMonitor(driver, vm) < 0) goto cleanup; @@ -1160,8 +1136,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, goto cleanup; if (vlan < 0) { - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { char *netdev_name; if (virAsprintf(&netdev_name, "host%s", net->info.alias) < 0) goto cleanup;