Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_driver.c | 75 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f1f961c51c..e8c819bfb9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20448,6 +20448,80 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom,
}
+static void
+qemuDomainUpdateFibreChannelAppid(virDomainDef *def,
+ const char *appid)
+{
+ if (!def->resource) {
+ def->resource = g_new0(virDomainResourceDef, 1);
+ } else {
+ g_free(def->resource->appid);
+ }
+
+ def->resource->appid = g_strdup(appid);
+}
+
+
+static int
+qemuDomainSetFibreChannelAppid(virDomainPtr dom,
+ const char *appid,
+ unsigned int flags)
+{
+ virQEMUDriver *driver = dom->conn->privateData;
+ g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
+ virDomainObj *vm = NULL;
+ virDomainDef *def = NULL;
+ virDomainDef *persistentDef = NULL;
+ int ret = -1;
+
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG, -1);
+
+ if (appid && virDomainDefResourceAppidValidate(appid) < 0)
+ return -1;
+
+ if (!(vm = qemuDomainObjFromDomain(dom)))
+ goto cleanup;
+
+ if (virDomainSetFibreChannelAppidEnsureACL(dom->conn, vm->def) < 0)
+ goto cleanup;
+
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+ goto cleanup;
+
+ if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
+ goto endjob;
+
+ if (def) {
+ qemuDomainObjPrivate *priv = vm->privateData;
+
+ if (virCgroupSetFCAppid(priv->cgroup, appid) < 0)
+ goto endjob;
+
+ qemuDomainUpdateFibreChannelAppid(def, appid);
+
+ if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
+ goto endjob;
+ }
+
+ if (persistentDef) {
+ qemuDomainUpdateFibreChannelAppid(persistentDef, appid);
+
+ if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) <
0)
+ goto endjob;
+ }
+
+ ret = 0;
+
+ endjob:
+ qemuDomainObjEndJob(driver, vm);
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
+
static virHypervisorDriver qemuHypervisorDriver = {
.name = QEMU_DRIVER_NAME,
.connectURIProbe = qemuConnectURIProbe,
@@ -20691,6 +20765,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
.domainAuthorizedSSHKeysSet = qemuDomainAuthorizedSSHKeysSet, /* 6.10.0 */
.domainGetMessages = qemuDomainGetMessages, /* 7.1.0 */
.domainStartDirtyRateCalc = qemuDomainStartDirtyRateCalc, /* 7.2.0 */
+ .domainSetFibreChannelAppid = qemuDomainSetFibreChannelAppid, /* 7.7.0 */
};
--
2.31.1