From: Peter Krempa Date: Thu, 19 Jun 2025 13:58:44 +0000 (+0200) Subject: qemu: monitor: Introduce 'qemuMonitorSetUSBDiskAttached' X-Git-Tag: v11.5.0-rc1~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3f8f18e3891420eca95d49b879074446abcd5301;p=thirdparty%2Flibvirt.git qemu: monitor: Introduce 'qemuMonitorSetUSBDiskAttached' The helper sets the 'attached' property of the 'usb-bot' device to true, which will be used on the hotplug code path. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index d508f50ed6..95c88fd5e8 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2164,6 +2164,18 @@ qemuMonitorSetDBusVMStateIdList(qemuMonitor *mon, } +int +qemuMonitorSetUSBDiskAttached(qemuMonitor *mon, + const char *alias) +{ + QEMU_CHECK_MONITOR(mon); + + VIR_DEBUG("alias=%s", alias); + + return qemuMonitorJSONSetUSBDiskAttached(mon, alias); +} + + /** * qemuMonitorGetMigrationParams: * @mon: Pointer to the monitor object. diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 51b65b4019..6030c31598 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -768,6 +768,9 @@ int qemuMonitorSavePhysicalMemory(qemuMonitor *mon, int qemuMonitorSetDBusVMStateIdList(qemuMonitor *mon, GSList *list); +int qemuMonitorSetUSBDiskAttached(qemuMonitor *mon, + const char *alias); + int qemuMonitorGetMigrationParams(qemuMonitor *mon, virJSONValue **params); int qemuMonitorSetMigrationParams(qemuMonitor *mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a6fb2a2013..5297ffb027 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2086,6 +2086,26 @@ qemuMonitorJSONSetDBusVMStateIdList(qemuMonitor *mon, } +/** + * qemuMonitorJSONSetUSBDiskAttached: + * @mon: monitor object + * @alias: alias of usb disk to set + * + * Sets the 'attached' property of @alias to true. + */ +int +qemuMonitorJSONSetUSBDiskAttached(qemuMonitor *mon, + const char *alias) +{ + qemuMonitorJSONObjectProperty prop = { + .type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN, + .val.b = true, + }; + + return qemuMonitorJSONSetObjectProperty(mon, alias, "attached", &prop); +} + + /* qemuMonitorJSONQueryNamedBlockNodes: * @mon: Monitor pointer * diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 7f07e55e06..bd437f7938 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -757,6 +757,11 @@ qemuMonitorJSONSetDBusVMStateIdList(qemuMonitor *mon, const char *idstr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); +int +qemuMonitorJSONSetUSBDiskAttached(qemuMonitor *mon, + const char *alias) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + int qemuMonitorJSONGetCPUMigratable(qemuMonitor *mon, const char *cpuQOMPath,