[libvirt] [PATCH v2 1/3] vbox: Remove old unflexible macros

2017-10-24 Thread Dawid Zamirski
The VBOX_SESSION_OPEN/CLOSE macros are only called in
_vboxDomainSnapshotRestore and they are unflexible because:

* assume the caller will have variable named "data"
* can only create Write lock type

As per above, it's not that hard to simply use the VBOX API directly.
---
 src/vbox/vbox_tmpl.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index dffeabde0..ce2ee9037 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -144,12 +144,6 @@ if (strUtf16) {\
   (unsigned)(iid)->m3[7]);\
 }\
 
-#define VBOX_SESSION_OPEN(/* unused */ iid_value, /* in */ machine) \
-machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Write)
-
-#define VBOX_SESSION_CLOSE() \
-data->vboxSession->vtbl->UnlockMachine(data->vboxSession)
-
 #define VBOX_IID_INITIALIZER { NULL, true }
 
 static void
@@ -323,7 +317,7 @@ _vboxDomainSnapshotRestore(virDomainPtr dom,
 goto cleanup;
 }
 
-rc = VBOX_SESSION_OPEN(domiid.value, machine);
+rc = machine->vtbl->LockMachine(machine, data->vboxSession, 
LockType_Write);
 #if VBOX_API_VERSION < 500
 if (NS_SUCCEEDED(rc))
 rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
@@ -368,7 +362,7 @@ _vboxDomainSnapshotRestore(virDomainPtr dom,
 #if VBOX_API_VERSION < 500
 VBOX_RELEASE(console);
 #endif /*VBOX_API_VERSION < 500*/
-VBOX_SESSION_CLOSE();
+data->vboxSession->vtbl->UnlockMachine(data->vboxSession);
 vboxIIDUnalloc(&domiid);
 return ret;
 }
-- 
2.14.2

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


Re: [libvirt] [PATCH v2 1/3] vbox: Remove old unflexible macros

2017-10-25 Thread John Ferlan


On 10/24/2017 05:09 PM, Dawid Zamirski wrote:
> The VBOX_SESSION_OPEN/CLOSE macros are only called in
> _vboxDomainSnapshotRestore and they are unflexible because:
> 
> * assume the caller will have variable named "data"
> * can only create Write lock type
> 
> As per above, it's not that hard to simply use the VBOX API directly.
> ---
>  src/vbox/vbox_tmpl.c | 10 ++
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 

Reviewed-by: John Ferlan 

John

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