[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] xenstore documentation
Jacob Gorm Hansen wrote: 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.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. 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |