sdk/emulator/qemu.git
12 years agoesp: add missing const on TypeInfo structures
Hervé Poussineau [Thu, 2 Aug 2012 08:40:30 +0000 (10:40 +0200)]
esp: add missing const on TypeInfo structures

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoesp: enable for all PCI machines
Paolo Bonzini [Thu, 2 Aug 2012 13:41:47 +0000 (15:41 +0200)]
esp: enable for all PCI machines

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoRevert "megasas: disable due to build breakage"
Paolo Bonzini [Wed, 1 Aug 2012 10:56:17 +0000 (12:56 +0200)]
Revert "megasas: disable due to build breakage"

This reverts commit 92336855975805d88c7979f53bc05c2d47abab04.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agomegasas: static SAS addresses
Hannes Reinecke [Wed, 1 Aug 2012 10:46:50 +0000 (12:46 +0200)]
megasas: static SAS addresses

This patch introduces a new property 'sas_address' which
allows the user to specify the SAS address for the HBA.
The default address is following the NAA locally assigned
identifier format with the locally assigned address
0x525400 as used eg for the MAC addresses.
The lower bytes are set to the pci address which
will ensure uniqueness for the local machine.

The port addresses are now calculated based on the magic
number 0x1221 (which is found in real hardware, too) plus
the device number.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Andreas Faerber <afaerber@suse.de>
Cc: Anthony Liguori <anthony@codemonkey.ws>
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: fix compilation with DEBUG_SCSI
Paolo Bonzini [Tue, 31 Jul 2012 14:10:23 +0000 (16:10 +0200)]
scsi-disk: fix compilation with DEBUG_SCSI

Reported-by: Gerhard Wiesinger <lists@wiesinger.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agomegasas: Update function megasys_scsi_uninit
Stefan Weil [Tue, 31 Jul 2012 05:54:57 +0000 (07:54 +0200)]
megasas: Update function megasys_scsi_uninit

Commit f90c2bcdbc69e41e575f868b984c3e2de8f51bac changed
PCIUnregisterFunc, therefore the function prototype
needs an update.

megasas.o is currently not linked, so this bug was not
detected by the buildbots.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoSCSI: STARTSTOPUNIT only eject/load media if powercondition is 0
Ronnie Sahlberg [Sat, 28 Jul 2012 01:14:53 +0000 (11:14 +1000)]
SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0

The START STOP UNIT command will only eject/load media if
power condition is zero.

If power condition is !0 then LOEJ and START will be ignored.

From MMC (sbc contains similar wordings too)
  The Power Conditions field requests the block device to be placed
  in the power condition defined in
  Table 558. If this field has a value other than 0h then the Start
  and LoEj bits shall be ignored.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoSCSI: Update the sense code for PREVENT REMOVAL errors
Ronnie Sahlberg [Sun, 29 Jul 2012 21:52:03 +0000 (07:52 +1000)]
SCSI: Update the sense code for PREVENT REMOVAL errors

Change the sense codes for failures to eject a device that is locked
by PREVENT_ALLOW_MEDIUM_REMOVAL from
the generic MEDIA_LOAD_OR_EJECT_FAILED to the more specific
MEDIUM_REMOVAL_PREVENTED.

The second sense code is more accurate, and is also listed in MMC annex F
for the recommended sense codes for MMC devices while the first sense code is not.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoMerge remote-tracking branch 'mst/tags/for_anthony' into staging
Anthony Liguori [Mon, 30 Jul 2012 15:00:48 +0000 (10:00 -0500)]
Merge remote-tracking branch 'mst/tags/for_anthony' into staging

* mst/tags/for_anthony:
  msi/msix: added API to set MSI message address and data
  pci: Add INTx routing notifier
  pci: Add pci_device_route_intx_to_irq
  pci: Unregister BARs before device exit
  pci: convert PCIUnregisterFunc to void
  msix: Switch msix_uninit to return void
  msix: Allow full specification of MSIX layout
  msix: Split PBA into it's own MemoryRegion
  msix: Note endian TODO item
  msix: Move msix_mmio_read
  virtio: Convert to msix_init_exclusive_bar() interface
  ivshmem: Convert to msix_init_exclusive_bar() interface
  msix: Add simple BAR allocation MSIX setup functions
  msix: fix PCIDevice naming inconsistency
  msix: drop unused msix_bar_size, require valid bar_size

12 years agoMerge remote-tracking branch 'bonzini/nbd-next' into staging
Anthony Liguori [Mon, 30 Jul 2012 14:59:38 +0000 (09:59 -0500)]
Merge remote-tracking branch 'bonzini/nbd-next' into staging

* bonzini/nbd-next:
  qemu-nbd: add --cache and --aio options
  qemu-nbd: reorganize help message

12 years agoMerge remote-tracking branch 'bonzini/scsi-next' into staging
Anthony Liguori [Mon, 30 Jul 2012 14:59:23 +0000 (09:59 -0500)]
Merge remote-tracking branch 'bonzini/scsi-next' into staging

