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

Re: [libvirt] [PATCH v3 12/12] parallels: implement domainUndefine and domainUndefineFlags



18.11.2014 16:17, Dmitry Guryanov пишет:
Signed-off-by: Dmitry Guryanov <dguryanov parallels com>
---
  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 85193f1..e06b6bf 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2675,3 +2675,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);
ack


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