好的,我想使用 libvirt-php 创建域。这是代码。
< ?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); ?>
一切都很好,但问题仅在于$flags。我通过了
- DOMAIN_FLAG_FEATURE_ACPI
- DOMAIN_FLAG_FEATURE_APIC
- DOMAIN_FLAG_FEATURE_PAE
- DOMAIN_FLAG_CLOCK
- DOMAIN_FLAG_SOUND_AC97, all options Indevedually 但是当我执行它时,它会显示以下警告:
注意:使用未定义的常量 DOMAIN_FLAG_FEATURE_ACPI - 在第 32 行的 /opt/lampp/htdocs/xampp/xen/create_vm.php 中假定为“DOMAIN_FLAG_FEATURE_ACPI”
警告:libvirt_domain_new() 期望参数 10 很长,字符串在第 34 行的 /opt/lampp/htdocs/xampp/xen/create_vm.php 中给出
警告:libvirt_domain_new() [function.libvirt-domain-new]:第 34 行 /opt/lampp/htdocs/xampp/xen/create_vm.php 中的参数无效