Signed-off-by: Luke Yue <lukedyue(a)gmail.com>
---
src/conf/domain_conf.c | 12 ++++++++++++
src/conf/domain_conf.h | 2 ++
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 3 ++-
4 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d66496c9b7..c8c2f13f8b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16734,6 +16734,18 @@ virDomainInputDefFind(const virDomainDef *def,
}
+virDomainInputDef *
+virDomainInputDefRemove(virDomainDef *def,
+ size_t idx)
+{
+ virDomainInputDef *ret = def->inputs[idx];
+
+ VIR_DELETE_ELEMENT(def->inputs, idx, def->ninputs);
+
+ return ret;
+}
+
+
bool
virDomainVsockDefEquals(const virDomainVsockDef *a,
const virDomainVsockDef *b)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index b2922e8cff..c0167eee85 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3888,6 +3888,8 @@ virDomainShmemDef *virDomainShmemDefRemove(virDomainDef *def, size_t
idx)
ssize_t virDomainInputDefFind(const virDomainDef *def,
const virDomainInputDef *input)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
+virDomainInputDef *virDomainInputDefRemove(virDomainDef *def, size_t idx)
+ ATTRIBUTE_NONNULL(1);
bool virDomainVsockDefEquals(const virDomainVsockDef *a,
const virDomainVsockDef *b)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 398cc79ee3..abdc8eaef7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -480,6 +480,7 @@ virDomainInputBusTypeToString;
virDomainInputDefFind;
virDomainInputDefFree;
virDomainInputDefGetPath;
+virDomainInputDefRemove;
virDomainInputSourceGrabToggleTypeFromString;
virDomainInputSourceGrabToggleTypeToString;
virDomainInputSourceGrabTypeFromString;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 698f57f00e..864ea10685 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7502,7 +7502,8 @@ qemuDomainDetachDeviceConfig(virDomainDef *vmdef,
_("matching input device not found"));
return -1;
}
- VIR_DELETE_ELEMENT(vmdef->inputs, idx, vmdef->ninputs);
+
+ virDomainInputDefFree(virDomainInputDefRemove(vmdef, idx));
break;
case VIR_DOMAIN_DEVICE_VSOCK:
--
2.35.1