sdk/emulator/qemu.git
14 years agopci: make pci_del_capability() update for w1cmask
Isaku Yamahata [Mon, 18 Oct 2010 03:17:42 +0000 (12:17 +0900)]
pci: make pci_del_capability() update for w1cmask

Clear w1cmask when deleting a pci capability.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agomsix: clear not only INTA, but all INTx when MSI-X is enabled.
Isaku Yamahata [Wed, 15 Sep 2010 05:38:26 +0000 (14:38 +0900)]
msix: clear not only INTA, but all INTx when MSI-X is enabled.

clear not only INTA, but all INTx when MSI-X is enabled.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci: implement RW1C register framework.
Isaku Yamahata [Wed, 15 Sep 2010 05:38:15 +0000 (14:38 +0900)]
pci: implement RW1C register framework.

Implement RW1C register framework.
With this patch, it would be easy to implement
W1C(Write 1 to Clear) register by just setting w1cmask.
Later RW1C register will be used by pcie.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci: improve signature of pci_register_bar().
Isaku Yamahata [Thu, 9 Sep 2010 02:48:57 +0000 (11:48 +0900)]
pci: improve signature of pci_register_bar().

Make type uint8_t from int because PCIIORegion::type is uint8_t.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
14 years agopci: don't ignore invalid parameter for pci_register_bar().
Isaku Yamahata [Thu, 9 Sep 2010 02:48:56 +0000 (11:48 +0900)]
pci: don't ignore invalid parameter for pci_register_bar().

Abort when invalid value for region_num is passed to pci_register_bar.
That is caller's bug. Abort instead of silently ignoring invalid value.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci: sorting out type confusion in pci_register_bar().
Isaku Yamahata [Thu, 9 Sep 2010 02:48:55 +0000 (11:48 +0900)]
pci: sorting out type confusion in pci_register_bar().

This patch sorts out invalid use of pcibus_t.

In pci_register_bar(), pcibus_t wmask is used.  It should,
however, be uint64_t because it is used to set
pci configuration space value(PCIDevice::wmask)
by pci_set_quad() or pci_set_long().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci_ids.h: add vendor id of Texas Intesruments
Isaku Yamahata [Mon, 6 Sep 2010 07:46:20 +0000 (16:46 +0900)]
pci_ids.h: add vendor id of Texas Intesruments

add vendor id of Texas Intesruments.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci: make pci_parse_devfn() aware of func.
Isaku Yamahata [Mon, 6 Sep 2010 07:46:19 +0000 (16:46 +0900)]
pci: make pci_parse_devfn() aware of func.

make pci_parse_devfn() aware of func. With func = NULL it behave as before.
This will be used later.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci: call hotplug callback even when not hotplug case for later use.
Isaku Yamahata [Mon, 6 Sep 2010 07:46:18 +0000 (16:46 +0900)]
pci: call hotplug callback even when not hotplug case for later use.

call hotplug callback even when not hotplug case for later use.
And move hotplug check into hotplug callback.
PCIE slot needs this for card presence detection.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci bridge: add helper function for ssvid capability.
Isaku Yamahata [Mon, 6 Sep 2010 07:46:17 +0000 (16:46 +0900)]
pci bridge: add helper function for ssvid capability.

helper function to add ssvid capability.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci: consolidate pci_add_capability_at_offset() into pci_add_capability().
Isaku Yamahata [Mon, 6 Sep 2010 07:46:16 +0000 (16:46 +0900)]
pci: consolidate pci_add_capability_at_offset() into pci_add_capability().

By making pci_add_capability() the special case of
pci_add_capability_at_offset() of offset = 0,
consolidate pci_add_capability_at_offset() into pci_add_capability().

Cc: Stefan Weil <weil@mail.berlios.de>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci_bridge: introduce pci bridge library.
Isaku Yamahata [Tue, 13 Jul 2010 04:01:42 +0000 (13:01 +0900)]
pci_bridge: introduce pci bridge library.

introduce pci bridge library.
convert apb bridge and dec p2p bridge to use new pci bridge library.
save/restore is supported as a side effect.
This is also preparation for pci express root/upstream/downstream port.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci_bridge: clean up: remove pci_{register, unregister}_secondary_bus()
Isaku Yamahata [Tue, 13 Jul 2010 04:01:41 +0000 (13:01 +0900)]
pci_bridge: clean up: remove pci_{register, unregister}_secondary_bus()

Remove pci_{register, unregister}_secondary_bus() by open code.
They are old stype API and aren't used any more by others. So eliminate it.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci_bridge: rename PCIBridge::bus -> PCIBridge::sec_bus.
Isaku Yamahata [Tue, 13 Jul 2010 04:01:40 +0000 (13:01 +0900)]
pci_bridge: rename PCIBridge::bus -> PCIBridge::sec_bus.

