mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
Fix list updating after disk/network/hostdev hot-unplug
The current code makes a poor effort at updating the device arrays after hot-unplug. Fix that and combine the two code paths into one. * src/qemu_driver.c: fix list updating in qemudDomainDetachNetDevice(), qemudDomainDetachPciDiskDevice() and qemudDomainDetachHostPciDevice()
This commit is contained in:
parent
331e1fcbee
commit
0b973381dc
@ -5704,18 +5704,17 @@ try_command:
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm->def->ndisks > 1) {
|
if (i != --vm->def->ndisks)
|
||||||
vm->def->disks[i] = vm->def->disks[--vm->def->ndisks];
|
memmove(&vm->def->disks[i],
|
||||||
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks) < 0) {
|
&vm->def->disks[i+1],
|
||||||
virReportOOMError(conn);
|
sizeof(*vm->def->disks) * (vm->def->ndisks-i));
|
||||||
goto cleanup;
|
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks) < 0) {
|
||||||
}
|
virReportOOMError(conn);
|
||||||
qsort(vm->def->disks, vm->def->ndisks, sizeof(*vm->def->disks),
|
goto cleanup;
|
||||||
virDomainDiskQSort);
|
|
||||||
} else {
|
|
||||||
VIR_FREE(vm->def->disks[0]);
|
|
||||||
vm->def->ndisks = 0;
|
|
||||||
}
|
}
|
||||||
|
qsort(vm->def->disks, vm->def->ndisks, sizeof(*vm->def->disks),
|
||||||
|
virDomainDiskQSort);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -5803,16 +5802,15 @@ qemudDomainDetachNetDevice(virConnectPtr conn,
|
|||||||
|
|
||||||
DEBUG("%s: host_net_remove reply: %s", vm->def->name, reply);
|
DEBUG("%s: host_net_remove reply: %s", vm->def->name, reply);
|
||||||
|
|
||||||
if (vm->def->nnets > 1) {
|
if (i != --vm->def->nnets)
|
||||||
vm->def->nets[i] = vm->def->nets[--vm->def->nnets];
|
memmove(&vm->def->nets[i],
|
||||||
if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets) < 0) {
|
&vm->def->nets[i+1],
|
||||||
virReportOOMError(conn);
|
sizeof(*vm->def->nets) * (vm->def->nnets-i));
|
||||||
goto cleanup;
|
if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets) < 0) {
|
||||||
}
|
virReportOOMError(conn);
|
||||||
} else {
|
goto cleanup;
|
||||||
VIR_FREE(vm->def->nets[0]);
|
|
||||||
vm->def->nnets = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -5908,15 +5906,13 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn,
|
|||||||
pciFreeDevice(conn, pci);
|
pciFreeDevice(conn, pci);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm->def->nhostdevs > 1) {
|
if (i != --vm->def->nhostdevs)
|
||||||
vm->def->hostdevs[i] = vm->def->hostdevs[--vm->def->nhostdevs];
|
memmove(&vm->def->hostdevs[i],
|
||||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs) < 0) {
|
&vm->def->hostdevs[i+1],
|
||||||
virReportOOMError(conn);
|
sizeof(*vm->def->hostdevs) * (vm->def->nhostdevs-i));
|
||||||
ret = -1;
|
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs) < 0) {
|
||||||
}
|
virReportOOMError(conn);
|
||||||
} else {
|
ret = -1;
|
||||||
VIR_FREE(vm->def->hostdevs[0]);
|
|
||||||
vm->def->nhostdevs = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user