I am trying to create a kvm using libvirt api using java. the problem i am facing is that i need a device(image file (eg: kvm.img)). I am using .xml file to create the kvm using libvirt api and java. Now what i am doing is that create the .img file first using the qemu-img create from terminal. qemu-img create /var/lib/libvirt/images/kvm.img 10G
is the code i am using and in the xml to create kvm i mention <source file='var/lib/libvirt/images/kvm.img'/>
Now i need to know is there any method in libvirt api to create the .img file bu passing the xml file and i need to know about the xml file(create img file) too
I am using libvirt 1.0
the xml file that i use to create kvm is :
<domain type='kvm'><name>ft</name><memory>131072</memory><currentMemory>131072</currentMemory><vcpu>1</vcpu><os><type arch='x86_64' machine='pc-0.12'>hvm</type><boot dev='hd'/></os><features><acpi/></features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff><on_reboot>restart</on_reboot><on_crash>destroy</on_crash> <devices><emulator>/usr/bin/kvm</emulator><disk type='file' device='disk'><source file='var/lib/libvirt/images/ft.img'/><target dev='hda' bus='ide'/></disk><interface type='network'><mac address='52:54:00:8b:08:dd'/><source network='default'/><model type='virtio'/></interface><input type='mouse' bus='ps2'/><graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'/><video><model type='cirrus' vram='9216' heads='1'/> </video></devices></domain>
in java am using the libvirt metod as Domain createVm = con.domainCreateXML(str, 0);
as str
i am passing xml string