From: Jacob Gorm Hansen Subject: Re: xenstore documentation Date: Tue, 4 Oct 2005 20:13:08 +0200 Message-ID: References: <1128429737.30221.12.camel@localhost.localdomain> <1128430090.30221.16.camel@localhost.localdomain> <1128431831.30221.24.camel@localhost.localdomain> <43429A1C.1090006@us.ibm.com> Reply-To: Jacob Gorm Hansen Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_11111_11027394.1128449588790" Return-path: In-Reply-To: <43429A1C.1090006@us.ibm.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Anthony Liguori Cc: harry , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org ------=_Part_11111_11027394.1128449588790 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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. Thanks, Jacob ------=_Part_11111_11027394.1128449588790 Content-Type: text/x-csrc; name=businit.c; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="businit.c" #include #include #include #include #include #include #include #include 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; } ------=_Part_11111_11027394.1128449588790 Content-Type: text/x-csrc; name=buscreate.c; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="buscreate.c" #include #include #include #include #include #include #include #include #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; } ------=_Part_11111_11027394.1128449588790 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ------=_Part_11111_11027394.1128449588790--