[Qemu-devel] what's new in qemu.git pci tree

2010-11-22 Thread Michael S. Tsirkin
Last chance to object to the following patches :)

The following changes since commit e927d48722fdcba50f82d653c5a1927752483054:

  pci: allow hotplug removal of cold-plugged devices (2010-11-16 14:55:23 +0200)

are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu.git pci

Anthony Liguori (2):
  qbus: add functions to walk both devices and busses
  qdev: reset qdev along with qdev tree

Isaku Yamahata (11):
  pci: add W1C bits to pci status register
  pcie_regs.h: more constants
  pcie/aer: helper functions for pcie aer capability
  ioh3420: support aer
  x3130/upstream: support aer
  x3130/downstream: support aer.
  pcie/port: fix bridge control register wmask
  qdev: introduce reset call back for qbus level
  qdev: trigger reset from a given device
  pci: use qdev reset framework for pci bus reset
  pci bridge: implement secondary bus reset

Michael S. Tsirkin (3):
  pcie_aer: get rid of recursion
  pcie_aer: complete unwinding recursion
  pci: fix bridge control bit wmask

Stefan Weil (3):
  pci: Replace unneeded type casts in calls of pci_register_bar
  pci: Automatically patch PCI vendor id and device id in PCI ROM
  eepro100: Use a single rom file for all i825xx devices

 Makefile   |1 -
 Makefile.objs  |2 +-
 hw/cirrus_vga.c|4 +-
 hw/e1000.c |4 +-
 hw/eepro100.c  |   14 +-
 hw/ide/via.c   |2 +-
 hw/ioh3420.c   |   80 +++-
 hw/lsi53c895a.c|7 +-
 hw/openpic.c   |2 +-
 hw/pci.c   |  137 ++-
 hw/pci.h   |1 +
 hw/pci_bridge.c|   11 +-
 hw/pcie.h  |   14 +
 hw/pcie_aer.c  |  815 
 hw/pcie_aer.h  |  106 +
 hw/pcie_port.c |8 +
 hw/pcie_regs.h |2 +
 hw/qdev.c  |   87 -
 hw/qdev.h  |   18 +
 hw/usb-ohci.c  |2 +-
 hw/xio3130_downstream.c|   43 ++-
 hw/xio3130_upstream.c  |   33 +-
 pc-bios/README |2 +-
 pc-bios/gpxe-eepro100-80861229.rom |  Bin 56832 - 0 bytes
 qemu-common.h  |3 +
 vl.c   |1 +
 26 files changed, 1327 insertions(+), 72 deletions(-)
 create mode 100644 hw/pcie_aer.c
 create mode 100644 hw/pcie_aer.h
 delete mode 100644 pc-bios/gpxe-eepro100-80861229.rom



Re: [Qemu-devel] Re: [PATCH] PCI: Bus number from the bridge, not the device

2010-11-22 Thread Michael S. Tsirkin
On Mon, Nov 22, 2010 at 09:37:07AM +0200, Gleb Natapov wrote:
It's probably required to make them stable anyway.

   Why?
  
  To avoid bus renumbering on reboot after you add a pci-to-pci bridge.
  
 Why should qemu care?

Stable bus numbering is a feature *users* care about, because
some Guest OSes get confused when a card gets moved to another
bus.

 --
   Gleb.



Re: [Qemu-devel] [PATCH 00/10] AHCI emulation support v2

2010-11-22 Thread Kevin Wolf
Am 21.11.2010 03:19, schrieb Alexander Graf:
 
 On 19.11.2010, at 14:46, Kevin Wolf wrote:
 
 Am 19.11.2010 14:08, schrieb Alexander Graf:

 On 19.11.2010, at 10:15, Kevin Wolf wrote:

 Am 18.11.2010 19:43, schrieb Alexander Graf:
 Then I believe that core.c is now a mixture of some generic ATA code
 (that is also used by SATA) and the Legacy IDE code. SATA doesn't seem
 to interact with the generic code through clean interfaces, but by
 accessing internal data structures and calls to somewhere in the middle
 of the existing IDE emultion. I think we should get a clean abstraction
 there and have a clean split between SATA, PATA and common code, with
 each of them sitting in its own file in hw/ide.

 I haven't reviewed the patches in detail but just had a quick look at
 them, so my impressions might be wrong. If so, please correct me.

 No, you're completely right. We're in a chicken and egg situation. We 
 don't have ahci, but the ide code is ugly. We would probably do a bad job 
 at refactoring the ata code if we don't know which interfaces to design 
 for.

 That problem is solved. You have posted patches, so you're aware what
 interfaces you need for AHCI. This awareness doesn't come from putting
 the code into git master.

 I guess you should go back and read the this doesn't work yet list. There 
 is a lot of stuff that I'm not sure we have all correctly sorted out. The 
 most intrusive one on that side is the legacy IDE compatibility. I don't 
 know what interfaces and what changes we will need for that to become 
 realistic.

 Fair enough. I'll accept that we can't get it sorted out now, but let's
 try to do the part that we can do. Let's change the split to SATA
 (ahci.c), Legacy IDE (ide.c?), common code (ata.c) and don't know yet
 (core.c).

 A start for that would be if in Patch 2 you moved the function to ata.c
 instead of just reindenting. We're also probably pretty sure that, for
 example, the I/O port handling won't need to be shared and can be moved
 to ide.c. Whenever it becomes clear for a part in which category it
 belongs, we would move it out of core.c and eventually, I hope, core.c
 could be removed.
 
 I can certainly move out obviously pata specific pieces to a new file called 
 pata.c. As for the split between ata.c and core.c, I don't think it's useful. 
 Once we moved everything pata specific out or core.c, that file will 
 essentially be ata.c.

The reason why I suggested ata.c is that core.c would serve as kind of a
todo list. But I don't really mind if you wan to keep it in core.c, the
important part is getting the split between core/ata and pata.

 Also to catch up on Gerd's point - whatever refactoring we do, we will 
 basically have to break migration. There is no way we can change all the 
 internal state and structure and maintain binary compatibility with the old 
 save states.

 Hm, breaking migration isn't really an option. I'm not familiar with
 migration code, but maybe Juan can contribute some magic?

 Speaking of migration, that seems to be missing for the AHCI yet, too.
 Are you planning to complete the functionality first before you start
 with that?
 
 I'm planning to take baby steps so others can contribute and I don't keep a 
 patch set lying around become more invasive and thus more prone to bitrot 
 every day :). I myself just don't scale well enough for a feature this 
 intrusive and important.
 
 I had the code bitrot for quite a bit already btw. GSoC ended a couple months 
 ago and I just didn't get around to polish the code well enough for upstream 
 submission. And believe me, it rots very fast.
 
 Vmstate is an issue we need to solve. I'm not sure what the right way forward 
 for that would be. I certainly would not recommend declaring the migration 
 protocol for sata even remotely stable for the time being, as we're missing 
 crucial pieces still that might require major restructuring or even 
 duplicating of core ide code. And as long as that's the case, I'm not sure 
 how much sense it really makes to have any at all.

Okay, I think that's a good point.

I was asking because I'm not sure if it wouldn't be easier to have
migration working early and then incrementally change it with whatever
is added, compared to developing everything and adding migration as the
last thing. I haven't done either yet, so I might be wrong.

 Basically, if there was a CONFIG_EXPERIMENTAL flag, I would set it on ahci. 
 The code is not and will not be 100% stable and well structures and reliable 
 within the next probably 1/2 year to year. But we need to start walking into 
 a direction where it can finally end up being there some day, and that only 
 works by multiple people working together on this, preferably upstream, so we 
 don't collide with other possible ide work.
 
 Of course there's some chance that it won't get there. If there is interest 
 in it though, it will. And from what I've gathered so far, there is interest, 
 as it's a speedup for a lot of guests 

Re: [Qemu-devel] [PATCH 01/16] Allow zero alloc_hint in qemu_sglist_init()

2010-11-22 Thread Hannes Reinecke
On 11/19/2010 07:28 PM, Christoph Hellwig wrote:
 On Thu, Nov 18, 2010 at 03:44:34PM +0100, Hannes Reinecke wrote:

 qemu_malloc doesn't check for zero argument, so we need to
 check ourselves.
 
 I'm not sure if it's a that good idea to remove the implicit
 -sg != NULL assumption.  Any reason you can't simply call
 qemu_sglist_init later?
 
We can actually drop this. It's a leftover from the old interface.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)



[Qemu-devel] Re: [PATCH] ahci: fix lst+fis mapping

2010-11-22 Thread Gerd Hoffmann

On 11/21/10 03:04, Alexander Graf wrote:


On 20.11.2010, at 00:06, Gerd Hoffmann wrote:


The ahci map_page() function checks whenever it got a full page
mapped. This is wrong.   The data structures are much smaller:
command list is 1k and fis is 256 bytes.  Checking whenever we can
access that much bytes without crossing a page border is good
enougth.


Looks good :). Do you want me to incorporate this with the next
revision of my patch set or keep it separate?


Feel free to squash it in.

cheers,
  Gerd




[Qemu-devel] Re: [PATCH 1/1] iscsi: add iSCSI block device support

2010-11-22 Thread Kevin Wolf
Am 21.11.2010 23:17, schrieb ronnie sahlberg:
 List,
 
 Please find attached a gzipped patch against master that adds support of 
 iSCSI.
 It is sent in gz format because of its uncompressed size, 100kb.

I think there's something missing in your mail. :-)

Anyway, I got the code from the KVM list, and I have some general comments:

* Please split this into some smaller patches and send them as a patch
  series. Inline the patches instead of a gzipped attachment, because
  that makes it a lot easier to comment the code when replying to your
  mail.
* Have a look at CODING_STYLE in the repository, especially at the
  sections about 80 chars per line and whitespace.
* Don't use printf() but error_report() for error messages
* Try to use qemu functions instead of POSIX ones so that the code
  will also work on Windows and other platforms. If you can't make it
  run on Windows, still use qemu functions where possible and change
  the Makefile to compile it only for POSIX hosts.
* Once you use qemu_malloc, you can drop your NULL checks. qemu_malloc
  never returns an error.
* Use QLISTs (qemu-queue.h) instead of introducing a new SLIST

Kevin



Re: [Qemu-devel] [patch 0/3] block migration fixes

2010-11-22 Thread Kevin Wolf
Am 21.11.2010 16:22, schrieb Anthony Liguori:
 On 11/08/2010 01:02 PM, Marcelo Tosatti wrote:
 Following patchset fixes block migration corruption issues

 
 Applied all.  Thanks.

This was the old version. Anyway, I'll include a diff between v1 and v2
in my next pull request.

Kevin



[Qemu-devel] Re: [PATCHv3 RFC] qemu-kvm: stop devices on vmstop

2010-11-22 Thread Gerd Hoffmann

On 11/21/10 20:16, Michael S. Tsirkin wrote:

Stop running devices on vmstop, so that VM does not interact with
outside world at that time.

Whitelist system handlers which run even when VM is stopped.
These are specific handlers like monitor, gdbstub, migration.
I'm not really sure about ui: spice and vnc: do they need to run?


Yes, vnc and spice should run.  They serve the clients.  They also don't 
change device state.


cheers,
  Gerd

PS: Well, in the spice case this isn't 100% true, the handlers can 
change qxl device state in some cases.  But spice has a start/stop 
handler which takes care to flush all outstanding work which could 
change device state on vmstop, so it is save to keep the handlers active 
when the vm is in stopped state.





[Qemu-devel] [PATCH] scsi: INQUIRY VPD fixes

2010-11-22 Thread Hannes Reinecke

We should announce and support the block device characterics page
only on block devices, not on CDROMs. And the VPD page 0x83 has
an off-by-one error.

Signed-off-by: Hannes Reinecke h...@suse.de
Acked-by: Christoph Hellwig h...@lst.de
---
 hw/scsi-disk.c |   18 ++
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index dc71957..a76e91c 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -398,15 +398,20 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 
 switch (page_code) {
 case 0x00: /* Supported page codes, mandatory */
+{
+int pages;
 DPRINTF(Inquiry EVPD[Supported pages] 
 buffer size %zd\n, req-cmd.xfer);
-outbuf[buflen++] = 4;// number of pages
+pages = buflen++;
 outbuf[buflen++] = 0x00; // list of supported pages (this page)
 outbuf[buflen++] = 0x80; // unit serial number
 outbuf[buflen++] = 0x83; // device identification
-outbuf[buflen++] = 0xb0; // block device characteristics
+if (bdrv_get_type_hint(s-bs) != BDRV_TYPE_CDROM) {
+outbuf[buflen++] = 0xb0; // block device characteristics
+}
+outbuf[pages] = buflen - pages - 1; // number of pages
 break;
-
+}
 case 0x80: /* Device serial number, optional */
 {
 int l = strlen(s-serial);
@@ -434,7 +439,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 DPRINTF(Inquiry EVPD[Device identification] 
 buffer size %zd\n, req-cmd.xfer);
 
-outbuf[buflen++] = 3 + id_len;
+outbuf[buflen++] = 4 + id_len;
 outbuf[buflen++] = 0x2; // ASCII
 outbuf[buflen++] = 0;   // not officially assigned
 outbuf[buflen++] = 0;   // reserved
@@ -451,6 +456,11 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 unsigned int opt_io_size =
 s-qdev.conf.opt_io_size / s-qdev.blocksize;
 
+if (bdrv_get_type_hint(s-bs) == BDRV_TYPE_CDROM) {
+DPRINTF(Inquiry (EVPD[%02X] not supported for CDROM\n,
+page_code);
+return -1;
+}
 /* required VPD size with unmap support */
 outbuf[3] = buflen = 0x3c;
 
-- 
1.6.0.2




[Qemu-devel] [PATCH] scsi: Increase the number of possible devices

2010-11-22 Thread Hannes Reinecke

The SCSI parallel interface has a limit of 8 devices, but
not the SCSI stack in general. So we should be removing the
hard-coded limit and use MAX_SCSI_DEVS instead.
And we only need to scan those devices which are allocated
by the bus.

Signed-off-by: Hannes Reinecke h...@suse.de
Acked-by: Christoph Hellwig h...@lst.de
---
 blockdev.h|2 +-
 hw/scsi-bus.c |2 +-
 hw/scsi.h |3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/blockdev.h b/blockdev.h
index 653affc..451dc06 100644
--- a/blockdev.h
+++ b/blockdev.h
@@ -32,7 +32,7 @@ struct DriveInfo {
 };
 
 #define MAX_IDE_DEVS   2
-#define MAX_SCSI_DEVS  7
+#define MAX_SCSI_DEVS  255
 
 DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
 int drive_get_max_bus(BlockInterfaceType type);
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 5a3fd4b..74a08b7 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -108,7 +108,7 @@ int scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
 int res = 0, unit;
 
 loc_push_none(loc);
-for (unit = 0; unit  MAX_SCSI_DEVS; unit++) {
+for (unit = 0; unit  bus-ndev; unit++) {
 dinfo = drive_get(IF_SCSI, bus-busnr, unit);
 if (dinfo == NULL) {
 continue;
diff --git a/hw/scsi.h b/hw/scsi.h
index cb06d6d..9c798ae 100644
--- a/hw/scsi.h
+++ b/hw/scsi.h
@@ -3,6 +3,7 @@
 
 #include qdev.h
 #include block.h
+#include blockdev.h
 #include block_int.h
 
 #define SCSI_CMD_BUF_SIZE 16
@@ -86,7 +87,7 @@ struct SCSIBus {
 int tcq, ndev;
 scsi_completionfn complete;
 
-SCSIDevice *devs[8];
+SCSIDevice *devs[MAX_SCSI_DEVS];
 };
 
 void scsi_bus_new(SCSIBus *bus, DeviceState *host, int tcq, int ndev,
-- 
1.6.0.2




[Qemu-devel] [PATCH] Megasas HBA emulation and SCSI update v.2

2010-11-22 Thread Hannes Reinecke

The is the second version of the megasas patchset; changes are:
v1 - v2:
- Include suggestions (and acked-by) from Christoph Hellwig
- Updated patch description as requested by Gerd Hoffman
- Use generic iov_size() implementation
- Drop old patches
- Make SCSI HBA configurable

This patchset can be found at

git://repo.or.cz/qemu/megasas.git
branch megasas.v2

The original description was:
Due to popular demand here is now the LSI Megaraid HBA emulation.
And an update to the SCSI stack to bring it more in line with
modern standards.

For the SCSI update there are three key points:
- Improved sense code handling: the SCSI standard specifies several
  sense codes to be returned on common errors; we should be following
  that.
- Reworked SCSI layer: Instead of indirectly addressing a SCSI
  request by an abstract 'tag' we're now using the request directly,
  thus saving us a lookup on every invocation.
- Add iovec passing: I've added an interface to pass an iovec
  to a SCSI request, so that we don't need to use bounce buffers
  for data transfer. The old interface is left in place.

And, of course, the megasas driver itself.

A quick 'dd' comparison against virtio on a tmpfs backed sparse file shows:

# dd if=/dev/sdb of=/dev/null bs=16M count=1000 iflag=direct
1000+0 records in
1000+0 records out
16777216000 bytes (17 GB) copied, 9.40123 s, 1.8 GB/s
# dd if=/dev/vda of=/dev/null bs=16M count=1000 iflag=direct
1000+0 records in
1000+0 records out
16777216000 bytes (17 GB) copied, 7.44681 s, 2.3 GB/s

So we're having about 80% virtio speed.
Unoptimized :-)

Hannes Reinecke (15):
  scsi: Increase the number of possible devices
  scsi: Return SAM status codes
  scsi: INQUIRY VPD fixes
  scsi: Move sense handling into the driver
  scsi-disk: Remove duplicate cdb parsing
  scsi: Update sense code handling
  lsi53c895a: Rename 'sense' to 'status'
  scsi-disk: Allocate iovec dynamically
  scsi: Use 'SCSIRequest' directly
  scsi-disk: add data direction checking
  Remove 'bus' argument from SCSI command completion callbacks
  scsi: Implement 'get_sense' callback
  scsi: Implement alloc_req_iov callback
  megasas: LSI Megaraid SAS emulation
  Make SCSI HBA configurable

 Makefile.objs|5 +-
 blockdev.h   |2 +-
 default-configs/i386-softmmu.mak |2 +
 default-configs/mips-softmmu.mak |2 +-
 default-configs/mips64-softmmu.mak   |2 +-
 default-configs/mips64el-softmmu.mak |2 +-
 default-configs/mipsel-softmmu.mak   |2 +-
 default-configs/ppc-softmmu.mak  |2 +
 default-configs/ppc64-softmmu.mak|2 +
 default-configs/ppcemb-softmmu.mak   |2 +
 default-configs/sparc-softmmu.mak|2 +-
 default-configs/sparc64-softmmu.mak  |2 +
 default-configs/x86_64-softmmu.mak   |2 +
 hw/esp.c |   23 +-
 hw/lsi53c895a.c  |   47 +-
 hw/megasas.c | 1826 ++
 hw/mfi.h | 1197 ++
 hw/pci_ids.h |2 +
 hw/scsi-bus.c|  120 ++-
 hw/scsi-defs.h   |   20 +-
 hw/scsi-disk.c   |  446 -
 hw/scsi-generic.c|  238 +++--
 hw/scsi.h|   64 +-
 hw/usb-msd.c |   26 +-
 24 files changed, 3603 insertions(+), 435 deletions(-)
 create mode 100644 hw/megasas.c
 create mode 100644 hw/mfi.h




[Qemu-devel] [PATCH] scsi: Return SAM status codes

2010-11-22 Thread Hannes Reinecke

Traditionally, the linux stack is using SCSI status codes
which are shifted by one as compared to those defined in SAM.
A SCSI emulation should naturally return the SAM defined codes,
not the linux ones.
So to avoid any confusion this patch modifies the existing
definitions to match those found in SAM and removes any
(now obsolete) byte-shift from the returned status codes.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 hw/scsi-defs.h|   20 +++-
 hw/scsi-generic.c |   10 +-
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h
index a4a3518..1473ecb 100644
--- a/hw/scsi-defs.h
+++ b/hw/scsi-defs.h
@@ -111,18 +111,20 @@
 #define BLANK 0xa1
 
 /*
- *  Status codes
+ *  SAM Status codes
  */
 
 #define GOOD 0x00
-#define CHECK_CONDITION  0x01
-#define CONDITION_GOOD   0x02
-#define BUSY 0x04
-#define INTERMEDIATE_GOOD0x08
-#define INTERMEDIATE_C_GOOD  0x0a
-#define RESERVATION_CONFLICT 0x0c
-#define COMMAND_TERMINATED   0x11
-#define QUEUE_FULL   0x14
+#define CHECK_CONDITION  0x02
+#define CONDITION_GOOD   0x04
+#define BUSY 0x08
+#define INTERMEDIATE_GOOD0x10
+#define INTERMEDIATE_C_GOOD  0x14
+#define RESERVATION_CONFLICT 0x18
+#define COMMAND_TERMINATED   0x22
+#define TASK_SET_FULL0x28
+#define ACA_ACTIVE   0x30
+#define TASK_ABORTED 0x40
 
 #define STATUS_MASK  0x3e
 
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 7212091..9be1cca 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -96,17 +96,17 @@ static void scsi_command_complete(void *opaque, int ret)
 s-senselen = r-io_header.sb_len_wr;
 
 if (ret != 0)
-r-req.status = BUSY  1;
+r-req.status = BUSY;
 else {
 if (s-driver_status  SG_ERR_DRIVER_TIMEOUT) {
-r-req.status = BUSY  1;
+r-req.status = BUSY;
 BADF(Driver Timeout\n);
 } else if (r-io_header.status)
 r-req.status = r-io_header.status;
 else if (s-driver_status  SG_ERR_DRIVER_SENSE)
-r-req.status = CHECK_CONDITION  1;
+r-req.status = CHECK_CONDITION;
 else
-r-req.status = GOOD  1;
+r-req.status = GOOD;
 }
 DPRINTF(Command complete 0x%p tag=0x%x status=%d\n,
 r, r-req.tag, r-req.status);
@@ -333,7 +333,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t 
tag,
 s-senselen = 7;
 s-driver_status = SG_ERR_DRIVER_SENSE;
 bus = scsi_bus_from_device(d);
-bus-complete(bus, SCSI_REASON_DONE, tag, CHECK_CONDITION  1);
+bus-complete(bus, SCSI_REASON_DONE, tag, CHECK_CONDITION);
 return 0;
 }
 
-- 
1.6.0.2




[Qemu-devel] [PATCH] lsi53c895a: Rename 'sense' to 'status'

2010-11-22 Thread Hannes Reinecke

The 'sense' field in the HBA status structure is misnamed, as it
actually carries the SCSI status. Rename it.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 hw/lsi53c895a.c |   18 +-
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index f97335e..8246ee8 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -189,7 +189,7 @@ typedef struct {
 uint32_t script_ram_base;
 
 int carry; /* ??? Should this be an a visible register somewhere?  */
-int sense;
+int status;
 /* Action to take at the end of a MSG IN phase.
0 = COMMAND, 1 = disconnect, 2 = DATA OUT, 3 = DATA IN.  */
 int msg_action;
@@ -695,8 +695,8 @@ static void lsi_command_complete(SCSIBus *bus, int reason, 
uint32_t tag,
 
 out = (s-sstat1  PHASE_MASK) == PHASE_DO;
 if (reason == SCSI_REASON_DONE) {
-DPRINTF(Command complete sense=%d\n, (int)arg);
-s-sense = arg;
+DPRINTF(Command complete status=%d\n, (int)arg);
+s-status = arg;
 s-command_complete = 2;
 if (s-waiting  s-dbc != 0) {
 /* Raise phase mismatch for short transfers.  */
@@ -783,14 +783,14 @@ static void lsi_do_command(LSIState *s)
 
 static void lsi_do_status(LSIState *s)
 {
-uint8_t sense;
-DPRINTF(Get status len=%d sense=%d\n, s-dbc, s-sense);
+uint8_t status;
+DPRINTF(Get status len=%d status=%d\n, s-dbc, s-status);
 if (s-dbc != 1)
 BADF(Bad Status move\n);
 s-dbc = 1;
-sense = s-sense;
-s-sfbr = sense;
-cpu_physical_memory_write(s-dnad, sense, 1);
+status = s-status;
+s-sfbr = status;
+cpu_physical_memory_write(s-dnad, status, 1);
 lsi_set_phase(s, PHASE_MI);
 s-msg_action = 1;
 lsi_add_msg_byte(s, 0); /* COMMAND COMPLETE */
@@ -2067,7 +2067,7 @@ static const VMStateDescription vmstate_lsi_scsi = {
 VMSTATE_PCI_DEVICE(dev, LSIState),
 
 VMSTATE_INT32(carry, LSIState),
-VMSTATE_INT32(sense, LSIState),
+VMSTATE_INT32(status, LSIState),
 VMSTATE_INT32(msg_action, LSIState),
 VMSTATE_INT32(msg_len, LSIState),
 VMSTATE_BUFFER(msg, LSIState),
-- 
1.6.0.2




[Qemu-devel] [PATCH] scsi: Move sense handling into the driver

2010-11-22 Thread Hannes Reinecke

The current sense handling in scsi-bus is only used by the
scsi-disk driver; the scsi-generic driver is using its own.
So we should move the current sense handling into the
scsi-disk driver.

Signed-off-by: Hannes Reinecke h...@suse.de
Acked-by: Christoph Hellwig h...@lst.de
---
 hw/scsi-bus.c  |   10 --
 hw/scsi-disk.c |   33 +
 hw/scsi.h  |8 
 3 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 74a08b7..93f0e9a 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -123,16 +123,6 @@ int scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
 return res;
 }
 
-void scsi_dev_clear_sense(SCSIDevice *dev)
-{
-memset(dev-sense, 0, sizeof(dev-sense));
-}
-
-void scsi_dev_set_sense(SCSIDevice *dev, uint8_t key)
-{
-dev-sense.key = key;
-}
-
 SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, uint32_t tag, uint32_t 
lun)
 {
 SCSIRequest *req;
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index a76e91c..da6c3f0 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -49,6 +49,10 @@ do { fprintf(stderr, scsi-disk:  fmt , ## __VA_ARGS__); } 
while (0)
 
 typedef struct SCSIDiskState SCSIDiskState;
 
+typedef struct SCSISense {
+uint8_t key;
+} SCSISense;
+
 typedef struct SCSIDiskReq {
 SCSIRequest req;
 /* ??? We should probably keep track of whether the data transfer is
@@ -72,6 +76,7 @@ struct SCSIDiskState
 QEMUBH *bh;
 char *version;
 char *serial;
+SCSISense sense;
 };
 
 static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type);
@@ -100,10 +105,22 @@ static SCSIDiskReq *scsi_find_request(SCSIDiskState *s, 
uint32_t tag)
 return DO_UPCAST(SCSIDiskReq, req, scsi_req_find(s-qdev, tag));
 }
 
-static void scsi_req_set_status(SCSIRequest *req, int status, int sense_code)
+static void scsi_disk_clear_sense(SCSIDiskState *s)
 {
-req-status = status;
-scsi_dev_set_sense(req-dev, sense_code);
+memset(s-sense, 0, sizeof(s-sense));
+}
+
+static void scsi_disk_set_sense(SCSIDiskState *s, uint8_t key)
+{
+s-sense.key = key;
+}
+
+static void scsi_req_set_status(SCSIDiskReq *r, int status, int sense_code)
+{
+SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r-req.dev);
+
+r-req.status = status;
+scsi_disk_set_sense(s, sense_code);
 }
 
 /* Helper function for command completion.  */
@@ -111,7 +128,7 @@ static void scsi_command_complete(SCSIDiskReq *r, int 
status, int sense)
 {
 DPRINTF(Command complete tag=0x%x status=%d sense=%d\n,
 r-req.tag, status, sense);
-scsi_req_set_status(r-req, status, sense);
+scsi_req_set_status(r, status, sense);
 scsi_req_complete(r-req);
 scsi_remove_request(r);
 }
@@ -822,7 +839,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r, 
uint8_t *outbuf)
 goto illegal_request;
 memset(outbuf, 0, 4);
 buflen = 4;
-if (req-dev-sense.key == NOT_READY  req-cmd.xfer = 18) {
+if (s-sense.key == NOT_READY  req-cmd.xfer = 18) {
 memset(outbuf, 0, 18);
 buflen = 18;
 outbuf[7] = 10;
@@ -832,8 +849,8 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r, 
uint8_t *outbuf)
 }
 outbuf[0] = 0xf0;
 outbuf[1] = 0;
-outbuf[2] = req-dev-sense.key;
-scsi_dev_clear_sense(req-dev);
+outbuf[2] = s-sense.key;
+scsi_disk_clear_sense(s);
 break;
 case INQUIRY:
 buflen = scsi_disk_emulate_inquiry(req, outbuf);
@@ -966,7 +983,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r, 
uint8_t *outbuf)
 default:
 goto illegal_request;
 }
-scsi_req_set_status(req, GOOD, NO_SENSE);
+scsi_req_set_status(r, GOOD, NO_SENSE);
 return buflen;
 
 not_ready:
diff --git a/hw/scsi.h b/hw/scsi.h
index 9c798ae..bf02adf 100644
--- a/hw/scsi.h
+++ b/hw/scsi.h
@@ -26,10 +26,6 @@ enum SCSIXferMode {
 SCSI_XFER_TO_DEV,/*  WRITE, MODE_SELECT, ... */
 };
 
-typedef struct SCSISense {
-uint8_t key;
-} SCSISense;
-
 typedef struct SCSIRequest {
 SCSIBus   *bus;
 SCSIDevice*dev;
@@ -57,7 +53,6 @@ struct SCSIDevice
 QTAILQ_HEAD(, SCSIRequest) requests;
 int blocksize;
 int type;
-struct SCSISense sense;
 };
 
 /* cdrom.c */
@@ -102,9 +97,6 @@ static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
 SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv, 
int unit);
 int scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
 
-void scsi_dev_clear_sense(SCSIDevice *dev);
-void scsi_dev_set_sense(SCSIDevice *dev, uint8_t key);
-
 SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, uint32_t tag, uint32_t 
lun);
 SCSIRequest *scsi_req_find(SCSIDevice *d, uint32_t tag);
 void scsi_req_free(SCSIRequest *req);
-- 
1.6.0.2




[Qemu-devel] [PATCH] scsi-disk: Allocate iovec dynamically

2010-11-22 Thread Hannes Reinecke

Rather than have the iovec part of the structure with a fixed size
of '1' we should be allocating it dynamically. This will allow us
to pass in SGLs directly.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 hw/scsi-disk.c |  102 +---
 1 files changed, 60 insertions(+), 42 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index a71607e..ed7e6ef 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -37,6 +37,7 @@ do { fprintf(stderr, scsi-disk:  fmt , ## __VA_ARGS__); } 
while (0)
 #include scsi-defs.h
 #include sysemu.h
 #include blockdev.h
+#include iov.h
 
 #define SCSI_DMA_BUF_SIZE131072
 #define SCSI_MAX_INQUIRY_LEN 256
@@ -56,7 +57,10 @@ typedef struct SCSIDiskReq {
 /* Both sector and sector_count are in terms of qemu 512 byte blocks.  */
 uint64_t sector;
 uint32_t sector_count;
-struct iovec iov;
+uint8_t *iov_buf;
+uint64_t iov_len;
+struct iovec *iov;
+int iov_num;
 QEMUIOVector qiov;
 uint32_t status;
 } SCSIDiskReq;
@@ -86,13 +90,19 @@ static SCSIDiskReq *scsi_new_request(SCSIDiskState *s, 
uint32_t tag,
 
 req = scsi_req_alloc(sizeof(SCSIDiskReq), s-qdev, tag, lun);
 r = DO_UPCAST(SCSIDiskReq, req, req);
-r-iov.iov_base = qemu_blockalign(s-bs, SCSI_DMA_BUF_SIZE);
+r-iov_buf = qemu_blockalign(s-bs, SCSI_DMA_BUF_SIZE);
+r-iov = qemu_mallocz(sizeof(struct iovec));
+r-iov[0].iov_base = r-iov_buf;
+r-iov_num = 1;
 return r;
 }
 
 static void scsi_remove_request(SCSIDiskReq *r)
 {
-qemu_vfree(r-iov.iov_base);
+qemu_vfree(r-iov);
+r-iov = NULL;
+qemu_vfree(r-iov_buf);
+r-iov_buf = NULL;
 scsi_req_free(r-req);
 }
 
@@ -117,7 +127,7 @@ static void scsi_req_set_status(SCSIDiskReq *r, int status, 
SCSISense sense)
 /* Helper function for command completion.  */
 static void scsi_command_complete(SCSIDiskReq *r, int status, SCSISense sense)
 {
-DPRINTF(Command complete tag=0x%x status=%d sense=%d/%d/%d\n,
+DPRINTF(Command complete tag=0x%x status=%d sense=%02x/%02x/%02x\n,
 r-req.tag, status, sense.key, sense.asc, sense.ascq);
 scsi_req_set_status(r, status, sense);
 scsi_req_complete(r-req);
@@ -142,7 +152,7 @@ static void scsi_cancel_io(SCSIDevice *d, uint32_t tag)
 static void scsi_read_complete(void * opaque, int ret)
 {
 SCSIDiskReq *r = (SCSIDiskReq *)opaque;
-int n;
+size_t iov_len = 0;
 
 r-req.aiocb = NULL;
 
@@ -151,13 +161,11 @@ static void scsi_read_complete(void * opaque, int ret)
 return;
 }
 }
+iov_len = iov_size(r-iov, r-iov_num);
 
-DPRINTF(Data ready tag=0x%x len=%zd\n, r-req.tag, r-iov.iov_len);
+DPRINTF(Data ready tag=0x%x len=%zd\n, r-req.tag, iov_len);
 
-n = r-iov.iov_len / 512;
-r-sector += n;
-r-sector_count -= n;
-r-req.bus-complete(r-req.bus, SCSI_REASON_DATA, r-req.tag, 
r-iov.iov_len);
+r-req.bus-complete(r-req.bus, SCSI_REASON_DATA, r-req.tag, iov_len);
 }
 
 
@@ -167,9 +175,10 @@ static void scsi_read_request(SCSIDiskReq *r)
 uint32_t n;
 
 if (r-sector_count == (uint32_t)-1) {
-DPRINTF(Read buf_len=%zd\n, r-iov.iov_len);
+DPRINTF(Read buf_len=%zd\n, r-iov[0].iov_len);
 r-sector_count = 0;
-r-req.bus-complete(r-req.bus, SCSI_REASON_DATA, r-req.tag, 
r-iov.iov_len);
+r-req.bus-complete(r-req.bus, SCSI_REASON_DATA, r-req.tag,
+ r-iov[0].iov_len);
 return;
 }
 DPRINTF(Read sector_count=%d\n, r-sector_count);
@@ -179,15 +188,21 @@ static void scsi_read_request(SCSIDiskReq *r)
 }
 
 n = r-sector_count;
-if (n  SCSI_DMA_BUF_SIZE / 512)
-n = SCSI_DMA_BUF_SIZE / 512;
+if (r-iov_buf) {
+/* Reset iovec */
+if (n  SCSI_DMA_BUF_SIZE / 512)
+n = SCSI_DMA_BUF_SIZE / 512;
+r-iov[0].iov_len = n * 512;
+}
 
-r-iov.iov_len = n * 512;
-qemu_iovec_init_external(r-qiov, r-iov, 1);
+qemu_iovec_init_external(r-qiov, r-iov, r-iov_num);
 r-req.aiocb = bdrv_aio_readv(s-bs, r-sector, r-qiov, n,
   scsi_read_complete, r);
 if (r-req.aiocb == NULL) {
 scsi_read_complete(r, -EIO);
+} else {
+r-sector += n;
+r-sector_count -= n;
 }
 }
 
@@ -264,17 +279,20 @@ static void scsi_write_complete(void * opaque, int ret)
 }
 }
 
-n = r-iov.iov_len / 512;
+n = iov_size(r-iov, r-iov_num) / 512;
 r-sector += n;
 r-sector_count -= n;
 if (r-sector_count == 0) {
 scsi_command_complete(r, GOOD, SENSE_CODE(NO_SENSE));
 } else {
 len = r-sector_count * 512;
-if (len  SCSI_DMA_BUF_SIZE) {
-len = SCSI_DMA_BUF_SIZE;
+if (r-iov_buf) {
+/* Reset iovec */
+if (len  SCSI_DMA_BUF_SIZE) {
+len = SCSI_DMA_BUF_SIZE;
+}
+r-iov[0].iov_len = len;
 }
-r-iov.iov_len = len;
 

[Qemu-devel] Re: [PATCHv3 RFC] qemu-kvm: stop devices on vmstop

2010-11-22 Thread Michael S. Tsirkin
On Mon, Nov 22, 2010 at 10:57:34AM +0100, Gerd Hoffmann wrote:
 On 11/21/10 20:16, Michael S. Tsirkin wrote:
 Stop running devices on vmstop, so that VM does not interact with
 outside world at that time.
 
 Whitelist system handlers which run even when VM is stopped.
 These are specific handlers like monitor, gdbstub, migration.
 I'm not really sure about ui: spice and vnc: do they need to run?
 
 Yes, vnc and spice should run.  They serve the clients.  They also
 don't change device state.
 
 cheers,
   Gerd
 
 PS: Well, in the spice case this isn't 100% true, the handlers can
 change qxl device state in some cases.  But spice has a start/stop
 handler which takes care to flush all outstanding work which could
 change device state on vmstop, so it is save to keep the handlers
 active when the vm is in stopped state.

So here's how I see it so far: assuming we want to avoid changing vm
state on vmstop

- flush bdrv and aio on vmstop
(this is so we don't need to stop them)
- keep running aio
- stop running bh
- stop running slirp
- keep running host/rt timers
- keep running fd callbacks for migration
- keep running fd callbacks for ui: vnc, spice

Note: only clock=vm can satisfy this requirement.
Default clock=rtc keeps running when VM is stopped,
this is by design.

-- 
MST



[Qemu-devel] [PATCH] Remove 'bus' argument from SCSI command completion callbacks

2010-11-22 Thread Hannes Reinecke

The 'bus' argument is now pointless, as we already pass the
request itself and the bus can be derived from it.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 hw/esp.c  |5 ++---
 hw/lsi53c895a.c   |5 ++---
 hw/scsi-bus.c |3 +--
 hw/scsi-disk.c|8 
 hw/scsi-generic.c |6 +++---
 hw/scsi.h |3 +--
 hw/usb-msd.c  |5 ++---
 7 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/hw/esp.c b/hw/esp.c
index 2784bec..d55bb6d 100644
--- a/hw/esp.c
+++ b/hw/esp.c
@@ -390,10 +390,9 @@ static void esp_do_dma(ESPState *s)
 }
 }
 
-static void esp_command_complete(SCSIBus *bus, int reason, SCSIRequest *req,
- uint32_t arg)
+static void esp_command_complete(SCSIRequest *req, int reason, uint32_t arg)
 {
-ESPState *s = DO_UPCAST(ESPState, busdev.qdev, bus-qbus.parent);
+ESPState *s = DO_UPCAST(ESPState, busdev.qdev, req-bus-qbus.parent);
 
 if (reason == SCSI_REASON_DONE) {
 DPRINTF(SCSI Command complete\n);
diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index 82a5d39..858c8f4 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -688,10 +688,9 @@ static int lsi_queue_tag(LSIState *s, uint32_t tag, 
uint32_t arg)
 }
 
 /* Callback to indicate that the SCSI layer has completed a transfer.  */
-static void lsi_command_complete(SCSIBus *bus, int reason, SCSIRequest *req,
- uint32_t arg)
+static void lsi_command_complete(SCSIRequest *req, int reason, uint32_t arg)
 {
-LSIState *s = DO_UPCAST(LSIState, dev.qdev, bus-qbus.parent);
+LSIState *s = DO_UPCAST(LSIState, dev.qdev, req-bus-qbus.parent);
 int out;
 
 out = (s-sstat1  PHASE_MASK) == PHASE_DO;
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index bb88a56..0f8fd57 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -594,6 +594,5 @@ void scsi_req_complete(SCSIRequest *req)
 {
 assert(req-status != -1);
 scsi_req_dequeue(req);
-req-bus-complete(req-bus, SCSI_REASON_DONE,
-   req, req-status);
+req-bus-complete(req, SCSI_REASON_DONE, req-status);
 }
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 82072a8..d43c7ae 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -156,7 +156,7 @@ static void scsi_read_complete(void * opaque, int ret)
 
 DPRINTF(Data ready tag=0x%x len=%zd\n, r-req.tag, iov_len);
 
-r-req.bus-complete(r-req.bus, SCSI_REASON_DATA, r-req, iov_len);
+r-req.bus-complete(r-req, SCSI_REASON_DATA, iov_len);
 }
 
 
@@ -176,7 +176,7 @@ static void scsi_read_data(SCSIRequest *req)
 if (r-sector_count == (uint32_t)-1) {
 DPRINTF(Read buf_len=%zd\n, r-iov[0].iov_len);
 r-sector_count = 0;
-r-req.bus-complete(r-req.bus, SCSI_REASON_DATA, r-req,
+r-req.bus-complete(r-req, SCSI_REASON_DATA,
  r-iov[0].iov_len);
 return;
 }
@@ -226,7 +226,7 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error, 
int type)
 vm_stop(0);
 } else {
 if (type == SCSI_REQ_STATUS_RETRY_READ) {
-r-req.bus-complete(r-req.bus, SCSI_REASON_DATA, r-req, 0);
+r-req.bus-complete(r-req, SCSI_REASON_DATA, 0);
 }
 if (error == EBADR) {
 scsi_command_complete(r, CHECK_CONDITION,
@@ -270,7 +270,7 @@ static void scsi_write_complete(void * opaque, int ret)
 r-iov[0].iov_len = len;
 }
 DPRINTF(Write complete tag=0x%x more=%d\n, r-req.tag, len);
-r-req.bus-complete(r-req.bus, SCSI_REASON_DATA, r-req, len);
+r-req.bus-complete(r-req, SCSI_REASON_DATA, len);
 }
 }
 
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index b402c3d..40b1255 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -196,7 +196,7 @@ static void scsi_read_complete(void * opaque, int ret)
 DPRINTF(Data ready tag=0x%x len=%d\n, r-req.tag, len);
 
 r-len = -1;
-r-req.bus-complete(r-req.bus, SCSI_REASON_DATA, r-req, len);
+r-req.bus-complete(r-req, SCSI_REASON_DATA, len);
 if (len == 0)
 scsi_command_complete(r, 0);
 }
@@ -226,7 +226,7 @@ static void scsi_read_data(SCSIRequest *req)
 DPRINTF(Sense: %d %d %d %d %d %d %d %d\n,
 r-buf[0], r-buf[1], r-buf[2], r-buf[3],
 r-buf[4], r-buf[5], r-buf[6], r-buf[7]);
-r-req.bus-complete(r-req.bus, SCSI_REASON_DATA, r-req, 
s-senselen);
+r-req.bus-complete(r-req, SCSI_REASON_DATA, s-senselen);
 /* Clear sensebuf after REQUEST_SENSE */
 scsi_clear_sense(s);
 return;
@@ -272,7 +272,7 @@ static int scsi_write_data(SCSIRequest *req)
 
 if (r-len == 0) {
 r-len = r-buflen;
-r-req.bus-complete(r-req.bus, SCSI_REASON_DATA, r-req, r-len);
+r-req.bus-complete(r-req, SCSI_REASON_DATA, r-len);
 return 0;
 }
 
diff --git a/hw/scsi.h b/hw/scsi.h
index d8ca775..25fda2f 100644
--- a/hw/scsi.h
+++ b/hw/scsi.h
@@ -18,8 +18,7 @@ typedef struct SCSIBus 

Re: [Qemu-devel] [PATCH 0/3] add hotplug opt-out option for devices.

2010-11-22 Thread Gerd Hoffmann

I understand why you're adding this but this is one of those horrible
abuses of qdev that we really need to avoid.

There are two valid reasons why hotplug is not possible:

1) Hotplugging is not supported by the *slot*.  This is something that
needs to be exposes through ACPI. This is not a qdev property, but a
property of a PCI slot.


Well, yea, right.  Sort of.  The ACPI thing applies to some of the slots 
only.  But, yes, strictly speaking this is a slot not a device property 
in the case of PCI.  Problem is qemu doesn't really has an idea what a 
pci slot is ...



It's very important that we do this correctly
because Windows puts a little icon in the systray that advertises
quick-removal of devices in slots that support hotplug.


Indeed.


2) The PCI device is soldered to the MB or is otherwise not part of a
PCI slot. Again, this is part of the ACPI definition.


(3) The qemu emulation can't handle hot-unplug.


Since the PIIX3 lives in slot 1, our ACPI tables should not advertise
slot 0 or slot 1 as supporting hotplug.


They do currently.  Should be easily fixable.


Hotplug information has no business being part of the core qdev
structures. Hotplug is a PCI concept and the information needs to live
at the PCI layer to be meaningfully.


Wrong.  PCI certainly isn't the only bus which supports hotplug.  It 
*does* make sense to handle generic hotplug stuff at qdev level.



An ideal interface would explicitly allow a user to mark a series of PCI
slots as no supporting hotplug. It would be convenient in order to
ensure that your virtio-net wasn't accidentally ejected by a click-happy
Windows user.


Indeed.  That one is a bit harder I suspect.  Can this be done without 
generating acpi tables dynamically?


cheers,
  Gerd




[Qemu-devel] [PATCH] scsi-disk: Remove duplicate cdb parsing

2010-11-22 Thread Hannes Reinecke

We parse the CDB twice, which is completely unnecessary.

Signed-off-by: Hannes Reinecke h...@suse.de
Acked-by: Christoph Hellwig h...@lst.de
---
 hw/scsi-disk.c |   74 
 1 files changed, 21 insertions(+), 53 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index da6c3f0..58e5f5b 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1004,9 +1004,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t 
tag,
  uint8_t *buf, int lun)
 {
 SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d);
-uint64_t lba;
 uint32_t len;
-int cmdlen;
 int is_write;
 uint8_t command;
 uint8_t *outbuf;
@@ -1025,55 +1023,21 @@ static int32_t scsi_send_command(SCSIDevice *d, 
uint32_t tag,
 outbuf = (uint8_t *)r-iov.iov_base;
 is_write = 0;
 DPRINTF(Command: lun=%d tag=0x%x data=0x%02x, lun, tag, buf[0]);
-switch (command  5) {
-case 0:
-lba = (uint64_t) buf[3] | ((uint64_t) buf[2]  8) |
-  (((uint64_t) buf[1]  0x1f)  16);
-len = buf[4];
-cmdlen = 6;
-break;
-case 1:
-case 2:
-lba = (uint64_t) buf[5] | ((uint64_t) buf[4]  8) |
-  ((uint64_t) buf[3]  16) | ((uint64_t) buf[2]  24);
-len = buf[8] | (buf[7]  8);
-cmdlen = 10;
-break;
-case 4:
-lba = (uint64_t) buf[9] | ((uint64_t) buf[8]  8) |
-  ((uint64_t) buf[7]  16) | ((uint64_t) buf[6]  24) |
-  ((uint64_t) buf[5]  32) | ((uint64_t) buf[4]  40) |
-  ((uint64_t) buf[3]  48) | ((uint64_t) buf[2]  56);
-len = buf[13] | (buf[12]  8) | (buf[11]  16) | (buf[10]  24);
-cmdlen = 16;
-break;
-case 5:
-lba = (uint64_t) buf[5] | ((uint64_t) buf[4]  8) |
-  ((uint64_t) buf[3]  16) | ((uint64_t) buf[2]  24);
-len = buf[9] | (buf[8]  8) | (buf[7]  16) | (buf[6]  24);
-cmdlen = 12;
-break;
-default:
+
+if (scsi_req_parse(r-req, buf) != 0) {
 BADF(Unsupported command length, command %x\n, command);
 goto fail;
 }
 #ifdef DEBUG_SCSI
 {
 int i;
-for (i = 1; i  cmdlen; i++) {
+for (i = 1; i  r-req.cmd.len; i++) {
 printf( 0x%02x, buf[i]);
 }
 printf(\n);
 }
 #endif
 
-if (scsi_req_parse(r-req, buf) != 0) {
-BADF(Unsupported command length, command %x\n, command);
-goto fail;
-}
-assert(r-req.cmd.len == cmdlen);
-assert(r-req.cmd.lba == lba);
-
 if (lun || buf[1]  5) {
 /* Only LUN 0 supported.  */
 DPRINTF(Unimplemented LUN %d\n, lun ? lun : buf[1]  5);
@@ -,10 +1075,11 @@ static int32_t scsi_send_command(SCSIDevice *d, 
uint32_t tag,
 case READ_10:
 case READ_12:
 case READ_16:
-DPRINTF(Read (sector % PRId64 , count %d)\n, lba, len);
-if (lba  s-max_lba)
+len = r-req.cmd.xfer / d-blocksize;
+DPRINTF(Read (sector % PRId64 , count %d)\n, r-req.cmd.lba, len);
+if (r-req.cmd.lba  s-max_lba)
 goto illegal_lba;
-r-sector = lba * s-cluster_size;
+r-sector = r-req.cmd.lba * s-cluster_size;
 r-sector_count = len * s-cluster_size;
 break;
 case WRITE_6:
@@ -1124,42 +1089,45 @@ static int32_t scsi_send_command(SCSIDevice *d, 
uint32_t tag,
 case WRITE_VERIFY:
 case WRITE_VERIFY_12:
 case WRITE_VERIFY_16:
+len = r-req.cmd.xfer / d-blocksize;
 DPRINTF(Write %s(sector % PRId64 , count %d)\n,
-(command  0xe) == 0xe ? And Verify  : , lba, len);
-if (lba  s-max_lba)
+(command  0xe) == 0xe ? And Verify  : ,
+r-req.cmd.lba, len);
+if (r-req.cmd.lba  s-max_lba)
 goto illegal_lba;
-r-sector = lba * s-cluster_size;
+r-sector = r-req.cmd.lba * s-cluster_size;
 r-sector_count = len * s-cluster_size;
 is_write = 1;
 break;
 case MODE_SELECT:
-DPRINTF(Mode Select(6) (len %d)\n, len);
+DPRINTF(Mode Select(6) (len %lu)\n, (long)r-req.cmd.xfer);
 /* We don't support mode parameter changes.
Allow the mode parameter header + block descriptors only. */
-if (len  12) {
+if (r-req.cmd.xfer  12) {
 goto fail;
 }
 break;
 case MODE_SELECT_10:
-DPRINTF(Mode Select(10) (len %d)\n, len);
+DPRINTF(Mode Select(10) (len %lu)\n, (long)r-req.cmd.xfer);
 /* We don't support mode parameter changes.
Allow the mode parameter header + block descriptors only. */
-if (len  16) {
+if (r-req.cmd.xfer  16) {
 goto fail;
 }
 break;
 case SEEK_6:
 case SEEK_10:
-DPRINTF(Seek(%d) (sector % PRId64 )\n, command == SEEK_6 ? 6 : 10, 
lba);
-if (lba  s-max_lba) {
+DPRINTF(Seek(%d) (sector % PRId64 )\n, command == SEEK_6 

[Qemu-devel] [PATCH] scsi: Update sense code handling

2010-11-22 Thread Hannes Reinecke

The SCSI spec has a quite detailed list of sense codes available.
It even mandates the use of specific ones for some failure cases.
The current implementation just has one type of 'generic' error
which is actually a violation of the spec in certain cases.
This patch introduces various predefined sense codes to have the
sense code reporting more in line with the spec.

Signed-off-by: Hannes Reinecke h...@suse.de
Acked-by: Christoph Hellwig h...@lst.de
---
 hw/scsi-bus.c |   92 
 hw/scsi-disk.c|  109 +++--
 hw/scsi-generic.c |   76 ++---
 hw/scsi.h |   38 ++
 4 files changed, 239 insertions(+), 76 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 93f0e9a..afdf0ad 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -388,6 +388,98 @@ int scsi_req_parse(SCSIRequest *req, uint8_t *buf)
 return 0;
 }
 
+/*
+ * Predefined sense codes
+ */
+
+/* No sense data available */
+const struct SCSISense sense_code_NO_SENSE = {
+.key = NO_SENSE , .asc = 0x00 , .ascq = 0x00
+};
+
+/* LUN not ready, Manual intervention required */
+const struct SCSISense sense_code_LUN_NOT_READY = {
+.key = NOT_READY, .asc = 0x04, .ascq = 0x03
+};
+
+/* LUN not ready, Medium not present */
+const struct SCSISense sense_code_NO_MEDIUM = {
+.key = NOT_READY, .asc = 0x3a, .ascq = 0x00
+};
+
+/* Hardware error, internal target failure */
+const struct SCSISense sense_code_TARGET_FAILURE = {
+.key = HARDWARE_ERROR, .asc = 0x44, .ascq = 0x00
+};
+
+/* Illegal request, invalid command operation code */
+const struct SCSISense sense_code_INVALID_OPCODE = {
+.key = ILLEGAL_REQUEST, .asc = 0x20, .ascq = 0x00
+};
+
+/* Illegal request, LBA out of range */
+const struct SCSISense sense_code_LBA_OUT_OF_RANGE = {
+.key = ILLEGAL_REQUEST, .asc = 0x21, .ascq = 0x00
+};
+
+/* Illegal request, Invalid field in CDB */
+const struct SCSISense sense_code_INVALID_FIELD = {
+.key = ILLEGAL_REQUEST, .asc = 0x24, .ascq = 0x00
+};
+
+/* Illegal request, LUN not supported */
+const struct SCSISense sense_code_LUN_NOT_SUPPORTED = {
+.key = ILLEGAL_REQUEST, .asc = 0x25, .ascq = 0x00
+};
+
+/* Command aborted, I/O process terminated */
+const struct SCSISense sense_code_IO_ERROR = {
+.key = ABORTED_COMMAND, .asc = 0x00, .ascq = 0x06
+};
+
+/* Command aborted, I_T Nexus loss occurred */
+const struct SCSISense sense_code_I_T_NEXUS_LOSS = {
+.key = ABORTED_COMMAND, .asc = 0x29, .ascq = 0x07
+};
+
+/* Command aborted, Logical Unit failure */
+const struct SCSISense sense_code_LUN_FAILURE = {
+.key = ABORTED_COMMAND, .asc = 0x3e, .ascq = 0x01
+};
+
+/*
+ * scsi_build_sense
+ *
+ * Build a sense buffer
+ */
+int scsi_build_sense(SCSISense sense, uint8_t *buf, int len, int fixed)
+{
+if (len  8)
+return 0;
+if (fixed  len  14)
+return 0;
+
+memset(buf, 0, len);
+if (fixed) {
+/* Return fixed format sense buffer */
+buf[0] = 0xf0;
+buf[2] = sense.key;
+buf[7] = 7;
+buf[12] = sense.asc;
+buf[13] = sense.ascq;
+len = 14;
+} else {
+/* Return descriptor format sense buffer */
+buf[0] = 0x72;
+buf[1] = sense.key;
+buf[2] = sense.asc;
+buf[3] = sense.ascq;
+len = 8;
+}
+
+return len;
+}
+
 static const char *scsi_command_name(uint8_t cmd)
 {
 static const char *names[] = {
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 58e5f5b..a71607e 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -49,10 +49,6 @@ do { fprintf(stderr, scsi-disk:  fmt , ## __VA_ARGS__); } 
while (0)
 
 typedef struct SCSIDiskState SCSIDiskState;
 
-typedef struct SCSISense {
-uint8_t key;
-} SCSISense;
-
 typedef struct SCSIDiskReq {
 SCSIRequest req;
 /* ??? We should probably keep track of whether the data transfer is
@@ -110,24 +106,19 @@ static void scsi_disk_clear_sense(SCSIDiskState *s)
 memset(s-sense, 0, sizeof(s-sense));
 }
 
-static void scsi_disk_set_sense(SCSIDiskState *s, uint8_t key)
-{
-s-sense.key = key;
-}
-
-static void scsi_req_set_status(SCSIDiskReq *r, int status, int sense_code)
+static void scsi_req_set_status(SCSIDiskReq *r, int status, SCSISense sense)
 {
 SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r-req.dev);
 
 r-req.status = status;
-scsi_disk_set_sense(s, sense_code);
+s-sense = sense;
 }
 
 /* Helper function for command completion.  */
-static void scsi_command_complete(SCSIDiskReq *r, int status, int sense)
+static void scsi_command_complete(SCSIDiskReq *r, int status, SCSISense sense)
 {
-DPRINTF(Command complete tag=0x%x status=%d sense=%d\n,
-r-req.tag, status, sense);
+DPRINTF(Command complete tag=0x%x status=%d sense=%d/%d/%d\n,
+r-req.tag, status, sense.key, sense.asc, sense.ascq);
 scsi_req_set_status(r, status, sense);
 

[Qemu-devel] [PATCH] scsi: Implement 'get_sense' callback

2010-11-22 Thread Hannes Reinecke

The get_sense callback copies existing sense information into
the provided buffer. This is required if sense information
should be transferred together with the command response.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 hw/scsi-disk.c|9 +
 hw/scsi-generic.c |   17 +
 hw/scsi.h |1 +
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index d43c7ae..d1b7f74 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -360,6 +360,14 @@ static uint8_t *scsi_get_buf(SCSIRequest *req)
 return r-iov_buf;
 }
 
+/* Copy sense information into the provided buffer */
+static int scsi_get_sense(SCSIRequest *req, uint8_t *outbuf, int len)
+{
+SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req-dev);
+
+return scsi_build_sense(s-sense, outbuf, len, len  14);
+}
+
 static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
 {
 SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req-dev);
@@ -1205,6 +1213,7 @@ static SCSIDeviceInfo scsi_disk_info = {
 .write_data   = scsi_write_data,
 .cancel_io= scsi_cancel_io,
 .get_buf  = scsi_get_buf,
+.get_sense= scsi_get_sense,
 .qdev.props   = (Property[]) {
 DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf),
 DEFINE_PROP_STRING(ver,  SCSIDiskState, version),
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 40b1255..5c0f6ab 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -83,6 +83,22 @@ static void scsi_clear_sense(SCSIGenericState *s)
 s-driver_status = 0;
 }
 
+static int scsi_get_sense(SCSIRequest *req, uint8_t *outbuf, int len)
+{
+SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, req-dev);
+int size = SCSI_SENSE_BUF_SIZE;
+
+if (s-driver_status  SG_ERR_DRIVER_SENSE) {
+if (len  SCSI_SENSE_BUF_SIZE)
+size = len;
+else
+size = SCSI_SENSE_BUF_SIZE;
+memcpy(outbuf, s-sensebuf, size);
+}
+
+return size;
+}
+
 static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun)
 {
 SCSIRequest *req;
@@ -550,6 +566,7 @@ static SCSIDeviceInfo scsi_generic_info = {
 .write_data   = scsi_write_data,
 .cancel_io= scsi_cancel_io,
 .get_buf  = scsi_get_buf,
+.get_sense= scsi_get_sense,
 .qdev.props   = (Property[]) {
 DEFINE_BLOCK_PROPERTIES(SCSIGenericState, qdev.conf),
 DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/scsi.h b/hw/scsi.h
index 25fda2f..0c467d1 100644
--- a/hw/scsi.h
+++ b/hw/scsi.h
@@ -78,6 +78,7 @@ struct SCSIDeviceInfo {
 int (*write_data)(SCSIRequest *req);
 void (*cancel_io)(SCSIRequest *req);
 uint8_t *(*get_buf)(SCSIRequest *req);
+int (*get_sense)(SCSIRequest *req, uint8_t *buf, int len);
 };
 
 typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv,
-- 
1.6.0.2




[Qemu-devel] [PATCH] scsi: Implement alloc_req_iov callback

2010-11-22 Thread Hannes Reinecke

Add callback to create a request with a predefined iovec.
This is required for drivers which can use the iovec
of a command directly.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 hw/scsi-disk.c|   25 +
 hw/scsi-generic.c |   44 ++--
 hw/scsi.h |2 ++
 3 files changed, 57 insertions(+), 14 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index d1b7f74..88a2f74 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -96,14 +96,30 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, 
uint32_t tag,
 return req;
 }
 
+static SCSIRequest *scsi_new_request_iovec(SCSIDevice *d, uint32_t tag,
+uint32_t lun, struct iovec *iov, int iov_num)
+{
+SCSIRequest *req;
+SCSIDiskReq *r;
+
+req = scsi_req_alloc(sizeof(SCSIDiskReq), d, tag, lun);
+r = DO_UPCAST(SCSIDiskReq, req, req);
+r-iov = iov;
+r-iov_num = iov_num;
+r-iov_buf = NULL;
+return req;
+}
+
 static void scsi_remove_request(SCSIRequest *req)
 {
 SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
 
-qemu_vfree(r-iov);
-r-iov = NULL;
-qemu_vfree(r-iov_buf);
-r-iov_buf = NULL;
+if (r-iov_buf) {
+qemu_vfree(r-iov);
+r-iov = NULL;
+qemu_vfree(r-iov_buf);
+r-iov_buf = NULL;
+}
 scsi_req_free(r-req);
 }
 
@@ -1207,6 +1223,7 @@ static SCSIDeviceInfo scsi_disk_info = {
 .init = scsi_disk_initfn,
 .destroy  = scsi_destroy,
 .alloc_req= scsi_new_request,
+.alloc_req_iov = scsi_new_request_iovec,
 .free_req = scsi_remove_request,
 .send_command = scsi_send_command,
 .read_data= scsi_read_data,
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 5c0f6ab..7d30115 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -107,6 +107,25 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, 
uint32_t tag, uint32_t lun)
 return req;
 }
 
+static SCSIRequest *scsi_new_request_iovec(SCSIDevice *d, uint32_t tag,
+   uint32_t lun, struct iovec *iov, 
int iov_num)
+{
+SCSIRequest *req;
+SCSIGenericReq *r;
+int i;
+
+req = scsi_req_alloc(sizeof(SCSIGenericReq), d, tag, lun);
+r = DO_UPCAST(SCSIGenericReq, req, req);
+r-io_header.dxferp = iov;
+r-io_header.iovec_count = iov_num;
+r-io_header.dxfer_len = 0;
+for (i = 0; i  iov_num; i++)
+r-io_header.dxfer_len += iov[i].iov_len;
+r-buf = NULL;
+r-buflen = 0;
+return req;
+}
+
 static void scsi_remove_request(SCSIRequest *req)
 {
 SCSIGenericReq *r = DO_UPCAST(SCSIGenericReq, req, req);
@@ -179,8 +198,10 @@ static int execute_command(BlockDriverState *bdrv,
 
 r-io_header.interface_id = 'S';
 r-io_header.dxfer_direction = direction;
-r-io_header.dxferp = r-buf;
-r-io_header.dxfer_len = r-buflen;
+if (r-buf) {
+r-io_header.dxferp = r-buf;
+r-io_header.dxfer_len = r-buflen;
+}
 r-io_header.cmdp = r-req.cmd.buf;
 r-io_header.cmd_len = r-req.cmd.len;
 r-io_header.mx_sb_len = sizeof(s-sensebuf);
@@ -286,7 +307,7 @@ static int scsi_write_data(SCSIRequest *req)
 
 DPRINTF(scsi_write_data 0x%x\n, req-tag);
 
-if (r-len == 0) {
+if (r-len == 0  r-io_header.dxfer_len == 0) {
 r-len = r-buflen;
 r-req.bus-complete(r-req, SCSI_REASON_DATA, r-len);
 return 0;
@@ -380,14 +401,16 @@ static int32_t scsi_send_command(SCSIRequest *req, 
uint8_t *cmd)
 return 0;
 }
 
-if (r-buflen != r-req.cmd.xfer) {
-if (r-buf != NULL)
-qemu_free(r-buf);
-r-buf = qemu_malloc(r-req.cmd.xfer);
-r-buflen = r-req.cmd.xfer;
-}
+if (!r-io_header.iovec_count) {
+if (r-buflen != r-req.cmd.xfer) {
+if (r-buf != NULL)
+qemu_free(r-buf);
+r-buf = qemu_malloc(r-req.cmd.xfer);
+r-buflen = r-req.cmd.xfer;
+}
 
-memset(r-buf, 0, r-buflen);
+memset(r-buf, 0, r-buflen);
+}
 r-len = r-req.cmd.xfer;
 if (r-req.cmd.mode == SCSI_XFER_TO_DEV) {
 r-len = 0;
@@ -560,6 +583,7 @@ static SCSIDeviceInfo scsi_generic_info = {
 .init = scsi_generic_initfn,
 .destroy  = scsi_destroy,
 .alloc_req= scsi_new_request,
+.alloc_req_iov  = scsi_new_request_iovec,
 .free_req = scsi_remove_request,
 .send_command = scsi_send_command,
 .read_data= scsi_read_data,
diff --git a/hw/scsi.h b/hw/scsi.h
index 0c467d1..538ae54 100644
--- a/hw/scsi.h
+++ b/hw/scsi.h
@@ -72,6 +72,8 @@ struct SCSIDeviceInfo {
 scsi_qdev_initfn init;
 void (*destroy)(SCSIDevice *s);
 SCSIRequest *(*alloc_req)(SCSIDevice *s, uint32_t tag, uint32_t lun);
+SCSIRequest *(*alloc_req_iov)(SCSIDevice *s, uint32_t tag, uint32_t lun,
+  struct iovec *iov, int iov_num);
 void (*free_req)(SCSIRequest *req);
 int32_t (*send_command)(SCSIRequest 

[Qemu-devel] Re: [PATCH v2 0/6] qdev reset refactoring and pci bus reset

2010-11-22 Thread Michael S. Tsirkin
On Mon, Nov 22, 2010 at 07:43:37PM +0900, Isaku Yamahata wrote:
 On Mon, Nov 22, 2010 at 09:54:02AM +0200, Michael S. Tsirkin wrote:
  On Fri, Nov 19, 2010 at 06:55:57PM +0900, Isaku Yamahata wrote:
   Here is v2. I updated the comments, and dropped the pci qdev reset patch.
   
   Patch description:
   The goal of this patch series is to implement secondary bus reset
   emulation in pci-to-pci bridge.
   At first, this patch series refactors qdev reset,
   and then cleans up pci bus reset. Lastly implements pci bridge control
   secondary bus reset bit.
   
   This patch series is for pci bus reset, which is ported
   from the following repo.
   git://repo.or.cz/qemu/aliguori.git qdev-refactor
  
  I've put the series on my pci branch, tweaking patches 5 and 6 in the
  process.  Out of time to compile-tested only for now.
 
 Thank you. The tweaking looks good.
 Do you still want me to send another patch to add a comment on RST#?

Probably not. I'm not sure I understand what the conventional
PCI spec says: should devices be reset on 0-1
transition, or kept in reset state until this bit is cleared?
And it seems quite clear that in the express
case the reset is only for 0-1 transition.
I've asked for clarification from pcisig.

 -- 
 yamahata



[Qemu-devel] [PATCH] scsi-disk: add data direction checking

2010-11-22 Thread Hannes Reinecke

scsi_req_parse() already provides for a data direction setting,
so we should be using it to check for correct direction.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 hw/scsi-disk.c |   13 +++--
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index a0dda88..82072a8 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -52,8 +52,6 @@ typedef struct SCSIDiskState SCSIDiskState;
 
 typedef struct SCSIDiskReq {
 SCSIRequest req;
-/* ??? We should probably keep track of whether the data transfer is
-   a read or a write.  Currently we rely on the host getting it right.  */
 /* Both sector and sector_count are in terms of qemu 512 byte blocks.  */
 uint64_t sector;
 uint32_t sector_count;
@@ -172,6 +170,9 @@ static void scsi_read_data(SCSIRequest *req)
 /* No data transfer may already be in progress */
 assert(r-req.aiocb == NULL);
 
+if (r-req.cmd.mode == SCSI_XFER_TO_DEV)
+BADF(Data transfer direction invalid\n);
+
 if (r-sector_count == (uint32_t)-1) {
 DPRINTF(Read buf_len=%zd\n, r-iov[0].iov_len);
 r-sector_count = 0;
@@ -284,6 +285,9 @@ static int scsi_write_data(SCSIRequest *req)
 /* No data transfer may already be in progress */
 assert(r-req.aiocb == NULL);
 
+if (r-req.cmd.mode != SCSI_XFER_TO_DEV)
+BADF(Data transfer direction invalid\n);
+
 n = iov_size(r-iov, r-iov_num) / 512;
 if (n) {
 qemu_iovec_init_external(r-qiov, r-iov, r-iov_num);
@@ -970,11 +974,9 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t 
*buf)
 SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
 SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req-dev);
 ssize_t len = 0;
-int is_write;
 uint8_t command;
 
 command = buf[0];
-is_write = 0;
 DPRINTF(Command: lun=%d tag=0x%x data=0x%02x, lun, tag, buf[0]);
 
 if (scsi_req_parse(r-req, buf) != 0) {
@@ -1057,7 +1059,6 @@ static int32_t scsi_send_command(SCSIRequest *req, 
uint8_t *buf)
 goto illegal_lba;
 }
 r-sector = r-req.cmd.lba * s-cluster_size;
-is_write = 1;
 break;
 case MODE_SELECT:
 DPRINTF(Mode Select(6) (len %lu)\n, (long)r-req.cmd.xfer);
@@ -1098,7 +1099,7 @@ static int32_t scsi_send_command(SCSIRequest *req, 
uint8_t *buf)
 scsi_command_complete(r, GOOD, SENSE_CODE(NO_SENSE));
 }
 len += r-sector_count * 512;
-if (is_write) {
+if (r-req.cmd.mode == SCSI_XFER_TO_DEV) {
 return -len;
 } else {
 if (!r-sector_count)
-- 
1.6.0.2




[Qemu-devel] [PATCH] scsi: Use 'SCSIRequest' directly

2010-11-22 Thread Hannes Reinecke

Currently the SCSIRequest structure is abstracted away and
cannot accessed directly from the driver. This requires
the handler to do a lookup on an abstract 'tag' which
identifies the SCSIRequest structure.
With this patch the SCSIRequest structure is exposed to
the driver. This allows use to use it directly as an
argument to the SCSIDeviceInfo callback functions and
remove the lookup.
Two new callback functions 'alloc_req' and 'free_req'
are introduced, which serve to allocate a new request
and to free up resources after use.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 hw/esp.c  |   20 ---
 hw/lsi53c895a.c   |   26 +
 hw/scsi-bus.c |   15 +-
 hw/scsi-disk.c|  147 
 hw/scsi-generic.c |  119 ++-
 hw/scsi.h |   20 ---
 hw/usb-msd.c  |   23 +
 7 files changed, 136 insertions(+), 234 deletions(-)

diff --git a/hw/esp.c b/hw/esp.c
index 910fd31..2784bec 100644
--- a/hw/esp.c
+++ b/hw/esp.c
@@ -65,6 +65,7 @@ struct ESPState {
 uint32_t dma;
 SCSIBus bus;
 SCSIDevice *current_dev;
+SCSIRequest *current_req;
 uint8_t cmdbuf[TI_BUFSZ];
 uint32_t cmdlen;
 uint32_t do_cmd;
@@ -209,7 +210,7 @@ static uint32_t get_cmd(ESPState *s, uint8_t *buf)
 
 if (s-current_dev) {
 /* Started a new command before the old one finished.  Cancel it.  */
-s-current_dev-info-cancel_io(s-current_dev, 0);
+s-current_dev-info-cancel_io(s-current_req);
 s-async_len = 0;
 }
 
@@ -232,7 +233,8 @@ static void do_busid_cmd(ESPState *s, uint8_t *buf, uint8_t 
busid)
 
 DPRINTF(do_busid_cmd: busid 0x%x\n, busid);
 lun = busid  7;
-datalen = s-current_dev-info-send_command(s-current_dev, 0, buf, lun);
+s-current_req = s-current_dev-info-alloc_req(s-current_dev, 0, lun);
+datalen = s-current_dev-info-send_command(s-current_req, buf);
 s-ti_size = datalen;
 if (datalen != 0) {
 s-rregs[ESP_RSTAT] = STAT_TC;
@@ -240,10 +242,10 @@ static void do_busid_cmd(ESPState *s, uint8_t *buf, 
uint8_t busid)
 s-dma_counter = 0;
 if (datalen  0) {
 s-rregs[ESP_RSTAT] |= STAT_DI;
-s-current_dev-info-read_data(s-current_dev, 0);
+s-current_dev-info-read_data(s-current_req);
 } else {
 s-rregs[ESP_RSTAT] |= STAT_DO;
-s-current_dev-info-write_data(s-current_dev, 0);
+s-current_dev-info-write_data(s-current_req);
 }
 }
 s-rregs[ESP_RINTR] = INTR_BS | INTR_FC;
@@ -372,9 +374,9 @@ static void esp_do_dma(ESPState *s)
 if (s-async_len == 0) {
 if (to_device) {
 // ti_size is negative
-s-current_dev-info-write_data(s-current_dev, 0);
+s-current_dev-info-write_data(s-current_req);
 } else {
-s-current_dev-info-read_data(s-current_dev, 0);
+s-current_dev-info-read_data(s-current_req);
 /* If there is still data to be read from the device then
complete the DMA operation immediately.  Otherwise defer
until the scsi layer has completed.  */
@@ -388,7 +390,7 @@ static void esp_do_dma(ESPState *s)
 }
 }
 
-static void esp_command_complete(SCSIBus *bus, int reason, uint32_t tag,
+static void esp_command_complete(SCSIBus *bus, int reason, SCSIRequest *req,
  uint32_t arg)
 {
 ESPState *s = DO_UPCAST(ESPState, busdev.qdev, bus-qbus.parent);
@@ -405,11 +407,13 @@ static void esp_command_complete(SCSIBus *bus, int 
reason, uint32_t tag,
 s-sense = arg;
 s-rregs[ESP_RSTAT] = STAT_ST;
 esp_dma_done(s);
+req-dev-info-free_req(req);
+s-current_req = NULL;
 s-current_dev = NULL;
 } else {
 DPRINTF(transfer %d/%d\n, s-dma_left, s-ti_size);
 s-async_len = arg;
-s-async_buf = s-current_dev-info-get_buf(s-current_dev, 0);
+s-async_buf = s-current_dev-info-get_buf(req);
 if (s-dma_left) {
 esp_do_dma(s);
 } else if (s-dma_counter != 0  s-ti_size = 0) {
diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index 8246ee8..82a5d39 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -174,6 +174,7 @@ do { fprintf(stderr, lsi_scsi: error:  fmt , ## 
__VA_ARGS__);} while (0)
 #define LSI_TAG_VALID (1  16)
 
 typedef struct lsi_request {
+SCSIRequest *req;
 uint32_t tag;
 uint32_t dma_len;
 uint8_t *dma_buf;
@@ -569,7 +570,7 @@ static void lsi_do_dma(LSIState *s, int out)
 s-dbc -= count;
 
 if (s-current-dma_buf == NULL) {
-s-current-dma_buf = dev-info-get_buf(dev, s-current-tag);
+s-current-dma_buf = dev-info-get_buf(s-current-req);
 }
 
 /* ??? Set SFBR to first data byte.  */
@@ -583,10 +584,10 @@ static void lsi_do_dma(LSIState *s, int out)
 s-current-dma_buf = NULL;
 if (out) {
 /* Write 

Re: [Qemu-devel] [PATCH] Megasas HBA emulation and SCSI update v.2

2010-11-22 Thread Hannes Reinecke
On 11/22/2010 11:15 AM, Hannes Reinecke wrote:
 
 The is the second version of the megasas patchset; changes are:
 v1 - v2:
 - Include suggestions (and acked-by) from Christoph Hellwig
 - Updated patch description as requested by Gerd Hoffman
 - Use generic iov_size() implementation
 - Drop old patches
 - Make SCSI HBA configurable
 
 This patchset can be found at
 
 git://repo.or.cz/qemu/megasas.git
 branch megasas.v2
 
Hey, sorry, just found out I've omitted the series numbers
in the patchset. But reposting the entire patchset just
to get the numbers back is a bit of a waste.
So please check with the above git tree or
use this as a series file:
 
 Hannes Reinecke (15):
   scsi: Increase the number of possible devices
   scsi: Return SAM status codes
   scsi: INQUIRY VPD fixes
   scsi: Move sense handling into the driver
   scsi-disk: Remove duplicate cdb parsing
   scsi: Update sense code handling
   lsi53c895a: Rename 'sense' to 'status'
   scsi-disk: Allocate iovec dynamically
   scsi: Use 'SCSIRequest' directly
   scsi-disk: add data direction checking
   Remove 'bus' argument from SCSI command completion callbacks
   scsi: Implement 'get_sense' callback
   scsi: Implement alloc_req_iov callback
   megasas: LSI Megaraid SAS emulation
   Make SCSI HBA configurable
 

Sorry about this.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)



[Qemu-devel] Re: [PATCH] Make SCSI HBA configurable

2010-11-22 Thread Paolo Bonzini

On 11/22/2010 11:15 AM, Hannes Reinecke wrote:


This patch introduces configuration variables
CONFIG_SCSI_LSI
CONFIG_SCSI_MEGASAS
and renames the existing CONFIG_ESP to CONFIG_SCSI_ESP.
With this the available SCSI HBAs can be configured for each
target configuration instead of compiling it in for everyone.

Signed-off-by: Hannes Reineckeh...@suse.de
---
  Makefile.objs|5 +++--
  default-configs/i386-softmmu.mak |2 ++
  default-configs/mips-softmmu.mak |2 +-
  default-configs/mips64-softmmu.mak   |2 +-
  default-configs/mips64el-softmmu.mak |2 +-
  default-configs/mipsel-softmmu.mak   |2 +-
  default-configs/ppc-softmmu.mak  |2 ++
  default-configs/ppc64-softmmu.mak|2 ++
  default-configs/ppcemb-softmmu.mak   |2 ++
  default-configs/sparc-softmmu.mak|2 +-
  default-configs/sparc64-softmmu.mak  |2 ++
  default-configs/x86_64-softmmu.mak   |2 ++
  12 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index 89c8661..3b040cd 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -231,8 +231,9 @@ hw-obj-$(CONFIG_IDE_MACIO) += ide/macio.o
  hw-obj-$(CONFIG_IDE_VIA) += ide/via.o

  # SCSI layer
-hw-obj-y += lsi53c895a.o megasas.o
-hw-obj-$(CONFIG_ESP) += esp.o
+hw-obj-$(CONFIG_SCSI_LSI) += lsi53c895a.o
+hw-obj-$(CONFIG_SCSI_MEGASAS) += megasas.o
+hw-obj-$(CONFIG_SCSI_ESP) += esp.o

  hw-obj-y += dma-helpers.o sysbus.o isa-bus.o
  hw-obj-y += qdev-addr.o
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index ed00471..130c157 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -19,6 +19,8 @@ CONFIG_IDE_QDEV=y
  CONFIG_IDE_PCI=y
  CONFIG_IDE_ISA=y
  CONFIG_IDE_PIIX=y
+CONFIG_SCSI_LSI=y
+CONFIG_SCSI_MEGASAS=y
  CONFIG_NE2000_ISA=y
  CONFIG_PIIX_PCI=y
  CONFIG_SOUND=y
diff --git a/default-configs/mips-softmmu.mak b/default-configs/mips-softmmu.mak
index 3d0af83..7e840a4 100644
--- a/default-configs/mips-softmmu.mak
+++ b/default-configs/mips-softmmu.mak
@@ -1,7 +1,7 @@
  # Default configuration for mips-softmmu

  CONFIG_ISA_MMIO=y
-CONFIG_ESP=y
+CONFIG_SCSI_ESP=y
  CONFIG_VGA_PCI=y
  CONFIG_VGA_ISA=y
  CONFIG_VGA_ISA_MM=y
diff --git a/default-configs/mips64-softmmu.mak 
b/default-configs/mips64-softmmu.mak
index 0030de4..3816be3 100644
--- a/default-configs/mips64-softmmu.mak
+++ b/default-configs/mips64-softmmu.mak
@@ -1,7 +1,7 @@
  # Default configuration for mips64-softmmu

  CONFIG_ISA_MMIO=y
-CONFIG_ESP=y
+CONFIG_SCSI_ESP=y
  CONFIG_VGA_PCI=y
  CONFIG_VGA_ISA=y
  CONFIG_VGA_ISA_MM=y
diff --git a/default-configs/mips64el-softmmu.mak 
b/default-configs/mips64el-softmmu.mak
index fa2a3ff..21c59e0 100644
--- a/default-configs/mips64el-softmmu.mak
+++ b/default-configs/mips64el-softmmu.mak
@@ -1,7 +1,7 @@
  # Default configuration for mips64el-softmmu

  CONFIG_ISA_MMIO=y
-CONFIG_ESP=y
+CONFIG_SCSI_ESP=y
  CONFIG_VGA_PCI=y
  CONFIG_VGA_ISA=y
  CONFIG_VGA_ISA_MM=y
diff --git a/default-configs/mipsel-softmmu.mak 
b/default-configs/mipsel-softmmu.mak
index 238b73a..3cf853a 100644
--- a/default-configs/mipsel-softmmu.mak
+++ b/default-configs/mipsel-softmmu.mak
@@ -1,7 +1,7 @@
  # Default configuration for mipsel-softmmu

  CONFIG_ISA_MMIO=y
-CONFIG_ESP=y
+CONFIG_SCSI_ESP=y
  CONFIG_VGA_PCI=y
  CONFIG_VGA_ISA=y
  CONFIG_VGA_ISA_MM=y
diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.mak
index 940f4bf..0cc5914 100644
--- a/default-configs/ppc-softmmu.mak
+++ b/default-configs/ppc-softmmu.mak
@@ -29,6 +29,8 @@ CONFIG_IDE_PCI=y
  CONFIG_IDE_ISA=y
  CONFIG_IDE_CMD646=y
  CONFIG_IDE_MACIO=y
+CONFIG_SCSI_LSI=y
+CONFIG_SCSI_MEGASAS=y
  CONFIG_NE2000_ISA=y
  CONFIG_SOUND=y
  CONFIG_VIRTIO_PCI=y
diff --git a/default-configs/ppc64-softmmu.mak 
b/default-configs/ppc64-softmmu.mak
index e1bc6b8..ce83254 100644
--- a/default-configs/ppc64-softmmu.mak
+++ b/default-configs/ppc64-softmmu.mak
@@ -29,6 +29,8 @@ CONFIG_IDE_PCI=y
  CONFIG_IDE_ISA=y
  CONFIG_IDE_CMD646=y
  CONFIG_IDE_MACIO=y
+CONFIG_SCSI_LSI=y
+CONFIG_SCSI_MEGASAS=y
  CONFIG_NE2000_ISA=y
  CONFIG_SOUND=y
  CONFIG_VIRTIO_PCI=y
diff --git a/default-configs/ppcemb-softmmu.mak 
b/default-configs/ppcemb-softmmu.mak
index 8f1cc09..44111c3 100644
--- a/default-configs/ppcemb-softmmu.mak
+++ b/default-configs/ppcemb-softmmu.mak
@@ -29,6 +29,8 @@ CONFIG_IDE_PCI=y
  CONFIG_IDE_ISA=y
  CONFIG_IDE_CMD646=y
  CONFIG_IDE_MACIO=y
+CONFIG_SCSI_LSI=y
+CONFIG_SCSI_MEGASAS=y
  CONFIG_NE2000_ISA=y
  CONFIG_SOUND=y
  CONFIG_VIRTIO_PCI=y
diff --git a/default-configs/sparc-softmmu.mak 
b/default-configs/sparc-softmmu.mak
index becf880..872929d 100644
--- a/default-configs/sparc-softmmu.mak
+++ b/default-configs/sparc-softmmu.mak
@@ -1,7 +1,7 @@
  # Default configuration for sparc-softmmu

  CONFIG_ECC=y
-CONFIG_ESP=y
+CONFIG_SCSI_ESP=y
  CONFIG_ESCC=y
  CONFIG_M48T59=y
  CONFIG_PTIMER=y
diff --git a/default-configs/sparc64-softmmu.mak 
b/default-configs/sparc64-softmmu.mak

[Qemu-devel] Re: [PATCH v2 0/6] qdev reset refactoring and pci bus reset

2010-11-22 Thread Isaku Yamahata
On Mon, Nov 22, 2010 at 09:54:02AM +0200, Michael S. Tsirkin wrote:
 On Fri, Nov 19, 2010 at 06:55:57PM +0900, Isaku Yamahata wrote:
  Here is v2. I updated the comments, and dropped the pci qdev reset patch.
  
  Patch description:
  The goal of this patch series is to implement secondary bus reset
  emulation in pci-to-pci bridge.
  At first, this patch series refactors qdev reset,
  and then cleans up pci bus reset. Lastly implements pci bridge control
  secondary bus reset bit.
  
  This patch series is for pci bus reset, which is ported
  from the following repo.
  git://repo.or.cz/qemu/aliguori.git qdev-refactor
 
 I've put the series on my pci branch, tweaking patches 5 and 6 in the
 process.  Out of time to compile-tested only for now.

Thank you. The tweaking looks good.
Do you still want me to send another patch to add a comment on RST#?
-- 
yamahata



Re: [Qemu-devel] [PATCH 11/16] scsi-disk: add data direction checking

2010-11-22 Thread Christoph Hellwig
On Thu, Nov 18, 2010 at 03:47:32PM +0100, Hannes Reinecke wrote:
 
 scsi_req_parse() already provides for a data direction setting,
 so we should be using it to check for correct direction.

Instead of just a debug printf that almost no one compiles in shouldn't
we reject the incorrect commands?




Re: [Qemu-devel] [PATCH vgabios] Add 1280x768 mode

2010-11-22 Thread Gerd Hoffmann

On 11/21/10 16:33, Avi Kivity wrote:

+{ 1280, 768, 16  , 0x175},
+{ 1280, 768, 24  , 0x176},
+{ 1280, 768, 32  , 0x177},


Acked-by: Gerd Hoffmann kra...@redhat.com

cheers,
  Gerd




Re: [Qemu-devel] [PATCH 13/16] Remove 'bus' argument from SCSI command completion callbacks

2010-11-22 Thread Christoph Hellwig
Looks good.



Re: [Qemu-devel] [PATCH 15/16] scsi: Implement get_req_iov callback

2010-11-22 Thread Christoph Hellwig
 @@ -95,14 +95,30 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, 
 uint32_t tag,
  return req;
  }
  
 +static SCSIRequest *scsi_new_request_iovec(SCSIDevice *d, uint32_t tag,
 +uint32_t lun, struct iovec *iov, int iov_num)
 +{
 +SCSIRequest *req;
 +SCSIDiskReq *r;
 +
 +req = scsi_req_alloc(sizeof(SCSIDiskReq), d, tag, lun);
 +r = DO_UPCAST(SCSIDiskReq, req, req);
 +r-iov = iov;
 +r-iov_num = iov_num;
 +r-iov_buf = NULL;
 +return req;
 +}

While the amount of duplicated code here is rather small I still hate
the duplication.

The simplest step is to implement scsi_new_request on top of
scsi_new_request_iovec by just allocation the iovec in scsi_new_request
and passing it to scsi_new_request_iovec.  The next patch on top would
be to move the iovec allocation to the HBA driver and only stick to
one interface.




Re: [Qemu-devel] [PATCH 11/16] scsi-disk: add data direction checking

2010-11-22 Thread Hannes Reinecke
On 11/22/2010 12:20 PM, Christoph Hellwig wrote:
 On Thu, Nov 18, 2010 at 03:47:32PM +0100, Hannes Reinecke wrote:

 scsi_req_parse() already provides for a data direction setting,
 so we should be using it to check for correct direction.
 
 Instead of just a debug printf that almost no one compiles in shouldn't
 we reject the incorrect commands?
 
Good point. Will be fixing it up for the next version.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)



Re: [Qemu-devel] [PATCH] scsi: Use 'SCSIRequest' directly

2010-11-22 Thread Christoph Hellwig
On Mon, Nov 22, 2010 at 11:15:35AM +0100, Hannes Reinecke wrote:
 
 Currently the SCSIRequest structure is abstracted away and
 cannot accessed directly from the driver. This requires
 the handler to do a lookup on an abstract 'tag' which
 identifies the SCSIRequest structure.
 With this patch the SCSIRequest structure is exposed to
 the driver. This allows use to use it directly as an
 argument to the SCSIDeviceInfo callback functions and
 remove the lookup.
 Two new callback functions 'alloc_req' and 'free_req'
 are introduced, which serve to allocate a new request
 and to free up resources after use.

I still think having the implementations of the method named different
than the method name is a bad idea.

Otherwise looks good.




Re: [Qemu-devel] [PATCH 1/1] NBD isn't used by qemu-img, so don't link qemu-img against NBD objects

2010-11-22 Thread Kevin Wolf
Am 19.11.2010 17:30, schrieb jes.soren...@redhat.com:
 From: Jes Sorensen jes.soren...@redhat.com
 
 Signed-off-by: Jes Sorensen jes.soren...@redhat.com

You're compiling the nbd block driver out here. This is certainly not
what you were attempting. (However, it's the only way to make it work,
because otherwise qemu-img will need the top-level nbd.o)

qemu-img -help before this change shows:

Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2
parallels nbd blkdebug sheepdog blkverify host_cdrom host_floppy
host_device file tftp ftps ftp https http

Afterwards:

Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2
parallels blkdebug sheepdog blkverify host_cdrom host_floppy host_device
file tftp ftps ftp https http

Kevin

 ---
  Makefile  |2 +-
  Makefile.objs |   12 ++--
  2 files changed, 11 insertions(+), 3 deletions(-)
 
 diff --git a/Makefile b/Makefile
 index 747e47c..a503c1c 100644
 --- a/Makefile
 +++ b/Makefile
 @@ -154,7 +154,7 @@ qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o: 
 $(GENERATED_HEADERS)
  
  qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(oslib-obj-y) 
 $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) 
 qemu-timer-common.o
  
 -qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(oslib-obj-y) 
 $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) 
 qemu-timer-common.o
 +qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(oslib-obj-y) 
 $(trace-obj-y) $(block-obj-y) $(nbd-obj-y) $(qobject-obj-y) $(version-obj-y) 
 qemu-timer-common.o
  
  qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(oslib-obj-y) 
 $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) 
 qemu-timer-common.o
  
 diff --git a/Makefile.objs b/Makefile.objs
 index 23b17ce..5120e88 100644
 --- a/Makefile.objs
 +++ b/Makefile.objs
 @@ -14,13 +14,13 @@ oslib-obj-$(CONFIG_POSIX) += oslib-posix.o
  # block-obj-y is code used by both qemu system emulation and qemu-img
  
  block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
 -block-obj-y += nbd.o block.o aio.o aes.o qemu-config.o
 +block-obj-y += block.o aio.o aes.o qemu-config.o
  block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
  block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
  
  block-nested-y += raw.o cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o 
 vpc.o vvfat.o
  block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o
 -block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o
 +block-nested-y += parallels.o blkdebug.o sheepdog.o blkverify.o
  block-nested-$(CONFIG_WIN32) += raw-win32.o
  block-nested-$(CONFIG_POSIX) += raw-posix.o
  block-nested-$(CONFIG_CURL) += curl.o
 @@ -45,6 +45,13 @@ net-obj-y += $(addprefix net/, $(net-nested-y))
  fsdev-nested-$(CONFIG_VIRTFS) = qemu-fsdev.o
  fsdev-obj-$(CONFIG_VIRTFS) += $(addprefix fsdev/, $(fsdev-nested-y))
  
 +###
 +# nbd-obj-y is code used by both qemu and qemu-nbd
 +
 +nbd-obj-y = nbd.o
 +nbd-nested-y = nbd.o
 +nbd-obj-y +=  $(addprefix block/, $(nbd-nested-y))
 +
  ##
  # libqemu_common.a: Target independent part of system emulation. The
  # long term path is to suppress *all* target specific code in case of
 @@ -53,6 +60,7 @@ fsdev-obj-$(CONFIG_VIRTFS) += $(addprefix fsdev/, 
 $(fsdev-nested-y))
  
  common-obj-y = $(block-obj-y) blockdev.o
  common-obj-y += $(net-obj-y)
 +common-obj-y += $(nbd-obj-y)
  common-obj-y += $(qobject-obj-y)
  common-obj-$(CONFIG_LINUX) += $(fsdev-obj-$(CONFIG_LINUX))
  common-obj-y += readline.o console.o cursor.o async.o qemu-error.o




Re: [Qemu-devel] [PATCH v2] ioport: Fix duplicated code

2010-11-22 Thread Luiz Capitulino
On Fri, 19 Nov 2010 19:50:10 -0600
Anthony Liguori anth...@codemonkey.ws wrote:

 On 11/11/2010 08:03 AM, Luiz Capitulino wrote:
  Functions register_ioport_read() and register_ioport_write() are almost
  identical, the only difference is that they write to different arrays.
 
  Introduce register_ioport_rw() to handle this difference and change both
  functions to use it instead of duplicating code.
 
  Signed-off-by: Luiz Capitulinolcapitul...@redhat.com
 
 
 While it make take some scripting, let's do a global query/replace.
 
 Having two interfaces where one is only scarely used hurts code 
 readability.  We need to do the janitorial work when changing interfaces 
 like this.

The goal of this patch was just to make register_ioport_read() and
register_ioport_write() use common code, what janitorial work should
we do?

Export register_ioport_rw() and change drivers to use it, instead of
calling register_ioport_read() and register_ioport_write()?


 Regards,
 
 Anthony Liguori
 
  ---
 
  v2: Fix error messages and make register_ioport_rw() register both handlers
   at the same call
 
ioport.c |   37 ++---
1 files changed, 18 insertions(+), 19 deletions(-)
 
  diff --git a/ioport.c b/ioport.c
  index ec3dc65..4560973 100644
  --- a/ioport.c
  +++ b/ioport.c
  @@ -137,41 +137,40 @@ static int ioport_bsize(int size, int *bsize)
}
 
/* size is the word size in byte */
  -int register_ioport_read(pio_addr_t start, int length, int size,
  - IOPortReadFunc *func, void *opaque)
  +static int register_ioport_rw(pio_addr_t start, int length, int size,
  +  IOPortReadFunc *read_func,
  +  IOPortWriteFunc *write_func, void *opaque)
{
int i, bsize;
 
if (ioport_bsize(size,bsize)) {
  -hw_error(register_ioport_read: invalid size);
  +hw_error(register_ioport_rw: invalid size);
return -1;
}
for(i = start; i  start + length; i += size) {
  -ioport_read_table[bsize][i] = func;
  +if (read_func) {
  +ioport_read_table[bsize][i] = read_func;
  +}
  +if (write_func) {
  +ioport_write_table[bsize][i] = write_func;
  +}
if (ioport_opaque[i] != NULL  ioport_opaque[i] != opaque)
  -hw_error(register_ioport_read: invalid opaque);
  +hw_error(register_ioport_rw: invalid opaque);
ioport_opaque[i] = opaque;
}
return 0;
}
 
  -/* size is the word size in byte */
  +int register_ioport_read(pio_addr_t start, int length, int size,
  + IOPortReadFunc *func, void *opaque)
  +{
  +return register_ioport_rw(start, length, size, func, NULL, opaque);
  +}
  +
int register_ioport_write(pio_addr_t start, int length, int size,
  IOPortWriteFunc *func, void *opaque)
{
  -int i, bsize;
  -
  -if (ioport_bsize(size,bsize)) {
  -hw_error(register_ioport_write: invalid size);
  -return -1;
  -}
  -for(i = start; i  start + length; i += size) {
  -ioport_write_table[bsize][i] = func;
  -if (ioport_opaque[i] != NULL  ioport_opaque[i] != opaque)
  -hw_error(register_ioport_write: invalid opaque);
  -ioport_opaque[i] = opaque;
  -}
  -return 0;
  +return register_ioport_rw(start, length, size, NULL, func, opaque);
}
 
void isa_unassign_ioport(pio_addr_t start, int length)
 
 




Re: [Qemu-devel] Re: [PATCH] PCI: Bus number from the bridge, not the device

2010-11-22 Thread Gleb Natapov
On Mon, Nov 22, 2010 at 10:16:57AM +0200, Michael S. Tsirkin wrote:
 On Mon, Nov 22, 2010 at 09:37:07AM +0200, Gleb Natapov wrote:
 It's probably required to make them stable anyway.
 
Why?
   
   To avoid bus renumbering on reboot after you add a pci-to-pci bridge.
   
  Why should qemu care?
 
 Stable bus numbering is a feature *users* care about, because
 some Guest OSes get confused when a card gets moved to another
 bus.
 
So if user cares about it it should not change HW configuration of QEMU.
I guess those OSes knows how to handle hot-pluggable equipment otherwise
they will get confused on real HW too. Why QEMU should care to preserve
something in a face of configuration change?

--
Gleb.



Re: [Qemu-devel] [PATCH 0/3] add hotplug opt-out option for devices.

2010-11-22 Thread Gleb Natapov
On Mon, Nov 22, 2010 at 11:17:10AM +0100, Gerd Hoffmann wrote:
 An ideal interface would explicitly allow a user to mark a series of PCI
 slots as no supporting hotplug. It would be convenient in order to
 ensure that your virtio-net wasn't accidentally ejected by a click-happy
 Windows user.
 
 Indeed.  That one is a bit harder I suspect.  Can this be done
 without generating acpi tables dynamically?
 
I tried and failed :( You can try to :)

--
Gleb.



Re: [Qemu-devel] [PATCH 1/1] NBD isn't used by qemu-img, so don't link qemu-img against NBD objects

2010-11-22 Thread Anthony Liguori

On 11/22/2010 08:38 AM, Kevin Wolf wrote:

You're free to dislike NBD as much as you want. Just compiling it out
unconditionally and calling it a cleanup is a bit too much. ;-)

A configure option for disabling NBD sounds reasonable, though I'm not
sure what you're trying to achieve with it. It doesn't have any external
dependencies that you could avoid this way, does it?
   


Using block format whitelisting should be enough to disable nbd.  I 
don't see a need for an explicit --disable-nbd option.


Regards,

Anthony Liguori


Kevin

   





Re: [Qemu-devel] Re: [PATCH] PCI: Bus number from the bridge, not the device

2010-11-22 Thread Michael S. Tsirkin
On Mon, Nov 22, 2010 at 04:52:32PM +0200, Gleb Natapov wrote:
 On Mon, Nov 22, 2010 at 04:50:29PM +0200, Michael S. Tsirkin wrote:
  On Mon, Nov 22, 2010 at 03:04:51PM +0200, Gleb Natapov wrote:
   On Mon, Nov 22, 2010 at 10:16:57AM +0200, Michael S. Tsirkin wrote:
On Mon, Nov 22, 2010 at 09:37:07AM +0200, Gleb Natapov wrote:
It's probably required to make them stable anyway.

   Why?
  
  To avoid bus renumbering on reboot after you add a pci-to-pci 
  bridge.
  
 Why should qemu care?

Stable bus numbering is a feature *users* care about, because
some Guest OSes get confused when a card gets moved to another
bus.

   So if user cares about it it should not change HW configuration of QEMU.
   I guess those OSes knows how to handle hot-pluggable equipment otherwise
   they will get confused on real HW too. Why QEMU should care to preserve
   something in a face of configuration change?
   
   --
 Gleb.
  
  We've been there, weren't we? See
  http://fedoraproject.org/wiki/Features/KVM_Stable_PCI_Addresses#KVM_Stable_PCI_Addresses
  
 This is about stable HW configuration.

Exactly. We have the same need for nested bridges and devices behind
them.

 --
   Gleb.



Re: [Qemu-devel] [PATCH 1/1] NBD isn't used by qemu-img, so don't link qemu-img against NBD objects

2010-11-22 Thread Jes Sorensen
On 11/22/10 15:54, Anthony Liguori wrote:
 On 11/22/2010 08:38 AM, Kevin Wolf wrote:
 You're free to dislike NBD as much as you want. Just compiling it out
 unconditionally and calling it a cleanup is a bit too much. ;-)

 A configure option for disabling NBD sounds reasonable, though I'm not
 sure what you're trying to achieve with it. It doesn't have any external
 dependencies that you could avoid this way, does it?

 
 Using block format whitelisting should be enough to disable nbd.  I
 don't see a need for an explicit --disable-nbd option.

Right, the right solution is probably to create a block driver list
argument for configure, similar to what we have for the sound drivers.

Ignore my patch.

Cheers,
Jes



Re: [Qemu-devel] Re: [PATCH] PCI: Bus number from the bridge, not the device

2010-11-22 Thread Gleb Natapov
On Mon, Nov 22, 2010 at 04:56:16PM +0200, Michael S. Tsirkin wrote:
 On Mon, Nov 22, 2010 at 04:52:32PM +0200, Gleb Natapov wrote:
  On Mon, Nov 22, 2010 at 04:50:29PM +0200, Michael S. Tsirkin wrote:
   On Mon, Nov 22, 2010 at 03:04:51PM +0200, Gleb Natapov wrote:
On Mon, Nov 22, 2010 at 10:16:57AM +0200, Michael S. Tsirkin wrote:
 On Mon, Nov 22, 2010 at 09:37:07AM +0200, Gleb Natapov wrote:
 It's probably required to make them stable anyway.
 
Why?
   
   To avoid bus renumbering on reboot after you add a pci-to-pci 
   bridge.
   
  Why should qemu care?
 
 Stable bus numbering is a feature *users* care about, because
 some Guest OSes get confused when a card gets moved to another
 bus.
 
So if user cares about it it should not change HW configuration of QEMU.
I guess those OSes knows how to handle hot-pluggable equipment otherwise
they will get confused on real HW too. Why QEMU should care to preserve
something in a face of configuration change?

--
Gleb.
   
   We've been there, weren't we? See
   http://fedoraproject.org/wiki/Features/KVM_Stable_PCI_Addresses#KVM_Stable_PCI_Addresses
   
  This is about stable HW configuration.
 
 Exactly. We have the same need for nested bridges and devices behind
 them.
 
And now you are talking about topology, not guest assigned bus numbers.
So suddenly you are on my side? I don't even get what are you arguing
about at this point.

--
Gleb.



Re: [Qemu-devel] [PATCH] Make SCSI HBA configurable

2010-11-22 Thread Jes Sorensen
On 11/22/10 11:15, Hannes Reinecke wrote:
 
 This patch introduces configuration variables
 CONFIG_SCSI_LSI
 CONFIG_SCSI_MEGASAS
 and renames the existing CONFIG_ESP to CONFIG_SCSI_ESP.
 With this the available SCSI HBAs can be configured for each
 target configuration instead of compiling it in for everyone.
 
 Signed-off-by: Hannes Reinecke h...@suse.de
 ---
  Makefile.objs|5 +++--
  default-configs/i386-softmmu.mak |2 ++
  default-configs/mips-softmmu.mak |2 +-
  default-configs/mips64-softmmu.mak   |2 +-
  default-configs/mips64el-softmmu.mak |2 +-
  default-configs/mipsel-softmmu.mak   |2 +-
  default-configs/ppc-softmmu.mak  |2 ++
  default-configs/ppc64-softmmu.mak|2 ++
  default-configs/ppcemb-softmmu.mak   |2 ++
  default-configs/sparc-softmmu.mak|2 +-
  default-configs/sparc64-softmmu.mak  |2 ++
  default-configs/x86_64-softmmu.mak   |2 ++
  12 files changed, 20 insertions(+), 7 deletions(-)

Acked-by: Jes Sorensen jes.soren...@redhat.com

With a configure flag to flip modify the list from the default it would
reach perfect status :)

Cheers,
Jes



Re: [Qemu-devel] [PATCH 1/1] NBD isn't used by qemu-img, so don't link qemu-img against NBD objects

2010-11-22 Thread Anthony Liguori

On 11/22/2010 08:58 AM, Jes Sorensen wrote:

On 11/22/10 15:54, Anthony Liguori wrote:
   

On 11/22/2010 08:38 AM, Kevin Wolf wrote:
 

You're free to dislike NBD as much as you want. Just compiling it out
unconditionally and calling it a cleanup is a bit too much. ;-)

A configure option for disabling NBD sounds reasonable, though I'm not
sure what you're trying to achieve with it. It doesn't have any external
dependencies that you could avoid this way, does it?

   

Using block format whitelisting should be enough to disable nbd.  I
don't see a need for an explicit --disable-nbd option.
 

Right, the right solution is probably to create a block driver list
argument for configure, similar to what we have for the sound drivers.
   


--block-drv-whitelist=

Regards,

Anthony Liguori




Ignore my patch.

Cheers,
Jes
   





Re: [Qemu-devel] [PATCH 1/1] NBD isn't used by qemu-img, so don't link qemu-img against NBD objects

2010-11-22 Thread Jes Sorensen
On 11/22/10 16:08, Anthony Liguori wrote:
 On 11/22/2010 08:58 AM, Jes Sorensen wrote:
 On 11/22/10 15:54, Anthony Liguori wrote:
 Using block format whitelisting should be enough to disable nbd.  I
 don't see a need for an explicit --disable-nbd option.
  
 Right, the right solution is probably to create a block driver list
 argument for configure, similar to what we have for the sound drivers.

 
 --block-drv-whitelist=

Any idea what the difference is between 'whitelist' and 'list' in this
context?

Jes



Re: [Qemu-devel] [PATCH 1/1] NBD isn't used by qemu-img, so don't link qemu-img against NBD objects

2010-11-22 Thread Anthony Liguori

On 11/22/2010 09:10 AM, Jes Sorensen wrote:

On 11/22/10 16:08, Anthony Liguori wrote:
   

On 11/22/2010 08:58 AM, Jes Sorensen wrote:
 

On 11/22/10 15:54, Anthony Liguori wrote:
   

Using block format whitelisting should be enough to disable nbd.  I
don't see a need for an explicit --disable-nbd option.

 

Right, the right solution is probably to create a block driver list
argument for configure, similar to what we have for the sound drivers.

   

--block-drv-whitelist=
 

Any idea what the difference is between 'whitelist' and 'list' in this
context?
   


Everything is built, but only the formats that are in the whitelist are 
usable.


Regards,

Anthony Liguori


Jes
   





[Qemu-devel] [Bug 595438] Re: KVM segmentation fault, using SCSI+writeback and linux 2.4 guest

2010-11-22 Thread Serge Hallyn
Thanks.  I will try to reproduce this as soon as I can (which will be next
week.)  IF anyone else can get to it sooner, to confirm that the proposed
fix works, by all means please comment the result here so the fix can
finally get cleared.

-- 
KVM segmentation fault, using SCSI+writeback and linux 2.4 guest
https://bugs.launchpad.net/bugs/595438
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in Kernel Virtual Machine: Confirmed
Status in QEMU: Fix Committed
Status in qemu-kvm: Fix Released
Status in “qemu-kvm” package in Ubuntu: Fix Released
Status in “qemu-kvm” source package in Lucid: Fix Committed
Status in “qemu-kvm” package in Debian: Fix Released

Bug description:
I Use Ubuntu 32 bit 10.04 with standard KVM.
I have Intel E7600  @ 3.06GHz processor with VMX

In this system I Run:
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin 
QEMU_AUDIO_DRV=none /usr/bin/kvm -M pc-0.12 -enable-kvm -m 256 -smp 1 -name 
spamsender -uuid b9cacd5e-08f7-41fd-78c8-89cec59af881 -chardev 
socket,id=monitor,path=/var/lib/libvirt/qemu/spamsender.monitor,server,nowait 
-monitor chardev:monitor -boot d -drive 
file=/mnt/megadiff/cdiso_400_130.iso,if=ide,media=cdrom,index=2 -drive 
file=/home/mmarkk/spamsender2.img,if=scsi,index=0,format=qcow2,cache=writeback 
-net nic,macaddr=00:00:00:00:00:00,vlan=0,name=nic.0 -net tap,vlan=0,name=tap.0 
-chardev pty,id=serial0 -serial chardev:serial0 -parallel none -usb -vnc 
127.0.0.1:0 -vga cirrus

.iso image contain custom distro of 2.4-linux kernel based system. During 
install process (when .tar.gz actively unpacked), kvm dead with segmentation 
fault.

And ONLY when I choose scsi virtual disk and writeback simultaneously.
But, writeback+ide, writethrough+scsi works OK.

I use qcow2. It seems, that qcow does not have such problems.

Virtual machine get down at random time during file copy. It seems, when qcow2 
file size need to be expanded.

IMPACT: kvm used with scsi virtual disk and writeback dies with segfault.

FIX: is the inclusion of a patch cherry-picked from upstream which dequeues
requests before invoking callbacks.  It is at
http://bazaar.launchpad.net/~serge-hallyn/ubuntu/lucid/qemu-kvm/fix-scsi-writeback/revision/70

TO REPRODUCE: See the command above.

REGRESSION POTENTIAL: this is cherry-picked from upstream, and has been
tested by the bug reporter with no ill effects.






Re: [Qemu-devel] [PATCH 1/1] NBD isn't used by qemu-img, so don't link qemu-img against NBD objects

2010-11-22 Thread Jes Sorensen
On 11/22/10 16:20, Anthony Liguori wrote:
 On 11/22/2010 09:10 AM, Jes Sorensen wrote:
 On 11/22/10 16:08, Anthony Liguori wrote:
 On 11/22/2010 08:58 AM, Jes Sorensen wrote:
 Right, the right solution is probably to create a block driver list
 argument for configure, similar to what we have for the sound drivers.

 --block-drv-whitelist=
  
 Any idea what the difference is between 'whitelist' and 'list' in this
 context?
 
 Everything is built, but only the formats that are in the whitelist are
 usable.

Kinda defeats the purpose IMHO. It would be useful to be able to strip
out the formats one doesn't want to get a slimmed down binary.

Cheers,
Jes




Re: [Qemu-devel] Re: [PATCH] PCI: Bus number from the bridge, not the device

2010-11-22 Thread Michael S. Tsirkin
On Mon, Nov 22, 2010 at 04:58:11PM +0200, Gleb Natapov wrote:
 On Mon, Nov 22, 2010 at 04:56:16PM +0200, Michael S. Tsirkin wrote:
  On Mon, Nov 22, 2010 at 04:52:32PM +0200, Gleb Natapov wrote:
   On Mon, Nov 22, 2010 at 04:50:29PM +0200, Michael S. Tsirkin wrote:
On Mon, Nov 22, 2010 at 03:04:51PM +0200, Gleb Natapov wrote:
 On Mon, Nov 22, 2010 at 10:16:57AM +0200, Michael S. Tsirkin wrote:
  On Mon, Nov 22, 2010 at 09:37:07AM +0200, Gleb Natapov wrote:
  It's probably required to make them stable anyway.
  
 Why?

To avoid bus renumbering on reboot after you add a pci-to-pci 
bridge.

   Why should qemu care?
  
  Stable bus numbering is a feature *users* care about, because
  some Guest OSes get confused when a card gets moved to another
  bus.
  
 So if user cares about it it should not change HW configuration of 
 QEMU.
 I guess those OSes knows how to handle hot-pluggable equipment 
 otherwise
 they will get confused on real HW too. Why QEMU should care to 
 preserve
 something in a face of configuration change?
 
 --
   Gleb.

We've been there, weren't we? See
http://fedoraproject.org/wiki/Features/KVM_Stable_PCI_Addresses#KVM_Stable_PCI_Addresses

   This is about stable HW configuration.
  
  Exactly. We have the same need for nested bridges and devices behind
  them.
  
 And now you are talking about topology, not guest assigned bus numbers.

I suspect that if bus numbers change, it has the same effect as topology
change on the guest. Need to test though, I'm not sure.

 So suddenly you are on my side? I don't even get what are you arguing
 about at this point.

By this time, I forgot, too :).

 --
   Gleb.



Re: [Qemu-devel] Re: [PATCH] PCI: Bus number from the bridge, not the device

2010-11-22 Thread Gleb Natapov
On Mon, Nov 22, 2010 at 06:41:28PM +0200, Michael S. Tsirkin wrote:
 On Mon, Nov 22, 2010 at 04:58:11PM +0200, Gleb Natapov wrote:
  On Mon, Nov 22, 2010 at 04:56:16PM +0200, Michael S. Tsirkin wrote:
   On Mon, Nov 22, 2010 at 04:52:32PM +0200, Gleb Natapov wrote:
On Mon, Nov 22, 2010 at 04:50:29PM +0200, Michael S. Tsirkin wrote:
 On Mon, Nov 22, 2010 at 03:04:51PM +0200, Gleb Natapov wrote:
  On Mon, Nov 22, 2010 at 10:16:57AM +0200, Michael S. Tsirkin wrote:
   On Mon, Nov 22, 2010 at 09:37:07AM +0200, Gleb Natapov wrote:
   It's probably required to make them stable anyway.
   
  Why?
 
 To avoid bus renumbering on reboot after you add a pci-to-pci 
 bridge.
 
Why should qemu care?
   
   Stable bus numbering is a feature *users* care about, because
   some Guest OSes get confused when a card gets moved to another
   bus.
   
  So if user cares about it it should not change HW configuration of 
  QEMU.
  I guess those OSes knows how to handle hot-pluggable equipment 
  otherwise
  they will get confused on real HW too. Why QEMU should care to 
  preserve
  something in a face of configuration change?
  
  --
  Gleb.
 
 We've been there, weren't we? See
 http://fedoraproject.org/wiki/Features/KVM_Stable_PCI_Addresses#KVM_Stable_PCI_Addresses
 
This is about stable HW configuration.
   
   Exactly. We have the same need for nested bridges and devices behind
   them.
   
  And now you are talking about topology, not guest assigned bus numbers.
 
 I suspect that if bus numbers change, it has the same effect as topology
 change on the guest. Need to test though, I'm not sure.
 
Hard to believe. Unplugging card with internal pci-pci bridge may change
bus numbering.

  So suddenly you are on my side? I don't even get what are you arguing
  about at this point.
 
 By this time, I forgot, too :).
 
:)

--
Gleb.



Re: [Qemu-devel] [PATCH] add a command line option to specify the IP address to send multicast packets from

2010-11-22 Thread Mike Ryan
Michael, this patch implements the feature with a bind address instead
of a bind interface. It should address the cross-platform issues that
were raised.

Others: any comments?

On Wed, Nov 17, 2010 at 05:16:26PM -0800, Mike Ryan wrote:
 Add an option to specify the host IP to send multicast packets from when
 using a multicast socket for networking. The option takes an IP address
 and sets the IP_MULTICAST_IF socket option, which causes the packets to
 use that IP's interface as an egress.
 
 This is useful if the host machine has several interfaces with several
 virtual networks across disparate interfaces.
 ---
  net.c   |4 
  net/socket.c|   46 ++
  qemu-options.hx |   11 +--
  3 files changed, 47 insertions(+), 14 deletions(-)
 
 diff --git a/net.c b/net.c
 index c5e6063..9ba5be2 100644
 --- a/net.c
 +++ b/net.c
 @@ -1050,6 +1050,10 @@ static const struct {
  .name = mcast,
  .type = QEMU_OPT_STRING,
  .help = UDP multicast address and port number,
 +}, {
 +.name = localaddr,
 +.type = QEMU_OPT_STRING,
 +.help = source address for multicast packets,
  },
  { /* end of list */ }
  },
 diff --git a/net/socket.c b/net/socket.c
 index 1c4e153..d443f4c 100644
 --- a/net/socket.c
 +++ b/net/socket.c
 @@ -149,7 +149,7 @@ static void net_socket_send_dgram(void *opaque)
  qemu_send_packet(s-nc, s-buf, size);
  }
  
 -static int net_socket_mcast_create(struct sockaddr_in *mcastaddr)
 +static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct 
 in_addr *localaddr)
  {
  struct ip_mreq imr;
  int fd;
 @@ -201,6 +201,15 @@ static int net_socket_mcast_create(struct sockaddr_in 
 *mcastaddr)
   goto fail;
  }
  
 +/* If a bind address is given, only send packets from that address */
 +if (localaddr != NULL) {
 +ret = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, localaddr, 
 sizeof(*localaddr));
 +if (ret  0) {
 +perror(setsockopt(IP_MULTICAST_IF));
 +goto fail;
 +}
 +}
 +
  socket_set_nonblock(fd);
  return fd;
  fail:
 @@ -248,7 +257,7 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState 
 *vlan,
   return NULL;
   }
   /* clone dgram socket */
 - newfd = net_socket_mcast_create(saddr);
 + newfd = net_socket_mcast_create(saddr, NULL);
   if (newfd  0) {
   /* error already reported by net_socket_mcast_create() */
   close(fd);
 @@ -468,17 +477,26 @@ static int net_socket_connect_init(VLANState *vlan,
  static int net_socket_mcast_init(VLANState *vlan,
   const char *model,
   const char *name,
 - const char *host_str)
 + const char *host_str,
 + const char *localaddr_str)
  {
  NetSocketState *s;
  int fd;
  struct sockaddr_in saddr;
 +struct in_addr localaddr, *param_localaddr;
  
  if (parse_host_port(saddr, host_str)  0)
  return -1;
  
 +if (localaddr_str != NULL) {
 +if (inet_aton(localaddr_str, localaddr) == 0)
 +return -1;
 +param_localaddr = localaddr;
 +} else {
 +param_localaddr = NULL;
 +}
  
 -fd = net_socket_mcast_create(saddr);
 +fd = net_socket_mcast_create(saddr, param_localaddr);
  if (fd  0)
   return -1;
  
 @@ -505,8 +523,9 @@ int net_init_socket(QemuOpts *opts,
  
  if (qemu_opt_get(opts, listen) ||
  qemu_opt_get(opts, connect) ||
 -qemu_opt_get(opts, mcast)) {
 -error_report(listen=, connect= and mcast= is invalid with fd=);
 +qemu_opt_get(opts, mcast) ||
 +qemu_opt_get(opts, localaddr)) {
 +error_report(listen=, connect=, mcast= and localaddr= is 
 invalid with fd=\n);
  return -1;
  }
  
 @@ -524,8 +543,9 @@ int net_init_socket(QemuOpts *opts,
  
  if (qemu_opt_get(opts, fd) ||
  qemu_opt_get(opts, connect) ||
 -qemu_opt_get(opts, mcast)) {
 -error_report(fd=, connect= and mcast= is invalid with listen=);
 +qemu_opt_get(opts, mcast) ||
 +qemu_opt_get(opts, localaddr)) {
 +error_report(fd=, connect=, mcast= and localaddr= is invalid 
 with listen=\n);
  return -1;
  }
  
 @@ -539,8 +559,9 @@ int net_init_socket(QemuOpts *opts,
  
  if (qemu_opt_get(opts, fd) ||
  qemu_opt_get(opts, listen) ||
 -qemu_opt_get(opts, mcast)) {
 -error_report(fd=, listen= and mcast= is invalid with connect=);
 +qemu_opt_get(opts, mcast) ||
 +qemu_opt_get(opts, localaddr)) {
 +error_report(fd=, 

[Qemu-devel] [PATCH, RFT] Speedup 'tb_find_slow' by using the same heuristic as during memory page lookup

2010-11-22 Thread Kirill Batuzov
Move the last found TB to the head of the list so it will be found more 
quickly next time it will be looked for.


Signed-off-by: Kirill Batuzov batuz...@ispras.ru
Signed-off-by: Pavel Yushchenko p...@ispras.ru
---
Hello.  This patch gives significant boost to a used by us rather rich 
(for embedded one - featuring X-server, many daemons and applications) 
ARM-based system literally decreasing its boot to desktop time by TWO 
times!  (Average number of traversed 'tb_phys_hash' entries in the main 
loop of the 'tb_find_slow' function reduced from 20 to 1.5.)  We were 
able to shorten boot to login time by about 25% as well using Debian on 
versatilepb (no X-server, only basic system). Seems like kernel booting 
time is not affected.  No problems were encountered during our experiments.


We are looking forward for comments about this change and help with 
testing. Thanks in advance!


 cpu-exec.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/cpu-exec.c b/cpu-exec.c
index 5d6dd51..55c4526 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -161,6 +161,11 @@ static TranslationBlock *tb_find_slow(target_ulong pc,
 tb = tb_gen_code(env, pc, cs_base, flags, 0);

  found:
+if (*ptb1) {
+*ptb1 = tb-phys_hash_next;
+tb-phys_hash_next = tb_phys_hash[h];
+tb_phys_hash[h] = tb;
+}
 /* we add the TB in the virtual pc hash table */
 env-tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;
 return tb;
diff --git a/cpu-exec.c b/cpu-exec.c
index 5d6dd51..55c4526 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -161,6 +161,11 @@ static TranslationBlock *tb_find_slow(target_ulong pc,
 tb = tb_gen_code(env, pc, cs_base, flags, 0);
 
  found:
+if (*ptb1) {
+*ptb1 = tb-phys_hash_next;
+tb-phys_hash_next = tb_phys_hash[h];
+tb_phys_hash[h] = tb;
+}
 /* we add the TB in the virtual pc hash table */
 env-tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;
 return tb;


[Qemu-devel] Re: [PATCH] scsi: Implement alloc_req_iov callback

2010-11-22 Thread Stefan Hajnoczi
On Mon, Nov 22, 2010 at 10:15 AM, Hannes Reinecke h...@suse.de wrote:
Looks good.  If you send out another version of the patchset you might
like to fix this nitpick:

 +    if (!r-io_header.iovec_count) {
 +        if (r-buflen != r-req.cmd.xfer) {
 +            if (r-buf != NULL)
 +                qemu_free(r-buf);

qemu_free(NULL) is a nop so it's safe to drop the if (r-buf != NULL)
check and just use qemu_free(r-buf) unconditionally.  That's nice
since it also fixes the if statement without curly braces.

Stefan



[Qemu-devel] Re: [PATCH] Remove 'bus' argument from SCSI command completion callbacks

2010-11-22 Thread Stefan Hajnoczi
On Mon, Nov 22, 2010 at 10:15 AM, Hannes Reinecke h...@suse.de wrote:

 The 'bus' argument is now pointless, as we already pass the
 request itself and the bus can be derived from it.

 Signed-off-by: Hannes Reinecke h...@suse.de
 ---
  hw/esp.c          |    5 ++---
  hw/lsi53c895a.c   |    5 ++---
  hw/scsi-bus.c     |    3 +--
  hw/scsi-disk.c    |    8 
  hw/scsi-generic.c |    6 +++---
  hw/scsi.h         |    3 +--
  hw/usb-msd.c      |    5 ++---
  7 files changed, 15 insertions(+), 20 deletions(-)

Reviewed-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com



[Qemu-devel] Re: [PATCH] scsi: Implement 'get_sense' callback

2010-11-22 Thread Stefan Hajnoczi
On Mon, Nov 22, 2010 at 10:15 AM, Hannes Reinecke h...@suse.de wrote:
 +static int scsi_get_sense(SCSIRequest *req, uint8_t *outbuf, int len)
 +{
 +    SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, req-dev);
 +    int size = SCSI_SENSE_BUF_SIZE;

If there is no error we return SCSI_SENSE_BUF_SIZE without touching
outbuf?  I was expecting a memset(outbuf, 0, ...) or something that
initializes outbuf.

 +
 +    if (s-driver_status  SG_ERR_DRIVER_SENSE) {
 +        if (len  SCSI_SENSE_BUF_SIZE)

{}

 +            size = len;
 +        else

{}

Stefan



Re: [Qemu-devel] [PATCH] Make SCSI HBA configurable

2010-11-22 Thread Alexander Graf

On 22.11.2010, at 16:05, Jes Sorensen wrote:

 On 11/22/10 11:15, Hannes Reinecke wrote:
 
 This patch introduces configuration variables
 CONFIG_SCSI_LSI
 CONFIG_SCSI_MEGASAS
 and renames the existing CONFIG_ESP to CONFIG_SCSI_ESP.
 With this the available SCSI HBAs can be configured for each
 target configuration instead of compiling it in for everyone.
 
 Signed-off-by: Hannes Reinecke h...@suse.de
 ---
 Makefile.objs|5 +++--
 default-configs/i386-softmmu.mak |2 ++
 default-configs/mips-softmmu.mak |2 +-
 default-configs/mips64-softmmu.mak   |2 +-
 default-configs/mips64el-softmmu.mak |2 +-
 default-configs/mipsel-softmmu.mak   |2 +-
 default-configs/ppc-softmmu.mak  |2 ++
 default-configs/ppc64-softmmu.mak|2 ++
 default-configs/ppcemb-softmmu.mak   |2 ++
 default-configs/sparc-softmmu.mak|2 +-
 default-configs/sparc64-softmmu.mak  |2 ++
 default-configs/x86_64-softmmu.mak   |2 ++
 12 files changed, 20 insertions(+), 7 deletions(-)
 
 Acked-by: Jes Sorensen jes.soren...@redhat.com
 
 With a configure flag to flip modify the list from the default it would
 reach perfect status :)

We don't have that for any device yet that's represented in the 
default-configs. I'd actually rather advocate to go with a make menuconfig + 
Kconfig style format here instead of configure options.


Alex




[Qemu-devel] [PATCH] Overwrite argv to set process title, eliminating 16-character prctl() limit.

2010-11-22 Thread John Morrissey
Linux seems to maintain the length of the original args, even when the new
args are shorter and NULL-terminated, so the trailing whitespace in ps(1)
output is probably unavoidable. I've seen the same result with other daemons
that overwrite argv.

Keeps the call to prctl(), since some tools get the process name from
/proc/PID/status.

Signed-off-by: John Morrissey j...@horde.net
---
 os-posix.c  |   34 +-
 qemu-os-posix.h |2 +-
 qemu-os-win32.h |3 ++-
 vl.c|   11 +--
 4 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/os-posix.c b/os-posix.c
index 38c29d1..04cc2e1 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -39,10 +39,6 @@
 #include net/slirp.h
 #include qemu-options.h
 
-#ifdef CONFIG_LINUX
-#include sys/prctl.h
-#endif
-
 #ifdef CONFIG_EVENTFD
 #include sys/eventfd.h
 #endif
@@ -149,20 +145,32 @@ char *os_find_datadir(const char *argv0)
 #undef SHARE_SUFFIX
 #undef BUILD_SUFFIX
 
-void os_set_proc_name(const char *s)
+void os_set_proc_name(int argc, char **argv, const char *name)
 {
-#if defined(PR_SET_NAME)
-char name[16];
-if (!s)
+#ifdef CONFIG_LINUX
+char prctl_name[16], *last_argv_byte, *p;
+int len, i;
+
+if (!name)
 return;
-name[sizeof(name) - 1] = 0;
-strncpy(name, s, sizeof(name));
-/* Could rewrite argv[0] too, but that's a bit more complicated.
-   This simple way is enough for `top'. */
-if (prctl(PR_SET_NAME, name)) {
+
+#if defined(PR_SET_NAME)
+strncpy(prctl_name, name, sizeof(prctl_name));
+if (prctl(PR_SET_NAME, prctl_name)) {
 perror(unable to change process name);
 exit(1);
 }
+#endif
+
+last_argv_byte = argv[argc - 1] + strlen(argv[argc - 1]);
+
+len = snprintf(argv[0], last_argv_byte - argv[0], %s, name);
+
+p = argv[0][len];
+while (p = last_argv_byte)
+*p++ = '\0';
+for (i = 1; i  argc; ++i)
+argv[i] = (char *) ;
 #else
 fprintf(stderr, Change of process name not supported by your OS\n);
 exit(1);
diff --git a/qemu-os-posix.h b/qemu-os-posix.h
index 353f878..b0cf993 100644
--- a/qemu-os-posix.h
+++ b/qemu-os-posix.h
@@ -31,7 +31,7 @@ static inline void os_host_main_loop_wait(int *timeout)
 }
 
 void os_set_line_buffering(void);
-void os_set_proc_name(const char *s);
+void os_set_proc_name(int argc, char **argv, const char *name);
 void os_setup_signal_handling(void);
 void os_daemonize(void);
 void os_setup_post(void);
diff --git a/qemu-os-win32.h b/qemu-os-win32.h
index 1a07e5e..c618362 100644
--- a/qemu-os-win32.h
+++ b/qemu-os-win32.h
@@ -46,7 +46,8 @@ static inline void os_setup_signal_handling(void) {}
 static inline void os_daemonize(void) {}
 static inline void os_setup_post(void) {}
 void os_set_line_buffering(void);
-static inline void os_set_proc_name(const char *dummy) {}
+static inline void os_set_proc_name(int argc, char **argv,
+const char *dummy) {}
 
 #if !defined(EPROTONOSUPPORT)
 # define EPROTONOSUPPORT EINVAL
diff --git a/vl.c b/vl.c
index 805e11f..74a939c 100644
--- a/vl.c
+++ b/vl.c
@@ -1776,7 +1776,11 @@ static const QEMUOption *lookup_opt(int argc, char 
**argv,
 optarg = NULL;
 }
 
-*poptarg = optarg;
+if (optarg != NULL) {
+*poptarg = qemu_strdup(optarg);
+} else {
+*poptarg = NULL;
+}
 *poptind = optind;
 
 return popt;
@@ -1804,6 +1808,7 @@ int main(int argc, char **argv, char **envp)
 int tb_size;
 const char *pid_file = NULL;
 const char *incoming = NULL;
+const char *process_name = NULL;
 int show_vnc_port = 0;
 int defconfig = 1;
 
@@ -2497,7 +2502,7 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
p += 8;
-   os_set_proc_name(p);
+   process_name = p;
 }  
 }  
 break;
@@ -2723,6 +2728,8 @@ int main(int argc, char **argv, char **envp)
 exit(1);
 }
 
+os_set_proc_name(argc, argv, process_name);
+
 if (kvm_allowed) {
 int ret = kvm_init(smp_cpus);
 if (ret  0) {
-- 
1.7.0.4




Re: [Qemu-devel] KVM call agenda for Nov 23

2010-11-22 Thread Chris Wright
* Juan Quintela (quint...@redhat.com) wrote:
 Please send in any agenda items you are interested in covering.

usb-ccid



Re: [Qemu-devel] KVM call agenda for Nov 23

2010-11-22 Thread Anthony Liguori

On 11/22/2010 03:45 PM, Chris Wright wrote:

* Juan Quintela (quint...@redhat.com) wrote:
   

Please send in any agenda items you are interested in covering.
 

usb-ccid
   


aka external device emulation in qemu.

This is an easy topic to discuss in an abstract sense and I'm sure 
everyone has an opinion.  However, what's needed is deep review of the 
current code with an eye towards all of the possible issues we will face 
in the future including live migration, configurability, and 
compatibility.  I need to find some time to spend with the appropriate 
specs.


It would be a lot simpler just to include the emulation in qemu like we 
do for every other device...


Regards,

Anthony Liguori


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
   





[Qemu-devel] Re: [PATCH v2 0/6] qdev reset refactoring and pci bus reset

2010-11-22 Thread Michael S. Tsirkin
On Mon, Nov 22, 2010 at 07:43:37PM +0900, Isaku Yamahata wrote:
 On Mon, Nov 22, 2010 at 09:54:02AM +0200, Michael S. Tsirkin wrote:
  On Fri, Nov 19, 2010 at 06:55:57PM +0900, Isaku Yamahata wrote:
   Here is v2. I updated the comments, and dropped the pci qdev reset patch.
   
   Patch description:
   The goal of this patch series is to implement secondary bus reset
   emulation in pci-to-pci bridge.
   At first, this patch series refactors qdev reset,
   and then cleans up pci bus reset. Lastly implements pci bridge control
   secondary bus reset bit.
   
   This patch series is for pci bus reset, which is ported
   from the following repo.
   git://repo.or.cz/qemu/aliguori.git qdev-refactor
  
  I've put the series on my pci branch, tweaking patches 5 and 6 in the
  process.  Out of time to compile-tested only for now.
 
 Thank you. The tweaking looks good.
 Do you still want me to send another patch to add a comment on RST#?

OK, I got response, and yes, we need to fix code to avoid claiming
transactions by devices on the secondary bus while secondary bus is in
RST# for both pci and express.

 -- 
 yamahata



[Qemu-devel] [PATCH] qemu-kvm: introduce cpu_start/cpu_stop commands

2010-11-22 Thread Anthony Liguori
qemu-kvm vcpu threads don't response to SIGSTOP/SIGCONT.  Instead of teaching
them to respond to these signals, introduce monitor commands that stop and start
individual vcpus.

The purpose of these commands are to implement CPU hard limits using an external
tool that watches the CPU consumption and stops the CPU as appropriate.

The monitor commands provide a more elegant solution that signals because it
ensures that a stopped vcpu isn't holding the qemu_mutex.

I'll reply to this note with an example tool.

Signed-off-by: Anthony Liguori aligu...@us.ibm.com

diff --git a/hmp-commands.hx b/hmp-commands.hx
index ba6de28..827bd67 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -279,6 +279,24 @@ Resume emulation.
 ETEXI
 
 {
+.name   = cpu_start,
+.args_type  = cpu:i,
+.params = [cpu],
+.help   = start cpu emulation,
+.user_print = monitor_user_noop,
+.mhandler.cmd_new = do_vcpu_start,
+},
+
+{
+.name   = cpu_stop,
+.args_type  = cpu:i,
+.params = [cpu],
+.help   = stop cpu emulation,
+.user_print = monitor_user_noop,
+.mhandler.cmd_new = do_vcpu_stop,
+},
+
+{
 .name   = gdbserver,
 .args_type  = device:s?,
 .params = [device],
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 471306b..35121ed 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1351,6 +1351,65 @@ static void pause_all_threads(void)
 }
 }
 
+static void vcpu_stop(int cpu)
+{
+CPUState *env = first_cpu;
+
+for (env = first_cpu; env; env = env-next_cpu) {
+if (env-cpu_index == cpu) {
+break;
+}
+}
+
+if (env) {
+if (env != cpu_single_env) {
+env-stop = 1;
+pthread_kill(env-kvm_cpu_state.thread, SIG_IPI);
+} else {
+env-stop = 0;
+env-stopped = 1;
+cpu_exit(env);
+}
+
+while (!env-stopped) {
+qemu_cond_wait(qemu_pause_cond);
+}
+}
+}
+
+static void vcpu_start(int cpu)
+{
+CPUState *env = first_cpu;
+
+assert(!cpu_single_env);
+
+for (env = first_cpu; env; env = env-next_cpu) {
+if (env-cpu_index == cpu) {
+break;
+}
+}
+
+if (env) {
+env-stop = 0;
+env-stopped = 0;
+pthread_kill(env-kvm_cpu_state.thread, SIG_IPI);
+}
+}
+
+int do_vcpu_stop(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+int vcpu = qdict_get_int(qdict, cpu);
+vcpu_stop(vcpu);
+return 0;
+}
+
+int do_vcpu_start(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+int vcpu = qdict_get_int(qdict, cpu);
+vcpu_start(vcpu);
+return 0;
+}
+
 static void resume_all_threads(void)
 {
 CPUState *penv = first_cpu;
diff --git a/sysemu.h b/sysemu.h
index 849dc8c..3ef68dd 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -61,6 +61,9 @@ void qemu_system_reset(void);
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
 
+int do_vcpu_stop(Monitor *mon, const QDict *qdict, QObject **ret_data);
+int do_vcpu_start(Monitor *mon, const QDict *qdict, QObject **ret_data);
+
 void do_savevm(Monitor *mon, const QDict *qdict);
 int load_vmstate(const char *name);
 void do_delvm(Monitor *mon, const QDict *qdict);
-- 
1.7.0.4




Re: [Qemu-devel] KVM call agenda for Nov 23

2010-11-22 Thread Anthony Liguori

On 11/22/2010 03:45 PM, Chris Wright wrote:

* Juan Quintela (quint...@redhat.com) wrote:
   

Please send in any agenda items you are interested in covering.
 

usb-ccid
   


- vcpu hard limits

Regards,

Anthony Liguori


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
   





[Qemu-devel] Re: [PATCH] qemu-kvm: introduce cpu_start/cpu_stop commands

2010-11-22 Thread Anthony Liguori

On 11/22/2010 05:00 PM, Anthony Liguori wrote:

qemu-kvm vcpu threads don't response to SIGSTOP/SIGCONT.  Instead of teaching
them to respond to these signals, introduce monitor commands that stop and start
individual vcpus.

The purpose of these commands are to implement CPU hard limits using an external
tool that watches the CPU consumption and stops the CPU as appropriate.

The monitor commands provide a more elegant solution that signals because it
ensures that a stopped vcpu isn't holding the qemu_mutex.

I'll reply to this note with an example tool.
   


This is super rough but demonstrates the concept.  If you run it with '0 
50 100' it will cap VCPU 0 at 50%.


It's not the prettiest thing in the world but it's minimally invasive 
and seems to work well.


Regards,

Anthony Liguori


Signed-off-by: Anthony Liguorialigu...@us.ibm.com

diff --git a/hmp-commands.hx b/hmp-commands.hx
index ba6de28..827bd67 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -279,6 +279,24 @@ Resume emulation.
  ETEXI

  {
+.name   = cpu_start,
+.args_type  = cpu:i,
+.params = [cpu],
+.help   = start cpu emulation,
+.user_print = monitor_user_noop,
+.mhandler.cmd_new = do_vcpu_start,
+},
+
+{
+.name   = cpu_stop,
+.args_type  = cpu:i,
+.params = [cpu],
+.help   = stop cpu emulation,
+.user_print = monitor_user_noop,
+.mhandler.cmd_new = do_vcpu_stop,
+},
+
+{
  .name   = gdbserver,
  .args_type  = device:s?,
  .params = [device],
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 471306b..35121ed 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1351,6 +1351,65 @@ static void pause_all_threads(void)
  }
  }

+static void vcpu_stop(int cpu)
+{
+CPUState *env = first_cpu;
+
+for (env = first_cpu; env; env = env-next_cpu) {
+if (env-cpu_index == cpu) {
+break;
+}
+}
+
+if (env) {
+if (env != cpu_single_env) {
+env-stop = 1;
+pthread_kill(env-kvm_cpu_state.thread, SIG_IPI);
+} else {
+env-stop = 0;
+env-stopped = 1;
+cpu_exit(env);
+}
+
+while (!env-stopped) {
+qemu_cond_wait(qemu_pause_cond);
+}
+}
+}
+
+static void vcpu_start(int cpu)
+{
+CPUState *env = first_cpu;
+
+assert(!cpu_single_env);
+
+for (env = first_cpu; env; env = env-next_cpu) {
+if (env-cpu_index == cpu) {
+break;
+}
+}
+
+if (env) {
+env-stop = 0;
+env-stopped = 0;
+pthread_kill(env-kvm_cpu_state.thread, SIG_IPI);
+}
+}
+
+int do_vcpu_stop(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+int vcpu = qdict_get_int(qdict, cpu);
+vcpu_stop(vcpu);
+return 0;
+}
+
+int do_vcpu_start(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+int vcpu = qdict_get_int(qdict, cpu);
+vcpu_start(vcpu);
+return 0;
+}
+
  static void resume_all_threads(void)
  {
  CPUState *penv = first_cpu;
diff --git a/sysemu.h b/sysemu.h
index 849dc8c..3ef68dd 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -61,6 +61,9 @@ void qemu_system_reset(void);
  void qemu_add_exit_notifier(Notifier *notify);
  void qemu_remove_exit_notifier(Notifier *notify);

+int do_vcpu_stop(Monitor *mon, const QDict *qdict, QObject **ret_data);
+int do_vcpu_start(Monitor *mon, const QDict *qdict, QObject **ret_data);
+
  void do_savevm(Monitor *mon, const QDict *qdict);
  int load_vmstate(const char *name);
  void do_delvm(Monitor *mon, const QDict *qdict);
   


#define _XOPEN_SOURCE 500
#define _GNU_SOURCE
#include stdio.h
#include fcntl.h
#include unistd.h
#include stdlib.h
#include stdbool.h
#include sys/types.h
#include signal.h
#include sys/time.h
#include sys/syscall.h
#include sys/socket.h
#include sys/un.h
#include stdarg.h

#define USEC_PER_SEC 100ULL

static long get_cguest_time(const char *buffer)
{
const char *ptr;
int space_count;

for (ptr = buffer; *ptr  space_count != 42; ptr++) {
if (*ptr == ' ') {
space_count++;
}
}

return strtol(ptr, NULL, 10);
}

static void tv_add(struct timeval *tv, suseconds_t usec)
{
tv-tv_usec += usec;

while (tv-tv_usec  USEC_PER_SEC) {
tv-tv_sec += 1;
tv-tv_usec -= USEC_PER_SEC;
}
}

static int tv_cmp(struct timeval *lhs, struct timeval *rhs)
{
if (lhs-tv_sec == rhs-tv_sec) {
if (lhs-tv_usec  rhs-tv_usec) {
return -1;
} else if (lhs-tv_usec  rhs-tv_usec) {
return 1;
}
return 0;
} else if (lhs-tv_sec  rhs-tv_sec) {
return -1;
} else if (lhs-tv_sec  rhs-tv_sec) {
return 1;
}
return 0;
}

static void write_all(int fd, const void *buffer, size_t buffer_len)
{
size_t offset = 0;

while (offset  buffer_len) {
ssize_t len;

len = write(fd, buffer + 

[Qemu-devel] Re: [PATCH] qemu-kvm: introduce cpu_start/cpu_stop commands

2010-11-22 Thread Chris Wright
* Anthony Liguori (aligu...@us.ibm.com) wrote:
 qemu-kvm vcpu threads don't response to SIGSTOP/SIGCONT.  Instead of teaching
 them to respond to these signals, introduce monitor commands that stop and 
 start
 individual vcpus.

In the past SIGSTOP has introduced time skew.  Have you verified this
isn't an issue.

thanks,
-chris



[Qemu-devel] [PATCH 7/7] tcg-ia64: Fix warning in qemu_ld.

2010-11-22 Thread Richard Henderson
The usermode version of qemu_ld doesn't used mem_index,
leading to set-but-not-used warnings.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/ia64/tcg-target.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/tcg/ia64/tcg-target.c b/tcg/ia64/tcg-target.c
index 57d0bcc..3ddf434 100644
--- a/tcg/ia64/tcg-target.c
+++ b/tcg/ia64/tcg-target.c
@@ -1658,11 +1658,10 @@ static inline void tcg_out_qemu_ld(TCGContext *s, const 
TCGArg *args, int opc)
 static uint64_t const opc_sxt_i29[4] = {
 OPC_SXT1_I29, OPC_SXT2_I29, OPC_SXT4_I29, 0
 };
-int addr_reg, data_reg, mem_index, s_bits, bswap;
+int addr_reg, data_reg, s_bits, bswap;
 
 data_reg = *args++;
 addr_reg = *args++;
-mem_index = *args;
 s_bits = opc  3;
 
 #ifdef TARGET_WORDS_BIGENDIAN
-- 
1.7.2.3




[Qemu-devel] [PATCH 5/7] tcg-ia64: Fix tlb read error for 32-bit targets.

2010-11-22 Thread Richard Henderson
Use ld4 not ld8 for reading the tlb of 32-bit targets.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/ia64/tcg-target.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/tcg/ia64/tcg-target.c b/tcg/ia64/tcg-target.c
index 62f0804..da81f1b 100644
--- a/tcg/ia64/tcg-target.c
+++ b/tcg/ia64/tcg-target.c
@@ -1459,7 +1459,9 @@ static inline void tcg_out_qemu_tlb(TCGContext *s, TCGArg 
addr_reg,
tcg_opc_a1 (TCG_REG_P0, OPC_ADD_A1, TCG_REG_R2,
TCG_REG_R2, TCG_AREG0));
 tcg_out_bundle(s, mII,
-   tcg_opc_m3 (TCG_REG_P0, OPC_LD8_M3, TCG_REG_R57,
+   tcg_opc_m3 (TCG_REG_P0,
+   (TARGET_LONG_BITS == 32
+? OPC_LD4_M3 : OPC_LD8_M3), TCG_REG_R57,
TCG_REG_R2, offset_addend - offset_rw),
tcg_opc_a1 (TCG_REG_P0, OPC_AND_A1, TCG_REG_R3,
TCG_REG_R3, TCG_REG_R56),
-- 
1.7.2.3




[Qemu-devel] [PATCH 3/7] tcg-ia64: Provide default GUEST_BASE.

2010-11-22 Thread Richard Henderson
Fix compilation error when GUEST_BASE is not defined.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/ia64/tcg-target.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/tcg/ia64/tcg-target.c b/tcg/ia64/tcg-target.c
index a0f3877..80c6950 100644
--- a/tcg/ia64/tcg-target.c
+++ b/tcg/ia64/tcg-target.c
@@ -45,6 +45,9 @@ static const char * const 
tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
 #else
 #define TCG_GUEST_BASE_REG TCG_REG_R0
 #endif
+#ifndef GUEST_BASE
+#define GUEST_BASE 0
+#endif
 
 /* Branch registers */
 enum {
-- 
1.7.2.3




[Qemu-devel] [PATCH 0/7] Fixes for ia64-linux host

2010-11-22 Thread Richard Henderson
Three compilation errors, one tcg_abort, two code-generation errors, and
one warning fix.  Though for the most part I'm using --disable-werror
until the code base is generally fixed up for gcc 4.6.

I don't know if Aurelien is still active or not, but I've cc'd him anyway.
Hopefully the ia64 bits are simple enough that anyone can look at them
and approve them...


r~



Richard Henderson (7):
  microblaze: target-ify target_ucontext
  tcg: Fix default definition of divu_i32 and remu_i32.
  tcg-ia64: Provide default GUEST_BASE.
  tcg-ia64: Implement qemu_ld32.
  tcg-ia64: Fix tlb read error for 32-bit targets.
  tcg-ia64: Fix address compilation in qemu_st.
  tcg-ia64: Fix warning in qemu_ld.

 linux-user/signal.c   |   18 +-
 tcg/ia64/tcg-target.c |   13 +
 tcg/tcg-op.h  |4 ++--
 3 files changed, 20 insertions(+), 15 deletions(-)

-- 
1.7.2.3




[Qemu-devel] [PATCH 1/7] microblaze: target-ify target_ucontext

2010-11-22 Thread Richard Henderson
From: Richard Henderson r...@redhat.com

Rename the members of target_ucontext so that they don't conflict
with possible host macros for ucontext members.  This has already
been done for the other targets.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 linux-user/signal.c |   18 +-
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 77683f7..7c62fac 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -3071,11 +3071,11 @@ struct target_stack_t {
 };
 
 struct target_ucontext {
-abi_ulong uc_flags;
-abi_ulong uc_link;
-struct target_stack_t uc_stack;
-struct target_sigcontext sc;
-uint32_t extramask[TARGET_NSIG_WORDS - 1];
+abi_ulong tuc_flags;
+abi_ulong tuc_link;
+struct target_stack_t tuc_stack;
+struct target_sigcontext tuc_mcontext;
+uint32_t tuc_extramask[TARGET_NSIG_WORDS - 1];
 };
 
 /* Signal frames. */
@@ -3189,7 +3189,7 @@ static void setup_frame(int sig, struct target_sigaction 
*ka,
 goto badframe;
 
 /* Save the mask.  */
-err |= __put_user(set-sig[0], frame-uc.sc.oldmask);
+err |= __put_user(set-sig[0], frame-uc.tuc_mcontext.oldmask);
 if (err)
 goto badframe;
 
@@ -3198,7 +3198,7 @@ static void setup_frame(int sig, struct target_sigaction 
*ka,
 goto badframe;
 }
 
-setup_sigcontext(frame-uc.sc, env);
+setup_sigcontext(frame-uc.tuc_mcontext, env);
 
 /* Set up to return from userspace. If provided, use a stub
already in userspace. */
@@ -3261,7 +3261,7 @@ long do_sigreturn(CPUState *env)
 goto badframe;
 
 /* Restore blocked signals */
-if (__get_user(target_set.sig[0], frame-uc.sc.oldmask))
+if (__get_user(target_set.sig[0], frame-uc.tuc_mcontext.oldmask))
 goto badframe;
 for(i = 1; i  TARGET_NSIG_WORDS; i++) {
 if (__get_user(target_set.sig[i], frame-extramask[i - 1]))
@@ -3270,7 +3270,7 @@ long do_sigreturn(CPUState *env)
 target_to_host_sigset_internal(set, target_set);
 sigprocmask(SIG_SETMASK, set, NULL);
 
-restore_sigcontext(frame-uc.sc, env);
+restore_sigcontext(frame-uc.tuc_mcontext, env);
 /* We got here through a sigreturn syscall, our path back is via an
rtb insn so setup r14 for that.  */
 env-regs[14] = env-sregs[SR_PC];
-- 
1.7.2.3




[Qemu-devel] [PATCH 4/7] tcg-ia64: Implement qemu_ld32.

2010-11-22 Thread Richard Henderson
The port was not properly merged following
86feb1c860dc38e9c89e787c5210e8191800385e

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/ia64/tcg-target.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tcg/ia64/tcg-target.c b/tcg/ia64/tcg-target.c
index 80c6950..62f0804 100644
--- a/tcg/ia64/tcg-target.c
+++ b/tcg/ia64/tcg-target.c
@@ -2124,6 +2124,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode 
opc,
 case INDEX_op_qemu_ld16s:
 tcg_out_qemu_ld(s, args, 1 | 4);
 break;
+case INDEX_op_qemu_ld32:
 case INDEX_op_qemu_ld32u:
 tcg_out_qemu_ld(s, args, 2);
 break;
-- 
1.7.2.3




[Qemu-devel] [PATCH 2/7] tcg: Fix default definition of divu_i32 and remu_i32.

2010-11-22 Thread Richard Henderson
From: Richard Henderson r...@redhat.com

The arguments to tcg_gen_helper32 for these functions were not
updated correctly in rev 2bece2c88331f024a46527634e3dd91c71d22141.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/tcg-op.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h
index c68927e..3ee0a58 100644
--- a/tcg/tcg-op.h
+++ b/tcg/tcg-op.h
@@ -727,7 +727,7 @@ static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 
arg1, TCGv_i32 arg2)
 sizemask |= tcg_gen_sizemask(1, 0, 0);
 sizemask |= tcg_gen_sizemask(2, 0, 0);
 
-tcg_gen_helper32(tcg_helper_divu_i32, ret, arg1, arg2, 0);
+tcg_gen_helper32(tcg_helper_divu_i32, sizemask, ret, arg1, arg2);
 }
 
 static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
@@ -738,7 +738,7 @@ static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 
arg1, TCGv_i32 arg2)
 sizemask |= tcg_gen_sizemask(1, 0, 0);
 sizemask |= tcg_gen_sizemask(2, 0, 0);
 
-tcg_gen_helper32(tcg_helper_remu_i32, ret, arg1, arg2, 0);
+tcg_gen_helper32(tcg_helper_remu_i32, sizemask, ret, arg1, arg2);
 }
 #endif
 
-- 
1.7.2.3




[Qemu-devel] [PATCH 6/7] tcg-ia64: Fix address compilation in qemu_st.

2010-11-22 Thread Richard Henderson
A typo in the usermode address calculation path; R3 used where R2 needed.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/ia64/tcg-target.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tcg/ia64/tcg-target.c b/tcg/ia64/tcg-target.c
index da81f1b..57d0bcc 100644
--- a/tcg/ia64/tcg-target.c
+++ b/tcg/ia64/tcg-target.c
@@ -1818,7 +1818,7 @@ static inline void tcg_out_qemu_st(TCGContext *s, const 
TCGArg *args, int opc)
 tcg_out_bundle(s, miI,
tcg_opc_m48(TCG_REG_P0, OPC_NOP_M48, 0),
tcg_opc_i29(TCG_REG_P0, OPC_ZXT4_I29,
-   TCG_REG_R3, addr_reg),
+   TCG_REG_R2, addr_reg),
tcg_opc_i18(TCG_REG_P0, OPC_NOP_I18, 0));
 }
 
-- 
1.7.2.3




[Qemu-devel] Re: [PATCH] qemu-kvm: introduce cpu_start/cpu_stop commands

2010-11-22 Thread Anthony Liguori

On 11/22/2010 05:04 PM, Chris Wright wrote:

* Anthony Liguori (aligu...@us.ibm.com) wrote:
   

qemu-kvm vcpu threads don't response to SIGSTOP/SIGCONT.  Instead of teaching
them to respond to these signals, introduce monitor commands that stop and start
individual vcpus.
 

In the past SIGSTOP has introduced time skew.  Have you verified this
isn't an issue.
   


Time skew is a big topic.  Are you talking about TSC drift, pit/rtc/hpet 
drift, etc?


It's certainly going to stress periodic interrupt catch up code.

Regards,

Anthony Liguori


thanks,
-chris
   





[Qemu-devel] Re: [PATCH] qemu-kvm: introduce cpu_start/cpu_stop commands

2010-11-22 Thread Chris Wright
* Anthony Liguori (aligu...@linux.vnet.ibm.com) wrote:
 On 11/22/2010 05:04 PM, Chris Wright wrote:
 * Anthony Liguori (aligu...@us.ibm.com) wrote:
 qemu-kvm vcpu threads don't response to SIGSTOP/SIGCONT.  Instead of 
 teaching
 them to respond to these signals, introduce monitor commands that stop and 
 start
 individual vcpus.
 In the past SIGSTOP has introduced time skew.  Have you verified this
 isn't an issue.
 
 Time skew is a big topic.  Are you talking about TSC drift,
 pit/rtc/hpet drift, etc?

Sorry to be vague, but it's been long enough that I don't recall
the details.  The guest kernel's clocksource effected how timekeeping
progressed across STOP/CONT (was probably missing qemu based timer ticks).
While this is not the same, made me wonder if you'd tested against that.

 It's certainly going to stress periodic interrupt catch up code.

Heh, call it a feature for autotest ;)

thanks,
-chris



[Qemu-devel] Re: [PATCH] qemu-kvm: introduce cpu_start/cpu_stop commands

2010-11-22 Thread Anthony Liguori

On 11/22/2010 05:56 PM, Chris Wright wrote:

* Anthony Liguori (aligu...@linux.vnet.ibm.com) wrote:
   

On 11/22/2010 05:04 PM, Chris Wright wrote:
 

* Anthony Liguori (aligu...@us.ibm.com) wrote:
   

qemu-kvm vcpu threads don't response to SIGSTOP/SIGCONT.  Instead of teaching
them to respond to these signals, introduce monitor commands that stop and start
individual vcpus.
 

In the past SIGSTOP has introduced time skew.  Have you verified this
isn't an issue.
   

Time skew is a big topic.  Are you talking about TSC drift,
pit/rtc/hpet drift, etc?
 

Sorry to be vague, but it's been long enough that I don't recall
the details.  The guest kernel's clocksource effected how timekeeping
progressed across STOP/CONT (was probably missing qemu based timer ticks).
While this is not the same, made me wonder if you'd tested against that.
   


Yeah, it's definitely going to increase the likelihood of interrupt 
coalescing but only as much as a contended CPU would already.


QEMU will keep getting timer ticks but the guest won't process them in a 
timely fashion.



It's certainly going to stress periodic interrupt catch up code.
 

Heh, call it a feature for autotest ;)
   


Excellent idea :-)

Regards,

Anthony Liguori


thanks,
-chris
   





[Qemu-devel] [Bug 427612] Re: kvm sends caps lock key up event twice

2010-11-22 Thread Benjamin Drung
Attached the patch for qemu-kvm 0.13. This patch is tested on natty with
qemu-kvm 0.13.0+noroms-0ubuntu7 and the German and NEO2 keyboard layout.

** Patch added: caps-lock-key-up-event.patch
   
https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/427612/+attachment/1742131/+files/caps-lock-key-up-event.patch

** Changed in: qemu
   Status: Invalid = New

-- 
kvm sends caps lock key up event twice
https://bugs.launchpad.net/bugs/427612
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: New
Status in “libsdl1.2” package in Ubuntu: Invalid
Status in “qemu-kvm” package in Ubuntu: New
Status in “libsdl1.2” package in Debian: Fix Released

Bug description:
Binary package hint: qemu-kvm

I have set the keyboard layout to German NEO 2 [1] in the host and the client 
(both current karmic). The caps lock is used as modifier (similar to shift) in 
NEO. When I press caps lock + t, then the client prints a t instead of a 
-. A caps lock key up event is sent to the client before I release the caps 
lock key.

[1] http://www.neo-layout.org/

ProblemType: Bug
Architecture: amd64
Date: Fri Sep 11 01:38:58 2009
DistroRelease: Ubuntu 9.10
KvmCmdLine: Error: command ['ps', '-C', 'kvm', '-F'] failed with exit code 1: 
UIDPID  PPID  CSZ   RSS PSR STIME TTY  TIME CMD
Package: qemu-kvm 0.11.0~rc2-0ubuntu2
PccardctlIdent:

PccardctlStatus:

ProcCmdLine: BOOT_IMAGE=/boot/vmlinuz-2.6.31-10-generic 
root=UUID=37b01f5a-a578-49d6-a812-f166b103e68a ro quiet splash
ProcEnviron:
 LANG=de_DE.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-10.31-generic
SourcePackage: qemu-kvm
Uname: Linux 2.6.31-10-generic x86_64
dmi.bios.date: 07/15/2009
dmi.bios.vendor: Intel Corp.
dmi.bios.version: DPP3510J.86A.0572.2009.0715.2346
dmi.board.asset.tag: Base Board Asset Tag
dmi.board.name: DG33TL
dmi.board.vendor: Intel Corporation
dmi.board.version: AAD89517-802
dmi.chassis.type: 3
dmi.modalias: 
dmi:bvnIntelCorp.:bvrDPP3510J.86A.0572.2009.0715.2346:bd07/15/2009:svn:pn:pvr:rvnIntelCorporation:rnDG33TL:rvrAAD89517-802:cvn:ct3:cvr:







[Qemu-devel] [Bug 680350] [NEW] fail to compile qemu-kvm-0.13.0

2010-11-22 Thread liheyuan
Public bug reported:

Problem
During compile with qemu-kvm-0.13.0, can't successfully make through with error:
#make  make install
kvm-all.o: In function `kvm_run':
/home/liheyuan/code/qemu-kvm-0.13.0/qemu-kvm.c:675: undefined reference to 
`kvm_handle_internal_error'
collect2: ld returned 1 exit status

Cause
The developer using an new ‘macro definition’:KVM_CAP_INTERNAL_ERROR_DATA, but 
fail to add it to every places it needed.

Solution
modify qemu-kvm.c, line:674,add the ‘macro definition’ before and after the 
‘case:’, as follows

#line674~~677  should be replace like this:
#ifdef KVM_CAP_INTERNAL_ERROR_DATA
case KVM_EXIT_INTERNAL_ERROR:
kvm_handle_internal_error(env, run);
r = 1;
break;
#endif

For more details at, http://www.coder4.com/archives/1174

** Affects: qemu
 Importance: Undecided
 Status: New


** Tags: 0.13.0 qmeu-kvm

-- 
fail to compile qemu-kvm-0.13.0
https://bugs.launchpad.net/bugs/680350
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: New

Bug description:
Problem
During compile with qemu-kvm-0.13.0, can't successfully make through with error:
#make  make install
kvm-all.o: In function `kvm_run':
/home/liheyuan/code/qemu-kvm-0.13.0/qemu-kvm.c:675: undefined reference to 
`kvm_handle_internal_error'
collect2: ld returned 1 exit status

Cause
The developer using an new ‘macro definition’:KVM_CAP_INTERNAL_ERROR_DATA, but 
fail to add it to every places it needed.

Solution
modify qemu-kvm.c, line:674,add the ‘macro definition’ before and after the 
‘case:’, as follows

#line674~~677  should be replace like this:
#ifdef KVM_CAP_INTERNAL_ERROR_DATA
case KVM_EXIT_INTERNAL_ERROR:
kvm_handle_internal_error(env, run);
r = 1;
break;
#endif

For more details at, http://www.coder4.com/archives/1174





[Qemu-devel] [PATCH] correct migrate_set_speed's args_type

2010-11-22 Thread Wen Congyang
The args_type of migrate_set_speed in qmp-commands.hx is wrong.
When we set migrate speed by json, qemu will be core dumped.

Signed-off-by: Wen Congyang

---
 qmp-commands.hx |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/qmp-commands.hx b/qmp-commands.hx
index 793cf1c..16bdb08 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -495,7 +495,7 @@ EQMP
 
 {
 .name   = migrate_set_speed,
-.args_type  = value:f,
+.args_type  = value:o,
 .params = value,
 .help   = set maximum speed (in bytes) for migrations,
 .user_print = monitor_user_noop,
-- 
1.7.1



Re: [Qemu-devel] [PATCH] qemu-kvm: introduce cpu_start/cpu_stop commands

2010-11-22 Thread Avi Kivity

On 11/23/2010 01:00 AM, Anthony Liguori wrote:

qemu-kvm vcpu threads don't response to SIGSTOP/SIGCONT.  Instead of teaching
them to respond to these signals, introduce monitor commands that stop and start
individual vcpus.

The purpose of these commands are to implement CPU hard limits using an external
tool that watches the CPU consumption and stops the CPU as appropriate.

The monitor commands provide a more elegant solution that signals because it
ensures that a stopped vcpu isn't holding the qemu_mutex.



From signal(7):

  The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.

Perhaps this is a bug in kvm?

If we could catch SIGSTOP, then it would be easy to unblock it only 
while running in guest context. It would then stop on exit to userspace.


Using monitor commands is fairly heavyweight for something as high 
frequency as this.  What control period do you see people using?  Maybe 
we should define USR1 for vcpu start/stop.


What happens if one vcpu is stopped while another is running?  Spin 
loops, synchronous IPIs will take forever.  Maybe we need to stop the 
entire process.


--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.




Re: [Qemu-devel] Re: [PATCH] qemu-kvm: introduce cpu_start/cpu_stop commands

2010-11-22 Thread Avi Kivity

On 11/23/2010 01:04 AM, Chris Wright wrote:

* Anthony Liguori (aligu...@us.ibm.com) wrote:
  qemu-kvm vcpu threads don't response to SIGSTOP/SIGCONT.  Instead of teaching
  them to respond to these signals, introduce monitor commands that stop and 
start
  individual vcpus.

In the past SIGSTOP has introduced time skew.  Have you verified this
isn't an issue.


Wouldn't we have the same problems with kernel cpu limits?  I'd say it 
only depends on the period of the controller, not on how it's implemented.


--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.