Skip to contentSkip to conversation

Trivial patches for 28 January to 10 February 2012

GIT PULL In review Stefan Hajnoczi 3 participants 13 messages Feb 10, 2012 – Feb 17, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The following changes since commit 57c83dacfe179bf061b8fa79d9553ebabe4d2ff4:

make: Remove duplicate use of GLIB_CFLAGS (2012-02-09 20:44:38 +0400)

are available in the git repository at:
git://github.com/stefanha/qemu.git trivial-patches

Benjamin MARSILI (1):
net: remove extra spaces in help messages

Hervé Poussineau (1):
ide: fix compilation errors when DEBUG_IDE is set

Luiz Capitulino (1):
virtio: Remove unneeded g_free() check in virtio_cleanup()

Paul Brook (1):
linux-user: brk() debugging

Peter Maydell (2):
CODING_STYLE: Clarify style for enum and function type names vl.c: Fix typo in variable name

Stefan Weil (1):
fmopl: Fix typo in function name

Ulrich Hecht (1):
linux-user: fail execve() if env/args too big

陳韋任 (1):
cpu-exec.c: Correct comment about this file and indentation cleanup

 CODING_STYLE         |    3 ++-
 cpu-exec.c           |   10 +++++-----
 hw/fmopl.c           |    4 ++--
 hw/ide/pci.c         |    2 +-
 hw/ide/piix.c        |    4 ++--
 hw/virtio.c          |    3 +--
 linux-user/syscall.c |   25 ++++++++++++++++++-------
 net/socket.c         |    8 ++++----
 vl.c                 |   10 +++++-----
 9 files changed, 40 insertions(+), 29 deletions(-)
Signature · 1 line
1.7.8.3
#1 lore raw

PATCH 1/9 linux-user: fail execve() if env/args too big

From: Ulrich Hecht <[email protected]>

If the host's page size is equal to or smaller than the target's, native execve() will fail appropriately with E2BIG if called with too big an environment for the target to handle. It may falsely succeed, however, if the host's page size is bigger, and feed the executed target process an environment that is too big for it to handle, at which point QEMU barfs and exits, confusing procmail's autoconf script and causing the build to fail.

This patch makes sure that execve() will return E2BIG if the environment is too large for the target.

---
 linux-user/syscall.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
linux-user/syscall.c +9 -0
index ee8899e..e868ec6 100644
@@ -4949,6 +4949,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             abi_ulong guest_envp;
             abi_ulong addr;
             char **q;
+            int total_size = 0;
 
             argc = 0;
             guest_argp = arg2;
@@ -4980,6 +4981,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                     break;
                 if (!(*q = lock_user_string(addr)))
                     goto execve_efault;
+                total_size += strlen(*q) + 1;
             }
             *q = NULL;
 
@@ -4991,9 +4993,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                     break;
                 if (!(*q = lock_user_string(addr)))
                     goto execve_efault;
+                total_size += strlen(*q) + 1;
             }
             *q = NULL;
 
+            /* This case will not be caught by the host's execve() if its
+               page size is bigger than the target's. */
+            if (total_size > MAX_ARG_PAGES * TARGET_PAGE_SIZE) {
+                ret = -TARGET_E2BIG;
+                goto execve_end;
+            }
             if (!(p = lock_user_string(arg1)))
                 goto execve_efault;
             ret = get_errno(execve(p, argp, envp));
Signature · 1 line
1.7.8.3
#2 lore raw

PATCH 2/9 CODING_STYLE: Clarify style for enum and function type names

In reply to Stefan Hajnoczi

From: Peter Maydell <[email protected]>

Clarify that enum type names and function type names should follow the CamelCase style used for structured type names.

---
 CODING_STYLE |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
CODING_STYLE +2 -1
index 6e61c49..7c82d4d 100644
@@ -44,7 +44,8 @@ Rationale:
 3. Naming
 
 Variables are lower_case_with_underscores; easy to type and read.  Structured
-type names are in CamelCase; harder to type but standing out.  Scalar type
+type names are in CamelCase; harder to type but standing out.  Enum type
+names and function type names should also be in CamelCase.  Scalar type
 names are lower_case_with_underscores_ending_with_a_t, like the POSIX
 uint64_t and family.  Note that this last convention contradicts POSIX
 and is therefore likely to be changed.
