[libvirt] Problems starting XEN HVM with libvirt

Matthew Donovan matthew at atc-nycorp.com
Tue Aug 26 13:25:06 UTC 2008


I've been having trouble getting a Xen HVM guest started using libvirt.
I've tried Windows Vista, Fedora Core 8, and Fedora Core 6 guests.  Domain 0
is FC 8.  The only guest that starts correctly is the FC 6 guest.  Has
anyone else encountered something like this?  Is there a master list of
guest OS's that libvirt supports?

Thanks
-matthew


CODE:

#include <stdio.h>
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>


const char* foo = 
"<domain type='xen'>"
"<name>fc6</name>"
"<os>"
    "<type>hvm</type>"
    "<loader>/usr/lib/xen/boot/hvmloader</loader>"
    "<boot dev='hd'/>"
"</os>"
"<memory>512000</memory>"
"<vcpu>1</vcpu>"
"<on_shutdown>shutdown</on_shutdown>"
"<on_reboot>restart</on_reboot>"
"<on_crash>restart</on_crash>"
"<features>"
    "<pae/>"
    "<acpi/>"
    "<apic/>"
"</features>"
"<clock sync='localtime'/>"
"<devices>"
	"<emulator>/usr/lib/xen/bin/qemu-dm</emulator>"
	"<disk type='block'>"
	    "<source dev='/dev/vgvms/fc6_test'/>"
	    "<target dev='hda'/>"
	"</disk>"
    "<interface type='ioemu'>"
        "<mac address='7A:AB:D0:01:82:98'/>"
    "</interface>"
    "<input type='tablet' bus='usb'/>"
    "<graphics type='sdl' password=''/>"
    "<serial type='pty'/>"
"</devices>"
"</domain>";


int main (int argc, char** argv) 
{
    virConnectPtr con;      /* connection to the Xen hypervisor */
    virDomainPtr  domain;

    virInitialize();

    con = virConnectOpen ("xen:///");
    if (!con) {
        virErrorPtr err = virGetLastError ();
        printf ("virConnectOpen failed: %s\n",
                err->message);
        return -1;
    }

    domain = virDomainDefineXML (con, foo);
    if (!domain) {
        virErrorPtr err = virConnGetLastError (con);
        printf ("virDomainDefineXML failed: %s\n",
                err->message);

    } else {
        
        if (virDomainCreate (domain) < 0) {
            virErrorPtr err = virConnGetLastError (con);
            printf ("virDomainCreate failed: %s\n",
                    err->message);
        } else {
            virDomainInfo info = {0};
            virDomainGetInfo (domain, &info);
            printf ("state = %d\n", info.state);
            getchar ();
        }
    }

    virConnectClose (con);
    return 0;
}




More information about the libvir-list mailing list