Message ID | 0d43c27193a39be9ef207e8b7f476d30e883e53c.1566576129.git.crobinso@redhat.com |
---|---|
State | New |
Headers | show |
Series | Add vhost-user-gpu support | expand |
On Fri, Aug 23, 2019 at 12:21:54PM -0400, Cole Robinson wrote: >From: Marc-André Lureau <marcandre.lureau@redhat.com> > >See function documentation. Used in a following patch. > >Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> >Signed-off-by: Cole Robinson <crobinso@redhat.com> >--- > src/qemu/qemu_security.c | 47 ++++++++++++++++++++++++++++++++++++++++ > src/qemu/qemu_security.h | 6 +++++ > 2 files changed, 53 insertions(+) > >diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c >index 3cd6d9bd3d..86b06594f6 100644 >--- a/src/qemu/qemu_security.c >+++ b/src/qemu/qemu_security.c >@@ -433,6 +433,53 @@ qemuSecurityRestoreChardevLabel(virQEMUDriverPtr driver, > } > > >+/* >+ * qemuSecurityStartVhostUserGPU: >+ * >+ * @driver: the QEMU driver >+ * @vm: the domain object >+ * @cmd: the command to run >+ * @existstatus: pointer to int returning exit status of process >+ * @cmdret: pointer to int returning result of virCommandRun >+ * >+ * Start the vhost-user-gpu process with approriate labels. >+ * This function returns -1 on security setup error, 0 if all the >+ * setup was done properly. In case the virCommand failed to run >+ * 0 is returned but cmdret is set appropriately with the process >+ * exitstatus also set. >+ */ >+int >+qemuSecurityStartVhostUserGPU(virQEMUDriverPtr driver, >+ virDomainObjPtr vm, >+ virCommandPtr cmd, >+ int *exitstatus, >+ int *cmdret) >+{ >+ int ret = -1; >+ >+ if (virSecurityManagerSetChildProcessLabel(driver->securityManager, >+ vm->def, cmd) < 0) >+ goto cleanup; >+ >+ if (virSecurityManagerPreFork(driver->securityManager) < 0) >+ goto cleanup; >+ >+ ret = 0; >+ >+ *cmdret = virCommandRun(cmd, exitstatus); >+ >+ virSecurityManagerPostFork(driver->securityManager); >+ >+ if (*cmdret < 0) >+ goto cleanup; >+ >+ return 0; >+ >+ cleanup: >+ return ret; The cleanup section is pointless here. Jano -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c index 3cd6d9bd3d..86b06594f6 100644 --- a/src/qemu/qemu_security.c +++ b/src/qemu/qemu_security.c @@ -433,6 +433,53 @@ qemuSecurityRestoreChardevLabel(virQEMUDriverPtr driver, } +/* + * qemuSecurityStartVhostUserGPU: + * + * @driver: the QEMU driver + * @vm: the domain object + * @cmd: the command to run + * @existstatus: pointer to int returning exit status of process + * @cmdret: pointer to int returning result of virCommandRun + * + * Start the vhost-user-gpu process with approriate labels. + * This function returns -1 on security setup error, 0 if all the + * setup was done properly. In case the virCommand failed to run + * 0 is returned but cmdret is set appropriately with the process + * exitstatus also set. + */ +int +qemuSecurityStartVhostUserGPU(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virCommandPtr cmd, + int *exitstatus, + int *cmdret) +{ + int ret = -1; + + if (virSecurityManagerSetChildProcessLabel(driver->securityManager, + vm->def, cmd) < 0) + goto cleanup; + + if (virSecurityManagerPreFork(driver->securityManager) < 0) + goto cleanup; + + ret = 0; + + *cmdret = virCommandRun(cmd, exitstatus); + + virSecurityManagerPostFork(driver->securityManager); + + if (*cmdret < 0) + goto cleanup; + + return 0; + + cleanup: + return ret; +} + + /* * qemuSecurityStartTPMEmulator: * diff --git a/src/qemu/qemu_security.h b/src/qemu/qemu_security.h index 68e377f418..a48ed8ec78 100644 --- a/src/qemu/qemu_security.h +++ b/src/qemu/qemu_security.h @@ -77,6 +77,12 @@ int qemuSecurityRestoreChardevLabel(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainChrDefPtr chr); +int qemuSecurityStartVhostUserGPU(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virCommandPtr cmd, + int *exitstatus, + int *cmdret); + int qemuSecurityStartTPMEmulator(virQEMUDriverPtr driver, virDomainObjPtr vm, virCommandPtr cmd,