Re: [libvirt] virStoragePoolDefParseString() fails with the following pool xml
Hi, I'm still having problems getting a virStoragePoolDefPtr from virStoragePoolDefParseString(xml). I've tried the example xmls in libvirt but still getting NULL. Can someone check if the following xml when passed to virStoragePoolDefParseString(..) returns a pointer to virStoragePoolDefPtr, so that I can confirm that this function really works. If something is wrong with the following XML please point out. NFS ISO library 6142b786-378d-9def-bc96-2d0dc0466c13 838729728 838729728 148315040 / 00 0 0 Thanks, Sharadha -Original Message----- From: Sharadha Prabhakar (3P) Sent: 19 March 2010 11:10 To: 'Daniel P. Berrange' Cc: libvir-list@redhat.com Subject: RE: [libvirt] virStoragePoolDefParseString() fails with the following pool xml -Original Message- From: Daniel P. Berrange [mailto:berra...@redhat.com] Sent: 19 March 2010 10:57 To: Sharadha Prabhakar (3P) Cc: libvir-list@redhat.com Subject: Re: [libvirt] virStoragePoolDefParseString() fails with the following pool xml On Fri, Mar 19, 2010 at 10:37:15AM +, Sharadha Prabhakar (3P) wrote: > Hi, > I have the following Pool XML > > > NFS ISO library > 6142b786-378d-9def-bc96-2d0dc0466c13 > 838729728 > 838729728 > 148315040 > > > >That needs to be '' instead of just ' I only filled the virStoragePoolDefPtr and passed it to virStoragePoolDefFormat(..) which Returned the XML string that you see now. I've attached the function I used to fill pdef and The call to virStoragePoolDefFormat at the end of this mail. I'm using libvirt version 0.7.6 > > > > > 00 > 0 > 0 > > > > > I'm passing this string to virStoragePoolDefParseString() to get a > virStoragePoolDefPtr > But it returns NULL. Can anyone explain if there's something wrong with the > XML format? >FYI, there are example XML files in examples/xml/storage/ too static char * xenapiStoragePoolGetXMLDesc (virStoragePoolPtr pool, unsigned int flags ATTRIBUTE_UNUSED) { xen_sr_record *record=NULL; xen_sr sr=NULL; xen_pbd_set *pbd_set=NULL; xen_pbd pbd=NULL; char *pathDetails = NULL, *host=NULL, *path=NULL,*xml=NULL; virConnectPtr conn = pool->conn; virStoragePoolDefPtr pdef=NULL; char uuidStr[VIR_UUID_STRING_BUFLEN]; int i; xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session; virUUIDFormat(pool->uuid,uuidStr); if (xen_sr_get_by_uuid(session, &sr, uuidStr)) { if (!xen_sr_get_record(session, &record, sr)) { xen_sr_free(sr); xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get SR information"); return NULL; } if (VIR_ALLOC(pdef)<0) { virReportOOMError(); xen_sr_record_free(record); return NULL; } if (STREQ(record->type,"nfs") || STREQ(record->type,"iso")) pdef->type = VIR_STORAGE_POOL_NETFS; else if(STREQ(record->type,"iscsi")) pdef->type = VIR_STORAGE_POOL_ISCSI; else if(STREQ(record->type,"file")) pdef->type = VIR_STORAGE_POOL_DIR; else if(STREQ(record->type,"lvm")) pdef->type = VIR_STORAGE_POOL_LOGICAL; else if(STREQ(record->type,"ext")) pdef->type = VIR_STORAGE_POOL_FS; else if(STREQ(record->type,"hba")) pdef->type = VIR_STORAGE_POOL_SCSI; fprintf(stderr,"\ntype:%s",virStoragePoolTypeToString(pdef->type)); if (!(pdef->name = strdup(record->name_label))) { virReportOOMError(); xen_sr_record_free(record); virStoragePoolDefFree(pdef); return NULL; //goto cleanup; } virUUIDParse(record->uuid,pdef->uuid); pdef->allocation = (record->virtual_allocation)/1024; pdef->capacity = (record->physical_size)/1024; pdef->available = (record->physical_size - record->physical_utilisation)/1024; if (STREQ(record->type,"ext")) { pdef->source.format = VIR_STORAGE_POOL_FS_EXT3; } else if (STREQ(record->type,"nfs")) { pdef->source.format = VIR_STORAGE_POOL_NETFS_NFS; } xen_sr_get_pbds (session, &pbd_set, sr); pbd = pbd_set->contents[0]; xen_string_string_map *deviceConfig=NULL; xen_pbd_get_device_config(session, &deviceConfig, pbd); if (deviceConfig) { for (i=0;isize;i++) { if
Re: [libvirt] virStoragePoolDefParseString() fails with the following pool xml
I just added target path to pool XML. It doesn't resolve the issue. virStoragePoolDefParseString() returns NULL. -Original Message- From: Daniel P. Berrange [mailto:berra...@redhat.com] Sent: 19 March 2010 11:16 To: Sharadha Prabhakar (3P) Cc: libvir-list@redhat.com Subject: Re: [libvirt] virStoragePoolDefParseString() fails with the following pool xml On Fri, Mar 19, 2010 at 10:37:15AM +0000, Sharadha Prabhakar (3P) wrote: > Hi, > I have the following Pool XML > > > NFS ISO library > 6142b786-378d-9def-bc96-2d0dc0466c13 > 838729728 > 838729728 > 148315040 > > > > > > > > 00 > 0 > 0 > > > > > I'm passing this string to virStoragePoolDefParseString() to get a > virStoragePoolDefPtr > But it returns NULL. Can anyone explain if there's something wrong with the > XML format? > I ran gdb and I kind of figured out that it fails at > if (virStoragePoolDefParseSource(ctxt, &ret->source, ret->type, > source_node) < 0) in > virStoragePoolDefParseXML() > in ~/src/conf/storage_conf.c I think you've got the wrong place here. If I feed your XML to 'virsh pool-define' using the QEMU driver, then I get error: XML description for missing storage pool target path is not well formed or invalid which is from static virStoragePoolDefPtr virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) { if ((ret->target.path = virXPathString("string(./target/path)", ctxt)) == NULL) { virStorageReportError(VIR_ERR_XML_ERROR, "%s", _("missing storage pool target path")); goto cleanup; } You need to add at least / as we previously discussed Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] virStoragePoolDefParseString() fails with the following pool xml
-Original Message- From: Daniel P. Berrange [mailto:berra...@redhat.com] Sent: 19 March 2010 10:57 To: Sharadha Prabhakar (3P) Cc: libvir-list@redhat.com Subject: Re: [libvirt] virStoragePoolDefParseString() fails with the following pool xml On Fri, Mar 19, 2010 at 10:37:15AM +, Sharadha Prabhakar (3P) wrote: > Hi, > I have the following Pool XML > > > NFS ISO library > 6142b786-378d-9def-bc96-2d0dc0466c13 > 838729728 > 838729728 > 148315040 > > > >That needs to be '' instead of just ' I only filled the virStoragePoolDefPtr and passed it to virStoragePoolDefFormat(..) which Returned the XML string that you see now. I've attached the function I used to fill pdef and The call to virStoragePoolDefFormat at the end of this mail. I'm using libvirt version 0.7.6 > > > > > 00 > 0 > 0 > > > > > I'm passing this string to virStoragePoolDefParseString() to get a > virStoragePoolDefPtr > But it returns NULL. Can anyone explain if there's something wrong with the > XML format? >FYI, there are example XML files in examples/xml/storage/ too static char * xenapiStoragePoolGetXMLDesc (virStoragePoolPtr pool, unsigned int flags ATTRIBUTE_UNUSED) { xen_sr_record *record=NULL; xen_sr sr=NULL; xen_pbd_set *pbd_set=NULL; xen_pbd pbd=NULL; char *pathDetails = NULL, *host=NULL, *path=NULL,*xml=NULL; virConnectPtr conn = pool->conn; virStoragePoolDefPtr pdef=NULL; char uuidStr[VIR_UUID_STRING_BUFLEN]; int i; xen_session *session = ((struct _xenapiStoragePrivate *)(conn->storagePrivateData))->session; virUUIDFormat(pool->uuid,uuidStr); if (xen_sr_get_by_uuid(session, &sr, uuidStr)) { if (!xen_sr_get_record(session, &record, sr)) { xen_sr_free(sr); xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get SR information"); return NULL; } if (VIR_ALLOC(pdef)<0) { virReportOOMError(); xen_sr_record_free(record); return NULL; } if (STREQ(record->type,"nfs") || STREQ(record->type,"iso")) pdef->type = VIR_STORAGE_POOL_NETFS; else if(STREQ(record->type,"iscsi")) pdef->type = VIR_STORAGE_POOL_ISCSI; else if(STREQ(record->type,"file")) pdef->type = VIR_STORAGE_POOL_DIR; else if(STREQ(record->type,"lvm")) pdef->type = VIR_STORAGE_POOL_LOGICAL; else if(STREQ(record->type,"ext")) pdef->type = VIR_STORAGE_POOL_FS; else if(STREQ(record->type,"hba")) pdef->type = VIR_STORAGE_POOL_SCSI; fprintf(stderr,"\ntype:%s",virStoragePoolTypeToString(pdef->type)); if (!(pdef->name = strdup(record->name_label))) { virReportOOMError(); xen_sr_record_free(record); virStoragePoolDefFree(pdef); return NULL; //goto cleanup; } virUUIDParse(record->uuid,pdef->uuid); pdef->allocation = (record->virtual_allocation)/1024; pdef->capacity = (record->physical_size)/1024; pdef->available = (record->physical_size - record->physical_utilisation)/1024; if (STREQ(record->type,"ext")) { pdef->source.format = VIR_STORAGE_POOL_FS_EXT3; } else if (STREQ(record->type,"nfs")) { pdef->source.format = VIR_STORAGE_POOL_NETFS_NFS; } xen_sr_get_pbds (session, &pbd_set, sr); pbd = pbd_set->contents[0]; xen_string_string_map *deviceConfig=NULL; xen_pbd_get_device_config(session, &deviceConfig, pbd); if (deviceConfig) { for (i=0;isize;i++) { if(STREQ(deviceConfig->contents[i].key,"location")) { fprintf(stderr,"\nfound location"); pathDetails = strdup(deviceConfig->contents[i].val); break; } } xen_string_string_map_free(deviceConfig); } if (pathDetails) { VIR_ALLOC_N(host,strlen(pathDetails)); VIR_ALLOC_N(path,strlen(pathDetails)); if(pathDetails[0]!='/') { sscanf(pathDetails,"%[^:]:%s",host,path); } else { if(pathDetails[1]=='/') { sscanf(pathDetails,"//%[^/]%s",host,path); } else { strcpy(path,pathDetails); } } fprintf(stderr,"\n
[libvirt] virStoragePoolDefParseString() fails with the following pool xml
Hi, I have the following Pool XML NFS ISO library 6142b786-378d-9def-bc96-2d0dc0466c13 838729728 838729728 148315040 00 0 0 I'm passing this string to virStoragePoolDefParseString() to get a virStoragePoolDefPtr But it returns NULL. Can anyone explain if there's something wrong with the XML format? I ran gdb and I kind of figured out that it fails at if (virStoragePoolDefParseSource(ctxt, &ret->source, ret->type, source_node) < 0) in virStoragePoolDefParseXML() in ~/src/conf/storage_conf.c The reason I need this is to dump Volume XML which takes the poolDefPtr as well as VolDefPtr To return the XML format(virStorageVolDefFormat()). Is there a simpler way of producing the Volume XML just using the VolDefPtr? Regards, Sharadha -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] virStoragePoolGetXMLDesc - how to specify format type
Hi, I'm trying to write virStoragePoolGetXMLDesc() for XenAPI remote storage. I'd like to produce an XML similar to this I'm trying to fill in the virStoragePoolDefPtr for this. I need to know if struct _virStoragePoolSource->format Is the one to fill for format type="nfs". It's seemingly an integer. Is there any enum for format types for Nfs and ext3? I couldn't find any in storage_conf.h My next query is, when would I have to fill in device path? What is it used for And which pool types use it for remote storage? Could someone explain? Regards, Sharadha -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] XenAPI remote storage - target path
> Hi, > I'm trying to write a Remote Storage driver for XenAPI. > I see that target-path is used for both storage pools and volumes. > In the case of XenAPI remote storage, the storage is not mounted on the > local host where libvirt is running. Storage is maintained in a remote > location only. > In this case how do I specify target-path and how do I go about creating > a VM with storage using libvirt APIs with virsh and virt-manager. > Virt-manager expects me to give an absolute path for target-path. But In my > case > I don't have an absolute path. > Can I have a target path like this for a particular storage volume > "/storage pool uuid/storage-vol uuid"? This will help me identify which > storage pool is > Libvirt talking about and which volume in it. Using this information I can > fetch data from > The remote location and give it back to libvirt. Is this approach > ok or does libvirt support my specific remote storage case in some way. Could > someone > clarify please? >It may help to understand the usage scenario. > - App creates a storage pool with a target '/foo' In the case of XenAPI there will be no target, it can be '/' for now as you said. The tag will have the host name and path. > - App creates a storage volume called 'bar' The volume target path will be /sr-uuid/vol-uuid > - Storage pool driver creates a path for volume based on pool target and > volume name. eg it might decide /foo/bar driver creates the path /sr-uuid/vol-uuid > - App queries path of new volume and gets '/foo/bar' virStorageVolGetPath() will return same as above for any volume > - App creates a new disk, passing '/foo/bar' in the element in > the guest XML source in the disk element will have the same path. Here using sr-uuid the driver would locate the actual location of the SR and the specified volume in it using vol-uuid and attach it to the new VM being created. >The real key thing here is that 'virStorageVolGetPath' *must* return a path >suitable for use in the guest XML element >To answer your question then, we ned to know what the path looks like that >you use to configure the guest disk when starting the guest ? Once you >know that, then the storage driver must be implemented such that >virStorageVolGetPath() returns a path that matches what XenAPI wants for >the guest config. This will be the UUID path as usual. As I said earlier XenAPI will get the Actual location from the UUIDs and attach with the new guest VM. >As for pool target, if nothing else you can simply require that the pool >is configured with a target path of '/' at which point it is essentially >ignorable, since all paths start with a '/' anyway. There is no pool target so I'll just leave it with '/' for now. |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] XenAPI remote storage - target path
Hi, I'm trying to write a Remote Storage driver for XenAPI. I see that target-path is used for both storage pools and volumes. In the case of XenAPI remote storage, the storage is not mounted on the local host where libvirt is running. Storage is maintained in a remote location only. In this case how do I specify target-path and how do I go about creating a VM with storage using libvirt APIs with virsh and virt-manager. Virt-manager expects me to give an absolute path for target-path. But In my case I don't have an absolute path. Can I have a target path like this for a particular storage volume "/storage pool uuid/storage-vol uuid"? This will help me identify which storage pool is Libvirt talking about and which volume in it. Using this information I can fetch data from The remote location and give it back to libvirt. Is this approach ok or does libvirt support my specific remote storage case in some way. Could someone clarify please? Regards, Sharadha -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] XenAPI remote storage - target path
Hi, I'm trying to write a Remote Storage driver for XenAPI. I see that target-path is used for both storage pools and volumes. In the case of XenAPI remote storage, the storage is not mounted on the local host where libvirt is running. Storage is maintained in a remote location only. In this case how do I specify target-path and how do I go about creating a VM with storage using libvirt APIs with virsh and virt-manager. Virt-manager expects me to give an absolute path for target-path. But In my case I don't have an absolute path. Can I have a target path like this for a particular storage volume "/storage pool uuid/storage-vol uuid"? This will help me identify which storage pool is Libvirt talking about and which volume in it. Using this information I can fetch data from The remote location and give it back to libvirt. Is this approach ok or does libvirt support my specific remote storage case in some way. Could someone clarify please? Regards, Sharadha -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] Addition of XenAPI support to libvirt
Resending patch 2 as attachment. Sharadha -Original Message- From: Matthias Bolte [mailto:matthias.bo...@googlemail.com] Sent: 05 March 2010 21:42 To: Sharadha Prabhakar (3P) Cc: libvir-list@redhat.com; Ewan Mellor Subject: Re: [libvirt] [PATCH 2/2] Addition of XenAPI support to libvirt 2010/3/5 Sharadha Prabhakar (3P) : > Please see my comments inline. The diff content of PATCH 2/2 with the changes > is > submitted at the end of this mail. Okay, this patch looks good now. I tried to apply it but the patch seems mangled. It seems that you copy and pasted the content of the patch into the mail body and your mail program mangled it. Please resend this patch, but attach the patch as file to the mail, so your mail program does not mangle it. Matthias xenapiPatch2 Description: xenapiPatch2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] Addition of XenAPI support to libvirt
Please see my comments inline. The diff content of PATCH 2/2 with the changes is submitted at the end of this mail. @<:@default=/usr/local/lib@:>@]),[],[with_libssh2=yes]) > AC_ARG_WITH([phyp], > AC_HELP_STRING([--with-phyp], [add PHYP support > @<:@default=check@:>@]),[],[with_phyp=check]) > +AC_ARG_WITH([xenapi], > + AC_HELP_STRING([--with-xenapi], [add XenAPI support > @<:@default=yes@:>@]),[],[with_xenapi=check]) >The actual default and the printed one mismatch. change default=yes to >default=check This has been changed. > AC_ARG_WITH([vbox], > AC_HELP_STRING([--with-vbox], [add VirtualBox support > @<:@default=yes@:>@]),[],[with_vbox=yes]) > AC_ARG_WITH([lxc], > @@ -307,6 +309,7 @@ > fi > AM_CONDITIONAL([WITH_VBOX], [test "$with_vbox" = "yes"]) > > + > if test "$with_libvirtd" = "no" ; then > with_qemu=no > fi > @@ -335,6 +338,49 @@ > fi > AM_CONDITIONAL([WITH_LIBVIRTD], [test "$with_libvirtd" = "yes"]) > > + > +old_LIBS="$LIBS" > +old_CFLAGS="$CFLAGS" > +LIBXENSERVER_LIBS="" > +LIBXENSERVER_CFLAGS="" > +LIBXENSERVER_LDFLAGS="" > +dnl search for the XenServer library > +if test "$with_xenapi" != "no" ; then > +if test "$with_xenapi" != "yes" -a "$with_xenapi" != "check" ; then > +LIBXENSERVER_CFLAGS="-I$with_xenapi/include" > +LIBXENSERVER_LDFLAGS="$with_xenapi/libxenserver.so" >Why do you add the path to an .so file to the LDFLAGS? I wasn't sure that adding LIBXENSERVER_LIBS to xenapi_ldflags would Suffice. LIBXENSERVER_LDFLAGS has been removed now. > +LIBXENSERVER_LIBS="-L$with_xenapi -lxenserver" > +fi > +fail=0 > +CFLAGS="$CFLAGS $LIBXENSERVER_CFLAGS" > +LIBS="$LIBS $LIBXENSERVER_LIBS" > +AC_CHECK_LIB([xen_vm_start], [xs_read], [ >I'm not sure that I understand what you're doing here. You're checking >for a xs_read function in a xen_vm_start library. This has been changed to check for the function xen_vm_start in libxenserver. > + with_xenapi=yes > + LIBXENSERVER_LIBS="$LIBXENSERVER_LIBS -lxenstore" >Do you really need xenstore? No. It has been changed to -lxenserver > + ],[ > + if test "$with_xenapi" = "yes"; then > + fail=1 > + fi > + with_xenapi=no > + ]) > +fi > + > +LIBS="$old_LIBS" > +CFLAGS="$old_CFLAGS" > + > +if test $fail = 1; then > +AC_MSG_ERROR([You must install the XenServer Library to compile XenAPI > driver with -lxenserver]) > +fi > + > +if test "$with_xenapi" = "yes"; then > +AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether Xen driver is enabled]) >'XenAPI driver' instead of 'Xen driver' Done > +fi > + > +AC_SUBST([LIBXENSERVER_CFLAGS]) > +AC_SUBST([LIBXENSERVER_LIBS]) > +AC_SUBST([LIBXENSERVER_LDFLAGS]) > + > + > old_LIBS="$LIBS" > old_CFLAGS="$CFLAGS" > XEN_LIBS="" > @@ -1447,23 +1493,31 @@ > LIBCURL_LIBS="" > LIBCURL_FOUND="no" > > -if test "$with_esx" = "yes" -o "$with_esx" = "check"; then > +if test "$with_esx" = "yes" -o "$with_esx" = "check" -o "$with_xenapi" = > "yes" -o "$with_xenapi" = "check"; >then > PKG_CHECK_MODULES(LIBCURL, libcurl >= $LIBCURL_REQUIRED, [ > LIBCURL_FOUND=yes > with_esx="yes" > +with_xenapi="yes" >This part should be split into an ESX and XenAPI part. Otherwise you >may change with_esx="no" to with_esx="yes" just because libcurl was >found. > ], [ > -if test "$with_esx" = "check"; then > +if test "$with_esx" = "check" -o "$with_xenapi" = "check"; then > with_esx=no > -AC_MSG_NOTICE([libcurl is required for ESX driver, disabling it]) > +with_xenapi=no > +AC_MSG_NOTICE([libcurl is required for ESX/XENAPI driver, > disabling it]) > else > -AC_MSG_ERROR([libcurl >= $LIBCURL_REQUIRED is required for the > ESX driver]) > +AC_MSG_ERROR([libcurl >= $LIBCURL_REQUIRED is required for the > ESX/XENAPI driver]) > fi >Also this part should be split into an ESX and XenAPI part. > ]) > fi > if test "$with_esx" = "yes" ; then > AC_DEFINE_UNQUOTED([WITH_ESX], 1, [whether ESX driver is enabled]) > fi > + > +if test "$with_xenapi" = "yes" ; then > +AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether XenAPI driver is enabled]) > +fi > + > AM_CONDITIONAL([WITH_ESX], [test "$with_esx" = "yes"]) > +AM_CONDITIONAL([WITH_XENAPI], [test "$with_xenapi" = "yes"]) > AC_SUBST([LIBCURL_CFLAGS]) > AC_SUBST([LIBCURL_LIBS]) >I suggest to restructure this tests like this: dnl dnl check for libcurl (ESX/XenAPI) dnl LIBCURL_CFLAGS="" LIBCURL_LIBS="" if test "$with_esx" = "yes" -o "$with_esx" = "check" -o "$with_xenapi" = "yes" -o "$with_xenapi" = "check"; then PKG_CHECK_MODULES(LIBCURL, libcurl >= $LIBCURL_REQUIRED, [ if test "$with_esx" = "check"; then with_esx=yes fi if test "$with_xenapi" = "check"; then with_xenapi=yes fi ], [ if test "$with_esx" = "check"; then with_e
Re: [libvirt] status on review comments
I've updated the patch with the changes discussed in this mail. Patch just posted. Regards, Sharadha -Original Message- From: Matthias Bolte [mailto:matthias.bo...@googlemail.com] Sent: 03 March 2010 15:28 To: Sharadha Prabhakar (3P) Cc: libvir-list@redhat.com; Ewan Mellor Subject: Re: status on review comments 2010/3/3 Sharadha Prabhakar (3P) : > I've sent a patch containing most of the changes you'd suggested, except the > Following ones. My comments inline. > >> diff -Nur ./libvirt_org/src/xenapi/xenapi_driver.c >> ./libvirt/src/xenapi/xenapi_driver.c >> --- ./libvirt_org/src/xenapi/xenapi_driver.c 1970-01-01 >> 01:00:00.0 +0100 >> +++ ./libvirt/src/xenapi/xenapi_driver.c 2010-02-26 >> 15:27:00.0 + >> @@ -0,0 +1,1564 @@ >> + >> +/* >> + * xenapi_driver.c: Xen API driver. >> + * Copyright (C) 2009 Citrix Ltd. >> + * Sharadha Prabhakar >> +*/ >> + > > >> + >> +char *url=NULL; > >>You should move this into the xenapiPrivate struct, otherwise you'll >>have trouble using multiple XenAPI connections at the same time, >>because multiple calls to xenapiOpen will overwrite the pointer an >>leak the previous value. > > url is passed to call_func() which is used by curl to talk to the server. > Call_func() doesn't have access to 'conn', hence it can't be embedded there. > I'll figure out a way to do this. The recent patch also has a SSL_verfiy flag > which is global and used by call_func that should also be embedded similarly. The second parameter for xen_session_login_with_password is a void pointer for user data. You can pass a pointer to the xenapiPrivate struct there. Then libxenserver will pass it to the call_func function as the user_handle parameter (I just verified this by looking at the libxenserver codebase). Regarding the no_verify query parameter: You should look at esxUtil_ParseQuery how the qparam_query_parse function is used there instead of parsing the URI yourself using strtok_r. >> +* >> +* Returns OS version on success or NULL in case of error >> +*/ >> +static char * >> +xenapiDomainGetOSType (virDomainPtr dom) >> +{ >> + /* vm.get_os-version */ >> + int i; >> + xen_vm vm; >> + char *os_version=NULL; >> + xen_vm_record *record; >> + xen_string_string_map *result; >> + char uuid[VIR_UUID_STRING_BUFLEN]; >> + xen_session *session = ((struct _xenapiPrivate >> *)(dom->conn->privateData))->session; >> + virUUIDFormat(dom->uuid,uuid); >> + if (xen_vm_get_by_uuid(session, &vm, uuid)) { >> + xen_vm_get_record(session, &record, vm); >> + if (record) { >> + xen_vm_guest_metrics_get_os_version(session, &result, >> record->guest_metrics->u.handle); >> + if (result) { >> + for (i=0; i<(result->size); i++) { >> + if (STREQ(result->contents[i].key, "distro")) { >> + if (STREQ(result->contents[i].val, "windows")) { > >>Is distro != windows a good indicator for paravirtualization mode? How >>do you detect the case when you have a non-windows system in HVM mode? > > As of now, the hypervisor supports only windows in HVM. I already installed Linux in Xen's HVM mode, that's why I asked. In that case your code would report paravirtualization mode, instead of HVM. >> diff -Nur ./libvirt_org/src/xenapi/xenapi_utils.c >> ./libvirt/src/xenapi/xenapi_utils.c >> --- ./libvirt_org/src/xenapi/xenapi_utils.c 1970-01-01 >> 01:00:00.0 +0100 >> +++ ./libvirt/src/xenapi/xenapi_utils.c 2010-02-26 15:49:24.0 + >> @@ -0,0 +1,433 @@ >> +/* >> + * xenapi_utils.c: Xen API driver -- utils parts. >> + * Copyright (C) 2009 Citrix Ltd. >> + * Sharadha Prabhakar >> + */ >> + > >> + >> +/* converts bitmap to string of the form '1,2...' */ >> +char * >> +mapDomainPinVcpu(unsigned int vcpu, unsigned char *cpumap, int maplen) >> +{ >> + char buf[VIR_UUID_BUFLEN], mapstr[sizeof(cpumap_t) * 64]; Okay, you could change it like this: -char buf[VIR_UUID_BUFLEN], mapstr[sizeof(cpumap_t) * 64]; +virBuffer buf = VIR_BUFFER_INITIALIZER; +size_t len; >> + char *ret=NULL; >> + int i, j; >> + mapstr[0] = 0; -mapstr[0] = 0; >> + for (i = 0; i < maplen; i++) { >> + for (j = 0; j < 8; j++) { >> + if (cpumap[i] & (1 << j)) { >> + snprintf(buf, sizeof(buf), "%d,", (8 * i) + j)
[libvirt] status on review comments
I've sent a patch containing most of the changes you'd suggested, except the Following ones. My comments inline. > diff -Nur ./libvirt_org/src/xenapi/xenapi_driver.c > ./libvirt/src/xenapi/xenapi_driver.c > --- ./libvirt_org/src/xenapi/xenapi_driver.c 1970-01-01 01:00:00.0 > +0100 > +++ ./libvirt/src/xenapi/xenapi_driver.c 2010-02-26 15:27:00.0 > + > @@ -0,0 +1,1564 @@ > + > +/* > + * xenapi_driver.c: Xen API driver. > + * Copyright (C) 2009 Citrix Ltd. > + * Sharadha Prabhakar > +*/ > + > + > +char *url=NULL; >You should move this into the xenapiPrivate struct, otherwise you'll >have trouble using multiple XenAPI connections at the same time, >because multiple calls to xenapiOpen will overwrite the pointer an >leak the previous value. url is passed to call_func() which is used by curl to talk to the server. Call_func() doesn't have access to 'conn', hence it can't be embedded there. I'll figure out a way to do this. The recent patch also has a SSL_verfiy flag which is global and used by call_func that should also be embedded similarly. > +* > +* Returns OS version on success or NULL in case of error > +*/ > +static char * > +xenapiDomainGetOSType (virDomainPtr dom) > +{ > + /* vm.get_os-version */ > + int i; > + xen_vm vm; > + char *os_version=NULL; > + xen_vm_record *record; > + xen_string_string_map *result; > + char uuid[VIR_UUID_STRING_BUFLEN]; > + xen_session *session = ((struct _xenapiPrivate > *)(dom->conn->privateData))->session; > + virUUIDFormat(dom->uuid,uuid); > + if (xen_vm_get_by_uuid(session, &vm, uuid)) { > + xen_vm_get_record(session, &record, vm); > + if (record) { > + xen_vm_guest_metrics_get_os_version(session, &result, > record->guest_metrics->u.handle); > + if (result) { > + for (i=0; i<(result->size); i++) { > + if (STREQ(result->contents[i].key, "distro")) { > + if (STREQ(result->contents[i].val, "windows")) { >Is distro != windows a good indicator for paravirtualization mode? How >do you detect the case when you have a non-windows system in HVM mode? As of now, the hypervisor supports only windows in HVM. > diff -Nur ./libvirt_org/src/xenapi/xenapi_utils.c > ./libvirt/src/xenapi/xenapi_utils.c > --- ./libvirt_org/src/xenapi/xenapi_utils.c 1970-01-01 01:00:00.0 > +0100 > +++ ./libvirt/src/xenapi/xenapi_utils.c 2010-02-26 15:49:24.0 + > @@ -0,0 +1,433 @@ > +/* > + * xenapi_utils.c: Xen API driver -- utils parts. > + * Copyright (C) 2009 Citrix Ltd. > + * Sharadha Prabhakar > + */ > + > + > +/* converts bitmap to string of the form '1,2...' */ > +char * > +mapDomainPinVcpu(unsigned int vcpu, unsigned char *cpumap, int maplen) > +{ > + char buf[VIR_UUID_BUFLEN], mapstr[sizeof(cpumap_t) * 64]; > + char *ret=NULL; > + int i, j; > + mapstr[0] = 0; > + for (i = 0; i < maplen; i++) { > + for (j = 0; j < 8; j++) { > + if (cpumap[i] & (1 << j)) { > + snprintf(buf, sizeof(buf), "%d,", (8 * i) + j); > + strcat(mapstr, buf); >Use the virBuffer API instea of snprintf and strcat. > + } > + } > + } > + mapstr[strlen(mapstr) - 1] = 0; > + snprintf(buf, sizeof(buf), "%d", vcpu); > + ret = strdup(mapstr); >Use virAsprintf instead of snprintf and strdup. > + return ret; > +} > + I couldn't find a way to match virBuffer APIs to do the exact operations as Above. Is there a strcat substitute in virBuffer APIs? Regards, Sharadha -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Query regarding no_verify in uri
Hi Daniel, I've submitted my XenAPI driver in 2parts before sometime with all the changes you had suggested. The following is possibly the only one that's not handled. > +curl_easy_setopt(curl, CURLOPT_POST, 1); > +curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); > +curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, len); > +curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); > +curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); >You shouldn't disable SSL verification here. It should be on by default. >For consistency with other libvirt drivers, you may wish to allow your >xenapi:/// uri to have an optional 'no_verify=1' parameter to turn >off SSL verification. It should always be verifying by default though. For now I have enabled verify SSL. I'm not sure about how libvirt hands Over the no_verify=1 part that the user types in the URI to my driver. virDrvOpen only receives the URI elements from 'conn' parameter. I couldn't find this information embedded in 'conn'? Could you explain how to get this information? Regards, Sharadha -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] Addition of XenAPI support to libvirt
This is the last patch in this series. It contains changes made to the following files. ~/libvirt/configure.ac ~/libvirt/src/Makefile.am ~/libvirt/src/util/virterror.c ~/libvirt/src/driver.h ~/libvirt/include/libvirt/virterror.h ~/libvirt/virterror.c --- ./libvirt_org/configure.ac 2010-02-17 17:39:21.0 + +++ ./libvirt/configure.ac 2010-02-26 11:18:47.0 + @@ -219,6 +219,8 @@ AC_HELP_STRING([--with-libssh2=@<:@PFX@:>@], [libssh2 location @<:@default=/usr/local/lib@:>@]),[],[with_libssh2=yes]) AC_ARG_WITH([phyp], AC_HELP_STRING([--with-phyp], [add PHYP support @<:@default=check@:>@]),[],[with_phyp=check]) +AC_ARG_WITH([xenapi], + AC_HELP_STRING([--with-xenapi], [add XenAPI support @<:@default=yes@:>@]),[],[with_xenapi=check]) AC_ARG_WITH([vbox], AC_HELP_STRING([--with-vbox], [add VirtualBox support @<:@default=yes@:>@]),[],[with_vbox=yes]) AC_ARG_WITH([lxc], @@ -307,6 +309,7 @@ fi AM_CONDITIONAL([WITH_VBOX], [test "$with_vbox" = "yes"]) + if test "$with_libvirtd" = "no" ; then with_qemu=no fi @@ -335,6 +338,49 @@ fi AM_CONDITIONAL([WITH_LIBVIRTD], [test "$with_libvirtd" = "yes"]) + +old_LIBS="$LIBS" +old_CFLAGS="$CFLAGS" +LIBXENSERVER_LIBS="" +LIBXENSERVER_CFLAGS="" +LIBXENSERVER_LDFLAGS="" +dnl search for the XenServer library +if test "$with_xenapi" != "no" ; then +if test "$with_xenapi" != "yes" -a "$with_xenapi" != "check" ; then +LIBXENSERVER_CFLAGS="-I$with_xenapi/include" +LIBXENSERVER_LDFLAGS="$with_xenapi/libxenserver.so" +LIBXENSERVER_LIBS="-L$with_xenapi -lxenserver" +fi +fail=0 +CFLAGS="$CFLAGS $LIBXENSERVER_CFLAGS" +LIBS="$LIBS $LIBXENSERVER_LIBS" +AC_CHECK_LIB([xen_vm_start], [xs_read], [ + with_xenapi=yes + LIBXENSERVER_LIBS="$LIBXENSERVER_LIBS -lxenstore" + ],[ + if test "$with_xenapi" = "yes"; then + fail=1 + fi + with_xenapi=no + ]) +fi + +LIBS="$old_LIBS" +CFLAGS="$old_CFLAGS" + +if test $fail = 1; then +AC_MSG_ERROR([You must install the XenServer Library to compile XenAPI driver with -lxenserver]) +fi + +if test "$with_xenapi" = "yes"; then +AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether Xen driver is enabled]) +fi + +AC_SUBST([LIBXENSERVER_CFLAGS]) +AC_SUBST([LIBXENSERVER_LIBS]) +AC_SUBST([LIBXENSERVER_LDFLAGS]) + + old_LIBS="$LIBS" old_CFLAGS="$CFLAGS" XEN_LIBS="" @@ -1447,23 +1493,31 @@ LIBCURL_LIBS="" LIBCURL_FOUND="no" -if test "$with_esx" = "yes" -o "$with_esx" = "check"; then +if test "$with_esx" = "yes" -o "$with_esx" = "check" -o "$with_xenapi" = "yes" -o "$with_xenapi" = "check"; then PKG_CHECK_MODULES(LIBCURL, libcurl >= $LIBCURL_REQUIRED, [ LIBCURL_FOUND=yes with_esx="yes" +with_xenapi="yes" ], [ -if test "$with_esx" = "check"; then +if test "$with_esx" = "check" -o "$with_xenapi" = "check"; then with_esx=no -AC_MSG_NOTICE([libcurl is required for ESX driver, disabling it]) +with_xenapi=no +AC_MSG_NOTICE([libcurl is required for ESX/XENAPI driver, disabling it]) else -AC_MSG_ERROR([libcurl >= $LIBCURL_REQUIRED is required for the ESX driver]) +AC_MSG_ERROR([libcurl >= $LIBCURL_REQUIRED is required for the ESX/XENAPI driver]) fi ]) fi if test "$with_esx" = "yes" ; then AC_DEFINE_UNQUOTED([WITH_ESX], 1, [whether ESX driver is enabled]) fi + +if test "$with_xenapi" = "yes" ; then +AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether XenAPI driver is enabled]) +fi + AM_CONDITIONAL([WITH_ESX], [test "$with_esx" = "yes"]) +AM_CONDITIONAL([WITH_XENAPI], [test "$with_xenapi" = "yes"]) AC_SUBST([LIBCURL_CFLAGS]) AC_SUBST([LIBCURL_LIBS]) @@ -1894,6 +1948,7 @@ AC_MSG_NOTICE([ UML: $with_uml]) AC_MSG_NOTICE([ OpenVZ: $with_openvz]) AC_MSG_NOTICE([VBox: $with_vbox]) +AC_MSG_NOTICE([ XenAPI: $with_xenapi]) AC_MSG_NOTICE([ LXC: $with_lxc]) AC_MSG_NOTICE([PHYP: $with_phyp]) AC_MSG_NOTICE([ ONE: $with_one]) @@ -1992,6 +2047,12 @@ else AC_MSG_NOTICE([ xen: no]) fi +if test "$with_xenapi" = "yes" ; then +AC_MSG_NOTICE([ xenapi: $LIBXENSERVER_CFLAGS $LIBXENSERVER_LIBS $LIBXENSERVER_LDFLAGS]) +else +AC_MSG_NOTICE([ xen: no]) +fi if test "$with_hal" = "yes" ; then AC_MSG_NOTICE([ hal: $HAL_CFLAGS $HAL_LIBS]) else --- ./libvirt_org/src/Makefile.am 2010-02-17 17:38:13.0 + +++ ./libvirt/src/Makefile.am 2010-02-26 13:13:59.0 + @@ -205,6 +207,11 @@ qemu/qemu_security_dac.h\ qemu/qemu_security_dac.c +XENAPI_DRIVER_SOURCES = \ +xenapi/xenapi_driver.c xenapi/xenapi_driver.h \ +xenapi_driver_private.h \ +xenapi/xenapi_utils.c xenapi/xenapi_utils.h + UML_DRIVER_SOURCES =
[libvirt] [PATCH 4/4] Addition of XenAPI support to libvirt
diff -Nur ./libvirt_org/src/xenapi/xenapi_utils.c ./libvirt/src/xenapi/xenapi_utils.c --- ./libvirt_org/src/xenapi/xenapi_utils.c 1970-01-01 01:00:00.0 +0100 +++ ./libvirt/src/xenapi/xenapi_utils.c 2010-02-18 16:26:52.0 + @@ -0,0 +1,507 @@ +/* + * xenapi_utils.c: Xen API driver -- utils parts. + * Copyright (C) 2009 Citrix Ltd. + * Sharadha Prabhakar + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libvirt_internal.h" +#include "libvirt/libvirt.h" +#include "virterror_internal.h" +#include "datatypes.h" +#include "xenapi_driver.h" +#include "util.h" +#include "uuid.h" +#include "memory.h" +#include "driver.h" +#include "buf.h" +#include "xenapi_utils.h" + +/* returns 'file' or 'block' for the storage type */ +int +getStorageVolumeType(char *type) +{ +if((STREQ(type,"lvmoiscsi")) || + (STREQ(type,"lvmohba")) || + (STREQ(type,"lvm")) || + (STREQ(type,"file")) || + (STREQ(type,"iso")) || + (STREQ(type,"ext")) || + (STREQ(type,"nfs"))) +return (int)VIR_STORAGE_VOL_FILE; +else if((STREQ(type,"iscsi")) || + (STREQ(type,"equal")) || + (STREQ(type,"hba")) || + (STREQ(type,"cslg")) || + (STREQ(type,"udev")) || + (STREQ(type,"netapp"))) +return (int)VIR_STORAGE_VOL_BLOCK; +return -1; +} + +/* returns error description if any received from the server */ +char * +returnErrorFromSession(xen_session *session) +{ +int i; +char *buf = NULL; +for (i=0; ierror_description_count-1; i++) { +if (buf==NULL) { +buf = (char *)realloc(buf,strlen(session->error_description[i])+1); +strcpy(buf,session->error_description[i]); +} else { +buf = (char *)realloc(buf,strlen(buf)+strlen(session->error_description[i])+2); +strcat(buf,":"); +strcat(buf,session->error_description[i]); +} +} +return buf; +} + +/* XenAPI error handler - internally calls libvirt error handler after clearing error +flag in session */ +void xenapiSessionErrorHandler(virConnectPtr conn, virErrorNumber errNum, + const char *buf, const char *filename, const char *func, size_t lineno) +{ +if (buf==NULL) { +char *ret=NULL; +ret = returnErrorFromSession(((struct _xenapiPrivate *)(conn->privateData))->session); +virReportErrorHelper (conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s\n"), ret); +xen_session_clear_error(((struct _xenapiPrivate *)(conn->privateData))->session); +VIR_FREE(ret); +} else { +virReportErrorHelper (conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s\n"), buf); +} +} + +/* converts bitmap to string of the form '1,2...' */ +char * +mapDomainPinVcpu(unsigned int vcpu, unsigned char *cpumap, int maplen) +{ +char buf[VIR_UUID_BUFLEN], mapstr[sizeof(cpumap_t) * 64]; +char *ret=NULL; +int i, j; +mapstr[0] = 0; +for (i = 0; i < maplen; i++) { +for (j = 0; j < 8; j++) { +if (cpumap[i] & (1 << j)) { +snprintf(buf, sizeof(buf), "%d,", (8 * i) + j); +strcat(mapstr, buf); + } +} +} +mapstr[strlen(mapstr) - 1] = 0; +snprintf(buf, sizeof(buf), "%d", vcpu); +ret = strdup(mapstr); +return ret; +} + +/* obtains the CPU bitmap from the string passed */ +void +getCpuBitMapfromString(char *mask, unsigned char *cpumap, int maplen) +{ +int pos; +int max_bits = maplen * 8; +char *num = NULL; +bzero(cpumap, maplen); +num = strtok (mask, ","); +while (num != NULL) { +sscanf (num, "%d", &pos); +if (pos<0 || pos>max_bits-1) +printf ("number in str %d exceeds cpumap's max bits %d\n", pos, max_bits); +else +(cpumap)[pos/8] |= (1<<(pos%8)); +num = strtok (NULL, ","); +} +} + + +/* mapping XenServer power state to Libvirt power state */ +virDomainState +mapPowerState(enum xen_vm_power_state state) +{ +virDomainState virState; +switch (state) { +case (XEN_VM_POWER_STATE_HALTED): +case (XEN_VM_POWER_STATE_SUSPENDED): +virState = VIR_DOMAIN_SHUTOFF; +break; +case (XEN_VM_POWER_STATE_PAUSED): +virState = VIR_DOMAIN_PAUSED; +break; +case (XEN_VM_POWER_STATE_RUNNING): +virState = VIR_DOMAIN_RUNNING; +break; +case (XEN_VM_POWER_STATE_UNKNOWN): +case (XEN_VM_POWER_STATE_UNDEFINED): +virState = VIR_DOMAIN_NOSTATE; +break; +default: +virState = VIR_DOMAIN_NOSTATE; +break; +} +return virState; +} + +/* Gets the value of the child for the current node passed */ +char * +getXmlChildValue(xmlDocPtr doc, x
[libvirt] [PATCH 2/4] Addition of XenAPI support to libvirt
diff -ur ./libvirt_org/src/libvirt.c ./libvirt/src/libvirt.c --- ./libvirt_org/src/libvirt.c 2010-02-17 17:38:08.0 + +++ ./libvirt/src/libvirt.c 2010-02-18 12:21:43.0 + @@ -64,6 +64,9 @@ #ifdef WITH_ESX #include "esx/esx_driver.h" #endif +#ifdef WITH_XENAPI +#include "xenapi/xenapi_driver.h" +#endif #endif #define VIR_FROM_THIS VIR_FROM_NONE @@ -357,6 +360,7 @@ virDriverLoadModule("openvz"); virDriverLoadModule("vbox"); virDriverLoadModule("esx"); +virDriverLoadModule("xenapi"); virDriverLoadModule("remote"); #else #ifdef WITH_TEST @@ -377,6 +381,9 @@ #ifdef WITH_ESX if (esxRegister() == -1) return -1; #endif +#ifdef WITH_XENAPI +if (xenapiRegister () == -1) return -1; +#endif #ifdef WITH_REMOTE if (remoteRegister () == -1) return -1; #endif @@ -1035,6 +1042,10 @@ if (STRCASEEQ(type, "Remote")) *typeVer = remoteVersion(); #endif +#if WITH_XENAPI +if (STRCASEEQ(type, "XenAPI")) +*typeVer = LIBVIR_VERSION_NUMBER; +#endif if (*typeVer == 0) { virLibConnError(NULL, VIR_ERR_NO_SUPPORT, type); goto error; diff -ur ./libvirt_org/src/driver.h ./libvirt/src/driver.h --- ./libvirt_org/src/driver.h 2010-02-17 17:38:08.0 + +++ ./libvirt/src/driver.h 2010-02-18 10:45:54.0 + @@ -27,6 +27,7 @@ VIR_DRV_ONE = 9, VIR_DRV_ESX = 10, VIR_DRV_PHYP = 11, +VIR_DRV_XENAPI = 12 } virDrvNo; diff -ur ./libvirt_org/include/libvirt/virterror.h ./libvirt/include/libvirt/virterror.h --- ./libvirt_org/include/libvirt/virterror.h 2010-02-17 17:37:51.0 + +++ ./libvirt/include/libvirt/virterror.h 2010-02-18 12:17:54.0 + @@ -69,6 +69,7 @@ VIR_FROM_PHYP, /* Error from IBM power hypervisor */ VIR_FROM_SECRET,/* Error from secret storage */ VIR_FROM_CPU, /* Error from CPU driver */ +VIR_FROM_XENAPI /* Error from XenAPI */ } virErrorDomain; diff -ur ./libvirt_org/src/util/virterror.c ./libvirt/src/util/virterror.c --- ./libvirt_org/src/util/virterror.c 2010-02-17 17:38:14.0 + +++ ./libvirt/src/util/virterror.c 2010-02-18 12:13:08.0 + @@ -85,6 +85,9 @@ case VIR_FROM_XEN: dom = "Xen "; break; +case VIR_FROM_XENAPI: +dom = "XenAPI "; +break; case VIR_FROM_XML: dom = "XML "; break; Only in ./libvirt/src: xenapi -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/4] Addition of XenAPI support to libvirt
Resending patches in plain text. ~/Libvirt/Src/Makefile.am contains some changes suggested by Daniel Veillard. This is a patch to add XenAPI driver support for libvirt version 0.7.6. XenAPI can be used against XenCloud platform and managed through virsh and virt-manger. This patch supports domain related APIs in libvirt. It is possible to get domain information, list active and inactive domains, get Domain XML configuration and Start/stop/pause/shutdown/destroy VMs. There will be more patches after this review to support more libvirt APIs and add remote storage support to XenAPI. In order to run this patch you would require libxenserver library. Libxenserver library can be downloaded from http://community.citrix.com/download/attachments/38633496/libxenserver-5.5.0-1-src.tar.bz2?version=1 Copy the libxenserver folder in the same directory level as libvirt. The XenCloud platform can be downloaded from http://xen.org/products/cloudxen.html diff -ur ./libvirt_org/configure.ac ./libvirt/configure.ac --- ./libvirt_org/configure.ac 2010-02-17 17:39:21.0 + +++ ./libvirt/configure.ac 2010-02-18 11:51:29.0 + @@ -219,6 +219,8 @@ AC_HELP_STRING([--with-libssh2=@<:@PFX@:>@], [libssh2 location @<:@default=/usr/local/lib@:>@]),[],[with_libssh2=yes]) AC_ARG_WITH([phyp], AC_HELP_STRING([--with-phyp], [add PHYP support @<:@default=check@:>@]),[],[with_phyp=check]) +AC_ARG_WITH([xenapi], + AC_HELP_STRING([--with-xenapi], [add XenAPI support @<:@default=yes@:>@]),[],[with_xenapi=check]) AC_ARG_WITH([vbox], AC_HELP_STRING([--with-vbox], [add VirtualBox support @<:@default=yes@:>@]),[],[with_vbox=yes]) AC_ARG_WITH([lxc], @@ -307,6 +309,11 @@ fi AM_CONDITIONAL([WITH_VBOX], [test "$with_vbox" = "yes"]) +if test "$with_xenapi" = "yes"; then +AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether XenAPI driver is enabled]) +fi +AM_CONDITIONAL([WITH_XENAPI], [test "$with_xenapi" = "yes"]) + if test "$with_libvirtd" = "no" ; then with_qemu=no fi @@ -1894,6 +1901,7 @@ AC_MSG_NOTICE([ UML: $with_uml]) AC_MSG_NOTICE([ OpenVZ: $with_openvz]) AC_MSG_NOTICE([VBox: $with_vbox]) +AC_MSG_NOTICE([ XenAPI: $with_xenapi]) AC_MSG_NOTICE([ LXC: $with_lxc]) AC_MSG_NOTICE([PHYP: $with_phyp]) AC_MSG_NOTICE([ ONE: $with_one]) Binary files ./libvirt_org/daemon/.libs/libvirtd and ./libvirt/daemon/.libs/libvirtd differ Only in ./libvirt_org/daemon/.libs: lt-libvirtd --- ./libvirt_org/src/Makefile.am 2010-02-17 17:38:13.0 + +++ ./libvirt/src/Makefile.am 2010-02-19 10:55:51.0 + @@ -3,12 +3,19 @@ # No libraries with the exception of LIBXML should be listed # here. List them against the individual XXX_la_CFLAGS targets # that actually use them + +XENAPI_CFLAGS = -...@top_srcdir@/../libxenserver/include + INCLUDES = \ -I$(top_srcdir)/gnulib/lib \ -I../gnulib/lib \ -I../include\ +-I/usr/include \ -...@top_srcdir@/src/util \ + -...@top_srcdir@/src \ + -...@top_srcdir@/src/xenapi \ -...@top_srcdir@/include \ + $(XENAPI_CFLAGS)\ $(DRIVER_MODULE_CFLAGS) \ $(LIBXML_CFLAGS)\ -DLIBDIR=\""$(libdir)"\"\ @@ -42,6 +49,9 @@ augeastestdir = $(datadir)/augeas/lenses/tests augeastest_DATA = +XENAPI_LIBS = @top_srcdir@/../libxenserver/libxenserver.so +XENAPI_LDFLAGS = -...@top_srcdir@/../libxenserver/ -lxenserver + # These files are not related to driver APIs. Simply generic # helper APIs for various purposes UTIL_SOURCES = \ @@ -205,6 +215,10 @@ qemu/qemu_security_dac.h\ qemu/qemu_security_dac.c +XENAPI_DRIVER_SOURCES = \ +xenapi/xenapi_driver.c xenapi/xenapi_driver.h \ +xenapi/xenapi_utils.c xenapi/xenapi_utils.h + UML_DRIVER_SOURCES = \ uml/uml_conf.c uml/uml_conf.h \ uml/uml_driver.c uml/uml_driver.h @@ -466,6 +480,28 @@ libvirt_driver_vbox_la_SOURCES = $(VBOX_DRIVER_SOURCES) endif +if WITH_XENAPI +if WITH_DRIVER_MODULES +mod_LTLIBRARIES += libvirt_driver_xenapi.la +else +noinst_LTLIBRARIES += libvirt_driver_xenapi.la + +libvirt_la_LIBADD += libvirt_driver_xenapi.la \ + $(XENAPI_LIBS) +endif +#libvirt_driver_xenapi_la_LIBADD = $(XENAPI_LIBS) +libvirt_driver_xenapi_la_CFLAGS = $(XEN_CFLAGS)
[libvirt] [PATCH 2/4] Addition of XenAPI support to libvirt
diff -ur ./libvirt_org/src/libvirt.c ./libvirt/src/libvirt.c --- ./libvirt_org/src/libvirt.c 2010-02-17 17:38:08.0 + +++ ./libvirt/src/libvirt.c 2010-02-18 12:21:43.0 + @@ -64,6 +64,9 @@ #ifdef WITH_ESX #include "esx/esx_driver.h" #endif +#ifdef WITH_XENAPI +#include "xenapi/xenapi_driver.h" +#endif #endif #define VIR_FROM_THIS VIR_FROM_NONE @@ -357,6 +360,7 @@ virDriverLoadModule("openvz"); virDriverLoadModule("vbox"); virDriverLoadModule("esx"); +virDriverLoadModule("xenapi"); virDriverLoadModule("remote"); #else #ifdef WITH_TEST @@ -377,6 +381,9 @@ #ifdef WITH_ESX if (esxRegister() == -1) return -1; #endif +#ifdef WITH_XENAPI +if (xenapiRegister () == -1) return -1; +#endif #ifdef WITH_REMOTE if (remoteRegister () == -1) return -1; #endif @@ -1035,6 +1042,10 @@ if (STRCASEEQ(type, "Remote")) *typeVer = remoteVersion(); #endif +#if WITH_XENAPI +if (STRCASEEQ(type, "XenAPI")) +*typeVer = LIBVIR_VERSION_NUMBER; +#endif if (*typeVer == 0) { virLibConnError(NULL, VIR_ERR_NO_SUPPORT, type); goto error; diff -ur ./libvirt_org/src/driver.h ./libvirt/src/driver.h --- ./libvirt_org/src/driver.h 2010-02-17 17:38:08.0 + +++ ./libvirt/src/driver.h 2010-02-18 10:45:54.0 + @@ -27,6 +27,7 @@ VIR_DRV_ONE = 9, VIR_DRV_ESX = 10, VIR_DRV_PHYP = 11, +VIR_DRV_XENAPI = 12 } virDrvNo; diff -ur ./libvirt_org/include/libvirt/virterror.h ./libvirt/include/libvirt/virterror.h --- ./libvirt_org/include/libvirt/virterror.h 2010-02-17 17:37:51.0 + +++ ./libvirt/include/libvirt/virterror.h 2010-02-18 12:17:54.0 + @@ -69,6 +69,7 @@ VIR_FROM_PHYP, /* Error from IBM power hypervisor */ VIR_FROM_SECRET,/* Error from secret storage */ VIR_FROM_CPU, /* Error from CPU driver */ +VIR_FROM_XENAPI /* Error from XenAPI */ } virErrorDomain; diff -ur ./libvirt_org/src/util/virterror.c ./libvirt/src/util/virterror.c --- ./libvirt_org/src/util/virterror.c 2010-02-17 17:38:14.0 + +++ ./libvirt/src/util/virterror.c 2010-02-18 12:13:08.0 + @@ -85,6 +85,9 @@ case VIR_FROM_XEN: dom = "Xen "; break; +case VIR_FROM_XENAPI: +dom = "XenAPI "; +break; case VIR_FROM_XML: dom = "XML "; break; Only in ./libvirt/src: xenapi -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] FW: [PATCH 1/4] Addition of XenAPI support to libvirt
This is a patch to add XenAPI driver support for libvirt version 0.7.6. XenAPI can be used against XenCloud platform and managed through virsh and virt-manger. This patch supports domain related APIs in libvirt. It is possible to get domain information, list active and inactive domains, get Domain XML configuration and Start/stop/pause/shutdown/destroy VMs. There will be more patches after this review to support more libvirt APIs and add remote storage support to XenAPI. In order to run this patch you would require libxenserver library. The XenCloud platform can be downloaded from http://xen.org/products/cloudxen.html diff -ur ./libvirt_org/configure.ac ./libvirt/configure.ac --- ./libvirt_org/configure.ac 2010-02-17 17:39:21.0 + +++ ./libvirt/configure.ac 2010-02-18 11:51:29.0 + @@ -219,6 +219,8 @@ AC_HELP_STRING([--with-libssh2=@<:@PFX@:>@], [libssh2 location @<:@default=/usr/local/lib@:>@]),[],[with_libssh2=yes]) AC_ARG_WITH([phyp], AC_HELP_STRING([--with-phyp], [add PHYP support @<:@default=check@:>@]),[],[with_phyp=check]) +AC_ARG_WITH([xenapi], + AC_HELP_STRING([--with-xenapi], [add XenAPI support @<:@default=yes@:>@]),[],[with_xenapi=check]) AC_ARG_WITH([vbox], AC_HELP_STRING([--with-vbox], [add VirtualBox support @<:@default=yes@:>@]),[],[with_vbox=yes]) AC_ARG_WITH([lxc], @@ -307,6 +309,11 @@ fi AM_CONDITIONAL([WITH_VBOX], [test "$with_vbox" = "yes"]) +if test "$with_xenapi" = "yes"; then +AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether XenAPI driver is enabled]) +fi +AM_CONDITIONAL([WITH_XENAPI], [test "$with_xenapi" = "yes"]) + if test "$with_libvirtd" = "no" ; then with_qemu=no fi @@ -1894,6 +1901,7 @@ AC_MSG_NOTICE([ UML: $with_uml]) AC_MSG_NOTICE([ OpenVZ: $with_openvz]) AC_MSG_NOTICE([VBox: $with_vbox]) +AC_MSG_NOTICE([ XenAPI: $with_xenapi]) AC_MSG_NOTICE([ LXC: $with_lxc]) AC_MSG_NOTICE([PHYP: $with_phyp]) AC_MSG_NOTICE([ ONE: $with_one]) diff -ur ./libvirt_org/src/Makefile.am ./libvirt/src/Makefile.am --- ./libvirt_org/src/Makefile.am 2010-02-17 17:38:13.0 + +++ ./libvirt/src/Makefile.am 2010-02-18 16:25:55.0 + @@ -3,12 +3,19 @@ # No libraries with the exception of LIBXML should be listed # here. List them against the individual XXX_la_CFLAGS targets # that actually use them + +XENAPI_CFLAGS = -...@top_srcdir@/../libxenserver/include + INCLUDES = \ -I$(top_srcdir)/gnulib/lib \ -I../gnulib/lib \ -I../include\ +-I/usr/include \ -...@top_srcdir@/src/util \ + -...@top_srcdir@/src \ + -...@top_srcdir@/src/xenapi \ -...@top_srcdir@/include \ + $(XENAPI_CFLAGS)\ $(DRIVER_MODULE_CFLAGS) \ $(LIBXML_CFLAGS)\ -DLIBDIR=\""$(libdir)"\"\ @@ -42,6 +49,8 @@ augeastestdir = $(datadir)/augeas/lenses/tests augeastest_DATA = +XENAPI_LIBS = @top_srcdir@/../libxenserver/libxenserver.so + # These files are not related to driver APIs. Simply generic # helper APIs for various purposes UTIL_SOURCES = \ @@ -205,6 +214,10 @@ qemu/qemu_security_dac.h\ qemu/qemu_security_dac.c +XENAPI_DRIVER_SOURCES = \ +xenapi/xenapi_driver.c xenapi/xenapi_driver.h \ +xenapi/xenapi_utils.c xenapi/xenapi_utils.h + UML_DRIVER_SOURCES = \ uml/uml_conf.c uml/uml_conf.h \ uml/uml_driver.c uml/uml_driver.h @@ -466,6 +479,28 @@ libvirt_driver_vbox_la_SOURCES = $(VBOX_DRIVER_SOURCES) endif +if WITH_XENAPI +if WITH_DRIVER_MODULES +mod_LTLIBRARIES += libvirt_driver_xenapi.la +else +noinst_LTLIBRARIES += libvirt_driver_xenapi.la + +libvirt_la_LIBADD += libvirt_driver_xenapi.la \ + $(XENAPI_LIBS) +endif +#libvirt_driver_xenapi_la_LIBADD = $(XENAPI_LIBS) +libvirt_driver_xenapi_la_CFLAGS = $(XEN_CFLAGS) \ + $(shell xml2-config --cflags) \ + $(shell curl-config --cflags) +libvirt_driver_xenapi_la_LDFLAGS = -...@top_srcdir@/../libxenserver/ -lxenserver -g $(shell xml2-config --libs) \ + $(shell curl-config --libs) + +if WITH_DRIVER_MODULES +libvirt_driver_xenapi_la_LDFLAGS += -module -avoid-version +endif +libvirt_driver_xenapi_la_SOURCES = $(XENAPI_DRIVER_SOURCES)
[libvirt] libvirt: python bindings
Hi, I'm writing XenServer APIs for libvirt and trying to test it on virt-Manager. I need to build the libvirt python bindings for that. I tried this for libvirt. ./configure -with-xenapi -with-python make make install I suppose this is supposed to build a .libs directory with libvirtmod.so in the ~/libvirt/python/ But I don't seem to have this at all after build. It was a clean build with no errors. I need libvirtmod.so to link with virt-manager. I'm using libvirt version 0.7.4 Can anyone help me with this. Am I missing something here Thanks in Advance, -SP -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] libvirt: build error
Hi, I'm getting the following error when I make libvirt version 0.7.4 Make all-recursive make[1]: Entering directory `/home/sharadhap/libvirt-0.7.4' Making all in gnulib/lib make[2]: Entering directory `/home/sharadhap/libvirt-0.7.4/gnulib/lib' make all-recursive make[3]: Entering directory `/home/sharadhap/libvirt-0.7.4/gnulib/lib' make[4]: Entering directory `/home/sharadhap/libvirt-0.7.4/gnulib/lib' /bin/sh ../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../.. -I../../intl -g -O2 -MT printf-parse.lo -MD -MP -MF .deps/printf-parse.Tpo -c -o printf-parse.lo printf-parse.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../.. -I../../intl -g -O2 -MT printf-parse.lo -MD -MP -MF .deps/printf-parse.Tpo -c printf-parse.c -fPIC -DPIC -o .libs/printf-parse.o In file included from printf-parse.c:70: xsize.h: In function 'xsum': xsize.h:59: error: expected expression before ')' token xsize.h:59: error: expected expression before ')' token printf-parse.c: In function 'printf_parse': printf-parse.c:164: error: expected expression before ')' token printf-parse.c:164: error: expected expression before ')' token printf-parse.c:164: error: expected expression before ')' token printf-parse.c:164: error: expected expression before ')' token printf-parse.c:168: error: expected expression before ')' token printf-parse.c:168: error: expected expression before ')' token printf-parse.c:234: error: expected expression before ')' token printf-parse.c:234: error: expected expression before ')' token printf-parse.c:234: error: expected expression before ')' token printf-parse.c:234: error: expected expression before ')' token printf-parse.c:238: error: expected expression before ')' token printf-parse.c:238: error: expected expression before ')' token printf-parse.c:252: error: expected expression before ')' token printf-parse.c:252: error: expected expression before ')' token printf-parse.c:252: error: expected expression before ')' token printf-parse.c:252: error: expected expression before ')' token printf-parse.c:252: error: expected expression before ')' token printf-parse.c:252: error: expected expression before ')' token printf-parse.c:252: error: expected expression before ')' token printf-parse.c:252: error: expected expression before ')' token printf-parse.c:252: error: expected expression before ')' token printf-parse.c:252: error: expected expression before ')' token printf-parse.c:291: error: expected expression before ')' token printf-parse.c:291: error: expected expression before ')' token printf-parse.c:291: error: expected expression before ')' token printf-parse.c:291: error: expected expression before ')' token printf-parse.c:295: error: expected expression before ')' token printf-parse.c:295: error: expected expression before ')' token printf-parse.c:310: error: expected expression before ')' token printf-parse.c:310: error: expected expression before ')' token printf-parse.c:310: error: expected expression before ')' token printf-parse.c:310: error: expected expression before ')' token printf-parse.c:310: error: expected expression before ')' token printf-parse.c:310: error: expected expression before ')' token printf-parse.c:310: error: expected expression before ')' token printf-parse.c:310: error: expected expression before ')' token printf-parse.c:310: error: expected expression before ')' token printf-parse.c:310: error: expected expression before ')' token printf-parse.c:567: error: expected expression before ')' token printf-parse.c:567: error: expected expression before ')' token printf-parse.c:567: error: expected expression before ')' token printf-parse.c:567: error: expected expression before ')' token printf-parse.c:567: error: expected expression before ')' token printf-parse.c:567: error: expected expression before ')' token printf-parse.c:567: error: expected expression before ')' token printf-parse.c:567: error: expected expression before ')' token printf-parse.c:567: error: expected expression before ')' token printf-parse.c:567: error: expected expression before ')' token printf-parse.c:579: error: expected expression before ')' token printf-parse.c:579: error: expected expression before ')' token printf-parse.c:579: error: expected expression before ')' token printf-parse.c:579: error: expected expression before ')' token printf-parse.c:580: error: expected expression before ')' token printf-parse.c:580: error: expected expression before ')' token printf-parse.c:580: error: expected expression before ')' token printf-parse.c:580: error: expected expression before ')' token printf-parse.c:581: error: expected expression before ')' token printf-parse.c:581: error: expected expression before ')' token make[4]: *** [printf-parse.lo] Error 1 make[4]: Leaving directory `/home/sharadhap/libvirt-0.7.4/gnulib/lib' make[3]: *** [all-recursive] Error 1 make[3]: Leaving directory `/home/sharadhap/libvirt-0.7.4/gnulib/lib' make[2]: *** [all] Error 2 make[2]: Leaving directory `/h
[libvirt] is libvirt test suite available
Hi, I'd like to know if there is a client test suite available to test libvirt. If so Where can I locate it? Thanks, SP -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list