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] xenstore documentation

To: Jacob Gorm Hansen <jacobg@xxxxxxx>
Subject: Re: [Xen-devel] xenstore documentation
From: Anthony Liguori <aliguori@xxxxxxxxxx>
Date: Tue, 04 Oct 2005 13:20:32 -0500
Cc: harry <harry@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 04 Oct 2005 18:18:15 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <e08041f30510041113g1e158b36u2e96d9fb403f2f0@xxxxxxxxxxxxxx>
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <e08041f30510031003p6c4911b8n22dbf10bd1a1997f@xxxxxxxxxxxxxx> <ae5426fb0510032327r4589aaerc4d279825dca0ad8@xxxxxxxxxxxxxx> <e08041f30510040520g53e96456xa7d93168fa8cdf90@xxxxxxxxxxxxxx> <1128429737.30221.12.camel@xxxxxxxxxxxxxxxxxxxxx> <1128430090.30221.16.camel@xxxxxxxxxxxxxxxxxxxxx> <e08041f30510040556i3c5eb9e3o1bbb5a2ba15d610a@xxxxxxxxxxxxxx> <1128431831.30221.24.camel@xxxxxxxxxxxxxxxxxxxxx> <e08041f30510040631j5eca8a81j1d3d67e40847b2f0@xxxxxxxxxxxxxx> <43429A1C.1090006@xxxxxxxxxx> <e08041f30510041113g1e158b36u2e96d9fb403f2f0@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050912)
Jacob Gorm Hansen wrote:

hi Anthony, others

I have converted your pseudocode to C, but I am still not able to
connect the device. I hope it's OK that I attach my code that I have
trouble getting working, if anyone could try to run it or comment if
anything obvious looks wrong.

The two files are businit.c and buscreate.c. The former inits xenstore
and dom0, and the latter creates a domU and attempts to connect hda1.
I'll run play with it tomorrow. Some people are having problems with block devices timing out. You should verify you can create a domain with a block device with Xend to determine if it's your platform.

Regards,

Anthony Liguori

Thanks,
Jacob
------------------------------------------------------------------------

#include <xenctrl.h>
#include <xenguest.h>

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>

#include <xs.h>
#include <fcntl.h>


int main(int argc,char** argv)
{
        int xc = xc_interface_open();
        struct xs_handle *xs = xs_daemon_open();
        char home[] = "/local/domain/0";

        int lstore = 0;
        int rstore = 0;

        xc_evtchn_bind_interdomain(xc, 0, 0, &lstore, &rstore);
        unsigned long mfn_store = xc_init_store(xc, rstore);
        xs_mkdir(xs,home);
        xs_introduce_domain(xs, 0, mfn_store, lstore, home);

        return 0;

}

------------------------------------------------------------------------

#include <xenctrl.h>
#include <xenguest.h>

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>

#include <xs.h>
#include <fcntl.h>


#define xs_write(a,b,c,d) printf("write %s <- %s : %d\n", 
b,c,xs_write(a,b,c,d));
#define xs_transaction_end(a,b) printf("end : %d\n", xs_transaction_end(a,b));
int main(int argc,char** argv)
{
        int xc = xc_interface_open();
        struct xs_handle *xs = xs_daemon_open();
        
        char kernel[] = "/vmlinux";
        char ramdisk[] = "/domUinitrd";
        char cmdline[] = "init=/linuxrc root=/dev/ram";
        char pdev[] = "0x301";
        char vdev[] = "0x301";
        int vcpus = 1;
        char home[256];

        unsigned long memory = 64*1024*1024;

        int domid = 0;
        xc_domain_create(xc, ACM_DEFAULT_SSID, &domid);
        xc_domain_setmaxmem(xc,domid, memory >> 10);
        xc_domain_memory_increase_reservation(xc,domid, memory >> 12, 0,0,0);

        // 2) Build domain
        int lconsole = 0;
        int rconsole = 0;
        int lstore = 0;
        int rstore = 0;
        unsigned long mfn_store, mfn_console;

        xc_evtchn_bind_interdomain(xc, 0, domid, &lconsole, &rconsole);
        xc_evtchn_bind_interdomain(xc, DOMID_SELF, domid, &lstore, &rstore);

        xc_linux_build(xc, domid, kernel, ramdisk, cmdline, 0, vcpus,
                        rstore, &mfn_store, rconsole, &mfn_console);

        sprintf(home,"/local/domain/%d",domid);
        xs_introduce_domain(xs, domid, mfn_store, lstore, home);

        char s[256];
        char s2[256];

        sprintf(s,"%s/console/ring-ref",home);
        sprintf(s2,"%lu",mfn_console);
        xs_write(xs, s, s2, strlen(s2));

        sprintf(s,"%s/console/port",home);
        sprintf(s2,"%d",lconsole);
        xs_write(xs, s, s2, strlen(s2));

        // 3) Create block device (pdev, vdev);
        int uuid = 1000 + domid;

        char* dom0_home = xs_get_domain_path(xs,0);
        printf("dom0_home is %s\n",dom0_home);

        char backend[256];
        char frontend[256];
        sprintf(backend,"%s/backend/vbd/%d/%d",dom0_home,uuid,domid);
        sprintf(frontend, "%s/device/vbd/%d",home,uuid);


        xs_transaction_start(xs);
        sprintf(s,"%s/frontend",backend);
        xs_write(xs, s, frontend, strlen(frontend));

        sprintf(s,"%s/frontend-id",backend);
        sprintf(s2,"%d",domid);
        xs_write(xs, s, s2, strlen(s2));
        xs_transaction_end(xs,0);


        xs_transaction_start(xs);
        sprintf(s,"%s/backend",frontend);
        xs_write(xs, s, backend, strlen(backend));

        sprintf(s, "%s/backend-id", frontend);
        xs_write(xs, s, "0",1);
        
        sprintf(s, "%s/virtual-device", frontend);
        xs_write(xs, s, vdev, strlen(vdev));
        xs_transaction_end(xs,0);



        sprintf(s, "%s/physical-device",backend);
        xs_write(xs, s, pdev, strlen(pdev));

        xc_domain_unpause(xc,domid);

        return 0;
}


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