xen-livepatch fixes for Xen 4.8
PATCH 1/1 xen-livepatch fixes for Xen 4.8
Hey!
Three tiny fixes that came about from various reports from folks.
tools/misc/xen-livepatch.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
Konrad Rzeszutek Wilk (3):
xen-livepatch: Remove the 'test' part
xen-livepatch: Print the header _after_ the first livepatch hypercall
xen-livepatch: If hypervisor is not compiled with Livepatching
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 1/3 xen-livepatch: Remove the 'test' part
As it has evolved a bit and is more of a test tool.
--- tools/misc/xen-livepatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/misc/xen-livepatch.c +1 -1
@@ -20,7 +20,7 @@ static xc_interface *xch;void show_help (void ) {fprintf (stderr, -"xen-livepatch: live patching test tool\n" +"xen-livepatch: live patching tool\n" "Usage: xen-livepatch <command> [args]\n" " <name> An unique name of payload. Up to %d characters.\n" "Commands:\n"
Signature · 7 lines
2.4.11 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v1 1/3] xen-livepatch: Remove the 'test' part
Quoted 14 lines · Konrad Rzeszutek Wilk
As it has evolved a bit and is more of a test tool.
Reported-by Bhavesh Davda <[email protected]>Signed-off-by Konrad Rzeszutek Wilk <[email protected]>--- tools/misc/xen-livepatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/misc/xen-livepatch.c +0
-0
tools/misc/xen-livepatch.c static xc_interface *xch; · line 26
Quoted 8 lines
tools/misc/xen-livepatch.c +1
-1@@ -20,7 +20,7 @@ static xc_interface *xch;void show_help (void ) {fprintf (stderr, -"xen-livepatch: live patching test tool\n" +"xen-livepatch: live patching tool\n" "Usage: xen-livepatch <command> [args]\n" " <name> An unique name of payload. Up to %d characters.\n" "Commands:\n"
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 2/3 xen-livepatch: Print the header _after_ the first livepatch hypercall
In reply to Konrad Rzeszutek WilkThat way we can print out the header if we are sure the hypervisor has been compiled with Xen Livepatching.
--- tools/misc/xen-livepatch.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/misc/xen-livepatch.c +4 -2
@@ -91,8 +91,6 @@ static int list_func(int argc, char *argv[])return rc; } -fprintf (stdout," ID | status\n" -"----------------------------------------+------------\n" ); do { done = 0; /* The memset is done to catch errors. */
@@ -106,6 +104,10 @@ static int list_func(int argc, char *argv[]) idx, left, errno, strerror(errno));break ; } +if ( !idx ) +fprintf (stdout," ID | status\n" +"----------------------------------------+------------\n" ); +for ( i =0 ; i < done; i++ ) {unsigned int j;
Signature · 7 lines
2.4.11 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v1 2/3] xen-livepatch: Print the header _after_ the first livepatch hypercall
Quoted 4 lines · Konrad Rzeszutek Wilk
That way we can print out the header if we are sure the hypervisor has been compiled with Xen Livepatching.
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 3/3 xen-livepatch: If hypervisor is not compiled with Livepatching
In reply to Konrad Rzeszutek Wilk. print a better error code.
--- tools/misc/xen-livepatch.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tools/misc/xen-livepatch.c +5 -2
@@ -100,8 +100,11 @@ static int list_func(int argc, char *argv[]) rc =xc_livepatch_list (xch,MAX_LEN , idx, info, name, len, &done, &left);if ( rc ) { -fprintf (stderr,"Failed to list %d/%d: %d(%s)!\n" , - idx, left, errno,strerror (errno)); +if ( errno ==ENOSYS ) +fprintf (stderr,"Hypervisor compiled without Xen Livepatching!\n" ); +else +fprintf (stderr,"Failed to list %d/%d: %d(%s)!\n" , + idx, left, errno,strerror (errno));break ; }if ( !idx )
Signature · 7 lines
2.4.11 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching
Quoted 17 lines · Konrad Rzeszutek Wilk
. print a better error code.
Reported-by Andrew Cooper <[email protected]>Signed-off-by Konrad Rzeszutek Wilk <[email protected]>--- tools/misc/xen-livepatch.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tools/misc/xen-livepatch.c +0
-0@@ -100,8 +100,11 @@ static int list_func(int argc, char *argv[]) rc =xc_livepatch_list (xch,MAX_LEN , idx, info, name, len, &done, &left);if ( rc ) {
tools/misc/xen-livepatch.c static int list_func(int argc, char *argv[]) · line 110
Quoted 10 lines
tools/misc/xen-livepatch.c +5
-2-fprintf (stderr,"Failed to list %d/%d: %d(%s)!\n" , - idx, left, errno,strerror (errno)); +if ( errno ==ENOSYS ) +fprintf (stderr,"Hypervisor compiled without Xen Livepatching!\n" ); +else +fprintf (stderr,"Failed to list %d/%d: %d(%s)!\n" , + idx, left, errno,strerror (errno));break ; }if ( !idx )
You should save errno since you have an fprintf before you check it.
Also, it would be good to do the same check for the first xc_livepatch_get in action_func() and for the xc_livepatch_upload in upload_func.
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching
Quoted 22 lines · Ross Lagerwall
Quoted 21 lines · Konrad Rzeszutek Wilk
. print a better error code.
Reported-by Andrew Cooper <[email protected]>Signed-off-by Konrad Rzeszutek Wilk <[email protected]>--- tools/misc/xen-livepatch.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tools/misc/xen-livepatch.c +3
-2@@ -100,8 +100,11 @@ static int list_func(int argc, char *argv[]) rc =xc_livepatch_list (xch,MAX_LEN , idx, info, name, len, &done, &left);if ( rc ) { -fprintf (stderr,"Failed to list %d/%d: %d(%s)!\n" , - idx, left, errno,strerror (errno)); +if ( errno ==ENOSYS ) +fprintf (stderr,"Hypervisor compiled without Xen Livepatching!\n" ); +else
Quoted 8 lines
tools/misc/xen-livepatch.c static int list_func(int argc, char *argv[]) · line 110
Quoted 6 lines
tools/misc/xen-livepatch.c +2
-0+fprintf (stderr,"Failed to list %d/%d: %d(%s)!\n" , + idx, left, errno,strerror (errno));break ; }if ( !idx )You should save errno since you have an fprintf before you check it.
I am missing something.
Why would fprintf mess up 'errno' ?
Quoted 3 lines
Also, it would be good to do the same check for the first
xc_livepatch_getinaction_func()and for thexc_livepatch_uploadinupload_func.
<nods>
Quoted 3 lines
Signature · 2 lines
-- Ross Lagerwall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching
Konrad Rzeszutek Wilk writes ("Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching"):
Quoted 6 lines · Ross Lagerwall
Quoted 1 line
You should save errno since you have an fprintf before you check it.
I am missing something.
Why would fprintf mess up 'errno' ?
Any libc function is entitled to set errno, if it fails.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching
Ian Jackson writes ("Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching"):
Quoted 4 lines
Konrad Rzeszutek Wilk writes ("Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching"):
Quoted 1 line
Why would fprintf mess up 'errno' ?
Any libc function is entitled to set errno, if it fails.
And, I forget the exact rules, but I think most are allowed to trash it even if they succeed. I just remember that errno needs to be saved across libc calls, if the value is important.
In practice, for example, the first fprintf on a particular FILE* can end up setting errno to ENOTTY as the libc calls isatty() to decide on the buffering mode.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching
Quoted 6 lines · Ian Jackson
Ian Jackson writes ("Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching"):
Quoted 4 lines
Konrad Rzeszutek Wilk writes ("Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching"):
Quoted 1 line
Why would fprintf mess up 'errno' ?
Any libc function is entitled to set errno, if it fails.
Quoted 7 lines
And, I forget the exact rules, but I think most are allowed to trash it even if they succeed. I just remember that errno needs to be saved across libc calls, if the value is important.
In practice, for example, the first fprintf on a particular FILE* can end up setting errno to ENOTTY as the libc calls
isatty()to decide on the buffering mode.
Aaah! Thanks!
Quoted 2 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching
In reply to Konrad Rzeszutek WilkQuoted 32 lines · Konrad Rzeszutek Wilk
Quoted 22 lines · Ross Lagerwall
Quoted 21 lines · Konrad Rzeszutek Wilk
. print a better error code.
Reported-by Andrew Cooper <[email protected]>Signed-off-by Konrad Rzeszutek Wilk <[email protected]>--- tools/misc/xen-livepatch.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tools/misc/xen-livepatch.c +3
-2@@ -100,8 +100,11 @@ static int list_func(int argc, char *argv[]) rc =xc_livepatch_list (xch,MAX_LEN , idx, info, name, len, &done, &left);if ( rc ) { -fprintf (stderr,"Failed to list %d/%d: %d(%s)!\n" , - idx, left, errno,strerror (errno)); +if ( errno ==ENOSYS ) +fprintf (stderr,"Hypervisor compiled without Xen Livepatching!\n" ); +else Quoted 8 lines
tools/misc/xen-livepatch.c static int list_func(int argc, char *argv[]) · line 110
Quoted 6 lines
tools/misc/xen-livepatch.c +2
-0+fprintf (stderr,"Failed to list %d/%d: %d(%s)!\n" , + idx, left, errno,strerror (errno));break ; }if ( !idx )You should save errno since you have an fprintf before you check it.
Quoted 4 lines
I am missing something.
Why would fprintf mess up 'errno' ?
Quoted 1 line
If the first fprintf fails for whatever reason (e.g. ENOSPC), then it will set errno and the subsequent check of errno afterwards will serve no purpose.
I have a patch to fix this issue for the rest of xen-livepatch.c, and will send it out shortly.
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel