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