]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
ch: implement disk attach in public API
authorStefan Kober <stefan.kober@cyberus-technology.de>
Thu, 4 Sep 2025 12:10:30 +0000 (14:10 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 8 Sep 2025 14:40:08 +0000 (16:40 +0200)
On-behalf-of: SAP stefan.kober@sap.com
Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/ch/ch_driver.c

index cf6874f22e1549c12d656ad0db65dc58c595e238..4f4783efb164ec45a89f097ba22c48ed96399bc5 100644 (file)
@@ -25,6 +25,7 @@
 #include "ch_conf.h"
 #include "ch_domain.h"
 #include "ch_driver.h"
+#include "ch_hotplug.h"
 #include "ch_monitor.h"
 #include "ch_process.h"
 #include "domain_cgroup.h"
@@ -2344,6 +2345,47 @@ chDomainInterfaceAddresses(virDomain *dom,
     return ret;
 }
 
+static int
+chDomainAttachDeviceFlags(virDomainPtr dom,
+                          const char *xml,
+                          unsigned int flags)
+{
+    virCHDriver *driver = dom->conn->privateData;
+    virDomainObj *vm = NULL;
+    int ret = -1;
+
+    if (!(vm = virCHDomainObjFromDomain(dom)))
+        goto cleanup;
+
+    if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
+        goto cleanup;
+
+    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+        goto cleanup;
+
+    if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
+        goto endjob;
+
+    if (chDomainAttachDeviceLiveAndUpdateConfig(vm, driver, xml, flags) < 0) {
+        goto endjob;
+    }
+
+    ret = 0;
+
+ endjob:
+    virDomainObjEndJob(vm);
+
+ cleanup:
+    virDomainObjEndAPI(&vm);
+    return ret;
+}
+
+static int
+chDomainAttachDevice(virDomainPtr dom,
+                     const char *xml)
+{
+    return chDomainAttachDeviceFlags(dom, xml, VIR_DOMAIN_AFFECT_LIVE);
+}
 
 /* Function Tables */
 static virHypervisorDriver chHypervisorDriver = {
@@ -2406,6 +2448,8 @@ static virHypervisorDriver chHypervisorDriver = {
     .connectDomainEventRegisterAny = chConnectDomainEventRegisterAny,       /* 10.10.0 */
     .connectDomainEventDeregisterAny = chConnectDomainEventDeregisterAny,   /* 10.10.0 */
     .domainInterfaceAddresses = chDomainInterfaceAddresses, /* 11.0.0 */
+    .domainAttachDevice = chDomainAttachDevice, /* 11.8.0 */
+    .domainAttachDeviceFlags = chDomainAttachDeviceFlags, /* 11.8.0 */
 };
 
 static virConnectDriver chConnectDriver = {