Mailing List Archive

Fwd: [Xen-devel] libxen-light
---------- Forwarded message ----------
From: kumara rathnavel <kumara.bsd@gmail.com>
Date: 21 September 2015 at 17:17
Subject: Re: [Xen-devel] libxen-light
To: Ian Campbell <ian.campbell@citrix.com>


Thanks for the reply Ian.

Please find the code below..
I have also attached the output files from the command truss...

The one prefixed with xl is generated when command is successful
The other one is from the code generated the SEGFAULT.

Thank You,..


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/syslog.h>
#include <libxl.h>
#include <libxl_utils.h>
#include <libxlutil.h>
#include <fcntl.h>
#define INVALID_DOMID 0
#define LIBXL__DEFBOOL_FALSE (-1)
#define LIBXL__DEFBOOL_TRUE (1)

int
main(
int argc,
char **argv
)
{
libxl_ctx *ctx;

int rc = 0;

libxl_device_nic nic;
int domid = 0;
char *bridge = NULL;

bridge = "bridge0";


libxl_device_nic_init(&nic);


domid = 2; //Have a domain running with ID 2.

rc = libxl_ctx_alloc(&ctx, LIBXL_VERSION, 0, NULL);
if (rc < 0) {
perror("ctx alloc failed.");
return rc;
}

nic.devid = -1;
nic.bridge = bridge;
nic.nictype = LIBXL_NIC_TYPE_VIF;

rc = libxl_device_nic_add(ctx, domid, &nic, 0);
if(rc != 0 ) {
printf("Attach Failed\n");
}

libxl_ctx_free(ctx);
return rc;
}




On 21 September 2015 at 13:57, Ian Campbell <ian.campbell@citrix.com> wrote:

> On Mon, 2015-09-21 at 11:56 +0530, kumara rathnavel wrote:
> > Hello,
> >
> > I do not find any proper documentation regarding API provided by the
> > Libxenlight. All I find is the documentation for the xl that in turn uses
> > Libxl Library. But I would like to use the library calls directly, I am
> > able to basic operations like listing vm, reboot and all those . But when
> > it comes to creation of domain or attaching device , I am filling the
> > structures the same way as xl is doing. But I get a Seg Fault. Can you
> > share some documentation on the Libxenlight API if possible or guidance
> > would do,,.....
>
> The documentation is mainly in the headers, starting with libxl.h.
>
> If you have specific questions then please provide the code as well as the
> error (e.g. the stack trace).
>
> Ian.
>