All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Jacob Gorm Hansen <jacobg@diku.dk>
Cc: harry <harry@hebutterworth.freeserve.co.uk>,
	xen-devel@lists.xensource.com
Subject: Re: xenstore documentation
Date: Tue, 04 Oct 2005 13:20:32 -0500	[thread overview]
Message-ID: <4342C7F0.4030508@us.ibm.com> (raw)
In-Reply-To: <e08041f30510041113g1e158b36u2e96d9fb403f2f0@mail.gmail.com>

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;
>}
>  
>

  reply	other threads:[~2005-10-04 18:20 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-03 17:03 xenstore documentation Jacob Gorm Hansen
2005-10-04  6:27 ` Rami Rosen
2005-10-04 12:20   ` Jacob Gorm Hansen
2005-10-04 12:42     ` harry
2005-10-04 12:48       ` harry
2005-10-04 12:56         ` Jacob Gorm Hansen
2005-10-04 13:17           ` harry
2005-10-04 13:31             ` Jacob Gorm Hansen
2005-10-04 15:05               ` Anthony Liguori
2005-10-04 15:28                 ` Nivedita Singhvi
2005-10-04 15:46                   ` Anthony Liguori
2005-10-04 15:33                 ` Jacob Gorm Hansen
2005-10-04 15:55                   ` Anthony Liguori
2005-10-04 18:13                 ` Jacob Gorm Hansen
2005-10-04 18:20                   ` Anthony Liguori [this message]
2005-10-04 22:12                   ` Jacob Gorm Hansen
2005-10-05 17:17                   ` Anthony Liguori
2005-10-05 17:22                     ` Jacob Gorm Hansen
2005-10-04 12:55       ` NAHieu
2005-10-04 13:25         ` harry
2005-10-04 14:42           ` Rolf Neugebauer
2005-10-04 17:24             ` NAHieu
2005-10-04 17:36               ` Rolf Neugebauer
2005-10-04 17:42               ` Anthony Liguori
2005-10-04 18:00                 ` NAHieu
2005-10-04 18:06                   ` Anthony Liguori
  -- strict thread matches above, loose matches on Subject: below --
2005-10-04 21:47 Neugebauer, Rolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4342C7F0.4030508@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=harry@hebutterworth.freeserve.co.uk \
    --cc=jacobg@diku.dk \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.