Signature · 1 line
1.7.8.3
#3 lore raw

PATCH 3/9 cpu-exec.c: Correct comment about this file and indentation cleanup

In reply to Stefan Hajnoczi

From: 陳韋任 <[email protected]>

Each target uses the #define macro (in target-xxx/cpu.h) to rename cpu_exec (cpu-exec.c) to cpu_xxx_exec, then defines its own cpu_loop which calls cpu_xxx_exec. So basically, cpu-exec.c is not only the i386 emulator main execution loop. This patch corrects the comment of this file and does indentation cleanup.

---
 cpu-exec.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
cpu-exec.c +5 -5
index a9fa608..2c2d24e 100644
@@ -1,5 +1,5 @@
 /*
- *  i386 emulator main execution loop
+ *  emulator main execution loop
  *
  *  Copyright (c) 2003-2005 Fabrice Bellard
  *
@@ -304,7 +304,7 @@ int cpu_exec(CPUState *env)
                             env->hflags2 |= HF2_NMI_MASK;
                             do_interrupt_x86_hardirq(env, EXCP02_NMI, 1);
                             next_tb = 0;
-			} else if (interrupt_request & CPU_INTERRUPT_MCE) {
+                        } else if (interrupt_request & CPU_INTERRUPT_MCE) {
                             env->interrupt_request &= ~CPU_INTERRUPT_MCE;
                             do_interrupt_x86_hardirq(env, EXCP12_MCHK, 0);
                             next_tb = 0;
@@ -390,7 +390,7 @@ int cpu_exec(CPUState *env)
                                 next_tb = 0;
                             }
                         }
-		    }
+                    }
 #elif defined(TARGET_ARM)
                     if (interrupt_request & CPU_INTERRUPT_FIQ
                         && !(env->uncached_cpsr & CPSR_F)) {
@@ -429,7 +429,7 @@ int cpu_exec(CPUState *env)
                     {
                         int idx = -1;
                         /* ??? This hard-codes the OSF/1 interrupt levels.  */
-		        switch (env->pal_mode ? 7 : env->ps & PS_INT_MASK) {
+                        switch (env->pal_mode ? 7 : env->ps & PS_INT_MASK) {
                         case 0 ... 3:
                             if (interrupt_request & CPU_INTERRUPT_HARD) {
                                 idx = EXCP_DEV_INTERRUPT;
@@ -562,7 +562,7 @@ int cpu_exec(CPUState *env)
                 barrier();
                 if (likely(!env->exit_request)) {
                     tc_ptr = tb->tc_ptr;
-                /* execute the generated code */
+                    /* execute the generated code */
                     next_tb = tcg_qemu_tb_exec(env, tc_ptr);
                     if ((next_tb & 3) == 2) {
                         /* Instruction counter expired.  */
Signature · 1 line
1.7.8.3
#4 lore raw

PATCH 4/9 ide: fix compilation errors when DEBUG_IDE is set

In reply to Stefan Hajnoczi

From: Hervé Poussineau <[email protected]>

---
 hw/ide/pci.c  |    2 +-
 hw/ide/piix.c |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
hw/ide/pci.c +1 -1
index 246dd57..88c0942 100644
@@ -336,7 +336,7 @@ static uint64_t bmdma_addr_read(void *opaque, target_phys_addr_t addr,
 
     data = (bm->addr >> (addr * 8)) & mask;
 #ifdef DEBUG_IDE
-    printf("%s: 0x%08x\n", __func__, (unsigned)*data);
+    printf("%s: 0x%08x\n", __func__, (unsigned)data);
 #endif
     return data;
 }
hw/ide/piix.c +2 -2
index bf4465b..76cf209 100644
@@ -53,7 +53,7 @@ static uint64_t bmdma_read(void *opaque, target_phys_addr_t addr, unsigned size)
         break;
     }
 #ifdef DEBUG_IDE
-    printf("bmdma: readb 0x%02x : 0x%02x\n", addr, val);
+    printf("bmdma: readb 0x%02x : 0x%02x\n", (uint8_t)addr, val);
 #endif
     return val;
 }
@@ -68,7 +68,7 @@ static void bmdma_write(void *opaque, target_phys_addr_t addr,
     }
 
 #ifdef DEBUG_IDE
-    printf("bmdma: writeb 0x%02x : 0x%02x\n", addr, val);
+    printf("bmdma: writeb 0x%02x : 0x%02x\n", (uint8_t)addr, (uint8_t)val);
 #endif
     switch(addr & 3) {
     case 0:
Signature · 1 line
1.7.8.3
#5 lore raw

PATCH 5/9 vl.c: Fix typo in variable name

In reply to Stefan Hajnoczi

From: Peter Maydell <[email protected]>

Fix a typo in a local variable name.

---
 vl.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
vl.c +5 -5
index 63dd725..c4b3aab 100644
@@ -2030,7 +2030,7 @@ static int configure_accelerator(void)
     const char *p = NULL;
     char buf[10];
     int i, ret;
-    bool accel_initalised = 0;
+    bool accel_initialised = 0;
     bool init_failed = 0;
 
     QemuOptsList *list = qemu_find_opts("machine");
@@ -2043,7 +2043,7 @@ static int configure_accelerator(void)
         p = "tcg";
     }
 
-    while (!accel_initalised && *p != '\0') {
+    while (!accel_initialised && *p != '\0') {
         if (*p == ':') {
             p++;
         }
@@ -2064,7 +2064,7 @@ static int configure_accelerator(void)
                     }
                     *(accel_list[i].allowed) = 0;
                 } else {
-                    accel_initalised = 1;
+                    accel_initialised = 1;
                 }
                 break;
             }
@@ -2074,7 +2074,7 @@ static int configure_accelerator(void)
         }
     }
 
-    if (!accel_initalised) {
+    if (!accel_initialised) {
         fprintf(stderr, "No accelerator found!\n");
         exit(1);
     }
@@ -2083,7 +2083,7 @@ static int configure_accelerator(void)
         fprintf(stderr, "Back to %s accelerator.\n", accel_list[i].name);
     }
 
-    return !accel_initalised;
+    return !accel_initialised;
 }
 
 void qemu_add_exit_notifier(Notifier *notify)
Signature · 1 line
1.7.8.3
#6 lore raw

PATCH 6/9 fmopl: Fix typo in function name

In reply to Stefan Hajnoczi

From: Stefan Weil <[email protected]>

Fix a typo in a local function name.

---
 hw/fmopl.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/fmopl.c +2 -2
index 734d2f4..f0a0234 100644
@@ -733,7 +733,7 @@ INLINE void CSMKeyControll(OPL_CH *CH)
 }
 
 /* ---------- opl initialize ---------- */
-static void OPL_initalize(FM_OPL *OPL)
+static void OPL_initialize(FM_OPL *OPL)
 {
 	int fn;
 
@@ -1239,7 +1239,7 @@ FM_OPL *OPLCreate(int type, int clock, int rate)
 	OPL->rate  = rate;
 	OPL->max_ch = max_ch;
 	/* init grobal tables */
-	OPL_initalize(OPL);
+	OPL_initialize(OPL);
 	/* reset chip */
 	OPLResetChip(OPL);
 #ifdef OPL_OUTPUT_LOG
Signature · 1 line
1.7.8.3
#7 lore raw

PATCH 7/9 net: remove extra spaces in help messages

In reply to Stefan Hajnoczi

From: Benjamin MARSILI <[email protected]>

---
 net/socket.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
net/socket.c +4 -4
index d4c2002..0bcf229 100644
@@ -664,8 +664,8 @@ int net_init_socket(QemuOpts *opts,
             qemu_opt_get(opts, "connect") ||
             qemu_opt_get(opts, "listen") ||
             qemu_opt_get(opts, "mcast")) {
-            error_report("fd=, connect=, listen=\
-                         and mcast= is invalid with udp=");
+            error_report("fd=, connect=, listen="
+                         " and mcast= is invalid with udp=");
             return -1;
         }
 
@@ -680,8 +680,8 @@ int net_init_socket(QemuOpts *opts,
             return -1;
         }
     } else {
-        error_report("-socket requires fd=, listen=, \
-                     connect=, mcast= or udp=");
+        error_report("-socket requires fd=, listen=,"
+                     " connect=, mcast= or udp=");
         return -1;
     }
     return 0;
