mirror of https://github.com/xemu-project/xemu.git
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1 iQEcBAABAgAGBQJgwtB7AAoJEO8Ells5jWIRvHgH/3iNIL9dQLAZL1efvcZwrXsS GeWroKutDX16SP6wRAyzJEZuPGV4miOkDG4a1A3ccQiW7UOlSqCZb6W6J+okzmxQ rupk6smkl//8+J3NLMbS7/X1PrLmAuufk5U3JM9TCoI/xN2CiaKKBUe2PSwd4Npb puAoaUrFmPiFgRmG/1GO2aFx5CehOYZD0biQrc+r0ZMMb9CIp69ukvn9Eqw7EO8V Kz4n8Qq7G++PmQ/Zik+0Cvue24quyv8BGLMRFb3cWJKLeavAItPAaom1AmBa3X8F onjd+bqlfnkfsovVN/2cqyToajfYsSHkujRiTR+Mw+2aXwUD/0YYxiOnAOw5jHs= =A2ee -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging # gpg: Signature made Fri 11 Jun 2021 03:54:51 BST # gpg: using RSA key EF04965B398D6211 # gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" [marginal] # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 215D 46F4 8246 689E C77F 3562 EF04 965B 398D 6211 * remotes/jasowang/tags/net-pull-request: Fixed calculation error of pkt->header_size in fill_pkt_tcp_info() Add the function of colo_compare_cleanup Add a function named packet_new_nocopy for COLO. Remove migrate_set_block_enabled in checkpoint Optimize the function of filter_send Fix the qemu crash when guest shutdown during checkpoint Remove some duplicate trace code. netdev: add more commands to preconfig mode vhost-vdpa: remove the unused vhost_vdpa_get_acked_features() vhost-vdpa: don't initialize backend_features vhost-vdpa: map virtqueue notification area if possible vhost-vdpa: skip ram device from the IOTLB mapping Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
894fc4fd67
|
@ -1269,6 +1269,7 @@ ERST
|
|||
.help = "add host network device",
|
||||
.cmd = hmp_netdev_add,
|
||||
.command_completion = netdev_add_completion,
|
||||
.flags = "p",
|
||||
},
|
||||
|
||||
SRST
|
||||
|
@ -1283,6 +1284,7 @@ ERST
|
|||
.help = "remove host network device",
|
||||
.cmd = hmp_netdev_del,
|
||||
.command_completion = netdev_del_completion,
|
||||
.flags = "p",
|
||||
},
|
||||
|
||||
SRST
|
||||
|
|
|
@ -28,6 +28,8 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section)
|
|||
{
|
||||
return (!memory_region_is_ram(section->mr) &&
|
||||
!memory_region_is_iommu(section->mr)) ||
|
||||
/* vhost-vDPA doesn't allow MMIO to be mapped */
|
||||
memory_region_is_ram_device(section->mr) ||
|
||||
/*
|
||||
* Sizing an enabled 64-bit BAR can cause spurious mappings to
|
||||
* addresses in the upper part of the 64-bit address space. These
|
||||
|
@ -172,22 +174,12 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener,
|
|||
vaddr, section->readonly);
|
||||
if (ret) {
|
||||
error_report("vhost vdpa map fail!");
|
||||
if (memory_region_is_ram_device(section->mr)) {
|
||||
/* Allow unexpected mappings not to be fatal for RAM devices */
|
||||
error_report("map ram fail!");
|
||||
return ;
|
||||
}
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
if (memory_region_is_ram_device(section->mr)) {
|
||||
error_report("failed to vdpa_dma_map. pci p2p may not work");
|
||||
return;
|
||||
|
||||
}
|
||||
/*
|
||||
* On the initfn path, store the first error in the container so we
|
||||
* can gracefully fail. Runtime, there's not much we can do other
|
||||
|
@ -276,15 +268,12 @@ static void vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status)
|
|||
static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque)
|
||||
{
|
||||
struct vhost_vdpa *v;
|
||||
uint64_t features;
|
||||
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_VDPA);
|
||||
trace_vhost_vdpa_init(dev, opaque);
|
||||
|
||||
v = opaque;
|
||||
v->dev = dev;
|
||||
dev->opaque = opaque ;
|
||||
vhost_vdpa_call(dev, VHOST_GET_FEATURES, &features);
|
||||
dev->backend_features = features;
|
||||
v->listener = vhost_vdpa_memory_listener;
|
||||
v->msg_type = VHOST_IOTLB_MSG_V2;
|
||||
|
||||
|
@ -294,12 +283,95 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev,
|
||||
int queue_index)
|
||||
{
|
||||
size_t page_size = qemu_real_host_page_size;
|
||||
struct vhost_vdpa *v = dev->opaque;
|
||||
VirtIODevice *vdev = dev->vdev;
|
||||
VhostVDPAHostNotifier *n;
|
||||
|
||||
n = &v->notifier[queue_index];
|
||||
|
||||
if (n->addr) {
|
||||
virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, false);
|
||||
object_unparent(OBJECT(&n->mr));
|
||||
munmap(n->addr, page_size);
|
||||
n->addr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void vhost_vdpa_host_notifiers_uninit(struct vhost_dev *dev, int n)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
vhost_vdpa_host_notifier_uninit(dev, i);
|
||||
}
|
||||
}
|
||||
|
||||
static int vhost_vdpa_host_notifier_init(struct vhost_dev *dev, int queue_index)
|
||||
{
|
||||
size_t page_size = qemu_real_host_page_size;
|
||||
struct vhost_vdpa *v = dev->opaque;
|
||||
VirtIODevice *vdev = dev->vdev;
|
||||
VhostVDPAHostNotifier *n;
|
||||
int fd = v->device_fd;
|
||||
void *addr;
|
||||
char *name;
|
||||
|
||||
vhost_vdpa_host_notifier_uninit(dev, queue_index);
|
||||
|
||||
n = &v->notifier[queue_index];
|
||||
|
||||
addr = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, fd,
|
||||
queue_index * page_size);
|
||||
if (addr == MAP_FAILED) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
name = g_strdup_printf("vhost-vdpa/host-notifier@%p mmaps[%d]",
|
||||
v, queue_index);
|
||||
memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name,
|
||||
page_size, addr);
|
||||
g_free(name);
|
||||
|
||||
if (virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, true)) {
|
||||
munmap(addr, page_size);
|
||||
goto err;
|
||||
}
|
||||
n->addr = addr;
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void vhost_vdpa_host_notifiers_init(struct vhost_dev *dev)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = dev->vq_index; i < dev->vq_index + dev->nvqs; i++) {
|
||||
if (vhost_vdpa_host_notifier_init(dev, i)) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
err:
|
||||
vhost_vdpa_host_notifiers_uninit(dev, i);
|
||||
return;
|
||||
}
|
||||
|
||||
static int vhost_vdpa_cleanup(struct vhost_dev *dev)
|
||||
{
|
||||
struct vhost_vdpa *v;
|
||||
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_VDPA);
|
||||
v = dev->opaque;
|
||||
trace_vhost_vdpa_cleanup(dev, v);
|
||||
vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs);
|
||||
memory_listener_unregister(&v->listener);
|
||||
|
||||
dev->opaque = NULL;
|
||||
|
@ -476,6 +548,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
|
|||
if (started) {
|
||||
uint8_t status = 0;
|
||||
memory_listener_register(&v->listener, &address_space_memory);
|
||||
vhost_vdpa_host_notifiers_init(dev);
|
||||
vhost_vdpa_set_vring_ready(dev);
|
||||
vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
|
||||
vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &status);
|
||||
|
@ -485,6 +558,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
|
|||
vhost_vdpa_reset_device(dev);
|
||||
vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE |
|
||||
VIRTIO_CONFIG_S_DRIVER);
|
||||
vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs);
|
||||
memory_listener_unregister(&v->listener);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -14,11 +14,17 @@
|
|||
|
||||
#include "hw/virtio/virtio.h"
|
||||
|
||||
typedef struct VhostVDPAHostNotifier {
|
||||
MemoryRegion mr;
|
||||
void *addr;
|
||||
} VhostVDPAHostNotifier;
|
||||
|
||||
typedef struct vhost_vdpa {
|
||||
int device_fd;
|
||||
uint32_t msg_type;
|
||||
MemoryListener listener;
|
||||
struct vhost_dev *dev;
|
||||
VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX];
|
||||
} VhostVDPA;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#define TYPE_VHOST_VDPA "vhost-vdpa"
|
||||
|
||||
struct vhost_net *vhost_vdpa_get_vhost_net(NetClientState *nc);
|
||||
uint64_t vhost_vdpa_get_acked_features(NetClientState *nc);
|
||||
|
||||
extern const int vdpa_feature_bits[];
|
||||
|
||||
|
|
|
@ -435,12 +435,6 @@ static int colo_do_checkpoint_transaction(MigrationState *s,
|
|||
if (failover_get_state() != FAILOVER_STATUS_NONE) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Disable block migration */
|
||||
migrate_set_block_enabled(false, &local_err);
|
||||
if (local_err) {
|
||||
goto out;
|
||||
}
|
||||
qemu_mutex_lock_iothread();
|
||||
|
||||
#ifdef CONFIG_REPLICATION
|
||||
|
|
|
@ -2217,6 +2217,10 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc,
|
|||
}
|
||||
|
||||
if (blk || blk_inc) {
|
||||
if (migrate_colo_enabled()) {
|
||||
error_setg(errp, "No disk migration is required in COLO mode");
|
||||
return false;
|
||||
}
|
||||
if (migrate_use_block() || migrate_use_block_incremental()) {
|
||||
error_setg(errp, "Command options are incompatible with "
|
||||
"current migration capabilities");
|
||||
|
|
|
@ -211,7 +211,7 @@ static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)
|
|||
pkt->tcp_ack = ntohl(tcphd->th_ack);
|
||||
*max_ack = *max_ack > pkt->tcp_ack ? *max_ack : pkt->tcp_ack;
|
||||
pkt->header_size = pkt->transport_header - (uint8_t *)pkt->data
|
||||
+ (tcphd->th_off << 2) - pkt->vnet_hdr_len;
|
||||
+ (tcphd->th_off << 2);
|
||||
pkt->payload_size = pkt->size - pkt->header_size;
|
||||
pkt->seq_end = pkt->tcp_seq + pkt->payload_size;
|
||||
pkt->flags = tcphd->th_flags;
|
||||
|
@ -590,19 +590,6 @@ static int colo_packet_compare_other(Packet *spkt, Packet *ppkt)
|
|||
uint16_t offset = ppkt->vnet_hdr_len;
|
||||
|
||||
trace_colo_compare_main("compare other");
|
||||
if (trace_event_get_state_backends(TRACE_COLO_COMPARE_IP_INFO)) {
|
||||
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
|
||||
|
||||
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
|
||||
strcpy(pri_ip_dst, inet_ntoa(ppkt->ip->ip_dst));
|
||||
strcpy(sec_ip_src, inet_ntoa(spkt->ip->ip_src));
|
||||
strcpy(sec_ip_dst, inet_ntoa(spkt->ip->ip_dst));
|
||||
|
||||
trace_colo_compare_ip_info(ppkt->size, pri_ip_src,
|
||||
pri_ip_dst, spkt->size,
|
||||
sec_ip_src, sec_ip_dst);
|
||||
}
|
||||
|
||||
if (ppkt->size != spkt->size) {
|
||||
trace_colo_compare_main("Other: payload size of packets are different");
|
||||
return -1;
|
||||
|
@ -1415,6 +1402,16 @@ static void colo_compare_init(Object *obj)
|
|||
compare_set_vnet_hdr);
|
||||
}
|
||||
|
||||
void colo_compare_cleanup(void)
|
||||
{
|
||||
CompareState *tmp = NULL;
|
||||
CompareState *n = NULL;
|
||||
|
||||
QTAILQ_FOREACH_SAFE(tmp, &net_compares, next, n) {
|
||||
object_unparent(OBJECT(tmp));
|
||||
}
|
||||
}
|
||||
|
||||
static void colo_compare_finalize(Object *obj)
|
||||
{
|
||||
CompareState *s = COLO_COMPARE(obj);
|
||||
|
|
|
@ -20,5 +20,6 @@
|
|||
void colo_notify_compares_event(void *opaque, int event, Error **errp);
|
||||
void colo_compare_register_notifier(Notifier *notify);
|
||||
void colo_compare_unregister_notifier(Notifier *notify);
|
||||
void colo_compare_cleanup(void);
|
||||
|
||||
#endif /* QEMU_COLO_COMPARE_H */
|
||||
|
|
25
net/colo.c
25
net/colo.c
|
@ -157,19 +157,28 @@ void connection_destroy(void *opaque)
|
|||
|
||||
Packet *packet_new(const void *data, int size, int vnet_hdr_len)
|
||||
{
|
||||
Packet *pkt = g_slice_new(Packet);
|
||||
Packet *pkt = g_slice_new0(Packet);
|
||||
|
||||
pkt->data = g_memdup(data, size);
|
||||
pkt->size = size;
|
||||
pkt->creation_ms = qemu_clock_get_ms(QEMU_CLOCK_HOST);
|
||||
pkt->vnet_hdr_len = vnet_hdr_len;
|
||||
pkt->tcp_seq = 0;
|
||||
pkt->tcp_ack = 0;
|
||||
pkt->seq_end = 0;
|
||||
pkt->header_size = 0;
|
||||
pkt->payload_size = 0;
|
||||
pkt->offset = 0;
|
||||
pkt->flags = 0;
|
||||
|
||||
return pkt;
|
||||
}
|
||||
|
||||
/*
|
||||
* packet_new_nocopy will not copy data, so the caller can't release
|
||||
* the data. And it will be released in packet_destroy.
|
||||
*/
|
||||
Packet *packet_new_nocopy(void *data, int size, int vnet_hdr_len)
|
||||
{
|
||||
Packet *pkt = g_slice_new0(Packet);
|
||||
|
||||
pkt->data = data;
|
||||
pkt->size = size;
|
||||
pkt->creation_ms = qemu_clock_get_ms(QEMU_CLOCK_HOST);
|
||||
pkt->vnet_hdr_len = vnet_hdr_len;
|
||||
|
||||
return pkt;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ bool connection_has_tracked(GHashTable *connection_track_table,
|
|||
ConnectionKey *key);
|
||||
void connection_hashtable_reset(GHashTable *connection_track_table);
|
||||
Packet *packet_new(const void *data, int size, int vnet_hdr_len);
|
||||
Packet *packet_new_nocopy(void *data, int size, int vnet_hdr_len);
|
||||
void packet_destroy(void *opaque, void *user_data);
|
||||
void packet_destroy_partial(void *opaque, void *user_data);
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ static int filter_send(MirrorState *s,
|
|||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return size;
|
||||
|
||||
err:
|
||||
return ret < 0 ? ret : -EIO;
|
||||
|
@ -159,7 +159,7 @@ static ssize_t filter_mirror_receive_iov(NetFilterState *nf,
|
|||
int ret;
|
||||
|
||||
ret = filter_send(s, iov, iovcnt);
|
||||
if (ret) {
|
||||
if (ret < 0) {
|
||||
error_report("filter mirror send failed(%s)", strerror(-ret));
|
||||
}
|
||||
|
||||
|
@ -182,10 +182,10 @@ static ssize_t filter_redirector_receive_iov(NetFilterState *nf,
|
|||
|
||||
if (qemu_chr_fe_backend_connected(&s->chr_out)) {
|
||||
ret = filter_send(s, iov, iovcnt);
|
||||
if (ret) {
|
||||
if (ret < 0) {
|
||||
error_report("filter redirector send failed(%s)", strerror(-ret));
|
||||
}
|
||||
return iov_size(iov, iovcnt);
|
||||
return ret;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -270,8 +270,7 @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf,
|
|||
vnet_hdr_len = nf->netdev->vnet_hdr_len;
|
||||
}
|
||||
|
||||
pkt = packet_new(buf, size, vnet_hdr_len);
|
||||
g_free(buf);
|
||||
pkt = packet_new_nocopy(buf, size, vnet_hdr_len);
|
||||
|
||||
/*
|
||||
* if we get tcp packet
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "qapi/error.h"
|
||||
#include "qapi/opts-visitor.h"
|
||||
#include "sysemu/runstate.h"
|
||||
#include "net/colo-compare.h"
|
||||
#include "net/filter.h"
|
||||
#include "qapi/string-output-visitor.h"
|
||||
|
||||
|
@ -1402,6 +1403,9 @@ void net_cleanup(void)
|
|||
{
|
||||
NetClientState *nc;
|
||||
|
||||
/*cleanup colo compare module for COLO*/
|
||||
colo_compare_cleanup();
|
||||
|
||||
/* We may del multiple entries during qemu_del_net_client(),
|
||||
* so QTAILQ_FOREACH_SAFE() is also not safe here.
|
||||
*/
|
||||
|
|
|
@ -68,15 +68,6 @@ VHostNetState *vhost_vdpa_get_vhost_net(NetClientState *nc)
|
|||
return s->vhost_net;
|
||||
}
|
||||
|
||||
uint64_t vhost_vdpa_get_acked_features(NetClientState *nc)
|
||||
{
|
||||
VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
|
||||
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
|
||||
s->acked_features = vhost_net_get_acked_features(s->vhost_net);
|
||||
|
||||
return s->acked_features;
|
||||
}
|
||||
|
||||
static int vhost_vdpa_net_check_device_id(struct vhost_net *net)
|
||||
{
|
||||
uint32_t device_id;
|
||||
|
|
|
@ -55,7 +55,8 @@
|
|||
# <- { "return": {} }
|
||||
#
|
||||
##
|
||||
{ 'command': 'netdev_add', 'data': 'Netdev', 'boxed': true }
|
||||
{ 'command': 'netdev_add', 'data': 'Netdev', 'boxed': true,
|
||||
'allow-preconfig': true }
|
||||
|
||||
##
|
||||
# @netdev_del:
|
||||
|
@ -75,7 +76,8 @@
|
|||
# <- { "return": {} }
|
||||
#
|
||||
##
|
||||
{ 'command': 'netdev_del', 'data': {'id': 'str'} }
|
||||
{ 'command': 'netdev_del', 'data': {'id': 'str'},
|
||||
'allow-preconfig': true }
|
||||
|
||||
##
|
||||
# @NetLegacyNicOptions:
|
||||
|
|
|
@ -126,6 +126,7 @@ static const RunStateTransition runstate_transitions_def[] = {
|
|||
{ RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH },
|
||||
|
||||
{ RUN_STATE_COLO, RUN_STATE_RUNNING },
|
||||
{ RUN_STATE_COLO, RUN_STATE_SHUTDOWN},
|
||||
|
||||
{ RUN_STATE_RUNNING, RUN_STATE_DEBUG },
|
||||
{ RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR },
|
||||
|
|
Loading…
Reference in New Issue