X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Finterfaces%2Fvmm_stream.c;h=3a3ccf761dd0a4fa919d1fb4325a6a2fa860b2b0;hb=4d1d8fadad33de7d3ebce2083d9782048f78b44e;hp=377a545f51eea9c7d8fc9c1c92c0fa0d4c47f9c1;hpb=ef34565873989f5b0240f7f9911c3666a69587c9;p=palacios.git diff --git a/palacios/src/interfaces/vmm_stream.c b/palacios/src/interfaces/vmm_stream.c index 377a545..3a3ccf7 100644 --- a/palacios/src/interfaces/vmm_stream.c +++ b/palacios/src/interfaces/vmm_stream.c @@ -29,14 +29,19 @@ static struct v3_stream_hooks * stream_hooks = NULL; // VM can be NULL struct v3_stream * v3_stream_open(struct v3_vm_info * vm, const char * name, - uint64_t (*input)(struct v3_stream * stream, uint8_t * buf, uint64_t len), + sint64_t (*input)(struct v3_stream * stream, uint8_t * buf, sint64_t len), void * guest_stream_data) { struct v3_stream * stream = NULL; - V3_ASSERT(stream_hooks != NULL); - V3_ASSERT(stream_hooks->open != NULL); + V3_ASSERT(vm, VCORE_NONE, stream_hooks != NULL); + V3_ASSERT(vm, VCORE_NONE, stream_hooks->open != NULL); - stream = V3_Malloc(sizeof(struct v3_stream *)); + stream = V3_Malloc(sizeof(struct v3_stream)); + + if (!stream) { + PrintError(vm, VCORE_NONE, "Cannot allocate in opening a stream\n"); + return NULL; + } stream->input = input; stream->guest_stream_data = guest_stream_data; @@ -45,16 +50,16 @@ struct v3_stream * v3_stream_open(struct v3_vm_info * vm, const char * name, return stream; } -uint64_t v3_stream_output(struct v3_stream * stream, uint8_t * buf, uint32_t len) { - V3_ASSERT(stream_hooks != NULL); - V3_ASSERT(stream_hooks->output != NULL); +sint64_t v3_stream_output(struct v3_stream * stream, uint8_t * buf, sint64_t len) { + V3_ASSERT(VM_NONE, VCORE_NONE, stream_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, stream_hooks->output != NULL); return stream_hooks->output(stream, buf, len); } void v3_stream_close(struct v3_stream * stream) { - V3_ASSERT(stream_hooks != NULL); - V3_ASSERT(stream_hooks->close != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, stream_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, stream_hooks->close != NULL); stream_hooks->close(stream); @@ -65,7 +70,7 @@ void v3_stream_close(struct v3_stream * stream) { void V3_Init_Stream(struct v3_stream_hooks * hooks) { stream_hooks = hooks; - PrintDebug("V3 stream inited\n"); + PrintDebug(VM_NONE, VCORE_NONE, "V3 stream inited\n"); return; }