To avoid confusion of primary bus with secondary bus,
rename PCIBridge::bus to PCIBridge::sec_bus.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci/bridge: split out pci bridge code into pci_bridge.c from pci.c
Isaku Yamahata [Tue, 13 Jul 2010 04:01:39 +0000 (13:01 +0900)]
pci/bridge: split out pci bridge code into pci_bridge.c from pci.c

Move pci bridge related code into pci_bridge.c from pci.c
for further enhancement. pci.c is big enough now, so split it out.
No code change but exporting some accesser functions.

In fact, few pci bridge functions stays in pci.c.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci: move out pci internal structures, PCIBus, PCIBridge, and pci_bus_info.
Isaku Yamahata [Mon, 12 Jul 2010 10:36:40 +0000 (19:36 +0900)]
pci: move out pci internal structures, PCIBus, PCIBridge, and pci_bus_info.

move out pci internal structures, PCIBus, PCIBridge and pci_bus_info into
private header file, pci_internals.h.
This is a preparation. Later pci bridge implementation will be
split out form pci.c into pci_bridge.c.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agovhost: fix miration during device start
Michael S. Tsirkin [Fri, 16 Jul 2010 14:11:46 +0000 (17:11 +0300)]
vhost: fix miration during device start

We need to know ring layout to allocate log buffer.
So init rings first.

Also fixes a theoretical memory-leak-on-error.

https://bugzilla.redhat.com/show_bug.cgi?id=615228

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
14 years agoe1000: secrc support
Michael S. Tsirkin [Mon, 12 Jul 2010 17:41:02 +0000 (20:41 +0300)]
e1000: secrc support

Add support for secrc field. Reportedly needed by old RHEL guests.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agoe1000: fix access 4 bytes beyond buffer end
Michael S. Tsirkin [Mon, 12 Jul 2010 17:24:59 +0000 (20:24 +0300)]
e1000: fix access 4 bytes beyond buffer end

We do range check for size, and get size as buffer,
but copy size + 4 bytes (4 is for FCS).
Let's copy size bytes but put size + 4 in length.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agoMerge branch 'master' into pci
Michael S. Tsirkin [Mon, 12 Jul 2010 12:13:02 +0000 (15:13 +0300)]
Merge branch 'master' into pci

14 years agotarget-sh4: Add support for ldc & stc with sgr
Alexandre Courbot [Mon, 12 Jul 2010 05:05:32 +0000 (14:05 +0900)]
target-sh4: Add support for ldc & stc with sgr

Add support for the following missing priviledged intructions:

For SH4:
- stc sgr, Rn
- stc.l sgr, @-Rn

For SH4A:
- ldc Rm, sgr
- ldc.l @Rm+, sgr

Signed-off-by: Alexandre Courbot <gnurou@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotarget-sh4: Split the LDST macro into 2 sub-macros
Alexandre Courbot [Mon, 12 Jul 2010 05:05:31 +0000 (14:05 +0900)]
target-sh4: Split the LDST macro into 2 sub-macros

The LDST macro is used to generate ldc and stc instructions that work with a
specific register. However, the SGR register only supports stc up to SH4A,
which supports both stc and ldc. This patch creates two sub-macros named LD
and ST that handle generating ldc and stc instructions separately, and
redeclares LDST to use these sub-macro.

Signed-off-by: Alexandre Courbot <gnurou@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agopci: fix bridge update
Michael S. Tsirkin [Tue, 6 Jul 2010 11:17:51 +0000 (14:17 +0300)]
pci: fix bridge update

bridge config write should trigger updates
on the secondary bus. never on the primary bus.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agovirtio-net: correct packet length math
Michael S. Tsirkin [Tue, 22 Jun 2010 13:22:49 +0000 (16:22 +0300)]
virtio-net: correct packet length math

We were requesting too much when checking buffer
length: size already includes host header length.

Further, we should not exit if we get a packet that
is too long, since this might not be under control
of the guest. Just drop the packet.

Red Hat bz 591494

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci hotplug: make pci hotplug return value to caller
Isaku Yamahata [Tue, 22 Jun 2010 02:55:35 +0000 (11:55 +0900)]
pci hotplug: make pci hotplug return value to caller

make pci hotplug callback return value to caller.
And when returning error, allocated resources are freed.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agovmware_vga: fix reset value for command register
Michael S. Tsirkin [Thu, 17 Jun 2010 11:01:38 +0000 (14:01 +0300)]
vmware_vga: fix reset value for command register

Make init value for this register match the spec.
BAR address is 0 at init, so enabling it
only works by chance.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agortl8139: address TODOs
Michael S. Tsirkin [Thu, 17 Jun 2010 11:17:59 +0000 (14:17 +0300)]
rtl8139: address TODOs

Make rtl8139 spec compliant, fixing reset values
for command register.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopci hotplug: make pci_device_hot_remove() static
Isaku Yamahata [Tue, 15 Jun 2010 03:48:36 +0000 (12:48 +0900)]
pci hotplug: make pci_device_hot_remove() static

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agopcnet: address TODOs
Michael S. Tsirkin [Thu, 17 Jun 2010 11:08:24 +0000 (14:08 +0300)]
pcnet: address TODOs

