From b739ef05dbaffcaade5e756a70f91cdf9c327154 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Mon, 16 Jun 2014 16:47:11 +0100 Subject: [PATCH 1/8] slirp: Give error message if hostfwd_add/remove for unrecognized vlan/stack If the user specified a (vlan ID, slirp stack name) tuple in a monitor hostfwd_add/remove command and we can't find it, give the user an error message rather than silently doing nothing. This brings this error case in slirp_lookup() into line with the other two. Signed-off-by: Peter Maydell Reviewed-by: Michael Tokarev Signed-off-by: Michael Tokarev --- net/slirp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/slirp.c b/net/slirp.c index 8fddc03841..647039ec39 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -282,6 +282,7 @@ static SlirpState *slirp_lookup(Monitor *mon, const char *vlan, NetClientState *nc; nc = net_hub_find_client_by_name(strtol(vlan, NULL, 0), stack); if (!nc) { + monitor_printf(mon, "unrecognized (vlan-id, stackname) pair\n"); return NULL; } if (strcmp(nc->model, "user")) { From a9dd38db68a280fd8e2ece16904a5bae52be1925 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 7 Jul 2014 21:00:41 +0200 Subject: [PATCH 2/8] Fix new typos in comments (found by codespell) arbitary -> arbitrary basicly -> basically Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- include/libdecnumber/decNumberLocal.h | 2 +- xen-hvm.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index ec8ccdb673..7081c08a69 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -114,7 +114,7 @@ static void pc_init1(MachineState *machine, lowmem = 0xe0000000; } - /* Handle the machine opt max-ram-below-4g. It is basicly doing + /* Handle the machine opt max-ram-below-4g. It is basically doing * min(qemu limit, user limit). */ if (lowmem > pc_machine->max_ram_below_4g) { diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 36b6ab0bce..f55196150c 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -103,7 +103,7 @@ static void pc_q35_init(MachineState *machine) lowmem = 0xb0000000; } - /* Handle the machine opt max-ram-below-4g. It is basicly doing + /* Handle the machine opt max-ram-below-4g. It is basically doing * min(qemu limit, user limit). */ if (lowmem > pc_machine->max_ram_below_4g) { diff --git a/include/libdecnumber/decNumberLocal.h b/include/libdecnumber/decNumberLocal.h index cd4eb79e80..71ed77bf21 100644 --- a/include/libdecnumber/decNumberLocal.h +++ b/include/libdecnumber/decNumberLocal.h @@ -153,7 +153,7 @@ /* ---------------------------------------------------------------- */ - /* Definitions for arbitary-precision modules (only valid after */ + /* Definitions for arbitrary-precision modules (only valid after */ /* decNumber.h has been included) */ /* ---------------------------------------------------------------- */ diff --git a/xen-hvm.c b/xen-hvm.c index c928b36a45..a2486cfd7e 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -165,7 +165,7 @@ static void xen_ram_init(ram_addr_t *below_4g_mem_size, PC_MACHINE_MAX_RAM_BELOW_4G, &error_abort); - /* Handle the machine opt max-ram-below-4g. It is basicly doing + /* Handle the machine opt max-ram-below-4g. It is basically doing * min(xen limit, user limit). */ if (HVM_BELOW_4G_RAM_END <= user_lowmem) { From b847ae2d60ce05643a7fd02fcc6e3390ae97a1ee Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Thu, 3 Jul 2014 23:57:15 +0800 Subject: [PATCH 3/8] qemu-img: Remove redundancy "ret = -1" In this case, 'ret' is already '-1', so need not do it again. Signed-off-by: Chen Gang Signed-off-by: Michael Tokarev --- qemu-img.c | 1 - 1 file changed, 1 deletion(-) diff --git a/qemu-img.c b/qemu-img.c index c98896b281..d4518e724f 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -246,7 +246,6 @@ static int read_password(char *buf, int buf_size) if (errno == EAGAIN || errno == EINTR) { continue; } else { - ret = -1; break; } } else if (ret == 0) { From 37cbfcce1426e9b53cd235d2c7f9f6740f4c467c Mon Sep 17 00:00:00 2001 From: Gernot Hillier Date: Thu, 10 Jul 2014 16:01:25 +0200 Subject: [PATCH 4/8] doc: slirp supports ICMP echo if enabled in Linux Since QEMU 0.15, slirp (user mode networking) supports ping to the Internet, see e6d43cfb1f9 Signed-off-by: Gernot Hillier Signed-off-by: Michael Tokarev --- qemu-doc.texi | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/qemu-doc.texi b/qemu-doc.texi index 551619abd7..2b232ae8b7 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -1205,9 +1205,16 @@ In order to check that the user mode network is working, you can ping the address 10.0.2.2 and verify that you got an address in the range 10.0.2.x from the QEMU virtual DHCP server. -Note that @code{ping} is not supported reliably to the internet as it -would require root privileges. It means you can only ping the local -router (10.0.2.2). +Note that ICMP traffic in general does not work with user mode networking. +@code{ping}, aka. ICMP echo, to the local router (10.0.2.2) shall work, +however. If you're using QEMU on Linux >= 3.0, it can use unprivileged ICMP +ping sockets to allow @code{ping} to the Internet. The host admin has to set +the ping_group_range in order to grant access to those sockets. To allow ping +for GID 100 (usually users group): + +@example +echo 100 100 > /proc/sys/net/ipv4/ping_group_range +@end example When using the built-in TFTP server, the router is also the TFTP server. From b9b45b4a88df949ab3780ecf7abca55e66ae05d1 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 7 Jul 2014 21:05:30 +0200 Subject: [PATCH 5/8] hw/usb: Add missing 'static' attribute Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- hw/usb/hcd-ohci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index cace945844..13afdf5919 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -2021,7 +2021,7 @@ static const VMStateDescription vmstate_ohci_eof_timer = { }, }; -const VMStateDescription vmstate_ohci_state = { +static const VMStateDescription vmstate_ohci_state = { .name = "ohci-core", .version_id = 1, .minimum_version_id = 1, From 13a439ec4027a442a69a46d8d5305689460c2af2 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 7 Jul 2014 21:07:29 +0200 Subject: [PATCH 6/8] qga: Add missing 'static' attribute This fixes a warning from the static code analysis (smatch). Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- qga/commands-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 34ddba0531..8e6272c5a2 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -643,7 +643,7 @@ typedef enum { FSFREEZE_HOOK_FREEZE, } FsfreezeHookArg; -const char *fsfreeze_hook_arg_string[] = { +static const char *fsfreeze_hook_arg_string[] = { "thaw", "freeze", }; From 7a46d042e02e87157c13424df56dd06e9da77e89 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 7 Jul 2014 21:09:30 +0200 Subject: [PATCH 7/8] migration: Add missing 'static' attribute Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- block-migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block-migration.c b/block-migration.c index 25a03889f4..73cdd07e8c 100644 --- a/block-migration.c +++ b/block-migration.c @@ -861,7 +861,7 @@ static bool block_is_active(void *opaque) return block_mig_state.blk_enable == 1; } -SaveVMHandlers savevm_block_handlers = { +static SaveVMHandlers savevm_block_handlers = { .set_params = block_set_params, .save_live_setup = block_save_setup, .save_live_iterate = block_save_iterate, From 748bfb4eee8e699f3d2dd6a95820d1a9e57e4aa6 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 7 Jul 2014 21:03:38 +0200 Subject: [PATCH 8/8] tests: Add missing 'static' attributes (fix warnings from smatch) Smatch also complains about 0 used for pointers, so replace those by NULL in test-visitor-serialization.c, too. Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- tests/fdc-test.c | 2 +- tests/test-aio.c | 2 +- tests/test-qemu-opts.c | 2 +- tests/test-throttle.c | 8 ++++---- tests/test-visitor-serialization.c | 6 +++--- tests/test-vmstate.c | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/fdc-test.c b/tests/fdc-test.c index c8e1e7bd18..203074cdad 100644 --- a/tests/fdc-test.c +++ b/tests/fdc-test.c @@ -65,7 +65,7 @@ enum { DSKCHG = 0x80, }; -char test_image[] = "/tmp/qtest.XXXXXX"; +static char test_image[] = "/tmp/qtest.XXXXXX"; #define assert_bit_set(data, mask) g_assert_cmphex((data) & (mask), ==, (mask)) #define assert_bit_clear(data, mask) g_assert_cmphex((data) & (mask), ==, 0) diff --git a/tests/test-aio.c b/tests/test-aio.c index 4c40a4971f..f12b6e0ae8 100644 --- a/tests/test-aio.c +++ b/tests/test-aio.c @@ -15,7 +15,7 @@ #include "qemu/timer.h" #include "qemu/sockets.h" -AioContext *ctx; +static AioContext *ctx; typedef struct { EventNotifier e; diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c index 3653507f56..ca08ac523d 100644 --- a/tests/test-qemu-opts.c +++ b/tests/test-qemu-opts.c @@ -56,7 +56,7 @@ static QemuOptsList opts_list_02 = { }, }; -QemuOptsList opts_list_03 = { +static QemuOptsList opts_list_03 = { .name = "opts_list_03", .head = QTAILQ_HEAD_INITIALIZER(opts_list_03.head), .desc = { diff --git a/tests/test-throttle.c b/tests/test-throttle.c index 3de6ab80e0..000ae31af9 100644 --- a/tests/test-throttle.c +++ b/tests/test-throttle.c @@ -15,10 +15,10 @@ #include "block/aio.h" #include "qemu/throttle.h" -AioContext *ctx; -LeakyBucket bkt; -ThrottleConfig cfg; -ThrottleState ts; +static AioContext *ctx; +static LeakyBucket bkt; +static ThrottleConfig cfg; +static ThrottleState ts; /* useful function */ static bool double_cmp(double x, double y) diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c index 74d6481992..7ad1886397 100644 --- a/tests/test-visitor-serialization.c +++ b/tests/test-visitor-serialization.c @@ -372,8 +372,8 @@ static void test_primitive_lists(gconstpointer opaque) TestArgs *args = (TestArgs *) opaque; const SerializeOps *ops = args->ops; PrimitiveType *pt = args->test_data; - PrimitiveList pl = { .value = { 0 } }; - PrimitiveList pl_copy = { .value = { 0 } }; + PrimitiveList pl = { .value = { NULL } }; + PrimitiveList pl_copy = { .value = { NULL } }; PrimitiveList *pl_copy_ptr = &pl_copy; Error *err = NULL; void *serialize_data; @@ -771,7 +771,7 @@ static void test_nested_struct_list(gconstpointer opaque) g_free(args); } -PrimitiveType pt_values[] = { +static PrimitiveType pt_values[] = { /* string tests */ { .description = "string_empty", diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index a462335c4b..d72c64c90b 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -29,8 +29,8 @@ #include "migration/vmstate.h" #include "block/coroutine.h" -char temp_file[] = "/tmp/vmst.test.XXXXXX"; -int temp_fd; +static char temp_file[] = "/tmp/vmst.test.XXXXXX"; +static int temp_fd; /* Fake yield_until_fd_readable() implementation so we don't have to pull the * coroutine code as dependency.