Signature · 1 line
1.7.8.3
#8 lore raw

Re: [Qemu-devel] [PATCH 7/9] net: remove extra spaces in help messages

I would like to know if some one is playing around with the patchset.

If yes, can you make one response? I am very interested in rebasing it, and then playing with it.

Quoted 38 lines · Stefan Hajnoczi

From: Benjamin MARSILI <[email protected]>

---
 net/socket.c |    8 ++++----

 1 files changed, 4 insertions(+), 4 deletions(-)
net/socket.c +0 -0
index d4c2002..0bcf229 100644
@@ -664,8 +664,8 @@ int net_init_socket(QemuOpts *opts,

            qemu_opt_get(opts, "connect") || qemu_opt_get(opts, "listen") || qemu_opt_get(opts, "mcast")) {
-            error_report("fd=, connect=, listen=\
-                         and mcast= is invalid with udp=");
+            error_report("fd=, connect=, listen="
+                         " and mcast= is invalid with udp="); return -1;
        }

net/socket.c +2 -3
@@ -680,8 +680,8 @@ int net_init_socket(QemuOpts *opts,
             return -1;
         }
     } else {
-        error_report("-socket requires fd=, listen=, \
-                     connect=, mcast= or udp=");
+        error_report("-socket requires fd=, listen=,"
+                     " connect=, mcast= or udp=");
         return -1;
     }
     return 0;
--

1.7.8.3

Signature · 3 lines
Regards,

Zhi Yong Wu
#9 lore raw

Re: [Qemu-devel] [PATCH 7/9] net: remove extra spaces in help messages

sorry, made one mistake

Quoted 52 lines · Zhi Yong Wu

I would like to know if some one is playing around with the patchset.

If yes, can you make one response? I am very interested in rebasing it, and then playing with it.

Quoted 35 lines · Stefan Hajnoczi

From: Benjamin MARSILI <[email protected]>

---
 net/socket.c |    8 ++++----

 1 files changed, 4 insertions(+), 4 deletions(-)
net/socket.c +0 -0
index d4c2002..0bcf229 100644
@@ -664,8 +664,8 @@ int net_init_socket(QemuOpts *opts,

            qemu_opt_get(opts, "connect") || qemu_opt_get(opts, "listen") || qemu_opt_get(opts, "mcast")) {
-            error_report("fd=, connect=, listen=\
-                         and mcast= is invalid with udp=");
+            error_report("fd=, connect=, listen="
+                         " and mcast= is invalid with udp="); return -1;
        }

net/socket.c +2 -3
@@ -680,8 +680,8 @@ int net_init_socket(QemuOpts *opts,
             return -1;
         }
     } else {
-        error_report("-socket requires fd=, listen=, \
-                     connect=, mcast= or udp=");
+        error_report("-socket requires fd=, listen=,"
+                     " connect=, mcast= or udp=");
         return -1;
     }
     return 0;
--
Quoted 3 lines

1.7.8.3

--
Regards,

Zhi Yong Wu

Signature · 3 lines
Regards,

Zhi Yong Wu
#10 lore raw

PATCH 8/9 virtio: Remove unneeded g_free() check in virtio_cleanup()

In reply to Stefan Hajnoczi

From: Luiz Capitulino <[email protected]>

---
 hw/virtio.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
hw/virtio.c +1 -2
index 74cc038..064aecf 100644
@@ -845,8 +845,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
 void virtio_cleanup(VirtIODevice *vdev)
 {
     qemu_del_vm_change_state_handler(vdev->vmstate);
-    if (vdev->config)
-        g_free(vdev->config);
+    g_free(vdev->config);
     g_free(vdev->vq);
     g_free(vdev);
 }
Signature · 1 line
1.7.8.3
#11 lore raw

PATCH 9/9 linux-user: brk() debugging

In reply to Stefan Hajnoczi

From: Paul Brook <[email protected]>

Fix format type mismatches in do_brk debug printfs.

