Skip to contentSkip to conversation

xen-livepatch fixes for Xen 4.8

PATCH New Konrad Rzeszutek Wilk 3 participants 12 messages Sep 21, 2016 – Sep 22, 2016

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

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
index 62c072e..7512a98 100644
@@ -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
Reviewed-by on v1 1/3
#2 lore raw

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.

---
 tools/misc/xen-livepatch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/misc/xen-livepatch.c +0 -0
index 62c072e..7512a98 100644

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

#3 lore raw

PATCH 2/3 xen-livepatch: Print the header _after_ the first livepatch hypercall

In reply to Konrad Rzeszutek Wilk

That 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
index 7512a98..2de04c0 100644
@@ -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
Reviewed-by on v1 2/3
#4 lore raw

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.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw

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
index 2de04c0..f11e71f07f 100644
@@ -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
#6 lore raw

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.

---
 tools/misc/xen-livepatch.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
tools/misc/xen-livepatch.c +0 -0
index 2de04c0..f11e71f07f 100644
@@ -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
#7 lore raw

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.

---
 tools/misc/xen-livepatch.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
tools/misc/xen-livepatch.c +3 -2
index 2de04c0..f11e71f07f 100644
@@ -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_get in action_func() and for the xc_livepatch_upload in upload_func.

<nods>

Quoted 3 lines
Signature · 2 lines
-- 
Ross Lagerwall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw

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

#9 lore raw

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

#10 lore raw

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

#11 lore raw

Re: [PATCH v1 3/3] xen-livepatch: If hypervisor is not compiled with Livepatching

In reply to Konrad Rzeszutek Wilk
Quoted 32 lines · Konrad Rzeszutek Wilk
Quoted 22 lines · Ross Lagerwall
Quoted 21 lines · 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 +3 -2
index 2de04c0..f11e71f07f 100644
@@ -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