mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu_hotplug: move (almost) all qemuDomainDetach*() functions together
There were two outliers at the end of the file beyond the Vcpu functions. Signed-off-by: Laine Stump <laine@laine.org> ACKed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
036a4521f3
commit
5a8ffaec76
@ -6099,6 +6099,93 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuDomainDetachInputDevice(virDomainObjPtr vm,
|
||||||
|
virDomainInputDefPtr def,
|
||||||
|
bool async)
|
||||||
|
{
|
||||||
|
virDomainInputDefPtr input;
|
||||||
|
int ret = -1;
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
if ((idx = virDomainInputDefFind(vm->def, def)) < 0) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||||
|
_("matching input device not found"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
input = vm->def->inputs[idx];
|
||||||
|
|
||||||
|
switch ((virDomainInputBus) input->bus) {
|
||||||
|
case VIR_DOMAIN_INPUT_BUS_PS2:
|
||||||
|
case VIR_DOMAIN_INPUT_BUS_XEN:
|
||||||
|
case VIR_DOMAIN_INPUT_BUS_PARALLELS:
|
||||||
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
||||||
|
_("input device on bus '%s' cannot be detached"),
|
||||||
|
virDomainInputBusTypeToString(input->bus));
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_INPUT_BUS_LAST:
|
||||||
|
case VIR_DOMAIN_INPUT_BUS_USB:
|
||||||
|
case VIR_DOMAIN_INPUT_BUS_VIRTIO:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!async)
|
||||||
|
qemuDomainMarkDeviceForRemoval(vm, &input->info);
|
||||||
|
|
||||||
|
if (qemuDomainDeleteDevice(vm, input->info.alias) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (async) {
|
||||||
|
ret = 0;
|
||||||
|
} else {
|
||||||
|
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
|
||||||
|
ret = qemuDomainRemoveInputDevice(vm, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (!async)
|
||||||
|
qemuDomainResetDeviceRemoval(vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuDomainDetachVsockDevice(virDomainObjPtr vm,
|
||||||
|
virDomainVsockDefPtr dev,
|
||||||
|
bool async)
|
||||||
|
{
|
||||||
|
virDomainVsockDefPtr vsock = vm->def->vsock;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
|
||||||
|
if (!vsock ||
|
||||||
|
!virDomainVsockDefEquals(dev, vsock)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||||
|
_("matching vsock device not found"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!async)
|
||||||
|
qemuDomainMarkDeviceForRemoval(vm, &vsock->info);
|
||||||
|
|
||||||
|
if (qemuDomainDeleteDevice(vm, vsock->info.alias) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (async) {
|
||||||
|
ret = 0;
|
||||||
|
} else {
|
||||||
|
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
|
||||||
|
ret = qemuDomainRemoveVsockDevice(vm, vsock);
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (!async)
|
||||||
|
qemuDomainResetDeviceRemoval(vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainRemoveVcpu(virQEMUDriverPtr driver,
|
qemuDomainRemoveVcpu(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
@ -6752,90 +6839,3 @@ qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
|
|||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
qemuDomainDetachInputDevice(virDomainObjPtr vm,
|
|
||||||
virDomainInputDefPtr def,
|
|
||||||
bool async)
|
|
||||||
{
|
|
||||||
virDomainInputDefPtr input;
|
|
||||||
int ret = -1;
|
|
||||||
int idx;
|
|
||||||
|
|
||||||
if ((idx = virDomainInputDefFind(vm->def, def)) < 0) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
|
||||||
_("matching input device not found"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
input = vm->def->inputs[idx];
|
|
||||||
|
|
||||||
switch ((virDomainInputBus) input->bus) {
|
|
||||||
case VIR_DOMAIN_INPUT_BUS_PS2:
|
|
||||||
case VIR_DOMAIN_INPUT_BUS_XEN:
|
|
||||||
case VIR_DOMAIN_INPUT_BUS_PARALLELS:
|
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
|
||||||
_("input device on bus '%s' cannot be detached"),
|
|
||||||
virDomainInputBusTypeToString(input->bus));
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
case VIR_DOMAIN_INPUT_BUS_LAST:
|
|
||||||
case VIR_DOMAIN_INPUT_BUS_USB:
|
|
||||||
case VIR_DOMAIN_INPUT_BUS_VIRTIO:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!async)
|
|
||||||
qemuDomainMarkDeviceForRemoval(vm, &input->info);
|
|
||||||
|
|
||||||
if (qemuDomainDeleteDevice(vm, input->info.alias) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (async) {
|
|
||||||
ret = 0;
|
|
||||||
} else {
|
|
||||||
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
|
|
||||||
ret = qemuDomainRemoveInputDevice(vm, input);
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (!async)
|
|
||||||
qemuDomainResetDeviceRemoval(vm);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
qemuDomainDetachVsockDevice(virDomainObjPtr vm,
|
|
||||||
virDomainVsockDefPtr dev,
|
|
||||||
bool async)
|
|
||||||
{
|
|
||||||
virDomainVsockDefPtr vsock = vm->def->vsock;
|
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
|
|
||||||
if (!vsock ||
|
|
||||||
!virDomainVsockDefEquals(dev, vsock)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
|
||||||
_("matching vsock device not found"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!async)
|
|
||||||
qemuDomainMarkDeviceForRemoval(vm, &vsock->info);
|
|
||||||
|
|
||||||
if (qemuDomainDeleteDevice(vm, vsock->info.alias) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (async) {
|
|
||||||
ret = 0;
|
|
||||||
} else {
|
|
||||||
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
|
|
||||||
ret = qemuDomainRemoveVsockDevice(vm, vsock);
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (!async)
|
|
||||||
qemuDomainResetDeviceRemoval(vm);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user