* bonzini/scsi-next: (32 commits)
  virtio-scsi: enable MSI-X support
  virtio-scsi: add ioeventfd support
  virtio-scsi: report parameter change events
  virtio-scsi: do not report dropped events after reset
  virtio-scsi: Report missed events
  virtio-scsi: Implement hotplug support for virtio-scsi
  scsi: report parameter changes to HBA drivers
  scsi-disk: report resized disk via sense codes
  scsi: establish precedence levels for unit attention
  scsi: introduce hotplug() and hot_unplug() interfaces for SCSI bus
  scsi: add tracepoint for scsi_req_cancel
  scsi-disk: removable hard disks support load/eject
  scsi-disk: Fail medium writes with proper sense for readonly LUNs
  scsi-disk: improve the lba-out-of-range tests for read/write/verify
  scsi-disk: rd/wr/vr-protect !=0 is an error
  scsi-disk: support toggling the write cache
  scsi-disk: parse MODE SELECT commands and parameters
  scsi-disk: fix changeable values for MODE_PAGE_R_W_ERROR
  scsi-disk: adjust offsets in MODE SENSE by 2
  scsi-disk: support emulated TO_DEV requests
  ...

12 years agoMerge commit 'quintela/migration-next-v5' into staging
Anthony Liguori [Mon, 30 Jul 2012 14:58:41 +0000 (09:58 -0500)]
Merge commit 'quintela/migration-next-v5' into staging

* commit '6c779f22a93cc6e4565b940ef616e3efc5b50ba5':
  Change ram_save_block to return -1 if there are no more changes
  ram: save_live_setup() we don't need to synchronize the dirty bitmap.
  ram: iterate phase
  ram: save_live_complete() only do one loop
  ram: save_live_setup() don't need to sent pages
  savevm: split save_live into stage2 and stage3
  savevm: split save_live_setup from save_live_state
  savevm: introduce is_active method
  savevm: Refactor cancel operation in its own operation
  savevm: remove SaveLiveStateHandler
  savevm: remove SaveSetParamsHandler
  savevm: Live migration handlers register the struct directly
  savevm: Use a struct to pass all handlers

12 years agoMerge branch pci into master
Michael S. Tsirkin [Sun, 29 Jul 2012 14:03:19 +0000 (17:03 +0300)]
Merge branch pci into master

Merge master and pci branch, resolve build breakage in hw/esp.c
introduced by f90c2bcd.

Conflicts:
hw/esp.c

12 years agox86: Fixed incorrect segment base address addition in 64-bits mode
Vitaly Chipounov [Mon, 2 Jul 2012 22:20:49 +0000 (00:20 +0200)]
x86: Fixed incorrect segment base address addition in 64-bits mode

According to the Intel manual
"Intel® 64 and IA-32 Architectures Software Developer’s Manual
Volume 3", "3.4.4 Segment Loading Instructions in IA-32e Mode":

"When in compatibility mode, FS and GS overrides operate as defined by
32-bit mode behavior regardless of the value loaded into the upper 32
linear-address bits of the hidden descriptor register base field.
Compatibility mode ignores the upper 32 bits when calculating an effective address."

However, the code misses the 64-bit mode case, where an instruction with
address and segment size override would be translated incorrectly. For example,
inc dword ptr gs:260h[ebx*4] gets incorrectly translated to:

(uint32_t)(gs.base + ebx * 4 + 0x260)
instead of
gs.base + (uint32_t)(ebx * 4 + 0x260)

Signed-off-by: Vitaly Chipounov <vitaly.chipounov@epfl.ch>
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoplace qemu-sockets.c contributions since 2012-01-13 under GPLv2+
Paolo Bonzini [Mon, 9 Jul 2012 09:08:39 +0000 (11:08 +0200)]
place qemu-sockets.c contributions since 2012-01-13 under GPLv2+

Past contributions since 2012-01-13 were only made by Red Hat people,
so they are already available under GPLv2+.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agobuild: Fix linking failure for qemu-ga
Dunrong Huang [Sat, 28 Jul 2012 19:11:24 +0000 (03:11 +0800)]
build: Fix linking failure for qemu-ga

This patch will fix the following linking failed:

  LINK  qemu-ga
gcc: error: qga/../qapi-generated/qga-qapi-types.o: No such file or directory
gcc: error: qga/../qapi-generated/qga-qapi-visit.o: No such file or directory
gcc: error: qga/../qapi-generated/qga-qmp-marshal.o: No such file or directory
make: *** [qemu-ga] Error 1

Commit cdc976b040f2760103ce2fb49f4d504093a7163f changes the
dependencies of qemu-ga to depend "../qapi-generated/qga-qapi-types.o",
which will be expanded to "qga/../qapi-generated/qga-qapi-types.o" when
building qemu-ga.

In top-level Makefile, we defined a target "qapi-generated/qga-qapi-types.o"
which was not equal to "qga/../qapi-generated/qga-qapi-types" in the
Makefile world. So "No such file" error happened when qemu-ga was linking.

The easy approach to fix is to change the target name to
"qga/../qapi-generated/qga-qapi-types.o", but it is weird.

So, in order to solve it more graciously, I move those temporary
files(qga-qapi-*.{c,h}) qemu-ga depends on to qemu-ga/qapi-generated,
this makes dependencies more clearer.

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoAvoid redefining inline
Blue Swirl [Sun, 8 Jul 2012 07:00:50 +0000 (07:00 +0000)]
Avoid redefining inline

System headers (e.g. gutils.h) may define 'inline', #undefine it
before #defining.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoAvoid returning void
Blue Swirl [Sun, 8 Jul 2012 06:56:53 +0000 (06:56 +0000)]
Avoid returning void

It's silly and non-conforming to standards to return void,
don't do it.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agohw/escc: Drop duplicate definition of 'disabled' property
Peter Maydell [Tue, 24 Jul 2012 14:10:27 +0000 (15:10 +0100)]
hw/escc: Drop duplicate definition of 'disabled' property

