Merge remote branch 'mst/for_anthony' into staging

This commit is contained in:
Anthony Liguori 2010-06-10 09:21:43 -05:00
commit 60a3992e75
2 changed files with 19 additions and 14 deletions

View File

@ -532,16 +532,17 @@ static ssize_t virtio_net_receive(VLANClientState *nc, const uint8_t *buf, size_
if (!virtio_net_can_receive(&n->nic->nc)) if (!virtio_net_can_receive(&n->nic->nc))
return -1; return -1;
if (!virtio_net_has_buffers(n, size)) /* hdr_len refers to the header we supply to the guest */
hdr_len = n->mergeable_rx_bufs ?
sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr);
if (!virtio_net_has_buffers(n, size + hdr_len))
return 0; return 0;
if (!receive_filter(n, buf, size)) if (!receive_filter(n, buf, size))
return size; return size;
/* hdr_len refers to the header we supply to the guest */
hdr_len = n->mergeable_rx_bufs ?
sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr);
offset = i = 0; offset = i = 0;
while (offset < size) { while (offset < size) {
@ -555,7 +556,9 @@ static ssize_t virtio_net_receive(VLANClientState *nc, const uint8_t *buf, size_
virtqueue_pop(n->rx_vq, &elem) == 0) { virtqueue_pop(n->rx_vq, &elem) == 0) {
if (i == 0) if (i == 0)
return -1; return -1;
fprintf(stderr, "virtio-net truncating packet\n"); fprintf(stderr, "virtio-net truncating packet: "
"offset %zd, size %zd, hdr_len %zd\n",
offset, size, hdr_len);
exit(1); exit(1);
} }
@ -877,12 +880,11 @@ static void virtio_net_set_status(struct VirtIODevice *vdev, uint8_t status)
static void virtio_net_vmstate_change(void *opaque, int running, int reason) static void virtio_net_vmstate_change(void *opaque, int running, int reason)
{ {
VirtIONet *n = opaque; VirtIONet *n = opaque;
if (!running) { uint8_t status = running ? VIRTIO_CONFIG_S_DRIVER_OK : 0;
return; /* This is called when vm is started/stopped,
} * it will start/stop vhost backend if * appropriate
/* This is called when vm is started, it will start vhost backend if * e.g. after migration. */
* appropriate e.g. after migration. */ virtio_net_set_status(&n->vdev, n->vdev.status & status);
virtio_net_set_status(&n->vdev, n->vdev.status);
} }
VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf) VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf)

7
net.c
View File

@ -1106,6 +1106,7 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
for (i = 0; net_client_types[i].type != NULL; i++) { for (i = 0; net_client_types[i].type != NULL; i++) {
if (!strcmp(net_client_types[i].type, type)) { if (!strcmp(net_client_types[i].type, type)) {
VLANState *vlan = NULL; VLANState *vlan = NULL;
int ret;
if (qemu_opts_validate(opts, &net_client_types[i].desc[0]) == -1) { if (qemu_opts_validate(opts, &net_client_types[i].desc[0]) == -1) {
return -1; return -1;
@ -1118,14 +1119,16 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1); vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1);
} }
ret = -1;
if (net_client_types[i].init) { if (net_client_types[i].init) {
if (net_client_types[i].init(opts, mon, name, vlan) < 0) { ret = net_client_types[i].init(opts, mon, name, vlan);
if (ret < 0) {
/* TODO push error reporting into init() methods */ /* TODO push error reporting into init() methods */
qerror_report(QERR_DEVICE_INIT_FAILED, type); qerror_report(QERR_DEVICE_INIT_FAILED, type);
return -1; return -1;
} }
} }
return 0; return ret;
} }
} }