pcnet enables memory/io on init, which
does not make sense as BAR values are wrong.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Jan Kiszka <jan.kiszka@siemens.com>
14 years agopci: fix pci_device_reset
Isaku Yamahata [Thu, 17 Jun 2010 06:15:45 +0000 (15:15 +0900)]
pci: fix pci_device_reset

Clear interrupt disable bit on reset, according to PCI spec.
Fix pci_device_reset() with 64bit BAR.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
14 years agoAppleSMC device emulation
Alexander Graf [Wed, 30 Jun 2010 08:41:12 +0000 (10:41 +0200)]
AppleSMC device emulation

Intel Macs have a chip called the "AppleSMC" which they use to control
certain Apple specific parts of the hardware, like the keyboard background
light.

That chip is also used to store a key that Mac OS X uses to decrypt binaries.

This patch adds emulation for that chip, so we're getting one step further
to having Mac OS X run natively on Qemu.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoDocumentation: Fix spelling bugs
Stefan Weil [Sun, 11 Jul 2010 16:34:28 +0000 (18:34 +0200)]
Documentation: Fix spelling bugs

rewuired -> required
ths      -> this

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoMakefile: Not every shell support {}
Hidetoshi Seto [Thu, 8 Jul 2010 05:26:18 +0000 (14:26 +0900)]
Makefile: Not every shell support {}

So interpret it by hand.

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoMakefile: add fsdev/*.{o,d} to clean
Hidetoshi Seto [Thu, 8 Jul 2010 05:26:00 +0000 (14:26 +0900)]
Makefile: add fsdev/*.{o,d} to clean

There were fsdev/qemu-fsdev.{o,d} not removed at "make clean".

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopci: set PCI multi-function bit appropriately.
Isaku Yamahata [Wed, 23 Jun 2010 07:15:33 +0000 (16:15 +0900)]
pci: set PCI multi-function bit appropriately.

Set PCI multi-function bit according to multifunction property.
PCI address, devfn ,is exported to users as addr property,
so users can populate pci function(PCIDevice in qemu)
at arbitrary devfn.
It means each function(PCIDevice) don't know whether pci device
(PCIDevice[8]) is multi function or not.
So this patch allows user to set multifunction bit via property
and checks whether multifunction bit is set correctly.

Cc: Juan Quintela <quintela@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopci_bridge: make pci bridge aware of pci multi function bit.
Isaku Yamahata [Wed, 23 Jun 2010 07:15:32 +0000 (16:15 +0900)]
pci_bridge: make pci bridge aware of pci multi function bit.

make pci bridge aware of pci multi function property and let pci generic
code to set the bit.

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopci: set multifunction property for normal device.
Isaku Yamahata [Wed, 23 Jun 2010 07:15:31 +0000 (16:15 +0900)]
pci: set multifunction property for normal device.

use pci_create_simple_multifunction() for normal device which sets
multifunction bit.
At the moment, only pc_piix.c and mips_malta.c uses multifunction
devices with piix3/4 pci-isa bridge.
And other boards don't populate those devices.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopci: introduce multifunction property.
Isaku Yamahata [Wed, 23 Jun 2010 07:15:30 +0000 (16:15 +0900)]
pci: introduce multifunction property.

introduce multifunction property.
Also introduce new convenient device creation function which
will be used later.

For bisectability this patch doesn't do anything, but sets the property
resulting in no functional changes.
Actual changes will be introduced by later patch.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoqdev: implement qdev_prop_set_bit().
Isaku Yamahata [Wed, 23 Jun 2010 07:15:29 +0000 (16:15 +0900)]
qdev: implement qdev_prop_set_bit().

implement qdev_prop_set_bit().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopci: remove PCIDeviceInfo::header_type
Isaku Yamahata [Wed, 23 Jun 2010 07:15:28 +0000 (16:15 +0900)]
pci: remove PCIDeviceInfo::header_type

replace PCIDeviceInfo::header_type with is_bridge
as suggested by Michael S. Tsirkin <mst@redhat.com>

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopci: don't overwrite multi functio bit in pci header type.
Isaku Yamahata [Wed, 23 Jun 2010 07:15:27 +0000 (16:15 +0900)]
pci: don't overwrite multi functio bit in pci header type.

Don't overwrite pci header type.
Otherwise, multi function bit which pci_init_header_type() sets
appropriately is lost.
Anyway PCI_HEADER_TYPE_NORMAL is zero, so it is unnecessary to zero
which is already zero cleared.

how to test:
run qemu and issue info pci to see whether a device in question is
normal device, not pci-to-pci bridge.
This is handy because guest os isn't required.

tested changes:
The following files are covered by using following commands.
sparc64-softmmu
  apb_pci.c, vga-pci.c, cmd646.c, ne2k_pci.c, sun4u.c
ppc-softmmu
  grackle_pci.c, cmd646.c, ne2k_pci.c, vga-pci.c, macio.c
ppc-softmmu -M mac99
  unin_pci.c(uni-north, uni-north-agp)
ppc64-softmmu
  pci-ohci, ne2k_pci, vga-pci, unin_pci.c(u3-agp)
x86_64-softmmu
  acpi_piix4.c, ide/piix.c, piix_pci.c
  -vga vmware vmware_vga.c
  -watchdog i6300esb wdt_i6300esb.c
  -usb usb-uhci.c
  -sound ac97 ac97.c
  -nic model=rtl8139 rtl8139.c
  -nic model=pcnet pcnet.c
  -balloon virtio virtio-pci.c:

untested changes:
The following changes aren't tested.
prep_pci.c: ppc-softmmu -M prep should cover, but core dumped.
unin_pci.c(uni-north-pci): the caller is commented out.
openpic.c: the caller is commented out in ppc_prep.c

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopci: insert assert that auto-assigned-address function is single function device.
Isaku Yamahata [Wed, 23 Jun 2010 07:15:26 +0000 (16:15 +0900)]
pci: insert assert that auto-assigned-address function is single function device.

Auto-assigned-address pci function (passing devfn = -1) is always
single function.
This patch adds assert() to guarantee that auto-assigned-address function
is always single function device at function = 0.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopci: use PCI_DEVFN() where appropriate.
Isaku Yamahata [Wed, 23 Jun 2010 07:15:25 +0000 (16:15 +0900)]
pci: use PCI_DEVFN() where appropriate.

Use PCI_DEVFN() and PCI_FUNC_MAX where appropriate.
This patch make it clear that func = 0.

test:
The following object files with/without this patch are stripped and compared.
They remains same.
  arm-softmmu/versatile_pci.o
  libhw32/ppce500_pci.o
  libhw32/unin_pci.o
  libhw64/ppce500_pci.o
  libhw64/unin_pci.o
  mips-softmmu/gt64xxx.o
  mips64-softmmu/gt64xxx.o
  mips64el-softmmu/gt64xxx.o
  mipsel-softmmu/gt64xxx.o

Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Yu Liu <yu.liu@freescale.com>
Cc: Paul Brook <paul@codesourcery.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agotarget-mips: add loongson 2E & 2F integer instructions
Aurelien Jarno [Fri, 18 Jun 2010 17:32:43 +0000 (19:32 +0200)]
target-mips: add loongson 2E & 2F integer instructions

This patch adds support for loongson 2E & 2F instructions. They are the
same instructions, but differ by the opcode encoding.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoFix warning about uninitialized variable
Blue Swirl [Wed, 7 Jul 2010 19:37:53 +0000 (19:37 +0000)]
Fix warning about uninitialized variable

With gcc 4.2.1-sjlj (mingw32-2) I get this warning:
/src/qemu/exec.c: In function 'qemu_ram_alloc':
/src/qemu/exec.c:2777: warning: 'offset' may be used uninitialized in this function

Fix by initializing the variable.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agosheepdog: fix compile error on systems without TCP_CORK
MORITA Kazutaka [Wed, 7 Jul 2010 06:25:30 +0000 (15:25 +0900)]
sheepdog: fix compile error on systems without TCP_CORK

WIN32 is not only the system which doesn't have TCP_CORK (e.g. OS X).

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoMerge remote branch 'kwolf/for-anthony' into staging
Anthony Liguori [Tue, 6 Jul 2010 15:48:01 +0000 (10:48 -0500)]
Merge remote branch 'kwolf/for-anthony' into staging

14 years agoramblocks: No more being lazy about duplicate names
Alex Williamson [Fri, 2 Jul 2010 17:13:29 +0000 (11:13 -0600)]
ramblocks: No more being lazy about duplicate names

Now that we have a working qemu_ram_free() and the primary runtime
user of it has been updated, don't be lenient about duplicate id strings.
We also shouldn't need to create them ondemand at the target.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agopci: Free the space allocated for the option rom on removal
Alex Williamson [Fri, 25 Jun 2010 17:10:19 +0000 (11:10 -0600)]
pci: Free the space allocated for the option rom on removal

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqemu_ram_free: Implement it
Alex Williamson [Fri, 2 Jul 2010 17:13:17 +0000 (11:13 -0600)]
qemu_ram_free: Implement it

Now that we can support a ram_addr_t space with holes, we can implement
qemu_ram_free().

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agosavevm: Create a new continue flag to avoid resending block name
Alex Williamson [Fri, 25 Jun 2010 17:10:05 +0000 (11:10 -0600)]
savevm: Create a new continue flag to avoid resending block name

Allows us to compress the protocol a bit by setting a flag on the
offset which indicates we're still working within the same block
as last time.  That way we can avoid sending the block name for
every page.  Suggested by Anthony Liguori.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agosavevm: Use RAM blocks for basis of migration
Alex Williamson [Fri, 25 Jun 2010 17:09:57 +0000 (11:09 -0600)]
savevm: Use RAM blocks for basis of migration

We don't want to assume a contiguous address space, so migrate based
on RAM blocks instead of a fixed linear address map.  This will allow
us to have holes in the ram_addr_t namespace, so we can implement
qemu_ram_free().

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agosavevm: Migrate RAM based on name/offset
Alex Williamson [Fri, 25 Jun 2010 17:09:50 +0000 (11:09 -0600)]
savevm: Migrate RAM based on name/offset

Synchronize RAM blocks with the target and migrate using name/offset
pairs.  This ensures both source and target have the same view of
RAM and that we get the right bits into the right slot.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoramblocks: Make use of DeviceState pointer and BusInfo.get_dev_path
Alex Williamson [Fri, 25 Jun 2010 17:09:43 +0000 (11:09 -0600)]
ramblocks: Make use of DeviceState pointer and BusInfo.get_dev_path

With these two pieces in place, we can start naming ramblocks.  When
the device is present and it lives on a bus that provides a device
path, we concatenate the path and the provided name.  Otherwise we
just use name.  The resulting id string must be unique.  For now we
assume an allocation for the same name and size is a device that has
been removed and reinserted and return the same block.  This will go
away once qemu_ram_free() is implemented.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqemu_ram_alloc: Add DeviceState and name parameters
Alex Williamson [Fri, 25 Jun 2010 17:09:35 +0000 (11:09 -0600)]
qemu_ram_alloc: Add DeviceState and name parameters

These will be used to generate unique id strings for ramblocks.  The name
field is required, the device pointer is optional as most callers don't
have a device.  When there's no device or the device isn't a child of
a bus implementing BusInfo.get_dev_path, the name should be unique for
the platform.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-net: Incorporate a DeviceState pointer and let savevm track instances
Alex Williamson [Fri, 25 Jun 2010 17:09:28 +0000 (11:09 -0600)]
virtio-net: Incorporate a DeviceState pointer and let savevm track instances

Stuff a pointer to the DeviceState into the VirtIONet structure so that
we can easily remove the vmstate entry later.  Also, let vmstate track
the instance number (it should always be zero internally since the
device path should now be unique).

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoeepro100: Add a dev field to eeprom new/free functions
Alex Williamson [Fri, 25 Jun 2010 17:09:21 +0000 (11:09 -0600)]
eepro100: Add a dev field to eeprom new/free functions

This allows us to create a more meaningful savevm string.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agosavevm: Make use of DeviceState
Alex Williamson [Fri, 25 Jun 2010 17:09:14 +0000 (11:09 -0600)]
savevm: Make use of DeviceState

For callers that pass a device we can traverse up the qdev tree and
make use of the BusInfo.get_dev_path information for creating unique
savevm id strings.  This avoids needing to rely on the instance number,
which can cause problems with device initialization order and hotplug.

For compatibility, we also store away the old id string and instance
so we can accept migrations from VMs as we add new get_dev_path
implementations.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agosavevm: Add DeviceState param
Alex Williamson [Fri, 25 Jun 2010 17:09:07 +0000 (11:09 -0600)]
savevm: Add DeviceState param

When available, we'd like to be able to access the DeviceState
when registering a savevm.  For buses with a get_dev_path()
function, this will allow us to create more unique savevm
id strings.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agopci: Implement BusInfo.get_dev_path()
Alex Williamson [Fri, 25 Jun 2010 17:08:59 +0000 (11:08 -0600)]
pci: Implement BusInfo.get_dev_path()

This works great for PCI since a <segment>:<bus>:<dev>.<fn> uniquely
describes a global address.  No need to traverse up the qdev tree.
PCI segment support is a placeholder for compatibility once we
support multiple segments.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqdev: Add a get_dev_path() function to BusInfo
Alex Williamson [Fri, 25 Jun 2010 17:08:52 +0000 (11:08 -0600)]
qdev: Add a get_dev_path() function to BusInfo

This function is meant to provide a stable device path for buses
which are able to implement it.  If a bus has a globally unique
addresses scheme, one address level may be sufficient to provide
a path.  Other buses may need to recursively traverse up the
qdev tree.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agopc: Allocate all ram in a single qemu_ram_alloc()
Alex Williamson [Fri, 25 Jun 2010 17:08:45 +0000 (11:08 -0600)]
pc: Allocate all ram in a single qemu_ram_alloc()

This will benefit us when we migrate based on ramblock name since
we won't be bouncing between separate blocks.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoRemove uses of ram.last_offset (aka last_ram_offset)
Alex Williamson [Fri, 25 Jun 2010 17:08:38 +0000 (11:08 -0600)]
Remove uses of ram.last_offset (aka last_ram_offset)

We currently need this either to allocate the next ram_addr_t for a
new block, or for total memory to be migrated.  Both of which we can
calculate without need of this to keep us in a contiguous address space.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomake rtc alatm work
Gleb Natapov [Mon, 5 Jul 2010 08:36:34 +0000 (11:36 +0300)]
make rtc alatm work

Convert alarm time from BCD if needed before comparing with current
time.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: Fix SCSI bus reset
Jan Kiszka [Tue, 6 Jul 2010 08:58:03 +0000 (10:58 +0200)]
scsi: Fix SCSI bus reset

When the controller raises the SCSI reset line, we have to perform the
requested reset on all disks attached to the controller's bus. Moreover,
reset is edge triggered, so avoid repeating it if the line was already
high.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoFix io-thread build breakage of a88790a14f
Jan Kiszka [Tue, 6 Jul 2010 08:49:57 +0000 (10:49 +0200)]
Fix io-thread build breakage of a88790a14f

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock: add sheepdog driver for distributed storage support
MORITA Kazutaka [Sun, 20 Jun 2010 20:01:00 +0000 (05:01 +0900)]
block: add sheepdog driver for distributed storage support

Sheepdog is a distributed storage system for QEMU. It provides highly
available block level storage volumes to VMs like Amazon EBS.  This
patch adds a qemu block driver for Sheepdog.

Sheepdog features are:
- No node in the cluster is special (no metadata node, no control
  node, etc)
- Linear scalability in performance and capacity
- No single point of failure
- Autonomous management (zero configuration)
- Useful volume management support such as snapshot and cloning
- Thin provisioning
- Autonomous load balancing

The more details are available at the project site:
    http://www.osrg.net/sheepdog/

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoide: Reject invalid CHS geometry
Markus Armbruster [Mon, 28 Jun 2010 19:25:17 +0000 (21:25 +0200)]
ide: Reject invalid CHS geometry

drive_init() doesn't permit invalid CHS for if=ide, but that's
worthless: we get it via if=none and -device.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoide: Reject readonly drives unless CD-ROM
Markus Armbruster [Mon, 28 Jun 2010 17:10:36 +0000 (19:10 +0200)]
ide: Reject readonly drives unless CD-ROM

drive_init() doesn't permit option readonly for if=ide, but that's
worthless: we get it via if=none and -device.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoide: Make ide_init_drive() return success
Markus Armbruster [Mon, 28 Jun 2010 17:07:51 +0000 (19:07 +0200)]
ide: Make ide_init_drive() return success

It still always succeeds.  The next commits will add failures.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoide: Replace IDEState members is_cdrom, is_cf by drive_kind
Markus Armbruster [Fri, 28 May 2010 11:32:45 +0000 (13:32 +0200)]
ide: Replace IDEState members is_cdrom, is_cf by drive_kind

The two aren't independent variables.  Make that obvious.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoide: Improve error messages
Markus Armbruster [Mon, 28 Jun 2010 06:36:53 +0000 (08:36 +0200)]
ide: Improve error messages

Use error_report(), because it points to the error location.

Reword "tried to assign twice" messages to make it clear that we're
complaining about the unit property.

Report invalid unit property instead of failing silently.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoscsi: Error locations for -drive if=scsi device initialization
Markus Armbruster [Thu, 27 May 2010 19:08:18 +0000 (21:08 +0200)]
scsi: Error locations for -drive if=scsi device initialization

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoerror: New qemu_opts_loc_restore()
Markus Armbruster [Thu, 27 May 2010 19:06:04 +0000 (21:06 +0200)]
error: New qemu_opts_loc_restore()

Needed for decent error locations when complaining about options
outside of qemu_opts_foreach().  That one sets the location
already.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoscsi: Reject unimplemented error actions
Markus Armbruster [Thu, 27 May 2010 18:02:28 +0000 (20:02 +0200)]
scsi: Reject unimplemented error actions

drive_init() doesn't permit rerror for if=scsi, but that's worthless:
we get it via if=none and -device.

Moreover, scsi-generic doesn't support werror.  Since drive_init()
doesn't catch that, option werror was silently ignored even with
if=scsi.

Wart: unlike drive_init(), we don't reject the default action when
it's explicitly specified.  That's because we can't distinguish "no
rerror option" from "rerror=report", or "no werror" from
"rerror=enospc".  Left for another day.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqdev: Don't hw_error() in qdev_init_nofail()
Markus Armbruster [Thu, 27 May 2010 19:23:08 +0000 (21:23 +0200)]
qdev: Don't hw_error() in qdev_init_nofail()

Some of the failures are internal errors, and hw_error() is okay then.
But the common way to fail is bad user input, e.g. -global
isa-fdc.driveA=foo where drive foo has an unsupported rerror value.

exit(1) instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agofdc: Reject unimplemented error actions
Markus Armbruster [Thu, 27 May 2010 18:06:12 +0000 (20:06 +0200)]
fdc: Reject unimplemented error actions

drive_init() doesn't permit them for if=floppy, but that's worthless:
we get them via if=none and -global.

This can make device initialization fail.  Since all callers of
fdctrl_init_isa() ignore its value, change it to die instead of
returning failure.  Without this, some callers would ignore the
failure, and others would crash.

Wart: unlike drive_init(), we don't reject the default action when
it's explicitly specified.  That's because we can't distinguish "no
rerror option" from "rerror=report", or "no werror" from
"rerror=enospc".  Left for another day.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoraw-posix: Fix test for host CD-ROM
Markus Armbruster [Mon, 28 Jun 2010 08:25:20 +0000 (10:25 +0200)]
raw-posix: Fix test for host CD-ROM

raw_pread_aligned() retries up to two times if the block device backs
a virtual CD-ROM (a drive with media=cdrom and if=ide, scsi, xen or
none).  This makes no sense.  Whether retrying reads can correct read
errors can only depend on what we're reading, not on how the result
gets used.  We need to check what whether we're reading from a
physical CD-ROM or floppy here.

I doubt retrying is useful even then.  Left for another day.

Impact:

* Virtual CD-ROM backed by host_cdrom behaves the same.

* Virtual CD-ROM backed by file or host_device no longer retries.

* A drive backed by host_cdrom now retries even if it's not a virtual
  CD-ROM.

* Any drive backed by host_floppy now retries.

While there, clean up gratuitous use of goto.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock migration: Fix test for read-only drive
Markus Armbruster [Mon, 28 Jun 2010 08:45:02 +0000 (10:45 +0200)]
block migration: Fix test for read-only drive

init_blk_migration_it() skips drives with type hint BDRV_TYPE_CDROM.
The intention is to skip read-only drives.  However, BDRV_TYPE_CDROM
is only a hint.  It is currently sufficent for read-only.  But it's
not necessary, and it may not remain sufficient.

Use bdrv_is_read_only() instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblockdev: Clean up how readonly persists across virtual media change
Markus Armbruster [Fri, 25 Jun 2010 13:26:48 +0000 (15:26 +0200)]
blockdev: Clean up how readonly persists across virtual media change

Since commit cb4e5f8e, monitor command change makes the new media
readonly iff the type hint is BDRV_TYPE_CDROM, i.e. the drive was
created with media=cdrom.  The intention is to avoid changing a block
device's read-only-ness.  However, BDRV_TYPE_CDROM is only a hint.  It
is currently sufficent for read-only.  But it's not necessary, and it
may not remain sufficient.

Use bdrv_is_read_only() instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoAdd virtio disk identification support
john cooper [Fri, 2 Jul 2010 17:44:25 +0000 (13:44 -0400)]
Add virtio disk identification support

This patch adds the final missing bits for support of
passing a serial/id string to a virtio-blk guest driver.

The guest-side component already exists in the virtio
driver, and has recently been reworked by Ryan to export
a /sys interface for retrieval of the id from guest userland.

Signed-off-by: john cooper <john.cooper@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqcow2/vdi: Change check to distinguish error cases
Kevin Wolf [Tue, 29 Jun 2010 10:37:54 +0000 (12:37 +0200)]
qcow2/vdi: Change check to distinguish error cases

This distinguishes between harmless leaks and real corruption. Hopefully users
better understand what qemu-img check wants to tell them.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqemu-img check: Distinguish different kinds of errors
Kevin Wolf [Tue, 29 Jun 2010 09:43:13 +0000 (11:43 +0200)]
qemu-img check: Distinguish different kinds of errors

People think that their images are corrupted when in fact there are just some
leaked clusters. Differentiating several error cases should make the messages
more comprehensible.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoInclude sys/mman.h before qemu-options.h
Jes Sorensen [Tue, 6 Jul 2010 08:50:27 +0000 (10:50 +0200)]
Include sys/mman.h before qemu-options.h

The result of parsing qemu-options.def depends on whehter or not
MAP_POPULATE is defined, so make sure to include sys/mman.h before
including qemu-options.h.

Reported by Frank Arnold.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoMerge remote branch 'kwolf/for-anthony' into staging
Anthony Liguori [Tue, 6 Jul 2010 13:31:43 +0000 (08:31 -0500)]
Merge remote branch 'kwolf/for-anthony' into staging

14 years agoMerge remote branch 'qmp/for-anthony' into staging
Anthony Liguori [Tue, 6 Jul 2010 13:31:17 +0000 (08:31 -0500)]
Merge remote branch 'qmp/for-anthony' into staging

14 years agocris: Avoid debug clobbering for both I & D MMU state.
Edgar E. Iglesias [Mon, 5 Jul 2010 09:39:04 +0000 (11:39 +0200)]
cris: Avoid debug clobbering for both I & D MMU state.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@axis.com>
14 years agocris: Dont clobber the MMU state across calls to cpu_get_phys_page_debug.
Edgar E. Iglesias [Mon, 5 Jul 2010 08:24:56 +0000 (10:24 +0200)]
cris: Dont clobber the MMU state across calls to cpu_get_phys_page_debug.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
14 years agocris: Break out rand LFSR update into a separate func.
Edgar E. Iglesias [Mon, 5 Jul 2010 08:15:10 +0000 (10:15 +0200)]
cris: Break out rand LFSR update into a separate func.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@axis.com>
14 years agopiix4: compile only once
Blue Swirl [Sat, 3 Jul 2010 06:49:47 +0000 (06:49 +0000)]
piix4: compile only once

Compile piix4 in hwlib. Two compilations less for the full build.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoremove exec-all.h inclusion from cpu.h
Paolo Bonzini [Tue, 29 Jun 2010 07:58:51 +0000 (09:58 +0200)]
remove exec-all.h inclusion from cpu.h

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agomove cpu_pc_from_tb to target-*/exec.h
Paolo Bonzini [Tue, 29 Jun 2010 07:58:50 +0000 (09:58 +0200)]
move cpu_pc_from_tb to target-*/exec.h

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoremove unused stuff from */exec.h
Paolo Bonzini [Tue, 29 Jun 2010 07:58:49 +0000 (09:58 +0200)]
remove unused stuff from */exec.h

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoblock: Handle multiwrite errors only when all requests have completed
Kevin Wolf [Thu, 1 Jul 2010 14:08:51 +0000 (16:08 +0200)]
block: Handle multiwrite errors only when all requests have completed

