From: Stefan Bader <stefan.bader@canonical.com>
To: libvir-list@redhat.com, xen-devel@lists.xen.org
Cc: Jim Fehlig <jfehlig@suse.com>, Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 1/3] libxl: Use id from virDomainObj inside the driver
Date: Thu, 27 Mar 2014 17:55:02 +0100 [thread overview]
Message-ID: <1395939304-9017-2-git-send-email-stefan.bader@canonical.com> (raw)
In-Reply-To: <1395939304-9017-1-git-send-email-stefan.bader@canonical.com>
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.bader@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,
- _("libxl_domain_info failed for domain '%d'"), dom->id);
+ _("libxl_domain_info failed for domain '%d'"),
+ vm->def->id);
goto cleanup;
}
info->cpuTime = d_info.cpu_time;
@@ -1483,11 +1484,11 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
if (!(flags & VIR_DUMP_LIVE) &&
virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
- if (libxl_domain_pause(priv->ctx, dom->id) != 0) {
+ if (libxl_domain_pause(priv->ctx, vm->def->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Before dumping core, failed to suspend domain '%d'"
" with libxenlight"),
- dom->id);
+ vm->def->id);
goto endjob;
}
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_DUMP);
@@ -1496,20 +1497,20 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
/* Unlock virDomainObj while dumping core */
virObjectUnlock(vm);
- ret = libxl_domain_core_dump(priv->ctx, dom->id, to, NULL);
+ ret = libxl_domain_core_dump(priv->ctx, vm->def->id, to, NULL);
virObjectLock(vm);
if (ret != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to dump core of domain '%d' with libxenlight"),
- dom->id);
+ vm->def->id);
ret = -1;
goto unpause;
}
if (flags & VIR_DUMP_CRASH) {
- if (libxl_domain_destroy(priv->ctx, dom->id, NULL) < 0) {
+ 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 unpause;
}
@@ -1524,10 +1525,10 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
unpause:
if (virDomainObjIsActive(vm) && 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,
_("After dumping core, failed to resume domain '%d' with"
- " libxenlight"), dom->id);
+ " libxenlight"), vm->def->id);
} else {
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING,
VIR_DOMAIN_RUNNING_UNPAUSED);
@@ -1786,19 +1787,19 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
break;
case VIR_DOMAIN_VCPU_LIVE:
- if (libxl_set_vcpuonline(priv->ctx, dom->id, &map) != 0) {
+ if (libxl_set_vcpuonline(priv->ctx, vm->def->id, &map) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set vcpus for domain '%d'"
- " with libxenlight"), dom->id);
+ " with libxenlight"), vm->def->id);
goto endjob;
}
break;
case VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG:
- if (libxl_set_vcpuonline(priv->ctx, dom->id, &map) != 0) {
+ if (libxl_set_vcpuonline(priv->ctx, vm->def->id, &map) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set vcpus for domain '%d'"
- " with libxenlight"), dom->id);
+ " with libxenlight"), vm->def->id);
goto endjob;
}
def->vcpus = nvcpus;
@@ -1934,7 +1935,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
libxlDomainObjPrivatePtr priv;
priv = vm->privateData;
- if (libxl_set_vcpuaffinity(priv->ctx, dom->id, vcpu, &map) != 0) {
+ if (libxl_set_vcpuaffinity(priv->ctx, vm->def->id, vcpu, &map) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to pin vcpu '%d' with libxenlight"),
vcpu);
@@ -2099,11 +2100,11 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
}
priv = vm->privateData;
- if ((vcpuinfo = libxl_list_vcpu(priv->ctx, dom->id, &maxcpu,
+ if ((vcpuinfo = libxl_list_vcpu(priv->ctx, vm->def->id, &maxcpu,
&hostcpus)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to list vcpus for domain '%d' with libxenlight"),
- dom->id);
+ vm->def->id);
goto cleanup;
}
@@ -3608,7 +3609,7 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to get scheduler id for domain '%d'"
- " with libxenlight"), dom->id);
+ " with libxenlight"), vm->def->id);
goto cleanup;
}
@@ -3659,10 +3660,10 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
goto cleanup;
}
- if (libxl_domain_sched_params_get(priv->ctx, dom->id, &sc_info) != 0) {
+ if (libxl_domain_sched_params_get(priv->ctx, vm->def->id, &sc_info) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to get scheduler parameters for domain '%d'"
- " with libxenlight"), dom->id);
+ " with libxenlight"), vm->def->id);
goto cleanup;
}
@@ -3740,10 +3741,10 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
goto endjob;
}
- if (libxl_domain_sched_params_get(priv->ctx, dom->id, &sc_info) != 0) {
+ if (libxl_domain_sched_params_get(priv->ctx, vm->def->id, &sc_info) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to get scheduler parameters for domain '%d'"
- " with libxenlight"), dom->id);
+ " with libxenlight"), vm->def->id);
goto endjob;
}
@@ -3756,10 +3757,10 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
sc_info.cap = params[i].value.ui;
}
- if (libxl_domain_sched_params_set(priv->ctx, dom->id, &sc_info) != 0) {
+ if (libxl_domain_sched_params_set(priv->ctx, vm->def->id, &sc_info) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set scheduler parameters for domain '%d'"
- " with libxenlight"), dom->id);
+ " with libxenlight"), vm->def->id);
goto endjob;
}
--
1.7.9.5
next parent reply other threads:[~2014-03-27 16:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1395939304-9017-1-git-send-email-stefan.bader@canonical.com>
2014-03-27 16:55 ` Stefan Bader [this message]
2014-04-03 14:16 ` [libvirt] [PATCH 1/3] libxl: Use id from virDomainObj inside the driver Michal Privoznik
2014-03-27 16:55 ` [PATCH 2/3] libxl: Set disk format for empty cdrom device Stefan Bader
2014-04-03 14:16 ` [libvirt] " Michal Privoznik
2014-03-27 16:55 ` [PATCH 3/3] libxl: Implement basic video device selection Stefan Bader
2014-04-03 14:16 ` [libvirt] " Michal Privoznik
2014-03-31 17:14 ` libxl fixes/improvements for libvirt Jim Fehlig
2014-04-03 15:45 ` [libvirt] " Michal Privoznik
[not found] ` <533D8207.8040402@redhat.com>
2014-04-03 15:49 ` Stefan Bader
2014-04-04 9:36 ` [PATCH v2] libxl: Implement basic video device selection Stefan Bader
[not found] ` <1396604199-8198-1-git-send-email-stefan.bader@canonical.com>
2014-04-04 9:48 ` Ian Campbell
[not found] ` <1396604917.4211.184.camel@kazak.uk.xensource.com>
2014-04-04 10:31 ` Stefan Bader
[not found] ` <533E8A1A.4030904@canonical.com>
2014-04-04 10:34 ` Ian Campbell
2014-04-04 10:34 ` Stefan Bader
[not found] ` <1396607657.4211.190.camel@kazak.uk.xensource.com>
2014-04-04 10:52 ` Stefan Bader
2014-04-04 12:51 ` [libvirt] " Daniel P. Berrange
[not found] ` <20140404125113.GA13990@redhat.com>
2014-04-04 12:56 ` Ian Campbell
[not found] ` <1396616169.4211.222.camel@kazak.uk.xensource.com>
2014-04-04 13:08 ` Daniel P. Berrange
2014-04-04 13:10 ` Stefan Bader
2014-04-04 13:17 ` Daniel P. Berrange
[not found] ` <20140404131711.GD13990@redhat.com>
2014-04-04 13:36 ` Stefan Bader
[not found] ` <533EB566.7000903@canonical.com>
2014-04-04 13:51 ` Daniel P. Berrange
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395939304-9017-2-git-send-email-stefan.bader@canonical.com \
--to=stefan.bader@canonical.com \
--cc=ian.campbell@citrix.com \
--cc=jfehlig@suse.com \
--cc=libvir-list@redhat.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).