Re: Need Help To Destroy Virtual Machines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03.04.2012 16:42, Ali Raza Memon wrote:
> Hello...!
> I am using libvirt-php for controlling my xen virtual machines. For this
> I have installed libvirt-php along with xampp server.
> Now I need to create a web based controll panel application which shows
> me running vms, and some options like Shutdown, Pause, Create, Destroy.
> My aim is, when I click Destroy button the selected vm should be
> destroyed. For this I have used the following php-script:
> 
> <?php
>     
>     $conn=libvirt_connect("xen:///");
>     $name=libvirt_domain_lookup_by_id($conn,4); // Here '4' is the id of
> my running vm
>     $dest=libvirt_domain_destroy($name);
>     echo $dest;
> 
> ?>  
> 
> 
> When I execute this it shows me following warning:
> 
> *Warning: libvirt_domain_destroy() [function.libvirt-domain-destroy]:
> operation virDomainDestroy forbidden for read only access in
> /opt/lampp/htdocs/xampp/xen/test.php on line 5
> *
> 
> So, Could you please help me to solve this?
> 
> ! Thank You !
> 

You need to pass credentials array:

$credentials = array(VIR_CRED_AUTHNAME=>'root',VIR_CRED_PASSPHRASE=>'super_secret_password');
$conn = libvirt_connect("xen:///", FALSE, $credentials); // FALSE means you want read-write connection

You can find examplese here:

http://phplibvirt.cybersales.cz/doc/function.libvirt-connect.html

Michal

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]