Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify

2011-05-16 Thread andrzej zaborowski
On 16 May 2011 06:54, Dmitry Eremin-Solenikov  wrote:
> Hello,
>
> On 5/16/11, andrzej zaborowski  wrote:
>> On 25 April 2011 11:06, Dmitry Eremin-Solenikov 
>> wrote:
>>> Switch dscm1 microdrive driver to use qdev infrastructure.
>>> ---
>>>  hw/ide/microdrive.c |   49
>>> +++--
>>>  hw/pcmcia.h         |    2 +-
>>>  hw/spitz.c          |    5 -
>>>  hw/tosa.c           |    5 -
>>>  4 files changed, 48 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
>>> index 9fbbf0e..7692603 100644
>>> --- a/hw/ide/microdrive.c
>>> +++ b/hw/ide/microdrive.c
>>> @@ -38,8 +38,8 @@
>>>
>>>  /* DSCM-1 Microdrive hard disk with CF+ II / PCMCIA interface.  */
>>>  typedef struct {
>>> -    IDEBus bus;
>>>     PCMCIACardState card;
>>> +    IDEBus bus;
>>>     uint32_t attr_base;
>>>     uint32_t io_base;
>>>
>>> @@ -529,22 +529,51 @@ static int dscm1_detach(void *opaque)
>>>     return 0;
>>>  }
>>>
>>> -PCMCIACardState *dscm1_init(DriveInfo *bdrv)
>>> +PCMCIACardState *dscm1_init(PCMCIASocket *socket, DriveInfo *bdrv)
>>
>> This looks like a regression that you have to pass the socket when
>> creating a PCMCIA card.  I consider it an advantage of the current
>> code that pcmcia cards are hotswappable.  Can we keep that with
>> qdevification?  Otherwise is there a gain from the qdevification?
>
> Socket is required, as we have to know the QBus before creating the
> device on it.

Let's skip the qbusification then.  It seems that qbus is a wrong
choice for pcmcia and there are no new features or bugs fixed by the
conversion, it's code motion?  I also don't see why the socket
structure should be needed at the creation time of a PCI device for
example, the BusInfo should be enough logically.

Cheers



[Qemu-devel] [PATCH] qed: support for growing images

2011-05-16 Thread Stefan Hajnoczi
The .bdrv_truncate() operation resizes images and growing is easy to
implement in QED.  Simply check that the new size is valid and then
update the image_size header field to reflect the new size.

Signed-off-by: Stefan Hajnoczi 
---
 block/qed.c |   22 +-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/block/qed.c b/block/qed.c
index c8c5930..bfb49d9 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1233,7 +1233,27 @@ static BlockDriverAIOCB 
*bdrv_qed_aio_flush(BlockDriverState *bs,
 
 static int bdrv_qed_truncate(BlockDriverState *bs, int64_t offset)
 {
-return -ENOTSUP;
+BDRVQEDState *s = bs->opaque;
+uint64_t old_image_size;
+int ret;
+
+if (!qed_is_image_size_valid(offset, s->header.cluster_size,
+ s->header.table_size)) {
+return -EINVAL;
+}
+
+/* Shrinking is currently not supported */
+if ((uint64_t)offset < s->header.image_size) {
+return -ENOTSUP;
+}
+
+old_image_size = s->header.image_size;
+s->header.image_size = offset;
+ret = qed_write_header_sync(s);
+if (ret < 0) {
+s->header.image_size = old_image_size;
+}
+return ret;
 }
 
 static int64_t bdrv_qed_getlength(BlockDriverState *bs)
-- 
1.7.4.4




[Qemu-devel] [PATCH][qemu-iotests] add qed support to 025 image resize test

2011-05-16 Thread Stefan Hajnoczi
QED now supports the truncate (aka resize) operation for growing images.
Update test 025 so it runs for QED.

Signed-off-by: Stefan Hajnoczi 
---
 025 |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/025 b/025
index 691b6da..7062aa6 100755
--- a/025
+++ b/025
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 . ./common.pattern
 
-_supported_fmt raw qcow2
+_supported_fmt raw qcow2 qed
 _supported_proto file sheepdog rbd
 _supported_os Linux
 
-- 
1.7.4.4




[Qemu-devel] [PATCH v4 6/6] block: Remove type hint, it's guest matter, doesn't belong here

2011-05-16 Thread Markus Armbruster
No users of bdrv_get_type_hint() left.  bdrv_set_type_hint() can make
the media removable by side effect.  Make that explicit.

Signed-off-by: Markus Armbruster 
---
 block.c |   12 
 block.h |5 -
 block_int.h |1 -
 blockdev.c  |4 ++--
 4 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/block.c b/block.c
index 9de7450..effa86f 100644
--- a/block.c
+++ b/block.c
@@ -1305,13 +1305,6 @@ void bdrv_set_geometry_hint(BlockDriverState *bs,
 bs->secs = secs;
 }
 
-void bdrv_set_type_hint(BlockDriverState *bs, int type)
-{
-bs->type = type;
-bs->removable = ((type == BDRV_TYPE_CDROM ||
-  type == BDRV_TYPE_FLOPPY));
-}
-
 void bdrv_set_translation_hint(BlockDriverState *bs, int translation)
 {
 bs->translation = translation;
@@ -1428,11 +1421,6 @@ void bdrv_get_floppy_geometry_hint(BlockDriverState *bs, 
int *nb_heads,
 }
 }
 
-int bdrv_get_type_hint(BlockDriverState *bs)
-{
-return bs->type;
-}
-
 int bdrv_get_translation_hint(BlockDriverState *bs)
 {
 return bs->translation;
diff --git a/block.h b/block.h
index 52e9cad..da7d39c 100644
--- a/block.h
+++ b/block.h
@@ -152,9 +152,6 @@ int bdrv_has_zero_init(BlockDriverState *bs);
 int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
int *pnum);
 
-#define BDRV_TYPE_HD 0
-#define BDRV_TYPE_CDROM  1
-#define BDRV_TYPE_FLOPPY 2
 #define BIOS_ATA_TRANSLATION_AUTO   0
 #define BIOS_ATA_TRANSLATION_NONE   1
 #define BIOS_ATA_TRANSLATION_LBA2
@@ -163,7 +160,6 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t 
sector_num, int nb_sectors,
 
 void bdrv_set_geometry_hint(BlockDriverState *bs,
 int cyls, int heads, int secs);
-void bdrv_set_type_hint(BlockDriverState *bs, int type);
 void bdrv_set_translation_hint(BlockDriverState *bs, int translation);
 void bdrv_get_geometry_hint(BlockDriverState *bs,
 int *pcyls, int *pheads, int *psecs);
@@ -177,7 +173,6 @@ typedef enum FDriveType {
 void bdrv_get_floppy_geometry_hint(BlockDriverState *bs, int *nb_heads,
int *max_track, int *last_sect,
FDriveType drive_in, FDriveType *drive);
-int bdrv_get_type_hint(BlockDriverState *bs);
 int bdrv_get_translation_hint(BlockDriverState *bs);
 void bdrv_set_on_error(BlockDriverState *bs, BlockErrorAction on_read_error,
BlockErrorAction on_write_error);
diff --git a/block_int.h b/block_int.h
index 545ad11..fa91337 100644
--- a/block_int.h
+++ b/block_int.h
@@ -194,7 +194,6 @@ struct BlockDriverState {
 /* NOTE: the following infos are only hints for real hardware
drivers. They are not used by the block driver */
 int cyls, heads, secs, translation;
-int type;
 BlockErrorAction on_read_error, on_write_error;
 char device_name[32];
 unsigned long *dirty_bitmap;
diff --git a/blockdev.c b/blockdev.c
index 28727df..6e0eb83 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -487,7 +487,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
 }
break;
case MEDIA_CDROM:
-bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM);
+bdrv_set_removable(dinfo->bdrv, 1);
 dinfo->media_cd = 1;
break;
}
@@ -496,7 +496,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
 /* FIXME: This isn't really a floppy, but it's a reasonable
approximation.  */
 case IF_FLOPPY:
-bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY);
+bdrv_set_removable(dinfo->bdrv, 1);
 break;
 case IF_PFLASH:
 case IF_MTD:
-- 
1.7.2.3




[Qemu-devel] [PATCH v4 4/6] block QMP: Deprecate query-block's "type", drop info block's "type="

2011-05-16 Thread Markus Armbruster
query-block's specification documents response member "type" with
values "hd", "cdrom", "floppy", "unknown".

Its value is unreliable: a block device used as floppy has type
"floppy" if created with if=floppy, but type "hd" if created with
if=none.

That's because with if=none, the type is at best a declaration of
intent: the drive can be connected to any guest device.  Its type is
really the guest device's business.  Reporting it here is wrong.

No known user of QMP uses "type".  It's unlikely that any unknown
users exist, because its value is useless unless you know how the
block device was created.  But then you also know the true value.

Fixing the broken value risks breaking (hypothetical!) clients that
somehow rely on the current behavior.  Not fixing the value risks
breaking (hypothetical!) clients that rely on the value to be
accurate.  Can't entirely avoid hypothetical lossage.  Change the
value to be always "unknown".

This makes "info block" always report "type=unknown".  Pointless.
Change it to not report the type.

Signed-off-by: Markus Armbruster 
---
 block.c |   20 +++-
 qmp-commands.hx |   11 ++-
 2 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/block.c b/block.c
index f403718..9de7450 100644
--- a/block.c
+++ b/block.c
@@ -1704,9 +1704,8 @@ static void bdrv_print_dict(QObject *obj, void *opaque)
 
 bs_dict = qobject_to_qdict(obj);
 
-monitor_printf(mon, "%s: type=%s removable=%d",
+monitor_printf(mon, "%s: removable=%d",
 qdict_get_str(bs_dict, "device"),
-qdict_get_str(bs_dict, "type"),
 qdict_get_bool(bs_dict, "removable"));
 
 if (qdict_get_bool(bs_dict, "removable")) {
@@ -1747,23 +1746,10 @@ void bdrv_info(Monitor *mon, QObject **ret_data)
 
 QTAILQ_FOREACH(bs, &bdrv_states, list) {
 QObject *bs_obj;
-const char *type = "unknown";
-
-switch(bs->type) {
-case BDRV_TYPE_HD:
-type = "hd";
-break;
-case BDRV_TYPE_CDROM:
-type = "cdrom";
-break;
-case BDRV_TYPE_FLOPPY:
-type = "floppy";
-break;
-}
 
-bs_obj = qobject_from_jsonf("{ 'device': %s, 'type': %s, "
+bs_obj = qobject_from_jsonf("{ 'device': %s, 'type': 'unknown', "
 "'removable': %i, 'locked': %i }",
-bs->device_name, type, bs->removable,
+bs->device_name, bs->removable,
 bs->locked);
 
 if (bs->drv) {
diff --git a/qmp-commands.hx b/qmp-commands.hx
index fbd98ee..a9f109a 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1039,7 +1039,8 @@ Each json-object contain the following:
 
 - "device": device name (json-string)
 - "type": device type (json-string)
- - Possible values: "hd", "cdrom", "floppy", "unknown"
+ - deprecated, retained for backward compatibility
+ - Possible values: "unknown"
 - "removable": true if the device is removable, false otherwise (json-bool)
 - "locked": true if the device is locked, false otherwise (json-bool)
 - "inserted": only present if the device is inserted, it is a json-object
@@ -1070,25 +1071,25 @@ Example:
"encrypted":false,
"file":"disks/test.img"
 },
-"type":"hd"
+"type":"unknown"
  },
  {
 "device":"ide1-cd0",
 "locked":false,
 "removable":true,
-"type":"cdrom"
+"type":"unknown"
  },
  {
 "device":"floppy0",
 "locked":false,
 "removable":true,
-"type": "floppy"
+"type":"unknown"
  },
  {
 "device":"sd0",
 "locked":false,
 "removable":true,
-"type":"floppy"
+"type":"unknown"
  }
   ]
}
-- 
1.7.2.3




[Qemu-devel] [PATCH v4 5/6] blockdev: Store -drive option media in DriveInfo

2011-05-16 Thread Markus Armbruster
DriveInfo is closely tied to -drive, and like -drive, it mixes
information about host and guest part of the block device.  Unlike
DriveInfo, BlockDriverState should be about the host part only.

One of the remaining guest bits there is the "type hint".  -drive
option media sets it, and qdevs "ide-drive", "scsi-disk" and non-qdev
IF_XEN devices check it to pick HD vs. CD.

Communicate -drive option media via new DriveInfo member media_cd
instead.

Signed-off-by: Markus Armbruster 
---
 blockdev.c |1 +
 blockdev.h |1 +
 hw/ide/core.c  |3 +--
 hw/ide/qdev.c  |   10 --
 hw/scsi-disk.c |5 +++--
 hw/xen_devconfig.c |2 +-
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 5429621..28727df 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -488,6 +488,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
break;
case MEDIA_CDROM:
 bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM);
+dinfo->media_cd = 1;
break;
}
 break;
