summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2010-06-10 09:21:43 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2010-06-10 09:21:43 -0500
commit60a3992e759d92b9111871b0881e65519c750b01 (patch)
treeaa55d288c1dd64a446154c8c8a66147264754a7c
parent77d4f95e111a7c82bf21908f4de170b7e0e722bb (diff)
parent50e32ea8f31035877decc10f1075aa0e619e09cb (diff)
downloadqemu-60a3992e759d92b9111871b0881e65519c750b01.tar.gz
qemu-60a3992e759d92b9111871b0881e65519c750b01.tar.bz2
qemu-60a3992e759d92b9111871b0881e65519c750b01.zip
Merge remote branch 'mst/for_anthony' into staging
-rw-r--r--hw/virtio-net.c26
-rw-r--r--net.c7
2 files changed, 19 insertions, 14 deletions
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index cb664e6207..06ba48103d 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -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))
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;
if (!receive_filter(n, buf, 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;
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) {
if (i == 0)
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);
}
@@ -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)
{
VirtIONet *n = opaque;
- if (!running) {
- return;
- }
- /* This is called when vm is started, it will start vhost backend if
- * appropriate e.g. after migration. */
- virtio_net_set_status(&n->vdev, n->vdev.status);
+ uint8_t status = running ? VIRTIO_CONFIG_S_DRIVER_OK : 0;
+ /* This is called when vm is started/stopped,
+ * it will start/stop vhost backend if * appropriate
+ * e.g. after migration. */
+ virtio_net_set_status(&n->vdev, n->vdev.status & status);
}
VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf)
diff --git a/net.c b/net.c
index efa8b3df54..4cb93ed5b7 100644
--- a/net.c
+++ b/net.c
@@ -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++) {
if (!strcmp(net_client_types[i].type, type)) {
VLANState *vlan = NULL;
+ int ret;
if (qemu_opts_validate(opts, &net_client_types[i].desc[0]) == -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);
}
+ ret = -1;
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 */
qerror_report(QERR_DEVICE_INIT_FAILED, type);
return -1;
}
}
- return 0;
+ return ret;
}
}