<>? 2011?11?13? 23:37, Eduard B ??:
Hi All,
Im trying to figure how to use libvirt_domain_is_active but I'm unable
to find what I am doing wrong.
I tested it with php-libvirt-0.4.4 an with 0.4.3 but i have the same
problem
Im using libvirt-0.9.6-2.fc16.x86_64 with the following code
Can someone point me in the right direction with the use of
libvirt_domain_is_active ?
Thanks
------8<------CODE --------8<------------------------------------
print_r ( libvirt_version() );
$domains=libvirt_list_domains($conn);
print_r ($domains);
foreach ( $domains as $domain ) {
print "$domain\n";
print libvirt_domain_is_active($domain);
libvirt_domain_is_active() wants a arg of resource type here. See
the codes in examples/libvirt-php.c to get how to do it:
<snip>
211
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
function get_domain_object($nameRes) {
212
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
if (is_resource($nameRes))
213
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
return $nameRes;
214
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
215
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
$dom=libvirt_domain_lookup_by_name($this->conn, $nameRes);
216
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
if (!$dom) {
217
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
$dom=libvirt_domain_lookup_by_uuid_string($this->conn,
$nameRes);
218
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
if (!$dom)
219
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
return $this->_set_last_error();
220
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
}
221
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
222
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
return $dom;
223
<
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=examples/libvirt.php;h...
}
</snip>
what you want might be something like:
foreach ($domains as $domname) {
$domobj = get_domain_object($domname);
print "$domain: " . libvirt_domain_is_active($domobj);
}
Osier