]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: monitor: Introduce 'qemuMonitorSetUSBDiskAttached'
authorPeter Krempa <pkrempa@redhat.com>
Thu, 19 Jun 2025 13:58:44 +0000 (15:58 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 24 Jun 2025 14:29:12 +0000 (16:29 +0200)
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 <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h

index d508f50ed625482f9a82fd584091320bcb121994..95c88fd5e8fa933f1b1d5c065629f17f3786fa8c 100644 (file)
@@ -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.
index 51b65b40196ea93235aa5f0dd1917ed646f4b0d6..6030c31598ca45f3db0db23b2f24ce7a52a70fb9 100644 (file)
@@ -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,
index a6fb2a201373e5f10534d9dbc369671c98c1b9e0..5297ffb0270581677a299ebb22470ed79d2652cc 100644 (file)
@@ -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
  *
index 7f07e55e06be544466df27f30d386abf9c25aac9..bd437f7938b946bcd0b99277340ada84e2c3e9f0 100644 (file)
@@ -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,