1 | The following changes since commit 23895cbd82be95428e90168b12e925d0d3ca2f06: | 1 | The following changes since commit 7fe7fae8b48e3f9c647fd685e5155ebc8e6fb84d: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20201123.0' into staging (2020-11-23 18:51:13 +0000) | 3 | Merge remote-tracking branch 'remotes/dgilbert-gitlab/tags/pull-migration-20210609a' into staging (2021-06-09 16:40:21 +0100) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the git repository at: |
6 | 6 | ||
7 | https://github.com/jasowang/qemu.git tags/net-pull-request | 7 | https://github.com/jasowang/qemu.git tags/net-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 9925990d01a92564af55f6f69d0f5f59b47609b1: | 9 | for you to fetch changes up to 5a2d9929ac1f01a1e8ef2a3f56f69e6069863dad: |
10 | 10 | ||
11 | net: Use correct default-path macro for downscript (2020-11-24 10:40:17 +0800) | 11 | Fixed calculation error of pkt->header_size in fill_pkt_tcp_info() (2021-06-11 10:30:13 +0800) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | 14 | ||
15 | ---------------------------------------------------------------- | 15 | ---------------------------------------------------------------- |
16 | Keqian Zhu (1): | 16 | Jason Wang (4): |
17 | net: Use correct default-path macro for downscript | 17 | vhost-vdpa: skip ram device from the IOTLB mapping |
18 | vhost-vdpa: map virtqueue notification area if possible | ||
19 | vhost-vdpa: don't initialize backend_features | ||
20 | vhost-vdpa: remove the unused vhost_vdpa_get_acked_features() | ||
18 | 21 | ||
19 | Paolo Bonzini (1): | 22 | Paolo Bonzini (1): |
20 | net: do not exit on "netdev_add help" monitor command | 23 | netdev: add more commands to preconfig mode |
21 | 24 | ||
22 | Prasad J Pandit (1): | 25 | Rao, Lei (7): |
23 | hw/net/e1000e: advance desc_offset in case of null descriptor | 26 | Remove some duplicate trace code. |
27 | Fix the qemu crash when guest shutdown during checkpoint | ||
28 | Optimize the function of filter_send | ||
29 | Remove migrate_set_block_enabled in checkpoint | ||
30 | Add a function named packet_new_nocopy for COLO. | ||
31 | Add the function of colo_compare_cleanup | ||
32 | Fixed calculation error of pkt->header_size in fill_pkt_tcp_info() | ||
24 | 33 | ||
25 | Yuri Benditovich (1): | 34 | hmp-commands.hx | 2 + |
26 | net: purge queued rx packets on queue deletion | 35 | hw/virtio/vhost-vdpa.c | 100 +++++++++++++++++++++++++++++++++++------ |
27 | 36 | include/hw/virtio/vhost-vdpa.h | 6 +++ | |
28 | yuanjungong (1): | 37 | include/net/vhost-vdpa.h | 1 - |
29 | tap: fix a memory leak | 38 | migration/colo.c | 6 --- |
30 | 39 | migration/migration.c | 4 ++ | |
31 | hw/net/e1000e_core.c | 8 +++--- | 40 | net/colo-compare.c | 25 +++++------ |
32 | include/net/net.h | 1 + | 41 | net/colo-compare.h | 1 + |
33 | monitor/hmp-cmds.c | 6 ++++ | 42 | net/colo.c | 25 +++++++---- |
34 | net/net.c | 80 +++++++++++++++++++++++++++------------------------- | 43 | net/colo.h | 1 + |
35 | net/tap.c | 5 +++- | 44 | net/filter-mirror.c | 8 ++-- |
36 | 5 files changed, 57 insertions(+), 43 deletions(-) | 45 | net/filter-rewriter.c | 3 +- |
46 | net/net.c | 4 ++ | ||
47 | net/vhost-vdpa.c | 9 ---- | ||
48 | qapi/net.json | 6 ++- | ||
49 | softmmu/runstate.c | 1 + | ||
50 | 16 files changed, 143 insertions(+), 59 deletions(-) | ||
37 | 51 | ||
38 | 52 | ||
53 | |||
54 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | vDPA is not tie to any specific hardware, for safety and simplicity, | ||
2 | vhost-vDPA doesn't allow MMIO area to be mapped via IOTLB. Only the | ||
3 | doorbell could be mapped via mmap(). So this patch exclude skip the | ||
4 | ram device from the IOTLB mapping. | ||
1 | 5 | ||
6 | Reviewed-by: Si-Wei Liu <si-wei.liu@oracle.com> | ||
7 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
8 | --- | ||
9 | hw/virtio/vhost-vdpa.c | 12 ++---------- | ||
10 | 1 file changed, 2 insertions(+), 10 deletions(-) | ||
11 | |||
12 | diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/virtio/vhost-vdpa.c | ||
15 | +++ b/hw/virtio/vhost-vdpa.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section) | ||
17 | { | ||
18 | return (!memory_region_is_ram(section->mr) && | ||
19 | !memory_region_is_iommu(section->mr)) || | ||
20 | + /* vhost-vDPA doesn't allow MMIO to be mapped */ | ||
21 | + memory_region_is_ram_device(section->mr) || | ||
22 | /* | ||
23 | * Sizing an enabled 64-bit BAR can cause spurious mappings to | ||
24 | * addresses in the upper part of the 64-bit address space. These | ||
25 | @@ -XXX,XX +XXX,XX @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, | ||
26 | vaddr, section->readonly); | ||
27 | if (ret) { | ||
28 | error_report("vhost vdpa map fail!"); | ||
29 | - if (memory_region_is_ram_device(section->mr)) { | ||
30 | - /* Allow unexpected mappings not to be fatal for RAM devices */ | ||
31 | - error_report("map ram fail!"); | ||
32 | - return ; | ||
33 | - } | ||
34 | goto fail; | ||
35 | } | ||
36 | |||
37 | return; | ||
38 | |||
39 | fail: | ||
40 | - if (memory_region_is_ram_device(section->mr)) { | ||
41 | - error_report("failed to vdpa_dma_map. pci p2p may not work"); | ||
42 | - return; | ||
43 | - | ||
44 | - } | ||
45 | /* | ||
46 | * On the initfn path, store the first error in the container so we | ||
47 | * can gracefully fail. Runtime, there's not much we can do other | ||
48 | -- | ||
49 | 2.7.4 | ||
50 | |||
51 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | This patch implements the vq notification mapping support for | ||
2 | vhost-vDPA. This is simply done by using mmap()/munmap() for the | ||
3 | vhost-vDPA fd during device start/stop. For the device without | ||
4 | notification mapping support, we fall back to eventfd based | ||
5 | notification gracefully. | ||
1 | 6 | ||
7 | Reviewed-by: Si-Wei Liu <si-wei.liu@oracle.com> | ||
8 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
9 | --- | ||
10 | hw/virtio/vhost-vdpa.c | 85 ++++++++++++++++++++++++++++++++++++++++++ | ||
11 | include/hw/virtio/vhost-vdpa.h | 6 +++ | ||
12 | 2 files changed, 91 insertions(+) | ||
13 | |||
14 | diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/virtio/vhost-vdpa.c | ||
17 | +++ b/hw/virtio/vhost-vdpa.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque) | ||
19 | return 0; | ||
20 | } | ||
21 | |||
22 | +static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev, | ||
23 | + int queue_index) | ||
24 | +{ | ||
25 | + size_t page_size = qemu_real_host_page_size; | ||
26 | + struct vhost_vdpa *v = dev->opaque; | ||
27 | + VirtIODevice *vdev = dev->vdev; | ||
28 | + VhostVDPAHostNotifier *n; | ||
29 | + | ||
30 | + n = &v->notifier[queue_index]; | ||
31 | + | ||
32 | + if (n->addr) { | ||
33 | + virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, false); | ||
34 | + object_unparent(OBJECT(&n->mr)); | ||
35 | + munmap(n->addr, page_size); | ||
36 | + n->addr = NULL; | ||
37 | + } | ||
38 | +} | ||
39 | + | ||
40 | +static void vhost_vdpa_host_notifiers_uninit(struct vhost_dev *dev, int n) | ||
41 | +{ | ||
42 | + int i; | ||
43 | + | ||
44 | + for (i = 0; i < n; i++) { | ||
45 | + vhost_vdpa_host_notifier_uninit(dev, i); | ||
46 | + } | ||
47 | +} | ||
48 | + | ||
49 | +static int vhost_vdpa_host_notifier_init(struct vhost_dev *dev, int queue_index) | ||
50 | +{ | ||
51 | + size_t page_size = qemu_real_host_page_size; | ||
52 | + struct vhost_vdpa *v = dev->opaque; | ||
53 | + VirtIODevice *vdev = dev->vdev; | ||
54 | + VhostVDPAHostNotifier *n; | ||
55 | + int fd = v->device_fd; | ||
56 | + void *addr; | ||
57 | + char *name; | ||
58 | + | ||
59 | + vhost_vdpa_host_notifier_uninit(dev, queue_index); | ||
60 | + | ||
61 | + n = &v->notifier[queue_index]; | ||
62 | + | ||
63 | + addr = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, fd, | ||
64 | + queue_index * page_size); | ||
65 | + if (addr == MAP_FAILED) { | ||
66 | + goto err; | ||
67 | + } | ||
68 | + | ||
69 | + name = g_strdup_printf("vhost-vdpa/host-notifier@%p mmaps[%d]", | ||
70 | + v, queue_index); | ||
71 | + memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name, | ||
72 | + page_size, addr); | ||
73 | + g_free(name); | ||
74 | + | ||
75 | + if (virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, true)) { | ||
76 | + munmap(addr, page_size); | ||
77 | + goto err; | ||
78 | + } | ||
79 | + n->addr = addr; | ||
80 | + | ||
81 | + return 0; | ||
82 | + | ||
83 | +err: | ||
84 | + return -1; | ||
85 | +} | ||
86 | + | ||
87 | +static void vhost_vdpa_host_notifiers_init(struct vhost_dev *dev) | ||
88 | +{ | ||
89 | + int i; | ||
90 | + | ||
91 | + for (i = dev->vq_index; i < dev->vq_index + dev->nvqs; i++) { | ||
92 | + if (vhost_vdpa_host_notifier_init(dev, i)) { | ||
93 | + goto err; | ||
94 | + } | ||
95 | + } | ||
96 | + | ||
97 | + return; | ||
98 | + | ||
99 | +err: | ||
100 | + vhost_vdpa_host_notifiers_uninit(dev, i); | ||
101 | + return; | ||
102 | +} | ||
103 | + | ||
104 | static int vhost_vdpa_cleanup(struct vhost_dev *dev) | ||
105 | { | ||
106 | struct vhost_vdpa *v; | ||
107 | assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_VDPA); | ||
108 | v = dev->opaque; | ||
109 | trace_vhost_vdpa_cleanup(dev, v); | ||
110 | + vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); | ||
111 | memory_listener_unregister(&v->listener); | ||
112 | |||
113 | dev->opaque = NULL; | ||
114 | @@ -XXX,XX +XXX,XX @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) | ||
115 | if (started) { | ||
116 | uint8_t status = 0; | ||
117 | memory_listener_register(&v->listener, &address_space_memory); | ||
118 | + vhost_vdpa_host_notifiers_init(dev); | ||
119 | vhost_vdpa_set_vring_ready(dev); | ||
120 | vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); | ||
121 | vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &status); | ||
122 | @@ -XXX,XX +XXX,XX @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) | ||
123 | vhost_vdpa_reset_device(dev); | ||
124 | vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | | ||
125 | VIRTIO_CONFIG_S_DRIVER); | ||
126 | + vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); | ||
127 | memory_listener_unregister(&v->listener); | ||
128 | |||
129 | return 0; | ||
130 | diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h | ||
131 | index XXXXXXX..XXXXXXX 100644 | ||
132 | --- a/include/hw/virtio/vhost-vdpa.h | ||
133 | +++ b/include/hw/virtio/vhost-vdpa.h | ||
134 | @@ -XXX,XX +XXX,XX @@ | ||
135 | |||
136 | #include "hw/virtio/virtio.h" | ||
137 | |||
138 | +typedef struct VhostVDPAHostNotifier { | ||
139 | + MemoryRegion mr; | ||
140 | + void *addr; | ||
141 | +} VhostVDPAHostNotifier; | ||
142 | + | ||
143 | typedef struct vhost_vdpa { | ||
144 | int device_fd; | ||
145 | uint32_t msg_type; | ||
146 | MemoryListener listener; | ||
147 | struct vhost_dev *dev; | ||
148 | + VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX]; | ||
149 | } VhostVDPA; | ||
150 | |||
151 | #endif | ||
152 | -- | ||
153 | 2.7.4 | ||
154 | |||
155 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We used to initialize backend_features during vhost_vdpa_init() | ||
2 | regardless whether or not it was supported by vhost. This will lead | ||
3 | the unsupported features like VIRTIO_F_IN_ORDER to be included and set | ||
4 | to the vhost-vdpa during vhost_dev_start. Because the | ||
5 | VIRTIO_F_IN_ORDER is not supported by vhost-vdpa so it won't be | ||
6 | advertised to guest which will break the datapath. | ||
1 | 7 | ||
8 | Fix this by not initializing the backend_features, so the | ||
9 | acked_features could be built only from guest features via | ||
10 | vhost_net_ack_features(). | ||
11 | |||
12 | Fixes: 108a64818e69b ("vhost-vdpa: introduce vhost-vdpa backend") | ||
13 | Cc: qemu-stable@nongnu.org | ||
14 | Cc: Gautam Dawar <gdawar@xilinx.com> | ||
15 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
16 | --- | ||
17 | hw/virtio/vhost-vdpa.c | 3 --- | ||
18 | 1 file changed, 3 deletions(-) | ||
19 | |||
20 | diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/virtio/vhost-vdpa.c | ||
23 | +++ b/hw/virtio/vhost-vdpa.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static void vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status) | ||
25 | static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque) | ||
26 | { | ||
27 | struct vhost_vdpa *v; | ||
28 | - uint64_t features; | ||
29 | assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_VDPA); | ||
30 | trace_vhost_vdpa_init(dev, opaque); | ||
31 | |||
32 | v = opaque; | ||
33 | v->dev = dev; | ||
34 | dev->opaque = opaque ; | ||
35 | - vhost_vdpa_call(dev, VHOST_GET_FEATURES, &features); | ||
36 | - dev->backend_features = features; | ||
37 | v->listener = vhost_vdpa_memory_listener; | ||
38 | v->msg_type = VHOST_IOTLB_MSG_V2; | ||
39 | |||
40 | -- | ||
41 | 2.7.4 | ||
42 | |||
43 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | No user for this helper, let's remove it. | ||
1 | 2 | ||
3 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
4 | --- | ||
5 | include/net/vhost-vdpa.h | 1 - | ||
6 | net/vhost-vdpa.c | 9 --------- | ||
7 | 2 files changed, 10 deletions(-) | ||
8 | |||
9 | diff --git a/include/net/vhost-vdpa.h b/include/net/vhost-vdpa.h | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/include/net/vhost-vdpa.h | ||
12 | +++ b/include/net/vhost-vdpa.h | ||
13 | @@ -XXX,XX +XXX,XX @@ | ||
14 | #define TYPE_VHOST_VDPA "vhost-vdpa" | ||
15 | |||
16 | struct vhost_net *vhost_vdpa_get_vhost_net(NetClientState *nc); | ||
17 | -uint64_t vhost_vdpa_get_acked_features(NetClientState *nc); | ||
18 | |||
19 | extern const int vdpa_feature_bits[]; | ||
20 | |||
21 | diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/net/vhost-vdpa.c | ||
24 | +++ b/net/vhost-vdpa.c | ||
25 | @@ -XXX,XX +XXX,XX @@ VHostNetState *vhost_vdpa_get_vhost_net(NetClientState *nc) | ||
26 | return s->vhost_net; | ||
27 | } | ||
28 | |||
29 | -uint64_t vhost_vdpa_get_acked_features(NetClientState *nc) | ||
30 | -{ | ||
31 | - VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); | ||
32 | - assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA); | ||
33 | - s->acked_features = vhost_net_get_acked_features(s->vhost_net); | ||
34 | - | ||
35 | - return s->acked_features; | ||
36 | -} | ||
37 | - | ||
38 | static int vhost_vdpa_net_check_device_id(struct vhost_net *net) | ||
39 | { | ||
40 | uint32_t device_id; | ||
41 | -- | ||
42 | 2.7.4 | ||
43 | |||
44 | diff view generated by jsdifflib |
1 | From: Paolo Bonzini <pbonzini@redhat.com> | 1 | From: Paolo Bonzini <pbonzini@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | "netdev_add help" is causing QEMU to exit because the code that | 3 | Creating and destroying network backend does not require a fully |
4 | invokes show_netdevs is shared between CLI and HMP processing. | 4 | constructed machine. Allow the related monitor commands to run before |
5 | Move the check to the callers so that exit(0) remains only | 5 | machine initialization has concluded. |
6 | in the CLI flow. | ||
7 | |||
8 | "netdev_add help" is not fixed by this patch; that is left for | ||
9 | later work. | ||
10 | 6 | ||
11 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | 7 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
8 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
12 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 9 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
13 | --- | 10 | --- |
14 | include/net/net.h | 1 + | 11 | hmp-commands.hx | 2 ++ |
15 | monitor/hmp-cmds.c | 6 +++++ | 12 | qapi/net.json | 6 ++++-- |
16 | net/net.c | 68 +++++++++++++++++++++++++++--------------------------- | 13 | 2 files changed, 6 insertions(+), 2 deletions(-) |
17 | 3 files changed, 41 insertions(+), 34 deletions(-) | ||
18 | 14 | ||
19 | diff --git a/include/net/net.h b/include/net/net.h | 15 | diff --git a/hmp-commands.hx b/hmp-commands.hx |
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/net/net.h | 17 | --- a/hmp-commands.hx |
22 | +++ b/include/net/net.h | 18 | +++ b/hmp-commands.hx |
23 | @@ -XXX,XX +XXX,XX @@ extern const char *host_net_devices[]; | 19 | @@ -XXX,XX +XXX,XX @@ ERST |
24 | 20 | .help = "add host network device", | |
25 | /* from net.c */ | 21 | .cmd = hmp_netdev_add, |
26 | int net_client_parse(QemuOptsList *opts_list, const char *str); | 22 | .command_completion = netdev_add_completion, |
27 | +void show_netdevs(void); | 23 | + .flags = "p", |
28 | int net_init_clients(Error **errp); | 24 | }, |
29 | void net_check_clients(void); | 25 | |
30 | void net_cleanup(void); | 26 | SRST |
31 | diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c | 27 | @@ -XXX,XX +XXX,XX @@ ERST |
28 | .help = "remove host network device", | ||
29 | .cmd = hmp_netdev_del, | ||
30 | .command_completion = netdev_del_completion, | ||
31 | + .flags = "p", | ||
32 | }, | ||
33 | |||
34 | SRST | ||
35 | diff --git a/qapi/net.json b/qapi/net.json | ||
32 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/monitor/hmp-cmds.c | 37 | --- a/qapi/net.json |
34 | +++ b/monitor/hmp-cmds.c | 38 | +++ b/qapi/net.json |
35 | @@ -XXX,XX +XXX,XX @@ | 39 | @@ -XXX,XX +XXX,XX @@ |
36 | #include "qemu/option.h" | 40 | # <- { "return": {} } |
37 | #include "qemu/timer.h" | 41 | # |
38 | #include "qemu/sockets.h" | 42 | ## |
39 | +#include "qemu/help_option.h" | 43 | -{ 'command': 'netdev_add', 'data': 'Netdev', 'boxed': true } |
40 | #include "monitor/monitor-internal.h" | 44 | +{ 'command': 'netdev_add', 'data': 'Netdev', 'boxed': true, |
41 | #include "qapi/error.h" | 45 | + 'allow-preconfig': true } |
42 | #include "qapi/clone-visitor.h" | 46 | |
43 | @@ -XXX,XX +XXX,XX @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict) | 47 | ## |
44 | { | 48 | # @netdev_del: |
45 | Error *err = NULL; | ||
46 | QemuOpts *opts; | ||
47 | + const char *type = qdict_get_try_str(qdict, "type"); | ||
48 | |||
49 | + if (type && is_help_option(type)) { | ||
50 | + show_netdevs(); | ||
51 | + return; | ||
52 | + } | ||
53 | opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err); | ||
54 | if (err) { | ||
55 | goto out; | ||
56 | diff --git a/net/net.c b/net/net.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/net/net.c | ||
59 | +++ b/net/net.c | ||
60 | @@ -XXX,XX +XXX,XX @@ | 49 | @@ -XXX,XX +XXX,XX @@ |
61 | #include "qemu/config-file.h" | 50 | # <- { "return": {} } |
62 | #include "qemu/ctype.h" | 51 | # |
63 | #include "qemu/iov.h" | 52 | ## |
64 | +#include "qemu/qemu-print.h" | 53 | -{ 'command': 'netdev_del', 'data': {'id': 'str'} } |
65 | #include "qemu/main-loop.h" | 54 | +{ 'command': 'netdev_del', 'data': {'id': 'str'}, |
66 | #include "qemu/option.h" | 55 | + 'allow-preconfig': true } |
67 | #include "qapi/error.h" | 56 | |
68 | @@ -XXX,XX +XXX,XX @@ static int net_client_init1(const Netdev *netdev, bool is_netdev, Error **errp) | 57 | ## |
69 | return 0; | 58 | # @NetLegacyNicOptions: |
70 | } | ||
71 | |||
72 | -static void show_netdevs(void) | ||
73 | +void show_netdevs(void) | ||
74 | { | ||
75 | int idx; | ||
76 | const char *available_netdevs[] = { | ||
77 | @@ -XXX,XX +XXX,XX @@ static void show_netdevs(void) | ||
78 | #endif | ||
79 | }; | ||
80 | |||
81 | - printf("Available netdev backend types:\n"); | ||
82 | + qemu_printf("Available netdev backend types:\n"); | ||
83 | for (idx = 0; idx < ARRAY_SIZE(available_netdevs); idx++) { | ||
84 | - puts(available_netdevs[idx]); | ||
85 | + qemu_printf("%s\n", available_netdevs[idx]); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @@ -XXX,XX +XXX,XX @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) | ||
90 | int ret = -1; | ||
91 | Visitor *v = opts_visitor_new(opts); | ||
92 | |||
93 | - const char *type = qemu_opt_get(opts, "type"); | ||
94 | - | ||
95 | - if (is_netdev && type && is_help_option(type)) { | ||
96 | - show_netdevs(); | ||
97 | - exit(0); | ||
98 | - } else { | ||
99 | - /* Parse convenience option format ip6-net=fec0::0[/64] */ | ||
100 | - const char *ip6_net = qemu_opt_get(opts, "ipv6-net"); | ||
101 | + /* Parse convenience option format ip6-net=fec0::0[/64] */ | ||
102 | + const char *ip6_net = qemu_opt_get(opts, "ipv6-net"); | ||
103 | |||
104 | - if (ip6_net) { | ||
105 | - char *prefix_addr; | ||
106 | - unsigned long prefix_len = 64; /* Default 64bit prefix length. */ | ||
107 | + if (ip6_net) { | ||
108 | + char *prefix_addr; | ||
109 | + unsigned long prefix_len = 64; /* Default 64bit prefix length. */ | ||
110 | |||
111 | - substrings = g_strsplit(ip6_net, "/", 2); | ||
112 | - if (!substrings || !substrings[0]) { | ||
113 | - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net", | ||
114 | - "a valid IPv6 prefix"); | ||
115 | - goto out; | ||
116 | - } | ||
117 | + substrings = g_strsplit(ip6_net, "/", 2); | ||
118 | + if (!substrings || !substrings[0]) { | ||
119 | + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net", | ||
120 | + "a valid IPv6 prefix"); | ||
121 | + goto out; | ||
122 | + } | ||
123 | |||
124 | - prefix_addr = substrings[0]; | ||
125 | + prefix_addr = substrings[0]; | ||
126 | |||
127 | - /* Handle user-specified prefix length. */ | ||
128 | - if (substrings[1] && | ||
129 | - qemu_strtoul(substrings[1], NULL, 10, &prefix_len)) | ||
130 | - { | ||
131 | - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, | ||
132 | - "ipv6-prefixlen", "a number"); | ||
133 | - goto out; | ||
134 | - } | ||
135 | - | ||
136 | - qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort); | ||
137 | - qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len, | ||
138 | - &error_abort); | ||
139 | - qemu_opt_unset(opts, "ipv6-net"); | ||
140 | + /* Handle user-specified prefix length. */ | ||
141 | + if (substrings[1] && | ||
142 | + qemu_strtoul(substrings[1], NULL, 10, &prefix_len)) | ||
143 | + { | ||
144 | + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, | ||
145 | + "ipv6-prefixlen", "a number"); | ||
146 | + goto out; | ||
147 | } | ||
148 | + | ||
149 | + qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort); | ||
150 | + qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len, | ||
151 | + &error_abort); | ||
152 | + qemu_opt_unset(opts, "ipv6-net"); | ||
153 | } | ||
154 | |||
155 | /* Create an ID for -net if the user did not specify one */ | ||
156 | @@ -XXX,XX +XXX,XX @@ static int net_init_client(void *dummy, QemuOpts *opts, Error **errp) | ||
157 | |||
158 | static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp) | ||
159 | { | ||
160 | + const char *type = qemu_opt_get(opts, "type"); | ||
161 | + | ||
162 | + if (type && is_help_option(type)) { | ||
163 | + show_netdevs(); | ||
164 | + exit(0); | ||
165 | + } | ||
166 | return net_client_init(opts, true, errp); | ||
167 | } | ||
168 | |||
169 | -- | 59 | -- |
170 | 2.7.4 | 60 | 2.7.4 |
171 | 61 | ||
172 | 62 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: "Rao, Lei" <lei.rao@intel.com> | ||
1 | 2 | ||
3 | There is the same trace code in the colo_compare_packet_payload. | ||
4 | |||
5 | Signed-off-by: Lei Rao <lei.rao@intel.com> | ||
6 | Reviewed-by: Li Zhijian <lizhijian@fujitsu.com> | ||
7 | Reviewed-by: Zhang Chen <chen.zhang@intel.com> | ||
8 | Reviewed-by: Lukas Straub <lukasstraub2@web.de> | ||
9 | Tested-by: Lukas Straub <lukasstraub2@web.de> | ||
10 | Signed-off-by: Zhang Chen <chen.zhang@intel.com> | ||
11 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
12 | --- | ||
13 | net/colo-compare.c | 13 ------------- | ||
14 | 1 file changed, 13 deletions(-) | ||
15 | |||
16 | diff --git a/net/colo-compare.c b/net/colo-compare.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/net/colo-compare.c | ||
19 | +++ b/net/colo-compare.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static int colo_packet_compare_other(Packet *spkt, Packet *ppkt) | ||
21 | uint16_t offset = ppkt->vnet_hdr_len; | ||
22 | |||
23 | trace_colo_compare_main("compare other"); | ||
24 | - if (trace_event_get_state_backends(TRACE_COLO_COMPARE_IP_INFO)) { | ||
25 | - char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20]; | ||
26 | - | ||
27 | - strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src)); | ||
28 | - strcpy(pri_ip_dst, inet_ntoa(ppkt->ip->ip_dst)); | ||
29 | - strcpy(sec_ip_src, inet_ntoa(spkt->ip->ip_src)); | ||
30 | - strcpy(sec_ip_dst, inet_ntoa(spkt->ip->ip_dst)); | ||
31 | - | ||
32 | - trace_colo_compare_ip_info(ppkt->size, pri_ip_src, | ||
33 | - pri_ip_dst, spkt->size, | ||
34 | - sec_ip_src, sec_ip_dst); | ||
35 | - } | ||
36 | - | ||
37 | if (ppkt->size != spkt->size) { | ||
38 | trace_colo_compare_main("Other: payload size of packets are different"); | ||
39 | return -1; | ||
40 | -- | ||
41 | 2.7.4 | ||
42 | |||
43 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: "Rao, Lei" <lei.rao@intel.com> | ||
1 | 2 | ||
3 | This patch fixes the following: | ||
4 | qemu-system-x86_64: invalid runstate transition: 'colo' ->'shutdown' | ||
5 | Aborted (core dumped) | ||
6 | |||
7 | Signed-off-by: Lei Rao <lei.rao@intel.com> | ||
8 | Reviewed-by: Li Zhijian <lizhijian@fujitsu.com> | ||
9 | Reviewed-by: Zhang Chen <chen.zhang@intel.com> | ||
10 | Reviewed-by: Lukas Straub <lukasstraub2@web.de> | ||
11 | Tested-by: Lukas Straub <lukasstraub2@web.de> | ||
12 | Signed-off-by: Zhang Chen <chen.zhang@intel.com> | ||
13 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
14 | --- | ||
15 | softmmu/runstate.c | 1 + | ||
16 | 1 file changed, 1 insertion(+) | ||
17 | |||
18 | diff --git a/softmmu/runstate.c b/softmmu/runstate.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/softmmu/runstate.c | ||
21 | +++ b/softmmu/runstate.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static const RunStateTransition runstate_transitions_def[] = { | ||
23 | { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH }, | ||
24 | |||
25 | { RUN_STATE_COLO, RUN_STATE_RUNNING }, | ||
26 | + { RUN_STATE_COLO, RUN_STATE_SHUTDOWN}, | ||
27 | |||
28 | { RUN_STATE_RUNNING, RUN_STATE_DEBUG }, | ||
29 | { RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR }, | ||
30 | -- | ||
31 | 2.7.4 | ||
32 | |||
33 | diff view generated by jsdifflib |
1 | From: Prasad J Pandit <pjp@fedoraproject.org> | 1 | From: "Rao, Lei" <lei.rao@intel.com> |
---|---|---|---|
2 | 2 | ||
3 | While receiving packets via e1000e_write_packet_to_guest() routine, | 3 | The iov_size has been calculated in filter_send(). we can directly |
4 | 'desc_offset' is advanced only when RX descriptor is processed. And | 4 | return the size.In this way, this is no need to repeat calculations |
5 | RX descriptor is not processed if it has NULL buffer address. | 5 | in filter_redirector_receive_iov(); |
6 | This may lead to an infinite loop condition. Increament 'desc_offset' | ||
7 | to process next descriptor in the ring to avoid infinite loop. | ||
8 | 6 | ||
9 | Reported-by: Cheol-woo Myung <330cjfdn@gmail.com> | 7 | Signed-off-by: Lei Rao <lei.rao@intel.com> |
10 | Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> | 8 | Reviewed-by: Li Zhijian <lizhijian@fujitsu.com> |
9 | Reviewed-by: Zhang Chen <chen.zhang@intel.com> | ||
10 | Reviewed-by: Lukas Straub <lukasstraub2@web.de> | ||
11 | Tested-by: Lukas Straub <lukasstraub2@web.de> | ||
12 | Signed-off-by: Zhang Chen <chen.zhang@intel.com> | ||
11 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 13 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
12 | --- | 14 | --- |
13 | hw/net/e1000e_core.c | 8 ++++---- | 15 | net/filter-mirror.c | 8 ++++---- |
14 | 1 file changed, 4 insertions(+), 4 deletions(-) | 16 | 1 file changed, 4 insertions(+), 4 deletions(-) |
15 | 17 | ||
16 | diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c | 18 | diff --git a/net/filter-mirror.c b/net/filter-mirror.c |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/net/e1000e_core.c | 20 | --- a/net/filter-mirror.c |
19 | +++ b/hw/net/e1000e_core.c | 21 | +++ b/net/filter-mirror.c |
20 | @@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt, | 22 | @@ -XXX,XX +XXX,XX @@ static int filter_send(MirrorState *s, |
21 | (const char *) &fcs_pad, e1000x_fcs_len(core->mac)); | 23 | goto err; |
22 | } | 24 | } |
23 | } | 25 | |
24 | - desc_offset += desc_size; | 26 | - return 0; |
25 | - if (desc_offset >= total_size) { | 27 | + return size; |
26 | - is_last = true; | 28 | |
27 | - } | 29 | err: |
28 | } else { /* as per intel docs; skip descriptors with null buf addr */ | 30 | return ret < 0 ? ret : -EIO; |
29 | trace_e1000e_rx_null_descriptor(); | 31 | @@ -XXX,XX +XXX,XX @@ static ssize_t filter_mirror_receive_iov(NetFilterState *nf, |
32 | int ret; | ||
33 | |||
34 | ret = filter_send(s, iov, iovcnt); | ||
35 | - if (ret) { | ||
36 | + if (ret < 0) { | ||
37 | error_report("filter mirror send failed(%s)", strerror(-ret)); | ||
38 | } | ||
39 | |||
40 | @@ -XXX,XX +XXX,XX @@ static ssize_t filter_redirector_receive_iov(NetFilterState *nf, | ||
41 | |||
42 | if (qemu_chr_fe_backend_connected(&s->chr_out)) { | ||
43 | ret = filter_send(s, iov, iovcnt); | ||
44 | - if (ret) { | ||
45 | + if (ret < 0) { | ||
46 | error_report("filter redirector send failed(%s)", strerror(-ret)); | ||
30 | } | 47 | } |
31 | + desc_offset += desc_size; | 48 | - return iov_size(iov, iovcnt); |
32 | + if (desc_offset >= total_size) { | 49 | + return ret; |
33 | + is_last = true; | 50 | } else { |
34 | + } | 51 | return 0; |
35 | 52 | } | |
36 | e1000e_write_rx_descr(core, desc, is_last ? core->rx_pkt : NULL, | ||
37 | rss_info, do_ps ? ps_hdr_len : 0, &bastate.written); | ||
38 | -- | 53 | -- |
39 | 2.7.4 | 54 | 2.7.4 |
40 | 55 | ||
41 | 56 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: "Rao, Lei" <lei.rao@intel.com> | ||
1 | 2 | ||
3 | We can detect disk migration in migrate_prepare, if disk migration | ||
4 | is enabled in COLO mode, we can directly report an error.and there | ||
5 | is no need to disable block migration at every checkpoint. | ||
6 | |||
7 | Signed-off-by: Lei Rao <lei.rao@intel.com> | ||
8 | Signed-off-by: Zhang Chen <chen.zhang@intel.com> | ||
9 | Reviewed-by: Li Zhijian <lizhijian@fujitsu.com> | ||
10 | Reviewed-by: Zhang Chen <chen.zhang@intel.com> | ||
11 | Reviewed-by: Lukas Straub <lukasstraub2@web.de> | ||
12 | Tested-by: Lukas Straub <lukasstraub2@web.de> | ||
13 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
14 | --- | ||
15 | migration/colo.c | 6 ------ | ||
16 | migration/migration.c | 4 ++++ | ||
17 | 2 files changed, 4 insertions(+), 6 deletions(-) | ||
18 | |||
19 | diff --git a/migration/colo.c b/migration/colo.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/migration/colo.c | ||
22 | +++ b/migration/colo.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static int colo_do_checkpoint_transaction(MigrationState *s, | ||
24 | if (failover_get_state() != FAILOVER_STATUS_NONE) { | ||
25 | goto out; | ||
26 | } | ||
27 | - | ||
28 | - /* Disable block migration */ | ||
29 | - migrate_set_block_enabled(false, &local_err); | ||
30 | - if (local_err) { | ||
31 | - goto out; | ||
32 | - } | ||
33 | qemu_mutex_lock_iothread(); | ||
34 | |||
35 | #ifdef CONFIG_REPLICATION | ||
36 | diff --git a/migration/migration.c b/migration/migration.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/migration/migration.c | ||
39 | +++ b/migration/migration.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, | ||
41 | } | ||
42 | |||
43 | if (blk || blk_inc) { | ||
44 | + if (migrate_colo_enabled()) { | ||
45 | + error_setg(errp, "No disk migration is required in COLO mode"); | ||
46 | + return false; | ||
47 | + } | ||
48 | if (migrate_use_block() || migrate_use_block_incremental()) { | ||
49 | error_setg(errp, "Command options are incompatible with " | ||
50 | "current migration capabilities"); | ||
51 | -- | ||
52 | 2.7.4 | ||
53 | |||
54 | diff view generated by jsdifflib |
1 | From: Keqian Zhu <zhukeqian1@huawei.com> | 1 | From: "Rao, Lei" <lei.rao@intel.com> |
---|---|---|---|
2 | 2 | ||
3 | Fixes: 63c4db4c2e6d (net: relocate paths to helpers and scripts) | 3 | Use the packet_new_nocopy instead of packet_new in the |
4 | Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com> | 4 | filter-rewriter module. There will be one less memory |
5 | copy in the processing of each network packet. | ||
6 | |||
7 | Signed-off-by: Lei Rao <lei.rao@intel.com> | ||
8 | Signed-off-by: Zhang Chen <chen.zhang@intel.com> | ||
9 | Reviewed-by: Zhang Chen <chen.zhang@intel.com> | ||
5 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 10 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
6 | --- | 11 | --- |
7 | net/tap.c | 3 ++- | 12 | net/colo.c | 25 +++++++++++++++++-------- |
8 | 1 file changed, 2 insertions(+), 1 deletion(-) | 13 | net/colo.h | 1 + |
14 | net/filter-rewriter.c | 3 +-- | ||
15 | 3 files changed, 19 insertions(+), 10 deletions(-) | ||
9 | 16 | ||
10 | diff --git a/net/tap.c b/net/tap.c | 17 | diff --git a/net/colo.c b/net/colo.c |
11 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/net/tap.c | 19 | --- a/net/colo.c |
13 | +++ b/net/tap.c | 20 | +++ b/net/colo.c |
14 | @@ -XXX,XX +XXX,XX @@ free_fail: | 21 | @@ -XXX,XX +XXX,XX @@ void connection_destroy(void *opaque) |
15 | script = default_script = get_relocated_path(DEFAULT_NETWORK_SCRIPT); | 22 | |
16 | } | 23 | Packet *packet_new(const void *data, int size, int vnet_hdr_len) |
17 | if (!downscript) { | 24 | { |
18 | - downscript = default_downscript = get_relocated_path(DEFAULT_NETWORK_SCRIPT); | 25 | - Packet *pkt = g_slice_new(Packet); |
19 | + downscript = default_downscript = | 26 | + Packet *pkt = g_slice_new0(Packet); |
20 | + get_relocated_path(DEFAULT_NETWORK_DOWN_SCRIPT); | 27 | |
21 | } | 28 | pkt->data = g_memdup(data, size); |
22 | 29 | pkt->size = size; | |
23 | if (tap->has_ifname) { | 30 | pkt->creation_ms = qemu_clock_get_ms(QEMU_CLOCK_HOST); |
31 | pkt->vnet_hdr_len = vnet_hdr_len; | ||
32 | - pkt->tcp_seq = 0; | ||
33 | - pkt->tcp_ack = 0; | ||
34 | - pkt->seq_end = 0; | ||
35 | - pkt->header_size = 0; | ||
36 | - pkt->payload_size = 0; | ||
37 | - pkt->offset = 0; | ||
38 | - pkt->flags = 0; | ||
39 | + | ||
40 | + return pkt; | ||
41 | +} | ||
42 | + | ||
43 | +/* | ||
44 | + * packet_new_nocopy will not copy data, so the caller can't release | ||
45 | + * the data. And it will be released in packet_destroy. | ||
46 | + */ | ||
47 | +Packet *packet_new_nocopy(void *data, int size, int vnet_hdr_len) | ||
48 | +{ | ||
49 | + Packet *pkt = g_slice_new0(Packet); | ||
50 | + | ||
51 | + pkt->data = data; | ||
52 | + pkt->size = size; | ||
53 | + pkt->creation_ms = qemu_clock_get_ms(QEMU_CLOCK_HOST); | ||
54 | + pkt->vnet_hdr_len = vnet_hdr_len; | ||
55 | |||
56 | return pkt; | ||
57 | } | ||
58 | diff --git a/net/colo.h b/net/colo.h | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/net/colo.h | ||
61 | +++ b/net/colo.h | ||
62 | @@ -XXX,XX +XXX,XX @@ bool connection_has_tracked(GHashTable *connection_track_table, | ||
63 | ConnectionKey *key); | ||
64 | void connection_hashtable_reset(GHashTable *connection_track_table); | ||
65 | Packet *packet_new(const void *data, int size, int vnet_hdr_len); | ||
66 | +Packet *packet_new_nocopy(void *data, int size, int vnet_hdr_len); | ||
67 | void packet_destroy(void *opaque, void *user_data); | ||
68 | void packet_destroy_partial(void *opaque, void *user_data); | ||
69 | |||
70 | diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/net/filter-rewriter.c | ||
73 | +++ b/net/filter-rewriter.c | ||
74 | @@ -XXX,XX +XXX,XX @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf, | ||
75 | vnet_hdr_len = nf->netdev->vnet_hdr_len; | ||
76 | } | ||
77 | |||
78 | - pkt = packet_new(buf, size, vnet_hdr_len); | ||
79 | - g_free(buf); | ||
80 | + pkt = packet_new_nocopy(buf, size, vnet_hdr_len); | ||
81 | |||
82 | /* | ||
83 | * if we get tcp packet | ||
24 | -- | 84 | -- |
25 | 2.7.4 | 85 | 2.7.4 |
26 | 86 | ||
27 | 87 | diff view generated by jsdifflib |
1 | From: Yuri Benditovich <yuri.benditovich@daynix.com> | 1 | From: "Rao, Lei" <lei.rao@intel.com> |
---|---|---|---|
2 | 2 | ||
3 | https://bugzilla.redhat.com/show_bug.cgi?id=1829272 | 3 | This patch fixes the following: |
4 | When deleting queue pair, purge pending RX packets if any. | 4 | #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 |
5 | Example of problematic flow: | 5 | #1 0x00007f6ae4559859 in __GI_abort () at abort.c:79 |
6 | 1. Bring up q35 VM with tap (vhost off) and virtio-net or e1000e | 6 | #2 0x0000559aaa386720 in error_exit (err=16, msg=0x559aaa5973d0 <__func__.16227> "qemu_mutex_destroy") at util/qemu-thread-posix.c:36 |
7 | 2. Run ping flood to the VM NIC ( 1 ms interval) | 7 | #3 0x0000559aaa3868c5 in qemu_mutex_destroy (mutex=0x559aabffe828) at util/qemu-thread-posix.c:69 |
8 | 3. Hot unplug the NIC device (device_del) | 8 | #4 0x0000559aaa2f93a8 in char_finalize (obj=0x559aabffe800) at chardev/char.c:285 |
9 | During unplug process one or more packets come, the NIC | 9 | #5 0x0000559aaa23318a in object_deinit (obj=0x559aabffe800, type=0x559aabfd7d20) at qom/object.c:606 |
10 | can't receive, tap disables read_poll | 10 | #6 0x0000559aaa2331b8 in object_deinit (obj=0x559aabffe800, type=0x559aabfd9060) at qom/object.c:610 |
11 | 4. Hot plug the device (device_add) with the same netdev | 11 | #7 0x0000559aaa233200 in object_finalize (data=0x559aabffe800) at qom/object.c:620 |
12 | The tap stays with read_poll disabled and does not receive | 12 | #8 0x0000559aaa234202 in object_unref (obj=0x559aabffe800) at qom/object.c:1074 |
13 | any packets anymore (tap_send never triggered) | 13 | #9 0x0000559aaa2356b6 in object_finalize_child_property (obj=0x559aac0dac10, name=0x559aac778760 "compare0-0", opaque=0x559aabffe800) at qom/object.c:1584 |
14 | #10 0x0000559aaa232f70 in object_property_del_all (obj=0x559aac0dac10) at qom/object.c:557 | ||
15 | #11 0x0000559aaa2331ed in object_finalize (data=0x559aac0dac10) at qom/object.c:619 | ||
16 | #12 0x0000559aaa234202 in object_unref (obj=0x559aac0dac10) at qom/object.c:1074 | ||
17 | #13 0x0000559aaa2356b6 in object_finalize_child_property (obj=0x559aac0c75c0, name=0x559aac0dadc0 "chardevs", opaque=0x559aac0dac10) at qom/object.c:1584 | ||
18 | #14 0x0000559aaa233071 in object_property_del_child (obj=0x559aac0c75c0, child=0x559aac0dac10, errp=0x0) at qom/object.c:580 | ||
19 | #15 0x0000559aaa233155 in object_unparent (obj=0x559aac0dac10) at qom/object.c:599 | ||
20 | #16 0x0000559aaa2fb721 in qemu_chr_cleanup () at chardev/char.c:1159 | ||
21 | #17 0x0000559aa9f9b110 in main (argc=54, argv=0x7ffeb62fa998, envp=0x7ffeb62fab50) at vl.c:4539 | ||
14 | 22 | ||
15 | Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com> | 23 | When chardev is cleaned up, chr_write_lock needs to be destroyed. But |
24 | the colo-compare module is not cleaned up normally before it when the | ||
25 | guest poweroff. It is holding chr_write_lock at this time. This will | ||
26 | cause qemu crash.So we add the function of colo_compare_cleanup() before | ||
27 | qemu_chr_cleanup() to fix the bug. | ||
28 | |||
29 | Signed-off-by: Lei Rao <lei.rao@intel.com> | ||
30 | Reviewed-by: Zhang Chen <chen.zhang@intel.com> | ||
31 | Reviewed-by: Lukas Straub <lukasstraub2@web.de> | ||
32 | Tested-by: Lukas Straub <lukasstraub2@web.de> | ||
33 | Signed-off-by: Zhang Chen <chen.zhang@intel.com> | ||
16 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 34 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
17 | --- | 35 | --- |
18 | net/net.c | 12 ++++++++---- | 36 | net/colo-compare.c | 10 ++++++++++ |
19 | 1 file changed, 8 insertions(+), 4 deletions(-) | 37 | net/colo-compare.h | 1 + |
38 | net/net.c | 4 ++++ | ||
39 | 3 files changed, 15 insertions(+) | ||
20 | 40 | ||
41 | diff --git a/net/colo-compare.c b/net/colo-compare.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/net/colo-compare.c | ||
44 | +++ b/net/colo-compare.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_init(Object *obj) | ||
46 | compare_set_vnet_hdr); | ||
47 | } | ||
48 | |||
49 | +void colo_compare_cleanup(void) | ||
50 | +{ | ||
51 | + CompareState *tmp = NULL; | ||
52 | + CompareState *n = NULL; | ||
53 | + | ||
54 | + QTAILQ_FOREACH_SAFE(tmp, &net_compares, next, n) { | ||
55 | + object_unparent(OBJECT(tmp)); | ||
56 | + } | ||
57 | +} | ||
58 | + | ||
59 | static void colo_compare_finalize(Object *obj) | ||
60 | { | ||
61 | CompareState *s = COLO_COMPARE(obj); | ||
62 | diff --git a/net/colo-compare.h b/net/colo-compare.h | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/net/colo-compare.h | ||
65 | +++ b/net/colo-compare.h | ||
66 | @@ -XXX,XX +XXX,XX @@ | ||
67 | void colo_notify_compares_event(void *opaque, int event, Error **errp); | ||
68 | void colo_compare_register_notifier(Notifier *notify); | ||
69 | void colo_compare_unregister_notifier(Notifier *notify); | ||
70 | +void colo_compare_cleanup(void); | ||
71 | |||
72 | #endif /* QEMU_COLO_COMPARE_H */ | ||
21 | diff --git a/net/net.c b/net/net.c | 73 | diff --git a/net/net.c b/net/net.c |
22 | index XXXXXXX..XXXXXXX 100644 | 74 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/net/net.c | 75 | --- a/net/net.c |
24 | +++ b/net/net.c | 76 | +++ b/net/net.c |
25 | @@ -XXX,XX +XXX,XX @@ void qemu_del_nic(NICState *nic) | 77 | @@ -XXX,XX +XXX,XX @@ |
26 | 78 | #include "qapi/error.h" | |
27 | qemu_macaddr_set_free(&nic->conf->macaddr); | 79 | #include "qapi/opts-visitor.h" |
28 | 80 | #include "sysemu/runstate.h" | |
29 | - /* If this is a peer NIC and peer has already been deleted, free it now. */ | 81 | +#include "net/colo-compare.h" |
30 | - if (nic->peer_deleted) { | 82 | #include "net/filter.h" |
31 | - for (i = 0; i < queues; i++) { | 83 | #include "qapi/string-output-visitor.h" |
32 | - qemu_free_net_client(qemu_get_subqueue(nic, i)->peer); | 84 | |
33 | + for (i = 0; i < queues; i++) { | 85 | @@ -XXX,XX +XXX,XX @@ void net_cleanup(void) |
34 | + NetClientState *nc = qemu_get_subqueue(nic, i); | 86 | { |
35 | + /* If this is a peer NIC and peer has already been deleted, free it now. */ | 87 | NetClientState *nc; |
36 | + if (nic->peer_deleted) { | 88 | |
37 | + qemu_free_net_client(nc->peer); | 89 | + /*cleanup colo compare module for COLO*/ |
38 | + } else if (nc->peer) { | 90 | + colo_compare_cleanup(); |
39 | + /* if there are RX packets pending, complete them */ | 91 | + |
40 | + qemu_purge_queued_packets(nc->peer); | 92 | /* We may del multiple entries during qemu_del_net_client(), |
41 | } | 93 | * so QTAILQ_FOREACH_SAFE() is also not safe here. |
42 | } | 94 | */ |
43 | |||
44 | -- | 95 | -- |
45 | 2.7.4 | 96 | 2.7.4 |
46 | 97 | ||
47 | 98 | diff view generated by jsdifflib |
1 | From: yuanjungong <ruc_gongyuanjun@163.com> | 1 | From: "Rao, Lei" <lei.rao@intel.com> |
---|---|---|---|
2 | 2 | ||
3 | Close fd before returning. | 3 | The data pointer has skipped vnet_hdr_len in the function of |
4 | parse_packet_early().So, we can not subtract vnet_hdr_len again | ||
5 | when calculating pkt->header_size in fill_pkt_tcp_info(). Otherwise, | ||
6 | it will cause network packet comparsion errors and greatly increase | ||
7 | the frequency of checkpoints. | ||
4 | 8 | ||
5 | Buglink: https://bugs.launchpad.net/qemu/+bug/1904486 | 9 | Signed-off-by: Lei Rao <lei.rao@intel.com> |
6 | 10 | Signed-off-by: Zhang Chen <chen.zhang@intel.com> | |
7 | Signed-off-by: yuanjungong <ruc_gongyuanjun@163.com> | 11 | Reviewed-by: Li Zhijian <lizhijian@fujitsu.com> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Reviewed-by: Zhang Chen <chen.zhang@intel.com> |
13 | Reviewed-by: Lukas Straub <lukasstraub2@web.de> | ||
14 | Tested-by: Lukas Straub <lukasstraub2@web.de> | ||
9 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 15 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
10 | --- | 16 | --- |
11 | net/tap.c | 2 ++ | 17 | net/colo-compare.c | 2 +- |
12 | 1 file changed, 2 insertions(+) | 18 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 19 | ||
14 | diff --git a/net/tap.c b/net/tap.c | 20 | diff --git a/net/colo-compare.c b/net/colo-compare.c |
15 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/net/tap.c | 22 | --- a/net/colo-compare.c |
17 | +++ b/net/tap.c | 23 | +++ b/net/colo-compare.c |
18 | @@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name, | 24 | @@ -XXX,XX +XXX,XX @@ static void fill_pkt_tcp_info(void *data, uint32_t *max_ack) |
19 | if (ret < 0) { | 25 | pkt->tcp_ack = ntohl(tcphd->th_ack); |
20 | error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d", | 26 | *max_ack = *max_ack > pkt->tcp_ack ? *max_ack : pkt->tcp_ack; |
21 | name, fd); | 27 | pkt->header_size = pkt->transport_header - (uint8_t *)pkt->data |
22 | + close(fd); | 28 | - + (tcphd->th_off << 2) - pkt->vnet_hdr_len; |
23 | return -1; | 29 | + + (tcphd->th_off << 2); |
24 | } | 30 | pkt->payload_size = pkt->size - pkt->header_size; |
25 | 31 | pkt->seq_end = pkt->tcp_seq + pkt->payload_size; | |
26 | @@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name, | 32 | pkt->flags = tcphd->th_flags; |
27 | vhostfdname, vnet_hdr, fd, &err); | ||
28 | if (err) { | ||
29 | error_propagate(errp, err); | ||
30 | + close(fd); | ||
31 | return -1; | ||
32 | } | ||
33 | } else if (tap->has_fds) { | ||
34 | -- | 33 | -- |
35 | 2.7.4 | 34 | 2.7.4 |
36 | 35 | ||
37 | 36 | diff view generated by jsdifflib |