Skip to contentSkip to conversation

xenstore documentation

DISCUSSION Jacob Gorm Hansen 7 participants 26 messages Oct 3, 2005 – Oct 5, 2005

lore
Share & tools
lore
#0 lore raw

hi,

it would be extremely useful for me if someone with knowledge of how the current tools and drivers use Xenstore would be kind enough to update the Wiki with current information. I have been spending quite a lot of time trying to get my domU connected to a block device in dom0 using a home-brewed domain creation tool, and I am still at the 'Timeout connecting to device!' stage.

My stragegy has been to log all calls to xs_write() under Xend, and then replay those same calls with my own tool on a freshly booted machine, but to no avail. In general things work with Xend, at least as long as I am not trying to restart xenstored without a reboot.

I have noticed that with the most recent Xen-unstable, the store is now split into /vm and /local, but there seems to be some overlap, e.g. UUIDs are in some cases referred from /local even though they seem to only belong in /vm. Also, the amount of info in the store seems to be growing to Windows Registry-like proportions, making it very hard to keep up and the store hard to navigate. Perhaps we could agree not to write any default settings to the store to save some space and confusion?

Thanks in advance,
Jacob
--
Save time and bandwidth with EDelta: http://www.diku.dk/~jacobg/edelta/

#1 lore raw

Hello ,

I had written some pages which I had inserted into XenWiki this morning. It is in http://wiki.xensource.com/xenwiki/XenIntro.

This is an initial draft, and I intend to deliver an enhanced version in a few days, and to update it from time to time.

Currently It deals with XenStore,frontend/backend drivers,Xend daemon, but it
is still very partial and there is still a lot to add.

It will probably not help you with this specific problem,
but I hope that this may be a helpful resource for everybody, espcially when I will add more into it.

Regards,
Rami Rosen

Quoted 29 lines · Jacob Gorm Hansen

hi,

it would be extremely useful for me if someone with knowledge of how the current tools and drivers use Xenstore would be kind enough to update the Wiki with current information. I have been spending quite a lot of time trying to get my domU connected to a block device in dom0 using a home-brewed domain creation tool, and I am still at the 'Timeout connecting to device!' stage.

My stragegy has been to log all calls to xs_write() under Xend, and then replay those same calls with my own tool on a freshly booted machine, but to no avail. In general things work with Xend, at least as long as I am not trying to restart xenstored without a reboot.

I have noticed that with the most recent Xen-unstable, the store is now split into /vm and /local, but there seems to be some overlap, e.g. UUIDs are in some cases referred from /local even though they seem to only belong in /vm. Also, the amount of info in the store seems to be growing to Windows Registry-like proportions, making it very hard to keep up and the store hard to navigate. Perhaps we could agree not to write any default settings to the store to save some space and confusion?

Thanks in advance,
Jacob
--
Save time and bandwidth with EDelta: http://www.diku.dk/~jacobg/edelta/

Quoted 5 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 4 lines · Rami Rosen

Hello ,

I had written some pages which I had inserted into XenWiki this morning. It is in http://wiki.xensource.com/xenwiki/XenIntro.

Thanks a lot for this work. I suppose my main problem right now is finding out why the backend probe function is never called. Does anyone know what the tools in dom0 have to do to trigger the backend driver probe function?

Thanks,
Jacob

#3 lore raw

If you look at writeDetails in tools/python/xen/xend/server/DevController.py you'll see the transactions which cause the back and front ends to get probed.

The transactions contain extra fields as provided by the derived class specific to the device type and are written into the store in the locations constructed in the frontendPath and backendPath functions in DevController.py. These paths contain the device id string as specified when you registered your xenbus drivers.

Looking at the current code, it looks like domainpath/backend/device_class/frontend_uuid/device_id/transaction_stuff_here for the back-end and and domainpath/device_id/transaction_stuff_here
for the front-end.

HTH

Harry.

Quoted 19 lines · Jacob Gorm Hansen
Quoted 4 lines · Rami Rosen

Hello ,

I had written some pages which I had inserted into XenWiki this morning. It is in http://wiki.xensource.com/xenwiki/XenIntro.

Thanks a lot for this work. I suppose my main problem right now is finding out why the backend probe function is never called. Does anyone know what the tools in dom0 have to do to trigger the backend driver probe function?

Thanks,
Jacob

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw

Sorry, I think that should have been

