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

Re: [libvirt] Create domain using libvirt-php



Hi Ali,
thanks for your e-mail, here are answers to your questions:

1) $iso_image is the location of ISO image to start installation from.
This is the only supported installation source for now.
2) $disks is the array of disk settings, if you don't understand the
description ("array of disk devices for domain, consist of keys as
'path' (storage location), 'driver' (image type, e.g. 'raw' or 'qcow2'),
'bus' (e.g. 'ide', 'scsi'), 'dev' (device to be presented to the guest -
e.g. 'hda'), 'size' (with 'M' or 'G' suffixes, like '10G' for 10
gigabytes image etc.) and 'flags' (VIR_DOMAIN_DISK_FILE or
VIR_DOMAIN_DISK_BLOCK, optionally VIR_DOMAIN_DISK_ACCESS_ALL to allow
access to the disk for all users on the host system)") then it's simply
this array:

    $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 );

This means just one disk image will be created for the VM, the image
will be created at /var/libvirt/images/vm.img with size of 10 Gigabytes
and it will be the raw image (like a normal hard-drive is, i.e. no
backing file or anything), on the IDE bus, presented to the guest as
/dev/hda device, the path (/var/libvirt/images/vm.img)is referring to a
file on disk (VIR_DOMAIN_DISK_FILE) and not a partition/block device and
we will allow the access to this disk to all users
(VIR_DOMAIN_DISK_ACCESS_ALL).

3) $networks => "a rray of network devices for domain, consists of keys
as 'mac' (for MAC address), 'network' (for network name) and optional
'model' for model of NIC device"

        $network1 = array(
                                'mac' => '00:11:22:33:44:55',
                                'network' => 'default',
                                'model' => 'e1000'
                            );

        $networks = array( $network1 );

This specifies that there will be one network interface with MAC address
of 00:11:22:33:44:55 added to the guest. This interface will be
presented to the guest as the e1000 NIC and will be connected to the
network 'default'.

4) $flags - this is the OR'ed int field of domain flags, those can be:

/* Domain flags */
DOMAIN_FLAG_FEATURE_ACPI - support ACPI in the guest
DOMAIN_FLAG_FEATURE_APIC- support APIC in the guest
DOMAIN_FLAG_FEATURE_PAE- support PAE in the guest
DOMAIN_FLAG_CLOCK_LOCALTIME- use localtime offset in the guest instead
of UTC offset (MS Windows requires localtime offset AFAIK)
DOMAIN_FLAG_SOUND_AC97 - support AC'97 sound card in the guest


For reference please see:
http://libvirt.org/php/api-reference.html#libvirt_domain_new

If you would like to see the project using it and the usage, you can
look to the php-virt-control project at http://www.php-virt-control.org
site. The project is maintained and developed by me and few others and
it's open-source as well. You can clone it's source codes from the
project git (link available on the website).

Hope this helps!
Michal

On 04/04/2012 03:44 PM, Ali Raza Memon wrote:
> Hello...!
>
> I want to create a new domain using libvirt-php, and after creating I
> want to start it.
> I have seen this to create new domain:*
>
> libvirt_domain_new($conn, $name, $arch, $memMB, $maxmemMB, $vcpus,
> $iso_image, $disks, $networks, $flags)*
>
> So in the above sysntax what should I pass in $iso_image? $disk?
> $networks and $flag??
> Please give me a complete example that can solve my problem.
> Thanks..
>
>
>
> --
> libvir-list mailing list
> libvir-list redhat com
> https://www.redhat.com/mailman/listinfo/libvir-list

-- 
Michal Novotny <minovotn redhat com>, RHCE, Red Hat
Virtualization | libvirt-php bindings | php-virt-control.org


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