I'm having a problem using libvirt to manage "defined" domains (ie:
domains for which it has XML, but are not running.)
I have tried several debugging scenarios, but the simplest one is this.
In a libvirt C program I define the following XML:
char domxml[]="<domain type='xen' id='99'>"
"<name>rhel5vm</name>"
"<uuid>f948d7f4f36c4bfae8053bca535183b3</uuid>"
"<os>"
"<type>linux</type>"
"<kernel>/var/lib/xen/boot/rhel5vm/vmlinuz-2.6.18-8.el5xen</kernel>"
"<initrd>/var/lib/xen/boot/rhel5vm/initrd-2.6.18-8.el5xen.img</initrd>"
"<root>/dev/xvda1</root>"
"</os>"
"<memory>512000</memory>"
"<vcpu>1</vcpu>"
"<on_poweroff>destroy</on_poweroff>"
"<on_reboot>restart</on_reboot>"
"<on_crash>restart</on_crash>"
"<devices>"
"<interface type='bridge'>"
"<source bridge='xenbr0'/>"
"<mac address='00:16:3e:09:ef:b0'/>"
"<script path='vif-bridge'/>"
"</interface>"
"<disk type='block' device='disk'>"
"<driver name='phy'/>"
"<source dev='/dev/sda3'/>"
"<target dev='xvda'/>"
"</disk>"
"<console tty='/dev/pts/2'/>"
"</devices>"
"</domain>";
(I've played with several values for the domain id).
What I find is that when I use virDomainDefineXML() to define the domain,
for some reason it drops, the "root" element from the "os"
specification.
Because of this the domain then crashes when I try to start it.
I've also tried, using virsh to create the domain from an XML file,
capture the XML with virDomainGetXMLDesc(), pause the C program, and then
try to redefine the domain with the domain with the exact XML
virDomainGetXMLDesc() gave me (after destroying the original of course),
and I get the same behavior, it strips the root element from the OS
specification.
Here is the version information:
[root@rhel5-xen tmp]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5 (Tikanga)
[root@rhel5-xen tmp]# uname -a
Linux rhel5-xen 2.6.18-8.1.8.el5xen #1 SMP Mon Jun 25 17:19:38 EDT 2007
x86_64 x86_64 x86_64 GNU/Linux
[root@rhel5-xen tmp]# virsh version
Compiled against library: libvir 0.3.1
Using library: libvir 0.3.1
Using API: Xen 3.0.1
Running hypervisor: Xen 3.0.0
I am using rhel5 "out of the box" with libvirt upgraded to:
libvirt-0.3.1-1.x86_64.rpm
libvirt-devel-0.3.1-1.x86_64.rpm
libvirt-python-0.3.1-1.x86_64.rpm
I tried using libvirt-0.3.2-1, but sample code segv'd in
virConnectClose().
All I'm really trying to do is build a primitive interface to list domains
(both running, and non-running), and start and stop them. I'm open to
suggestions as to whether I have this misconfigured or if there would be a
better version with which to do this.
Thanks,
Evan