|
|
383d26 |
From 3c3163e2db902b0c585971f73308b6dc90ed45a0 Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: "plai@redhat.com" <plai@redhat.com>
|
|
|
383d26 |
Date: Thu, 21 Jun 2018 18:54:36 +0200
|
|
|
383d26 |
Subject: [PATCH 27/57] vhost-user: add Net prefix to internal state structure
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: plai@redhat.com
|
|
|
383d26 |
Message-id: <1529607285-9942-2-git-send-email-plai@redhat.com>
|
|
|
383d26 |
Patchwork-id: 80943
|
|
|
383d26 |
O-Subject: [RHEL7.6 PATCH BZ 1526645 01/10] vhost-user: add Net prefix to internal state structure
|
|
|
383d26 |
Bugzilla: 1526645
|
|
|
383d26 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
From: Tiwei Bie <tiwei.bie@intel.com>
|
|
|
383d26 |
|
|
|
383d26 |
We are going to introduce a shared vhost user state which
|
|
|
383d26 |
will be named as 'VhostUserState'. So add 'Net' prefix to
|
|
|
383d26 |
the existing internal state structure in the vhost-user
|
|
|
383d26 |
netdev to avoid conflict.
|
|
|
383d26 |
|
|
|
383d26 |
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
|
|
|
383d26 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
383d26 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
383d26 |
(cherry picked from commit 703878e2e0975123b1a89a006c0204c469333278)
|
|
|
383d26 |
Signed-off-by: Paul Lai <plai@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
net/vhost-user.c | 38 +++++++++++++++++++-------------------
|
|
|
383d26 |
1 file changed, 19 insertions(+), 19 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/net/vhost-user.c b/net/vhost-user.c
|
|
|
383d26 |
index e0f16c8..fa28aad 100644
|
|
|
383d26 |
--- a/net/vhost-user.c
|
|
|
383d26 |
+++ b/net/vhost-user.c
|
|
|
383d26 |
@@ -20,38 +20,38 @@
|
|
|
383d26 |
#include "qemu/option.h"
|
|
|
383d26 |
#include "trace.h"
|
|
|
383d26 |
|
|
|
383d26 |
-typedef struct VhostUserState {
|
|
|
383d26 |
+typedef struct NetVhostUserState {
|
|
|
383d26 |
NetClientState nc;
|
|
|
383d26 |
CharBackend chr; /* only queue index 0 */
|
|
|
383d26 |
VHostNetState *vhost_net;
|
|
|
383d26 |
guint watch;
|
|
|
383d26 |
uint64_t acked_features;
|
|
|
383d26 |
bool started;
|
|
|
383d26 |
-} VhostUserState;
|
|
|
383d26 |
+} NetVhostUserState;
|
|
|
383d26 |
|
|
|
383d26 |
VHostNetState *vhost_user_get_vhost_net(NetClientState *nc)
|
|
|
383d26 |
{
|
|
|
383d26 |
- VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
|
|
|
383d26 |
+ NetVhostUserState *s = DO_UPCAST(NetVhostUserState, nc, nc);
|
|
|
383d26 |
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
|
|
383d26 |
return s->vhost_net;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
uint64_t vhost_user_get_acked_features(NetClientState *nc)
|
|
|
383d26 |
{
|
|
|
383d26 |
- VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
|
|
|
383d26 |
+ NetVhostUserState *s = DO_UPCAST(NetVhostUserState, nc, nc);
|
|
|
383d26 |
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
|
|
383d26 |
return s->acked_features;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
static void vhost_user_stop(int queues, NetClientState *ncs[])
|
|
|
383d26 |
{
|
|
|
383d26 |
- VhostUserState *s;
|
|
|
383d26 |
+ NetVhostUserState *s;
|
|
|
383d26 |
int i;
|
|
|
383d26 |
|
|
|
383d26 |
for (i = 0; i < queues; i++) {
|
|
|
383d26 |
assert(ncs[i]->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
|
|
383d26 |
|
|
|
383d26 |
- s = DO_UPCAST(VhostUserState, nc, ncs[i]);
|
|
|
383d26 |
+ s = DO_UPCAST(NetVhostUserState, nc, ncs[i]);
|
|
|
383d26 |
|
|
|
383d26 |
if (s->vhost_net) {
|
|
|
383d26 |
/* save acked features */
|
|
|
383d26 |
@@ -68,7 +68,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be)
|
|
|
383d26 |
{
|
|
|
383d26 |
VhostNetOptions options;
|
|
|
383d26 |
struct vhost_net *net = NULL;
|
|
|
383d26 |
- VhostUserState *s;
|
|
|
383d26 |
+ NetVhostUserState *s;
|
|
|
383d26 |
int max_queues;
|
|
|
383d26 |
int i;
|
|
|
383d26 |
|
|
|
383d26 |
@@ -77,7 +77,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be)
|
|
|
383d26 |
for (i = 0; i < queues; i++) {
|
|
|
383d26 |
assert(ncs[i]->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
|
|
383d26 |
|
|
|
383d26 |
- s = DO_UPCAST(VhostUserState, nc, ncs[i]);
|
|
|
383d26 |
+ s = DO_UPCAST(NetVhostUserState, nc, ncs[i]);
|
|
|
383d26 |
|
|
|
383d26 |
options.net_backend = ncs[i];
|
|
|
383d26 |
options.opaque = be;
|
|
|
383d26 |
@@ -123,7 +123,7 @@ static ssize_t vhost_user_receive(NetClientState *nc, const uint8_t *buf,
|
|
|
383d26 |
without GUEST_ANNOUNCE capability.
|
|
|
383d26 |
*/
|
|
|
383d26 |
if (size == 60) {
|
|
|
383d26 |
- VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
|
|
|
383d26 |
+ NetVhostUserState *s = DO_UPCAST(NetVhostUserState, nc, nc);
|
|
|
383d26 |
int r;
|
|
|
383d26 |
static int display_rarp_failure = 1;
|
|
|
383d26 |
char mac_addr[6];
|
|
|
383d26 |
@@ -146,7 +146,7 @@ static ssize_t vhost_user_receive(NetClientState *nc, const uint8_t *buf,
|
|
|
383d26 |
|
|
|
383d26 |
static void vhost_user_cleanup(NetClientState *nc)
|
|
|
383d26 |
{
|
|
|
383d26 |
- VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
|
|
|
383d26 |
+ NetVhostUserState *s = DO_UPCAST(NetVhostUserState, nc, nc);
|
|
|
383d26 |
|
|
|
383d26 |
if (s->vhost_net) {
|
|
|
383d26 |
vhost_net_cleanup(s->vhost_net);
|
|
|
383d26 |
@@ -180,7 +180,7 @@ static bool vhost_user_has_ufo(NetClientState *nc)
|
|
|
383d26 |
|
|
|
383d26 |
static NetClientInfo net_vhost_user_info = {
|
|
|
383d26 |
.type = NET_CLIENT_DRIVER_VHOST_USER,
|
|
|
383d26 |
- .size = sizeof(VhostUserState),
|
|
|
383d26 |
+ .size = sizeof(NetVhostUserState),
|
|
|
383d26 |
.receive = vhost_user_receive,
|
|
|
383d26 |
.cleanup = vhost_user_cleanup,
|
|
|
383d26 |
.has_vnet_hdr = vhost_user_has_vnet_hdr,
|
|
|
383d26 |
@@ -190,7 +190,7 @@ static NetClientInfo net_vhost_user_info = {
|
|
|
383d26 |
static gboolean net_vhost_user_watch(GIOChannel *chan, GIOCondition cond,
|
|
|
383d26 |
void *opaque)
|
|
|
383d26 |
{
|
|
|
383d26 |
- VhostUserState *s = opaque;
|
|
|
383d26 |
+ NetVhostUserState *s = opaque;
|
|
|
383d26 |
|
|
|
383d26 |
qemu_chr_fe_disconnect(&s->chr);
|
|
|
383d26 |
|
|
|
383d26 |
@@ -203,7 +203,7 @@ static void chr_closed_bh(void *opaque)
|
|
|
383d26 |
{
|
|
|
383d26 |
const char *name = opaque;
|
|
|
383d26 |
NetClientState *ncs[MAX_QUEUE_NUM];
|
|
|
383d26 |
- VhostUserState *s;
|
|
|
383d26 |
+ NetVhostUserState *s;
|
|
|
383d26 |
Error *err = NULL;
|
|
|
383d26 |
int queues;
|
|
|
383d26 |
|
|
|
383d26 |
@@ -212,7 +212,7 @@ static void chr_closed_bh(void *opaque)
|
|
|
383d26 |
MAX_QUEUE_NUM);
|
|
|
383d26 |
assert(queues < MAX_QUEUE_NUM);
|
|
|
383d26 |
|
|
|
383d26 |
- s = DO_UPCAST(VhostUserState, nc, ncs[0]);
|
|
|
383d26 |
+ s = DO_UPCAST(NetVhostUserState, nc, ncs[0]);
|
|
|
383d26 |
|
|
|
383d26 |
qmp_set_link(name, false, &err;;
|
|
|
383d26 |
vhost_user_stop(queues, ncs);
|
|
|
383d26 |
@@ -229,7 +229,7 @@ static void net_vhost_user_event(void *opaque, int event)
|
|
|
383d26 |
{
|
|
|
383d26 |
const char *name = opaque;
|
|
|
383d26 |
NetClientState *ncs[MAX_QUEUE_NUM];
|
|
|
383d26 |
- VhostUserState *s;
|
|
|
383d26 |
+ NetVhostUserState *s;
|
|
|
383d26 |
Chardev *chr;
|
|
|
383d26 |
Error *err = NULL;
|
|
|
383d26 |
int queues;
|
|
|
383d26 |
@@ -239,7 +239,7 @@ static void net_vhost_user_event(void *opaque, int event)
|
|
|
383d26 |
MAX_QUEUE_NUM);
|
|
|
383d26 |
assert(queues < MAX_QUEUE_NUM);
|
|
|
383d26 |
|
|
|
383d26 |
- s = DO_UPCAST(VhostUserState, nc, ncs[0]);
|
|
|
383d26 |
+ s = DO_UPCAST(NetVhostUserState, nc, ncs[0]);
|
|
|
383d26 |
chr = qemu_chr_fe_get_driver(&s->chr);
|
|
|
383d26 |
trace_vhost_user_event(chr->label, event);
|
|
|
383d26 |
switch (event) {
|
|
|
383d26 |
@@ -283,7 +283,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
|
|
|
383d26 |
{
|
|
|
383d26 |
Error *err = NULL;
|
|
|
383d26 |
NetClientState *nc, *nc0 = NULL;
|
|
|
383d26 |
- VhostUserState *s;
|
|
|
383d26 |
+ NetVhostUserState *s;
|
|
|
383d26 |
int i;
|
|
|
383d26 |
|
|
|
383d26 |
assert(name);
|
|
|
383d26 |
@@ -296,7 +296,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
|
|
|
383d26 |
nc->queue_index = i;
|
|
|
383d26 |
if (!nc0) {
|
|
|
383d26 |
nc0 = nc;
|
|
|
383d26 |
- s = DO_UPCAST(VhostUserState, nc, nc);
|
|
|
383d26 |
+ s = DO_UPCAST(NetVhostUserState, nc, nc);
|
|
|
383d26 |
if (!qemu_chr_fe_init(&s->chr, chr, &err)) {
|
|
|
383d26 |
error_report_err(err);
|
|
|
383d26 |
return -1;
|
|
|
383d26 |
@@ -305,7 +305,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
|
|
|
383d26 |
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
- s = DO_UPCAST(VhostUserState, nc, nc0);
|
|
|
383d26 |
+ s = DO_UPCAST(NetVhostUserState, nc, nc0);
|
|
|
383d26 |
do {
|
|
|
383d26 |
if (qemu_chr_fe_wait_connected(&s->chr, &err) < 0) {
|
|
|
383d26 |
error_report_err(err);
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|