# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1206112986 25200
# Node ID c3dca3932e0b9f80778cbd6cbdfa09de4a7632a9
# Parent 594c9195e59c8025ea18b3d6b5ca43b322db55e1
Make domain_online() re-lookup domain to make sure we're getting fresh info
This is necessary if you're using domain_online() in a polling loop.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 594c9195e59c -r c3dca3932e0b libxkutil/misc_util.c
--- a/libxkutil/misc_util.c Thu Mar 20 13:13:57 2008 -0700
+++ b/libxkutil/misc_util.c Fri Mar 21 08:23:06 2008 -0700
@@ -378,12 +378,25 @@ bool domain_online(virDomainPtr dom)
bool domain_online(virDomainPtr dom)
{
virDomainInfo info;
-
- if (virDomainGetInfo(dom, &info) != 0)
+ virDomainPtr _dom;
+ bool rc;
+
+ _dom = virDomainLookupByName(virDomainGetConnect(dom),
+ virDomainGetName(dom));
+ if (_dom == NULL) {
+ CU_DEBUG("Unable to re-lookup domain");
return false;
-
- return (info.state == VIR_DOMAIN_BLOCKED) ||
- (info.state == VIR_DOMAIN_RUNNING);
+ }
+
+ if (virDomainGetInfo(_dom, &info) != 0)
+ rc = false;
+ else
+ rc = (info.state == VIR_DOMAIN_BLOCKED) ||
+ (info.state == VIR_DOMAIN_RUNNING) ||
+ (info.state == VIR_DOMAIN_NOSTATE);
+ virDomainFree(_dom);
+
+ return rc;
}
int parse_id(const char *id,