[PATCH 1/4] vz: Split logic of prlsdkAddDomain() into two functions

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

 



Add two functions
1. prlsdkNewDomain() creates new empty domain in domains list with the specific uuid.
2. prlsdkSetDomainInstance() add data from VM to domain object.
---
 src/vz/vz_sdk.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/vz/vz_sdk.h |  8 ++++++++
 2 files changed, 57 insertions(+)

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index b78c413..c705517 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -1509,6 +1509,55 @@ prlsdkUpdateDomain(vzConnPtr privconn, virDomainObjPtr dom)
     return retdom ? 0 : -1;
 }
 
+int
+prlsdkSetDomainInstance(vzConnPtr privconn, virDomainObjPtr dom, const unsigned char *uuid)
+{
+    PRL_HANDLE sdkdom = PRL_INVALID_HANDLE;
+    virDomainObjPtr retdom;
+
+    sdkdom = prlsdkSdkDomainLookupByUUID(privconn, uuid);
+    if (sdkdom == PRL_INVALID_HANDLE)
+        return -1;
+
+    retdom = prlsdkLoadDomain(privconn, sdkdom, dom);
+    PrlHandle_Free(sdkdom);
+    return retdom ? 0 : -1;
+}
+
+virDomainObjPtr
+prlsdkNewDomain(vzConnPtr privconn, char *name, const unsigned char *uuid)
+{
+    virDomainDefPtr def = NULL;
+    virDomainObjPtr dom = NULL;
+    vzDomObjPtr pdom = NULL;
+
+    if (!(def = virDomainDefNewFull(name, uuid, -1)))
+        goto error;
+
+    if (VIR_ALLOC(pdom) < 0)
+        goto error;
+
+    if (STREQ(privconn->drivername, "vz"))
+        def->virtType = VIR_DOMAIN_VIRT_VZ;
+    else
+        def->virtType = VIR_DOMAIN_VIRT_PARALLELS;
+
+    if (!(dom = virDomainObjListAdd(privconn->domains, def,
+                                        privconn->xmlopt,
+                                        0, NULL)))
+        goto error;
+
+    dom->privateData = pdom;
+    dom->privateDataFreeFunc = prlsdkDomObjFreePrivate;
+    dom->persistent = 1;
+    return dom;
+
+ error:
+    virDomainDefFree(def);
+    VIR_FREE(pdom);
+    return NULL;
+}
+
 static int prlsdkSendEvent(vzConnPtr privconn,
                            virDomainObjPtr dom,
                            virDomainEventType lvEventType,
diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h
index ff6be07..060635e 100644
--- a/src/vz/vz_sdk.h
+++ b/src/vz/vz_sdk.h
@@ -32,6 +32,14 @@ int
 prlsdkLoadDomains(vzConnPtr privconn);
 virDomainObjPtr
 prlsdkAddDomain(vzConnPtr privconn, const unsigned char *uuid);
+virDomainObjPtr
+prlsdkNewDomain(vzConnPtr privconn,
+                char *name,
+                const unsigned char *uuid);
+int
+prlsdkSetDomainInstance(vzConnPtr privconn,
+                        virDomainObjPtr dom,
+                        const unsigned char *uuid);
 int prlsdkUpdateDomain(vzConnPtr privconn, virDomainObjPtr dom);
 int prlsdkSubscribeToPCSEvents(vzConnPtr privconn);
 void prlsdkUnsubscribeFromPCSEvents(vzConnPtr privconn);
-- 
1.8.3.1

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]