domainpath/device/device_class/device_id/transaction_stuff_here for the front_end.

Also, see correction below:

Quoted 10 lines · harry

If you look at writeDetails in tools/python/xen/xend/server/DevController.py you'll see the transactions which cause the back and front ends to get probed.

The transactions contain extra fields as provided by the derived class specific to the device type and are written into the store in the locations constructed in the frontendPath and backendPath functions in DevController.py. These paths contain the

device id - nope.

device_class

Quoted 40 lines

string as specified
when you registered your xenbus drivers.

Looking at the current code, it looks like domainpath/backend/device_class/frontend_uuid/device_id/transaction_stuff_here for the back-end and and domainpath/device_id/transaction_stuff_here
for the front-end.

HTH

Harry.

Quoted 11 lines · Jacob Gorm Hansen
Quoted 4 lines · Rami Rosen

Hello ,

I had written some pages which I had inserted into XenWiki this morning. It is in http://wiki.xensource.com/xenwiki/XenIntro.

Thanks a lot for this work. I suppose my main problem right now is finding out why the backend probe function is never called. Does anyone know what the tools in dom0 have to do to trigger the backend driver probe function?

Quoted 8 lines

Thanks,
Jacob

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw

(longing for the days when all one had to do was poke a few values in /proc/xen)

Quoted 4 lines · harry
Quoted 4 lines

Looking at the current code, it looks like domainpath/backend/device_class/frontend_uuid/device_id/transaction_stuff_here for the back-end and and
domainpath/device_id/transaction_stuff_here
for the front-end.

Hmm why does the backend need to deal with the uuid, I thought that was solely for the tools? So to recap, I have to:

- introduce dom0 to xenstore, with prefix=/local/domain/0
- mkdir /local/domain/0/backend
- mkdir /local/domain/0/device

And that will trigger the blkback-probe? Sorry if I am sounding confused, but I am fairly confident this stuff is more complex than it needs to be.

Thanks,
Jacob

#6 lore raw
Quoted 9 lines · Jacob Gorm Hansen

(longing for the days when all one had to do was poke a few values in /proc/xen)

Quoted 4 lines · harry
Quoted 4 lines

Looking at the current code, it looks like domainpath/backend/device_class/frontend_uuid/device_id/transaction_stuff_here for the back-end and and
domainpath/device_id/transaction_stuff_here
for the front-end.

Quoted 6 lines

Hmm why does the backend need to deal with the uuid, I thought that was solely for the tools? So to recap, I have to:

- introduce dom0 to xenstore, with prefix=/local/domain/0
- mkdir /local/domain/0/backend
- mkdir /local/domain/0/device

I doubt that mkdir will work. I would expect that you would have to go through xenstored to modify the store. vm-tools contained a utility to submit an arbitrary transaction to xenstored.

Quoted 4 lines

And that will trigger the blkback-probe? Sorry if I am sounding confused, but I am fairly confident this stuff is more complex than it needs to be.

Ouch, don't shoot the messenger.

Quoted 9 lines

Thanks,
Jacob

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#7 lore raw
Quoted 3 lines · harry

I doubt that mkdir will work. I would expect that you would have to go through xenstored to modify the store. vm-tools contained a utility to submit an arbitrary transaction to xenstored.

Sorry, I meant xs_mkdir().

Quoted 5 lines
Quoted 3 lines

And that will trigger the blkback-probe? Sorry if I am sounding confused, but I am fairly confident this stuff is more complex than it needs to be.

Ouch, don't shoot the messenger.

Sorry about that too, whoever dreamed this whole thing up has not been able to answer my increasingly desperate cries for help recently, and I am a little frustrated with the amount of time I have spent just getting a simple block device attached.

Jacob

#8 lore raw
Quoted 6 lines · Jacob Gorm Hansen

Sorry about that too, whoever dreamed this whole thing up has not been able to answer my increasingly desperate cries for help recently, and I am a little frustrated with the amount of time I have spent just getting a simple block device attached.

1) Create domain
domid = 0
xc_domain_create(&domid)
xc_domain_maxmem(domid, memory >> 10); xc_domain_memory_increase_reservation(domid, memory >> 12);

2) Build domain
lconsole = rconsole = 0; xc_evtchn_bind_interdomain(0, domid, &lconsole, &rconsole); lstore = rstore = 0; xc_evtchn_bind_interdomain(0, domid, &lconsole, &rconsole);

