Re: [libvirt] [PATCH v4 03/15] qemu_tpm: Pass virDomainObjPtr instead of virDomainDefPtr

2018-11-15 Thread John Ferlan



On 11/14/18 7:44 AM, Michal Privoznik wrote:
> The TPM code currently accepts pointer to a domain definition.
> This is okay for now, but in near future the security driver APIs
> it calls will require domain object. Therefore, change the TPM
> code to accept the domain object pointer.
> 
> Signed-off-by: Michal Privoznik 
> ---
>  src/qemu/qemu_extdevice.c | 16 
>  src/qemu/qemu_extdevice.h |  4 ++--
>  src/qemu/qemu_process.c   |  6 +++---
>  src/qemu/qemu_security.c  | 14 +++---
>  src/qemu/qemu_security.h  |  4 ++--
>  src/qemu/qemu_tpm.c   | 24 
>  src/qemu/qemu_tpm.h   |  4 ++--
>  7 files changed, 36 insertions(+), 36 deletions(-)
> 

Reviewed-by: John Ferlan 

John

At one time I really hoped we could make the obj's transparent to
callers and force usage of virDomainObjGetDef, but I know that's a sheer
impossibility!

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v4 03/15] qemu_tpm: Pass virDomainObjPtr instead of virDomainDefPtr

2018-11-14 Thread Michal Privoznik
The TPM code currently accepts pointer to a domain definition.
This is okay for now, but in near future the security driver APIs
it calls will require domain object. Therefore, change the TPM
code to accept the domain object pointer.

Signed-off-by: Michal Privoznik 
---
 src/qemu/qemu_extdevice.c | 16 
 src/qemu/qemu_extdevice.h |  4 ++--
 src/qemu/qemu_process.c   |  6 +++---
 src/qemu/qemu_security.c  | 14 +++---
 src/qemu/qemu_security.h  |  4 ++--
 src/qemu/qemu_tpm.c   | 24 
 src/qemu/qemu_tpm.h   |  4 ++--
 7 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
index d982922470..27cf118c14 100644
--- a/src/qemu/qemu_extdevice.c
+++ b/src/qemu/qemu_extdevice.c
@@ -129,16 +129,16 @@ qemuExtDevicesCleanupHost(virQEMUDriverPtr driver,
 
 int
 qemuExtDevicesStart(virQEMUDriverPtr driver,
-virDomainDefPtr def,
+virDomainObjPtr vm,
 qemuDomainLogContextPtr logCtxt)
 {
 int ret = 0;
 
-if (qemuExtDevicesInitPaths(driver, def) < 0)
+if (qemuExtDevicesInitPaths(driver, vm->def) < 0)
 return -1;
 
-if (def->tpm)
-ret = qemuExtTPMStart(driver, def, logCtxt);
+if (vm->def->tpm)
+ret = qemuExtTPMStart(driver, vm, logCtxt);
 
 return ret;
 }
@@ -146,13 +146,13 @@ qemuExtDevicesStart(virQEMUDriverPtr driver,
 
 void
 qemuExtDevicesStop(virQEMUDriverPtr driver,
-   virDomainDefPtr def)
+   virDomainObjPtr vm)
 {
-if (qemuExtDevicesInitPaths(driver, def) < 0)
+if (qemuExtDevicesInitPaths(driver, vm->def) < 0)
 return;
 
-if (def->tpm)
-qemuExtTPMStop(driver, def);
+if (vm->def->tpm)
+qemuExtTPMStop(driver, vm);
 }
 
 
diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h
index c557778ddb..c26cdd50b2 100644
--- a/src/qemu/qemu_extdevice.h
+++ b/src/qemu/qemu_extdevice.h
@@ -41,13 +41,13 @@ void qemuExtDevicesCleanupHost(virQEMUDriverPtr driver,
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
 int qemuExtDevicesStart(virQEMUDriverPtr driver,
-virDomainDefPtr def,
+virDomainObjPtr vm,
 qemuDomainLogContextPtr logCtxt)
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
 ATTRIBUTE_RETURN_CHECK;
 
 void qemuExtDevicesStop(virQEMUDriverPtr driver,
-virDomainDefPtr def)
+virDomainObjPtr vm)
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
 bool qemuExtDevicesHasDevice(virDomainDefPtr def);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1850923914..2c9e605047 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6392,7 +6392,7 @@ qemuProcessLaunch(virConnectPtr conn,
 if (qemuProcessGenID(vm, flags) < 0)
 goto cleanup;
 
-if (qemuExtDevicesStart(driver, vm->def, logCtxt) < 0)
+if (qemuExtDevicesStart(driver, vm, logCtxt) < 0)
 goto cleanup;
 
 VIR_DEBUG("Building emulator command line");
@@ -6648,7 +6648,7 @@ qemuProcessLaunch(virConnectPtr conn,
 
  cleanup:
 if (ret < 0)
-qemuExtDevicesStop(driver, vm->def);
+qemuExtDevicesStop(driver, vm);
 qemuDomainSecretDestroy(vm);
 virCommandFree(cmd);
 virObjectUnref(logCtxt);
@@ -7079,7 +7079,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
 
 qemuDomainCleanupRun(driver, vm);
 
-qemuExtDevicesStop(driver, vm->def);
+qemuExtDevicesStop(driver, vm);
 
 /* Stop autodestroy in case guest is restarted */
 qemuProcessAutoDestroyRemove(driver, vm);
diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c
index 34921b4046..bf45abf93a 100644
--- a/src/qemu/qemu_security.c
+++ b/src/qemu/qemu_security.c
@@ -453,7 +453,7 @@ qemuSecurityRestoreChardevLabel(virQEMUDriverPtr driver,
  * qemuSecurityStartTPMEmulator:
  *
  * @driver: the QEMU driver
- * @def: the domain definition
+ * @vm: the domain object
  * @cmd: the command to run
  * @uid: the uid to run the emulator
  * @gid: the gid to run the emulator
@@ -469,7 +469,7 @@ qemuSecurityRestoreChardevLabel(virQEMUDriverPtr driver,
  */
 int
 qemuSecurityStartTPMEmulator(virQEMUDriverPtr driver,
- virDomainDefPtr def,
+ virDomainObjPtr vm,
  virCommandPtr cmd,
  uid_t uid,
  gid_t gid,
@@ -484,7 +484,7 @@ qemuSecurityStartTPMEmulator(virQEMUDriverPtr driver,
 transactionStarted = true;
 
 if (virSecurityManagerSetTPMLabels(driver->securityManager,
-   def) < 0) {
+   vm->def) < 0) {
 virSecurityManagerTransactionAbort(driver->securityManager);
 return -1;
 }
@@ -494,7 +494,7 @@ qemuSecurityStartTPMEmulator(virQEMUDriverPtr