Jacob Gorm Hansen
2006-Jan-12 11:42 UTC
[Xen-devel] Getting VBD working with xenstore, again
hi, I have the code below, a version of which used to (just before xen3 release) work fine for giving my domain access to a block device. I have tried to adjust this based on the python source, but my block device no longer registers in domU :-( For domU I am using the linux-2.6.12 from xen-unstable (about one week old) and for dom0 linux-2.6-xen.hg of about the same age. void setup_vbd(int domid, int uuid, char* vdev, char* pdev) { struct xs_transaction_handle* t; struct xs_permissions xsperms[2]; xsperms[0].id = domid; xsperms[0].perms = XS_PERM_READ | XS_PERM_WRITE; char s[256]; char s2[256]; char* home = xs_get_domain_path(xs,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_begin(); sprintf(s,"%s/domain",backend); sprintf(s2,"%d",domid); xs_w(s, s2); sprintf(s,"%s/frontend",backend); xs_w(s, frontend ); sprintf(s,"%s/frontend-id",backend); sprintf(s2,"%d",domid); xs_w(s, s2 ); sprintf(s, "%s/state", backend); xs_w(s, "1"); xs_end(); xs_begin(); xs_mkdir(xs,t,backend); int result = xs_set_permissions(xs, t, backend, xsperms, 1); sprintf(s,"%s/backend",frontend); xs_w(s, backend ); sprintf(s, "%s/backend-id", frontend); xs_w(s, "0"); sprintf(s, "%s/state", frontend); xs_w(s, "1"); sprintf(s, "%s/virtual-device", frontend); xs_w(s, vdev ); xs_end(); } I hope someone can point out the obvious mistake in the code above. Thanks in advance, Jacob _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jacob Gorm Hansen
2006-Jan-12 14:42 UTC
[Xen-devel] Re: Getting VBD working with xenstore, again
On 1/12/06, Jacob Gorm Hansen <jacobg@diku.dk> wrote:> hi, > > I have the code below, a version of which used to (just before xen3 > release) work fine for giving my domain access to a block device. I > have tried to adjust this based on the python source, but my block > device no longer registers in domU :-(Got it working, main points was that I had to reverse the order of writing to frontend and backend stores (probably not new actually), that the physical-device string is now in "%x:%x" format (but the virtual-device is not...) and that the the mode key is mandatory. Best, Jacob _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ewan Mellor
2006-Jan-12 15:55 UTC
Re: [Xen-devel] Re: Getting VBD working with xenstore, again
On Thu, Jan 12, 2006 at 03:42:12PM +0100, Jacob Gorm Hansen wrote:> On 1/12/06, Jacob Gorm Hansen <jacobg@diku.dk> wrote: > > hi, > > > > I have the code below, a version of which used to (just before xen3 > > release) work fine for giving my domain access to a block device. I > > have tried to adjust this based on the python source, but my block > > device no longer registers in domU :-( > > Got it working, main points was that I had to reverse the order of > writing to frontend and backend stores (probably not new actually),You ought to be writing these entries in one transaction, so that they appear atomically. This will guarantee that you avoid any race conditions on start-up.> that the physical-device string is now in "%x:%x" format (but the > virtual-device is not...)My intention was to change virtual-device so that it was the name rather than the device number -- there''s no reason for dom0''s device numbers to be the same as domU''s, as they may be different operating systems -- but it didn''t make it into 3.0, due to lack of time ;-( Ewan. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel