[Qemu-devel] Simulate different network card vendors

2014-01-14 Thread rajan pathak
Hello All

I am new QEMU development and wanted to Simulate Atheros Network controller.


I am Running QEMU on x86 machine with underlaying network controller from
Broadcom and
 compiled linux kernel based on ARM having Atheros driver support.

I guess there must be mapping at QEMU level calls for Atheros driver maps
to Broadcom.
Have no idea where to start looking in to QEMU code and what files to look
into.

Can anyone let me know how in general mapping mapping between two different
network vendors takes plave at QEMU level.

Thanks
Rajan


Re: [Qemu-devel] [PATCH 1/1] KVM: Retry KVM_CREATE_VM on EINTR or EAGAIN

2014-01-14 Thread Paolo Bonzini
Il 15/01/2014 03:09, Tom Knych ha scritto:
> Doing it with sigprocmask seems good I will send an updated patch

No need, I'll apply this patch.

Paolo



[Qemu-devel] [Bug 1256546] Re: qemu-s390x-static: segmentation fault entering chroot

2014-01-14 Thread Ken Sharp
** Changed in: qemu
   Status: New => Confirmed

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

Title:
  qemu-s390x-static: segmentation fault entering chroot

Status in QEMU:
  Confirmed
Status in “qemu” package in Ubuntu:
  Triaged

Bug description:
  Host: Ubuntu Trusty i386
  Guest: Debian Sid s390x

  When attempting to debootstrap a Debian Sid s390x guest the second
  stage process immediately fails with a segmentation fault, and any
  subsequent attempts to run any command while in the chroot.

  I: Running command: chroot s390x /debootstrap/debootstrap --second-stage
  Segmentation fault (core dumped)
  # chroot s390x/
  # ps
  Segmentation fault (core dumped)
  # ls
  Segmentation fault (core dumped)
  # exit
  exit

  ProblemType: Bug
  DistroRelease: Ubuntu 14.04
  Package: qemu-user-static 1.6.0+dfsg-2ubuntu4
  ProcVersionSignature: Ubuntu 3.12.0-4.12-generic 3.12.1
  Uname: Linux 3.12.0-4-generic i686
  ApportVersion: 2.12.7-0ubuntu1
  Architecture: i386
  Date: Sat Nov 30 18:19:59 2013
  InstallationDate: Installed on 2013-11-29 (1 days ago)
  InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Alpha i386 (20131126)
  ProcEnviron:
   LANGUAGE=en_GB:en
   TERM=xterm
   PATH=(custom, no user)
   LANG=en_GB.UTF-8
   SHELL=/bin/bash
  SourcePackage: qemu
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1256546/+subscriptions



Re: [Qemu-devel] [PATCH v2] hw/misc/blob-loader: add a generic blob loader

2014-01-14 Thread Peter Crosthwaite
On Wed, Jan 15, 2014 at 5:06 PM, Li Guang  wrote:
> ping ...
>
> any other comments?
> or new suggestions?
>

No new suggestions from me, but PMM has a point about
load_image_targphys@realize doing exactly whats needed, so something
closer to V1 WRT to that may actually be best.

Regards,
peter

> Thanks!
>
>
>
> Li Guang wrote:
>>
>> this blob loader will be used to load a specified
>> blob into a specified RAM address.
>>
>> Signed-off-by: Li Guang
>> Suggested-by: Peter Crosthwaite
>> ---
>>   hw/misc/Makefile.objs |2 +
>>   hw/misc/blob-loader.c |  112
>> +
>>   include/hw/misc/blob-loader.h |   17 ++
>>   3 files changed, 131 insertions(+), 0 deletions(-)
>>   create mode 100644 hw/misc/blob-loader.c
>>   create mode 100644 include/hw/misc/blob-loader.h
>>
>> diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
>> index f674365..3edbd5c 100644
>> --- a/hw/misc/Makefile.objs
>> +++ b/hw/misc/Makefile.objs
>> @@ -42,3 +42,5 @@ obj-$(CONFIG_SLAVIO) += slavio_misc.o
>>   obj-$(CONFIG_ZYNQ) += zynq_slcr.o
>>
>>   obj-$(CONFIG_PVPANIC) += pvpanic.o
>> +
>> +common-obj-y += blob-loader.o
>> diff --git a/hw/misc/blob-loader.c b/hw/misc/blob-loader.c
>> new file mode 100644
>> index 000..4f790e5
>> --- /dev/null
>> +++ b/hw/misc/blob-loader.c
>> @@ -0,0 +1,112 @@
>> +/*
>> + * generic blob loader
>> + *
>> + * Copyright (C) 2014 Li Guang
>> + * Written by Li Guang
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> it
>> + * under the terms of the GNU General Public License as published by the
>> + * Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful, but
>> WITHOUT
>> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
>> + * for more details.
>> + */
>> +
>> +#include "hw/sysbus.h"
>> +#include "hw/devices.h"
>> +#include "hw/loader.h"
>> +#include "hw/misc/blob-loader.h"
>> +#include "qemu/error-report.h"
>> +
>> +static Property blob_loader_props[] = {
>> +DEFINE_PROP_UINT64("addr", BlobLoaderState, addr, 0),
>> +DEFINE_PROP_STRING("file", BlobLoaderState, file),
>> +DEFINE_PROP_END_OF_LIST(),
>> +};
>> +
>> +static int load_blob_into_ram(const char *file,  uint64_t addr,  int
>> count)
>> +{
>> +int fd = -1, size;
>> +uint8_t *data;
>> +
>> +fd = open(file, O_RDONLY | O_BINARY);
>> +if (fd == -1) {
>> +error_report("can't open file %s\n", file);
>> +return -1;
>> +}
>> +lseek(fd, 0, SEEK_SET);
>> +data = g_malloc0(count);
>> +size = read(fd, data, count);
>> +if (count != size) {
>> +error_report("%s: read error: %d (expected %d)\n", file, size,
>> count);
>> +return -1;
>> +}
>> +close(fd);
>> +
>> +cpu_physical_memory_write_rom(addr, data, size);
>> +
>> +g_free(data);
>> +data = NULL;
>> +
>> +return 0;
>> +}
>> +
>> +static void blob_loader_reset(DeviceState *dev)
>> +{
>> +BlobLoaderState *s = BLOB_LOADER(dev);
>> +int file_size;
>> +
>> +file_size = get_image_size(s->file);
>> +if (file_size<  0) {
>> +error_report("can't get file size of %s\n", s->file);
>> +exit(1);
>> +}
>> +
>> +if (load_blob_into_ram(s->file, s->addr, file_size)<  0) {
>> +error_report("can't load %s\n", s->file);
>> +exit(1);
>> +}
>> +}
>> +
>> +static void blob_loader_realize(DeviceState *dev, Error **errp)
>> +{
>> +BlobLoaderState *s = BLOB_LOADER(dev);
>> +char *file_name;
>> +
>> +if (s->file == NULL) {
>> +error_setg(errp, "please spicify a file for blob loader.\n");
>> +return;
>> +}
>> +file_name = qemu_find_file(QEMU_FILE_TYPE_BIOS, s->file);
>> +if (file_name == NULL) {
>> +error_setg(errp, "can't find %s\n", s->file);
>> +return;
>> +}
>> +}
>> +
>> +static void blob_loader_class_init(ObjectClass *klass, void *data)
>> +{
>> +DeviceClass *dc = DEVICE_CLASS(klass);
>> +
>> +dc->reset = blob_loader_reset;
>> +dc->realize = blob_loader_realize;
>> +dc->props = blob_loader_props;
>> +dc->desc = "blob loader";
>> +}
>> +
>> +static TypeInfo blob_loader_info = {
>> +.name = TYPE_BLOB_LOADER,
>> +.parent = TYPE_SYS_BUS_DEVICE,
>> +.instance_size = sizeof(BlobLoaderState),
>> +.class_init = blob_loader_class_init,
>> +};
>> +
>> +static void blob_loader_register_type(void)
>> +{
>> +type_register_static(&blob_loader_info);
>> +}
>> +
>> +type_init(blob_loader_register_type)
>> diff --git a/include/hw/misc/blob-loader.h b/include/hw/misc/blob-loader.h
>> new file mode 100644
>> index 000..478fd8d
>> --- /dev/null
>> +++ b/include/hw/misc/blob-loader.h
>> @@ -0,0 +1,17 @@
>> +#ifndef BLOB_LOADER_H
>> +#define BLOB_LOADER_H
>> +
>> 

Re: [Qemu-devel] [PATCH 0/4] spapr-pci: prepare for vfio

2014-01-14 Thread Alexey Kardashevskiy
On 12/20/2013 01:47 PM, Alexey Kardashevskiy wrote:
> On 12/05/2013 08:39 PM, Alexey Kardashevskiy wrote:
>> On 11/21/2013 03:08 PM, Alexey Kardashevskiy wrote:
>>> Here are few reworks for spapr-pci PHB which I'd like to have to support 
>>> VFIO.
>>> QOM, errors printing, traces, nothing really serious. Thanks!
>>>
>>> Alexey Kardashevskiy (4):
>>>   spapr-pci: convert init() callback to realize()
>>>   spapr-pci: introduce a finish_realize() callback
>>>   spapr-pci: add spapr_pci trace
>>>   spapr-pci: converts fprintf to error_report
>>>
>>>  hw/ppc/spapr_pci.c  | 90 
>>> ++---
>>>  include/hw/pci-host/spapr.h | 18 -
>>>  trace-events|  1 +
>>>  3 files changed, 69 insertions(+), 40 deletions(-)
>>
>>
>> Ping?
> 
> Ping?

Ping?


-- 
Alexey



Re: [Qemu-devel] [PATCH v2] hw/misc/blob-loader: add a generic blob loader

2014-01-14 Thread Li Guang

ping ...

any other comments?
or new suggestions?

Thanks!


Li Guang wrote:

this blob loader will be used to load a specified
blob into a specified RAM address.

Signed-off-by: Li Guang
Suggested-by: Peter Crosthwaite
---
  hw/misc/Makefile.objs |2 +
  hw/misc/blob-loader.c |  112 +
  include/hw/misc/blob-loader.h |   17 ++
  3 files changed, 131 insertions(+), 0 deletions(-)
  create mode 100644 hw/misc/blob-loader.c
  create mode 100644 include/hw/misc/blob-loader.h

diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
index f674365..3edbd5c 100644
--- a/hw/misc/Makefile.objs
+++ b/hw/misc/Makefile.objs
@@ -42,3 +42,5 @@ obj-$(CONFIG_SLAVIO) += slavio_misc.o
  obj-$(CONFIG_ZYNQ) += zynq_slcr.o

  obj-$(CONFIG_PVPANIC) += pvpanic.o
+
+common-obj-y += blob-loader.o
diff --git a/hw/misc/blob-loader.c b/hw/misc/blob-loader.c
new file mode 100644
index 000..4f790e5
--- /dev/null
+++ b/hw/misc/blob-loader.c
@@ -0,0 +1,112 @@
+/*
+ * generic blob loader
+ *
+ * Copyright (C) 2014 Li Guang
+ * Written by Li Guang
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "hw/sysbus.h"
+#include "hw/devices.h"
+#include "hw/loader.h"
+#include "hw/misc/blob-loader.h"
+#include "qemu/error-report.h"
+
+static Property blob_loader_props[] = {
+DEFINE_PROP_UINT64("addr", BlobLoaderState, addr, 0),
+DEFINE_PROP_STRING("file", BlobLoaderState, file),
+DEFINE_PROP_END_OF_LIST(),
+};
+
+static int load_blob_into_ram(const char *file,  uint64_t addr,  int count)
+{
+int fd = -1, size;
+uint8_t *data;
+
+fd = open(file, O_RDONLY | O_BINARY);
+if (fd == -1) {
+error_report("can't open file %s\n", file);
+return -1;
+}
+lseek(fd, 0, SEEK_SET);
+data = g_malloc0(count);
+size = read(fd, data, count);
+if (count != size) {
+error_report("%s: read error: %d (expected %d)\n", file, size, count);
+return -1;
+}
+close(fd);
+
+cpu_physical_memory_write_rom(addr, data, size);
+
+g_free(data);
+data = NULL;
+
+return 0;
+}
+
+static void blob_loader_reset(DeviceState *dev)
+{
+BlobLoaderState *s = BLOB_LOADER(dev);
+int file_size;
+
+file_size = get_image_size(s->file);
+if (file_size<  0) {
+error_report("can't get file size of %s\n", s->file);
+exit(1);
+}
+
+if (load_blob_into_ram(s->file, s->addr, file_size)<  0) {
+error_report("can't load %s\n", s->file);
+exit(1);
+}
+}
+
+static void blob_loader_realize(DeviceState *dev, Error **errp)
+{
+BlobLoaderState *s = BLOB_LOADER(dev);
+char *file_name;
+
+if (s->file == NULL) {
+error_setg(errp, "please spicify a file for blob loader.\n");
+return;
+}
+file_name = qemu_find_file(QEMU_FILE_TYPE_BIOS, s->file);
+if (file_name == NULL) {
+error_setg(errp, "can't find %s\n", s->file);
+return;
+}
+}
+
+static void blob_loader_class_init(ObjectClass *klass, void *data)
+{
+DeviceClass *dc = DEVICE_CLASS(klass);
+
+dc->reset = blob_loader_reset;
+dc->realize = blob_loader_realize;
+dc->props = blob_loader_props;
+dc->desc = "blob loader";
+}
+
+static TypeInfo blob_loader_info = {
+.name = TYPE_BLOB_LOADER,
+.parent = TYPE_SYS_BUS_DEVICE,
+.instance_size = sizeof(BlobLoaderState),
+.class_init = blob_loader_class_init,
+};
+
+static void blob_loader_register_type(void)
+{
+type_register_static(&blob_loader_info);
+}
+
+type_init(blob_loader_register_type)
diff --git a/include/hw/misc/blob-loader.h b/include/hw/misc/blob-loader.h
new file mode 100644
index 000..478fd8d
--- /dev/null
+++ b/include/hw/misc/blob-loader.h
@@ -0,0 +1,17 @@
+#ifndef BLOB_LOADER_H
+#define BLOB_LOADER_H
+
+typedef struct BlobLoaderState {
+/*<  private>*/
+DeviceState parent_obj;
+/*<  public>*/
+
+uint64_t addr;
+char *file;
+} BlobLoaderState;
+
+#define TYPE_BLOB_LOADER "blob-loader"
+#define BLOB_LOADER(obj) OBJECT_CHECK(BlobLoaderState, (obj), TYPE_BLOB_LOADER)
+
+#endif
+
   





Re: [Qemu-devel] [PATCHv6 6/6] qemu-iotests: blacklist test 020 for NFS protocol

2014-01-14 Thread Peter Lieven

On 15.01.2014 07:27, Fam Zheng wrote:

On Mon, 01/13 11:21, Peter Lieven wrote:

reopening is currently not supported.

Signed-off-by: Peter Lieven 
---
  tests/qemu-iotests/020 |5 +
  1 file changed, 5 insertions(+)

diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
index a42f32f..f8a849c 100755
--- a/tests/qemu-iotests/020
+++ b/tests/qemu-iotests/020
@@ -46,6 +46,11 @@ _supported_fmt qcow qcow2 vmdk qed
  _supported_proto file
  _supported_os Linux
  
+# NFS does not support bdrv_reopen_prepare thus qemu-img commit fails.

+if [ "$IMGPROTO" = "nfs" ]; then
+_notrun "image protocol $IMGPROTO does not support bdrv_commit"
+fi
+

Doesn't "_supported_proto file" above already skip this case?

Fam

You are right, the proto should be generic and just NFS should be blacklisted.

Peter




Re: [Qemu-devel] [PATCHv6 5/6] qemu-iotests: fix expected output of test 067

2014-01-14 Thread Peter Lieven

On 15.01.2014 07:54, Fam Zheng wrote:

On Mon, 01/13 11:21, Peter Lieven wrote:

Signed-off-by: Peter Lieven 
---
  tests/qemu-iotests/067.out |8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
index 8d271cc..79ed90f 100644
--- a/tests/qemu-iotests/067.out
+++ b/tests/qemu-iotests/067.out
@@ -12,7 +12,7 @@ QMP_VERSION
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "DEVICE_DELETED", 
"data": {"path": "/machine/peripheral/virtio0/virtio-backend"}}
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "DEVICE_DELETED", "data": 
{"device": "virtio0", "path": "/machine/peripheral/virtio0"}}
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"RESET"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
+{"return": [{"io-status": "ok", "device": "disk", "locked": false, "removable": false, "inserted": {"iops_rd": 0, "image": {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": "qcow2", "data": {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": 
"qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", "encryption_key_missing": false}, "type": "unknown"}, {"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}]}
  {"return": {}}
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"SHUTDOWN"}
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": 
{"device": "ide1-cd0", "tray-open": true}}
@@ -31,7 +31,7 @@ QMP_VERSION
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "DEVICE_DELETED", 
"data": {"path": "/machine/peripheral/virtio0/virtio-backend"}}
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "DEVICE_DELETED", "data": 
{"device": "virtio0", "path": "/machine/peripheral/virtio0"}}
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"RESET"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
+{"return": [{"io-status": "ok", "device": "disk", "locked": false, "removable": false, "inserted": {"iops_rd": 0, "image": {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": "qcow2", "data": {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": 
"qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", "encryption_key_missing": false}, "type": "unknown"}, {"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}]}
  {"return": {}}
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"SHUTDOWN"}
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": 
{"device": "ide1-cd0", "tray-open": true}}
@@ -51,7 +51,7 @@ QMP_VERSION
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "DEVICE_DELETED", 
"data": {"path": "/machine/peripheral/virtio0/virtio-backend"}}
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "DEVICE_DELETED", "data": 
{"device": "virtio0", "path": "/machine/peripheral/virtio0"}}
  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"RESET"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
+{"return": [{

Re: [Qemu-devel] [PATCHv6 5/6] qemu-iotests: fix expected output of test 067

2014-01-14 Thread Fam Zheng
On Mon, 01/13 11:21, Peter Lieven wrote:
> Signed-off-by: Peter Lieven 
> ---
>  tests/qemu-iotests/067.out |8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
> index 8d271cc..79ed90f 100644
> --- a/tests/qemu-iotests/067.out
> +++ b/tests/qemu-iotests/067.out
> @@ -12,7 +12,7 @@ QMP_VERSION
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "DEVICE_DELETED", "data": {"path": 
> "/machine/peripheral/virtio0/virtio-backend"}}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "DEVICE_DELETED", "data": {"device": "virtio0", "path": 
> "/machine/peripheral/virtio0"}}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "RESET"}
> -{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
> "removable": true, "tray_open": false, "type": "unknown"}, {"device": 
> "floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
> "unknown"}, {"device": "sd0", "locked": false, "removable": true, 
> "tray_open": false, "type": "unknown"}]}
> +{"return": [{"io-status": "ok", "device": "disk", "locked": false, 
> "removable": false, "inserted": {"iops_rd": 0, "image": {"virtual-size": 
> 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": 
> "qcow2", "actual-size": SIZE, "format-specific": {"type": "qcow2", "data": 
> {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 
> 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 
> 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", 
> "encryption_key_missing": false}, "type": "unknown"}, {"io-status": "ok", 
> "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, 
> "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, 
> "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, 
> "removable": true, "tray_open": false, "type": "unknown"}]}
>  {"return": {}}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "SHUTDOWN"}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
> @@ -31,7 +31,7 @@ QMP_VERSION
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "DEVICE_DELETED", "data": {"path": 
> "/machine/peripheral/virtio0/virtio-backend"}}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "DEVICE_DELETED", "data": {"device": "virtio0", "path": 
> "/machine/peripheral/virtio0"}}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "RESET"}
> -{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
> "removable": true, "tray_open": false, "type": "unknown"}, {"device": 
> "floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
> "unknown"}, {"device": "sd0", "locked": false, "removable": true, 
> "tray_open": false, "type": "unknown"}]}
> +{"return": [{"io-status": "ok", "device": "disk", "locked": false, 
> "removable": false, "inserted": {"iops_rd": 0, "image": {"virtual-size": 
> 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": 
> "qcow2", "actual-size": SIZE, "format-specific": {"type": "qcow2", "data": 
> {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 
> 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 
> 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", 
> "encryption_key_missing": false}, "type": "unknown"}, {"io-status": "ok", 
> "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, 
> "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, 
> "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, 
> "removable": true, "tray_open": false, "type": "unknown"}]}
>  {"return": {}}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "SHUTDOWN"}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
> @@ -51,7 +51,7 @@ QMP_VERSION
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "DEVICE_DELETED", "data": {"path": 
> "/machine/peripheral/virtio0/virtio-backend"}}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "DEVICE_DELETED", "data": {"device": "virtio0", "path": 
> "/machine/peripheral/virtio0"}}
>  {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
> "RESET"}
> -{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
> "removable": true, "tray_open": false, "type": "unknown"}, {"device": 
> "floppy0", "locked": false, "removable": true, "tray_open

Re: [Qemu-devel] [PATCH v2 0/6] Add netmap backend offloadings support

2014-01-14 Thread Barak Wasserstrom
Vincenzo,
I'm using a tap interface and in the guest virtual device i see all
offloading features are disabled, even though they are enabled in the
physical device.
Perhaps you can help? See below related information:

Bridge to the physical interface in the host:
---
brctl addbr br0
brctl  addif br0 eth3
---

/etc/qemu-ifup:
---
#!/bin/sh
set -x

switch=br0

if [ -n "$1" ];then
/usr/bin/sudo /usr/sbin/tunctl -u `whoami` -t $1
/usr/bin/sudo /sbin/ip link set $1 up
sleep 0.5s
/usr/bin/sudo /sbin/brctl addif $switch $1
exit 0
else
echo "Error: no interface specified"
exit 1
fi
---

Activation command:
---
qemu-system-arm -enable-kvm  -M vexpress-a15  -serial /dev/ttyS1 -append
'root=/dev/vda rw console=ttyAMA0 rootwait earlyprintk' -nographic -kernel
/guest/zImage_vexpress -dtb /guest/vexpress-v2p-ca15_a7.dtb -drive
if=none,file=/guest/arm-wheezy.img,id=foo -device
virtio-blk-device,drive=foo -device
virtio-net-device,netdev=net0,mac=DE:AD:BE:EF:F4:E5 -netdev tap,id=net0
---

Physical interface features (ethtool -k eth3):
---
Features for eth3:
rx-checksumming: on
tx-checksumming: on
tx-checksum-ipv4: on
tx-checksum-ip-generic: off [fixed]
tx-checksum-ipv6: on
tx-checksum-fcoe-crc: off [fixed]
tx-checksum-sctp: off [fixed]
scatter-gather: on
tx-scatter-gather: on
tx-scatter-gather-fraglist: off [fixed]
tcp-segmentation-offload: on
tx-tcp-segmentation: on
tx-tcp-ecn-segmentation: on
tx-tcp6-segmentation: on
udp-fragmentation-offload: off [fixed]
generic-segmentation-offload: on
generic-receive-offload: on
large-receive-offload: off [fixed]
rx-vlan-offload: off [fixed]
tx-vlan-offload: off [fixed]
ntuple-filters: on
receive-hashing: on
highdma: on
rx-vlan-filter: off [fixed]
vlan-challenged: off [fixed]
tx-lockless: off [fixed]
netns-local: off [fixed]
tx-gso-robust: off [fixed]
tx-fcoe-segmentation: off [fixed]
tx-gre-segmentation: off [fixed]
tx-udp_tnl-segmentation: off [fixed]
fcoe-mtu: off [fixed]
tx-nocache-copy: on
loopback: off [fixed]
rx-fcs: off [fixed]
rx-all: off [fixed]
tx-vlan-stag-hw-insert: off [fixed]
rx-vlan-stag-hw-parse: off [fixed]
rx-vlan-stag-filter: off [fixed]
---

Virtual device features in the guest (ethtool -k eth0):
---
Features for eth0:

rx-checksumming: off [fixed]

tx-checksumming: off

tx-checksum-ipv4: off [fixed]

tx-checksum-ip-generic: off [fixed]

tx-checksum-ipv6: off [fixed]

tx-checksum-fcoe-crc: off [fixed]

tx-checksum-sctp: off [fixed]

scatter-gather: off

tx-scatter-gather: off [fixed]

tx-scatter-gather-fraglist: off [fixed]

tcp-segmentation-offload: off

tx-tcp-segmentation: off [fixed]

tx-tcp-ecn-segmentation: off [fixed]

tx-tcp6-segmentation: off [fixed]

udp-fragmentation-offload: off [fixed]

generic-segmentation-offload: off [requested on]

generic-receive-offload: on

large-receive-offload: off [fixed]

rx-vlan-offload: off [fixed]

tx-vlan-offload: off [fixed]

ntuple-filters: off [fixed]

receive-hashing: off [fixed]

highdma: on [fixed]

rx-vlan-filter: off [fixed]

vlan-challenged: off [fixed]

tx-lockless: off [fixed]

netns-local: off [fixed]

tx-gso-robust: off [fixed]

tx-fcoe-segmentation: off [fixed]

tx-gre-segmentation: off [fixed]

tx-ipip-segmentation: off [fixed]

tx-sit-segmentation: off [fixed]

tx-udp_tnl-segmentation: off [fixed]

tx-mpls-segmentation: off [fixed]

fcoe-mtu: off [fixed]

tx-nocache-copy: off

loopback: off [fixed]

rx-fcs: off [fixed]

rx-all: off [fixed]

tx-vlan-stag-hw-insert: off [fixed]

rx-vlan-stag-hw-parse: off [fixed]

rx-vlan-stag-filter: off [fixed]

l2-fwd-offload: off [fixed]

---

Regards,
Barak



On Tue, Jan 14, 2014 at 12:59 PM, Vincenzo Maffione wrote:

> The purpose of this patch series is to add offloadings support
> (TSO/UFO/CSUM) to the netmap network backend, and make it possible
> for the paravirtual network frontends (virtio-net and vmxnet3) to
> use it.
> In order to achieve this, these patches extend the existing
> net.h interface to add abstract operations through which a network
> frontend can manipulate backend offloading features, instead of
> directly calling TAP-specific functions.
>
> Guest-to-guest performance before this patches for virtio-net

Re: [Qemu-devel] [PATCH target-arm v4 1/3] xilinx_zynq: added SMP support:

2014-01-14 Thread Peter Crosthwaite
On Sat, Jan 11, 2014 at 4:08 AM, Peter Maydell  wrote:
> On 2 January 2014 07:30, Peter Crosthwaite  
> wrote:
>> Added Linux SMP support for the Xilinx Zynq platform (2x CPUs are
>> supported)
>>
>> Signed-off-by: Peter Crosthwaite 
>> ---
>> Changed from v3:
>> Author reset
>> s/zynq_cpus/cpus
>> simplified custom secondary bootloader
>> Rebased
>> Changed from v2:
>> macro defined the maximum number of CPUS
>> Changed from v1:
>> Addressed PMM review
>> Shorted secondary bootloop using MVN instruction.
>> Used default reset secondary instead of custom one.
>> Rebased against QOM cpu developments.
>> Few whitespace fixes.
>>
>>  hw/arm/xilinx_zynq.c | 69 
>> 
>>  1 file changed, 53 insertions(+), 16 deletions(-)
>>
>> diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
>> index 17251c7..c09ff36 100644
>> --- a/hw/arm/xilinx_zynq.c
>> +++ b/hw/arm/xilinx_zynq.c
>> @@ -27,6 +27,8 @@
>>  #include "hw/ssi.h"
>>  #include "qemu/error-report.h"
>>
>> +#define MAX_CPUS 2
>> +
>>  #define NUM_SPI_FLASHES 4
>>  #define NUM_QSPI_FLASHES 2
>>  #define NUM_QSPI_BUSSES 2
>> @@ -38,10 +40,37 @@
>>
>>  #define MPCORE_PERIPHBASE 0xF8F0
>>
>> +/* Dummy bootreg addr to keep ARM bootloader happy. Very top of OCM */
>> +#define SMP_BOOTREG_ADDR 0xfffc
>
> It would probably be nicer to provide your own
> reset_secondary hook, and then hw/arm/boot.c won't
> ever look at what you set in bootreg_addr.
>

Yep, thatll be much cleaner. Thanks. All fixed in v2.

Regards,
Peter

> Looks ok otherwise, though.
>
> thanks
> -- PMM
>



Re: [Qemu-devel] [PATCHv6 6/6] qemu-iotests: blacklist test 020 for NFS protocol

2014-01-14 Thread Fam Zheng
On Mon, 01/13 11:21, Peter Lieven wrote:
> reopening is currently not supported.
> 
> Signed-off-by: Peter Lieven 
> ---
>  tests/qemu-iotests/020 |5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
> index a42f32f..f8a849c 100755
> --- a/tests/qemu-iotests/020
> +++ b/tests/qemu-iotests/020
> @@ -46,6 +46,11 @@ _supported_fmt qcow qcow2 vmdk qed
>  _supported_proto file
>  _supported_os Linux
>  
> +# NFS does not support bdrv_reopen_prepare thus qemu-img commit fails.
> +if [ "$IMGPROTO" = "nfs" ]; then
> +_notrun "image protocol $IMGPROTO does not support bdrv_commit"
> +fi
> +

Doesn't "_supported_proto file" above already skip this case?

Fam



Re: [Qemu-devel] troubleshooting live migration

2014-01-14 Thread Marcus Sorensen
Ok, more information. The console spews 'lapic increasing min_delta_ns
to ' when this happens.

On Tue, Jan 14, 2014 at 8:31 AM, Marcus Sorensen  wrote:
> Does anyone have tips on troubleshooting live migration? I've got
> several E5-2650 servers running in test environment, kernel 3.10.26
> and qemu 1.7.0. If I start a VM guest (say ubuntu, debian, or centos),
> I can migrate it around  from host to host to host just fine, but if I
> wait awhile (say 1 hour), I try to migrate and it succeeds but the
> guest is hosed. No longer pings, cpu is thrashing. I've tried to
> strace it and don't see anything that other working hosts aren't
> doing, and I've tried gdb but I'm not entirely sure what I'm doing. I
> tried downgrading to qemu 1.6.1. I've found dozens of reports of such
> behavior, but they're all due to other things (migrating between
> different host CPUs, someone thinking it's virtio or memballoon only
> to later find a fix like changing machine type, etc). I'm at a loss.
> This seems to work just fine with stock CentOS builds.
>
> I'd be happy to try to capture a core if someone is willing to look at it.
>
> Here's an example xml:
>
> 
>   VM12
>   dd25acfc-e24d-4de6-814c-72ac465bc208
>   
>   4194304
>   4194304
>   2
>   
> 2000
>   
>   
> /machine
>   
>   
> hvm
> 
> 
>   
>   
> 
> 
> 
>   
>   
>   
>   
> 
>   
>   destroy
>   restart
>   destroy
>   
> /usr/bin/qemu-kvm
> 
>   
>   
>   
>function='0x0'/>
> 
> 
>   
>   
>   
>   
> 
> 
>function='0x1'/>
> 
> 
>function='0x0'/>
> 
> 
>function='0x2'/>
> 
> 
> 
>   
>   
>   
>   
> 
> 
>   
>function='0x0'/>
> 
> 
>   
> 
> 
>   
> 
> 
>   
>   
>   
> 
> 
> 
> 
>   
> 
> 
>   
>function='0x0'/>
> 
> 
>function='0x0'/>
> 
>   
>   
> 