xc_linux_build(domid, kernel, ramdisk, cmdline, 0, vcpus, rstore,
&mfn_store, rconsole, &mfn_console)
home = "/tools/<yourtool>/domain/%d" % domid xs_domain_introduce(domid, mfn_store, lstore, home); xs_write(home + "/console/ring-ref", mfn_console) xs_write(home + "/console/port", lconsole)

3) Create block device (pdev, vdev)
static int uuid;

dom0_home = xs_get_domain_path(0)

backend = dom0_home + "/backend/vbd/%s/%s' % (uuid, domid) frontend = home + "/device/vbd/%s' % uuid

   transaction_start()
   xs_write(backend + "/frontend", frontend);
   xs_write(backend + "/frontend-id", domid);
   transaction_end()

   transaction_start()
   xs_write(frontend + "/backend", backend);
   xs_write(frontend + "/backend-id", 0);
   xs_write(frontend + "/virtual-device", vdev)
   transaction_end()

xs_write(backend + "/physical-device", pdev)

This might seem complicated, but compared to what you had to do under 2.0.x, it's a 1000x times easier.

Regards,

Anthony Liguori

Quoted 9 lines

Jacob

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#9 lore raw
Quoted 7 lines · Anthony Liguori

Jacob Gorm Hansen wrote:

1) Create domain
domid = 0
xc_domain_create(&domid)

   xc_domain_maxmem(domid, memory >> 10);
   xc_domain_memory_increase_reservation(domid, memory >> 12);

Hi Anthony,

Sounds like you're the right person to get the interface documentation written? :). Would be very helpful.

thanks,
Nivedita

Quoted 56 lines

2) Build domain

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

   xc_linux_build(domid, kernel, ramdisk, cmdline, 0, vcpus, rstore, 

&mfn_store, rconsole, &mfn_console)
home = "/tools/<yourtool>/domain/%d" % domid xs_domain_introduce(domid, mfn_store, lstore, home); xs_write(home + "/console/ring-ref", mfn_console) xs_write(home + "/console/port", lconsole)

3) Create block device (pdev, vdev)
static int uuid;

   dom0_home = xs_get_domain_path(0)

   backend = dom0_home + "/backend/vbd/%s/%s' % (uuid, domid)
   frontend = home + "/device/vbd/%s' % uuid

   transaction_start()
   xs_write(backend + "/frontend", frontend);
   xs_write(backend + "/frontend-id", domid);
   transaction_end()

   transaction_start()
   xs_write(frontend + "/backend", backend);
   xs_write(frontend + "/backend-id", 0);
   xs_write(frontend + "/virtual-device", vdev)
   transaction_end()

   xs_write(backend + "/physical-device", pdev)

This might seem complicated, but compared to what you had to do under 2.0.x, it's a 1000x times easier.

Regards,

Anthony Liguori

Quoted 9 lines

Jacob

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#10 lore raw
Quoted 12 lines · Nivedita Singhvi
Quoted 8 lines · Anthony Liguori

Jacob Gorm Hansen wrote:

1) Create domain
domid = 0
xc_domain_create(&domid)

   xc_domain_maxmem(domid, memory >> 10);
   xc_domain_memory_increase_reservation(domid, memory >> 12);
Quoted 4 lines

Hi Anthony,

Sounds like you're the right person to get the interface documentation written? :). Would be very helpful.

Doh! Seriously though, I'm more than happy to once 3.0 ships.

Regards,

Anthony Liguori

Quoted 62 lines

thanks,
Nivedita

Quoted 56 lines

2) Build domain

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

   xc_linux_build(domid, kernel, ramdisk, cmdline, 0, vcpus, rstore, 

&mfn_store, rconsole, &mfn_console)
home = "/tools/<yourtool>/domain/%d" % domid xs_domain_introduce(domid, mfn_store, lstore, home); xs_write(home + "/console/ring-ref", mfn_console) xs_write(home + "/console/port", lconsole)

3) Create block device (pdev, vdev)
static int uuid;

   dom0_home = xs_get_domain_path(0)

   backend = dom0_home + "/backend/vbd/%s/%s' % (uuid, domid)
   frontend = home + "/device/vbd/%s' % uuid

   transaction_start()
   xs_write(backend + "/frontend", frontend);
   xs_write(backend + "/frontend-id", domid);
   transaction_end()

   transaction_start()
   xs_write(frontend + "/backend", backend);
   xs_write(frontend + "/backend-id", 0);
   xs_write(frontend + "/virtual-device", vdev)
   transaction_end()

   xs_write(backend + "/physical-device", pdev)

