Attached is a patch that fully 'grant-table-ifies' the block front and

backends.  It is necessary to do a make clean in the tools directory and 
then rebuild the tree.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
This commit is contained in:
kaf24@firebug.cl.cam.ac.uk committed 2005-07-06 08:50:11 +00:00
1 parent 29395fa9ef
commit 3f54e6d5ec
7 files changed
+75 -5

No files matched your search

@@ -65,6 +65,11 @@ typedef struct blkif_st {
atomic_t refcnt;
struct work_struct work;
#ifdef CONFIG_XEN_BLKDEV_GRANT
u16 shmem_handle;
memory_t shmem_vaddr;
grant_ref_t shmem_ref;
#endif
} blkif_t;
void blkif_create(blkif_be_create_t *create);
@@ -39,6 +39,23 @@ static void __blkif_disconnect_complete(void *arg)
* must still be notified to the remote driver.
*/
unbind_evtchn_from_irq(blkif->evtchn);
#ifdef CONFIG_XEN_BLKDEV_GRANT
{
/*
* Release the shared memory page.
*/
struct gnttab_unmap_grant_ref op;
op.host_virt_addr = blkif->shmem_vaddr;
op.handle = blkif->shmem_handle;
op.dev_bus_addr = 0;
if(unlikely(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))) {
BUG();
}
}
#endif
vfree(blkif->blk_ring.sring);
/* Construct the deferred response message. */
@@ -154,8 +171,12 @@ void blkif_connect(blkif_be_connect_t *connect)
unsigned int evtchn = connect->evtchn;
unsigned long shmem_frame = connect->shmem_frame;
struct vm_struct *vma;
#ifdef CONFIG_XEN_BLKDEV_GRANT
int ref = connect->shmem_ref;
#else
pgprot_t prot;
int error;
#endif
blkif_t *blkif;
blkif_sring_t *sring;
@@ -174,6 +195,7 @@ void blkif_connect(blkif_be_connect_t *connect)
return;
}
#ifndef CONFIG_XEN_BLKDEV_GRANT
prot = __pgprot(_KERNPG_TABLE);
error = direct_remap_area_pages(&init_mm, VMALLOC_VMADDR(vma->addr),
shmem_frame<<PAGE_SHIFT, PAGE_SIZE,
@@ -189,6 +211,36 @@ void blkif_connect(blkif_be_connect_t *connect)
vfree(vma->addr);
return;
}
#else
{ /* Map: Use the Grant table reference */
struct gnttab_map_grant_ref op;
op.host_virt_addr = VMALLOC_VMADDR(vma->addr);
op.flags = GNTMAP_host_map;
op.ref = ref;
op.dom = domid;
if(unlikely(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))) {
BUG();
}
handle = op.handle;
if (op.handle < 0) {
DPRINTK(" Grant table operation failure !\n");
connect->status = BLKIF_BE_STATUS_MAPPING_ERROR;
vfree(vma->addr);
return;
}
phys_to_machine_mapping[__pa(VMALLOC_VMADDR(vma->addr)) >>
PAGE_SHIFT] =
FOREIGN_FRAME(shmem_frame);
blkif->shmem_ref = ref;
blkif->shmem_handle = handle;
blkif->shmem_vaddr = VMALLOC_VMADDR(vma->addr);
}
#endif
if ( blkif->status != DISCONNECTED )
{
@@ -1136,6 +1136,12 @@ static void blkif_send_interface_connect(void)
msg->handle = 0;
msg->shmem_frame = (virt_to_machine(blk_ring.sring) >> PAGE_SHIFT);
#ifdef CONFIG_XEN_BLKDEV_GRANT
msg->shmem_ref = gnttab_claim_grant_reference( &gref_head, gref_terminal );
ASSERT( msg->shmem_ref != -ENOSPC );
gnttab_grant_foreign_access_ref ( msg->shmem_ref , rdomid, msg->shmem_frame, 0 );
#endif
ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
}
@@ -1261,9 +1267,6 @@ static void blkif_connect(blkif_fe_interface_status_t *status)
blkif_evtchn = status->evtchn;
blkif_irq = bind_evtchn_to_irq(blkif_evtchn);
#ifdef CONFIG_XEN_BLKDEV_GRANT
rdomid = status->domid;
#endif
err = request_irq(blkif_irq, blkif_int, SA_SAMPLE_RANDOM, "blkif", NULL);
if ( err )
@@ -1300,6 +1303,10 @@ static void unexpected(blkif_fe_interface_status_t *status)
static void blkif_status(blkif_fe_interface_status_t *status)
{
#ifdef CONFIG_XEN_BLKDEV_GRANT
rdomid = status->domid; /* need to set rdomid early */
#endif
if ( status->handle != blkif_handle )
{
WPRINTK(" Invalid blkif: handle=%u\n", status->handle);
+3
View File
@@ -594,6 +594,7 @@ static PyObject *xu_message_get_payload(PyObject *self, PyObject *args)
case TYPE(CMSG_BLKIF_FE, CMSG_BLKIF_FE_INTERFACE_CONNECT):
C2P(blkif_fe_interface_connect_t, handle, Int, Long);
C2P(blkif_fe_interface_connect_t, shmem_frame, Int, Long);
C2P(blkif_fe_interface_connect_t, shmem_ref , Int, Long);
return dict;
case TYPE(CMSG_BLKIF_FE, CMSG_BLKIF_FE_INTERFACE_DISCONNECT):
C2P(blkif_fe_interface_disconnect_t, handle, Int, Long);
@@ -612,6 +613,7 @@ static PyObject *xu_message_get_payload(PyObject *self, PyObject *args)
C2P(blkif_be_connect_t, domid, Int, Long);
C2P(blkif_be_connect_t, blkif_handle, Int, Long);
C2P(blkif_be_connect_t, shmem_frame, Int, Long);
C2P(blkif_be_connect_t, shmem_ref, Int, Long);
C2P(blkif_be_connect_t, evtchn, Int, Long);
C2P(blkif_be_connect_t, status, Int, Long);
return dict;
@@ -842,6 +844,7 @@ static PyObject *xu_message_new(PyObject *self, PyObject *args)
P2C(blkif_be_connect_t, domid, u32);
P2C(blkif_be_connect_t, blkif_handle, u32);
P2C(blkif_be_connect_t, shmem_frame, memory_t);
P2C(blkif_be_connect_t, shmem_ref, u32);
P2C(blkif_be_connect_t, evtchn, u16);
break;
case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DISCONNECT):
+2 -1
View File
@@ -126,7 +126,8 @@ class BlkifBackend:
{ 'domid' : self.frontendDomain,
'blkif_handle' : self.id,
'evtchn' : self.getEventChannelBackend(),
'shmem_frame' : val['shmem_frame'] })
'shmem_frame' : val['shmem_frame'],
'shmem_ref' : val['shmem_ref'] })
msg = self.backendChannel.requestResponse(msg)
#todo: check return status
val = unpackMsg('blkif_be_connect_t', msg)
+1 -1
View File
@@ -19,7 +19,7 @@
* This makes sure that old versions of dom0 tools will stop working in a
* well-defined way (rather than crashing the machine, for instance).
*/
#define DOM0_INTERFACE_VERSION 0xAAAA100B
#define DOM0_INTERFACE_VERSION 0xAAAA100C
/************************************************************************/
@@ -140,6 +140,7 @@ typedef struct blkif_fe_driver_status {
typedef struct blkif_fe_interface_connect {
u32 handle;
memory_t shmem_frame;
int shmem_ref;
} blkif_fe_interface_connect_t;
/*
@@ -249,6 +250,7 @@ typedef struct blkif_be_connect {
domid_t domid; /* Domain attached to new interface. */
u32 blkif_handle; /* Domain-specific interface handle. */
memory_t shmem_frame; /* Page cont. shared comms window. */
int shmem_ref; /* Grant table reference. */
u32 evtchn; /* Event channel for notifications. */
/* OUT */
u32 status;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.