mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
qemu: allow cold unplugging of input devices
https://bugzilla.redhat.com/show_bug.cgi?id=1379603
This commit is contained in:
parent
ba589d88bc
commit
513a8d4588
@ -16612,6 +16612,43 @@ virDomainShmemDefRemove(virDomainDefPtr def,
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
virDomainInputDefEquals(const virDomainInputDef *a,
|
||||
const virDomainInputDef *b)
|
||||
{
|
||||
if (a->type != b->type)
|
||||
return false;
|
||||
|
||||
if (a->bus != b->bus)
|
||||
return false;
|
||||
|
||||
if (a->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH &&
|
||||
STRNEQ_NULLABLE(a->source.evdev, b->source.evdev))
|
||||
return false;
|
||||
|
||||
if (a->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
|
||||
!virDomainDeviceInfoAddressIsEqual(&a->info, &b->info))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
virDomainInputDefFind(const virDomainDef *def,
|
||||
const virDomainInputDef *input)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < def->ninputs; i++) {
|
||||
if (virDomainInputDefEquals(input, def->inputs[i]))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
virDomainDefGetDefaultEmulator(virDomainDefPtr def,
|
||||
virCapsPtr caps)
|
||||
|
@ -3184,6 +3184,9 @@ ssize_t virDomainShmemDefFind(virDomainDefPtr def, virDomainShmemDefPtr shmem)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
|
||||
virDomainShmemDefPtr virDomainShmemDefRemove(virDomainDefPtr def, size_t idx)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
ssize_t virDomainInputDefFind(const virDomainDef *def,
|
||||
const virDomainInputDef *input)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
|
||||
|
||||
VIR_ENUM_DECL(virDomainTaint)
|
||||
VIR_ENUM_DECL(virDomainVirt)
|
||||
|
@ -386,6 +386,7 @@ virDomainHubTypeFromString;
|
||||
virDomainHubTypeToString;
|
||||
virDomainHypervTypeFromString;
|
||||
virDomainHypervTypeToString;
|
||||
virDomainInputDefFind;
|
||||
virDomainInputDefFree;
|
||||
virDomainIOMMUModelTypeFromString;
|
||||
virDomainIOMMUModelTypeToString;
|
||||
|
@ -8239,6 +8239,14 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_INPUT:
|
||||
if ((idx = virDomainInputDefFind(vmdef, dev->data.input)) < 0) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||
_("matching input device not found"));
|
||||
return -1;
|
||||
}
|
||||
VIR_DELETE_ELEMENT(vmdef->inputs, idx, vmdef->ninputs);
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_SOUND:
|
||||
case VIR_DOMAIN_DEVICE_VIDEO:
|
||||
case VIR_DOMAIN_DEVICE_GRAPHICS:
|
||||
|
Loading…
Reference in New Issue
Block a user