Re: [libvirt] [PATCH V2 10/13] libxl: use job functions in vcpu set and pin functions

2014-02-19 Thread Daniel P. Berrange
On Wed, Feb 12, 2014 at 06:56:24PM -0700, Jim Fehlig wrote:
 These operations aren't necessarily time consuming, but need to
 wait in the queue of modify jobs.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
 
 V2: Check libxlDomainObjEndJob() return value
 
  src/libxl/libxl_driver.c | 48 
 +++-
  1 file changed, 31 insertions(+), 17 deletions(-)

ACK


Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


[libvirt] [PATCH V2 10/13] libxl: use job functions in vcpu set and pin functions

2014-02-12 Thread Jim Fehlig
These operations aren't necessarily time consuming, but need to
wait in the queue of modify jobs.

Signed-off-by: Jim Fehlig jfeh...@suse.com
---

V2: Check libxlDomainObjEndJob() return value

 src/libxl/libxl_driver.c | 48 +++-
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 9c42e28..1f3ea51 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2329,22 +2329,25 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int 
nvcpus,
 if (virDomainSetVcpusFlagsEnsureACL(dom-conn, vm-def, flags)  0)
 goto cleanup;
 
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY)  0)
+goto cleanup;
+
 if (!virDomainObjIsActive(vm)  (flags  VIR_DOMAIN_VCPU_LIVE)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(cannot set vcpus on an inactive domain));
-goto cleanup;
+goto endjob;
 }
 
 if (!vm-persistent  (flags  VIR_DOMAIN_VCPU_CONFIG)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(cannot change persistent config of a transient 
domain));
-goto cleanup;
+goto endjob;
 }
 
 if ((max = libxlConnectGetMaxVcpus(dom-conn, NULL))  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR, %s,
_(could not determine max vcpus for the domain));
-goto cleanup;
+goto endjob;
 }
 
 if (!(flags  VIR_DOMAIN_VCPU_MAXIMUM)  vm-def-maxvcpus  max) {
@@ -2355,17 +2358,17 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int 
nvcpus,
 virReportError(VIR_ERR_INVALID_ARG,
_(requested vcpus is greater than max allowable
   vcpus for the domain: %d  %d), nvcpus, max);
-goto cleanup;
+goto endjob;
 }
 
 priv = vm-privateData;
 
 if (!(def = virDomainObjGetPersistentDef(cfg-caps, driver-xmlopt, vm)))
-goto cleanup;
+goto endjob;
 
 maplen = VIR_CPU_MAPLEN(nvcpus);
 if (VIR_ALLOC_N(bitmask, maplen)  0)
-goto cleanup;
+goto endjob;
 
 for (i = 0; i  nvcpus; ++i) {
 pos = i / 8;
@@ -2391,7 +2394,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int 
nvcpus,
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to set vcpus for domain '%d'
   with libxenlight), dom-id);
-goto cleanup;
+goto endjob;
 }
 break;
 
@@ -2400,7 +2403,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int 
nvcpus,
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to set vcpus for domain '%d'
   with libxenlight), dom-id);
-goto cleanup;
+goto endjob;
 }
 def-vcpus = nvcpus;
 break;
@@ -2411,6 +2414,10 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int 
nvcpus,
 if (flags  VIR_DOMAIN_VCPU_CONFIG)
 ret = virDomainSaveConfig(cfg-configDir, def);
 
+endjob:
+if (!libxlDomainObjEndJob(driver, vm))
+vm = NULL;
+
 cleanup:
 VIR_FREE(bitmask);
  if (vm)
@@ -2502,15 +2509,18 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int 
vcpu,
 if (virDomainPinVcpuFlagsEnsureACL(dom-conn, vm-def, flags)  0)
 goto cleanup;
 
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY)  0)
+goto cleanup;
+
 if ((flags  VIR_DOMAIN_AFFECT_LIVE)  !virDomainObjIsActive(vm)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(domain is inactive));
-goto cleanup;
+goto endjob;
 }
 
 if (virDomainLiveConfigHelperMethod(cfg-caps, driver-xmlopt, vm,
 flags, targetDef)  0)
-goto cleanup;
+goto endjob;
 
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 targetDef = vm-def;
@@ -2521,7 +2531,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int 
vcpu,
 
 pcpumap = virBitmapNewData(cpumap, maplen);
 if (!pcpumap)
-goto cleanup;
+goto endjob;
 
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 libxl_bitmap map = { .size = maplen, .map = cpumap };
@@ -2532,7 +2542,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int 
vcpu,
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to pin vcpu '%d' with libxenlight),
vcpu);
-goto cleanup;
+goto endjob;
 }
 }
 
@@ -2542,14 +2552,14 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int 
vcpu,
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to delete vcpupin xml for vcpu '%d'),
vcpu);
-goto cleanup;
+goto endjob;
 }
-goto out;
+goto done;
 }