Ok I want to create domain using libvirt-php.Here is the code.
< ?php
$credentials = array(VIR_CRED_AUTHNAME=>'root',VIR_CRED_PASSPHRASE=>'root');
$conn = libvirt_connect("xen:///", FALSE, $credentials);
$name="oneiric";
$arch="i386";
$memMB=1024;
$maxmemMB=1536;
$vcpus=2;
$iso_image="/root/onericGUI.iso";
$disk1 = array(
"path" => "/var/libvirt/images/vm.img",
"driver" => "raw",
"bus" => "ide",
"dev" => "hda",
"size" => "10G",
"flags" => VIR_DOMAIN_DISK_FILE | VIR_DOMAIN_DISK_ACCESS_ALL ); $disks = array( $disk1 );
$network1 = array(
'mac' => '00:11:22:33:44:55',
'network' => 'default',
'model' => 'e1000'
);
$networks = array( $network1 ); $flags=DOMAIN_FLAG_FEATURE_ACPI;
$newdom=libvirt_domain_new($conn, $name, $arch, $memMB, $maxmemMB, $vcpus, $iso_image, $disks, $networks, $flags);
print_r($newdom); ?>
Every thing all right but the problem is only at $flags . I have passed
- DOMAIN_FLAG_FEATURE_ACPI
- DOMAIN_FLAG_FEATURE_APIC
- DOMAIN_FLAG_FEATURE_PAE
- DOMAIN_FLAG_CLOCK
- DOMAIN_FLAG_SOUND_AC97, all options Indevedually but when I execute it it shows me following warning:
Notice: Use of undefined constant DOMAIN_FLAG_FEATURE_ACPI - assumed 'DOMAIN_FLAG_FEATURE_ACPI' in /opt/lampp/htdocs/xampp/xen/create_vm.php on line 32
Warning: libvirt_domain_new() expects parameter 10 to be long, string given in /opt/lampp/htdocs/xampp/xen/create_vm.php on line 34
Warning: libvirt_domain_new() [function.libvirt-domain-new]: Invalid arguments in /opt/lampp/htdocs/xampp/xen/create_vm.php on line 34
You have defined $flags
as a string, but a long is required. I'm guessing what you wanted to was assign $flags
the value of the constant DOMAIN_FLAG_FEATURE_ACPI
, but instead you defined it as a literal string containing DOMAIN_FLAG_FEATURE_ACPI
itself as text.
$flags = DOMAIN_FLAG_FEATURE_ACPI;
Warning: libvirtdomainnew() [function.libvirt-domain-new http://localhost/xampp/xen/function.libvirt-domain-new]: Domain not found: xenUnifiedDomainLookupByUUID in /opt/lampp/htdocs/xampp/xen/create_vm.php on line 3 - Alee 2012-04-07 17:31
The message:
Domain not found: xenUnifiedDomainLookupByUUID in /opt/lampp/htdocs/xampp/xen/create_vm.php on line 32
is coming from libvirt itself, not libvirt-php. It seems that there's an error on libvirt connecting to your Xen instance.