Re: [libvirt] [PATCH] libxl: Use id from virDomainObj inside the driver

2014-04-03 Thread Michal Privoznik

On 25.03.2014 18:39, Stefan Bader wrote:

There is a domain id in the virDomain structure as well as in the
virDomainObj structure. While the former can become stale the latter
is kept up to date. So it is safer to always (virDomainObjPtr)-def-id
internally.

This will fix issues seen when managing Xen guests through libvirt from
virt-manager (not being able to get domain info after define or reboot).
This was caused both though libxlDomainGetInfo() only but there were
a lot of places that might potentially cause issues, too.

Signed-off-by: Stefan Bader stefan.ba...@canonical.com
---
  src/libxl/libxl_driver.c |   75 +++---
  1 file changed, 38 insertions(+), 37 deletions(-)


ACK

Michal

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


[libvirt] [PATCH] libxl: Use id from virDomainObj inside the driver

2014-03-25 Thread Stefan Bader
There is a domain id in the virDomain structure as well as in the
virDomainObj structure. While the former can become stale the latter
is kept up to date. So it is safer to always (virDomainObjPtr)-def-id
internally.

This will fix issues seen when managing Xen guests through libvirt from
virt-manager (not being able to get domain info after define or reboot).
This was caused both though libxlDomainGetInfo() only but there were
a lot of places that might potentially cause issues, too.

Signed-off-by: Stefan Bader stefan.ba...@canonical.com
---
 src/libxl/libxl_driver.c |   75 +++---
 1 file changed, 38 insertions(+), 37 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index fc97db4..b5061df 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -770,10 +770,10 @@ libxlDomainSuspend(virDomainPtr dom)
 priv = vm-privateData;
 
 if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) {
-if (libxl_domain_pause(priv-ctx, dom-id) != 0) {
+if (libxl_domain_pause(priv-ctx, vm-def-id) != 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to suspend domain '%d' with libxenlight),
-   dom-id);
+   vm-def-id);
 goto endjob;
 }
 
@@ -829,10 +829,10 @@ libxlDomainResume(virDomainPtr dom)
 priv = vm-privateData;
 
 if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
-if (libxl_domain_unpause(priv-ctx, dom-id) != 0) {
+if (libxl_domain_unpause(priv-ctx, vm-def-id) != 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to resume domain '%d' with libxenlight),
-   dom-id);
+   vm-def-id);
 goto endjob;
 }
 
@@ -883,10 +883,10 @@ libxlDomainShutdownFlags(virDomainPtr dom, unsigned int 
flags)
 }
 
 priv = vm-privateData;
-if (libxl_domain_shutdown(priv-ctx, dom-id) != 0) {
+if (libxl_domain_shutdown(priv-ctx, vm-def-id) != 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to shutdown domain '%d' with libxenlight),
-   dom-id);
+   vm-def-id);
 goto cleanup;
 }
 
@@ -930,10 +930,10 @@ libxlDomainReboot(virDomainPtr dom, unsigned int flags)
 }
 
 priv = vm-privateData;
-if (libxl_domain_reboot(priv-ctx, dom-id) != 0) {
+if (libxl_domain_reboot(priv-ctx, vm-def-id) != 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to reboot domain '%d' with libxenlight),
-   dom-id);
+   vm-def-id);
 goto cleanup;
 }
 ret = 0;
@@ -974,7 +974,7 @@ libxlDomainDestroyFlags(virDomainPtr dom,
 priv = vm-privateData;
 if (libxl_domain_destroy(priv-ctx, vm-def-id, NULL)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(Failed to destroy domain '%d'), dom-id);
+   _(Failed to destroy domain '%d'), vm-def-id);
 goto cleanup;
 }
 
@@ -1105,10 +1105,10 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned 
long newmem,
 
 if (flags  VIR_DOMAIN_MEM_LIVE) {
 priv = vm-privateData;
-if (libxl_domain_setmaxmem(priv-ctx, dom-id, newmem)  0) {
+if (libxl_domain_setmaxmem(priv-ctx, vm-def-id, newmem)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to set maximum memory for domain '%d'
-  with libxenlight), dom-id);
+  with libxenlight), vm-def-id);
 goto endjob;
 }
 }
@@ -1138,13 +1138,13 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned 
long newmem,
 priv = vm-privateData;
 /* Unlock virDomainObj while ballooning memory */
 virObjectUnlock(vm);
-res = libxl_set_memory_target(priv-ctx, dom-id, newmem, 0,
+res = libxl_set_memory_target(priv-ctx, vm-def-id, newmem, 0,
   /* force */ 1);
 virObjectLock(vm);
 if (res  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to set memory for domain '%d'
-  with libxenlight), dom-id);
+  with libxenlight), vm-def-id);
 goto endjob;
 }
 }
@@ -1202,9 +1202,10 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr 
info)
 info-memory = vm-def-mem.cur_balloon;
 info-maxMem = vm-def-mem.max_balloon;
 } else {
-if (libxl_domain_info(priv-ctx, d_info, dom-id) != 0) {
+if (libxl_domain_info(priv-ctx, d_info, vm-def-id) != 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-