Drop a duplicate definition of the 'disabled' property from
the escc qdev property list: this redefinition is currently
effectively ignored but will become an error. (The duplication
was inadvertently introduced in 2009 in commit ec02f7dec2.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agobuild: get dependency file directories from object file names
Paolo Bonzini [Wed, 11 Jul 2012 14:40:21 +0000 (16:40 +0200)]
build: get dependency file directories from object file names

After commit dcff25f2cd8c11a9368cc2369aeb0319c32d9e26, Dependency file
are taken from the directories that have a Makefile.objs file.  This is
not enough, since files can be included from other directories.
So, pick them from directories that have an object file in them.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agobuild: include qapi-generated/ files in qga/Makefile.objs
Paolo Bonzini [Wed, 11 Jul 2012 14:40:20 +0000 (16:40 +0200)]
build: include qapi-generated/ files in qga/Makefile.objs

No reason to leave them out, and it will ensure that the dependencies
are picked up.  Later we can perhaps move the files to another
directory to avoid ../ usage.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotests: Makefile: include dependency files
Eduardo Habkost [Wed, 18 Jul 2012 17:22:27 +0000 (14:22 -0300)]
tests: Makefile: include dependency files

Otherwise 'make check' won't recompile files that need to be recompiled
because of header changes.

To reproduce the bug, run:

 $ make check  # succeeds
 $ echo B0RKED > hw/mc146818rtc_regs.h
 $ make check  # is supposed to try to rebuild tests/rtc-test.o and fail

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agovl.c: Don't print errno after failed qemu_chr_new()
Peter Maydell [Mon, 9 Jul 2012 04:28:30 +0000 (04:28 +0000)]
vl.c: Don't print errno after failed qemu_chr_new()

The qemu_chr_new() function doesn't set errno on failure, so
don't print strerror(errno) on the error handling path when
dealing with the -serial, -parallel and -virtioconsole arguments.
This avoids nonsensical error messages like:
  $ ./arm-softmmu/qemu-system-arm -serial wombat
  qemu: could not open serial device 'wombat': Success

We also rephrase the message slightly to make it a little clearer
that we're expecting the name of a QEMU chr backend rather than
a host or guest serial/parallel/etc device.

Reported-by: Christian Müller <christian.mueller@heig-vd.ch>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-xtensa: fix big-endian BBS/BBC implementation
Max Filippov [Tue, 17 Jul 2012 19:45:23 +0000 (23:45 +0400)]
target-xtensa: fix big-endian BBS/BBC implementation

Quote from ISA, 2.1:

For most Xtensa instructions, bit numbering is irrelevant; only the BBC
and BBS instructions assign bit numbers to values on which the processor
operates. The BBC/BBS instructions use big-endian bit ordering (0 is the
most-significant bit) on a big-endian processor configuration.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add testcases
Jia Liu [Fri, 20 Jul 2012 07:50:53 +0000 (15:50 +0800)]
target-or32: Add testcases

Add testcases for OpenRISC.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add linux user support
Jia Liu [Fri, 20 Jul 2012 07:50:52 +0000 (15:50 +0800)]
target-or32: Add linux user support

Add QEMU OpenRISC linux user support.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add linux syscall, signal and termbits
Jia Liu [Fri, 20 Jul 2012 07:50:51 +0000 (15:50 +0800)]
target-or32: Add linux syscall, signal and termbits

Add OpenRISC linux syscall, signal and termbits.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add gdb stub support
Jia Liu [Fri, 20 Jul 2012 07:50:50 +0000 (15:50 +0800)]
target-or32: Add gdb stub support

Add OpenRISC gdb stub support.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add system instructions
Jia Liu [Fri, 20 Jul 2012 07:50:49 +0000 (15:50 +0800)]
target-or32: Add system instructions

Add OpenRISC system instructions.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add a IIS dummy board
Jia Liu [Fri, 20 Jul 2012 07:50:48 +0000 (15:50 +0800)]
target-or32: Add a IIS dummy board

Add a IIS dummy board.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add timer support
Jia Liu [Fri, 20 Jul 2012 07:50:47 +0000 (15:50 +0800)]
target-or32: Add timer support

Add OpenRISC timer support.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add PIC support
Jia Liu [Fri, 20 Jul 2012 07:50:46 +0000 (15:50 +0800)]
target-or32: Add PIC support

Add OpenRISC Programmable Interrupt Controller support.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add instruction translation
Jia Liu [Fri, 20 Jul 2012 07:50:45 +0000 (15:50 +0800)]
target-or32: Add instruction translation

Add OpenRISC instruction tanslation routines.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add float instruction helpers
Jia Liu [Fri, 20 Jul 2012 07:50:44 +0000 (15:50 +0800)]
target-or32: Add float instruction helpers

Add OpenRISC float instruction helpers.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add int instruction helpers
Jia Liu [Fri, 20 Jul 2012 07:50:43 +0000 (15:50 +0800)]
target-or32: Add int instruction helpers

Add OpenRISC int instruction helpers.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add exception support
Jia Liu [Fri, 20 Jul 2012 07:50:42 +0000 (15:50 +0800)]
target-or32: Add exception support

Add OpenRISC exception support.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add interrupt support
Jia Liu [Fri, 20 Jul 2012 07:50:41 +0000 (15:50 +0800)]
target-or32: Add interrupt support

Add OpenRISC interrupt support.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add MMU support
Jia Liu [Fri, 20 Jul 2012 07:50:40 +0000 (15:50 +0800)]
target-or32: Add MMU support

Add OpenRISC MMU support.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-or32: Add target stubs and QOM cpu
Jia Liu [Fri, 20 Jul 2012 07:50:39 +0000 (15:50 +0800)]
target-or32: Add target stubs and QOM cpu

Add OpenRISC target stubs, QOM cpu and basic machine.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agovirtio-scsi: enable MSI-X support
Paolo Bonzini [Fri, 27 Jul 2012 12:38:03 +0000 (14:38 +0200)]
virtio-scsi: enable MSI-X support

While virtio-scsi does support multiqueue, the default number of
interrupt vectors is not enough to actually enable usage of
multiple queues in the driver; this is because with only 2
vectors the driver will not be able to use a separate
interrupt for each request queue.  Derive the desired number
of vectors from the number of request queues.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirtio-scsi: add ioeventfd support
Paolo Bonzini [Fri, 27 Jul 2012 12:36:07 +0000 (14:36 +0200)]
virtio-scsi: add ioeventfd support

Probably due to bad merge months ago, virtio-scsi-pci did not have
ioeventfd support.  Fix this and enable it by default, as is the
case for other virtio-pci devices.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirtio-scsi: report parameter change events
Paolo Bonzini [Mon, 16 Jul 2012 12:22:52 +0000 (14:22 +0200)]
virtio-scsi: report parameter change events

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirtio-scsi: do not report dropped events after reset
Paolo Bonzini [Mon, 16 Jul 2012 12:50:27 +0000 (14:50 +0200)]
virtio-scsi: do not report dropped events after reset

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirtio-scsi: Report missed events
Paolo Bonzini [Mon, 2 Jul 2012 08:47:35 +0000 (10:47 +0200)]
virtio-scsi: Report missed events

When an event is reported but no buffers are present in the event vq,
we can set a flag and report a dummy event as soon as one is added.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirtio-scsi: Implement hotplug support for virtio-scsi
Cong Meng [Wed, 20 Jun 2012 06:47:11 +0000 (14:47 +0800)]
virtio-scsi: Implement hotplug support for virtio-scsi

Implement the hotplug() and hot_unplug() interfaces in virtio-scsi, by signal
the virtio_scsi.ko in guest kernel via event virtual queue.

The counterpart patch of virtio_scsi.ko will be sent soon in another thread.

Signed-off-by: Sen Wang <senwang@linux.vnet.ibm.com>
Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
[ Add memset, fix LUN field, placate checkpatch - Paolo ]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi: report parameter changes to HBA drivers
Paolo Bonzini [Mon, 16 Jul 2012 12:22:36 +0000 (14:22 +0200)]
scsi: report parameter changes to HBA drivers

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: report resized disk via sense codes
Paolo Bonzini [Mon, 16 Jul 2012 12:07:55 +0000 (14:07 +0200)]
scsi-disk: report resized disk via sense codes

Linux will not use these, but a very similar mechanism will be used to
report the condition via virtio-scsi events.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi: establish precedence levels for unit attention
Paolo Bonzini [Mon, 16 Jul 2012 12:18:58 +0000 (14:18 +0200)]
scsi: establish precedence levels for unit attention

When a device is resized, we will report a unit attention condition
for CAPACITY DATA HAS CHANGED.  However, we should ensure that this
condition does not override a more important unit attention condition.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi: introduce hotplug() and hot_unplug() interfaces for SCSI bus
Cong Meng [Wed, 20 Jun 2012 06:47:10 +0000 (14:47 +0800)]
scsi: introduce hotplug() and hot_unplug() interfaces for SCSI bus

Add two interfaces hotplug() and hot_unplug() to scsi bus info.
The scsi bus can implement these two interfaces to signal the HBA driver
of guest kernel to add/remove the scsi device in question.

Signed-off-by: Sen Wang <senwang@linux.vnet.ibm.com>
Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
[ Fixed braces and indentation - Paolo ]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi: add tracepoint for scsi_req_cancel
Paolo Bonzini [Fri, 27 Jul 2012 06:23:07 +0000 (08:23 +0200)]
scsi: add tracepoint for scsi_req_cancel

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: removable hard disks support load/eject
Paolo Bonzini [Mon, 16 Jul 2012 13:59:57 +0000 (15:59 +0200)]
scsi-disk: removable hard disks support load/eject

Support for the LOEJ bit of the START/STOP UNIT command right now is
limited to CD-ROMs.  This is wrong, since removable hard disks (in the
real world: SD card readers) also support it in pretty much the same way.

Without the LOEJ bit, START/STOP UNIT does nothing for all devices.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: Fail medium writes with proper sense for readonly LUNs
Ronnie Sahlberg [Mon, 16 Jul 2012 06:53:28 +0000 (08:53 +0200)]
scsi-disk: Fail medium writes with proper sense for readonly LUNs

Add sense code for DATA_PROTECT/WRITE_PROTECTED and return this error
for any WRITE*/WRITE_VERIFY* calls if the device is readonly=on,
i.e. write-protected

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: improve the lba-out-of-range tests for read/write/verify
Ronnie Sahlberg [Thu, 12 Jul 2012 06:52:47 +0000 (16:52 +1000)]
scsi-disk: improve the lba-out-of-range tests for read/write/verify

Improve the tests for the LBA to cover more cases.

For the 16 byte opcodes, the lba is a uint64, so we need to check is to
make sure that we do not wrap.  For example if an opcode would specify
the LBA:0xffffffffffffffff and LEN:2 then lba+len would wrap to 1.

Also verify that ALL requested blocks are available, not just the first one.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: rd/wr/vr-protect !=0 is an error
Ronnie Sahlberg [Thu, 12 Jul 2012 00:19:38 +0000 (10:19 +1000)]
scsi-disk: rd/wr/vr-protect !=0 is an error

The QEMU SCSI emulation does not support protection information,
so any READ/WRITE/VERIFY commands that has the protect bits set to
non-zero should fail with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB

From SCSI SBC :
If the logical unit does not support protection information,
then the device server should terminate the command with CHECK CONDITION
status with the sense key set to ILLEGAL REQUEST and the additional sense
code set to INVALID FIELD IN CDB.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
[ Rebase after scsi_dma_reqops introduction - Paolo ]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: support toggling the write cache
Paolo Bonzini [Tue, 10 Jul 2012 13:03:17 +0000 (15:03 +0200)]
scsi-disk: support toggling the write cache

Finally, this uses the "plumbing" in the previous patch to
add support for toggling the WCE bit of the caching mode page.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: parse MODE SELECT commands and parameters
Paolo Bonzini [Tue, 10 Jul 2012 13:02:55 +0000 (15:02 +0200)]
scsi-disk: parse MODE SELECT commands and parameters

This adds the bulk of the parsing code for MODE SELECT, including
breaking out changes to different mode pages, and checking that only
changeable values are modified.

In order to report errors correctly two passes are made through the
parameters; the first only looks for errors, the second actually
applies the changes to the mode page.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: fix changeable values for MODE_PAGE_R_W_ERROR
Paolo Bonzini [Tue, 10 Jul 2012 12:04:51 +0000 (14:04 +0200)]
scsi-disk: fix changeable values for MODE_PAGE_R_W_ERROR

The changeable values were not all-zeros for this mode page, fix it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: adjust offsets in MODE SENSE by 2
Paolo Bonzini [Thu, 12 Jul 2012 14:08:24 +0000 (16:08 +0200)]
scsi-disk: adjust offsets in MODE SENSE by 2

This will make offsets the same when implementing MODE SELECT.  This is
because MODE SELECT has to deal with both 2-byte and 4-byte headers.
Unfortunately, this means that the offsets are now off by two compared
to the descriptions in the SCSI specs, which include the header.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: support emulated TO_DEV requests
Paolo Bonzini [Wed, 8 Feb 2012 09:32:55 +0000 (10:32 +0100)]
scsi-disk: support emulated TO_DEV requests

This adds the implementation of write_data for the emulated
command case.  The first time through it asks for more data,
the second time it finishes the processing of the command.

MODE SELECT and MODE SELECT(10) can now be re-enabled, but they
will not do much.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: separate read_data/write_data implementation for emulate_reqops
Paolo Bonzini [Wed, 8 Feb 2012 09:26:21 +0000 (10:26 +0100)]
scsi-disk: separate read_data/write_data implementation for emulate_reqops

The previous patch only separated the send_command callback.
Use different implementations also for read_data and write_data.
The latter is still unreachable, so it aborts for now.

read_data passes the data buffer that was prepared and completes
the command.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: split scsi-disk reqops
Paolo Bonzini [Wed, 8 Feb 2012 08:53:42 +0000 (09:53 +0100)]
scsi-disk: split scsi-disk reqops

Only checks for present medium were still done in scsi_send_command
for emulated commands.  So move those to scsi_disk_emulate_command
and return different SCSIReqOps depending on the kind of command.

Checks for present medium can be done unconditionally for the
scsi_disk_dma_reqops case.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: move all non-DMA commands to scsi_disk_emulate_command
Paolo Bonzini [Wed, 8 Feb 2012 08:43:52 +0000 (09:43 +0100)]
scsi-disk: move all non-DMA commands to scsi_disk_emulate_command

We want to use separate SCSIReqOps for emulated commands needing an
allocated buffer vs. those that are zerocopy when the HBA supports
S/G lists.  Ensure that all of the former are in scsi_disk_emulate_command.

Commands that do not have any parameters are more similar to emulated
commands, so also move them, even if they do I/O.

Finally, MODE SELECT and MODE SELECT(10) are broken because we do not
yet support passing parameter data _to_ emulated commands, so disable
them.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: make discard asynchronous
Paolo Bonzini [Wed, 8 Feb 2012 09:37:48 +0000 (10:37 +0100)]
scsi-disk: make discard asynchronous

By making discard asynchronous, we can reuse all the error handling
code that is used for other commands.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: let the user customize vendor and product name
Dmitry Fleytman [Sat, 7 Jul 2012 05:03:35 +0000 (22:03 -0700)]
scsi-disk: let the user customize vendor and product name

This patch adds two new properties vendor and product to SCSI disks.
These options let the user customize the inquiry data returned by the
disk.

Signed-off-by: Yan Vugenfirer <yan@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
[ Use vendor and product property names, avoid "if" statements. - PB ]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agocutils: add strpadcpy()
Dmitry Fleytman [Mon, 9 Jul 2012 06:50:43 +0000 (08:50 +0200)]
cutils: add strpadcpy()

Signed-off-by: Yan Vugenfirer <yan@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-block: remove properties that are not relevant for passthrough
Paolo Bonzini [Mon, 9 Jul 2012 10:11:04 +0000 (12:11 +0200)]
scsi-block: remove properties that are not relevant for passthrough

scsi-block is a passthrough device and does not allow customization
of vendor, product, removable, DPOFUA, block size or any other piece of
information.  Thus, drop DEFINE_SCSI_DISK_PROPERTIES() from the
list of qdev properties.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agolsi: avoid redundant tests of s->current != NULL
Paolo Bonzini [Mon, 2 Jul 2012 15:07:40 +0000 (17:07 +0200)]
lsi: avoid redundant tests of s->current != NULL

Simplify the code by checking against req->hba_private directly,
and asserting that it is non-NULL before a command is completed
or canceled.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agolsi: introduce lsi_request_free
Paolo Bonzini [Mon, 2 Jul 2012 15:04:40 +0000 (17:04 +0200)]
lsi: introduce lsi_request_free

Split the common bits of lsi_request_cancelled and lsi_command_complete
out to a new function.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agolsi: use qdev_reset_all
Paolo Bonzini [Mon, 2 Jul 2012 15:03:55 +0000 (17:03 +0200)]
lsi: use qdev_reset_all

By first resetting the devices, lsi_soft_reset will find the queue
already cleared so there is no need to do that forcibly (which may also
leak SCSIRequests, and/or worse due to dangling references to the
lsi_request in the hba_private field).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agomegasas: fix misuse of scsi_req_abort
Paolo Bonzini [Thu, 12 Jul 2012 13:02:29 +0000 (15:02 +0200)]
megasas: fix misuse of scsi_req_abort

scsi_req_abort is for terminating a command with a non-zero status.
The ABORT task management function is invoked by scsi_req_cancel.
In fact, ABORTED_COMMAND is a sense key, not a SAM status code.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agomegasas: Replace trace_megasas_dcmd_dump_frame()
Hannes Reinecke [Wed, 11 Jul 2012 11:35:16 +0000 (13:35 +0200)]
megasas: Replace trace_megasas_dcmd_dump_frame()

trace_megasas_dcmd_dump_frame() takes 9 arguments, which is
rather much. Plus the trace infrastructure doesn't support
it.  As we can get the information via other means it's pointless
to have it in the driver, so rather use some proper trace
point here and remove the old one.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Cc: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: add --cache and --aio options
Paolo Bonzini [Wed, 18 Jul 2012 12:57:15 +0000 (14:57 +0200)]
qemu-nbd: add --cache and --aio options

Add two options to tune the I/O implementation of qemu-nbd, matching
the possibilities given by the QEMU -drive option.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: reorganize help message
Paolo Bonzini [Wed, 18 Jul 2012 12:50:52 +0000 (14:50 +0200)]
qemu-nbd: reorganize help message

This patch separates qemu-nbd's options in logical groups, thus making
the help message easier to read.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoMerge remote-tracking branch 'stefanha/net' into staging
Anthony Liguori [Mon, 23 Jul 2012 18:15:34 +0000 (13:15 -0500)]
Merge remote-tracking branch 'stefanha/net' into staging

* stefanha/net:
  remove unused QemuOpts parameter from net init functions
  convert net_init_bridge() to NetClientOptions
  convert net_init_tap() to NetClientOptions
  convert net_init_vde() to NetClientOptions
  convert net_init_socket() to NetClientOptions
  convert net_init_slirp() to NetClientOptions
  convert net_init_dump() to NetClientOptions
  convert net_init_nic() to NetClientOptions
  convert net_client_init() to OptsVisitor
  hw, net: "net_client_type" -> "NetClientOptionsKind" (qapi-generated)
  qapi schema: add Netdev types
  qapi schema: remove trailing whitespace
  qapi: introduce OptsVisitor
  expose QemuOpt and QemuOpts struct definitions to interested parties
  qapi: introduce "size" type
  qapi: generate C types for fixed-width integers
  qapi: add test case for deallocating traversal of incomplete structure
  qapi: fix error propagation
  MAINTAINERS: Replace net maintainer Mark McLoughlin with Stefan Hajnoczi

12 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Mon, 23 Jul 2012 18:15:34 +0000 (13:15 -0500)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

* stefanha/trivial-patches:
  Fix some more Qemus in documentation and help text
  qdev: Fix Open Firmware comment
  cpus.c: Make all_cpu_threads_idle() static
  Use macro QEMU_PACKED for new packed structures
  Recognize PCID feature
  powerpc pci: fixed packing of ranges[]

12 years agoMerge remote-tracking branch 'pmaydell/arm-devs.for-upstream' into staging
Anthony Liguori [Mon, 23 Jul 2012 18:15:34 +0000 (13:15 -0500)]
Merge remote-tracking branch 'pmaydell/arm-devs.for-upstream' into staging

* pmaydell/arm-devs.for-upstream:
  exynos4210: add Exynos4210 i2c implementation
  hw/exynos4210_rtc.c: remove unnecessary code
  hw/exynos4210_rtc.c: Fix calculating for value of year
  hw/vexpress.c: Allow >4GB of RAM for Cortex-A15 daughterboard
  hw/arm_boot.c: Support DTBs which use 64 bit addresses
  device_tree: Add support for reading device tree properties
  hw/arm_boot.c: Check for RAM sizes exceeding ATAGS capacity
  hw/arm_boot.c: Consistently use ram_size from arm_boot_info struct
  hw/arm_boot.c: Make ram_size a uint64_t
  hw/pl011.c: Avoid crash on read when no chr backend present

12 years agoMerge remote-tracking branch 'stefanha/tracing' into staging
Anthony Liguori [Mon, 23 Jul 2012 18:15:34 +0000 (13:15 -0500)]
Merge remote-tracking branch 'stefanha/tracing' into staging

* stefanha/tracing:
  Update simpletrace.py for new log format
  Simpletrace v2: Support multiple arguments, strings.
  monitor: remove unused do_info_trace
  trace: added ability to comment out events in the list

12 years agoChange ram_save_block to return -1 if there are no more changes
Orit Wasserman [Tue, 10 Jul 2012 09:37:13 +0000 (12:37 +0300)]
Change ram_save_block to return -1 if there are no more changes

It will return 0 if the page is unmodifed.

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
12 years agoremove unused QemuOpts parameter from net init functions
Laszlo Ersek [Tue, 17 Jul 2012 14:17:21 +0000 (16:17 +0200)]
remove unused QemuOpts parameter from net init functions

v1->v2:
- unchanged

v2->v3:
- keep "qemu-option.h" included in "net/slirp.h"

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoconvert net_init_bridge() to NetClientOptions
Laszlo Ersek [Tue, 17 Jul 2012 14:17:20 +0000 (16:17 +0200)]
convert net_init_bridge() to NetClientOptions

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoconvert net_init_tap() to NetClientOptions
Laszlo Ersek [Tue, 17 Jul 2012 14:17:19 +0000 (16:17 +0200)]
convert net_init_tap() to NetClientOptions

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoconvert net_init_vde() to NetClientOptions
Laszlo Ersek [Tue, 17 Jul 2012 14:17:18 +0000 (16:17 +0200)]
convert net_init_vde() to NetClientOptions

v1->v2:
- NetdevVdeOptions::port and ::mode are of type uint16. Remove superfluous
  range checks.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoconvert net_init_socket() to NetClientOptions
Laszlo Ersek [Tue, 17 Jul 2012 14:17:17 +0000 (16:17 +0200)]
convert net_init_socket() to NetClientOptions

I "reverse engineered" the following permissions between the -socket
sub-options:

             fd  listen  connect  mcast  udp | localaddr
  fd         x   .       .        .      .   | .
  listen     .   x       .        .      .   | .
  connect    .   .       x        .      .   | .
  mcast      .   .       .        x      .   | x
  udp        .   .       .        .      x   | x
  -------------------------------------------+
  localaddr  .   .       .        x      x     x

I transformed the code accordingly. The real fix would be to embed "fd",
"listen", "connect", "mcast" and "udp" in a separate union. However
OptsVisitor's enum parser only supports the type=XXX QemuOpt instance as
union discriminator.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoconvert net_init_slirp() to NetClientOptions
Laszlo Ersek [Tue, 17 Jul 2012 14:17:16 +0000 (16:17 +0200)]
convert net_init_slirp() to NetClientOptions

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoconvert net_init_dump() to NetClientOptions
Laszlo Ersek [Tue, 17 Jul 2012 14:17:15 +0000 (16:17 +0200)]
convert net_init_dump() to NetClientOptions

v1->v2:
- NetdevDumpOptions::len is of type 'size', whose C type was changed to
  uint64_t. Adapt the printf() format specifier macro.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoconvert net_init_nic() to NetClientOptions
Laszlo Ersek [Tue, 17 Jul 2012 14:17:14 +0000 (16:17 +0200)]
convert net_init_nic() to NetClientOptions

v1->v2:
- NetLegacyNicOptions::vectors is of type uint32

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoconvert net_client_init() to OptsVisitor
Laszlo Ersek [Tue, 17 Jul 2012 14:17:13 +0000 (16:17 +0200)]
convert net_client_init() to OptsVisitor

The net_client_init() prototype is kept intact.

Based on "is_netdev", the QemuOpts-rooted QemuOpt-list is parsed as a
Netdev or a NetLegacy. The original meat of net_client_init() is moved to
and simplified in net_client_init1():

Fields not common between -net and -netdev are clearly separated. Getting
the name for the init functions is cleaner: Netdev::id is mandatory, and
all init functions handle a NULL NetLegacy::name. NetLegacy::vlan
explicitly depends on -net (see below).

Verifying the "type=" option for -netdev can be turned into a switch.

Format validation with qemu_opts_validate() can be removed because the
visitor covers it. Relatedly, the "net_client_types" array is reduced to
an array of init functions that can be directly indexed by opts->kind.
(Help text is available in the schema JSON.)

The outermost negation in the condition around qemu_find_vlan() was
flattened, because it expresses the dependent code's requirements more
clearly.

VLAN lookup is avoided if there's no init function to pass the VLAN to.

Whenever the value of type=... is needed, we substitute
NetClientOptionsKind_lookup[kind].

The individual init functions are not converted yet, thus the original
QemuOpts instance is passed transparently.

v1->v2:
- NetLegacy::name is optional. Tracked it through all init functions: they
  all handle a NULL name. Updated commit message accordingly.

v2->v3:
- NetLegacy::id is allowed and takes precedence over NetLegacy::name.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agohw, net: "net_client_type" -> "NetClientOptionsKind" (qapi-generated)
Laszlo Ersek [Tue, 17 Jul 2012 14:17:12 +0000 (16:17 +0200)]
hw, net: "net_client_type" -> "NetClientOptionsKind" (qapi-generated)

NET_CLIENT_TYPE_ -> NET_CLIENT_OPTIONS_KIND_

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqapi schema: add Netdev types
Laszlo Ersek [Tue, 17 Jul 2012 14:17:11 +0000 (16:17 +0200)]
qapi schema: add Netdev types

NetdevTapOptions::sndbuf and NetdevDumpOptions::len use the new "size"
type.

v1->v2:
- NetLegacy::name is optional
- NetLegacyNicOptions::vectors is of type uint32
- NetdevVdeOptions::port and ::mode are of type uint16
- NetLegacy::vlan has type int32

v2->v3:
- NetLegacy::id is allowed and takes precedence over NetLegacy::name
- replace "@traits" with "@opts" in NetLegacy & Netdev descriptions

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqapi schema: remove trailing whitespace
Laszlo Ersek [Tue, 17 Jul 2012 14:17:10 +0000 (16:17 +0200)]
qapi schema: remove trailing whitespace

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqapi: introduce OptsVisitor
Laszlo Ersek [Tue, 17 Jul 2012 14:17:09 +0000 (16:17 +0200)]
qapi: introduce OptsVisitor

This visitor supports parsing

  -option [type=]discriminator[,optarg1=val1][,optarg2=val2][,...]

style QemuOpts objects into "native" C structures. After defining the type
tree in the qapi schema (see below), a root type traversal with this
visitor linked to the underlying QemuOpts object will build the "native" C
representation of the option.

The type tree in the schema, corresponding to an option with a
discriminator, must have the following structure:

  struct
    scalar member for non-discriminated optarg 1 [*]
    list for repeating non-discriminated optarg 2 [*]
      wrapper struct
        single scalar member
    union
      struct for discriminator case 1
        scalar member for optarg 3 [*]
        list for repeating optarg 4 [*]
          wrapper struct
            single scalar member
        scalar member for optarg 5 [*]
      struct for discriminator case 2
        ...

The "type" optarg name is fixed for the discriminator role. Its schema
representation is "union of structures", and each discriminator value must
correspond to a member name in the union.

If the option takes no "type" descriminator, then the type subtree rooted
at the union must be absent from the schema (including the union itself).

Optarg values can be of scalar types str / bool / integers / size.

Members marked with [*] may be defined as optional in the schema,
describing an optional optarg.

Repeating an optarg is supported; its schema representation must be "list
of structure with single mandatory scalar member". If an optarg is not
described as repeating in the schema (ie. it is defined as a scalar field
instead of a list), its last occurrence will take effect. Ordering between
differently named optargs is not preserved.

A mandatory list (or an optional one which is reported to be available),
corresponding to a repeating optarg, has at least one element after
successful parsing.

v1->v2:
- Update opts_type_size() prototype to uint64_t.
- Add opts_type_uint64() for options needing the full uint64_t range.
  (Internals could be extracted to "cutils.c".)
- Allow negative values in opts_type_int().
- Rebase to nested Makefiles.

v2->v3:
- Factor opts_visitor_insert() out of opts_start_struct() and call it
  separately for opts_root->id if there's any.
- Don't require non-negative values in opts_type_int()'s error message.
- g_malloc0() may return NULL for zero-sized requests. Support empty
  structures by requesting 1 byte for them instead.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoexpose QemuOpt and QemuOpts struct definitions to interested parties
Laszlo Ersek [Tue, 17 Jul 2012 14:17:08 +0000 (16:17 +0200)]
expose QemuOpt and QemuOpts struct definitions to interested parties

The only clients should be the existent "qemu-option.c", and the upcoming
"qapi/opts-visitor.c".

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqapi: introduce "size" type
Laszlo Ersek [Tue, 17 Jul 2012 14:17:07 +0000 (16:17 +0200)]
qapi: introduce "size" type

v1->v2:
- fall back to uint64 rather than int

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqapi: generate C types for fixed-width integers
Laszlo Ersek [Tue, 17 Jul 2012 14:17:06 +0000 (16:17 +0200)]
qapi: generate C types for fixed-width integers

(Long line folded using parens:
<http://www.python.org/dev/peps/pep-0008/#maximum-line-length>.)

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqapi: add test case for deallocating traversal of incomplete structure
Laszlo Ersek [Tue, 17 Jul 2012 14:17:05 +0000 (16:17 +0200)]
qapi: add test case for deallocating traversal of incomplete structure

v3:
- new patch

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqapi: fix error propagation
Paolo Bonzini [Tue, 17 Jul 2012 14:17:04 +0000 (16:17 +0200)]
qapi: fix error propagation

Don't overwrite / leak previously set errors.
Make traversal cope with missing mandatory sub-structs.
Don't try to end a container that could not be started.

v1->v2:
- unchanged

v2->v3:
- instead of examining, assert that we never overwrite errors with
  error_set()
- allow visitors to set a NULL struct pointer successfully, so traversal
  of incomplete objects can continue
- check for a NULL "obj" before accessing "(*obj)->has_XXX" (this is not a
  typo, "obj != NULL" implies "*obj != NULL" here)
- fix start_struct / end_struct balance for unions as well

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoMAINTAINERS: Replace net maintainer Mark McLoughlin with Stefan Hajnoczi
Stefan Hajnoczi [Fri, 20 Jul 2012 13:29:24 +0000 (14:29 +0100)]
MAINTAINERS: Replace net maintainer Mark McLoughlin with Stefan Hajnoczi

The net subsystem has lacked an active maintainer since 2009.  I have
built and tested a net-next tree to get the ball rolling again.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoFix some more Qemus in documentation and help text
Stefan Weil [Fri, 20 Jul 2012 21:26:02 +0000 (23:26 +0200)]
Fix some more Qemus in documentation and help text

Hopefully they will be eliminated one day.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqdev: Fix Open Firmware comment
Stefan Weil [Fri, 20 Jul 2012 21:04:49 +0000 (23:04 +0200)]
qdev: Fix Open Firmware comment

Commit 0d936928ef87ca1bb7b41b5b89c400c699a7691c removed code,
but left the related comment at a location where it no longer
belongs to.

The patch moves the comment to the correct callback and improves the text.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agocpus.c: Make all_cpu_threads_idle() static
Peter Maydell [Thu, 19 Jul 2012 15:52:27 +0000 (16:52 +0100)]
cpus.c: Make all_cpu_threads_idle() static

Commit 946fb27c1 moved all the uses of all_cpu_threads_idle()
into cpus.c. This means we can mark the function 'static'
(again), if we shuffle it a bit earlier in the source file.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>