diff --git a/blockdev.h b/blockdev.h
index 2c9e780..3587786 100644
--- a/blockdev.h
+++ b/blockdev.h
@@ -33,6 +33,7 @@ struct DriveInfo {
 int bus;
 int unit;
 int auto_del;   /* see blockdev_mark_auto_del() */
+int media_cd;
 QemuOpts *opts;
 char serial[BLOCK_SERIAL_STRLEN + 1];
 QTAILQ_ENTRY(DriveInfo) next;
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 542ed65..45410e8 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -1731,8 +1731,7 @@ void ide_init2_with_non_qdev_drives(IDEBus *bus, 
DriveInfo *hd0,
 ide_init1(bus, i);
 if (dinfo) {
 if (ide_init_drive(&bus->ifs[i], dinfo->bdrv,
-   bdrv_get_type_hint(dinfo->bdrv) == 
BDRV_TYPE_CDROM ? IDE_CD : IDE_HD,
-   NULL,
+   dinfo->media_cd ? IDE_CD : IDE_HD, NULL,
*dinfo->serial ? dinfo->serial : NULL) < 0) {
 error_report("Can't set up IDE drive %s", dinfo->id);
 exit(1);
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 3bca726..3f9dc89 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -98,9 +98,7 @@ IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo 
*drive)
 {
 DeviceState *dev;
 
-dev = qdev_create(&bus->qbus,
-  bdrv_get_type_hint(drive->bdrv) == BDRV_TYPE_CDROM
-  ? "ide-cd" : "ide-hd");
+dev = qdev_create(&bus->qbus, drive->media_cd ? "ide-cd" : "ide-hd");
 qdev_prop_set_uint32(dev, "unit", unit);
 qdev_prop_set_drive_nofail(dev, "drive", drive->bdrv);
 qdev_init_nofail(dev);
@@ -165,9 +163,9 @@ static int ide_cd_initfn(IDEDevice *dev)
 
 static int ide_drive_initfn(IDEDevice *dev)
 {
-return ide_dev_initfn(dev,
-  bdrv_get_type_hint(dev->conf.bs) == BDRV_TYPE_CDROM
-  ? IDE_CD : IDE_HD);
+DriveInfo *dinfo = drive_get_by_blockdev(dev->conf.bs);
+
+return ide_dev_initfn(dev, dinfo->media_cd ? IDE_CD : IDE_HD);
 }
 
 #define DEFINE_IDE_DEV_PROPERTIES() \
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 8df8518..397b9d6 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1295,12 +1295,13 @@ static int scsi_cd_initfn(SCSIDevice *dev)
 static int scsi_disk_initfn(SCSIDevice *dev)
 {
 SCSIDriveKind kind;
+DriveInfo *dinfo;
 
 if (!dev->conf.bs) {
 kind = SCSI_HD; /* will die in scsi_initfn() */
 } else {
-kind = bdrv_get_type_hint(dev->conf.bs) == BDRV_TYPE_CDROM
-? SCSI_CD : SCSI_HD;
+dinfo = drive_get_by_blockdev(dev->conf.bs);
+kind = dinfo->media_cd ? SCSI_CD : SCSI_HD;
 }
 
 return scsi_initfn(dev, kind);
diff --git a/hw/xen_devconfig.c b/hw/xen_devconfig.c
index 8d50216..3a92155 100644
--- a/hw/xen_devconfig.c
+++ b/hw/xen_devconfig.c
@@ -96,7 +96,7 @@ int xen_config_dev_blk(DriveInfo *disk)
 {
 char fe[256], be[256];
 int vdev = 202 * 256 + 16 * disk->unit;
-int cdrom = disk->bdrv->type == BDRV_TYPE_CDROM;
+int cdrom = disk->media_cd;
 const char *devtype = cdrom ? "cdrom" : "disk";
 const char *mode= cdrom ? "r" : "w";
 
-- 
1.7.2.3




[Qemu-devel] [PATCH v4 2/6] scsi: Split qdev "scsi-disk" into "scsi-hd" and "scsi-cd"

2011-05-16 Thread Markus Armbruster
A "scsi-disk" is either a hard disk or a CD-ROM, depending on the
associated BlockDriverState's type hint.  Unclean; disk vs. CD belongs
to the guest part, not the host part.

Have separate qdevs "scsi-hd" and "scsi-cd" to model disk vs. CD in
the guest part.

Keep scsi-disk for backward compatibility.

Don't copy scsi-disk property removable to scsi-cd.  It's not used and
always zero(!) there.

Signed-off-by: Markus Armbruster 
---
 hw/scsi-disk.c |  136 ++--
 1 files changed, 103 insertions(+), 33 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index b05e654..8df8518 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -65,6 +65,8 @@ typedef struct SCSIDiskReq {
 uint32_t status;
 } SCSIDiskReq;
 
+typedef enum { SCSI_HD, SCSI_CD } SCSIDriveKind;
+
 struct SCSIDiskState
 {
 SCSIDevice qdev;
@@ -78,6 +80,7 @@ struct SCSIDiskState
 char *version;
 char *serial;
 SCSISense sense;
+SCSIDriveKind drive_kind;
 };
 
 static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type);
@@ -406,7 +409,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 return -1;
 }
 
-if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) {
+if (s->drive_kind == SCSI_CD) {
 outbuf[buflen++] = 5;
 } else {
 outbuf[buflen++] = 0;
@@ -424,7 +427,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 outbuf[buflen++] = 0x00; // list of supported pages (this page)
 outbuf[buflen++] = 0x80; // unit serial number
 outbuf[buflen++] = 0x83; // device identification
-if (bdrv_get_type_hint(s->bs) != BDRV_TYPE_CDROM) {
+if (s->drive_kind == SCSI_HD) {
 outbuf[buflen++] = 0xb0; // block limits
 outbuf[buflen++] = 0xb2; // thin provisioning
 }
@@ -477,7 +480,7 @@ 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) {
+if (s->drive_kind == SCSI_CD) {
 DPRINTF("Inquiry (EVPD[%02X] not supported for CDROM\n",
 page_code);
 return -1;
@@ -547,7 +550,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 return buflen;
 }
 
-if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) {
+if (s->drive_kind == SCSI_CD) {
 outbuf[0] = 5;
 outbuf[1] = 0x80;
 memcpy(&outbuf[16], "QEMU CD-ROM ", 16);
@@ -678,7 +681,7 @@ static int mode_sense_page(SCSIRequest *req, int page, 
uint8_t *p,
 return p[1] + 2;
 
 case 0x2a: /* CD Capabilities and Mechanical Status page. */
-if (bdrv_get_type_hint(bdrv) != BDRV_TYPE_CDROM)
+if (s->drive_kind != SCSI_CD)
 return 0;
 p[0] = 0x2a;
 p[1] = 0x14;
@@ -905,7 +908,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r, 
uint8_t *outbuf)
 goto illegal_request;
 break;
 case START_STOP:
-if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM && (req->cmd.buf[4] & 
2)) {
+if (s->drive_kind == SCSI_CD && (req->cmd.buf[4] & 2)) {
 /* load/eject medium */
 bdrv_eject(s->bs, !(req->cmd.buf[4] & 1));
 }
@@ -1232,10 +1235,9 @@ static void scsi_destroy(SCSIDevice *dev)
 blockdev_mark_auto_del(s->qdev.conf.bs);
 }
 
-static int scsi_disk_initfn(SCSIDevice *dev)
+static int scsi_initfn(SCSIDevice *dev, SCSIDriveKind kind)
 {
 SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
-int is_cd;
 DriveInfo *dinfo;
 
 if (!s->qdev.conf.bs) {
@@ -1243,9 +1245,9 @@ static int scsi_disk_initfn(SCSIDevice *dev)
 return -1;
 }
 s->bs = s->qdev.conf.bs;
-is_cd = bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM;
+s->drive_kind = kind;
 
-if (!is_cd && !bdrv_is_inserted(s->bs)) {
+if (kind == SCSI_HD && !bdrv_is_inserted(s->bs)) {
 error_report("Device needs media, but drive is empty");
 return -1;
 }
@@ -1265,7 +1267,7 @@ static int scsi_disk_initfn(SCSIDevice *dev)
 return -1;
 }
 
-if (is_cd) {
+if (kind == SCSI_CD) {
 s->qdev.blocksize = 2048;
 } else {
 s->qdev.blocksize = s->qdev.conf.logical_block_size;
@@ -1275,35 +1277,103 @@ static int scsi_disk_initfn(SCSIDevice *dev)
 
 s->qdev.type = TYPE_DISK;
 qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);
-bdrv_set_removable(s->bs, is_cd);
+bdrv_set_removable(s->bs, kind == SCSI_CD);
 add_boot_device_path(s->qdev.conf.bootindex, &dev->qdev, ",0");
 return 0;
 }
 
-static SCSIDeviceInfo scsi_disk_info = {
-.qdev.name= "scsi-disk",
-.qdev.fw_name = "disk",
-.qdev.desc= "virtual scsi disk or cdrom",

[Qemu-devel] [PATCH v4 3/6] defaults: ide-cd and scsi-cd devices suppress default CD-ROM

2011-05-16 Thread Markus Armbruster
ide-hd does *not* suppress the default CD-ROM, unlike legacy
ide-drive.

scsi-cd *does* suppress it, unlike legacy scsi-disk.

Signed-off-by: Markus Armbruster 
---
 vl.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/vl.c b/vl.c
index bffba69..e271c0b 100644
--- a/vl.c
+++ b/vl.c
@@ -279,7 +279,9 @@ static struct {
 { .driver = "isa-serial",   .flag = &default_serial},
 { .driver = "isa-parallel", .flag = &default_parallel  },
 { .driver = "isa-fdc",  .flag = &default_floppy},
+{ .driver = "ide-cd",   .flag = &default_cdrom },
 { .driver = "ide-drive",.flag = &default_cdrom },
+{ .driver = "scsi-cd",  .flag = &default_cdrom },
 { .driver = "virtio-serial-pci",.flag = &default_virtcon   },
 { .driver = "virtio-serial-s390",   .flag = &default_virtcon   },
 { .driver = "virtio-serial",.flag = &default_virtcon   },
-- 
1.7.2.3




[Qemu-devel] [PATCH v4 0/6] Split ide-drive and scsi-disk qdevs, and more

2011-05-16 Thread Markus Armbruster
This patch series is about purging the "type hint" from the block
layer.  My previous series cleaned up improper uses it.  Remaining
uses are info block and qdevs ide-drive, scsi-disk.

ide-drive and scsi-disk can either act as disk or as CD drive.  They
use their drive's type hint to decide between disk and CD.  This is
unclean.  Disk vs. CD needs to be in qdev, not BlockDriverState,
because it belongs to the drive's guest part.

Split them into separate devices for disk and CD.  Keep the old ones
for backward compatibility.

Remove the type hint from info block.  Its value is unreliable anyway.
libvirt doesn't use it.

I posted v1 quite some time ago.  Since we were working towards a
release then, we decided to take only the bonus bug fixes (PATCH 1-3),
and revisit the rest later.  Which has turned out to be "somewhat"
later than anticpiated.  Sorry about that.

v4:
* Trivially rebased
* Reordered again so that potentially controversial parts come later
  in the series
* Deprecate query-block's response member type instead of removing it

v3:
* Trivially rebased
* fix if=ide: ide_create_drive() got HD vs. CD backwards (one-liner)
* ide-cd and scsi-cd devices suppress default CD-ROM (PATCH 6/6)

v2:
* Rebased
* Review comments addressed
* Reordered so that potentially controversial parts come later in the
  series
* More verbose commit messages

v1: http://lists.gnu.org/archive/html/qemu-devel/2010-07/msg00304.html

Markus Armbruster (6):
  ide: Split qdev "ide-drive" into "ide-hd" and "ide-cd"
  scsi: Split qdev "scsi-disk" into "scsi-hd" and "scsi-cd"
  defaults: ide-cd and scsi-cd devices suppress default CD-ROM
  block QMP: Deprecate query-block's "type", drop info block's "type="
  blockdev: Store -drive option media in DriveInfo
  block: Remove type hint, it's guest matter, doesn't belong here

 block.c|   32 +---
 block.h|5 --
 block_int.h|1 -
 blockdev.c |5 +-
 blockdev.h |1 +
 hw/ide/core.c  |   10 ++--
 hw/ide/internal.h  |2 +-
 hw/ide/qdev.c  |   81 ---
 hw/scsi-disk.c |  137 +++-
 hw/xen_devconfig.c |2 +-
 qmp-commands.hx|   11 ++--
 vl.c   |2 +
 12 files changed, 191 insertions(+), 98 deletions(-)

-- 
1.7.2.3




[Qemu-devel] [PATCH v4 1/6] ide: Split qdev "ide-drive" into "ide-hd" and "ide-cd"

2011-05-16 Thread Markus Armbruster
An "ide-drive" is either a hard disk or a CD-ROM, depending on the
associated BlockDriverState's type hint.  Unclean; disk vs. CD belongs
to the guest part, not the host part.

Have separate qdevs "ide-hd" and "ide-cd" to model disk vs. CD in
the guest part.

Keep ide-drive for backward compatibility.

"ide-disk" would perhaps be a nicer name than "ide-hd", but there's
already "scsi-disk", which is like "ide-drive", and will be likewise
split in the next commit.  {ide,scsi}-{hd,cd} is the best consistent
set of names I could find within the backward compatibility
straightjacket.

Signed-off-by: Markus Armbruster 
---
 hw/ide/core.c |   11 --
 hw/ide/internal.h |2 +-
 hw/ide/qdev.c |   83 ++---
 3 files changed, 74 insertions(+), 22 deletions(-)

diff --git a/hw/ide/core.c b/hw/ide/core.c
index 90f553b..542ed65 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -1592,13 +1592,15 @@ void ide_bus_reset(IDEBus *bus)
 bus->dma->ops->reset(bus->dma);
 }
 
-int ide_init_drive(IDEState *s, BlockDriverState *bs,
+int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
const char *version, const char *serial)
 {
 int cylinders, heads, secs;
 uint64_t nb_sectors;
 
 s->bs = bs;
+s->drive_kind = kind;
+
 bdrv_get_geometry(bs, &nb_sectors);
 bdrv_guess_geometry(bs, &cylinders, &heads, &secs);
 if (cylinders < 1 || cylinders > 16383) {
@@ -1623,8 +1625,7 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs,
 s->smart_autosave = 1;
 s->smart_errors = 0;
 s->smart_selftest_count = 0;
-if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) {
-s->drive_kind = IDE_CD;
+if (kind == IDE_CD) {
 bdrv_set_change_cb(bs, cdrom_change_cb, s);
 bs->buffer_alignment = 2048;
 } else {
@@ -1729,7 +1730,9 @@ void ide_init2_with_non_qdev_drives(IDEBus *bus, 
DriveInfo *hd0,
 dinfo = i == 0 ? hd0 : hd1;
 ide_init1(bus, i);
 if (dinfo) {
-if (ide_init_drive(&bus->ifs[i], dinfo->bdrv, NULL,
+if (ide_init_drive(&bus->ifs[i], dinfo->bdrv,
+   bdrv_get_type_hint(dinfo->bdrv) == 
BDRV_TYPE_CDROM ? IDE_CD : IDE_HD,
+   NULL,
*dinfo->serial ? dinfo->serial : NULL) < 0) {
 error_report("Can't set up IDE drive %s", dinfo->id);
 exit(1);
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index aa198b6..c2b35ec 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -558,7 +558,7 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr);
 void ide_data_writel(void *opaque, uint32_t addr, uint32_t val);
 uint32_t ide_data_readl(void *opaque, uint32_t addr);
 
-int ide_init_drive(IDEState *s, BlockDriverState *bs,
+int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
const char *version, const char *serial);
 void ide_init2(IDEBus *bus, qemu_irq irq);
 void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 2bb5c27..3bca726 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -98,7 +98,9 @@ IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo 
*drive)
 {
 DeviceState *dev;
 
-dev = qdev_create(&bus->qbus, "ide-drive");
+dev = qdev_create(&bus->qbus,
+  bdrv_get_type_hint(drive->bdrv) == BDRV_TYPE_CDROM
+  ? "ide-cd" : "ide-hd");
 qdev_prop_set_uint32(dev, "unit", unit);
 qdev_prop_set_drive_nofail(dev, "drive", drive->bdrv);
 qdev_init_nofail(dev);
@@ -118,7 +120,7 @@ typedef struct IDEDrive {
 IDEDevice dev;
 } IDEDrive;
 
-static int ide_drive_initfn(IDEDevice *dev)
+static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
 {
 IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
 IDEState *s = bus->ifs + dev->unit;
@@ -134,7 +136,7 @@ static int ide_drive_initfn(IDEDevice *dev)
 }
 }
 
-if (ide_init_drive(s, dev->conf.bs, dev->version, serial) < 0) {
+if (ide_init_drive(s, dev->conf.bs, kind, dev->version, serial) < 0) {
 return -1;
 }
 
@@ -151,22 +153,69 @@ static int ide_drive_initfn(IDEDevice *dev)
 return 0;
 }
 
-static IDEDeviceInfo ide_drive_info = {
-.qdev.name  = "ide-drive",
-.qdev.fw_name  = "drive",
-.qdev.size  = sizeof(IDEDrive),
-.init   = ide_drive_initfn,
-.qdev.props = (Property[]) {
-DEFINE_PROP_UINT32("unit", IDEDrive, dev.unit, -1),
-DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf),
-DEFINE_PROP_STRING("ver",  IDEDrive, dev.version),
-DEFINE_PROP_STRING("serial",  IDEDrive, dev.serial),
-DEFINE_PROP_END_OF_LIST(),
+static int ide_hd_initfn(IDEDevice *dev)
+{
+return ide_dev_initfn(dev, IDE_HD);
+}
+
+static int ide_cd_initfn(IDEDevice *dev)
+{
+return ide_dev_initfn(dev, IDE_CD);
+}
+
+static int ide_driv

Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify

2011-05-16 Thread Dmitry Eremin-Solenikov
On 5/16/11, andrzej zaborowski  wrote:
> On 16 May 2011 06:54, Dmitry Eremin-Solenikov  wrote:
>> Hello,
>>
>> On 5/16/11, andrzej zaborowski  wrote:
>>> On 25 April 2011 11:06, Dmitry Eremin-Solenikov 
>>> wrote:
 Switch dscm1 microdrive driver to use qdev infrastructure.
 ---
  hw/ide/microdrive.c |   49
 +++--
  hw/pcmcia.h |2 +-
  hw/spitz.c  |5 -
  hw/tosa.c   |5 -
  4 files changed, 48 insertions(+), 13 deletions(-)

 diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
 index 9fbbf0e..7692603 100644
 --- a/hw/ide/microdrive.c
 +++ b/hw/ide/microdrive.c
 @@ -38,8 +38,8 @@

  /* DSCM-1 Microdrive hard disk with CF+ II / PCMCIA interface.  */
  typedef struct {
 -IDEBus bus;
 PCMCIACardState card;
 +IDEBus bus;
 uint32_t attr_base;
 uint32_t io_base;

 @@ -529,22 +529,51 @@ static int dscm1_detach(void *opaque)
 return 0;
  }

 -PCMCIACardState *dscm1_init(DriveInfo *bdrv)
 +PCMCIACardState *dscm1_init(PCMCIASocket *socket, DriveInfo *bdrv)
>>>
>>> This looks like a regression that you have to pass the socket when
>>> creating a PCMCIA card.  I consider it an advantage of the current
>>> code that pcmcia cards are hotswappable.  Can we keep that with
>>> qdevification?  Otherwise is there a gain from the qdevification?
>>
>> Socket is required, as we have to know the QBus before creating the
>> device on it.
>
> Let's skip the qbusification then.  It seems that qbus is a wrong
> choice for pcmcia and there are no new features or bugs fixed by the
> conversion, it's code motion?  I also don't see why the socket
> structure should be needed at the creation time of a PCI device for
> example, the BusInfo should be enough logically.

Major point for qbus'ification was ability to create PCMCIA devices from
command line/via other management tools. This would also allow us e.g.
to move microdrive driver to common ide parts, etc.

For creation of a DeviceState via qdev_create you need BusState (which
is a part of PCMCIASocket). Of course I can make one global QBus for
all PCMCIA devices and make some artificial hacks to attach/detach cards
to artificial sockets, but this seems like a hack.

-- 
With best wishes
Dmitry



[Qemu-devel] [PATCH] libcacard: add libcacard.la target

2011-05-16 Thread Alon Levy
No flag to configure is required. Instead, added a libcacard.la target that
is not built by default, only when requested explicitly via:

mkdir build
cd build
../configure
make libcacard.la
make install-libcacard

Uses libtool to do actual linking of object files and shared library, and
installing. Tested only under linux, but supposed to work on other systems as
well.

If libtool isn't found you get a message complaining about that, only at build
time (since it is not a default target I did not add a message at configure
time).

Note: please ignore the following warning message, it is harmless, and fixing
it would require using libtool to build trace-dtrace.lo which, since it isn't
built by gcc, I don't know how to do.

 *** Warning: Linking the shared library libcacard.la against the non-libtool
 *** objects  ../trace-dtrace.o is not portable!
---
 Makefile   |   17 +
 configure  |   12 +++-
 libcacard/Makefile |   38 ++
 3 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 2b0438c..0215307 100644
--- a/Makefile
+++ b/Makefile
@@ -119,6 +119,23 @@ version.o: $(SRC_PATH)/version.rc config-host.mak
 
 version-obj-$(CONFIG_WIN32) += version.o
 ##
+# Support building shared library libcacard
+
+.PHONY: libcacard.la install-libcacard
+ifeq ($(LIBTOOL),)
+libcacard.la:
+   @echo libtool is missing, please install and rerun configure
+
+install-libcacard:
+   @echo libtool is missing, please install and rerun configure
+else
+libcacard.la: $(GENERATED_HEADERS) $(oslib-obj-y) qemu-malloc.o 
qemu-timer-common.o $(trace-obj-y)
+   $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" 
TARGET_DIR="$*/" libcacard.la,)
+
+install-libcacard: libcacard.la
+   $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" 
TARGET_DIR="$*/" install-libcacard,)
+endif
+##
 
 qemu-img.o: qemu-img-cmds.h
 qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS)
diff --git a/configure b/configure
index 0627f1d..e62841e 100755
--- a/configure
+++ b/configure
@@ -1276,6 +1276,15 @@ if ! has $pkg_config; then
 fi
 
 ##
+# libtool probe
+
+if ! has libtool; then
+libtool=
+else
+libtool=libtool
+fi
+
+##
 # Sparse probe
 if test "$sparse" != "no" ; then
   if has cgcc; then
@@ -3060,6 +3069,7 @@ echo "AR=$ar" >> $config_host_mak
 echo "OBJCOPY=$objcopy" >> $config_host_mak
 echo "LD=$ld" >> $config_host_mak
 echo "WINDRES=$windres" >> $config_host_mak
+echo "LIBTOOL=$libtool" >> $config_host_mak
 echo "CFLAGS=$CFLAGS" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
@@ -3595,7 +3605,7 @@ if [ "$source_path" != `pwd` ]; then
 # out of tree build
 mkdir -p libcacard
 rm -f libcacard/Makefile
-ln -s "$source_path/libcacard/Makefile" libcacard/Makefile
+symlink "$source_path/libcacard/Makefile" libcacard/Makefile
 fi
 
 d=libuser
diff --git a/libcacard/Makefile b/libcacard/Makefile
index 1d34df0..3a5ad61 100644
--- a/libcacard/Makefile
+++ b/libcacard/Makefile
@@ -4,15 +4,45 @@
 
 $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard)
 
-QEMU_OBJS=$(addprefix ../, $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o 
qemu-timer-common.o)
+QEMU_TRACE_OBJS=$(addprefix ../,$(trace-obj-y))
+
+QEMU_BASE_OBJS=$(addprefix ../,$(oslib-obj-y) qemu-malloc.o 
qemu-timer-common.o)
+
+# objects linked against normal qemu binaries, not compiled with libtool
+QEMU_OBJS = $(QEMU_BASE_OBJS) $(QEMU_TRACE_OBJS)
+
+# objects linked into a shared library, built with libtool with -fPIC if 
required
+QEMU_BASE_OBJS_LIB=$(addsuffix .lo,$(basename $(QEMU_BASE_OBJS)))
+
+QEMU_OBJS_LIB = $(QEMU_BASE_OBJS_LIB) $(QEMU_TRACE_OBJS)
 
 QEMU_CFLAGS+=-I../
 
+libcacard.lib-y=$(addsuffix .lo,$(basename $(libcacard-y)))
+
 vscclient: $(libcacard-y) $(QEMU_OBJS) vscclient.o
-   $(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^,"  LINK  
$(TARGET_DIR)$@")
+   $(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^,"  LINK  $@")
+
+clean:
+   rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient libcacard.so *.lo 
.libs/* *.la
+   rm -Rf .libs
 
 all: vscclient
 
-clean:
-   rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient
+ifeq ($(LIBTOOL),)
+libcacard.la:
+   @echo libtool is missing, please install and rerun configure
+
+install-libcacard:
+   @echo libtool is missing, please install and rerun configure
+else
+$(libcacard.lib-y) $(QEMU_BASE_OBJS_LIB) : %.lo: %.c
+   $(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) 
$(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt CC 
$@")
+
+libcacard.la: $(libcacard.l

Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target

2011-05-16 Thread Anthony Liguori

On 05/16/2011 08:25 AM, Alon Levy wrote:

No flag to configure is required. Instead, added a libcacard.la target that
is not built by default, only when requested explicitly via:

mkdir build
cd build
../configure
make libcacard.la
make install-libcacard

Uses libtool to do actual linking of object files and shared library, and
installing. Tested only under linux, but supposed to work on other systems as
well.

If libtool isn't found you get a message complaining about that, only at build
time (since it is not a default target I did not add a message at configure
time).

Note: please ignore the following warning message, it is harmless, and fixing
it would require using libtool to build trace-dtrace.lo which, since it isn't
built by gcc, I don't know how to do.

  *** Warning: Linking the shared library libcacard.la against the non-libtool
  *** objects  ../trace-dtrace.o is not portable!


I don't think slipping in libtool like this is such a good idea.

Why do you need this target?

Isn't la just a static archive compiled with -fPIC?  Doesn't the whole 
code base need to be compiled with -fPIC then (and isn't the warning 
above a legitimate concern?).


Regards,

Anthony Liguori


---
  Makefile   |   17 +
  configure  |   12 +++-
  libcacard/Makefile |   38 ++
  3 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 2b0438c..0215307 100644
--- a/Makefile
+++ b/Makefile
@@ -119,6 +119,23 @@ version.o: $(SRC_PATH)/version.rc config-host.mak

  version-obj-$(CONFIG_WIN32) += version.o
  ##
+# Support building shared library libcacard
+
+.PHONY: libcacard.la install-libcacard
+ifeq ($(LIBTOOL),)
+libcacard.la:
+   @echo libtool is missing, please install and rerun configure
+
+install-libcacard:
+   @echo libtool is missing, please install and rerun configure
+else
+libcacard.la: $(GENERATED_HEADERS) $(oslib-obj-y) qemu-malloc.o 
qemu-timer-common.o $(trace-obj-y)
+   $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" 
TARGET_DIR="$*/" libcacard.la,)
+
+install-libcacard: libcacard.la
+   $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" 
TARGET_DIR="$*/" install-libcacard,)
+endif
+##

  qemu-img.o: qemu-img-cmds.h
  qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS)
diff --git a/configure b/configure
index 0627f1d..e62841e 100755
--- a/configure
+++ b/configure
@@ -1276,6 +1276,15 @@ if ! has $pkg_config; then
  fi

  ##
+# libtool probe
+
+if ! has libtool; then
+libtool=
+else
+libtool=libtool
+fi
+
+##
  # Sparse probe
  if test "$sparse" != "no" ; then
if has cgcc; then
@@ -3060,6 +3069,7 @@ echo "AR=$ar">>  $config_host_mak
  echo "OBJCOPY=$objcopy">>  $config_host_mak
  echo "LD=$ld">>  $config_host_mak
  echo "WINDRES=$windres">>  $config_host_mak
+echo "LIBTOOL=$libtool">>  $config_host_mak
  echo "CFLAGS=$CFLAGS">>  $config_host_mak
  echo "QEMU_CFLAGS=$QEMU_CFLAGS">>  $config_host_mak
  echo "QEMU_INCLUDES=$QEMU_INCLUDES">>  $config_host_mak
@@ -3595,7 +3605,7 @@ if [ "$source_path" != `pwd` ]; then
  # out of tree build
  mkdir -p libcacard
  rm -f libcacard/Makefile
-ln -s "$source_path/libcacard/Makefile" libcacard/Makefile
+symlink "$source_path/libcacard/Makefile" libcacard/Makefile
  fi

  d=libuser
diff --git a/libcacard/Makefile b/libcacard/Makefile
index 1d34df0..3a5ad61 100644
--- a/libcacard/Makefile
+++ b/libcacard/Makefile
@@ -4,15 +4,45 @@

  $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard)

-QEMU_OBJS=$(addprefix ../, $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o 
qemu-timer-common.o)
+QEMU_TRACE_OBJS=$(addprefix ../,$(trace-obj-y))
+
+QEMU_BASE_OBJS=$(addprefix ../,$(oslib-obj-y) qemu-malloc.o 
qemu-timer-common.o)
+
+# objects linked against normal qemu binaries, not compiled with libtool
+QEMU_OBJS = $(QEMU_BASE_OBJS) $(QEMU_TRACE_OBJS)
+
+# objects linked into a shared library, built with libtool with -fPIC if 
required
+QEMU_BASE_OBJS_LIB=$(addsuffix .lo,$(basename $(QEMU_BASE_OBJS)))
+
+QEMU_OBJS_LIB = $(QEMU_BASE_OBJS_LIB) $(QEMU_TRACE_OBJS)

  QEMU_CFLAGS+=-I../

+libcacard.lib-y=$(addsuffix .lo,$(basename $(libcacard-y)))
+
  vscclient: $(libcacard-y) $(QEMU_OBJS) vscclient.o
-   $(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^,"  LINK  
$(TARGET_DIR)$@")
+   $(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^,"  LINK  $@")
+
+clean:
+   rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient libcacard.so *.lo 
.libs/* *.la
+   rm -Rf .libs

  all: vscclient

-clean:
-   rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient
+ifeq ($(LIBTOOL),)
+libcacard.la:
+   @echo libtool is missing, please install

Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target

2011-05-16 Thread Paolo Bonzini

On 05/16/2011 03:28 PM, Anthony Liguori wrote:



  *** Warning: Linking the shared library libcacard.la against the
non-libtool
  *** objects  ../trace-dtrace.o is not portable!


I don't think slipping in libtool like this is such a good idea.


I disagree but, the warning is indeed legitimate, so

NACK


Isn't la just a static archive compiled with -fPIC?


No, .la is a text file pointing (most importantly) to the static 
library, the shared library, and the dependencies of the static library.


Alon, do you need this to comply with some packaging guidelines 
forbidding static libraries?


Paolo



Re: [Qemu-devel] -net interface association behavior change in current -git.

2011-05-16 Thread Markus Armbruster
Rob Landley  writes:

> On 05/13/2011 07:19 AM, Markus Armbruster wrote:
>> Rob Landley  writes:
>> 
>>> On 05/13/2011 01:54 AM, Markus Armbruster wrote:
 Rob Landley  writes:

> On 05/12/2011 09:10 AM, Markus Armbruster wrote:
>> Rob Landley  writes:
>>
>>> In 1.14.0, if I did this:
>>>
>>>   qemu -net nic,blah -net user -net nic,blah -net tun,blah
>>>
>>> Then the first nic would be -net user, and the second nic would be -net
>>> tun.In current -git, -net user attaches to the second interface and
>>> -net tun attaches to the first, I.E. the order is reversed.
>>>
>>> Either way the first -nic becomes eth0 in Linux and the second becomes
>>> eth1 (I can manually assign mac addresses in order to confirm which is
>>> which), but eth0 used to be the -net user interface and now eth1 is the
>>> -net user interface.
>>>
>>> I bisected this to commit 60c07d933c66c4b30a83b but I don't know why it
>>> changed the behavior, and I can't find _documentation_ on having
>>> multiple interfaces transports hooked up to the same qemu instance
>>> anyway.  (It used to work, but possibly that was an accident?)
>>>
>>> Any ideas?
>>
>> Does it happen with -device and -netdev as well?
>>
>> See docs/qdev-device-use.txt for how to go from -net to -device.
>
> Read read read...
>
> That seems to be micromanaging PCI bus slot assignment, which isn't
> changed by this patch.  The cards don't move around, nor does the
> association between cards and Linux eth0/eth1.  What changes is which
> virtual LAN each virtual ethernet card is plugged into.  (The virtual
> cat5 cable coming out of the card moves to a different switch.)

 I didn't mean to tell you "try using -device to juggle PCI addresses".
 I meant to steer you away from QEMU VLANs, to find out whether they're a
 factor in your problem.  Possible, because non-VLAN uses a few different
 code paths in QEMU.  Sorry if I was too terse.

 In general, my advice is stay away from QEMU VLANs.
>>>
>>> Ok, now I'm confused.
>> 
>> Sorry :)
>> 
>>> Before this, I wasn't using them.  Now I am.  What's the reason for
>>> avoiding them?  (Also, I didn't see a way in -device to specify a
>>> network transport, just cards and their properties.  Quite possibly I
>>> missed it...)
>> 
>> A virtual network device has a host and a guest part.
>> 
>> The modern way to configure host and guest part is -netdev for host and
>> -device for guest part.  Example:
>> 
>> -netdev user,id=net0 -device e1000,netdev=net0
>> 
>> (qemu) info network
>> Devices not on any VLAN:
>>   net0: net=10.0.2.0, restricted=n peer=e1000.0
>>   e1000.0: model=e1000,macaddr=52:54:00:12:34:56 peer=net0
>> 
>> One guest part connected to one host part.
>
> Well, not calling it a "VLAN" which already has at least two other
> meanings is less confusing, so I'll give it a shot.  (I'm trying to
> update my container documentation at http://landley.net/lxc so I don't
> just want to get this to work but I want to be able to EXPLAIN it.)
>
> The name "netdev" is not self-explanatory.  FYI.  Let's see...

I guess it was chosen for similarity to -chardev.  Both create a device
host part.

> Doesn't like "macaddr".  It got gratuitously renamed to "mac=".  Eh,
> remove that and try again.

Documented in docs/qdev-device-use.txt.

> qemu-system-x86_64: -netdev id=lan0,user,hostfwd=tcp:127.0.0.1:9876-:22:
> Parameter 'type' is missing
>
> Um, no it isn't?  Ok, that argument magically has to be first...

"user" is shorthand for "type=user".  The short form is only accepted
when it comes first.  Many option arguments of the form NAME=VALUE...
work that way, including -net.

> So my third wild guess at redoing my command line worked:
>
> qemu-system-x86_64 -m 512 -kernel ~/linux/linux/arch/x86/boot/bzImage
> -no-reboot -hda squeeze.ext3 -append "root=/dev/hda rw" -netdev
> user,id=lan0,hostfwd=tcp:127.0.0.1:9876-:22 -device e1000,netdev=lan0
> -netdev tap,id=lan1,ifname=kvm0,script=no,downscript=no -device
> e1000,netdev=lan1
> Warning: more nics requested than this machine supports; some have been
> ignored
>
> I have no idea where that warning came from, but I got both my
> interfaces so it's at least working.

Relatively recent regression, suspecting commit f68b9d67.  Ignore the
warning for now.

>> For backward compatibility, the older way still works:
>> 
>> -netdev user,id=net0 -net nic,model=rtl8139,netdev=net0
>> 
>> There's also a completely different kind of host part, called VLAN (not
>> related to 802.1q VLANs).  Example:
>> 
>> -net user,vlan=0 -device rtl8139,vlan=0
>> 
>> (qemu) info network
>> VLAN 0 devices:
>>   user.0: net=10.0.2.0, restricted=n
>>   rtl8139.0: model=rtl8139,macaddr=52:54:00:12:34:56
>> 
>> You can connect multiple guest parts to it.  This is rarely needed, and
>> when you need it, you're

Re: [Qemu-devel] KVM Forum 2011: Call For Participation

2011-05-16 Thread Dor Laor

The abstract submission deadline was originally set for today.
The forum committee agreed to extend the deadline period until next 
Sunday, May 22.


The notification date remains the same (May 31).

Thanks,
 your KVM Forum 2011 Program Committee


On 04/21/2011 08:21 PM, kvm-forum-2011...@redhat.com wrote:

=
KVM Forum 2011: Call For Participation
August 15-16, 2011 - Hyatt Regency Vancouver - Vancouver, Canada
=

KVM is an industry leading open source hypervisor that provides an ideal
platform for datacenter virtualization, virtual desktop infrastructure,
and cloud computing.  Once again, it's time to bring together the
community of developers and users that define the KVM ecosystem for
our annual technical conference.  We will discuss the current state of
affairs and plan for the future of KVM, its surrounding infrastructure,
and management tools.  So mark your calendar and join us in advancing KVM.

http://events.linuxfoundation.org/events/kvm-forum/

We are colocated with The Linux Foundation's LinuxCon again this year.
KVM Forum attendees will be eligible to attend LinuxCon for a discounted
rate.

http://events.linuxfoundation.org/events/kvm-forum/register

We invite you to lead part of the discussion by submitting a speaking
proposal for KVM Forum 2011.

http://events.linuxfoundation.org/cfp

Suggested topics:

  KVM
  - Scaling and performance
  - Nested virtualization
  - I/O improvements
  - PCI device assignment
  - Driver domains
  - Time keeping
  - Resource management (cpu, memory, i/o)
  - Memory management (page sharing, swapping, huge pages, etc)
  - Fault tolerance
  - VEPA, VN-Link, vswitch
  - Security

  QEMU
  - Device model improvements
  - New devices
  - Scaling and performance
  - Desktop virtualization
  - Spice
  - Increasing robustness and hardening
  - Security model
  - Management interfaces
  - QMP protocol and implementation
  - Image formats
  - Live migration
  - Live snapshots and merging

  Virtio
  - Speeding up existing devices
  - Alternatives
  - Virtio on non-Linux

  Management infrastructure
  - Libvirt
  - KVM autotest
  - OpenStack
  - Network virtualization management
  - Enterprise storage management

  Cloud computing
  - Scalable storage
  - Virtual networking
  - Security
  - Provisioning
  - Hybrid

SUBMISSION REQUIREMENTS

Abstracts due: May 16th, 2011
Notification: May 31th, 2011

Please submit a short abstract (~150 words) describing your presentation
proposal.  In your submission please note how long your talk will take.
Slots vary in length up to 45 minutes.  Also include in your proposal
the proposal type -- one of:

- technical talk
- end-user talk
- BOF (birds of a feather) session

Sumbit your proposal here:

http://events.linuxfoundation.org/cfp

You will receive a notification whether or not your presentation proposal
was accepted by May 31st.

END-USER COLLABORATION

One of the big challenges as developers is to know what, where and how
people actually use our software.  We will reserve a few slots for end
users talking about their deployment challenges and achievements.

If you are using KVM in production you are encouraged submit a speaking
proposal.  Simply mark it as an end-user collaboration proposal.  As and
end user, this is a unique opportunity to get your input to developers.

BOF SESSION

We will reserve some slots in the evening after the main conference
tracks, for birds of a feather sessions. These sessions will be less
formal than presentation tracks and targetted for people who would
like to discuss specific issues with other developers and/or users.
If you are interested in getting developers and/or uses together to
discuss a specific problem, please submit a BOF proposal.

LIGHTNING TALKS

In addition to submitted talks we will also have some room for lightning
talks. These are short (5 minute) discussions to highlight new work or
ideas that aren't complete enough to warrant a full presentation slot.
Lightning talk submissions and scheduling will be handled on-site at
KVM Forum.

HOTEL / TRAVEL

The KVM Forum 2011 will be held in Vancouver BC at the Hyatt Regency
Vancouver.

http://events.linuxfoundation.org/events/kvm-forum/travel

Thank you for your interest in KVM.  We're looking forward to your
submissions and seeing you at the KVM Forum 2011 in August!

Thanks,
your KVM Forum 2011 Program Commitee

Please contact us with any questions or comments.
kvm-forum-2011...@redhat.com

___
Kvm-forum-2011-pc mailing list
kvm-forum-2011...@redhat.com
https://www.redhat.com/mailman/listinfo/kvm-forum-2011-pc





Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target

2011-05-16 Thread Alon Levy
On Mon, May 16, 2011 at 03:59:53PM +0200, Paolo Bonzini wrote:
> On 05/16/2011 03:28 PM, Anthony Liguori wrote:
> >>
> >>
> >>  *** Warning: Linking the shared library libcacard.la against the
> >>non-libtool
> >>  *** objects  ../trace-dtrace.o is not portable!
> >
> >I don't think slipping in libtool like this is such a good idea.
> 
> I disagree but, the warning is indeed legitimate, so
> 
> NACK
> 
> >Isn't la just a static archive compiled with -fPIC?
> 
> No, .la is a text file pointing (most importantly) to the static
> library, the shared library, and the dependencies of the static
> library.
> 
> Alon, do you need this to comply with some packaging guidelines
> forbidding static libraries?
> 

I'm basically trying to replace the current shared object built by
the standalone libcacard project. Since we are deprecating that on
account of not wanting to maintain two code bases, I need a replacement
shared object producing something somewhere. It seems best to do it
within the project and not, say, as spec file for an rpm, for obvious
reasons of wanting this to be distribution agnostic. I've settled on libtool
as the linker solution since it seems to be the de facto standard, please
correct me on this point if I'm wrong. We are not using autoconf, so
I've called it directly in it's various modes, compile, link and install.

Regarding your concerns from above:
The libcacard.la target produces a shared object with the right version
symlinks (libcacard.so.0.0.0, libcacard.so.0 and libcacard.so) thanks to libtool

Legitemacy of the warning: basically libtool is concerned about linking in 
position
dependant code. But the trace-dtrace.o contains no .rodata section and is not 
actually
a problem for the linker, I've verfied the resulting library works fine with 
spicec (the
spice client using it).

I'd appreciate any suggestion of a replacement for libtool if it is not 
appropriate.
Note that this building of a shared library is not something new - we've talked 
about
this before in relation to libcacard inclusion inside qemu git repository.

> Paolo



Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target

2011-05-16 Thread Alon Levy
On Mon, May 16, 2011 at 08:28:49AM -0500, Anthony Liguori wrote:
> On 05/16/2011 08:25 AM, Alon Levy wrote:
> >No flag to configure is required. Instead, added a libcacard.la target that
> >is not built by default, only when requested explicitly via:
> >
> >mkdir build
> >cd build
> >../configure
> >make libcacard.la
> >make install-libcacard
> >
> >Uses libtool to do actual linking of object files and shared library, and
> >installing. Tested only under linux, but supposed to work on other systems as
> >well.
> >
> >If libtool isn't found you get a message complaining about that, only at 
> >build
> >time (since it is not a default target I did not add a message at configure
> >time).
> >
> >Note: please ignore the following warning message, it is harmless, and fixing
> >it would require using libtool to build trace-dtrace.lo which, since it isn't
> >built by gcc, I don't know how to do.
> >
> >  *** Warning: Linking the shared library libcacard.la against the 
> > non-libtool
> >  *** objects  ../trace-dtrace.o is not portable!
> 
> I don't think slipping in libtool like this is such a good idea.

Forgot from my reply to Paolo: libtool is complaining about the only object I 
didn't
rebuild, trace-dtrace.o, the rest I've added rules specifically to rebuild into 
lo
(-fPIC'ed) objects under libcacard (including specifically any qemu support 
code). I
didn't do the same for trace-dtrace.o because a) I didn't find an easy way of 
doing it
on account of it not being built by gcc b) it wasn't a real problem like I 
mentioned in
the reply to Paolo.

> 
> Why do you need this target?
Answered in the reply to Paolo's email.

> 
> Isn't la just a static archive compiled with -fPIC?  Doesn't the
> whole code base need to be compiled with -fPIC then (and isn't the
> warning above a legitimate concern?).
> 
> Regards,
> 
> Anthony Liguori
> 
> >---
> >  Makefile   |   17 +
> >  configure  |   12 +++-
> >  libcacard/Makefile |   38 ++
> >  3 files changed, 62 insertions(+), 5 deletions(-)
> >
> >diff --git a/Makefile b/Makefile
> >index 2b0438c..0215307 100644
> >--- a/Makefile
> >+++ b/Makefile
> >@@ -119,6 +119,23 @@ version.o: $(SRC_PATH)/version.rc config-host.mak
> >
> >  version-obj-$(CONFIG_WIN32) += version.o
> >  ##
> >+# Support building shared library libcacard
> >+
> >+.PHONY: libcacard.la install-libcacard
> >+ifeq ($(LIBTOOL),)
> >+libcacard.la:
> >+@echo libtool is missing, please install and rerun configure
> >+
> >+install-libcacard:
> >+@echo libtool is missing, please install and rerun configure
> >+else
> >+libcacard.la: $(GENERATED_HEADERS) $(oslib-obj-y) qemu-malloc.o 
> >qemu-timer-common.o $(trace-obj-y)
> >+$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" 
> >TARGET_DIR="$*/" libcacard.la,)
> >+
> >+install-libcacard: libcacard.la
> >+$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" 
> >TARGET_DIR="$*/" install-libcacard,)
> >+endif
> >+##
> >
> >  qemu-img.o: qemu-img-cmds.h
> >  qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS)
> >diff --git a/configure b/configure
> >index 0627f1d..e62841e 100755
> >--- a/configure
> >+++ b/configure
> >@@ -1276,6 +1276,15 @@ if ! has $pkg_config; then
> >  fi
> >
> >  ##
> >+# libtool probe
> >+
> >+if ! has libtool; then
> >+libtool=
> >+else
> >+libtool=libtool
> >+fi
> >+
> >+##
> >  # Sparse probe
> >  if test "$sparse" != "no" ; then
> >if has cgcc; then
> >@@ -3060,6 +3069,7 @@ echo "AR=$ar">>  $config_host_mak
> >  echo "OBJCOPY=$objcopy">>  $config_host_mak
> >  echo "LD=$ld">>  $config_host_mak
> >  echo "WINDRES=$windres">>  $config_host_mak
> >+echo "LIBTOOL=$libtool">>  $config_host_mak
> >  echo "CFLAGS=$CFLAGS">>  $config_host_mak
> >  echo "QEMU_CFLAGS=$QEMU_CFLAGS">>  $config_host_mak
> >  echo "QEMU_INCLUDES=$QEMU_INCLUDES">>  $config_host_mak
> >@@ -3595,7 +3605,7 @@ if [ "$source_path" != `pwd` ]; then
> >  # out of tree build
> >  mkdir -p libcacard
> >  rm -f libcacard/Makefile
> >-ln -s "$source_path/libcacard/Makefile" libcacard/Makefile
> >+symlink "$source_path/libcacard/Makefile" libcacard/Makefile
> >  fi
> >
> >  d=libuser
> >diff --git a/libcacard/Makefile b/libcacard/Makefile
> >index 1d34df0..3a5ad61 100644
> >--- a/libcacard/Makefile
> >+++ b/libcacard/Makefile
> >@@ -4,15 +4,45 @@
> >
> >  $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard)
> >
> >-QEMU_OBJS=$(addprefix ../, $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o 
> >qemu-timer-common.o)
> >+QEMU_TRACE_OBJS=$(addprefix ../,$(trace-obj-y))
> >+
> >+QEMU_BASE_OBJS=$(addprefix ../,$(oslib-obj-y) qemu-malloc.o 
> >qemu-timer-common.o)
> >+
> >+# objects linked against norma

Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target

2011-05-16 Thread Paolo Bonzini

On 05/16/2011 07:37 PM, Alon Levy wrote:

I've settled on libtool
as the linker solution since it seems to be the de facto standard, please
correct me on this point if I'm wrong. We are not using autoconf, so
I've called it directly in it's various modes, compile, link and install.


I agree.  I don't dislike this particularly :) if at all.


Legitemacy of the warning: basically libtool is concerned about linking in 
position
dependant code. But the trace-dtrace.o contains no .rodata section and is not 
actually
a problem for the linker, I've verfied the resulting library works fine with 
spicec (the
spice client using it).


I'm not sure, however, that glibc would still keep the sharing of .text.


I'd appreciate any suggestion of a replacement for libtool if it is not 
appropriate.
Note that this building of a shared library is not something new - we've talked 
about
this before in relation to libcacard inclusion inside qemu git repository.


Do you really need tracing besides as a dependency of qemu_malloc? 
Perhaps you can recompile qemu-malloc.o specially for libcacard, and 
force usage of the nop backend.


Paolo



Re: [Qemu-devel] [PATCH] libcacard: add libcacard.la target

2011-05-16 Thread Alon Levy
On Mon, May 16, 2011 at 04:44:03PM +0200, Paolo Bonzini wrote:
> On 05/16/2011 07:37 PM, Alon Levy wrote:
> >I've settled on libtool
> >as the linker solution since it seems to be the de facto standard, please
> >correct me on this point if I'm wrong. We are not using autoconf, so
> >I've called it directly in it's various modes, compile, link and install.
> 
> I agree.  I don't dislike this particularly :) if at all.
> 
> >Legitemacy of the warning: basically libtool is concerned about linking in 
> >position
> >dependant code. But the trace-dtrace.o contains no .rodata section and is 
> >not actually
> >a problem for the linker, I've verfied the resulting library works fine with 
> >spicec (the
> >spice client using it).
> 
> I'm not sure, however, that glibc would still keep the sharing of .text.
> 

I'll check.

> >I'd appreciate any suggestion of a replacement for libtool if it is not 
> >appropriate.
> >Note that this building of a shared library is not something new - we've 
> >talked about
> >this before in relation to libcacard inclusion inside qemu git repository.
> 
> Do you really need tracing besides as a dependency of qemu_malloc?
> Perhaps you can recompile qemu-malloc.o specially for libcacard, and
> force usage of the nop backend.

Sounds like a very good idea for short term. Otoh if I'm already building 
libcacard
with qemu dependencies, it would be nice if I could benefit from the tracing 
framework.

I'll investigate building trace-dtrace.lo and if this doesn't work I'll try nop 
backend.

> 
> Paolo
> 



Re: [Qemu-devel] [regression] qemu-system-arm: segfault in lsi_do_command

2011-05-16 Thread Kevin Wolf
Hi Jonathan,

Am 16.05.2011 13:23, schrieb Jonathan Nieder:
> Hi,
> 
> Kevin Wolf wrote:
> 
>> This pulls the request completion for error cases from the caller to
>> scsi_disk_emulate_command. This should not change semantics, but allows to
>> reuse scsi_handle_write_error() for flushes in the next patch.
> 
> Today I tried out qemu-system-arm for the first time.  It's faster
> than I expected; very neat.  Unfortunately it segfaults.
> 
> Reproducible with "master" (077030d11).  Bisects to v0.14.0-rc0~489
> (scsi-disk: Complete failed requests in scsi_disk_emulate_command,
> 2010-10-25).

Your instructions seemed clear enough, so I tried to reproduce your
problem. Now I have an ARM VM with a Debian installation that works just
fine and I have no idea what to use it for. ;-)

I also reviewed the patch that you mentioned and I can't find anything
suspicious there. I'm afraid you'll have to bite the bullet and run it
with some debugging code yourself (if it's really related to that patch,
you'll want to enable DPRINTF in hw/scsi-disk.c as a first step)

Kevin



Re: [Qemu-devel] [regression] qemu-system-arm: segfault in lsi_do_command

2011-05-16 Thread Jonathan Nieder
Kevin Wolf wrote:

> I also reviewed the patch that you mentioned and I can't find anything
> suspicious there. I'm afraid you'll have to bite the bullet and run it
> with some debugging code yourself (if it's really related to that patch,
> you'll want to enable DPRINTF in hw/scsi-disk.c as a first step)

I tried reverting a6d96eb7 (scsi: Move sense handling into the driver,
2010-11-24), 78ced65e (scsi-disk: Implement werror for flushes,
2010-10-25), and 8af7a3a (csi-disk: Complete failed requests in
scsi_disk_emulate_command, 2010-10-25), and the segfault is gone.  So
now I also have a nice ARM image to reproduce it more quickly with. :)

Here's what the default DPRINTFs write when it segfaults, for what
it's worth.  I'll try playing with this some more.

scsi-disk: Command: lun=0 tag=0x0 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x0 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x10001 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x10001 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x10003 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x10003 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x10005 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x10005 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x10007 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x10007 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x10009 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x10009 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x1000b data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x1000b status=0 sense=0
scsi-disk: Command: lun=0 tag=0x1000d data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x1000d status=0 sense=0
scsi-disk: Command: lun=0 tag=0x1000f data=0xa0 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x10 0x00 0x00 0x00
scsi-disk: Read buf_len=16
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x1000f status=0 sense=0
scsi-disk: Command: lun=0 tag=0x200 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x200 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x10201 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x10201 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x10203 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x10203 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x10205 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x10205 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x10207 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x10207 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x10209 data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x10209 status=0 sense=0
scsi-disk: Command: lun=0 tag=0x1020b data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x1020b status=0 sense=0
scsi-disk: Command: lun=0 tag=0x1020d data=0x12 0x00 0x00 0x00 0x24 0x00
scsi-disk: Read buf_len=36
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x1020d status=0 sense=0
scsi-disk: Command: lun=0 tag=0x1020f data=0xa0 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x10 0x00 0x00 0x00
scsi-disk: Read buf_len=16
scsi-disk: Read sector_count=0
scsi-disk: Command complete tag=0x1020f status=0 sense=0
scsi-disk: Command: lun=0 tag=0x10011 data=0x00 0x00 0x00 0x00 0x00 0x00
scsi-disk: Command complete tag=0x10011 status=0 sense=0



Re: [Qemu-devel] [regression] qemu-system-arm: segfault in lsi_do_command

2011-05-16 Thread Jonathan Nieder
Kevin Wolf wrote:

> Your instructions seemed clear enough, so I tried to reproduce your
> problem. Now I have an ARM VM with a Debian installation that works just
> fine and I have no idea what to use it for. ;-)

So I was puzzled about this for a while, but then I had a flash
of inspiration:

unset MALLOC_PERTURB_
reproduction-script;# no segfault

MALLOC_PERTURB_=37
export MALLOC_PERTURB_
reproduction-script;# segfaults

Thanks.  Sorry, it's easy to forget.



Re: [Qemu-devel] [regression] qemu-system-arm: segfault in lsi_do_command

2011-05-16 Thread Kevin Wolf
Am 16.05.2011 17:43, schrieb Jonathan Nieder:
> Kevin Wolf wrote:
> 
>> Your instructions seemed clear enough, so I tried to reproduce your
>> problem. Now I have an ARM VM with a Debian installation that works just
>> fine and I have no idea what to use it for. ;-)
> 
> So I was puzzled about this for a while, but then I had a flash
> of inspiration:
> 
>   unset MALLOC_PERTURB_
>   reproduction-script;# no segfault
> 
>   MALLOC_PERTURB_=37
>   export MALLOC_PERTURB_
>   reproduction-script;# segfaults
> 
> Thanks.  Sorry, it's easy to forget.

Thanks. Still doesn't make much sense to me, the patch shouldn't change
anything with respect to a malloc, but I can reproduce a segfault now. I
think I'll have a closer look tomorrow.

Kevin



Re: [Qemu-devel] [PATCH] target-arm: Minimal implementation of performance counters

2011-05-16 Thread Paul Brook
> > I just spoke with Paul on IRC about this. In summary:
> >  * for a helper to cause an exception then it has (a) to make sure CPU
> >
> > state (pc, condflags) is sync'd before the call to the helper and (b)
> > the helper has to be in a file with access to global env, because it
> > needs to call cpu_loop_exit()
> 
> I don't think (a) is true. It is possible to use the same way as for
> load/store operations, that is call cpu_restore_state() before calling
> cpu_loop_exit().

To call cpu_restore_state you need to know searched_pc.  To find that you need 
to unwind the host stack all the way back to translated code.

Paul



Re: [Qemu-devel] TCG: AREG0 removal planning

2011-05-16 Thread Paul Brook
> > For changes to
> > the TCG side we want to consider how we can provide useful aliasing
> > information, rather than a naive replacement of TCG_AREG0 with a
> > variable.
> 
> What aliasing information?

Aliasing of cpu state accesses between tcg_global_mem_new_* variables, 
qemu_ld/st ops, and helper functions.

Paul



Re: [Qemu-devel] AHCI broken in current git, bisected.

2011-05-16 Thread Anthony Liguori

On 05/15/2011 03:03 PM, Michael S. Tsirkin wrote:

On Sun, May 15, 2011 at 10:20:23PM +0300, Michael S. Tsirkin wrote:

On Sun, May 15, 2011 at 07:14:42PM +0200, Jan Kiszka wrote:

Pity I missed this the first time. Thanks!


Ah, I see, I didn't miss it, just back from vacation and didn't get so
far back in the backlog yet.


Applied Jan's patch.

Regards,

Anthony Liguori


--
MST







Re: [Qemu-devel] [regression] qemu-system-arm: segfault in lsi_do_command

2011-05-16 Thread Paolo Bonzini
On 05/16/2011 05:58 PM, Kevin Wolf wrote:
> Thanks. Still doesn't make much sense to me, the patch shouldn't change
> anything with respect to a malloc, but I can reproduce a segfault now. I
> think I'll have a closer look tomorrow.

This fixes it on top of my SCSI refactoring series.  Should I send v3
with this one squashed in appropriately?  Or should this be sent later?

Paolo

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 2f0ffda..57cfc87 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -167,11 +167,17 @@ int scsi_req_get_sense(SCSIRequest *req, uint8_t *buf, 
int len)
 
 int32_t scsi_req_enqueue(SCSIRequest *req, uint8_t *buf)
 {
+int32_t rc;
 assert(!req->enqueued);
 scsi_req_ref(req);
 req->enqueued = true;
 QTAILQ_INSERT_TAIL(&req->dev->requests, req, next);
-return req->dev->info->send_command(req, buf);
+
+/* Make sure the request doesn't disappear under send_command's feet.  */
+scsi_req_ref(req);
+rc = req->dev->info->send_command(req, buf);
+scsi_req_unref(req);
+return rc;
 }
 
 static void scsi_req_dequeue(SCSIRequest *req)




Re: [Qemu-devel] [PATCH] target-arm: Minimal implementation of performance counters

2011-05-16 Thread Peter Maydell
On 16 May 2011 17:10, Paul Brook  wrote:
>> > I just spoke with Paul on IRC about this. In summary:
>> >  * for a helper to cause an exception then it has (a) to make sure CPU
>> >
>> > state (pc, condflags) is sync'd before the call to the helper and (b)
>> > the helper has to be in a file with access to global env, because it
>> > needs to call cpu_loop_exit()
>>
>> I don't think (a) is true. It is possible to use the same way as for
>> load/store operations, that is call cpu_restore_state() before calling
>> cpu_loop_exit().
>
> To call cpu_restore_state you need to know searched_pc.  To find that you need
> to unwind the host stack all the way back to translated code.

You can do this by calling GETPC() from the top level helper function
though, right? [OK, we'd need to move the definition out of dyngen-exec.h.]

-- PMM



[Qemu-devel] segfault with VNC and --enable-debug

2011-05-16 Thread Anthony PERARD
Hi,

I found a segfault when I use VNC with qemu compiled with
--enable-debug. Without debug mode, that works fine. The segfault
happen usualy when the debian (guest) is ready to be used, or a little
bit after I'm logged in, in console mode.

Here is few detail:

HEAD
711c212 Merge remote-tracking branch 'stefanha/trivial-patches' into staging

# Configured with: '../configure' '--target-list=i386-softmmu'
'--enable-trace-backend=stderr' '--enable-debug'

Run with:
~/work/qemu/_build-noxen/i386-softmmu/qemu -name debian -vnc
0.0.0.0:0,to=99 -sdl -boot order=c -smp 2,maxcpus=3 -net
nic,vlan=0,macaddr=00:16:3e:26:42:7d,model=rtl8139 -net
tap,vlan=0,ifname=tap8.0,script=no -m 512 -drive
file=/root/vm/vm.img,if=ide,index=0,media=disk,format=raw

And the backtrace:
Program received signal SIGSEGV, Segmentation fault.
0x91fdce94 in ?? ()
(gdb) bt
#0  0x91fdce94 in ?? ()
#1  0x0811f3a5 in vnc_refresh_server_surface (vd=0x8b3f720) at
/local/home/anthony/work/qemu/ui/vnc.c:2419
#2  0x0811f572 in vnc_refresh (opaque=0x8b3f720) at
/local/home/anthony/work/qemu/ui/vnc.c:2453
#3  0x08138ce1 in qemu_run_timers (clock=0x89647d8) at
/local/home/anthony/work/qemu/qemu-timer.c:608
#4  0x08139081 in qemu_run_all_timers () at
/local/home/anthony/work/qemu/qemu-timer.c:726
#5  0x081d7daa in main_loop_wait (nonblocking=1) at
/local/home/anthony/work/qemu/vl.c:1336
#6  0x081d7e65 in main_loop () at /local/home/anthony/work/qemu/vl.c:1377
#7  0x081dca68 in main (argc=18, argv=0xb684, envp=0xb6d0) at
/local/home/anthony/work/qemu/vl.c:3289
(gdb) up
#1  0x0811f3a5 in vnc_refresh_server_surface (vd=0x8b3f720) at
/local/home/anthony/work/qemu/ui/vnc.c:2419
2419if (!test_and_clear_bit((x / 16), vd->guest.dirty[y]))

Regards,

-- 
Anthony PERARD



Re: [Qemu-devel] [PATCH] target-arm: Minimal implementation of performance counters

2011-05-16 Thread Aurelien Jarno
On Mon, May 16, 2011 at 05:37:03PM +0100, Peter Maydell wrote:
> On 16 May 2011 17:10, Paul Brook  wrote:
> >> > I just spoke with Paul on IRC about this. In summary:
> >> >  * for a helper to cause an exception then it has (a) to make sure CPU
> >> >
> >> > state (pc, condflags) is sync'd before the call to the helper and (b)
> >> > the helper has to be in a file with access to global env, because it
> >> > needs to call cpu_loop_exit()
> >>
> >> I don't think (a) is true. It is possible to use the same way as for
> >> load/store operations, that is call cpu_restore_state() before calling
> >> cpu_loop_exit().
> >
> > To call cpu_restore_state you need to know searched_pc.  To find that you 
> > need
> > to unwind the host stack all the way back to translated code.
> 
> You can do this by calling GETPC() from the top level helper function
> though, right? [OK, we'd need to move the definition out of dyngen-exec.h.]

No we don't need to move it out of dyngen-exec.h. dyngen-exec.h is
included in target-*/exec.h, as the softmmu helpers, which are included
in target-*/op_helper.c, call cpu_restore_state().

For an actual usage of cpu_restore_state() outside of the softmmu
helpers, you can have a look at target-sh4/op-helper.c, which uses this
technique for raising most exceptions, and especially the FPU ones.

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH] target-arm: Minimal implementation of performance counters

2011-05-16 Thread Aurelien Jarno
On Mon, May 16, 2011 at 10:59:47AM +0100, Peter Maydell wrote:
> On 14 May 2011 22:32, Aurelien Jarno  wrote:
> > On Fri, May 06, 2011 at 03:32:27PM +0100, Peter Maydell wrote:
> >> I just spoke with Paul on IRC about this. In summary:
> >>  * for a helper to cause an exception then it has (a) to make sure CPU
> >> state (pc, condflags) is sync'd before the call to the helper and (b)
> >> the helper has to be in a file with access to global env, because it
> >> needs to call cpu_loop_exit()
> >
> > I don't think (a) is true. It is possible to use the same way as for
> > load/store operations, that is call cpu_restore_state() before calling
> > cpu_loop_exit().
> 
> Yes, I think you're right here, I'm not sure why I didn't think that
> would work. (b) still applies, though.
> 
> > If you don't really like having env as a fixed host registers (recent
> > patch series from Blue Swirl seems to want to get rid of this), it is
> > possible to pass env as an argument of the helper to do that.
> 
> I think really my position on this patch is that it adds
> functionality that means you can't actually boot recent Linux
> kernels with hw breakpoint support enabled, and I'd rather not
> have it get tangled up with either the ongoing "remove AREG0"
> discussions or a more general overhaul of how cp15 registers
> are handled. It just handles this handful of new registers in
> the same way we currently handle all the other cp14/cp15 regs.

Well the current discussion is about to know if env access should be
implicit (through a fixed register), or explicit (passed as an argument
to the helper). Blue Swirl is working towards the second solution to see
if it could work or not, so currently I think both options are still
acceptable (both options are currently in use in the current code).

> > What ever solution is used, we need env for the load/store functions,
> > and theses functions already provide a framework to restore the CPU
> > state. I think it's a good idea to use this framework instead of having
> > a second framework using TCG code for that.
> 
> Do you mean you'd like to see us using cpu_restore_state() instead
> of explicit state-syncing TCG code for the cases where the exception
> is "expected" like SVC instructions? (ie what most targets have
> a gen_exception() function for.)
> 

Well maybe this patch is not the best example to use
cpu_restore_state(), but I think we should go toward this direction.
Exceptions as their name suggests are not the rules, so we should avoid
generating code to handle them (like state-syncing TCG code), and use
CPU state restoration, even if it is not fast (that's not a problem, as
exceptions are not the rules).

That said given this patch is more or less an extension of an existing
code, we may want to apply it anyway.

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH] target-arm: Minimal implementation of performance counters

2011-05-16 Thread Peter Maydell
On 16 May 2011 18:29, Aurelien Jarno  wrote:
> On Mon, May 16, 2011 at 05:37:03PM +0100, Peter Maydell wrote:
>> You can do this by calling GETPC() from the top level helper function
>> though, right? [OK, we'd need to move the definition out of dyngen-exec.h.]
>
> No we don't need to move it out of dyngen-exec.h. dyngen-exec.h is
> included in target-*/exec.h, as the softmmu helpers, which are included
> in target-*/op_helper.c, call cpu_restore_state().

I meant, assuming we want to reduce the set of helpers which use
the implicit-global-env (ie: back out the patches which made
helpers other than op_helper.c include exec.h). At the moment
you can't get GETPC() without also getting the global-env which
means you have to be in a source file compiled with the right CFLAGS.
Sorry for the lack of clarity.

> For an actual usage of cpu_restore_state() outside of the softmmu
> helpers, you can have a look at target-sh4/op-helper.c, which uses this
> technique for raising most exceptions, and especially the FPU ones.

Sure. It's in a file which has access to global-env, though.

-- PMM



Re: [Qemu-devel] [PATCH] target-arm: Minimal implementation of performance counters

2011-05-16 Thread Peter Maydell
On 16 May 2011 18:29, Aurelien Jarno  wrote:
> That said given this patch is more or less an extension of an existing
> code, we may want to apply it anyway.

That is the conclusion I'm hoping to persuade you to, yes :-)

-- PMM



[Qemu-devel] Regression "Warning: more nics requested than this machine supports"

2011-05-16 Thread Markus Armbruster
Watch this:

$ qemu-system-x86_64 -nodefaults -enable-kvm -m 384 -vnc :0 -S -netdev 
user,id=net0 -device e1000,netdev=net0
Warning: more nics requested than this machine supports; some have been 
ignored
(qemu) info network
Devices not on any VLAN:
  net0: net=10.0.2.0, restricted=n peer=e1000.0
  e1000.0: model=e1000,macaddr=52:54:00:12:34:56 peer=net0

Culprit is

commit f68b9d672b90dedc79aeb9b44607f484dbe46a6b
Author: Peter Maydell 
Date:   Tue Mar 22 18:39:40 2011 +

net: Improve the warnings for dubious command line option combinations

Improve the warnings we give if the user specified a combination of -net
options which don't make much sense:
 * Don't warn about anything if the config is the implicit default
   "-net user -net nic" rather than one specified by the user (this will
   only kick in for boards with no NIC or if CONFIG_SLIRP is not set)
 * Diagnose the case where the user asked for NICs which the board
   didn't instantiate (for example where the user asked for two NICs
   but the board only supports one)

Signed-off-by: Peter Maydell 
Signed-off-by: Aurelien Jarno 

Its count of requested NICs is blissfully unaware of -device.  In my
example, it comes up with nb_nics == 0 and seen_nics == 1.



[Qemu-devel] [RFC Patch 0/3]Qemu: Enable dynamic cache change through qemu monitor

2011-05-16 Thread Supriya Kannery

Currently cache setting of a block device cannot be changed without 
restarting a running VM. Following patchset is for enabling dynamic 
change of cache setting for block devices through qemu monitor. Code 
changes are based on patches from Christoph Hellwig and Prerna Saxena.

Monitor command "info block" is extended to display cache setting of 
block devices. New monitor command "cache_set" is added using which 
cache setting can be dynamically changed
Usage:
"cache_set  "
= block device  
= "off"/"none", "on"/"writeback", "writethrough", "unsafe"
  
 1/3 Enhance "info block" to display cache setting
 2/3 New error classes for file reopen and device insertion
 3/3 Add monitor command "cache_set" for dynamic cache change

 qemu/block.c |   71
++--
 qemu/block.h |2 +
 qemu/blockdev.c  |   20 +++
 qemu/blockdev.h  |1
 qemu/hmp-commands.hx |   14 +
 qemu/qerror.c|8 +++
 qemu/qerror.h|6 +
 qemu/qmp-commands.hx |   28 ++
 8 files changed, 148 insertions(+), 2 deletions(-)

~   



[Qemu-devel] [RFC Patch 1/3]Qemu: Enhance "info block" to display cache setting

2011-05-16 Thread Supriya Kannery
Enhance "info block" to display cache setting

Example:
(qemu) info block
ide0-hd0: type=hd removable=0 file=../rhel6-32.qcow2 ro=0 drv=qcow2 
encrypted=0

Enhanced to include "cache" setting:
(qemu) info block
ide0-hd0: type=hd removable=0 cache=none file=../rhel6-32.qcow2 ro=0 
drv=qcow2 encrypted=0

Signed-off-by: Supriya Kannery 
Signed-off-by: Prerna Saxena 

---
 block.c |   18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

Index: qemu/block.c
===
--- qemu.orig/block.c
+++ qemu/block.c
@@ -1713,6 +1713,19 @@ static void bdrv_print_dict(QObject *obj
 monitor_printf(mon, " locked=%d", qdict_get_bool(bs_dict, "locked"));
 }
 
+if (qdict_haskey(bs_dict, "open_flags")) {
+int open_flags = qdict_get_int(bs_dict, "open_flags");
+if (open_flags & BDRV_O_NOCACHE) {
+monitor_printf(mon, " cache=none");
+} else if (open_flags & BDRV_O_CACHE_WB) {
+if (open_flags & BDRV_O_NO_FLUSH)
+monitor_printf(mon, " cache=unsafe");
+else
+monitor_printf(mon, " cache=writeback");
+} else
+monitor_printf(mon, " cache=writethrough");
+}
+
 if (qdict_haskey(bs_dict, "inserted")) {
 QDict *qdict = qobject_to_qdict(qdict_get(bs_dict, "inserted"));
 
@@ -1762,9 +1775,10 @@ void bdrv_info(Monitor *mon, QObject **r
 }
 
 bs_obj = qobject_from_jsonf("{ 'device': %s, 'type': %s, "
-"'removable': %i, 'locked': %i }",
+"'removable': %i, 'locked': %i, "
+"'open_flags': %d }",
 bs->device_name, type, bs->removable,
-bs->locked);
+bs->locked, bs->open_flags);
 
 if (bs->drv) {
 QObject *obj;



[Qemu-devel] [RFC Patch 2/3]Qemu: New error classes for file reopen and device insertion

2011-05-16 Thread Supriya Kannery
New errors defined for device insertion and file reopen

Signed-off-by: Supriya Kannery 

---
 qerror.c |8 
 qerror.h |6 ++
 2 files changed, 14 insertions(+)

Index: qemu/qerror.c
===
--- qemu.orig/qerror.c
+++ qemu/qerror.c
@@ -93,6 +93,10 @@ static const QErrorStringTable qerror_ta
 .desc  = "Device '%(device)' not found",
 },
 {
+.error_fmt = QERR_DEVICE_NOT_INSERTED,
+.desc  = "Device '%(device)' has not been inserted",
+},
+{
 .error_fmt = QERR_DEVICE_NOT_REMOVABLE,
 .desc  = "Device '%(device)' is not removable",
 },
@@ -161,6 +165,10 @@ static const QErrorStringTable qerror_ta
 .desc  = "Could not open '%(filename)'",
 },
 {
+.error_fmt = QERR_REOPEN_FILE_FAILED,
+.desc  = "Could not reopen '%(filename)'",
+},
+{
 .error_fmt = QERR_PROPERTY_NOT_FOUND,
 .desc  = "Property '%(device).%(property)' not found",
 },
Index: qemu/qerror.h
===
--- qemu.orig/qerror.h
+++ qemu/qerror.h
@@ -84,6 +84,9 @@ QError *qobject_to_qerror(const QObject 
 #define QERR_DEVICE_NOT_FOUND \
 "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
 
+#define QERR_DEVICE_NOT_INSERTED \
+"{ 'class': 'DeviceNotInserted', 'data': { 'device': %s } }"
+
 #define QERR_DEVICE_NOT_REMOVABLE \
 "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
 
@@ -135,6 +138,9 @@ QError *qobject_to_qerror(const QObject 
 #define QERR_OPEN_FILE_FAILED \
 "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
 
+#define QERR_REOPEN_FILE_FAILED \
+"{ 'class': 'ReopenFileFailed', 'data': { 'filename': %s } }"
+
 #define QERR_PROPERTY_NOT_FOUND \
 "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
 



[Qemu-devel] [RFC Patch 3/3]Qemu: Add command "cache_set" for dynamic cache change

2011-05-16 Thread Supriya Kannery
Add monitor command "cache_set" for dynamic cache change

Signed-off-by: Christoph Hellwig 
Signed-off-by: Supriya Kannery 

---
 block.c |   53 +
 block.h |2 ++
 blockdev.c  |   20 
 blockdev.h  |1 +
 hmp-commands.hx |   14 ++
 qmp-commands.hx |   28 
 6 files changed, 118 insertions(+)

Index: qemu/hmp-commands.hx
===
--- qemu.orig/hmp-commands.hx
+++ qemu/hmp-commands.hx
@@ -70,6 +70,20 @@ but should be used with extreme caution.
 resizes image files, it can not resize block devices like LVM volumes.
 ETEXI
 
+{
+.name   = "cache_set",
+.args_type  = "device:B,cache:s",
+.params = "device cache",
+.help   = "change cache setting for device",
+.user_print = monitor_user_noop,
+.mhandler.cmd_new = do_cache_set,
+},
+
+STEXI
+@item cache_set
+@findex cache_set
+Change cache options for a block device while guest is running.
+ETEXI
 
 {
 .name   = "eject",
Index: qemu/block.c
===
--- qemu.orig/block.c
+++ qemu/block.c
@@ -657,6 +657,34 @@ unlink_and_fail:
 return ret;
 }
 
+int bdrv_reopen(BlockDriverState *bs, int bdrv_flags)
+{
+BlockDriver *drv = bs->drv;
+int ret = 0;
+
+/* No need to reopen as no change in flags */
+if (bdrv_flags == bs->open_flags) {
+return 0;
+}
+
+/* Quiesce IO for the given block device */
+qemu_aio_flush();
+bdrv_flush(bs);
+
+bdrv_close(bs);
+ret = bdrv_open(bs, bs->filename, bdrv_flags, drv);
+
+/*
+ * A failed attempt to reopen the image file must lead to 'abort()'
+ */
+if (ret != 0) {
+qerror_report(QERR_REOPEN_FILE_FAILED, bs->filename);
+abort();
+}
+
+return ret;
+}
+
 void bdrv_close(BlockDriverState *bs)
 {
 if (bs->drv) {
@@ -3063,3 +3091,28 @@ out:
 
 return ret;
 }
+
+int bdrv_change_cache(BlockDriverState *bs, const char *cache)
+{
+int bdrv_flags = 0;
+
+/* Clear cache flags */
+bdrv_flags = bs->open_flags & ~BDRV_O_CACHE_MASK;
+
+/* Set flags for requested cache setting */
+if (strcmp(cache, "writethrough")) {
+  if (!strcmp(cache, "off") || !strcmp(cache, "none")) {
+bdrv_flags |= BDRV_O_NOCACHE;
+} else if (!strcmp(cache, "writeback") || !strcmp(cache, "on")) {
+bdrv_flags |= BDRV_O_CACHE_WB;
+} else if (!strcmp(cache, "unsafe")) {
+bdrv_flags |= BDRV_O_CACHE_WB;
+bdrv_flags |= BDRV_O_NO_FLUSH;
+} else {
+   error_report("invalid cache option");
+   return -1;
+}
+}
+
+return(bdrv_reopen(bs, bdrv_flags));
+}
Index: qemu/blockdev.c
===
--- qemu.orig/blockdev.c
+++ qemu/blockdev.c
@@ -796,3 +796,23 @@ int do_block_resize(Monitor *mon, const 
 
 return 0;
 }
+
+int do_cache_set(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+const char *device = qdict_get_str(qdict, "device");
+const char *cache = qdict_get_str(qdict, "cache");
+BlockDriverState *bs;
+
+bs = bdrv_find(device);
+if (!bs) {
+qerror_report(QERR_DEVICE_NOT_FOUND, device);
+return -1;
+}
+
+if(bdrv_is_inserted(bs)) {
+   return(bdrv_change_cache(bs, cache));
+} else {
+   qerror_report(QERR_DEVICE_NOT_INSERTED, device);
+   return -1;
+}
+}
Index: qemu/block.h
===
--- qemu.orig/block.h
+++ qemu/block.h
@@ -71,6 +71,7 @@ void bdrv_delete(BlockDriverState *bs);
 int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags);
 int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
   BlockDriver *drv);
+int bdrv_reopen(BlockDriverState *bs, int bdrv_flags);
 void bdrv_close(BlockDriverState *bs);
 int bdrv_attach(BlockDriverState *bs, DeviceState *qdev);
 void bdrv_detach(BlockDriverState *bs, DeviceState *qdev);
@@ -96,6 +97,7 @@ void bdrv_commit_all(void);
 int bdrv_change_backing_file(BlockDriverState *bs,
 const char *backing_file, const char *backing_fmt);
 void bdrv_register(BlockDriver *bdrv);
+int bdrv_change_cache(BlockDriverState *bs, const char *cache);
 
 
 typedef struct BdrvCheckResult {
Index: qemu/blockdev.h
===
--- qemu.orig/blockdev.h
+++ qemu/blockdev.h
@@ -64,5 +64,6 @@ int do_change_block(Monitor *mon, const 
 int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
 int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data);
 int do_block_resize(Monitor *mon, const QDict *qdict, QObject **ret_data);
+int do_cache_set(Monitor *mon, const QDict *qdict, QObject **ret_data);
 

Re: [Qemu-devel] [PATCH] target-arm: Minimal implementation of performance counters

2011-05-16 Thread Aurelien Jarno
On Mon, May 16, 2011 at 06:47:42PM +0100, Peter Maydell wrote:
> On 16 May 2011 18:29, Aurelien Jarno  wrote:
> > On Mon, May 16, 2011 at 05:37:03PM +0100, Peter Maydell wrote:
> >> You can do this by calling GETPC() from the top level helper function
> >> though, right? [OK, we'd need to move the definition out of dyngen-exec.h.]
> >
> > No we don't need to move it out of dyngen-exec.h. dyngen-exec.h is
> > included in target-*/exec.h, as the softmmu helpers, which are included
> > in target-*/op_helper.c, call cpu_restore_state().
> 
> I meant, assuming we want to reduce the set of helpers which use
> the implicit-global-env (ie: back out the patches which made
> helpers other than op_helper.c include exec.h). At the moment
> you can't get GETPC() without also getting the global-env which
> means you have to be in a source file compiled with the right CFLAGS.
> Sorry for the lack of clarity.

Well, I haven't tried, but it seems you can simply include dyngen-exec.h
directly in the file you want. 

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] BUG: 0.14.0 -device usb-host supports only one device

2011-05-16 Thread Erik Rull

Gerd Hoffmann wrote:

  Hi,


When enabling the -device usb-host option support for adding
automatically USB devices from the host to the guest, only one device
gets detected.


Yes. -device usb-host creates a *single* virtual usb device instance.
When a matching device on the host is found the virtual device is
plugged in, otherwise it is plugged out. In plugged out state qemu looks
now and then (every two seconds IIRC) whenever a matching device was
plugged into the host.

Try -device usb-host twice if you need two virtual usb devices.

cheers,
Gerd


Hi Gerd,

hm, if I add it multiple times and plug in a USB flashdrive, then all slots 
are filled up with this device (duplicated)...
And Windows detects them with the result, that the "not first" devices are 
marked with a yellow exclamation mark in the device manager.
And the next device plugged in gets then not detected because all 
preallocated slots are full :-(


Any ideas?

Best regards,

Erik








Re: [Qemu-devel] [regression] qemu-system-arm: segfault in lsi_do_command

2011-05-16 Thread Jonathan Nieder
Paolo Bonzini wrote:

> This fixes it on top of my SCSI refactoring series.

Thanks!  Works here, too, for what it's worth.

I squashed the following in when applying the "scsi: introduce
scsi_req_cancel" patch, for easier reading and to get a little closer
to warning-free compilation with gcc 4.6.

Signed-off-by: Jonathan Nieder 
---
 hw/lsi53c895a.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index f291283..43de6f8 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -889,7 +889,6 @@ static void lsi_do_msgout(LSIState *s)
 uint8_t msg;
 int len;
 uint32_t current_tag;
-SCSIDevice *current_dev;
 lsi_request *current_req, *p, *p_next;
 int id;
 
@@ -900,8 +899,6 @@ static void lsi_do_msgout(LSIState *s)
 current_tag = s->select_tag;
 current_req = lsi_find_by_tag(s, current_tag);
 }
-id = (current_tag >> 8) & 0xf;
-current_dev = s->bus.devs[id];
 
 DPRINTF("MSG out len=%d\n", s->dbc);
 while (s->dbc) {
-- 
1.7.5.1




[Qemu-devel] [PATCH v3] Add an isa device for SGA

2011-05-16 Thread Glauber Costa
This patch adds a dummy legacy ISA device whose responsibility is to
deploy sgabios, an option rom for a serial graphics adapter.
The proposal is that this device is always-on when -nographics,
but can otherwise be enable in any setup when -device sga is used.

[v2: suggestions on qdev by Markus ]
[v3: cleanups and documentation, per list suggestions ]

Signed-off-by: Glauber Costa 
---
 Makefile.target |2 +-
 hw/pc.c |9 
 hw/sga.c|   56 +++
 3 files changed, 66 insertions(+), 1 deletions(-)
 create mode 100644 hw/sga.c

diff --git a/Makefile.target b/Makefile.target
index fdbdc6c..004ea7e 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -224,7 +224,7 @@ obj-$(CONFIG_KVM) += ivshmem.o
 # Hardware support
 obj-i386-y += vga.o
 obj-i386-y += mc146818rtc.o i8259.o pc.o
-obj-i386-y += cirrus_vga.o apic.o ioapic.o piix_pci.o
+obj-i386-y += cirrus_vga.o sga.o apic.o ioapic.o piix_pci.o
 obj-i386-y += vmport.o
 obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o
 obj-i386-y += extboot.o
diff --git a/hw/pc.c b/hw/pc.c
index 8d351ba..5a8e00a 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1096,6 +1096,15 @@ void pc_vga_init(PCIBus *pci_bus)
 isa_vga_init();
 }
 }
+
+/*
+ * sga does not suppress normal vga output. So a machine can have both a
+ * vga card and sga manually enabled. Output will be seen on both.
+ * For nographic case, sga is enabled at all times
+ */
+if (display_type == DT_NOGRAPHIC) {
+isa_create_simple("sga");
+}
 }
 
 static void cpu_request_exit(void *opaque, int irq, int level)
diff --git a/hw/sga.c b/hw/sga.c
new file mode 100644
index 000..7ef750a
--- /dev/null
+++ b/hw/sga.c
@@ -0,0 +1,56 @@
+/*
+ * QEMU dummy ISA device for loading sgabios option rom.
+ *
+ * Copyright (c) 2011 Glauber Costa, Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * sgabios code originally available at code.google.com/p/sgabios
+ *
+ */
+#include "pci.h"
+#include "pc.h"
+#include "loader.h"
+#include "sysemu.h"
+
+#define SGABIOS_FILENAME "sgabios.bin"
+
+typedef struct ISAGAState {
+ISADevice dev;
+} ISASGAState;
+
+static int isa_cirrus_vga_initfn(ISADevice *dev)
+{
+rom_add_vga(SGABIOS_FILENAME);
+return 0;
+}
+
+static ISADeviceInfo sga_info = {
+.qdev.name= "sga",
+.qdev.desc= "Serial Graphics Adapter",
+.qdev.size= sizeof(ISASGAState),
+.init = isa_cirrus_vga_initfn,
+};
+
+static void sga_register(void)
+{
+  isa_qdev_register(&sga_info);
+}
+
+device_init(sga_register);
-- 
1.7.4.2




Re: [Qemu-devel] KVM call agenda for May 17th

2011-05-16 Thread Anthony Liguori

On 05/16/2011 07:17 AM, Paolo Bonzini wrote:

On 05/16/2011 12:07 PM, Juan Quintela wrote:

From two weeks ago, we have already:

- import kvm headers into qemu, drop #ifdef maze (Jan)


SCSI patches merge plan


 - libtool usage

Regards,

Anthony Liguori



Paolo






Re: [Qemu-devel] TCG: AREG0 removal planning

2011-05-16 Thread Blue Swirl
On Mon, May 16, 2011 at 7:16 PM, Paul Brook  wrote:
>> > For changes to
>> > the TCG side we want to consider how we can provide useful aliasing
>> > information, rather than a naive replacement of TCG_AREG0 with a
>> > variable.
>>
>> What aliasing information?
>
> Aliasing of cpu state accesses between tcg_global_mem_new_* variables,
> qemu_ld/st ops, and helper functions.

Structures describing such aliases must be somewhat complex. Those
descriptors should then be attached to these variables, ops and
functions. Checking the structures during translation may be simpler
but I'd expect some kind of list or bit map search to happen for each
access to these variables etc.

Maybe you have a better design in mind, but I'm not sure this way
would bring performance. The translator can't be too complex.



[Qemu-devel] [PATCH 00/18] usb patch queue: add usb 2.0

2011-05-16 Thread Gerd Hoffmann
  Hi,

Here is the current usb patch queue.  Patches 1-9 have been on the list
already, the other ones are new.  I plan to send a pull request for this
stuff next week.

The major new feature added is USB 2.0 support:  A bunch of fixes and
improvements for the usb passthrough code.  The EHCI host adapter.

Don't expect this being rock solid, EHCI has some known issues.  I want
stabilize EHCI support in-tree though to ease testing.  I hope to get it
reasonable good stabilized for the 0.15 release, failing that there is
still the option to disable it by default.

Improving documentation as requested in recent reviews has been defered
until we have a qdev documentation plan.

The patches are available in the git repository at:

  git://git.kraxel.org/qemu usb.11.pull

please review,
  Gerd

Brad Hards (4):
  usb: Add Interface Association Descriptor descriptor type
  usb: update config descriptors to identify number of interfaces
  usb: remove fallback to bNumInterfaces if no .nif
  usb: add support for "grouped" interfaces and the Interface
Association Descriptor

Gerd Hoffmann (11):
  usb-linux: fix device path aka physical port handling
  usb-linux: add hostport property
  usb-linux: track aurbs in list
  usb-linux: walk async urb list in cancel
  usb-linux: split large xfers
  usb-linux: fix max_packet_size for highspeed.
  usb: add usb_handle_packet
  usb: keep track of packet owner.
  usb: move cancel callback to USBDeviceInfo
  usb-storage: don't call usb_packet_complete twice
  usb: add ehci adapter

Hans de Goede (2):
  usb: Pass the packet to the device's handle_control callback
  usb-linux: use usb_generic_handle_packet()

Jan Vesely (1):
  Bug #757654: UHCI fails to signal stall response patch

 Makefile.objs   |1 +
 default-configs/pci.mak |1 +
 docs/usb2.txt   |   38 +
 hw/bt-hid.c |6 +-
 hw/pci_ids.h|1 +
 hw/usb-bt.c |6 +-
 hw/usb-ccid.c   |4 +-
 hw/usb-desc.c   |   56 ++-
 hw/usb-desc.h   |   24 +-
 hw/usb-ehci.c   | 2057 +++
 hw/usb-ehci.h   |8 +
 hw/usb-hid.c|9 +-
 hw/usb-hub.c|9 +-
 hw/usb-msd.c|   18 +-
 hw/usb-musb.c   |2 +-
 hw/usb-net.c|6 +-
 hw/usb-ohci.c   |4 +-
 hw/usb-serial.c |7 +-
 hw/usb-uhci.c   |6 +-
 hw/usb-wacom.c  |7 +-
 hw/usb.c|  101 +++-
 hw/usb.h|   40 +-
 usb-bsd.c   |1 +
 usb-linux.c |  440 ---
 24 files changed, 2469 insertions(+), 383 deletions(-)
 create mode 100644 docs/usb2.txt
 create mode 100644 hw/usb-ehci.c
 create mode 100644 hw/usb-ehci.h




[Qemu-devel] [PATCH 06/18] usb: Pass the packet to the device's handle_control callback

2011-05-16 Thread Gerd Hoffmann
From: Hans de Goede 

This allows using the generic usb_generic_handle_packet function from
device code which does ASYNC control requests (such as the linux host
pass through code).

Signed-off-by: Hans de Goede 
Signed-off-by: Gerd Hoffmann 
---
 hw/bt-hid.c |6 +++---
 hw/usb-bt.c |6 +++---
 hw/usb-ccid.c   |4 ++--
 hw/usb-desc.c   |4 ++--
 hw/usb-desc.h   |4 ++--
 hw/usb-hid.c|6 +++---
 hw/usb-hub.c|6 +++---
 hw/usb-msd.c|6 +++---
 hw/usb-net.c|6 +++---
 hw/usb-serial.c |6 +++---
 hw/usb-wacom.c  |6 +++---
 hw/usb.c|   11 +++
 hw/usb.h|2 +-
 usb-bsd.c   |1 +
 14 files changed, 39 insertions(+), 35 deletions(-)

diff --git a/hw/bt-hid.c b/hw/bt-hid.c
index abdfd35..09120af 100644
--- a/hw/bt-hid.c
+++ b/hw/bt-hid.c
@@ -323,7 +323,7 @@ static void bt_hid_control_transaction(struct 
bt_hid_device_s *s,
 break;
 }
 s->proto = parameter;
-s->usbdev->info->handle_control(s->usbdev, SET_PROTOCOL, s->proto, 0, 
0,
+s->usbdev->info->handle_control(s->usbdev, NULL, SET_PROTOCOL, 
s->proto, 0, 0,
 NULL);
 ret = BT_HS_SUCCESSFUL;
 break;
@@ -333,7 +333,7 @@ static void bt_hid_control_transaction(struct 
bt_hid_device_s *s,
 ret = BT_HS_ERR_INVALID_PARAMETER;
 break;
 }
-s->usbdev->info->handle_control(s->usbdev, GET_IDLE, 0, 0, 1,
+s->usbdev->info->handle_control(s->usbdev, NULL, GET_IDLE, 0, 0, 1,
 s->control->sdu_out(s->control, 1));
 s->control->sdu_submit(s->control);
 break;
@@ -346,7 +346,7 @@ static void bt_hid_control_transaction(struct 
bt_hid_device_s *s,
 
 /* We don't need to know about the Idle Rate here really,
  * so just pass it on to the device.  */
-ret = s->usbdev->info->handle_control(s->usbdev,
+ret = s->usbdev->info->handle_control(s->usbdev, NULL,
 SET_IDLE, data[1], 0, 0, NULL) ?
 BT_HS_SUCCESSFUL : BT_HS_ERR_INVALID_PARAMETER;
 /* XXX: Does this generate a handshake? */
diff --git a/hw/usb-bt.c b/hw/usb-bt.c
index 22e6845..baae487 100644
--- a/hw/usb-bt.c
+++ b/hw/usb-bt.c
@@ -372,13 +372,13 @@ static void usb_bt_handle_reset(USBDevice *dev)
 s->altsetting = 0;
 }
 
-static int usb_bt_handle_control(USBDevice *dev, int request, int value,
-int index, int length, uint8_t *data)
+static int usb_bt_handle_control(USBDevice *dev, USBPacket *p,
+   int request, int value, int index, int length, uint8_t *data)
 {
 struct USBBtState *s = (struct USBBtState *) dev->opaque;
 int ret;
 
-ret = usb_desc_handle_control(dev, request, value, index, length, data);
+ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
 if (ret >= 0) {
 switch (request) {
 case DeviceRequest | USB_REQ_GET_CONFIGURATION:
diff --git a/hw/usb-ccid.c b/hw/usb-ccid.c
index 079b4a2..5b6878b 100644
--- a/hw/usb-ccid.c
+++ b/hw/usb-ccid.c
@@ -602,8 +602,8 @@ static void ccid_handle_reset(USBDevice *dev)
 ccid_reset(s);
 }
 
-static int ccid_handle_control(USBDevice *dev, int request, int value,
-  int index, int length, uint8_t *data)
+static int ccid_handle_control(USBDevice *dev, USBPacket *p, int request,
+   int value, int index, int length, uint8_t *data)
 {
 USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev);
 int ret = 0;
diff --git a/hw/usb-desc.c b/hw/usb-desc.c
index 8367c45..e4a4680 100644
--- a/hw/usb-desc.c
+++ b/hw/usb-desc.c
@@ -390,8 +390,8 @@ int usb_desc_get_descriptor(USBDevice *dev, int value, 
uint8_t *dest, size_t len
 return ret;
 }
 
-int usb_desc_handle_control(USBDevice *dev, int request, int value,
-int index, int length, uint8_t *data)
+int usb_desc_handle_control(USBDevice *dev, USBPacket *p,
+int request, int value, int index, int length, uint8_t *data)
 {
 const USBDesc *desc = dev->info->usb_desc;
 int i, ret = -1;
diff --git a/hw/usb-desc.h b/hw/usb-desc.h
index a612515..9d7ed59 100644
--- a/hw/usb-desc.h
+++ b/hw/usb-desc.h
@@ -106,7 +106,7 @@ void usb_desc_set_string(USBDevice *dev, uint8_t index, 
const char *str);
 const char *usb_desc_get_string(USBDevice *dev, uint8_t index);
 int usb_desc_string(USBDevice *dev, int index, uint8_t *dest, size_t len);
 int usb_desc_get_descriptor(USBDevice *dev, int value, uint8_t *dest, size_t 
len);
-int usb_desc_handle_control(USBDevice *dev, int request, int value,
-int index, int length, uint8_t *data);
+int usb_desc_handle_control(USBDevice *dev, USBPacket *p,
+int request, int value, int index, int length, uint8_t *data);
 
 #endif /* QEMU_HW_USB_DESC_H */
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index bf59a7d..53b261c 100644
--- a/hw/usb-hid.c
++

[Qemu-devel] [PATCH 01/18] usb: Add Interface Association Descriptor descriptor type

2011-05-16 Thread Gerd Hoffmann
From: Brad Hards 

Signed-off-by: Brad Hards 
Signed-off-by: Gerd Hoffmann 
---
 hw/usb.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/hw/usb.h b/hw/usb.h
index 7e46141..ca06bf8 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -124,6 +124,7 @@
 #define USB_DT_ENDPOINT0x05
 #define USB_DT_DEVICE_QUALIFIER 0x06
 #define USB_DT_OTHER_SPEED_CONFIG   0x07
+#define USB_DT_INTERFACE_ASSOC  0x0B
 
 #define USB_ENDPOINT_XFER_CONTROL  0
 #define USB_ENDPOINT_XFER_ISOC 1
-- 
1.7.1




[Qemu-devel] [PATCH 11/18] usb-linux: walk async urb list in cancel

2011-05-16 Thread Gerd Hoffmann
Lookup async urbs which are to be canceled using the linked list
instead of the direct opaque pointer.  There are two reasons we
are doing that:  First, to avoid the opaque poiner to the callback,
which is needed for upcoming cleanups.  Second, because we might
need multiple urbs per request for highspeed support, so a single
opaque pointer doesn't cut it any more anyway.

Signed-off-by: Gerd Hoffmann 
---
 usb-linux.c |   28 +---
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index 3c5a248..b8f7705 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -315,19 +315,25 @@ static void async_complete(void *opaque)
 }
 }
 
-static void async_cancel(USBPacket *unused, void *opaque)
+static void async_cancel(USBPacket *p, void *opaque)
 {
-AsyncURB *aurb = opaque;
-USBHostDevice *s = aurb->hdev;
+USBHostDevice *s = opaque;
+AsyncURB *aurb;
 
-DPRINTF("husb: async cancel. aurb %p\n", aurb);
+QLIST_FOREACH(aurb, &s->aurbs, next) {
+if (p != aurb->packet) {
+continue;
+}
 
-/* Mark it as dead (see async_complete above) */
-aurb->packet = NULL;
+DPRINTF("husb: async cancel: packet %p, aurb %p\n", p, aurb);
 
-int r = ioctl(s->fd, USBDEVFS_DISCARDURB, aurb);
-if (r < 0) {
-DPRINTF("husb: async. discard urb failed errno %d\n", errno);
+/* Mark it as dead (see async_complete above) */
+aurb->packet = NULL;
+
+int r = ioctl(s->fd, USBDEVFS_DISCARDURB, aurb);
+if (r < 0) {
+DPRINTF("husb: async. discard urb failed errno %d\n", errno);
+}
 }
 }
 
@@ -696,7 +702,7 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket 
*p)
 }
 }
 
-usb_defer_packet(p, async_cancel, aurb);
+usb_defer_packet(p, async_cancel, s);
 return USB_RET_ASYNC;
 }
 
@@ -828,7 +834,7 @@ static int usb_host_handle_control(USBDevice *dev, 
USBPacket *p,
 }
 }
 
-usb_defer_packet(p, async_cancel, aurb);
+usb_defer_packet(p, async_cancel, s);
 return USB_RET_ASYNC;
 }
 
-- 
1.7.1




[Qemu-devel] [PATCH 03/18] usb: remove fallback to bNumInterfaces if no .nif

2011-05-16 Thread Gerd Hoffmann
From: Brad Hards 

All callers have been updated.

Signed-off-by: Brad Hards 
Signed-off-by: Gerd Hoffmann 
---
 hw/usb-desc.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/usb-desc.c b/hw/usb-desc.c
index 62591f2..a784155 100644
--- a/hw/usb-desc.c
+++ b/hw/usb-desc.c
@@ -76,7 +76,7 @@ int usb_desc_config(const USBDescConfig *conf, uint8_t *dest, 
size_t len)
 {
 uint8_t  bLength = 0x09;
 uint16_t wTotalLength = 0;
-int i, rc, count;
+int i, rc;
 
 if (len < bLength) {
 return -1;
@@ -91,8 +91,7 @@ int usb_desc_config(const USBDescConfig *conf, uint8_t *dest, 
size_t len)
 dest[0x08] = conf->bMaxPower;
 wTotalLength += bLength;
 
-count = conf->nif ? conf->nif : conf->bNumInterfaces;
-for (i = 0; i < count; i++) {
+for (i = 0; i < conf->nif; i++) {
 rc = usb_desc_iface(conf->ifs + i, dest + wTotalLength, len - 
wTotalLength);
 if (rc < 0) {
 return rc;
-- 
1.7.1




[Qemu-devel] [PATCH 13/18] usb-linux: fix max_packet_size for highspeed.

2011-05-16 Thread Gerd Hoffmann
Calculate the max packet size correctly.  Only bits 0..11 specify the size,
bits 11+12 specify the number of (highspeed) microframes the endpoint wants
to use.

Signed-off-by: Gerd Hoffmann 
---
 usb-linux.c |   19 +--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index b95c119..5547b02 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -213,6 +213,22 @@ static int get_iso_buffer_used(USBHostDevice *s, int ep)
 return s->endp_table[ep - 1].iso_buffer_used;
 }
 
+static void set_max_packet_size(USBHostDevice *s, int ep, uint8_t *descriptor)
+{
+int raw = descriptor[4] + (descriptor[5] << 8);
+int size, microframes;
+
+size = raw & 0x7ff;
+switch ((raw >> 11) & 3) {
+case 1:  microframes = 2; break;
+case 2:  microframes = 3; break;
+default: microframes = 1; break;
+}
+DPRINTF("husb: max packet size: 0x%x -> %d x %d\n",
+raw, microframes, size);
+s->endp_table[ep - 1].max_packet_size = size * microframes;
+}
+
 static int get_max_packet_size(USBHostDevice *s, int ep)
 {
 return s->endp_table[ep - 1].max_packet_size;
@@ -1008,8 +1024,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
 break;
 case 0x01:
 type = USBDEVFS_URB_TYPE_ISO;
-s->endp_table[(devep & 0xf) - 1].max_packet_size =
-descriptors[i + 4] + (descriptors[i + 5] << 8);
+set_max_packet_size(s, (devep & 0xf), descriptors + i);
 break;
 case 0x02:
 type = USBDEVFS_URB_TYPE_BULK;
-- 
1.7.1




[Qemu-devel] [PATCH 09/18] usb-linux: add hostport property

2011-05-16 Thread Gerd Hoffmann
This patch adds a hostport property which allows to specify the host usb
devices to pass through by bus number and physical port.  This means you
can basically hand over one (or more) of the usb plugs on your host to
the guest and whatever device is plugged in there will show up in the
guest.

Usage:

  -device usb-host,hostbus=1,hostport=1

You can figure the port numbers by plugging in some usb device, then
find it in "info usbhost" and pick bus and port specified there.

Signed-off-by: Gerd Hoffmann 
---
 usb-linux.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index 2fa3591..b75c48b 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -104,6 +104,7 @@ struct endp_data {
 struct USBAutoFilter {
 uint32_t bus_num;
 uint32_t addr;
+char *port;
 uint32_t vendor_id;
 uint32_t product_id;
 };
@@ -1162,6 +1163,7 @@ static struct USBDeviceInfo usb_host_dev_info = {
 .qdev.props = (Property[]) {
 DEFINE_PROP_UINT32("hostbus",  USBHostDevice, match.bus_num,0),
 DEFINE_PROP_UINT32("hostaddr", USBHostDevice, match.addr,   0),
+DEFINE_PROP_STRING("hostport", USBHostDevice, match.port),
 DEFINE_PROP_HEX32("vendorid",  USBHostDevice, match.vendor_id,  0),
 DEFINE_PROP_HEX32("productid", USBHostDevice, match.product_id, 0),
 DEFINE_PROP_END_OF_LIST(),
@@ -1584,6 +1586,9 @@ static int usb_host_auto_scan(void *opaque, int bus_num, 
int addr, char *port,
 if (f->addr > 0 && f->addr != addr) {
 continue;
 }
+if (f->port != NULL && (port == NULL || strcmp(f->port, port) != 0)) {
+continue;
+}
 
 if (f->vendor_id > 0 && f->vendor_id != vendor_id) {
 continue;
@@ -1809,7 +1814,7 @@ void usb_host_info(Monitor *mon)
 dec2str(f->addr, addr, sizeof(addr));
 hex2str(f->vendor_id, vid, sizeof(vid));
 hex2str(f->product_id, pid, sizeof(pid));
-monitor_printf(mon, "Device %s.%s ID %s:%s\n",
-   bus, addr, vid, pid);
+monitor_printf(mon, "Bus %s, Addr %s, Port %s, ID %s:%s\n",
+   bus, addr, f->port ? f->port : "*", vid, pid);
 }
 }
-- 
1.7.1




[Qemu-devel] [PATCH 05/18] Bug #757654: UHCI fails to signal stall response patch

2011-05-16 Thread Gerd Hoffmann
From: Jan Vesely 

UHCI host controller status register indicates error and
an interrupt is triggered on BABBLE and STALL errors.

Signed-off-by: Jan Vesely 
Signed-off-by: Gerd Hoffmann 
---
 hw/usb-uhci.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index a65e0b3..1e9c1e7 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -702,11 +702,15 @@ out:
 case USB_RET_STALL:
 td->ctrl |= TD_CTRL_STALL;
 td->ctrl &= ~TD_CTRL_ACTIVE;
+s->status |= UHCI_STS_USBERR;
+uhci_update_irq(s);
 return 1;
 
 case USB_RET_BABBLE:
 td->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL;
 td->ctrl &= ~TD_CTRL_ACTIVE;
+s->status |= UHCI_STS_USBERR;
+uhci_update_irq(s);
 /* frame interrupted */
 return -1;
 
-- 
1.7.1




[Qemu-devel] [PATCH 10/18] usb-linux: track aurbs in list

2011-05-16 Thread Gerd Hoffmann
This patch adds code to track all async urbs in a linked list,
so we can find them without having to pass around a opaque
pointer to them.  Prerequisite for the cleanups.

Signed-off-by: Gerd Hoffmann 
---
 usb-linux.c |   18 +++---
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index b75c48b..3c5a248 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -121,6 +121,7 @@ typedef struct USBHostDevice {
 Notifier  exit;
 
 struct endp_data endp_table[MAX_ENDPOINTS];
+QLIST_HEAD(, AsyncURB) aurbs;
 
 /* Host side address */
 int bus_num;
@@ -223,22 +224,27 @@ struct AsyncURB
 {
 struct usbdevfs_urb urb;
 struct usbdevfs_iso_packet_desc isocpd[ISO_FRAME_DESC_PER_URB];
+USBHostDevice *hdev;
+QLIST_ENTRY(AsyncURB) next;
 
 /* For regular async urbs */
 USBPacket *packet;
-USBHostDevice *hdev;
 
 /* For buffered iso handling */
 int iso_frame_idx; /* -1 means in flight */
 };
 
-static AsyncURB *async_alloc(void)
+static AsyncURB *async_alloc(USBHostDevice *s)
 {
-return (AsyncURB *) qemu_mallocz(sizeof(AsyncURB));
+AsyncURB *aurb = qemu_mallocz(sizeof(AsyncURB));
+aurb->hdev = s;
+QLIST_INSERT_HEAD(&s->aurbs, aurb, next);
+return aurb;
 }
 
 static void async_free(AsyncURB *aurb)
 {
+QLIST_REMOVE(aurb, next);
 qemu_free(aurb);
 }
 
@@ -661,8 +667,7 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket 
*p)
 return usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN);
 }
 
-aurb = async_alloc();
-aurb->hdev   = s;
+aurb = async_alloc(s);
 aurb->packet = p;
 
 urb = &aurb->urb;
@@ -787,8 +792,7 @@ static int usb_host_handle_control(USBDevice *dev, 
USBPacket *p,
 return USB_RET_STALL;
 }
 
-aurb = async_alloc();
-aurb->hdev   = s;
+aurb = async_alloc(s);
 aurb->packet = p;
 
 /*
-- 
1.7.1




[Qemu-devel] [PATCH 14/18] usb: add usb_handle_packet

2011-05-16 Thread Gerd Hoffmann
Add a usb_handle_packet function, put it into use everywhere.
Right now it just calls dev->info->handle_packet(), that will
change in future patches though.

Signed-off-by: Gerd Hoffmann 
---
 hw/usb-hub.c  |2 +-
 hw/usb-musb.c |2 +-
 hw/usb-ohci.c |4 ++--
 hw/usb-uhci.c |2 +-
 hw/usb.c  |   17 +++--
 hw/usb.h  |2 ++
 6 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index 477927b..6e2a358 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -495,7 +495,7 @@ static int usb_hub_broadcast_packet(USBHubState *s, 
USBPacket *p)
 port = &s->ports[i];
 dev = port->port.dev;
 if (dev && (port->wPortStatus & PORT_STAT_ENABLE)) {
-ret = dev->info->handle_packet(dev, p);
+ret = usb_handle_packet(dev, p);
 if (ret != USB_RET_NODEV) {
 return ret;
 }
diff --git a/hw/usb-musb.c b/hw/usb-musb.c
index 38986d3..6037193 100644
--- a/hw/usb-musb.c
+++ b/hw/usb-musb.c
@@ -601,7 +601,7 @@ static void musb_packet(MUSBState *s, MUSBEndPoint *ep,
 ep->packey[dir].dir = dir;
 
 if (s->port.dev)
-ret = s->port.dev->info->handle_packet(s->port.dev, 
&ep->packey[dir].p);
+ret = usb_handle_packet(s->port.dev, &ep->packey[dir].p);
 else
 ret = USB_RET_NODEV;
 
diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index 32913eb..8b966f7 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -748,7 +748,7 @@ static int ohci_service_iso_td(OHCIState *ohci, struct 
ohci_ed *ed,
 ohci->usb_packet.devep = OHCI_BM(ed->flags, ED_EN);
 ohci->usb_packet.data = ohci->usb_buf;
 ohci->usb_packet.len = len;
-ret = dev->info->handle_packet(dev, &ohci->usb_packet);
+ret = usb_handle_packet(dev, &ohci->usb_packet);
 if (ret != USB_RET_NODEV)
 break;
 }
@@ -944,7 +944,7 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed 
*ed)
 ohci->usb_packet.devep = OHCI_BM(ed->flags, ED_EN);
 ohci->usb_packet.data = ohci->usb_buf;
 ohci->usb_packet.len = len;
-ret = dev->info->handle_packet(dev, &ohci->usb_packet);
+ret = usb_handle_packet(dev, &ohci->usb_packet);
 if (ret != USB_RET_NODEV)
 break;
 }
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 1e9c1e7..c0de05b 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -632,7 +632,7 @@ static int uhci_broadcast_packet(UHCIState *s, USBPacket *p)
 USBDevice *dev = port->port.dev;
 
 if (dev && (port->ctrl & UHCI_PORT_EN))
-ret = dev->info->handle_packet(dev, p);
+ret = usb_handle_packet(dev, p);
 }
 
 DPRINTF("uhci: packet exit. ret %d len %d\n", ret, p->len);
diff --git a/hw/usb.c b/hw/usb.c
index 60027c6..966cb0f 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -297,9 +297,22 @@ int set_usb_string(uint8_t *buf, const char *str)
 void usb_send_msg(USBDevice *dev, int msg)
 {
 USBPacket p;
+int ret;
+
 memset(&p, 0, sizeof(p));
 p.pid = msg;
-dev->info->handle_packet(dev, &p);
-
+ret = usb_handle_packet(dev, &p);
 /* This _must_ be synchronous */
+assert(ret != USB_RET_ASYNC);
+}
+
+/* Hand over a packet to a device for processing.  Return value
+   USB_RET_ASYNC indicates the processing isn't finished yet, the
+   driver will call usb_packet_complete() when done processing it. */
+int usb_handle_packet(USBDevice *dev, USBPacket *p)
+{
+int ret;
+
+ret = dev->info->handle_packet(dev, p);
+return ret;
 }
diff --git a/hw/usb.h b/hw/usb.h
index c1d1014..6889467 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -266,6 +266,8 @@ struct USBPacket {
 void *cancel_opaque;
 };
 
+int usb_handle_packet(USBDevice *dev, USBPacket *p);
+
 /* Defer completion of a USB packet.  The hadle_packet routine should then
return USB_RET_ASYNC.  Packets that complete immediately (before
handle_packet returns) should not call this method.  */
-- 
1.7.1




[Qemu-devel] [PATCH 08/18] usb-linux: fix device path aka physical port handling

2011-05-16 Thread Gerd Hoffmann
The device path isn't just a number.  It specifies the physical port
the device is connected to and in case the device is connected via
usb hub you'll have two numbers there, like this: "5.1".  The first
specifies the root port where the hub is plugged into, the second
specifies the port number of the hub where the device is plugged in.
With multiple hubs chained the string can become longer.

This patch renames devpath to port and makes it a string.   It also
adapts the sysfs parsing code accordingly.  The "info usbhost" monitor
command now prints bus number, (os-assigned) device address and physical
port for each device.

Signed-off-by: Gerd Hoffmann 
---
 usb-linux.c |   38 --
 1 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index 84d3a8b..2fa3591 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -54,7 +54,7 @@ struct usb_ctrltransfer {
 void *data;
 };
 
-typedef int USBScanFunc(void *opaque, int bus_num, int addr, int devpath,
+typedef int USBScanFunc(void *opaque, int bus_num, int addr, char *port,
 int class_id, int vendor_id, int product_id,
 const char *product_name, int speed);
 
@@ -71,6 +71,7 @@ typedef int USBScanFunc(void *opaque, int bus_num, int addr, 
int devpath,
 #define USBPROCBUS_PATH "/proc/bus/usb"
 #define PRODUCT_NAME_SZ 32
 #define MAX_ENDPOINTS 15
+#define MAX_PORTLEN 8
 #define USBDEVBUS_PATH "/dev/bus/usb"
 #define USBSYSBUS_PATH "/sys/bus/usb"
 
@@ -123,7 +124,7 @@ typedef struct USBHostDevice {
 /* Host side address */
 int bus_num;
 int addr;
-int devpath;
+char port[MAX_PORTLEN];
 struct USBAutoFilter match;
 
 QTAILQ_ENTRY(USBHostDevice) next;
@@ -836,7 +837,7 @@ static int usb_linux_get_configuration(USBHostDevice *s)
 char device_name[32], line[1024];
 int configuration;
 
-sprintf(device_name, "%d-%d", s->bus_num, s->devpath);
+sprintf(device_name, "%d-%s", s->bus_num, s->port);
 
 if (!usb_host_read_file(line, sizeof(line), "bConfigurationValue",
 device_name)) {
@@ -882,7 +883,7 @@ static uint8_t usb_linux_get_alt_setting(USBHostDevice *s,
 char device_name[64], line[1024];
 int alt_setting;
 
-sprintf(device_name, "%d-%d:%d.%d", s->bus_num, s->devpath,
+sprintf(device_name, "%d-%s:%d.%d", s->bus_num, s->port,
 (int)configuration, (int)interface);
 
 if (!usb_host_read_file(line, sizeof(line), "bAlternateSetting",
@@ -1001,7 +1002,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
 }
 
 static int usb_host_open(USBHostDevice *dev, int bus_num,
- int addr, int devpath, const char *prod_name)
+ int addr, char *port, const char *prod_name)
 {
 int fd = -1, ret;
 struct usbdevfs_connectinfo ci;
@@ -1027,7 +1028,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num,
 
 dev->bus_num = bus_num;
 dev->addr = addr;
-dev->devpath = devpath;
+strcpy(dev->port, port);
 dev->fd = fd;
 
 /* read the device description */
@@ -1401,8 +1402,9 @@ static int usb_host_scan_sys(void *opaque, USBScanFunc 
*func)
 {
 DIR *dir = NULL;
 char line[1024];
-int bus_num, addr, devpath, speed, class_id, product_id, vendor_id;
+int bus_num, addr, speed, class_id, product_id, vendor_id;
 int ret = 0;
+char port[MAX_PORTLEN];
 char product_name[512];
 struct dirent *de;
 
@@ -1418,8 +1420,8 @@ static int usb_host_scan_sys(void *opaque, USBScanFunc 
*func)
 if (!strncmp(de->d_name, "usb", 3)) {
 tmpstr += 3;
 }
-if (sscanf(tmpstr, "%d-%d", &bus_num, &devpath) < 1) {
-goto the_end;
+if (sscanf(tmpstr, "%d-%7[0-9.]", &bus_num, port) < 2) {
+continue;
 }
 
 if (!usb_host_read_file(line, sizeof(line), "devnum", de->d_name)) 
{
@@ -1471,7 +1473,7 @@ static int usb_host_scan_sys(void *opaque, USBScanFunc 
*func)
 speed = USB_SPEED_FULL;
 }
 
-ret = func(opaque, bus_num, addr, devpath, class_id, vendor_id,
+ret = func(opaque, bus_num, addr, port, class_id, vendor_id,
product_id, product_name, speed);
 if (ret) {
 goto the_end;
@@ -1562,7 +1564,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)
 
 static QEMUTimer *usb_auto_timer;
 
-static int usb_host_auto_scan(void *opaque, int bus_num, int addr, int devpath,
+static int usb_host_auto_scan(void *opaque, int bus_num, int addr, char *port,
   int class_id, int vendor_id, int product_id,
   const char *product_name, int speed)
 {
@@ -1598,7 +1600,7 @@ static int usb_host_auto_scan(void *opaque, int bus_num, 
int addr, int devpath,
 }
 DPRINTF("husb: a

[Qemu-devel] [PATCH 02/18] usb: update config descriptors to identify number of interfaces

2011-05-16 Thread Gerd Hoffmann
From: Brad Hards 

Previously we relied on the .bNumInterfaces, but that won't always be
accurate after the introduction of grouped interfaces.

Signed-off-by: Brad Hards 
Signed-off-by: Gerd Hoffmann 
---
 hw/usb-hid.c|3 +++
 hw/usb-hub.c|1 +
 hw/usb-msd.c|2 ++
 hw/usb-serial.c |1 +
 hw/usb-wacom.c  |1 +
 5 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index 89c293c..bf59a7d 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -211,6 +211,7 @@ static const USBDescDevice desc_device_mouse = {
 .iConfiguration= STR_CONFIG_MOUSE,
 .bmAttributes  = 0xa0,
 .bMaxPower = 50,
+.nif = 1,
 .ifs = &desc_iface_mouse,
 },
 },
@@ -227,6 +228,7 @@ static const USBDescDevice desc_device_tablet = {
 .iConfiguration= STR_CONFIG_TABLET,
 .bmAttributes  = 0xa0,
 .bMaxPower = 50,
+.nif = 1,
 .ifs = &desc_iface_tablet,
 },
 },
@@ -243,6 +245,7 @@ static const USBDescDevice desc_device_keyboard = {
 .iConfiguration= STR_CONFIG_KEYBOARD,
 .bmAttributes  = 0xa0,
 .bMaxPower = 50,
+.nif = 1,
 .ifs = &desc_iface_keyboard,
 },
 },
diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index e0588f8..7c1f159 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -119,6 +119,7 @@ static const USBDescDevice desc_device_hub = {
 .bNumInterfaces= 1,
 .bConfigurationValue   = 1,
 .bmAttributes  = 0xe0,
+.nif = 1,
 .ifs = &desc_iface_hub,
 },
 },
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index bd1c3a4..040ea7a 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -119,6 +119,7 @@ static const USBDescDevice desc_device_full = {
 .bConfigurationValue   = 1,
 .iConfiguration= STR_CONFIG_FULL,
 .bmAttributes  = 0xc0,
+.nif = 1,
 .ifs = &desc_iface_full,
 },
 },
@@ -153,6 +154,7 @@ static const USBDescDevice desc_device_high = {
 .bConfigurationValue   = 1,
 .iConfiguration= STR_CONFIG_HIGH,
 .bmAttributes  = 0xc0,
+.nif = 1,
 .ifs = &desc_iface_high,
 },
 },
diff --git a/hw/usb-serial.c b/hw/usb-serial.c
index 6763d52..48ea0d8 100644
--- a/hw/usb-serial.c
+++ b/hw/usb-serial.c
@@ -146,6 +146,7 @@ static const USBDescDevice desc_device = {
 .bConfigurationValue   = 1,
 .bmAttributes  = 0x80,
 .bMaxPower = 50,
+.nif = 1,
 .ifs = &desc_iface0,
 },
 },
diff --git a/hw/usb-wacom.c b/hw/usb-wacom.c
index 16be7a2..57041a1 100644
--- a/hw/usb-wacom.c
+++ b/hw/usb-wacom.c
@@ -108,6 +108,7 @@ static const USBDescDevice desc_device_wacom = {
 .bConfigurationValue   = 1,
 .bmAttributes  = 0x80,
 .bMaxPower = 40,
+.nif = 1,
 .ifs = &desc_iface_wacom,
 },
 },
-- 
1.7.1




[Qemu-devel] [PATCH 17/18] usb-storage: don't call usb_packet_complete twice

2011-05-16 Thread Gerd Hoffmann
usb_msd_copy_data() may cause a recursive call to
usb_msd_command_complete() which in turn may complete
the packet, setting s->packet to NULL in case it does.
Recheck s->packet before calling usb_packet_complete()
to fix the double call.

Signed-off-by: Gerd Hoffmann 
---
 hw/usb-msd.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 7a08358..141da2c 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -253,7 +253,7 @@ static void usb_msd_command_complete(SCSIBus *bus, int 
reason, uint32_t tag,
 s->scsi_buf = s->scsi_dev->info->get_buf(s->scsi_dev, tag);
 if (p) {
 usb_msd_copy_data(s);
-if (s->usb_len == 0) {
+if (s->packet && s->usb_len == 0) {
 /* Set s->packet to NULL before calling usb_packet_complete
because another request may be issued before
usb_packet_complete returns.  */
-- 
1.7.1




[Qemu-devel] [PATCH 12/18] usb-linux: split large xfers

2011-05-16 Thread Gerd Hoffmann
Add support for splitting large transfers into multiple smaller ones.
This is needed for the upcoming EHCI emulation which allows guests
to submit requests up to 20k in size.  The linux kernel allows 16k
max size though.

Roughly based on a patch from git://git.kiszka.org/qemu.git ehci

Signed-off-by: Gerd Hoffmann 
---
 usb-linux.c |   68 +-
 1 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index b8f7705..b95c119 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -89,6 +89,9 @@ static int usb_fs_type;
 #define ISO_URB_COUNT 3
 #define INVALID_EP_TYPE 255
 
+/* devio.c limits single requests to 16k */
+#define MAX_USBFS_BUFFER_SIZE 16384
+
 typedef struct AsyncURB AsyncURB;
 
 struct endp_data {
@@ -229,6 +232,7 @@ struct AsyncURB
 
 /* For regular async urbs */
 USBPacket *packet;
+int more; /* large transfer, more urbs follow */
 
 /* For buffered iso handling */
 int iso_frame_idx; /* -1 means in flight */
@@ -291,7 +295,7 @@ static void async_complete(void *opaque)
 if (p) {
 switch (aurb->urb.status) {
 case 0:
-p->len = aurb->urb.actual_length;
+p->len += aurb->urb.actual_length;
 break;
 
 case -EPIPE:
@@ -306,7 +310,7 @@ static void async_complete(void *opaque)
 
 if (aurb->urb.type == USBDEVFS_URB_TYPE_CONTROL) {
 usb_generic_async_ctrl_complete(&s->dev, p);
-} else {
+} else if (!aurb->more) {
 usb_packet_complete(&s->dev, p);
 }
 }
@@ -646,7 +650,8 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket 
*p)
 USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev);
 struct usbdevfs_urb *urb;
 AsyncURB *aurb;
-int ret;
+int ret, rem;
+uint8_t *pbuf;
 uint8_t ep;
 
 if (!is_valid(s, p->devep)) {
@@ -673,32 +678,45 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket 
*p)
 return usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN);
 }
 
-aurb = async_alloc(s);
-aurb->packet = p;
+rem = p->len;
+pbuf = p->data;
+p->len = 0;
+while (rem) {
+aurb = async_alloc(s);
+aurb->packet = p;
 
-urb = &aurb->urb;
+urb = &aurb->urb;
+urb->endpoint  = ep;
+urb->type  = USBDEVFS_URB_TYPE_BULK;
+urb->usercontext   = s;
+urb->buffer= pbuf;
 
-urb->endpoint  = ep;
-urb->buffer= p->data;
-urb->buffer_length = p->len;
-urb->type  = USBDEVFS_URB_TYPE_BULK;
-urb->usercontext   = s;
+if (rem > MAX_USBFS_BUFFER_SIZE) {
+urb->buffer_length = MAX_USBFS_BUFFER_SIZE;
+aurb->more = 1;
+} else {
+urb->buffer_length = rem;
+aurb->more = 0;
+}
+pbuf += urb->buffer_length;
+rem  -= urb->buffer_length;
 
-ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
+ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
 
-DPRINTF("husb: data submit. ep 0x%x len %u aurb %p\n",
-urb->endpoint, p->len, aurb);
+DPRINTF("husb: data submit: ep 0x%x, len %u, more %d, packet %p, aurb 
%p\n",
+urb->endpoint, urb->buffer_length, aurb->more, p, aurb);
 
-if (ret < 0) {
-DPRINTF("husb: submit failed. errno %d\n", errno);
-async_free(aurb);
+if (ret < 0) {
+DPRINTF("husb: submit failed. errno %d\n", errno);
+async_free(aurb);
 
-switch(errno) {
-case ETIMEDOUT:
-return USB_RET_NAK;
-case EPIPE:
-default:
-return USB_RET_STALL;
+switch(errno) {
+case ETIMEDOUT:
+return USB_RET_NAK;
+case EPIPE:
+default:
+return USB_RET_STALL;
+}
 }
 }
 
-- 
1.7.1




[Qemu-devel] [PATCH 16/18] usb: move cancel callback to USBDeviceInfo

2011-05-16 Thread Gerd Hoffmann
Remove the cancel callback from the USBPacket struct, move it over
to USBDeviceInfo.  Zap usb_defer_packet() which is obsolete now.

Signed-off-by: Gerd Hoffmann 
---
 hw/usb-msd.c |8 +++-
 hw/usb.c |2 +-
 hw/usb.h |   17 +
 usb-linux.c  |7 +++
 4 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index c3a197a..7a08358 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -315,9 +315,9 @@ static int usb_msd_handle_control(USBDevice *dev, USBPacket 
*p,
 return ret;
 }
 
-static void usb_msd_cancel_io(USBPacket *p, void *opaque)
+static void usb_msd_cancel_io(USBDevice *dev, USBPacket *p)
 {
-MSDState *s = opaque;
+MSDState *s = DO_UPCAST(MSDState, dev, dev);
 s->scsi_dev->info->cancel_io(s->scsi_dev, s->tag);
 s->packet = NULL;
 s->scsi_len = 0;
@@ -398,7 +398,6 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)
 }
 if (s->usb_len) {
 DPRINTF("Deferring packet %p\n", p);
-usb_defer_packet(p, usb_msd_cancel_io, s);
 s->packet = p;
 ret = USB_RET_ASYNC;
 } else {
@@ -421,7 +420,6 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)
 if (s->data_len != 0 || len < 13)
 goto fail;
 /* Waiting for SCSI write to complete.  */
-usb_defer_packet(p, usb_msd_cancel_io, s);
 s->packet = p;
 ret = USB_RET_ASYNC;
 break;
@@ -455,7 +453,6 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)
 }
 if (s->usb_len) {
 DPRINTF("Deferring packet %p\n", p);
-usb_defer_packet(p, usb_msd_cancel_io, s);
 s->packet = p;
 ret = USB_RET_ASYNC;
 } else {
@@ -604,6 +601,7 @@ static struct USBDeviceInfo msd_info = {
 .usb_desc   = &desc,
 .init   = usb_msd_initfn,
 .handle_packet  = usb_generic_handle_packet,
+.cancel_packet  = usb_msd_cancel_io,
 .handle_attach  = usb_desc_attach,
 .handle_reset   = usb_msd_handle_reset,
 .handle_control = usb_msd_handle_control,
diff --git a/hw/usb.c b/hw/usb.c
index 8a9a7fc..4a39cbc 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -345,6 +345,6 @@ void usb_packet_complete(USBDevice *dev, USBPacket *p)
 void usb_cancel_packet(USBPacket * p)
 {
 assert(p->owner != NULL);
-p->cancel_cb(p, p->cancel_opaque);
+p->owner->info->cancel_packet(p->owner, p);
 p->owner = NULL;
 }
diff --git a/hw/usb.h b/hw/usb.h
index 80e8e90..9882400 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -194,6 +194,11 @@ struct USBDeviceInfo {
 int (*handle_packet)(USBDevice *dev, USBPacket *p);
 
 /*
+ * Called when a packet is canceled.
+ */
+void (*cancel_packet)(USBDevice *dev, USBPacket *p);
+
+/*
  * Called when device is destroyed.
  */
 void (*handle_destroy)(USBDevice *dev);
@@ -263,24 +268,12 @@ struct USBPacket {
 int len;
 /* Internal use by the USB layer.  */
 USBDevice *owner;
-USBCallback *cancel_cb;
-void *cancel_opaque;
 };
 
 int usb_handle_packet(USBDevice *dev, USBPacket *p);
 void usb_packet_complete(USBDevice *dev, USBPacket *p);
 void usb_cancel_packet(USBPacket * p);
 
-/* Defer completion of a USB packet.  The hadle_packet routine should then
-   return USB_RET_ASYNC.  Packets that complete immediately (before
-   handle_packet returns) should not call this method.  */
-static inline void usb_defer_packet(USBPacket *p, USBCallback *cancel,
-void * opaque)
-{
-p->cancel_cb = cancel;
-p->cancel_opaque = opaque;
-}
-
 void usb_attach(USBPort *port, USBDevice *dev);
 void usb_wakeup(USBDevice *dev);
 int usb_generic_handle_packet(USBDevice *s, USBPacket *p);
diff --git a/usb-linux.c b/usb-linux.c
index 5547b02..f9f8d28 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -335,9 +335,9 @@ static void async_complete(void *opaque)
 }
 }
 
-static void async_cancel(USBPacket *p, void *opaque)
+static void usb_host_async_cancel(USBDevice *dev, USBPacket *p)
 {
-USBHostDevice *s = opaque;
+USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev);
 AsyncURB *aurb;
 
 QLIST_FOREACH(aurb, &s->aurbs, next) {
@@ -736,7 +736,6 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket 
*p)
 }
 }
 
-usb_defer_packet(p, async_cancel, s);
 return USB_RET_ASYNC;
 }
 
@@ -868,7 +867,6 @@ static int usb_host_handle_control(USBDevice *dev, 
USBPacket *p,
 }
 }
 
-usb_defer_packet(p, async_cancel, s);
 return USB_RET_ASYNC;
 }
 
@@ -1197,6 +1195,7 @@ static struct USBDeviceInfo usb_host_dev_info = {
 .qdev.size  = sizeof(USBHostDevice),
 .init   = usb_host_initfn,
 .handle_packet  = usb_generic_handle_packet,
+.cancel_packet  = usb_host_async_cancel,
 .handle_data= usb_host_handle_data,
 

[Qemu-devel] [PATCH 04/18] usb: add support for "grouped" interfaces and the Interface Association Descriptor

2011-05-16 Thread Gerd Hoffmann
From: Brad Hards 

This is used for some devices that have multiple interfaces that form a logic
device. An example is Video Class, which has a Control interface and a
Streaming interface. There can be additional interfaces on the same (physical)
devices (e.g. a microphone), and Interface Association Descriptor handles this
case.

Signed-off-by: Brad Hards 
Signed-off-by: Gerd Hoffmann 
---
 hw/usb-desc.c |   47 +++
 hw/usb-desc.h |   20 
 hw/usb.h  |1 +
 3 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/hw/usb-desc.c b/hw/usb-desc.c
index a784155..8367c45 100644
--- a/hw/usb-desc.c
+++ b/hw/usb-desc.c
@@ -91,6 +91,18 @@ int usb_desc_config(const USBDescConfig *conf, uint8_t 
*dest, size_t len)
 dest[0x08] = conf->bMaxPower;
 wTotalLength += bLength;
 
+/* handle grouped interfaces if any*/
+for (i = 0; i < conf->nif_groups; i++) {
+rc = usb_desc_iface_group(&(conf->if_groups[i]),
+  dest + wTotalLength,
+  len - wTotalLength);
+if (rc < 0) {
+return rc;
+}
+wTotalLength += rc;
+}
+
+/* handle normal (ungrouped / no IAD) interfaces if any */
 for (i = 0; i < conf->nif; i++) {
 rc = usb_desc_iface(conf->ifs + i, dest + wTotalLength, len - 
wTotalLength);
 if (rc < 0) {
@@ -104,6 +116,41 @@ int usb_desc_config(const USBDescConfig *conf, uint8_t 
*dest, size_t len)
 return wTotalLength;
 }
 
+int usb_desc_iface_group(const USBDescIfaceAssoc *iad, uint8_t *dest,
+ size_t len)
+{
+int pos = 0;
+int i = 0;
+
+/* handle interface association descriptor */
+uint8_t bLength = 0x08;
+
+if (len < bLength) {
+return -1;
+}
+
+dest[0x00] = bLength;
+dest[0x01] = USB_DT_INTERFACE_ASSOC;
+dest[0x02] = iad->bFirstInterface;
+dest[0x03] = iad->bInterfaceCount;
+dest[0x04] = iad->bFunctionClass;
+dest[0x05] = iad->bFunctionSubClass;
+dest[0x06] = iad->bFunctionProtocol;
+dest[0x07] = iad->iFunction;
+pos += bLength;
+
+/* handle associated interfaces in this group */
+for (i = 0; i < iad->nif; i++) {
+int rc = usb_desc_iface(&(iad->ifs[i]), dest + pos, len - pos);
+if (rc < 0) {
+return rc;
+}
+pos += rc;
+}
+
+return pos;
+}
+
 int usb_desc_iface(const USBDescIface *iface, uint8_t *dest, size_t len)
 {
 uint8_t bLength = 0x09;
diff --git a/hw/usb-desc.h b/hw/usb-desc.h
index ac734ab..a612515 100644
--- a/hw/usb-desc.h
+++ b/hw/usb-desc.h
@@ -30,6 +30,24 @@ struct USBDescConfig {
 uint8_t   bmAttributes;
 uint8_t   bMaxPower;
 
+/* grouped interfaces */
+uint8_t   nif_groups;
+const USBDescIfaceAssoc   *if_groups;
+
+/* "normal" interfaces */
+uint8_t   nif;
+const USBDescIface*ifs;
+};
+
+/* conceptually an Interface Association Descriptor, and releated interfaces */
+struct USBDescIfaceAssoc {
+uint8_t   bFirstInterface;
+uint8_t   bInterfaceCount;
+uint8_t   bFunctionClass;
+uint8_t   bFunctionSubClass;
+uint8_t   bFunctionProtocol;
+uint8_t   iFunction;
+
 uint8_t   nif;
 const USBDescIface*ifs;
 };
@@ -75,6 +93,8 @@ int usb_desc_device(const USBDescID *id, const USBDescDevice 
*dev,
 int usb_desc_device_qualifier(const USBDescDevice *dev,
   uint8_t *dest, size_t len);
 int usb_desc_config(const USBDescConfig *conf, uint8_t *dest, size_t len);
+int usb_desc_iface_group(const USBDescIfaceAssoc *iad, uint8_t *dest,
+ size_t len);
 int usb_desc_iface(const USBDescIface *iface, uint8_t *dest, size_t len);
 int usb_desc_endpoint(const USBDescEndpoint *ep, uint8_t *dest, size_t len);
 int usb_desc_other(const USBDescOther *desc, uint8_t *dest, size_t len);
diff --git a/hw/usb.h b/hw/usb.h
index ca06bf8..e0961ac 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -141,6 +141,7 @@ typedef struct USBDesc USBDesc;
 typedef struct USBDescID USBDescID;
 typedef struct USBDescDevice USBDescDevice;
 typedef struct USBDescConfig USBDescConfig;
+typedef struct USBDescIfaceAssoc USBDescIfaceAssoc;
 typedef struct USBDescIface USBDescIface;
 typedef struct USBDescEndpoint USBDescEndpoint;
 typedef struct USBDescOther USBDescOther;
-- 
1.7.1




[Qemu-devel] [PATCH 07/18] usb-linux: use usb_generic_handle_packet()

2011-05-16 Thread Gerd Hoffmann
From: Hans de Goede 

Make the linux usb host passthrough code use the usb_generic_handle_packet()
function, rather then the curent DYI code. This removes 200 lines of almost
identical code.

Signed-off-by: Hans de Goede 
Signed-off-by: Gerd Hoffmann 
---
 hw/usb.c|   41 +-
 hw/usb.h|1 +
 usb-linux.c |  269 ++-
 3 files changed, 66 insertions(+), 245 deletions(-)

diff --git a/hw/usb.c b/hw/usb.c
index f503b7a..60027c6 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -63,9 +63,10 @@ void usb_wakeup(USBDevice *dev)
protocol)
 */
 
-#define SETUP_STATE_IDLE 0
-#define SETUP_STATE_DATA 1
-#define SETUP_STATE_ACK  2
+#define SETUP_STATE_IDLE  0
+#define SETUP_STATE_SETUP 1
+#define SETUP_STATE_DATA  2
+#define SETUP_STATE_ACK   3
 
 static int do_token_setup(USBDevice *s, USBPacket *p)
 {
@@ -86,6 +87,10 @@ static int do_token_setup(USBDevice *s, USBPacket *p)
 if (s->setup_buf[0] & USB_DIR_IN) {
 ret = s->info->handle_control(s, p, request, value, index,
   s->setup_len, s->data_buf);
+if (ret == USB_RET_ASYNC) {
+ s->setup_state = SETUP_STATE_SETUP;
+ return USB_RET_ASYNC;
+}
 if (ret < 0)
 return ret;
 
@@ -241,6 +246,36 @@ int usb_generic_handle_packet(USBDevice *s, USBPacket *p)
 }
 }
 
+/* ctrl complete function for devices which use usb_generic_handle_packet and
+   may return USB_RET_ASYNC from their handle_control callback. Device code
+   which does this *must* call this function instead of the normal
+   usb_packet_complete to complete their async control packets. */
+void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p)
+{
+if (p->len < 0) {
+s->setup_state = SETUP_STATE_IDLE;
+}
+
+switch (s->setup_state) {
+case SETUP_STATE_SETUP:
+if (p->len < s->setup_len) {
+s->setup_len = p->len;
+}
+s->setup_state = SETUP_STATE_DATA;
+p->len = 8;
+break;
+
+case SETUP_STATE_ACK:
+s->setup_state = SETUP_STATE_IDLE;
+p->len = 0;
+break;
+
+default:
+break;
+}
+usb_packet_complete(s, p);
+}
+
 /* XXX: fix overflow */
 int set_usb_string(uint8_t *buf, const char *str)
 {
diff --git a/hw/usb.h b/hw/usb.h
index b52fa34..c1d1014 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -294,6 +294,7 @@ static inline void usb_cancel_packet(USBPacket * p)
 void usb_attach(USBPort *port, USBDevice *dev);
 void usb_wakeup(USBDevice *dev);
 int usb_generic_handle_packet(USBDevice *s, USBPacket *p);
+void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p);
 int set_usb_string(uint8_t *buf, const char *str);
 void usb_send_msg(USBDevice *dev, int msg);
 
diff --git a/usb-linux.c b/usb-linux.c
index 0ef1d26..84d3a8b 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -54,14 +54,6 @@ struct usb_ctrltransfer {
 void *data;
 };
 
-struct usb_ctrlrequest {
-uint8_t bRequestType;
-uint8_t bRequest;
-uint16_t wValue;
-uint16_t wIndex;
-uint16_t wLength;
-};
-
 typedef int USBScanFunc(void *opaque, int bus_num, int addr, int devpath,
 int class_id, int vendor_id, int product_id,
 const char *product_name, int speed);
@@ -108,26 +100,6 @@ struct endp_data {
 int max_packet_size;
 };
 
-enum {
-CTRL_STATE_IDLE = 0,
-CTRL_STATE_SETUP,
-CTRL_STATE_DATA,
-CTRL_STATE_ACK
-};
-
-/*
- * Control transfer state.
- * Note that 'buffer' _must_ follow 'req' field because
- * we need contiguous buffer when we submit control URB.
- */
-struct ctrl_struct {
-uint16_t len;
-uint16_t offset;
-uint8_t  state;
-struct   usb_ctrlrequest req;
-uint8_t  buffer[8192];
-};
-
 struct USBAutoFilter {
 uint32_t bus_num;
 uint32_t addr;
@@ -146,7 +118,6 @@ typedef struct USBHostDevice {
 int   closing;
 Notifier  exit;
 
-struct ctrl_struct ctrl;
 struct endp_data endp_table[MAX_ENDPOINTS];
 
 /* Host side address */
@@ -269,26 +240,6 @@ static void async_free(AsyncURB *aurb)
 qemu_free(aurb);
 }
 
-static void async_complete_ctrl(USBHostDevice *s, USBPacket *p)
-{
-switch(s->ctrl.state) {
-case CTRL_STATE_SETUP:
-if (p->len < s->ctrl.len)
-s->ctrl.len = p->len;
-s->ctrl.state = CTRL_STATE_DATA;
-p->len = 8;
-break;
-
-case CTRL_STATE_ACK:
-s->ctrl.state = CTRL_STATE_IDLE;
-p->len = 0;
-break;
-
-default:
-break;
-}
-}
-
 static void async_complete(void *opaque)
 {
 USBHostDevice *s = opaque;
@@ -333,9 +284,6 @@ static void async_complete(void *opaque)
 switch (aurb->urb.status) {
 case 0:
 p->len = aurb->urb.actual_length;
-if (aurb->urb.type == USBDEVFS_URB_TYPE_CONTROL) {
-async_complete_ctrl(s, p);
-}
 break

[Qemu-devel] [PATCH 15/18] usb: keep track of packet owner.

2011-05-16 Thread Gerd Hoffmann
Keep track of the device which owns the usb packet for async processing.

Signed-off-by: Gerd Hoffmann 
---
 hw/usb.c |   32 
 hw/usb.h |   18 +++---
 2 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/hw/usb.c b/hw/usb.c
index 966cb0f..8a9a7fc 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -313,6 +313,38 @@ int usb_handle_packet(USBDevice *dev, USBPacket *p)
 {
 int ret;
 
+assert(p->owner == NULL);
 ret = dev->info->handle_packet(dev, p);
+if (ret == USB_RET_ASYNC) {
+if (p->owner == NULL) {
+p->owner = dev;
+} else {
+/* We'll end up here when usb_handle_packet is called
+ * recursively due to a hub being in the chain.  Nothing
+ * to do.  Leave p->owner pointing to the device, not the
+ * hub. */;
+}
+}
 return ret;
 }
+
+/* Notify the controller that an async packet is complete.  This should only
+   be called for packets previously deferred by returning USB_RET_ASYNC from
+   handle_packet. */
+void usb_packet_complete(USBDevice *dev, USBPacket *p)
+{
+/* Note: p->owner != dev is possible in case dev is a hub */
+assert(p->owner != NULL);
+dev->port->ops->complete(dev, p);
+p->owner = NULL;
+}
+
+/* Cancel an active packet.  The packed must have been deferred by
+   returning USB_RET_ASYNC from handle_packet, and not yet
+   completed.  */
+void usb_cancel_packet(USBPacket * p)
+{
+assert(p->owner != NULL);
+p->cancel_cb(p, p->cancel_opaque);
+p->owner = NULL;
+}
diff --git a/hw/usb.h b/hw/usb.h
index 6889467..80e8e90 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -262,11 +262,14 @@ struct USBPacket {
 uint8_t *data;
 int len;
 /* Internal use by the USB layer.  */
+USBDevice *owner;
 USBCallback *cancel_cb;
 void *cancel_opaque;
 };
 
 int usb_handle_packet(USBDevice *dev, USBPacket *p);
+void usb_packet_complete(USBDevice *dev, USBPacket *p);
+void usb_cancel_packet(USBPacket * p);
 
 /* Defer completion of a USB packet.  The hadle_packet routine should then
return USB_RET_ASYNC.  Packets that complete immediately (before
@@ -278,21 +281,6 @@ static inline void usb_defer_packet(USBPacket *p, 
USBCallback *cancel,
 p->cancel_opaque = opaque;
 }
 
-/* Notify the controller that an async packet is complete.  This should only
-   be called for packets previously deferred with usb_defer_packet, and
-   should never be called from within handle_packet.  */
-static inline void usb_packet_complete(USBDevice *dev, USBPacket *p)
-{
-dev->port->ops->complete(dev, p);
-}
-
-/* Cancel an active packet.  The packed must have been deferred with
-   usb_defer_packet,  and not yet completed.  */
-static inline void usb_cancel_packet(USBPacket * p)
-{
-p->cancel_cb(p, p->cancel_opaque);
-}
-
 void usb_attach(USBPort *port, USBDevice *dev);
 void usb_wakeup(USBDevice *dev);
 int usb_generic_handle_packet(USBDevice *s, USBPacket *p);
-- 
1.7.1




Re: [Qemu-devel] [PATCH 00/18] usb patch queue: add usb 2.0

2011-05-16 Thread Anthony Liguori

On 05/16/2011 02:56 PM, Gerd Hoffmann wrote:

   Hi,

Here is the current usb patch queue.  Patches 1-9 have been on the list
already, the other ones are new.  I plan to send a pull request for this
stuff next week.

The major new feature added is USB 2.0 support:  A bunch of fixes and
improvements for the usb passthrough code.  The EHCI host adapter.

Don't expect this being rock solid, EHCI has some known issues.  I want
stabilize EHCI support in-tree though to ease testing.  I hope to get it
reasonable good stabilized for the 0.15 release, failing that there is
still the option to disable it by default.

Improving documentation as requested in recent reviews has been defered
until we have a qdev documentation plan.

The patches are available in the git repository at:

   git://git.kraxel.org/qemu usb.11.pull


Cool!  I'm glad to see someone actively working in this space.

Any specific areas where testing would be helpful?

Regards,

Anthony Liguori



please review,
   Gerd

Brad Hards (4):
   usb: Add Interface Association Descriptor descriptor type
   usb: update config descriptors to identify number of interfaces
   usb: remove fallback to bNumInterfaces if no .nif
   usb: add support for "grouped" interfaces and the Interface
 Association Descriptor

Gerd Hoffmann (11):
   usb-linux: fix device path aka physical port handling
   usb-linux: add hostport property
   usb-linux: track aurbs in list
   usb-linux: walk async urb list in cancel
   usb-linux: split large xfers
   usb-linux: fix max_packet_size for highspeed.
   usb: add usb_handle_packet
   usb: keep track of packet owner.
   usb: move cancel callback to USBDeviceInfo
   usb-storage: don't call usb_packet_complete twice
   usb: add ehci adapter

Hans de Goede (2):
   usb: Pass the packet to the device's handle_control callback
   usb-linux: use usb_generic_handle_packet()

Jan Vesely (1):
   Bug #757654: UHCI fails to signal stall response patch

  Makefile.objs   |1 +
  default-configs/pci.mak |1 +
  docs/usb2.txt   |   38 +
  hw/bt-hid.c |6 +-
  hw/pci_ids.h|1 +
  hw/usb-bt.c |6 +-
  hw/usb-ccid.c   |4 +-
  hw/usb-desc.c   |   56 ++-
  hw/usb-desc.h   |   24 +-
  hw/usb-ehci.c   | 2057 +++
  hw/usb-ehci.h   |8 +
  hw/usb-hid.c|9 +-
  hw/usb-hub.c|9 +-
  hw/usb-msd.c|   18 +-
  hw/usb-musb.c   |2 +-
  hw/usb-net.c|6 +-
  hw/usb-ohci.c   |4 +-
  hw/usb-serial.c |7 +-
  hw/usb-uhci.c   |6 +-
  hw/usb-wacom.c  |7 +-
  hw/usb.c|  101 +++-
  hw/usb.h|   40 +-
  usb-bsd.c   |1 +
  usb-linux.c |  440 ---
  24 files changed, 2469 insertions(+), 383 deletions(-)
  create mode 100644 docs/usb2.txt
  create mode 100644 hw/usb-ehci.c
  create mode 100644 hw/usb-ehci.h







Re: [Qemu-devel] [RFC Patch 0/3]Qemu: Enable dynamic cache change through qemu monitor

2011-05-16 Thread Christoph Hellwig
Why are you even trying this again?  As explained very clearly last time you
can't change from a writeback-style to a write-through style I/O from
the monitor without creating massive data integrity problems.  See my
patchset that allows changing this from the guest for how it should be
done - I just need to get back and revisit the virtio protocol support
for it.




Re: [Qemu-devel] [RFC Patch 0/3]Qemu: Enable dynamic cache change through qemu monitor

2011-05-16 Thread Anthony Liguori

On 05/16/2011 03:23 PM, Christoph Hellwig wrote:

Why are you even trying this again?  As explained very clearly last time you
can't change from a writeback-style to a write-through style I/O from
the monitor without creating massive data integrity problems.


To further clarify:

Today cache=none|writethrough|writeback does two things.  It:

1) Changes the WCE flag that's visible to the guest

2) Determines whether the host page cache is used for doing guest I/O

As Christoph is very correct in pointing out, we cannot change (1) at 
run time because this is guest visible.  You will break a guest if you 
do this.


But it's still desirable to be able to change (2) at run time.  Before 
we can do this properly though, we need to separate out the logic for 
setting (1) vs. (2).


And ideally, we would allow (1) to be changed by the guest itself at run 
time which allows for full dynamic control.  This is what he's referring 
to below.


Regards,

Anthony Liguori

  See my

patchset that allows changing this from the guest for how it should be
done - I just need to get back and revisit the virtio protocol support
for it.







Re: [Qemu-devel] [PATCH 00/26] q35 chipset support for native pci express support

2011-05-16 Thread Adnan Khaleel
I finally got this work after I realised that the AHCI driver was not being 
loaded in my disk image and that ACHI was not being enabled in the Seabios 
.config file.
This is really good work Yamahata, thanks.


As far as I can tell, everything works like the stock Qemu 0.14 except 
networking. The guest OS sees the network device and initialises it but I think 
the Qemu DHCP server/firewall never gets back, since the network device doesn't 
even get a 10.0.2.15 ip address during bootup and the guest dhcp client never 
gets an ip address, 


eth0   device: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 03)
eth0   Starting DHCP4 client. . . . . . . .
eth0   DHCP4 continues in background 
eth0   device: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 03)
eth0   DHCP4 client (dhcpcd) is running
eth0   . . . but is still waiting for data
eth0   interface could not be set up until now


So doing an ifconfig later on just shows


eth0   Link encap:Ethernet  HWaddr 52:54:00:12:34:56
 UP BROADCAST MULTICAST  MTU:1500  Metric:1
 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:0 (0.0 b)   TX bytes:0 (0.0 b)



lo  Link encap:Local loopback  
 inet addr:127.0.0.1  Mask:255.0.0.0
 inet6 addr: ::1/128 Scope:Host
 UP LOOPBACK RUNING  MTU:16436  Metric:1
 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:0 (0.0 b)   TX bytes:0 (0.0 b)


I'm going to start a separate thread to see what the possible cause might be 
and what might be the best way to debug this. Do you have any idea if this q35 
chipset going to be committed to Qemu upstream?


Thanks


AK

[Qemu-devel] Debug Qemu dhcpd

2011-05-16 Thread Adnan Khaleel
I'm using Isaku Yamahata's q35 chipset model in Qemu0.14 and I'm trying to 
figure out why the Qemu dhcpd server is not responding back to the nic device 
in the guest OS when used with user mode networking.
The guest OS sees the network device and initialises it but I think the Qemu 
DHCP server/firewall never gets back, since the network device doesn't even get 
a 10.0.2.15 ip address during bootup and the guest dhcp client never gets an ip 
address, 




eth0   device: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 03)
eth0   Starting DHCP4 client. . . . . . . .
eth0   DHCP4 continues in background 
eth0   device: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 03)
eth0   DHCP4 client (dhcpcd) is running
eth0   . . . but is still waiting for data
eth0   interface could not be set up until now


So doing an ifconfig later on just shows


eth0 Link encap:Ethernet  HWaddr 52:54:00:12:34:56
 UP BROADCAST MULTICAST  MTU:1500  Metric:1
 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:0 (0.0 b)   TX bytes:0 (0.0 b)



lo   Link encap:Local loopback  
 inet addr:127.0.0.1  Mask:255.0.0.0
 inet6 addr: ::1/128 Scope:Host
 UP LOOPBACK RUNING  MTU:16436  Metric:1
 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:0 (0.0 b)   TX bytes:0 (0.0 b)


The NIC device is an Intel e1000 however, even if I use a pci ne2k, I get the 
same result. I've enabled debugging in the hw/e1000.c and in comparing the good 
debug output with the bad debug output, I noticed the point of deviation. The 
two traces are identical up till that point. Given that the problem is not the 
e1000 model itself, I doubt these traces are anything but symptomatic of the 
underlying problem in the Qemu portion that handles network traffic. 


Any ideas on what I can check next to see where the underlying problem might be?


-AK


This is a trace of the e1000.c debug messages from boot up for the good case on 
the left (where networking works) and the bad case on the right (where it 
doesn't).



Good - Debug out  Bad - 
Debug out

  
===
e1000: e1000_ioport_map addr=0xc040 size=0x0040  
e1000: e1000_ioport_map addr=0xc040 size=0x0040
e1000: RCTL: 0, mac_reg[RCTL] = 0x0
e1000: tx disabled
e1000: RCTL: 0, mac_reg[RCTL] = 0x0  
e1000: tx disabled
e1000: MMIO unknown write addr=0x5800,val=0x  
e1000: tx disabled
e1000: MMIO unknown write addr=0x0030,val=0x8808  
e1000: MMIO unknown write addr=0x002c,val=0x0100  
e1000: MMIO unknown write addr=0x0028,val=0x00c28001  
e1000: MMIO unknown write addr=0x0170,val=0x0680  
e1000: MMIO unknown write addr=0x2160,val=0x  
e1000: MMIO unknown write addr=0x2168,val=0x  
e1000: MMIO unknown read addr=0x4014  
e1000: MMIO unknown read addr=0x4018  
e1000: MMIO unknown read addr=0x401c  
e1000: MMIO unknown read addr=0x4020  
:
e1000: MMIO unknown read addr=0x40b4  
e1000: MMIO unknown read addr=0x40b8  
e1000: MMIO unknown read addr=0x40bc  
e1000: MMIO unknown write addr=0x0458,val=0x  
e1000: RCTL: 0, mac_reg[RCTL] = 0x4   
e1000: tx disabled
e1000: MMIO unknown write addr=0x0410,val=0x00602008  
e1000: MMIO unknown write addr=0x3820,val=0x0008  
e1000: MMIO unknown write addr=0x382c,val=0x0020  
e1000: tx disabled
e1000: tx disabled
e1000: RCTL: 0, mac_reg[RCTL] = 0x48002   
e1000: RCTL: 0, mac_reg[RCTL] = 0x48000   
e1000: MMIO unknown write addr=0x2820,val=0x  
e1000: MMIO unknown write addr=0x282c,val=0x0008  
e1000: MMIO unknown write addr=0x00c4,val=0x00c3  
e1000: MMIO unknown read addr=0x5000  
e1000: MMIO unknown write addr=0x5000,val=0x0200 
e1000: RCTL: 0, mac_reg[RCTL] = 0x48002 e1000: RCTL: 0, mac_reg[RCTL] = 
0x48002  
e1000: MMIO unknown write addr=0x00c4,val=0x03d0  e1000: RCTL: 254, 
mac_reg[RCTL] = 0x48002 <= Point at which 1st difference appears
e1000: RCTL: 254, mac_reg[RCTL] = 0x48002e1000: RCTL: 254, mac_reg[RCTL] = 
0x48002
e1000: tx disabled   e1000: RCTL: 254, mac_reg[RCTL] = 0x48002
e1000: MMIO unknown read addr=0x

Re: [Qemu-devel] [PATCH 2/3] target-mips:Support for Cavium-Octeon specific instructions

2011-05-16 Thread Andreas Färber

Am 29.04.2011 um 08:19 schrieb Khansa Butt:


From f699dbfdca62c5af92d764673b2300131d26263e Mon Sep 17 00:00:00 2001
From: Ehsan-ul-Haq, Abdul Qadeer, Abdul Waheed, Khansa Butt >

Date: Wed, 27 Apr 2011 16:08:16 +0500
Subject: [PATCH 2/3] target-mips:Support for Cavium-Octeon specific  
instructions


These headers, except for From:, shouldn't turn up here. It looks as  
if the message was HTML-formatted, too. Same issue with the other two.  
Use git-send-email to avoid this, so that the patch can be processed.


Space after the colon in the subject, please. :)

Further patch description is missing?


Signed-off-by: Khansa Butt 


This is the first time I'm seeing multiple people in From:. I would  
rather expect only you in the From: and multiple Signed-off-by: lines  
here... Maybe one of the Linux gurus can enlighten us?



---
 host-utils.c|1 +
 target-mips/cpu.h   |7 +
 target-mips/helper.h|5 +
 target-mips/op_helper.c |   62 +++
 target-mips/translate.c |  445 + 
--

 5 files changed, 509 insertions(+), 11 deletions(-)



diff --git a/host-utils.c b/host-utils.c
index dc96123..1128698 100644
--- a/host-utils.c
+++ b/host-utils.c
@@ -102,4 +102,5 @@ void muls64 (uint64_t *plow, uint64_t *phigh,  
int64_t a, int64_t b)

a, b, *phigh, *plow);
 #endif
 }
+
 #endif /* !defined(__x86_64__) */


Please remove this unnecessary whitespace change from the patch series.


diff --git a/target-mips/helper.h b/target-mips/helper.h
index 297ab64..e892d39 100644
--- a/target-mips/helper.h
+++ b/target-mips/helper.h
@@ -8,7 +8,12 @@ DEF_HELPER_3(ldl, tl, tl, tl, int)
 DEF_HELPER_3(ldr, tl, tl, tl, int)
 DEF_HELPER_3(sdl, void, tl, tl, int)
 DEF_HELPER_3(sdr, void, tl, tl, int)
+DEF_HELPER_2(v3mulu, tl, tl, tl)
+DEF_HELPER_2(vmulu, tl, tl, tl)
+DEF_HELPER_1(dpop, tl, tl)
 #endif
+DEF_HELPER_1(pop, tl, tl);


The other ones don't end with semicolon?


+
 DEF_HELPER_3(lwl, tl, tl, tl, int)
 DEF_HELPER_3(lwr, tl, tl, tl, int)
 DEF_HELPER_3(swl, void, tl, tl, int)



diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index b8e4991..96cfbe6 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -266,7 +266,69 @@ void helper_dmultu (target_ulong arg1,  
target_ulong arg2)

 {
 mulu64(&(env->active_tc.LO[0]), &(env->active_tc.HI[0]), arg1,  
arg2);

 }


I would expect an empty line between functions.


+static void addc(uint64_t res[], uint64_t a, int i)
+{
+uint64_t c = res[i];
+for (; i < 4; i++) {
+res[i] = c + a;
+if (res[i] < a) {
+c = 1;
+a = res[i+1];
+} else


Coding style.


+  break;
+}
+}


Line?


+target_ulong helper_v3mulu(target_ulong arg1, target_ulong arg2)
+{
+uint64_t hi, lo, res[4];
+int i;
+for (i = 0; i < 4; i++) {
+res[i] = 0;
+}
+mulu64(&res[0], &res[1], env->active_tc.MPL0, arg1);
+mulu64(&lo, &hi, env->active_tc.MPL1, arg1);
+res[1] = res[1] + lo;
+if (res[1] < lo)


Coding Style.


+res[2]++;
+res[2] = res[2] + hi;
+if (res[2] < hi)


Dito. More skipped, try using the checkpatch script.


diff --git a/target-mips/translate.c b/target-mips/translate.c
index c88c3f9..cb431a8 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -70,6 +70,11 @@ enum {
 OPC_JAL  = (0x03 << 26),
 OPC_JALS = OPC_JAL | 0x5,
 OPC_BEQ  = (0x04 << 26),  /* Unconditional if rs = rt = 0  
(B) */

+/* Cavium Specific */


This seems misleading to me: Probably only the ones inserted are  
Cavium-specific but not OPC_BEQL etc.?


+OPC_BBIT1= (0x3a << 26),  /* jump on bit set, cavium  
specific */
+OPC_BBIT132  = (0x3e << 26),  /* jump on bit set(for upper 32  
bits) */
+OPC_BBIT0= (0x32 << 26),  /* jump on bit clear, cavium  
specific */
+OPC_BBIT032  = (0x36 << 26),  /* jump on bit clear(for upper 32  
bits) */

 OPC_BEQL = (0x14 << 26),
 OPC_BNE  = (0x05 << 26),
 OPC_BNEL = (0x15 << 26),
@@ -265,6 +270,31 @@ enum {
 OPC_MADD = 0x00 | OPC_SPECIAL2,
 OPC_MADDU= 0x01 | OPC_SPECIAL2,
 OPC_MUL  = 0x02 | OPC_SPECIAL2,
+/* Cavium Specific Instructions */
+OPC_BADDU= 0x28 | OPC_SPECIAL2,
+OPC_DMUL = 0x03 | OPC_SPECIAL2,
+OPC_EXTS = 0x3a | OPC_SPECIAL2,
+OPC_EXTS32   = 0x3b | OPC_SPECIAL2,
+OPC_CINS = 0x32 | OPC_SPECIAL2,
+OPC_CINS32   = 0x33 | OPC_SPECIAL2,
+OPC_SEQI = 0x2e | OPC_SPECIAL2,
+OPC_SNEI = 0x2f | OPC_SPECIAL2,
+OPC_MTM0 = 0x08 | OPC_SPECIAL2,
+OPC_MTM1 = 0x0c | OPC_SPECIAL2,
+OPC_MTM2 = 0x0d | OPC_SPECIAL2,
+OPC_MTP0 = 0x09 | OPC_SPECIAL2,
+OPC_MTP1 = 0x0a | OPC_SPECIAL2,
+OPC_MTP2 = 0x0b | OPC_SPECIAL2,
+OPC_V3MULU   = 0x11 | OPC_SPECIAL2,
+OPC_VMM0 = 0x10 | OPC_SPECIAL2,
+OPC_VMULU= 0x0f | OPC_SPECIAL2,
+OPC_POP  = 0X2C | OPC_

Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify

2011-05-16 Thread andrzej zaborowski
On 16 May 2011 15:08, Dmitry Eremin-Solenikov  wrote:
> On 5/16/11, andrzej zaborowski  wrote:
>> On 16 May 2011 06:54, Dmitry Eremin-Solenikov  wrote:
>>> Socket is required, as we have to know the QBus before creating the
>>> device on it.
>>
>> Let's skip the qbusification then.  It seems that qbus is a wrong
>> choice for pcmcia and there are no new features or bugs fixed by the
>> conversion, it's code motion?  I also don't see why the socket
>> structure should be needed at the creation time of a PCI device for
>> example, the BusInfo should be enough logically.
>
> Major point for qbus'ification was ability to create PCMCIA devices from
> command line/via other management tools. This would also allow us e.g.
> to move microdrive driver to common ide parts, etc.

That would be nice but it may be better to use separate command line
switches / monitor commands for hotpluggable busses.

>
> For creation of a DeviceState via qdev_create you need BusState (which
> is a part of PCMCIASocket). Of course I can make one global QBus for
> all PCMCIA devices and make some artificial hacks to attach/detach cards
> to artificial sockets, but this seems like a hack.

I considered that for a moment too but it's uglier than current code
and doesn't achieve what you want, because the command line has no
provision for triggering attachment.  A major problem with qdev I see
now is that the creation and attachment of a device are one event
instead of two, which is the case for pcmcia.  So your patch tries to
merge these two events.

Cheers



Re: [Qemu-devel] [PATCH 12/18] usb-linux: split large xfers

2011-05-16 Thread David Ahern
On 05/16/11 13:56, Gerd Hoffmann wrote:
> Add support for splitting large transfers into multiple smaller ones.
> This is needed for the upcoming EHCI emulation which allows guests
> to submit requests up to 20k in size.  The linux kernel allows 16k
> max size though.
> 
> Roughly based on a patch from git://git.kiszka.org/qemu.git ehci

More specifically:
http://www.mail-archive.com/qemu-devel@nongnu.org/msg30337.html

And "roughly based" is a bit of a stretch. The logic for handling 20k
requests in a 16k limit (the focus of this patch) came from the patch
above. This patch is a forward port based on changes made to the USB
code and some code movement.

David


> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  usb-linux.c |   68 +-
>  1 files changed, 43 insertions(+), 25 deletions(-)
> 
> diff --git a/usb-linux.c b/usb-linux.c
> index b8f7705..b95c119 100644
> --- a/usb-linux.c
> +++ b/usb-linux.c
> @@ -89,6 +89,9 @@ static int usb_fs_type;
>  #define ISO_URB_COUNT 3
>  #define INVALID_EP_TYPE 255
>  
> +/* devio.c limits single requests to 16k */
> +#define MAX_USBFS_BUFFER_SIZE 16384
> +
>  typedef struct AsyncURB AsyncURB;
>  
>  struct endp_data {
> @@ -229,6 +232,7 @@ struct AsyncURB
>  
>  /* For regular async urbs */
>  USBPacket *packet;
> +int more; /* large transfer, more urbs follow */
>  
>  /* For buffered iso handling */
>  int iso_frame_idx; /* -1 means in flight */
> @@ -291,7 +295,7 @@ static void async_complete(void *opaque)
>  if (p) {
>  switch (aurb->urb.status) {
>  case 0:
> -p->len = aurb->urb.actual_length;
> +p->len += aurb->urb.actual_length;
>  break;
>  
>  case -EPIPE:
> @@ -306,7 +310,7 @@ static void async_complete(void *opaque)
>  
>  if (aurb->urb.type == USBDEVFS_URB_TYPE_CONTROL) {
>  usb_generic_async_ctrl_complete(&s->dev, p);
> -} else {
> +} else if (!aurb->more) {
>  usb_packet_complete(&s->dev, p);
>  }
>  }
> @@ -646,7 +650,8 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket 
> *p)
>  USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev);
>  struct usbdevfs_urb *urb;
>  AsyncURB *aurb;
> -int ret;
> +int ret, rem;
> +uint8_t *pbuf;
>  uint8_t ep;
>  
>  if (!is_valid(s, p->devep)) {
> @@ -673,32 +678,45 @@ static int usb_host_handle_data(USBDevice *dev, 
> USBPacket *p)
>  return usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN);
>  }
>  
> -aurb = async_alloc(s);
> -aurb->packet = p;
> +rem = p->len;
> +pbuf = p->data;
> +p->len = 0;
> +while (rem) {
> +aurb = async_alloc(s);
> +aurb->packet = p;
>  
> -urb = &aurb->urb;
> +urb = &aurb->urb;
> +urb->endpoint  = ep;
> +urb->type  = USBDEVFS_URB_TYPE_BULK;
> +urb->usercontext   = s;
> +urb->buffer= pbuf;
>  
> -urb->endpoint  = ep;
> -urb->buffer= p->data;
> -urb->buffer_length = p->len;
> -urb->type  = USBDEVFS_URB_TYPE_BULK;
> -urb->usercontext   = s;
> +if (rem > MAX_USBFS_BUFFER_SIZE) {
> +urb->buffer_length = MAX_USBFS_BUFFER_SIZE;
> +aurb->more = 1;
> +} else {
> +urb->buffer_length = rem;
> +aurb->more = 0;
> +}
> +pbuf += urb->buffer_length;
> +rem  -= urb->buffer_length;
>  
> -ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
> +ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
>  
> -DPRINTF("husb: data submit. ep 0x%x len %u aurb %p\n",
> -urb->endpoint, p->len, aurb);
> +DPRINTF("husb: data submit: ep 0x%x, len %u, more %d, packet %p, 
> aurb %p\n",
> +urb->endpoint, urb->buffer_length, aurb->more, p, aurb);
>  
> -if (ret < 0) {
> -DPRINTF("husb: submit failed. errno %d\n", errno);
> -async_free(aurb);
> +if (ret < 0) {
> +DPRINTF("husb: submit failed. errno %d\n", errno);
> +async_free(aurb);
>  
> -switch(errno) {
> -case ETIMEDOUT:
> -return USB_RET_NAK;
> -case EPIPE:
> -default:
> -return USB_RET_STALL;
> +switch(errno) {
> +case ETIMEDOUT:
> +return USB_RET_NAK;
> +case EPIPE:
> +default:
> +return USB_RET_STALL;
> +}
>  }
>  }
>  



Re: [Qemu-devel] [RESEND][PATCH 3/9] microdrive: qdevify

2011-05-16 Thread Jan Kiszka
On 2011-05-17 03:38, andrzej zaborowski wrote:
> On 16 May 2011 15:08, Dmitry Eremin-Solenikov  wrote:
>> On 5/16/11, andrzej zaborowski  wrote:
>>> On 16 May 2011 06:54, Dmitry Eremin-Solenikov  wrote:
 Socket is required, as we have to know the QBus before creating the
 device on it.
>>>
>>> Let's skip the qbusification then.  It seems that qbus is a wrong
>>> choice for pcmcia and there are no new features or bugs fixed by the
>>> conversion, it's code motion?  I also don't see why the socket
>>> structure should be needed at the creation time of a PCI device for
>>> example, the BusInfo should be enough logically.
>>
>> Major point for qbus'ification was ability to create PCMCIA devices from
>> command line/via other management tools. This would also allow us e.g.
>> to move microdrive driver to common ide parts, etc.
> 
> That would be nice but it may be better to use separate command line
> switches / monitor commands for hotpluggable busses.
> 
>>
>> For creation of a DeviceState via qdev_create you need BusState (which
>> is a part of PCMCIASocket). Of course I can make one global QBus for
>> all PCMCIA devices and make some artificial hacks to attach/detach cards
>> to artificial sockets, but this seems like a hack.
> 
> I considered that for a moment too but it's uglier than current code
> and doesn't achieve what you want, because the command line has no
> provision for triggering attachment.  A major problem with qdev I see
> now is that the creation and attachment of a device are one event
> instead of two, which is the case for pcmcia.  So your patch tries to
> merge these two events.

What is the point of allowing the existence of unattached pcmcia
devices? I think there was similar discussion about usb to allow attach
detach without delete, but IIRC that was finally rejected as there is no
real benefit in avoiding full creation/destruction.

Keep in mind that there may be a day where we finally obsolete support
for non-qdev (or whatever it's name will be then) devices. Every device
needs to be discoverable for QEMU in a generic way, e.g. to decide if
there are devices attached that do not support save/restore or to
explore its state. Rejecting a qdev conversion looks a bit strange from
that perspective.

Jan



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH 1/3] pSeries: Clean up write-only variables

2011-05-16 Thread David Gibson
A few pieces of the pSeries emulation code have variables which are set
but never used, which causes warnings on gcc 4.6.  This patch removes
these instances.

Signed-off-by: David Gibson 
---
 hw/spapr_hcall.c |7 +--
 hw/spapr_llan.c  |3 ---
 2 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
index 5281ba2..43c441d 100644
--- a/hw/spapr_hcall.c
+++ b/hw/spapr_hcall.c
@@ -100,22 +100,18 @@ static target_ulong h_enter(CPUState *env, 
sPAPREnvironment *spapr,
 target_ulong pte_index = args[1];
 target_ulong pteh = args[2];
 target_ulong ptel = args[3];
-target_ulong porder;
-target_ulong i, pa;
+target_ulong i;
 uint8_t *hpte;
 
 /* only handle 4k and 16M pages for now */
-porder = 12;
 if (pteh & HPTE_V_LARGE) {
 #if 0 /* We don't support 64k pages yet */
 if ((ptel & 0xf000) == 0x1000) {
 /* 64k page */
-porder = 16;
 } else
 #endif
 if ((ptel & 0xff000) == 0) {
 /* 16M page */
-porder = 24;
 /* lowest AVA bit must be 0 for 16M pages */
 if (pteh & 0x80) {
 return H_PARAMETER;
@@ -125,7 +121,6 @@ static target_ulong h_enter(CPUState *env, sPAPREnvironment 
*spapr,
 }
 }
 
-pa = ptel & HPTE_R_RPN;
 /* FIXME: bounds check the pa? */
 
 /* Check WIMG */
diff --git a/hw/spapr_llan.c b/hw/spapr_llan.c
index ff3a78f..c18efc7 100644
--- a/hw/spapr_llan.c
+++ b/hw/spapr_llan.c
@@ -185,9 +185,6 @@ static NetClientInfo net_spapr_vlan_info = {
 static int spapr_vlan_init(VIOsPAPRDevice *sdev)
 {
 VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
-VIOsPAPRBus *bus;
-
-bus = DO_UPCAST(VIOsPAPRBus, bus, sdev->qdev.parent_bus);
 
 qemu_macaddr_default_if_unset(&dev->nicconf.macaddr);
 
-- 
1.7.4.4




[Qemu-devel] pSseries platform updates, cleanup and virtio support

2011-05-16 Thread David Gibson
Hi Alex,

Here's a few more patches for the pSeries machine emulation.  First
there's a small cleanup / bugfix that removes warnings with gcc 4.6.
Then there are two patches which add virtio support (as opposed to
PAPR style VIO) to the pSeries platform.

Please apply.



[Qemu-devel] [PATCH 2/3] virtio: Added function to calculate number of bytes required to allocate a VRing

2011-05-16 Thread David Gibson
From: Alexey Kardashevskiy 

The existing function virtio_queue_get_ring_size returns number of bytes
for vring only when it is already initialized.

In order to know how much memory new vring requires, new function
virtio_queue_get_mem_size has been introduced. It is a copy
of the vring_size function from the linux kernel (include/linux/virtio_ring.h).

Signed-off-by: Alexey Kardashevskiy 
Signed-off-by: David Gibson 
---
 hw/virtio.c |8 
 hw/virtio.h |1 +
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/hw/virtio.c b/hw/virtio.c
index 6e8814c..ff05b25 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -574,6 +574,14 @@ int virtio_queue_get_num(VirtIODevice *vdev, int n)
 return vdev->vq[n].vring.num;
 }
 
+int virtio_queue_get_mem_size(VirtIODevice *vdev, int n, int align)
+{
+int num = virtio_queue_get_num(vdev, n);
+return ((sizeof(VRingDesc)*num + sizeof(uint16_t)*(2 + num)
++ align - 1) & ~(align - 1))
++ sizeof(uint16_t)*2 + sizeof(VRingUsedElem)*num;
+}
+
 void virtio_queue_notify_vq(VirtQueue *vq)
 {
 if (vq->vring.desc) {
diff --git a/hw/virtio.h b/hw/virtio.h
index bc72289..114a877 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -182,6 +182,7 @@ void virtio_config_writel(VirtIODevice *vdev, uint32_t 
addr, uint32_t data);
 void virtio_queue_set_addr(VirtIODevice *vdev, int n, target_phys_addr_t addr);
 target_phys_addr_t virtio_queue_get_addr(VirtIODevice *vdev, int n);
 int virtio_queue_get_num(VirtIODevice *vdev, int n);
+int virtio_queue_get_mem_size(VirtIODevice *vdev, int n, int align);
 void virtio_queue_notify(VirtIODevice *vdev, int n);
 uint16_t virtio_queue_vector(VirtIODevice *vdev, int n);
 void virtio_queue_set_vector(VirtIODevice *vdev, int n, uint16_t vector);
-- 
1.7.4.4




[Qemu-devel] [PATCH 3/3] powerpc-virtio: virtio support introduced (block, network, serial, balloon, 9p-fs), both fullemu and power-kvm

2011-05-16 Thread David Gibson
From: Alexey Kardashevskiy 

The recently added pseries machine does not currently support PCI
emulation.  For the (upcoming) kvm case, this is quite difficult to do
because the preferred HV mode for the host kernel does not allow MMIO
emulation (a hardware limitation).

Therefore, to support virtio devices, we implement a new virtio setup
protocol for PAPR guests.  This is based loosely on the s390 and lguest
methods, using the PAPR hcalls for the virtio primitive operations,
and the PAPR device tree to advertise the virtio device resources to the
guest.

This patch includes support for the virtio block, network, serial, and
balloon devices, and the 9p filesystem.

The guest linux kernel should be updated as well in order to
support a new virtio setup.

Supported devices are (below are QEMU command line switches):

- virtio-blk - block device, at the moment works as "IDE":
usage: -drive file=test-virtio-blk.img,if=ide

- virtio-net - network device
usage: -net nic,model=virtio-net

- virtio-balloon - memory hot-swap device (at the moment of commit, power-kvm
did not support balloon)
usage: -device virtio-balloon-spapr

- virtio-serial - serial bus controller
usage: -device virtio-serial-spapr \
   -chardev socket,id=CONSOLE,host=localhost,port=,server,telnet \
   -device virtconsole,chardev=CONSOLE
The first switch tells QEMU to create a serial bus device and next
2 switches create "chardev" and virtual console device connected to
that "chardev".

- virtio-9p - plan9 filesystem with ability to work over virtio transport
usage: -fsdev fstype=local,id=TAG,path=/home/aik/,security_model=none \
   -device virtio-9p-spapr,fsdev=TAG,mount_tag=TAG
where TAG is a tag which should be used later when mounting is linux as:
   mount -t 9p -o trans=virtio TAG /mnt

Configure for full emulation as:
   ./configure --target-list=ppc64-softmmu --enable-attr

Configure for power-kvm as:
   ./configure --enable-kvm  --target-list=ppc64-softmmu --enable-fdt \
--cc="gcc -m64" \
--kerneldir=/root/kheaders --enable-io-thread --enable-attr

Note: --enable-attr is required for 9p support. On ppc64 systems, libattr
should be compiled and installed manually as it is not distributes in
64bit packages.

Signed-off-by: Alexey Kardashevskiy 
Signed-off-by: David Gibson 
---
 Makefile.target   |1 +
 hw/spapr.c|   47 -
 hw/spapr.h|   11 +-
 hw/spapr_virtio.c |  641 +
 hw/spapr_virtio.h |   60 +
 5 files changed, 756 insertions(+), 4 deletions(-)
 create mode 100644 hw/spapr_virtio.c
 create mode 100644 hw/spapr_virtio.h

diff --git a/Makefile.target b/Makefile.target
index 2e281a4..fb7d513 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -253,6 +253,7 @@ obj-ppc-y += ppc_newworld.o
 ifeq ($(CONFIG_FDT)$(TARGET_PPC64),yy)
 obj-ppc-y += spapr.o spapr_hcall.o spapr_rtas.o spapr_vio.o
 obj-ppc-y += xics.o spapr_vty.o spapr_llan.o spapr_vscsi.o
+obj-ppc-$(CONFIG_VIRTIO) += spapr_virtio.o
 endif
 # PowerPC 4xx boards
 obj-ppc-y += ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o
diff --git a/hw/spapr.c b/hw/spapr.c
index 109b774..6815157 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -36,6 +36,7 @@
 
 #include "hw/spapr.h"
 #include "hw/spapr_vio.h"
+#include "hw/spapr_virtio.h"
 #include "hw/xics.h"
 
 #include 
@@ -53,6 +54,7 @@
 
 #define MAX_CPUS256
 #define XICS_IRQS  1024
+#define MAX_BLK_DEVS10
 
 sPAPREnvironment *spapr;
 
@@ -214,6 +216,17 @@ static void *spapr_create_fdt_skel(const char *cpu_model,
 
 _FDT((fdt_end_node(fdt)));
 
+/* virtio-bus */
+_FDT((fdt_begin_node(fdt, "virtio-bus")));
+
+_FDT((fdt_property_string(fdt, "compatible", "ibm,virtio-bus")));
+_FDT((fdt_property_cell(fdt, "#address-cells", 0x2)));
+_FDT((fdt_property_cell(fdt, "#size-cells", 0x1)));
+_FDT((fdt_property_cell(fdt, "#interrupt-cells", 0x2)));
+_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
+
+_FDT((fdt_end_node(fdt)));
+
 _FDT((fdt_end_node(fdt))); /* close root node */
 _FDT((fdt_finish(fdt)));
 
@@ -239,6 +252,12 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,
 exit(1);
 }
 
+ret = spapr_populate_virtio_devices(spapr->virtio_bus, fdt);
+if (ret < 0) {
+fprintf(stderr, "couldn't setup virtio devices in fdt\n");
+exit(1);
+}
+
 /* RTAS */
 ret = spapr_rtas_device_tree_setup(fdt, rtas_addr, rtas_size);
 if (ret < 0) {
@@ -330,8 +349,10 @@ static void ppc_spapr_init(ram_addr_t ram_size,
 }
 
 /* allocate RAM */
-ram_offset = qemu_ram_alloc(NULL, "ppc_spapr.ram", ram_size);
-cpu_register_physical_memory(0, ram_size, ram_offset);
+ram_offset = qemu_ram_alloc(NULL, "ppc_spapr.ram", ram_size +
+SPAPR_VIRTIO_SHARED_MEM_SIZE);
+cpu_register_physical_memory(0

Re: [Qemu-devel] [PATCH 2/3] virtio: Added function to calculate number of bytes required to allocate a VRing

2011-05-16 Thread Alexander Graf

On 17.05.2011, at 08:47, David Gibson wrote:

> From: Alexey Kardashevskiy 
> 
> The existing function virtio_queue_get_ring_size returns number of bytes
> for vring only when it is already initialized.
> 
> In order to know how much memory new vring requires, new function
> virtio_queue_get_mem_size has been introduced. It is a copy
> of the vring_size function from the linux kernel 
> (include/linux/virtio_ring.h).
> 
> Signed-off-by: Alexey Kardashevskiy 
> Signed-off-by: David Gibson 

Michael, could I please get your signed-off-by here?


Alex




Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target

2011-05-16 Thread Paolo Bonzini

On 05/15/2011 05:40 PM, Alon Levy wrote:

-ln -s "$source_path/libcacard/Makefile" libcacard/Makefile
+ln -s -f "$source_path/libcacard/Makefile" libcacard/Makefile


Use the "symlink" function rather than ln -s -f for portability to 
broken platforms, please.


Note that this requires libtool at build time rather than only for 
maintainers.  This is unlike all other software using it.  However, I 
believe this is not too bad given that a special make invocation is 
required.


Paolo



Re: [Qemu-devel] Why does -device qxl-vga not suppress default vga?

2011-05-16 Thread Gerd Hoffmann

On 05/13/11 16:18, Markus Armbruster wrote:

VGA, cirrus-vga and vmware-svga do.  Gerd, you added it (commit
a19cbfb3), care to explain?


Just forgot to add it to the list when merging.
I'll go stuff a patch into the spice patch queue.

Does "-device VGA" work these days btw?
Last time I tries it didn't due to some init order issues.

cheers,
  Gerd




Re: [Qemu-devel] Why does -device qxl-vga not suppress default vga?

2011-05-16 Thread Jan Kiszka
On 2011-05-16 09:28, Gerd Hoffmann wrote:
> On 05/13/11 16:18, Markus Armbruster wrote:
>> VGA, cirrus-vga and vmware-svga do.  Gerd, you added it (commit
>> a19cbfb3), care to explain?
> 
> Just forgot to add it to the list when merging.
> I'll go stuff a patch into the spice patch queue.
> 
> Does "-device VGA" work these days btw?
> Last time I tries it didn't due to some init order issues.

I've (mostly) fixed the PAM/SMRAM stuff that still breaks this. Will
post the series soon.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux



Re: [Qemu-devel] [RFC] live snapshot, live merge, live block migration

2011-05-16 Thread Dor Laor

On 05/16/2011 12:38 AM, Jagane Sundar wrote:

Hello Dor,

One important advantage of live snapshot over live backup is support of
multiple (consecutive) live snapshots while there can be only a single
live backup at one time.

This is why I tend to think that although live backup carry some benefit
(no merge required), the live snapshot + live merge are more robust
mechanism.



The two things that concern me regarding the
live snapshot/live merge approach are:
1. Performance considerations of having
multiple active snapshots?


My description above was in accurate and I only hinted that multiple 
snapshots are possible but they are done consecutively -
Live snapshot takes practically almost no time - just the time to get 
the guest virtagent to freeze the guest FS and to create the snapshot 
(for qcow2 is immediate).


So if you like to have multiple snapshot, let's say 5 minute after you 
issued the first snapshot, there is no problem.


The new writes will go to the snapshot while the former base is marked 
as read only.
Eventually you like to (live) merge the snapshots together. This can be 
done in any point in time.



2. Robustness of this solution in the face of
errors in the disk, etc. If any one of the snapshot
files were to get corrupted, the whole VM is
adversely impacted.


Since the base images and any snapshot which is not a leaf is marked as 
read only there is no such risk.




The primary goal of Livebackup architecture was to have zero
performance impact on the running VM.

Livebackup impacts performance of the VM only when the
backup client connects to qemu to transfer the modified
blocks over, which should be, say 15 minutes a day, for a
daily backup schedule VM.


In case there were lots of changing for example additional 50GB changes 
it will take more time and there will be a performance hit.




One useful thing to do is to evaluate the important use cases
for this technology, and then decide which approach makes
most sense. As an example, let me state this use case:
- A IaaS cloud, where VMs are always on, running off of a local
disk, and need to be backed up once a day or so.

Can you list some of the other use cases that live snapshot and
live merge were designed to solve. Perhaps we can put up a
single wiki page that describes all of these proposals.


Both solutions can serve for the same scenario:
With live snapshot the backup is done the following:

1. Take a live snapshot (s1) of image s0.
2. Newer writes goes to the snapshot s1 while s0 is read only.
3. Backup software processes s0 image.
   There are multiple ways for doing that -
   1. Use qemu-img and get the dirty blocks from former backup.
  - Currently qemu-img does not support it.
  - Nevertheless, such mechanism will work for lvm, btrfs, NetApp
   2. Mount the s0 image to another guest that runs traditional backup
  software at the file system level and let it do the backup.
4. Live merge s1->s0
   We'll use live copy for that so each write is duplicated (like your
   live backup solution).
5. Delete s1

As you can see, both approaches are very similar, while live snapshot is 
more general and not tied to backup specifically.




Thanks,
Jagane






Re: [Qemu-devel] Should new USB devices such as usb-ccid support legacy -usbdevice?

2011-05-16 Thread Gerd Hoffmann

On 05/13/11 18:47, Anthony Liguori wrote:

On 05/13/2011 11:36 AM, Markus Armbruster wrote:

When Gerd qdevified USB, he kept legacy -usbdevice working (commit
0958b4cc...). What about new USB devices? Should they get a legacy
syntax, too?


Any reason to do that?  We already have a number of devices which can be 
setup via -device only, and that is perfectly fine IMHO.  Also I don't 
want extend the legacy syntax when adding new properties for new 
features to usb devices, which will add more cases where you have to use 
-device to use new features.



The only existing new device is usb-ccid, and it got one in commit
36707144.


What keeps -usbdevice from being a light wrapper to -device such that no
future code is needed for this?


Different command line syntax.  Each device (which needs/accepts 
parameters) has a init function to handle the -usbdevice command line, 
which basically does:


  * parse old syntax
  * usb_create()
  * qdev_set_prop_*() calls
  * qdev_init


I know some of the names are different but presumably we could use a map
for existing ones and pass through names for newer ones.


Just the device name is easy, there is a field in USBDeviceInfo for that 
already, and in fact "-usbdevice tablet" acts like "-device usb-tablet" 
thanks to that entry ;)


cheers,
  Gerd




Re: [Qemu-devel] Why is qdev vga-isa no_user?

2011-05-16 Thread Markus Armbruster
Blue Swirl  writes:

> On Fri, May 13, 2011 at 4:36 PM, Markus Armbruster  wrote:
>> Blue, you did the conversion (commit 7435b791), care to explain?
>
> Because I/O ports of VGA are fixed, so there can be only zero (which
> is handled by -vga none) or one devices.

Reason I'm asking: the other VGA devices can be configured with "-device
NAME", like any other user-configurable device.  I want that for
isa-vga, too.

Of any device with fixed resources, there can be at most one.  If you
configure more than one, you get an error.  Same as for inter-device
resource clashes.  Our reporting of resource clashes isn't exactly user
friendly, and should be improved.

no_user is strictly for devices that aren't user-configurable at all.

I'll post a patch to bring isa-vga in line with the other VGA devices.



Re: [Qemu-devel] Why does -device qxl-vga not suppress default vga?

2011-05-16 Thread Markus Armbruster
Gerd Hoffmann  writes:

> On 05/13/11 16:18, Markus Armbruster wrote:
>> VGA, cirrus-vga and vmware-svga do.  Gerd, you added it (commit
>> a19cbfb3), care to explain?
>
> Just forgot to add it to the list when merging.
> I'll go stuff a patch into the spice patch queue.
>
> Does "-device VGA" work these days btw?
> Last time I tries it didn't due to some init order issues.

docs/qdev-device-use.txt on -device with graphics devices:

Bug: the new way doesn't work for machine type "pc", because it
violates obscure device initialization ordering constraints.

I'm working on an update for qdev-device-use.txt, and I plan to
retest the bug.



Re: [Qemu-devel] [PATCH v2] Add an isa device for SGA

2011-05-16 Thread Brad Hards
On Thu, 12 May 2011 10:55:13 pm Glauber Costa wrote:
> This patch adds a dummy legacy ISA device whose responsibility is to
> deploy sgabios, an option rom for a serial graphics adapter.
> The proposal is that this device is always-on when -nographics,
> but can otherwise be enable in any setup when -device sga is used.
Perhaps could use documentation changes, especially a reference to the 
location for the ROM image (given that came up as a question on the original 
patch series)

Brad



Re: [Qemu-devel] [RFC] live snapshot, live merge, live block migration

2011-05-16 Thread Jagane Sundar

Hello Dor,

Let me see if I understand live snapshot correctly:
If I want to configure a VM for daily backup, then I would do
the following:
- Create a snapshot s1. s0 is marked read-only.
- Do a full backup of s0 on day 0.
- On day 1, I would create a new snapshot s2, then
  copy over the snapshot s1, which is the incremental
   backup image from s0 to s1.
- After copying s1 over, I do not need that snapshot, so
  I would live merge s1 with s0, to create a new merged
  read-only image s1'.
- On day 2, I would create a new snapshot s3, then
   copy over s2, which is the incremental backup from
   s1' to s2
- And so on...

With this sequence of operations, I would need to keep a
snapshot active at all times, in order to enable the
incremental backup capability, right?

If the base image is s0 and there is a single snapshot s1, then a
read operation from the VM will first look in s1. if the block is
not present in s1, then it will read the block from s0, right?
So most reads from the VM will effectively translate into two
reads, right?

Isn't this a continuous performance penalty for the VM,
amounting to almost doubling the read I/O from the VM?

Please read below for more comments:

2. Robustness of this solution in the face of
errors in the disk, etc. If any one of the snapshot
files were to get corrupted, the whole VM is
adversely impacted.

Since the base images and any snapshot which is not a leaf is marked as
read only there is no such risk.


What happens when a VM host reboots while a live merge of s0
and s1 is being done?

The primary goal of Livebackup architecture was to have zero
performance impact on the running VM.

Livebackup impacts performance of the VM only when the
backup client connects to qemu to transfer the modified
blocks over, which should be, say 15 minutes a day, for a
daily backup schedule VM.

In case there were lots of changing for example additional 50GB changes
it will take more time and there will be a performance hit.


Of course, the performance hit is proportional to the amount of data
being copied over. However, the performance penalty is paid during
the backup operation, and not during normal VM operation.


One useful thing to do is to evaluate the important use cases
for this technology, and then decide which approach makes
most sense. As an example, let me state this use case:
- A IaaS cloud, where VMs are always on, running off of a local
disk, and need to be backed up once a day or so.

Can you list some of the other use cases that live snapshot and
live merge were designed to solve. Perhaps we can put up a
single wiki page that describes all of these proposals.

Both solutions can serve for the same scenario:
With live snapshot the backup is done the following:

1. Take a live snapshot (s1) of image s0.
2. Newer writes goes to the snapshot s1 while s0 is read only.
3. Backup software processes s0 image.
 There are multiple ways for doing that -
 1. Use qemu-img and get the dirty blocks from former backup.
- Currently qemu-img does not support it.
- Nevertheless, such mechanism will work for lvm, btrfs, NetApp
 2. Mount the s0 image to another guest that runs traditional backup
software at the file system level and let it do the backup.
4. Live merge s1->s0
 We'll use live copy for that so each write is duplicated (like your
 live backup solution).
5. Delete s1

As you can see, both approaches are very similar, while live snapshot is
more general and not tied to backup specifically.



As I explained at the head of this email, I believe that live snapshot
results in the VM read I/O paying a high penalty during normal operation
of the VM, whereas Livebackup results in this penalty being paid only
during the backup dirty block transfer operation.

Finally, I would like to bring up considerations of disk space. To expand on
my use case further, consider a Cloud Compute service with 100 VMs
running on a host. If live snapshot is used to create snapshot COW files,
then potentially each VM could grow the COW snapshot file to the size
of the base file, which means the VM host needs to reserve space for
the snapshot that equals the size of the VMs - i.e. a 8GB VM would
require an additional 8GB of space to be reserved for the snapshot,
so that the service provider could safely guarantee that the snapshot
will not run out of space.
Contrast this with livebackup, wherein the COW files are kept only when
the dirty block transfers are being done. This means that for a host with
100 VMs, if the backup server is connecting to each of the 100 qemu's
one by one and doing a livebackup, the service provider would need
to provision spare disk for at most the COW size of one VM.

Thanks,
Jagane




Re: [Qemu-devel] Should new USB devices such as usb-ccid support legacy -usbdevice?

2011-05-16 Thread Markus Armbruster
Anthony Liguori  writes:

> On 05/13/2011 11:36 AM, Markus Armbruster wrote:
>> When Gerd qdevified USB, he kept legacy -usbdevice working (commit
>> 0958b4cc...).  What about new USB devices?  Should they get a legacy
>> syntax, too?
>>
>> The only existing new device is usb-ccid, and it got one in commit
>> 36707144.
>
> What keeps -usbdevice from being a light wrapper to -device such that
> no future code is needed for this?

What would that buy us?  Inhowfar is -usbdevice any lighter than
-device?

> I know some of the names are different but presumably we could use a
> map for existing ones and pass through names for newer ones.

Here's what an USB device needs to do for -usbdevice:

* For -usbdevice NAME (no parameters), set USBDeviceInfo member
  usbdevice_name to NAME.

* For -usbdevice NAME:PARAMS, additionally set USBDeviceInfo member
  usbdevice_init() to a function that parses PARAMS and creates the
  device.

  Legacy PARAMs use various ad hoc syntax, and that's why we have a
  callback here.

  For new devices, we could require regular syntax, and then a common
  callback would do.  The common NAME=VALUE,... syntax is the obvious
  choice, where the NAMEs are property names.

  But then -usbdevice is *exactly* like -device, except you the "usb"
  goes in a different place: "-usbdevice ccid" vs. "-device usb-ccid".
  And except that -usbdevice is crippled for some devices.  For
  instance, usb-ccid doesn't support parameters with -usbdevice, even
  though it has a qdev property.



Re: [Qemu-devel] [PATCH] target-arm: Minimal implementation of performance counters

2011-05-16 Thread Peter Maydell
On 14 May 2011 22:32, Aurelien Jarno  wrote:
> On Fri, May 06, 2011 at 03:32:27PM +0100, Peter Maydell wrote:
>> I just spoke with Paul on IRC about this. In summary:
>>  * for a helper to cause an exception then it has (a) to make sure CPU
>> state (pc, condflags) is sync'd before the call to the helper and (b)
>> the helper has to be in a file with access to global env, because it
>> needs to call cpu_loop_exit()
>
> I don't think (a) is true. It is possible to use the same way as for
> load/store operations, that is call cpu_restore_state() before calling
> cpu_loop_exit().

Yes, I think you're right here, I'm not sure why I didn't think that
would work. (b) still applies, though.

> If you don't really like having env as a fixed host registers (recent
> patch series from Blue Swirl seems to want to get rid of this), it is
> possible to pass env as an argument of the helper to do that.

I think really my position on this patch is that it adds
functionality that means you can't actually boot recent Linux
kernels with hw breakpoint support enabled, and I'd rather not
have it get tangled up with either the ongoing "remove AREG0"
discussions or a more general overhaul of how cp15 registers
are handled. It just handles this handful of new registers in
the same way we currently handle all the other cp14/cp15 regs.

> What ever solution is used, we need env for the load/store functions,
> and theses functions already provide a framework to restore the CPU
> state. I think it's a good idea to use this framework instead of having
> a second framework using TCG code for that.

Do you mean you'd like to see us using cpu_restore_state() instead
of explicit state-syncing TCG code for the cases where the exception
is "expected" like SVC instructions? (ie what most targets have
a gen_exception() function for.)

-- PMM



[Qemu-devel] KVM call agenda for May 17th

2011-05-16 Thread Juan Quintela

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

>From two weeks ago, we have already:

 - import kvm headers into qemu, drop #ifdef maze (Jan)

Thanks, Juan.




Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target

2011-05-16 Thread Alon Levy
On Mon, May 16, 2011 at 09:00:10AM +0200, Paolo Bonzini wrote:
> On 05/15/2011 05:40 PM, Alon Levy wrote:
> >-ln -s "$source_path/libcacard/Makefile" libcacard/Makefile
> >+ln -s -f "$source_path/libcacard/Makefile" libcacard/Makefile
> 
> Use the "symlink" function rather than ln -s -f for portability to
> broken platforms, please.
ok.

> 
> Note that this requires libtool at build time rather than only for
> maintainers.  This is unlike all other software using it.  However,
> I believe this is not too bad given that a special make invocation
> is required.

I was under the impression this was the way to use libtool (I've basically
followed the manual). Is there another way that is better?

> 
> Paolo



Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target

2011-05-16 Thread Paolo Bonzini

On 05/16/2011 12:25 PM, Alon Levy wrote:

>  Note that this requires libtool at build time rather than only for
>  maintainers.  This is unlike all other software using it.  However,
>  I believe this is not too bad given that a special make invocation
>  is required.

I was under the impression this was the way to use libtool (I've basically
followed the manual). Is there another way that is better?


Without using Autoconf, this is the way.

Usually programs that are fully autoconf-iscated will ship a subset of 
libtool sources in the tarball, build a custom version at configure 
time, and invoke it from the Makefile via ./libtool.  This has the 
advantage that only the maintainer needs to have libtool installed. 
OTOH we do not use Autoconf and I think this contributes to 99% of the 
bad name for Autoconf, so it's not something we want.


Paolo



Re: [Qemu-devel] Add option to disable Cocoa on Mac OS X

2011-05-16 Thread Ben Leslie
On Wed, May 11, 2011 at 23:54, Peter Maydell  wrote:
> On 7 May 2011 12:40, Alexander Graf  wrote:
>> So I suppose the only thing missing is a --disable-cocoa option, yup.
>
> I've just noticed that some of the code in block/raw-posix.c
> uses the CONFIG_COCOA #define to gate whether to do MacOSX
> specific handling of CDROMs and so on. I'm not a MacOS expert
> but maybe that needs to be changed to some other ifdef -- I'm
> guessing we don't want to have cdrom handling randomly change
> behaviour just because the user tried to disable Cocoa graphics
> handling...

These seems to be a good point. Potentially checking for __APPLE__ and
__MACH__ makes more sense? (See: http://predef.sourceforge.net/preos.html#sec20)

Cheers,

Ben



[Qemu-devel] [regression] qemu-system-arm: segfault in lsi_do_command

2011-05-16 Thread Jonathan Nieder
Hi,

Kevin Wolf wrote:

> This pulls the request completion for error cases from the caller to
> scsi_disk_emulate_command. This should not change semantics, but allows to
> reuse scsi_handle_write_error() for flushes in the next patch.

Today I tried out qemu-system-arm for the first time.  It's faster
than I expected; very neat.  Unfortunately it segfaults.

Reproducible with "master" (077030d11).  Bisects to v0.14.0-rc0~489
(scsi-disk: Complete failed requests in scsi_disk_emulate_command,
2010-10-25).

Ideas?
Jonathan

Backtrace:

| Program received signal SIGSEGV, Segmentation fault.
| 0x005552b5 in lsi_do_command (s=0x13b84d0) at 
/home/jrn/src/qemu/hw/lsi53c895a.c:762
| 762 dev->info->read_data(dev, s->current->tag);
| (gdb) bt full
| #0  0x005552b5 in lsi_do_command (s=0x13b84d0) at 
/home/jrn/src/qemu/hw/lsi53c895a.c:762
| dev = 0x13baf10
| buf = "\000\000\000\000\000\000\000\000\251\207Q\000\000\000\000"
| n = 656877154
| #1  lsi_execute_script (s=0x13b84d0) at 
/home/jrn/src/qemu/hw/lsi53c895a.c:1067
| insn = 20688656
| addr = 97263452
| addr_high = 
| opcode = 
| insn_processed = 18
| #2  0x005566b8 in lsi_reg_writeb (s=0x13b84d0, offset=, val=32 ' ')
| at /home/jrn/src/qemu/hw/lsi53c895a.c:1656
| No locals.
| #3  0x4059fe4e in ?? ()
| No symbol table info available.
| #4  0x0040 in ?? ()
| No symbol table info available.
| #5  0x in ?? ()
| No symbol table info available.
| (gdb) p n
| $1 = 656877154
| (gdb) p dev->info
| $2 = (SCSIDeviceInfo *) 0x8df000
| (gdb) p s->current
| $3 = (lsi_request *) 0x0

That's weird because qemu_mallocz should have checked for NULL.

Program counter:

| Dump of assembler code for function lsi_execute_script:
[...]
|0x00555250 <+2784>:  callq  0x42a970 
|0x00555255 <+2789>:  mov0x334(%rbx),%edx
|0x0055525b <+2795>:  mov%rax,0x350(%rbx)
|0x00555262 <+2802>:  mov%rbp,%rdi
|0x00555265 <+2805>:  mov%edx,(%rax)
|0x00555267 <+2807>:  mov0x350(%rbx),%rsi
|0x0055526e <+2814>:  lea0x30(%rsp),%rdx
|0x00555273 <+2819>:  mov0x98(%rbp),%rax
|0x0055527a <+2826>:  mov0x330(%rbx),%ecx
|0x00555280 <+2832>:  mov(%rsi),%esi
|0x00555282 <+2834>:  callq  *0x78(%rax)
|0x00555285 <+2837>:  cmp$0x0,%eax
|0x00555288 <+2840>:  mov%eax,%r14d
|0x0055528b <+2843>:  jle0xcc 
|0x00555291 <+2849>:  movzbl 0x38b(%rbx),%eax
|0x00555298 <+2856>:  mov0x350(%rbx),%rdx
|0x0055529f <+2863>:  mov%rbp,%rdi
|0x005552a2 <+2866>:  and$0xfff8,%eax
|0x005552a5 <+2869>:  or $0x1,%eax
|0x005552a8 <+2872>:  mov%al,0x38b(%rbx)
|0x005552ae <+2878>:  mov0x98(%rbp),%rax
| => 0x005552b5 <+2885>:  mov(%rdx),%esi
|0x005552b7 <+2887>:  callq  *0x80(%rax)
|0x005552bd <+2893>:  mov0x338(%rbx),%ebp

Recipe:

| $ ./configure --prefix=$HOME/opt/qemu --disable-werror
| [...]
| $ make -j2 install STRIP=:
| [...]
| $ PATH=$HOME/opt/qemu/bin:$PATH
| $ qemu-img create arm-install.qemu 10G
| Formatting 'arm-install.qemu', fmt=raw size=10737418240
| $ wget 
http://d-i.debian.org/daily-images/armel/daily/versatile/netboot/initrd.gz
| [...]
| $ wget 
http://d-i.debian.org/daily-images/armel/daily/versatile/netboot/vmlinuz-2.6.37-2-versatile
| [...]
| $ sha1sum initrd.gz vmlinuz-2.6.37-2-versatile
| 9822cd356e2e66c0ee2d08f2dfc100f074683b81  initrd.gz
| 81aa8f15f6d0fb3fa971d859787f89eec653d1a3  vmlinuz-2.6.37-2-versatile
| $
| $ qemu-system-arm  -M versatilepb -kernel vmlinuz-2.6.37-2-versatile \
|   -initrd initrd.gz -hda arm-install.qemu
| Segmentation fault (core dumped)

The above transcript does not describe the installation process, since
it happened in another window.

1. choice of keymap, mirror, etc are boring
2. It asks for a root password.  Leave it blank.
3. It asks for a new account.  I chose "sudoer".
4. It wants a password.  Give one.
5. Choose a time zone and switch to vt4 for messages.
6. Messages (copied by hand):

| kernel: [  928.454139] SCSI subsystem initialized
| kernel: [  928.767929] PCI: enabling device :00:0c.0 (0100 -> 0103)
| kernel: [  928.840653] sym0: <895a> rev 0x0 at pci :00:0c.0 irq 27
| kernel: [  928.893943] sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
| kernel: [  928.902942] sym0: SCSI BUS has been reset.
| kernel: [  928.903283] scsi0 : sym-2.2.3
| kernel: [  931.915071] sym0: unknown interrupt(s) ignored, ISTAT=0x5 
DSTAT=0x80 SIST=0x0
| kernel: [  931.922015] scsi 0:0:0:0: Direct-Access QEMU QEMU HARDDISK 
   0.14 PQ: 0 ANSI: 5
| kernel: [  931.922765] scsi target0:0:0: tagged command queuing enabled, 
command queue depth 16.
| kernel: [  931.92317

[Qemu-devel] [PATCH] Abort on attempts to load out-of-range ROMs

2011-05-16 Thread Ben Leslie
Abort on attempts to load out-of-range ROMs

Change ROM loading behaviour so that attempts to load ROMs that fall outside
valid memory ranges causing an abort with a useful error message, rather
than silently ignoring the problem.

Signed-off-by: Ben Leslie 
---
 exec.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/exec.c b/exec.c
index a718d74..af1b6a2 100644
--- a/exec.c
+++ b/exec.c
@@ -3838,7 +3838,7 @@ void
cpu_physical_memory_write_rom(target_phys_addr_t addr,
 if ((pd & ~TARGET_PAGE_MASK) != IO_MEM_RAM &&
 (pd & ~TARGET_PAGE_MASK) != IO_MEM_ROM &&
 !(pd & IO_MEM_ROMD)) {
-/* do nothing */
+   cpu_abort(first_cpu, "Attempting to load malformed ROM at
address: 0x%x\n", addr);
 } else {
 unsigned long addr1;
 addr1 = (pd & TARGET_PAGE_MASK) + (addr & ~TARGET_PAGE_MASK);



[Qemu-devel] [PATCH] piix_pci: fix piix3_set_irq_pic()

2011-05-16 Thread TeLeMan
If pic_irq is greater than 7, the irq level is always 0 on 32bits.

Signed-off-by: TeLeMan 
---
 hw/piix_pci.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 7f1c4cc..85a320e 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -312,7 +312,7 @@ static void piix3_set_irq_pic(PIIX3State *piix3,
int pic_irq)
 {
 qemu_set_irq(piix3->pic[pic_irq],
  !!(piix3->pic_levels &
-(((1UL << PIIX_NUM_PIRQS) - 1) <<
+(((1ULL << PIIX_NUM_PIRQS) - 1) <<
  (pic_irq * PIIX_NUM_PIRQS;
 }

-- 
1.7.3.1.msysgit.0
--
SUN OF A BEACH



Re: [Qemu-devel] [Qemu-trivial] [PATCH] piix_pci: fix piix3_set_irq_pic()

2011-05-16 Thread Stefan Hajnoczi
On Mon, May 16, 2011 at 12:50 PM, TeLeMan  wrote:
> If pic_irq is greater than 7, the irq level is always 0 on 32bits.
>
> Signed-off-by: TeLeMan 
> ---
>  hw/piix_pci.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Thanks, applied to the trivial-patches tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches

Your patch is line-wrapped.  I have manually applied it, please make
sure future submissions are not line-wrapped.  GMail's web interface
always line wraps, you must use their SMTP server directly (e.g. with
git-send-email(1)).

Stefan



Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target

2011-05-16 Thread Gerd Hoffmann

  Hi,


Usually programs that are fully autoconf-iscated will ship a subset of
libtool sources in the tarball, build a custom version at configure
time, and invoke it from the Makefile via ./libtool. This has the
advantage that only the maintainer needs to have libtool installed. OTOH
we do not use Autoconf and I think this contributes to 99% of the bad
name for Autoconf, so it's not something we want.


Another option would be to not use autoconf at all.  Building ELF shared 
libs isn't that difficuilt these days.  Question is whenever there is 
any non-ELF platform we care about (Windows maybe?).


cheers,
  Gerd



Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target

2011-05-16 Thread Paolo Bonzini

On 05/16/2011 02:06 PM, Gerd Hoffmann wrote:

Usually programs that are fully autoconf-iscated will ship a subset of
libtool sources in the tarball, build a custom version at configure
time, and invoke it from the Makefile via ./libtool. This has the
advantage that only the maintainer needs to have libtool installed. OTOH
we do not use Autoconf and I think this contributes to 99% of the bad
name for Autoconf, so it's not something we want.


Another option would be to not use autoconf at all.

 

You probably mean libtool?


Building ELF shared
libs isn't that difficuilt these days. Question is whenever there is any
non-ELF platform we care about (Windows maybe?).


... and Darwin?

Paolo



Re: [Qemu-devel] [PATCH 2/2] libcacard: add libcacard.la target

2011-05-16 Thread Alon Levy
On Mon, May 16, 2011 at 02:07:55PM +0200, Paolo Bonzini wrote:
> On 05/16/2011 02:06 PM, Gerd Hoffmann wrote:
> >>Usually programs that are fully autoconf-iscated will ship a subset of
> >>libtool sources in the tarball, build a custom version at configure
> >>time, and invoke it from the Makefile via ./libtool. This has the
> >>advantage that only the maintainer needs to have libtool installed. OTOH
> >>we do not use Autoconf and I think this contributes to 99% of the bad
> >>name for Autoconf, so it's not something we want.
> >
> >Another option would be to not use autoconf at all.
>  
> 
> You probably mean libtool?
> 
> >Building ELF shared
> >libs isn't that difficuilt these days. Question is whenever there is any
> >non-ELF platform we care about (Windows maybe?).
> 
> ... and Darwin?
> 

For linux all that is needed is to recompile all required sources with -fPIC 
(doesn't
make sense to force that on the objects linked to the rest of qemu), and link 
them with
gcc -shared. Does that work on Darwin? on Windows (mingw / cygwin)?

> Paolo
> 



[Qemu-devel] [PATCH v2 00/21] SCSI subsystem improvements

2011-05-16 Thread Paolo Bonzini
This series includes the following improvements to the SCSI subsystem:

1) introduction of SCSIBusOps that generalize the existing
command_complete callback;

2) widespread use of the SCSIRequest abstraction, with simpler memory
management (refcounting) and with various common idioms converted into
simple C functions instead of duplicating them all over the place;

3) support for autosense.

Some patches are from Hannes Reinecke's megasas patchset posted last
November, forward ported and applied to the new vSCSI controller as
well.

I already planned the following two series too:

1) adding support for zerocopy.  Previous attempts were rejected
because they were applied to real devices (thus making for example an
IOMMU hard to impossible).  However, for PV devices zerocopy should be
uncontroversial---and it is a must to get competitive performance WRT
virtio-blk.  I'll use vmw-pvscsi for the first implementation and for
benchmarking.

2) adding support for multiple LUNs.  I plan to add a fake "scsi-target"
device for this.

After this I'll work on the virtio-scsi device model.

Testing:
- RHEL6.1 install complete to scsi-disk with lsi, from scsi-generic CD
- iozone run with lsi on scsi-disk target
- RHEL6.1 install to usb-msd from IDE CD is too slow, but it manages to
  format /boot in ~10 minutes with or without the patch
- RHEL6.1 install started with vscsi, from scsi-generic CD including
  playing with opening/closing the tray (to exercise autosense), complete
  test not done yet

esp is only compile tested.

Please review and apply; I do not think this should go in through the
block branch.

v1->v2:
rebased, added patch 21

Hannes Reinecke (4):
  scsi: Use 'SCSIRequest' directly
  scsi: Update sense code handling
  scsi: Implement 'get_sense' callback
  scsi-disk: add data direction checking

Paolo Bonzini (17):
  scsi: add tracing of scsi requests
  scsi-generic: Remove bogus double complete
  scsi: introduce scsi_req_data
  scsi: introduce SCSIBusOps
  scsi: reference-count requests
  lsi: extract lsi_find_by_tag
  scsi: commonize purging requests
  scsi: introduce scsi_req_abort
  scsi: introduce scsi_req_cancel
  scsi: use scsi_req_complete
  scsi: do not call send_command directly
  scsi: introduce scsi_req_new
  scsi: introduce scsi_req_kick
  scsi: introduce scsi_req_get_buf
  scsi: make write_data return void
  scsi-generic: Handle queue full
  scsi: split command_complete callback in two

 hw/esp.c  |  111 +-
 hw/lsi53c895a.c   |  186 +++--
 hw/scsi-bus.c |  203 +---
 hw/scsi-disk.c|  264 ++---
 hw/scsi-generic.c |  218 +---
 hw/scsi.h |   91 ++
 hw/spapr_vscsi.c  |  180 
 hw/usb-msd.c  |  118 ++--
 trace-events  |8 ++
 9 files changed, 830 insertions(+), 549 deletions(-)

-- 
1.7.4.4




  1   2   >