Trivial patches for 2014-08-24
This time, we've a bunch of trivial stuff all over, including a series from zhanghailiang, some minor fixes from Stefan Weil and Peter Crosthwaite, and also a bugfix for a rare device - vmxnet3 - reviewed by the author.
Please consider pulling/applying.
Thanks,
/mjt
The following changes since commit 33886ebeec0c0ff6253a49253fae0db44c9ed0f3:
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2014-08-22 16:12:51 +0100)
are available in the git repository at:
git://git.corpit.ru/qemu.git tags/trivial-patches-2014-08-24
for you to fetch changes up to 40a87c6c9b11ef9c14e0301f76abf0eb2582f08e:
vmxnet3: Pad short frames to minimum size (60 bytes) (2014-08-24 17:11:08 +0400)
----------------------------------------------------------------
trivial patches for 2014-08-24
----------------------------------------------------------------
Ben Draper (1):
vmxnet3: Pad short frames to minimum size (60 bytes)
Liming Wang (1):
configure: no need to mkdir QMP
Peter Crosthwaite (2):
microblaze: ml605: Get rid of ddr_base variable
dma: axidma: Variablise repeated s->streams[i] sub-expr
Stefan Weil (2):
po: Fix Makefile rules for in-tree builds without configuration
libdecnumber: Fix warnings from smatch (missing static, boolean operations)
zhanghailiang (5):
util/path: Use the GLib memory allocation routines
tcg: dump op count into qemu log tests/bios-tables-test: check the value returned by fopen() slirp/misc: Use the GLib memory allocation APIs
linux-user: fix file descriptor leaks
configure | 4 ---- hw/dma/xilinx_axidma.c | 10 ++++++---- hw/microblaze/petalogix_ml605_mmu.c | 5 ++--- hw/net/vmxnet3.c | 10 ++++++++++ libdecnumber/decNumber.c | 21 +++++++++++---------- linux-user/syscall.c | 1 + po/Makefile | 7 +++++-- slirp/misc.c | 20 +++----------------- slirp/misc.h | 4 ---- slirp/slirp_config.h | 3 --- tcg/tcg.c | 6 ++---- tests/bios-tables-test.c | 5 +++++ util/path.c | 10 +++++----- 13 files changed, 50 insertions(+), 56 deletions(-)
[Qemu-devel] [PULL 09/11] linux-user: fix file descriptor leaks
From: zhanghailiang <[email protected]>
Handle variable "fd_orig" going out of scope leaks the handle.
--- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+)
linux-user/syscall.c +1 -0
@@ -5167,6 +5167,7 @@ static int open_self_cmdline(void *cpu_env, int fd)if (word_skipped) {if (write (fd, cp_buf, nb_read) != nb_read) { +close (fd_orig);return -1 ; } }
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 03/11] tests/bios-tables-test: check the value returned by fopen()
In reply to Michael TokarevFrom: zhanghailiang <[email protected]>
The function fopen() may fail, so check its return value.
--- tests/bios-tables-test.c | 5 +++++ 1 file changed, 5 insertions(+)
tests/bios-tables-test.c +5 -0
@@ -790,6 +790,11 @@ int main(int argc, char *argv[])const char *arch =qtest_get_arch ();FILE *f =fopen (disk,"w" );int ret; + +if (!f) { +fprintf (stderr,"Couldn't open \"%s\": %s" , disk,strerror (errno)); +return 1 ; + }fwrite (boot_sector,1 ,sizeof boot_sector, f);fclose (f);
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 02/11] tcg: dump op count into qemu log
In reply to Michael TokarevFrom: zhanghailiang <[email protected]>
fopen() may fail and it does not check its return vaule here, it is better to dump op count to the normal log file.
--- tcg/tcg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
tcg/tcg.c +2 -4
@@ -2404,12 +2404,10 @@ static int64_t tcg_table_op_count[NB_OPS];static void dump_op_count (void ) {int i; -FILE *f; - f =fopen ("/tmp/op.log" ,"w" ); +for (i = INDEX_op_end; i <NB_OPS ; i++) { -fprintf (f,"%s %" PRId64"\n" , tcg_op_defs[i].name, tcg_table_op_count[i]); +qemu_log ("%s %" PRId64"\n" , tcg_op_defs[i].name, tcg_table_op_count[i]); } -fclose (f); }#endif
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 06/11] configure: no need to mkdir QMP
In reply to Michael TokarevFrom: Liming Wang <[email protected]>
commit 7537fe04 QMP: QMP/ -> docs/qmp/
Above commit has moved last QMP files to docs/qmp and it's not necessary to create QMP directory. So remove it from configure.
--- configure | 4 ---- 1 file changed, 4 deletions(-)
configure +0 -4
@@ -5372,10 +5372,6 @@ for rom in seabios vgabios ; do echo "LD=$ld" >> $config_mak done -if test "$docs" = "yes" ; then - mkdir -p QMP -fi - # set up qemu-iotests in this build directory iotests_common_env="tests/qemu-iotests/common.env" iotests_check="tests/qemu-iotests/check"
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 10/11] libdecnumber: Fix warnings from smatch (missing static, boolean operations)
In reply to Michael TokarevFrom: Stefan Weil <[email protected]>
--- libdecnumber/decNumber.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
libdecnumber/decNumber.c +11 -10
@@ -5275,8 +5275,8 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,/* 4. The working precisions for the static buffers are twice the */ /* obvious size to allow for calls from decNumberPower. */ /* ------------------------------------------------------------------ */ -decNumber *decExpOp (decNumber *res,const decNumber *rhs, -decContext *set,uInt *status) { +static decNumber *decExpOp (decNumber *res,const decNumber *rhs, +decContext *set,uInt *status) {uInt ignore=0 ;/* working status */ Int h;/* adjusted exponent for 0.xxxx */ Int p;/* working precision */
@@ -5563,7 +5563,8 @@ decNumber * decExpOp(decNumber *res, const decNumber *rhs,/* where x is truncated (NB) into the range 10 through 99, */ /* and then c = k>>2 and e = k&3. */ /* ------------------------------------------------------------------ */ -const uShort LNnn[90 ]={9016 ,8652 ,8316 ,8008 ,7724 ,7456 ,7208 , +static const uShort LNnn[90 ] = { +9016 ,8652 ,8316 ,8008 ,7724 ,7456 ,7208 ,6972 ,6748 ,6540 ,6340 ,6148 ,5968 ,5792 ,5628 ,5464 ,5312 ,5164 ,5020 ,4884 ,4748 ,4620 ,4496 ,4376 ,4256 ,4144 ,4032 ,39233 ,38181 ,37157 ,36157 ,35181 ,34229 ,33297 ,32389 ,31501 ,30629 ,
@@ -5635,8 +5636,8 @@ const uShort LNnn[90]={9016, 8652, 8316, 8008, 7724, 7456, 7208,/* 5. The static buffers are larger than might be expected to allow */ /* for calls from decNumberPower. */ /* ------------------------------------------------------------------ */ -decNumber *decLnOp (decNumber *res,const decNumber *rhs, -decContext *set,uInt *status) { +static decNumber *decLnOp (decNumber *res,const decNumber *rhs, +decContext *set,uInt *status) {uInt ignore=0 ;/* working status accumulator */ uInt needbytes;/* for space calculations */ Int residue;/* rounding residue */
@@ -6052,9 +6053,9 @@ static decNumber * decQuantizeOp(decNumber *res, const decNumber *lhs,/* The emphasis here is on speed for common cases, and avoiding */ /* coefficient comparison if possible. */ /* ------------------------------------------------------------------ */ -decNumber *decCompareOp (decNumber *res,const decNumber *lhs, -const decNumber *rhs,decContext *set, -Flag op,uInt *status) { +static decNumber *decCompareOp (decNumber *res,const decNumber *lhs, +const decNumber *rhs,decContext *set, +Flag op,uInt *status) {#if DECSUBSET decNumber *alloclhs=NULL ;/* non-NULL if rounded lhs allocated */ decNumber *allocrhs=NULL ;/* .., rhs */
@@ -6086,11 +6087,11 @@ decNumber * decCompareOp(decNumber *res, const decNumber *lhs,/* If total ordering then handle differing signs 'up front' */ if (op==COMPTOTAL ) {/* total ordering */ -if (decNumberIsNegative (lhs) & !decNumberIsNegative (rhs)) { +if (decNumberIsNegative (lhs) && !decNumberIsNegative (rhs)) { result=-1 ;break ; } -if (!decNumberIsNegative (lhs) &decNumberIsNegative (rhs)) { +if (!decNumberIsNegative (lhs) &&decNumberIsNegative (rhs)) { result=+1 ;break ; }
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 01/11] util/path: Use the GLib memory allocation routines
In reply to Michael TokarevFrom: zhanghailiang <[email protected]>
In this file, we don't check the return value of malloc/strdup/realloc which may fail. Instead of using these routines, we use the GLib memory APIs g_malloc/g_strdup/g_realloc. They will exit on allocation failure, so there is no need to test for failure, which would be fine for setup.
--- util/path.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
util/path.c +5 -5
@@ -45,8 +45,8 @@ static struct pathelem *new_entry(const char *root,struct pathelem *parent, const char *name) { - struct pathelem *new = malloc(sizeof(*new)); - new->name =strdup (name); + struct pathelem *new = g_malloc(sizeof(*new)); + new->name =g_strdup (name); new->pathname =g_strdup_printf ("%s/%s" , root, name); new->num_entries =0 ;return new;
@@ -88,7 +88,7 @@ static struct pathelem *add_entry(struct pathelem *root, const char *name, root->num_entries++; - root =realloc (root,sizeof (*root) + root =g_realloc (root,sizeof (*root) +sizeof (root->entries[0 ])*root->num_entries); e = &root->entries[root->num_entries-1 ];
@@ -161,8 +161,8 @@ void init_paths(const char *prefix) base =add_dir_maybe (base);if (base->num_entries ==0 ) {g_free (base->pathname); -free (base->name); -free (base); +g_free (base->name); +g_free (base); base =NULL ; }else {set_parents (base, base);
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 07/11] slirp/misc: Use the GLib memory allocation APIs
In reply to Michael TokarevFrom: zhanghailiang <[email protected]>
Here we don't check the return value of malloc() which may fail. Use the g_new() instead, which will abort the program when there is not enough memory.
Also, use g_strdup instead of strdup and remove the unnecessary strdup function.
--- slirp/misc.c | 20 +++----------------- slirp/misc.h | 4 ---- slirp/slirp_config.h | 3 --- 3 files changed, 3 insertions(+), 24 deletions(-)
slirp/misc.c +3 -17
@@ -54,11 +54,11 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec, } tmp_ptr = *ex_ptr; - *ex_ptr = (struct ex_list *)malloc (sizeof (struct ex_list )); + *ex_ptr = g_new(struct ex_list, 1); (*ex_ptr)->ex_fport = port; (*ex_ptr)->ex_addr = addr; (*ex_ptr)->ex_pty = do_pty; - (*ex_ptr)->ex_exec = (do_pty ==3 ) ? exec :strdup (exec); + (*ex_ptr)->ex_exec = (do_pty ==3 ) ? exec :g_strdup (exec); (*ex_ptr)->ex_next = tmp_ptr;return 0 ; }
@@ -187,7 +187,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty) bptr++; c = *bptr; *bptr++ = (char )0 ; - argv[i++] =strdup (curarg); + argv[i++] =g_strdup (curarg); }while (c); argv[i] =NULL ;
@@ -228,20 +228,6 @@ fork_exec(struct socket *so, const char *ex, int do_pty) }#endif -#ifndef HAVE_STRDUP -char * -strdup (str ) - const char *str; -{ -char *bptr; - - bptr = (char *)malloc (strlen (str)+1 ); -strcpy (bptr, str); - -return bptr; -} -#endif -void slirp_connection_info (Slirp *slirp,Monitor *mon) {const char *const tcpstates[] = {
slirp/misc.h +0 -4
@@ -16,10 +16,6 @@ struct ex_list {struct ex_list *ex_next; }; -#ifndef HAVE_STRDUP -char *strdup (const char *); -#endif -#define EMU_NONE 0x0/* TCP emulations */
slirp/slirp_config.h +0 -3
@@ -72,9 +72,6 @@/* Define if you have strerror */ #define HAVE_STRERROR -/* Define if you have strdup() */ -#define HAVE_STRDUP -/* Define according to how time.h should be included */ #define TIME_WITH_SYS_TIME 0#undef HAVE_SYS_TIME_H
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 11/11] vmxnet3: Pad short frames to minimum size (60 bytes)
In reply to Michael TokarevFrom: Ben Draper <[email protected]>
When running VMware ESXi under qemu-kvm the guest discards frames that are too short. Short ARP Requests will be dropped, this prevents guests on the same bridge as VMware ESXi from communicating. This patch simply adds the padding on the network device itself.
--- hw/net/vmxnet3.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/net/vmxnet3.c +10 -0
@@ -34,6 +34,7 @@#define PCI_DEVICE_ID_VMWARE_VMXNET3_REVISION 0x1#define VMXNET3_MSIX_BAR_SIZE 0x2000 +#define MIN_BUF_SIZE 60#define VMXNET3_BAR0_IDX (0)#define VMXNET3_BAR1_IDX (1)
@@ -1871,12 +1872,21 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *buf, size_t size) {VMXNET3State *s =qemu_get_nic_opaque (nc);size_t bytes_indicated; +uint8_t min_buf[MIN_BUF_SIZE ];if (!vmxnet3_can_receive (nc)) {VMW_PKPRN ("Cannot receive now" );return -1 ; } +/* Pad to minimum Ethernet frame length */ +if (size <sizeof (min_buf)) { +memcpy (min_buf, buf, size); +memset (&min_buf[size],0 ,sizeof (min_buf) - size); + buf = min_buf; + size =sizeof (min_buf); + } +if (s->peer_has_vhdr) {vmxnet_rx_pkt_set_vhdr (s->rx_pkt, (struct virtio_net_hdr *)buf); buf +=sizeof (struct virtio_net_hdr );
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 08/11] po: Fix Makefile rules for in-tree builds without configuration
In reply to Michael TokarevFrom: Stefan Weil <[email protected]>
Adding 'update' to the phony targets fixes this error:
$ LANG=C make -C po update make: Entering directory `/qemu/po' LINK update /qemu/po/de_DE.po: file not recognized: File format not recognized collect2: error: ld returned 1 exit status make: *** [update] Error 1 make: Leaving directory `/qemu/po'
Some other phony targets (build, install) were also added, and the existing .PHONY statement was moved to a more prominent position at the beginning of the Makefile.
The patch also fixes a 2nd bug. The default target should be 'all', but instead 'modules' (from rules.mak) was the default. Fix this by adding 'all' as a target before any include statement.
--- po/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
po/Makefile +5 -2
@@ -4,6 +4,11 @@ # Set SRC_PATH for in-tree builds without configuration. SRC_PATH=.. +# The default target must come before any include statements. +all: + +.PHONY: all build clean install update + -include ../config-host.mak include $(SRC_PATH)/rules.mak
@@ -45,5 +50,3 @@ $(PO_PATH)/messages.po: $(SRC_PATH)/ui/gtk.c $(PO_PATH)/%.po: $(PO_PATH)/messages.po $(call quiet-command, msgmerge -q $@ $< > [email protected] && mv [email protected] $@, " GEN $@") - -.PHONY: clean all
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 05/11] dma: axidma: Variablise repeated s->streams[i] sub-expr
In reply to Michael TokarevFrom: Peter Crosthwaite <[email protected]>
This have 6 inline usages. Make it a bit more readable by using a local variable.
--- hw/dma/xilinx_axidma.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
hw/dma/xilinx_axidma.c +6 -4
@@ -553,10 +553,12 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp)int i;for (i =0 ; i <2 ; i++) { - s->streams[i].nr = i; - s->streams[i].bh =qemu_bh_new (timer_hit, &s->streams[i]); - s->streams[i].ptimer =ptimer_init (s->streams[i].bh); -ptimer_set_freq (s->streams[i].ptimer, s->freqhz); +struct Stream *st = &s->streams[i]; + + st->nr = i; + st->bh =qemu_bh_new (timer_hit, st); + st->ptimer =ptimer_init (st->bh); +ptimer_set_freq (st->ptimer, s->freqhz); }return ;
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 04/11] microblaze: ml605: Get rid of ddr_base variable
In reply to Michael TokarevFrom: Peter Crosthwaite <[email protected]>
It's a constant based on a macro. Just use the macro in place.
--- hw/microblaze/petalogix_ml605_mmu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
hw/microblaze/petalogix_ml605_mmu.c +2 -3
@@ -89,7 +89,6 @@ petalogix_ml605_init(MachineState *machine)SysBusDevice *busdev;DriveInfo *dinfo;int i; -hwaddr ddr_base =MEMORY_BASEADDR ;MemoryRegion *phys_lmb_bram =g_new (MemoryRegion,1 );MemoryRegion *phys_ram =g_new (MemoryRegion,1 );qemu_irq irq[32 ];
@@ -106,7 +105,7 @@ petalogix_ml605_init(MachineState *machine)memory_region_init_ram (phys_ram,NULL ,"petalogix_ml605.ram" , ram_size);vmstate_register_ram_global (phys_ram); -memory_region_add_subregion (address_space_mem, ddr_base, phys_ram); +memory_region_add_subregion (address_space_mem,MEMORY_BASEADDR , phys_ram); dinfo =drive_get (IF_PFLASH ,0 ,0 );/* 5th parameter 2 means bank-width
@@ -201,7 +200,7 @@ petalogix_ml605_init(MachineState *machine) } } -microblaze_load_kernel (cpu, ddr_base, ram_size, +microblaze_load_kernel (cpu,MEMORY_BASEADDR , ram_size, machine->initrd_filename,BINARY_DEVICE_TREE_FILE , machine_cpu_reset);
Signature · 1 line
1.7.10.4
Peter Maydell
AppliedQuoted 16 lines · Michael Tokarev
This time, we've a bunch of trivial stuff all over, including a series from zhanghailiang, some minor fixes from Stefan Weil and Peter Crosthwaite, and also a bugfix for a rare device - vmxnet3 - reviewed by the author.
Please consider pulling/applying.
Thanks,
/mjt
The following changes since commit
33886ebeec0c0ff6253a49253fae0db44c9ed0f3:Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2014-08-22 16:12:51 +0100)
are available in the git repository at:
Quoted 9 lines
git://git.corpit.ru/qemu.gittags/trivial-patches-2014-08-24for you to fetch changes up to
40a87c6c9b11ef9c14e0301f76abf0eb2582f08e:vmxnet3: Pad short frames to minimum size (60 bytes) (2014-08-24 17:11:08 +0400)
----------------------------------------------------------------
trivial patches for 2014-08-24
Applied, thanks.
-- PMM