This might seem complicated, but compared to what you had to do under 2.0.x, it's a 1000x times easier.

Regards,

Anthony Liguori

Quoted 9 lines

Jacob

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#12 lore raw
Quoted 6 lines · Jacob Gorm Hansen

Excellent, thank you!

One question: What (if anything) do I need to do to introduce dom0 and xenstore to eachother?

After booting and before doing anything else (but after starting xenstore):

lstore = rstore = 0;
xc_evtchn_bind_interdomain(0, 0, &lstore, &rstore)
mfn_store = xc_init_store(rstore); xs_mkdir("/tools/<yourtool>/domain/0") xs_introduce_domain(0, mfn_store, lstore, "/tools/<yourtool>/domain/0")

The store is supposed to remember introductions but I'm not sure if Rusty has gotten to that yet. If things don't work when you restart the store, it means that it isn't remembering them, in which case, you have to reintroduce. You'll have to remember the domain-0 stuff somehow as you cannot call xc_init_store more than once.

Regards,

Anthony Liguori

Quoted 5 lines

Thanks again, just what I was looking for.
Jacob

#13 lore raw
In reply to Anthony Liguori

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

#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
[email protected]
http://lists.xensource.com/xen-devel

#14 lore raw
Quoted 11 lines · Jacob Gorm Hansen

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

Quoted 145 lines

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;
}
#15 lore raw
In reply to Jacob Gorm Hansen
Quoted 6 lines · Jacob Gorm Hansen

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.

Funny, removing the xc_transaction_* calls changes things. The blkdev still does not work, but now blkback_probe gets called in dom0...

Jacob

#16 lore raw
In reply to Jacob Gorm Hansen
Quoted 8 lines · Jacob Gorm Hansen

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 code works for me.

Can you be more specific about what error you are seeing and what changeset you are on? It works just fine on my snapshot from Monday.

Regards,

Anthony Liguori

Quoted 148 lines

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

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

#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;
}
#17 lore raw

hi Anthony, thanks for testing the code.

I am on:

Changeset:   7267:89b1b67fc2c4
user:        [email protected]
date:        Wed Oct  5 17:54:09 2005 +0100
summary:     Emulate guest reads of CR4, masking features that Xen

(but I have had these problems with various 'latest' versions over the last couple of days).

Basically I am getting a timeout from the blkfront, which seems to because the blkback_probe function never gets called. At least now I know the code ought to be working, then I can start looking for the problem elsewhere. Perhaps this has to do with my hotplug installation.

Jacob

#18 lore raw
In reply to harry
Quoted 10 lines · harry

If you look at writeDetails in tools/python/xen/xend/server/DevController.py you'll see the transactions which cause the back and front ends to get probed.

The transactions contain extra fields as provided by the derived class specific to the device type and are written into the store in the locations constructed in the frontendPath and backendPath functions in DevController.py. These paths contain the device id string as specified when you registered your xenbus drivers.

Does that mean if I want to write a new split device, I must patch xend to let it aware of the new type of device?

I have the same problem here: I am struggling on the first simple backend/frontend driver, and I cannot figure out why probe functions in the frontend is not called.

Jacob, would you please share some of your experiences if you make your code run successfully?

Many thanks.
Hieu.

#19 lore raw
Quoted 12 lines · NAHieu
Quoted 10 lines · harry

If you look at writeDetails in tools/python/xen/xend/server/DevController.py you'll see the transactions which cause the back and front ends to get probed.

The transactions contain extra fields as provided by the derived class specific to the device type and are written into the store in the locations constructed in the frontendPath and backendPath functions in DevController.py. These paths contain the device id string as specified when you registered your xenbus drivers.

Quoted 2 lines

Does that mean if I want to write a new split device, I must patch xend to let it aware of the new type of device?

Yes. You have to add a new class in python/xen/xend/server (see blkif.py as an example) and then hook this class into xend in XendDomainInfo.py and xm/create.py to get the config parameters passed correctly.

Quoted 4 lines

I have the same problem here: I am struggling on the first simple backend/frontend driver, and I cannot figure out why probe functions in the frontend is not called.

