aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/ide/atapi.c15
-rw-r--r--hw/ide/core.c6
-rw-r--r--hw/qdev-monitor.c5
-rw-r--r--hw/qxl.c1
-rw-r--r--hw/usb/bus.c7
-rw-r--r--hw/usb/hcd-ehci-pci.c1
-rw-r--r--hw/usb/hcd-ehci-sysbus.c1
-rw-r--r--hw/usb/hcd-ohci.c1
-rw-r--r--hw/usb/hcd-uhci.c1
-rw-r--r--hw/usb/hcd-xhci.c1
-rw-r--r--hw/virtio-rng.c12
-rw-r--r--hw/virtio-serial-bus.c2
-rw-r--r--hw/virtio.c15
-rw-r--r--hw/virtio.h3
14 files changed, 45 insertions, 26 deletions
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index 685cbaa889..861fd2bec3 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -1124,12 +1124,17 @@ void ide_atapi_cmd(IDEState *s)
* GET_EVENT_STATUS_NOTIFICATION to detect such tray open/close
* states rely on this behavior.
*/
- if (!s->tray_open && bdrv_is_inserted(s->bs) && s->cdrom_changed) {
- ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+ if (!(atapi_cmd_table[s->io_buffer[0]].flags & ALLOW_UA) &&
+ !s->tray_open && bdrv_is_inserted(s->bs) && s->cdrom_changed) {
+
+ if (s->cdrom_changed == 1) {
+ ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+ s->cdrom_changed = 2;
+ } else {
+ ide_atapi_cmd_error(s, UNIT_ATTENTION, ASC_MEDIUM_MAY_HAVE_CHANGED);
+ s->cdrom_changed = 0;
+ }
- s->cdrom_changed = 0;
- s->sense_key = UNIT_ATTENTION;
- s->asc = ASC_MEDIUM_MAY_HAVE_CHANGED;
return;
}
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 8da894f240..c4f93d0e47 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2160,12 +2160,6 @@ static int ide_drive_post_load(void *opaque, int version_id)
{
IDEState *s = opaque;
- if (version_id < 3) {
- if (s->sense_key == UNIT_ATTENTION &&
- s->asc == ASC_MEDIUM_MAY_HAVE_CHANGED) {
- s->cdrom_changed = 1;
- }
- }
if (s->identify_set) {
bdrv_set_enable_write_cache(s->bs, !!(s->identify_data[85] & (1 << 5)));
}
diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index 479eecda31..a1b4d6ae5f 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -289,8 +289,7 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name,
if (name && (strcmp(bus->name, name) != 0)) {
match = 0;
}
- if (bus_typename &&
- (strcmp(object_get_typename(OBJECT(bus)), bus_typename) != 0)) {
+ if (bus_typename && !object_dynamic_cast(OBJECT(bus), bus_typename)) {
match = 0;
}
if (match) {
@@ -435,7 +434,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
if (!bus) {
return NULL;
}
- if (strcmp(object_get_typename(OBJECT(bus)), k->bus_type) != 0) {
+ if (!object_dynamic_cast(OBJECT(bus), k->bus_type)) {
qerror_report(QERR_BAD_BUS_FOR_DEVICE,
driver, object_get_typename(OBJECT(bus)));
return NULL;
diff --git a/hw/qxl.c b/hw/qxl.c
index 1bc2d32aa8..96887c4aad 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -2146,6 +2146,7 @@ static int qxl_post_load(void *opaque, int version)
switch (newmode) {
case QXL_MODE_UNDEFINED:
+ qxl_create_memslots(d);
break;
case QXL_MODE_VGA:
qxl_create_memslots(d);
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 99aac7a2c0..55d0edd5c3 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -590,6 +590,13 @@ USBDevice *usbdevice_create(const char *cmdline)
return NULL;
}
+ if (!bus) {
+ error_report("Error: no usb bus to attach usbdevice %s, "
+ "please try -machine usb=on and check that "
+ "the machine model supports USB", driver);
+ return NULL;
+ }
+
if (!f->usbdevice_init) {
if (*params) {
error_report("usbdevice %s accepts no params", driver);
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 5887eab197..41dbb539f2 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -123,6 +123,7 @@ static void ehci_class_init(ObjectClass *klass, void *data)
k->revision = i->revision;
k->class_id = PCI_CLASS_SERIAL_USB;
k->config_write = usb_ehci_pci_write_config;
+ k->no_hotplug = 1;
dc->vmsd = &vmstate_ehci_pci;
dc->props = ehci_pci_properties;
}
diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
index 1584079796..803df92f31 100644
--- a/hw/usb/hcd-ehci-sysbus.c
+++ b/hw/usb/hcd-ehci-sysbus.c
@@ -45,6 +45,7 @@ static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
s->capsbase = 0x100;
s->opregbase = 0x140;
+ s->dma = &dma_context_memory;
usb_ehci_initfn(s, DEVICE(dev));
sysbus_init_irq(dev, &s->irq);
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 64de906e41..e16a2ecab4 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1882,6 +1882,7 @@ static void ohci_pci_class_init(ObjectClass *klass, void *data)
k->vendor_id = PCI_VENDOR_ID_APPLE;
k->device_id = PCI_DEVICE_ID_APPLE_IPID_USB;
k->class_id = PCI_CLASS_SERIAL_USB;
+ k->no_hotplug = 1;
dc->desc = "Apple USB Controller";
dc->props = ohci_pci_properties;
}
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 8e478030ad..d053791de0 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1327,6 +1327,7 @@ static void uhci_class_init(ObjectClass *klass, void *data)
k->device_id = info->device_id;
k->revision = info->revision;
k->class_id = PCI_CLASS_SERIAL_USB;
+ k->no_hotplug = 1;
dc->vmsd = &vmstate_uhci;
dc->props = uhci_properties;
u->info = *info;
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 8ef4b0730e..efb509e423 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3167,6 +3167,7 @@ static void xhci_class_init(ObjectClass *klass, void *data)
k->class_id = PCI_CLASS_SERIAL_USB;
k->revision = 0x03;
k->is_express = 1;
+ k->no_hotplug = 1;
}
static TypeInfo xhci_info = {
diff --git a/hw/virtio-rng.c b/hw/virtio-rng.c
index df329f25e1..a73ef8e334 100644
--- a/hw/virtio-rng.c
+++ b/hw/virtio-rng.c
@@ -43,11 +43,11 @@ static bool is_guest_ready(VirtIORNG *vrng)
return false;
}
-static size_t get_request_size(VirtQueue *vq)
+static size_t get_request_size(VirtQueue *vq, unsigned quota)
{
unsigned int in, out;
- virtqueue_get_avail_bytes(vq, &in, &out);
+ virtqueue_get_avail_bytes(vq, &in, &out, quota, 0);
return in;
}
@@ -84,12 +84,18 @@ static void chr_read(void *opaque, const void *buf, size_t size)
static void virtio_rng_process(VirtIORNG *vrng)
{
size_t size;
+ unsigned quota;
if (!is_guest_ready(vrng)) {
return;
}
- size = get_request_size(vrng->vq);
+ if (vrng->quota_remaining < 0) {
+ quota = 0;
+ } else {
+ quota = MIN((uint64_t)vrng->quota_remaining, (uint64_t)UINT32_MAX);
+ }
+ size = get_request_size(vrng->vq, quota);
size = MIN(vrng->quota_remaining, size);
if (size) {
rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index efa8a81db6..155da58dcd 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -306,7 +306,7 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port)
if (use_multiport(port->vser) && !port->guest_connected) {
return 0;
}
- virtqueue_get_avail_bytes(vq, &bytes, NULL);
+ virtqueue_get_avail_bytes(vq, &bytes, NULL, 4096, 0);
return bytes;
}
diff --git a/hw/virtio.c b/hw/virtio.c
index ec8b7d8463..f40a8c5571 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -336,7 +336,8 @@ static unsigned virtqueue_next_desc(hwaddr desc_pa,
}
void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
- unsigned int *out_bytes)
+ unsigned int *out_bytes,
+ unsigned max_in_bytes, unsigned max_out_bytes)
{
unsigned int idx;
unsigned int total_bufs, in_total, out_total;
@@ -385,6 +386,9 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
} else {
out_total += vring_desc_len(desc_pa, i);
}
+ if (in_total >= max_in_bytes && out_total >= max_out_bytes) {
+ goto done;
+ }
} while ((i = virtqueue_next_desc(desc_pa, i, max)) != max);
if (!indirect)
@@ -392,6 +396,7 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
else
total_bufs++;
}
+done:
if (in_bytes) {
*in_bytes = in_total;
}
@@ -405,12 +410,8 @@ int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes,
{
unsigned int in_total, out_total;
- virtqueue_get_avail_bytes(vq, &in_total, &out_total);
- if ((in_bytes && in_bytes < in_total)
- || (out_bytes && out_bytes < out_total)) {
- return 1;
- }
- return 0;
+ virtqueue_get_avail_bytes(vq, &in_total, &out_total, in_bytes, out_bytes);
+ return in_bytes <= in_total && out_bytes <= out_total;
}
void virtqueue_map_sg(struct iovec *sg, hwaddr *addr,
diff --git a/hw/virtio.h b/hw/virtio.h
index df8d0f7b69..7c17f7ba0b 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -150,7 +150,8 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem);
int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes,
unsigned int out_bytes);
void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
- unsigned int *out_bytes);
+ unsigned int *out_bytes,
+ unsigned max_in_bytes, unsigned max_out_bytes);
void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);