[libvirt-users] Java Bindings against RHEL5.5 KVM

James Hogarth james.hogarth at gmail.com
Tue Jun 1 15:25:43 UTC 2010


On 1 June 2010 13:49, James Hogarth <james.hogarth at gmail.com> wrote:
> Hi all,
>
> I'm doing some dev work against the native RHEL/centos 5.5 KVM
> installation for maintenance, creation and deletion of virtual guests
> using the libvirt API vai the java bindings from a java based web app.
>
> Things in general seem to be working - I can connect to and query the
> kvm instance using the libvirt interface and get a list of guests,
> pull information about them and stop/start/restart guests.
>
> I'm hitting a bit of an issue with creation of a guest however....
>
> When calling domainDefineXML with XML following the domain XML
> specification (with the XML as per a dumpxml on the relevant box) I
> get an error creating the guest of:
>
> "internal error unknown lifecycle action restart "
>
> The virsh version information for the host is:
>
> Compiled against library: libvir 0.6.3
> Using library: libvir 0.6.3
> Using API: QEMU 0.6.3
> Running hypervisor: QEMU 0.10.5
>
>
> I have tried this against my ubuntu system as well with the same error
> - that has version:
>
> Compiled against library: libvir 0.7.5
> Using library: libvir 0.7.5
> Using API: QEMU 0.7.5
> Running hypervisor: QEMU 0.12.3
>
> I'm currently using jna 3.2.5 with libvirt 0.4.5 bindings.
>
> The example XML being used is:
>
> <domain type="kvm">
>  <name>
>    newguestfomwebapp
>  </name>
>  <memory>
>    512
>  </memory>
>  <vcpu>
>    1
>  </vcpu>
>  <os>
>    <type arch="x86_64" machine="rhel5.4.0">
>      hvm
>    </type>
>    <boot dev="hd"/>
>  </os>
>  <features>
>    <acpi/>
>    <apic/>
>    <pae/>
>  </features>
>  <clock offset="utc"/>
>  <on_poweroff>
>    destroy
>  </on_poweroff>
>  <on_reboot>
>    restart
>  </on_reboot>
>  <on_crash>
>    restart
>  </on_crash>
>  <devices>
>    <emulator>
>      /usr/libexec/qemu-kvm
>    </emulator>
>    <disk type="file" device="cdrom">
>      <driver name="qemu" type="raw"/>
>      <source file="/var/lib/libvirt/images/ISOs/centos5.5-ks.iso"/>
>      <target dev="hdc" bus="ide"/>
>      <readonly/>
>    </disk>
>    <interface type="network">
>      <source network="default"/>
>      <model type="virtio"/>
>    </interface>
>    <input type="mouse" bus="ps2"/>
>    <graphics type="vnc" port="-1" autoport="yes"/>
>  </devices>
> </domain>
>
> If I remove the lifecycle information from the xml I get:
>
> "unknown OS type hvm "
>
> The xml works from the command line with virsh define ...
>
> Anyone seen anything similar or have any ideas?
>
> Regards,
>
> James
>

For the record.... I managed to get this to work in the end and it
appeared to be down to the whitespace.... creating a string
representation of the XML DOM that looked like:

<domain type="kvm">
  <name>testserver2002</name>
  <memory>512</memory>
  <vcpu>1</vcpu>
  <os>
    <type arch="x86_64" machine="pc-0.11">hvm</type>
    <boot dev="hd"/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset="utc"/>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/var/lib/libvirt/images/ISOs/centos5.5-ks.iso"/>
      <target dev="hdc" bus="ide"/>
      <readonly/>
    </disk>
    <interface type="network">
      <source network="default"/>
      <model type="virtio"/>
    </interface>
    <input type="mouse" bus="ps2"/>
    <graphics type="vnc" port="-1" autoport="yes"/>
  </devices>
</domain>

Allowed the domain to be created....

James




More information about the libvirt-users mailing list