# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1194454618 28800
# Node ID e7bab3523bd443fe7aaeaf30a7cc97bb312e988d
# Parent b9eaad2ace9b71f7c6cb9feb3b6ea630050e3e0f
Add domain_online() helper function
to return true if a domain is running or blocked.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r b9eaad2ace9b -r e7bab3523bd4 libxkutil/misc_util.c
--- a/libxkutil/misc_util.c Wed Nov 07 08:56:44 2007 -0800
+++ b/libxkutil/misc_util.c Wed Nov 07 08:56:58 2007 -0800
@@ -360,6 +360,17 @@ bool provider_is_responsible(const CMPIB
return rc;
}
+bool domain_online(virDomainPtr dom)
+{
+ virDomainInfo info;
+
+ if (virDomainGetInfo(dom, &info) != 0)
+ return false;
+
+ return (info.state == VIR_DOMAIN_BLOCKED) ||
+ (info.state == VIR_DOMAIN_RUNNING);
+}
+
/*
* Local Variables:
diff -r b9eaad2ace9b -r e7bab3523bd4 libxkutil/misc_util.h
--- a/libxkutil/misc_util.h Wed Nov 07 08:56:44 2007 -0800
+++ b/libxkutil/misc_util.h Wed Nov 07 08:56:58 2007 -0800
@@ -82,6 +82,7 @@ char *get_key_from_ref_arg(const CMPIArg
char *get_key_from_ref_arg(const CMPIArgs *args, char *arg, char *key);
bool domain_exists(virConnectPtr conn, const char *name);
+bool domain_online(virDomainPtr dom);
uint64_t allocated_memory(virConnectPtr conn);