---
 linux-user/syscall.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
linux-user/syscall.c +9 -7
index e868ec6..8a11213 100644
@@ -756,14 +756,15 @@ abi_long do_brk(abi_ulong new_brk)
     abi_long mapped_addr;
     int	new_alloc_size;
 
-    DEBUGF_BRK("do_brk(%#010x) -> ", new_brk);
+    DEBUGF_BRK("do_brk(" TARGET_ABI_FMT_lx ") -> ", new_brk);
 
     if (!new_brk) {
-        DEBUGF_BRK("%#010x (!new_brk)\n", target_brk);
+        DEBUGF_BRK(TARGET_ABI_FMT_lx " (!new_brk)\n", target_brk);
         return target_brk;
     }
     if (new_brk < target_original_brk) {
-        DEBUGF_BRK("%#010x (new_brk < target_original_brk)\n", target_brk);
+        DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk < target_original_brk)\n",
+                   target_brk);
         return target_brk;
     }
 
@@ -776,7 +777,7 @@ abi_long do_brk(abi_ulong new_brk)
             memset(g2h(target_brk), 0, new_brk - target_brk);
         }
 	target_brk = new_brk;
-        DEBUGF_BRK("%#010x (new_brk <= brk_page)\n", target_brk);
+        DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk <= brk_page)\n", target_brk);
     	return target_brk;
     }
 
@@ -803,7 +804,8 @@ abi_long do_brk(abi_ulong new_brk)
 
         target_brk = new_brk;
         brk_page = HOST_PAGE_ALIGN(target_brk);
-        DEBUGF_BRK("%#010x (mapped_addr == brk_page)\n", target_brk);
+        DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr == brk_page)\n",
+            target_brk);
         return target_brk;
     } else if (mapped_addr != -1) {
         /* Mapped but at wrong address, meaning there wasn't actually
@@ -811,10 +813,10 @@ abi_long do_brk(abi_ulong new_brk)
          */
         target_munmap(mapped_addr, new_alloc_size);
         mapped_addr = -1;
-        DEBUGF_BRK("%#010x (mapped_addr != -1)\n", target_brk);
+        DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr != -1)\n", target_brk);
     }
     else {
-        DEBUGF_BRK("%#010x (otherwise)\n", target_brk);
+        DEBUGF_BRK(TARGET_ABI_FMT_lx " (otherwise)\n", target_brk);
     }
 
 #if defined(TARGET_ALPHA)
Signature · 1 line
1.7.8.3
#12 lore raw
In reply to Stefan Hajnoczi
Quoted 6 lines · Stefan Hajnoczi

The following changes since commit 57c83dacfe179bf061b8fa79d9553ebabe4d2ff4:

   make: Remove duplicate use of GLIB_CFLAGS (2012-02-09 20:44:38 +0400)

are available in the git repository at:
git://github.com/stefanha/qemu.git trivial-patches

Pulled. Thanks.

Regards,

Anthony Liguori

Quoted 37 lines

Benjamin MARSILI (1):
net: remove extra spaces in help messages

Hervé Poussineau (1):
ide: fix compilation errors when DEBUG_IDE is set

Luiz Capitulino (1):
virtio: Remove unneeded g_free() check in virtio_cleanup()

Paul Brook (1):
linux-user: brk() debugging

Peter Maydell (2):
CODING_STYLE: Clarify style for enum and function type names vl.c: Fix typo in variable name

Stefan Weil (1):
fmopl: Fix typo in function name

Ulrich Hecht (1):
linux-user: fail execve() if env/args too big

陳韋任 (1):
cpu-exec.c: Correct comment about this file and indentation cleanup

  CODING_STYLE         |    3 ++-
  cpu-exec.c           |   10 +++++-----
  hw/fmopl.c           |    4 ++--
  hw/ide/pci.c         |    2 +-
  hw/ide/piix.c        |    4 ++--
  hw/virtio.c          |    3 +--
  linux-user/syscall.c |   25 ++++++++++++++++++-------
  net/socket.c         |    8 ++++----
  vl.c                 |   10 +++++-----
  9 files changed, 40 insertions(+), 29 deletions(-)