X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_usr%2Fv3_user_keyed_stream_example.c;h=6068b0cf31863859571775face61a8f9b4d55a75;hb=3878df3f39c735f0cc565166ee5bcf0294ea1092;hp=1e126da7333617fbe7e0fa12d7370150c5dbd192;hpb=7b67d47d87463b237db5ad43941742c5a5d4b0bf;p=palacios.releases.git diff --git a/linux_usr/v3_user_keyed_stream_example.c b/linux_usr/v3_user_keyed_stream_example.c index 1e126da..6068b0c 100644 --- a/linux_usr/v3_user_keyed_stream_example.c +++ b/linux_usr/v3_user_keyed_stream_example.c @@ -30,13 +30,24 @@ int do_work(struct palacios_user_keyed_stream_op *req, // req->xfer : unused // req->user_key : the opaque key previously provided by you by an open key // req->buf_len : length of data - // req->buf : buffer (contains key name (open key) or value (write key)) - // - + // req->data_off : start of data within the buffer + // buf[0..data_off-1] is a tag (for read or write key) + // buf[data_off..buf_len-1] is data (for write key) + // req->buf : buffer + // open key: key name (open key) + // read key: tag + // write key: tag and data + // now built a response *resp = malloc(sizeof(struct palacios_user_keyed_stream_op) + datasize); + if (!*resp) { + fprintf(stderr, "ERROR: could not allocate space for response\n"); + return -1; + } + (*resp)->len = sizeof(struct palacios_user_keyed_stream_op) + datasize; (*resp)->buf_len = datasize; + (*resp)->data_off = 0; // always the case for a response (*resp)->type = req->type; (*resp)->user_key = req->user_key; @@ -48,7 +59,10 @@ int do_work(struct palacios_user_keyed_stream_op *req, // resp->xfer : contains the size of data read or written (in read key or write key) // resp->user_key : unused // resp->buf_len : length of data following + // resp->data_off : offset of the data in the buffer // resp->buf : buffer (contains the data (read key)) + // read key: data + // write key: nothing return 0;