WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] creating vif and vbd devices

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] creating vif and vbd devices
From: exdiff@xxxxxxxxx
Date: Thu, 25 Sep 2008 16:14:42 +0400
Delivery-date: Thu, 25 Sep 2008 05:15:14 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:x-mailer:mime-version:content-type :content-transfer-encoding; bh=+sW9wf5oRwHPM8iqkYj8mQrib9ihU5SxHAvYCVw0cZs=; b=kDiWP7FH/NOo0sJXMY8DQT9rvPdJ85jfcO8dNLG2HZvUTO8VkVQe385T2NIOgEPo0S bhrRM0kWEqIJzeDK00xruhpSTWSoY+Xp7LDgUYdcDow+nXAA2eH27KSoUWV8NJEfoGTk dTlQumzRsfpEQiBcniQ7fWfAmASYJnPYIcWxs=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:x-mailer:mime-version:content-type :content-transfer-encoding; b=MCMpcl9l2r+clIl8QQnxBrqtNWYWv/U6o4Bg9esvsG/4g4bP5pAcbacqB51SIVQksW uNr1YFHWFUdbAmUS1+ZayMs1XvcrERcW6CEszOTgxW3vBVyFC279GaQwH+cCMEUZH2i1 NDE1SB63nsoT7qD9IXb85ASQpNX/kA5Q8wmwU=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] creating vif and vbd devices, exdiff <=