References: bnc#777890

# HG changeset patch
# User Jan Beulich <jbeulich@suse.com>
# Date 1347365916 -7200
# Node ID 0520982a602a3ac06dd5bc573ddaff5edc9c6987
# Parent  109ea6a0c23aa0c5df79e3f5658162aed959ffcf
tmem: reduce severity of log messages

Otherwise they can be used by a guest to spam the hypervisor log with
all settings at their defaults.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>

--- a/xen/common/tmem.c
+++ b/xen/common/tmem.c
@@ -1110,7 +1110,7 @@ static int shared_pool_join(pool_t *pool
     sl->client = new_client;
     list_add_tail(&sl->share_list, &pool->share_list);
     if ( new_client->cli_id != pool->client->cli_id )
-        printk("adding new %s %d to shared pool owned by %s %d\n",
+        tmh_client_info("adding new %s %d to shared pool owned by %s %d\n",
             client_str, new_client->cli_id, client_str, pool->client->cli_id);
     return ++pool->shared_count;
 }
@@ -1140,7 +1140,7 @@ static NOINLINE void shared_pool_reassig
     old_client->eph_count -= _atomic_read(pool->pgp_count);
     list_splice_init(&old_client->ephemeral_page_list,
                      &new_client->ephemeral_page_list);
-    printk("reassigned shared pool from %s=%d to %s=%d pool_id=%d\n",
+    tmh_client_info("reassigned shared pool from %s=%d to %s=%d pool_id=%d\n",
         cli_id_str, old_client->cli_id, cli_id_str, new_client->cli_id, poolid);
     pool->pool_id = poolid;
 }
@@ -1176,7 +1176,7 @@ static NOINLINE int shared_pool_quit(poo
             }
         return 0;
     }
-    printk("tmem: no match unsharing pool, %s=%d\n",
+    tmh_client_warn("tmem: no match unsharing pool, %s=%d\n",
         cli_id_str,pool->client->cli_id);
     return -1;
 }