Don't try to be clever by freeing all temporary data and calling all callbacks
when the return value (an error) is certain. Doing so has at least two
important problems:

* The temporary data that is freed (qiov, possibly zero buffer) is still used
  by the requests that have not yet completed.
* Calling the callbacks for all requests in the multiwrite means for the caller
  that it may free buffers etc. which are still in use.

Just remember the error value and do the cleanup when all requests have
completed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Fix early failure in multiwrite
Kevin Wolf [Fri, 2 Jul 2010 12:01:21 +0000 (14:01 +0200)]
block: Fix early failure in multiwrite

bdrv_aio_writev may call the callback immediately (and it will commonly do so
in error cases). Current code doesn't consider this. For details see the
comment added by this patch.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqemu-img: avoid calling exit(1) to release resources properly
MORITA Kazutaka [Sun, 20 Jun 2010 19:26:35 +0000 (04:26 +0900)]
qemu-img: avoid calling exit(1) to release resources properly

This patch removes exit(1) from error(), and properly releases
resources such as a block driver and an allocated memory.

For testing the Sheepdog block driver with qemu-iotests, it is
necessary to call bdrv_delete() before the program exits.  Because the
driver releases the lock of VM images in the close handler.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agopc: Fix CMOS info for drives defined with -device
Markus Armbruster [Thu, 24 Jun 2010 17:58:20 +0000 (19:58 +0200)]
pc: Fix CMOS info for drives defined with -device

