handling errors in blktaplib
PATCH 1/1 handling errors in blktaplib
blktaplib doesnt handle errors properly in several places: it just printed out the error message and exit, which is a bad behaviour for a library.
this patch (against [email protected]) fixes the problem and then handles the potential errors in blkdump. it also makes few cleanups. (Andrew, there is another fix for parallax, but it will be sent later, after my last patch on parallax get merged/rejected)
$ diffstat blktap2.patch blkdump.c | 18 +++++++++++++++--- blktaplib.c | 46 +++++++++++++++++++++++++++++++--------------- blktaplib.h | 12 +++++++++--- 3 files changed, 55 insertions(+), 21 deletions(-)
===== tools/blktap/blkdump.c 1.3 vs edited =====
tools/blktap/blkdump.c +15 -3
@@ -122,9 +122,21 @@int main (int argc,char *argv[]) { -blktap_register_ctrl_hook ("control_print" , control_print); -blktap_register_request_hook ("request_print" , request_print); -blktap_register_response_hook ("response_print" , response_print); +if (blktap_register_ctrl_hook ("control_print" , control_print) ==-1 ) + { +printf ("Error on registering control_print hook. Halt!\n" ); +return -1 ; + } +if (blktap_register_request_hook ("request_print" , request_print) ==-1 ) + { +printf ("Error on registering request_print hook. Halt!\n" ); +return -1 ; + } +if (blktap_register_response_hook ("response_print" , response_print) ==-1 ) + { +printf ("Error on registering response_print hook. Halt!\n" ); +return -1 ; + }blktap_listen ();return 0 ;
===== tools/blktap/blktaplib.c 1.6 vs edited =====
tools/blktap/blktaplib.c +31 -15
119 lines not on this page · raw message
===== tools/blktap/blktaplib.h 1.5 vs edited =====
tools/blktap/blktaplib.h +9 -3
@@ -67,9 +67,15 @@inline unsigned int ID_TO_IDX (unsigned long id);inline domid_t ID_TO_DOM (unsigned long id); -void blktap_register_ctrl_hook (char *name,int (*ch)(control_msg_t *)); -void blktap_register_request_hook (char *name,int (*rh)(blkif_request_t *)); -void blktap_register_response_hook (char *name,int (*rh)(blkif_response_t *)); +/* blktap_register_ctrl_hook returns -1 on error, 0 on success */ +int blktap_register_ctrl_hook (char *name,int (*ch)(control_msg_t *)); + +/* blktap_register_request_hook returns -1 on error, 0 on success */ +int blktap_register_request_hook (char *name,int (*rh)(blkif_request_t *)); + +/* blktap_register_response_hook returns -1 on error, 0 on success */ +int blktap_register_response_hook (char *name,int (*rh)(blkif_response_t *)); +void blktap_inject_response (blkif_response_t *);int blktap_attach_poll (int fd,short events,int (*func)(int ));void blktap_detach_poll (int fd);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel