Skip to contentSkip to conversation

numa: Add missing \n to error message

PATCH Applied Greg Kurz 4 participants 9 messages Nov 6, 2019 – Nov 12, 2019

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH 1/1 numa: Add missing \n to error message

If memory allocation fails when using -mem-path, QEMU is supposed to print out a message to indicate that fallback to anonymous RAM is deprecated. This is done with error_printf() which does output buffering. As a consequence, the message is only printed at the next flush, eg. when quiting QEMU, and it also lacks a trailing newline:

qemu-system-ppc64: unable to map backing store for guest RAM: Cannot allocate memory
qemu-system-ppc64: warning: falling back to regular RAM allocation
QEMU 4.1.50 monitor - type 'help' for more information
(qemu) q
This is deprecated. Make sure that -mem-path specified path has sufficient resources to allocate -m specified RAM amountgreg@boss02:~/Work/qemu/qemu-spapr$

Add the missing \n to fix both issues.

Fixes cb79224b7e4b "deprecate -mem-path fallback to anonymous RAM"
---
 hw/core/numa.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/numa.c +1 -1
index 038c96d4abc6..e3332a984f7c 100644
@@ -503,7 +503,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             warn_report("falling back to regular RAM allocation");
             error_printf("This is deprecated. Make sure that -mem-path "
                          " specified path has sufficient resources to allocate"
-                         " -m specified RAM amount");
+                         " -m specified RAM amount\n");
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */
author
#1 lore raw

Oops I hadn't realized that Marcel had a new e-mail address... since last year :-\ Sorry for the noise.

Quoted 35 lines · On Wed, 06 Nov 2019 13:46:40 +0100 Greg Kurz <[email protected]> wrote:

If memory allocation fails when using -mem-path, QEMU is supposed to print out a message to indicate that fallback to anonymous RAM is deprecated. This is done with error_printf() which does output buffering. As a consequence, the message is only printed at the next flush, eg. when quiting QEMU, and it also lacks a trailing newline:

qemu-system-ppc64: unable to map backing store for guest RAM: Cannot allocate memory
qemu-system-ppc64: warning: falling back to regular RAM allocation
QEMU 4.1.50 monitor - type 'help' for more information
(qemu) q
This is deprecated. Make sure that -mem-path specified path has sufficient resources to allocate -m specified RAM amountgreg@boss02:~/Work/qemu/qemu-spapr$

Add the missing \n to fix both issues.

Fixes cb79224b7e4b "deprecate -mem-path fallback to anonymous RAM"
---
 hw/core/numa.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/numa.c +1 -1
index 038c96d4abc6..e3332a984f7c 100644
@@ -503,7 +503,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             warn_report("falling back to regular RAM allocation");
             error_printf("This is deprecated. Make sure that -mem-path "
                          " specified path has sufficient resources to allocate"
-                         " -m specified RAM amount");
+                         " -m specified RAM amount\n");
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */
#2 lore raw
In reply to Greg Kurz

Le 06/11/2019 à 13:46, Greg Kurz a écrit :

Quoted 27 lines

If memory allocation fails when using -mem-path, QEMU is supposed to print out a message to indicate that fallback to anonymous RAM is deprecated. This is done with error_printf() which does output buffering. As a consequence, the message is only printed at the next flush, eg. when quiting QEMU, and it also lacks a trailing newline:

qemu-system-ppc64: unable to map backing store for guest RAM: Cannot allocate memory
qemu-system-ppc64: warning: falling back to regular RAM allocation
QEMU 4.1.50 monitor - type 'help' for more information
(qemu) q
This is deprecated. Make sure that -mem-path specified path has sufficient resources to allocate -m specified RAM amountgreg@boss02:~/Work/qemu/qemu-spapr$

Add the missing \n to fix both issues.

Fixes cb79224b7e4b "deprecate -mem-path fallback to anonymous RAM"
---
 hw/core/numa.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/numa.c +0 -0
index 038c96d4abc6..e3332a984f7c 100644

hw/core/numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 509

Quoted 8 lines
hw/core/numa.c +1 -1
@@ -503,7 +503,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             warn_report("falling back to regular RAM allocation");
             error_printf("This is deprecated. Make sure that -mem-path "
                          " specified path has sufficient resources to allocate"
-                         " -m specified RAM amount");
+                         " -m specified RAM amount\n");
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */

Why is this an error_printf() and not an error_report()?

Thanks,
Laurent

author
#3 lore raw
Quoted 30 lines · On Wed, 6 Nov 2019 14:01:01 +0100 Laurent Vivier <[email protected]> wrote:

Le 06/11/2019 à 13:46, Greg Kurz a écrit :

Quoted 29 lines

If memory allocation fails when using -mem-path, QEMU is supposed to print out a message to indicate that fallback to anonymous RAM is deprecated. This is done with error_printf() which does output buffering. As a consequence, the message is only printed at the next flush, eg. when quiting QEMU, and it also lacks a trailing newline:

qemu-system-ppc64: unable to map backing store for guest RAM: Cannot allocate memory
qemu-system-ppc64: warning: falling back to regular RAM allocation
QEMU 4.1.50 monitor - type 'help' for more information
(qemu) q
This is deprecated. Make sure that -mem-path specified path has sufficient resources to allocate -m specified RAM amountgreg@boss02:~/Work/qemu/qemu-spapr$

Add the missing \n to fix both issues.

Fixes cb79224b7e4b "deprecate -mem-path fallback to anonymous RAM"
---
 hw/core/numa.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/numa.c +0 -1
index 038c96d4abc6..e3332a984f7c 100644
@@ -503,7 +503,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             warn_report("falling back to regular RAM allocation");
             error_printf("This is deprecated. Make sure that -mem-path "
                          " specified path has sufficient resources to allocate"
-                         " -m specified RAM amount");
Quoted 9 lines

hw/core/numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 509

Quoted 6 lines
hw/core/numa.c +1 -0
+                         " -m specified RAM amount\n");
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */

Why is this an error_printf() and not an error_report()?

Because CODING_STYLE suggests to do so I guess:

Reporting errors to the human user
----------------------------------

Do not use printf(), fprintf() or monitor_printf(). Instead, use error_report() or error_vreport() from error-report.h. This ensures the error is reported in the right place (current monitor or stderr), and in a uniform format.

Use error_printf() & friends to print additional information. <===

error_report() prints the current location. In certain common cases like command line parsing, the current location is tracked automatically. To manipulate it manually, use the loc_``*``() from error-report.h.

Quoted 3 lines

Thanks,
Laurent

Reviewed-by
#4 lore raw

Le 06/11/2019 à 15:12, Greg Kurz a écrit :

Quoted 53 lines
Quoted 30 lines · On Wed, 6 Nov 2019 14:01:01 +0100 Laurent Vivier <[email protected]> wrote:

Le 06/11/2019 à 13:46, Greg Kurz a écrit :

Quoted 29 lines

If memory allocation fails when using -mem-path, QEMU is supposed to print out a message to indicate that fallback to anonymous RAM is deprecated. This is done with error_printf() which does output buffering. As a consequence, the message is only printed at the next flush, eg. when quiting QEMU, and it also lacks a trailing newline:

qemu-system-ppc64: unable to map backing store for guest RAM: Cannot allocate memory
qemu-system-ppc64: warning: falling back to regular RAM allocation
QEMU 4.1.50 monitor - type 'help' for more information
(qemu) q
This is deprecated. Make sure that -mem-path specified path has sufficient resources to allocate -m specified RAM amountgreg@boss02:~/Work/qemu/qemu-spapr$

Add the missing \n to fix both issues.

Fixes cb79224b7e4b "deprecate -mem-path fallback to anonymous RAM"
---
 hw/core/numa.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/numa.c +0 -1
index 038c96d4abc6..e3332a984f7c 100644
@@ -503,7 +503,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             warn_report("falling back to regular RAM allocation");
             error_printf("This is deprecated. Make sure that -mem-path "
                          " specified path has sufficient resources to allocate"
-                         " -m specified RAM amount");
Quoted 9 lines

hw/core/numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 509

Quoted 6 lines
hw/core/numa.c +1 -0
+                         " -m specified RAM amount\n");
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */

Why is this an error_printf() and not an error_report()?

Because CODING_STYLE suggests to do so I guess:

Reporting errors to the human user
----------------------------------

Do not use printf(), fprintf() or monitor_printf(). Instead, use error_report() or error_vreport() from error-report.h. This ensures the error is reported in the right place (current monitor or stderr), and in a uniform format.

Quoted 6 lines

Use error_printf() & friends to print additional information. <===

error_report() prints the current location. In certain common cases like command line parsing, the current location is tracked automatically. To manipulate it manually, use the loc_``*``() from error-report.h.

So I guess it's to not report the current location and the binary name .

#5 lore raw
Quoted 56 lines · Laurent Vivier

Le 06/11/2019 à 15:12, Greg Kurz a écrit :

Quoted 55 lines
Quoted 30 lines · On Wed, 6 Nov 2019 14:01:01 +0100 Laurent Vivier <[email protected]> wrote:

Le 06/11/2019 à 13:46, Greg Kurz a écrit :

Quoted 29 lines

If memory allocation fails when using -mem-path, QEMU is supposed to print out a message to indicate that fallback to anonymous RAM is deprecated. This is done with error_printf() which does output buffering. As a consequence, the message is only printed at the next flush, eg. when quiting QEMU, and it also lacks a trailing newline:

qemu-system-ppc64: unable to map backing store for guest RAM: Cannot allocate memory
qemu-system-ppc64: warning: falling back to regular RAM allocation
QEMU 4.1.50 monitor - type 'help' for more information
(qemu) q
This is deprecated. Make sure that -mem-path specified path has sufficient resources to allocate -m specified RAM amountgreg@boss02:~/Work/qemu/qemu-spapr$

Add the missing \n to fix both issues.

Fixes cb79224b7e4b "deprecate -mem-path fallback to anonymous RAM"
---
  hw/core/numa.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/numa.c +0 -1
index 038c96d4abc6..e3332a984f7c 100644
@@ -503,7 +503,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
              warn_report("falling back to regular RAM allocation");
              error_printf("This is deprecated. Make sure that -mem-path "
                           " specified path has sufficient resources to allocate"
-                         " -m specified RAM amount");
Quoted 9 lines

hw/core/numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 509

Quoted 6 lines
hw/core/numa.c +1 -0
+                         " -m specified RAM amount\n");
              /* Legacy behavior: if allocation failed, fall back to
               * regular RAM allocation.
               */

Why is this an error_printf() and not an error_report()?

Because CODING_STYLE suggests to do so I guess:

Reporting errors to the human user
----------------------------------

Do not use printf(), fprintf() or monitor_printf(). Instead, use error_report() or error_vreport() from error-report.h. This ensures the error is reported in the right place (current monitor or stderr), and in a uniform format.

Use error_printf() & friends to print additional information. <===

Quoted 8 lines
Quoted 4 lines

error_report() prints the current location. In certain common cases like command line parsing, the current location is tracked automatically. To manipulate it manually, use the loc_``*``() from error-report.h.

So I guess it's to not report the current location and the binary name .

#6 lore raw
In reply to Greg Kurz
Quoted 48 lines · Greg Kurz
Quoted 30 lines · On Wed, 6 Nov 2019 14:01:01 +0100 Laurent Vivier <[email protected]> wrote:

Le 06/11/2019 à 13:46, Greg Kurz a écrit :

Quoted 29 lines

If memory allocation fails when using -mem-path, QEMU is supposed to print out a message to indicate that fallback to anonymous RAM is deprecated. This is done with error_printf() which does output buffering. As a consequence, the message is only printed at the next flush, eg. when quiting QEMU, and it also lacks a trailing newline:

qemu-system-ppc64: unable to map backing store for guest RAM: Cannot allocate memory
qemu-system-ppc64: warning: falling back to regular RAM allocation
QEMU 4.1.50 monitor - type 'help' for more information
(qemu) q
This is deprecated. Make sure that -mem-path specified path has sufficient resources to allocate -m specified RAM amountgreg@boss02:~/Work/qemu/qemu-spapr$

Add the missing \n to fix both issues.

Fixes cb79224b7e4b "deprecate -mem-path fallback to anonymous RAM"
---
 hw/core/numa.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/numa.c +0 -1
index 038c96d4abc6..e3332a984f7c 100644
@@ -503,7 +503,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             warn_report("falling back to regular RAM allocation");
             error_printf("This is deprecated. Make sure that -mem-path "
                          " specified path has sufficient resources to allocate"
-                         " -m specified RAM amount");
Quoted 9 lines

hw/core/numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 509

Quoted 6 lines
hw/core/numa.c +1 -0
+                         " -m specified RAM amount\n");
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */

Why is this an error_printf() and not an error_report()?

Because CODING_STYLE suggests to do so I guess:

Reporting errors to the human user
----------------------------------

Quoted 6 lines

Do not use printf(), fprintf() or monitor_printf(). Instead, use error_report() or error_vreport() from error-report.h. This ensures the error is reported in the right place (current monitor or stderr), and in a uniform format.

Use error_printf() & friends to print additional information. <===

You're right.

Since I have nothing queued up right now, I'd prefer to have this go via qemu-trivial.

Quoted 4 lines

error_report() prints the current location. In certain common cases like command line parsing, the current location is tracked automatically. To manipulate it manually, use the loc_``*``() from error-report.h.

#7 lore raw

Le 06/11/2019 à 17:55, Markus Armbruster a écrit :

Quoted 55 lines
Quoted 53 lines · Greg Kurz
Quoted 30 lines · On Wed, 6 Nov 2019 14:01:01 +0100 Laurent Vivier <[email protected]> wrote:

Le 06/11/2019 à 13:46, Greg Kurz a écrit :

Quoted 29 lines

If memory allocation fails when using -mem-path, QEMU is supposed to print out a message to indicate that fallback to anonymous RAM is deprecated. This is done with error_printf() which does output buffering. As a consequence, the message is only printed at the next flush, eg. when quiting QEMU, and it also lacks a trailing newline:

qemu-system-ppc64: unable to map backing store for guest RAM: Cannot allocate memory
qemu-system-ppc64: warning: falling back to regular RAM allocation
QEMU 4.1.50 monitor - type 'help' for more information
(qemu) q
This is deprecated. Make sure that -mem-path specified path has sufficient resources to allocate -m specified RAM amountgreg@boss02:~/Work/qemu/qemu-spapr$

Add the missing \n to fix both issues.

Fixes cb79224b7e4b "deprecate -mem-path fallback to anonymous RAM"
---
 hw/core/numa.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/numa.c +0 -1
index 038c96d4abc6..e3332a984f7c 100644
@@ -503,7 +503,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             warn_report("falling back to regular RAM allocation");
             error_printf("This is deprecated. Make sure that -mem-path "
                          " specified path has sufficient resources to allocate"
-                         " -m specified RAM amount");
Quoted 9 lines

hw/core/numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 509

Quoted 6 lines
hw/core/numa.c +1 -0
+                         " -m specified RAM amount\n");
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */

Why is this an error_printf() and not an error_report()?

Because CODING_STYLE suggests to do so I guess:

Reporting errors to the human user
----------------------------------

Do not use printf(), fprintf() or monitor_printf(). Instead, use error_report() or error_vreport() from error-report.h. This ensures the error is reported in the right place (current monitor or stderr), and in a uniform format.

Quoted 6 lines
Quoted 1 line

Use error_printf() & friends to print additional information. <===

You're right.

Since I have nothing queued up right now, I'd prefer to have this go via qemu-trivial.

Ok, I will take it in my next qemu-trivial pull request (with the other Greg's patch).

Thanks,
Laurent

#8 lore raw
In reply to Greg Kurz

Le 06/11/2019 à 13:46, Greg Kurz a écrit :

Quoted 27 lines

If memory allocation fails when using -mem-path, QEMU is supposed to print out a message to indicate that fallback to anonymous RAM is deprecated. This is done with error_printf() which does output buffering. As a consequence, the message is only printed at the next flush, eg. when quiting QEMU, and it also lacks a trailing newline:

qemu-system-ppc64: unable to map backing store for guest RAM: Cannot allocate memory
qemu-system-ppc64: warning: falling back to regular RAM allocation
QEMU 4.1.50 monitor - type 'help' for more information
(qemu) q
This is deprecated. Make sure that -mem-path specified path has sufficient resources to allocate -m specified RAM amountgreg@boss02:~/Work/qemu/qemu-spapr$

Add the missing \n to fix both issues.

Fixes cb79224b7e4b "deprecate -mem-path fallback to anonymous RAM"
---
 hw/core/numa.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/numa.c +0 -0
index 038c96d4abc6..e3332a984f7c 100644

hw/core/numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 509

Quoted 8 lines
hw/core/numa.c +1 -1
@@ -503,7 +503,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             warn_report("falling back to regular RAM allocation");
             error_printf("This is deprecated. Make sure that -mem-path "
                          " specified path has sufficient resources to allocate"
-                         " -m specified RAM amount");
+                         " -m specified RAM amount\n");
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */

Applied to my trivial-patches branch.

Thanks,
Laurent