vhost-user: add Net prefix to internal state structure
We are going to introduce a shared vhost user state which will be named as 'VhostUserState'. So add 'Net' prefix to the existing internal state structure in the vhost-user netdev to avoid conflict. Signed-off-by: Tiwei Bie <tiwei.bie@intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
85e99cf80b
commit
703878e2e0
@ -20,38 +20,38 @@
|
|||||||
#include "qemu/option.h"
|
#include "qemu/option.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
typedef struct VhostUserState {
|
typedef struct NetVhostUserState {
|
||||||
NetClientState nc;
|
NetClientState nc;
|
||||||
CharBackend chr; /* only queue index 0 */
|
CharBackend chr; /* only queue index 0 */
|
||||||
VHostNetState *vhost_net;
|
VHostNetState *vhost_net;
|
||||||
guint watch;
|
guint watch;
|
||||||
uint64_t acked_features;
|
uint64_t acked_features;
|
||||||
bool started;
|
bool started;
|
||||||
} VhostUserState;
|
} NetVhostUserState;
|
||||||
|
|
||||||
VHostNetState *vhost_user_get_vhost_net(NetClientState *nc)
|
VHostNetState *vhost_user_get_vhost_net(NetClientState *nc)
|
||||||
{
|
{
|
||||||
VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
|
NetVhostUserState *s = DO_UPCAST(NetVhostUserState, nc, nc);
|
||||||
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
||||||
return s->vhost_net;
|
return s->vhost_net;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t vhost_user_get_acked_features(NetClientState *nc)
|
uint64_t vhost_user_get_acked_features(NetClientState *nc)
|
||||||
{
|
{
|
||||||
VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
|
NetVhostUserState *s = DO_UPCAST(NetVhostUserState, nc, nc);
|
||||||
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
||||||
return s->acked_features;
|
return s->acked_features;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vhost_user_stop(int queues, NetClientState *ncs[])
|
static void vhost_user_stop(int queues, NetClientState *ncs[])
|
||||||
{
|
{
|
||||||
VhostUserState *s;
|
NetVhostUserState *s;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < queues; i++) {
|
for (i = 0; i < queues; i++) {
|
||||||
assert(ncs[i]->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
assert(ncs[i]->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
||||||
|
|
||||||
s = DO_UPCAST(VhostUserState, nc, ncs[i]);
|
s = DO_UPCAST(NetVhostUserState, nc, ncs[i]);
|
||||||
|
|
||||||
if (s->vhost_net) {
|
if (s->vhost_net) {
|
||||||
/* save acked features */
|
/* save acked features */
|
||||||
@ -68,7 +68,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be)
|
|||||||
{
|
{
|
||||||
VhostNetOptions options;
|
VhostNetOptions options;
|
||||||
struct vhost_net *net = NULL;
|
struct vhost_net *net = NULL;
|
||||||
VhostUserState *s;
|
NetVhostUserState *s;
|
||||||
int max_queues;
|
int max_queues;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be)
|
|||||||
for (i = 0; i < queues; i++) {
|
for (i = 0; i < queues; i++) {
|
||||||
assert(ncs[i]->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
assert(ncs[i]->info->type == NET_CLIENT_DRIVER_VHOST_USER);
|
||||||
|
|
||||||
s = DO_UPCAST(VhostUserState, nc, ncs[i]);
|
s = DO_UPCAST(NetVhostUserState, nc, ncs[i]);
|
||||||
|
|
||||||
options.net_backend = ncs[i];
|
options.net_backend = ncs[i];
|
||||||
options.opaque = be;
|
options.opaque = be;
|
||||||
@ -123,7 +123,7 @@ static ssize_t vhost_user_receive(NetClientState *nc, const uint8_t *buf,
|
|||||||
without GUEST_ANNOUNCE capability.
|
without GUEST_ANNOUNCE capability.
|
||||||
*/
|
*/
|
||||||
if (size == 60) {
|
if (size == 60) {
|
||||||
VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
|
NetVhostUserState *s = DO_UPCAST(NetVhostUserState, nc, nc);
|
||||||
int r;
|
int r;
|
||||||
static int display_rarp_failure = 1;
|
static int display_rarp_failure = 1;
|
||||||
char mac_addr[6];
|
char mac_addr[6];
|
||||||
@ -146,7 +146,7 @@ static ssize_t vhost_user_receive(NetClientState *nc, const uint8_t *buf,
|
|||||||
|
|
||||||
static void vhost_user_cleanup(NetClientState *nc)
|
static void vhost_user_cleanup(NetClientState *nc)
|
||||||
{
|
{
|
||||||
VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
|
NetVhostUserState *s = DO_UPCAST(NetVhostUserState, nc, nc);
|
||||||
|
|
||||||
if (s->vhost_net) {
|
if (s->vhost_net) {
|
||||||
vhost_net_cleanup(s->vhost_net);
|
vhost_net_cleanup(s->vhost_net);
|
||||||
@ -180,7 +180,7 @@ static bool vhost_user_has_ufo(NetClientState *nc)
|
|||||||
|
|
||||||
static NetClientInfo net_vhost_user_info = {
|
static NetClientInfo net_vhost_user_info = {
|
||||||
.type = NET_CLIENT_DRIVER_VHOST_USER,
|
.type = NET_CLIENT_DRIVER_VHOST_USER,
|
||||||
.size = sizeof(VhostUserState),
|
.size = sizeof(NetVhostUserState),
|
||||||
.receive = vhost_user_receive,
|
.receive = vhost_user_receive,
|
||||||
.cleanup = vhost_user_cleanup,
|
.cleanup = vhost_user_cleanup,
|
||||||
.has_vnet_hdr = vhost_user_has_vnet_hdr,
|
.has_vnet_hdr = vhost_user_has_vnet_hdr,
|
||||||
@ -190,7 +190,7 @@ static NetClientInfo net_vhost_user_info = {
|
|||||||
static gboolean net_vhost_user_watch(GIOChannel *chan, GIOCondition cond,
|
static gboolean net_vhost_user_watch(GIOChannel *chan, GIOCondition cond,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
VhostUserState *s = opaque;
|
NetVhostUserState *s = opaque;
|
||||||
|
|
||||||
qemu_chr_fe_disconnect(&s->chr);
|
qemu_chr_fe_disconnect(&s->chr);
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ static void chr_closed_bh(void *opaque)
|
|||||||
{
|
{
|
||||||
const char *name = opaque;
|
const char *name = opaque;
|
||||||
NetClientState *ncs[MAX_QUEUE_NUM];
|
NetClientState *ncs[MAX_QUEUE_NUM];
|
||||||
VhostUserState *s;
|
NetVhostUserState *s;
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
int queues;
|
int queues;
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ static void chr_closed_bh(void *opaque)
|
|||||||
MAX_QUEUE_NUM);
|
MAX_QUEUE_NUM);
|
||||||
assert(queues < MAX_QUEUE_NUM);
|
assert(queues < MAX_QUEUE_NUM);
|
||||||
|
|
||||||
s = DO_UPCAST(VhostUserState, nc, ncs[0]);
|
s = DO_UPCAST(NetVhostUserState, nc, ncs[0]);
|
||||||
|
|
||||||
qmp_set_link(name, false, &err);
|
qmp_set_link(name, false, &err);
|
||||||
vhost_user_stop(queues, ncs);
|
vhost_user_stop(queues, ncs);
|
||||||
@ -229,7 +229,7 @@ static void net_vhost_user_event(void *opaque, int event)
|
|||||||
{
|
{
|
||||||
const char *name = opaque;
|
const char *name = opaque;
|
||||||
NetClientState *ncs[MAX_QUEUE_NUM];
|
NetClientState *ncs[MAX_QUEUE_NUM];
|
||||||
VhostUserState *s;
|
NetVhostUserState *s;
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
int queues;
|
int queues;
|
||||||
@ -239,7 +239,7 @@ static void net_vhost_user_event(void *opaque, int event)
|
|||||||
MAX_QUEUE_NUM);
|
MAX_QUEUE_NUM);
|
||||||
assert(queues < MAX_QUEUE_NUM);
|
assert(queues < MAX_QUEUE_NUM);
|
||||||
|
|
||||||
s = DO_UPCAST(VhostUserState, nc, ncs[0]);
|
s = DO_UPCAST(NetVhostUserState, nc, ncs[0]);
|
||||||
chr = qemu_chr_fe_get_driver(&s->chr);
|
chr = qemu_chr_fe_get_driver(&s->chr);
|
||||||
trace_vhost_user_event(chr->label, event);
|
trace_vhost_user_event(chr->label, event);
|
||||||
switch (event) {
|
switch (event) {
|
||||||
@ -283,7 +283,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
|
|||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
NetClientState *nc, *nc0 = NULL;
|
NetClientState *nc, *nc0 = NULL;
|
||||||
VhostUserState *s;
|
NetVhostUserState *s;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
assert(name);
|
assert(name);
|
||||||
@ -296,7 +296,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
|
|||||||
nc->queue_index = i;
|
nc->queue_index = i;
|
||||||
if (!nc0) {
|
if (!nc0) {
|
||||||
nc0 = nc;
|
nc0 = nc;
|
||||||
s = DO_UPCAST(VhostUserState, nc, nc);
|
s = DO_UPCAST(NetVhostUserState, nc, nc);
|
||||||
if (!qemu_chr_fe_init(&s->chr, chr, &err)) {
|
if (!qemu_chr_fe_init(&s->chr, chr, &err)) {
|
||||||
error_report_err(err);
|
error_report_err(err);
|
||||||
return -1;
|
return -1;
|
||||||
@ -305,7 +305,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s = DO_UPCAST(VhostUserState, nc, nc0);
|
s = DO_UPCAST(NetVhostUserState, nc, nc0);
|
||||||
do {
|
do {
|
||||||
if (qemu_chr_fe_wait_connected(&s->chr, &err) < 0) {
|
if (qemu_chr_fe_wait_connected(&s->chr, &err) < 0) {
|
||||||
error_report_err(err);
|
error_report_err(err);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user