WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: James Harper <james.harper@xxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] how to read value from xenstore inside kernel
From: Kuriakose Mathew <kmathew123@xxxxxxxxx>
Date: Fri, 28 Aug 2009 20:09:10 +0530
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 28 Aug 2009 07:39:41 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=12Fw2SdUzha/PXibwMBjxjKyB6/gbUeoSC4V3cuqvxQ=; b=bMnKFpZauYzcZLBdFQDJoCAEOJShO8h/4RYZvEnlItb20zingUDTwtCUqNH2tl3s/S HVRT2WrcpicpbzzmX5LO7PEHUUUUobkqE6jAJvXob+/b8RM+VILPnpGsEFFL5dD5q1RB umb2UCQjAQW7NsM5OpRIvT0H4a+XmZ4QARInc=
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=mXZlls1XvkN9i26V9+4fiNUSuQdSYdcFU9pNGtTV9+cnSR6Ch7BAZVD9Ek8PVr8xGl WN0WBh3kIiJdUbRaKonTA8/ntjrQI+xnovpls1erfyAy/vHwWIUjkiR/TRMarrD+Zuio klObo1/r5dd2vc6QSFW1D+H3nlRkDGRATMVjk=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <AEC6C66638C05B468B556EA548C1A77D0177CEF9@trantor>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <9e81bde0908162340h42011f5cn7606c962fda89da4@xxxxxxxxxxxxxx> <20090817182023.GA6144@xxxxxxxxxxxxxxxxxxx> <9e81bde0908250357j5678af58ob56633561bf5a2bb@xxxxxxxxxxxxxx> <AEC6C66638C05B468B556EA548C1A77D0177CE13@trantor> <9e81bde0908280152r35c7b06ck866ab69487e0aa16@xxxxxxxxxxxxxx> <AEC6C66638C05B468B556EA548C1A77D0177CEF6@trantor> <9e81bde0908280441h2961f63bkf858c6812caeb81e@xxxxxxxxxxxxxx> <AEC6C66638C05B468B556EA548C1A77D0177CEF8@trantor> <9e81bde0908280451j5afd68bn2ad99db9866d4276@xxxxxxxxxxxxxx> <AEC6C66638C05B468B556EA548C1A77D0177CEF9@trantor>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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