Hi,
How can I create vbd and vif devices?
This code does'nt work.
void setup_vbd(struct xs_handle *xs, uint32_t domid, struct vbd* vbd) {
char s[256];
char s2[256];
char pdev[8];
char vdev[8];
char backend[256];
char frontend[256];
char node[16];
xs_transaction_t trans;
struct xs_permissions xsperms[2];
char* home = xs_get_domain_path(xs,domid);
char* dom0_home = xs_get_domain_path(xs,0);
xsperms[0].id = domid;
xsperms[0].perms = XS_PERM_READ | XS_PERM_WRITE;
sprintf( pdev,"%u:%u",vbd->pdev>>8, vbd->pdev & 0xff );
sprintf( backend,"%s/backend/vbd/%d/%d",dom0_home,domid,vbd->vdev );
sprintf( frontend, "%s/device/vbd/%d",home,vbd->vdev );
trans = xs_transaction_start( xs );
xs_mkdir( xs, trans, backend );
xs_set_permissions( xs, trans, backend, xsperms, 1 );
sprintf( s,"%s/backend",frontend );
xs_write( xs, trans, s, backend, strlen(backend) );
sprintf( s, "%s/backend-id", frontend );
xs_write( xs, trans, s, "0", 1);
sprintf( s, "%s/state", frontend );
xs_write( xs, trans, s, "1", 1);
sprintf( s, "%s/virtual-device", frontend );
sprintf( vdev,"%u",vbd->vdev );
xs_write( xs, trans, s, vdev, strlen(vdev) );
sprintf( s,"%s/domain",backend );
sprintf( s2,"%d",domid );
xs_write( xs, trans, s, s2, strlen(s2) );
sprintf( s,"%s/frontend",backend );
xs_write( xs, trans, s, frontend, strlen(frontend) );
sprintf( s,"%s/frontend-id",backend );
sprintf( s2,"%d",domid );
xs_write( xs, trans, s, s2, strlen(s2) );
sprintf( s, "%s/state", backend );
xs_write( xs, trans, s, "1", 1 );
sprintf( s, "%s/physical-device",backend );
xs_write( xs, trans, s, pdev, strlen(pdev) );
sprintf( s, "%s/mode",backend );
xs_write( xs, trans, s, vbd->mode, strlen(vbd->mode));
sprintf( node,"/dev/hda%d",vbd->vdev-0x300 );
xs_transaction_end( xs, trans, 0 );
return;
}
void setup_vif(struct xs_handle *xs, uint32_t domid, int uuid ) {
char s[256];
char s2[256];
struct xs_permissions xsperms[2];
char* home = xs_get_domain_path(xs,domid);
char* dom0_home = xs_get_domain_path(xs,0);
char backend[256];
char frontend[256];
xs_transaction_t trans;
xsperms[0].id = domid;
xsperms[0].perms = XS_PERM_READ | XS_PERM_WRITE;
sprintf(backend,"%s/backend/vif/%d/%d",dom0_home,domid,uuid);
sprintf(frontend, "%s/device/vif/%d",home,uuid);
trans = xs_transaction_start( xs );
xs_mkdir( xs, trans, backend );
xs_set_permissions( xs, trans, backend, xsperms, 1 );
sprintf(s,"%s/handle",frontend);
sprintf(s2,"%d",uuid);
xs_write( xs, trans, s, s2, strlen(s2) );
sprintf( s,"%s/mac",frontend );
xs_write( xs, trans, s, "aa:00:00:11:a6:02", 17 );
sprintf(s, "%s/backend-id", frontend);
xs_write( xs, trans, s, "0", 1 );
sprintf( s,"%s/backend",frontend );
xs_write( xs, trans, s, backend, strlen(backend) );
sprintf( s, "%s/state", frontend );
xs_write( xs, trans, s, "1", 1);
sprintf( s,"%s/handle",backend );
sprintf( s2,"%d",uuid );
xs_write( xs, trans, s, s2, strlen(s2) );
sprintf( s,"%s/mac",backend );
xs_write( xs, trans, s, "aa:00:00:11:a6:02", 17 );
sprintf( s,"%s/script",backend );
xs_write( xs, trans, s, "/bin/test", 9 );
sprintf( s,"%s/frontend", backend );
xs_write( xs, trans, s, frontend, strlen(frontend) );
sprintf( s,"%s/frontend-id",backend );
sprintf( s2,"%d",domid );
xs_write( xs, trans, s, s2, strlen(s2) );
sprintf( s, "%s/state", backend );
xs_write( xs, trans, s, "1", 1 );
sprintf( s, "%s/handle", backend );
sprintf( s2,"%d",uuid );
xs_write( xs, trans, s, s2, strlen(s2) );
//sprintf(s, "%s/online", backend);
//xs_w(s, "1");
xs_transaction_end( xs, trans, 0 );
return;
}
--
Dmitry Fedotov <exdiff@xxxxxxxxx>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|