[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] how to read value from xenstore inside kernel


  • To: James Harper <james.harper@xxxxxxxxxxxxxxxx>
  • From: Kuriakose Mathew <kmathew123@xxxxxxxxx>
  • Date: Sat, 29 Aug 2009 21:08:56 +0530
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
  • Delivery-date: Sat, 29 Aug 2009 08:39:25 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=RlLJ+ELfC2UxqvPnRXzJj5qhVpxhYuxxUrJ9gAz6KS0h0tnCjMHzji69bAGApdCDSr /5M+/KhbDOTCCh7DxKq48lyyEbFhODNtnJWPPmnshr8Pb5n/84O+ySVQbaBqIloshFmU 9oNy7rasChHrupruJ+5yUDqEmQ4+CcyIB8PDg=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

How to avoid the callback function  getting called again and again after registration of xenbus_watch?

-Mathew



On Sat, Aug 29, 2009 at 8:31 PM, Kuriakose Mathew <kmathew123@xxxxxxxxx> wrote:
Hi ,

Thanks. I think the registration is happening. I mistook the call trace to be a crash. But now when I write a new value to xenstore memory/target , it is showing some odd behavior like the shell is scrolling up .

I think the callback function is getting called again and again as though some kind of infinite loop.

-Mathew


On Fri, Aug 28, 2009 at 8:09 PM, Kuriakose Mathew <kmathew123@xxxxxxxxx> wrote:
I tried watch in xenbus.c ( connect function)

code is as shown below.

//////////ADDED CODE////////////////////



static struct xenbus_watch target_watch =
{
    .node = "memory/target"
   
};

////////////////////////////////////////////////

/* React to a change in the target key */
static void mywatch_target(struct xenbus_watch *watch,
             const char **vec, unsigned int len)
{
    unsigned long long new_target;
    int err;
    printk(KERN_NOTICE "In netback.c::watch_target called \n");
    err = xenbus_scanf(XBT_NIL, "memory", "target", "%llu", &new_target);
    if (err != 1) {
        /* This is ok (for domain0 at least) - so just return */
        return;
    }

    /* The given memory/target value is in KiB, so it needs converting to
     * pages. PAGE_SHIFT converts bytes to pages, hence PAGE_SHIFT - 10.
     */
    //balloon_set_new_target(new_target >> (PAGE_SHIFT - 10));
}


////////////////////END OF ADD ////////////////////////////


static void connect(struct backend_info *be)
{
    int err;
    struct xenbus_device *dev = be->dev;

    err = connect_rings(be);
    if (err)
        return;

    err = xen_net_read_mac(dev, be->netif->fe_dev_addr);
    if (err) {
        xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
        return;
    }

    xen_net_read_rate(dev, &be->netif->credit_bytes,
              &be->netif->credit_usec);
    be->netif->remaining_credit = be->netif->credit_bytes;

    xenbus_switch_state(dev, XenbusStateConnected);

    netif_wake_queue(be->netif->dev);
   
   /////////////////ADDED CODE////////////
    target_watch.callback = mywatch_target;
   
    printk(KERN_NOTICE "In xenbus.c::connect b4 register \n");

    err = register_xenbus_watch(&target_watch);
    if(IS_ERR(err)) {
              printk(KERN_NOTICE "In xenbus.c::connect Failed to initialize  watcher\n");
        } else {
              printk(KERN_NOTICE " In xenbus.c::connect xenbus watcher initialized\n");
      }
    //////////////END OF ADD//////////////
}

The crash message is

In xenbus.c::connect b4 register
------------[ cut here ]------------
kernel BUG at /home/saransh/xen-3.1.3/linux-2.6.18.8-xen/drivers/xen/xenbus/xenbus_xs.c:607!
invalid opcode: 0000 [#1]
SMP
Modules linked in: xt_tcpudp xt_physdev iptable_filter ip_tables x_tables ppdev ac video container button sbs i2c_ec i2c_core asus_acpi battery bridge lp serio_raw parport_pc parport serial_core rtc pcspkr shpchp pci_hotplug ipv6 tsdev evdev ext3 jbd sg sd_mod amd74xx usbhid ehci_hcd ohci_hcd usbcore sata_nv libata scsi_mod forcedeth thermal processor fan fuse
CPU:    1
EIP:    0061:[<c0249306>]    Not tainted VLI
EFLAGS: 00010286   (2.6.18.8-xen #1)
EIP is at register_xenbus_watch+0xc6/0xe0
eax: c0364bd4   ebx: c0364bd4   ecx: c0f2da10   edx: c0364bd4
esi: fffffffe   edi: c1511f03   ebp: ed00cb40   esp: c1511ef4
ds: 007b   es: 007b   ss: 0069
Process xenwatch (pid: 13, ti=c1510000 task=c0446620 task.ti=c1510000)
Stack: c1511f03 c032d562 c0364bd4 43fe0400 34363330 00344442 c0fe0000 fffffffe
       c0fe0400 c02564db c03218b0 ed00c540 c032db45 c030ec5b c1511f5c c032db12
       c031610b c1511f68 c032dc1d c031ac96 c1511f64 00000000 c0fe0408 ed00c540
Call Trace:
 [<c02564db>] frontend_changed+0x4db/0x650
 [<c024a8d8>] otherend_changed+0xa8/0xb0
 [<c0249710>] xenwatch_thread+0x0/0x140
 [<c0248b5a>] xenwatch_handle_callback+0x1a/0x60
 [<c0249840>] xenwatch_thread+0x130/0x140
 [<c0248b40>] xenwatch_handle_callback+0x0/0x60

 [<c0138640>] autoremove_wake_function+0x0/0x40
 [<c0138486>] kthread+0xf6/0x100
 [<c0138390>] kthread+0x0/0x100
 [<c0103005>] kernel_thread_helper+0x5/0x10
Code: 10 00 c7 43 04 00 02 20 00 86 05 e0 3d 36 c0 b8 a8 3e 41 c0 e8 0c 2a ef ff 89 f8 8b 5c 24 18 8b 74 24 1c 8b 7c 24 20 83 c4 24 c3 <0f> 0b 5f 02 6c 03 32 c0 e9 75 ff ff ff 8d b6 00 00 00 00 8d bc
EIP: [<c0249306>] register_xenbus_watch+0xc6/0xe0 SS:ESP 0069:c1511ef4
 <6>Bluetooth: Core ver 2.10


Thanks
Mathew



On Fri, Aug 28, 2009 at 5:27 PM, James Harper <james.harper@xxxxxxxxxxxxxxxx> wrote:
>
> The .node  member I initialized while declaring  and .callback I
initialized
> in netbacl init function (just above where I use register_xenbus_watch
)as
> shown below. (used balloon.c as guideline)
>

Try adding the watch (or just a read as a test) in netback/xenbus.c
inside the connect() function where a lot of other xenbus activity is
happening

James



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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.