All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Liu Jinsong <jinsong.liu@alibaba-inc.com>,
	Christoph Egger <chegger@amazon.de>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	David Vrabel <david.vrabel@citrix.com>
Subject: [PATCH 1/5] tools/mce: remove extra newlines from xen-mceinj error message
Date: Mon, 23 Jun 2014 18:56:57 +0100	[thread overview]
Message-ID: <1403546221-4149-2-git-send-email-david.vrabel@citrix.com> (raw)
In-Reply-To: <1403546221-4149-1-git-send-email-david.vrabel@citrix.com>

err() calls perror() which appends a newline.

Make Lprintf() also append a newline so err() and Lprintf() are
consistent.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Christoph Egger <chegger@amazon.de>
---
 tools/tests/mce-test/tools/xen-mceinj.c |   85 +++++++++++++++----------------
 1 file changed, 42 insertions(+), 43 deletions(-)

diff --git a/tools/tests/mce-test/tools/xen-mceinj.c b/tools/tests/mce-test/tools/xen-mceinj.c
index 21a488b..7030bb2 100644
--- a/tools/tests/mce-test/tools/xen-mceinj.c
+++ b/tools/tests/mce-test/tools/xen-mceinj.c
@@ -94,7 +94,7 @@ static void Lprintf(const char *fmt, ...)
     va_start(args, fmt);
     if (vasprintf(&buf, fmt, args) < 0)
         abort();
-    fprintf(LOGFILE, "%s", buf);
+    fprintf(LOGFILE, "%s\n", buf);
     va_end(args);
     free(buf);
 }
@@ -156,7 +156,7 @@ static int inject_cmci(xc_interface *xc_handle, int cpu_nr)
 
     nr_cpus = mca_cpuinfo(xc_handle);
     if (!nr_cpus)
-        err(xc_handle, "Failed to get mca_cpuinfo\n");
+        err(xc_handle, "Failed to get mca_cpuinfo");
 
     mc.cmd = XEN_MC_inject_v2;
     mc.interface_version = XEN_MCA_INTERFACE_VERSION;
