14-Apr-17 17:53, Konstantin Neumoin пишет:

Acked-by: Nikolay Shirokovskiy <nshirokovs...@virtuozzo.com>
Signed-off-by: Konstantin Neumoin <kneum...@virtuozzo.com>
---
  src/vz/vz_driver.c | 43 +++++++++++++++++++++++++++++++++++++++++++
  src/vz/vz_sdk.c    | 23 +++++++++++++++++++++++
  src/vz/vz_sdk.h    |  1 +
  3 files changed, 67 insertions(+)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index da83a8f..ed7132f 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -3905,6 +3905,47 @@ vzDomainReset(virDomainPtr domain, unsigned int flags)
      return ret;
  }

+static int vzDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
+                                 unsigned int flags)
+{
+    virDomainObjPtr dom = NULL;
+    int ret = -1;
+    bool job = false;
+
+    virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+                  VIR_DOMAIN_AFFECT_CONFIG, -1);
+
+    if (!(dom = vzDomObjFromDomainRef(domain)))
+        goto cleanup;
+
+    if (vzCheckConfigUpdateFlags(dom, &flags) < 0)
+        goto cleanup;
+
+    if (virDomainSetVcpusFlagsEnsureACL(domain->conn, dom->def, flags) < 0)
+        goto cleanup;
+
+    if (vzDomainObjBeginJob(dom) < 0)
+        goto cleanup;
+    job = true;
+
+    if (vzEnsureDomainExists(dom) < 0)
+        goto cleanup;
+
+    ret = prlsdkSetCpuCount(dom, nvcpus);
+
+ cleanup:
+    if (job)
+        vzDomainObjEndJob(dom);
+    virDomainObjEndAPI(&dom);
+    return ret;
+}
+
+static int vzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
+{
+    return vzDomainSetVcpusFlags(dom, nvcpus,
+                                 VIR_DOMAIN_AFFECT_LIVE | 
VIR_DOMAIN_AFFECT_CONFIG);
+}
+
  static virHypervisorDriver vzHypervisorDriver = {
      .name = "vz",
      .connectOpen = vzConnectOpen,            /* 0.10.0 */
@@ -3954,6 +3995,8 @@ static virHypervisorDriver vzHypervisorDriver = {
      .domainDetachDeviceFlags = vzDomainDetachDeviceFlags, /* 1.2.15 */
      .domainIsActive = vzDomainIsActive, /* 1.2.10 */
      .domainIsUpdated = vzDomainIsUpdated,     /* 1.2.21 */
+    .domainSetVcpus = vzDomainSetVcpus, /* 3.3.0 */
+    .domainSetVcpusFlags = vzDomainSetVcpusFlags, /* 3.3.0 */
      .domainGetVcpusFlags = vzDomainGetVcpusFlags, /* 1.2.21 */
      .domainGetMaxVcpus = vzDomainGetMaxVcpus, /* 1.2.21 */
      .domainSetUserPassword = vzDomainSetUserPassword, /* 2.0.0 */
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index c1a50fd..2daa44a 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -4902,3 +4902,26 @@ int prlsdkMigrate(virDomainObjPtr dom, virURIPtr uri,
   cleanup:
      return ret;
  }
+
+int prlsdkSetCpuCount(virDomainObjPtr dom, unsigned int count)
+{
+    vzDomObjPtr privdom = dom->privateData;
+    PRL_HANDLE job;
+    PRL_RESULT pret;
+
+    job = PrlVm_BeginEdit(privdom->sdkdom);
+    if (PRL_FAILED(waitDomainJob(job, dom)))
+        goto error;
+
+    pret = PrlVmCfg_SetCpuCount(privdom->sdkdom, count);
+    prlsdkCheckRetGoto(pret, error);
+
+    job = PrlVm_CommitEx(privdom->sdkdom, 0);
+    if (PRL_FAILED(waitDomainJob(job, dom)))
+        goto error;
+
+    return 0;
+
+ error:
+    return -1;
+}
diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h
index f8da2ad..100a5e3 100644
--- a/src/vz/vz_sdk.h
+++ b/src/vz/vz_sdk.h
@@ -71,6 +71,7 @@ int
  prlsdkGetMemoryStats(PRL_HANDLE sdkstas, virDomainMemoryStatPtr stats, 
unsigned int nr_stats);
  /* memsize is in MiB */
  int prlsdkSetMemsize(virDomainObjPtr dom, unsigned int memsize);
+int prlsdkSetCpuCount(virDomainObjPtr dom, unsigned int count);
  int
  prlsdkDomainSetUserPassword(virDomainObjPtr dom,
                              const char *user,
--
2.7.4

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

ACK to both and pushed.

Thanks,
Maxim

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

Reply via email to