Well, I have managed to get my probe functions called successfully :-) But I'm struggling with creating a mechanism which correctly constructs and tears-down the shared memory page in all the following scenarios:

FE module load/unload
BE module load/unload
device hot plug/remove
domain suspend/resume
domain start/stop

If someone with superior understanding would like to document a complete solution that would be really helpful.

Harry.

Quoted 12 lines

Jacob, would you please share some of your experiences if you make your code run successfully?

Many thanks.
Hieu.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#20 lore raw
Quoted 13 lines · harry
Quoted 12 lines · NAHieu
Quoted 10 lines · harry

If you look at writeDetails in tools/python/xen/xend/server/DevController.py you'll see the transactions which cause the back and front ends to get probed.

The transactions contain extra fields as provided by the derived class specific to the device type and are written into the store in the locations constructed in the frontendPath and backendPath functions in DevController.py. These paths contain the device id string as specified when you registered your xenbus drivers.

Quoted 7 lines
Quoted 2 lines

Does that mean if I want to write a new split device, I must patch xend to let it aware of the new type of device?

Yes. You have to add a new class in python/xen/xend/server (see blkif.py as an example) and then hook this class into xend in XendDomainInfo.py and xm/create.py to get the config parameters passed correctly.

or no ;) depending on what you want to do. so for example if you only ever have one backend in the system then you "could" store that under a well known name in the store and the frontends can simply read that. you'll also need a place for the BE to watch for FE updates in a similar fashion.

however this pretty adhoc and breaks a few conventions and might not work with well save/restore etc.but for prototyping it is sufficient and doesn't require xend mods.

if you want the split device be general available you'd probably have to mod xend.

Rolf

Quoted 37 lines
Quoted 4 lines

I have the same problem here: I am struggling on the first simple backend/frontend driver, and I cannot figure out why probe functions in the frontend is not called.

Well, I have managed to get my probe functions called successfully :-) But I'm struggling with creating a mechanism which correctly constructs and tears-down the shared memory page in all the following scenarios:

FE module load/unload
BE module load/unload
device hot plug/remove
domain suspend/resume
domain start/stop

If someone with superior understanding would like to document a complete solution that would be really helpful.

Harry.

Quoted 4 lines

Jacob, would you please share some of your experiences if you make your code run successfully?

Quoted 8 lines

Many thanks.
Hieu.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#21 lore raw
Quoted 22 lines · Rolf Neugebauer
Quoted 13 lines · harry
Quoted 12 lines · NAHieu
Quoted 10 lines · harry

If you look at writeDetails in tools/python/xen/xend/server/DevController.py you'll see the transactions which cause the back and front ends to get probed.

The transactions contain extra fields as provided by the derived class specific to the device type and are written into the store in the locations constructed in the frontendPath and backendPath functions in DevController.py. These paths contain the device id string as specified when you registered your xenbus drivers.

Quoted 7 lines
Quoted 2 lines

Does that mean if I want to write a new split device, I must patch xend to let it aware of the new type of device?

Yes. You have to add a new class in python/xen/xend/server (see blkif.py as an example) and then hook this class into xend in XendDomainInfo.py and xm/create.py to get the config parameters passed correctly.

Quoted 6 lines

or no ;) depending on what you want to do. so for example if you only ever have one backend in the system then you "could" store that under a well known name in the store and the frontends can simply read that. you'll also need a place for the BE to watch for FE updates in a similar fashion.

Rolf, I am really suprised here: how can BE watch for FE updates? BE and FE are in different domain, so they cannot access each other xenstore tree. (??)

So exactly what did you mean?

Thanks.
Hieu

#22 lore raw
Quoted 30 lines · NAHieu
Quoted 22 lines · Rolf Neugebauer
Quoted 13 lines · harry
Quoted 12 lines · NAHieu
Quoted 10 lines · harry

If you look at writeDetails in tools/python/xen/xend/server/DevController.py you'll see the transactions which cause the back and front ends to get probed.

The transactions contain extra fields as provided by the derived class specific to the device type and are written into the store in the locations constructed in the frontendPath and backendPath functions in DevController.py. These paths contain the device id string as specified when you registered your xenbus drivers.

Quoted 7 lines
Quoted 2 lines

Does that mean if I want to write a new split device, I must patch xend to let it aware of the new type of device?

