Skip to content

Commit 654790b

Browse files
jasowangmstsirkin
authored andcommitted
vhost-vdpa: let net_vhost_vdpa_init() returns NetClientState *
This patch switches to let net_vhost_vdpa_init() to return NetClientState *. This is used for the callers to allocate multiqueue NetClientState for multiqueue support. Signed-off-by: Jason Wang <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 353244d commit 654790b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

net/vhost-vdpa.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ static NetClientInfo net_vhost_vdpa_info = {
169169
.check_peer_type = vhost_vdpa_check_peer_type,
170170
};
171171

172-
static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
173-
const char *name, int vdpa_device_fd)
172+
static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
173+
const char *device,
174+
const char *name,
175+
int vdpa_device_fd)
174176
{
175177
NetClientState *nc = NULL;
176178
VhostVDPAState *s;
@@ -184,15 +186,17 @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
184186
ret = vhost_vdpa_add(nc, (void *)&s->vhost_vdpa);
185187
if (ret) {
186188
qemu_del_net_client(nc);
189+
return NULL;
187190
}
188-
return ret;
191+
return nc;
189192
}
190193

191194
int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
192195
NetClientState *peer, Error **errp)
193196
{
194197
const NetdevVhostVDPAOptions *opts;
195-
int vdpa_device_fd, ret;
198+
int vdpa_device_fd;
199+
NetClientState *nc;
196200

197201
assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
198202
opts = &netdev->u.vhost_vdpa;
@@ -202,10 +206,11 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
202206
return -errno;
203207
}
204208

205-
ret = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd);
206-
if (ret) {
209+
nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd);
210+
if (!nc) {
207211
qemu_close(vdpa_device_fd);
212+
return -1;
208213
}
209214

210-
return ret;
215+
return 0;
211216
}

0 commit comments

Comments
 (0)