[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v3 04/12] parallels: handle events from parallels server



27.11.2014 17:51, Dmitry Guryanov пишет:
On Tuesday 25 November 2014 15:31:19 Maxim Nestratov wrote:
18.11.2014 16:16, Dmitry Guryanov пишет:
From: Alexander Burluka <aburluka parallels com>

Subscribe to events from parallels server. It's
needed for 2 things: to update cached domains list
and to send corresponding libvirt events.

Parallels server sends a lot of different events, in
this patch we handle only some of them. In the future
we can handle for example, changes in a host network
configuration or devices states.

Signed-off-by: Dmitry Guryanov <dguryanov parallels com>
....
+ error:
+    return -1;
+}
+
+void prlsdkUnsubscribeFromPCSEvents(parallelsConnPtr privconn)
+{
+    PRL_RESULT ret = PRL_ERR_UNINITIALIZED;
+    ret = PrlSrv_UnregEventHandler(privconn->server,
+                                 prlsdkEventsHandler,
+                                 privconn);
+    if (PRL_FAILED(ret))
+        logPrlError(ret);
+}
diff --git a/src/parallels/parallels_sdk.h b/src/parallels/parallels_sdk.h
index d9461ca..5ffbf53 100644
--- a/src/parallels/parallels_sdk.h
+++ b/src/parallels/parallels_sdk.h
@@ -32,3 +32,5 @@ int

   prlsdkLoadDomains(parallelsConnPtr privconn);
   virDomainObjPtr
   prlsdkAddDomain(parallelsConnPtr privconn, const unsigned char *uuid);

+int prlsdkSubscribeToPCSEvents(parallelsConnPtr privconn);
+void prlsdkUnsubscribeFromPCSEvents(parallelsConnPtr privconn);
I would protect all event processing functions
(prlsdkHandleVmStateEvent, prlsdkHandleVmConfigEvent,
prlsdkHandleVmAddedEvent, prlsdkHandleVmRemovedEvent) with
parallelsDriverLock/parallelsDriverUnlock calls to prevent possible
races triggered by simultaneous operations on the same domain.
Otherwise, ack.
Functions virDomainObjListAdd and virDomainObjListRemove lock domains list, so
no need to protect the privconn->domains list twice.

Function virDomainObjListFindByUUID returns locked virDomainObj. So all
affected objects are already protected.




Hm. Argeed. I missed the point that  virDomainObjListFindByUUID takes mutex.
Then calling parallelsDriverLock/parallelsDriverUnlock in parallelsDomainDefineXML looks unnecessary.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]