@@ -273,32 +273,32 @@ static uint64_t guest_mfn(xc_interface *xc_handle,
     max_gpfn = do_memory_op(xc_handle, XENMEM_maximum_gpfn, &domain, 
                                sizeof(domain)) + 1;
     if ( max_gpfn <= 0 )
-        err(xc_handle, "Failed to get max_gpfn 0x%lx\n", max_gpfn);
+        err(xc_handle, "Failed to get max_gpfn 0x%lx", max_gpfn);
 
-    Lprintf("Maxium gpfn for dom %d is 0x%lx\n", domain, max_gpfn);
+    Lprintf("Maxium gpfn for dom %d is 0x%lx", domain, max_gpfn);
 
     /* Get max mfn */
     if ( !get_platform_info(xc_handle, domain,
                             &max_mfn, &hvirt_start,
                             &pt_levels, &guest_width) )
-        err(xc_handle, "Failed to get platform information\n");
+        err(xc_handle, "Failed to get platform information");
 
     /* Get guest's pfn list */
     pfn_buf = malloc(sizeof(uint64_t) * max_gpfn);
     if ( !pfn_buf )
-        err(xc_handle, "Failed to alloc pfn buf\n");
+        err(xc_handle, "Failed to alloc pfn buf");
     memset(pfn_buf, 0, sizeof(uint64_t) * max_gpfn);
 
     ret = xc_get_pfn_list(xc_handle, domain, pfn_buf, max_gpfn);
     if ( ret < 0 ) {
         free(pfn_buf);
-        err(xc_handle, "Failed to get pfn list %x\n", ret);
+        err(xc_handle, "Failed to get pfn list %x", ret);
     }
 
     /* Now get the m2p table */
     live_m2p = xc_map_m2p(xc_handle, max_mfn, PROT_READ, &m2p_mfn0);
     if ( !live_m2p )
-        err(xc_handle, "Failed to map live M2P table\n");
+        err(xc_handle, "Failed to map live M2P table");
 
     /* match the mapping */
     for ( i = 0; i < max_gpfn; i++ )
@@ -309,7 +309,7 @@ static uint64_t guest_mfn(xc_interface *xc_handle,
         if (mfn_valid(tmp) &&  (mfn_to_pfn(tmp) == gpfn))
         {
             mfn = tmp;
-            Lprintf("We get the mfn 0x%lx for this injection\n", mfn);
+            Lprintf("We get the mfn 0x%lx for this injection", mfn);
             break;
         }
     }
@@ -334,7 +334,7 @@ static uint64_t mca_gpfn_to_mfn(xc_interface *xc_handle,
     max_gpfn = do_memory_op(xc_handle, XENMEM_maximum_gpfn, &domain, 
                                sizeof(domain)) + 1;
     if ( max_gpfn <= 0 )
-        err(xc_handle, "Failed to get max_gpfn 0x%lx\n", max_gpfn);
+        err(xc_handle, "Failed to get max_gpfn 0x%lx", max_gpfn);
     index = gfn % max_gpfn;
 
     return guest_mfn(xc_handle, domain, index);
@@ -385,33 +385,33 @@ static int inject_llc_srao(xc_interface *xc_handle,
 
     ret = inject_mcg_status(xc_handle, cpu_nr, MCG_STATUS_SRAO_LLC_VAL);
     if ( ret )
-        err(xc_handle, "Failed to inject MCG_STATUS MSR\n");
+        err(xc_handle, "Failed to inject MCG_STATUS MSR");
 
     ret = inject_mci_status(xc_handle, cpu_nr,
                             MCE_SRAO_LLC_BANK, MCi_STATUS_SRAO_LLC_VAL);
     if ( ret )
-        err(xc_handle, "Failed to inject MCi_STATUS MSR\n");
+        err(xc_handle, "Failed to inject MCi_STATUS MSR");
 
     ret = inject_mci_misc(xc_handle, cpu_nr,
                           MCE_SRAO_LLC_BANK, MCi_MISC_SRAO_LLC_VAL);
     if ( ret )
-        err(xc_handle, "Failed to inject MCi_MISC MSR\n");
+        err(xc_handle, "Failed to inject MCi_MISC MSR");
 
     gpfn = gaddr >> PAGE_SHIFT;
     mfn = mca_gpfn_to_mfn(xc_handle, domain, gpfn);
     if (!mfn_valid(mfn))
-        err(xc_handle, "The MFN is not valid\n");
+        err(xc_handle, "The MFN is not valid");
     haddr = (mfn << PAGE_SHIFT) | (gaddr & (PAGE_SIZE - 1));
     ret = inject_mci_addr(xc_handle, cpu_nr, MCE_SRAO_LLC_BANK, haddr);
     if ( ret )
-        err(xc_handle, "Failed to inject MCi_ADDR MSR\n");
+        err(xc_handle, "Failed to inject MCi_ADDR MSR");
 
     ret = flush_msr_inj(xc_handle);
     if ( ret )
-        err(xc_handle, "Failed to inject MSR\n");
+        err(xc_handle, "Failed to inject MSR");
     ret = inject_mce(xc_handle, cpu_nr);
     if ( ret )
-        err(xc_handle, "Failed to inject MCE error\n");
+        err(xc_handle, "Failed to inject MCE error");
 
     return 0;
 }
@@ -426,33 +426,33 @@ static int inject_mem_srao(xc_interface *xc_handle,
 
     ret = inject_mcg_status(xc_handle, cpu_nr, MCG_STATUS_SRAO_MEM_VAL);
     if ( ret )
-        err(xc_handle, "Failed to inject MCG_STATUS MSR\n");
+        err(xc_handle, "Failed to inject MCG_STATUS MSR");
 
     ret = inject_mci_status(xc_handle, cpu_nr,
                             MCE_SRAO_MEM_BANK, MCi_STATUS_SRAO_MEM_VAL);
     if ( ret )
-        err(xc_handle, "Failed to inject MCi_STATUS MSR\n");
+        err(xc_handle, "Failed to inject MCi_STATUS MSR");
 
     ret = inject_mci_misc(xc_handle, cpu_nr,
                           MCE_SRAO_MEM_BANK, MCi_MISC_SRAO_MEM_VAL);
     if ( ret )
-        err(xc_handle, "Failed to inject MCi_MISC MSR\n");
+        err(xc_handle, "Failed to inject MCi_MISC MSR");
 
     gpfn = gaddr >> PAGE_SHIFT;
     mfn = mca_gpfn_to_mfn(xc_handle, domain, gpfn);
     if (!mfn_valid(mfn))
-        err(xc_handle, "The MFN is not valid\n");
+        err(xc_handle, "The MFN is not valid");
     haddr = (mfn << PAGE_SHIFT) | (gaddr & (PAGE_SIZE - 1));
     ret = inject_mci_addr(xc_handle, cpu_nr, MCE_SRAO_MEM_BANK, haddr);
     if ( ret )
-        err(xc_handle, "Failed to inject MCi_ADDR MSR\n");
+        err(xc_handle, "Failed to inject MCi_ADDR MSR");
 
     ret = flush_msr_inj(xc_handle);
     if ( ret )
-        err(xc_handle, "Failed to inject MSR\n");
+        err(xc_handle, "Failed to inject MSR");
     ret = inject_mce(xc_handle, cpu_nr);
     if ( ret )
-        err(xc_handle, "Failed to inject MCE error\n");
+        err(xc_handle, "Failed to inject MCE error");
 
     return 0;
 }
@@ -467,33 +467,33 @@ static int inject_llc_ucna(xc_interface *xc_handle,
 
     ret = inject_mcg_status(xc_handle, cpu_nr, MCG_STATUS_UCNA_LLC_VAL);
     if ( ret )
-        err(xc_handle, "Failed to inject MCG_STATUS MSR\n");
+        err(xc_handle, "Failed to inject MCG_STATUS MSR");
 
     ret = inject_mci_status(xc_handle, cpu_nr,
                             CMCI_UCNA_LLC_BANK, MCi_STATUS_UCNA_LLC_VAL);
     if ( ret )
-        err(xc_handle, "Failed to inject MCi_STATUS MSR\n");
+        err(xc_handle, "Failed to inject MCi_STATUS MSR");
 
     ret = inject_mci_misc(xc_handle, cpu_nr,
                           CMCI_UCNA_LLC_BANK, MCi_MISC_UCNA_LLC_VAL);
     if ( ret )
-        err(xc_handle, "Failed to inject MCi_MISC MSR\n");
+        err(xc_handle, "Failed to inject MCi_MISC MSR");
 
     gpfn = gaddr >> PAGE_SHIFT;
     mfn = mca_gpfn_to_mfn(xc_handle, domain, gpfn);
     if (!mfn_valid(mfn))
-        err(xc_handle, "The MFN is not valid\n");
+        err(xc_handle, "The MFN is not valid");
     haddr = (mfn << PAGE_SHIFT) | (gaddr & (PAGE_SIZE - 1));
     ret = inject_mci_addr(xc_handle, cpu_nr, CMCI_UCNA_LLC_BANK, haddr);
     if ( ret )
-        err(xc_handle, "Failed to inject MCi_ADDR MSR\n");
+        err(xc_handle, "Failed to inject MCi_ADDR MSR");
 
     ret = flush_msr_inj(xc_handle);
     if ( ret )
-        err(xc_handle, "Failed to inject MSR\n");
+        err(xc_handle, "Failed to inject MSR");
     ret = inject_cmci(xc_handle, cpu_nr);
     if ( ret )
-        err(xc_handle, "Failed to inject MCE error\n");
+        err(xc_handle, "Failed to inject MCE error");
 
     return 0;
 }
@@ -569,7 +569,7 @@ int main(int argc, char *argv[])
     init_msr_inj();
     xc_handle = xc_interface_open(0, 0, 0);
     if ( !xc_handle ) {
-        Lprintf("Failed to get xc interface\n");
+        Lprintf("Failed to get xc interface");
         exit(EXIT_FAILURE);
     }
 
@@ -584,17 +584,17 @@ int main(int argc, char *argv[])
         case 'c':
             cpu_nr = strtol(optarg, &optarg, 10);
             if ( strlen(optarg) != 0 )
-                err(xc_handle, "Please input a digit parameter for CPU\n");
+                err(xc_handle, "Please input a digit parameter for CPU");
             break;
         case 'd':
             domid = strtol(optarg, &optarg, 10);
             if ( strlen(optarg) != 0 )
-                err(xc_handle, "Please input a digit parameter for domain\n");
+                err(xc_handle, "Please input a digit parameter for domain");
             break;
         case 'p':
             gaddr = strtol(optarg, &optarg, 0);
             if ( strlen(optarg) != 0 )
-                err(xc_handle, "Please input correct page address\n");
+                err(xc_handle, "Please input correct page address");
             break;
         case 't':
             type = strtol(optarg, NULL, 0);
@@ -608,23 +608,22 @@ int main(int argc, char *argv[])
     
     if ( domid != DOMID_XEN ) {
         max_gpa = xs_get_dom_mem(domid);
-        Lprintf("get domain %d max gpa is: 0x%lx \n", domid, max_gpa);
+        Lprintf("get domain %d max gpa is: 0x%lx", domid, max_gpa);
         if ( gaddr >= max_gpa )
-            err(xc_handle, "Fail: gaddr exceeds max_gpa 0x%lx\n", max_gpa);
+            err(xc_handle, "Fail: gaddr exceeds max_gpa 0x%lx", max_gpa);
     }
-    Lprintf("get gaddr of error inject is: 0x%lx \n", gaddr);
+    Lprintf("get gaddr of error inject is: 0x%lx", gaddr);
 
     if ( dump ) {
         gpfn = gaddr >> PAGE_SHIFT;
         mfn = mca_gpfn_to_mfn(xc_handle, domid, gpfn);
         if (!mfn_valid(mfn))
-            err(xc_handle, "The MFN is not valid\n");
+            err(xc_handle, "The MFN is not valid");
         haddr = (mfn << PAGE_SHIFT) | (gaddr & (PAGE_SIZE - 1));
         if ( domid == DOMID_XEN )
-            Lprintf("Xen: mfn=0x%lx, haddr=0x%lx\n", mfn, haddr);
+            Lprintf("Xen: mfn=0x%lx, haddr=0x%lx", mfn, haddr);
         else 
-            Lprintf("Dom%d: gaddr=0x%lx, gpfn=0x%lx,"
-                    "mfn=0x%lx, haddr=0x%lx\n",
+            Lprintf("Dom%d: gaddr=0x%lx, gpfn=0x%lx, mfn=0x%lx, haddr=0x%lx",
                     domid, gaddr, gpfn, mfn, haddr);
         goto out;
     }
@@ -641,7 +640,7 @@ int main(int argc, char *argv[])
         inject_llc_ucna(xc_handle, cpu_nr, domid, gaddr);
         break;
     default:
-        err(xc_handle, "Unsupported error type\n");
+        err(xc_handle, "Unsupported error type");
         break;
     }
 
-- 
1.7.10.4

  reply	other threads:[~2014-06-23 17:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23 17:56 [PATCHv2 0/5] tools/mce: xen-mceinj improvements David Vrabel
2014-06-23 17:56 ` David Vrabel [this message]
2014-06-23 17:56 ` [PATCH 2/5] tools/mce: clarify xen-mceinj usage David Vrabel
2014-06-23 17:56 ` [PATCH 3/5] tools/mce: use calloc() instead of malloc()/memset() in xen-mceinj David Vrabel
2014-06-24  8:14   ` Egger, Christoph
2014-06-23 17:57 ` [PATCH 4/5] tools/mce: refactor xen-mceinj to ease injection of other MCEs David Vrabel
2014-06-23 17:57 ` [PATCH 5/5] tools/mce: add more MCE types to xen-mceinj David Vrabel
2014-06-27 13:39 ` [PATCHv2 0/5] tools/mce: xen-mceinj improvements Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403546221-4149-2-git-send-email-david.vrabel@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=chegger@amazon.de \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jinsong.liu@alibaba-inc.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.