Re: [Qemu-devel] [PATCH build-fix v2 1/1] error: Don't use error_report() for assertion msgs.

2014-01-14 Thread Edgar E. Iglesias
On Tue, Jan 14, 2014 at 07:37:09PM -0800, Peter Crosthwaite wrote:
> Use fprintf(stderr instead. This removes dependency of libqemuutil.a
> on the monitor.
> 
> We can further justify this change, in that this code path should only
> trigger under a fatal error condition. fprintf-stderr is probably the
> appropriate medium as under a fatal error conidition the monitor itself
> may be down and out for the count. So assertion failure messages should
> go lowest common denominator - straight to stderr.
> 
> Fixes the build as reported by Kevin Wolf. Issue debugged and change
> suggested by Luiz Capitulino. Issue introduced by
> 5d24ee70bcbcf578614193526bcd5ed30a8eb16c.

Applied, thanks


> 
> Signed-off-by: Peter Crosthwaite 
> ---
> changed since v1:
> Added "\n" (AF reivew)
> 
>  util/error.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/util/error.c b/util/error.c
> index f11f1d5..e5de34f 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -44,7 +44,7 @@ void error_set(Error **errp, ErrorClass err_class, const 
> char *fmt, ...)
>  err->err_class = err_class;
>  
>  if (errp == &error_abort) {
> -error_report("%s", error_get_pretty(err));
> +fprintf(stderr, "%s\n", error_get_pretty(err));
>  abort();
>  }
>  
> @@ -80,7 +80,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass 
> err_class,
>  err->err_class = err_class;
>  
>  if (errp == &error_abort) {
> -error_report("%s", error_get_pretty(err));
> +fprintf(stderr, "%s\n", error_get_pretty(err));
>  abort();
>  }
>  
> @@ -125,7 +125,7 @@ void error_set_win32(Error **errp, int win32_err, 
> ErrorClass err_class,
>  err->err_class = err_class;
>  
>  if (errp == &error_abort) {
> -error_report("%s", error_get_pretty(err));
> +fprintf(stderr, "%s\n", error_get_pretty(err));
>  abort();
>  }
>  
> @@ -171,7 +171,7 @@ void error_free(Error *err)
>  void error_propagate(Error **dst_err, Error *local_err)
>  {
>  if (local_err && dst_err == &error_abort) {
> -error_report("%s", error_get_pretty(local_err));
> +fprintf(stderr, "%s\n", error_get_pretty(local_err));
>  abort();
>  } else if (dst_err && !*dst_err) {
>  *dst_err = local_err;
> -- 
> 1.8.5.3
> 
> 





Re: [Qemu-devel] [PATCH 2/2] block: resize backing image during active layer commit, if needed

2014-01-14 Thread Fam Zheng
On Mon, 01/13 15:18, Jeff Cody wrote:
> If the top image to commit is the active layer, and also larger than
> the base image, then an I/O error will likely be returned during
> block-commit.
> 
> For instance, if we have a base image with a virtual size 10G, and a
> active layer image of size 20G, then committing the snapshot via
> 'block-commit' will likely fail.
> 
> This will automatically attempt to resize the base image, if the
> active layer image to be committed is larger.
> 
> Signed-off-by: Jeff Cody 
> ---
>  block/mirror.c | 13 +
>  1 file changed, 13 insertions(+)
> 
> diff --git a/block/mirror.c b/block/mirror.c
> index 2932bab..c4e42fa 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -630,9 +630,22 @@ void commit_active_start(BlockDriverState *bs, 
> BlockDriverState *base,
>   BlockDriverCompletionFunc *cb,
>   void *opaque, Error **errp)
>  {
> +int64_t length;
>  if (bdrv_reopen(base, bs->open_flags, errp)) {
>  return;
>  }

"base" is already reopened here.

> +
> +length = bdrv_getlength(bs);
> +
> +if (length > bdrv_getlength(base)) {
> +if (bdrv_truncate(base, length) < 0) {
> +error_setg(errp, "Top image %s is larger than base image %s, and 
> "
> + "resize of base image failed.",
> + bs->filename, base->filename);
> +return;

Should we restore open flags for base?

Thanks,
Fam

> +}
> +}
> +
>  bdrv_ref(base);
>  mirror_start_job(bs, base, speed, 0, 0,
>   on_error, on_error, cb, opaque, errp,
> -- 
> 1.8.3.1
> 



Re: [Qemu-devel] [PATCH v2] SPARC: Fix LEON3 power down instruction

2014-01-14 Thread Edgar E. Iglesias
On Tue, Jan 14, 2014 at 08:04:40AM +0100, Sebastian Huber wrote:
> Hello,
> 
> maybe this patch can be qualified as trivial?

Hi,

I've applied it, thanks.

Cheers,
Edgar

> 
> http://lists.nongnu.org/archive/html/qemu-devel/2013-11/msg03488.html
> 
> On 2014-01-07 19:07, Sebastian Huber wrote:
> >Hello,
> >
> >would somebody mind committing this.
> >
> >On 12/06/2013 06:48 PM, Richard Henderson wrote:
> >>On 11/27/2013 08:50 PM, Sebastian Huber wrote:
> >>>Synchronize the program counter before the power down helper call
> >>>otherwise interrupts will return to the wrong context.
> >>>
> >>>Signed-off-by: Sebastian Huber 
> >>>---
> >>>  target-sparc/translate.c |1 +
> >>>  1 files changed, 1 insertions(+), 0 deletions(-)
> >>>
> >>>diff --git a/target-sparc/translate.c b/target-sparc/translate.c
> >>>index 05639ef..7481c85 100644
> >>>--- a/target-sparc/translate.c
> >>>+++ b/target-sparc/translate.c
> >>>@@ -3630,6 +3630,7 @@ static void disas_sparc_insn(DisasContext * dc,
> >>>unsigned int insn)
> >>>  if ((rd == 0x13) && (dc->def->features &
> >>>
> >>>CPU_FEATURE_POWERDOWN)) {
> >>>  /* LEON3 power-down */
> >>>+save_state(dc);
> >>>  gen_helper_power_down(cpu_env);
> >>>  }
> >>>  break;
> >>>
> >>Reviewed-by: Richard Henderson 
> >>
> >>
> >>r~
> >>
> >
> >
> 
> 
> -- 
> Sebastian Huber, embedded brains GmbH
> 
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone   : +49 89 189 47 41-16
> Fax : +49 89 189 47 41-09
> E-Mail  : sebastian.hu...@embedded-brains.de
> PGP : Public key available on request.
> 
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
> 



[Qemu-devel] [Bug 1254672] Re: ps segfaults with qemu-{arm, armel, mips, powerpc}-static

2014-01-14 Thread Ken Sharp
** Tags added: saucy

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

Title:
  ps segfaults with qemu-{arm,armel,mips,powerpc}-static

Status in QEMU:
  Fix Committed
Status in Linaro QEMU:
  New
Status in “qemu-linaro” package in Ubuntu:
  Fix Committed

Bug description:
  Host: Ubuntu Precise AMD64
  Guest: Debian Testing armhf (or armel)

  After running a debootstrap for Debian testing/armhf and entering the
  chroot, simply running "ps" causes a segmentation fault.

  $ sudo qemu-debootstrap --arch=armhf testing armhf 
http://ftp.uk.debian.org/debian/
  [...]
  $ sudo chroot armhf
  # ps
  Signal 11 (SEGV) caught by ps (procps-ng version 3.3.4).
  /bin/ps:display.c:59: please report this bug

  I couldn't find a bug report for procps, which would be unusual if
  such a bug existed, so I'm assuming the bug is in qemu.

  Unfortunately trying to run debootstrap for an Ubuntu variant fails to
  find the release file.

  ps is used a lot, as you can imagine, but specifically it fails when
  trying to install some packages via "apt-get install" and no attempt
  is made to recover.

  ProblemType: Bug
  DistroRelease: Ubuntu 12.04
  Package: qemu-user-static 1.0.50-2012.03-0ubuntu2.1
  ProcVersionSignature: Ubuntu 3.8.0-33.48~precise1-generic 3.8.13.11
  Uname: Linux 3.8.0-33-generic x86_64
  NonfreeKernelModules: wl
  ApportVersion: 2.0.1-0ubuntu17.6
  Architecture: amd64
  Date: Mon Nov 25 10:43:12 2013
  Dependencies:

  InstallationMedia: Ubuntu 12.04.3 LTS "Precise Pangolin" - Release amd64 
(20130820.1)
  MarkForUpload: True
  ProcEnviron:
   LANGUAGE=en_GB:en
   TERM=xterm
   PATH=(custom, no user)
   LANG=en_GB.UTF-8
   SHELL=/bin/bash
  SourcePackage: qemu-linaro
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1254672/+subscriptions



[Qemu-devel] [PATCH] spapr: reset @kvm_vcpu_dirty before starting CPU

2014-01-14 Thread Alexey Kardashevskiy
Normally QEMU kvm_arch_get_registers() reads registers and sets a dirty
flag which prevents further registers reading from KVM till
kvm_arch_put_registers() executes and resets the flag.

However if we run QEMU with "-S" ("suspended"), then execute "info cpus"
from the QEMU monitor, we end up with not reading registers in
rtas_start_cpu() as qmp_query_cpus() calls kvm_cpu_synchronize_state()
which leaves @kvm_vcpu_dirty=true what prevents kvm_cpu_synchronize_state()
from synchronizing registers and we loose the values.

This resets @kvm_vcpu_dirty flag as we do not have content which we really want 
to
keep at this point as the CPU is halted.

Signed-off-by: Alexey Kardashevskiy 
---

We could also reset @kvm_vcpu_dirty in qmp_query_cpus() but that would be
racy.
---
 hw/ppc/spapr_rtas.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index 1cb276d..3dade5e 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -185,6 +185,8 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, 
sPAPREnvironment *spapr,
 /* This will make sure qemu state is up to date with kvm, and
  * mark it dirty so our changes get flushed back before the
  * new cpu enters */
+
+cs->kvm_vcpu_dirty = false;
 kvm_cpu_synchronize_state(cs);
 
 env->msr = (1ULL << MSR_SF) | (1ULL << MSR_ME);
-- 
1.8.4.rc4




Re: [Qemu-devel] make check fails on the current master: 133fe7743 "Merge remote branch 'luiz/queue/qmp' into qmpq"

2014-01-14 Thread Peter Crosthwaite
Fixing patch is on list.

Regards,
Peter

On Wed, Jan 15, 2014 at 1:49 PM, Stefan Hajnoczi  wrote:
> On Tue, Jan 14, 2014 at 03:46:24PM +0100, Igor Mammedov wrote:
>> make check
>>
>> ...
>>   LINK  tests/check-qom-interface
>> libqemuutil.a(qemu-error.o): In function `error_vprintf':
>> /home/imammedo/builds/qemu/util/qemu-error.c:23: undefined reference to 
>> `cur_mon'
>> /home/imammedo/builds/qemu/util/qemu-error.c:24: undefined reference to 
>> `cur_mon'
>> /home/imammedo/builds/qemu/util/qemu-error.c:24: undefined reference to 
>> `monitor_vprintf'
>> libqemuutil.a(qemu-error.o): In function `error_printf_unless_qmp':
>> /home/imammedo/builds/qemu/util/qemu-error.c:47: undefined reference to 
>> `monitor_cur_is_qmp'
>> libqemuutil.a(qemu-error.o): In function `error_print_loc':
>> /home/imammedo/builds/qemu/util/qemu-error.c:174: undefined reference to 
>> `cur_mon'
>
> Seeing the same thing here.
>



Re: [Qemu-devel] make check fails on the current master: 133fe7743 "Merge remote branch 'luiz/queue/qmp' into qmpq"

2014-01-14 Thread Stefan Hajnoczi
On Tue, Jan 14, 2014 at 03:46:24PM +0100, Igor Mammedov wrote:
> make check
> 
> ...
>   LINK  tests/check-qom-interface
> libqemuutil.a(qemu-error.o): In function `error_vprintf':
> /home/imammedo/builds/qemu/util/qemu-error.c:23: undefined reference to 
> `cur_mon'
> /home/imammedo/builds/qemu/util/qemu-error.c:24: undefined reference to 
> `cur_mon'
> /home/imammedo/builds/qemu/util/qemu-error.c:24: undefined reference to 
> `monitor_vprintf'
> libqemuutil.a(qemu-error.o): In function `error_printf_unless_qmp':
> /home/imammedo/builds/qemu/util/qemu-error.c:47: undefined reference to 
> `monitor_cur_is_qmp'
> libqemuutil.a(qemu-error.o): In function `error_print_loc':
> /home/imammedo/builds/qemu/util/qemu-error.c:174: undefined reference to 
> `cur_mon'

Seeing the same thing here.



Re: [Qemu-devel] [PATCH] dataplane: fix shadowed return value

2014-01-14 Thread Stefan Hajnoczi
On Mon, Jan 13, 2014 at 06:47:39PM +0800, Stefan Hajnoczi wrote:
> Propagate the error return value from get_indirect().
> 
> Signed-off-by: Stefan Hajnoczi 
> ---
>  hw/virtio/dataplane/vring.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Fixed commit description as suggested by Markus.

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan



[Qemu-devel] [Bug 1042388] Re: qemu: Unsupported syscall: 257 (timer_create)

2014-01-14 Thread Erik de Castro Lopo
Thanks  for the test case Martin. Problem confirmed.

The issue is that timer_create allows a number of different callback
mechanisms and I had only implemented the one I need.

 Working on it now.

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

Title:
  qemu: Unsupported syscall: 257 (timer_create)

Status in QEMU:
  Fix Released
Status in “qemu” package in Ubuntu:
  Triaged

Bug description:
  Running qemu-arm-static for git HEAD. When I try to install ghc from
  debian into my arm chroot I get:

  Setting up ghc (7.4.1-4) ...
  qemu: Unsupported syscall: 257
  ghc: timer_create: Function not implemented
  qemu: Unsupported syscall: 257
  ghc-pkg: timer_create: Function not implemented
  dpkg: error processing ghc (--configure):
   subprocess installed post-installation script returned error exit status 1
  Errors were encountered while processing:
   ghc
  E: Sub-process /usr/bin/dpkg returned an error code (1)

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1042388/+subscriptions



[Qemu-devel] [PATCH build-fix v2 1/1] error: Don't use error_report() for assertion msgs.

2014-01-14 Thread Peter Crosthwaite
Use fprintf(stderr instead. This removes dependency of libqemuutil.a
on the monitor.

We can further justify this change, in that this code path should only
trigger under a fatal error condition. fprintf-stderr is probably the
appropriate medium as under a fatal error conidition the monitor itself
may be down and out for the count. So assertion failure messages should
go lowest common denominator - straight to stderr.

Fixes the build as reported by Kevin Wolf. Issue debugged and change
suggested by Luiz Capitulino. Issue introduced by
5d24ee70bcbcf578614193526bcd5ed30a8eb16c.

Signed-off-by: Peter Crosthwaite 
---
changed since v1:
Added "\n" (AF reivew)

 util/error.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/util/error.c b/util/error.c
index f11f1d5..e5de34f 100644
--- a/util/error.c
+++ b/util/error.c
@@ -44,7 +44,7 @@ void error_set(Error **errp, ErrorClass err_class, const char 
*fmt, ...)
 err->err_class = err_class;
 
 if (errp == &error_abort) {
-error_report("%s", error_get_pretty(err));
+fprintf(stderr, "%s\n", error_get_pretty(err));
 abort();
 }
 
@@ -80,7 +80,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass 
err_class,
 err->err_class = err_class;
 
 if (errp == &error_abort) {
-error_report("%s", error_get_pretty(err));
+fprintf(stderr, "%s\n", error_get_pretty(err));
 abort();
 }
 
@@ -125,7 +125,7 @@ void error_set_win32(Error **errp, int win32_err, 
ErrorClass err_class,
 err->err_class = err_class;
 
 if (errp == &error_abort) {
-error_report("%s", error_get_pretty(err));
+fprintf(stderr, "%s\n", error_get_pretty(err));
 abort();
 }
 
@@ -171,7 +171,7 @@ void error_free(Error *err)
 void error_propagate(Error **dst_err, Error *local_err)
 {
 if (local_err && dst_err == &error_abort) {
-error_report("%s", error_get_pretty(local_err));
+fprintf(stderr, "%s\n", error_get_pretty(local_err));
 abort();
 } else if (dst_err && !*dst_err) {
 *dst_err = local_err;
-- 
1.8.5.3




Re: [Qemu-devel] [PATCH build-fix v1 1/1] error: Don't use error_report() for assertion msgs.

2014-01-14 Thread Peter Crosthwaite
On Wed, Jan 15, 2014 at 1:31 PM, Peter Crosthwaite
 wrote:
> On Wed, Jan 15, 2014 at 12:55 PM, Andreas Färber  wrote:
>> Am 15.01.2014 03:29, schrieb Peter Crosthwaite:
>>> Use fprintf(stderr instead. This removes dependency of libqemuutil.a
>>> on the monitor.
>>>
>>> We can further justify this change, in that this code path should only
>>> trigger under a fatal error condition. fprintf-stderr is probably the
>>> appropriate medium as under a fatal error conidition the monitor itself
>>> may be down and out for the count. So assertion failure messages should
>>> go lowest common denominator - straight to stderr.
>>
>> Actually I thought the point of error_report() was to add an appropriate
>> prefix "qemu-system-foo: ..." to the error message and an optional
>> timestamp, not to send it to the monitor...
>>
>
> Well this patch routes it away from the monitor. Never implemented
> prefixing though. My main motivations were:
>
> 1: Text reduction. No need to define local_err and assert them constantly.
> 2: Full backtraceability of the error.
>

Sry misread your mail, you were commenting error_report not error_abort as
I read it if your wondering why my mail makes no sense at all. Sry for the
noise :S

> Regards,
> Peter
>
>>>
>>> Fixes the build as reported by Kevin Wolf. Issue debugged and change
>>> suggested by Luiz Capitulino. Issue introduced by
>>> 5d24ee70bcbcf578614193526bcd5ed30a8eb16c.
>>>
>>> Signed-off-by: Peter Crosthwaite 
>>> ---
>>>
>>>  util/error.c | 8 
>>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/util/error.c b/util/error.c
>>> index f11f1d5..7c7650c 100644
>>> --- a/util/error.c
>>> +++ b/util/error.c
>>> @@ -44,7 +44,7 @@ void error_set(Error **errp, ErrorClass err_class, const 
>>> char *fmt, ...)
>>>  err->err_class = err_class;
>>>
>>>  if (errp == &error_abort) {
>>> -error_report("%s", error_get_pretty(err));
>>> +fprintf(stderr, "%s", error_get_pretty(err));
>>
>> You need to add \n if you do this.
>>

Fixed. V2 en-route.

Regards,
Peter

>> Andreas
>>
>>>  abort();
>>>  }
>>>
>>> @@ -80,7 +80,7 @@ void error_set_errno(Error **errp, int os_errno, 
>>> ErrorClass err_class,
>>>  err->err_class = err_class;
>>>
>>>  if (errp == &error_abort) {
>>> -error_report("%s", error_get_pretty(err));
>>> +fprintf(stderr, "%s", error_get_pretty(err));
>>>  abort();
>>>  }
>>>
>>> @@ -125,7 +125,7 @@ void error_set_win32(Error **errp, int win32_err, 
>>> ErrorClass err_class,
>>>  err->err_class = err_class;
>>>
>>>  if (errp == &error_abort) {
>>> -error_report("%s", error_get_pretty(err));
>>> +fprintf(stderr, "%s", error_get_pretty(err));
>>>  abort();
>>>  }
>>>
>>> @@ -171,7 +171,7 @@ void error_free(Error *err)
>>>  void error_propagate(Error **dst_err, Error *local_err)
>>>  {
>>>  if (local_err && dst_err == &error_abort) {
>>> -error_report("%s", error_get_pretty(local_err));
>>> +fprintf(stderr, "%s", error_get_pretty(local_err));
>>>  abort();
>>>  } else if (dst_err && !*dst_err) {
>>>  *dst_err = local_err;
>>>
>>
>>
>> --
>> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
>> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
>>



Re: [Qemu-devel] [PATCH build-fix v1 1/1] error: Don't use error_report() for assertion msgs.

2014-01-14 Thread Peter Crosthwaite
On Wed, Jan 15, 2014 at 12:55 PM, Andreas Färber  wrote:
> Am 15.01.2014 03:29, schrieb Peter Crosthwaite:
>> Use fprintf(stderr instead. This removes dependency of libqemuutil.a
>> on the monitor.
>>
>> We can further justify this change, in that this code path should only
>> trigger under a fatal error condition. fprintf-stderr is probably the
>> appropriate medium as under a fatal error conidition the monitor itself
>> may be down and out for the count. So assertion failure messages should
>> go lowest common denominator - straight to stderr.
>
> Actually I thought the point of error_report() was to add an appropriate
> prefix "qemu-system-foo: ..." to the error message and an optional
> timestamp, not to send it to the monitor...
>

Well this patch routes it away from the monitor. Never implemented
prefixing though. My main motivations were:

1: Text reduction. No need to define local_err and assert them constantly.
2: Full backtraceability of the error.

Regards,
Peter

>>
>> Fixes the build as reported by Kevin Wolf. Issue debugged and change
>> suggested by Luiz Capitulino. Issue introduced by
>> 5d24ee70bcbcf578614193526bcd5ed30a8eb16c.
>>
>> Signed-off-by: Peter Crosthwaite 
>> ---
>>
>>  util/error.c | 8 
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/util/error.c b/util/error.c
>> index f11f1d5..7c7650c 100644
>> --- a/util/error.c
>> +++ b/util/error.c
>> @@ -44,7 +44,7 @@ void error_set(Error **errp, ErrorClass err_class, const 
>> char *fmt, ...)
>>  err->err_class = err_class;
>>
>>  if (errp == &error_abort) {
>> -error_report("%s", error_get_pretty(err));
>> +fprintf(stderr, "%s", error_get_pretty(err));
>
> You need to add \n if you do this.
>
> Andreas
>
>>  abort();
>>  }
>>
>> @@ -80,7 +80,7 @@ void error_set_errno(Error **errp, int os_errno, 
>> ErrorClass err_class,
>>  err->err_class = err_class;
>>
>>  if (errp == &error_abort) {
>> -error_report("%s", error_get_pretty(err));
>> +fprintf(stderr, "%s", error_get_pretty(err));
>>  abort();
>>  }
>>
>> @@ -125,7 +125,7 @@ void error_set_win32(Error **errp, int win32_err, 
>> ErrorClass err_class,
>>  err->err_class = err_class;
>>
>>  if (errp == &error_abort) {
>> -error_report("%s", error_get_pretty(err));
>> +fprintf(stderr, "%s", error_get_pretty(err));
>>  abort();
>>  }
>>
>> @@ -171,7 +171,7 @@ void error_free(Error *err)
>>  void error_propagate(Error **dst_err, Error *local_err)
>>  {
>>  if (local_err && dst_err == &error_abort) {
>> -error_report("%s", error_get_pretty(local_err));
>> +fprintf(stderr, "%s", error_get_pretty(local_err));
>>  abort();
>>  } else if (dst_err && !*dst_err) {
>>  *dst_err = local_err;
>>
>
>
> --
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
>



Re: [Qemu-devel] [Bug 1261743] [NEW] trace-backend "simple" doesn't support "disable" property of event

2014-01-14 Thread Stefan Hajnoczi
On Tue, Dec 17, 2013 at 9:19 PM, bkantor <1261...@bugs.launchpad.net> wrote:
> Public bug reported:
>
> trace-backend "simple" generates wrong eventid in trace/generated-
> tracers.c after "disable" property occured in trace-events record.
>
> Result: missing or mixing logs in trace file.

Thanks for the bug report.  I have posted a fix:
http://permalink.gmane.org/gmane.comp.emulators.qemu/250845



[Qemu-devel] [PATCH] trace: fix simple trace "disable" keyword

2014-01-14 Thread Stefan Hajnoczi
The trace-events "disable" keyword turns an event into a nop at
compile-time.  This is important for high-frequency events that can
impact performance.

The "disable" keyword is currently broken in the simple trace backend.
This patch fixes the problem as follows:

Trace events are identified by their TraceEventID number.  When events
are disabled there are two options for assigning TraceEventID numbers:
1. Skip disabled events and don't assign them a number.
2. Assign numbers for all events regardless of the disabled keyword.

The simple trace backend and its binary file format uses approach #1.

The tracetool infrastructure has been using approach #2 for a while.

The result is that the numbers used in simple trace files do not
correspond with TraceEventIDs.  In trace/simple.c we assumed that they
are identical and therefore emitted bogus numbers.

This patch fixes the bug by using TraceEventID for trace_event_id()
while sticking to approach #1 for simple trace file numbers.  This
preserves simple trace file format compatibility.

Signed-off-by: Stefan Hajnoczi 
---
 scripts/tracetool/backend/simple.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/tracetool/backend/simple.py 
b/scripts/tracetool/backend/simple.py
index 37ef599..7b72164 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -56,7 +56,7 @@ def c(events):
 
 
 out('',
-'TraceEvent *eventp = trace_event_id(%(event_id)s);',
+'TraceEvent *eventp = trace_event_id(%(event_enum)s);',
 'bool _state = trace_event_get_state_dynamic(eventp);',
 'if (!_state) {',
 'return;',
@@ -65,6 +65,7 @@ def c(events):
 'if (trace_record_start(&rec, %(event_id)s, %(size_str)s)) {',
 'return; /* Trace Buffer Full, Event Dropped ! */',
 '}',
+event_enum = 'TRACE_' + event.name.upper(),
 event_id = num,
 size_str = sizestr,
 )
-- 
1.8.4.2




Re: [Qemu-devel] [PATCH build-fix v1 1/1] error: Don't use error_report() for assertion msgs.

2014-01-14 Thread Andreas Färber
Am 15.01.2014 03:29, schrieb Peter Crosthwaite:
> Use fprintf(stderr instead. This removes dependency of libqemuutil.a
> on the monitor.
> 
> We can further justify this change, in that this code path should only
> trigger under a fatal error condition. fprintf-stderr is probably the
> appropriate medium as under a fatal error conidition the monitor itself
> may be down and out for the count. So assertion failure messages should
> go lowest common denominator - straight to stderr.

Actually I thought the point of error_report() was to add an appropriate
prefix "qemu-system-foo: ..." to the error message and an optional
timestamp, not to send it to the monitor...

> 
> Fixes the build as reported by Kevin Wolf. Issue debugged and change
> suggested by Luiz Capitulino. Issue introduced by
> 5d24ee70bcbcf578614193526bcd5ed30a8eb16c.
> 
> Signed-off-by: Peter Crosthwaite 
> ---
> 
>  util/error.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/util/error.c b/util/error.c
> index f11f1d5..7c7650c 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -44,7 +44,7 @@ void error_set(Error **errp, ErrorClass err_class, const 
> char *fmt, ...)
>  err->err_class = err_class;
>  
>  if (errp == &error_abort) {
> -error_report("%s", error_get_pretty(err));
> +fprintf(stderr, "%s", error_get_pretty(err));

You need to add \n if you do this.

Andreas

>  abort();
>  }
>  
> @@ -80,7 +80,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass 
> err_class,
>  err->err_class = err_class;
>  
>  if (errp == &error_abort) {
> -error_report("%s", error_get_pretty(err));
> +fprintf(stderr, "%s", error_get_pretty(err));
>  abort();
>  }
>  
> @@ -125,7 +125,7 @@ void error_set_win32(Error **errp, int win32_err, 
> ErrorClass err_class,
>  err->err_class = err_class;
>  
>  if (errp == &error_abort) {
> -error_report("%s", error_get_pretty(err));
> +fprintf(stderr, "%s", error_get_pretty(err));
>  abort();
>  }
>  
> @@ -171,7 +171,7 @@ void error_free(Error *err)
>  void error_propagate(Error **dst_err, Error *local_err)
>  {
>  if (local_err && dst_err == &error_abort) {
> -error_report("%s", error_get_pretty(local_err));
> +fprintf(stderr, "%s", error_get_pretty(local_err));
>  abort();
>  } else if (dst_err && !*dst_err) {
>  *dst_err = local_err;
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] Using virtio-net and vhost_net on an ARM machine using qemu-system-arm & KVM

2014-01-14 Thread Ying-Shiuan Pan

Best Regards,
潘穎軒Ying-Shiuan Pan


2014/1/14 Barak Wasserstrom 

> Ying-Shiuan Pan,
> Thanks again - please see few questions below.
>
> Regards,
> Barak
>
>
> On Tue, Jan 14, 2014 at 5:37 AM, Ying-Shiuan Pan  > wrote:
>
>> Hi, Barak,
>>
>> Hope the following info can help you
>>
>> 1.
>> HOST:
>>  
>> http://git.linaro.org/people/christoffer.dall/linux-kvm-arm.git
>> branch: v3.10-arndale
>> config: arch/arm/configs/exynos5_arndale_defconfig
>> dtb: arch/arm/boot/dts/exynos5250-arndale.dtb
>> rootfs: Ubuntu 13.10
>>
>> GUEST:
>> Official 3.12
>>  config: arch/arm/configs/vexpress_defconfig  with virtio-devices enabled
>> dtb: arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dtb
>> rootfs: Ubuntu 12.04
>>
>> 2.
>> We are still developing it in progress and will try to open source asap.
>> The main purpose of that patch is to introduce the ioeventfd into kvm-arm
>>
> [Barak] Do you have any estimation about when you can release these
> patches?
>
Actually, No. I will discuss with my boss about the release plan.

>  [Barak] Is this required for enabling vhost-net?
>
Yes, it is because vhost-net relies on ioeventfd to get kick request from
front-end driver.


>
>>
>> 3. as mentioned in 1.
>>
>> 4. qemu-1.6.0
>>
>> 5. We ported part of guest/host notifiers of virtio-pci to virtio-mmio
>>
> [Barak] Any patches available for this?
>
I did not see any.. but there might be somebody is also developing this..

> [Barak] Is this required for enabling vhost-net?
>
Yes. Without those notifiers, you will see the error messages as you
mentioned below.

>
>
>>
>> 6. /usr/bin/qemu-system-arm -enable-kvm -kernel /root/nfs/zImage -m 128
>> --machine vexpress-a15 -cpu cortex-a15 -drive
>> file=/root/nfs/guest-1G-precise-vm1.img,id=virtio-blk,if=none,cache=none
>> -device virtio-blk-device,drive=virtio-blk -append "earlyprintk=ttyAMA0
>> console=ttyAMA0 root=/dev/vda rw 
>> ip=192.168.101.101::192.168.101.1:vm1:eth0:off
>> --no-log" -dtb /root/nfs/vexpress-v2p-ca15-tc1.dtb --nographic -chardev
>> socket,id=mon,path=/root/vm1.monitor,server,nowait -mon
>> chardev=mon,id=monitor,mode=readline -device
>> virtio-net-device,netdev=net0,mac="52:54:00:12:34:01" -netdev
>> type=tap,id=net0,script=/root/nfs/net.sh,downscript=no,vhost=off
>>
> [Barak] Could you share "/root/nfs/net.sh" with me?
>
Sorry, I forgot that.
---
#!/bin/sh
ifconfig $1 0.0.0.0
brctl addif virbr0 $1
---

virbr0 is a bridge created by manual. The setup steps of virbr0 are also
provided:
brctl create virbr0
brctl addif virbr0 eth0
ifconfig virbr0 [ETH0_IP]
ifconfig eth0 0.0.0.0

[Barak] In the guest i can see that eth0 has all offload features disabled
> and cannot be enabled. I suspect this is related to the tap configuration
> in the host. Do you have any ideas?
>
>
>>
>> vhost-net could be truned on by changing the last parameter vhost=on.
>>
> [Barak] When enabling vhost i get errors in qemu, do you know what might
> be the reason?
> [Barak] qemu-system-arm: binding does not support guest notifiers
> [Barak] qemu-system-arm: unable to start vhost net: 38: falling back on
> userspace virtio
>
QEMU requires host/guest notifiers to setup vhost-net, but currently
virtio-mmio does not support yet.
That's why you got those error messages.

>
>
>>
>>
>> --
>> Ying-Shiuan Pan,
>> H Div., CCMA, ITRI, TW
>>
>>
>> 
>> Best Regards,
>> 潘穎軒Ying-Shiuan Pan
>>
>>
>> 2014/1/13 Barak Wasserstrom 
>>
>>> Ying-Shiuan Pan,
>>> Your experiments with arndale Exynos-5250 board can help me greatly and
>>> i would really appreciate if you share with me the following information:
>>> 1. Which Linux kernel did you use for the host and for the guest?
>>> 2. Which Linux kernel patches did you use for KVM?
>>> 3. Which config files did you use for both the host and guest?
>>> 4. Which QEMU did you use?
>>> 5. Which QEMU patches did you use?
>>> 6. What is the exact command line you used for invoking the guest, with
>>> and without vhost-net?
>>>
>>> Many thanks in advance!
>>>
>>> Regards,
>>> Barak
>>>
>>>
>>>
>>> On Mon, Jan 13, 2014 at 5:47 AM, Ying-Shiuan Pan <
>>> yingshiuan@gmail.com> wrote:
>>>
 Hi, Barak,

 We've tried vhost-net in kvm-arm on arndale Exynos-5250 board (it
 requires some patches in qemu and kvm, of course). It works (without irqfd
 support), however, the performance does not increase much. The throughput
 (iperf) of virtio-net and vhost-net are 93.5Mbps and 93.6Mbps respectively.
 I thought the result are because both virtio-net and vhost-net almost
 reached the limitation of 100Mbps Ethernet.

 The good news is that we even ported vhost-net in our kvm-a9 hypervisor
 (refer:
 http://academic.odysci.com/article/1010113020064758/evaluation-of-a-server-grade-software-only-arm-hypervisor),
 and the throughput of vhost-net on that platform (with 1Gbps Ethernet)
 increased from 323Mbps to 435Mbps.

 --
 Ying-Shiuan

Re: [Qemu-devel] Enabling vhost-net cause insane high memory usage.

2014-01-14 Thread Stefan Hajnoczi
On Fri, Jan 10, 2014 at 12:00:31AM +0100, Piotr Karbowski wrote:
> kernel 3.12.5, qemu-1.7.0.
> 
> With vhost=on, qemu shortly after start uses all its assigned memory
> (2G for example), without vhost-net enabled it does not go to more
> than 200 MB on my idling test virtual machine. 100% reproducable. I
> think its not how it should be.
> 
> Full command:
> /usr/bin/qemu-system-x86_64 -machine accel=kvm -name _debian -usb
> -machine accel=kvm -cpu host,level=9 -smp cpus=2 -vga std -monitor 
> unix://home/piotr/src/vmninja/sockets/_debian.monitor.socket,server,nowait
> -vnc unix://home/piotr/src/vmninja/sockets/_debian.vnc.socket -m
> 2048 -boot order=d,menu=on -drive
> if=ide,index=2,media=cdrom,id=virtcd -netdev
> tap,id=if0,helper=/usr/libexec/qemu-bridge-helper --br=lebridge0
> -device virtio-net-pci,netdev=if0,mac=de:ee:b3:9e:a3:d5,romfile=
> -drive
> file=/home/piotr/virt/kvm/_debian.raw,if=virtio,cache=writeback

How are you measuring memory usage?  Please post the output of the
command.

Did previous kernel/qemu versions work better?

Maybe Michael or Jason can give you hints on debugging this.

Stefan



[Qemu-devel] [PATCH build-fix v1 1/1] error: Don't use error_report() for assertion msgs.

2014-01-14 Thread Peter Crosthwaite
Use fprintf(stderr instead. This removes dependency of libqemuutil.a
on the monitor.

We can further justify this change, in that this code path should only
trigger under a fatal error condition. fprintf-stderr is probably the
appropriate medium as under a fatal error conidition the monitor itself
may be down and out for the count. So assertion failure messages should
go lowest common denominator - straight to stderr.

Fixes the build as reported by Kevin Wolf. Issue debugged and change
suggested by Luiz Capitulino. Issue introduced by
5d24ee70bcbcf578614193526bcd5ed30a8eb16c.

Signed-off-by: Peter Crosthwaite 
---

 util/error.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/util/error.c b/util/error.c
index f11f1d5..7c7650c 100644
--- a/util/error.c
+++ b/util/error.c
@@ -44,7 +44,7 @@ void error_set(Error **errp, ErrorClass err_class, const char 
*fmt, ...)
 err->err_class = err_class;
 
 if (errp == &error_abort) {
-error_report("%s", error_get_pretty(err));
+fprintf(stderr, "%s", error_get_pretty(err));
 abort();
 }
 
@@ -80,7 +80,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass 
err_class,
 err->err_class = err_class;
 
 if (errp == &error_abort) {
-error_report("%s", error_get_pretty(err));
+fprintf(stderr, "%s", error_get_pretty(err));
 abort();
 }
 
@@ -125,7 +125,7 @@ void error_set_win32(Error **errp, int win32_err, 
ErrorClass err_class,
 err->err_class = err_class;
 
 if (errp == &error_abort) {
-error_report("%s", error_get_pretty(err));
+fprintf(stderr, "%s", error_get_pretty(err));
 abort();
 }
 
@@ -171,7 +171,7 @@ void error_free(Error *err)
 void error_propagate(Error **dst_err, Error *local_err)
 {
 if (local_err && dst_err == &error_abort) {
-error_report("%s", error_get_pretty(local_err));
+fprintf(stderr, "%s", error_get_pretty(local_err));
 abort();
 } else if (dst_err && !*dst_err) {
 *dst_err = local_err;
-- 
1.8.5.3




Re: [Qemu-devel] [PATCH v2] trace: [simple] Do not include "trace/simple.h" in generated tracer headers

2014-01-14 Thread Stefan Hajnoczi
On Tue, Jan 14, 2014 at 04:52:55PM +0100, Lluís Vilanova wrote:
> The header is not necessary, given that the simple backend does not define any
> inlined tracing routines.
> 
> Signed-off-by: Lluís Vilanova 
> ---
>  scripts/tracetool/backend/simple.py |3 ---
>  trace/simple.c  |1 +
>  2 files changed, 1 insertion(+), 3 deletions(-)

Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/tracing

Stefan



Re: [Qemu-devel] [PATCH RFC 2/3] qapi script: add support of event

2014-01-14 Thread Wenchao Xia
于 2014/1/13 18:08, Markus Armbruster 写道:
> Ping^2!
> 
> Markus Armbruster  writes:
> 
>> Ping?
>>
>> Markus Armbruster  writes:
>>
>>> [Licensing problem, cc: Anthony]
>>>
>>> Kevin Wolf  writes:
>>>
 Am 13.12.2013 um 14:31 hat Eric Blake geschrieben:
> On 11/12/2013 06:44 PM, Wenchao Xia wrote:
>> +++ b/scripts/qapi-event.py
>> @@ -0,0 +1,355 @@
>> +#
>> +# QAPI event generator
>> +#
>> +# Copyright IBM, Corp. 2013
>> +#
>> +# Authors:
>> +#  Wenchao Xia 
>> +#
>> +# This work is licensed under the terms of the GNU GPLv2.
>
> Can you please use GPLv2+ (that is, add the "or later" clause)?  We
> already have GPLv2-only code, but I don't want to increase the size of
> that unfortunate license choice.

 In fact, it's even worse:

 +# This work is licensed under the terms of the GNU GPLv2.
 +# See the COPYING.LIB file in the top-level directory.

 These two lines contradict each other, COPYING.LIB contains the
 LGPL 2.1. The same bad license header is in the other QAPI generator
 scripts, so it's only copy&paste here.
>>>
>>> Specifically:
>>>
>>>  FileCommit
>>>  scripts/qapi-commands.pyc17d9908
>>>  scripts/qapi-visit.py   fb3182ce
>>>  scripts/qapi-types.py   06d64c62
>>>  scripts/qapi.py 0f923be2
>>>
>>> All four from Michael Roth via Luiz.
>>>
 This doesn't make things easier, because if things are copied, the
 license of the source must be respected. And it seems rather dubious to
 me what this license actually is. If it's GPLv2-only, we can't just
 change it in the new copy.
>>>
>>> IANAL, and I wouldn't dare to judge which of the two conflicting license
>>> claims takes precedence.  Possibly neither, and then the files might
>>> technically not be distributable.
>>>
>>> Anyway, this mess needs to be addressed.  Michael, what was your
>>> *intended* license?
>>>
>>> If it wasn't GPLv2+, then why?
>>>
>>> Do we need formal ACKs from all contributors to fix the licensing
>>> comment in these four files?
> 
  I used GPLv2+ in my new files of v2, but not sure about other files.
Michael, do you think other scripts should be changed either?




[Qemu-devel] [Bug 685096] Re: USB Passthrough not working for Windows 7 guest

2014-01-14 Thread Gonglei
I think you should appoint the usb bus which according to your usb type, such 
as:
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 
-device usb-ehci,id=usb1,bus=pci.0,addr=0x4 
-device usb-hub,id=hub0,bus=usb.0,port=2 
-device usb-tablet,id=input0,bus=usb.0,port=1 
-device usb-host,hostbus=2,hostport=2,id=hostdev0,bus=usb1.0

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

Title:
  USB Passthrough not working for Windows 7 guest

Status in QEMU:
  Confirmed
Status in “qemu-kvm” package in Ubuntu:
  Confirmed

Bug description:
  USB Passthrough from host to guest is not working for a 32-bit Windows
  7 guest, while it works perfectly for a 32-bit Windows XP guest.

  The device appears in the device manager of Windows 7, but with "Error
  code 10: device cannot start". I have tried this with numerous USB
  thumbdrives and a USB wireless NIC, all with the same result. The
  device name and functionality is recognized, so at least some USB
  negotiation is taking place.

  I am trying this with the latest git-pull of QEMU-KVM.

  The command line to launch qemu-kvm for win7 is:
  sudo /home/user/local_install/bin/qemu-system-x86_64 -cpu core2duo -m 1024 
-smp 2 -vga std -hda ./disk_images/win7.qcow -vnc :1 -boot c -usb -usbdevice 
tablet -usbdevice host:0781:5150

  The command line to launch qemu-kvm for winxp is:
  sudo /home/user/local_install/bin/qemu-system-x86_64 -cpu core2duo -m 1024 
-smp 2 -usb -vga std -hda ./winxpsp3.qcow -vnc :0 -boot c -usbdevice tablet 
-usbdevice host:0781:5150

  Any help is appreciated.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/685096/+subscriptions



Re: [Qemu-devel] [PULL 14/28] exec: make address spaces 64-bit wide

2014-01-14 Thread Alexey Kardashevskiy
On 01/15/2014 01:05 AM, Michael S. Tsirkin wrote:
> On Tue, Jan 14, 2014 at 08:50:54AM -0500, Mike Day wrote:
>>
>> "Michael S. Tsirkin"  writes:
>>
>>> On Fri, Jan 10, 2014 at 08:31:36AM -0700, Alex Williamson wrote:
>>
>>> Short term, just assume 48 bits on x86.
>>>
>>> We need to figure out what's the limitation on ppc and arm -
>>> maybe there's none and it can address full 64 bit range.
>>>
>>> Cc some people who might know about these platforms.
>>
>> The document you need is here: 
>>
>> http://goo.gl/fJYxdN
>>
>> "PCI Bus Binding To: IEEE Std 1275-1994"
>>
>> The short answer is that Power (OpenFirmware-to-PCI) supports both MMIO
>> and Memory mappings for BARs.
>>
>> Also, both 32-bit and 64-bit BARs are required to be supported. It is
>> legal to construct a 64-bit BAR by masking all the high bits to
>> zero. Presumably it would be OK to mask the 16 high bits to zero as
>> well, constructing a 48-bit address.
>>
>> Mike
>>
>> -- 
>> Mike Day | "Endurance is a Virtue"
> 
> The question was whether addresses such as 
> 0xfec0 can be a valid BAR value on these
> platforms, whether it's accessible to the CPU and
> to other PCI devices.


On ppc64, the guest address is limited by 60 bits (2Alex: even PA from HPT
has the same limit) but there is no actual limit for PCI bus addresses. The
actual hardware has some (less than 60 bits but close) limits but since we
do not emulate any real PHB in qemu-spapr and do para-virtualization, we do
not have to put limits there and BARs like 0xfec0 should be
allowed (but we do not really expect them to be as big though).


-- 
Alexey



Re: [Qemu-devel] Fix make check breakage (was [PULL 00/14] QMP queue)

2014-01-14 Thread Peter Crosthwaite
On Wed, Jan 15, 2014 at 8:26 AM, Peter Crosthwaite
 wrote:
> On Wed, Jan 15, 2014 at 4:22 AM, Luiz Capitulino  
> wrote:
>> On Tue, 14 Jan 2014 17:44:51 +0100
>> Kevin Wolf  wrote:
>>
>>> Am 14.01.2014 um 04:38 hat Edgar E. Iglesias geschrieben:
>>> > On Tue, Jan 14, 2014 at 09:27:10AM +1000, Peter Crosthwaite wrote:
>>> > > Ping,
>>> > >
>>> > > Has this one been forgotten or are there issues? PMM had a small
>>> > > comment, but he waived it AFAICT.
>>> >
>>> > Pong,
>>> >
>>> > I've merged it now, thanks!
>>>
>>> I believe it's something in this pull requests that breaks make check.
>>
>> And you're right. But first, let me confirm that we're talking about the
>> same breakage. This is what I'm getting:
>>
>> make tests/check-qom-interface
>> libqemuutil.a(qemu-error.o): In function `error_vprintf':
>> /home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:23: 
>> undefined reference to `cur_mon'
>> /home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:24: 
>> undefined reference to `cur_mon'
>> /home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:24: 
>> undefined reference to `monitor_vprintf'
>> libqemuutil.a(qemu-error.o): In function `error_printf_unless_qmp':
>> /home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:47: 
>> undefined reference to `monitor_cur_is_qmp'
>> libqemuutil.a(qemu-error.o): In function `error_print_loc':
>> /home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:174: 
>> undefined reference to `cur_mon'
>> collect2: error: ld returned 1 exit status
>> make: *** [tests/check-qom-interface] Error 1
>>
>> I tried bisecting it, but git bisect weren't capable of finding the
>> culprit. So debugged it, and the problem was introduced by:
>>
>>   commit 594278718323ca7bffaab0fb7fc6c82fa2c1cd5f
>>   Author: Peter Crosthwaite 
>>   Date:   Wed Jan 1 18:49:52 2014 -0800
>>
>>   qerror: Remove assert_no_error()
>>
>> There isn't nothing really wrong with this commit. The problem seems to
>> be that the tests link against libqemuutil.a and this library pulls in
>> everything from util/. The commit above changed util/error.c to call
>> error_report(), which depends on 'cur_mon', which is only made available
>> by monitor.o.
>>
>> I don't think we want to mess up with including monitor.o on libqemuutil.a.
>> Besides, I now find it a bit weird to call error_report() from an error
>> reporting function. So it's better to just call fprintf(stderr,) instead.
>>
>> Peter, Markus, are you ok with this patch?
>
> Patch is good.
>
> Acked-by: Peter Crosthwiate 
>

Do you want to spin this as a patch or should I?

>>
>> PS: I do run make check before sending a pull request, and did run this
>> time too. Not sure how I didn't catch this. Thanks for the report
>> Kevin!
>>
>
> I ran make check before sending out the patches too. Not sure what
> happened since.
>

I tested the tip of the merged branch and it is ok:

commit c950114286ea358a93ce632db0421945e1008395
Author: Luiz Capitulino 
Date:   Sun Dec 29 22:39:58 2013 -0500

migration: qmp_migrate(): keep working after syntax error

If a user or QMP client enter a bad syntax for the migrate
command in QMP/HMP, then the migrate command will never succeed
from that point on.

Something merged since has had an effect, so bisection is impossible
as we would need to reorder the history to figure out what it was and
I don't think it's worth it.

Regards,
Peter

> Regards,
> Peter
>
>> diff --git a/util/error.c b/util/error.c
>> index f11f1d5..7c7650c 100644
>> --- a/util/error.c
>> +++ b/util/error.c
>> @@ -44,7 +44,7 @@ void error_set(Error **errp, ErrorClass err_class, const 
>> char *fmt, ...)
>>  err->err_class = err_class;
>>
>>  if (errp == &error_abort) {
>> -error_report("%s", error_get_pretty(err));
>> +fprintf(stderr, "%s", error_get_pretty(err));
>>  abort();
>>  }
>>
>> @@ -80,7 +80,7 @@ void error_set_errno(Error **errp, int os_errno, 
>> ErrorClass err_class,
>>  err->err_class = err_class;
>>
>>  if (errp == &error_abort) {
>> -error_report("%s", error_get_pretty(err));
>> +fprintf(stderr, "%s", error_get_pretty(err));
>>  abort();
>>  }
>>
>> @@ -125,7 +125,7 @@ void error_set_win32(Error **errp, int win32_err, 
>> ErrorClass err_class,
>>  err->err_class = err_class;
>>
>>  if (errp == &error_abort) {
>> -error_report("%s", error_get_pretty(err));
>> +fprintf(stderr, "%s", error_get_pretty(err));
>>  abort();
>>  }
>>
>> @@ -171,7 +171,7 @@ void error_free(Error *err)
>>  void error_propagate(Error **dst_err, Error *local_err)
>>  {
>>  if (local_err && dst_err == &error_abort) {
>> -error_report("%s", error_get_pretty(local_err));
>> +fprintf(stderr, "%s", error_get_pretty(local_err));
>>  abort();
>>  } else if (dst_err && !*dst_err) {
>>  *dst_err = local_err;
>>



Re: [Qemu-devel] [PATCH] gdbstub: allow byte swapping for reading/writing registers

2014-01-14 Thread Peter Maydell
On 14 January 2014 23:01, Alexander Graf  wrote:
>> Is the underlying issue here that we might have a CPU which is
>> in littleendian mode but in a QEMU executable compiled with
>> TARGET_WORDS_BIGENDIAN ?  (If so I can't help feeling that
>> the gdb stub is only the tip of the iceberg for things that might need
>> attention...)
>
> Yes, which is going to be the same problem you have for AArch64 :).
> LE vs BE is really just a register flip. The qemu binary is the same
> for both when you run system emulation mode.

Right, then I think we really need to look at the issue in a more
holistic fashion. You're essentially trying to make
TARGET_WORDS_BIGENDIAN irrelevant, which is a goal I
thoroughly approve of, but it's pretty thoroughly baked into various
parts of the codebase and I don't think it's going to be easy to
eradicate.

thanks
-- PMM



Re: [Qemu-devel] [PATCH] gdbstub: allow byte swapping for reading/writing registers

2014-01-14 Thread Alexander Graf

On 14.01.2014, at 23:55, Peter Maydell  wrote:

> On 14 January 2014 22:40, Alexander Graf  wrote:
>> Uli, I thought ppc64le gdb wasn't finalized yet? What does the gdbstub
>> layout look like? Are all fields the same as ppc64(be) but simply byte
>> swapped - including FPR ones?
> 
>> This is quite invasive (and prone to get wrong). If we really just have
>> to swap every single register by its size (which we yet have to confirm
>> with Uli) why don't we just wrap this function by another one that takes
>> the return value of ppc_cpu_gdb_read_register (the integer size) and
>> swaps it in-place in mem_buf? At least we're 100% consistent that way.
> 
> Note that we already support "fields in the buffer are in target byte order"
> (ie matching TARGET_WORDS_BIGENDIAN) with gdb_get_reg*,
> "fields are always LE" (use st*_le_p()) and "fields are always BE"
> (use st*_be_p()).
> 
> Is the underlying issue here that we might have a CPU which is
> in littleendian mode but in a QEMU executable compiled with
> TARGET_WORDS_BIGENDIAN ?  (If so I can't help feeling that
> the gdb stub is only the tip of the iceberg for things that might need
> attention...)

Yes, which is going to be the same problem you have for AArch64 :). LE vs BE is 
really just a register flip. The qemu binary is the same for both when you run 
system emulation mode.


Alex




Re: [Qemu-devel] [PATCH] gdbstub: allow byte swapping for reading/writing registers

2014-01-14 Thread Peter Maydell
On 14 January 2014 22:40, Alexander Graf  wrote:
> Uli, I thought ppc64le gdb wasn't finalized yet? What does the gdbstub
> layout look like? Are all fields the same as ppc64(be) but simply byte
> swapped - including FPR ones?

> This is quite invasive (and prone to get wrong). If we really just have
> to swap every single register by its size (which we yet have to confirm
> with Uli) why don't we just wrap this function by another one that takes
> the return value of ppc_cpu_gdb_read_register (the integer size) and
> swaps it in-place in mem_buf? At least we're 100% consistent that way.

Note that we already support "fields in the buffer are in target byte order"
(ie matching TARGET_WORDS_BIGENDIAN) with gdb_get_reg*,
"fields are always LE" (use st*_le_p()) and "fields are always BE"
(use st*_be_p()).

Is the underlying issue here that we might have a CPU which is
in littleendian mode but in a QEMU executable compiled with
TARGET_WORDS_BIGENDIAN ?  (If so I can't help feeling that
the gdb stub is only the tip of the iceberg for things that might need
attention...)

thanks
-- PMM



Re: [Qemu-devel] [PATCH v2 1/1] genius: add genius serial mouse emulation

2014-01-14 Thread Peter Maydell
On 14 January 2014 22:05, Romain Naour  wrote:
> This patch adds the emulation for a serial Genius mouse using
> Mouse Systems protocol (5bytes).
> This protocol is compatible with most 3-button serial mouse.

"mice".

It might be helpful to note why we should care, ie if there are
any particularly interesting guests which can only deal with this
and not the MS mouse protocol, or if there are mouse features
you can only get support for with this protocol.

> Signed-off-by: Romain Naour 

> ---
> Changes v1 -> v2:
>  Fixes documentation (Paolo Bonzini)
>  Fixes typos
>
>  backends/Makefile.objs |   2 +-
>  backends/gnmouse.c | 339 
> +
>  include/sysemu/char.h  |   3 +
>  qapi-schema.json   |   1 +
>  qemu-char.c|   4 +
>  qemu-options.hx|  14 +-
>  6 files changed, 360 insertions(+), 3 deletions(-)
>  create mode 100644 backends/gnmouse.c
>
> diff --git a/backends/Makefile.objs b/backends/Makefile.objs
> index 42557d5..e4b072c 100644
> --- a/backends/Makefile.objs
> +++ b/backends/Makefile.objs
> @@ -1,7 +1,7 @@
>  common-obj-y += rng.o rng-egd.o
>  common-obj-$(CONFIG_POSIX) += rng-random.o
>
> -common-obj-y += msmouse.o
> +common-obj-y += msmouse.o gnmouse.o

I was going to suggest a separate CONFIG_GNMOUSE for this,
but we don't have a nice place to then enable it, so never mind.

>  common-obj-$(CONFIG_BRLAPI) += baum.o
>  $(obj)/baum.o: QEMU_CFLAGS += $(SDL_CFLAGS)
>
> diff --git a/backends/gnmouse.c b/backends/gnmouse.c
> new file mode 100644
> index 000..9581419
> --- /dev/null
> +++ b/backends/gnmouse.c
> @@ -0,0 +1,339 @@
> +/*
> + * QEMU Genius GM-6 serial mouse emulation
> + *
> + * Adapted from msmouse
> + *
> + * Copyright (c) 2014 Romain Naour
> + *
> + * 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.
> + */
> +#include 
> +#include 
> +#include 
> +
> +#include "qemu-common.h"
> +#include "sysemu/char.h"
> +#include "ui/console.h"
> +#include "qemu/timer.h"
> +
> +/* #define DEBUG_GENIUS_MOUSE */
> +
> +#ifdef DEBUG_GENIUS_MOUSE
> +#define DPRINTF(fmt, ...) \
> +do { fprintf(stderr, "gnmouse: " fmt , ## __VA_ARGS__); } while (0)
> +#else
> +#define DPRINTF(fmt, ...) \
> +do {} while (0)
> +#endif
> +
> +/*
> + * struct gnmouse_save:
> + * This structure is used to save private info for Genius mouse.
> + *
> + * dx: deltas on x-axis saved since last frame send to emulated system.
> + * dy: deltas on y-axis saved since last frame send to emulated system.
> + * transmit_timer: QEMU's timer
> + * transmit_time: reload value for transmit_timer
> + * data: frame to be sent
> + * index: used to save current state of the state machine. see type states 
> below
> + */
> +typedef struct gnmouse_save {

Coding style says struct names (and struct typedef names) should be
CamelCase.

> +int dx;
> +int dy;
> +int button;
> +struct QEMUTimer *transmit_timer; /* QEMU timer */
> +uint64_t transmit_time;   /* time to transmit a char in ticks */
> +unsigned char data[5];
> +int index;
> +} gnmouse_save;

How does all this state get migrated at VM migration? I know
how this works for device models, but does anybody know
the answer for char backends?

> +
> +
> +/* states */
> +typedef enum {
> +START,  /* 0 */
> +CHAR_1, /* 1 : BP */
> +CHAR_2, /* 2 : Dx */
> +CHAR_3, /* 3 : Dy */
> +CHAR_4, /* 4 : Dx */
> +CHAR_5, /* 5 : Dy */
> +STOP/* 6 */
> +}
> +states;

Stray newline after '}'.

> +
> +/**
> + * gnmouse_chr_write: this function is used when QEMU
> + * try to write something to mouse port.
> + * Nothing is send to the emulated mouse.

"sent"

> + *
> + * Return: lengh of the buffer

"length"

> + *
> + * @s: address of the CharDriverState used by the mouse
> + * @buf: buffer to write
> + * @len: lengh of the buffer to write

"length"

> + */
> +static int gnmouse_chr_write(struct CharDriverState *s, 

Re: [Qemu-devel] [PATCH] gdbstub: allow byte swapping for reading/writing registers

2014-01-14 Thread Alexander Graf

On 14.01.2014, at 23:06, Thomas Falcon  wrote:

> This patch allows registers to be properly read from and written to
> when using the gdbstub to debug a ppc guest running in little
> endian mode.  It accomplishes this goal by byte swapping the values of
> any registers only if the MSR:LE value is set and if the host machine
> is big endian.
> 
> Signed-off-by: Thomas Falcon

Uli, I thought ppc64le gdb wasn't finalized yet? What does the gdbstub layout 
look like? Are all fields the same as ppc64(be) but simply byte swapped - 
including FPR ones?


Alex

> ---
> target-ppc/gdbstub.c | 50 --
> 1 file changed, 32 insertions(+), 18 deletions(-)
> 
> diff --git a/target-ppc/gdbstub.c b/target-ppc/gdbstub.c
> index 1c91090..eba501a 100644
> --- a/target-ppc/gdbstub.c
> +++ b/target-ppc/gdbstub.c
> @@ -21,6 +21,19 @@
> #include "qemu-common.h"
> #include "exec/gdbstub.h"
> 
> +/* The following macros are used to ensure the correct
> + * transfer of registers between a little endian ppc target
> + * and a big endian host by checking the LE bit in the Machine State Register
> + */
> +
> +#define end_swap64(x) (msr_le && HOST_WORDS_BIGENDIAN) ? bswap64(x) : x
> +#define end_swap32(x) (msr_le && HOST_WORDS_BIGENDIAN) ? bswap32(x) : x
> +#if TARGET_LONG_BITS == 64
> +#define end_swapl(x) end_swap64(x)
> +#else
> +#define end_swapl(x) end_swap32(x)
> +#endif
> +
> /* Old gdb always expects FP registers.  Newer (xml-aware) gdb only
>  * expects whatever the target description contains.  Due to a
>  * historical mishap the FP registers appear in between core integer
> @@ -35,20 +48,20 @@ int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t 
> *mem_buf, int n)
> 
> if (n < 32) {
> /* gprs */
> -return gdb_get_regl(mem_buf, env->gpr[n]);
> +  return gdb_get_regl(mem_buf, end_swapl(env->gpr[n]));

This is quite invasive (and prone to get wrong). If we really just have to swap 
every single register by its size (which we yet have to confirm with Uli) why 
don't we just wrap this function by another one that takes the return value of 
ppc_cpu_gdb_read_register (the integer size) and swaps it in-place in mem_buf? 
At least we're 100% consistent that way.

Unless of course we only need to swap half of the registers, then it makes more 
sense the way you do it now.


Alex

> } else if (n < 64) {
> /* fprs */
> if (gdb_has_xml) {
> return 0;
> }
> -stfq_p(mem_buf, env->fpr[n-32]);
> +stfq_p(mem_buf, end_swapl(env->fpr[n-32]));
> return 8;
> } else {
> switch (n) {
> case 64:
> -return gdb_get_regl(mem_buf, env->nip);
> +return gdb_get_regl(mem_buf, end_swapl(env->nip));
> case 65:
> -return gdb_get_regl(mem_buf, env->msr);
> +return gdb_get_regl(mem_buf, end_swapl(env->msr));
> case 66:
> {
> uint32_t cr = 0;
> @@ -56,20 +69,20 @@ int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t 
> *mem_buf, int n)
> for (i = 0; i < 8; i++) {
> cr |= env->crf[i] << (32 - ((i + 1) * 4));
> }
> -return gdb_get_reg32(mem_buf, cr);
> +return gdb_get_reg32(mem_buf, end_swap32(cr));
> }
> case 67:
> -return gdb_get_regl(mem_buf, env->lr);
> +return gdb_get_regl(mem_buf, end_swapl(env->lr));
> case 68:
> -return gdb_get_regl(mem_buf, env->ctr);
> +return gdb_get_regl(mem_buf, end_swapl(env->ctr));
> case 69:
> -return gdb_get_regl(mem_buf, env->xer);
> +return gdb_get_regl(mem_buf, end_swapl(env->xer));
> case 70:
> {
> if (gdb_has_xml) {
> return 0;
> }
> -return gdb_get_reg32(mem_buf, env->fpscr);
> +return gdb_get_reg32(mem_buf, end_swap32(env->fpscr));
> }
> }
> }
> @@ -83,47 +96,48 @@ int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t 
> *mem_buf, int n)
> 
> if (n < 32) {
> /* gprs */
> -env->gpr[n] = ldtul_p(mem_buf);
> +env->gpr[n] = end_swapl(ldtul_p(mem_buf));
> return sizeof(target_ulong);
> } else if (n < 64) {
> /* fprs */
> if (gdb_has_xml) {
> return 0;
> }
> -env->fpr[n-32] = ldfq_p(mem_buf);
> +env->fpr[n-32] = end_swapl(ldfq_p(mem_buf));
> return 8;
> } else {
> switch (n) {
> case 64:
> -env->nip = ldtul_p(mem_buf);
> +env->nip = end_swapl(ldtul_p(mem_buf));
> return sizeof(target_ulong);
> case 65:
> -ppc_store_msr(env, ldtul_p(mem_buf));
> +ppc_store_msr(env, end_swapl(ldtul_p(mem_buf)));
> return sizeof(target_ulong);
> case 66:
> {
>   

[Qemu-devel] [PATCH] gdbstub: allow byte swapping for reading/writing registers

2014-01-14 Thread Thomas Falcon
This patch allows registers to be properly read from and written to
when using the gdbstub to debug a ppc guest running in little
endian mode.  It accomplishes this goal by byte swapping the values of
any registers only if the MSR:LE value is set and if the host machine
is big endian.

Signed-off-by: Thomas Falcon 
---
 target-ppc/gdbstub.c | 50 --
 1 file changed, 32 insertions(+), 18 deletions(-)

diff --git a/target-ppc/gdbstub.c b/target-ppc/gdbstub.c
index 1c91090..eba501a 100644
--- a/target-ppc/gdbstub.c
+++ b/target-ppc/gdbstub.c
@@ -21,6 +21,19 @@
 #include "qemu-common.h"
 #include "exec/gdbstub.h"
 
+/* The following macros are used to ensure the correct 
+ * transfer of registers between a little endian ppc target
+ * and a big endian host by checking the LE bit in the Machine State Register
+ */
+
+#define end_swap64(x) (msr_le && HOST_WORDS_BIGENDIAN) ? bswap64(x) : x
+#define end_swap32(x) (msr_le && HOST_WORDS_BIGENDIAN) ? bswap32(x) : x
+#if TARGET_LONG_BITS == 64
+#define end_swapl(x) end_swap64(x)
+#else
+#define end_swapl(x) end_swap32(x)
+#endif
+
 /* Old gdb always expects FP registers.  Newer (xml-aware) gdb only
  * expects whatever the target description contains.  Due to a
  * historical mishap the FP registers appear in between core integer
@@ -35,20 +48,20 @@ int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t 
*mem_buf, int n)
 
 if (n < 32) {
 /* gprs */
-return gdb_get_regl(mem_buf, env->gpr[n]);
+  return gdb_get_regl(mem_buf, end_swapl(env->gpr[n]));
 } else if (n < 64) {
 /* fprs */
 if (gdb_has_xml) {
 return 0;
 }
-stfq_p(mem_buf, env->fpr[n-32]);
+stfq_p(mem_buf, end_swapl(env->fpr[n-32]));
 return 8;
 } else {
 switch (n) {
 case 64:
-return gdb_get_regl(mem_buf, env->nip);
+return gdb_get_regl(mem_buf, end_swapl(env->nip));
 case 65:
-return gdb_get_regl(mem_buf, env->msr);
+return gdb_get_regl(mem_buf, end_swapl(env->msr));
 case 66:
 {
 uint32_t cr = 0;
@@ -56,20 +69,20 @@ int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t 
*mem_buf, int n)
 for (i = 0; i < 8; i++) {
 cr |= env->crf[i] << (32 - ((i + 1) * 4));
 }
-return gdb_get_reg32(mem_buf, cr);
+return gdb_get_reg32(mem_buf, end_swap32(cr));
 }
 case 67:
-return gdb_get_regl(mem_buf, env->lr);
+return gdb_get_regl(mem_buf, end_swapl(env->lr));
 case 68:
-return gdb_get_regl(mem_buf, env->ctr);
+return gdb_get_regl(mem_buf, end_swapl(env->ctr));
 case 69:
-return gdb_get_regl(mem_buf, env->xer);
+return gdb_get_regl(mem_buf, end_swapl(env->xer));
 case 70:
 {
 if (gdb_has_xml) {
 return 0;
 }
-return gdb_get_reg32(mem_buf, env->fpscr);
+return gdb_get_reg32(mem_buf, end_swap32(env->fpscr));
 }
 }
 }
@@ -83,47 +96,48 @@ int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t 
*mem_buf, int n)
 
 if (n < 32) {
 /* gprs */
-env->gpr[n] = ldtul_p(mem_buf);
+env->gpr[n] = end_swapl(ldtul_p(mem_buf));
 return sizeof(target_ulong);
 } else if (n < 64) {
 /* fprs */
 if (gdb_has_xml) {
 return 0;
 }
-env->fpr[n-32] = ldfq_p(mem_buf);
+env->fpr[n-32] = end_swapl(ldfq_p(mem_buf));
 return 8;
 } else {
 switch (n) {
 case 64:
-env->nip = ldtul_p(mem_buf);
+env->nip = end_swapl(ldtul_p(mem_buf));
 return sizeof(target_ulong);
 case 65:
-ppc_store_msr(env, ldtul_p(mem_buf));
+ppc_store_msr(env, end_swapl(ldtul_p(mem_buf)));
 return sizeof(target_ulong);
 case 66:
 {
 uint32_t cr = ldl_p(mem_buf);
 int i;
 for (i = 0; i < 8; i++) {
-env->crf[i] = (cr >> (32 - ((i + 1) * 4))) & 0xF;
+env->crf[i] = end_swap32((cr >> (32 - 
+ ((i + 1) * 4))) & 0xF);
 }
 return 4;
 }
 case 67:
-env->lr = ldtul_p(mem_buf);
+env->lr = end_swapl(ldtul_p(mem_buf));
 return sizeof(target_ulong);
 case 68:
-env->ctr = ldtul_p(mem_buf);
+env->ctr = end_swapl(ldtul_p(mem_buf));
 return sizeof(target_ulong);
 case 69:
-env->xer = ldtul_p(mem_buf);
+env->xer = end_swapl(ldtul_p(mem_buf));
 return sizeof(target_ulong);
 case 70:
 /* fpscr */
 if (gdb

Re: [Qemu-devel] Fix make check breakage (was [PULL 00/14] QMP queue)

2014-01-14 Thread Peter Crosthwaite
On Wed, Jan 15, 2014 at 4:22 AM, Luiz Capitulino  wrote:
> On Tue, 14 Jan 2014 17:44:51 +0100
> Kevin Wolf  wrote:
>
>> Am 14.01.2014 um 04:38 hat Edgar E. Iglesias geschrieben:
>> > On Tue, Jan 14, 2014 at 09:27:10AM +1000, Peter Crosthwaite wrote:
>> > > Ping,
>> > >
>> > > Has this one been forgotten or are there issues? PMM had a small
>> > > comment, but he waived it AFAICT.
>> >
>> > Pong,
>> >
>> > I've merged it now, thanks!
>>
>> I believe it's something in this pull requests that breaks make check.
>
> And you're right. But first, let me confirm that we're talking about the
> same breakage. This is what I'm getting:
>
> make tests/check-qom-interface
> libqemuutil.a(qemu-error.o): In function `error_vprintf':
> /home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:23: 
> undefined reference to `cur_mon'
> /home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:24: 
> undefined reference to `cur_mon'
> /home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:24: 
> undefined reference to `monitor_vprintf'
> libqemuutil.a(qemu-error.o): In function `error_printf_unless_qmp':
> /home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:47: 
> undefined reference to `monitor_cur_is_qmp'
> libqemuutil.a(qemu-error.o): In function `error_print_loc':
> /home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:174: 
> undefined reference to `cur_mon'
> collect2: error: ld returned 1 exit status
> make: *** [tests/check-qom-interface] Error 1
>
> I tried bisecting it, but git bisect weren't capable of finding the
> culprit. So debugged it, and the problem was introduced by:
>
>   commit 594278718323ca7bffaab0fb7fc6c82fa2c1cd5f
>   Author: Peter Crosthwaite 
>   Date:   Wed Jan 1 18:49:52 2014 -0800
>
>   qerror: Remove assert_no_error()
>
> There isn't nothing really wrong with this commit. The problem seems to
> be that the tests link against libqemuutil.a and this library pulls in
> everything from util/. The commit above changed util/error.c to call
> error_report(), which depends on 'cur_mon', which is only made available
> by monitor.o.
>
> I don't think we want to mess up with including monitor.o on libqemuutil.a.
> Besides, I now find it a bit weird to call error_report() from an error
> reporting function. So it's better to just call fprintf(stderr,) instead.
>
> Peter, Markus, are you ok with this patch?

Patch is good.

Acked-by: Peter Crosthwiate 

>
> PS: I do run make check before sending a pull request, and did run this
> time too. Not sure how I didn't catch this. Thanks for the report
> Kevin!
>

I ran make check before sending out the patches too. Not sure what
happened since.

Regards,
Peter

> diff --git a/util/error.c b/util/error.c
> index f11f1d5..7c7650c 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -44,7 +44,7 @@ void error_set(Error **errp, ErrorClass err_class, const 
> char *fmt, ...)
>  err->err_class = err_class;
>
>  if (errp == &error_abort) {
> -error_report("%s", error_get_pretty(err));
> +fprintf(stderr, "%s", error_get_pretty(err));
>  abort();
>  }
>
> @@ -80,7 +80,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass 
> err_class,
>  err->err_class = err_class;
>
>  if (errp == &error_abort) {
> -error_report("%s", error_get_pretty(err));
> +fprintf(stderr, "%s", error_get_pretty(err));
>  abort();
>  }
>
> @@ -125,7 +125,7 @@ void error_set_win32(Error **errp, int win32_err, 
> ErrorClass err_class,
>  err->err_class = err_class;
>
>  if (errp == &error_abort) {
> -error_report("%s", error_get_pretty(err));
> +fprintf(stderr, "%s", error_get_pretty(err));
>  abort();
>  }
>
> @@ -171,7 +171,7 @@ void error_free(Error *err)
>  void error_propagate(Error **dst_err, Error *local_err)
>  {
>  if (local_err && dst_err == &error_abort) {
> -error_report("%s", error_get_pretty(local_err));
> +fprintf(stderr, "%s", error_get_pretty(local_err));
>  abort();
>  } else if (dst_err && !*dst_err) {
>  *dst_err = local_err;
>



Re: [Qemu-devel] [PATCH] gdbstub: allow byte swapping for reading/writing registers

2014-01-14 Thread Peter Maydell
On 14 January 2014 22:06, Thomas Falcon  wrote:
> This patch allows registers to be properly read from and written to
> when using the gdbstub to debug a ppc guest running in little
> endian mode.  It accomplishes this goal by byte swapping the values of
> any registers only if the MSR:LE value is set and if the host machine
> is big endian.

Since this patch only affects ppc targets it would be helpful if the
subject line had an appropriate prefix indicating that.

>
> Signed-off-by: Thomas Falcon
> ---
>  target-ppc/gdbstub.c | 50
> --
>  1 file changed, 32 insertions(+), 18 deletions(-)
>
> diff --git a/target-ppc/gdbstub.c b/target-ppc/gdbstub.c
> index 1c91090..eba501a 100644
> --- a/target-ppc/gdbstub.c
> +++ b/target-ppc/gdbstub.c
> @@ -21,6 +21,19 @@
>  #include "qemu-common.h"
>  #include "exec/gdbstub.h"
>
> +/* The following macros are used to ensure the correct
> + * transfer of registers between a little endian ppc target
> + * and a big endian host by checking the LE bit in the Machine State
> Register
> + */
> +
> +#define end_swap64(x) (msr_le && HOST_WORDS_BIGENDIAN) ? bswap64(x) : x
> +#define end_swap32(x) (msr_le && HOST_WORDS_BIGENDIAN) ? bswap32(x) : x

Surely we need to swap if the host is little endian and the target
is bigendian, as well as if the host is bigendian and the target
little endian?

Also, it seems a bit dubious to switch the endianness of words
based on a runtime flag in the guest CPU -- I'm pretty sure a
connected gdb won't be able to cope with that. On the other
hand, gdb's pretty bad at dealing with the kind of thing real
CPUs can do with switching endianness or word size at run
time, so maybe this is just better than the alternatives...

thanks
-- PMM



[Qemu-devel] [PATCH v2 1/1] genius: add genius serial mouse emulation

2014-01-14 Thread Romain Naour
This patch adds the emulation for a serial Genius mouse using
Mouse Systems protocol (5bytes).
This protocol is compatible with most 3-button serial mouse.

Signed-off-by: Romain Naour 
---
Changes v1 -> v2:
 Fixes documentation (Paolo Bonzini)
 Fixes typos

 backends/Makefile.objs |   2 +-
 backends/gnmouse.c | 339 +
 include/sysemu/char.h  |   3 +
 qapi-schema.json   |   1 +
 qemu-char.c|   4 +
 qemu-options.hx|  14 +-
 6 files changed, 360 insertions(+), 3 deletions(-)
 create mode 100644 backends/gnmouse.c

diff --git a/backends/Makefile.objs b/backends/Makefile.objs
index 42557d5..e4b072c 100644
--- a/backends/Makefile.objs
+++ b/backends/Makefile.objs
@@ -1,7 +1,7 @@
 common-obj-y += rng.o rng-egd.o
 common-obj-$(CONFIG_POSIX) += rng-random.o
 
-common-obj-y += msmouse.o
+common-obj-y += msmouse.o gnmouse.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 $(obj)/baum.o: QEMU_CFLAGS += $(SDL_CFLAGS) 
 
diff --git a/backends/gnmouse.c b/backends/gnmouse.c
new file mode 100644
index 000..9581419
--- /dev/null
+++ b/backends/gnmouse.c
@@ -0,0 +1,339 @@
+/*
+ * QEMU Genius GM-6 serial mouse emulation
+ *
+ * Adapted from msmouse
+ *
+ * Copyright (c) 2014 Romain Naour
+ *
+ * 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.
+ */
+#include 
+#include 
+#include 
+
+#include "qemu-common.h"
+#include "sysemu/char.h"
+#include "ui/console.h"
+#include "qemu/timer.h"
+
+/* #define DEBUG_GENIUS_MOUSE */
+
+#ifdef DEBUG_GENIUS_MOUSE
+#define DPRINTF(fmt, ...) \
+do { fprintf(stderr, "gnmouse: " fmt , ## __VA_ARGS__); } while (0)
+#else
+#define DPRINTF(fmt, ...) \
+do {} while (0)
+#endif
+
+/*
+ * struct gnmouse_save:
+ * This structure is used to save private info for Genius mouse.
+ *
+ * dx: deltas on x-axis saved since last frame send to emulated system.
+ * dy: deltas on y-axis saved since last frame send to emulated system.
+ * transmit_timer: QEMU's timer
+ * transmit_time: reload value for transmit_timer
+ * data: frame to be sent
+ * index: used to save current state of the state machine. see type states 
below
+ */
+typedef struct gnmouse_save {
+int dx;
+int dy;
+int button;
+struct QEMUTimer *transmit_timer; /* QEMU timer */
+uint64_t transmit_time;   /* time to transmit a char in ticks */
+unsigned char data[5];
+int index;
+} gnmouse_save;
+
+
+/* states */
+typedef enum {
+START,  /* 0 */
+CHAR_1, /* 1 : BP */
+CHAR_2, /* 2 : Dx */
+CHAR_3, /* 3 : Dy */
+CHAR_4, /* 4 : Dx */
+CHAR_5, /* 5 : Dy */
+STOP/* 6 */
+}
+states;
+
+/**
+ * gnmouse_chr_write: this function is used when QEMU
+ * try to write something to mouse port.
+ * Nothing is send to the emulated mouse.
+ *
+ * Return: lengh of the buffer
+ *
+ * @s: address of the CharDriverState used by the mouse
+ * @buf: buffer to write
+ * @len: lengh of the buffer to write
+ */
+static int gnmouse_chr_write(struct CharDriverState *s, const uint8_t *buf,
+ int len)
+{
+/* Ignore writes to mouse port */
+return len;
+}
+
+/**
+ * gnmouse_chr_close: this function close the mouse port.
+ * It stop and free the QEMU's timer and free gnmouse_save struct.
+ *
+ * Return: void
+ *
+ * @chr: address of the CharDriverState used by the mouse
+ */
+static void gnmouse_chr_close(struct CharDriverState *chr)
+{
+/* stop and free the QEMU's timer */
+timer_del(((gnmouse_save *)chr->opaque)->transmit_timer);
+timer_free(((gnmouse_save *)chr->opaque)->transmit_timer);
+/* free gnmouse_save struct */
+g_free(chr->opaque);
+g_free(chr);
+}
+
+/**
+ * gnmouse_handler: send a byte on serial port to the guest system
+ * This handler is called on each timer timeout or directly by gnmouse_event()
+ * when no transmission is underway.
+ * It use a state machine in order to know which byte of the frame must be 
send.
+ *
+ * Returns void
+ *
+ * @opaque: ad

Re: [Qemu-devel] [PATCH 1/1] genius: add genius serial mouse emulation

2014-01-14 Thread Romain Naour

Hi,

The standard is more like

# A union referencing different chardev backend configuration' info.
#
# @gnmouse: Send mouse data using the Genius protocol (since 2.0).
#
# Since: 1.4
##

but that format would require doucmenting all items. :(

You can leave this out of v2.

However, I'd be happy if you changed the documentation like this

@item -chardev msmouse,id=@var{id}
Forward events from QEMU's emulated mouse to the guest using the
Microsoft protocol. @option{msmouse} does not take any options.

@item -chardev gnmouse ,id=@var{id}

Forward events from QEMU's emulated mouse to the guest using the Genius
(Mouse Systems) protocol. @option{gnmouse} does not take any options.

Certainly, I changed the documentation accordingly.
The v2 in on the way.

Best regards,
Romain Naour



[Qemu-devel] [PATCH] gdbstub: allow byte swapping for reading/writing registers

2014-01-14 Thread Thomas Falcon

This patch allows registers to be properly read from and written to
when using the gdbstub to debug a ppc guest running in little
endian mode.  It accomplishes this goal by byte swapping the values of
any registers only if the MSR:LE value is set and if the host machine
is big endian.

Signed-off-by: Thomas Falcon
---
 target-ppc/gdbstub.c | 50 --
 1 file changed, 32 insertions(+), 18 deletions(-)

diff --git a/target-ppc/gdbstub.c b/target-ppc/gdbstub.c
index 1c91090..eba501a 100644
--- a/target-ppc/gdbstub.c
+++ b/target-ppc/gdbstub.c
@@ -21,6 +21,19 @@
 #include "qemu-common.h"
 #include "exec/gdbstub.h"

+/* The following macros are used to ensure the correct
+ * transfer of registers between a little endian ppc target
+ * and a big endian host by checking the LE bit in the Machine State Register
+ */
+
+#define end_swap64(x) (msr_le && HOST_WORDS_BIGENDIAN) ? bswap64(x) : x
+#define end_swap32(x) (msr_le && HOST_WORDS_BIGENDIAN) ? bswap32(x) : x
+#if TARGET_LONG_BITS == 64
+#define end_swapl(x) end_swap64(x)
+#else
+#define end_swapl(x) end_swap32(x)
+#endif
+
 /* Old gdb always expects FP registers.  Newer (xml-aware) gdb only
  * expects whatever the target description contains.  Due to a
  * historical mishap the FP registers appear in between core integer
@@ -35,20 +48,20 @@ int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t 
*mem_buf, int n)

 if (n < 32) {
 /* gprs */
-return gdb_get_regl(mem_buf, env->gpr[n]);
+  return gdb_get_regl(mem_buf, end_swapl(env->gpr[n]));
 } else if (n < 64) {
 /* fprs */
 if (gdb_has_xml) {
 return 0;
 }
-stfq_p(mem_buf, env->fpr[n-32]);
+stfq_p(mem_buf, end_swapl(env->fpr[n-32]));
 return 8;
 } else {
 switch (n) {
 case 64:
-return gdb_get_regl(mem_buf, env->nip);
+return gdb_get_regl(mem_buf, end_swapl(env->nip));
 case 65:
-return gdb_get_regl(mem_buf, env->msr);
+return gdb_get_regl(mem_buf, end_swapl(env->msr));
 case 66:
 {
 uint32_t cr = 0;
@@ -56,20 +69,20 @@ int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t 
*mem_buf, int n)
 for (i = 0; i < 8; i++) {
 cr |= env->crf[i] << (32 - ((i + 1) * 4));
 }
-return gdb_get_reg32(mem_buf, cr);
+return gdb_get_reg32(mem_buf, end_swap32(cr));
 }
 case 67:
-return gdb_get_regl(mem_buf, env->lr);
+return gdb_get_regl(mem_buf, end_swapl(env->lr));
 case 68:
-return gdb_get_regl(mem_buf, env->ctr);
+return gdb_get_regl(mem_buf, end_swapl(env->ctr));
 case 69:
-return gdb_get_regl(mem_buf, env->xer);
+return gdb_get_regl(mem_buf, end_swapl(env->xer));
 case 70:
 {
 if (gdb_has_xml) {
 return 0;
 }
-return gdb_get_reg32(mem_buf, env->fpscr);
+return gdb_get_reg32(mem_buf, end_swap32(env->fpscr));
 }
 }
 }
@@ -83,47 +96,48 @@ int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t 
*mem_buf, int n)

 if (n < 32) {
 /* gprs */
-env->gpr[n] = ldtul_p(mem_buf);
+env->gpr[n] = end_swapl(ldtul_p(mem_buf));
 return sizeof(target_ulong);
 } else if (n < 64) {
 /* fprs */
 if (gdb_has_xml) {
 return 0;
 }
-env->fpr[n-32] = ldfq_p(mem_buf);
+env->fpr[n-32] = end_swapl(ldfq_p(mem_buf));
 return 8;
 } else {
 switch (n) {
 case 64:
-env->nip = ldtul_p(mem_buf);
+env->nip = end_swapl(ldtul_p(mem_buf));
 return sizeof(target_ulong);
 case 65:
-ppc_store_msr(env, ldtul_p(mem_buf));
+ppc_store_msr(env, end_swapl(ldtul_p(mem_buf)));
 return sizeof(target_ulong);
 case 66:
 {
 uint32_t cr = ldl_p(mem_buf);
 int i;
 for (i = 0; i < 8; i++) {
-env->crf[i] = (cr >> (32 - ((i + 1) * 4))) & 0xF;
+env->crf[i] = end_swap32((cr >> (32 -
+ ((i + 1) * 4))) & 0xF);
 }
 return 4;
 }
 case 67:
-env->lr = ldtul_p(mem_buf);
+env->lr = end_swapl(ldtul_p(mem_buf));
 return sizeof(target_ulong);
 case 68:
-env->ctr = ldtul_p(mem_buf);
+env->ctr = end_swapl(ldtul_p(mem_buf));
 return sizeof(target_ulong);
 case 69:
-env->xer = ldtul_p(mem_buf);
+env->xer = end_swapl(ldtul_p(mem_buf));
 return sizeof(target_ulong);
 case 70:
 /* fpscr */
 if (gdb_has_

[Qemu-devel] QEMU next release schedule?

2014-01-14 Thread Peter Maydell
Hi; I notice we still don't seem to have anything up on
the wiki at http://wiki.qemu.org/Planning/1.8 (or even at
/2.0). Any suggestions about what the schedule for the
next release, freeze dates, etc should be?

thanks
-- PMM



Re: [Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together

2014-01-14 Thread Eric Blake
On 01/14/2014 12:12 PM, Jeff Cody wrote:
> Having both read-only=on and snapshot=on together does not make sense;
> currently, the read-only argument is effectively ignored for the
> temporary snapshot.  To prevent confusion, disallow the usage of both
> 'snapshot=on' and 'read-only=on'.
> 
> Signed-off-by: Jeff Cody 
> ---
>  blockdev.c | 7 +++
>  1 file changed, 7 insertions(+)

Reviewed-by: Eric Blake 

No impact to libvirt, which (intentionally) doesn't use snapshot=on.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] virtio-balloon: don't hardcode config size value

2014-01-14 Thread Michael S. Tsirkin
On Tue, Jan 14, 2014 at 09:05:31PM +0400, Michael Tokarev wrote:
> 09.01.2014 18:58, Luiz Capitulino wrote:
> > Use sizeof(strucy virtio_balloon_config) instead.
> > 
> > --- a/hw/virtio/virtio-balloon.c
> > +++ b/hw/virtio/virtio-balloon.c
> > @@ -263,7 +263,7 @@ static void virtio_balloon_get_config(VirtIODevice 
> > *vdev, uint8_t *config_data)
> >  config.num_pages = cpu_to_le32(dev->num_pages);
> >  config.actual = cpu_to_le32(dev->actual);
> >  
> > -memcpy(config_data, &config, 8);
> > +memcpy(config_data, &config, sizeof(struct virtio_balloon_config));
> 
> I'm not sure any of those is better than another.
> 
> This is a published guest <=> host interface, the config _must_ be 8 bytes
> long and must contain 2 4-byte words in it.

no, config can be extended in the future.
and hard coded constants are evil.

> 
> We may use assert(sizeof(struct virtio_balloon_config) == 8) somewhere,
> but to my taste it is a bit overkill.  No?

I agree assert like this would be overkill.

> Thanks,
> 
> /mjt
-- 
MST



[Qemu-devel] [PATCH v2 2/3] scsi/virtio-scsi: Cleanup of I/Os that never started

2014-01-14 Thread Eric Farman
There is still a small window that occurs when a cancel I/O affects
an asynchronous I/O operation that hasn't started.  In other words,
when the residual data length equals the expected data length.

Today, the routine virtio_scsi_command_complete fails because the
VirtIOSCSIReq pointer (from the hba_private field in SCSIRequest)
was cleared earlier when virtio_scsi_complete_req was called by
the virtio_scsi_request_cancelled routine.  As a result, the
virtio_scsi_command_complete routine needs to simply return when
it is processing a SCSIRequest block that was marked canceled.

Reviewed-by: Paolo Bonzini 
Signed-off-by: Eric Farman 
---
 hw/scsi/virtio-scsi.c |4 
 1 file changed, 4 insertions(+)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 6dcdd1b..1da98cd 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -306,6 +306,10 @@ static void virtio_scsi_command_complete(SCSIRequest *r, 
uint32_t status,
 VirtIOSCSIReq *req = r->hba_private;
 uint32_t sense_len;
 
+if (r->io_canceled) {
+return;
+}
+
 req->resp.cmd->response = VIRTIO_SCSI_S_OK;
 req->resp.cmd->status = status;
 if (req->resp.cmd->status == GOOD) {
-- 
1.7.9.5




[Qemu-devel] [PATCH v2 3/3] scsi/virtio-scsi: Prevent assertion on missed events

2014-01-14 Thread Eric Farman
In some cases, an unplug can cause events to be dropped, which
leads to an assertion failure when preparing to notify the guest
kernel.

Signed-off-by: Eric Farman 
---
 hw/scsi/virtio-scsi.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 1da98cd..6610b3a 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -520,7 +520,7 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, 
SCSIDevice *dev,
 evt->event = event;
 evt->reason = reason;
 if (!dev) {
-assert(event == VIRTIO_SCSI_T_NO_EVENT);
+assert(event == VIRTIO_SCSI_T_EVENTS_MISSED);
 } else {
 evt->lun[0] = 1;
 evt->lun[1] = dev->id;
-- 
1.7.9.5




[Qemu-devel] [PATCH v2 1/3] scsi: Assign cancel_io vector for scsi disk

2014-01-14 Thread Eric Farman
Provide the cancel_io vector for disk devices, to ensure that
all asynchronous I/Os are properly cleaned up of their references.

Signed-off-by: Paolo Bonzini 
Signed-off-by: Eric Farman 
---
 hw/scsi/scsi-disk.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index bce617c..ee1f5eb 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2306,6 +2306,7 @@ static const SCSIReqOps scsi_disk_emulate_reqops = {
 .send_command = scsi_disk_emulate_command,
 .read_data= scsi_disk_emulate_read_data,
 .write_data   = scsi_disk_emulate_write_data,
+.cancel_io= scsi_cancel_io,
 .get_buf  = scsi_get_buf,
 };
 
-- 
1.7.9.5




[Qemu-devel] [PATCH v2 0/3] virtio-scsi unplug of active device

2014-01-14 Thread Eric Farman
In working with hot-plug/unplug of virtio-scsi devices on s390,
we have occasionally noticed some erratic behavior when an unplug
occurs while I/O is in flight.  Ideally a device is not being used
when it is removed from a guest configuration, but no guarantee
can be made that this will be the case.  And while this scenario
is meant for I/O that occurs during normal use of a device, it
includes the pathological case of an unplug that occurs while the
asynchronous Inquiry loop (initiated by a hotplug) is still ongoing.

Symptoms vary depending on when the unplug is recognized.  Sometimes
a hang occurs, because a reference is not properly released and thus
never reaches zero.  Sometimes a reference is released too early,
allowing the count to go negative and trip an assertion (or more
unpredictable results, if storage is released but still used).

Of course there are many times when things work perfectly, though
that seems to be when the I/O was able to complete in time.  These
patches simply straighten out the completion of I/Os during an
unplug, such that it results in predictable behavior whenever the
device is not idle.

Eric Farman (3):
  scsi: Assign cancel_io vector for scsi disk
  scsi/virtio-scsi: Cleanup of I/Os that never started
  scsi/virtio-scsi: Prevent assertion on missed events

 hw/scsi/scsi-disk.c   |1 +
 hw/scsi/virtio-scsi.c |6 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

-- 
1.7.9.5




[Qemu-devel] [PATCH] block: do not allow read-only=on and snapshot=on to be used together

2014-01-14 Thread Jeff Cody
Having both read-only=on and snapshot=on together does not make sense;
currently, the read-only argument is effectively ignored for the
temporary snapshot.  To prevent confusion, disallow the usage of both
'snapshot=on' and 'read-only=on'.

Signed-off-by: Jeff Cody 
---
 blockdev.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/blockdev.c b/blockdev.c
index e457494..845ff8a 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -352,6 +352,13 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
 /* extract parameters */
 snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
 ro = qemu_opt_get_bool(opts, "read-only", 0);
+
+/* having ro and snapshot together does not make sense */
+if (ro && snapshot) {
+error_setg(errp, "invalid option combination: read-only and snapshot");
+goto early_err;
+}
+
 copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false);
 
 file = qemu_opt_get(opts, "file");
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH v3] Fix QEMU build on OpenBSD on x86 archs

2014-01-14 Thread Brad Smith

On 12/20/13 06:19, Brad Smith wrote:

On 14/12/13 11:27 PM, Brad Smith wrote:

On 10/12/13 7:49 PM, Brad Smith wrote:

This resolves the build issue with building the ROMs on OpenBSD on x86
archs.
As of OpenBSD 5.3 the compiler builds PIE binaries by default and thus
the
whole OS/packages and so forth. The ROMs need to have PIE disabled. 
This

is my initial attempt at trying to get somehting upstream so that QEMU
both builds out of the box and to resolve the build issue with the
buildbots that has been around for awhile. We have a patch in our ports
tree but it is just the flags hardcoded into the Makefile which 
obviously

is not appropriate for upstream.

 From the OpenBSD buildbots..
   Building optionrom/multiboot.img
ld: multiboot.o: relocation R_X86_64_16 can not be used when making a
shared object; recompile with -fPIC

Signed-off by: Brad Smith 


ping.


ping ping.


ping ping ping.

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




Re: [Qemu-devel] [PATCH] virtio-balloon: don't hardcode config size value

2014-01-14 Thread Luiz Capitulino
On Tue, 14 Jan 2014 21:05:31 +0400
Michael Tokarev  wrote:

> 09.01.2014 18:58, Luiz Capitulino wrote:
> > Use sizeof(strucy virtio_balloon_config) instead.
> > 
> > --- a/hw/virtio/virtio-balloon.c
> > +++ b/hw/virtio/virtio-balloon.c
> > @@ -263,7 +263,7 @@ static void virtio_balloon_get_config(VirtIODevice 
> > *vdev, uint8_t *config_data)
> >  config.num_pages = cpu_to_le32(dev->num_pages);
> >  config.actual = cpu_to_le32(dev->actual);
> >  
> > -memcpy(config_data, &config, 8);
> > +memcpy(config_data, &config, sizeof(struct virtio_balloon_config));
> 
> I'm not sure any of those is better than another.

No duplication, no risk of changing virtio_balloon_config and
forgetting about changing all the memcpys out there (which is
exactly what happened to me). This is also what the other
devices do.

> This is a published guest <=> host interface, the config _must_ be 8 bytes
> long and must contain 2 4-byte words in it.

That's not changed by this patch.

> We may use assert(sizeof(struct virtio_balloon_config) == 8) somewhere,
> but to my taste it is a bit overkill.  No?
> 
> Thanks,
> 
> /mjt
> 




Re: [Qemu-devel] [PATCH 1/1] KVM: Retry KVM_CREATE_VM on EINTR or EAGAIN

2014-01-14 Thread Andrea Arcangeli
On Mon, Jan 13, 2014 at 12:16:11PM +0100, Paolo Bonzini wrote:
> Il 10/01/2014 23:15, Tom Knych ha scritto:
> > I'll flip the conditional check
> > 
> > So I traced thru the code and the one path I saw returning EINTR was:
> > 
> > kvm_dev_ioctl_create_vm -> kvm_create_vm -> kvm_init_mmu_notifier ->
> > mmu_notifier_register ->  do_mmu_notifier_register -> mm_take_all_locks
> > 
> > Which checks if any signals have been raised while it was attaining
> > locks and returns EINTR.
> > 
> > Going thru my logs - all of my errors actually are EINTRs I'll remove
> > the EAGAIN
> 
> Andrea, what do you think here?  Is it intended that
> kvm_init_mmu_notifier return an EINTR that percolates up to userspace?

It is intended yes. The reason being that mm_take_all_locks is
potentially a CPU intensive operation so if we don't return -EINTR and
break it immediately if a signal is pending, we'd be potentially
hanging the process for too long, if you press C^c or the task wouldn't
go away immediately, or if you kill -9 same problem.

All CPU intensive syscalls in the kernel should check for pending
signals and return -EINTR immediately to allow userland to remain
interactive.

EAGAIN shouldn't originate anywhere in those paths so yes they're all
EINTR for interactivity.

Why don't you mask the signals instead of looping? That would be more
efficient, what's the point of interrupting the syscall and restarting
it when you can just avoid being interrupted during it? If the signal
is blocked signal_pending won't be raised and EINTR won't be
generated. I think you only need a sigprocmask or equivalent around
the call.

It's important to check the retval and fail the startup of qemu if you
still get a error, but you shouldn't loop if you just mask the signal
instead of looping.



Re: [Qemu-devel] [PATCH] ifname=xxx for -netdev bridge

2014-01-14 Thread William Dauchy
Hi Alexandre,

On Mon, Mar 25, 2013 at 10:28 PM, Alexandre Kandalintsev
 wrote:
> Ok, lets go this way. We will define patterns in bridge.conf like
> ~~~
> allowifname vm*
> ~~~

Do you have any news about this patch?

Regards,
-- 
William



Re: [Qemu-devel] [PATCH] tap: add the possibility to specify a tap prefix

2014-01-14 Thread William Dauchy
On Jan14 19:24, Paolo Bonzini wrote:
> See http://lists.gnu.org/archive/html/qemu-devel/2013-03/msg04279.html
> and http://lists.gnu.org/archive/html/qemu-devel/2012-10/msg02149.html
> for previous discussions on this topic.

Thanks for pointing me this out, it's now clear.
-- 
William


signature.asc
Description: Digital signature


Re: [Qemu-devel] [PATCH] tap: add the possibility to specify a tap prefix

2014-01-14 Thread Paolo Bonzini
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Il 14/01/2014 18:40, William Dauchy ha scritto:
>>> I think this was nacked already in the past.  You would need to
>>> implement some kind of ACL system like the one that is in place
>>> for bridges.  Without it, for example, you could hijack 
>>> existing iptables rules.
> I don't get it; this does not change anything to the existing but 
> permits to change the default "tap" string prefix.
> 
> Am I missing something?

See http://lists.gnu.org/archive/html/qemu-devel/2013-03/msg04279.html
and http://lists.gnu.org/archive/html/qemu-devel/2012-10/msg02149.html
for previous discussions on this topic.

Paolo
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJS1YDdAAoJEBvWZb6bTYbyS64P/jJZT2FmUEqh1HiRLl5JA41C
zUZSjs6yIPI2PBZTwAQFR8WbFoQd8WHusqZF2DyMsCCcQ/5SN+H70ZdVavkA30T+
SoiJ2KdBdZdSWocMr2VqU7nVVsUEVkYuVVmjAESB0z2uG+Z/BrJM0Y5LxPbqjAJT
3munoW3w0pU2v4v3zzm48W4GlOUQTsp1vqdIsXhKbMO40G+BuM95LiNyn6g+B+i+
G9rbLN3IVjnsGasIcUNGhMVoTaP4p+NufX7NVX1D0H46wVXgmtGjDRfva3EW2qvv
P0WvTG4b1nRC20zXcmznfOrVd4d9XgtABByvkvzeY6Bawzp5ZW7nV31AVX7H7G+7
vG8AdttsgH3/mYN0VwzVAhwlmhxMbB3Ip3AnfCEGSTSPUV1rMsdA3xIiWZb5Kjqc
xCZloSbLI0E1kFrVepoGBq0g81jVHaPM+BHpSUQSTCbuXqCHrgdm+z3kHkqZbpE8
HmAXkIn4ot4+Q3nZ8a0jEXC2ipJsNl9v8zkvPbTai/5/C2j+1aU7oBLXES63K19w
DoUaFdSgHbEXMx/CTcryWjxdBCrOGiilpanObTIT9cfVbm0LfNLS8sZap3ATE5/6
o7OHQlZ1u0s91yikMiex+UkBjXt2mFJmJ/T/LbOI7rxFV+cnQoA1s7ErbvSa9jaC
RIhf6mVXZGAzCLNVdJNz
=PvwW
-END PGP SIGNATURE-



[Qemu-devel] [PATCH 9/9] hw/pci: switch to a generic hotplug handling for PCIDevice

2014-01-14 Thread Igor Mammedov
make qdev_unplug()/device_set_realized() to call hotplug handler's
plug/unplug methods if available and remove not needed anymore
hot(un)plug handling from PCIDevice.

In case if hotplug handler is not available, revert to the legacy
hotplug method.

Signed-off-by: Igor Mammedov 
---
v2:
 * fix test-qdev-global-props build failure during "make check"
---
 hw/core/qdev.c   |   17 +
 hw/pci/pci.c |   29 +
 include/hw/pci/pci.h |   10 --
 include/hw/pci/pci_bus.h |2 --
 tests/Makefile   |2 +-
 5 files changed, 15 insertions(+), 45 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index d8b83f1..3486e5d 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -213,7 +213,6 @@ void qdev_unplug(DeviceState *dev, Error **errp)
 error_set(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
 return;
 }
-assert(dc->unplug != NULL);
 
 if (!dc->hotpluggable) {
 error_set(errp, QERR_DEVICE_NO_HOTPLUG,
@@ -223,9 +222,13 @@ void qdev_unplug(DeviceState *dev, Error **errp)
 
 qdev_hot_removed = true;
 
-if (dc->unplug(dev) < 0) {
-error_set(errp, QERR_UNDEFINED_ERROR);
-return;
+if (dev->parent_bus && dev->parent_bus->hotplug_handler) {
+hotplug_handler_unplug(dev->parent_bus->hotplug_handler, dev, errp);
+} else {
+assert(dc->unplug != NULL);
+if (dc->unplug(dev) < 0) { /* legacy handler */
+error_set(errp, QERR_UNDEFINED_ERROR);
+}
 }
 }
 
@@ -720,6 +723,12 @@ static void device_set_realized(Object *obj, bool value, 
Error **err)
 dc->realize(dev, &local_err);
 }
 
+if (dev->parent_bus && dev->parent_bus->hotplug_handler &&
+local_err == NULL) {
+hotplug_handler_plug(dev->parent_bus->hotplug_handler,
+ dev, &local_err);
+}
+
 if (qdev_get_vmsd(dev) && local_err == NULL) {
 vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
dev->instance_id_alias,
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index b8770ef..7e36f29 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -35,6 +35,7 @@
 #include "hw/pci/msi.h"
 #include "hw/pci/msix.h"
 #include "exec/address-spaces.h"
+#include "hw/hotplug.h"
 
 //#define DEBUG_PCI
 #ifdef DEBUG_PCI
@@ -346,13 +347,6 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, 
pci_map_irq_fn map_irq,
 bus->irq_count = g_malloc0(nirq * sizeof(bus->irq_count[0]));
 }
 
-void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug, DeviceState *qdev)
-{
-bus->qbus.allow_hotplug = 1;
-bus->hotplug = hotplug;
-bus->hotplug_qdev = qdev;
-}
-
 PCIBus *pci_register_bus(DeviceState *parent, const char *name,
  pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
  void *irq_opaque,
@@ -1750,29 +1744,9 @@ static int pci_qdev_init(DeviceState *qdev)
 }
 pci_add_option_rom(pci_dev, is_default_rom);
 
-if (bus->hotplug) {
-/* Let buses differentiate between hotplug and when device is
- * enabled during qemu machine creation. */
-rc = bus->hotplug(bus->hotplug_qdev, pci_dev,
-  qdev->hotplugged ? PCI_HOTPLUG_ENABLED:
-  PCI_COLDPLUG_ENABLED);
-if (rc != 0) {
-int r = pci_unregister_device(&pci_dev->qdev);
-assert(!r);
-return rc;
-}
-}
 return 0;
 }
 
-static int pci_unplug_device(DeviceState *qdev)
-{
-PCIDevice *dev = PCI_DEVICE(qdev);
-
-return dev->bus->hotplug(dev->bus->hotplug_qdev, dev,
- PCI_HOTPLUG_DISABLED);
-}
-
 PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction,
 const char *name)
 {
@@ -2243,7 +2217,6 @@ static void pci_device_class_init(ObjectClass *klass, 
void *data)
 {
 DeviceClass *k = DEVICE_CLASS(klass);
 k->init = pci_qdev_init;
-k->unplug = pci_unplug_device;
 k->exit = pci_unregister_device;
 k->bus_type = TYPE_PCI_BUS;
 k->props = pci_props;
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 03d4bee..c709d62 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -327,15 +327,6 @@ typedef void (*pci_set_irq_fn)(void *opaque, int irq_num, 
int level);
 typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);
 typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin);
 
-typedef enum {
-PCI_HOTPLUG_DISABLED,
-PCI_HOTPLUG_ENABLED,
-PCI_COLDPLUG_ENABLED,
-} PCIHotplugState;
-
-typedef int (*pci_hotplug_fn)(DeviceState *qdev, PCIDevice *pci_dev,
-  PCIHotplugState state);
-
 #define TYPE_PCI_BUS "PCI"
 #define PCI_BUS(obj) OBJECT_CHECK(PCIBus, (obj), TYPE_PCI_BUS)
 #define TYPE_PCIE_BUS "PCIE"
@@ -354,7 +345,6 @@ PCIBus *pci_bus_new(

[Qemu-devel] Fix make check breakage (was [PULL 00/14] QMP queue)

2014-01-14 Thread Luiz Capitulino
On Tue, 14 Jan 2014 17:44:51 +0100
Kevin Wolf  wrote:

> Am 14.01.2014 um 04:38 hat Edgar E. Iglesias geschrieben:
> > On Tue, Jan 14, 2014 at 09:27:10AM +1000, Peter Crosthwaite wrote:
> > > Ping,
> > > 
> > > Has this one been forgotten or are there issues? PMM had a small
> > > comment, but he waived it AFAICT.
> > 
> > Pong,
> > 
> > I've merged it now, thanks!
> 
> I believe it's something in this pull requests that breaks make check.

And you're right. But first, let me confirm that we're talking about the
same breakage. This is what I'm getting:

make tests/check-qom-interface
libqemuutil.a(qemu-error.o): In function `error_vprintf':
/home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:23: 
undefined reference to `cur_mon'
/home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:24: 
undefined reference to `cur_mon'
/home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:24: 
undefined reference to `monitor_vprintf'
libqemuutil.a(qemu-error.o): In function `error_printf_unless_qmp':
/home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:47: 
undefined reference to `monitor_cur_is_qmp'
libqemuutil.a(qemu-error.o): In function `error_print_loc':
/home/lcapitulino/work/src/upstream/qmp-unstable/util/qemu-error.c:174: 
undefined reference to `cur_mon'
collect2: error: ld returned 1 exit status
make: *** [tests/check-qom-interface] Error 1

I tried bisecting it, but git bisect weren't capable of finding the
culprit. So debugged it, and the problem was introduced by:

  commit 594278718323ca7bffaab0fb7fc6c82fa2c1cd5f
  Author: Peter Crosthwaite 
  Date:   Wed Jan 1 18:49:52 2014 -0800
  
  qerror: Remove assert_no_error()

There isn't nothing really wrong with this commit. The problem seems to
be that the tests link against libqemuutil.a and this library pulls in
everything from util/. The commit above changed util/error.c to call
error_report(), which depends on 'cur_mon', which is only made available
by monitor.o.

I don't think we want to mess up with including monitor.o on libqemuutil.a.
Besides, I now find it a bit weird to call error_report() from an error
reporting function. So it's better to just call fprintf(stderr,) instead.

Peter, Markus, are you ok with this patch?

PS: I do run make check before sending a pull request, and did run this
time too. Not sure how I didn't catch this. Thanks for the report
Kevin!

diff --git a/util/error.c b/util/error.c
index f11f1d5..7c7650c 100644
--- a/util/error.c
+++ b/util/error.c
@@ -44,7 +44,7 @@ void error_set(Error **errp, ErrorClass err_class, const char 
*fmt, ...)
 err->err_class = err_class;
 
 if (errp == &error_abort) {
-error_report("%s", error_get_pretty(err));
+fprintf(stderr, "%s", error_get_pretty(err));
 abort();
 }
 
@@ -80,7 +80,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass 
err_class,
 err->err_class = err_class;
 
 if (errp == &error_abort) {
-error_report("%s", error_get_pretty(err));
+fprintf(stderr, "%s", error_get_pretty(err));
 abort();
 }
 
@@ -125,7 +125,7 @@ void error_set_win32(Error **errp, int win32_err, 
ErrorClass err_class,
 err->err_class = err_class;
 
 if (errp == &error_abort) {
-error_report("%s", error_get_pretty(err));
+fprintf(stderr, "%s", error_get_pretty(err));
 abort();
 }
 
@@ -171,7 +171,7 @@ void error_free(Error *err)
 void error_propagate(Error **dst_err, Error *local_err)
 {
 if (local_err && dst_err == &error_abort) {
-error_report("%s", error_get_pretty(local_err));
+fprintf(stderr, "%s", error_get_pretty(local_err));
 abort();
 } else if (dst_err && !*dst_err) {
 *dst_err = local_err;



Re: [Qemu-devel] [PULL 14/28] exec: make address spaces 64-bit wide

2014-01-14 Thread Mike Day
>>
>> The address above has already been masked. What you need to do is read
>> the BAR. If the value from the BAR end in '1', its MMIO. If it ends in
>> '10', its RAM. If it ends in '0n' its disabled. The first thing that
>> the PCI software does after reading the BAR is mask off the two low
>> bits.
>
> Are you perhaps confusing MMIO and I/O port?  I/O port cannot be mmap'd
> on x86, so it can't be directly mapped.  It also doesn't come through
> the address_space_memory filter.  I/O port is deprecated, or at least
> discouraged, MMIO is not.  Thanks,

You're right, sorry I missed that. It doesn't solve the problem.

Mike



Re: [Qemu-devel] [Qemu-trivial] [PATCH] exec: Exclude non portable function for MinGW

2014-01-14 Thread Juan Quintela
Stefan Weil  wrote:
> Am 14.01.2014 18:26, schrieb Michael Tokarev:
>> 14.01.2014 10:00, Stefan Weil wrote:
>>> cpu_physical_memory_set_dirty_lebitmap calls getpageaddr and ffsl which are
>>> unavailable for MinGW. As the function is unused for MinGW, it can simply
>>> be excluded from compilation.
>> I applied it to -trivial.  But maybe it's better to just move whole
>> thing to kvm-all.c where
>> it is actually used?
>>
>> Thanks,
>>
>> /mjt
>
> That's a good suggestion.

Let it as your change.  Functions on ram_addr.h should be opaque, and
nothing else should access the bitmap.


>
> Juan, a comment in include/exec/ram_addr.h says that those functions
> will be removed soon. Would you suggest moving them to kvm-all.c now, or
> would you prefer the conditional compilation for MinGW which I
> introduced with my patch?

The "soon" was introduced when Memory API was included, and we are still
waiting on TCG.

Later, Juan.



Re: [Qemu-devel] [PATCH v6 5/8] Add domain socket communication for vhost-user backend

2014-01-14 Thread Antonios Motakis
On Tue, Jan 14, 2014 at 12:10 PM, Michael S. Tsirkin  wrote:

> On Mon, Jan 13, 2014 at 03:25:16PM +0100, Antonios Motakis wrote:
> > Add structures for passing vhost-user messages over a unix domain socket.
> > This is the equivalent of the existing vhost-kernel ioctls.
> >
> > Connect to the named unix domain socket. The system call sendmsg
> > is used for communication. To be able to pass file descriptors
> > between processes - we use SCM_RIGHTS type in the message control header.
> >
> > Signed-off-by: Antonios Motakis 
> > Signed-off-by: Nikolay Nikolaev 
>
> Not all comments in v5 review of this file have been
> addressed.
> I think if a comment was wrong it's a good idea to
> add clarification in code on why it is, so future readers
> aren't confused.
>
> In particular I think always explicitly opening
> domain sockets and forcing a specific client/server
> model is a problem.
>
>
I think we need to clarify how the model would work when using QEMU as the
server. As a client it is clear, because it parallels what vhost does when
used with the kernel, however as a server it is not completely clear what
the use case is and how it would work.


> I think we also want the protocol documented in docs/
> so future users don't have to read the code to connect
> to qemu.
>
> Can you add a unit test for this code?
>
> We ship pxe ROM that enables virtio net,
> so you can write a small stub that works as the
> remote side of this protocol, poke at
> guest memory to see that it has
> the expected content (compare to what we get with
> readl).
>
> In theory you could also get and put some buffers
> though that's not a must.
>
>
> > ---
> >  hw/virtio/vhost-backend.c | 306
> +-
> >  1 file changed, 301 insertions(+), 5 deletions(-)
> >
> > diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
> > index 1d83e1d..460ee02 100644
> > --- a/hw/virtio/vhost-backend.c
> > +++ b/hw/virtio/vhost-backend.c
> > @@ -11,34 +11,330 @@
> >  #include "hw/virtio/vhost.h"
> >  #include "hw/virtio/vhost-backend.h"
> >  #include "qemu/error-report.h"
> > +#include "qemu/sockets.h"
> >
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define VHOST_MEMORY_MAX_NREGIONS8
> > +#define VHOST_USER_SOCKTO(300) /* msec */
> > +
> > +typedef enum VhostUserRequest {
> > +VHOST_USER_NONE = 0,
> > +VHOST_USER_GET_FEATURES = 1,
> > +VHOST_USER_SET_FEATURES = 2,
> > +VHOST_USER_SET_OWNER = 3,
> > +VHOST_USER_RESET_OWNER = 4,
> > +VHOST_USER_SET_MEM_TABLE = 5,
> > +VHOST_USER_SET_LOG_BASE = 6,
> > +VHOST_USER_SET_LOG_FD = 7,
> > +VHOST_USER_SET_VRING_NUM = 8,
> > +VHOST_USER_SET_VRING_ADDR = 9,
> > +VHOST_USER_SET_VRING_BASE = 10,
> > +VHOST_USER_GET_VRING_BASE = 11,
> > +VHOST_USER_SET_VRING_KICK = 12,
> > +VHOST_USER_SET_VRING_CALL = 13,
> > +VHOST_USER_SET_VRING_ERR = 14,
> > +VHOST_USER_NET_SET_BACKEND = 15,
> > +VHOST_USER_ECHO = 16,
> > +VHOST_USER_MAX
> > +} VhostUserRequest;
> > +
> > +typedef struct VhostUserMemoryRegion {
> > +uint64_t guest_phys_addr;
> > +uint64_t memory_size;
> > +uint64_t userspace_addr;
> > +} VhostUserMemoryRegion;
> > +
> > +typedef struct VhostUserMemory {
> > +uint32_t nregions;
> > +uint32_t padding;
> > +VhostUserMemoryRegion regions[VHOST_MEMORY_MAX_NREGIONS];
> > +} VhostUserMemory;
> > +
> > +typedef struct VhostUserMsg {
> > +VhostUserRequest request;
> > +
> > +#define VHOST_USER_VERSION_MASK (0x3)
> > +#define VHOST_USER_REPLY_MASK   (0x1<<2)
> > +uint32_t flags;
> > +uint32_t size; /* the following payload size */
> > +union {
> > +uint64_t u64;
> > +struct vhost_vring_state state;
> > +struct vhost_vring_addr addr;
> > +VhostUserMemory memory;
> > +};
> > +} QEMU_PACKED VhostUserMsg;
> > +
> > +static VhostUserMsg m __attribute__ ((unused));
> > +#define VHOST_USER_HDR_SIZE (sizeof(m.request) \
> > ++ sizeof(m.flags) \
> > ++ sizeof(m.size))
> > +
> > +#define VHOST_USER_PAYLOAD_SIZE (sizeof(m) - VHOST_USER_HDR_SIZE)
> > +
> > +/* The version of the protocol we support */
> > +#define VHOST_USER_VERSION(0x1)
> > +
> > +static int vhost_user_recv(int fd, VhostUserMsg *msg)
> > +{
> > +ssize_t r;
> > +uint8_t *p = (uint8_t *) msg;
> > +
> > +/* read the header */
> > +do {
> > +r = read(fd, p, VHOST_USER_HDR_SIZE);
> > +} while (r < 0 && errno == EINTR);
> > +
> > +if (r < 0) {
> > +error_report("Failed to read msg header, reason: %s\n",
> > + strerror(errno));
> > +goto fail;
> > +}
> > +
> > +if (r != VHOST_USER_HDR_SIZE) {
> > +error_report("Failed to read msg header. Read %zu instead of
> %zu.\n",
> > + r, VHOST_USER_HDR_SIZE);
> > +goto fail;
> > +}
>

Re: [Qemu-devel] [PATCH v6 6/8] Add vhost-user calls implementation

2014-01-14 Thread Antonios Motakis
On Tue, Jan 14, 2014 at 12:21 PM, Michael S. Tsirkin  wrote:

> On Mon, Jan 13, 2014 at 03:25:17PM +0100, Antonios Motakis wrote:
> > Each ioctl request of vhost-kernel has a vhost-user message equivalent,
> > which is sent over the control socket.
> >
> > The general approach is to copy the data from the supplied argument
> > pointer to a designated field in the message. If a file descriptor is
> > to be passed it will be placed in the fds array for inclusion in
> > the sendmsd control header.
> >
> > VHOST_SET_MEM_TABLE ignores the supplied vhost_memory structure and scans
> > the global ram_list for ram blocks with a valid fd field set. This would
> > be set when the -mem-path option with shared=on property is used.
> >
> > Signed-off-by: Antonios Motakis 
> > Signed-off-by: Nikolay Nikolaev 
>
> the name vhost-backend and vhost-user is unfortunate as you let some
> net specific stuff get in there.
>

The vhost-net stuff here is not strictly necessary, so it can be removed.
We don't need to set a TAP backend when using vhost-user.


>
> > ---
> >  hw/virtio/vhost-backend.c | 147
> --
> >  1 file changed, 143 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
> > index 460ee02..8f98562 100644
> > --- a/hw/virtio/vhost-backend.c
> > +++ b/hw/virtio/vhost-backend.c
> > @@ -81,6 +81,39 @@ static VhostUserMsg m __attribute__ ((unused));
> >  /* The version of the protocol we support */
> >  #define VHOST_USER_VERSION(0x1)
> >
> > +static unsigned long int ioctl_to_vhost_user_request[VHOST_USER_MAX] = {
> > +-1, /* VHOST_USER_NONE */
> > +VHOST_GET_FEATURES, /* VHOST_USER_GET_FEATURES */
> > +VHOST_SET_FEATURES, /* VHOST_USER_SET_FEATURES */
> > +VHOST_SET_OWNER, /* VHOST_USER_SET_OWNER */
> > +VHOST_RESET_OWNER, /* VHOST_USER_RESET_OWNER */
> > +VHOST_SET_MEM_TABLE, /* VHOST_USER_SET_MEM_TABLE */
> > +VHOST_SET_LOG_BASE, /* VHOST_USER_SET_LOG_BASE */
> > +VHOST_SET_LOG_FD, /* VHOST_USER_SET_LOG_FD */
> > +VHOST_SET_VRING_NUM, /* VHOST_USER_SET_VRING_NUM */
> > +VHOST_SET_VRING_ADDR, /* VHOST_USER_SET_VRING_ADDR */
> > +VHOST_SET_VRING_BASE, /* VHOST_USER_SET_VRING_BASE */
> > +VHOST_GET_VRING_BASE, /* VHOST_USER_GET_VRING_BASE */
> > +VHOST_SET_VRING_KICK, /* VHOST_USER_SET_VRING_KICK */
> > +VHOST_SET_VRING_CALL, /* VHOST_USER_SET_VRING_CALL */
> > +VHOST_SET_VRING_ERR, /* VHOST_USER_SET_VRING_ERR */
> > +VHOST_NET_SET_BACKEND, /* VHOST_USER_NET_SET_BACKEND */
> > +-1 /* VHOST_USER_ECHO */
> > +};
> > +
> > +static VhostUserRequest vhost_user_request_translate(unsigned long int
> request)
> > +{
> > +VhostUserRequest idx;
> > +
> > +for (idx = 0; idx < VHOST_USER_MAX; idx++) {
> > +if (ioctl_to_vhost_user_request[idx] == request) {
> > +break;
> > +}
> > +}
> > +
> > +return (idx == VHOST_USER_MAX) ? VHOST_USER_NONE : idx;
> > +}
> > +
> >  static int vhost_user_recv(int fd, VhostUserMsg *msg)
> >  {
> >  ssize_t r;
> > @@ -235,7 +268,10 @@ static int vhost_user_call(struct vhost_dev *dev,
> unsigned long int request,
> >  {
> >  int fd = dev->control;
> >  VhostUserMsg msg;
> > -int result = 0;
> > +VhostUserRequest msg_request;
> > +RAMBlock *block = 0;
> > +struct vhost_vring_file *file = 0;
> > +int need_reply = 0;
> >  int fds[VHOST_MEMORY_MAX_NREGIONS];
> >  size_t fd_num = 0;
> >
> > @@ -245,20 +281,123 @@ static int vhost_user_call(struct vhost_dev *dev,
> unsigned long int request,
> >  return 0;
> >  }
> >
> > -msg.request = VHOST_USER_NONE;
> > +msg_request = vhost_user_request_translate(request);
> > +msg.request = msg_request;
> >  msg.flags = VHOST_USER_VERSION;
> >  msg.size = 0;
> >
> >  switch (request) {
> > +case VHOST_GET_FEATURES:
> > +case VHOST_GET_VRING_BASE:
> > +need_reply = 1;
> > +break;
> > +
> > +case VHOST_SET_FEATURES:
> > +case VHOST_SET_LOG_BASE:
> > +msg.u64 = *((__u64 *) arg);
> > +msg.size = sizeof(m.u64);
> > +break;
> > +
> > +case VHOST_SET_OWNER:
> > +case VHOST_RESET_OWNER:
> > +break;
> > +
> > +case VHOST_SET_MEM_TABLE:
> > +QTAILQ_FOREACH(block, &ram_list.blocks, next)
> > +{
> > +if (block->fd > 0) {
> > +msg.memory.regions[fd_num].userspace_addr = (__u64)
> block->host;
> > +msg.memory.regions[fd_num].memory_size = block->length;
> > +msg.memory.regions[fd_num].guest_phys_addr =
> block->offset;
> > +fds[fd_num++] = block->fd;
> > +}
> > +}
> > +
> > +msg.memory.nregions = fd_num;
> > +
> > +if (!fd_num) {
> > +error_report("Failed initializing vhost-user memory map\n"
> > +"consider using -mem-path option\n");
> > +return -1;
> > + 

Re: [Qemu-devel] [PATCH v6 2/8] New -mem-path option - unlink.

2014-01-14 Thread Antonios Motakis
On Tue, Jan 14, 2014 at 12:16 PM, Michael S. Tsirkin  wrote:

> On Mon, Jan 13, 2014 at 03:25:13PM +0100, Antonios Motakis wrote:
> > The unlink option allows the created file to be externally deleted
> > after QEMU is terminated.
> >
> >  - unlink=on|off - default on, unlink the file after opening it
> >
> > Signed-off-by: Antonios Motakis 
> > Signed-off-by: Nikolay Nikolaev 
>
>
> I have doubts about this patch.
>
> In particular we seem to commit to a specific
> file naming scheme without ever documenting
> its users or adding any tests.
>
> Please document who uses this in the commit log,
> document the scheme in docs/ and add a test so we
> don't break this without noticing.
>

We added this feature based on the comments we received on this mailing
list from reviewers. We do not need it from our point of view, so for us it
is straightforward to remove it.


>
>
> > ---
> >  exec.c  | 18 +-
> >  qemu-options.hx |  7 ---
> >  vl.c|  4 
> >  3 files changed, 21 insertions(+), 8 deletions(-)
> >
> > diff --git a/exec.c b/exec.c
> > index 1c40a0d..30f4019 100644
> > --- a/exec.c
> > +++ b/exec.c
> > @@ -999,7 +999,7 @@ static void *file_ram_alloc(RAMBlock *block,
> >  int flags;
> >  unsigned long hpagesize;
> >  QemuOpts *opts;
> > -unsigned int mem_prealloc = 0, mem_share = 0;
> > +unsigned int mem_prealloc = 0, mem_share = 0, mem_unlink = 1;
> >
> >  hpagesize = gethugepagesize(path);
> >  if (!hpagesize) {
> > @@ -1020,6 +1020,7 @@ static void *file_ram_alloc(RAMBlock *block,
> >  if (opts) {
> >  mem_prealloc = qemu_opt_get_bool(opts, "prealloc", 0);
> >  mem_share = qemu_opt_get_bool(opts, "share", 0);
> > +mem_unlink = qemu_opt_get_bool(opts, "unlink", 1);
> >  }
> >
> >  /* Make name safe to use with mkstemp by replacing '/' with '_'. */
> > @@ -1029,18 +1030,25 @@ static void *file_ram_alloc(RAMBlock *block,
> >  *c = '_';
> >  }
> >
> > -filename = g_strdup_printf("%s/qemu_back_mem.%s.XX", path,
> > -   sanitized_name);
> > +filename = g_strdup_printf("%s/qemu_back_mem.%s%s", path,
> sanitized_name,
> > +   (mem_unlink) ? ".XX" : "");
> >  g_free(sanitized_name);
> >
> > -fd = mkstemp(filename);
> > +if (mem_unlink) {
> > +fd = mkstemp(filename);
> > +} else {
> > +fd = open(filename, O_CREAT | O_RDWR | O_EXCL,
> > +S_IRWXU | S_IRWXG | S_IRWXO);
> > +}
> >  if (fd < 0) {
> >  perror("unable to create guest RAM backing store");
> >  g_free(filename);
> >  return NULL;
> >  }
> >
> > -unlink(filename);
> > +if (mem_unlink) {
> > +unlink(filename);
> > +}
> >  g_free(filename);
> >
> >  memory = (memory + hpagesize - 1) & ~(hpagesize - 1);
> > diff --git a/qemu-options.hx b/qemu-options.hx
> > index 60ecc95..a12af97 100644
> > --- a/qemu-options.hx
> > +++ b/qemu-options.hx
> > @@ -221,14 +221,15 @@ gigabytes respectively.
> >  ETEXI
> >
> >  DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
> > -"-mem-path [path=]path[,prealloc=on|off][,share=on|off]\n"
> > +"-mem-path
> [path=]path[,prealloc=on|off][,share=on|off][,unlink=on|off]\n"
> >  "provide backing storage for guest RAM\n"
> >  "path= a directory path for the backing store\n"
> >  "prealloc= preallocate guest memory [default
> disabled]\n"
> > -"share= enable mmap share flag [default
> disabled]\n",
> > +"share= enable mmap share flag [default disabled]\n"
> > +"unlink= enable unlinking the guest RAM files
> [default enabled]\n",
> >  QEMU_ARCH_ALL)
> >  STEXI
> > -@item -mem-path [path=]@var{path}[,prealloc=on|off][,share=on|off]
> > +@item -mem-path
> [path=]@var{path}[,prealloc=on|off][,share=on|off][,unlink=on|off]
> >  @findex -mem-path
> >  Allocate guest RAM from a temporarily created file in @var{path}.
> >  ETEXI
> > diff --git a/vl.c b/vl.c
> > index e98abc8..5034bb6 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -546,6 +546,10 @@ static QemuOptsList qemu_mem_path_opts = {
> >  .name = "share",
> >  .type = QEMU_OPT_BOOL,
> >  },
> > +{
> > +.name = "unlink",
> > +.type = QEMU_OPT_BOOL,
> > +},
> >  { /* end of list */ }
> >  },
> >  };
> > --
> > 1.8.3.2
> >
>


Re: [Qemu-devel] [PATCH v6 0/8] Vhost and vhost-net support for userspace based backends

2014-01-14 Thread Antonios Motakis
On Tue, Jan 14, 2014 at 12:33 PM, Michael S. Tsirkin  wrote:

> On Mon, Jan 13, 2014 at 03:25:11PM +0100, Antonios Motakis wrote:
> > In this patch series we would like to introduce our approach for putting
> a
> > virtio-net backend in an external userspace process. Our eventual target
> is to
> > run the network backend in the Snabbswitch ethernet switch, while
> receiving
> > traffic from a guest inside QEMU/KVM which runs an unmodified virtio-net
> > implementation.
> >
> > For this, we are working into extending vhost to allow equivalent
> functionality
> > for userspace. Vhost already passes control of the data plane of
> virtio-net to
> > the host kernel; we want to realize a similar model, but for userspace.
> >
> > In this patch series the concept of a vhost-backend is introduced.
> >
> > We define two vhost backend types - vhost-kernel and vhost-user. The
> former is
> > the interface to the current kernel module implementation. Its control
> plane is
> > ioctl based. The data plane is the kernel directly accessing the QEMU
> allocated,
> > guest memory.
> >
> > In the new vhost-user backend, the control plane is based on
> communication
> > between QEMU and another userspace process using a unix domain socket.
> This
> > allows to implement a virtio backend for a guest running in QEMU, inside
> the
> > other userspace process.
> >
> > We change -mem-path to QemuOpts and add prealloc, share and unlink as
> properties
> > to it. HugeTLBFS requirements of -mem-path are relaxed, so any valid
> path can
> > be used now. The new properties allow more fine grained control over the
> guest
> > RAM backing store.
> >
> > The data path is realized by directly accessing the vrings and the
> buffer data
> > off the guest's memory.
> >
> > The current user of vhost-user is only vhost-net. We add new netdev
> backend
> > that is intended to initialize vhost-net with vhost-user backend.
>
> Some meta comments.
>
> Something that makes this patch harder to review is how it's
> split up. Generally IMHO it's not a good idea to repeatedly
> edit same part of file adding stuff in patch after patch,
> it's only making things harder to read if you add stubs, then fill them up.
> (we do this sometimes when we are changing existing code, but
> it is generally not needed when adding new code)
>
> Instead, split it like this:
>
> 1. general refactoring, split out linux specific and generic parts
>and add the ops indirection
> 2. add new files for vhost-user with complete implementation.
>without command line to support it, there will be no way to use it,
>but should build fine.
> 3. tie it all up with option parsing
>
>
> Generic vhost and vhost net files should be kept separate.
> Don't let vhost net stuff seep back into generic files,
> we have vhost-scsi too.
> I would also prefer that userspace vhost has its own files.
>

Ok, we'll keep this into account.


>
> We need a small test server qemu can talk to, to verify things
> actually work.
>

We have implemented such a test app:
https://github.com/virtualopensystems/vapp

We use it for testing, and also as a reference implementation. A client is
also included.


> Already commented on: reuse the chardev syntax and preferably code.
> We already support a bunch of options there for
> domain sockets that will be useful here, they should
> work here as well.
>

We adapted the syntax for this to be consistent with chardev. What we
didn't use, it is not obvious at all to us on how they should be used; a
lot of the chardev options just don't apply to us.


> In particular you shouldn't require filesystem access by qemu,
> passing fd for domain socket should work.
>

We can add an option to pass an fd for the domain socket if needed. However
as far as we understand, chardev doesn't do that either (at least form
looking at the man page). Maybe we misunderstand what you mean.


>
> > Example usage:
> >
> > qemu -m 1024 -mem-path /hugetlbfs,prealloc=on,share=on \
> >  -netdev type=vhost-user,id=net0,path=/path/to/sock,poll_time=2500 \
> >  -device virtio-net-pci,netdev=net0
>
> It's not clear which parts of -mem-path are required for vhost-user.
> It should be documented somewhere, made clear in -help
> and should fail gracefully if misconfigured.
>
>
Ok.


>
> >
> > Changes from v5:
> >  - Split -mem-path unlink option to a separate patch
> >  - Fds are passed only in the ancillary data
> >  - Stricter message size checks on receive/send
> >  - Netdev vhost-user now includes path and poll_time options
> >  - The connection probing interval is configurable
> >
> > Changes from v4:
> >  - Use error_report for errors
> >  - VhostUserMsg has new field `size` indicating the following payload
> length.
> >Field `flags` now has version and reply bits. The structure is packed.
> >  - Send data is of variable length (`size` field in message)
> >  - Receive in 2 steps, header and payload
> >  - Add new message type VHOST_USER_ECHO, to check connection status
> >

Re: [Qemu-devel] [PATCH v6 0/8] Vhost and vhost-net support for userspace based backends

2014-01-14 Thread Antonios Motakis
Hello,


On Tue, Jan 14, 2014 at 12:14 PM, Michael S. Tsirkin  wrote:

> On Mon, Jan 13, 2014 at 03:25:11PM +0100, Antonios Motakis wrote:
> > In this patch series we would like to introduce our approach for putting
> a
> > virtio-net backend in an external userspace process. Our eventual target
> is to
> > run the network backend in the Snabbswitch ethernet switch, while
> receiving
> > traffic from a guest inside QEMU/KVM which runs an unmodified virtio-net
> > implementation.
> >
> > For this, we are working into extending vhost to allow equivalent
> functionality
> > for userspace. Vhost already passes control of the data plane of
> virtio-net to
> > the host kernel; we want to realize a similar model, but for userspace.
> >
> > In this patch series the concept of a vhost-backend is introduced.
> >
> > We define two vhost backend types - vhost-kernel and vhost-user. The
> former is
> > the interface to the current kernel module implementation. Its control
> plane is
> > ioctl based. The data plane is the kernel directly accessing the QEMU
> allocated,
> > guest memory.
> >
> > In the new vhost-user backend, the control plane is based on
> communication
> > between QEMU and another userspace process using a unix domain socket.
> This
> > allows to implement a virtio backend for a guest running in QEMU, inside
> the
> > other userspace process.
> >
> > We change -mem-path to QemuOpts and add prealloc, share and unlink as
> properties
> > to it. HugeTLBFS requirements of -mem-path are relaxed, so any valid
> path can
> > be used now.
>
> Wait a second. This does not actually work well: if you mmap
> a random file outside HugeTLBFS, kernel won't create huge pages
> from this memory so performance of the system as a whole will suffer.
>
> You'll have fix the kernel MM before this scheme can fly.
>

I'm not sure I completely understand this point. It is up to the user to
choose not to use HugeTLBFS. Is there a particular problem with the kernel
when not using it?


>
>
> > The new properties allow more fine grained control over the guest
> > RAM backing store.
> >
> > The data path is realized by directly accessing the vrings and the
> buffer data
> > off the guest's memory.
> >
> > The current user of vhost-user is only vhost-net. We add new netdev
> backend
> > that is intended to initialize vhost-net with vhost-user backend.
> >
> > Example usage:
> >
> > qemu -m 1024 -mem-path /hugetlbfs,prealloc=on,share=on \
> >  -netdev type=vhost-user,id=net0,path=/path/to/sock,poll_time=2500 \
> >  -device virtio-net-pci,netdev=net0
> >
> > Changes from v5:
> >  - Split -mem-path unlink option to a separate patch
> >  - Fds are passed only in the ancillary data
> >  - Stricter message size checks on receive/send
> >  - Netdev vhost-user now includes path and poll_time options
> >  - The connection probing interval is configurable
> >
> > Changes from v4:
> >  - Use error_report for errors
> >  - VhostUserMsg has new field `size` indicating the following payload
> length.
> >Field `flags` now has version and reply bits. The structure is packed.
> >  - Send data is of variable length (`size` field in message)
> >  - Receive in 2 steps, header and payload
> >  - Add new message type VHOST_USER_ECHO, to check connection status
> >
> > Changes from v3:
> >  - Convert -mem-path to QemuOpts with prealloc, share and unlink
> properties
> >  - Set 1 sec timeout when read/write to the unix domain socket
> >  - Fix file descriptor leak
> >
> > Changes from v2:
> >  - Reconnect when the backend disappears
> >
> > Changes from v1:
> >  - Implementation of vhost-user netdev backend
> >  - Code improvements
> >
> > Antonios Motakis (8):
> >   Convert -mem-path to QemuOpts and add prealloc and share properties
> >   New -mem-path option - unlink.
> >   Decouple vhost from kernel interface
> >   Add vhost-user skeleton
> >   Add domain socket communication for vhost-user backend
> >   Add vhost-user calls implementation
> >   Add new vhost-user netdev backend
> >   Add vhost-user reconnection
> >
> >  exec.c|  57 +++-
> >  hmp-commands.hx   |   4 +-
> >  hw/net/vhost_net.c| 144 +++---
> >  hw/net/virtio-net.c   |  42 ++-
> >  hw/scsi/vhost-scsi.c  |  13 +-
> >  hw/virtio/Makefile.objs   |   2 +-
> >  hw/virtio/vhost-backend.c | 556
> ++
> >  hw/virtio/vhost.c |  46 ++--
> >  include/exec/cpu-all.h|   3 -
> >  include/hw/virtio/vhost-backend.h |  40 +++
> >  include/hw/virtio/vhost.h |   4 +-
> >  include/net/vhost-user.h  |  17 ++
> >  include/net/vhost_net.h   |  15 +-
> >  net/Makefile.objs |   2 +-
> >  net/clients.h |   3 +
> >  net/hub.c |   1 +
> >  net/net.c |   2 +
> >  net/tap.c |  16 +-
> >  net/vhost-user.c 

[Qemu-devel] [PATCH 8/9] pci/pcie: convert PCIE hotplug to use hotplug-handler API

2014-01-14 Thread Igor Mammedov
Split pcie_cap_slot_hotplug() into hotplug/unplug callbacks
and register them as "hotplug-handler" interface implementation of
PCIE_SLOT device.

Replace pci_bus_hotplug() wiring with setting link on PCI BUS
"hotplug-handler" property to PCI_BRIDGE_DEV device.

Signed-off-by: Igor Mammedov 
---
v2:
* keep original non abort behavior of pcie_cap_slot_init()
---
 hw/pci/pcie.c |   67 ++--
 hw/pci/pcie_port.c|8 ++
 include/hw/pci/pcie.h |5 +++
 3 files changed, 55 insertions(+), 25 deletions(-)

diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index ca60cf2..66d234a 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -26,6 +26,7 @@
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pcie_regs.h"
 #include "qemu/range.h"
+#include "qapi/qmp/qerror.h"
 
 //#define DEBUG_PCIE
 #ifdef DEBUG_PCIE
@@ -216,28 +217,20 @@ static void pcie_cap_slot_event(PCIDevice *dev, 
PCIExpressHotPlugEvent event)
 hotplug_event_notify(dev);
 }
 
-static int pcie_cap_slot_hotplug(DeviceState *qdev,
- PCIDevice *pci_dev, PCIHotplugState state)
+static void pcie_cap_slot_hotplug_common(PCIDevice *hotplug_dev,
+ DeviceState *dev,
+ uint8_t **exp_cap, Error **errp)
 {
-PCIDevice *d = PCI_DEVICE(qdev);
-uint8_t *exp_cap = d->config + d->exp.exp_cap;
-uint16_t sltsta = pci_get_word(exp_cap + PCI_EXP_SLTSTA);
-
-/* Don't send event when device is enabled during qemu machine creation:
- * it is present on boot, no hotplug event is necessary. We do send an
- * event when the device is disabled later. */
-if (state == PCI_COLDPLUG_ENABLED) {
-pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
-   PCI_EXP_SLTSTA_PDS);
-return 0;
-}
+PCIDevice *pci_dev = PCI_DEVICE(dev);
+*exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap;
+uint16_t sltsta = pci_get_word(*exp_cap + PCI_EXP_SLTSTA);
 
 PCIE_DEV_PRINTF(pci_dev, "hotplug state: %d\n", state);
 if (sltsta & PCI_EXP_SLTSTA_EIS) {
 /* the slot is electromechanically locked.
  * This error is propagated up to qdev and then to HMP/QMP.
  */
-return -EBUSY;
+error_setg_errno(errp, -EBUSY, "slot is electromechanically locked");
 }
 
 /* TODO: multifunction hot-plug.
@@ -245,18 +238,40 @@ static int pcie_cap_slot_hotplug(DeviceState *qdev,
  * hot plugged/unplugged.
  */
 assert(PCI_FUNC(pci_dev->devfn) == 0);
+}
 
-if (state == PCI_HOTPLUG_ENABLED) {
+void pcie_cap_slot_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
+  Error **errp)
+{
+uint8_t *exp_cap;
+
+pcie_cap_slot_hotplug_common(PCI_DEVICE(hotplug_dev), dev, &exp_cap, errp);
+
+/* Don't send event when device is enabled during qemu machine creation:
+ * it is present on boot, no hotplug event is necessary. We do send an
+ * event when the device is disabled later. */
+if (!dev->hotplugged) {
 pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
PCI_EXP_SLTSTA_PDS);
-pcie_cap_slot_event(d, PCI_EXP_HP_EV_PDC);
-} else {
-object_unparent(OBJECT(pci_dev));
-pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA,
- PCI_EXP_SLTSTA_PDS);
-pcie_cap_slot_event(d, PCI_EXP_HP_EV_PDC);
+return;
 }
-return 0;
+
+pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
+   PCI_EXP_SLTSTA_PDS);
+pcie_cap_slot_event(PCI_DEVICE(hotplug_dev), PCI_EXP_HP_EV_PDC);
+}
+
+void pcie_cap_slot_hot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
+ Error **errp)
+{
+uint8_t *exp_cap;
+
+pcie_cap_slot_hotplug_common(PCI_DEVICE(hotplug_dev), dev, &exp_cap, errp);
+
+object_unparent(OBJECT(dev));
+pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA,
+ PCI_EXP_SLTSTA_PDS);
+pcie_cap_slot_event(PCI_DEVICE(hotplug_dev), PCI_EXP_HP_EV_PDC);
 }
 
 /* pci express slot for pci express root/downstream port
@@ -264,6 +279,7 @@ static int pcie_cap_slot_hotplug(DeviceState *qdev,
 void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot)
 {
 uint32_t pos = dev->exp.exp_cap;
+BusState *bus = BUS(pci_bridge_get_sec_bus(PCI_BRIDGE(dev)));
 
 pci_word_test_and_set_mask(dev->config + pos + PCI_EXP_FLAGS,
PCI_EXP_FLAGS_SLOT);
@@ -305,8 +321,9 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot)
 
 dev->exp.hpev_notified = false;
 
-pci_bus_hotplug(pci_bridge_get_sec_bus(PCI_BRIDGE(dev)),
-pcie_cap_slot_hotplug, &dev->qdev);
+bus->allow_hotplug = 1;
+object_property_set_link(OBJECT(bus), OBJECT(dev),
+ QDEV_HOTPLUG_HANDLER_PROPERTY, N

[Qemu-devel] [PATCH] block: add .bdrv_reopen_prepare() stub for iscsi

2014-01-14 Thread Jeff Cody
To suppport reopen(), the .bdrv_reopen_prepare() stub must exist.
iSCSI does not have anything that needs to be done to support reopen,
so we can just implement the _prepare() stub.

Signed-off-by: Jeff Cody 
---
 block/iscsi.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/block/iscsi.c b/block/iscsi.c
index c0ea0c4..5976bd1 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1326,6 +1326,14 @@ static void iscsi_close(BlockDriverState *bs)
 memset(iscsilun, 0, sizeof(IscsiLun));
 }
 
+/* We have nothing to do for iSCSI reopen, stub just returns
+ * success */
+static int iscsi_reopen_prepare(BDRVReopenState *state,
+BlockReopenQueue *queue, Error **errp)
+{
+return 0;
+}
+
 static int iscsi_truncate(BlockDriverState *bs, int64_t offset)
 {
 IscsiLun *iscsilun = bs->opaque;
@@ -1434,6 +1442,7 @@ static BlockDriver bdrv_iscsi = {
 .bdrv_close  = iscsi_close,
 .bdrv_create = iscsi_create,
 .create_options  = iscsi_create_options,
+.bdrv_reopen_prepare  = iscsi_reopen_prepare,
 
 .bdrv_getlength  = iscsi_getlength,
 .bdrv_get_info   = iscsi_get_info,
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH v2] piix: fix 32bit pci hole

2014-01-14 Thread Michael Roth
Quoting Michael S. Tsirkin (2014-01-12 00:50:13)
> On Fri, Jan 10, 2014 at 09:28:39PM +0100, Laszlo Ersek wrote:
> > On 11/28/13 17:03, Laszlo Ersek wrote:
> > > Mike,
> > > 
> > > On 11/27/13 12:57, Gerd Hoffmann wrote:
> > >> Make the 32bit pci hole start at end of ram, so all possible address
> > >> space is covered.  Of course the firmware can use less than that.
> > >> Leaving space unused is no problem, mapping pci bars outside the
> > >> hole causes problems though.
> > >>
> > >> Signed-off-by: Gerd Hoffmann 
> > >> ---
> > >>  hw/pci-host/piix.c | 10 +-
> > >>  1 file changed, 1 insertion(+), 9 deletions(-)
> > >>
> > >> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
> > >> index edc974e..8e41ac1 100644
> > >> --- a/hw/pci-host/piix.c
> > >> +++ b/hw/pci-host/piix.c
> > >> @@ -345,15 +345,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,
> > >>  f->ram_memory = ram_memory;
> > >>  
> > >>  i440fx = I440FX_PCI_HOST_BRIDGE(dev);
> > >> -/* Set PCI window size the way seabios has always done it. */
> > >> -/* Power of 2 so bios can cover it with a single MTRR */
> > >> -if (ram_size <= 0x8000) {
> > >> -i440fx->pci_info.w32.begin = 0x8000;
> > >> -} else if (ram_size <= 0xc000) {
> > >> -i440fx->pci_info.w32.begin = 0xc000;
> > >> -} else {
> > >> -i440fx->pci_info.w32.begin = 0xe000;
> > >> -}
> > >> +i440fx->pci_info.w32.begin = pci_hole_start;
> > >>  
> > >>  memory_region_init_alias(&f->pci_hole, OBJECT(d), "pci-hole", 
> > >> f->pci_address_space,
> > >>   pci_hole_start, pci_hole_size);
> > >>
> > > 
> > > please pick this up for 1.7.1.
> > > 
> > > 1.7.0 has been released without this patch, also without etc/pci-info,
> > > but with etc/acpi/tables.
> > > 
> > > For OVMF to work with "etc/acpi/tables" correctly, with eg. a guest RAM
> > > size of 2560MB, OVMF needs:
> > > - either this patch in qemu, or
> > > - etc/pci-info (which won't come back), or
> > > - a hack in OVMF that mimicks the same 0x8000/0xc000/0xe000
> > >   logic (which I won't add).
> > 
> > Nominating this for v1.7.1 again.
> > 
> > The qemu-2.0 version (ie. a forward-port) of this patch has been merged as
> > 
> >   ddaaefb piix: fix 32bit pci hole
> > 
> > If necessary I can resubmit the v1.7.1 patch.
> > 
> > Thanks,
> > Laszlo
> 
> 
> It seems cleaner to backport this into stable.
> Mike, can you pick this up please?

Sure, will queue this up for 1.7.1 and backport from upstream

> 
> -- 
> MST




Re: [Qemu-devel] [PULL 14/28] exec: make address spaces 64-bit wide

2014-01-14 Thread Alex Williamson
On Tue, 2014-01-14 at 12:55 -0500, Mike Day wrote:
> On Tue, Jan 14, 2014 at 12:49 PM, Mike Day  wrote:
> >>> > > >>>
> >>> > > > Prior to this change, there was no re-map with the 
> >>> > > > febe
> >
> >> If we choose not to map them, how do we distinguish them from guest RAM?
> >> There's no MemoryRegion flag that I'm aware of to distinguish a ram_ptr
> >> that points to a chunk of guest memory from one that points to the mmap
> >> of a device BAR.  I think I'd need to explicitly walk all of the vfio
> >> device and try to match the MemoryRegion pointer to one of my devices.
> >> That only solves the problem for vfio devices and not ivshmem devices or
> >> pci-assign devices.
> >>
> >
> > I don't know if this will save you doing your memory region search or
> > not. But a BAR that ends with the low bit set is MMIO, and BAR that
> > ends with the low bit clear is RAM. So the address above is RAM as was
> > pointed out earlier in the thread. If you got an ambitious address in
> > the future you could test the low bit. But MMIO is deprecated
> > according to http://wiki.osdev.org/PCI so you probably won't see it,
> > at least for 64-bit addresses.
> 
> s/ambitious/ambiguous/
> 
> The address above has already been masked. What you need to do is read
> the BAR. If the value from the BAR end in '1', its MMIO. If it ends in
> '10', its RAM. If it ends in '0n' its disabled. The first thing that
> the PCI software does after reading the BAR is mask off the two low
> bits.

Are you perhaps confusing MMIO and I/O port?  I/O port cannot be mmap'd
on x86, so it can't be directly mapped.  It also doesn't come through
the address_space_memory filter.  I/O port is deprecated, or at least
discouraged, MMIO is not.  Thanks,

Alex





Re: [Qemu-devel] [PULL 14/28] exec: make address spaces 64-bit wide

2014-01-14 Thread Mike Day
On Tue, Jan 14, 2014 at 12:49 PM, Mike Day  wrote:
>>> > > >>>
>>> > > > Prior to this change, there was no re-map with the 
>>> > > > febe
>
>> If we choose not to map them, how do we distinguish them from guest RAM?
>> There's no MemoryRegion flag that I'm aware of to distinguish a ram_ptr
>> that points to a chunk of guest memory from one that points to the mmap
>> of a device BAR.  I think I'd need to explicitly walk all of the vfio
>> device and try to match the MemoryRegion pointer to one of my devices.
>> That only solves the problem for vfio devices and not ivshmem devices or
>> pci-assign devices.
>>
>
> I don't know if this will save you doing your memory region search or
> not. But a BAR that ends with the low bit set is MMIO, and BAR that
> ends with the low bit clear is RAM. So the address above is RAM as was
> pointed out earlier in the thread. If you got an ambitious address in
> the future you could test the low bit. But MMIO is deprecated
> according to http://wiki.osdev.org/PCI so you probably won't see it,
> at least for 64-bit addresses.

s/ambitious/ambiguous/

The address above has already been masked. What you need to do is read
the BAR. If the value from the BAR end in '1', its MMIO. If it ends in
'10', its RAM. If it ends in '0n' its disabled. The first thing that
the PCI software does after reading the BAR is mask off the two low
bits.

Mike



Re: [Qemu-devel] [PATCH] tap: add the possibility to specify a tap prefix

2014-01-14 Thread Eric Blake
On 01/14/2014 10:15 AM, William Dauchy wrote:
> this will permit to specify an interface prefix to the tap instead of the
> default one ("tap")
> this functionnality is useful when you need an easy way to find the

s/functionnality/functionality/

> interfaces attached to a given virtual machine
> 

> +++ b/qapi-schema.json
> @@ -3028,7 +3028,8 @@
>  { 'type': 'NetdevBridgeOptions',
>'data': {
>  '*br': 'str',
> -'*helper': 'str' } }
> +'*helper': 'str',
> +'*prefix': 'str'} }

Need to document the new field, including when it was added.  Something
like:

# @NetdevBridgeOptions
#
# Connect a host TAP network interface to a host bridge device.
#
# @br: #optional bridge name
#
# @helper: #optional command to execute to configure bridge
#
# @prefix: #optional prefix to use in naming the bridge, default
#  "tap" (since 2.0)
#
# Since 1.2

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH 0/9] target-arm: Add AArch32 ARMv8 VRINT instructions

2014-01-14 Thread Will Newton
This series adds support for the floating-point and Advanced SIMD
versions of the VRINT family of instructions. 

Will Newton (9):
  target-arm: Move arm_rmode_to_sf to a shared location.
  target-arm: Add AArch32 FP VRINTA, VRINTN, VRINTP and VRINTM
  target-arm: Add support for AArch32 FP VRINTR
  target-arm: Add support for AArch32 FP VRINTZ
  target-arm: Add support for AArch32 FP VRINTX
  target-arm: Add support for AArch32 SIMD VRINTX
  target-arm: Add set_neon_rmode helper
  target-arm: Add support for AArch32 SIMD VRINTZ
  target-arm: Add AArch32 SIMD VRINTA, VRINTN, VRINTP and VRINTM

 target-arm/cpu.h   |   2 +
 target-arm/helper.c|  45 ++
 target-arm/helper.h|   1 +
 target-arm/translate-a64.c |  28 -
 target-arm/translate.c | 145 +
 5 files changed, 193 insertions(+), 28 deletions(-)

-- 
1.8.1.4




[Qemu-devel] [PATCH 1/9] target-arm: Move arm_rmode_to_sf to a shared location.

2014-01-14 Thread Will Newton
This function will be needed for AArch32 ARMv8 support, so move it to
helper.c where it can be used by both targets. Also moves the code out
of line, but as it is quite a large function I don't believe this
should be a significant performance impact.

Signed-off-by: Will Newton 
---
 target-arm/cpu.h   |  2 ++
 target-arm/helper.c| 28 
 target-arm/translate-a64.c | 28 
 3 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 198b6b8..383c582 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -496,6 +496,8 @@ enum arm_fprounding {
 FPROUNDING_ODD
 };
 
+int arm_rmode_to_sf(int rmode);
+
 enum arm_cpu_mode {
   ARM_CPU_MODE_USR = 0x10,
   ARM_CPU_MODE_FIQ = 0x11,
diff --git a/target-arm/helper.c b/target-arm/helper.c
index c708f15..b1541b9 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -4418,3 +4418,31 @@ float64 HELPER(rintd)(float64 x, void *fp_status)
 
 return ret;
 }
+
+/* Convert ARM rounding mode to softfloat */
+int arm_rmode_to_sf(int rmode)
+{
+switch (rmode) {
+case FPROUNDING_TIEAWAY:
+rmode = float_round_ties_away;
+break;
+case FPROUNDING_ODD:
+/* FIXME: add support for TIEAWAY and ODD */
+qemu_log_mask(LOG_UNIMP, "arm: unimplemented rounding mode: %d\n",
+  rmode);
+case FPROUNDING_TIEEVEN:
+default:
+rmode = float_round_nearest_even;
+break;
+case FPROUNDING_POSINF:
+rmode = float_round_up;
+break;
+case FPROUNDING_NEGINF:
+rmode = float_round_down;
+break;
+case FPROUNDING_ZERO:
+rmode = float_round_to_zero;
+break;
+}
+return rmode;
+}
diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
index cf80c46..8effbe2 100644
--- a/target-arm/translate-a64.c
+++ b/target-arm/translate-a64.c
@@ -3186,34 +3186,6 @@ static void disas_data_proc_reg(DisasContext *s, 
uint32_t insn)
 }
 }
 
-/* Convert ARM rounding mode to softfloat */
-static inline int arm_rmode_to_sf(int rmode)
-{
-switch (rmode) {
-case FPROUNDING_TIEAWAY:
-rmode = float_round_ties_away;
-break;
-case FPROUNDING_ODD:
-/* FIXME: add support for TIEAWAY and ODD */
-qemu_log_mask(LOG_UNIMP, "arm: unimplemented rounding mode: %d\n",
-  rmode);
-case FPROUNDING_TIEEVEN:
-default:
-rmode = float_round_nearest_even;
-break;
-case FPROUNDING_POSINF:
-rmode = float_round_up;
-break;
-case FPROUNDING_NEGINF:
-rmode = float_round_down;
-break;
-case FPROUNDING_ZERO:
-rmode = float_round_to_zero;
-break;
-}
-return rmode;
-}
-
 static void handle_fp_compare(DisasContext *s, bool is_double,
   unsigned int rn, unsigned int rm,
   bool cmp_with_zero, bool signal_all_nans)
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH] virtio-balloon: don't hardcode config size value

2014-01-14 Thread Michael Tokarev
09.01.2014 18:58, Luiz Capitulino wrote:
> Use sizeof(strucy virtio_balloon_config) instead.
> 
> --- a/hw/virtio/virtio-balloon.c
> +++ b/hw/virtio/virtio-balloon.c
> @@ -263,7 +263,7 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, 
> uint8_t *config_data)
>  config.num_pages = cpu_to_le32(dev->num_pages);
>  config.actual = cpu_to_le32(dev->actual);
>  
> -memcpy(config_data, &config, 8);
> +memcpy(config_data, &config, sizeof(struct virtio_balloon_config));

I'm not sure any of those is better than another.

This is a published guest <=> host interface, the config _must_ be 8 bytes
long and must contain 2 4-byte words in it.

We may use assert(sizeof(struct virtio_balloon_config) == 8) somewhere,
but to my taste it is a bit overkill.  No?

Thanks,

/mjt



Re: [Qemu-devel] [PULL 14/28] exec: make address spaces 64-bit wide

2014-01-14 Thread Mike Day
>> > > >>>
>> > > > Prior to this change, there was no re-map with the 
>> > > > febe

> If we choose not to map them, how do we distinguish them from guest RAM?
> There's no MemoryRegion flag that I'm aware of to distinguish a ram_ptr
> that points to a chunk of guest memory from one that points to the mmap
> of a device BAR.  I think I'd need to explicitly walk all of the vfio
> device and try to match the MemoryRegion pointer to one of my devices.
> That only solves the problem for vfio devices and not ivshmem devices or
> pci-assign devices.
>

I don't know if this will save you doing your memory region search or
not. But a BAR that ends with the low bit set is MMIO, and BAR that
ends with the low bit clear is RAM. So the address above is RAM as was
pointed out earlier in the thread. If you got an ambitious address in
the future you could test the low bit. But MMIO is deprecated
according to http://wiki.osdev.org/PCI so you probably won't see it,
at least for 64-bit addresses.

Mike



Re: [Qemu-devel] [PATCH] tap: add the possibility to specify a tap prefix

2014-01-14 Thread William Dauchy
Hello Paolo,

Thanks for your quick reply.

On Jan14 18:31, Paolo Bonzini wrote:
> I think this was nacked already in the past.  You would need to
> implement some kind of ACL system like the one that is in place for
> bridges.  Without it, for example, you could hijack existing iptables rules.

I don't get it; this does not change anything to the existing but
permits to change the default "tap" string prefix.

Am I missing something?

-- 
William


signature.asc
Description: Digital signature


[Qemu-devel] [PATCH] tap: add the possibility to specify a tap prefix

2014-01-14 Thread William Dauchy
this will permit to specify an interface prefix to the tap instead of the
default one ("tap")
this functionnality is useful when you need an easy way to find the
interfaces attached to a given virtual machine

example:
 -net bridge,prefix=tapvmA. -net bridge,prefix=tapvmA.
 will create `tapvmA.0` and `tapvmA.1`
 `brctl show | grep vmA` will be an easy way to find the interfaces
 attached to the vmA

Signed-off-by: 
---
 include/net/net.h|  1 +
 net/tap.c| 18 --
 qapi-schema.json |  3 ++-
 qemu-bridge-helper.c |  9 +++--
 qemu-options.hx  |  3 ++-
 5 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/include/net/net.h b/include/net/net.h
index 11e1468..4cb0566 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -180,6 +180,7 @@ NetClientState *net_hub_port_find(int hub_id);
 #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
 #define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
 #define DEFAULT_BRIDGE_INTERFACE "br0"
+#define DEFAULT_BRIDGE_PREFIX "tap"
 
 void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
 
diff --git a/net/tap.c b/net/tap.c
index 39c1cda..667cf17 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -419,7 +419,8 @@ static int recv_fd(int c)
 return len;
 }
 
-static int net_bridge_run_helper(const char *helper, const char *bridge)
+static int net_bridge_run_helper(const char *helper, const char *bridge,
+   const char *prefix)
 {
 sigset_t oldmask, mask;
 int pid, status;
@@ -441,7 +442,8 @@ static int net_bridge_run_helper(const char *helper, const 
char *bridge)
 int open_max = sysconf(_SC_OPEN_MAX), i;
 char fd_buf[6+10];
 char br_buf[6+IFNAMSIZ] = {0};
-char helper_cmd[PATH_MAX + sizeof(fd_buf) + sizeof(br_buf) + 15];
+char pr_buf[6+IFNAMSIZ] = {0};
+char helper_cmd[PATH_MAX + sizeof(fd_buf) + sizeof(br_buf) + 
sizeof(pr_buf) + 15];
 
 for (i = 0; i < open_max; i++) {
 if (i != STDIN_FILENO &&
@@ -453,6 +455,7 @@ static int net_bridge_run_helper(const char *helper, const 
char *bridge)
 }
 
 snprintf(fd_buf, sizeof(fd_buf), "%s%d", "--fd=", sv[1]);
+snprintf(pr_buf, sizeof(br_buf), "%s%s", "--tap-prefix=", prefix);
 
 if (strrchr(helper, ' ') || strrchr(helper, '\t')) {
 /* assume helper is a command */
@@ -481,6 +484,7 @@ static int net_bridge_run_helper(const char *helper, const 
char *bridge)
 *parg++ = (char *)"--use-vnet";
 *parg++ = fd_buf;
 *parg++ = br_buf;
+*parg++ = pr_buf;
 *parg++ = NULL;
 
 execv(helper, args);
@@ -519,7 +523,7 @@ int net_init_bridge(const NetClientOptions *opts, const 
char *name,
 NetClientState *peer)
 {
 const NetdevBridgeOptions *bridge;
-const char *helper, *br;
+const char *helper, *br, *prefix;
 
 TAPState *s;
 int fd, vnet_hdr;
@@ -528,9 +532,10 @@ int net_init_bridge(const NetClientOptions *opts, const 
char *name,
 bridge = opts->bridge;
 
 helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER;
+prefix = bridge->has_prefix ? bridge->prefix : DEFAULT_BRIDGE_PREFIX;
 br = bridge->has_br ? bridge->br : DEFAULT_BRIDGE_INTERFACE;
 
-fd = net_bridge_run_helper(helper, br);
+fd = net_bridge_run_helper(helper, br, prefix);
 if (fd == -1) {
 return -1;
 }
@@ -728,7 +733,7 @@ int net_init_tap(const NetClientOptions *opts, const char 
*name,
 tap->has_vnet_hdr || tap->has_helper || tap->has_queues ||
 tap->has_vhostfd) {
 error_report("ifname=, script=, downscript=, vnet_hdr=, "
- "helper=, queues=, and vhostfd= "
+ "helper=, queues=, and vhostfd="
  "are invalid with fds=");
 return -1;
 }
@@ -773,7 +778,8 @@ int net_init_tap(const NetClientOptions *opts, const char 
*name,
 return -1;
 }
 
-fd = net_bridge_run_helper(tap->helper, DEFAULT_BRIDGE_INTERFACE);
+fd = net_bridge_run_helper(tap->helper, DEFAULT_BRIDGE_INTERFACE,
+   DEFAULT_BRIDGE_PREFIX);
 if (fd == -1) {
 return -1;
 }
diff --git a/qapi-schema.json b/qapi-schema.json
index f27c48a..83d8895 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3028,7 +3028,8 @@
 { 'type': 'NetdevBridgeOptions',
   'data': {
 '*br': 'str',
-'*helper': 'str' } }
+'*helper': 'str',
+'*prefix': 'str'} }
 
 ##
 # @NetdevHubPortOptions
diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c
index 6a0974e..6eef43b 100644
--- a/qemu-bridge-helper.c
+++ b/qemu-bridge-helper.c
@@ -67,7 +67,8 @@ typedef QSIMPLEQ_HEAD(ACLList, ACLRule) ACLList;
 static void usage(void)
 {
 fprintf(stderr,
-"Usage: qemu-bridge-helper [--use-vnet] --br=bridge 
--fd=unixfd\n");
+"Usage: qemu-brid

[Qemu-devel] [PATCH 6/9] target-arm: Add support for AArch32 SIMD VRINTX

2014-01-14 Thread Will Newton
Add support for the AArch32 Advanced SIMD VRINTX instruction.

Signed-off-by: Will Newton 
---
 target-arm/translate.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 5108f6b..b6d11db 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -4709,6 +4709,7 @@ static const uint8_t neon_3r_sizes[] = {
 #define NEON_2RM_VMOVN 36 /* Includes VQMOVN, VQMOVUN */
 #define NEON_2RM_VQMOVN 37 /* Includes VQMOVUN */
 #define NEON_2RM_VSHLL 38
+#define NEON_2RM_VRINTX 41
 #define NEON_2RM_VCVT_F16_F32 44
 #define NEON_2RM_VCVT_F32_F16 46
 #define NEON_2RM_VRECPE 56
@@ -4724,7 +4725,7 @@ static int neon_2rm_is_float_op(int op)
 {
 /* Return true if this neon 2reg-misc op is float-to-float */
 return (op == NEON_2RM_VABS_F || op == NEON_2RM_VNEG_F ||
-op >= NEON_2RM_VRECPE_F);
+op == NEON_2RM_VRINTX || op >= NEON_2RM_VRECPE_F);
 }
 
 /* Each entry in this array has bit n set if the insn allows
@@ -4768,6 +4769,7 @@ static const uint8_t neon_2rm_sizes[] = {
 [NEON_2RM_VMOVN] = 0x7,
 [NEON_2RM_VQMOVN] = 0x7,
 [NEON_2RM_VSHLL] = 0x7,
+[NEON_2RM_VRINTX] = 0x4,
 [NEON_2RM_VCVT_F16_F32] = 0x2,
 [NEON_2RM_VCVT_F32_F16] = 0x2,
 [NEON_2RM_VRECPE] = 0x4,
@@ -6480,6 +6482,13 @@ static int disas_neon_data_insn(CPUARMState * env, 
DisasContext *s, uint32_t ins
 }
 neon_store_reg(rm, pass, tmp2);
 break;
+case NEON_2RM_VRINTX:
+{
+TCGv_ptr fpstatus = get_fpstatus_ptr(1);
+gen_helper_rints_exact(cpu_F0s, cpu_F0s, fpstatus);
+tcg_temp_free_ptr(fpstatus);
+break;
+}
 case NEON_2RM_VRECPE:
 gen_helper_recpe_u32(tmp, tmp, cpu_env);
 break;
-- 
1.8.1.4




Re: [Qemu-devel] [Qemu-trivial] [PATCH] exec: Exclude non portable function for MinGW

2014-01-14 Thread Stefan Weil
Am 14.01.2014 18:26, schrieb Michael Tokarev:
> 14.01.2014 10:00, Stefan Weil wrote:
>> cpu_physical_memory_set_dirty_lebitmap calls getpageaddr and ffsl which are
>> unavailable for MinGW. As the function is unused for MinGW, it can simply
>> be excluded from compilation.
> I applied it to -trivial.  But maybe it's better to just move whole thing to 
> kvm-all.c where
> it is actually used?
>
> Thanks,
>
> /mjt

That's a good suggestion.

Juan, a comment in include/exec/ram_addr.h says that those functions
will be removed soon. Would you suggest moving them to kvm-all.c now, or
would you prefer the conditional compilation for MinGW which I
introduced with my patch?

Regards,
Stefan




[Qemu-devel] [PATCH 4/9] hw/acpi: move typeinfo to the file end

2014-01-14 Thread Igor Mammedov
do so to avoid not necessary forward declarations and
place typeinfo registration at the file end where it's
usualy expected.

Signed-off-by: Igor Mammedov 
---
 hw/acpi/piix4.c |   88 +++---
 1 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 20353b9..3dcaaca 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -504,50 +504,6 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t 
smb_io_base,
 return s->smb.smbus;
 }
 
-static Property piix4_pm_properties[] = {
-DEFINE_PROP_UINT32("smb_io_base", PIIX4PMState, smb_io_base, 0),
-DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0),
-DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0),
-DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
-DEFINE_PROP_END_OF_LIST(),
-};
-
-static void piix4_pm_class_init(ObjectClass *klass, void *data)
-{
-DeviceClass *dc = DEVICE_CLASS(klass);
-PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
-
-k->no_hotplug = 1;
-k->init = piix4_pm_initfn;
-k->config_write = pm_write_config;
-k->vendor_id = PCI_VENDOR_ID_INTEL;
-k->device_id = PCI_DEVICE_ID_INTEL_82371AB_3;
-k->revision = 0x03;
-k->class_id = PCI_CLASS_BRIDGE_OTHER;
-dc->desc = "PM";
-dc->vmsd = &vmstate_acpi;
-dc->props = piix4_pm_properties;
-/*
- * Reason: part of PIIX4 southbridge, needs to be wired up,
- * e.g. by mips_malta_init()
- */
-dc->cannot_instantiate_with_device_add_yet = true;
-}
-
-static const TypeInfo piix4_pm_info = {
-.name  = TYPE_PIIX4_PM,
-.parent= TYPE_PCI_DEVICE,
-.instance_size = sizeof(PIIX4PMState),
-.class_init= piix4_pm_class_init,
-};
-
-static void piix4_pm_register_types(void)
-{
-type_register_static(&piix4_pm_info);
-}
-
-type_init(piix4_pm_register_types)
-
 static uint64_t gpe_readb(void *opaque, hwaddr addr, unsigned width)
 {
 PIIX4PMState *s = opaque;
@@ -757,3 +713,47 @@ static int piix4_device_hotplug(DeviceState *qdev, 
PCIDevice *dev,
 
 return 0;
 }
+
+static Property piix4_pm_properties[] = {
+DEFINE_PROP_UINT32("smb_io_base", PIIX4PMState, smb_io_base, 0),
+DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0),
+DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0),
+DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
+DEFINE_PROP_END_OF_LIST(),
+};
+
+static void piix4_pm_class_init(ObjectClass *klass, void *data)
+{
+DeviceClass *dc = DEVICE_CLASS(klass);
+PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+k->no_hotplug = 1;
+k->init = piix4_pm_initfn;
+k->config_write = pm_write_config;
+k->vendor_id = PCI_VENDOR_ID_INTEL;
+k->device_id = PCI_DEVICE_ID_INTEL_82371AB_3;
+k->revision = 0x03;
+k->class_id = PCI_CLASS_BRIDGE_OTHER;
+dc->desc = "PM";
+dc->vmsd = &vmstate_acpi;
+dc->props = piix4_pm_properties;
+/*
+ * Reason: part of PIIX4 southbridge, needs to be wired up,
+ * e.g. by mips_malta_init()
+ */
+dc->cannot_instantiate_with_device_add_yet = true;
+}
+
+static const TypeInfo piix4_pm_info = {
+.name  = TYPE_PIIX4_PM,
+.parent= TYPE_PCI_DEVICE,
+.instance_size = sizeof(PIIX4PMState),
+.class_init= piix4_pm_class_init,
+};
+
+static void piix4_pm_register_types(void)
+{
+type_register_static(&piix4_pm_info);
+}
+
+type_init(piix4_pm_register_types)
-- 
1.7.1




Re: [Qemu-devel] [PATCH] tap: add the possibility to specify a tap prefix

2014-01-14 Thread Paolo Bonzini
Il 14/01/2014 18:15, William Dauchy ha scritto:
> this will permit to specify an interface prefix to the tap instead of the
> default one ("tap")
> this functionnality is useful when you need an easy way to find the
> interfaces attached to a given virtual machine
> 
> example:
>  -net bridge,prefix=tapvmA. -net bridge,prefix=tapvmA.
>  will create `tapvmA.0` and `tapvmA.1`
>  `brctl show | grep vmA` will be an easy way to find the interfaces
>  attached to the vmA
> 
> Signed-off-by: 

I think this was nacked already in the past.  You would need to
implement some kind of ACL system like the one that is in place for
bridges.  Without it, for example, you could hijack existing iptables rules.

Sorry for the bad news. :)

Paolo



Re: [Qemu-devel] [Qemu-trivial] [PATCH] exec: Exclude non portable function for MinGW

2014-01-14 Thread Michael Tokarev
14.01.2014 10:00, Stefan Weil wrote:
> cpu_physical_memory_set_dirty_lebitmap calls getpageaddr and ffsl which are
> unavailable for MinGW. As the function is unused for MinGW, it can simply
> be excluded from compilation.

I applied it to -trivial.  But maybe it's better to just move whole thing to 
kvm-all.c where
it is actually used?

Thanks,

/mjt



[Qemu-devel] [PATCH 3/9] target-arm: Add support for AArch32 FP VRINTR

2014-01-14 Thread Will Newton
Add support for the AArch32 floating-point VRINTR instruction.

Signed-off-by: Will Newton 
---
 target-arm/translate.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index f688f6d..73e0e8d 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -3374,6 +3374,17 @@ static int disas_vfp_insn(CPUARMState * env, 
DisasContext *s, uint32_t insn)
 gen_vfp_F1_ld0(dp);
 gen_vfp_cmpe(dp);
 break;
+case 12: /* vrintr */
+if (dp) {
+TCGv_ptr fpst = get_fpstatus_ptr(0);
+gen_helper_rintd(cpu_F0d, cpu_F0d, fpst);
+tcg_temp_free_ptr(fpst);
+} else {
+TCGv_ptr fpst = get_fpstatus_ptr(0);
+gen_helper_rints(cpu_F0s, cpu_F0s, fpst);
+tcg_temp_free_ptr(fpst);
+}
+break;
 case 15: /* single<->double conversion */
 if (dp)
 gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env);
-- 
1.8.1.4




[Qemu-devel] [PATCH 5/9] target-arm: Add support for AArch32 FP VRINTX

2014-01-14 Thread Will Newton
Add support for the AArch32 floating-point VRINTX instruction.

Signed-off-by: Will Newton 
---
 target-arm/translate.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 153d0e6..5108f6b 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -3406,6 +3406,17 @@ static int disas_vfp_insn(CPUARMState * env, 
DisasContext *s, uint32_t insn)
 tcg_temp_free_ptr(fpst);
 }
 break;
+case 14: /* vrintx */
+if (dp) {
+TCGv_ptr fpst = get_fpstatus_ptr(0);
+gen_helper_rintd_exact(cpu_F0d, cpu_F0d, fpst);
+tcg_temp_free_ptr(fpst);
+} else {
+TCGv_ptr fpst = get_fpstatus_ptr(0);
+gen_helper_rints_exact(cpu_F0s, cpu_F0s, fpst);
+tcg_temp_free_ptr(fpst);
+}
+break;
 case 15: /* single<->double conversion */
 if (dp)
 gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env);
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH 1/2] vfio: warn if host device rom can't be read

2014-01-14 Thread Alex Williamson
On Tue, 2014-01-14 at 22:37 +0530, Bandan Das wrote:
> Ccing Markus for the *_once macros
> 
> Alex Williamson  writes:
> 
> > On Tue, 2014-01-14 at 21:45 +0530, Bandan Das wrote:
> >> If the device rom can't be read, report an error to the
> >> user. The guest might try to read the rom contents more than
> >> once, so introduce macros that print a message only once and
> >> not clutter up the console. This is to alert the user
> >> that the device has a bad state that is causing rom read
> >> failure or option rom loading has been disabled from the device
> >> boot menu (among other reasons).
> >> 
> >> Signed-off-by: Bandan Das 
> >> ---
> >>  hw/misc/vfio.c  |  7 +++
> >>  include/qemu/error-report.h | 20 
> >>  2 files changed, 27 insertions(+)
> >> 
> >> diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
> >> index 9aecaa8..e5b2826 100644
> >> --- a/hw/misc/vfio.c
> >> +++ b/hw/misc/vfio.c
> >> @@ -1125,6 +1125,13 @@ static void vfio_pci_load_rom(VFIODevice *vdev)
> >>  vdev->rom_offset = reg_info.offset;
> >>  
> >>  if (!vdev->rom_size) {
> >> +error_report_once("vfio-pci: Cannot read device rom at "
> >> +"%04x:%02x:%02x.%x\n",
> >> +vdev->host.domain, vdev->host.bus, vdev->host.slot,
> >> +vdev->host.function);
> >> +error_printf_once("Device option ROM contents are probably 
> >> invalid "
> >> +"(check dmesg).\nSkip option ROM probe with rombar=0, 
> >> "
> >> +"or load from file with romfile=\n");
> >>  return;
> >>  }
> >>  
> >> diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
> >> index 3b098a9..7d24e4c 100644
> >> --- a/include/qemu/error-report.h
> >> +++ b/include/qemu/error-report.h
> >> @@ -43,4 +43,24 @@ void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 
> >> 2);
> >>  const char *error_get_progname(void);
> >>  extern bool enable_timestamp_msg;
> >>  
> >> +#define error_printf_once(fmt, ...) \
> >> +({  \
> >> +static bool __printf_once;  \
> >> +\
> >> +if (!__printf_once) {   \
> >> +__printf_once = true;   \
> >> +error_printf(fmt, ##__VA_ARGS__);   \
> >> +}   \
> >> +})  \
> >> +
> >> +#define error_report_once(fmt, ...) \
> >> +({  \
> >> +static bool __report_once;  \
> >> +\
> >> +if (!__report_once) {   \
> >> +__report_once = true;   \
> >> +error_report(fmt, ##__VA_ARGS__);   \
> >> +}   \
> >> +})  \
> >> +
> >>  #endif
> >
> > Why do we need these if patch 2/2 comes along and only calls
> > vfio_pci_load_rom() once?  If we do need these, they should be a
> > separate patch.  Thanks,
> 
> I was in and out on this until I decided to include it for cases 
> where we vfio assign a number of functions from the same card - if rom 
> loading fails for one, it will most probably fail for others as 
> well and this will make sure to print it just once at bootup. 
> However, this also means that it will print once for unrelated assignments
> too, I kind of half-convinced myself that that's probably ok :)
> 
> Would you rather have this get printed for each assigned device if loading 
> fails ? 

The error_report is going to list a specific device, so yes, it's
probably best to be explicit about all the devices that are having
problems.  Thanks,

Alex





Re: [Qemu-devel] [PATCH 1/2] vfio: warn if host device rom can't be read

2014-01-14 Thread Bandan Das
Ccing Markus for the *_once macros

Alex Williamson  writes:

> On Tue, 2014-01-14 at 21:45 +0530, Bandan Das wrote:
>> If the device rom can't be read, report an error to the
>> user. The guest might try to read the rom contents more than
>> once, so introduce macros that print a message only once and
>> not clutter up the console. This is to alert the user
>> that the device has a bad state that is causing rom read
>> failure or option rom loading has been disabled from the device
>> boot menu (among other reasons).
>> 
>> Signed-off-by: Bandan Das 
>> ---
>>  hw/misc/vfio.c  |  7 +++
>>  include/qemu/error-report.h | 20 
>>  2 files changed, 27 insertions(+)
>> 
>> diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
>> index 9aecaa8..e5b2826 100644
>> --- a/hw/misc/vfio.c
>> +++ b/hw/misc/vfio.c
>> @@ -1125,6 +1125,13 @@ static void vfio_pci_load_rom(VFIODevice *vdev)
>>  vdev->rom_offset = reg_info.offset;
>>  
>>  if (!vdev->rom_size) {
>> +error_report_once("vfio-pci: Cannot read device rom at "
>> +"%04x:%02x:%02x.%x\n",
>> +vdev->host.domain, vdev->host.bus, vdev->host.slot,
>> +vdev->host.function);
>> +error_printf_once("Device option ROM contents are probably invalid "
>> +"(check dmesg).\nSkip option ROM probe with rombar=0, "
>> +"or load from file with romfile=\n");
>>  return;
>>  }
>>  
>> diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
>> index 3b098a9..7d24e4c 100644
>> --- a/include/qemu/error-report.h
>> +++ b/include/qemu/error-report.h
>> @@ -43,4 +43,24 @@ void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 
>> 2);
>>  const char *error_get_progname(void);
>>  extern bool enable_timestamp_msg;
>>  
>> +#define error_printf_once(fmt, ...) \
>> +({  \
>> +static bool __printf_once;  \
>> +\
>> +if (!__printf_once) {   \
>> +__printf_once = true;   \
>> +error_printf(fmt, ##__VA_ARGS__);   \
>> +}   \
>> +})  \
>> +
>> +#define error_report_once(fmt, ...) \
>> +({  \
>> +static bool __report_once;  \
>> +\
>> +if (!__report_once) {   \
>> +__report_once = true;   \
>> +error_report(fmt, ##__VA_ARGS__);   \
>> +}   \
>> +})  \
>> +
>>  #endif
>
> Why do we need these if patch 2/2 comes along and only calls
> vfio_pci_load_rom() once?  If we do need these, they should be a
> separate patch.  Thanks,

I was in and out on this until I decided to include it for cases 
where we vfio assign a number of functions from the same card - if rom 
loading fails for one, it will most probably fail for others as 
well and this will make sure to print it just once at bootup. 
However, this also means that it will print once for unrelated assignments
too, I kind of half-convinced myself that that's probably ok :)

Would you rather have this get printed for each assigned device if loading 
fails ? 

> Alex



[Qemu-devel] [PATCH 1/2] vfio: warn if host device rom can't be read

2014-01-14 Thread Bandan Das
If the device rom can't be read, report an error to the
user. The guest might try to read the rom contents more than
once, so introduce macros that print a message only once and
not clutter up the console. This is to alert the user
that the device has a bad state that is causing rom read
failure or option rom loading has been disabled from the device
boot menu (among other reasons).

Signed-off-by: Bandan Das 
---
 hw/misc/vfio.c  |  7 +++
 include/qemu/error-report.h | 20 
 2 files changed, 27 insertions(+)

diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index 9aecaa8..e5b2826 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -1125,6 +1125,13 @@ static void vfio_pci_load_rom(VFIODevice *vdev)
 vdev->rom_offset = reg_info.offset;
 
 if (!vdev->rom_size) {
+error_report_once("vfio-pci: Cannot read device rom at "
+"%04x:%02x:%02x.%x\n",
+vdev->host.domain, vdev->host.bus, vdev->host.slot,
+vdev->host.function);
+error_printf_once("Device option ROM contents are probably invalid "
+"(check dmesg).\nSkip option ROM probe with rombar=0, "
+"or load from file with romfile=\n");
 return;
 }
 
diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
index 3b098a9..7d24e4c 100644
--- a/include/qemu/error-report.h
+++ b/include/qemu/error-report.h
@@ -43,4 +43,24 @@ void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
 const char *error_get_progname(void);
 extern bool enable_timestamp_msg;
 
+#define error_printf_once(fmt, ...) \
+({  \
+static bool __printf_once;  \
+\
+if (!__printf_once) {   \
+__printf_once = true;   \
+error_printf(fmt, ##__VA_ARGS__);   \
+}   \
+})  \
+
+#define error_report_once(fmt, ...) \
+({  \
+static bool __report_once;  \
+\
+if (!__report_once) {   \
+__report_once = true;   \
+error_report(fmt, ##__VA_ARGS__);   \
+}   \
+})  \
+
 #endif
-- 
1.8.3.1




[Qemu-devel] [PATCH 3/9] qdev: add "hotpluggable" property to Device

2014-01-14 Thread Igor Mammedov
Currently it's possible to make PCIDevice not hotpluggable by using
no_hotplug field of PCIDeviceClass. However it limits this
only to PCI devices and prevents from generalizing hotplug code.

So add similar field to DeviceClass so it could be reused with other
Devices and would allow to replace PCI specific hotplug callbacks
with generic implementation.

In addition expose field as "hotpluggable" readonly property, to make
it possible to get it via QOM interface.

Make DeviceClass hotpluggable by default as it was assumed before.

Signed-off-by: Igor Mammedov 
---
v5:
* drop 'boolean' from doc comment of hotpluggable field
v4:
* s/hotplugable/hotpluggable/

v3:
* make DeviceClass hotpluggable by default
  Since PCIDevice still uses internal no_hotlpug checks it shouldn't
  reggress. And follow up patch that converts PCIDevices to use
  "hotpluggable" property will take care about not hotpluggable PCI
  devices explicitly setting "hotpluggable" to false in their class_init().

* move generic hotplug checks from
  "7/11 qdev:pci: refactor PCIDevice to use generic "hotplugable" property"
  to this patch
---
 hw/core/qdev.c |   29 +
 include/hw/qdev-core.h |3 +++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index c9f0c33..d8b83f1 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -215,6 +215,12 @@ void qdev_unplug(DeviceState *dev, Error **errp)
 }
 assert(dc->unplug != NULL);
 
+if (!dc->hotpluggable) {
+error_set(errp, QERR_DEVICE_NO_HOTPLUG,
+  object_get_typename(OBJECT(dev)));
+return;
+}
+
 qdev_hot_removed = true;
 
 if (dc->unplug(dev) < 0) {
@@ -694,6 +700,11 @@ static void device_set_realized(Object *obj, bool value, 
Error **err)
 DeviceClass *dc = DEVICE_GET_CLASS(dev);
 Error *local_err = NULL;
 
+if (dev->hotplugged && !dc->hotpluggable) {
+error_set(err, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
+return;
+}
+
 if (value && !dev->realized) {
 if (!obj->parent && local_err == NULL) {
 static int unattached_count;
@@ -734,6 +745,14 @@ static void device_set_realized(Object *obj, bool value, 
Error **err)
 dev->realized = value;
 }
 
+static bool device_get_hotpluggable(Object *obj, Error **err)
+{
+DeviceClass *dc = DEVICE_GET_CLASS(obj);
+DeviceState *dev = DEVICE(obj);
+
+return dc->hotpluggable && dev->parent_bus->allow_hotplug;
+}
+
 static void device_initfn(Object *obj)
 {
 DeviceState *dev = DEVICE(obj);
@@ -750,6 +769,8 @@ static void device_initfn(Object *obj)
 
 object_property_add_bool(obj, "realized",
  device_get_realized, device_set_realized, NULL);
+object_property_add_bool(obj, "hotpluggable",
+ device_get_hotpluggable, NULL, NULL);
 
 class = object_get_class(OBJECT(dev));
 do {
@@ -786,6 +807,14 @@ static void device_class_base_init(ObjectClass *class, 
void *data)
  * so do not propagate them to the subclasses.
  */
 klass->props = NULL;
+
+/* by default all devices were considered as hotpluggable,
+ * so with intent to check it in generic qdev_unplug() /
+ * device_set_realized() functions make every device
+ * hotpluggable. Devices that shouldn't be hoplugable,
+ * should override it in their class_init()
+ */
+klass->hotpluggable = true;
 }
 
 static void device_unparent(Object *obj)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 58a5c69..9d58a9d 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -50,6 +50,8 @@ struct VMStateDescription;
  * is changed to %true. Deprecated, new types inheriting directly from
  * TYPE_DEVICE should use @realize instead, new leaf types should consult
  * their respective parent type.
+ * @hotpluggable: indicates if #DeviceClass is hotpluggable, available
+ * as readonly "hotpluggable" property of #DeviceState instance
  *
  * # Realization #
  * Devices are constructed in two stages,
@@ -110,6 +112,7 @@ typedef struct DeviceClass {
  * TODO remove once we're there
  */
 bool cannot_instantiate_with_device_add_yet;
+bool hotpluggable;
 
 /* callbacks */
 void (*reset)(DeviceState *dev);
-- 
1.7.1




[Qemu-devel] [PATCH 2/9] qdev: add to BusState "hotplug-handler" link

2014-01-14 Thread Igor Mammedov
It will allow to reuse field with different BUSes, reducing code duplication.
Field is intended fot replacing 'hotplug_qdev' field in PCIBus and also
will allow to avoid adding equivalent field to DimmBus with possiblitity
to refactor other BUSes to use it instead of custom field.
In addition once all users of allow_hotplug field are converted to new
API, link could replace allow_hotplug in qdev hotplug code.

Signed-off-by: Igor Mammedov 
---
 hw/core/qdev.c |4 
 include/hw/qdev-core.h |5 +
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 82a9123..c9f0c33 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -32,6 +32,7 @@
 #include "qapi/visitor.h"
 #include "qapi/qmp/qjson.h"
 #include "monitor/monitor.h"
+#include "hw/hotplug.h"
 
 int qdev_hotplug = 0;
 static bool qdev_hot_added = false;
@@ -870,6 +871,9 @@ static void qbus_initfn(Object *obj)
 BusState *bus = BUS(obj);
 
 QTAILQ_INIT(&bus->children);
+object_property_add_link(obj, QDEV_HOTPLUG_HANDLER_PROPERTY,
+ TYPE_HOTPLUG_HANDLER,
+ (Object **)&bus->hotplug_handler, NULL);
 }
 
 static char *default_bus_get_fw_dev_path(DeviceState *dev)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 2c4f140..58a5c69 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -8,6 +8,7 @@
 #include "qom/object.h"
 #include "hw/irq.h"
 #include "qapi/error.h"
+#include "hw/hotplug.h"
 
 enum {
 DEV_NVECTORS_UNSPECIFIED = -1,
@@ -180,14 +181,18 @@ typedef struct BusChild {
 QTAILQ_ENTRY(BusChild) sibling;
 } BusChild;
 
+#define QDEV_HOTPLUG_HANDLER_PROPERTY "hotplug-handler"
+
 /**
  * BusState:
+ * @hotplug_device: link to a hotplug device associated with bus.
  */
 struct BusState {
 Object obj;
 DeviceState *parent;
 const char *name;
 int allow_hotplug;
+HotplugHandler *hotplug_handler;
 int max_index;
 QTAILQ_HEAD(ChildrenHead, BusChild) children;
 QLIST_ENTRY(BusState) sibling;
-- 
1.7.1




[Qemu-devel] [PATCH 5/9] qdev:pci: refactor PCIDevice to use generic "hotpluggable" property

2014-01-14 Thread Igor Mammedov
Get rid of PCIDevice specific PCIDeviceClass.no_hotplug and use
generic DeviceClass.hotpluggable field instead.

Signed-off-by: Igor Mammedov 
---
v2:
* move generic hotplug checks to
  "qdev: add "hotpluggable" property to Device" patch
* s/hotplugable/hotpluggable/
---
 hw/acpi/piix4.c |   10 +-
 hw/display/cirrus_vga.c |2 +-
 hw/display/qxl.c|2 +-
 hw/display/vga-pci.c|2 +-
 hw/display/vmware_vga.c |2 +-
 hw/i386/acpi-build.c|6 +++---
 hw/ide/piix.c   |4 ++--
 hw/isa/piix4.c  |2 +-
 hw/pci-host/piix.c  |6 +++---
 hw/pci/pci.c|   11 +--
 hw/usb/hcd-ehci-pci.c   |2 +-
 hw/usb/hcd-ohci.c   |2 +-
 hw/usb/hcd-uhci.c   |2 +-
 hw/usb/hcd-xhci.c   |2 +-
 include/hw/pci/pci.h|3 ---
 15 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 3dcaaca..c292753 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -304,9 +304,9 @@ static void acpi_piix_eject_slot(PIIX4PMState *s, unsigned 
slots)
 QTAILQ_FOREACH_SAFE(kid, &bus->children, sibling, next) {
 DeviceState *qdev = kid->child;
 PCIDevice *dev = PCI_DEVICE(qdev);
-PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
+DeviceClass *dc = DEVICE_GET_CLASS(dev);
 if (PCI_SLOT(dev->devfn) == slot) {
-if (pc->no_hotplug) {
+if (!dc->hotpluggable) {
 slot_free = false;
 } else {
 object_unparent(OBJECT(qdev));
@@ -334,10 +334,10 @@ static void piix4_update_hotplug(PIIX4PMState *s)
 QTAILQ_FOREACH_SAFE(kid, &bus->children, sibling, next) {
 DeviceState *qdev = kid->child;
 PCIDevice *pdev = PCI_DEVICE(qdev);
-PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pdev);
+DeviceClass *dc = DEVICE_GET_CLASS(qdev);
 int slot = PCI_SLOT(pdev->devfn);
 
-if (pc->no_hotplug) {
+if (!dc->hotpluggable) {
 s->pci0_hotplug_enable &= ~(1U << slot);
 }
 
@@ -727,7 +727,6 @@ static void piix4_pm_class_init(ObjectClass *klass, void 
*data)
 DeviceClass *dc = DEVICE_CLASS(klass);
 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
-k->no_hotplug = 1;
 k->init = piix4_pm_initfn;
 k->config_write = pm_write_config;
 k->vendor_id = PCI_VENDOR_ID_INTEL;
@@ -742,6 +741,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void 
*data)
  * e.g. by mips_malta_init()
  */
 dc->cannot_instantiate_with_device_add_yet = true;
+dc->hotpluggable = false;
 }
 
 static const TypeInfo piix4_pm_info = {
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index e4c345f..3a8fc0b 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -2996,7 +2996,6 @@ static void cirrus_vga_class_init(ObjectClass *klass, 
void *data)
 DeviceClass *dc = DEVICE_CLASS(klass);
 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
-k->no_hotplug = 1;
 k->init = pci_cirrus_vga_initfn;
 k->romfile = VGABIOS_CIRRUS_FILENAME;
 k->vendor_id = PCI_VENDOR_ID_CIRRUS;
@@ -3006,6 +3005,7 @@ static void cirrus_vga_class_init(ObjectClass *klass, 
void *data)
 dc->desc = "Cirrus CLGD 54xx VGA";
 dc->vmsd = &vmstate_pci_cirrus_vga;
 dc->props = pci_vga_cirrus_properties;
+dc->hotpluggable = false;
 }
 
 static const TypeInfo cirrus_vga_info = {
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index e4f172e..ec82e00 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -2299,7 +2299,6 @@ static void qxl_primary_class_init(ObjectClass *klass, 
void *data)
 DeviceClass *dc = DEVICE_CLASS(klass);
 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
-k->no_hotplug = 1;
 k->init = qxl_init_primary;
 k->romfile = "vgabios-qxl.bin";
 k->vendor_id = REDHAT_PCI_VENDOR_ID;
@@ -2310,6 +2309,7 @@ static void qxl_primary_class_init(ObjectClass *klass, 
void *data)
 dc->reset = qxl_reset_handler;
 dc->vmsd = &qxl_vmstate;
 dc->props = qxl_properties;
+dc->hotpluggable = false;
 }
 
 static const TypeInfo qxl_primary_info = {
diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
index b3a45c8..f74fc43 100644
--- a/hw/display/vga-pci.c
+++ b/hw/display/vga-pci.c
@@ -190,7 +190,6 @@ static void vga_class_init(ObjectClass *klass, void *data)
 DeviceClass *dc = DEVICE_CLASS(klass);
 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
-k->no_hotplug = 1;
 k->init = pci_std_vga_initfn;
 k->romfile = "vgabios-stdvga.bin";
 k->vendor_id = PCI_VENDOR_ID_QEMU;
@@ -198,6 +197,7 @@ static void vga_class_init(ObjectClass *klass, void *data)
 k->class_id = PCI_CLASS_DISPLAY_VGA;
 dc->vmsd = &vmstate_vga_pci;
 dc->props = vga_pci_properties;
+dc->hotpluggable = false;
 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
 }
 
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index aba292c..334e718 100644
--- a/hw/display/vmwar

[Qemu-devel] [PATCH 0/9 v4] Refactor PCI/SHPC/PCIE hotplug to use a more generic hotplug API

2014-01-14 Thread Igor Mammedov
changes since v3:
 - fixup/add comments as reqused by  Peter Crosthwaite
 - use error_abort to reduce error handling verbosity
 - fix tests/test-qdev-global-props build failure on make check
 - rebase on top of current master:133fe7743 (with interface fixes)

Reference to previous version:
http://lists.gnu.org/archive/html/qemu-devel/2013-12/msg02461.html

git tree for testing:
https://github.com/imammedo/qemu/commits/hotplug_dev_inf_v4

Igor Mammedov (9):
  define hotplug interface
  qdev: add to BusState "hotplug-handler" link
  qdev: add "hotpluggable" property to Device
  hw/acpi: move typeinfo to the file end
  qdev:pci: refactor PCIDevice to use generic "hotpluggable" property
  acpi/piix4pm: convert ACPI PCI hotplug to use hotplug-handler API
  pci/shpc: convert SHPC hotplug to use hotplug-handler API
  pci/pcie: convert PCIE hotplug to use hotplug-handler API
  hw/pci: switch to a generic hotplug handling for PCIDevice

 hw/acpi/piix4.c|  156 
 hw/core/Makefile.objs  |1 +
 hw/core/hotplug.c  |   48 
 hw/core/qdev.c |   50 -
 hw/display/cirrus_vga.c|2 +-
 hw/display/qxl.c   |2 +-
 hw/display/vga-pci.c   |2 +-
 hw/display/vmware_vga.c|2 +-
 hw/i386/acpi-build.c   |6 +-
 hw/ide/piix.c  |4 +-
 hw/isa/piix4.c |2 +-
 hw/pci-bridge/pci_bridge_dev.c |9 +++
 hw/pci-host/piix.c |6 +-
 hw/pci/pci.c   |   40 +--
 hw/pci/pcie.c  |   67 +++---
 hw/pci/pcie_port.c |8 ++
 hw/pci/shpc.c  |  127 
 hw/usb/hcd-ehci-pci.c  |2 +-
 hw/usb/hcd-ohci.c  |2 +-
 hw/usb/hcd-uhci.c  |2 +-
 hw/usb/hcd-xhci.c  |2 +-
 include/hw/hotplug.h   |   78 
 include/hw/pci/pci.h   |   13 
 include/hw/pci/pci_bus.h   |2 -
 include/hw/pci/pcie.h  |5 ++
 include/hw/pci/shpc.h  |8 ++
 include/hw/qdev-core.h |8 ++
 tests/Makefile |2 +-
 28 files changed, 432 insertions(+), 224 deletions(-)
 create mode 100644 hw/core/hotplug.c
 create mode 100644 include/hw/hotplug.h




[Qemu-devel] [PATCH 6/9] acpi/piix4pm: convert ACPI PCI hotplug to use hotplug-handler API

2014-01-14 Thread Igor Mammedov
Split piix4_device_hotplug() into hotplug/unplug callbacks
and register them as "hotplug-handler" interface implementation of
PIIX4_PM device.

Replace pci_bus_hotplug() wiring with setting link on
PCI BUS "hotplug-handler" property to PIIX4_PM device.

Signed-off-by: Igor Mammedov 
---
v2:
* use error_abort to make error handling less verbose
---
 hw/acpi/piix4.c |   68 --
 1 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index c292753..20b1ea3 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -30,6 +30,8 @@
 #include "hw/nvram/fw_cfg.h"
 #include "exec/address-spaces.h"
 #include "hw/acpi/piix4.h"
+#include "qapi/qmp/qerror.h"
+#include "hw/hotplug.h"
 
 //#define DEBUG
 
@@ -107,7 +109,7 @@ typedef struct PIIX4PMState {
 OBJECT_CHECK(PIIX4PMState, (obj), TYPE_PIIX4_PM)
 
 static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
-   PCIBus *bus, PIIX4PMState *s);
+   BusState *bus, PIIX4PMState *s);
 
 #define ACPI_ENABLE 0xf1
 #define ACPI_DISABLE 0xf0
@@ -459,7 +461,7 @@ static int piix4_pm_initfn(PCIDevice *dev)
 qemu_add_machine_init_done_notifier(&s->machine_ready);
 qemu_register_reset(piix4_reset, s);
 
-piix4_acpi_system_hot_add_init(pci_address_space_io(dev), dev->bus, s);
+piix4_acpi_system_hot_add_init(pci_address_space_io(dev), BUS(dev->bus), 
s);
 
 piix4_pm_add_propeties(s);
 return 0;
@@ -645,11 +647,8 @@ static void piix4_cpu_added_req(Notifier *n, void *opaque)
 piix4_cpu_hotplug_req(s, CPU(opaque), PLUG);
 }
 
-static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,
-PCIHotplugState state);
-
 static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
-   PCIBus *bus, PIIX4PMState *s)
+   BusState *bus, PIIX4PMState *s)
 {
 CPUState *cpu;
 
@@ -661,7 +660,9 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion 
*parent,
   "acpi-pci-hotplug", PCI_HOTPLUG_SIZE);
 memory_region_add_subregion(parent, PCI_HOTPLUG_ADDR,
 &s->io_pci);
-pci_bus_hotplug(bus, piix4_device_hotplug, DEVICE(s));
+object_property_set_link(OBJECT(bus), OBJECT(s),
+ QDEV_HOTPLUG_HANDLER_PROPERTY, &error_abort);
+bus->allow_hotplug = 1;
 
 CPU_FOREACH(cpu) {
 CPUClass *cc = CPU_GET_CLASS(cpu);
@@ -677,41 +678,35 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion 
*parent,
 qemu_register_cpu_added_notifier(&s->cpu_added_notifier);
 }
 
-static void enable_device(PIIX4PMState *s, int slot)
+static void piix4_pci_device_hotplug_cb(HotplugHandler *hotplug_dev,
+DeviceState *dev, Error **errp)
 {
-s->ar.gpe.sts[0] |= PIIX4_PCI_HOTPLUG_STATUS;
-s->pci0_slot_device_present |= (1U << slot);
-}
-
-static void disable_device(PIIX4PMState *s, int slot)
-{
-s->ar.gpe.sts[0] |= PIIX4_PCI_HOTPLUG_STATUS;
-s->pci0_status.down |= (1U << slot);
-}
-
-static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,
-   PCIHotplugState state)
-{
-int slot = PCI_SLOT(dev->devfn);
-PIIX4PMState *s = PIIX4_PM(qdev);
+PCIDevice *pci_dev = PCI_DEVICE(dev);
+int slot = PCI_SLOT(pci_dev->devfn);
+PIIX4PMState *s = PIIX4_PM(hotplug_dev);
 
+s->pci0_slot_device_present |= (1U << slot);
 /* Don't send event when device is enabled during qemu machine creation:
  * it is present on boot, no hotplug event is necessary. We do send an
  * event when the device is disabled later. */
-if (state == PCI_COLDPLUG_ENABLED) {
-s->pci0_slot_device_present |= (1U << slot);
-return 0;
-}
-
-if (state == PCI_HOTPLUG_ENABLED) {
-enable_device(s, slot);
-} else {
-disable_device(s, slot);
+if (!dev->hotplugged) {
+return;
 }
 
+s->ar.gpe.sts[0] |= PIIX4_PCI_HOTPLUG_STATUS;
 acpi_update_sci(&s->ar, s->irq);
+}
 
-return 0;
+static void piix4_pci_device_hot_unplug_cb(HotplugHandler *hotplug_dev,
+   DeviceState *dev, Error **errp)
+{
+PCIDevice *pci_dev = PCI_DEVICE(dev);
+int slot = PCI_SLOT(pci_dev->devfn);
+PIIX4PMState *s = PIIX4_PM(hotplug_dev);
+
+s->pci0_status.down |= (1U << slot);
+s->ar.gpe.sts[0] |= PIIX4_PCI_HOTPLUG_STATUS;
+acpi_update_sci(&s->ar, s->irq);
 }
 
 static Property piix4_pm_properties[] = {
@@ -726,6 +721,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void 
*data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
 
 k->init = piix4_pm_initfn;
 k->config_write = pm_write_config;
@@ -

Re: [Qemu-devel] [Qemu-trivial] [PATCH] docs: Fix typo in QMP WAKEUP example

2014-01-14 Thread Michael Tokarev
Thanks, applied to the trivial patches queue.

/mjt



Re: [Qemu-devel] [Qemu-trivial] [PATCH] Fix typo of tiemr in timer.h

2014-01-14 Thread Michael Tokarev
Thanks, applied to the trivial-patches queue.

/mjt



[Qemu-devel] [PATCH 1/9] define hotplug interface

2014-01-14 Thread Igor Mammedov
Provide a generic hotplug interface for hotplug handlers.
Intended for replacing hotplug mechanism used by
PCI/PCIE/SHPC code and will be used for memory hotplug.

Signed-off-by: Igor Mammedov 
---
v3:
* amend commit description as requested by Peter Crosthwaite
* add  doc comments to type definitions
v2:
* s/device/handler/
* add hotplug_handler_plug/hotplug_handler_unplug API
v1:
it's scsi-bus like interface, but abstracted from bus altogether
since all current users care about in hotplug handlers, it's
hotplug device and hotplugged device and bus only serves
as a means to get access to hotplug device and it's callbacks.
---
 hw/core/Makefile.objs |1 +
 hw/core/hotplug.c |   48 ++
 include/hw/hotplug.h  |   78 +
 3 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 hw/core/hotplug.c
 create mode 100644 include/hw/hotplug.h

diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
index 950146c..9e324be 100644
--- a/hw/core/Makefile.objs
+++ b/hw/core/Makefile.objs
@@ -2,6 +2,7 @@
 common-obj-y += qdev.o qdev-properties.o
 # irq.o needed for qdev GPIO handling:
 common-obj-y += irq.o
+common-obj-y += hotplug.o
 
 common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
 common-obj-$(CONFIG_XILINX_AXI) += stream.o
diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c
new file mode 100644
index 000..5c3b5c9
--- /dev/null
+++ b/hw/core/hotplug.c
@@ -0,0 +1,48 @@
+/*
+ * Hotplug handler interface.
+ *
+ * Copyright (c) 2013 Red Hat Inc.
+ *
+ * Authors:
+ *  Igor Mammedov ,
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/hotplug.h"
+#include "qemu/module.h"
+
+void hotplug_handler_plug(HotplugHandler *plug_handler,
+  DeviceState *plugged_dev,
+  Error **errp)
+{
+HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
+
+if (hdc->plug) {
+hdc->plug(plug_handler, plugged_dev, errp);
+}
+}
+
+void hotplug_handler_unplug(HotplugHandler *plug_handler,
+DeviceState *plugged_dev,
+Error **errp)
+{
+HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
+
+if (hdc->unplug) {
+hdc->unplug(plug_handler, plugged_dev, errp);
+}
+}
+
+static const TypeInfo hotplug_handler_info = {
+.name  = TYPE_HOTPLUG_HANDLER,
+.parent= TYPE_INTERFACE,
+.class_size = sizeof(HotplugHandlerClass),
+};
+
+static void hotplug_handler_register_types(void)
+{
+type_register_static(&hotplug_handler_info);
+}
+
+type_init(hotplug_handler_register_types)
diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
new file mode 100644
index 000..22ce92c
--- /dev/null
+++ b/include/hw/hotplug.h
@@ -0,0 +1,78 @@
+/*
+ * Hotplug handler interface.
+ *
+ * Copyright (c) 2013 Red Hat Inc.
+ *
+ * Authors:
+ *  Igor Mammedov ,
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef HOTPLUG_H
+#define HOTPLUG_H
+
+#include "qom/object.h"
+#include "qemu/typedefs.h"
+
+#define TYPE_HOTPLUG_HANDLER "hotplug-handler"
+
+#define HOTPLUG_HANDLER_CLASS(klass) \
+ OBJECT_CLASS_CHECK(HotplugHandlerClass, (klass), TYPE_HOTPLUG_HANDLER)
+#define HOTPLUG_HANDLER_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(HotplugHandlerClass, (obj), TYPE_HOTPLUG_HANDLER)
+#define HOTPLUG_HANDLER(obj) \
+ INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER)
+
+
+typedef struct HotplugHandler {
+/*  */
+Object Parent;
+} HotplugHandler;
+
+/**
+ * hotplug_fn:
+ * @plug_handler: a device performing plug/uplug action
+ * @plugged_dev: a device that has been (un)plugged
+ * @errp: returns an error if this function fails
+ */
+typedef void (*hotplug_fn)(HotplugHandler *plug_handler,
+   DeviceState *plugged_dev, Error **errp);
+
+/**
+ * HotplugDeviceClass:
+ *
+ * Interface to be implemented by a device performing
+ * hardware (un)plug functions.
+ *
+ * @parent: Opaque parent interface.
+ * @plug: plug callback.
+ * @unplug: unplug callback.
+ */
+typedef struct HotplugHandlerClass {
+/*  */
+InterfaceClass parent;
+
+/*  */
+hotplug_fn plug;
+hotplug_fn unplug;
+} HotplugHandlerClass;
+
+/**
+ * hotplug_handler_plug:
+ *
+ * Call #HotplugHandlerClass.plug callback of @plug_handler.
+ */
+void hotplug_handler_plug(HotplugHandler *plug_handler,
+  DeviceState *plugged_dev,
+  Error **errp);
+
+/**
+ * hotplug_handler_unplug:
+ *
+ * Call #HotplugHandlerClass.unplug callback of @plug_handler.
+ */
+void hotplug_handler_unplug(HotplugHandler *plug_handler,
+DeviceState *plugged_dev,
+Error **errp);
+#endif
-- 
1.7.1




  1   2   3   >