xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: ravi kerur <rkerur@gmail.com>
Cc: xen-devel@lists.xensource.com
Subject: Re: event notification
Date: Mon, 8 Mar 2010 11:47:29 -0500	[thread overview]
Message-ID: <20100308164727.GA4568@phenom.dumpdata.com> (raw)
In-Reply-To: <dfc283f41003061912g7a5de86dh5d29fb601ea101f8@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 810 bytes --]

On Sat, Mar 06, 2010 at 07:12:02PM -0800, ravi kerur wrote:
> Hi,
> 
> Is there a mechanism available in Xen such that a kernel module in dom0 can
> register to it and when a VM(domU) is installed or deleted or suspend or
> resumed kernel module in domU can send notification to its counterpart in
> dom0. I have looked into xenbus mechanism used by PV drivers and it won't
> work for us. Inputs appreciated.

You can listen on udev events and see when a vif device has been added.
Also you can add pieces to the dom0 kernel to send uevents when a device
is suspended and do something.

Attached is a simple program to listen to all uevents..

> 
> Thanks
> -RK

> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel


[-- Attachment #2: listen.c --]
[-- Type: text/plain, Size: 1061 bytes --]

#include <sys/socket.h>
#include <linux/netlink.h>
#include <stdio.h>
#include <string.h>
#define MAX_PAYLOAD 1024        /* maximum payload size */
struct sockaddr_nl src_addr;
int sock_fd;
static char buff[MAX_PAYLOAD];
ssize_t buflen;

int
main ()
{
  sock_fd = socket (PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);

  memset (&src_addr, 0, sizeof (src_addr));
  src_addr.nl_family = AF_NETLINK;
  src_addr.nl_pid = getpid ();  /* self pid */
  src_addr.nl_groups = 0xffffffff;

  printf ("Listen..\n");
  bind (sock_fd, (struct sockaddr *) &src_addr, sizeof (src_addr));
  printf ("Receiving..\n");
  while (1)
    {
      buflen = recv (sock_fd, &buff, sizeof (buff), 0);
      printf ("Got data: %d\n", buflen);
      int i, bufpos;
      char *key;
      for (i = 0, bufpos = 0; (bufpos < buflen) && i < MAX_PAYLOAD; i++)
        {
          key = &buff[bufpos];
          printf ("[%s]\n", key);
          bufpos += strlen (key) + 1;
        }
      memset (&buff, 0, MAX_PAYLOAD);
    }
  /* Close Netlink Socket */
  close (sock_fd);
  return 0;
}

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  reply	other threads:[~2010-03-08 16:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-07  3:12 event notification ravi kerur
2010-03-08 16:47 ` Konrad Rzeszutek Wilk [this message]
2010-03-10 16:09   ` Ian Campbell
2010-03-10 23:20     ` ravi kerur
2010-03-11  7:43       ` Ian Campbell
2010-03-15 23:25         ` Konrad Rzeszutek Wilk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100308164727.GA4568@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=rkerur@gmail.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).