Skip to content

Commit 2f849db

Browse files
jasowangmstsirkin
authored andcommitted
net: introduce control client
This patch introduces a boolean for the device has control queue which can accepts control command via network queue. The first user would be the control virtqueue support for vhost. 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 654790b commit 2f849db

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

include/net/net.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ struct NetClientState {
105105
int vnet_hdr_len;
106106
bool is_netdev;
107107
bool do_not_pad; /* do not pad to the minimum ethernet frame length */
108+
bool is_datapath;
108109
QTAILQ_HEAD(, NetFilterState) filters;
109110
};
110111

@@ -136,6 +137,10 @@ NetClientState *qemu_new_net_client(NetClientInfo *info,
136137
NetClientState *peer,
137138
const char *model,
138139
const char *name);
140+
NetClientState *qemu_new_net_control_client(NetClientInfo *info,
141+
NetClientState *peer,
142+
const char *model,
143+
const char *name);
139144
NICState *qemu_new_nic(NetClientInfo *info,
140145
NICConf *conf,
141146
const char *model,

net/net.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ static void qemu_net_client_setup(NetClientState *nc,
239239
NetClientState *peer,
240240
const char *model,
241241
const char *name,
242-
NetClientDestructor *destructor)
242+
NetClientDestructor *destructor,
243+
bool is_datapath)
243244
{
244245
nc->info = info;
245246
nc->model = g_strdup(model);
@@ -258,6 +259,7 @@ static void qemu_net_client_setup(NetClientState *nc,
258259

259260
nc->incoming_queue = qemu_new_net_queue(qemu_deliver_packet_iov, nc);
260261
nc->destructor = destructor;
262+
nc->is_datapath = is_datapath;
261263
QTAILQ_INIT(&nc->filters);
262264
}
263265

@@ -272,7 +274,23 @@ NetClientState *qemu_new_net_client(NetClientInfo *info,
272274

273275
nc = g_malloc0(info->size);
274276
qemu_net_client_setup(nc, info, peer, model, name,
275-
qemu_net_client_destructor);
277+
qemu_net_client_destructor, true);
278+
279+
return nc;
280+
}
281+
282+
NetClientState *qemu_new_net_control_client(NetClientInfo *info,
283+
NetClientState *peer,
284+
const char *model,
285+
const char *name)
286+
{
287+
NetClientState *nc;
288+
289+
assert(info->size >= sizeof(NetClientState));
290+
291+
nc = g_malloc0(info->size);
292+
qemu_net_client_setup(nc, info, peer, model, name,
293+
qemu_net_client_destructor, false);
276294

277295
return nc;
278296
}
@@ -297,7 +315,7 @@ NICState *qemu_new_nic(NetClientInfo *info,
297315

298316
for (i = 0; i < queues; i++) {
299317
qemu_net_client_setup(&nic->ncs[i], info, peers[i], model, name,
300-
NULL);
318+
NULL, true);
301319
nic->ncs[i].queue_index = i;
302320
}
303321

0 commit comments

Comments
 (0)