[PATCH v2 12/12] parallels: implement domainUndefine and domainUndefineFlags

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

 



Signed-off-by: Dmitry Guryanov <dguryanov@xxxxxxxxxxxxx>
---
 src/parallels/parallels_driver.c | 26 ++++++++++++++++++++++++++
 src/parallels/parallels_sdk.c    | 18 ++++++++++++++++++
 src/parallels/parallels_sdk.h    |  2 ++
 3 files changed, 46 insertions(+)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 522c39f..08d2e30 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -917,6 +917,30 @@ parallelsDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
     return parallelsDomainCreate(domain);
 }
 
+static int
+parallelsDomainUndefineFlags(virDomainPtr domain,
+                             unsigned int flags)
+{
+    parallelsConnPtr privconn = domain->conn->privateData;
+    virDomainObjPtr dom = NULL;
+
+    virCheckFlags(0, -1);
+
+    dom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
+    if (dom == NULL) {
+        parallelsDomNotFoundError(domain);
+        return -1;
+    }
+
+    return prlsdkUnregisterDomain(privconn, dom);
+}
+
+static int
+parallelsDomainUndefine(virDomainPtr domain)
+{
+    return parallelsDomainUndefineFlags(domain, 0);
+}
+
 static virHypervisorDriver parallelsDriver = {
     .no = VIR_DRV_PARALLELS,
     .name = "Parallels",
@@ -949,6 +973,8 @@ static virHypervisorDriver parallelsDriver = {
     .domainCreate = parallelsDomainCreate,    /* 0.10.0 */
     .domainCreateWithFlags = parallelsDomainCreateWithFlags, /* 1.2.10 */
     .domainDefineXML = parallelsDomainDefineXML,      /* 0.10.0 */
+    .domainUndefine = parallelsDomainUndefine, /* 1.2.10 */
+    .domainUndefineFlags = parallelsDomainUndefineFlags, /* 1.2.10 */
     .domainIsActive = parallelsDomainIsActive, /* 1.2.10 */
     .connectDomainEventRegisterAny = parallelsConnectDomainEventRegisterAny, /* 1.2.10 */
     .connectDomainEventDeregisterAny = parallelsConnectDomainEventDeregisterAny, /* 1.2.10 */
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index b4bd19e..fceb05a 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2672,3 +2672,21 @@ prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def)
     PrlHandle_Free(sdkdom);
     return ret;
 }
+
+int
+prlsdkUnregisterDomain(parallelsConnPtr privconn, virDomainObjPtr dom)
+{
+    parallelsDomObjPtr privdom = dom->privateData;
+    PRL_HANDLE job;
+
+    job = PrlVm_Unreg(privdom->sdkdom);
+    if (waitJob(job, privconn->jobTimeout))
+        return -1;
+
+    if (prlsdkSendEvent(privconn, dom, VIR_DOMAIN_EVENT_UNDEFINED,
+                        VIR_DOMAIN_EVENT_UNDEFINED_REMOVED) < 0)
+        return -1;
+
+    virDomainObjListRemove(privconn->domains, dom);
+    return 0;
+}
diff --git a/src/parallels/parallels_sdk.h b/src/parallels/parallels_sdk.h
index 1fdef1a..dee9359 100644
--- a/src/parallels/parallels_sdk.h
+++ b/src/parallels/parallels_sdk.h
@@ -51,3 +51,5 @@ prlsdkApplyConfig(virConnectPtr conn,
                   virDomainDefPtr new);
 int prlsdkCreateVm(virConnectPtr conn, virDomainDefPtr def);
 int prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def);
+int
+prlsdkUnregisterDomain(parallelsConnPtr privconn, virDomainObjPtr dom);
-- 
1.9.3

--
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]