Yes. You have to add a new class in python/xen/xend/server (see blkif.py as an example) and then hook this class into xend in XendDomainInfo.py and xm/create.py to get the config parameters passed correctly.

Quoted 6 lines

or no ;) depending on what you want to do. so for example if you only ever have one backend in the system then you "could" store that under a well known name in the store and the frontends can simply read that. you'll also need a place for the BE to watch for FE updates in a similar fashion.

Quoted 5 lines

Rolf, I am really suprised here: how can BE watch for FE updates? BE and FE are in different domain, so they cannot access each other xenstore tree. (??)

So exactly what did you mean?

so, you BE could set up:
/foobar/backend/domid = 2
/foobar/frontends <- watch on this

then FE looks up /foobar/backend/domid
setup its end of eventchannel + grant for shared page then creates:
/foobar/frontends/<domid>/fe_port /foobar/frontends/<domid>/grant_ref

BE watch fires, reads port and GR and finalises device channel set up

Seems to work for me.

Rolf

#23 lore raw
In reply to NAHieu
Quoted 9 lines · NAHieu
Quoted 8 lines

or no ;) depending on what you want to do. so for example if you only ever have one backend in the system then you "could" store that under a well known name in the store and the frontends can simply read that. you'll also need a place for the BE to watch for FE updates in a similar fashion.

Quoted 5 lines

Rolf, I am really suprised here: how can BE watch for FE updates? BE and FE are in different domain, so they cannot access each other xenstore tree. (??)

Yes they can. Permissions are currently off so technically any domain can access any other domains tree.

When permissions are enabled, the backends will have at least read permission on all the frontend domains.

Regards,

Anthony Liguori

Quoted 12 lines

So exactly what did you mean?

Thanks.
Hieu

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#24 lore raw
Quoted 16 lines · Anthony Liguori
Quoted 9 lines · NAHieu
Quoted 8 lines

or no ;) depending on what you want to do. so for example if you only ever have one backend in the system then you "could" store that under a well known name in the store and the frontends can simply read that. you'll also need a place for the BE to watch for FE updates in a similar fashion.

Quoted 5 lines

Rolf, I am really suprised here: how can BE watch for FE updates? BE and FE are in different domain, so they cannot access each other xenstore tree. (??)

Quoted 6 lines

Yes they can. Permissions are currently off so technically any domain can access any other domains tree.

When permissions are enabled, the backends will have at least read permission on all the frontend domains.

If so, I think we can do simply like this to exchange information between dom0 & domU:

- dom0 watch for @introduceDomain to detect the new domU comes up. Then dom0 watch for /domU/<device>/{evtchn,grant-ref}

- domU write evtchn,grant-ref,... to /domU/<device>/{evtchn,grant-ref} (better doesnt write it outside its home, like in Rolf's example)

- dom0 detect the updates, setup evtchn, then start to notify domU via this channel. Other data can be written into the share memory (like grant-ref above) to exchange information at this step.

This way is good (if it works - I will try it myself), since we don't need to mod xend, which is horrified to many. Any ideas?

But like Rolf pointed out, this solution is not good incase we want to save/restore(?)

Thanks.
Hieu

Quoted 18 lines

Regards,

Anthony Liguori

Quoted 12 lines

So exactly what did you mean?

Thanks.
Hieu

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#25 lore raw
Quoted 7 lines · NAHieu

If so, I think we can do simply like this to exchange information between dom0 & domU:

- dom0 watch for @introduceDomain to detect the new domU comes up. Then dom0 watch for /domU/<device>/{evtchn,grant-ref}

Tools should store their information in /tool/<toolname>/. Otherwise, yeah, it seems sane to me.

Regards,

Anthony Liguori

Quoted 43 lines

- domU write evtchn,grant-ref,... to /domU/<device>/{evtchn,grant-ref} (better doesnt write it outside its home, like in Rolf's example)

- dom0 detect the updates, setup evtchn, then start to notify domU via this channel. Other data can be written into the share memory (like grant-ref above) to exchange information at this step.

This way is good (if it works - I will try it myself), since we don't need to mod xend, which is horrified to many. Any ideas?

But like Rolf pointed out, this solution is not good incase we want to save/restore(?)

Thanks.
Hieu

Quoted 22 lines

Regards,

Anthony Liguori

Quoted 14 lines

So exactly what did you mean?

Thanks.
Hieu

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel