* [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers
@ 2016-05-09 12:07 Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 01/23] hw/ppc/spapr: Fix crash when specifying bad parameters to spapr-pci-host-bridge Stefan Hajnoczi
` (23 more replies)
0 siblings, 24 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel; +Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Stefan Hajnoczi
v2:
* Fix missing s/X/(1u << X)/ conversion in Patch 3 [Marc]
This patch series eliminates code duplication in libqos virtio.
include/standard-headers/ contains the Linux virtio header files so we don't
need to define our own version of the structs and constants.
Eric Blake (1):
qapi: Don't pass NULL to printf in string input visitor
Gerd Hoffmann (2):
usb/uhci: move pid check
Revert "acpi: mark PMTIMER as unlocked"
Igor Mammedov (1):
acpi: fix bios linker loadder COMMAND_ALLOCATE on bigendian host
James Hogan (1):
target-mips: Fix RDHWR exception host PC
Jan Vesely (1):
configure: Check if struct fsxattr is available from linux header
Kevin Wolf (2):
vvfat: Fix volume name assertion
vvfat: Fix default volume label
Markus Armbruster (3):
QemuOpts: Fix qemu_opts_foreach() dangling location regression
replay: Fix dangling location bug in replay_configure()
qom: -object error messages lost location, restore it
Michael Roth (1):
spapr_drc: fix aborts during DRC-count based hotplug
Peter Maydell (1):
Update version for v2.6.0-rc4 release
Samuel Thibault (1):
slirp: fix guest network access with darwin host
Stefan Hajnoczi (8):
libqos: use virtio_ids.h for device ID definitions
libqos: drop duplicated PCI vendor ID definition
libqos: drop duplicated virtio_config.h definitions
libqos: drop duplicated virtio_ring.h bit definitions
libqos: drop duplicated virtio_vring.h structs
libqos: drop duplicated virtio_blk.h definitions
libqos: drop duplicated virtio_scsi.h definitions
libqos: drop duplicated virtio_pci.h definitions
Thomas Huth (1):
hw/ppc/spapr: Fix crash when specifying bad parameters to
spapr-pci-host-bridge
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 01/23] hw/ppc/spapr: Fix crash when specifying bad parameters to spapr-pci-host-bridge
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 02/23] usb/uhci: move pid check Stefan Hajnoczi
` (22 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Thomas Huth,
David Gibson
From: Thomas Huth <thuth@redhat.com>
QEMU currently crashes when using bad parameters for the
spapr-pci-host-bridge device:
$ qemu-system-ppc64 -device spapr-pci-host-bridge,buid=0x123,liobn=0x321,mem_win_addr=0x1,io_win_addr=0x10
Segmentation fault
The problem is that spapr_tce_find_by_liobn() might return NULL, but
the code in spapr_populate_pci_dt() does not check for this condition
and then tries to dereference this NULL pointer.
Apart from that, the return value of spapr_populate_pci_dt() also
has to be checked for all PCI buses, not only for the last one, to
make sure we catch all errors.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/spapr.c | 9 ++++-----
hw/ppc/spapr_pci.c | 3 +++
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index feaab08..b69995e 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -940,11 +940,10 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
QLIST_FOREACH(phb, &spapr->phbs, list) {
ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt);
- }
-
- if (ret < 0) {
- fprintf(stderr, "couldn't setup PCI devices in fdt\n");
- exit(1);
+ if (ret < 0) {
+ error_report("couldn't setup PCI devices in fdt");
+ exit(1);
+ }
}
/* RTAS */
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 8c20d34..573e635 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1816,6 +1816,9 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
sizeof(interrupt_map)));
tcet = spapr_tce_find_by_liobn(SPAPR_PCI_LIOBN(phb->index, 0));
+ if (!tcet) {
+ return -1;
+ }
spapr_dma_dt(fdt, bus_off, "ibm,dma-window",
tcet->liobn, tcet->bus_offset,
tcet->nb_table << tcet->page_shift);
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 02/23] usb/uhci: move pid check
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 01/23] hw/ppc/spapr: Fix crash when specifying bad parameters to spapr-pci-host-bridge Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 03/23] spapr_drc: fix aborts during DRC-count based hotplug Stefan Hajnoczi
` (21 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Gerd Hoffmann,
Peter Maydell
From: Gerd Hoffmann <kraxel@redhat.com>
commit "5f77e06 usb: add pid check at the first of uhci_handle_td()"
moved the pid verification to the start of the uhci_handle_td function,
to simplify the error handling (we don't have to free stuff which we
didn't allocate in the first place ...).
Problem is now the check fires too often, it raises error IRQs even for
TDs which we are not going to process because they are not set active.
So, lets move down the check a bit, so it is done only for active TDs,
but still before we are going to allocate stuff to process the requested
transfer.
Reported-by: Joe Clifford <joe@thunderbug.co.uk>
Tested-by: Joe Clifford <joe@thunderbug.co.uk>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1461321893-15811-1-git-send-email-kraxel@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/usb/hcd-uhci.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 18057bf..ca72a80 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -776,19 +776,6 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr,
uint8_t pid = td->token & 0xff;
UHCIAsync *async;
- switch (pid) {
- case USB_TOKEN_OUT:
- case USB_TOKEN_SETUP:
- case USB_TOKEN_IN:
- break;
- default:
- /* invalid pid : frame interrupted */
- s->status |= UHCI_STS_HCPERR;
- s->cmd &= ~UHCI_CMD_RS;
- uhci_update_irq(s);
- return TD_RESULT_STOP_FRAME;
- }
-
async = uhci_async_find_td(s, td_addr);
if (async) {
if (uhci_queue_verify(async->queue, qh_addr, td, td_addr, queuing)) {
@@ -828,6 +815,19 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr,
return TD_RESULT_NEXT_QH;
}
+ switch (pid) {
+ case USB_TOKEN_OUT:
+ case USB_TOKEN_SETUP:
+ case USB_TOKEN_IN:
+ break;
+ default:
+ /* invalid pid : frame interrupted */
+ s->status |= UHCI_STS_HCPERR;
+ s->cmd &= ~UHCI_CMD_RS;
+ uhci_update_irq(s);
+ return TD_RESULT_STOP_FRAME;
+ }
+
if (async) {
if (queuing) {
/* we are busy filling the queue, we are not prepared
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 03/23] spapr_drc: fix aborts during DRC-count based hotplug
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 01/23] hw/ppc/spapr: Fix crash when specifying bad parameters to spapr-pci-host-bridge Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 02/23] usb/uhci: move pid check Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 04/23] QemuOpts: Fix qemu_opts_foreach() dangling location regression Stefan Hajnoczi
` (20 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Michael Roth,
Bharata B Rao, david, qemu-ppc
From: Michael Roth <mdroth@linux.vnet.ibm.com>
CPU/memory resources can be signalled en-masse via
spapr_hotplug_req_add_by_count(), and when doing so, actually change
the meaning of the 'drc' parameter passed to
spapr_hotplug_req_event() to be a count rather than an index.
f40eb92 added a hook in spapr_hotplug_req_event() to record when a
device had been 'signalled' to the guest, but that code assumes that
drc is always an index. In cases where it's a count, such as memory
hotplug, the DRC lookup will fail, leading to an assert.
Fix this by only explicitly setting the signalled state for cases where
we are doing PCI hotplug.
For other resources types, since we cannot selectively track whether a
resource has been signalled in cases where we signal attach as a count,
set the 'signalled' state to true immediately upon making the
resource available via drck->attach().
Reported-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
Cc: david@gibson.dropbear.id.au
Cc: qemu-ppc@nongnu.org
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/spapr_drc.c | 12 +++++++++++-
hw/ppc/spapr_events.c | 7 +++----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 3173940..1f5f1d7 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -364,7 +364,17 @@ static void attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt,
drc->fdt = fdt;
drc->fdt_start_offset = fdt_start_offset;
drc->configured = coldplug;
- drc->signalled = coldplug;
+ /* 'logical' DR resources such as memory/cpus are in some cases treated
+ * as a pool of resources from which the guest is free to choose from
+ * based on only a count. for resources that can be assigned in this
+ * fashion, we must assume the resource is signalled immediately
+ * since a single hotplug request might make an arbitrary number of
+ * such attached resources available to the guest, as opposed to
+ * 'physical' DR resources such as PCI where each device/resource is
+ * signalled individually.
+ */
+ drc->signalled = (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI)
+ ? true : coldplug;
object_property_add_link(OBJECT(drc), "device",
object_get_typename(OBJECT(drc->dev)),
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index 269ab7e..049fb1b 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -442,6 +442,9 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,
switch (drc_type) {
case SPAPR_DR_CONNECTOR_TYPE_PCI:
hp->hotplug_type = RTAS_LOG_V6_HP_TYPE_PCI;
+ if (hp->hotplug_action == RTAS_LOG_V6_HP_ACTION_ADD) {
+ spapr_hotplug_set_signalled(drc);
+ }
break;
case SPAPR_DR_CONNECTOR_TYPE_LMB:
hp->hotplug_type = RTAS_LOG_V6_HP_TYPE_MEMORY;
@@ -462,10 +465,6 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,
rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp, true);
- if (hp->hotplug_action == RTAS_LOG_V6_HP_ACTION_ADD) {
- spapr_hotplug_set_signalled(drc);
- }
-
qemu_irq_pulse(xics_get_qirq(spapr->icp, spapr->check_exception_irq));
}
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 04/23] QemuOpts: Fix qemu_opts_foreach() dangling location regression
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (2 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 03/23] spapr_drc: fix aborts during DRC-count based hotplug Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 05/23] replay: Fix dangling location bug in replay_configure() Stefan Hajnoczi
` (19 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel; +Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
qemu_opts_foreach() pushes and pops a Location with automatic storage
duration. Except it fails to pop when @func() returns non-zero.
cur_loc then points to unused stack space, and will most likely get
clobbered in short order.
Clobbered cur_loc can make loc_pop() and error_print_loc() crash or
report bogus locations.
Affects several qemu command line options as well as qemu-img,
qemu-io, qemu-nbd -object, and blkdebug's configuration file.
Broken in commit a4c7367, v2.4.0.
Reproducer:
$ qemu-system-x86_64 -nodefaults -display none -object secret,id=foo,foo=bar
main() reports "Property '.foo' not found" like this:
if (qemu_opts_foreach(qemu_find_opts("object"),
user_creatable_add_opts_foreach,
object_create_delayed, &err)) {
error_report_err(err);
exit(1);
}
cur_loc then points to where qemu_opts_foreach()'s Location used to
be, i.e. unused stack space. With optimization, this Location doesn't
get clobbered for me, and also happens to be the correct location.
Without optimization, it does get clobbered in a way that makes
error_report_err() report no location.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1461767349-15329-2-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
util/qemu-option.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/util/qemu-option.c b/util/qemu-option.c
index dd9e73d..3467dc2 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -1108,19 +1108,19 @@ int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
{
Location loc;
QemuOpts *opts;
- int rc;
+ int rc = 0;
loc_push_none(&loc);
QTAILQ_FOREACH(opts, &list->head, next) {
loc_restore(&opts->loc);
rc = func(opaque, opts, errp);
if (rc) {
- return rc;
+ break;
}
assert(!errp || !*errp);
}
loc_pop(&loc);
- return 0;
+ return rc;
}
static size_t count_opts_list(QemuOptsList *list)
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 05/23] replay: Fix dangling location bug in replay_configure()
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (3 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 04/23] QemuOpts: Fix qemu_opts_foreach() dangling location regression Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 06/23] qom: -object error messages lost location, restore it Stefan Hajnoczi
` (18 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Markus Armbruster,
Eduardo Habkost
From: Markus Armbruster <armbru@redhat.com>
replay_configure() pushes and pops a Location with automatic storage
duration. Except it fails to pop when -icount parameter "rr" isn't
given. cur_loc then points to unused stack space, and will most
likely get clobbered in short order.
Clobbered cur_loc can make loc_pop() and error_print_loc() crash or
report bogus locations.
Broken in commit 890ad55.
I didn't take the time to find a reproducer.
Cc: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1461767349-15329-3-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
---
replay/replay.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/replay/replay.c b/replay/replay.c
index 7c2573a..167fd29 100644
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -275,7 +275,7 @@ void replay_configure(QemuOpts *opts)
rr = qemu_opt_get(opts, "rr");
if (!rr) {
/* Just enabling icount */
- return;
+ goto out;
} else if (!strcmp(rr, "record")) {
mode = REPLAY_MODE_RECORD;
} else if (!strcmp(rr, "replay")) {
@@ -293,6 +293,7 @@ void replay_configure(QemuOpts *opts)
replay_enable(fname, mode);
+out:
loc_pop(&loc);
}
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 06/23] qom: -object error messages lost location, restore it
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (4 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 05/23] replay: Fix dangling location bug in replay_configure() Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 07/23] target-mips: Fix RDHWR exception host PC Stefan Hajnoczi
` (17 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Markus Armbruster,
Daniel P. Berrange
From: Markus Armbruster <armbru@redhat.com>
qemu_opts_foreach() runs its callback with the error location set to
the option's location. Any errors the callback reports use the
option's location automatically.
Commit 90998d5 moved the actual error reporting from "inside"
qemu_opts_foreach() to after it. Here's a typical hunk:
if (qemu_opts_foreach(qemu_find_opts("object"),
- object_create,
- object_create_initial, NULL)) {
+ user_creatable_add_opts_foreach,
+ object_create_initial, &err)) {
+ error_report_err(err);
exit(1);
}
Before, object_create() reports from within qemu_opts_foreach(), using
the option's location. Afterwards, we do it after
qemu_opts_foreach(), using whatever location happens to be current
there. Commonly a "none" location.
This is because Error objects don't have location information.
Problematic.
Reproducer:
$ qemu-system-x86_64 -nodefaults -display none -object secret,id=foo,foo=bar
qemu-system-x86_64: Property '.foo' not found
Note no location. This commit restores it:
qemu-system-x86_64: -object secret,id=foo,foo=bar: Property '.foo' not found
Note that the qemu_opts_foreach() bug just fixed could mask the bug
here: if the location it leaves dangling hasn't been clobbered, yet,
it's the correct one.
Reported-by: Eric Blake <eblake@redhat.com>
Cc: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1461767349-15329-4-git-send-email-armbru@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Paragraph on Error added to commit message]
---
include/qom/object_interfaces.h | 5 +++--
qemu-img.c | 39 +++++++++++----------------------------
qemu-io.c | 3 +--
qemu-nbd.c | 3 +--
qom/object_interfaces.c | 4 +++-
vl.c | 6 ++----
6 files changed, 21 insertions(+), 39 deletions(-)
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index d579746..8b17f4d 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -140,7 +140,7 @@ typedef bool (*user_creatable_add_opts_predicate)(const char *type);
* user_creatable_add_opts_foreach:
* @opaque: a user_creatable_add_opts_predicate callback or NULL
* @opts: options to create
- * @errp: if an error occurs, a pointer to an area to store the error
+ * @errp: unused
*
* An iterator callback to be used in conjunction with
* the qemu_opts_foreach() method for creating a list of
@@ -148,8 +148,9 @@ typedef bool (*user_creatable_add_opts_predicate)(const char *type);
*
* The @opaque parameter can be passed a user_creatable_add_opts_predicate
* callback to filter which types of object are created during iteration.
+ * When it fails, report the error.
*
- * Returns: 0 on success, -1 on error
+ * Returns: 0 on success, -1 when an error was reported.
*/
int user_creatable_add_opts_foreach(void *opaque,
QemuOpts *opts, Error **errp);
diff --git a/qemu-img.c b/qemu-img.c
index 1697762..46f2a6d 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -435,8 +435,7 @@ static int img_create(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_err)) {
- error_report_err(local_err);
+ NULL, NULL)) {
goto fail;
}
@@ -598,7 +597,6 @@ static int img_check(int argc, char **argv)
bool writethrough;
ImageCheck *check;
bool quiet = false;
- Error *local_err = NULL;
bool image_opts = false;
fmt = NULL;
@@ -679,8 +677,7 @@ static int img_check(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_err)) {
- error_report_err(local_err);
+ NULL, NULL)) {
return 1;
}
@@ -871,8 +868,7 @@ static int img_commit(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_err)) {
- error_report_err(local_err);
+ NULL, NULL)) {
return 1;
}
@@ -1133,7 +1129,6 @@ static int img_compare(int argc, char **argv)
int64_t nb_sectors;
int c, pnum;
uint64_t progress_base;
- Error *local_err = NULL;
bool image_opts = false;
cache = BDRV_DEFAULT_CACHE;
@@ -1201,8 +1196,7 @@ static int img_compare(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_err)) {
- error_report_err(local_err);
+ NULL, NULL)) {
ret = 2;
goto out4;
}
@@ -1864,8 +1858,7 @@ static int img_convert(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_err)) {
- error_report_err(local_err);
+ NULL, NULL)) {
goto fail_getopt;
}
@@ -2299,7 +2292,6 @@ static int img_info(int argc, char **argv)
bool chain = false;
const char *filename, *fmt, *output;
ImageInfoList *list;
- Error *local_err = NULL;
bool image_opts = false;
fmt = NULL;
@@ -2363,8 +2355,7 @@ static int img_info(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_err)) {
- error_report_err(local_err);
+ NULL, NULL)) {
return 1;
}
@@ -2513,7 +2504,6 @@ static int img_map(int argc, char **argv)
int64_t length;
MapEntry curr = { .length = 0 }, next;
int ret = 0;
- Error *local_err = NULL;
bool image_opts = false;
fmt = NULL;
@@ -2573,8 +2563,7 @@ static int img_map(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_err)) {
- error_report_err(local_err);
+ NULL, NULL)) {
return 1;
}
@@ -2717,8 +2706,7 @@ static int img_snapshot(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &err)) {
- error_report_err(err);
+ NULL, NULL)) {
return 1;
}
@@ -2867,8 +2855,7 @@ static int img_rebase(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_err)) {
- error_report_err(local_err);
+ NULL, NULL)) {
return 1;
}
@@ -3133,7 +3120,6 @@ static int img_resize(int argc, char **argv)
bool quiet = false;
BlockBackend *blk = NULL;
QemuOpts *param;
- Error *local_err = NULL;
static QemuOptsList resize_options = {
.name = "resize_options",
@@ -3204,8 +3190,7 @@ static int img_resize(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_err)) {
- error_report_err(local_err);
+ NULL, NULL)) {
return 1;
}
@@ -3297,7 +3282,6 @@ static int img_amend(int argc, char **argv)
bool quiet = false, progress = false;
BlockBackend *blk = NULL;
BlockDriverState *bs = NULL;
- Error *local_err = NULL;
bool image_opts = false;
cache = BDRV_DEFAULT_CACHE;
@@ -3365,8 +3349,7 @@ static int img_amend(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_err)) {
- error_report_err(local_err);
+ NULL, NULL)) {
ret = -1;
goto out_no_progress;
}
diff --git a/qemu-io.c b/qemu-io.c
index 288bba8..0598251 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -534,8 +534,7 @@ int main(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_error)) {
- error_report_err(local_error);
+ NULL, NULL)) {
exit(1);
}
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 2c9754e..c55b40f 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -711,8 +711,7 @@ int main(int argc, char **argv)
if (qemu_opts_foreach(&qemu_object_opts,
user_creatable_add_opts_foreach,
- NULL, &local_err)) {
- error_report_err(local_err);
+ NULL, NULL)) {
exit(EXIT_FAILURE);
}
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index ab5da35..3931890 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -170,6 +170,7 @@ int user_creatable_add_opts_foreach(void *opaque, QemuOpts *opts, Error **errp)
{
bool (*type_predicate)(const char *) = opaque;
Object *obj = NULL;
+ Error *err = NULL;
const char *type;
type = qemu_opt_get(opts, "qom-type");
@@ -178,8 +179,9 @@ int user_creatable_add_opts_foreach(void *opaque, QemuOpts *opts, Error **errp)
return 0;
}
- obj = user_creatable_add_opts(opts, errp);
+ obj = user_creatable_add_opts(opts, &err);
if (!obj) {
+ error_report_err(err);
return -1;
}
object_unref(obj);
diff --git a/vl.c b/vl.c
index 9df534f..5fd22cb 100644
--- a/vl.c
+++ b/vl.c
@@ -4291,8 +4291,7 @@ int main(int argc, char **argv, char **envp)
if (qemu_opts_foreach(qemu_find_opts("object"),
user_creatable_add_opts_foreach,
- object_create_initial, &err)) {
- error_report_err(err);
+ object_create_initial, NULL)) {
exit(1);
}
@@ -4410,8 +4409,7 @@ int main(int argc, char **argv, char **envp)
if (qemu_opts_foreach(qemu_find_opts("object"),
user_creatable_add_opts_foreach,
- object_create_delayed, &err)) {
- error_report_err(err);
+ object_create_delayed, NULL)) {
exit(1);
}
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 07/23] target-mips: Fix RDHWR exception host PC
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (5 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 06/23] qom: -object error messages lost location, restore it Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 08/23] slirp: fix guest network access with darwin host Stefan Hajnoczi
` (16 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, James Hogan, Leon Alrae,
Yongbok Kim, Aurelien Jarno
From: James Hogan <james.hogan@imgtec.com>
Commit b00c72180c36 ("target-mips: add PC, XNP reg numbers to RDHWR")
changed the rdhwr helpers to use check_hwrena() to check the register
being accessed is enabled in CP0_HWREna when used from user mode. If
that check fails an EXCP_RI exception is raised at the host PC
calculated with GETPC().
However check_hwrena() may not be fully inlined as the
do_raise_exception() part of it is common regardless of the arguments.
This causes GETPC() to calculate the address in the call in the helper
instead of the generated code calling the helper. No TB will be found
and the EPC reported with the resulting guest RI exception points to the
beginning of the TB instead of the RDHWR instruction.
We can't reliably force check_hwrena() to be inlined, and converting it
to a macro would be ugly, so instead pass the host PC in as an argument,
with each rdhwr helper passing GETPC(). This should avoid any dependence
on compiler behaviour, and in practice seems to ensure the full inlining
of check_hwrena() on x86_64.
This issue causes failures when running a MIPS KVM (trap & emulate)
guest in a MIPS QEMU TCG guest, as the inner guest kernel will do a
RDHWR of counter, which is disabled in the outer guest's CP0_HWREna by
KVM so it can emulate the inner guest's counter. The emulation fails and
the RI exception is passed to the inner guest.
Fixes: b00c72180c36 ("target-mips: add PC, XNP reg numbers to RDHWR")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Leon Alrae <leon.alrae@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
---
target-mips/op_helper.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index 8ec1bef..4417e6b 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -2294,29 +2294,29 @@ void helper_deret(CPUMIPSState *env)
}
#endif /* !CONFIG_USER_ONLY */
-static inline void check_hwrena(CPUMIPSState *env, int reg)
+static inline void check_hwrena(CPUMIPSState *env, int reg, uintptr_t pc)
{
if ((env->hflags & MIPS_HFLAG_CP0) || (env->CP0_HWREna & (1 << reg))) {
return;
}
- do_raise_exception(env, EXCP_RI, GETPC());
+ do_raise_exception(env, EXCP_RI, pc);
}
target_ulong helper_rdhwr_cpunum(CPUMIPSState *env)
{
- check_hwrena(env, 0);
+ check_hwrena(env, 0, GETPC());
return env->CP0_EBase & 0x3ff;
}
target_ulong helper_rdhwr_synci_step(CPUMIPSState *env)
{
- check_hwrena(env, 1);
+ check_hwrena(env, 1, GETPC());
return env->SYNCI_Step;
}
target_ulong helper_rdhwr_cc(CPUMIPSState *env)
{
- check_hwrena(env, 2);
+ check_hwrena(env, 2, GETPC());
#ifdef CONFIG_USER_ONLY
return env->CP0_Count;
#else
@@ -2326,19 +2326,19 @@ target_ulong helper_rdhwr_cc(CPUMIPSState *env)
target_ulong helper_rdhwr_ccres(CPUMIPSState *env)
{
- check_hwrena(env, 3);
+ check_hwrena(env, 3, GETPC());
return env->CCRes;
}
target_ulong helper_rdhwr_performance(CPUMIPSState *env)
{
- check_hwrena(env, 4);
+ check_hwrena(env, 4, GETPC());
return env->CP0_Performance0;
}
target_ulong helper_rdhwr_xnp(CPUMIPSState *env)
{
- check_hwrena(env, 5);
+ check_hwrena(env, 5, GETPC());
return (env->CP0_Config5 >> CP0C5_XNP) & 1;
}
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 08/23] slirp: fix guest network access with darwin host
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (6 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 07/23] target-mips: Fix RDHWR exception host PC Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:43 ` Samuel Thibault
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 09/23] qapi: Don't pass NULL to printf in string input visitor Stefan Hajnoczi
` (15 subsequent siblings)
23 siblings, 1 reply; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Samuel Thibault,
Peter Maydell
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
On Darwin, connect, sendto and friends want the exact size of the sockaddr,
not more (and in particular, not sizeof(struct sockaddr_storaget))
This commit adds the sockaddr_size helper to be used when passing a sockaddr
size to such function, and makes use of it int sendto and connect calls.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: John Arbuckle <programmingkidx@gmail.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
slirp/ip_icmp.c | 2 +-
slirp/socket.c | 2 +-
slirp/socket.h | 12 ++++++++++++
slirp/tcp_subr.c | 2 +-
4 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index 590dada..5ffc7a6 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -186,7 +186,7 @@ icmp_input(struct mbuf *m, int hlen)
sotranslate_out(so, &addr);
if(sendto(so->s, icmp_ping_msg, strlen(icmp_ping_msg), 0,
- (struct sockaddr *)&addr, sizeof(addr)) == -1) {
+ (struct sockaddr *)&addr, sockaddr_size(&addr)) == -1) {
DEBUG_MISC((dfd,"icmp_input udp sendto tx errno = %d-%s\n",
errno,strerror(errno)));
icmp_send_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, 0, strerror(errno));
diff --git a/slirp/socket.c b/slirp/socket.c
index bd97b2d..a10eff1 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -627,7 +627,7 @@ sosendto(struct socket *so, struct mbuf *m)
/* Don't care what port we get */
ret = sendto(so->s, m->m_data, m->m_len, 0,
- (struct sockaddr *)&addr, sizeof(addr));
+ (struct sockaddr *)&addr, sockaddr_size(&addr));
if (ret < 0)
return -1;
diff --git a/slirp/socket.h b/slirp/socket.h
index 7dca506..b602e69 100644
--- a/slirp/socket.h
+++ b/slirp/socket.h
@@ -122,6 +122,18 @@ static inline int sockaddr_equal(struct sockaddr_storage *a,
return 0;
}
+static inline socklen_t sockaddr_size(struct sockaddr_storage *a)
+{
+ switch (a->ss_family) {
+ case AF_INET:
+ return sizeof(struct sockaddr_in);
+ case AF_INET6:
+ return sizeof(struct sockaddr_in6);
+ default:
+ g_assert_not_reached();
+ }
+}
+
struct socket *solookup(struct socket **, struct socket *,
struct sockaddr_storage *, struct sockaddr_storage *);
struct socket *socreate(Slirp *);
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index 32ff452..6b9fef2 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -413,7 +413,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)
sotranslate_out(so, &addr);
/* We don't care what port we get */
- ret = connect(s,(struct sockaddr *)&addr,sizeof (addr));
+ ret = connect(s, (struct sockaddr *)&addr, sockaddr_size(&addr));
/*
* If it's not in progress, it failed, so we just return 0,
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 09/23] qapi: Don't pass NULL to printf in string input visitor
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (7 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 08/23] slirp: fix guest network access with darwin host Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 10/23] vvfat: Fix volume name assertion Stefan Hajnoczi
` (14 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Eric Blake,
Markus Armbruster
From: Eric Blake <eblake@redhat.com>
Make sure the error message for visit_type_uint64() gracefully
handles a NULL 'name' when called from the top level or a list
context, as not all the world behaves like glibc in allowing
NULL through a printf-family %s.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1461879932-9020-21-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
qapi/string-input-visitor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index ab12953..5ea2d77 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -222,7 +222,7 @@ static void parse_type_int64(Visitor *v, const char *name, int64_t *obj,
return;
error:
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"an int64 value or range");
}
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 10/23] vvfat: Fix volume name assertion
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (8 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 09/23] qapi: Don't pass NULL to printf in string input visitor Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 11/23] vvfat: Fix default volume label Stefan Hajnoczi
` (13 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Kevin Wolf, qemu-stable
From: Kevin Wolf <kwolf@redhat.com>
Commit d5941dd made the volume name configurable, but it didn't consider
that the rw code compares the volume name string to assert that the
first directory entry is the volume name. This made vvfat crash in rw
mode.
This fixes the assertion to compare with the configured volume name
instead of a literal string.
Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/vvfat.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/block/vvfat.c b/block/vvfat.c
index 6b85314..ff3df35 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -2283,12 +2283,17 @@ DLOG(fprintf(stderr, "commit_direntries for %s, parent_mapping_index %d\n", mapp
factor * (old_cluster_count - new_cluster_count));
for (c = first_cluster; !fat_eof(s, c); c = modified_fat_get(s, c)) {
+ direntry_t *first_direntry;
void* direntry = array_get(&(s->directory), current_dir_index);
int ret = vvfat_read(s->bs, cluster2sector(s, c), direntry,
s->sectors_per_cluster);
if (ret)
return ret;
- assert(!strncmp(s->directory.pointer, "QEMU", 4));
+
+ /* The first directory entry on the filesystem is the volume name */
+ first_direntry = (direntry_t*) s->directory.pointer;
+ assert(!memcmp(first_direntry->name, s->volume_label, 11));
+
current_dir_index += factor;
}
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 11/23] vvfat: Fix default volume label
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (9 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 10/23] vvfat: Fix volume name assertion Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 12/23] acpi: fix bios linker loadder COMMAND_ALLOCATE on bigendian host Stefan Hajnoczi
` (12 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Kevin Wolf, qemu-stable
From: Kevin Wolf <kwolf@redhat.com>
Commit d5941dd documented that it leaves the default volume name as it
was ("QEMU VVFAT"), but it doesn't actually implement this. You get an
empty name (eleven space characters) instead.
This fixes the implementation to apply the advertised default.
Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/vvfat.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block/vvfat.c b/block/vvfat.c
index ff3df35..183fc4f 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -1109,6 +1109,8 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
goto fail;
}
memcpy(s->volume_label, label, label_length);
+ } else {
+ memcpy(s->volume_label, "QEMU VVFAT", 10);
}
if (floppy) {
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 12/23] acpi: fix bios linker loadder COMMAND_ALLOCATE on bigendian host
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (10 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 11/23] vvfat: Fix default volume label Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 13/23] configure: Check if struct fsxattr is available from linux header Stefan Hajnoczi
` (11 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Igor Mammedov,
Michael S. Tsirkin
From: Igor Mammedov <imammedo@redhat.com>
'make check' fails with:
ERROR:tests/bios-tables-test.c:493:load_expected_aml:
assertion failed: (g_file_test(aml_file, G_FILE_TEST_EXISTS))
since commit:
caf50c7166a6ed96c462ab5db4b495e1234e4cc6
tests: pc: acpi: drop not needed 'expected SSDT' blobs
Assert happens because qemu-system-x86_64 generates
SSDT table and test looks for a corresponding expected
table to compare with.
However there is no expected SSDT blob anymore, since
QEMU souldn't generate one. As it happens BIOS is not
able to read ACPI tables from QEMU and fallbacks to
embeded legacy ACPI codepath, which generates SSDT.
That happens due to wrongly sized endiannes conversion
which makes
uint8_t BiosLinkerLoaderEntry.alloc.zone
end up with 0 due to truncation of 32 bit integer
which on host is 1 or 2.
Fix it by dropping invalid cpu_to_le32() as uint8_t
doesn't require any conversion.
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1330174
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
---
hw/acpi/bios-linker-loader.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/hw/acpi/bios-linker-loader.c b/hw/acpi/bios-linker-loader.c
index ace9abb..5153ab1 100644
--- a/hw/acpi/bios-linker-loader.c
+++ b/hw/acpi/bios-linker-loader.c
@@ -135,9 +135,8 @@ void bios_linker_loader_alloc(GArray *linker,
strncpy(entry.alloc.file, file, sizeof entry.alloc.file - 1);
entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ALLOCATE);
entry.alloc.align = cpu_to_le32(alloc_align);
- entry.alloc.zone = cpu_to_le32(alloc_fseg ?
- BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG :
- BIOS_LINKER_LOADER_ALLOC_ZONE_HIGH);
+ entry.alloc.zone = alloc_fseg ? BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG :
+ BIOS_LINKER_LOADER_ALLOC_ZONE_HIGH;
/* Alloc entries must come first, so prepend them */
g_array_prepend_vals(linker, &entry, sizeof entry);
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 13/23] configure: Check if struct fsxattr is available from linux header
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (11 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 12/23] acpi: fix bios linker loadder COMMAND_ALLOCATE on bigendian host Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 14/23] Revert "acpi: mark PMTIMER as unlocked" Stefan Hajnoczi
` (10 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Jan Vesely, qemu-trivial,
Markus Armbruster, Peter Maydell, Stefan Weil
From: Jan Vesely <jano.vesely@gmail.com>
Fixes build failure with --enable-xfsctl and
new linux headers (>=4.5) and older xfsprogs(<4.5):
In file included from /usr/include/xfs/xfs.h:38:0,
from /var/tmp/portage/app-emulation/qemu-2.5.0-r1/work/qemu-2.5.0/block/raw-posix.c:97:
/usr/include/xfs/xfs_fs.h:42:8: error: redefinition of ‘struct fsxattr’
struct fsxattr {
^
In file included from /var/tmp/portage/app-emulation/qemu-2.5.0-r1/work/qemu-2.5.0/block/raw-posix.c:60:0:
/usr/include/linux/fs.h:155:8: note: originally defined here
struct fsxattr {
This is really a bug in the system headers, but we can work around it
by defining HAVE_FSXATTR in the QEMU headers if linux/fs.h provides
the struct, so that xfs_fs.h doesn't try to define it as well.
CC: qemu-trivial@nongnu.org
CC: Markus Armbruster <armbru@redhat.com>
CC: Peter Maydell <peter.maydell@linaro.org>
CC: Stefan Weil <sw@weilnetz.de>
Tested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Jan Vesely <jano.vesely@gmail.com>
[PMM: adjusted commit message, comments]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
configure | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/configure b/configure
index ab54f3c..c37fc5f 100755
--- a/configure
+++ b/configure
@@ -4494,6 +4494,21 @@ if test "$fortify_source" != "no"; then
fi
##########################################
+# check if struct fsxattr is available via linux/fs.h
+
+have_fsxattr=no
+cat > $TMPC << EOF
+#include <linux/fs.h>
+struct fsxattr foo;
+int main(void) {
+ return 0;
+}
+EOF
+if compile_prog "" "" ; then
+ have_fsxattr=yes
+fi
+
+##########################################
# End of CC checks
# After here, no more $cc or $ld runs
@@ -5160,6 +5175,14 @@ fi
if test "$have_ifaddrs_h" = "yes" ; then
echo "HAVE_IFADDRS_H=y" >> $config_host_mak
fi
+
+# Work around a system header bug with some kernel/XFS header
+# versions where they both try to define 'struct fsxattr':
+# xfs headers will not try to redefine structs from linux headers
+# if this macro is set.
+if test "$have_fsxattr" = "yes" ; then
+ echo "HAVE_FSXATTR=y" >> $config_host_mak
+fi
if test "$vte" = "yes" ; then
echo "CONFIG_VTE=y" >> $config_host_mak
echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 14/23] Revert "acpi: mark PMTIMER as unlocked"
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (12 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 13/23] configure: Check if struct fsxattr is available from linux header Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 15/23] Update version for v2.6.0-rc4 release Stefan Hajnoczi
` (9 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Gerd Hoffmann,
Peter Maydell
From: Gerd Hoffmann <kraxel@redhat.com>
This reverts commit 7070e085d490c396f9237c8f10bf8b6e69cd0066.
Commit message claims locking is not needed, but that appears
to not be true, seabios ehci driver runs into timekeeping problems
with this, see
https://bugzilla.redhat.com/show_bug.cgi?id=1322713
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1460702609-25971-1-git-send-email-kraxel@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/acpi/core.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index 7925a1a..6a2f452 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -536,7 +536,6 @@ void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
ar->tmr.timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, acpi_pm_tmr_timer, ar);
memory_region_init_io(&ar->tmr.io, memory_region_owner(parent),
&acpi_pm_tmr_ops, ar, "acpi-tmr", 4);
- memory_region_clear_global_locking(&ar->tmr.io);
memory_region_add_subregion(parent, 8, &ar->tmr.io);
}
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 15/23] Update version for v2.6.0-rc4 release
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (13 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 14/23] Revert "acpi: mark PMTIMER as unlocked" Stefan Hajnoczi
@ 2016-05-09 12:07 ` Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 16/23] libqos: use virtio_ids.h for device ID definitions Stefan Hajnoczi
` (8 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:07 UTC (permalink / raw)
To: qemu-devel; +Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
VERSION | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/VERSION b/VERSION
index 127ee42..7ff039e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.5.93
+2.5.94
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 16/23] libqos: use virtio_ids.h for device ID definitions
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (14 preceding siblings ...)
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 15/23] Update version for v2.6.0-rc4 release Stefan Hajnoczi
@ 2016-05-09 12:08 ` Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 17/23] libqos: drop duplicated PCI vendor ID definition Stefan Hajnoczi
` (7 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Stefan Hajnoczi
Avoid redefining device IDs. Use the standard Linux headers that are
already in the source tree.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/libqos/virtio.h | 9 ---------
tests/virtio-blk-test.c | 7 ++++---
tests/virtio-net-test.c | 5 +++--
tests/virtio-scsi-test.c | 5 +++--
4 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
index 0101278..af03793 100644
--- a/tests/libqos/virtio.h
+++ b/tests/libqos/virtio.h
@@ -19,15 +19,6 @@
#define QVIRTIO_DRIVER 0x2
#define QVIRTIO_DRIVER_OK 0x4
-#define QVIRTIO_NET_DEVICE_ID 0x1
-#define QVIRTIO_BLK_DEVICE_ID 0x2
-#define QVIRTIO_CONSOLE_DEVICE_ID 0x3
-#define QVIRTIO_RNG_DEVICE_ID 0x4
-#define QVIRTIO_BALLOON_DEVICE_ID 0x5
-#define QVIRTIO_RPMSG_DEVICE_ID 0x7
-#define QVIRTIO_SCSI_DEVICE_ID 0x8
-#define QVIRTIO_9P_DEVICE_ID 0x9
-
#define QVIRTIO_F_NOTIFY_ON_EMPTY 0x01000000
#define QVIRTIO_F_ANY_LAYOUT 0x08000000
#define QVIRTIO_F_RING_INDIRECT_DESC 0x10000000
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 3a66630..02107a6 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -19,6 +19,7 @@
#include "libqos/malloc-pc.h"
#include "libqos/malloc-generic.h"
#include "qemu/bswap.h"
+#include "standard-headers/linux/virtio_ids.h"
#define QVIRTIO_BLK_F_BARRIER 0x00000001
#define QVIRTIO_BLK_F_SIZE_MAX 0x00000002
@@ -119,9 +120,9 @@ static QVirtioPCIDevice *virtio_blk_pci_init(QPCIBus *bus, int slot)
{
QVirtioPCIDevice *dev;
- dev = qvirtio_pci_device_find(bus, QVIRTIO_BLK_DEVICE_ID);
+ dev = qvirtio_pci_device_find(bus, VIRTIO_ID_BLOCK);
g_assert(dev != NULL);
- g_assert_cmphex(dev->vdev.device_type, ==, QVIRTIO_BLK_DEVICE_ID);
+ g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_BLOCK);
g_assert_cmphex(dev->pdev->devfn, ==, ((slot << 3) | PCI_FN));
qvirtio_pci_device_enable(dev);
@@ -733,7 +734,7 @@ static void mmio_basic(void)
dev = qvirtio_mmio_init_device(MMIO_DEV_BASE_ADDR, MMIO_PAGE_SIZE);
g_assert(dev != NULL);
- g_assert_cmphex(dev->vdev.device_type, ==, QVIRTIO_BLK_DEVICE_ID);
+ g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_BLOCK);
qvirtio_reset(&qvirtio_mmio, &dev->vdev);
qvirtio_set_acknowledge(&qvirtio_mmio, &dev->vdev);
diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 04cfcd5..7fd7a2f 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -21,6 +21,7 @@
#include "libqos/malloc-generic.h"
#include "qemu/bswap.h"
#include "hw/virtio/virtio-net.h"
+#include "standard-headers/linux/virtio_ids.h"
#define PCI_SLOT_HP 0x06
#define PCI_SLOT 0x04
@@ -40,9 +41,9 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot)
{
QVirtioPCIDevice *dev;
- dev = qvirtio_pci_device_find(bus, QVIRTIO_NET_DEVICE_ID);
+ dev = qvirtio_pci_device_find(bus, VIRTIO_ID_NET);
g_assert(dev != NULL);
- g_assert_cmphex(dev->vdev.device_type, ==, QVIRTIO_NET_DEVICE_ID);
+ g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_NET);
qvirtio_pci_device_enable(dev);
qvirtio_reset(&qvirtio_pci, &dev->vdev);
diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c
index d78747a..625bd6d 100644
--- a/tests/virtio-scsi-test.c
+++ b/tests/virtio-scsi-test.c
@@ -18,6 +18,7 @@
#include "libqos/malloc.h"
#include "libqos/malloc-pc.h"
#include "libqos/malloc-generic.h"
+#include "standard-headers/linux/virtio_ids.h"
#define PCI_SLOT 0x02
#define PCI_FN 0x00
@@ -164,10 +165,10 @@ static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot)
vs->alloc = pc_alloc_init();
vs->bus = qpci_init_pc();
- dev = qvirtio_pci_device_find(vs->bus, QVIRTIO_SCSI_DEVICE_ID);
+ dev = qvirtio_pci_device_find(vs->bus, VIRTIO_ID_SCSI);
vs->dev = (QVirtioDevice *)dev;
g_assert(dev != NULL);
- g_assert_cmphex(vs->dev->device_type, ==, QVIRTIO_SCSI_DEVICE_ID);
+ g_assert_cmphex(vs->dev->device_type, ==, VIRTIO_ID_SCSI);
qvirtio_pci_device_enable(dev);
qvirtio_reset(&qvirtio_pci, vs->dev);
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 17/23] libqos: drop duplicated PCI vendor ID definition
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (15 preceding siblings ...)
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 16/23] libqos: use virtio_ids.h for device ID definitions Stefan Hajnoczi
@ 2016-05-09 12:08 ` Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 18/23] libqos: drop duplicated virtio_config.h definitions Stefan Hajnoczi
` (6 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Stefan Hajnoczi
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/libqos/virtio-pci.c | 3 ++-
tests/libqos/virtio.h | 2 --
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
index fde2ff0..275c14d 100644
--- a/tests/libqos/virtio-pci.c
+++ b/tests/libqos/virtio-pci.c
@@ -17,6 +17,7 @@
#include "libqos/malloc.h"
#include "libqos/malloc-pc.h"
+#include "hw/pci/pci.h"
#include "hw/pci/pci_regs.h"
typedef struct QVirtioPCIForeachData {
@@ -264,7 +265,7 @@ void qvirtio_pci_foreach(QPCIBus *bus, uint16_t device_type,
.device_type = device_type,
.user_data = data };
- qpci_device_foreach(bus, QVIRTIO_VENDOR_ID, -1,
+ qpci_device_foreach(bus, PCI_VENDOR_ID_REDHAT_QUMRANET, -1,
qvirtio_pci_foreach_callback, &d);
}
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
index af03793..e663bcf 100644
--- a/tests/libqos/virtio.h
+++ b/tests/libqos/virtio.h
@@ -12,8 +12,6 @@
#include "libqos/malloc.h"
-#define QVIRTIO_VENDOR_ID 0x1AF4
-
#define QVIRTIO_RESET 0x0
#define QVIRTIO_ACKNOWLEDGE 0x1
#define QVIRTIO_DRIVER 0x2
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 18/23] libqos: drop duplicated virtio_config.h definitions
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (16 preceding siblings ...)
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 17/23] libqos: drop duplicated PCI vendor ID definition Stefan Hajnoczi
@ 2016-05-09 12:08 ` Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 19/23] libqos: drop duplicated virtio_ring.h bit definitions Stefan Hajnoczi
` (5 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Stefan Hajnoczi
Note that VIRTIO_F_ANY_LAYOUT and VIRTIO_F_NOTIFY_ON_EMPTY are bit
numbers in virtio_config.h but bit masks in qtest virtio.h. Therefore
it's necessary to change users from X to (1u << X).
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/libqos/virtio.c | 19 ++++++++++---------
tests/libqos/virtio.h | 9 ---------
tests/virtio-blk-test.c | 6 ++++--
3 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
index 613dece..ee9e892 100644
--- a/tests/libqos/virtio.c
+++ b/tests/libqos/virtio.c
@@ -11,6 +11,7 @@
#include <glib.h>
#include "libqtest.h"
#include "libqos/virtio.h"
+#include "standard-headers/linux/virtio_config.h"
uint8_t qvirtio_config_readb(const QVirtioBus *bus, QVirtioDevice *d,
uint64_t addr)
@@ -55,28 +56,28 @@ QVirtQueue *qvirtqueue_setup(const QVirtioBus *bus, QVirtioDevice *d,
void qvirtio_reset(const QVirtioBus *bus, QVirtioDevice *d)
{
- bus->set_status(d, QVIRTIO_RESET);
- g_assert_cmphex(bus->get_status(d), ==, QVIRTIO_RESET);
+ bus->set_status(d, 0);
+ g_assert_cmphex(bus->get_status(d), ==, 0);
}
void qvirtio_set_acknowledge(const QVirtioBus *bus, QVirtioDevice *d)
{
- bus->set_status(d, bus->get_status(d) | QVIRTIO_ACKNOWLEDGE);
- g_assert_cmphex(bus->get_status(d), ==, QVIRTIO_ACKNOWLEDGE);
+ bus->set_status(d, bus->get_status(d) | VIRTIO_CONFIG_S_ACKNOWLEDGE);
+ g_assert_cmphex(bus->get_status(d), ==, VIRTIO_CONFIG_S_ACKNOWLEDGE);
}
void qvirtio_set_driver(const QVirtioBus *bus, QVirtioDevice *d)
{
- bus->set_status(d, bus->get_status(d) | QVIRTIO_DRIVER);
+ bus->set_status(d, bus->get_status(d) | VIRTIO_CONFIG_S_DRIVER);
g_assert_cmphex(bus->get_status(d), ==,
- QVIRTIO_DRIVER | QVIRTIO_ACKNOWLEDGE);
+ VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_ACKNOWLEDGE);
}
void qvirtio_set_driver_ok(const QVirtioBus *bus, QVirtioDevice *d)
{
- bus->set_status(d, bus->get_status(d) | QVIRTIO_DRIVER_OK);
- g_assert_cmphex(bus->get_status(d), ==,
- QVIRTIO_DRIVER_OK | QVIRTIO_DRIVER | QVIRTIO_ACKNOWLEDGE);
+ bus->set_status(d, bus->get_status(d) | VIRTIO_CONFIG_S_DRIVER_OK);
+ g_assert_cmphex(bus->get_status(d), ==, VIRTIO_CONFIG_S_DRIVER_OK |
+ VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_ACKNOWLEDGE);
}
void qvirtio_wait_queue_isr(const QVirtioBus *bus, QVirtioDevice *d,
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
index e663bcf..993ae0e 100644
--- a/tests/libqos/virtio.h
+++ b/tests/libqos/virtio.h
@@ -12,13 +12,6 @@
#include "libqos/malloc.h"
-#define QVIRTIO_RESET 0x0
-#define QVIRTIO_ACKNOWLEDGE 0x1
-#define QVIRTIO_DRIVER 0x2
-#define QVIRTIO_DRIVER_OK 0x4
-
-#define QVIRTIO_F_NOTIFY_ON_EMPTY 0x01000000
-#define QVIRTIO_F_ANY_LAYOUT 0x08000000
#define QVIRTIO_F_RING_INDIRECT_DESC 0x10000000
#define QVIRTIO_F_RING_EVENT_IDX 0x20000000
#define QVIRTIO_F_BAD_FEATURE 0x40000000
@@ -27,8 +20,6 @@
#define QVRING_DESC_F_WRITE 0x2
#define QVRING_DESC_F_INDIRECT 0x4
-#define QVIRTIO_F_NOTIFY_ON_EMPTY 0x01000000
-#define QVIRTIO_F_ANY_LAYOUT 0x08000000
#define QVIRTIO_F_RING_INDIRECT_DESC 0x10000000
#define QVIRTIO_F_RING_EVENT_IDX 0x20000000
#define QVIRTIO_F_BAD_FEATURE 0x40000000
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 02107a6..adc6862 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -20,6 +20,7 @@
#include "libqos/malloc-generic.h"
#include "qemu/bswap.h"
#include "standard-headers/linux/virtio_ids.h"
+#include "standard-headers/linux/virtio_config.h"
#define QVIRTIO_BLK_F_BARRIER 0x00000001
#define QVIRTIO_BLK_F_SIZE_MAX 0x00000002
@@ -240,7 +241,7 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice *dev,
guest_free(alloc, req_addr);
- if (features & QVIRTIO_F_ANY_LAYOUT) {
+ if (features & (1u << VIRTIO_F_ANY_LAYOUT)) {
/* Write and read with 2 descriptor layout */
/* Write request */
req.type = QVIRTIO_BLK_T_OUT;
@@ -607,7 +608,8 @@ static void pci_idx(void)
features = qvirtio_get_features(&qvirtio_pci, &dev->vdev);
features = features & ~(QVIRTIO_F_BAD_FEATURE |
QVIRTIO_F_RING_INDIRECT_DESC |
- QVIRTIO_F_NOTIFY_ON_EMPTY | QVIRTIO_BLK_F_SCSI);
+ (1u << VIRTIO_F_NOTIFY_ON_EMPTY) |
+ QVIRTIO_BLK_F_SCSI);
qvirtio_set_features(&qvirtio_pci, &dev->vdev, features);
vqpci = (QVirtQueuePCI *)qvirtqueue_setup(&qvirtio_pci, &dev->vdev,
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 19/23] libqos: drop duplicated virtio_ring.h bit definitions
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (17 preceding siblings ...)
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 18/23] libqos: drop duplicated virtio_config.h definitions Stefan Hajnoczi
@ 2016-05-09 12:08 ` Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 20/23] libqos: drop duplicated virtio_vring.h structs Stefan Hajnoczi
` (4 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Stefan Hajnoczi
Note that virtio_ring.h defines feature bits using their bit number:
#define VIRTIO_RING_F_INDIRECT_DESC 28
On the other hand libqos virtio.h uses the bit mask:
#define QVIRTIO_F_RING_INDIRECT_DESC 0x10000000
The patch makes the necessary adjustments.
I have used "1u << BITMASK" instead of "1ULL << BITMASK" because the
64-bit feature fields are not implemented in libqos virtio.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/libqos/virtio-mmio.c | 5 +++--
tests/libqos/virtio-pci.c | 5 +++--
tests/libqos/virtio.c | 13 +++++++------
tests/libqos/virtio.h | 14 --------------
tests/virtio-blk-test.c | 18 +++++++++++-------
tests/virtio-net-test.c | 5 +++--
6 files changed, 27 insertions(+), 33 deletions(-)
diff --git a/tests/libqos/virtio-mmio.c b/tests/libqos/virtio-mmio.c
index a4382f3..8aa05e7 100644
--- a/tests/libqos/virtio-mmio.c
+++ b/tests/libqos/virtio-mmio.c
@@ -14,6 +14,7 @@
#include "libqos/virtio-mmio.h"
#include "libqos/malloc.h"
#include "libqos/malloc-generic.h"
+#include "standard-headers/linux/virtio_ring.h"
static uint8_t qvirtio_mmio_config_readb(QVirtioDevice *d, uint64_t addr)
{
@@ -136,8 +137,8 @@ static QVirtQueue *qvirtio_mmio_virtqueue_setup(QVirtioDevice *d,
vq->free_head = 0;
vq->num_free = vq->size;
vq->align = dev->page_size;
- vq->indirect = (dev->features & QVIRTIO_F_RING_INDIRECT_DESC) != 0;
- vq->event = (dev->features & QVIRTIO_F_RING_EVENT_IDX) != 0;
+ vq->indirect = (dev->features & (1u << VIRTIO_RING_F_INDIRECT_DESC)) != 0;
+ vq->event = (dev->features & (1u << VIRTIO_RING_F_EVENT_IDX)) != 0;
writel(dev->addr + QVIRTIO_MMIO_QUEUE_NUM, vq->size);
diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
index 275c14d..0b98ef2 100644
--- a/tests/libqos/virtio-pci.c
+++ b/tests/libqos/virtio-pci.c
@@ -16,6 +16,7 @@
#include "libqos/pci-pc.h"
#include "libqos/malloc.h"
#include "libqos/malloc-pc.h"
+#include "standard-headers/linux/virtio_ring.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_regs.h"
@@ -213,8 +214,8 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,
vqpci->vq.free_head = 0;
vqpci->vq.num_free = vqpci->vq.size;
vqpci->vq.align = QVIRTIO_PCI_ALIGN;
- vqpci->vq.indirect = (feat & QVIRTIO_F_RING_INDIRECT_DESC) != 0;
- vqpci->vq.event = (feat & QVIRTIO_F_RING_EVENT_IDX) != 0;
+ vqpci->vq.indirect = (feat & (1u << VIRTIO_RING_F_INDIRECT_DESC)) != 0;
+ vqpci->vq.event = (feat & (1u << VIRTIO_RING_F_EVENT_IDX)) != 0;
vqpci->msix_entry = -1;
vqpci->msix_addr = 0;
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
index ee9e892..69b5426 100644
--- a/tests/libqos/virtio.c
+++ b/tests/libqos/virtio.c
@@ -12,6 +12,7 @@
#include "libqtest.h"
#include "libqos/virtio.h"
#include "standard-headers/linux/virtio_config.h"
+#include "standard-headers/linux/virtio_ring.h"
uint8_t qvirtio_config_readb(const QVirtioBus *bus, QVirtioDevice *d,
uint64_t addr)
@@ -173,7 +174,7 @@ QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
/* indirect->desc[i].addr */
writeq(indirect->desc + (16 * i), 0);
/* indirect->desc[i].flags */
- writew(indirect->desc + (16 * i) + 12, QVRING_DESC_F_NEXT);
+ writew(indirect->desc + (16 * i) + 12, VRING_DESC_F_NEXT);
/* indirect->desc[i].next */
writew(indirect->desc + (16 * i) + 14, i + 1);
}
@@ -191,7 +192,7 @@ void qvring_indirect_desc_add(QVRingIndirectDesc *indirect, uint64_t data,
flags = readw(indirect->desc + (16 * indirect->index) + 12);
if (write) {
- flags |= QVRING_DESC_F_WRITE;
+ flags |= VRING_DESC_F_WRITE;
}
/* indirect->desc[indirect->index].addr */
@@ -211,11 +212,11 @@ uint32_t qvirtqueue_add(QVirtQueue *vq, uint64_t data, uint32_t len, bool write,
vq->num_free--;
if (write) {
- flags |= QVRING_DESC_F_WRITE;
+ flags |= VRING_DESC_F_WRITE;
}
if (next) {
- flags |= QVRING_DESC_F_NEXT;
+ flags |= VRING_DESC_F_NEXT;
}
/* vq->desc[vq->free_head].addr */
@@ -242,7 +243,7 @@ uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indirect)
writel(vq->desc + (16 * vq->free_head) + 8,
sizeof(QVRingDesc) * indirect->elem);
/* vq->desc[vq->free_head].flags */
- writew(vq->desc + (16 * vq->free_head) + 12, QVRING_DESC_F_INDIRECT);
+ writew(vq->desc + (16 * vq->free_head) + 12, VRING_DESC_F_INDIRECT);
return vq->free_head++; /* Return and increase, in this order */
}
@@ -268,7 +269,7 @@ void qvirtqueue_kick(const QVirtioBus *bus, QVirtioDevice *d, QVirtQueue *vq,
(sizeof(struct QVRingUsedElem) * vq->size));
/* < 1 because we add elements to avail queue one by one */
- if ((flags & QVRING_USED_F_NO_NOTIFY) == 0 &&
+ if ((flags & VRING_USED_F_NO_NOTIFY) == 0 &&
(!vq->event || (uint16_t)(idx-avail_event) < 1)) {
bus->virtqueue_kick(d, vq);
}
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
index 993ae0e..2af8036 100644
--- a/tests/libqos/virtio.h
+++ b/tests/libqos/virtio.h
@@ -12,22 +12,8 @@
#include "libqos/malloc.h"
-#define QVIRTIO_F_RING_INDIRECT_DESC 0x10000000
-#define QVIRTIO_F_RING_EVENT_IDX 0x20000000
#define QVIRTIO_F_BAD_FEATURE 0x40000000
-#define QVRING_DESC_F_NEXT 0x1
-#define QVRING_DESC_F_WRITE 0x2
-#define QVRING_DESC_F_INDIRECT 0x4
-
-#define QVIRTIO_F_RING_INDIRECT_DESC 0x10000000
-#define QVIRTIO_F_RING_EVENT_IDX 0x20000000
-#define QVIRTIO_F_BAD_FEATURE 0x40000000
-
-#define QVRING_AVAIL_F_NO_INTERRUPT 1
-
-#define QVRING_USED_F_NO_NOTIFY 1
-
typedef struct QVirtioDevice {
/* Device type */
uint16_t device_type;
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index adc6862..e4a3d9a 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -21,6 +21,7 @@
#include "qemu/bswap.h"
#include "standard-headers/linux/virtio_ids.h"
#include "standard-headers/linux/virtio_config.h"
+#include "standard-headers/linux/virtio_ring.h"
#define QVIRTIO_BLK_F_BARRIER 0x00000001
#define QVIRTIO_BLK_F_SIZE_MAX 0x00000002
@@ -184,7 +185,8 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice *dev,
features = qvirtio_get_features(bus, dev);
features = features & ~(QVIRTIO_F_BAD_FEATURE |
- QVIRTIO_F_RING_INDIRECT_DESC | QVIRTIO_F_RING_EVENT_IDX |
+ (1u << VIRTIO_RING_F_INDIRECT_DESC) |
+ (1u << VIRTIO_RING_F_EVENT_IDX) |
QVIRTIO_BLK_F_SCSI);
qvirtio_set_features(bus, dev, features);
@@ -350,9 +352,10 @@ static void pci_indirect(void)
g_assert_cmpint(capacity, ==, TEST_IMAGE_SIZE / 512);
features = qvirtio_get_features(&qvirtio_pci, &dev->vdev);
- g_assert_cmphex(features & QVIRTIO_F_RING_INDIRECT_DESC, !=, 0);
- features = features & ~(QVIRTIO_F_BAD_FEATURE | QVIRTIO_F_RING_EVENT_IDX |
- QVIRTIO_BLK_F_SCSI);
+ g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=, 0);
+ features = features & ~(QVIRTIO_F_BAD_FEATURE |
+ (1u << VIRTIO_RING_F_EVENT_IDX) |
+ QVIRTIO_BLK_F_SCSI);
qvirtio_set_features(&qvirtio_pci, &dev->vdev, features);
alloc = pc_alloc_init();
@@ -492,8 +495,9 @@ static void pci_msix(void)
features = qvirtio_get_features(&qvirtio_pci, &dev->vdev);
features = features & ~(QVIRTIO_F_BAD_FEATURE |
- QVIRTIO_F_RING_INDIRECT_DESC |
- QVIRTIO_F_RING_EVENT_IDX | QVIRTIO_BLK_F_SCSI);
+ (1u << VIRTIO_RING_F_INDIRECT_DESC) |
+ (1u << VIRTIO_RING_F_EVENT_IDX) |
+ QVIRTIO_BLK_F_SCSI);
qvirtio_set_features(&qvirtio_pci, &dev->vdev, features);
vqpci = (QVirtQueuePCI *)qvirtqueue_setup(&qvirtio_pci, &dev->vdev,
@@ -607,7 +611,7 @@ static void pci_idx(void)
features = qvirtio_get_features(&qvirtio_pci, &dev->vdev);
features = features & ~(QVIRTIO_F_BAD_FEATURE |
- QVIRTIO_F_RING_INDIRECT_DESC |
+ (1u << VIRTIO_RING_F_INDIRECT_DESC) |
(1u << VIRTIO_F_NOTIFY_ON_EMPTY) |
QVIRTIO_BLK_F_SCSI);
qvirtio_set_features(&qvirtio_pci, &dev->vdev, features);
diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 7fd7a2f..a66dab0 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -22,6 +22,7 @@
#include "qemu/bswap.h"
#include "hw/virtio/virtio-net.h"
#include "standard-headers/linux/virtio_ids.h"
+#include "standard-headers/linux/virtio_ring.h"
#define PCI_SLOT_HP 0x06
#define PCI_SLOT 0x04
@@ -71,8 +72,8 @@ static void driver_init(const QVirtioBus *bus, QVirtioDevice *dev)
features = qvirtio_get_features(bus, dev);
features = features & ~(QVIRTIO_F_BAD_FEATURE |
- QVIRTIO_F_RING_INDIRECT_DESC |
- QVIRTIO_F_RING_EVENT_IDX);
+ (1u << VIRTIO_RING_F_INDIRECT_DESC) |
+ (1u << VIRTIO_RING_F_EVENT_IDX));
qvirtio_set_features(bus, dev, features);
qvirtio_set_driver_ok(bus, dev);
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 20/23] libqos: drop duplicated virtio_vring.h structs
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (18 preceding siblings ...)
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 19/23] libqos: drop duplicated virtio_ring.h bit definitions Stefan Hajnoczi
@ 2016-05-09 12:08 ` Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 21/23] libqos: drop duplicated virtio_blk.h definitions Stefan Hajnoczi
` (3 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Stefan Hajnoczi
The descriptor element, used, and avail vring structs are defined in
virtio_ring.h. There is no need to duplicate them in libqos virtio.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/libqos/virtio.c | 10 +++++-----
tests/libqos/virtio.h | 39 +++++++--------------------------------
2 files changed, 12 insertions(+), 37 deletions(-)
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
index 69b5426..7910774 100644
--- a/tests/libqos/virtio.c
+++ b/tests/libqos/virtio.c
@@ -136,7 +136,7 @@ void qvring_init(const QGuestAllocator *alloc, QVirtQueue *vq, uint64_t addr)
int i;
vq->desc = addr;
- vq->avail = vq->desc + vq->size*sizeof(QVRingDesc);
+ vq->avail = vq->desc + vq->size * sizeof(struct vring_desc);
vq->used = (uint64_t)((vq->avail + sizeof(uint16_t) * (3 + vq->size)
+ vq->align - 1) & ~(vq->align - 1));
@@ -157,7 +157,7 @@ void qvring_init(const QGuestAllocator *alloc, QVirtQueue *vq, uint64_t addr)
/* vq->used->flags */
writew(vq->used, 0);
/* vq->used->avail_event */
- writew(vq->used+2+(sizeof(struct QVRingUsedElem)*vq->size), 0);
+ writew(vq->used + 2 + sizeof(struct vring_used_elem) * vq->size, 0);
}
QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
@@ -168,7 +168,7 @@ QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
indirect->index = 0;
indirect->elem = elem;
- indirect->desc = guest_alloc(alloc, sizeof(QVRingDesc)*elem);
+ indirect->desc = guest_alloc(alloc, sizeof(struct vring_desc) * elem);
for (i = 0; i < elem - 1; ++i) {
/* indirect->desc[i].addr */
@@ -241,7 +241,7 @@ uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indirect)
writeq(vq->desc + (16 * vq->free_head), indirect->desc);
/* vq->desc[vq->free_head].len */
writel(vq->desc + (16 * vq->free_head) + 8,
- sizeof(QVRingDesc) * indirect->elem);
+ sizeof(struct vring_desc) * indirect->elem);
/* vq->desc[vq->free_head].flags */
writew(vq->desc + (16 * vq->free_head) + 12, VRING_DESC_F_INDIRECT);
@@ -266,7 +266,7 @@ void qvirtqueue_kick(const QVirtioBus *bus, QVirtioDevice *d, QVirtQueue *vq,
/* Must read after idx is updated */
flags = readw(vq->avail);
avail_event = readw(vq->used + 4 +
- (sizeof(struct QVRingUsedElem) * vq->size));
+ sizeof(struct vring_used_elem) * vq->size);
/* < 1 because we add elements to avail queue one by one */
if ((flags & VRING_USED_F_NO_NOTIFY) == 0 &&
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
index 2af8036..c73fd8c 100644
--- a/tests/libqos/virtio.h
+++ b/tests/libqos/virtio.h
@@ -11,6 +11,7 @@
#define LIBQOS_VIRTIO_H
#include "libqos/malloc.h"
+#include "standard-headers/linux/virtio_ring.h"
#define QVIRTIO_F_BAD_FEATURE 0x40000000
@@ -19,36 +20,10 @@ typedef struct QVirtioDevice {
uint16_t device_type;
} QVirtioDevice;
-typedef struct QVRingDesc {
- uint64_t addr;
- uint32_t len;
- uint16_t flags;
- uint16_t next;
-} QVRingDesc;
-
-typedef struct QVRingAvail {
- uint16_t flags;
- uint16_t idx;
- uint16_t ring[0]; /* This is an array of uint16_t */
- uint16_t used_event;
-} QVRingAvail;
-
-typedef struct QVRingUsedElem {
- uint32_t id;
- uint32_t len;
-} QVRingUsedElem;
-
-typedef struct QVRingUsed {
- uint16_t flags;
- uint16_t idx;
- QVRingUsedElem ring[0]; /* This is an array of QVRingUsedElem structs */
- uint16_t avail_event;
-} QVRingUsed;
-
typedef struct QVirtQueue {
- uint64_t desc; /* This points to an array of QVRingDesc */
- uint64_t avail; /* This points to a QVRingAvail */
- uint64_t used; /* This points to a QVRingDesc */
+ uint64_t desc; /* This points to an array of struct vring_desc */
+ uint64_t avail; /* This points to a struct vring_avail */
+ uint64_t used; /* This points to a struct vring_desc */
uint16_t index;
uint32_t size;
uint32_t free_head;
@@ -59,7 +34,7 @@ typedef struct QVirtQueue {
} QVirtQueue;
typedef struct QVRingIndirectDesc {
- uint64_t desc; /* This points to an array fo QVRingDesc */
+ uint64_t desc; /* This points to an array fo struct vring_desc */
uint16_t index;
uint16_t elem;
} QVRingIndirectDesc;
@@ -110,9 +85,9 @@ typedef struct QVirtioBus {
static inline uint32_t qvring_size(uint32_t num, uint32_t align)
{
- return ((sizeof(struct QVRingDesc) * num + sizeof(uint16_t) * (3 + num)
+ return ((sizeof(struct vring_desc) * num + sizeof(uint16_t) * (3 + num)
+ align - 1) & ~(align - 1))
- + sizeof(uint16_t) * 3 + sizeof(struct QVRingUsedElem) * num;
+ + sizeof(uint16_t) * 3 + sizeof(struct vring_used_elem) * num;
}
uint8_t qvirtio_config_readb(const QVirtioBus *bus, QVirtioDevice *d,
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 21/23] libqos: drop duplicated virtio_blk.h definitions
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (19 preceding siblings ...)
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 20/23] libqos: drop duplicated virtio_vring.h structs Stefan Hajnoczi
@ 2016-05-09 12:08 ` Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 22/23] libqos: drop duplicated virtio_scsi.h definitions Stefan Hajnoczi
` (2 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Stefan Hajnoczi
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/virtio-blk-test.c | 50 ++++++++++++++++---------------------------------
1 file changed, 16 insertions(+), 34 deletions(-)
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index e4a3d9a..ff66d93 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -22,25 +22,7 @@
#include "standard-headers/linux/virtio_ids.h"
#include "standard-headers/linux/virtio_config.h"
#include "standard-headers/linux/virtio_ring.h"
-
-#define QVIRTIO_BLK_F_BARRIER 0x00000001
-#define QVIRTIO_BLK_F_SIZE_MAX 0x00000002
-#define QVIRTIO_BLK_F_SEG_MAX 0x00000004
-#define QVIRTIO_BLK_F_GEOMETRY 0x00000010
-#define QVIRTIO_BLK_F_RO 0x00000020
-#define QVIRTIO_BLK_F_BLK_SIZE 0x00000040
-#define QVIRTIO_BLK_F_SCSI 0x00000080
-#define QVIRTIO_BLK_F_WCE 0x00000200
-#define QVIRTIO_BLK_F_TOPOLOGY 0x00000400
-#define QVIRTIO_BLK_F_CONFIG_WCE 0x00000800
-
-#define QVIRTIO_BLK_T_IN 0
-#define QVIRTIO_BLK_T_OUT 1
-#define QVIRTIO_BLK_T_SCSI_CMD 2
-#define QVIRTIO_BLK_T_SCSI_CMD_OUT 3
-#define QVIRTIO_BLK_T_FLUSH 4
-#define QVIRTIO_BLK_T_FLUSH_OUT 5
-#define QVIRTIO_BLK_T_GET_ID 8
+#include "standard-headers/linux/virtio_blk.h"
#define TEST_IMAGE_SIZE (64 * 1024 * 1024)
#define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000)
@@ -187,14 +169,14 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice *dev,
features = features & ~(QVIRTIO_F_BAD_FEATURE |
(1u << VIRTIO_RING_F_INDIRECT_DESC) |
(1u << VIRTIO_RING_F_EVENT_IDX) |
- QVIRTIO_BLK_F_SCSI);
+ (1u << VIRTIO_BLK_F_SCSI));
qvirtio_set_features(bus, dev, features);
qvirtio_set_driver_ok(bus, dev);
/* Write and read with 3 descriptor layout */
/* Write request */
- req.type = QVIRTIO_BLK_T_OUT;
+ req.type = VIRTIO_BLK_T_OUT;
req.ioprio = 1;
req.sector = 0;
req.data = g_malloc0(512);
@@ -217,7 +199,7 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice *dev,
guest_free(alloc, req_addr);
/* Read request */
- req.type = QVIRTIO_BLK_T_IN;
+ req.type = VIRTIO_BLK_T_IN;
req.ioprio = 1;
req.sector = 0;
req.data = g_malloc0(512);
@@ -246,7 +228,7 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice *dev,
if (features & (1u << VIRTIO_F_ANY_LAYOUT)) {
/* Write and read with 2 descriptor layout */
/* Write request */
- req.type = QVIRTIO_BLK_T_OUT;
+ req.type = VIRTIO_BLK_T_OUT;
req.ioprio = 1;
req.sector = 1;
req.data = g_malloc0(512);
@@ -267,7 +249,7 @@ static void test_basic(const QVirtioBus *bus, QVirtioDevice *dev,
guest_free(alloc, req_addr);
/* Read request */
- req.type = QVIRTIO_BLK_T_IN;
+ req.type = VIRTIO_BLK_T_IN;
req.ioprio = 1;
req.sector = 1;
req.data = g_malloc0(512);
@@ -355,7 +337,7 @@ static void pci_indirect(void)
g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=, 0);
features = features & ~(QVIRTIO_F_BAD_FEATURE |
(1u << VIRTIO_RING_F_EVENT_IDX) |
- QVIRTIO_BLK_F_SCSI);
+ (1u << VIRTIO_BLK_F_SCSI));
qvirtio_set_features(&qvirtio_pci, &dev->vdev, features);
alloc = pc_alloc_init();
@@ -364,7 +346,7 @@ static void pci_indirect(void)
qvirtio_set_driver_ok(&qvirtio_pci, &dev->vdev);
/* Write request */
- req.type = QVIRTIO_BLK_T_OUT;
+ req.type = VIRTIO_BLK_T_OUT;
req.ioprio = 1;
req.sector = 0;
req.data = g_malloc0(512);
@@ -389,7 +371,7 @@ static void pci_indirect(void)
guest_free(alloc, req_addr);
/* Read request */
- req.type = QVIRTIO_BLK_T_IN;
+ req.type = VIRTIO_BLK_T_IN;
req.ioprio = 1;
req.sector = 0;
req.data = g_malloc0(512);
@@ -497,7 +479,7 @@ static void pci_msix(void)
features = features & ~(QVIRTIO_F_BAD_FEATURE |
(1u << VIRTIO_RING_F_INDIRECT_DESC) |
(1u << VIRTIO_RING_F_EVENT_IDX) |
- QVIRTIO_BLK_F_SCSI);
+ (1u << VIRTIO_BLK_F_SCSI));
qvirtio_set_features(&qvirtio_pci, &dev->vdev, features);
vqpci = (QVirtQueuePCI *)qvirtqueue_setup(&qvirtio_pci, &dev->vdev,
@@ -516,7 +498,7 @@ static void pci_msix(void)
g_assert_cmpint(capacity, ==, n_size / 512);
/* Write request */
- req.type = QVIRTIO_BLK_T_OUT;
+ req.type = VIRTIO_BLK_T_OUT;
req.ioprio = 1;
req.sector = 0;
req.data = g_malloc0(512);
@@ -540,7 +522,7 @@ static void pci_msix(void)
guest_free(alloc, req_addr);
/* Read request */
- req.type = QVIRTIO_BLK_T_IN;
+ req.type = VIRTIO_BLK_T_IN;
req.ioprio = 1;
req.sector = 0;
req.data = g_malloc0(512);
@@ -613,7 +595,7 @@ static void pci_idx(void)
features = features & ~(QVIRTIO_F_BAD_FEATURE |
(1u << VIRTIO_RING_F_INDIRECT_DESC) |
(1u << VIRTIO_F_NOTIFY_ON_EMPTY) |
- QVIRTIO_BLK_F_SCSI);
+ (1u << VIRTIO_BLK_F_SCSI));
qvirtio_set_features(&qvirtio_pci, &dev->vdev, features);
vqpci = (QVirtQueuePCI *)qvirtqueue_setup(&qvirtio_pci, &dev->vdev,
@@ -623,7 +605,7 @@ static void pci_idx(void)
qvirtio_set_driver_ok(&qvirtio_pci, &dev->vdev);
/* Write request */
- req.type = QVIRTIO_BLK_T_OUT;
+ req.type = VIRTIO_BLK_T_OUT;
req.ioprio = 1;
req.sector = 0;
req.data = g_malloc0(512);
@@ -642,7 +624,7 @@ static void pci_idx(void)
QVIRTIO_BLK_TIMEOUT_US);
/* Write request */
- req.type = QVIRTIO_BLK_T_OUT;
+ req.type = VIRTIO_BLK_T_OUT;
req.ioprio = 1;
req.sector = 1;
req.data = g_malloc0(512);
@@ -668,7 +650,7 @@ static void pci_idx(void)
guest_free(alloc, req_addr);
/* Read request */
- req.type = QVIRTIO_BLK_T_IN;
+ req.type = VIRTIO_BLK_T_IN;
req.ioprio = 1;
req.sector = 1;
req.data = g_malloc0(512);
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 22/23] libqos: drop duplicated virtio_scsi.h definitions
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (20 preceding siblings ...)
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 21/23] libqos: drop duplicated virtio_blk.h definitions Stefan Hajnoczi
@ 2016-05-09 12:08 ` Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 23/23] libqos: drop duplicated virtio_pci.h definitions Stefan Hajnoczi
2016-05-09 12:45 ` [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Stefan Hajnoczi
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/virtio-scsi-test.c | 45 +++++++++++++++------------------------------
1 file changed, 15 insertions(+), 30 deletions(-)
diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c
index 625bd6d..8b8f5f3 100644
--- a/tests/virtio-scsi-test.c
+++ b/tests/virtio-scsi-test.c
@@ -19,11 +19,11 @@
#include "libqos/malloc-pc.h"
#include "libqos/malloc-generic.h"
#include "standard-headers/linux/virtio_ids.h"
+#include "standard-headers/linux/virtio_scsi.h"
#define PCI_SLOT 0x02
#define PCI_FN 0x00
#define QVIRTIO_SCSI_TIMEOUT_US (1 * 1000 * 1000)
-#define CDB_SIZE 32
#define MAX_NUM_QUEUES 64
@@ -35,24 +35,6 @@ typedef struct {
QVirtQueue *vq[MAX_NUM_QUEUES + 2];
} QVirtIOSCSI;
-typedef struct {
- uint8_t lun[8];
- int64_t tag;
- uint8_t task_attr;
- uint8_t prio;
- uint8_t crn;
- uint8_t cdb[CDB_SIZE];
-} QEMU_PACKED QVirtIOSCSICmdReq;
-
-typedef struct {
- uint32_t sense_len;
- uint32_t resid;
- uint16_t status_qualifier;
- uint8_t status;
- uint8_t response;
- uint8_t sense[96];
-} QEMU_PACKED QVirtIOSCSICmdResp;
-
static void qvirtio_scsi_start(const char *extra_opts)
{
char *cmdline;
@@ -101,11 +83,11 @@ static uint8_t virtio_scsi_do_command(QVirtIOSCSI *vs, const uint8_t *cdb,
const uint8_t *data_in,
size_t data_in_len,
uint8_t *data_out, size_t data_out_len,
- QVirtIOSCSICmdResp *resp_out)
+ struct virtio_scsi_cmd_resp *resp_out)
{
QVirtQueue *vq;
- QVirtIOSCSICmdReq req = { { 0 } };
- QVirtIOSCSICmdResp resp = { .response = 0xff, .status = 0xff };
+ struct virtio_scsi_cmd_req req = { { 0 } };
+ struct virtio_scsi_cmd_resp resp = { .response = 0xff, .status = 0xff };
uint64_t req_addr, resp_addr, data_in_addr = 0, data_out_addr = 0;
uint8_t response;
uint32_t free_head;
@@ -114,7 +96,7 @@ static uint8_t virtio_scsi_do_command(QVirtIOSCSI *vs, const uint8_t *cdb,
req.lun[0] = 1; /* Select LUN */
req.lun[1] = 1; /* Select target 1 */
- memcpy(req.cdb, cdb, CDB_SIZE);
+ memcpy(req.cdb, cdb, VIRTIO_SCSI_CDB_SIZE);
/* XXX: Fix endian if any multi-byte field in req/resp is used */
@@ -139,7 +121,8 @@ static uint8_t virtio_scsi_do_command(QVirtIOSCSI *vs, const uint8_t *cdb,
qvirtqueue_kick(&qvirtio_pci, vs->dev, vq, free_head);
qvirtio_wait_queue_isr(&qvirtio_pci, vs->dev, vq, QVIRTIO_SCSI_TIMEOUT_US);
- response = readb(resp_addr + offsetof(QVirtIOSCSICmdResp, response));
+ response = readb(resp_addr +
+ offsetof(struct virtio_scsi_cmd_resp, response));
if (resp_out) {
memread(resp_addr, resp_out, sizeof(*resp_out));
@@ -154,10 +137,10 @@ static uint8_t virtio_scsi_do_command(QVirtIOSCSI *vs, const uint8_t *cdb,
static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot)
{
- const uint8_t test_unit_ready_cdb[CDB_SIZE] = {};
+ const uint8_t test_unit_ready_cdb[VIRTIO_SCSI_CDB_SIZE] = {};
QVirtIOSCSI *vs;
QVirtioPCIDevice *dev;
- QVirtIOSCSICmdResp resp;
+ struct virtio_scsi_cmd_resp resp;
void *addr;
int i;
@@ -240,10 +223,12 @@ static void test_unaligned_write_same(void)
QVirtIOSCSI *vs;
uint8_t buf1[512] = { 0 };
uint8_t buf2[512] = { 1 };
- const uint8_t write_same_cdb_1[CDB_SIZE] = { 0x41, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x02, 0x00 };
- const uint8_t write_same_cdb_2[CDB_SIZE] = { 0x41, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x33, 0x00, 0x00 };
+ const uint8_t write_same_cdb_1[VIRTIO_SCSI_CDB_SIZE] = {
+ 0x41, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00
+ };
+ const uint8_t write_same_cdb_2[VIRTIO_SCSI_CDB_SIZE] = {
+ 0x41, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x33, 0x00, 0x00
+ };
qvirtio_scsi_start("-drive file=blkdebug::null-co://,if=none,id=dr1"
",format=raw,file.align=4k "
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2 23/23] libqos: drop duplicated virtio_pci.h definitions
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (21 preceding siblings ...)
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 22/23] libqos: drop duplicated virtio_scsi.h definitions Stefan Hajnoczi
@ 2016-05-09 12:08 ` Stefan Hajnoczi
2016-05-09 12:45 ` [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: marc.mari.barcelo, Paolo Bonzini, jsnow, Stefan Hajnoczi
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/libqos/virtio-pci.c | 42 ++++++++++++++++++++++--------------------
tests/libqos/virtio-pci.h | 17 -----------------
tests/virtio-blk-test.c | 11 ++++++-----
tests/virtio-scsi-test.c | 3 ++-
4 files changed, 30 insertions(+), 43 deletions(-)
diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
index 0b98ef2..cdde0b3 100644
--- a/tests/libqos/virtio-pci.c
+++ b/tests/libqos/virtio-pci.c
@@ -17,6 +17,7 @@
#include "libqos/malloc.h"
#include "libqos/malloc-pc.h"
#include "standard-headers/linux/virtio_ring.h"
+#include "standard-headers/linux/virtio_pci.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_regs.h"
@@ -104,31 +105,31 @@ static uint64_t qvirtio_pci_config_readq(QVirtioDevice *d, uint64_t addr)
static uint32_t qvirtio_pci_get_features(QVirtioDevice *d)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
- return qpci_io_readl(dev->pdev, dev->addr + QVIRTIO_PCI_DEVICE_FEATURES);
+ return qpci_io_readl(dev->pdev, dev->addr + VIRTIO_PCI_HOST_FEATURES);
}
static void qvirtio_pci_set_features(QVirtioDevice *d, uint32_t features)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
- qpci_io_writel(dev->pdev, dev->addr + QVIRTIO_PCI_GUEST_FEATURES, features);
+ qpci_io_writel(dev->pdev, dev->addr + VIRTIO_PCI_GUEST_FEATURES, features);
}
static uint32_t qvirtio_pci_get_guest_features(QVirtioDevice *d)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
- return qpci_io_readl(dev->pdev, dev->addr + QVIRTIO_PCI_GUEST_FEATURES);
+ return qpci_io_readl(dev->pdev, dev->addr + VIRTIO_PCI_GUEST_FEATURES);
}
static uint8_t qvirtio_pci_get_status(QVirtioDevice *d)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
- return qpci_io_readb(dev->pdev, dev->addr + QVIRTIO_PCI_DEVICE_STATUS);
+ return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_STATUS);
}
static void qvirtio_pci_set_status(QVirtioDevice *d, uint8_t status)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
- qpci_io_writeb(dev->pdev, dev->addr + QVIRTIO_PCI_DEVICE_STATUS, status);
+ qpci_io_writeb(dev->pdev, dev->addr + VIRTIO_PCI_STATUS, status);
}
static bool qvirtio_pci_get_queue_isr_status(QVirtioDevice *d, QVirtQueue *vq)
@@ -152,7 +153,7 @@ static bool qvirtio_pci_get_queue_isr_status(QVirtioDevice *d, QVirtQueue *vq)
}
}
} else {
- return qpci_io_readb(dev->pdev, dev->addr + QVIRTIO_PCI_ISR_STATUS) & 1;
+ return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_ISR) & 1;
}
}
@@ -176,26 +177,26 @@ static bool qvirtio_pci_get_config_isr_status(QVirtioDevice *d)
}
}
} else {
- return qpci_io_readb(dev->pdev, dev->addr + QVIRTIO_PCI_ISR_STATUS) & 2;
+ return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_ISR) & 2;
}
}
static void qvirtio_pci_queue_select(QVirtioDevice *d, uint16_t index)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
- qpci_io_writeb(dev->pdev, dev->addr + QVIRTIO_PCI_QUEUE_SELECT, index);
+ qpci_io_writeb(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_SEL, index);
}
static uint16_t qvirtio_pci_get_queue_size(QVirtioDevice *d)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
- return qpci_io_readw(dev->pdev, dev->addr + QVIRTIO_PCI_QUEUE_SIZE);
+ return qpci_io_readw(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_NUM);
}
static void qvirtio_pci_set_queue_address(QVirtioDevice *d, uint32_t pfn)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
- qpci_io_writel(dev->pdev, dev->addr + QVIRTIO_PCI_QUEUE_ADDRESS, pfn);
+ qpci_io_writel(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_PFN, pfn);
}
static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,
@@ -213,7 +214,7 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,
vqpci->vq.size = qvirtio_pci_get_queue_size(d);
vqpci->vq.free_head = 0;
vqpci->vq.num_free = vqpci->vq.size;
- vqpci->vq.align = QVIRTIO_PCI_ALIGN;
+ vqpci->vq.align = VIRTIO_PCI_VRING_ALIGN;
vqpci->vq.indirect = (feat & (1u << VIRTIO_RING_F_INDIRECT_DESC)) != 0;
vqpci->vq.event = (feat & (1u << VIRTIO_RING_F_EVENT_IDX)) != 0;
@@ -227,9 +228,10 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,
/* Check power of 2 */
g_assert_cmpint(vqpci->vq.size & (vqpci->vq.size - 1), ==, 0);
- addr = guest_alloc(alloc, qvring_size(vqpci->vq.size, QVIRTIO_PCI_ALIGN));
+ addr = guest_alloc(alloc, qvring_size(vqpci->vq.size,
+ VIRTIO_PCI_VRING_ALIGN));
qvring_init(alloc, &vqpci->vq, addr);
- qvirtio_pci_set_queue_address(d, vqpci->vq.desc / QVIRTIO_PCI_ALIGN);
+ qvirtio_pci_set_queue_address(d, vqpci->vq.desc / VIRTIO_PCI_VRING_ALIGN);
return &vqpci->vq;
}
@@ -237,7 +239,7 @@ static QVirtQueue *qvirtio_pci_virtqueue_setup(QVirtioDevice *d,
static void qvirtio_pci_virtqueue_kick(QVirtioDevice *d, QVirtQueue *vq)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
- qpci_io_writew(dev->pdev, dev->addr + QVIRTIO_PCI_QUEUE_NOTIFY, vq->index);
+ qpci_io_writew(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_NOTIFY, vq->index);
}
const QVirtioBus qvirtio_pci = {
@@ -317,9 +319,9 @@ void qvirtqueue_pci_msix_setup(QVirtioPCIDevice *d, QVirtQueuePCI *vqpci,
control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT);
qvirtio_pci_queue_select(&d->vdev, vqpci->vq.index);
- qpci_io_writew(d->pdev, d->addr + QVIRTIO_PCI_MSIX_QUEUE_VECTOR, entry);
- vector = qpci_io_readw(d->pdev, d->addr + QVIRTIO_PCI_MSIX_QUEUE_VECTOR);
- g_assert_cmphex(vector, !=, QVIRTIO_MSI_NO_VECTOR);
+ qpci_io_writew(d->pdev, d->addr + VIRTIO_MSI_QUEUE_VECTOR, entry);
+ vector = qpci_io_readw(d->pdev, d->addr + VIRTIO_MSI_QUEUE_VECTOR);
+ g_assert_cmphex(vector, !=, VIRTIO_MSI_NO_VECTOR);
}
void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice *d,
@@ -349,7 +351,7 @@ void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice *d,
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL,
control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT);
- qpci_io_writew(d->pdev, d->addr + QVIRTIO_PCI_MSIX_CONF_VECTOR, entry);
- vector = qpci_io_readw(d->pdev, d->addr + QVIRTIO_PCI_MSIX_CONF_VECTOR);
- g_assert_cmphex(vector, !=, QVIRTIO_MSI_NO_VECTOR);
+ qpci_io_writew(d->pdev, d->addr + VIRTIO_MSI_CONFIG_VECTOR, entry);
+ vector = qpci_io_readw(d->pdev, d->addr + VIRTIO_MSI_CONFIG_VECTOR);
+ g_assert_cmphex(vector, !=, VIRTIO_MSI_NO_VECTOR);
}
diff --git a/tests/libqos/virtio-pci.h b/tests/libqos/virtio-pci.h
index 8f0e52a..efcac2d 100644
--- a/tests/libqos/virtio-pci.h
+++ b/tests/libqos/virtio-pci.h
@@ -13,23 +13,6 @@
#include "libqos/virtio.h"
#include "libqos/pci.h"
-#define QVIRTIO_PCI_DEVICE_FEATURES 0x00
-#define QVIRTIO_PCI_GUEST_FEATURES 0x04
-#define QVIRTIO_PCI_QUEUE_ADDRESS 0x08
-#define QVIRTIO_PCI_QUEUE_SIZE 0x0C
-#define QVIRTIO_PCI_QUEUE_SELECT 0x0E
-#define QVIRTIO_PCI_QUEUE_NOTIFY 0x10
-#define QVIRTIO_PCI_DEVICE_STATUS 0x12
-#define QVIRTIO_PCI_ISR_STATUS 0x13
-#define QVIRTIO_PCI_MSIX_CONF_VECTOR 0x14
-#define QVIRTIO_PCI_MSIX_QUEUE_VECTOR 0x16
-#define QVIRTIO_PCI_DEVICE_SPECIFIC_MSIX 0x18
-#define QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX 0x14
-
-#define QVIRTIO_PCI_ALIGN 4096
-
-#define QVIRTIO_MSI_NO_VECTOR 0xFFFF
-
typedef struct QVirtioPCIDevice {
QVirtioDevice vdev;
QPCIDevice *pdev;
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index ff66d93..2c5d2db 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -23,6 +23,7 @@
#include "standard-headers/linux/virtio_config.h"
#include "standard-headers/linux/virtio_ring.h"
#include "standard-headers/linux/virtio_blk.h"
+#include "standard-headers/linux/virtio_pci.h"
#define TEST_IMAGE_SIZE (64 * 1024 * 1024)
#define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000)
@@ -292,7 +293,7 @@ static void pci_basic(void)
alloc, 0);
/* MSI-X is not enabled */
- addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX;
+ addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(false);
test_basic(&qvirtio_pci, &dev->vdev, alloc, &vqpci->vq,
(uint64_t)(uintptr_t)addr);
@@ -327,7 +328,7 @@ static void pci_indirect(void)
dev = virtio_blk_pci_init(bus, PCI_SLOT);
/* MSI-X is not enabled */
- addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX;
+ addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(false);
capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev,
(uint64_t)(uintptr_t)addr);
@@ -422,7 +423,7 @@ static void pci_config(void)
dev = virtio_blk_pci_init(bus, PCI_SLOT);
/* MSI-X is not enabled */
- addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX;
+ addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(false);
capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev,
(uint64_t)(uintptr_t)addr);
@@ -469,7 +470,7 @@ static void pci_msix(void)
qvirtio_pci_set_msix_configuration_vector(dev, alloc, 0);
/* MSI-X is enabled */
- addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_MSIX;
+ addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(true);
capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev,
(uint64_t)(uintptr_t)addr);
@@ -585,7 +586,7 @@ static void pci_idx(void)
qvirtio_pci_set_msix_configuration_vector(dev, alloc, 0);
/* MSI-X is enabled */
- addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_MSIX;
+ addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(true);
capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev,
(uint64_t)(uintptr_t)addr);
diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c
index 8b8f5f3..71f5aeb 100644
--- a/tests/virtio-scsi-test.c
+++ b/tests/virtio-scsi-test.c
@@ -19,6 +19,7 @@
#include "libqos/malloc-pc.h"
#include "libqos/malloc-generic.h"
#include "standard-headers/linux/virtio_ids.h"
+#include "standard-headers/linux/virtio_pci.h"
#include "standard-headers/linux/virtio_scsi.h"
#define PCI_SLOT 0x02
@@ -158,7 +159,7 @@ static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot)
qvirtio_set_acknowledge(&qvirtio_pci, vs->dev);
qvirtio_set_driver(&qvirtio_pci, vs->dev);
- addr = dev->addr + QVIRTIO_PCI_DEVICE_SPECIFIC_NO_MSIX;
+ addr = dev->addr + VIRTIO_PCI_CONFIG_OFF(false);
vs->num_queues = qvirtio_config_readl(&qvirtio_pci, vs->dev,
(uint64_t)(uintptr_t)addr);
--
2.5.5
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH v2 08/23] slirp: fix guest network access with darwin host
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 08/23] slirp: fix guest network access with darwin host Stefan Hajnoczi
@ 2016-05-09 12:43 ` Samuel Thibault
0 siblings, 0 replies; 26+ messages in thread
From: Samuel Thibault @ 2016-05-09 12:43 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: qemu-devel, marc.mari.barcelo, Paolo Bonzini, jsnow,
Peter Maydell
Hello,
Stefan Hajnoczi, on Mon 09 May 2016 13:07:52 +0100, wrote:
> From: Samuel Thibault <samuel.thibault@ens-lyon.org>
>
> On Darwin, connect, sendto and friends want the exact size of the sockaddr,
> not more (and in particular, not sizeof(struct sockaddr_storaget))
>
> This commit adds the sockaddr_size helper to be used when passing a sockaddr
> size to such function, and makes use of it int sendto and connect calls.
This was already committed, before rc4.
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> Reviewed-by: John Arbuckle <programmingkidx@gmail.com>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> slirp/ip_icmp.c | 2 +-
> slirp/socket.c | 2 +-
> slirp/socket.h | 12 ++++++++++++
> slirp/tcp_subr.c | 2 +-
> 4 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
> index 590dada..5ffc7a6 100644
> --- a/slirp/ip_icmp.c
> +++ b/slirp/ip_icmp.c
> @@ -186,7 +186,7 @@ icmp_input(struct mbuf *m, int hlen)
> sotranslate_out(so, &addr);
>
> if(sendto(so->s, icmp_ping_msg, strlen(icmp_ping_msg), 0,
> - (struct sockaddr *)&addr, sizeof(addr)) == -1) {
> + (struct sockaddr *)&addr, sockaddr_size(&addr)) == -1) {
> DEBUG_MISC((dfd,"icmp_input udp sendto tx errno = %d-%s\n",
> errno,strerror(errno)));
> icmp_send_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, 0, strerror(errno));
> diff --git a/slirp/socket.c b/slirp/socket.c
> index bd97b2d..a10eff1 100644
> --- a/slirp/socket.c
> +++ b/slirp/socket.c
> @@ -627,7 +627,7 @@ sosendto(struct socket *so, struct mbuf *m)
>
> /* Don't care what port we get */
> ret = sendto(so->s, m->m_data, m->m_len, 0,
> - (struct sockaddr *)&addr, sizeof(addr));
> + (struct sockaddr *)&addr, sockaddr_size(&addr));
> if (ret < 0)
> return -1;
>
> diff --git a/slirp/socket.h b/slirp/socket.h
> index 7dca506..b602e69 100644
> --- a/slirp/socket.h
> +++ b/slirp/socket.h
> @@ -122,6 +122,18 @@ static inline int sockaddr_equal(struct sockaddr_storage *a,
> return 0;
> }
>
> +static inline socklen_t sockaddr_size(struct sockaddr_storage *a)
> +{
> + switch (a->ss_family) {
> + case AF_INET:
> + return sizeof(struct sockaddr_in);
> + case AF_INET6:
> + return sizeof(struct sockaddr_in6);
> + default:
> + g_assert_not_reached();
> + }
> +}
> +
> struct socket *solookup(struct socket **, struct socket *,
> struct sockaddr_storage *, struct sockaddr_storage *);
> struct socket *socreate(Slirp *);
> diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
> index 32ff452..6b9fef2 100644
> --- a/slirp/tcp_subr.c
> +++ b/slirp/tcp_subr.c
> @@ -413,7 +413,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)
> sotranslate_out(so, &addr);
>
> /* We don't care what port we get */
> - ret = connect(s,(struct sockaddr *)&addr,sizeof (addr));
> + ret = connect(s, (struct sockaddr *)&addr, sockaddr_size(&addr));
>
> /*
> * If it's not in progress, it failed, so we just return 0,
> --
> 2.5.5
>
--
Samuel
"How should I know if it works? That's what beta testers are for. I only
coded it."
(Attributed to Linus Torvalds, somewhere in a posting)
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
` (22 preceding siblings ...)
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 23/23] libqos: drop duplicated virtio_pci.h definitions Stefan Hajnoczi
@ 2016-05-09 12:45 ` Stefan Hajnoczi
23 siblings, 0 replies; 26+ messages in thread
From: Stefan Hajnoczi @ 2016-05-09 12:45 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel, Marc Marí, Paolo Bonzini, John Snow
On Mon, May 9, 2016 at 1:07 PM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> v2:
> * Fix missing s/X/(1u << X)/ conversion in Patch 3 [Marc]
NACK
A bunch of extra commits were included due to an error invoking my
patch submission script. Sorry for the noise, I'll resend a clean
series.
Stefan
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2016-05-09 12:59 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-09 12:07 [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 01/23] hw/ppc/spapr: Fix crash when specifying bad parameters to spapr-pci-host-bridge Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 02/23] usb/uhci: move pid check Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 03/23] spapr_drc: fix aborts during DRC-count based hotplug Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 04/23] QemuOpts: Fix qemu_opts_foreach() dangling location regression Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 05/23] replay: Fix dangling location bug in replay_configure() Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 06/23] qom: -object error messages lost location, restore it Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 07/23] target-mips: Fix RDHWR exception host PC Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 08/23] slirp: fix guest network access with darwin host Stefan Hajnoczi
2016-05-09 12:43 ` Samuel Thibault
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 09/23] qapi: Don't pass NULL to printf in string input visitor Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 10/23] vvfat: Fix volume name assertion Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 11/23] vvfat: Fix default volume label Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 12/23] acpi: fix bios linker loadder COMMAND_ALLOCATE on bigendian host Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 13/23] configure: Check if struct fsxattr is available from linux header Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 14/23] Revert "acpi: mark PMTIMER as unlocked" Stefan Hajnoczi
2016-05-09 12:07 ` [Qemu-devel] [PATCH v2 15/23] Update version for v2.6.0-rc4 release Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 16/23] libqos: use virtio_ids.h for device ID definitions Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 17/23] libqos: drop duplicated PCI vendor ID definition Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 18/23] libqos: drop duplicated virtio_config.h definitions Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 19/23] libqos: drop duplicated virtio_ring.h bit definitions Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 20/23] libqos: drop duplicated virtio_vring.h structs Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 21/23] libqos: drop duplicated virtio_blk.h definitions Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 22/23] libqos: drop duplicated virtio_scsi.h definitions Stefan Hajnoczi
2016-05-09 12:08 ` [Qemu-devel] [PATCH v2 23/23] libqos: drop duplicated virtio_pci.h definitions Stefan Hajnoczi
2016-05-09 12:45 ` [Qemu-devel] [PATCH v2 00/23] libqos: use standard virtio headers Stefan Hajnoczi
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).