Drives defined with -drive if=ide get get created along with the IDE
controller, inside machine->init().  That's before cmos_init().
Drives defined with -device get created during generic device init.
That's after cmos_init().  Because of that, CMOS has no information on
them (type, geometry, translation).  Older versions of Windows such as
XP reportedly choke on that.

Split off the part of CMOS initialization that needs to know about
-device devices, and turn it into a reset handler, so it runs after
device creation.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoide: Make PIIX and ISA IDE init functions return the qdev
Markus Armbruster [Thu, 24 Jun 2010 17:59:29 +0000 (19:59 +0200)]
ide: Make PIIX and ISA IDE init functions return the qdev

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Fix virtual media change for if=none
Markus Armbruster [Fri, 25 Jun 2010 11:42:14 +0000 (13:42 +0200)]
block: Fix virtual media change for if=none

BlockDriverState member removable controls whether virtual media
change (monitor commands change, eject) is allowed.  It is set when
the "type hint" is BDRV_TYPE_CDROM or BDRV_TYPE_FLOPPY.

The type hint is only set by drive_init().  It sets BDRV_TYPE_FLOPPY
for if=floppy.  It sets BDRV_TYPE_CDROM for media=cdrom and if=ide,
scsi, xen, or none.

if=ide and if=scsi work, because the type hint makes it a CD-ROM.
if=xen likewise, I think.

For the same reason, if=none works when it's used by ide-drive or
scsi-disk.  For other guest devices, there are problems:

* fdc: you can't change virtual media

    $ qemu [...] -drive if=none,id=foo,... -global isa-fdc.driveA=foo
    QEMU 0.12.50 monitor - type 'help' for more information
    (qemu) eject foo
    Device 'foo' is not removable

  unless you add media=cdrom, but that makes it readonly.

* virtio: if you add media=cdrom, you can change virtual media.  If
  you eject, the guest gets I/O errors.  If you change, the guest sees
  the drive's contents suddenly change.

* scsi-generic: if you add media=cdrom, you can change virtual media.
  I didn't test what that does to the guest or the physical device,
  but it can't be pretty.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Clean up bdrv_snapshots()
Markus Armbruster [Thu, 1 Jul 2010 07:30:38 +0000 (09:30 +0200)]
block: Clean up bdrv_snapshots()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>