void qemuSecurityRestoreAllLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, bool migrated) { struct qemuSecuritySetRestoreAllLabelData data; memset(&data, 0, sizeof(data)); data.driver = driver; data.vm = vm; data.migrated = migrated; if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) { if (virSecurityManagerPreFork(driver->securityManager) < 0) return; virProcessRunInMountNamespace(vm->pid, qemuSecuritySetRestoreAllLabelHelper, &data); virSecurityManagerPostFork(driver->securityManager); } else { virSecurityManagerRestoreAllLabel(driver->securityManager, vm->def, migrated); } }
int qemuSecuritySetAllLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, const char *stdin_path) { struct qemuSecuritySetRestoreAllLabelData data; memset(&data, 0, sizeof(data)); data.set = true; data.driver = driver; data.vm = vm; data.stdin_path = stdin_path; if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) { if (virSecurityManagerPreFork(driver->securityManager) < 0) return -1; if (virProcessRunInMountNamespace(vm->pid, qemuSecuritySetRestoreAllLabelHelper, &data) < 0) { virSecurityManagerPostFork(driver->securityManager); return -1; } virSecurityManagerPostFork(driver->securityManager); } else { if (virSecurityManagerSetAllLabel(driver->securityManager, vm->def, stdin_path) < 0) return -1; } return 0; }
int qemuSecurityRestoreSavedStateLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, const char *savefile) { pid_t pid = -1; int ret = -1; if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) pid = vm->pid; if (virSecurityManagerTransactionStart(driver->securityManager) < 0) goto cleanup; if (virSecurityManagerRestoreSavedStateLabel(driver->securityManager, vm->def, savefile) < 0) goto cleanup; if (virSecurityManagerTransactionCommit(driver->securityManager, pid) < 0) goto cleanup; ret = 0; cleanup: virSecurityManagerTransactionAbort(driver->securityManager); return ret; }
int qemuSecuritySetDiskLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDiskDefPtr disk) { pid_t pid = -1; int ret = -1; if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) pid = vm->pid; if (virSecurityManagerTransactionStart(driver->securityManager) < 0) goto cleanup; if (virSecurityManagerSetDiskLabel(driver->securityManager, vm->def, disk) < 0) goto cleanup; if (virSecurityManagerTransactionCommit(driver->securityManager, pid) < 0) goto cleanup; ret = 0; cleanup: virSecurityManagerTransactionAbort(driver->securityManager); return ret; }
int qemuSecurityDomainSetPathLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, const char *path, bool allowSubtree) { pid_t pid = -1; int ret = -1; if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) pid = vm->pid; if (virSecurityManagerTransactionStart(driver->securityManager) < 0) goto cleanup; if (virSecurityManagerDomainSetPathLabel(driver->securityManager, vm->def, path, allowSubtree) < 0) goto cleanup; if (virSecurityManagerTransactionCommit(driver->securityManager, pid) < 0) goto cleanup; ret = 0; cleanup: virSecurityManagerTransactionAbort(driver->securityManager); return ret; }
int qemuSecurityRestoreChardevLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainChrDefPtr chr) { int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; pid_t pid = -1; if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) pid = vm->pid; if (virSecurityManagerTransactionStart(driver->securityManager) < 0) goto cleanup; if (virSecurityManagerRestoreChardevLabel(driver->securityManager, vm->def, chr->source, priv->chardevStdioLogd) < 0) goto cleanup; if (virSecurityManagerTransactionCommit(driver->securityManager, pid) < 0) goto cleanup; ret = 0; cleanup: virSecurityManagerTransactionAbort(driver->securityManager); return ret; }
int qemuSecurityRestoreInputLabel(virDomainObjPtr vm, virDomainInputDefPtr input) { qemuDomainObjPrivatePtr priv = vm->privateData; virQEMUDriverPtr driver = priv->driver; pid_t pid = -1; int ret = -1; if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) pid = vm->pid; if (virSecurityManagerTransactionStart(driver->securityManager) < 0) goto cleanup; if (virSecurityManagerRestoreInputLabel(driver->securityManager, vm->def, input) < 0) goto cleanup; if (virSecurityManagerTransactionCommit(driver->securityManager, pid) < 0) goto cleanup; ret = 0; cleanup: virSecurityManagerTransactionAbort(driver->securityManager); return ret; }
int qemuSecuritySetAllLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, const char *stdin_path) { int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; pid_t pid = -1; if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) pid = vm->pid; if (virSecurityManagerTransactionStart(driver->securityManager) < 0) goto cleanup; if (virSecurityManagerSetAllLabel(driver->securityManager, vm->def, stdin_path, priv->chardevStdioLogd) < 0) goto cleanup; if (virSecurityManagerTransactionCommit(driver->securityManager, pid) < 0) goto cleanup; ret = 0; cleanup: virSecurityManagerTransactionAbort(driver->securityManager); return ret; }
int qemuSecurityRestoreHostdevLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev) { pid_t pid = -1; int ret = -1; if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) pid = vm->pid; if (virSecurityManagerTransactionStart(driver->securityManager) < 0) goto cleanup; if (virSecurityManagerRestoreHostdevLabel(driver->securityManager, vm->def, hostdev, NULL) < 0) goto cleanup; if (virSecurityManagerTransactionCommit(driver->securityManager, pid) < 0) goto cleanup; ret = 0; cleanup: virSecurityManagerTransactionAbort(driver->securityManager); return ret; }
int qemuSecurityRestoreDiskLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDiskDefPtr disk) { if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) { /* Already handled by namespace code. */ return 0; } return virSecurityManagerRestoreDiskLabel(driver->securityManager, vm->def, disk); }
int qemuSecuritySetHostdevLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev) { if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) { /* Already handled by namespace code. */ return 0; } return virSecurityManagerSetHostdevLabel(driver->securityManager, vm->def, hostdev, NULL); }