@@ -1187,17 +1187,18 @@ static void pool_flush(pool_t *pool, cli
     ASSERT(pool != NULL);
     if ( (is_shared(pool)) && (shared_pool_quit(pool,cli_id) > 0) )
     {
-        printk("tmem: %s=%d no longer using shared pool %d owned by %s=%d\n",
+        tmh_client_warn("tmem: %s=%d no longer using shared pool %d owned by %s=%d\n",
            cli_id_str, cli_id, pool->pool_id, cli_id_str,pool->client->cli_id);
         return;
     }
-    printk("%s %s-%s tmem pool ",destroy?"destroying":"flushing",
-        is_persistent(pool) ? "persistent" : "ephemeral" ,
-        is_shared(pool) ? "shared" : "private");
-    printk("%s=%d pool_id=%d\n", cli_id_str,pool->client->cli_id,pool->pool_id);
+    tmh_client_info("%s %s-%s tmem pool %s=%d pool_id=%d\n",
+                    destroy ? "destroying" : "flushing",
+                    is_persistent(pool) ? "persistent" : "ephemeral" ,
+                    is_shared(pool) ? "shared" : "private",
+                    cli_id_str, pool->client->cli_id, pool->pool_id);
     if ( pool->client->live_migrating )
     {
-        printk("can't %s pool while %s is live-migrating\n",
+        tmh_client_warn("can't %s pool while %s is live-migrating\n",
                destroy?"destroy":"flush", client_str);
         return;
     }
@@ -1216,21 +1217,22 @@ static client_t *client_create(cli_id_t 
     client_t *client = tmh_alloc_infra(sizeof(client_t),__alignof__(client_t));
     int i;
 
-    printk("tmem: initializing tmem capability for %s=%d...",cli_id_str,cli_id);
+    tmh_client_info("tmem: initializing tmem capability for %s=%d...",
+                    cli_id_str, cli_id);
     if ( client == NULL )
     {
-        printk("failed... out of memory\n");
+        tmh_client_err("failed... out of memory\n");
         goto fail;
     }
     memset(client,0,sizeof(client_t));
     if ( (client->tmh = tmh_client_init(cli_id)) == NULL )
     {
-        printk("failed... can't allocate host-dependent part of client\n");
+        tmh_client_err("failed... can't allocate host-dependent part of client\n");
         goto fail;
     }
     if ( !tmh_set_client_from_id(client, client->tmh, cli_id) )
     {
-        printk("failed... can't set client\n");
+        tmh_client_err("failed... can't set client\n");
         goto fail;
     }
     client->cli_id = cli_id;
@@ -1252,7 +1254,7 @@ static client_t *client_create(cli_id_t 
     client->eph_count = client->eph_count_max = 0;
     client->total_cycles = 0; client->succ_pers_puts = 0;
     client->succ_eph_gets = 0; client->succ_pers_gets = 0;
-    printk("ok\n");
+    tmh_client_info("ok\n");
     return client;
 
  fail:
@@ -1906,32 +1908,33 @@ static NOINLINE int do_tmem_new_pool(cli
         cli_id = tmh_get_cli_id_from_current();
     else
         cli_id = this_cli_id;
-    printk("tmem: allocating %s-%s tmem pool for %s=%d...",
+    tmh_client_info("tmem: allocating %s-%s tmem pool for %s=%d...",
         persistent ? "persistent" : "ephemeral" ,
         shared ? "shared" : "private", cli_id_str, cli_id);
     if ( specversion != TMEM_SPEC_VERSION )
     {
-        printk("failed... unsupported spec version\n");
+        tmh_client_err("failed... unsupported spec version\n");
         return -EPERM;
     }
     if ( pagebits != (PAGE_SHIFT - 12) )
     {
-        printk("failed... unsupported pagesize %d\n",1<<(pagebits+12));
+        tmh_client_err("failed... unsupported pagesize %d\n",
+                       1 << (pagebits + 12));
         return -EPERM;
     }
     if ( flags & TMEM_POOL_PRECOMPRESSED )
     {
-        printk("failed... precompression flag set but unsupported\n");
+        tmh_client_err("failed... precompression flag set but unsupported\n");
         return -EPERM;
     }
     if ( flags & TMEM_POOL_RESERVED_BITS )
     {
-        printk("failed... reserved bits must be zero\n");
+        tmh_client_err("failed... reserved bits must be zero\n");
         return -EPERM;
     }
     if ( (pool = pool_alloc()) == NULL )
     {
-        printk("failed... out of memory\n");
+        tmh_client_err("failed... out of memory\n");
         return -ENOMEM;
     }
     if ( this_cli_id != CLI_ID_NULL )
@@ -1950,7 +1953,7 @@ static NOINLINE int do_tmem_new_pool(cli
                 break;
         if ( d_poolid >= MAX_POOLS_PER_DOMAIN )
         {
-            printk("failed... no more pool slots available for this %s\n",
+            tmh_client_err("failed... no more pool slots available for this %s\n",
                    client_str);
             goto fail;
         }
@@ -1980,9 +1983,8 @@ static NOINLINE int do_tmem_new_pool(cli
             {
                 if ( shpool->uuid[0] == uuid_lo && shpool->uuid[1] == uuid_hi )
                 {
-                    printk("(matches shared pool uuid=%"PRIx64".%"PRIx64") ",
-                        uuid_hi, uuid_lo);
-                    printk("pool_id=%d\n",d_poolid);
+                    tmh_client_info("(matches shared pool uuid=%"PRIx64".%"PRIx64") pool_id=%d\n",
+                        uuid_hi, uuid_lo, d_poolid);
                     client->pools[d_poolid] = global_shared_pools[s_poolid];
                     shared_pool_join(global_shared_pools[s_poolid], client);
                     pool_free(pool);
@@ -1994,7 +1996,7 @@ static NOINLINE int do_tmem_new_pool(cli
         }
         if ( first_unused_s_poolid == MAX_GLOBAL_SHARED_POOLS )
         {
-            printk("tmem: failed... no global shared pool slots available\n");
+            tmh_client_warn("tmem: failed... no global shared pool slots available\n");
             goto fail;
         }
         else
@@ -2010,7 +2012,7 @@ static NOINLINE int do_tmem_new_pool(cli
     pool->pool_id = d_poolid;
     pool->persistent = persistent;
     pool->uuid[0] = uuid_lo; pool->uuid[1] = uuid_hi;
-    printk("pool_id=%d\n",d_poolid);
+    tmh_client_info("pool_id=%d\n", d_poolid);
     return d_poolid;
 
 fail:
@@ -2033,14 +2035,15 @@ static int tmemc_freeze_pools(cli_id_t c
     {
         list_for_each_entry(client,&global_client_list,client_list)
             client_freeze(client,freeze);
-        printk("tmem: all pools %s for all %ss\n",s,client_str);
+        tmh_client_info("tmem: all pools %s for all %ss\n", s, client_str);
     }
     else
     {
         if ( (client = tmh_client_from_cli_id(cli_id)) == NULL)
             return -1;
         client_freeze(client,freeze);
-        printk("tmem: all pools %s for %s=%d\n",s,cli_id_str,cli_id);
+        tmh_client_info("tmem: all pools %s for %s=%d\n",
+                         s, cli_id_str, cli_id);
     }
     return 0;
 }
@@ -2051,7 +2054,7 @@ static int tmemc_flush_mem(cli_id_t cli_
 
     if ( cli_id != CLI_ID_NULL )
     {
-        printk("tmem: %s-specific flush not supported yet, use --all\n",
+        tmh_client_warn("tmem: %s-specific flush not supported yet, use --all\n",
            client_str);
         return -1;
     }
@@ -2264,13 +2267,15 @@ static int tmemc_set_var_one(client_t *c
     case TMEMC_SET_WEIGHT:
         old_weight = client->weight;
         client->weight = arg1;
-        printk("tmem: weight set to %d for %s=%d\n",arg1,cli_id_str,cli_id);
+        tmh_client_info("tmem: weight set to %d for %s=%d\n",
+                        arg1, cli_id_str, cli_id);
         atomic_sub(old_weight,&client_weight_total);
         atomic_add(client->weight,&client_weight_total);
         break;
     case TMEMC_SET_CAP:
         client->cap = arg1;
-        printk("tmem: cap set to %d for %s=%d\n",arg1,cli_id_str,cli_id);
+        tmh_client_info("tmem: cap set to %d for %s=%d\n",
+                        arg1, cli_id_str, cli_id);
         break;
     case TMEMC_SET_COMPRESS:
 #ifdef __i386__
@@ -2278,17 +2283,17 @@ static int tmemc_set_var_one(client_t *c
 #endif
         if ( tmh_dedup_enabled() )
         {
-            printk("tmem: compression %s for all %ss, cannot be changed "
-                   "when tmem_dedup is enabled\n",
-            tmh_compression_enabled() ? "enabled" : "disabled",client_str);
+            tmh_client_warn("tmem: compression %s for all %ss, cannot be changed when tmem_dedup is enabled\n",
+                            tmh_compression_enabled() ? "enabled" : "disabled",
+                            client_str);
             return -1;
         }
         client->compress = arg1 ? 1 : 0;
-        printk("tmem: compression %s for %s=%d\n",
+        tmh_client_info("tmem: compression %s for %s=%d\n",
             arg1 ? "enabled" : "disabled",cli_id_str,cli_id);
         break;
     default:
-        printk("tmem: unknown subop %d for tmemc_set_var\n",subop);
+        tmh_client_warn("tmem: unknown subop %d for tmemc_set_var\n", subop);
         return -1;
     }
     return 0;
@@ -2671,7 +2676,7 @@ EXPORT long do_tmem_op(tmem_cli_op_t uop
 
     if ( unlikely(tmh_get_tmemop_from_client(&op, uops) != 0) )
     {
-        printk("tmem: can't get tmem struct from %s\n",client_str);
+        tmh_client_err("tmem: can't get tmem struct from %s\n", client_str);
         rc = -EFAULT;
         if ( !tmh_lock_all )
             goto simple_error;
@@ -2705,7 +2710,8 @@ EXPORT long do_tmem_op(tmem_cli_op_t uop
         tmem_write_lock_set = 1;
         if ( (client = client_create(tmh_get_cli_id_from_current())) == NULL )
         {
-            printk("tmem: can't create tmem structure for %s\n",client_str);
+            tmh_client_err("tmem: can't create tmem structure for %s\n",
+                           client_str);
             rc = -ENOMEM;
             goto out;
         }
@@ -2729,8 +2735,8 @@ EXPORT long do_tmem_op(tmem_cli_op_t uop
         if ( ((uint32_t)op.pool_id >= MAX_POOLS_PER_DOMAIN) ||
              ((pool = client->pools[op.pool_id]) == NULL) )
         {
+            tmh_client_err("tmem: operation requested on uncreated pool\n");
             rc = -ENODEV;
-            printk("tmem: operation requested on uncreated pool\n");
             goto out;
         }
         ASSERT_SENTINEL(pool,POOL);
@@ -2786,11 +2792,11 @@ EXPORT long do_tmem_op(tmem_cli_op_t uop
         break;
     case TMEM_XCHG:
         /* need to hold global lock to ensure xchg is atomic */
-        printk("tmem_xchg op not implemented yet\n");
+        tmh_client_warn("tmem_xchg op not implemented yet\n");
         rc = 0;
         break;
     default:
-        printk("tmem: op %d not implemented\n", op.cmd);
+        tmh_client_warn("tmem: op %d not implemented\n", op.cmd);
         rc = 0;
         break;
     }
--- a/xen/include/xen/tmem_xen.h
+++ b/xen/include/xen/tmem_xen.h
@@ -512,6 +512,9 @@ int tmh_copy_to_client(tmem_cli_mfn_t, p
 
 extern int tmh_copy_tze_to_client(tmem_cli_mfn_t cmfn, void *tmem_va, pagesize_t len);
 
+#define tmh_client_err(fmt, args...)  printk(XENLOG_G_ERR fmt, ##args)
+#define tmh_client_warn(fmt, args...) printk(XENLOG_G_WARNING fmt, ##args)
+#define tmh_client_info(fmt, args...) printk(XENLOG_G_INFO fmt, ##args)
 
 #define TMEM_PERF
 #ifdef TMEM_PERF
