From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 10/24] qdev-monitor: Fix check for full bus
Date: Mon, 22 Jun 2015 21:04:35 +0200 [thread overview]
Message-ID: <1434999889-849-11-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1434999889-849-1-git-send-email-armbru@redhat.com>
Property bus has always been too screwed up to be really usable for
values other than plain bus IDs. This just fixes a bug that crept in
in commit 1395af6 "qdev: add a maximum device allowed field for the
bus."
It doesn't always fail when it should:
$ qemu-system-x86_64 -nodefaults -device virtio-serial-pci -device virtio-rng-device,bus=pci.0/virtio-serial-pci/virtio-bus
Happily plugs the virtio-rng-device into the virtio-bus provided by
virtio-serial-pci, even though its only slot is already occupied by a
virtio-serial-device.
And sometimes fails when it shouldn't:
$ qemu-system-x86_64 -nodefaults -device virtio-serial-pci -device virtserialport,bus=virtio-bus/virtio-serial-device
Yes, the virtio-bus is full, but the virtio-serial-bus provided by
virtio-serial-device isn't, and that's the one we're trying to use.
Root cause: we check "bus full" when we resolve the first element of
the path. That's the correct one only when it's also the last one.
Fix by moving the "bus full" check to right before we return a bus.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
qdev-monitor.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 2c4d4c8..afc0395 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -435,10 +435,6 @@ static BusState *qbus_find(const char *path)
if (!bus) {
qerror_report(QERR_BUS_NOT_FOUND, elem);
return NULL;
- } else if (qbus_is_full(bus)) {
- qerror_report(ERROR_CLASS_GENERIC_ERROR, "Bus '%s' is full",
- elem);
- return NULL;
}
pos = len;
}
@@ -449,7 +445,7 @@ static BusState *qbus_find(const char *path)
pos++;
}
if (path[pos] == '\0') {
- return bus;
+ break;
}
/* find device */
@@ -474,21 +470,21 @@ static BusState *qbus_find(const char *path)
if (path[pos] == '\0') {
/* last specified element is a device. If it has exactly
* one child bus accept it nevertheless */
- switch (dev->num_child_bus) {
- case 0:
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "Device '%s' has no child bus", elem);
- return NULL;
- case 1:
- return QLIST_FIRST(&dev->child_bus);
- default:
+ if (dev->num_child_bus == 1) {
+ bus = QLIST_FIRST(&dev->child_bus);
+ break;
+ }
+ if (dev->num_child_bus) {
qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' has multiple child busses", elem);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
- return NULL;
+ } else {
+ qerror_report(ERROR_CLASS_GENERIC_ERROR,
+ "Device '%s' has no child bus", elem);
}
+ return NULL;
}
/* find bus */
@@ -506,6 +502,13 @@ static BusState *qbus_find(const char *path)
return NULL;
}
}
+
+ if (qbus_is_full(bus)) {
+ qerror_report(ERROR_CLASS_GENERIC_ERROR, "Bus '%s' is full",
+ path);
+ return NULL;
+ }
+ return bus;
}
DeviceState *qdev_device_add(QemuOpts *opts)
--
1.9.3
next prev parent reply other threads:[~2015-06-22 19:05 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 19:04 [Qemu-devel] [PULL 00/24] Monitor patches Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 01/24] qobject: Use 'bool' for qbool Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 02/24] qobject: Use 'bool' inside qdict Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 03/24] monitor: remove debug prints Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 04/24] monitor: cleanup parsing of cmd name and cmd arguments Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 05/24] monitor: Point to "help" command on syntax error Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 06/24] monitor: Fix failure path for "S" argument Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 07/24] monitor: Split mon_get_cpu fn to remove ENV_GET_CPU Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 08/24] disas: Remove uses of CPU env Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 09/24] qdev-monitor: Stop error avalanche in qbus_find_recursive() Markus Armbruster
2015-06-22 19:04 ` Markus Armbruster [this message]
2015-06-22 19:04 ` [Qemu-devel] [PULL 11/24] qdev-monitor: Convert qbus_find() to Error Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 12/24] qdev-monitor: Propagate errors through set_property() Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 13/24] qdev-monitor: Propagate errors through qdev_device_add() Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 14/24] QemuOpts: Wean off qerror_report_err() Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 15/24] vl: Avoid qerror_report() outside QMP command handlers Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 16/24] vl: Use error_report() for --display errors Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 17/24] qerror: Eliminate QERR_DEVICE_NOT_FOUND Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 18/24] qerror: Clean up QERR_ macros to expand into a single string Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 19/24] tpm: Avoid qerror_report() outside QMP command handlers Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 20/24] qmp: Wean off qerror_report() Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 21/24] qerror: Finally unused, clean up Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 22/24] qerror: Move #include out of qerror.h Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 23/24] Include qapi/qmp/qerror.h exactly where needed Markus Armbruster
2015-06-22 19:04 ` [Qemu-devel] [PULL 24/24] Include monitor/monitor.h " Markus Armbruster
2015-06-23 12:32 ` [Qemu-devel] [PULL 00/24] Monitor patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1434999889-849-11-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).