From 13a12f869bf2211c7039f9a601ac9e1076535663 Mon Sep 17 00:00:00 2001 From: Pankaj Gupta Date: Wed, 12 Mar 2014 22:24:27 +0530 Subject: [PATCH 1/6] tap: Avoid extra iterations while closing file fd Avoid iterations for fd 0, 1 & 2 when we are closing file fds in child process. Signed-off-by: Pankaj Gupta Signed-off-by: Stefan Hajnoczi --- net/tap.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/net/tap.c b/net/tap.c index 8847ce100a..fc1b865e08 100644 --- a/net/tap.c +++ b/net/tap.c @@ -367,11 +367,8 @@ static int launch_script(const char *setup_script, const char *ifname, int fd) if (pid == 0) { int open_max = sysconf(_SC_OPEN_MAX), i; - for (i = 0; i < open_max; i++) { - if (i != STDIN_FILENO && - i != STDOUT_FILENO && - i != STDERR_FILENO && - i != fd) { + for (i = 3; i < open_max; i++) { + if (i != fd) { close(i); } } @@ -452,11 +449,8 @@ static int net_bridge_run_helper(const char *helper, const char *bridge) char br_buf[6+IFNAMSIZ] = {0}; char helper_cmd[PATH_MAX + sizeof(fd_buf) + sizeof(br_buf) + 15]; - for (i = 0; i < open_max; i++) { - if (i != STDIN_FILENO && - i != STDOUT_FILENO && - i != STDERR_FILENO && - i != sv[1]) { + for (i = 3; i < open_max; i++) { + if (i != sv[1]) { close(i); } } From 16cf0b2b343d0bce1ab69ca14c898b3406234f80 Mon Sep 17 00:00:00 2001 From: Prasad Joshi Date: Sun, 23 Mar 2014 14:58:40 +0530 Subject: [PATCH 2/6] pcnet: remove duplicate assignment Signed-off-by: Prasad Joshi Signed-off-by: Stefan Hajnoczi --- hw/net/pcnet.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c index 7cb47b3f1f..ebe505784d 100644 --- a/hw/net/pcnet.c +++ b/hw/net/pcnet.c @@ -718,7 +718,6 @@ static void pcnet_s_reset(PCNetState *s) s->csr[94] = 0x0000; s->csr[100] = 0x0200; s->csr[103] = 0x0105; - s->csr[103] = 0x0105; s->csr[112] = 0x0000; s->csr[114] = 0x0000; s->csr[122] = 0x0000; From b925965294e8cf370a922ca0504c21877e748e70 Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Wed, 16 Apr 2014 17:43:07 +0400 Subject: [PATCH 3/6] net/net.c: Remove unnecessary semicolon Signed-off-by: Igor Ryzhov Reviewed-by: Stefan Weil Signed-off-by: Stefan Hajnoczi --- net/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/net.c b/net/net.c index a4aadffc11..bc9ed6def0 100644 --- a/net/net.c +++ b/net/net.c @@ -473,7 +473,7 @@ ssize_t qemu_deliver_packet(NetClientState *sender, if (ret == 0) { nc->receive_disabled = 1; - }; + } return ret; } From f663faac3e2e9d9134415f75d429ae30432e6038 Mon Sep 17 00:00:00 2001 From: Nathan Rossi Date: Tue, 8 Apr 2014 18:52:39 -0700 Subject: [PATCH 4/6] net: xilinx_axienet.c: Add phy soft reset bit clearing Clear the BMCR Reset when writing to registers. Signed-off-by: Nathan Rossi [ PC: * Trivial style fixes to commit message ] Signed-off-by: Peter Crosthwaite Reviewed-by: Beniamino Galvani Reviewed-by: Edgar E. Iglesias Signed-off-by: Stefan Hajnoczi --- hw/net/xilinx_axienet.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c index 839d97ca86..0f485a0283 100644 --- a/hw/net/xilinx_axienet.c +++ b/hw/net/xilinx_axienet.c @@ -142,6 +142,9 @@ tdk_write(struct PHY *phy, unsigned int req, unsigned int data) phy->regs[regnum] = data; break; } + + /* Unconditionally clear regs[BMCR][BMCR_RESET] */ + phy->regs[0] &= ~0x8000; } static void From 638fb14169ad96cf9bc0dd5f61460daaecee5bb1 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 24 Apr 2014 15:44:17 +0200 Subject: [PATCH 5/6] net: Make qmp_query_rx_filter() with name argument more obvious With a client name, the QMP command is specified to return a list of one element. This isn't locally obvious in the code. Make it so. Signed-off-by: Markus Armbruster Signed-off-by: Stefan Hajnoczi --- net/net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/net.c b/net/net.c index bc9ed6def0..ccb354aee8 100644 --- a/net/net.c +++ b/net/net.c @@ -1066,6 +1066,10 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, " rx-filter querying", name); break; } + + if (has_name) { + break; + } } if (filter_list == NULL && !error_is_set(errp) && has_name) { From 9083da1d4c9dfff30d411f8c73ea494e9d78de1b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 24 Apr 2014 15:44:18 +0200 Subject: [PATCH 6/6] net: Don't use error_is_set() to suppress additional errors Using error_is_set(errp) that way can sweep programming errors under the carpet when we get called incorrectly with an error set. qmp_query_rx_filter() breaks its loop when it detects an error. It needs to set another error when the loop completes normally. Return right away instead of merely breaking the loop. Signed-off-by: Markus Armbruster Signed-off-by: Stefan Hajnoczi --- net/net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/net.c b/net/net.c index ccb354aee8..9db4dba769 100644 --- a/net/net.c +++ b/net/net.c @@ -1045,7 +1045,7 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, if (nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC) { if (has_name) { error_setg(errp, "net client(%s) isn't a NIC", name); - break; + return NULL; } continue; } @@ -1064,7 +1064,7 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, } else if (has_name) { error_setg(errp, "net client(%s) doesn't support" " rx-filter querying", name); - break; + return NULL; } if (has_name) { @@ -1072,7 +1072,7 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, } } - if (filter_list == NULL && !error_is_set(errp) && has_name) { + if (filter_list == NULL && has_name) { error_setg(errp, "invalid net client name: %s", name); }