[Libvir] Problem in Migrating domain....

Hi... This is my program for Domain Migrating using virDomainMigrate() Function.... #include <stdlib.h> #include <stdio.h> #include <libvirt/libvirt.h> static virConnectPtr conn = NULL; /* the hypervisor connection */ static int checkDomainState(virDomainPtr dom) { virDomainInfo info; /* the information being fetched */ int ret; ret = virDomainGetInfo(dom, &info); if (ret < 0) { return(-1); } return(info.state); } static void migrate(int id) { virDomainPtr dom = NULL; /* the domain being checked */ virDomainPtr dom1= NULL; int ret, state; /* Find the domain of the given id */ dom = virDomainLookupByID(conn, id); if (dom == NULL) { fprintf(stderr, "Failed to find Domain %d\n", id); goto error; } state = checkDomainState(dom); if ((state == VIR_DOMAIN_RUNNING)) { dom1=virDomainMigrate(dom,conn,VIR_MIGRATE_LIVE,NULL,NULL,0); if(dom1==NULL) { fprintf(stderr,"Failed to migrate"); } else { fprintf(stderr,"migrate successfully"); } } error: if (dom != NULL) virDomainFree(dom); } int main(int argc, char **argv) { int id = 0; /* NULL means connect to local Xen hypervisor */ conn = virConnectOpen(NULL); if (conn == NULL) { fprintf(stderr, "Failed to connect to hypervisor\n"); goto error; } if (argc > 1) { id = atoi(argv[1]); } if (id == 0) { int i, j, ids[10]; i = virConnectListDomains(conn, &ids[0], 10); if (i < 0) { fprintf(stderr, "Failed to list the domains\n"); goto error; } for (j = 0;j < i;j++) { if (ids[j] != 0) { id = ids[j]; break; } } } if (id == 0) { fprintf(stderr, "Failed find a running guest domain\n"); goto error; } migrate(id); error: if (conn != NULL) virConnectClose(conn); return(0); } When I Compile this by the command gcc `pkg-config --cflags --libs libvirt` migrate1.c I got the error... migrate1.c: In function migrate: migrate1.c:67: warning: assignment makes pointer from integer without a cast /tmp/ccmgmkE1.o: In function `migrate': migrate1.c:(.text+0xd4): undefined reference to `virDomainMigrate' collect2: ld returned 1 exit status Can you help me... with regard, Mano

On Thu, Apr 03, 2008 at 04:44:45PM +0530, manon.mani@wipro.com wrote:
migrate1.c: In function migrate: migrate1.c:67: warning: assignment makes pointer from integer without a cast /tmp/ccmgmkE1.o: In function `migrate': migrate1.c:(.text+0xd4): undefined reference to `virDomainMigrate' collect2: ld returned 1 exit status
Can you help me...
Update your libvirt version to something recent, I guess it's the problem. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Thu, Apr 03, 2008 at 04:44:45PM +0530, manon.mani@wipro.com wrote:
migrate1.c: In function migrate: migrate1.c:67: warning: assignment makes pointer from integer without a cast /tmp/ccmgmkE1.o: In function `migrate': migrate1.c:(.text+0xd4): undefined reference to `virDomainMigrate' collect2: ld returned 1 exit status
As Daniel said, this is because your version of libvirt is older than version 0.3.2. This page may help: http://libvirt.org/hvsupport.html Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
participants (3)
-
Daniel Veillard
-
manon.mani@wipro.com
-
Richard W.M. Jones